From e71a537a5b05fadc37ec3fe1161496332a3fe4c5 Mon Sep 17 00:00:00 2001
From: Jonathan Beck
Date: Sun, 11 Oct 2009 15:51:40 +0200
Subject: Add new_plist and edit_type callbacks.
---
src/gnome-plist-editor.c | 64 +++++++++++++++++++++++++++++++++++++++++------
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 @@
-
- 0
-
--
cgit v1.1-32-gdbae