Show hidden location/ web search temporarily when needed.
If the location or web search was hidden, and one attempted to use the menus or shortcuts for Location or Web search, an appropriate dialog with an entry was shown. Now we show the according widget temporarily and hide it again once it loses focus.
This commit is contained in:
parent
d9f7abc5c7
commit
7a7499d8db
1 changed files with 54 additions and 78 deletions
|
@ -1064,44 +1064,25 @@ _action_location_activate (GtkAction* action,
|
||||||
{
|
{
|
||||||
MidoriBrowserPrivate* priv = browser->priv;
|
MidoriBrowserPrivate* priv = browser->priv;
|
||||||
|
|
||||||
if (GTK_WIDGET_VISIBLE (priv->navigationbar))
|
if (!GTK_WIDGET_VISIBLE (priv->navigationbar))
|
||||||
gtk_widget_grab_focus (priv->location);
|
gtk_widget_show (priv->navigationbar);
|
||||||
else
|
gtk_widget_grab_focus (priv->location);
|
||||||
{
|
}
|
||||||
// TODO: We should offer all of the location's features here
|
|
||||||
GtkWidget* dialog;
|
static gboolean
|
||||||
dialog = gtk_dialog_new_with_buttons (_("Open location")
|
midori_browser_location_focus_out_event_cb (GtkWidget* widget,
|
||||||
, GTK_WINDOW (browser)
|
GdkEventFocus* event,
|
||||||
, GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR
|
MidoriBrowser* browser)
|
||||||
, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL
|
{
|
||||||
, GTK_STOCK_JUMP_TO, GTK_RESPONSE_ACCEPT
|
MidoriBrowserPrivate* priv = browser->priv;
|
||||||
, NULL);
|
|
||||||
gtk_window_set_icon_name (GTK_WINDOW (dialog), GTK_STOCK_JUMP_TO);
|
gboolean show_navigationbar;
|
||||||
gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
|
g_object_get (priv->settings,
|
||||||
gtk_container_set_border_width (
|
"show-navigationbar", &show_navigationbar,
|
||||||
GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), 5);
|
NULL);
|
||||||
GtkWidget* hbox = gtk_hbox_new (FALSE, 8);
|
if (!show_navigationbar)
|
||||||
gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
|
gtk_widget_hide (priv->navigationbar);
|
||||||
GtkWidget* label = gtk_label_new_with_mnemonic (_("_Location:"));
|
return FALSE;
|
||||||
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
|
|
||||||
GtkWidget* entry = gtk_entry_new ();
|
|
||||||
gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE);
|
|
||||||
gtk_box_pack_start (GTK_BOX (hbox), entry, FALSE, FALSE, 0);
|
|
||||||
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), hbox);
|
|
||||||
gtk_widget_show_all( hbox);
|
|
||||||
gtk_dialog_set_default_response (GTK_DIALOG (dialog),
|
|
||||||
GTK_RESPONSE_ACCEPT);
|
|
||||||
if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
|
|
||||||
{
|
|
||||||
gtk_entry_set_text (GTK_ENTRY (priv->location)
|
|
||||||
, gtk_entry_get_text (GTK_ENTRY (entry)));
|
|
||||||
GdkEventKey event;
|
|
||||||
event.keyval = GDK_Return;
|
|
||||||
midori_browser_location_key_press_event_cb (priv->location,
|
|
||||||
&event, browser);
|
|
||||||
}
|
|
||||||
gtk_widget_destroy (dialog);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -1110,41 +1091,31 @@ _action_search_activate (GtkAction* action,
|
||||||
{
|
{
|
||||||
MidoriBrowserPrivate* priv = browser->priv;
|
MidoriBrowserPrivate* priv = browser->priv;
|
||||||
|
|
||||||
if (GTK_WIDGET_VISIBLE (priv->search)
|
if (!GTK_WIDGET_VISIBLE (priv->search))
|
||||||
&& GTK_WIDGET_VISIBLE (priv->navigationbar))
|
gtk_widget_show (priv->search);
|
||||||
gtk_widget_grab_focus (priv->search);
|
if (!GTK_WIDGET_VISIBLE (priv->navigationbar))
|
||||||
else
|
gtk_widget_show (priv->navigationbar);
|
||||||
{
|
gtk_widget_grab_focus (priv->search);
|
||||||
// TODO: We should offer all of the search's features here
|
}
|
||||||
GtkWidget* dialog = gtk_dialog_new_with_buttons (_("Web search")
|
|
||||||
, GTK_WINDOW (browser)
|
static gboolean
|
||||||
, GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR
|
midori_browser_search_focus_out_event_cb (GtkWidget* widget,
|
||||||
, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL
|
GdkEventFocus* event,
|
||||||
, GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT
|
MidoriBrowser* browser)
|
||||||
, NULL);
|
{
|
||||||
gtk_window_set_icon_name (GTK_WINDOW (dialog), GTK_STOCK_FIND);
|
MidoriBrowserPrivate* priv = browser->priv;
|
||||||
gtk_container_set_border_width(GTK_CONTAINER (dialog), 5);
|
|
||||||
gtk_container_set_border_width (
|
gboolean show_navigationbar;
|
||||||
GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), 5);
|
gboolean show_web_search;
|
||||||
GtkWidget* hbox = gtk_hbox_new (FALSE, 8);
|
g_object_get (priv->settings,
|
||||||
gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
|
"show-navigationbar", &show_navigationbar,
|
||||||
GtkWidget* label = gtk_label_new_with_mnemonic (_("_Location:"));
|
"show-web-search", &show_web_search,
|
||||||
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
|
NULL);
|
||||||
GtkWidget* entry = gtk_entry_new ();
|
if (!show_navigationbar)
|
||||||
gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE);
|
gtk_widget_hide (priv->navigationbar);
|
||||||
gtk_box_pack_start (GTK_BOX (hbox), entry, FALSE, FALSE, 0);
|
if (!show_web_search)
|
||||||
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), hbox);
|
gtk_widget_hide (priv->search);
|
||||||
gtk_widget_show_all (hbox);
|
return FALSE;
|
||||||
gtk_dialog_set_default_response (GTK_DIALOG (dialog),
|
|
||||||
GTK_RESPONSE_ACCEPT);
|
|
||||||
if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
|
|
||||||
{
|
|
||||||
gtk_entry_set_text (GTK_ENTRY (priv->search)
|
|
||||||
, gtk_entry_get_text (GTK_ENTRY (entry)));
|
|
||||||
on_webSearch_activate (priv->search, browser);
|
|
||||||
}
|
|
||||||
gtk_widget_destroy (dialog);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -2369,11 +2340,14 @@ midori_browser_init (MidoriBrowser* browser)
|
||||||
sexy_icon_entry_set_icon (SEXY_ICON_ENTRY (priv->location)
|
sexy_icon_entry_set_icon (SEXY_ICON_ENTRY (priv->location)
|
||||||
, SEXY_ICON_ENTRY_PRIMARY, GTK_IMAGE (priv->location_icon));
|
, SEXY_ICON_ENTRY_PRIMARY, GTK_IMAGE (priv->location_icon));
|
||||||
sexy_icon_entry_add_clear_button (SEXY_ICON_ENTRY (priv->location));
|
sexy_icon_entry_add_clear_button (SEXY_ICON_ENTRY (priv->location));
|
||||||
g_signal_connect (priv->location, "key-press-event",
|
g_object_connect (priv->location,
|
||||||
G_CALLBACK (midori_browser_location_key_press_event_cb),
|
"signal::key-press-event",
|
||||||
browser);
|
midori_browser_location_key_press_event_cb, browser,
|
||||||
g_signal_connect (priv->location, "changed",
|
"signal::focus-out-event",
|
||||||
G_CALLBACK (midori_browser_location_changed_cb), browser);
|
midori_browser_location_focus_out_event_cb, browser,
|
||||||
|
"signal::changed",
|
||||||
|
midori_browser_location_changed_cb, browser,
|
||||||
|
NULL);
|
||||||
GtkToolItem* toolitem = gtk_tool_item_new ();
|
GtkToolItem* toolitem = gtk_tool_item_new ();
|
||||||
gtk_tool_item_set_expand (GTK_TOOL_ITEM (toolitem), TRUE);
|
gtk_tool_item_set_expand (GTK_TOOL_ITEM (toolitem), TRUE);
|
||||||
gtk_container_add (GTK_CONTAINER(toolitem), priv->location);
|
gtk_container_add (GTK_CONTAINER(toolitem), priv->location);
|
||||||
|
@ -2396,6 +2370,8 @@ midori_browser_init (MidoriBrowser* browser)
|
||||||
on_webSearch_scroll, browser,
|
on_webSearch_scroll, browser,
|
||||||
"signal::activate",
|
"signal::activate",
|
||||||
on_webSearch_activate, browser,
|
on_webSearch_activate, browser,
|
||||||
|
"signal::focus-out-event",
|
||||||
|
midori_browser_search_focus_out_event_cb, browser,
|
||||||
NULL);
|
NULL);
|
||||||
toolitem = gtk_tool_item_new ();
|
toolitem = gtk_tool_item_new ();
|
||||||
gtk_container_add (GTK_CONTAINER (toolitem), priv->search);
|
gtk_container_add (GTK_CONTAINER (toolitem), priv->search);
|
||||||
|
|
Loading…
Reference in a new issue