guint page_num,
MidoriBrowser* browser)
{
- GtkWidget* view;
+ GtkWidget* widget;
+ GtkAction* action;
+ const gchar* text;
+
+ if (!(widget = midori_browser_get_current_tab (browser)))
+ return;
+
+ action = _action_by_name (browser, "Location");
+ text = midori_location_action_get_text (MIDORI_LOCATION_ACTION (action));
+ g_object_set_data_full (G_OBJECT (widget), "midori-browser-typed-text",
+ g_strdup (text), g_free);
+}
+
+static void
+gtk_notebook_switch_page_after_cb (GtkWidget* notebook,
+ GtkNotebookPage* page,
+ guint page_num,
+ MidoriBrowser* browser)
+{
+ GtkWidget* widget;
+ MidoriView* view;
const gchar* uri;
GtkAction* action;
const gchar* title;
gchar* window_title;
- if (!(view = midori_browser_get_current_tab (browser)))
+ if (!(widget = midori_browser_get_current_tab (browser)))
return;
- uri = midori_view_get_display_uri (MIDORI_VIEW (view));
+ view = MIDORI_VIEW (widget);
+ uri = g_object_get_data (G_OBJECT (widget), "midori-browser-typed-text");
+ if (!uri)
+ uri = midori_view_get_display_uri (view);
action = _action_by_name (browser, "Location");
- midori_location_action_set_uri (MIDORI_LOCATION_ACTION (action), uri);
+ midori_location_action_set_text (MIDORI_LOCATION_ACTION (action), uri);
midori_location_action_set_icon (MIDORI_LOCATION_ACTION (action),
- midori_view_get_icon (MIDORI_VIEW (view)));
+ midori_view_get_icon (view));
- title = midori_view_get_display_title (MIDORI_VIEW (view));
+ title = midori_view_get_display_title (view);
window_title = g_strconcat (title, " - ", g_get_application_name (), NULL);
gtk_window_set_title (GTK_WINDOW (browser), window_title);
g_free (window_title);
_midori_browser_set_statusbar_text (browser, NULL);
_midori_browser_update_interface (browser);
- _midori_browser_update_progress (browser, MIDORI_VIEW (view));
+ _midori_browser_update_progress (browser, view);
}
static void
g_object_unref (rcstyle);
gtk_notebook_set_scrollable (GTK_NOTEBOOK (browser->notebook), TRUE);
gtk_paned_pack2 (GTK_PANED (vpaned), browser->notebook, FALSE, FALSE);
+ g_signal_connect (browser->notebook, "switch-page",
+ G_CALLBACK (gtk_notebook_switch_page_cb),
+ browser);
g_signal_connect_after (browser->notebook, "switch-page",
- G_CALLBACK (gtk_notebook_switch_page_cb),
+ G_CALLBACK (gtk_notebook_switch_page_after_cb),
browser);
g_signal_connect (browser->notebook, "page-reordered",
G_CALLBACK (midori_browser_notebook_page_reordered_cb),
{
GtkAction parent_instance;
+ gchar* text;
gchar* uri;
KatzeArray* search_engines;
gdouble progress;
static void
midori_location_action_init (MidoriLocationAction* location_action)
{
- location_action->uri = NULL;
+ location_action->text = location_action->uri = NULL;
location_action->search_engines = NULL;
location_action->progress = 0.0;
location_action->secondary_icon = NULL;
{
MidoriLocationAction* location_action = MIDORI_LOCATION_ACTION (object);
+ katze_assign (location_action->text, NULL);
katze_assign (location_action->uri, NULL);
katze_assign (location_action->search_engines, NULL);
return toolitem;
}
+static void
+midori_location_action_changed_cb (GtkEntry* entry,
+ MidoriLocationAction* location_action)
+{
+ katze_assign (location_action->text, g_strdup (gtk_entry_get_text (entry)));
+}
+
static gboolean
-midori_location_action_key_press_event_cb (GtkWidget* widget,
+midori_location_action_key_press_event_cb (GtkEntry* entry,
GdkEventKey* event,
GtkAction* action)
{
case GDK_KP_Enter:
case GDK_Return:
{
- if ((uri = gtk_entry_get_text (GTK_ENTRY (widget))) && *uri)
+ if ((uri = gtk_entry_get_text (entry)) && *uri)
{
g_signal_emit (action, signals[SUBMIT_URI], 0, uri,
(event->state & GDK_MOD1_MASK) ? TRUE : FALSE);
static gboolean
midori_location_action_focus_in_event_cb (GtkWidget* widget,
- GdkEventKey* event,
- GtkAction* action)
+ GdkEventKey* event,
+ GtkAction* action)
{
g_signal_emit (action, signals[FOCUS_IN], 0);
return FALSE;
gchar* uri;
gtk_tree_model_get (model, iter, URI_COL, &uri, -1);
- midori_location_action_set_uri (location_action, uri);
+ midori_location_action_set_text (location_action, uri);
g_signal_emit (location_action, signals[SUBMIT_URI], 0, uri, FALSE);
g_free (uri);
if (!item)
return;
search = sokoke_search_uri (uri, keywords);
- midori_location_action_set_uri (location_action, search);
+ midori_location_action_set_text (location_action, search);
g_signal_emit (location_action, signals[SUBMIT_URI], 0, search, FALSE);
g_free (search);
}
gtk_icon_entry_set_icon_from_pixbuf (GTK_ICON_ENTRY (entry),
GTK_ICON_ENTRY_PRIMARY, pixbuf);
g_object_unref (pixbuf);
+ katze_assign (location_action->text, uri);
katze_assign (location_action->uri, uri);
g_signal_emit (location_action, signals[ACTIVE_CHANGED], 0,
G_CALLBACK (midori_location_action_entry_changed_cb), action);
g_object_connect (gtk_bin_get_child (GTK_BIN (entry)),
+ "signal::changed",
+ midori_location_action_changed_cb, action,
"signal::key-press-event",
midori_location_action_key_press_event_cb, action,
"signal::focus-in-event",
(action, proxy);
}
+/**
+ * midori_location_action_get_uri:
+ * @location_action: a #MidoriLocationAction
+ *
+ * Retrieves the current URI. See also midori_location_action_get_text().
+ *
+ * Return value: the current URI
+ **/
const gchar*
midori_location_action_get_uri (MidoriLocationAction* location_action)
{
return location_action->uri;
}
+/**
+ * midori_location_action_get_text:
+ * @location_action: a #MidoriLocationAction
+ *
+ * Retrieves the current text, which may be the current URI or
+ * anything typed in the entry.
+ *
+ * Return value: the current text
+ *
+ * Since: 0.2.0
+ **/
+const gchar*
+midori_location_action_get_text (MidoriLocationAction* location_action)
+{
+ g_return_val_if_fail (MIDORI_IS_LOCATION_ACTION (location_action), NULL);
+
+ return location_action->text;
+}
+
/**
* midori_location_action_set_text:
* @location_action: a #MidoriLocationAction
* @text: a string
*
* Sets the entry text to @text and, if applicable, updates the icon.
+ *
+ * Since: 0.2.0
**/
-static void
+void
midori_location_action_set_text (MidoriLocationAction* location_action,
const gchar* text)
{
GtkTreeIter iter;
GdkPixbuf* icon;
+ g_return_if_fail (MIDORI_IS_LOCATION_ACTION (location_action));
+ g_return_if_fail (text != NULL);
+
+ katze_assign (location_action->text, g_strdup (text));
+
if (!(proxies = gtk_action_get_proxies (GTK_ACTION (location_action))))
return;
if (midori_location_action_iter_lookup (location_action, text, &iter))
+ {
gtk_tree_model_get (location_action->model,
&iter, FAVICON_COL, &icon, -1);
+ katze_assign (location_action->uri, g_strdup (text));
+ }
else
icon = g_object_ref (location_action->default_icon);
g_object_unref (icon);
}
+/**
+ * midori_location_action_set_uri:
+ * @location_action: a #MidoriLocationAction
+ * @uri: an URI string
+ *
+ * Sets the entry URI to @uri and, if applicable, updates the icon.
+ *
+ * Deprecated: 0.2.0
+ **/
void
midori_location_action_set_uri (MidoriLocationAction* location_action,
const gchar* uri)