From 59f4a3acdbfac190e29d8fa6c450f13d9b3d7e73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enrico=20Tr=C3=B6ger?= Date: Sat, 18 Apr 2009 19:26:42 +0200 Subject: [PATCH] Move search engine items in selection context menus to a submenu --- midori/midori-view.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/midori/midori-view.c b/midori/midori-view.c index 7c36d2c4..bb10bfe5 100644 --- a/midori/midori-view.c +++ b/midori/midori-view.c @@ -1043,21 +1043,24 @@ webkit_web_view_populate_popup_cb (WebKitWebView* web_view, { KatzeArray* search_engines; KatzeItem* item; + GtkWidget* sub_menu = gtk_menu_new (); + + menuitem = gtk_image_menu_item_new_with_mnemonic (_("Search _with")); + gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), sub_menu); + gtk_menu_shell_insert (GTK_MENU_SHELL (menu), menuitem, 1); + gtk_widget_show (menuitem); search_engines = katze_object_get_object (window, "search-engines"); while ((item = katze_array_get_nth_item (search_engines, i++))) { GdkPixbuf* pixbuf; - gchar* text = g_strdup_printf (_("Search with %s"), - katze_item_get_name (item)); - menuitem = gtk_image_menu_item_new_with_mnemonic (text); - g_free (text); + menuitem = gtk_image_menu_item_new_with_mnemonic (katze_item_get_name (item)); pixbuf = midori_search_action_get_icon (view->net, item, GTK_WIDGET (web_view)); icon = gtk_image_new_from_pixbuf (pixbuf); g_object_unref (pixbuf); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), icon); - gtk_menu_shell_insert (GTK_MENU_SHELL (menu), menuitem, i - 1); + gtk_menu_shell_insert (GTK_MENU_SHELL (sub_menu), menuitem, i - 1); g_object_set_data (G_OBJECT (menuitem), "search", (gchar*)katze_item_get_uri (item)); g_signal_connect (menuitem, "activate", @@ -1067,19 +1070,15 @@ webkit_web_view_populate_popup_cb (WebKitWebView* web_view, g_object_unref (search_engines); } items = gtk_container_get_children (GTK_CONTAINER (menu)); - menuitem = (GtkWidget*)g_list_nth_data (items, i - 1); - if (i > 1) - gtk_widget_destroy (menuitem); - else - { - /* hack to localize menu item */ - label = gtk_bin_get_child (GTK_BIN (menuitem)); - gtk_label_set_label (GTK_LABEL (label), _("_Search the Web")); - /* hack to implement Search the Web */ - g_signal_connect (menuitem, "activate", - G_CALLBACK (midori_web_view_menu_search_web_activate_cb), view); - } + menuitem = (GtkWidget*)g_list_nth_data (items, 0); + /* hack to localize menu item */ + label = gtk_bin_get_child (GTK_BIN (menuitem)); + gtk_label_set_label (GTK_LABEL (label), _("_Search the Web")); + /* hack to implement Search the Web */ + g_signal_connect (menuitem, "activate", + G_CALLBACK (midori_web_view_menu_search_web_activate_cb), view); g_list_free (items); + if (strchr (view->selected_text, '.') && !strchr (view->selected_text, ' ')) {