midori_location_action_disconnect_proxy (GtkAction* action,
GtkWidget* proxy);
-#if !HAVE_SQLITE
-static gboolean
-midori_location_action_filter_match_cb (GtkTreeModel* model,
- GtkTreeIter* iter,
- gpointer data);
-#endif
-
static void
midori_location_entry_render_text_cb (GtkCellLayout* layout,
GtkCellRenderer* renderer,
return model;
}
+#if HAVE_SQLITE
static void
midori_location_action_popup_position (GtkWidget* popup,
GtkWidget* widget)
MidoriLocationAction* action = data;
static GtkTreeModel* model = NULL;
GtkTreeViewColumn* column;
- #if HAVE_SQLITE
GtkListStore* store;
sqlite3* db;
gchar* query;
gint result;
sqlite3_stmt* statement;
- #endif
gint matches, height, screen_height;
if (!gtk_widget_has_focus (action->entry) || !action->history)
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)
return FALSE;
}
- #if HAVE_SQLITE
db = g_object_get_data (G_OBJECT (action->history), "db");
/* FIXME: Consider keeping the prepared statement with '...LIKE ?...'
and prepending/ appending % to the key. */
midori_location_action_popdown_completion (action);
return FALSE;
}
- #endif
if (G_UNLIKELY (!action->popup))
{
GtkWidget* treeview;
GtkCellRenderer* renderer;
- #if HAVE_SQLITE
model = midori_location_action_create_model ();
- #else
- model = gtk_tree_model_filter_new (action->model, NULL);
- gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (model),
- midori_location_action_filter_match_cb, action, NULL);
- #endif
action->completion_model = model;
popup = gtk_window_new (GTK_WINDOW_POPUP);
G_CALLBACK (gtk_widget_destroyed), &action->popup);
}
- #if HAVE_SQLITE
store = GTK_LIST_STORE (model);
gtk_list_store_clear (store);
result = sqlite3_step (statement);
}
while (result == SQLITE_ROW);
- #else
- gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (model));
- matches = gtk_tree_model_iter_n_children (model, NULL);
- #endif
/* TODO: Suggest _("Search with %s") or opening hostname as actions */
if (!GTK_WIDGET_VISIBLE (action->popup))
return FALSE;
}
+#endif
static void
midori_location_action_popup_completion (MidoriLocationAction* action,
action->entry = entry;
g_signal_connect (entry, "destroy",
G_CALLBACK (gtk_widget_destroyed), &action->entry);
+ #if HAVE_SQLITE
action->completion_timeout = g_timeout_add (COMPLETION_DELAY,
midori_location_action_popup_timeout_cb, action);
/* TODO: Inline completion */
+ #endif
}
static void
GtkAction* action)
{
MidoriLocationAction* location_action = MIDORI_LOCATION_ACTION (action);
- #if HAVE_SQLITE
midori_location_action_popup_completion (location_action,
GTK_WIDGET (widget), preedit);
- #else
- gchar* key = katze_collfold (preedit);
- midori_location_action_popup_completion (location_action,
- GTK_WIDGET (widget), key);
- g_free (key);
- #endif
}
#endif
g_free (desc);
}
-#if !HAVE_SQLITE
-static gboolean
-midori_location_action_match (GtkTreeModel* model,
- const gchar* key,
- GtkTreeIter* iter,
- gpointer data)
-{
- gchar* uri;
- gchar* title;
- gboolean match;
-
- gtk_tree_model_get (model, iter, URI_COL, &uri, TITLE_COL, &title, -1);
-
- match = FALSE;
- if (G_LIKELY (uri))
- {
- match = katze_utf8_stristr (uri, key);
- g_free (uri);
-
- if (!match && G_LIKELY (title))
- match = katze_utf8_stristr (title, key);
- }
-
- g_free (title);
-
- return match;
-}
-
-static gboolean
-midori_location_action_filter_match_cb (GtkTreeModel* model,
- GtkTreeIter* iter,
- gpointer data)
-{
- MidoriLocationAction* action = data;
- return midori_location_action_match (model, action->key, iter, data);
-}
-#endif
-
/**
* midori_location_action_iter_lookup:
* @location_action: a #MidoriLocationAction