Added SILC Thread Queue API
[crypto.git] / apps / irssi / src / perl / ui / Themes.xs
index fc3165e9872d5380b5b224286ad2995d91b31853..4afd437c4dc92f03c466715b7b08e6e3169deb40 100644 (file)
@@ -136,6 +136,32 @@ CODE:
 
         printformat_perl(&dest, format, arglist);
 
+void
+abstracts_register(abstracts)
+       SV *abstracts
+PREINIT:
+       AV *av;
+       char *key, *value;
+       int i, len;
+CODE:
+        if (!SvROK(abstracts))
+               croak("abstracts is not a reference to list");
+       av = (AV *) SvRV(abstracts);
+       len = av_len(av)+1;
+       if (len == 0 || (len & 1) != 0)
+               croak("abstracts list is invalid - not divisible by 2 (%d)", len);
+
+        for (i = 0; i < len; i++) {
+               key = SvPV(*av_fetch(av, i, 0), PL_na); i++;
+               value = SvPV(*av_fetch(av, i, 0), PL_na);
+
+               theme_set_default_abstract(key, value);
+       }
+       themes_reload();
+
+void
+themes_reload()
+
 #*******************************
 MODULE = Irssi::UI::Themes  PACKAGE = Irssi::Server
 #*******************************
@@ -195,7 +221,7 @@ PREINIT:
        char *arglist[MAX_FORMAT_PARAMS+1];
        int n;
 CODE:
-       format_create_dest(&dest, item->server, item->name, level, NULL);
+       format_create_dest(&dest, item->server, item->visible_name, level, NULL);
        memset(arglist, 0, sizeof(arglist));
        for (n = 3; n < items && n < MAX_FORMAT_PARAMS+3; n++) {
                arglist[n-3] = SvPV(ST(n), PL_na);
@@ -223,3 +249,33 @@ PPCODE:
        }
        XPUSHs(sv_2mortal(new_pv(ret)));
        g_free_not_null(ret);
+
+char *
+theme_get_format(theme, module, tag)
+       Irssi::UI::Theme theme
+       char *module
+       char *tag
+PREINIT:
+       MODULE_THEME_REC *modtheme;
+       FORMAT_REC *formats;
+       int i;
+CODE:
+       formats = g_hash_table_lookup(default_formats, module);
+       if (formats == NULL)
+               croak("Unknown module: %s", module);
+
+       for (i = 0; formats[i].def != NULL; i++) {
+               if (formats[i].tag != NULL &&
+                   g_strcasecmp(formats[i].tag, tag) == 0)
+                       break;
+       }
+
+       if (formats[i].def == NULL)
+               croak("Unknown format tag: %s", tag);
+
+       modtheme = g_hash_table_lookup(theme->modules, module);
+       RETVAL = modtheme == NULL ? NULL : modtheme->formats[i];
+       if (RETVAL == NULL)
+               RETVAL = formats[i].def;
+OUTPUT:
+       RETVAL