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_show (priv->navigationbar);
|
||||||
gtk_widget_grab_focus (priv->location);
|
gtk_widget_grab_focus (priv->location);
|
||||||
else
|
}
|
||||||
{
|
|
||||||
// TODO: We should offer all of the location's features here
|
static gboolean
|
||||||
GtkWidget* dialog;
|
midori_browser_location_focus_out_event_cb (GtkWidget* widget,
|
||||||
dialog = gtk_dialog_new_with_buttons (_("Open location")
|
GdkEventFocus* event,
|
||||||
, GTK_WINDOW (browser)
|
MidoriBrowser* browser)
|
||||||
, GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR
|
{
|
||||||
, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL
|
MidoriBrowserPrivate* priv = browser->priv;
|
||||||
, GTK_STOCK_JUMP_TO, GTK_RESPONSE_ACCEPT
|
|
||||||
, NULL);
|
gboolean show_navigationbar;
|
||||||
gtk_window_set_icon_name (GTK_WINDOW (dialog), GTK_STOCK_JUMP_TO);
|
g_object_get (priv->settings,
|
||||||
gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
|
"show-navigationbar", &show_navigationbar,
|
||||||
gtk_container_set_border_width (
|
NULL);
|
||||||
GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), 5);
|
if (!show_navigationbar)
|
||||||
GtkWidget* hbox = gtk_hbox_new (FALSE, 8);
|
gtk_widget_hide (priv->navigationbar);
|
||||||
gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
|
return FALSE;
|
||||||
GtkWidget* label = gtk_label_new_with_mnemonic (_("_Location:"));
|
|
||||||
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);
|
||||||
|
if (!GTK_WIDGET_VISIBLE (priv->navigationbar))
|
||||||
|
gtk_widget_show (priv->navigationbar);
|
||||||
gtk_widget_grab_focus (priv->search);
|
gtk_widget_grab_focus (priv->search);
|
||||||
else
|
}
|
||||||
{
|
|
||||||
// TODO: We should offer all of the search's features here
|
static gboolean
|
||||||
GtkWidget* dialog = gtk_dialog_new_with_buttons (_("Web search")
|
midori_browser_search_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_OPEN, GTK_RESPONSE_ACCEPT
|
MidoriBrowserPrivate* priv = browser->priv;
|
||||||
, NULL);
|
|
||||||
gtk_window_set_icon_name (GTK_WINDOW (dialog), GTK_STOCK_FIND);
|
gboolean show_navigationbar;
|
||||||
gtk_container_set_border_width(GTK_CONTAINER (dialog), 5);
|
gboolean show_web_search;
|
||||||
gtk_container_set_border_width (
|
g_object_get (priv->settings,
|
||||||
GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), 5);
|
"show-navigationbar", &show_navigationbar,
|
||||||
GtkWidget* hbox = gtk_hbox_new (FALSE, 8);
|
"show-web-search", &show_web_search,
|
||||||
gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
|
NULL);
|
||||||
GtkWidget* label = gtk_label_new_with_mnemonic (_("_Location:"));
|
if (!show_navigationbar)
|
||||||
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
|
gtk_widget_hide (priv->navigationbar);
|
||||||
GtkWidget* entry = gtk_entry_new ();
|
if (!show_web_search)
|
||||||
gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE);
|
gtk_widget_hide (priv->search);
|
||||||
gtk_box_pack_start (GTK_BOX (hbox), entry, FALSE, FALSE, 0);
|
return FALSE;
|
||||||
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->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