Merge Irssi 0.8.16-rc1
[silc.git] / apps / irssi / src / perl / ui / Themes.xs
index 64a0567686e67de6940adfecf429fd32ee5daf66..ff025ee94d278c02e3713461e9b1edd0d748f19d 100644 (file)
@@ -1,9 +1,8 @@
 #include "module.h"
 
-void printformat_perl(TEXT_DEST_REC *dest, char *format, char **arglist)
+static void printformat_perl(TEXT_DEST_REC *dest, char *format, char **arglist)
 {
-       THEME_REC *theme;
-       char *module, *str;
+       char *module;
        int formatnum;
 
        module = g_strdup(perl_get_package());
@@ -14,14 +13,7 @@ void printformat_perl(TEXT_DEST_REC *dest, char *format, char **arglist)
                return;
        }
 
-       theme = dest->window->theme == NULL ? current_theme :
-               dest->window->theme;
-       signal_emit("print format", 5, theme, module,
-                   dest, GINT_TO_POINTER(formatnum), arglist);
-
-        str = format_get_text_theme_charargs(theme, module, dest, formatnum, arglist);
-       if (*str != '\0') printtext_dest(dest, "%s", str);
-       g_free(str);
+       printformat_module_dest_charargs(module, dest, formatnum, arglist);
        g_free(module);
 }
 
@@ -98,8 +90,12 @@ PREINIT:
 CODE:
 
         if (!SvROK(formats))
-               croak("formats is not a reference to list");
+               croak("formats is not a reference");
+
        av = (AV *) SvRV(formats);
+       if (SvTYPE(av) != SVt_PVAV)
+               croak("formats is not a reference to a list");
+
        len = av_len(av)+1;
        if (len == 0 || (len & 1) != 0)
                croak("formats list is invalid - not divisible by 2 (%d)", len);
@@ -136,6 +132,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 +217,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);