summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Jonathan Beck2009-10-11 15:51:40 +0200
committerGravatar Martin Szulecki2009-10-12 10:53:41 +0200
commite71a537a5b05fadc37ec3fe1161496332a3fe4c5 (patch)
tree22b18c6738dca9f94cc6548023d75e46c5095e95
parentc4ffca78040e71d68bd0a8472374a1f42d94aacd (diff)
downloadgnome-plist-editor-e71a537a5b05fadc37ec3fe1161496332a3fe4c5.tar.gz
gnome-plist-editor-e71a537a5b05fadc37ec3fe1161496332a3fe4c5.tar.bz2
Add new_plist and edit_type callbacks.
-rw-r--r--src/gnome-plist-editor.c64
-rw-r--r--src/gnome-plist-editor.ui10
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>