katze_throbber_set_animated (KATZE_THROBBER (browser->throbber), loading);
action = _action_by_name (browser, "Location");
- if (browser->news_aggregator && *browser->news_aggregator
- && g_object_get_data (G_OBJECT (view), "news-feeds"))
+ if (g_object_get_data (G_OBJECT (view), "news-feeds"))
midori_location_action_set_secondary_icon (
MIDORI_LOCATION_ACTION (action), STOCK_NEWS_FEED);
else
midori_location_action_set_secondary_icon (
- MIDORI_LOCATION_ACTION (action), NULL);
+ MIDORI_LOCATION_ACTION (action), GTK_STOCK_JUMP_TO);
}
static void
midori_location_action_set_uri (
MIDORI_LOCATION_ACTION (action), uri);
midori_location_action_set_secondary_icon (
- MIDORI_LOCATION_ACTION (action), NULL);
+ MIDORI_LOCATION_ACTION (action), GTK_STOCK_JUMP_TO);
g_object_notify (G_OBJECT (browser), "uri");
}
}
}
+static void
+_action_location_focus_in (GtkAction* action,
+ MidoriBrowser* browser)
+{
+ midori_location_action_set_secondary_icon (
+ MIDORI_LOCATION_ACTION (action), GTK_STOCK_JUMP_TO);
+}
+
static void
_action_location_focus_out (GtkAction* action,
MidoriBrowser* browser)
{
+ GtkWidget* view = midori_browser_get_current_tab (browser);
+
if (!browser->show_navigationbar)
gtk_widget_hide (browser->navigationbar);
+
+ if (g_object_get_data (G_OBJECT (view), "news-feeds"))
+ midori_location_action_set_secondary_icon (
+ MIDORI_LOCATION_ACTION (action), STOCK_NEWS_FEED);
+ else
+ midori_location_action_set_secondary_icon (
+ MIDORI_LOCATION_ACTION (action), GTK_STOCK_JUMP_TO);
}
static void
if ((view = midori_browser_get_current_tab (browser)))
{
const gchar* uri = midori_view_get_display_uri (MIDORI_VIEW (view));
- if (browser->news_aggregator && *browser->news_aggregator)
+ if (gtk_window_get_focus (GTK_WINDOW (browser)) == widget)
+ _action_location_submit_uri (action, uri, FALSE, browser);
+ else if (g_object_get_data (G_OBJECT (view), "news-feeds"))
sokoke_spawn_program (browser->news_aggregator, uri, TRUE);
+ else
+ _action_location_submit_uri (action, uri, FALSE, browser);
}
}
_action_location_activate, browser,
"signal::active-changed",
_action_location_active_changed, browser,
+ "signal::focus-in",
+ _action_location_focus_in, browser,
"signal::focus-out",
_action_location_focus_out, browser,
"signal::reset-uri",
enum
{
ACTIVE_CHANGED,
+ FOCUS_IN,
FOCUS_OUT,
SECONDARY_ICON_RELEASED,
RESET_URI,
G_TYPE_NONE, 1,
G_TYPE_INT);
+ /**
+ * MidoriLocationAction:focus-in:
+ *
+ * The focus-in signal is emitted when the entry obtains the focus.
+ *
+ * Since 0.1.8
+ */
+ signals[FOCUS_IN] = g_signal_new ("focus-in",
+ G_TYPE_FROM_CLASS (class),
+ (GSignalFlags) (G_SIGNAL_RUN_LAST),
+ 0,
+ 0,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
signals[FOCUS_OUT] = g_signal_new ("focus-out",
G_TYPE_FROM_CLASS (class),
(GSignalFlags) (G_SIGNAL_RUN_LAST),
midori_location_action_entry_for_proxy (GtkWidget* proxy)
{
GtkWidget* alignment = gtk_bin_get_child (GTK_BIN (proxy));
- GtkWidget* hbox = gtk_bin_get_child (GTK_BIN (alignment));
- GList* children = gtk_container_get_children (GTK_CONTAINER (hbox));
- GtkWidget* entry = g_list_nth_data (children, 0);
- g_list_free (children);
+ GtkWidget* entry = gtk_bin_get_child (GTK_BIN (alignment));
return entry;
}
GTK_ACTION_CLASS (midori_location_action_parent_class)->activate (action);
}
-static void
-midori_location_action_go_clicked_cb (GtkWidget* button,
- GtkAction* action)
-{
- GtkWidget* hbox = gtk_widget_get_parent (button);
- GList* children = gtk_container_get_children (GTK_CONTAINER (hbox));
- GtkWidget* location_entry = g_list_nth_data (children, 0);
- g_list_free (children);
- GtkWidget* entry = gtk_bin_get_child (GTK_BIN (location_entry));
- const gchar* uri = gtk_entry_get_text (GTK_ENTRY (entry));
- if (uri && *uri)
- g_signal_emit (action, signals[SUBMIT_URI], 0, uri, FALSE);
-}
-
static GtkWidget*
midori_location_action_create_tool_item (GtkAction* action)
{
GtkWidget* toolitem;
GtkWidget* alignment;
- GtkWidget* hbox;
GtkWidget* location_entry;
- GtkWidget* go_button;
- GtkWidget* go_icon;
toolitem = GTK_WIDGET (gtk_tool_item_new ());
gtk_tool_item_set_expand (GTK_TOOL_ITEM (toolitem), TRUE);
alignment = gtk_alignment_new (0.0f, 0.5f, 1.0f, 0.1f);
gtk_widget_show (alignment);
gtk_container_add (GTK_CONTAINER (toolitem), alignment);
- hbox = gtk_hbox_new (FALSE, 0);
- gtk_widget_show (hbox);
- gtk_container_add (GTK_CONTAINER (alignment), hbox);
location_entry = midori_location_entry_new ();
gtk_widget_show (location_entry);
- gtk_box_pack_start (GTK_BOX (hbox), location_entry, TRUE, TRUE, 0);
- go_button = gtk_button_new ();
- gtk_button_set_focus_on_click (GTK_BUTTON (go_button), FALSE);
- gtk_button_set_relief (GTK_BUTTON (go_button), GTK_RELIEF_NONE);
- go_icon = gtk_image_new_from_stock (GTK_STOCK_JUMP_TO, GTK_ICON_SIZE_MENU);
- gtk_button_set_image (GTK_BUTTON (go_button), go_icon);
- gtk_widget_show (go_button);
- gtk_box_pack_start (GTK_BOX (hbox), go_button, FALSE, FALSE, 0);
- g_signal_connect (go_button, "clicked",
- G_CALLBACK (midori_location_action_go_clicked_cb), action);
+ gtk_container_add (GTK_CONTAINER (alignment), location_entry);
return toolitem;
}
return FALSE;
}
+static gboolean
+midori_location_action_focus_in_event_cb (GtkWidget* widget,
+ GdkEventKey* event,
+ GtkAction* action)
+{
+ g_signal_emit (action, signals[FOCUS_IN], 0);
+ return FALSE;
+}
+
static gboolean
midori_location_action_focus_out_event_cb (GtkWidget* widget,
GdkEventKey* event,
g_object_connect (gtk_bin_get_child (GTK_BIN (entry)),
"signal::key-press-event",
midori_location_action_key_press_event_cb, action,
+ "signal::focus-in-event",
+ midori_location_action_focus_in_event_cb, action,
"signal::focus-out-event",
midori_location_action_focus_out_event_cb, action,
"signal::icon-release",