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
This commit is contained in:
Timo Sirainen 2002-04-27 19:42:15 +00:00 committed by cras
parent ad9329a1a6
commit abdd0f04c5

View File

@ -225,29 +225,32 @@ PPCODE:
g_free_not_null(ret); g_free_not_null(ret);
char * char *
theme_get_format(theme, module, formatnum) theme_get_format(theme, module, tag)
Irssi::UI::Theme theme Irssi::UI::Theme theme
char *module char *module
int formatnum char *tag
PREINIT: PREINIT:
MODULE_THEME_REC *modtheme; MODULE_THEME_REC *modtheme;
FORMAT_REC *formats; FORMAT_REC *formats;
char *ret; char *ret;
int i;
CODE: CODE:
formats = g_hash_table_lookup(default_formats, module); formats = g_hash_table_lookup(default_formats, module);
if (formats == NULL) if (formats == NULL)
croak("Unknown module: %s", module); croak("Unknown module: %s", module);
modtheme = g_hash_table_lookup(theme->modules, module); for (i = 0; formats[i].def != NULL; i++) {
if (modtheme != NULL && formatnum >= modtheme->count) { if (formats[i].tag != NULL &&
croak("Format number out of range (%s: %d < %d)", g_strcasecmp(formats[i].tag, tag) == 0)
module, formatnum, modtheme->count); break;
} }
RETVAL = modtheme == NULL ? NULL : modtheme->formats[formatnum]; if (formats[i].def == NULL)
if (RETVAL == NULL) { croak("Unknown format tag: %s", tag);
formats = g_hash_table_lookup(default_formats, module);
RETVAL = formats == NULL ? NULL : formats[formatnum].def; modtheme = g_hash_table_lookup(theme->modules, module);
} RETVAL = modtheme == NULL ? NULL : modtheme->formats[i];
if (RETVAL == NULL)
RETVAL = formats[i].def;
OUTPUT: OUTPUT:
RETVAL RETVAL