From 6f8957df88f959f0c9b1ade3e066e56e36c9addf Mon Sep 17 00:00:00 2001 From: Andrea Zagli Date: Mon, 26 Sep 2016 19:35:55 +0200 Subject: [PATCH] Adding config. --- data/zak-confi-gui/ui/zak-confi-gui.ui | 221 ++++++------------------- src/main.c | 33 ++-- 2 files changed, 67 insertions(+), 187 deletions(-) diff --git a/data/zak-confi-gui/ui/zak-confi-gui.ui b/data/zak-confi-gui/ui/zak-confi-gui.ui index 095f20a..f09a7db 100644 --- a/data/zak-confi-gui/ui/zak-confi-gui.ui +++ b/data/zak-confi-gui/ui/zak-confi-gui.ui @@ -386,8 +386,8 @@ True False 3 - 3 - 3 + 5 + 5 True @@ -451,65 +451,58 @@ okbutton1 - - True False - Configuration - ZakConfiGUI - True - center-on-parent + 320 + 260 dialog wMain wMain - - True + False 5 5 5 5 vertical + 5 - - True + False end - - gtk-cancel + + gtk-undo True True - True - False + True True - False - False + True + True 0 - + gtk-ok True True - True - False + True True - False - False + True + True 1 False - True - end + False 0 @@ -517,35 +510,8 @@ True False - 3 - 3 - 3 - - - True - False - start - ID - - - 0 - 0 - - - - - True - True - True - False - False - False - - - 1 - 0 - - + 5 + 5 True @@ -555,7 +521,7 @@ 1 - 1 + 0 @@ -570,13 +536,12 @@ True True word - textbuffer1 1 - 2 + 1 @@ -588,7 +553,7 @@ 0 - 1 + 0 @@ -601,24 +566,23 @@ 0 - 2 + 1 True True - 2 + 1 - btnCancel - btnOk + button2 + button1 - True False @@ -628,6 +592,7 @@ dialog wMain wMain + True @@ -681,8 +646,8 @@ True False 3 - 3 - 3 + 5 + 5 True @@ -695,19 +660,6 @@ 0 - - - True - True - False - False - False - - - 1 - 1 - - True @@ -717,7 +669,7 @@ 1 - 3 + 2 @@ -729,7 +681,7 @@ 1 - 4 + 3 @@ -744,89 +696,12 @@ True True word - textbuffer2 - - - - - 1 - 5 - - - - - True - False - - - True - True - False - False - False - - - False - False - 0 - - - - - True - True - False - False - False - - True - True - 1 - 1 - 2 - - - - - True - False - - - True - True - False - False - False - - - False - False - 0 - - - - - True - True - False - False - False - - - True - True - 1 - - - - - 1 - 0 + 4 @@ -838,7 +713,7 @@ 0 - 2 + 1 @@ -850,7 +725,7 @@ 0 - 3 + 2 @@ -862,7 +737,7 @@ 0 - 4 + 3 @@ -875,18 +750,32 @@ 0 - 5 + 4 - + True - False - start - ID + True + False + False + False - 0 + 1 + 0 + + + + + True + True + False + False + False + + + 1 1 diff --git a/src/main.c b/src/main.c index 8d842fc..d775f87 100644 --- a/src/main.c +++ b/src/main.c @@ -533,6 +533,7 @@ on_mnuDbOpen_activate (GtkMenuItem *menuitem, gpointer user_data) { GError *error = NULL; + gtk_builder_add_objects_from_file (glaMain, uifilename, g_strsplit_set ("diagOpenDbCfg", "|", -1), @@ -540,11 +541,11 @@ on_mnuDbOpen_activate (GtkMenuItem *menuitem, GtkWidget *diag = GTK_WIDGET (gtk_builder_get_object (glaMain, "diagOpenDbCfg")); - GtkWidget *txtCncString = GTK_WIDGET (gtk_builder_get_object (glaMain, "txtCncString")); - GtkWidget *txtConfigsFilter = GTK_WIDGET (gtk_builder_get_object (glaMain, "txtConfigsFilter")); - if (gtk_dialog_run (GTK_DIALOG (diag)) == GTK_RESPONSE_OK) { + GtkWidget *txtCncString = GTK_WIDGET (gtk_builder_get_object (glaMain, "txtCncString")); + GtkWidget *txtConfigsFilter = GTK_WIDGET (gtk_builder_get_object (glaMain, "txtConfigsFilter")); + cnc_string = g_strdup (gtk_entry_get_text (GTK_ENTRY (txtCncString))); if (cnc_string != NULL) { @@ -579,9 +580,6 @@ on_mnuDbClose_activate (GtkMenuItem *menuitem, cnc_string = g_strdup (""); - /* TO DO */ - /* deallocate first every Confi object */ - gtk_tree_store_clear (storeFolders); gtk_widget_set_sensitive (mnuDbClose, FALSE); @@ -604,6 +602,7 @@ on_mnuConfigsNew_activate (GtkMenuItem *menuitem, gpointer user_data) { GError *error = NULL; + gtk_builder_add_objects_from_file (glaMain, uifilename, g_strsplit_set ("wConfiguration", "|", -1), @@ -613,13 +612,14 @@ on_mnuConfigsNew_activate (GtkMenuItem *menuitem, if (gtk_dialog_run (GTK_DIALOG (diag)) == GTK_RESPONSE_OK) { + GtkTreeIter iter; GtkWidget *txtName; GtkWidget *txtvDescription; GtkTextBuffer *buffer; GtkTextIter iter1, iter2; gchar *name; gchar *description; - ZakConfi *confi; + ZakConfiConfi *conficonfi; txtName = GTK_WIDGET (gtk_builder_get_object (glaMain, "txtName")); txtvDescription = GTK_WIDGET (gtk_builder_get_object (glaMain, "txtvDescription")); @@ -630,20 +630,9 @@ on_mnuConfigsNew_activate (GtkMenuItem *menuitem, gtk_text_buffer_get_bounds (buffer, &iter1, &iter2); description = gtk_text_buffer_get_text (buffer, &iter1, &iter2, FALSE); - confi = zak_confi_new (cnc_string); - if (confi != NULL) + conficonfi = zak_confi_add_config (confi, name, description); + if (conficonfi != NULL) { - GtkTreeIter iter; - gint id; - - g_object_set (G_OBJECT (confi), - "description", description, - NULL); - - g_object_get (G_OBJECT (confi), - "id_config", &id, - NULL); - gtk_tree_store_append (storeFolders, &iter, NULL); gtk_tree_store_set (storeFolders, &iter, FOLDERS_COL_KEY, name, @@ -669,6 +658,7 @@ on_mnuConfigsEdit_activate (GtkMenuItem *menuitem, ZakConfi *confi; GError *error = NULL; + gtk_builder_add_objects_from_file (glaMain, uifilename, g_strsplit_set ("wConfiguration", "|", -1), @@ -1104,7 +1094,8 @@ on_trFolders_button_press_event (GtkWidget *widget, gpointer user_data) { /* single click with the right mouse button? */ - if (event->type == GDK_BUTTON_PRESS && event->button == 3) + if (event->type == GDK_BUTTON_PRESS + && event->button == 3) { /* select row if no row is selected */ if (gtk_tree_selection_count_selected_rows (selFolders) <= 1) -- 2.49.0