]> spindle.queued.net Git - midori/commitdiff
Implement 'Edit' in adblock to activate the cell in the list
authorChristian Dywan <christian@twotoasts.de>
Fri, 20 Nov 2009 19:53:41 +0000 (20:53 +0100)
committerChristian Dywan <christian@twotoasts.de>
Sat, 21 Nov 2009 01:35:15 +0000 (02:35 +0100)
extensions/adblock.c

index 83f5b8dca6e79df33444e7d51f4140d75b74e27f..ea0f78388036d701fec00e45844c4b280454cb50 100644 (file)
@@ -306,6 +306,26 @@ adblock_preferences_add_clicked_cb (GtkWidget*    button,
     gtk_entry_set_text (entry, "");
 }
 
+static void
+adblock_preferences_edit_clicked_cb (GtkWidget*         button,
+                                     GtkTreeViewColumn* column)
+{
+    GdkEvent* event = gtk_get_current_event ();
+    GtkTreeView* treeview = g_object_get_data (G_OBJECT (button), "treeview");
+    GtkTreeModel* model;
+    GtkTreeIter iter;
+    if (katze_tree_view_get_selected_iter (treeview, &model, &iter))
+    {
+        gchar* path = gtk_tree_model_get_string_from_iter (model, &iter);
+        GtkTreePath* tree_path = gtk_tree_path_new_from_string (path);
+        /* gtk_cell_renderer_start_editing */
+        gtk_tree_view_set_cursor (treeview, tree_path, column, TRUE);
+        gtk_tree_path_free (tree_path);
+        g_free (path);
+    }
+    gdk_event_free (event);
+}
+
 static void
 adblock_preferences_remove_clicked_cb (GtkWidget*   button,
                                        GtkTreeView* treeview)
@@ -458,8 +478,10 @@ adblock_get_preferences_dialog (MidoriExtension* extension)
         G_CALLBACK (adblock_preferences_add_clicked_cb), liststore);
     gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
     button = gtk_button_new_from_stock (GTK_STOCK_EDIT);
+    g_object_set_data (G_OBJECT (button), "treeview", treeview);
+    g_signal_connect (button, "clicked",
+        G_CALLBACK (adblock_preferences_edit_clicked_cb), column);
     gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
-    gtk_widget_set_sensitive (button, FALSE);
     button = gtk_button_new_from_stock (GTK_STOCK_REMOVE);
     g_signal_connect (button, "clicked",
         G_CALLBACK (adblock_preferences_remove_clicked_cb), treeview);