static void categories_icon_theme_hack (void) { GtkIconTheme *icon_theme; const gchar *category_name; const gchar *filename; gchar *dirname; /* XXX Allow the category icons to be referenced as named * icons, since GtkAction does not support GdkPixbufs. */ /* Get the icon file for some default category. Doesn't matter * which, so long as it has an icon. We're just interested in * the directory components. */ category_name = _("Birthday"); filename = e_categories_get_icon_file_for (category_name); g_return_if_fail (filename != NULL && *filename != '\0'); /* Extract the directory components. */ dirname = g_path_get_dirname (filename); /* Add it to the icon theme's search path. This relies on * GtkIconTheme's legacy feature of using image files found * directly in the search path. */ icon_theme = gtk_icon_theme_get_default (); gtk_icon_theme_append_search_path (icon_theme, dirname); g_free (dirname); }
/** * e_categories_config_get_icon_for: * @category: Category for which to get the icon. * @pixbuf: A pointer to where the pixbuf will be returned. * * Returns the icon configured for the given category. * * Returns: the icon configured for the given category */ gboolean e_categories_config_get_icon_for (const gchar *category, GdkPixbuf **pixbuf) { const gchar *icon_file; g_return_val_if_fail (pixbuf != NULL, FALSE); g_return_val_if_fail (category != NULL, FALSE); if (!pixbufs_cache) { pixbufs_cache = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, free_pixbuf_cb); e_categories_add_change_hook ( (GHookFunc) categories_changed_cb, NULL); } else { gpointer key = NULL, value = NULL; if (g_hash_table_lookup_extended (pixbufs_cache, category, &key, &value)) { *pixbuf = value; if (*pixbuf) g_object_ref (*pixbuf); return *pixbuf != NULL; } } icon_file = e_categories_get_icon_file_for (category); if (!icon_file) { *pixbuf = NULL; } else { /* load the icon in our list */ *pixbuf = gdk_pixbuf_new_from_file (icon_file, NULL); } g_hash_table_insert (pixbufs_cache, g_strdup (category), *pixbuf == NULL ? NULL : g_object_ref (*pixbuf)); return *pixbuf != NULL; }
void e_book_shell_view_update_search_filter (EBookShellView *book_shell_view) { EBookShellContent *book_shell_content; EShellView *shell_view; EShellWindow *shell_window; EShellSearchbar *searchbar; EActionComboBox *combo_box; GtkActionGroup *action_group; GtkRadioAction *radio_action; GList *list, *iter; GSList *group; gint ii; shell_view = E_SHELL_VIEW (book_shell_view); shell_window = e_shell_view_get_shell_window (shell_view); action_group = ACTION_GROUP (CONTACTS_FILTER); e_action_group_remove_all_actions (action_group); /* Add the standard filter actions. No callback is needed * because changes in the EActionComboBox are detected and * handled by EShellSearchbar. */ gtk_action_group_add_radio_actions ( action_group, contact_filter_entries, G_N_ELEMENTS (contact_filter_entries), CONTACT_FILTER_ANY_CATEGORY, NULL, NULL); /* Retrieve the radio group from an action we just added. */ list = gtk_action_group_list_actions (action_group); radio_action = GTK_RADIO_ACTION (list->data); group = gtk_radio_action_get_group (radio_action); g_list_free (list); /* Build the category actions. */ list = e_util_get_searchable_categories (); for (iter = list, ii = 0; iter != NULL; iter = iter->next, ii++) { const gchar *category_name = iter->data; const gchar *filename; GtkAction *action; gchar *action_name; action_name = g_strdup_printf ( "contact-filter-category-%d", ii); radio_action = gtk_radio_action_new ( action_name, category_name, NULL, NULL, ii); g_free (action_name); /* Convert the category icon file to a themed icon name. */ filename = e_categories_get_icon_file_for (category_name); if (filename != NULL && *filename != '\0') { gchar *basename; gchar *cp; basename = g_path_get_basename (filename); /* Lose the file extension. */ if ((cp = strrchr (basename, '.')) != NULL) *cp = '\0'; g_object_set ( radio_action, "icon-name", basename, NULL); g_free (basename); } gtk_radio_action_set_group (radio_action, group); group = gtk_radio_action_get_group (radio_action); /* The action group takes ownership of the action. */ action = GTK_ACTION (radio_action); gtk_action_group_add_action (action_group, action); g_object_unref (radio_action); } g_list_free (list); book_shell_content = book_shell_view->priv->book_shell_content; searchbar = e_book_shell_content_get_searchbar (book_shell_content); combo_box = e_shell_searchbar_get_filter_combo_box (searchbar); e_shell_view_block_execute_search (shell_view); /* Use any action in the group; doesn't matter which. */ e_action_combo_box_set_action (combo_box, radio_action); ii = CONTACT_FILTER_UNMATCHED; e_action_combo_box_add_separator_after (combo_box, ii); e_shell_view_unblock_execute_search (shell_view); }