From a4d269d09189cad2103ca85d8045c5da9ff06573 Mon Sep 17 00:00:00 2001 From: Jonathan Beck Date: Sun, 11 Oct 2009 20:56:53 +0200 Subject: Implement delete node. --- src/gnome-plist-editor.c | 34 ++++++++++++++++++++++++++++++++++ src/gnome-plist-editor.ui | 6 +++--- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/src/gnome-plist-editor.c b/src/gnome-plist-editor.c index 9a730d1..6badefb 100644 --- a/src/gnome-plist-editor.c +++ b/src/gnome-plist-editor.c @@ -243,6 +243,40 @@ void add_child_cb(GtkWidget* item, gpointer user_data) { } } +void remove_child_cb(GtkWidget* item, gpointer user_data) { + + GtkTreeSelection *selection; + GtkTreeModel *model; + GtkTreeView *view = GTK_TREE_VIEW(app.document_tree_view); + GtkTreeIter iter; + plist_t parent = NULL; + + selection = gtk_tree_view_get_selection(view); + if (gtk_tree_selection_get_selected(selection, &model, &iter)) { + plist_t node = NULL; + gtk_tree_model_get (model, &iter, 0, &node, -1); + parent = plist_get_parent(node); + + if (parent) { + plist_type type = plist_get_node_type(parent); + + if (type == PLIST_ARRAY) { + plist_array_remove_item(parent, plist_array_get_item_index(node)); + } + else if (type == PLIST_DICT) { + char* key = NULL; + plist_dict_get_item_key(node, &key); + plist_dict_remove_item(parent, key); + free(key); + } + + //update tree model + gtk_tree_store_remove(app.document_tree_store, &iter); + } + } +} + + void type_edited_cb(GtkCellRendererText *cell, gchar *path_string, gchar *new_text, gpointer user_data) { plist_t node; diff --git a/src/gnome-plist-editor.ui b/src/gnome-plist-editor.ui index 92cea0b..bc28a39 100644 --- a/src/gnome-plist-editor.ui +++ b/src/gnome-plist-editor.ui @@ -43,8 +43,8 @@ Property List Editor center - 450 - 350 + 600 + 600 text-editor @@ -264,10 +264,10 @@ True - False Delete Item True list-remove + False -- cgit v1.1-32-gdbae