summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2002-04-27 19:42:15 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2002-04-27 19:42:15 +0000
commitabdd0f04c5c5533785cd488482c6bcb132f117aa (patch)
tree94c49de93277f0d1c0a94aa51d382464a3cdb546
parentad9329a1a65cace9c61ce1aa189c9dbaacf564e2 (diff)
downloadirssi-abdd0f04c5c5533785cd488482c6bcb132f117aa.zip
Irssi::Theme::get_format() now uses format tag instead of number.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@2727 dbcabf3a-b0e7-0310-adc4-f8d773084564
-rw-r--r--src/perl/ui/Themes.xs25
1 files changed, 14 insertions, 11 deletions
diff --git a/src/perl/ui/Themes.xs b/src/perl/ui/Themes.xs
index b56fc9df..f4528083 100644
--- a/src/perl/ui/Themes.xs
+++ b/src/perl/ui/Themes.xs
@@ -225,29 +225,32 @@ PPCODE:
g_free_not_null(ret);
char *
-theme_get_format(theme, module, formatnum)
+theme_get_format(theme, module, tag)
Irssi::UI::Theme theme
char *module
- int formatnum
+ char *tag
PREINIT:
MODULE_THEME_REC *modtheme;
FORMAT_REC *formats;
char *ret;
+ int i;
CODE:
formats = g_hash_table_lookup(default_formats, module);
if (formats == NULL)
croak("Unknown module: %s", module);
- modtheme = g_hash_table_lookup(theme->modules, module);
- if (modtheme != NULL && formatnum >= modtheme->count) {
- croak("Format number out of range (%s: %d < %d)",
- module, formatnum, modtheme->count);
+ for (i = 0; formats[i].def != NULL; i++) {
+ if (formats[i].tag != NULL &&
+ g_strcasecmp(formats[i].tag, tag) == 0)
+ break;
}
- RETVAL = modtheme == NULL ? NULL : modtheme->formats[formatnum];
- if (RETVAL == NULL) {
- formats = g_hash_table_lookup(default_formats, module);
- RETVAL = formats == NULL ? NULL : formats[formatnum].def;
- }
+ 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