]> saetta.ns0.it Git - zakconfi/gui/commitdiff
First build after refactoring from libpeas usage.
authorAndrea Zagli <azagli@libero.it>
Mon, 26 Sep 2016 14:22:37 +0000 (16:22 +0200)
committerAndrea Zagli <azagli@libero.it>
Mon, 26 Sep 2016 14:22:37 +0000 (16:22 +0200)
data/zak-confi-gui/ui/zak-confi-gui.ui
src/main.c

index a47849ad289c7dd0e7a2c15f226160ba6748ec6e..095f20a811ac88a6903516801dfdebe33b36b84f 100644 (file)
               <object class="GtkMenuItem" id="mnuDb">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="label" translatable="yes">_Database</property>
+                <property name="label" translatable="yes">_ZakConfi</property>
                 <property name="use_underline">True</property>
                 <child type="submenu">
                   <object class="GtkMenu" id="mnuDb_menu">
                     <property name="can_focus">False</property>
-                    <child>
-                      <object class="GtkImageMenuItem" id="mnuDbNew">
-                        <property name="label">gtk-new</property>
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="use_underline">True</property>
-                        <property name="use_stock">True</property>
-                        <property name="accel_group">accelgroup1</property>
-                        <signal name="activate" handler="on_mnuDbNew_activate" swapped="no"/>
-                      </object>
-                    </child>
                     <child>
                       <object class="GtkImageMenuItem" id="mnuDbOpen">
                         <property name="label">gtk-open</property>
                         <signal name="activate" handler="on_mnuConfigsNew_activate" swapped="no"/>
                       </object>
                     </child>
-                    <child>
-                      <object class="GtkMenuItem" id="mnuConfigsNewFromSchema">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="label" translatable="yes">New from _schema</property>
-                        <property name="use_underline">True</property>
-                        <signal name="activate" handler="on_mnuConfigsNewFromSchema_activate" swapped="no"/>
-                      </object>
-                    </child>
                     <child>
                       <object class="GtkImageMenuItem" id="mnuConfigsEdit">
                         <property name="label">gtk-edit</property>
                         <signal name="activate" handler="on_mnuKeysNew_activate" swapped="no"/>
                       </object>
                     </child>
-                    <child>
-                      <object class="GtkMenuItem" id="mnuKeysNewFromSchema">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="label" translatable="yes">New from _schema</property>
-                        <property name="use_underline">True</property>
-                        <signal name="activate" handler="on_mnuKeysNewFromSchema_activate" swapped="no"/>
-                      </object>
-                    </child>
                     <child>
                       <object class="GtkImageMenuItem" id="mnuKeysEdit">
                         <property name="label">gtk-edit</property>
       </object>
     </child>
   </object>
