if (!gtk_widget_has_focus (action->entry))
return FALSE;
+ if (!*action->key)
+ {
+ const gchar* uri = gtk_entry_get_text (GTK_ENTRY (action->entry));
+ #if HAVE_SQLITE
+ katze_assign (action->key, g_strdup (uri));
+ #else
+ katze_assign (action->key, katze_collfold (uri));
+ #endif
+ }
+
+ if (!(action->key && *action->key))
+ return FALSE;
+
if (G_UNLIKELY (!action->popup))
{
GtkWidget* popup;
G_CALLBACK (gtk_widget_destroyed), &action->popup);
}
- if (!*action->key)
- {
- const gchar* uri = gtk_entry_get_text (GTK_ENTRY (action->entry));
- #if HAVE_SQLITE
- katze_assign (action->key, g_strdup (uri));
- #else
- katze_assign (action->key, katze_collfold (uri));
- #endif
- }
-
#if HAVE_SQLITE
store = GTK_LIST_STORE (model);
gtk_list_store_clear (store);
gtk_tree_selection_unselect_all (gtk_tree_view_get_selection (
GTK_TREE_VIEW (location_action->treeview)));
}
- location_action->completion_timeout = 0;
+ if (location_action->completion_timeout)
+ {
+ g_source_remove (location_action->completion_timeout);
+ location_action->completion_timeout = 0;
+ }
location_action->completion_index = -1;
}
katze_assign (location_action->text, g_strdup (gtk_entry_get_text (entry)));
}
+static void
+midori_location_action_move_cursor_cb (GtkEntry* entry,
+ GtkMovementStep step,
+ gint count,
+ gboolean extend_selection,
+ MidoriLocationAction* action)
+{
+ gchar* text = g_strdup (pango_layout_get_text (gtk_entry_get_layout (entry)));
+ /* Update entry with the completed text */
+ gtk_entry_set_text (entry, text);
+ g_free (text);
+ midori_location_action_popdown_completion (action);
+}
+
+static void
+midori_location_action_backspace_cb (GtkWidget* entry,
+ MidoriLocationAction* action)
+{
+ midori_location_action_popup_completion (action, entry, "");
+ action->completion_index = -1;
+}
+
+static void
+midori_location_action_paste_clipboard_cb (GtkWidget* entry,
+ MidoriLocationAction* action)
+{
+ midori_location_action_popup_completion (action, entry, "");
+ action->completion_index = -1;
+}
+
static gboolean
midori_location_action_button_press_event_cb (GtkEntry* entry,
GdkEventKey* event,
if (location_action->popup && GTK_WIDGET_VISIBLE (location_action->popup))
{
midori_location_action_popdown_completion (location_action);
+ text = gtk_entry_get_text (entry);
+ pango_layout_set_text (gtk_entry_get_layout (entry), text, -1);
return TRUE;
}
{
gchar* uri;
gtk_tree_model_get (model, &iter, URI_COL, &uri, -1);
- gtk_entry_set_text (entry, uri);
+ /* Update the layout without actually changing the text */
+ pango_layout_set_text (gtk_entry_get_layout (entry), uri, -1);
g_free (uri);
}
location_action->completion_index = selected;
g_object_connect (child,
"signal::changed",
midori_location_action_changed_cb, action,
+ "signal::move-cursor",
+ midori_location_action_move_cursor_cb, action,
+ "signal::backspace",
+ midori_location_action_backspace_cb, action,
+ "signal::paste-clipboard",
+ midori_location_action_paste_clipboard_cb, action,
"signal::button-press-event",
midori_location_action_button_press_event_cb, action,
"signal::key-press-event",