]> Dogcows Code - chaz/tint2/commitdiff
fixed issue 134
authorThierry Lorthiois <lorthiois@bbsoft.fr>
Sat, 29 Aug 2009 16:19:01 +0000 (16:19 +0000)
committerThierry Lorthiois <lorthiois@bbsoft.fr>
Sat, 29 Aug 2009 16:19:01 +0000 (16:19 +0000)
ChangeLog
src/config.c
src/config.h
src/tint.c

index 45e6d80f95bedf84255a8df5dd1e7edfa2da2e18..f78eedb1e716a36a1592213597c4084c764c727a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+2009-08-29
+- fixed issue 134
+
 2009-08-29
 - cleanup and add desktop_right/desktop_left action on task (by jackp)
 
index a2d6fa83dbc4301b1443ac2a87f98830303fd607..10fd1aae0065baf90c8e7e8432b11f16754f75a3 100644 (file)
@@ -48,6 +48,9 @@
 #include "battery.h"
 #endif
 
+// global path
+char *config_path = 0;
+char *thumbnail_path = 0;
 
 // --------------------------------------------------
 // backward compatibility
@@ -739,6 +742,7 @@ deb:
    path1 = g_build_filename (g_get_user_config_dir(), "tint2", "tint2rc", NULL);
    if (g_file_test (path1, G_FILE_TEST_EXISTS)) {
                i = config_read_file (path1);
+               config_path = strdup(path1);
                g_free(path1);
           return i;
        }
@@ -781,6 +785,7 @@ deb:
                g_free(path2);
 
                i = config_read_file (path1);
+               config_path = strdup(path1);
                g_free(path1);
                return i;
        }
index d32ac14693e672c9dfb79c4480b5edcaa5c67f1b..ca851853d0e7c410b903c939087b7d5f776eb319 100644 (file)
@@ -9,6 +9,8 @@
 #ifndef CONFIG_H
 #define CONFIG_H
 
+extern char *config_path;
+extern char *thumbnail_path;
 
 void init_config();
 void cleanup_config();
index ba79855190a3b512f9148eed3b44758a4e5e3124..4eb8cc7cbec7380443fabd338bfd13203db8204a 100644 (file)
@@ -46,8 +46,19 @@ void signal_handler(int sig)
 }
 
 
-void init ()
+void init (int argc, char *argv[])
 {
+   int c;
+
+       // read options
+   c = getopt (argc, argv, "c:");
+   if (c != -1) {
+               config_path = strdup (optarg);
+          c = getopt (argc, argv, "j:");
+          if (c != -1)
+                       thumbnail_path = strdup (optarg);
+       }
+
        // Set signal handler
    signal(SIGUSR1, signal_handler);
        signal(SIGINT, signal_handler);
@@ -105,6 +116,8 @@ void cleanup()
 #endif
        if (clock_lclick_command) g_free(clock_lclick_command);
        if (clock_rclick_command) g_free(clock_rclick_command);
+       if (config_path) g_free(config_path);
+       if (thumbnail_path) g_free(thumbnail_path);
 
    if (server.monitor) free(server.monitor);
    XFreeGC(server.dsp, server.gc);
@@ -618,35 +631,32 @@ int main (int argc, char *argv[])
 {
    XEvent e;
    fd_set fd;
-   int x11_fd, i, c;
+   int x11_fd, i;
    struct timeval tv;
    Panel *panel;
        GSList *it;
 
-   init ();
+   init (argc, argv);
 
 load_config:
    i = 0;
-   c = getopt (argc, argv, "c:");
        init_config();
-   if (c != -1) {
-      i = config_read_file (optarg);
-          c = getopt (argc, argv, "j:");
-          if (c != -1) {
-                       // usage: tint2 [-c] <config_file> -j <file> for internal use
-          printf("file %s\n", optarg);
-             cleanup();
-          exit(0);
-               }
+   if (config_path)
+      i = config_read_file (config_path);
+       else
+               i = config_read ();
+       if (!i) {
+               fprintf(stderr, "usage: tint2 [-c] <config_file>\n");
+               cleanup();
+               exit(1);
        }
-   if (!i)
-      i = config_read ();
-   if (!i) {
-      fprintf(stderr, "usage: tint2 [-c] <config_file>\n");
-      cleanup();
-      exit(1);
-   }
    config_finish();
+       if (thumbnail_path) {
+               // usage: tint2 -j <file> for internal use
+               printf("file %s\n", thumbnail_path);
+               cleanup();
+               exit(0);
+       }
 
    x11_fd = ConnectionNumber(server.dsp);
    XSync(server.dsp, False);
This page took 0.035921 seconds and 4 git commands to generate.