Rely on sqlite for completion, otherwise disable it entirely

This commit is contained in:
Christian Dywan 2010-01-25 01:19:03 +01:00
parent 726c7c34e0
commit 65c56f26a8
2 changed files with 5 additions and 72 deletions

View file

@ -121,13 +121,6 @@ static void
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,
@ -281,6 +274,7 @@ midori_location_action_create_model (void)
return model;
}
#if HAVE_SQLITE
static void
midori_location_action_popup_position (GtkWidget* popup,
GtkWidget* widget)
@ -342,13 +336,11 @@ midori_location_action_popup_timeout_cb (gpointer data)
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)
@ -357,11 +349,7 @@ midori_location_action_popup_timeout_cb (gpointer data)
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)
@ -370,7 +358,6 @@ midori_location_action_popup_timeout_cb (gpointer data)
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. */
@ -396,7 +383,6 @@ midori_location_action_popup_timeout_cb (gpointer data)
midori_location_action_popdown_completion (action);
return FALSE;
}
#endif
if (G_UNLIKELY (!action->popup))
{
@ -405,13 +391,7 @@ midori_location_action_popup_timeout_cb (gpointer data)
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);
@ -449,7 +429,6 @@ midori_location_action_popup_timeout_cb (gpointer data)
G_CALLBACK (gtk_widget_destroyed), &action->popup);
}
#if HAVE_SQLITE
store = GTK_LIST_STORE (model);
gtk_list_store_clear (store);
@ -468,10 +447,6 @@ midori_location_action_popup_timeout_cb (gpointer data)
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))
@ -495,6 +470,7 @@ midori_location_action_popup_timeout_cb (gpointer data)
return FALSE;
}
#endif
static void
midori_location_action_popup_completion (MidoriLocationAction* action,
@ -507,9 +483,11 @@ 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
@ -1044,15 +1022,8 @@ midori_location_action_preedit_changed_cb (GtkWidget* widget,
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
@ -1210,44 +1181,6 @@ midori_location_entry_render_text_cb (GtkCellLayout* layout,
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

View file

@ -306,7 +306,7 @@ def configure (conf):
print '''
Localization: %(nls)s (intltool)
Icon optimizations: %(icons)s (rsvg-convert)
Persistent history: %(sqlite)s (sqlite3)
History: %(sqlite)s (sqlite3)
Notifications: %(libnotify)s (libnotify)
IDN support: %(idn)s (libidn or libsoup 2.27.90)