diff options
author | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2013-10-04 09:16:40 +0000 |
---|---|---|
committer | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2013-10-04 09:16:40 +0000 |
commit | fd5c980f1770aa74b9d4dd2ecdbaeb5abbb7b8de (patch) | |
tree | 56c86b7a645beeb23b8036b0f1952dcb4b7ec123 | |
parent | 20e1d21eecd0c3ab6312ee9ba635427607d7837c (diff) |
made the rest of toolbar icons themeable.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@3288 ee746299-78ed-0310-b773-934348b2243d
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | src/compose.c | 7 | ||||
-rw-r--r-- | src/mainwindow.c | 7 | ||||
-rw-r--r-- | src/prefs_toolbar.c | 26 | ||||
-rw-r--r-- | src/stock_pixmap.c | 82 | ||||
-rw-r--r-- | src/stock_pixmap.h | 16 |
6 files changed, 106 insertions, 39 deletions
@@ -1,3 +1,10 @@ +2013-10-04 + + * src/compose.c + src/prefs_toolbar.c + src/stock_pixmap.[ch] + src/mainwindow.c: made the rest of toolbar icons themeable. + 2013-09-20 * makewin32.sh: added --with-themedir configure option. diff --git a/src/compose.c b/src/compose.c index 726790a9..257cea3f 100644 --- a/src/compose.c +++ b/src/compose.c @@ -5892,12 +5892,7 @@ static GtkWidget *compose_toolbar_create_from_list(Compose *compose, if (item->id == -1) continue; - if (ditem->stock_id) { - icon_wid = gtk_image_new_from_stock - (ditem->stock_id, GTK_ICON_SIZE_LARGE_TOOLBAR); - } else - icon_wid = stock_pixbuf_widget(NULL, ditem->icon); - + icon_wid = stock_pixbuf_widget_for_toolbar(ditem->icon); toolitem = gtk_tool_button_new(icon_wid, gettext(ditem->label)); if (ditem->description) { gtk_tool_item_set_tooltip(toolitem, diff --git a/src/mainwindow.c b/src/mainwindow.c index d72b1a22..3995c322 100644 --- a/src/mainwindow.c +++ b/src/mainwindow.c @@ -2708,12 +2708,7 @@ static GtkWidget *main_window_toolbar_create_from_list(MainWindow *mainwin, if (item->id == -1) continue; - if (ditem->stock_id) { - icon_wid = gtk_image_new_from_stock - (ditem->stock_id, GTK_ICON_SIZE_LARGE_TOOLBAR); - } else - icon_wid = stock_pixbuf_widget(NULL, ditem->icon); - + icon_wid = stock_pixbuf_widget_for_toolbar(ditem->icon); toolitem = gtk_tool_button_new(icon_wid, gettext(ditem->label)); if (ditem->description) { gtk_tool_item_set_tooltip(toolitem, diff --git a/src/prefs_toolbar.c b/src/prefs_toolbar.c index 9cb89b72..1aad7519 100644 --- a/src/prefs_toolbar.c +++ b/src/prefs_toolbar.c @@ -46,7 +46,7 @@ static PrefsDisplayItem all_items[] = STOCK_PIXMAP_MAIL_RECEIVE_ALL, NULL, FALSE, FALSE}, {T_REMOTE_MAILBOX, "remote-mailbox", N_("Remote mailbox"), N_("POP3 Remote mailbox"), - -1, GTK_STOCK_NETWORK, FALSE, FALSE}, + STOCK_PIXMAP_REMOTE_MAILBOX, GTK_STOCK_NETWORK, FALSE, FALSE}, {T_SEND_QUEUE, "send-queue", N_("Send"), N_("Send queued message(s)"), STOCK_PIXMAP_MAIL_SEND, NULL, FALSE, FALSE}, @@ -73,31 +73,31 @@ static PrefsDisplayItem all_items[] = STOCK_PIXMAP_NOTSPAM, NULL, FALSE, FALSE}, {T_NEXT, "next", N_("Next"), N_("Next unread message"), - -1, GTK_STOCK_GO_DOWN, FALSE, FALSE}, + STOCK_PIXMAP_NEXT, GTK_STOCK_GO_DOWN, FALSE, FALSE}, {T_PREV, "prev", N_("Prev"), N_("Previous unread message"), - -1, GTK_STOCK_GO_UP, FALSE, FALSE}, + STOCK_PIXMAP_PREV, GTK_STOCK_GO_UP, FALSE, FALSE}, {T_SEARCH, "search", N_("Search"), N_("Search messages"), - -1, GTK_STOCK_FIND, FALSE, FALSE}, + STOCK_PIXMAP_SEARCH, GTK_STOCK_FIND, FALSE, FALSE}, {T_PRINT, "print", N_("Print"), N_("Print message"), - -1, GTK_STOCK_PRINT, FALSE, FALSE}, + STOCK_PIXMAP_PRINT, GTK_STOCK_PRINT, FALSE, FALSE}, {T_STOP, "stop", N_("Stop"), N_("Stop receiving"), - -1, GTK_STOCK_STOP, FALSE, FALSE}, + STOCK_PIXMAP_STOP, GTK_STOCK_STOP, FALSE, FALSE}, {T_ADDRESS_BOOK, "address-book", N_("Address"), N_("Address book"), STOCK_PIXMAP_ADDRESS_BOOK, NULL, FALSE, FALSE}, {T_EXECUTE, "execute", N_("Execute"), N_("Execute marked process"), - -1, GTK_STOCK_EXECUTE, FALSE, FALSE}, + STOCK_PIXMAP_EXECUTE, GTK_STOCK_EXECUTE, FALSE, FALSE}, {T_COMMON_PREFS, "common-prefs", N_("Prefs"), N_("Common preferences"), - -1, GTK_STOCK_PREFERENCES, FALSE, FALSE}, + STOCK_PIXMAP_COMMON_PREFS, GTK_STOCK_PREFERENCES, FALSE, FALSE}, {T_ACCOUNT_PREFS, "account-prefs", N_("Account"), N_("Account preferences"), - -1, GTK_STOCK_PREFERENCES, FALSE, FALSE}, + STOCK_PIXMAP_ACCOUNT_PREFS, GTK_STOCK_PREFERENCES, FALSE, FALSE}, {T_SEND, "send", N_("Send"), N_("Send message"), @@ -107,7 +107,7 @@ static PrefsDisplayItem all_items[] = STOCK_PIXMAP_MAIL_SEND_QUEUE, NULL, FALSE, FALSE}, {T_DRAFT, "draft", N_("Draft"), N_("Save to draft folder"), - -1, GTK_STOCK_SAVE, FALSE, FALSE}, + STOCK_PIXMAP_SAVE, GTK_STOCK_SAVE, FALSE, FALSE}, {T_INSERT_FILE, "insert-file", N_("Insert"), N_("Insert file"), STOCK_PIXMAP_INSERT_FILE, NULL, FALSE, FALSE}, @@ -119,11 +119,7 @@ static PrefsDisplayItem all_items[] = STOCK_PIXMAP_SIGN, NULL, FALSE, FALSE}, {T_EDITOR, "editor", N_("Editor"), N_("Edit with external editor"), -#ifdef GTK_STOCK_EDIT - -1, GTK_STOCK_EDIT, FALSE, FALSE}, -#else - STOCK_PIXMAP_MAIL_COMPOSE, NULL, FALSE, FALSE}, -#endif + STOCK_PIXMAP_EDIT, GTK_STOCK_EDIT, FALSE, FALSE}, {T_LINEWRAP, "linewrap", N_("Linewrap"), N_("Wrap all long lines"), STOCK_PIXMAP_LINEWRAP, NULL, FALSE, FALSE}, diff --git a/src/stock_pixmap.c b/src/stock_pixmap.c index 93a0628e..e41b405b 100644 --- a/src/stock_pixmap.c +++ b/src/stock_pixmap.c @@ -99,6 +99,7 @@ struct _StockPixmapData gint size; gchar *icon_file; + GdkPixbuf *icon_file_pixbuf; }; static StockPixmapData pixmaps[] = @@ -159,6 +160,19 @@ static StockPixmapData pixmaps[] = {NULL, NULL, NULL, NULL, stock_person, sizeof(stock_person), "stock_person", 16, "stock_person.png"}, {NULL, NULL, NULL, NULL, folder_search, sizeof(folder_search), "folder-search", 0, "folder-search.png"}, {NULL, NULL, NULL, NULL, stock_spam_16, sizeof(stock_spam_16), "stock_spam", 16, "stock_spam_16.png"}, + + /* for toolbar */ + {NULL, NULL, NULL, NULL, NULL, 0, GTK_STOCK_NETWORK, 24, "remote-mailbox.png"}, + {NULL, NULL, NULL, NULL, NULL, 0, GTK_STOCK_GO_DOWN, 24, "next.png"}, + {NULL, NULL, NULL, NULL, NULL, 0, GTK_STOCK_GO_UP, 24, "prev.png"}, + {NULL, NULL, NULL, NULL, NULL, 0, GTK_STOCK_FIND, 24, "search.png"}, + {NULL, NULL, NULL, NULL, NULL, 0, GTK_STOCK_PRINT, 24, "print.png"}, + {NULL, NULL, NULL, NULL, NULL, 0, GTK_STOCK_STOP, 24, "stop.png"}, + {NULL, NULL, NULL, NULL, NULL, 0, GTK_STOCK_EXECUTE, 24, "execute.png"}, + {NULL, NULL, NULL, NULL, NULL, 0, GTK_STOCK_PREFERENCES, 24, "common-prefs.png"}, + {NULL, NULL, NULL, NULL, NULL, 0, GTK_STOCK_PREFERENCES, 24, "account-prefs.png"}, + {NULL, NULL, NULL, NULL, NULL, 0, GTK_STOCK_SAVE, 24, "save.png"}, + {NULL, NULL, NULL, NULL, NULL, 0, GTK_STOCK_EDIT, 24, "editor.png"}, }; static gchar *theme_dir = NULL; @@ -192,6 +206,60 @@ GtkWidget *stock_pixbuf_widget_scale(GtkWidget *window, StockPixmap icon, return image; } +static gboolean stock_pixbuf_load_theme_icon_file(StockPixmap icon) +{ + StockPixmapData *pix_d; + + g_return_val_if_fail(icon >= 0 && icon < N_STOCK_PIXMAPS, FALSE); + + pix_d = &pixmaps[icon]; + + if (!pix_d->icon_file_pixbuf && pix_d->icon_file && theme_dir) { + gchar *path; + + path = g_strconcat(theme_dir, G_DIR_SEPARATOR_S, + pix_d->icon_file, NULL); + debug_print("stock_pixbuf_load_theme_icon_file: checking theme icon: %s\n", path); + if (is_file_exist(path)) { + debug_print("stock_pixbuf_load_theme_icon_file: loading theme icon: %s\n", path); + pix_d->icon_file_pixbuf = gdk_pixbuf_new_from_file(path, NULL); + if (!pix_d->icon_file_pixbuf) { + g_warning("stock_pixbuf_load_theme_icon_file: loading of theme icon failed: %s", path); + pix_d->icon_file = NULL; + } else if (!pix_d->pixbuf) + pix_d->pixbuf = pix_d->icon_file_pixbuf; + } else + pix_d->icon_file = NULL; + g_free(path); + } + + return pix_d->icon_file_pixbuf != NULL; +} + +GtkWidget *stock_pixbuf_widget_for_toolbar(StockPixmap icon) +{ + GtkWidget *image = NULL; + StockPixmapData *pix_d; + + g_return_val_if_fail(icon >= 0 && icon < N_STOCK_PIXMAPS, NULL); + + stock_pixbuf_load_theme_icon_file(icon); + + pix_d = &pixmaps[icon]; + + if (pix_d->icon_file_pixbuf) { + image = gtk_image_new_from_pixbuf(pix_d->icon_file_pixbuf); + } + + if (!image && pix_d->icon_name) + image = gtk_image_new_from_stock(pix_d->icon_name, GTK_ICON_SIZE_LARGE_TOOLBAR); + + if (!image) + image = stock_pixbuf_widget(NULL, icon); + + return image; +} + /* create GdkPixmap if it has not created yet */ gint stock_pixmap_gdk(GtkWidget *window, StockPixmap icon, GdkPixmap **pixmap, GdkBitmap **mask) @@ -228,19 +296,9 @@ gint stock_pixbuf_gdk(GtkWidget *window, StockPixmap icon, GdkPixbuf **pixbuf) g_return_val_if_fail(icon >= 0 && icon < N_STOCK_PIXMAPS, -1); - pix_d = &pixmaps[icon]; + stock_pixbuf_load_theme_icon_file(icon); - if (!pix_d->pixbuf && pix_d->icon_file && theme_dir) { - gchar *path; - - path = g_strconcat(theme_dir, G_DIR_SEPARATOR_S, - pix_d->icon_file, NULL); - if (is_file_exist(path)) { - debug_print("stock_pixbuf_gdk: loading theme icon: %s\n", path); - pix_d->pixbuf = gdk_pixbuf_new_from_file(path, NULL); - } - g_free(path); - } + pix_d = &pixmaps[icon]; if (!pix_d->pixbuf && pix_d->pixbuf_data) pix_d->pixbuf = gdk_pixbuf_new_from_inline diff --git a/src/stock_pixmap.h b/src/stock_pixmap.h index 15017516..b0496988 100644 --- a/src/stock_pixmap.h +++ b/src/stock_pixmap.h @@ -82,6 +82,20 @@ typedef enum STOCK_PIXMAP_FOLDER_SEARCH, STOCK_PIXMAP_SPAM_SMALL, + /* for toolbar */ + + STOCK_PIXMAP_REMOTE_MAILBOX, + STOCK_PIXMAP_NEXT, + STOCK_PIXMAP_PREV, + STOCK_PIXMAP_SEARCH, + STOCK_PIXMAP_PRINT, + STOCK_PIXMAP_STOP, + STOCK_PIXMAP_EXECUTE, + STOCK_PIXMAP_COMMON_PREFS, + STOCK_PIXMAP_ACCOUNT_PREFS, + STOCK_PIXMAP_SAVE, + STOCK_PIXMAP_EDIT, + N_STOCK_PIXMAPS } StockPixmap; @@ -93,6 +107,8 @@ GtkWidget *stock_pixbuf_widget_scale (GtkWidget *window, gint width, gint height); +GtkWidget *stock_pixbuf_widget_for_toolbar(StockPixmap icon); + gint stock_pixmap_gdk (GtkWidget *window, StockPixmap icon, GdkPixmap **pixmap, |