From 313e0f9e355f1d7d3a2676d35c53e49efcd77c76 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Enrico=20Tr=C3=B6ger?= Date: Fri, 10 Jul 2009 16:37:44 +0100 Subject: [PATCH] Add a public function to retrieve the recommended toolbar actions --- midori/midori-browser.c | 38 +++++++++++++++++++++++++++++--------- midori/midori-browser.h | 3 +++ 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/midori/midori-browser.c b/midori/midori-browser.c index 3ac60cff..ea8345c5 100644 --- a/midori/midori-browser.c +++ b/midori/midori-browser.c @@ -2335,6 +2335,28 @@ midori_browser_toolbar_remove_item_cb (GtkWidget* menuitem, } #endif +/** + * midori_browser_get_toolbar_actions: + * + * Retrieves a list of actions which are suitable for use in a toolbar. + * + * Return value: a NULL-terminated array of strings with actions + * + * Since: 0.1.8 + **/ +const gchar** +midori_browser_get_toolbar_actions (MidoriBrowser* browser) +{ + static const gchar* actions[] = { + "WindowNew", "TabNew", "Open", "SaveAs", "Print", "Find", + "Fullscreen", "Preferences", "Window", "Bookmarks", + "RecentlyVisited", "AddSpeedDial", "ReloadStop", "ZoomIn", + "ZoomOut", "Separator", "Back", "Forward", "Homepage", + "Panel", "Trash", "Search", NULL }; + + return actions; +} + static gboolean midori_browser_toolbar_popup_context_menu_cb (GtkWidget* widget, gint x, @@ -2371,14 +2393,9 @@ midori_browser_toolbar_popup_context_menu_cb (GtkWidget* widget, gtk_widget_is_ancestor (widget, browser->navigationbar)) { GtkAction* widget_action = gtk_widget_get_action (widget); - const gchar* actions[] = { - "WindowNew", "TabNew", "Open", "SaveAs", "Print", "Find", - "Fullscreen", "Preferences", "Window", "Bookmarks", - "RecentlyVisited", "AddSpeedDial", "ReloadStop", "ZoomIn", - "Separator", "ZoomOut", "Back", "Forward", - "Homepage", "Panel", "Trash", "Search" }; + const gchar** actions = midori_browser_get_toolbar_actions (browser); + const gchar** name; GtkWidget* submenu; - gsize i; menuitem = gtk_separator_menu_item_new (); gtk_widget_show (menuitem); @@ -2401,9 +2418,10 @@ midori_browser_toolbar_popup_context_menu_cb (GtkWidget* widget, else gtk_widget_set_sensitive (menuitem, FALSE); - for (i = 0; i < G_N_ELEMENTS (actions); i++) + name = actions; + while (*name != NULL) { - GtkAction* action = _action_by_name (browser, actions[i]); + GtkAction* action = _action_by_name (browser, *name); gchar* stock_id = katze_object_get_string (action, "stock-id"); gchar* label = katze_object_get_string (action, "label"); @@ -2425,6 +2443,8 @@ midori_browser_toolbar_popup_context_menu_cb (GtkWidget* widget, g_object_set_data (G_OBJECT (menuitem), "action", action); g_signal_connect (menuitem, "activate", G_CALLBACK (midori_browser_toolbar_add_item_cb), browser); + + name++; } sokoke_container_show_children (GTK_CONTAINER (submenu)); } diff --git a/midori/midori-browser.h b/midori/midori-browser.h index f0d2ffd7..49d475d6 100644 --- a/midori/midori-browser.h +++ b/midori/midori-browser.h @@ -138,6 +138,9 @@ midori_browser_get_for_widget (GtkWidget* widget); void midori_browser_quit (MidoriBrowser* browser); +const gchar** +midori_browser_get_toolbar_actions (MidoriBrowser* browser); + G_END_DECLS #endif /* __MIDORI_BROWSER_H__ */ -- 2.39.5