mirror of
https://github.com/irssi/irssi.git
synced 2025-01-03 14:56:47 -05:00
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
This commit is contained in:
parent
bc8ee2d26c
commit
99fe282e6d
@ -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
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user