Move search engine items in selection context menus to a submenu
This commit is contained in:
parent
b8f9571783
commit
59f4a3acdb
1 changed files with 16 additions and 17 deletions
|
@ -1043,21 +1043,24 @@ webkit_web_view_populate_popup_cb (WebKitWebView* web_view,
|
||||||
{
|
{
|
||||||
KatzeArray* search_engines;
|
KatzeArray* search_engines;
|
||||||
KatzeItem* item;
|
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");
|
search_engines = katze_object_get_object (window, "search-engines");
|
||||||
while ((item = katze_array_get_nth_item (search_engines, i++)))
|
while ((item = katze_array_get_nth_item (search_engines, i++)))
|
||||||
{
|
{
|
||||||
GdkPixbuf* pixbuf;
|
GdkPixbuf* pixbuf;
|
||||||
gchar* text = g_strdup_printf (_("Search with %s"),
|
menuitem = gtk_image_menu_item_new_with_mnemonic (katze_item_get_name (item));
|
||||||
katze_item_get_name (item));
|
|
||||||
menuitem = gtk_image_menu_item_new_with_mnemonic (text);
|
|
||||||
g_free (text);
|
|
||||||
pixbuf = midori_search_action_get_icon (view->net, item,
|
pixbuf = midori_search_action_get_icon (view->net, item,
|
||||||
GTK_WIDGET (web_view));
|
GTK_WIDGET (web_view));
|
||||||
icon = gtk_image_new_from_pixbuf (pixbuf);
|
icon = gtk_image_new_from_pixbuf (pixbuf);
|
||||||
g_object_unref (pixbuf);
|
g_object_unref (pixbuf);
|
||||||
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), icon);
|
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",
|
g_object_set_data (G_OBJECT (menuitem), "search",
|
||||||
(gchar*)katze_item_get_uri (item));
|
(gchar*)katze_item_get_uri (item));
|
||||||
g_signal_connect (menuitem, "activate",
|
g_signal_connect (menuitem, "activate",
|
||||||
|
@ -1067,19 +1070,15 @@ webkit_web_view_populate_popup_cb (WebKitWebView* web_view,
|
||||||
g_object_unref (search_engines);
|
g_object_unref (search_engines);
|
||||||
}
|
}
|
||||||
items = gtk_container_get_children (GTK_CONTAINER (menu));
|
items = gtk_container_get_children (GTK_CONTAINER (menu));
|
||||||
menuitem = (GtkWidget*)g_list_nth_data (items, i - 1);
|
menuitem = (GtkWidget*)g_list_nth_data (items, 0);
|
||||||
if (i > 1)
|
|
||||||
gtk_widget_destroy (menuitem);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* hack to localize menu item */
|
/* hack to localize menu item */
|
||||||
label = gtk_bin_get_child (GTK_BIN (menuitem));
|
label = gtk_bin_get_child (GTK_BIN (menuitem));
|
||||||
gtk_label_set_label (GTK_LABEL (label), _("_Search the Web"));
|
gtk_label_set_label (GTK_LABEL (label), _("_Search the Web"));
|
||||||
/* hack to implement Search the Web */
|
/* hack to implement Search the Web */
|
||||||
g_signal_connect (menuitem, "activate",
|
g_signal_connect (menuitem, "activate",
|
||||||
G_CALLBACK (midori_web_view_menu_search_web_activate_cb), view);
|
G_CALLBACK (midori_web_view_menu_search_web_activate_cb), view);
|
||||||
}
|
|
||||||
g_list_free (items);
|
g_list_free (items);
|
||||||
|
|
||||||
if (strchr (view->selected_text, '.')
|
if (strchr (view->selected_text, '.')
|
||||||
&& !strchr (view->selected_text, ' '))
|
&& !strchr (view->selected_text, ' '))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue