summaryrefslogtreecommitdiff
path: root/src/perl
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2001-10-21 18:28:42 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2001-10-21 18:28:42 +0000
commit99fe282e6d9ce5eb975b17e58ee7d2420ec86dfa (patch)
tree6b32aaad8b5d607b9fd514008fca2f1f4ed80e71 /src/perl
parentbc8ee2d26c95bd2ce5ae9c5dee9b057fec6367df (diff)
downloadirssi-99fe282e6d9ce5eb975b17e58ee7d2420ec86dfa.zip
Moved theme registering stuff to Themes.xs. Corrected signal "script
destroy" -> "script destroyed" - unregistering themes works now properly. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1886 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/perl')
-rw-r--r--src/perl/ui/Themes.xs51
-rw-r--r--src/perl/ui/UI.xs46
2 files changed, 53 insertions, 44 deletions
diff --git a/src/perl/ui/Themes.xs b/src/perl/ui/Themes.xs
index c2a0f1bc..f22d6859 100644
--- a/src/perl/ui/Themes.xs
+++ b/src/perl/ui/Themes.xs
@@ -1,5 +1,56 @@
#include "module.h"
+void printformat_perl(TEXT_DEST_REC *dest, char *format, char **arglist)
+{
+ THEME_REC *theme;
+ char *module, *str;
+ int formatnum;
+
+ module = g_strdup(perl_get_package());
+ theme = dest->window->theme == NULL ? current_theme :
+ dest->window->theme;
+
+ formatnum = format_find_tag(module, format);
+ 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);
+ g_free(module);
+}
+
+static void perl_unregister_theme(const char *package)
+{
+ FORMAT_REC *formats;
+ int n;
+
+ formats = g_hash_table_lookup(default_formats, package);
+ if (formats == NULL) return;
+
+ for (n = 0; formats[n].def != NULL; n++) {
+ g_free(formats[n].tag);
+ g_free(formats[n].def);
+ }
+ g_free(formats);
+ theme_unregister_module(package);
+}
+
+static void sig_script_destroyed(PERL_SCRIPT_REC *script)
+{
+ perl_unregister_theme(script->package);
+}
+
+void perl_themes_init(void)
+{
+ signal_add("script destroyed", (SIGNAL_FUNC) sig_script_destroyed);
+}
+
+void perl_themes_deinit(void)
+{
+ signal_remove("script destroyed", (SIGNAL_FUNC) sig_script_destroyed);
+}
+
MODULE = Irssi::UI::Themes PACKAGE = Irssi
PROTOTYPES: ENABLE
diff --git a/src/perl/ui/UI.xs b/src/perl/ui/UI.xs
index 8ad60bd7..963f6bbb 100644
--- a/src/perl/ui/UI.xs
+++ b/src/perl/ui/UI.xs
@@ -55,47 +55,6 @@ static void perl_text_dest_fill_hash(HV *hv, TEXT_DEST_REC *dest)
hv_store(hv, "hilight_color", 13, new_pv(dest->hilight_color), 0);
}
-void printformat_perl(TEXT_DEST_REC *dest, char *format, char **arglist)
-{
- THEME_REC *theme;
- char *module, *str;
- int formatnum;
-
- module = g_strdup(perl_get_package());
- theme = dest->window->theme == NULL ? current_theme :
- dest->window->theme;
-
- formatnum = format_find_tag(module, format);
- 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);
- g_free(module);
-}
-
-static void perl_unregister_theme(const char *package)
-{
- FORMAT_REC *formats;
- int n;
-
- formats = g_hash_table_lookup(default_formats, package);
- if (formats == NULL) return;
-
- for (n = 0; formats[n].def != NULL; n++) {
- g_free(formats[n].tag);
- g_free(formats[n].def);
- }
- g_free(formats);
- theme_unregister_module(package);
-}
-
-static void sig_script_destroy(PERL_SCRIPT_REC *script)
-{
- perl_unregister_theme(script->package);
-}
-
static PLAIN_OBJECT_INIT_REC fe_plains[] = {
{ "Irssi::UI::Process", (PERL_OBJECT_FUNC) perl_process_fill_hash },
{ "Irssi::UI::Window", (PERL_OBJECT_FUNC) perl_window_fill_hash },
@@ -118,13 +77,12 @@ CODE:
initialized = TRUE;
irssi_add_plains(fe_plains);
-
- signal_add("script destroy", (SIGNAL_FUNC) sig_script_destroy);
+ perl_themes_init();
void
deinit()
CODE:
- signal_remove("script destroy", (SIGNAL_FUNC) sig_script_destroy);
+ perl_themes_deinit();
BOOT:
irssi_boot(UI__Themes);