forked from AuroraMiddleware/gtk
Add a new API call gtk_icon_theme_list_contexts so that one can choose
2007-03-21 Rodney Dawes <dobey@novell.com> * gtk/gtk.symbols: * gtk/gtkicontheme.[ch]: * docs/reference/gtk/gtk-sections.txt: * tests/testicontheme.c: Add a new API call gtk_icon_theme_list_contexts so that one can choose icons from a theme by context (#420719) svn path=/trunk/; revision=17550
This commit is contained in:
parent
846f70ddec
commit
57f51f5d54
@ -1,3 +1,12 @@
|
||||
2007-03-21 Rodney Dawes <dobey@novell.com>
|
||||
|
||||
* gtk/gtk.symbols:
|
||||
* gtk/gtkicontheme.[ch]:
|
||||
* docs/reference/gtk/gtk-sections.txt:
|
||||
* tests/testicontheme.c:
|
||||
Add a new API call gtk_icon_theme_list_contexts so that one can
|
||||
choose icons from a theme by context (#420719)
|
||||
|
||||
2007-03-21 Ross Burton <ross@burtonini.com>
|
||||
|
||||
* gtk/gtktexttag.c:
|
||||
|
@ -6004,6 +6004,7 @@ gtk_icon_theme_set_custom_theme
|
||||
gtk_icon_theme_has_icon
|
||||
gtk_icon_theme_lookup_icon
|
||||
gtk_icon_theme_load_icon
|
||||
gtk_icon_theme_list_contexts
|
||||
gtk_icon_theme_list_icons
|
||||
gtk_icon_theme_get_icon_sizes
|
||||
gtk_icon_theme_get_example_icon_name
|
||||
|
@ -1764,6 +1764,7 @@ gtk_icon_theme_get_search_path_utf8
|
||||
#endif
|
||||
gtk_icon_theme_get_type G_GNUC_CONST
|
||||
gtk_icon_theme_has_icon
|
||||
gtk_icon_theme_list_contexts
|
||||
gtk_icon_theme_list_icons
|
||||
gtk_icon_theme_load_icon
|
||||
gtk_icon_theme_lookup_icon
|
||||
|
@ -200,6 +200,8 @@ static GtkIconInfo *theme_lookup_icon (IconTheme *theme,
|
||||
static void theme_list_icons (IconTheme *theme,
|
||||
GHashTable *icons,
|
||||
GQuark context);
|
||||
static void theme_list_contexts (IconTheme *theme,
|
||||
GHashTable *contexts);
|
||||
static void theme_subdir_load (GtkIconTheme *icon_theme,
|
||||
IconTheme *theme,
|
||||
GKeyFile *theme_file,
|
||||
@ -1648,6 +1650,51 @@ gtk_icon_theme_list_icons (GtkIconTheme *icon_theme,
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_icon_theme_list_contexts:
|
||||
* @icon_theme: a #GtkIconTheme
|
||||
*
|
||||
* Gets the list of contexts available within the current
|
||||
* hierarchy of icon themes
|
||||
*
|
||||
* Return value: a #GList list holding the names of all the
|
||||
* contexts in the theme. You must first free each element
|
||||
* in the list with g_free(), then free the list itself
|
||||
* with g_list_free().
|
||||
*
|
||||
* Since: 2.12
|
||||
**/
|
||||
GList *
|
||||
gtk_icon_theme_list_contexts (GtkIconTheme *icon_theme)
|
||||
{
|
||||
GtkIconThemePrivate *priv;
|
||||
GHashTable *contexts;
|
||||
GList *list, *l;
|
||||
|
||||
priv = icon_theme->priv;
|
||||
|
||||
ensure_valid_themes (icon_theme);
|
||||
|
||||
contexts = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
|
||||
l = priv->themes;
|
||||
while (l != NULL)
|
||||
{
|
||||
theme_list_contexts (l->data, contexts);
|
||||
l = l->next;
|
||||
}
|
||||
|
||||
list = NULL;
|
||||
|
||||
g_hash_table_foreach (contexts,
|
||||
add_key_to_list,
|
||||
&list);
|
||||
|
||||
g_hash_table_destroy (contexts);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_icon_theme_get_example_icon_name:
|
||||
* @icon_theme: a #GtkIconTheme
|
||||
@ -2109,6 +2156,25 @@ theme_list_icons (IconTheme *theme,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
theme_list_contexts (IconTheme *theme,
|
||||
GHashTable *contexts)
|
||||
{
|
||||
GList *l = theme->dirs;
|
||||
IconThemeDir *dir;
|
||||
const char *context;
|
||||
|
||||
while (l != NULL)
|
||||
{
|
||||
dir = l->data;
|
||||
|
||||
context = g_quark_to_string (dir->context);
|
||||
g_hash_table_replace (contexts, context, NULL);
|
||||
|
||||
l = l->next;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
load_icon_data (IconThemeDir *dir, const char *path, const char *name)
|
||||
{
|
||||
|
@ -139,6 +139,7 @@ GdkPixbuf * gtk_icon_theme_load_icon (GtkIconTheme
|
||||
|
||||
GList * gtk_icon_theme_list_icons (GtkIconTheme *icon_theme,
|
||||
const gchar *context);
|
||||
GList * gtk_icon_theme_list_contexts (GtkIconTheme *icon_theme);
|
||||
char * gtk_icon_theme_get_example_icon_name (GtkIconTheme *icon_theme);
|
||||
|
||||
gboolean gtk_icon_theme_rescan_if_needed (GtkIconTheme *icon_theme);
|
||||
|
@ -31,6 +31,8 @@ usage (void)
|
||||
"usage: test-icon-theme list <theme name> [context]\n"
|
||||
" or\n"
|
||||
"usage: test-icon-theme display <theme name> <icon name> [size]\n"
|
||||
" or\n"
|
||||
"usage: test-icon-theme contexts <theme name>\n"
|
||||
);
|
||||
}
|
||||
|
||||
@ -98,6 +100,16 @@ main (int argc, char *argv[])
|
||||
list = gtk_icon_theme_list_icons (icon_theme,
|
||||
context);
|
||||
|
||||
while (list)
|
||||
{
|
||||
g_print ("%s\n", (char *)list->data);
|
||||
list = list->next;
|
||||
}
|
||||
}
|
||||
else if (strcmp (argv[1], "contexts") == 0)
|
||||
{
|
||||
list = gtk_icon_theme_list_contexts (icon_theme);
|
||||
|
||||
while (list)
|
||||
{
|
||||
g_print ("%s\n", (char *)list->data);
|
||||
|
Loading…
Reference in New Issue
Block a user