diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2009-05-24 23:54:43 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2009-05-25 00:43:11 +0800 |
commit | 2393a5d17e92435cb3d7726b04ff6f4a5c27c8db (patch) | |
tree | c69db32dede1ce4e8bc233dc7c5ef83799b258dd | |
parent | 7702ac84d7e02093881d5a139398b1615e4070ac (diff) | |
download | gsoc2013-evolution-2393a5d17e92435cb3d7726b04ff6f4a5c27c8db.tar.gz gsoc2013-evolution-2393a5d17e92435cb3d7726b04ff6f4a5c27c8db.tar.zst gsoc2013-evolution-2393a5d17e92435cb3d7726b04ff6f4a5c27c8db.zip |
Eliminate redundant E_ICON_SIZE_* enumeration.
-rw-r--r-- | addressbook/gui/contact-editor/e-contact-editor.c | 2 | ||||
-rw-r--r-- | addressbook/gui/widgets/e-minicard.c | 2 | ||||
-rw-r--r-- | addressbook/gui/widgets/eab-contact-display.c | 2 | ||||
-rw-r--r-- | addressbook/gui/widgets/eab-gui-util.c | 2 | ||||
-rw-r--r-- | calendar/gui/e-calendar-table.c | 4 | ||||
-rw-r--r-- | calendar/gui/e-day-view.c | 10 | ||||
-rw-r--r-- | calendar/gui/e-itip-control.c | 4 | ||||
-rw-r--r-- | calendar/gui/e-memo-table.c | 2 | ||||
-rw-r--r-- | calendar/gui/e-week-view.c | 10 | ||||
-rw-r--r-- | e-util/e-icon-factory.c | 81 | ||||
-rw-r--r-- | e-util/e-icon-factory.h | 35 | ||||
-rw-r--r-- | mail/em-format-html-display.c | 2 | ||||
-rw-r--r-- | mail/em-format-html.c | 2 | ||||
-rw-r--r-- | mail/message-list.c | 2 | ||||
-rw-r--r-- | plugins/calendar-weather/calendar-weather.c | 2 | ||||
-rw-r--r-- | plugins/groupwise-features/proxy-login.c | 2 | ||||
-rw-r--r-- | plugins/groupwise-features/proxy.c | 2 | ||||
-rw-r--r-- | shell/e-shell-importer.c | 2 |
18 files changed, 50 insertions, 118 deletions
diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c index e4447b9075..d13e378151 100644 --- a/addressbook/gui/contact-editor/e-contact-editor.c +++ b/addressbook/gui/contact-editor/e-contact-editor.c @@ -2866,7 +2866,7 @@ update_preview_cb (GtkFileChooser *file_chooser, gpointer data) pixbuf = gdk_pixbuf_new_from_file_at_size (filename, 128, 128, NULL); if (!pixbuf) { gchar *alternate_file; - alternate_file = e_icon_factory_get_icon_filename ("stock_person",E_ICON_SIZE_DIALOG); + alternate_file = e_icon_factory_get_icon_filename ("stock_person", GTK_ICON_SIZE_DIALOG); if (alternate_file) { pixbuf = gdk_pixbuf_new_from_file_at_size (alternate_file, 128, 128, NULL); g_free (alternate_file); diff --git a/addressbook/gui/widgets/e-minicard.c b/addressbook/gui/widgets/e-minicard.c index a875e43a8d..a7cb37459a 100644 --- a/addressbook/gui/widgets/e-minicard.c +++ b/addressbook/gui/widgets/e-minicard.c @@ -256,7 +256,7 @@ e_minicard_init (EMinicard *minicard) minicard->contact = NULL; - minicard->list_icon_pixbuf = e_icon_factory_get_icon (LIST_ICON_NAME, E_ICON_SIZE_MENU); + minicard->list_icon_pixbuf = e_icon_factory_get_icon (LIST_ICON_NAME, GTK_ICON_SIZE_MENU); minicard->list_icon_size = gdk_pixbuf_get_height (minicard->list_icon_pixbuf); minicard->changed = FALSE; diff --git a/addressbook/gui/widgets/eab-contact-display.c b/addressbook/gui/widgets/eab-contact-display.c index 42cc65294f..87718933b3 100644 --- a/addressbook/gui/widgets/eab-contact-display.c +++ b/addressbook/gui/widgets/eab-contact-display.c @@ -263,7 +263,7 @@ contact_display_on_url_requested (GtkHTML *html, gsize data_length; gchar *filename; - filename = e_icon_factory_get_icon_filename (url + strlen ("evo-icon:"), E_ICON_SIZE_MENU); + filename = e_icon_factory_get_icon_filename (url + strlen ("evo-icon:"), GTK_ICON_SIZE_MENU); if (g_file_get_contents (filename, &data, &data_length, NULL)) { gtk_html_stream_write (handle, data, data_length); g_free (data); diff --git a/addressbook/gui/widgets/eab-gui-util.c b/addressbook/gui/widgets/eab-gui-util.c index 9db9630b72..4ea2136ee6 100644 --- a/addressbook/gui/widgets/eab-gui-util.c +++ b/addressbook/gui/widgets/eab-gui-util.c @@ -645,7 +645,7 @@ eab_create_image_chooser_widget(gchar *name, gtk_widget_show_all (w); if (string1) { - filename = e_icon_factory_get_icon_filename (string1, E_ICON_SIZE_DIALOG); + filename = e_icon_factory_get_icon_filename (string1, GTK_ICON_SIZE_DIALOG); e_image_chooser_set_from_file (E_IMAGE_CHOOSER (w), filename); diff --git a/calendar/gui/e-calendar-table.c b/calendar/gui/e-calendar-table.c index 26c0ad6dea..c96e763958 100644 --- a/calendar/gui/e-calendar-table.c +++ b/calendar/gui/e-calendar-table.c @@ -795,14 +795,14 @@ calendar_table_constructed (GObject *object) if (!icon_pixbufs[0]) for (i = 0; i < E_CALENDAR_MODEL_NUM_ICONS; i++) { - icon_pixbufs[i] = e_icon_factory_get_icon (icon_names[i], E_ICON_SIZE_LIST); + icon_pixbufs[i] = e_icon_factory_get_icon (icon_names[i], GTK_ICON_SIZE_MENU); } cell = e_cell_toggle_new (0, E_CALENDAR_MODEL_NUM_ICONS, icon_pixbufs); e_table_extras_add_cell(extras, "icon", cell); e_table_extras_add_pixbuf(extras, "icon", icon_pixbufs[0]); - pixbuf = e_icon_factory_get_icon ("stock_check-filled", E_ICON_SIZE_LIST); + pixbuf = e_icon_factory_get_icon ("stock_check-filled", GTK_ICON_SIZE_MENU); e_table_extras_add_pixbuf(extras, "complete", pixbuf); g_object_unref(pixbuf); diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c index 7c082e5c6b..5dd940610b 100644 --- a/calendar/gui/e-day-view.c +++ b/calendar/gui/e-day-view.c @@ -1162,11 +1162,11 @@ e_day_view_realize (GtkWidget *widget) gdk_gc_set_colormap (day_view->main_gc, colormap); /* Create the pixmaps. */ - day_view->reminder_icon = e_icon_factory_get_icon ("stock_bell", E_ICON_SIZE_MENU); - day_view->recurrence_icon = e_icon_factory_get_icon ("view-refresh", E_ICON_SIZE_MENU); - day_view->timezone_icon = e_icon_factory_get_icon ("stock_timezone", E_ICON_SIZE_MENU); - day_view->meeting_icon = e_icon_factory_get_icon ("stock_people", E_ICON_SIZE_MENU); - day_view->attach_icon = e_icon_factory_get_icon ("mail-attachment", E_ICON_SIZE_MENU); + day_view->reminder_icon = e_icon_factory_get_icon ("stock_bell", GTK_ICON_SIZE_MENU); + day_view->recurrence_icon = e_icon_factory_get_icon ("view-refresh", GTK_ICON_SIZE_MENU); + day_view->timezone_icon = e_icon_factory_get_icon ("stock_timezone", GTK_ICON_SIZE_MENU); + day_view->meeting_icon = e_icon_factory_get_icon ("stock_people", GTK_ICON_SIZE_MENU); + day_view->attach_icon = e_icon_factory_get_icon ("mail-attachment", GTK_ICON_SIZE_MENU); /* Set the canvas item colors. */ diff --git a/calendar/gui/e-itip-control.c b/calendar/gui/e-itip-control.c index 4ecacd2bfe..94fd234f27 100644 --- a/calendar/gui/e-itip-control.c +++ b/calendar/gui/e-itip-control.c @@ -1012,7 +1012,7 @@ write_error_html (EItipControl *itip, const gchar *itip_err) /* The column for the image */ gtk_html_stream_printf (html_stream, "<tr><td width=48 align=\"center\" valign=\"top\" rowspan=\"8\">"); /* The image */ - filename = e_icon_factory_get_icon_filename ("stock_new-meeting", E_ICON_SIZE_DIALOG); + filename = e_icon_factory_get_icon_filename ("stock_new-meeting", GTK_ICON_SIZE_DIALOG); gtk_html_stream_printf (html_stream, "<img src=\"%s\"></td>", filename); g_free (filename); @@ -1072,7 +1072,7 @@ write_html (EItipControl *itip, const gchar *itip_desc, const gchar *itip_title, gtk_html_write (GTK_HTML (priv->html), html_stream, const_html, strlen(const_html)); /* The image */ - filename = e_icon_factory_get_icon_filename ("stock_new-meeting", E_ICON_SIZE_DIALOG); + filename = e_icon_factory_get_icon_filename ("stock_new-meeting", GTK_ICON_SIZE_DIALOG); gtk_html_stream_printf (html_stream, "<img src=\"%s\"></td>", filename); g_free (filename); diff --git a/calendar/gui/e-memo-table.c b/calendar/gui/e-memo-table.c index 208e3ad9fc..25e6005f40 100644 --- a/calendar/gui/e-memo-table.c +++ b/calendar/gui/e-memo-table.c @@ -580,7 +580,7 @@ memo_table_constructed (GObject *object) if (!icon_pixbufs[0]) for (i = 0; i < E_MEMO_MODEL_NUM_ICONS; i++) { - icon_pixbufs[i] = e_icon_factory_get_icon (icon_names[i], E_ICON_SIZE_LIST); + icon_pixbufs[i] = e_icon_factory_get_icon (icon_names[i], GTK_ICON_SIZE_MENU); } cell = e_cell_toggle_new (0, E_MEMO_MODEL_NUM_ICONS, icon_pixbufs); diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c index f008f4e3f3..90ea61e901 100644 --- a/calendar/gui/e-week-view.c +++ b/calendar/gui/e-week-view.c @@ -734,11 +734,11 @@ e_week_view_realize (GtkWidget *widget) gdk_gc_set_colormap (week_view->main_gc, colormap); /* Create the pixmaps. */ - week_view->reminder_icon = e_icon_factory_get_icon ("stock_bell", E_ICON_SIZE_MENU); - week_view->recurrence_icon = e_icon_factory_get_icon ("view-refresh", E_ICON_SIZE_MENU); - week_view->timezone_icon = e_icon_factory_get_icon ("stock_timezone", E_ICON_SIZE_MENU); - week_view->attach_icon = e_icon_factory_get_icon ("mail-attachment", E_ICON_SIZE_MENU); - week_view->meeting_icon = e_icon_factory_get_icon ("stock_people", E_ICON_SIZE_MENU); + week_view->reminder_icon = e_icon_factory_get_icon ("stock_bell", GTK_ICON_SIZE_MENU); + week_view->recurrence_icon = e_icon_factory_get_icon ("view-refresh", GTK_ICON_SIZE_MENU); + week_view->timezone_icon = e_icon_factory_get_icon ("stock_timezone", GTK_ICON_SIZE_MENU); + week_view->attach_icon = e_icon_factory_get_icon ("mail-attachment", GTK_ICON_SIZE_MENU); + week_view->meeting_icon = e_icon_factory_get_icon ("stock_people", GTK_ICON_SIZE_MENU); } static void diff --git a/e-util/e-icon-factory.c b/e-util/e-icon-factory.c index 7e9cf4cad7..299dfff6f5 100644 --- a/e-util/e-icon-factory.c +++ b/e-util/e-icon-factory.c @@ -166,27 +166,6 @@ load_icon (const char *icon_key, const char *icon_name, int size, int scale) return icon_new (icon_key, pixbuf); } -static GtkIconSize -e_icon_size_to_gtk_icon_size (guint size) -{ - switch (size) { - case E_ICON_SIZE_MENU: - return GTK_ICON_SIZE_MENU; - case E_ICON_SIZE_BUTTON: - return GTK_ICON_SIZE_BUTTON; - case E_ICON_SIZE_SMALL_TOOLBAR: - return GTK_ICON_SIZE_SMALL_TOOLBAR; - case E_ICON_SIZE_LARGE_TOOLBAR: - return GTK_ICON_SIZE_LARGE_TOOLBAR; - case E_ICON_SIZE_DND: - return GTK_ICON_SIZE_DND; - case E_ICON_SIZE_DIALOG: - return GTK_ICON_SIZE_DIALOG; - default: - g_assert_not_reached (); - } -} - static void icon_theme_changed_cb (GtkIconTheme *icon_theme, gpointer user_data) { @@ -250,48 +229,35 @@ e_icon_factory_shutdown (void) /** * e_icon_factory_get_icon_filename: * @icon_name: name of the icon - * @size: MENU/SMALL_TOOLBAR/etc + * @size: size of the icon * * Looks up the icon to use based on name and size. * * Returns the requested icon pixbuf. **/ -char * -e_icon_factory_get_icon_filename (const char *icon_name, int icon_size) +gchar * +e_icon_factory_get_icon_filename (const gchar *icon_name, + GtkIconSize icon_size) { + GtkIconTheme *icon_theme; GtkIconInfo *icon_info; - char *filename; + gchar *filename = NULL; gint width, height; g_return_val_if_fail (icon_name != NULL, NULL); - g_return_val_if_fail (strcmp (icon_name, ""), NULL); - - if (icon_size >= E_ICON_NUM_SIZES) { - g_critical ( - "calling %s with unknown icon_size value (%d)", - G_STRFUNC, icon_size); - /* if ((icon_size = pixel_size_to_icon_size (icon_size)) == -1)*/ - return NULL; - } - if (! gtk_icon_size_lookup_for_settings (gtk_settings_get_default (), - e_icon_size_to_gtk_icon_size (icon_size), - &width, &height)) - return NULL; + icon_theme = gtk_icon_theme_get_default (); - d(g_message ("Size is %d", icon_size)); - d(g_message ("looking up %s at %dx%d", icon_name, width, height)); + if (!gtk_icon_size_lookup (icon_size, &width, &height)) + return NULL; - g_static_mutex_lock (&mutex); icon_info = gtk_icon_theme_lookup_icon ( icon_theme, icon_name, height, 0); if (icon_info != NULL) { filename = g_strdup ( gtk_icon_info_get_filename (icon_info)); gtk_icon_info_free (icon_info); - } else - filename = NULL; - g_static_mutex_unlock (&mutex); + } return filename; } @@ -300,7 +266,7 @@ e_icon_factory_get_icon_filename (const char *icon_name, int icon_size) /** * e_icon_factory_get_icon: * @icon_name: name of the icon - * @icon_size: size of the icon (one of the E_ICON_SIZE_* enum values) + * @icon_size: size of the icon * * Returns the specified icon of the requested size (may perform * scaling to achieve this). If @icon_name is a full path, that file @@ -311,38 +277,21 @@ e_icon_factory_get_icon_filename (const char *icon_name, int icon_size) * requested icon, then a "broken-image" icon is returned. **/ GdkPixbuf * -e_icon_factory_get_icon (const char *icon_name, int icon_size) +e_icon_factory_get_icon (const gchar *icon_name, + GtkIconSize icon_size) { GdkPixbuf *pixbuf; char *icon_key; Icon *icon; int size, width, height; - if (icon_size >= E_ICON_NUM_SIZES) { - g_critical ( - "calling %s with unknown icon_size value (%d)", - G_STRFUNC, icon_size); - /*if ((icon_size = pixel_size_to_icon_size (icon_size)) == -1) */ - return NULL; - } + g_return_val_if_fail (icon_name != NULL, NULL); - if (! gtk_icon_size_lookup_for_settings (gtk_settings_get_default (), - e_icon_size_to_gtk_icon_size (icon_size), - &width, &height)) + if (!gtk_icon_size_lookup (icon_size, &width, &height)) return NULL; - d(g_message ("Size is %d", icon_size)); - d(g_message ("looking up %s at %dx%d", icon_name, width, height)); - size = height; - if (icon_name == NULL || !strcmp (icon_name, "")) { - if (size >= 24) - return gdk_pixbuf_scale_simple (broken24_pixbuf, size, size, GDK_INTERP_NEAREST); - else - return gdk_pixbuf_scale_simple (broken16_pixbuf, size, size, GDK_INTERP_NEAREST); - } - icon_key = g_alloca (strlen (icon_name) + 7); sprintf (icon_key, "%dx%d/%s", size, size, icon_name); diff --git a/e-util/e-icon-factory.h b/e-util/e-icon-factory.h index f8d1fc2fc7..c864b1be8e 100644 --- a/e-util/e-icon-factory.h +++ b/e-util/e-icon-factory.h @@ -26,31 +26,14 @@ #include <gtk/gtk.h> -enum { - E_ICON_SIZE_MENU, - E_ICON_SIZE_BUTTON, - E_ICON_SIZE_SMALL_TOOLBAR, - E_ICON_SIZE_LARGE_TOOLBAR, - E_ICON_SIZE_DND, - E_ICON_SIZE_DIALOG, - E_ICON_NUM_SIZES -}; - -/* standard size for list/tree widgets (16x16) */ -#define E_ICON_SIZE_LIST E_ICON_SIZE_MENU - -/* standard size for status bar icons (16x16) */ -#define E_ICON_SIZE_STATUS E_ICON_SIZE_MENU - - - -void e_icon_factory_init (void); -void e_icon_factory_shutdown (void); - -char *e_icon_factory_get_icon_filename (const char *icon_name, int icon_size); - -GdkPixbuf *e_icon_factory_get_icon (const char *icon_name, int icon_size); - -GdkPixbuf *e_icon_factory_pixbuf_scale (GdkPixbuf *pixbuf, int width, int height); +void e_icon_factory_init (void); +void e_icon_factory_shutdown (void); +gchar * e_icon_factory_get_icon_filename(const gchar *icon_name, + GtkIconSize icon_size); +GdkPixbuf * e_icon_factory_get_icon (const gchar *icon_name, + GtkIconSize icon_size); +GdkPixbuf * e_icon_factory_pixbuf_scale (GdkPixbuf *pixbuf, + gint width, + gint height); #endif /* _E_ICON_FACTORY_H_ */ diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c index 6faa6ae803..1cc7d43175 100644 --- a/mail/em-format-html-display.c +++ b/mail/em-format-html-display.c @@ -783,7 +783,7 @@ efhd_message_prefix(EMFormat *emf, CamelStream *stream, CamelMimePart *part, EMF camel_stream_printf(stream, "<table border=1 width=\"100%%\" cellspacing=2 cellpadding=2><tr>"); comp = camel_folder_get_message_user_tag(emf->folder, emf->uid, "completed-on"); - iconpath = e_icon_factory_get_icon_filename (comp && comp[0] ? "stock_flag-for-followup-done" : "stock_flag-for-followup", E_ICON_SIZE_MENU); + iconpath = e_icon_factory_get_icon_filename (comp && comp[0] ? "stock_flag-for-followup-done" : "stock_flag-for-followup", GTK_ICON_SIZE_MENU); if (iconpath) { CamelMimePart *iconpart; diff --git a/mail/em-format-html.c b/mail/em-format-html.c index fae1566876..cbf90a9214 100644 --- a/mail/em-format-html.c +++ b/mail/em-format-html.c @@ -1503,7 +1503,7 @@ efh_format_secure(EMFormat *emf, CamelStream *stream, CamelMimePart *part, Camel icon = smime_sign_table[valid->sign.status].icon; else icon = smime_encrypt_table[valid->encrypt.status].icon; - iconpath = e_icon_factory_get_icon_filename(icon, E_ICON_SIZE_DIALOG); + iconpath = e_icon_factory_get_icon_filename(icon, GTK_ICON_SIZE_DIALOG); iconpart = em_format_html_file_part((EMFormatHTML *)emf, "image/png", iconpath); if (iconpart) { (void)em_format_add_puri(emf, sizeof(EMFormatPURI), classid, iconpart, efh_write_image); diff --git a/mail/message-list.c b/mail/message-list.c index 2a72fe98eb..e970a09a7d 100644 --- a/mail/message-list.c +++ b/mail/message-list.c @@ -1721,7 +1721,7 @@ message_list_init_images (void) for (i = 0; i < G_N_ELEMENTS (states_pixmaps); i++) { if (states_pixmaps[i].icon_name) - states_pixmaps[i].pixbuf = e_icon_factory_get_icon (states_pixmaps[i].icon_name, E_ICON_SIZE_MENU); + states_pixmaps[i].pixbuf = e_icon_factory_get_icon (states_pixmaps[i].icon_name, GTK_ICON_SIZE_MENU); else states_pixmaps[i].pixbuf = gdk_pixbuf_new_from_xpm_data ((const char **) empty_xpm); } diff --git a/plugins/calendar-weather/calendar-weather.c b/plugins/calendar-weather/calendar-weather.c index 77eda067aa..b636bcee86 100644 --- a/plugins/calendar-weather/calendar-weather.c +++ b/plugins/calendar-weather/calendar-weather.c @@ -82,7 +82,7 @@ e_plugin_lib_enable (EPluginLib *epl, int enable) char *filename; filename = e_icon_factory_get_icon_filename ( - categories[ii].icon_name, E_ICON_SIZE_MENU); + categories[ii].icon_name, GTK_ICON_SIZE_MENU); e_categories_add ( _(categories[ii].description), NULL, filename, FALSE); g_free (filename); diff --git a/plugins/groupwise-features/proxy-login.c b/plugins/groupwise-features/proxy-login.c index 64653a073a..012a0df6e1 100644 --- a/plugins/groupwise-features/proxy-login.c +++ b/plugins/groupwise-features/proxy-login.c @@ -442,7 +442,7 @@ proxy_login_update_tree (void) char *proxy_email; EGwConnection *cnc; proxyLoginPrivate *priv = pld->priv; - gchar *file_name = e_icon_factory_get_icon_filename ("stock_person", E_ICON_SIZE_DIALOG); + gchar *file_name = e_icon_factory_get_icon_filename ("stock_person", GTK_ICON_SIZE_DIALOG); broken_image = file_name ? gdk_pixbuf_new_from_file (file_name, NULL) : NULL; cnc = proxy_login_get_cnc (pld->account, priv->main ? (GTK_WINDOW (gtk_widget_get_toplevel (priv->main))) : NULL); diff --git a/plugins/groupwise-features/proxy.c b/plugins/groupwise-features/proxy.c index 8bf212ee24..60be390eb3 100644 --- a/plugins/groupwise-features/proxy.c +++ b/plugins/groupwise-features/proxy.c @@ -602,7 +602,7 @@ proxy_update_tree_view (EAccount *account) GdkPixbuf *broken_image = NULL; GList *list_iter; proxyHandler *aclInstance; - gchar *file_name = e_icon_factory_get_icon_filename ("stock_person", E_ICON_SIZE_DIALOG); + gchar *file_name = e_icon_factory_get_icon_filename ("stock_person", GTK_ICON_SIZE_DIALOG); proxyDialogPrivate *priv; prd = g_object_get_data ((GObject *)account, "prd"); diff --git a/shell/e-shell-importer.c b/shell/e-shell-importer.c index 8a639342b1..69a30ee3a6 100644 --- a/shell/e-shell-importer.c +++ b/shell/e-shell-importer.c @@ -676,7 +676,7 @@ e_shell_importer_start_import (EShellWindow *shell_window) data->import = e_import_new("org.gnome.evolution.shell.importer"); - icon = e_icon_factory_get_icon ("stock_mail-import", E_ICON_SIZE_DIALOG); + icon = e_icon_factory_get_icon ("stock_mail-import", GTK_ICON_SIZE_DIALOG); dialog_open = TRUE; data->window = shell_window; |