Implement adding and removing of adblock URIs

This commit is contained in:
Christian Dywan 2009-07-17 22:05:20 +02:00
parent 746b17e49e
commit cc326885bc

View file

@ -69,6 +69,33 @@ adblock_preferences_model_row_changed_cb (GtkTreeModel* model,
midori_extension_set_string_list (extension, "filters", filters, length); midori_extension_set_string_list (extension, "filters", filters, length);
} }
static void
adblock_preferences_model_row_deleted_cb (GtkTreeModel* model,
GtkTreePath* path,
MidoriExtension* extension)
{
GtkTreeIter iter;
adblock_preferences_model_row_changed_cb (model, path, &iter, extension);
}
static void
adblock_preferences_add_clicked_cb (GtkWidget* button,
GtkTreeModel* model)
{
gtk_list_store_insert_with_values (GTK_LIST_STORE (model),
NULL, 0, 0, "", -1);
}
static void
adblock_preferences_remove_clicked_cb (GtkWidget* button,
GtkTreeView* treeview)
{
GtkTreeModel* model;
GtkTreeIter iter;
if (katze_tree_view_get_selected_iter (treeview, &model, &iter))
gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
}
static GtkWidget* static GtkWidget*
adblock_get_preferences_dialog (MidoriExtension* extension) adblock_get_preferences_dialog (MidoriExtension* extension)
{ {
@ -122,8 +149,14 @@ adblock_get_preferences_dialog (MidoriExtension* extension)
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), hbox, gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), hbox,
TRUE, TRUE, 12); TRUE, TRUE, 12);
liststore = gtk_list_store_new (1, G_TYPE_STRING); liststore = gtk_list_store_new (1, G_TYPE_STRING);
g_signal_connect (liststore, "row-changed", g_object_connect (liststore,
G_CALLBACK (adblock_preferences_model_row_changed_cb), extension); "signal::row-inserted",
adblock_preferences_model_row_changed_cb, extension,
"signal::row-changed",
adblock_preferences_model_row_changed_cb, extension,
"signal::row-deleted",
adblock_preferences_model_row_deleted_cb, extension,
NULL);
treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (liststore)); treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (liststore));
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), FALSE); gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), FALSE);
column = gtk_tree_view_column_new (); column = gtk_tree_view_column_new ();
@ -159,18 +192,16 @@ adblock_get_preferences_dialog (MidoriExtension* extension)
vbox = gtk_vbox_new (FALSE, 4); vbox = gtk_vbox_new (FALSE, 4);
gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 4); gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 4);
button = gtk_button_new_from_stock (GTK_STOCK_ADD); button = gtk_button_new_from_stock (GTK_STOCK_ADD);
/* g_signal_connect (button, "clicked", g_signal_connect (button, "clicked",
G_CALLBACK (adblock_preferences_add_cb), extension); */ G_CALLBACK (adblock_preferences_add_clicked_cb), liststore);
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); 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_EDIT); button = gtk_button_new_from_stock (GTK_STOCK_EDIT);
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
gtk_widget_set_sensitive (button, FALSE); gtk_widget_set_sensitive (button, FALSE);
button = gtk_button_new_from_stock (GTK_STOCK_REMOVE); button = gtk_button_new_from_stock (GTK_STOCK_REMOVE);
/* g_signal_connect (button, "clicked", g_signal_connect (button, "clicked",
G_CALLBACK (adblock_preferences_remove_cb), extension); */ G_CALLBACK (adblock_preferences_remove_clicked_cb), treeview);
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
gtk_widget_set_sensitive (button, FALSE);
button = gtk_label_new (""); /* This is an invisible separator */ button = gtk_label_new (""); /* This is an invisible separator */
gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 8); gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 8);
gtk_widget_set_sensitive (button, FALSE); gtk_widget_set_sensitive (button, FALSE);