[Xfce4-commits] <midori:master> Implement 'Customize...' on toolbar right-click

Christian Dywan noreply at xfce.org
Sun Apr 17 22:46:01 CEST 2011


Updating branch refs/heads/master
         to 7691130cc31af9e010b1e014db4610c50c29b1f4 (commit)
       from 201808f9dfe5271742f632806e764ecd10b84d50 (commit)

commit 7691130cc31af9e010b1e014db4610c50c29b1f4
Author: Tomasz Szatkowski <szatkus at gmail.com>
Date:   Sun Apr 17 22:43:54 2011 +0200

    Implement 'Customize...' on toolbar right-click
    
    The new MidoriBrowser::populate-toolbar-menu allows
    extensions to add menu items.
    
    Fixes: https://bugs.launchpad.net/midori/+bug/699933

 extensions/toolbar-editor.c |   25 +++++++++++++++++++++++--
 midori/midori-browser.c     |   22 ++++++++++++++++++++++
 2 files changed, 45 insertions(+), 2 deletions(-)

diff --git a/extensions/toolbar-editor.c b/extensions/toolbar-editor.c
index e7d9da6..e83fce0 100644
--- a/extensions/toolbar-editor.c
+++ b/extensions/toolbar-editor.c
@@ -48,6 +48,9 @@ static const gint tb_editor_dnd_targets_len = G_N_ELEMENTS(tb_editor_dnd_targets
 
 static void tb_editor_browser_populate_tool_menu_cb(MidoriBrowser *browser, GtkWidget *menu, MidoriExtension *ext);
 
+static void tb_editor_browser_populate_toolbar_menu_cb(MidoriBrowser *browser, GtkWidget *menu,
+                                                       MidoriExtension *ext);
+
 static void tb_editor_app_add_browser_cb(MidoriApp *app, MidoriBrowser *browser, MidoriExtension *ext);
 
 
@@ -56,6 +59,7 @@ static void tb_editor_deactivate_cb(MidoriExtension *extension, MidoriBrowser *b
 	MidoriApp *app = midori_extension_get_app(extension);
 
 	g_signal_handlers_disconnect_by_func(browser, tb_editor_browser_populate_tool_menu_cb, extension);
+	g_signal_handlers_disconnect_by_func(browser, tb_editor_browser_populate_toolbar_menu_cb, extension);
 	g_signal_handlers_disconnect_by_func(extension, tb_editor_deactivate_cb, browser);
 	g_signal_handlers_disconnect_by_func(app, tb_editor_app_add_browser_cb, extension);
 }
@@ -579,10 +583,27 @@ static void tb_editor_browser_populate_tool_menu_cb(MidoriBrowser *browser, GtkW
     gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
 }
 
+static void tb_editor_browser_populate_toolbar_menu_cb(MidoriBrowser *browser, GtkWidget *menu,
+                                                       MidoriExtension *ext)
+{
+    GtkWidget* separator;
+    GtkWidget* menuitem;
+
+    separator = gtk_separator_menu_item_new ();
+    gtk_widget_show (separator);
+    gtk_menu_shell_append (GTK_MENU_SHELL (menu), separator);
+    menuitem = gtk_menu_item_new_with_mnemonic (_("_Customize..."));
+    g_signal_connect (menuitem, "activate",
+        G_CALLBACK (tb_editor_menu_configure_toolbar_activate_cb), browser);
+    gtk_widget_show (menuitem);
+    gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
+}
+
 static void tb_editor_app_add_browser_cb(MidoriApp *app, MidoriBrowser *browser, MidoriExtension *ext)
 {
-	g_signal_connect(browser, "populate-tool-menu", G_CALLBACK(tb_editor_browser_populate_tool_menu_cb), ext);
-	g_signal_connect(ext, "deactivate", G_CALLBACK(tb_editor_deactivate_cb), browser);
+    g_signal_connect(browser, "populate-tool-menu", G_CALLBACK(tb_editor_browser_populate_tool_menu_cb), ext);
+    g_signal_connect(browser, "populate-toolbar-menu", G_CALLBACK(tb_editor_browser_populate_toolbar_menu_cb), ext);
+    g_signal_connect(ext, "deactivate", G_CALLBACK(tb_editor_deactivate_cb), browser);
 }
 
 
diff --git a/midori/midori-browser.c b/midori/midori-browser.c
index 4fbb409..9234a96 100644
--- a/midori/midori-browser.c
+++ b/midori/midori-browser.c
@@ -143,6 +143,7 @@ enum
     ADD_DOWNLOAD,
     SEND_NOTIFICATION,
     POPULATE_TOOL_MENU,
+    POPULATE_TOOLBAR_MENU,
     QUIT,
     SHOW_PREFERENCES,
 
@@ -1852,6 +1853,25 @@ midori_browser_class_init (MidoriBrowserClass* class)
         g_cclosure_marshal_VOID__OBJECT,
         G_TYPE_NONE, 1,
         GTK_TYPE_MENU);
+    /**
+     * MidoriBrowser::populate-toolbar-menu:
+     * @browser: the object on which the signal is emitted
+     * @menu: the #GtkMenu to populate
+     *
+     * Emitted when a toolbar menu is displayed on right-click.
+     *
+     * Since: 0.3.4
+     */
+    signals[POPULATE_TOOLBAR_MENU] = g_signal_new (
+        "populate-toolbar-menu",
+        G_TYPE_FROM_CLASS (class),
+        (GSignalFlags)(G_SIGNAL_RUN_LAST),
+        0,
+        0,
+        NULL,
+        g_cclosure_marshal_VOID__OBJECT,
+        G_TYPE_NONE, 1,
+        GTK_TYPE_MENU);
 
     signals[QUIT] = g_signal_new (
         "quit",
@@ -2676,6 +2696,8 @@ midori_browser_toolbar_popup_context_menu_cb (GtkWidget*     widget,
         _action_by_name (browser, "Statusbar"));
     gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
 
+    g_signal_emit (browser, signals[POPULATE_TOOLBAR_MENU], 0, menu);
+
     katze_widget_popup (widget, GTK_MENU (menu), NULL,
         button == -1 ? KATZE_MENU_POSITION_LEFT : KATZE_MENU_POSITION_CURSOR);
     return TRUE;



More information about the Xfce4-commits mailing list