Prefill description when adding search engine
This commit is contained in:
parent
dce8096593
commit
d95513226d
2 changed files with 37 additions and 7 deletions
|
@ -946,7 +946,6 @@ midori_search_action_get_editor (MidoriSearchAction* search_action,
|
||||||
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
|
||||||
entry_description = gtk_entry_new ();
|
entry_description = gtk_entry_new ();
|
||||||
gtk_entry_set_activates_default (GTK_ENTRY (entry_description), TRUE);
|
gtk_entry_set_activates_default (GTK_ENTRY (entry_description), TRUE);
|
||||||
if (!new_engine)
|
|
||||||
gtk_entry_set_text (GTK_ENTRY (entry_description)
|
gtk_entry_set_text (GTK_ENTRY (entry_description)
|
||||||
, katze_str_non_null (katze_item_get_text (item)));
|
, katze_str_non_null (katze_item_get_text (item)));
|
||||||
gtk_box_pack_start (GTK_BOX (hbox), entry_description, TRUE, TRUE, 0);
|
gtk_box_pack_start (GTK_BOX (hbox), entry_description, TRUE, TRUE, 0);
|
||||||
|
|
|
@ -2442,7 +2442,8 @@ midori_view_menu_add_search_engine_cb (GtkWidget* widget,
|
||||||
}
|
}
|
||||||
|
|
||||||
static KatzeItem*
|
static KatzeItem*
|
||||||
midori_view_search_engine_for_form (WebKitWebView* web_view)
|
midori_view_search_engine_for_form (MidoriView* view,
|
||||||
|
WebKitWebView* web_view)
|
||||||
{
|
{
|
||||||
|
|
||||||
WebKitDOMDocument* doc;
|
WebKitDOMDocument* doc;
|
||||||
|
@ -2450,9 +2451,12 @@ midori_view_search_engine_for_form (WebKitWebView* web_view)
|
||||||
WebKitDOMHTMLCollection* form_nodes;
|
WebKitDOMHTMLCollection* form_nodes;
|
||||||
WebKitDOMElement* active_element;
|
WebKitDOMElement* active_element;
|
||||||
gchar* token_element;
|
gchar* token_element;
|
||||||
|
const gchar* title;
|
||||||
GString* uri_str;
|
GString* uri_str;
|
||||||
gulong form_len;
|
gulong form_len;
|
||||||
guint i;
|
guint i;
|
||||||
|
KatzeItem* item;
|
||||||
|
gchar** parts;
|
||||||
|
|
||||||
#if WEBKIT_CHECK_VERSION (1, 9, 5)
|
#if WEBKIT_CHECK_VERSION (1, 9, 5)
|
||||||
doc = webkit_web_frame_get_dom_document (web_view);
|
doc = webkit_web_frame_get_dom_document (web_view);
|
||||||
|
@ -2504,10 +2508,37 @@ midori_view_search_engine_for_form (WebKitWebView* web_view)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
title = webkit_web_view_get_title (web_view);
|
||||||
|
|
||||||
|
item = katze_item_new ();
|
||||||
|
katze_item_set_uri (item, g_string_free (uri_str, FALSE));
|
||||||
|
|
||||||
|
if (strstr (title, " - "))
|
||||||
|
parts = g_strsplit (title, " - ", 2);
|
||||||
|
else if (strstr (title, ": "))
|
||||||
|
parts = g_strsplit (title, ": ", 2);
|
||||||
|
else
|
||||||
|
parts = NULL;
|
||||||
|
if (parts != NULL)
|
||||||
|
{
|
||||||
|
/* See midori_view_set_title: title can be first or last */
|
||||||
|
if (view->ellipsize == PANGO_ELLIPSIZE_END)
|
||||||
|
{
|
||||||
|
katze_item_set_name (item, g_strdup (parts[0]));
|
||||||
|
katze_item_set_text (item, g_strdup (parts[1]));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
katze_item_set_name (item, g_strdup (parts[1]));
|
||||||
|
katze_item_set_text (item, g_strdup (parts[2]));
|
||||||
|
}
|
||||||
|
g_strfreev (parts);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
katze_item_set_name (item, title);
|
||||||
|
|
||||||
g_free (token_element);
|
g_free (token_element);
|
||||||
return g_object_new (KATZE_TYPE_ITEM,
|
return item;
|
||||||
"uri", g_string_free (uri_str, FALSE),
|
|
||||||
"name", webkit_web_view_get_title (web_view), NULL);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -2619,7 +2650,7 @@ midori_view_populate_popup (MidoriView* view,
|
||||||
|
|
||||||
#if WEBKIT_CHECK_VERSION (1, 5, 0)
|
#if WEBKIT_CHECK_VERSION (1, 5, 0)
|
||||||
{
|
{
|
||||||
KatzeItem* item = midori_view_search_engine_for_form (web_view);
|
KatzeItem* item = midori_view_search_engine_for_form (view, web_view);
|
||||||
if (item != NULL)
|
if (item != NULL)
|
||||||
{
|
{
|
||||||
menuitem = midori_view_insert_menu_item (menu_shell, -1,
|
menuitem = midori_view_insert_menu_item (menu_shell, -1,
|
||||||
|
|
Loading…
Reference in a new issue