]> saetta.ns0.it Git - zakconfi/gui/commitdiff
UIDIR relocation.
authorAndrea Zagli <azagli@libero.it>
Mon, 26 Sep 2016 14:43:01 +0000 (16:43 +0200)
committerAndrea Zagli <azagli@libero.it>
Mon, 26 Sep 2016 14:43:01 +0000 (16:43 +0200)
src/main.c

index a0079004d85d7a1f7f3173a7aace3c28cd324419..8d842fcc15ecddd6811356627232dfcf75a382a8 100644 (file)
@@ -57,6 +57,8 @@ static GtkTreeStore *storeFolders;
 
 static GtkTreeSelection *selFolders;
 
+static gchar *uifilename;
+
 static ZakConfi *confi;
 
 static gchar *cnc_string;
@@ -532,7 +534,7 @@ on_mnuDbOpen_activate (GtkMenuItem *menuitem,
 {
        GError *error = NULL;
        gtk_builder_add_objects_from_file (glaMain,
-                                          UIDIR "/zak-confi-gui.ui",
+                                          uifilename,
                                           g_strsplit_set ("diagOpenDbCfg", "|", -1),
                                           &error);
 
@@ -603,7 +605,7 @@ on_mnuConfigsNew_activate (GtkMenuItem *menuitem,
 {
        GError *error = NULL;
        gtk_builder_add_objects_from_file (glaMain,
-                                          UIDIR "/zak-confi-gui.ui",
+                                          uifilename,
                                           g_strsplit_set ("wConfiguration", "|", -1),
                                           &error);
 
@@ -668,7 +670,7 @@ on_mnuConfigsEdit_activate (GtkMenuItem *menuitem,
 
                                        GError *error = NULL;
                                        gtk_builder_add_objects_from_file (glaMain,
-                                                                          UIDIR "/zak-confi-gui.ui",
+                                                                          uifilename,
                                                                           g_strsplit_set ("wConfiguration", "|", -1),
                                                                           &error);
 
@@ -849,7 +851,7 @@ on_mnuKeysNew_activate (GtkMenuItem *menuitem,
 
                                        GError *error = NULL;
                                        gtk_builder_add_objects_from_file (glaMain,
-                                                                          UIDIR "/zak-confi-gui.ui",
+                                                                          uifilename,
                                                                           g_strsplit_set ("wKey", "|", -1),
                                                                           &error);
 
@@ -945,7 +947,7 @@ on_mnuKeysEdit_activate (GtkMenuItem *menuitem,
 
                                        GError *error = NULL;
                                        gtk_builder_add_objects_from_file (glaMain,
-                                                                          UIDIR "/zak-confi-gui.ui",
+                                                                          uifilename,
                                                                           g_strsplit_set ("wKey", "|", -1),
                                                                           &error);
 
@@ -1087,7 +1089,7 @@ on_mnuHelpAbout_activate (GtkMenuItem *menuitem,
 {
        GError *error = NULL;
        gtk_builder_add_objects_from_file (glaMain,
-                                          UIDIR "/zak-confi-gui.ui",
+                                          uifilename,
                                           g_strsplit_set ("diagAbout", "|", -1),
                                           &error);
 
@@ -1163,6 +1165,8 @@ on_trFolders_row_activated (GtkTreeView *tree_view,
 int
 main (int argc, char **argv)
 {
+       gchar *guidir;
+
        GOptionEntry entries[] =
                {
                        { "cnc_string", 'c', 0, G_OPTION_ARG_STRING, &cnc_string, "Connection string", NULL },
@@ -1175,11 +1179,42 @@ main (int argc, char **argv)
 
        gtk_init (&argc, &argv);
 
+#ifdef G_OS_WIN32
+
+       gchar *moddir;
+       gchar *p;
+
+       moddir = g_win32_get_package_installation_directory_of_module (NULL);
+
+       p = g_strrstr (moddir, g_strdup_printf ("%c", G_DIR_SEPARATOR));
+       if (p != NULL
+           && (g_ascii_strcasecmp (p + 1, "src") == 0
+           || g_ascii_strcasecmp (p + 1, ".libs") == 0))
+               {
+                       guidir = g_strdup (UIDIR);
+
+#undef UIDIR
+               }
+       else
+               {
+                       guidir = g_build_filename (moddir, "share", PACKAGE, "ui", NULL);
+               }
+
+#else
+
+       guidir = g_strdup (UIDIR);
+
+#endif
+
+       uifilename = g_build_filename (guidir, "zak-confi-gui.ui", NULL);
+
+       g_free (guidir);
+
        glaMain = gtk_builder_new ();
 
        error = NULL;
        gtk_builder_add_objects_from_file (glaMain,
-                                          UIDIR "/zak-confi-gui.ui",
+                                          uifilename,
                                           g_strsplit_set ("accelgroup1"
                                                           "|image2"
                                                           "|image3"