Delete history from completion with Delete key
This commit is contained in:
parent
f8e5e8f7e0
commit
10fab99090
1 changed files with 49 additions and 7 deletions
|
@ -457,7 +457,6 @@ midori_location_action_popup_timeout_cb (gpointer data)
|
||||||
style = gtk_widget_get_style (action->treeview);
|
style = gtk_widget_get_style (action->treeview);
|
||||||
while (result == SQLITE_ROW)
|
while (result == SQLITE_ROW)
|
||||||
{
|
{
|
||||||
gchar* unescaped_uri;
|
|
||||||
sqlite3_int64 type = sqlite3_column_int64 (stmt, 0);
|
sqlite3_int64 type = sqlite3_column_int64 (stmt, 0);
|
||||||
const unsigned char* uri = sqlite3_column_text (stmt, 1);
|
const unsigned char* uri = sqlite3_column_text (stmt, 1);
|
||||||
const unsigned char* title = sqlite3_column_text (stmt, 2);
|
const unsigned char* title = sqlite3_column_text (stmt, 2);
|
||||||
|
@ -466,12 +465,9 @@ midori_location_action_popup_timeout_cb (gpointer data)
|
||||||
icon = action->default_icon;
|
icon = action->default_icon;
|
||||||
if (type == 1 /* history_view */)
|
if (type == 1 /* history_view */)
|
||||||
{
|
{
|
||||||
unescaped_uri = sokoke_uri_unescape_string ((const char*)uri);
|
|
||||||
|
|
||||||
gtk_list_store_insert_with_values (store, NULL, matches,
|
gtk_list_store_insert_with_values (store, NULL, matches,
|
||||||
URI_COL, unescaped_uri, TITLE_COL, title, YALIGN_COL, 0.25,
|
URI_COL, uri, TITLE_COL, title, YALIGN_COL, 0.25,
|
||||||
FAVICON_COL, icon, -1);
|
FAVICON_COL, icon, -1);
|
||||||
g_free (unescaped_uri);
|
|
||||||
}
|
}
|
||||||
else if (type == 2 /* search_view */)
|
else if (type == 2 /* search_view */)
|
||||||
{
|
{
|
||||||
|
@ -897,6 +893,48 @@ midori_location_action_key_press_event_cb (GtkEntry* entry,
|
||||||
case GDK_Page_Down:
|
case GDK_Page_Down:
|
||||||
if (!(location_action->popup && gtk_widget_get_visible (location_action->popup)))
|
if (!(location_action->popup && gtk_widget_get_visible (location_action->popup)))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
case GDK_Delete:
|
||||||
|
case GDK_KP_Delete:
|
||||||
|
{
|
||||||
|
gint selected = location_action->completion_index;
|
||||||
|
GtkTreeModel* model = location_action->completion_model;
|
||||||
|
GtkTreeIter iter;
|
||||||
|
|
||||||
|
if (selected > -1 &&
|
||||||
|
gtk_tree_model_iter_nth_child (model, &iter, NULL, selected))
|
||||||
|
{
|
||||||
|
gchar* uri;
|
||||||
|
gchar* sqlcmd;
|
||||||
|
sqlite3* db;
|
||||||
|
gchar* errmsg;
|
||||||
|
gint result;
|
||||||
|
|
||||||
|
gtk_tree_model_get (model, &iter, URI_COL, &uri, -1);
|
||||||
|
sqlcmd = sqlite3_mprintf ("DELETE FROM history "
|
||||||
|
"WHERE uri = '%q'", uri);
|
||||||
|
g_free (uri);
|
||||||
|
db = g_object_get_data (G_OBJECT (location_action->history), "db");
|
||||||
|
result = sqlite3_exec (db, sqlcmd, NULL, NULL, &errmsg);
|
||||||
|
sqlite3_free (sqlcmd);
|
||||||
|
if (result == SQLITE_ERROR)
|
||||||
|
{
|
||||||
|
gtk_list_store_set (GTK_LIST_STORE (model), &iter,
|
||||||
|
URI_COL, errmsg, -1);
|
||||||
|
sqlite3_free (errmsg);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (result != SQLITE_OK || sqlite3_changes (db) == 0)
|
||||||
|
break;
|
||||||
|
if (!gtk_list_store_remove (GTK_LIST_STORE (model), &iter))
|
||||||
|
{
|
||||||
|
midori_location_action_popdown_completion (location_action);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
/* Fall through to advance the selection */
|
||||||
|
}
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
case GDK_Down:
|
case GDK_Down:
|
||||||
case GDK_KP_Down:
|
case GDK_KP_Down:
|
||||||
case GDK_Up:
|
case GDK_Up:
|
||||||
|
@ -1024,6 +1062,7 @@ midori_location_entry_render_text_cb (GtkCellLayout* layout,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
MidoriLocationAction* action = data;
|
MidoriLocationAction* action = data;
|
||||||
|
gchar* uri_escaped;
|
||||||
gchar* uri;
|
gchar* uri;
|
||||||
gchar* title;
|
gchar* title;
|
||||||
GdkColor* background;
|
GdkColor* background;
|
||||||
|
@ -1045,14 +1084,14 @@ midori_location_entry_render_text_cb (GtkCellLayout* layout,
|
||||||
gchar** parts;
|
gchar** parts;
|
||||||
size_t offset;
|
size_t offset;
|
||||||
|
|
||||||
gtk_tree_model_get (model, iter, URI_COL, &uri, TITLE_COL, &title,
|
gtk_tree_model_get (model, iter, URI_COL, &uri_escaped, TITLE_COL, &title,
|
||||||
BACKGROUND_COL, &background, STYLE_COL, &style, -1);
|
BACKGROUND_COL, &background, STYLE_COL, &style, -1);
|
||||||
|
|
||||||
if (style) /* A search engine action */
|
if (style) /* A search engine action */
|
||||||
{
|
{
|
||||||
g_object_set (renderer, "text", title,
|
g_object_set (renderer, "text", title,
|
||||||
"ellipsize-set", TRUE, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
|
"ellipsize-set", TRUE, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
|
||||||
g_free (uri);
|
g_free (uri_escaped);
|
||||||
g_free (title);
|
g_free (title);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1067,6 +1106,9 @@ midori_location_entry_render_text_cb (GtkCellLayout* layout,
|
||||||
keys = g_strsplit_set (key, " %", -1);
|
keys = g_strsplit_set (key, " %", -1);
|
||||||
g_free (key);
|
g_free (key);
|
||||||
|
|
||||||
|
uri = sokoke_uri_unescape_string (uri_escaped);
|
||||||
|
g_free (uri_escaped);
|
||||||
|
|
||||||
if (G_LIKELY (uri))
|
if (G_LIKELY (uri))
|
||||||
{
|
{
|
||||||
temp_iter = temp = g_utf8_strdown (uri, -1);
|
temp_iter = temp = g_utf8_strdown (uri, -1);
|
||||||
|
|
Loading…
Reference in a new issue