diff --git a/midori/midori-locationaction.c b/midori/midori-locationaction.c index 84f20097..4495a445 100644 --- a/midori/midori-locationaction.c +++ b/midori/midori-locationaction.c @@ -457,7 +457,6 @@ midori_location_action_popup_timeout_cb (gpointer data) style = gtk_widget_get_style (action->treeview); while (result == SQLITE_ROW) { - gchar* unescaped_uri; sqlite3_int64 type = sqlite3_column_int64 (stmt, 0); const unsigned char* uri = sqlite3_column_text (stmt, 1); 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; if (type == 1 /* history_view */) { - unescaped_uri = sokoke_uri_unescape_string ((const char*)uri); - 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); - g_free (unescaped_uri); } else if (type == 2 /* search_view */) { @@ -897,6 +893,48 @@ midori_location_action_key_press_event_cb (GtkEntry* entry, case GDK_Page_Down: if (!(location_action->popup && gtk_widget_get_visible (location_action->popup))) 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_KP_Down: case GDK_Up: @@ -1024,6 +1062,7 @@ midori_location_entry_render_text_cb (GtkCellLayout* layout, gpointer data) { MidoriLocationAction* action = data; + gchar* uri_escaped; gchar* uri; gchar* title; GdkColor* background; @@ -1045,14 +1084,14 @@ midori_location_entry_render_text_cb (GtkCellLayout* layout, gchar** parts; 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); if (style) /* A search engine action */ { g_object_set (renderer, "text", title, "ellipsize-set", TRUE, "ellipsize", PANGO_ELLIPSIZE_END, NULL); - g_free (uri); + g_free (uri_escaped); g_free (title); return; } @@ -1067,6 +1106,9 @@ midori_location_entry_render_text_cb (GtkCellLayout* layout, keys = g_strsplit_set (key, " %", -1); g_free (key); + uri = sokoke_uri_unescape_string (uri_escaped); + g_free (uri_escaped); + if (G_LIKELY (uri)) { temp_iter = temp = g_utf8_strdown (uri, -1);