-  <object class="GtkDialog" id="diagNewDbCfg">
-    <property name="visible">True</property>
-    <property name="can_focus">False</property>
-    <property name="title" translatable="yes">New - ZakConfiGUI</property>
-    <property name="modal">True</property>
-    <property name="window_position">center-on-parent</property>
-    <property name="default_width">300</property>
-    <property name="type_hint">dialog</property>
-    <property name="transient_for">wMain</property>
-    <property name="attached_to">wMain</property>
-    <signal name="response" handler="gtk_widget_hide" swapped="no"/>
-    <child internal-child="vbox">
-      <object class="GtkBox" id="vbox2">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="margin_left">5</property>
-        <property name="margin_right">5</property>
-        <property name="margin_top">5</property>
-        <property name="margin_bottom">5</property>
-        <property name="orientation">vertical</property>
-        <child internal-child="action_area">
-          <object class="GtkButtonBox" id="hbuttonbox1">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="layout_style">end</property>
-            <child>
-              <object class="GtkButton" id="button1">
-                <property name="label">gtk-cancel</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="receives_default">False</property>
-                <property name="use_stock">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkButton" id="button2">
-                <property name="label">gtk-ok</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="receives_default">False</property>
-                <property name="use_stock">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="pack_type">end</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkGrid" id="table4">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="border_width">3</property>
-            <property name="row_spacing">3</property>
-            <property name="column_spacing">3</property>
-            <child>
-              <object class="GtkLabel" id="label13">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="halign">start</property>
-                <property name="label" translatable="yes">1° Connection String</property>
-              </object>
-              <packing>
-                <property name="left_attach">0</property>
-                <property name="top_attach">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkEntry" id="txtCncString1">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="hexpand">True</property>
-                <property name="primary_icon_activatable">False</property>
-                <property name="secondary_icon_activatable">False</property>
-              </object>
-              <packing>
-                <property name="left_attach">1</property>
-                <property name="top_attach">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkEntry" id="txtDbName">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="primary_icon_activatable">False</property>
-                <property name="secondary_icon_activatable">False</property>
-              </object>
-              <packing>
-                <property name="left_attach">1</property>
-                <property name="top_attach">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkEntry" id="txtCncString2">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="primary_icon_activatable">False</property>
-                <property name="secondary_icon_activatable">False</property>
-              </object>
-              <packing>
-                <property name="left_attach">1</property>
-                <property name="top_attach">2</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel" id="label14">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="halign">start</property>
-                <property name="label" translatable="yes">Database Name</property>
-              </object>
-              <packing>
-                <property name="left_attach">0</property>
-                <property name="top_attach">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel" id="label16">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="halign">start</property>
-                <property name="label" translatable="yes">2° Connection String</property>
-              </object>
-              <packing>
-                <property name="left_attach">0</property>
-                <property name="top_attach">2</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">True</property>
-            <property name="fill">True</property>
-            <property name="position">2</property>
-          </packing>
-        </child>
-      </object>
-    </child>
-    <action-widgets>
-      <action-widget response="-6">button1</action-widget>
-      <action-widget response="-5">button2</action-widget>
-    </action-widgets>
-  </object>
   <object class="GtkDialog" id="diagOpenDbCfg">
     <property name="visible">True</property>
     <property name="can_focus">False</property>
index d8c4134a76b67c09aca04a96a288f519b865f779..a0079004d85d7a1f7f3173a7aace3c28cd324419 100644 (file)
@@ -25,7 +25,6 @@
 #include <glib/gprintf.h>
 
 #include <gtk/gtk.h>
-#include <libgdaex/libgdaex.h>
 #include <libxml/tree.h>
 #include <libxml/xinclude.h>
 #include <libxml/xpath.h>
 
 enum
 {
-       FOLDERS_COL_ID,
-       FOLDERS_COL_NAME,
+       FOLDERS_COL_CONFIG,
+       FOLDERS_COL_PATH,
+       FOLDERS_COL_KEY,
        FOLDERS_COL_VALUE,
        FOLDERS_COL_DESCRIPTION,
-       FOLDERS_COL_OBJPTR,
        FOLDERS_COLS
 };
 
@@ -58,6 +57,8 @@ static GtkTreeStore *storeFolders;
 
 static GtkTreeSelection *selFolders;
 
+static ZakConfi *confi;
+
 static gchar *cnc_string;
 static gchar *filter;
 
@@ -76,7 +77,8 @@ create_trFolders ()
        GtkTreeViewColumn *column;
 
        storeFolders = gtk_tree_store_new (FOLDERS_COLS,
-                                          G_TYPE_INT,
+                                          G_TYPE_STRING,
+                                          G_TYPE_STRING,
                                           G_TYPE_STRING,
                                           G_TYPE_STRING,
                                           G_TYPE_STRING,
@@ -85,9 +87,9 @@ create_trFolders ()
        gtk_tree_view_set_model (GTK_TREE_VIEW (trFolders), GTK_TREE_MODEL (storeFolders));
 
        renderer = gtk_cell_renderer_text_new ();
-       column = gtk_tree_view_column_new_with_attributes ("Name",
+       column = gtk_tree_view_column_new_with_attributes ("Key",
                                                      renderer,
-                                                     "text", FOLDERS_COL_NAME,
+                                                     "text", FOLDERS_COL_KEY,
                                                      NULL);
        gtk_tree_view_column_set_resizable (column, TRUE);
        gtk_tree_view_append_column (GTK_TREE_VIEW (trFolders), column);
@@ -110,7 +112,7 @@ create_trFolders ()
 
        selFolders = gtk_tree_view_get_selection (GTK_TREE_VIEW (trFolders));
 
-       gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (storeFolders), FOLDERS_COL_NAME, GTK_SORT_ASCENDING);
+       gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (storeFolders), FOLDERS_COL_KEY, GTK_SORT_ASCENDING);
 }
 
 static void
