summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Jonathan Beck2009-10-11 20:56:53 +0200
committerGravatar Martin Szulecki2009-10-12 10:53:58 +0200
commita4d269d09189cad2103ca85d8045c5da9ff06573 (patch)
treeda6809691d61ce02207569b4ba242dca03a4fe00 /src
parentae1f57fd754c14f621ea9c135b3b586b38257b30 (diff)
downloadgnome-plist-editor-a4d269d09189cad2103ca85d8045c5da9ff06573.tar.gz
gnome-plist-editor-a4d269d09189cad2103ca85d8045c5da9ff06573.tar.bz2
Implement delete node.
Diffstat (limited to 'src')
-rw-r--r--src/gnome-plist-editor.c34
-rw-r--r--src/gnome-plist-editor.ui6
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 @@
<object class="GtkWindow" id="main_window">
<property name="title" translatable="yes">Property List Editor</property>
<property name="window_position">center</property>
- <property name="default_width">450</property>
- <property name="default_height">350</property>
+ <property name="default_width">600</property>
+ <property name="default_height">600</property>
<property name="icon_name">text-editor</property>
<signal name="destroy" handler="main_window_destroy_cb"/>
<child>
@@ -264,10 +264,10 @@
<child>
<object class="GtkToolButton" id="delete_item_button">
<property name="visible">True</property>
- <property name="sensitive">False</property>
<property name="label" translatable="yes">Delete Item</property>
<property name="use_underline">True</property>
<property name="icon_name">list-remove</property>
+ <signal name="clicked" handler="remove_child_cb"/>
</object>
<packing>
<property name="expand">False</property>