]> saetta.ns0.it Git - zakconfi/gui/commitdiff
Editing keys.
authorAndrea Zagli <azagli@libero.it>
Wed, 28 Sep 2016 19:43:51 +0000 (21:43 +0200)
committerAndrea Zagli <azagli@libero.it>
Wed, 28 Sep 2016 19:43:51 +0000 (21:43 +0200)
src/main.c

index 5cad691d649680688df145e81d09b1b060fbb60c..1a75d96341835f71fb007cfd47ba9a42af7e3b76 100644 (file)
@@ -977,6 +977,7 @@ on_mnuKeysEdit_activate (GtkMenuItem *menuitem,
                                                                           &error);
 
                                        GtkWidget *diag = GTK_WIDGET (gtk_builder_get_object (glaMain, "wKey"));
+
                                        GtkWidget *txtConfig = GTK_WIDGET (gtk_builder_get_object (glaMain, "txtConfig"));
                                        GtkWidget *txtParent = GTK_WIDGET (gtk_builder_get_object (glaMain, "txtParent"));
                                        GtkWidget *txtName = GTK_WIDGET (gtk_builder_get_object (glaMain, "txtName1"));
@@ -986,62 +987,44 @@ on_mnuKeysEdit_activate (GtkMenuItem *menuitem,
 
                                        ZakConfiKey *ck;
 
-                                       GtkTreeIter iterConfi;
-                                       GtkTreeIter iterParent;
-
-                                       if (gtk_tree_model_get_iter (GTK_TREE_MODEL (storeFolders), &iterConfi,
-                                                                    gtk_tree_path_new_from_indices (gtk_tree_path_get_indices (path)[0], -1)))
-                                               {
-                                                       gchar *name;
-
-                                                       gtk_tree_model_get (GTK_TREE_MODEL (storeFolders), &iterConfi,
-                                                                           -1);
-
-                                                       g_object_get (G_OBJECT (confi),
-                                                                     "name", &name,
-                                                                     NULL);
-
-                                                       gtk_entry_set_text (GTK_ENTRY (txtConfig), name);
-                                               }
+                                       ck = g_new0 (ZakConfiKey, 1);
 
                                        gtk_tree_model_get (GTK_TREE_MODEL (storeFolders), &iter,
+                                                                               FOLDERS_COL_CONFIG, &ck->config,
+                                                                               FOLDERS_COL_PATH, &ck->path,
+                                                                               FOLDERS_COL_KEY, &ck->key,
+                                                                               FOLDERS_COL_VALUE, &ck->value,
+                                                                               FOLDERS_COL_DESCRIPTION, &ck->description,
                                                            -1);
 
-                                       if (ck != NULL)
+                                       gtk_entry_set_text (GTK_ENTRY (txtConfig), ck->config);
+                                       gtk_entry_set_text (GTK_ENTRY (txtParent), ck->path);
+                                       gtk_entry_set_text (GTK_ENTRY (txtName), ck->key);
+                                       gtk_entry_set_text (GTK_ENTRY (txtValue), ck->value);
+                                       gtk_text_buffer_set_text (buffer, ck->description, strlen (ck->description));
+
+                                       if (gtk_dialog_run (GTK_DIALOG (diag)) == GTK_RESPONSE_OK)
                                                {
-                                                       gtk_entry_set_text (GTK_ENTRY (txtName), ck->key);
-                                                       gtk_entry_set_text (GTK_ENTRY (txtValue), ck->value);
-                                                       gtk_text_buffer_set_text (buffer, ck->description, strlen (ck->description));
+                                                       GtkTextIter iter1;
+                                                       GtkTextIter iter2;
 
-                                                       if (g_strcmp0 (ck->path, "") != 0
-                                                               && gtk_tree_model_iter_parent (GTK_TREE_MODEL (storeFolders), &iterParent, &iter))
-                                                               {
-                                                                       ZakConfiKey *ckParent;
+                                                       ck->key = g_strdup (gtk_entry_get_text (GTK_ENTRY (txtName)));
+                                                       ck->value = g_strdup (gtk_entry_get_text (GTK_ENTRY (txtValue)));
 
-                                                                       gtk_tree_model_get (GTK_TREE_MODEL (storeFolders), &iterParent,
-                                                                                           -1);
+                                                       gtk_text_buffer_get_bounds (buffer, &iter1, &iter2);
+                                                       ck->description = gtk_text_buffer_get_text (buffer, &iter1, &iter2, FALSE);
 
-                                                                       gtk_entry_set_text (GTK_ENTRY (txtParent), ckParent->key);
-                                                               }
+                                                       confi = zak_confi_new (g_strdup_printf ("%s;CONFI_NAME=%s", cnc_string, ck->config));
 
-                                                       if (gtk_dialog_run (GTK_DIALOG (diag)) == GTK_RESPONSE_OK)
+                                                       if (confi != NULL)
                                                                {
-                                                                       GtkTextIter iter1;
-                                                                       GtkTextIter iter2;
-
-                                                                       ck->key = g_strdup (gtk_entry_get_text (GTK_ENTRY (txtName)));
-                                                                       ck->value = g_strdup (gtk_entry_get_text (GTK_ENTRY (txtValue)));
-
-                                                                       gtk_text_buffer_get_bounds (buffer, &iter1, &iter2);
-                                                                       ck->description = gtk_text_buffer_get_text (buffer, &iter1, &iter2, FALSE);
-
                                                                        zak_confi_key_set_key (confi, ck);
 
                                                                        gtk_tree_store_set (storeFolders, &iter,
-                                                                                           FOLDERS_COL_KEY, ck->key,
-                                                                                           FOLDERS_COL_VALUE, ck->value,
-                                                                                           FOLDERS_COL_DESCRIPTION, ck->description,
-                                                                                           -1);
+                                                                                                               FOLDERS_COL_KEY, ck->key,
+                                                                                                               FOLDERS_COL_VALUE, ck->value,
+                                                                                                               FOLDERS_COL_DESCRIPTION, ck->description,
+                                                                                                               -1);
                                                                }
                                                }