From: Christian Dywan Date: Sat, 21 Feb 2009 21:36:03 +0000 (+0100) Subject: Move stock item registrations to sokoke so it can be tested X-Git-Url: https://spindle.queued.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5f52e0d21fe57e1ddd880033aef2d6097f8898a3;p=midori Move stock item registrations to sokoke so it can be tested --- diff --git a/midori/main.c b/midori/main.c index 19310ac0..80950642 100644 --- a/midori/main.c +++ b/midori/main.c @@ -24,7 +24,6 @@ #include "midori-panel.h" #include "midori-preferences.h" #include "midori-plugins.h" -#include "midori-stock.h" #include "midori-view.h" #include "midori-websettings.h" @@ -71,66 +70,6 @@ typedef enum } MidoriHistoryError; -static void -stock_items_init (void) -{ - typedef struct - { - const gchar* stock_id; - const gchar* label; - GdkModifierType modifier; - guint keyval; - const gchar* fallback; - } FatStockItem; - GtkIconSource* icon_source; - GtkIconSet* icon_set; - GtkIconFactory* factory = gtk_icon_factory_new (); - gsize i; - - static FatStockItem items[] = - { - { STOCK_EXTENSION, NULL, 0, 0, GTK_STOCK_CONVERT }, - { STOCK_NEWS_FEED, NULL, 0, 0, GTK_STOCK_INDEX }, - { STOCK_SCRIPT, NULL, 0, 0, GTK_STOCK_EXECUTE }, - { STOCK_STYLE, NULL, 0, 0, GTK_STOCK_SELECT_COLOR }, - { STOCK_TRANSFER, NULL, 0, 0, GTK_STOCK_SAVE }, - - { STOCK_BOOKMARK, N_("_Bookmark"), 0, 0, GTK_STOCK_FILE }, - { STOCK_BOOKMARKS, N_("_Bookmarks"), 0, 0, GTK_STOCK_DIRECTORY }, - { STOCK_BOOKMARK_ADD, N_("_Add Bookmark"), 0, 0, GTK_STOCK_ADD }, - { STOCK_CONSOLE, N_("_Console"), 0, 0, GTK_STOCK_DIALOG_WARNING }, - { STOCK_EXTENSIONS, N_("_Extensions"), 0, 0, GTK_STOCK_CONVERT }, - { STOCK_HISTORY, N_("_History"), 0, 0, GTK_STOCK_SORT_ASCENDING }, - { STOCK_HOMEPAGE, N_("_Homepage"), 0, 0, GTK_STOCK_HOME }, - { STOCK_SCRIPTS, N_("_Userscripts"), 0, 0, GTK_STOCK_EXECUTE }, - { STOCK_STYLES, N_("User_styles"), 0, 0, GTK_STOCK_SELECT_COLOR }, - { STOCK_TAB_NEW, N_("New _Tab"), 0, 0, GTK_STOCK_ADD }, - { STOCK_TRANSFERS, N_("_Transfers"), 0, 0, GTK_STOCK_SAVE }, - { STOCK_USER_TRASH, N_("_Closed Tabs and Windows"), 0, 0, "gtk-undo-ltr" }, - { STOCK_WINDOW_NEW, N_("New _Window"), 0, 0, GTK_STOCK_ADD }, - }; - - for (i = 0; i < G_N_ELEMENTS (items); i++) - { - icon_set = gtk_icon_set_new (); - icon_source = gtk_icon_source_new (); - if (items[i].fallback) - { - gtk_icon_source_set_icon_name (icon_source, items[i].fallback); - items[i].fallback = NULL; - gtk_icon_set_add_source (icon_set, icon_source); - } - gtk_icon_source_set_icon_name (icon_source, items[i].stock_id); - gtk_icon_set_add_source (icon_set, icon_source); - gtk_icon_source_free (icon_source); - gtk_icon_factory_add (factory, items[i].stock_id, icon_set); - gtk_icon_set_unref (icon_set); - } - gtk_stock_add ((GtkStockItem*)items, G_N_ELEMENTS (items)); - gtk_icon_factory_add_default (factory); - g_object_unref (factory); -} - static gchar* build_config_filename (const gchar* filename) { @@ -1765,7 +1704,7 @@ main (int argc, /* libSoup uses threads, therefore if WebKit is built with libSoup or Midori is using it, we need to initialize threads. */ if (!g_thread_supported ()) g_thread_init (NULL); - stock_items_init (); + sokoke_register_stock_items (); g_set_application_name (_("Midori")); if (version) diff --git a/midori/sokoke.c b/midori/sokoke.c index 8a756e6e..98d9384d 100644 --- a/midori/sokoke.c +++ b/midori/sokoke.c @@ -10,6 +10,7 @@ */ #include "sokoke.h" +#include "midori-stock.h" #if HAVE_CONFIG_H #include @@ -700,3 +701,68 @@ sokoke_time_t_to_julian (const time_t* timestamp) return julian; } + +/** + * sokoke_register_stock_items: + * + * Registers several custom stock items used throughout Midori. + **/ +void +sokoke_register_stock_items (void) +{ + typedef struct + { + const gchar* stock_id; + const gchar* label; + GdkModifierType modifier; + guint keyval; + const gchar* fallback; + } FatStockItem; + GtkIconSource* icon_source; + GtkIconSet* icon_set; + GtkIconFactory* factory = gtk_icon_factory_new (); + gsize i; + + static FatStockItem items[] = + { + { STOCK_EXTENSION, NULL, 0, 0, GTK_STOCK_CONVERT }, + { STOCK_NEWS_FEED, NULL, 0, 0, GTK_STOCK_INDEX }, + { STOCK_SCRIPT, NULL, 0, 0, GTK_STOCK_EXECUTE }, + { STOCK_STYLE, NULL, 0, 0, GTK_STOCK_SELECT_COLOR }, + { STOCK_TRANSFER, NULL, 0, 0, GTK_STOCK_SAVE }, + + { STOCK_BOOKMARK, N_("_Bookmark"), 0, 0, GTK_STOCK_FILE }, + { STOCK_BOOKMARKS, N_("_Bookmarks"), 0, 0, GTK_STOCK_DIRECTORY }, + { STOCK_BOOKMARK_ADD, N_("_Add Bookmark"), 0, 0, GTK_STOCK_ADD }, + { STOCK_CONSOLE, N_("_Console"), 0, 0, GTK_STOCK_DIALOG_WARNING }, + { STOCK_EXTENSIONS, N_("_Extensions"), 0, 0, GTK_STOCK_CONVERT }, + { STOCK_HISTORY, N_("_History"), 0, 0, GTK_STOCK_SORT_ASCENDING }, + { STOCK_HOMEPAGE, N_("_Homepage"), 0, 0, GTK_STOCK_HOME }, + { STOCK_SCRIPTS, N_("_Userscripts"), 0, 0, GTK_STOCK_EXECUTE }, + { STOCK_STYLES, N_("User_styles"), 0, 0, GTK_STOCK_SELECT_COLOR }, + { STOCK_TAB_NEW, N_("New _Tab"), 0, 0, GTK_STOCK_ADD }, + { STOCK_TRANSFERS, N_("_Transfers"), 0, 0, GTK_STOCK_SAVE }, + { STOCK_USER_TRASH, N_("_Closed Tabs and Windows"), 0, 0, "gtk-undo-ltr" }, + { STOCK_WINDOW_NEW, N_("New _Window"), 0, 0, GTK_STOCK_ADD }, + }; + + for (i = 0; i < G_N_ELEMENTS (items); i++) + { + icon_set = gtk_icon_set_new (); + icon_source = gtk_icon_source_new (); + if (items[i].fallback) + { + gtk_icon_source_set_icon_name (icon_source, items[i].fallback); + items[i].fallback = NULL; + gtk_icon_set_add_source (icon_set, icon_source); + } + gtk_icon_source_set_icon_name (icon_source, items[i].stock_id); + gtk_icon_set_add_source (icon_set, icon_source); + gtk_icon_source_free (icon_source); + gtk_icon_factory_add (factory, items[i].stock_id, icon_set); + gtk_icon_set_unref (icon_set); + } + gtk_stock_add ((GtkStockItem*)items, G_N_ELEMENTS (items)); + gtk_icon_factory_add_default (factory); + g_object_unref (factory); +} diff --git a/midori/sokoke.h b/midori/sokoke.h index 13190475..4212f7e6 100644 --- a/midori/sokoke.h +++ b/midori/sokoke.h @@ -124,4 +124,7 @@ sokoke_image_menu_item_new_ellipsized (const gchar* label); gint64 sokoke_time_t_to_julian (const time_t* timestamp); +void +sokoke_register_stock_items (void); + #endif /* !__SOKOKE_H__ */