]> spindle.queued.net Git - midori/commitdiff
Move stock item registrations to sokoke so it can be tested
authorChristian Dywan <christian@twotoasts.de>
Sat, 21 Feb 2009 21:36:03 +0000 (22:36 +0100)
committerChristian Dywan <christian@twotoasts.de>
Sat, 21 Feb 2009 21:36:03 +0000 (22:36 +0100)
midori/main.c
midori/sokoke.c
midori/sokoke.h

index 19310ac08d1ed9aa2646b7bfc92d99f4b725c608..8095064227017c52ac7d9984771e04e917c5eb38 100644 (file)
@@ -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)
index 8a756e6e16024d2ffb1862a0660129cbe1315757..98d9384d0772b078fe83131103315910020b90bc 100644 (file)
@@ -10,6 +10,7 @@
 */
 
 #include "sokoke.h"
+#include "midori-stock.h"
 
 #if HAVE_CONFIG_H
     #include <config.h>
@@ -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);
+}
index 13190475da354d1b6f68f1bb926457d170672db2..4212f7e67f9ae974b3bbf72019b8e1f2ced48778 100644 (file)
@@ -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__ */