@@ -128,11 +130,9 @@ fill_trFolders_Keys (GNode *node, GtkTreeIter parent)
 
                        gtk_tree_store_append (storeFolders, &child, &parent);
                        gtk_tree_store_set (storeFolders, &child,
-                                           FOLDERS_COL_ID, ck->id,
-                                           FOLDERS_COL_NAME, ck->key,
+                                           FOLDERS_COL_KEY, ck->key,
                                            FOLDERS_COL_DESCRIPTION, ck->description,
                                            FOLDERS_COL_VALUE, ck->value,
-                                           FOLDERS_COL_OBJPTR, ck,
                                            -1);
 
                        fill_trFolders_Keys (node, child);
@@ -142,40 +142,29 @@ fill_trFolders_Keys (GNode *node, GtkTreeIter parent)
 }
 
 static gboolean
-fill_trFolders (const gchar *cnc_string, const gchar *filter)
+fill_trFolders (const gchar *filter)
 {
        gboolean ret = FALSE;
 
-       GList *lstConfigs = zak_confi_get_configs_list (cnc_string, filter);
+       GList *lstConfigs = zak_confi_get_configs_list (confi, filter);
 
        gtk_tree_store_clear (storeFolders);
 
        if (lstConfigs != NULL)
                {
                        GtkTreeIter iter;
-                       ZakConfi *confi;
-                       gint id;
-                       gchar *name;
-                       gchar *description;
+                       ZakConfiConfi *conficonfi;
                        GNode *tree;
 
                        lstConfigs = g_list_first (lstConfigs);
-                       while (lstConfigs && ZAK_IS_CONFI (lstConfigs->data))
+                       while (lstConfigs != NULL && lstConfigs->data != NULL)
                                {
-                                       confi = (ZakConfi *)lstConfigs->data;
-
-                                       g_object_get (G_OBJECT (confi),
-                                                     "id_config", &id,
-                                                     "name", &name,
-                                                     "description", &description,
-                                                     NULL);
+                                       conficonfi = (ZakConfiConfi *)lstConfigs->data;
 
                                        gtk_tree_store_append (storeFolders, &iter, NULL);
                                        gtk_tree_store_set (storeFolders, &iter,
-                                                           FOLDERS_COL_ID, id,
-                                                           FOLDERS_COL_NAME, name,
-                                                           FOLDERS_COL_DESCRIPTION, description,
-                                                           FOLDERS_COL_OBJPTR, confi,
+                                                           FOLDERS_COL_KEY, conficonfi->name,
+                                                           FOLDERS_COL_DESCRIPTION, conficonfi->description,
                                                            -1);
 
                                        tree = zak_confi_get_tree (confi);
@@ -349,11 +338,9 @@ create_key_from_xml (ZakConfi *confi,
 
                                        gtk_tree_store_append (storeFolders, &iter, iterParent);
                                        gtk_tree_store_set (storeFolders, &iter,
-                                                           FOLDERS_COL_ID, ck->id,
-                                                           FOLDERS_COL_NAME, ck->key,
+                                                           FOLDERS_COL_KEY, ck->key,
                                                            FOLDERS_COL_VALUE, ck->value,
                                                            FOLDERS_COL_DESCRIPTION, ck->description,
-                                                           FOLDERS_COL_OBJPTR, ck,
                                                            -1);
 
                                        xpresult = xmlXPathEvalExpression ((const xmlChar *)"child::gconfi-key", xpcontext);
@@ -417,10 +404,8 @@ create_config_from_xml (xmlNode *xnode, xmlXPathContextPtr xpcontext)
 
                                                        gtk_tree_store_append (storeFolders, &iter, NULL);
                                                        gtk_tree_store_set (storeFolders, &iter,
-                                                                           FOLDERS_COL_ID, id,
-                                                                           FOLDERS_COL_NAME, name,
+                                                                           FOLDERS_COL_KEY, name,
                                                                            FOLDERS_COL_DESCRIPTION, description,
-                                                                           FOLDERS_COL_OBJPTR, confi,
                                                                            -1);
 
                                                        xpresult = xmlXPathEvalExpression ((const xmlChar *)"child::gconfi-key", xpcontext);
@@ -490,7 +475,6 @@ load_xml_configuration_schema (const gchar *filename)
                                                                                                                        ZakConfi *confi;
 
                                                                                                                        gtk_tree_model_get (GTK_TREE_MODEL (storeFolders), &iter,
-                                                                                                                                           FOLDERS_COL_OBJPTR, &confi,
                                                                                                                                            -1);
 
                                                                                                                        create_key_from_xml (confi, "", &iter, xnode, xpcontext);
@@ -506,11 +490,9 @@ load_xml_configuration_schema (const gchar *filename)
                                                                                                                                        ZakConfiKey *ck;
 
                                                                                                                                        gtk_tree_model_get (GTK_TREE_MODEL (storeFolders), &iterConfi,
-                                                                                                                                                           FOLDERS_COL_OBJPTR, &confi,
                                                                                                                                                            -1);
 
                                                                                                                                        gtk_tree_model_get (GTK_TREE_MODEL (storeFolders), &iter,
-                                                                                                                                                           FOLDERS_COL_OBJPTR, &ck,
                                                                                                                                                            -1);
 
                                                                                                                                        if (ZAK_IS_CONFI (confi))
@@ -544,134 +526,6 @@ load_xml_configuration_schema (const gchar *filename)
 }
 
 /* CALLBACKS */
-G_MODULE_EXPORT void
-on_mnuDbNew_activate (GtkMenuItem *menuitem,
-                      gpointer user_data)
-{
-       GError *error = NULL;
-       gtk_builder_add_objects_from_file (glaMain,
-                                          UIDIR "/zak-confi-gui.ui",
-                                          g_strsplit_set ("diagNewDbCfg", "|", -1),
-                                          &error);
-
-       GtkWidget *diag = GTK_WIDGET (gtk_builder_get_object (glaMain, "diagNewDbCfg"));
-
-       GtkWidget *txtCncString1 = GTK_WIDGET (gtk_builder_get_object (glaMain, "txtCncString1"));
-       GtkWidget *txtDbName = GTK_WIDGET (gtk_builder_get_object (glaMain, "txtDbName"));
-       GtkWidget *txtCncString2 = GTK_WIDGET (gtk_builder_get_object (glaMain, "txtCncString2"));
-
-       if (gtk_dialog_run (GTK_DIALOG (diag)) == GTK_RESPONSE_OK)
-               {
-                       cnc_string = g_strstrip (g_strdup (gtk_entry_get_text (GTK_ENTRY (txtCncString1))));
-                       gchar *dbName = g_strstrip (g_strdup (gtk_entry_get_text (GTK_ENTRY (txtDbName))));
-                       if (strcmp (cnc_string, "") != 0)
-                               {
-                                       GdaEx *gdao = gdaex_new_from_string (cnc_string);
-                                       if (gdao != NULL)
-                                               {
-                                                       GdaConnection *gdaConn = (GdaConnection *)gdaex_get_gdaconnection (gdao);
-                                                       if (gdaConn == NULL)
-                                                               {
-                                                                       /* TO DO */
-                                                                       g_fprintf (stderr,"error on first connection\n");
-                                                               }
-                                                       else
-                                                               {
-                                                                       if (strcmp (dbName, "") != 0)
-                                                                               {
-                                                                                       cnc_string = g_strstrip (g_strdup (gtk_entry_get_text (GTK_ENTRY (txtCncString2))));
-                                                                                       if (strcmp (cnc_string, "") != 0)
-                                                                                               {
-                                                                                                       GError *error;
-                                                                                                       GdaServerOperation *op =  gda_server_operation_prepare_create_database (gda_connection_get_provider_name (gdaConn), dbName, &error);
-                                                                                                       if (op == NULL || error != NULL)
-                                                                                                               {
-                                                                                                                       /* TO DO */
-                                                                                                                       g_fprintf(stderr,"error on database creation\n%s",
-                                                                                                                                 error != NULL && error->message != NULL ? error->message : "no details");
-                                                                                                                       gdao = NULL;
-                                                                                                               }
-                                                                                                       else
-                                                                                                               {
-                                                                                                                       gda_connection_close (gdaConn);
-                                                                                                                       gdao = gdaex_new_from_string (cnc_string);
-                                                                                                                       if (gdao == NULL)
-                                                                                                                               {
-                                                                                                                                       /* TO DO */
-                                                                                                                                       g_fprintf(stderr,"error on second connection\n");
-                                                                                                                                       gdao = NULL;
-                                                                                                                               }
-                                                                                                               }
-                                                                                               }
-                                                                                       else
-                                                                                               {
-                                                                                                       /* TO DO */
-                                                                                                       g_fprintf(stderr,"second connection must be specified\n");
-                                                                                                       gdao = NULL;
-                                                                                               }
-                                                                               }
-
-                                                                       if (gdao != NULL)
-                                                                               {
-                                                                                       if (gdaex_execute (gdao, "CREATE TABLE configs "
-                                                                                                           "("
-                                                                                                           " id integer NOT NULL, "
-                                                                                                           " name varchar(100) DEFAULT '', "
-                                                                                                           " description varchar(255) DEFAULT '', "
-                                                                                                           " CONSTRAINT configs_pkey PRIMARY KEY (id), "
-                                                                                                           " CONSTRAINT name_unique UNIQUE (name)"
-                                                                                                           ")") == -1)
-                                                                                               {
-                                                                                                       /* TO DO */
-                                                                                                       gdao = NULL;
-                                                                                               }
-                                                                                       else
-                                                                                               {
-                                                                                                       gchar chrquot = '\"';
-                                                                                                       gchar *sql;
-
-                                                                                                       sql = g_strdup_printf ("CREATE TABLE %cvalues%c "
-                                                                                                                               "("
-                                                                                                                               " id_configs integer NOT NULL, "
-                                                                                                                               " id integer NOT NULL, "
-                                                                                                                               " id_parent integer, "
-                                                                                                                               " %ckey%c varchar(50) DEFAULT '', "
-                                                                                                                               " value text DEFAULT '', "
-                                                                                                                               " description varchar(255) DEFAULT '', "
-                                                                                                                               " CONSTRAINT values_pkey PRIMARY KEY (id_configs, id), "
-                                                                                                                               " CONSTRAINT values_name_unique UNIQUE (id_configs, id_parent, %ckey%c)"
-                                                                                                                               ")",
-                                                                                                                               chrquot, chrquot, chrquot, chrquot, chrquot, chrquot);
-
-                                                                                                       if (gdaex_execute (gdao, sql) == -1)
-                                                                                                               {
-                                                                                                                       /* TO DO */
-                                                                                                                       gdao = NULL;
-                                                                                                               }
-                                                                                                       else
-                                                                                                               {
-                                                                                                                       if (fill_trFolders (cnc_string, NULL))
-                                                                                                                               {
-                                                                                                                                       gtk_widget_set_sensitive (mnuDbClose, TRUE);
-                                                                                                                                       gtk_widget_set_sensitive (mnuDbRefresh, TRUE);
-                                                                                                                                       gtk_widget_set_sensitive (mnuConfigs, TRUE);
-                                                                                                                                       gtk_widget_set_sensitive (mnuKeys, TRUE);
-
-                                                                                                                                       gtk_statusbar_pop (GTK_STATUSBAR (stbar), 0);
-                                                                                                                                       gtk_statusbar_push (GTK_STATUSBAR (stbar), 0,
-                                                                                                                                                           g_strconcat ("Connection string: ", cnc_string, NULL));
-                                                                                                                               }
-                                                                                                               }
-                                                                                               }
-                                                                               }
-                                                               }
-                                               }
-                               }
-               }
-
-       gtk_widget_destroy (diag);
-}
-
 G_MODULE_EXPORT void
 on_mnuDbOpen_activate (GtkMenuItem *menuitem,
                        gpointer user_data)
@@ -693,7 +547,11 @@ on_mnuDbOpen_activate (GtkMenuItem *menuitem,
                        if (cnc_string != NULL)
                                {
                                        filter = (gchar *)gtk_entry_get_text (GTK_ENTRY (txtConfigsFilter));
-                                       if (fill_trFolders (cnc_string, filter))
+
+                                       confi = zak_confi_new (cnc_string);
+
+                                       if (confi != NULL
+                                               && fill_trFolders (filter))
                                                {
                                                        gtk_widget_set_sensitive (mnuDbClose, TRUE);
                                                        gtk_widget_set_sensitive (mnuDbRefresh, TRUE);
@@ -714,6 +572,9 @@ G_MODULE_EXPORT void
 on_mnuDbClose_activate (GtkMenuItem *menuitem,
                         gpointer user_data)
 {
+       g_object_unref (confi);
+       confi = NULL;
+
        cnc_string = g_strdup ("");
 
        /* TO DO */
@@ -733,7 +594,7 @@ G_MODULE_EXPORT void
 on_mnuDbRefresh_activate (GtkMenuItem *menuitem,
                           gpointer user_data)
 {
-       fill_trFolders (cnc_string, filter);
+       fill_trFolders (filter);
 }
 
 G_MODULE_EXPORT void
@@ -783,10 +644,8 @@ on_mnuConfigsNew_activate (GtkMenuItem *menuitem,
 
                                        gtk_tree_store_append (storeFolders, &iter, NULL);
                                        gtk_tree_store_set (storeFolders, &iter,
-                                                           FOLDERS_COL_ID, id,
-                                                           FOLDERS_COL_NAME, name,
+                                                           FOLDERS_COL_KEY, name,
                                                            FOLDERS_COL_DESCRIPTION, description,
-                                                           FOLDERS_COL_OBJPTR, confi,
                                                            -1);
                                }
                }
@@ -794,26 +653,6 @@ on_mnuConfigsNew_activate (GtkMenuItem *menuitem,
        gtk_widget_destroy (diag);
 }
 
-G_MODULE_EXPORT void
-on_mnuConfigsNewFromSchema_activate (GtkMenuItem *menuitem,
-                                     gpointer user_data)
-{
-       GtkWidget *diag = gtk_file_chooser_dialog_new ("Choose a schema file - gConfi",
-                                                      GTK_WINDOW (w),
-                                                      GTK_FILE_CHOOSER_ACTION_OPEN,
-                                                      GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
-                                                      GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
-                                                      NULL);
-
-       if (gtk_dialog_run (GTK_DIALOG (diag)) == GTK_RESPONSE_ACCEPT)
-               {
-                       const gchar *filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (diag));
-                       load_xml_configuration_schema (filename);
-               }
-
-       gtk_widget_destroy (diag);
-}
-
 G_MODULE_EXPORT void
 on_mnuConfigsEdit_activate (GtkMenuItem *menuitem,
                             gpointer user_data)
@@ -844,7 +683,6 @@ on_mnuConfigsEdit_activate (GtkMenuItem *menuitem,
                                        gchar *description;
 
                                        gtk_tree_model_get (GTK_TREE_MODEL (storeFolders), &iter,
-                                                           FOLDERS_COL_OBJPTR, &confi,
                                                            -1);
 
                                        g_object_get (G_OBJECT (confi),
@@ -871,9 +709,8 @@ on_mnuConfigsEdit_activate (GtkMenuItem *menuitem,
                                                                      NULL);
 
                                                        gtk_tree_store_set (storeFolders, &iter,
-                                                                           FOLDERS_COL_NAME, name,
+                                                                           FOLDERS_COL_KEY, name,
                                                                            FOLDERS_COL_DESCRIPTION, description,
-                                                                           FOLDERS_COL_OBJPTR, confi,
                                                                            -1);
                                                }
 
@@ -896,7 +733,6 @@ on_mnuConfigsDelete_activate (GtkMenuItem *menuitem,
                                        ZakConfi *confi;
 
                                        gtk_tree_model_get (GTK_TREE_MODEL (storeFolders), &iter,
-                                                           FOLDERS_COL_OBJPTR, &confi,
                                                            -1);
                                        if (ZAK_IS_CONFI (confi))
                                                {
@@ -947,7 +783,6 @@ on_mnuConfigsExport_activate (GtkMenuItem *menuitem,
                                                }
 
                                        gtk_tree_model_get (GTK_TREE_MODEL (storeFolders), &iter,
-                                                           FOLDERS_COL_OBJPTR, &confi,
                                                            -1);
                                        if (ZAK_IS_CONFI (confi))
                                                {
@@ -968,7 +803,7 @@ on_mnuConfigsExport_activate (GtkMenuItem *menuitem,
                        else
                                {
                                        /* saving all configurations */
-                                       GList *configs = zak_confi_get_configs_list (cnc_string, filter);
+                                       GList *configs = zak_confi_get_configs_list (confi, filter);
                                        if (configs != NULL)
                                                {
                                                        xmlDocPtr xdoc;
@@ -1043,16 +878,14 @@ on_mnuKeysNew_activate (GtkMenuItem *menuitem,
                                                                                 gtk_tree_path_new_from_indices (gtk_tree_path_get_indices (path)[0], -1));
 
                                                        gtk_tree_model_get (GTK_TREE_MODEL (storeFolders), &iter,
-                                                                           FOLDERS_COL_OBJPTR, &ck,
                                                                            -1);
 
                                                        keyPath = g_strjoin (NULL, ck->path, "/", ck->key, NULL);
-                                                       gtk_entry_set_text (GTK_ENTRY (txtIDParent), g_strdup_printf ("%d", ck->id));
+                                                       gtk_entry_set_text (GTK_ENTRY (txtIDParent), ck->path);
                                                        gtk_entry_set_text (GTK_ENTRY (txtParent), ck->key);
                                                }
 
                                        gtk_tree_model_get (GTK_TREE_MODEL (storeFolders), &iterConfi,
-                                                           FOLDERS_COL_OBJPTR, &confi,
                                                            -1);
 
                                        g_object_get (G_OBJECT (confi),
@@ -1085,11 +918,9 @@ on_mnuKeysNew_activate (GtkMenuItem *menuitem,
 
                                                                        gtk_tree_store_append (storeFolders, &iter, &parent);
                                                                        gtk_tree_store_set (storeFolders, &iter,
-                                                                                           FOLDERS_COL_ID, ck->id,
-                                                                                           FOLDERS_COL_NAME, name,
+                                                                                           FOLDERS_COL_KEY, name,
                                                                                            FOLDERS_COL_VALUE, value,
                                                                                            FOLDERS_COL_DESCRIPTION, description,
-                                                                                           FOLDERS_COL_OBJPTR, ck,
                                                                                            -1);
                                                                }
                                                }
@@ -1099,26 +930,6 @@ on_mnuKeysNew_activate (GtkMenuItem *menuitem,
                }
 }
 
-G_MODULE_EXPORT void
-on_mnuKeysNewFromSchema_activate (GtkMenuItem *menuitem,
-                                  gpointer user_data)
-{
-       GtkWidget *diag = gtk_file_chooser_dialog_new ("Choose a key's schema file - gConfi",
-                                                      GTK_WINDOW (w),
-                                                      GTK_FILE_CHOOSER_ACTION_OPEN,
-                                                      GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
-                                                      GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
-                                                      NULL);
-
-       if (gtk_dialog_run (GTK_DIALOG (diag)) == GTK_RESPONSE_ACCEPT)
-               {
-                       const gchar *filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (diag));
-                       load_xml_configuration_schema (filename);
-               }
-
-       gtk_widget_destroy (diag);
-}
-
 G_MODULE_EXPORT void
 on_mnuKeysEdit_activate (GtkMenuItem *menuitem,
                          gpointer user_data)
@@ -1160,7 +971,6 @@ on_mnuKeysEdit_activate (GtkMenuItem *menuitem,
                                                        gchar *name;
 
                                                        gtk_tree_model_get (GTK_TREE_MODEL (storeFolders), &iterConfi,
-                                                                           FOLDERS_COL_OBJPTR, &confi,
                                                                            -1);
 
                                                        g_object_get (G_OBJECT (confi),
@@ -1171,24 +981,23 @@ on_mnuKeysEdit_activate (GtkMenuItem *menuitem,
                                                }
 
                                        gtk_tree_model_get (GTK_TREE_MODEL (storeFolders), &iter,
-                                                           FOLDERS_COL_OBJPTR, &ck,
                                                            -1);
 
                                        if (ck != NULL)
                                                {
-                                                       gtk_entry_set_text (GTK_ENTRY (txtIDConfig), g_strdup_printf ("%d", ck->id_config));
-                                                       gtk_entry_set_text (GTK_ENTRY (txtID), g_strdup_printf ("%d", ck->id));
-                                                       gtk_entry_set_text (GTK_ENTRY (txtIDParent), g_strdup_printf ("%d", ck->id_parent));
+                                                       gtk_entry_set_text (GTK_ENTRY (txtIDConfig), ck->config);
+                                                       gtk_entry_set_text (GTK_ENTRY (txtID), ck->key);
+                                                       gtk_entry_set_text (GTK_ENTRY (txtIDParent), 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 (ck->id_parent > 0 && gtk_tree_model_iter_parent (GTK_TREE_MODEL (storeFolders), &iterParent, &iter))
+                                                       if (g_strcmp0 (ck->path, "") != 0
+                                                               && gtk_tree_model_iter_parent (GTK_TREE_MODEL (storeFolders), &iterParent, &iter))
                                                                {
                                                                        ZakConfiKey *ckParent;
 
                                                                        gtk_tree_model_get (GTK_TREE_MODEL (storeFolders), &iterParent,
-                                                                                           FOLDERS_COL_OBJPTR, &ckParent,
                                                                                            -1);
 
                                                                        gtk_entry_set_text (GTK_ENTRY (txtParent), ckParent->key);
@@ -1208,10 +1017,9 @@ on_mnuKeysEdit_activate (GtkMenuItem *menuitem,
                                                                        zak_confi_key_set_key (confi, ck);
 
                                                                        gtk_tree_store_set (storeFolders, &iter,
-                                                                                           FOLDERS_COL_NAME, ck->key,
+                                                                                           FOLDERS_COL_KEY, ck->key,
                                                                                            FOLDERS_COL_VALUE, ck->value,
                                                                                            FOLDERS_COL_DESCRIPTION, ck->description,
-                                                                                           FOLDERS_COL_OBJPTR, ck,
                                                                                            -1);
                                                                }
                                                }
@@ -1246,7 +1054,6 @@ on_mnuKeysDelete_activate (GtkMenuItem *menuitem,
                                                                                 gtk_tree_path_new_from_indices (gtk_tree_path_get_indices (path)[0], -1));
 
                                                        gtk_tree_model_get (GTK_TREE_MODEL (storeFolders), &iterConfig,
-                                                                           FOLDERS_COL_OBJPTR, &confi,
                                                                            -1);
 
                                                        if (ZAK_IS_CONFI (confi))
@@ -1254,7 +1061,6 @@ on_mnuKeysDelete_activate (GtkMenuItem *menuitem,
                                                                        ZakConfiKey *ck;
 
                                                                        gtk_tree_model_get (GTK_TREE_MODEL (storeFolders), &iter,
-                                                                                           FOLDERS_COL_OBJPTR, &ck,
                                                                                            -1);
 
                                                                        if (zak_confi_remove_path (confi, g_strconcat (ck->path, "/", ck->key, NULL)))
@@ -1410,16 +1216,20 @@ main (int argc, char **argv)
 
        if (cnc_string != NULL)
                {
-                       if (fill_trFolders (cnc_string, filter))
+                       confi = zak_confi_new (cnc_string);
+                       if (confi!= NULL)
                                {
-                                       gtk_widget_set_sensitive (mnuDbClose, TRUE);
-                                       gtk_widget_set_sensitive (mnuDbRefresh, TRUE);
-                                       gtk_widget_set_sensitive (mnuConfigs, TRUE);
-                                       gtk_widget_set_sensitive (mnuKeys, TRUE);
-
-                                       gtk_statusbar_pop (GTK_STATUSBAR (stbar), 0);
-                                       gtk_statusbar_push (GTK_STATUSBAR (stbar), 0,
-                                                           g_strconcat ("Connection string: ", cnc_string, NULL));
+                                       if (fill_trFolders (filter))
+                                               {
+                                                       gtk_widget_set_sensitive (mnuDbClose, TRUE);
+                                                       gtk_widget_set_sensitive (mnuDbRefresh, TRUE);
+                                                       gtk_widget_set_sensitive (mnuConfigs, TRUE);
+                                                       gtk_widget_set_sensitive (mnuKeys, TRUE);
+
+                                                       gtk_statusbar_pop (GTK_STATUSBAR (stbar), 0);
+                                                       gtk_statusbar_push (GTK_STATUSBAR (stbar), 0,
+                                                                                               g_strconcat ("Connection string: ", cnc_string, NULL));
+                                               }
                                }
                }