diff options
-rw-r--r-- | src/gnome-plist-editor.c | 64 | ||||
-rw-r--r-- | src/gnome-plist-editor.ui | 10 |
2 files changed, 61 insertions, 13 deletions
diff --git a/src/gnome-plist-editor.c b/src/gnome-plist-editor.c index d6667ba..32a9418 100644 --- a/src/gnome-plist-editor.c +++ b/src/gnome-plist-editor.c @@ -38,6 +38,13 @@ static struct AppState { gboolean is_binary; } app; +typedef enum { + COL_KEY, + COL_TYPE, + COL_VALUE, + N_COLUMNS +} col_type_t; + void main_window_destroy_cb(GtkWidget* widget, gpointer user_data) { if (app.document_tree_store) gtk_tree_store_clear(app.document_tree_store); @@ -177,6 +184,56 @@ void open_plist_cb(GtkWidget* item, gpointer user_data) { gtk_widget_destroy (dialog); } +void new_plist_cb(GtkWidget* item, gpointer user_data) { + + gtk_tree_store_clear(app.document_tree_store); + + plist_free(app.root_node); + app.root_node = plist_new_dict(); + update_document_tree_view(app.root_node, NULL); + gtk_tree_view_expand_all(app.document_tree_view); +} + +void type_edited_cb(GtkCellRendererText *cell, gchar *path_string, gchar *new_text, gpointer user_data) +{ + plist_t node; + GtkTreeIter iter; + GtkTreePath *path = NULL; + plist_type type = PLIST_NONE; + GtkTreeModel *model = GTK_TREE_MODEL(app.document_tree_store); + + gtk_tree_model_get_iter_from_string(model, &iter, path_string); + path = gtk_tree_path_new_from_string(path_string); + gtk_tree_model_get(model, &iter, 0, &node, -1); + + if (!strcmp(new_text,"Boolean")){ + type = PLIST_BOOLEAN; + } + else if (!strcmp(new_text,"Number")){ + type = PLIST_UINT; + } + else if (!strcmp(new_text,"Float")){ + type = PLIST_REAL; + } + else if (!strcmp(new_text,"String")){ + type = PLIST_STRING; + } + else if (!strcmp(new_text,"Data")){ + type = PLIST_DATA; + } + else if (!strcmp(new_text,"Date")){ + type = PLIST_DATE; + } + else if (!strcmp(new_text,"Array")){ + type = PLIST_ARRAY; + } + else if (!strcmp(new_text,"Dictionary")){ + type = PLIST_DICT; + } + plist_set_type(node, type); + gtk_tree_model_row_changed(model, path, &iter); +} + void about_menu_item_activate_cb(GtkMenuItem* item, gpointer user_data) { gtk_show_about_dialog(app.main_window, "program-name", "GNOME Property List Editor", @@ -187,13 +244,6 @@ void about_menu_item_activate_cb(GtkMenuItem* item, gpointer user_data) { NULL); } -typedef enum { - COL_KEY, - COL_TYPE, - COL_VALUE, - N_COLUMNS -} col_type_t; - void plist_cell_data_function (GtkTreeViewColumn *col, GtkCellRenderer *renderer, GtkTreeModel *model, diff --git a/src/gnome-plist-editor.ui b/src/gnome-plist-editor.ui index e7e125d..e1a7931 100644 --- a/src/gnome-plist-editor.ui +++ b/src/gnome-plist-editor.ui @@ -63,12 +63,12 @@ <object class="GtkMenu" id="menu1"> <property name="visible">True</property> <child> - <object class="GtkImageMenuItem" id="imagemenuitem1"> + <object class="GtkImageMenuItem" id="new_plist_menu_item"> <property name="label">gtk-new</property> <property name="visible">True</property> - <property name="sensitive">False</property> <property name="use_underline">True</property> <property name="use_stock">True</property> + <signal name="activate" handler="new_plist_cb"/> </object> </child> <child> @@ -203,10 +203,10 @@ <child> <object class="GtkToolButton" id="new_plist_button"> <property name="visible">True</property> - <property name="sensitive">False</property> <property name="label" translatable="yes">New</property> <property name="use_underline">True</property> <property name="stock_id">gtk-new</property> + <signal name="clicked" handler="new_plist_cb"/> </object> <packing> <property name="expand">False</property> @@ -317,10 +317,8 @@ <property name="editable">True</property> <property name="model">plist_type_list_store</property> <property name="text_column">0</property> + <signal name="edited" handler="type_edited_cb"/> </object> - <attributes> - <attribute name="has-entry">0</attribute> - </attributes> </child> </object> </child> |