Split location and search entry
Fixes: https://bugs.launchpad.net/midori/+bug/738422
This commit is contained in:
parent
524a4bb0a7
commit
ccd0562d7d
2 changed files with 114 additions and 3 deletions
|
@ -19,6 +19,7 @@
|
||||||
#include "midori-panel.h"
|
#include "midori-panel.h"
|
||||||
#include "midori-locationaction.h"
|
#include "midori-locationaction.h"
|
||||||
#include "midori-searchaction.h"
|
#include "midori-searchaction.h"
|
||||||
|
#include "midori-panedaction.h"
|
||||||
#include "midori-findbar.h"
|
#include "midori-findbar.h"
|
||||||
#include "midori-transferbar.h"
|
#include "midori-transferbar.h"
|
||||||
#include "midori-platform.h"
|
#include "midori-platform.h"
|
||||||
|
@ -2717,6 +2718,20 @@ _midori_browser_save_toolbar_items (MidoriBrowser* browser)
|
||||||
g_free (items);
|
g_free (items);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_midori_browser_save_search_item (MidoriBrowser* browser)
|
||||||
|
{
|
||||||
|
MidoriPanedAction* paned_action = MIDORI_PANED_ACTION (_action_by_name (browser, "LocationSearch"));
|
||||||
|
GtkWidget* search = midori_paned_action_get_child_by_name (paned_action, "Search");
|
||||||
|
GtkAllocation allocation;
|
||||||
|
MidoriWebSettings* settings = browser->settings;
|
||||||
|
if (!search)
|
||||||
|
return;
|
||||||
|
|
||||||
|
gtk_widget_get_allocation (search, &allocation);
|
||||||
|
g_object_set (settings, "search-width", allocation.width, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* midori_browser_get_toolbar_actions:
|
* midori_browser_get_toolbar_actions:
|
||||||
*
|
*
|
||||||
|
@ -5523,6 +5538,8 @@ midori_browser_destroy_cb (MidoriBrowser* browser)
|
||||||
if (G_UNLIKELY (browser->alloc_timeout))
|
if (G_UNLIKELY (browser->alloc_timeout))
|
||||||
g_source_remove (browser->alloc_timeout);
|
g_source_remove (browser->alloc_timeout);
|
||||||
|
|
||||||
|
_midori_browser_save_search_item (browser);
|
||||||
|
|
||||||
/* Destroy panel first, so panels don't need special care */
|
/* Destroy panel first, so panels don't need special care */
|
||||||
gtk_widget_destroy (browser->panel);
|
gtk_widget_destroy (browser->panel);
|
||||||
/* Destroy tabs second, so child widgets don't need special care */
|
/* Destroy tabs second, so child widgets don't need special care */
|
||||||
|
@ -5953,6 +5970,12 @@ midori_browser_init (MidoriBrowser* browser)
|
||||||
action, "<Ctrl>K");
|
action, "<Ctrl>K");
|
||||||
g_object_unref (action);
|
g_object_unref (action);
|
||||||
|
|
||||||
|
action = g_object_new (MIDORI_TYPE_PANED_ACTION,
|
||||||
|
"name", "LocationSearch",
|
||||||
|
NULL);
|
||||||
|
gtk_action_group_add_action (browser->action_group, action);
|
||||||
|
g_object_unref (action);
|
||||||
|
|
||||||
action = g_object_new (KATZE_TYPE_ARRAY_ACTION,
|
action = g_object_new (KATZE_TYPE_ARRAY_ACTION,
|
||||||
"name", "Trash",
|
"name", "Trash",
|
||||||
"stock-id", STOCK_USER_TRASH,
|
"stock-id", STOCK_USER_TRASH,
|
||||||
|
@ -6377,18 +6400,73 @@ _midori_browser_set_toolbar_items (MidoriBrowser* browser,
|
||||||
gchar** name;
|
gchar** name;
|
||||||
GtkAction* action;
|
GtkAction* action;
|
||||||
GtkWidget* toolitem;
|
GtkWidget* toolitem;
|
||||||
|
const char* token_location = g_intern_static_string ("Location");
|
||||||
|
const char* token_search = g_intern_static_string ("Search");
|
||||||
|
const char* token_dontcare = g_intern_static_string ("Dontcare");
|
||||||
|
const char* token_current = token_dontcare;
|
||||||
|
const char* token_last = token_dontcare;
|
||||||
|
|
||||||
gtk_container_foreach (GTK_CONTAINER (browser->navigationbar),
|
gtk_container_foreach (GTK_CONTAINER (browser->navigationbar),
|
||||||
(GtkCallback)gtk_widget_destroy, NULL);
|
(GtkCallback)gtk_widget_destroy, NULL);
|
||||||
|
|
||||||
names = g_strsplit (items ? items : "", ",", 0);
|
names = g_strsplit (items ? items : "", ",", 0);
|
||||||
name = names;
|
name = names;
|
||||||
while (*name)
|
for (; *name; ++name)
|
||||||
{
|
{
|
||||||
action = _action_by_name (browser, *name);
|
action = _action_by_name (browser, *name);
|
||||||
if (action)
|
if (action)
|
||||||
{
|
{
|
||||||
|
token_last = token_current;
|
||||||
|
|
||||||
|
/* Decide, what kind of token (item) we got now */
|
||||||
|
if (name && !g_strcmp0 (*name, "Location"))
|
||||||
|
token_current = token_location;
|
||||||
|
else if (name && !g_strcmp0 (*name, "Search"))
|
||||||
|
token_current = token_search;
|
||||||
|
else
|
||||||
|
token_current = token_dontcare;
|
||||||
|
|
||||||
|
if ((token_current == token_location || token_current == token_search) &&
|
||||||
|
(token_last == token_location || token_last == token_search))
|
||||||
|
{
|
||||||
|
GtkWidget* toolitem_first = gtk_action_create_tool_item (
|
||||||
|
_action_by_name (browser, token_last));
|
||||||
|
GtkWidget* toolitem_second = gtk_action_create_tool_item (
|
||||||
|
_action_by_name (browser, token_current));
|
||||||
|
MidoriPanedAction* paned_action = MIDORI_PANED_ACTION (
|
||||||
|
_action_by_name (browser, "LocationSearch"));
|
||||||
|
MidoriWebSettings* midori_settings = browser->settings;
|
||||||
|
midori_paned_action_set_child1 (paned_action, toolitem_first, token_last,
|
||||||
|
token_last == token_search ? FALSE : TRUE, TRUE);
|
||||||
|
midori_paned_action_set_child2 (paned_action, toolitem_second, token_current,
|
||||||
|
token_current == token_search ? FALSE : TRUE, TRUE);
|
||||||
|
|
||||||
|
gtk_widget_set_size_request (
|
||||||
|
token_last == token_search ? toolitem_first : toolitem_second,
|
||||||
|
katze_object_get_int ((gpointer) midori_settings,
|
||||||
|
"search-width"),
|
||||||
|
-1);
|
||||||
|
|
||||||
|
toolitem = gtk_action_create_tool_item (GTK_ACTION (paned_action));
|
||||||
|
token_current = token_dontcare;
|
||||||
|
token_last = token_dontcare;
|
||||||
|
}
|
||||||
|
else if (token_current == token_dontcare && token_last != token_dontcare)
|
||||||
|
{
|
||||||
|
/* There was a location or search item, but was not followed by
|
||||||
|
the other one, that form a couple */
|
||||||
|
gtk_toolbar_insert (GTK_TOOLBAR (browser->navigationbar),
|
||||||
|
GTK_TOOL_ITEM (gtk_action_create_tool_item (
|
||||||
|
_action_by_name (browser, token_last))),
|
||||||
|
-1);
|
||||||
|
|
||||||
toolitem = gtk_action_create_tool_item (action);
|
toolitem = gtk_action_create_tool_item (action);
|
||||||
|
}
|
||||||
|
else if (token_current != token_dontcare && token_last == token_dontcare)
|
||||||
|
continue;
|
||||||
|
else
|
||||||
|
toolitem = gtk_action_create_tool_item (action);
|
||||||
|
|
||||||
if (gtk_bin_get_child (GTK_BIN (toolitem)))
|
if (gtk_bin_get_child (GTK_BIN (toolitem)))
|
||||||
g_signal_connect (gtk_bin_get_child (GTK_BIN (toolitem)),
|
g_signal_connect (gtk_bin_get_child (GTK_BIN (toolitem)),
|
||||||
"button-press-event",
|
"button-press-event",
|
||||||
|
@ -6405,9 +6483,17 @@ _midori_browser_set_toolbar_items (MidoriBrowser* browser,
|
||||||
gtk_toolbar_insert (GTK_TOOLBAR (browser->navigationbar),
|
gtk_toolbar_insert (GTK_TOOLBAR (browser->navigationbar),
|
||||||
GTK_TOOL_ITEM (toolitem), -1);
|
GTK_TOOL_ITEM (toolitem), -1);
|
||||||
}
|
}
|
||||||
name++;
|
|
||||||
}
|
}
|
||||||
g_strfreev (names);
|
g_strfreev (names);
|
||||||
|
|
||||||
|
/* There was a last item, which could have formed a couple, but
|
||||||
|
there is no item left, we add that last item to toolbar as is */
|
||||||
|
if (token_current != token_dontcare)
|
||||||
|
{
|
||||||
|
gtk_toolbar_insert (GTK_TOOLBAR (browser->navigationbar),
|
||||||
|
GTK_TOOL_ITEM (gtk_action_create_tool_item (
|
||||||
|
_action_by_name (browser, token_current))), -1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -67,6 +67,7 @@ struct _MidoriWebSettings
|
||||||
gint last_web_search;
|
gint last_web_search;
|
||||||
gint maximum_cookie_age;
|
gint maximum_cookie_age;
|
||||||
gint maximum_history_age;
|
gint maximum_history_age;
|
||||||
|
gint search_width;
|
||||||
|
|
||||||
gchar* toolbar_items;
|
gchar* toolbar_items;
|
||||||
gchar* homepage;
|
gchar* homepage;
|
||||||
|
@ -176,6 +177,8 @@ enum
|
||||||
PROP_STRIP_REFERER,
|
PROP_STRIP_REFERER,
|
||||||
PROP_ENFORCE_FONT_FAMILY,
|
PROP_ENFORCE_FONT_FAMILY,
|
||||||
PROP_USER_STYLESHEET_URI,
|
PROP_USER_STYLESHEET_URI,
|
||||||
|
|
||||||
|
PROP_SEARCH_WIDTH,
|
||||||
};
|
};
|
||||||
|
|
||||||
GType
|
GType
|
||||||
|
@ -1077,6 +1080,22 @@ midori_web_settings_class_init (MidoriWebSettingsClass* class)
|
||||||
"Load stylesheets from a local URI",
|
"Load stylesheets from a local URI",
|
||||||
NULL,
|
NULL,
|
||||||
flags));
|
flags));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MidoriWebSettings:search-entry-width:
|
||||||
|
*
|
||||||
|
* Search action width in pixels
|
||||||
|
*
|
||||||
|
* Since: 0.4.3
|
||||||
|
**/
|
||||||
|
g_object_class_install_property (gobject_class,
|
||||||
|
PROP_SEARCH_WIDTH,
|
||||||
|
g_param_spec_int (
|
||||||
|
"search-width",
|
||||||
|
"Search action width",
|
||||||
|
"Search action width in pixels",
|
||||||
|
10, G_MAXINT, 200,
|
||||||
|
flags));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -1565,6 +1584,9 @@ midori_web_settings_set_property (GObject* object,
|
||||||
midori_web_settings_process_stylesheets (web_settings, new_len - old_len);
|
midori_web_settings_process_stylesheets (web_settings, new_len - old_len);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case PROP_SEARCH_WIDTH:
|
||||||
|
web_settings->search_width = g_value_get_int (value);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
|
@ -1830,6 +1852,9 @@ midori_web_settings_get_property (GObject* object,
|
||||||
g_value_take_string (value, katze_object_get_string (web_settings,
|
g_value_take_string (value, katze_object_get_string (web_settings,
|
||||||
"WebKitWebSettings::user-stylesheet-uri"));
|
"WebKitWebSettings::user-stylesheet-uri"));
|
||||||
break;
|
break;
|
||||||
|
case PROP_SEARCH_WIDTH:
|
||||||
|
g_value_set_int (value, web_settings->search_width);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue