]> git.pld-linux.org Git - packages/fbpanel.git/blob - fbpanel-file_watcher.patch
a13349958c116d0616d4aa5789244275730b5098
[packages/fbpanel.git] / fbpanel-file_watcher.patch
1 diff -aurN fbpanel-4.3.orig/panel.c fbpanel-4.3/panel.c
2 --- fbpanel-4.3.orig/panel.c    2005-05-08 09:46:40.000000000 +0200
3 +++ fbpanel-4.3/panel.c 2006-08-20 12:38:19.000000000 +0200
4 @@ -9,6 +9,7 @@
5  #include <locale.h>
6  #include <string.h>
7  #include <signal.h>
8 +#include <time.h>
9  
10  #include "plugin.h"
11  #include "panel.h"
12 @@ -18,6 +19,11 @@
13  #include "gtkbgbox.h"
14  
15  static gchar *cfgfile = NULL;
16 +time_t last_config_poll = 0;
17 +
18 +/* Array of config files to watch */
19 +GArray *config_files = NULL;
20 +
21  static gchar version[] = VERSION;
22  gchar *cprofile = "default";
23  
24 @@ -243,6 +249,26 @@
25  panel_configure_event (GtkWidget *widget, GdkEventConfigure *e, panel *p)
26  {
27      ENTER;
28 +
29 +    if ((time(NULL) - last_config_poll) > 10)
30 +    {
31 +       int i;
32 +       struct stat cfgstat;
33 +       watched_file f;
34 +       
35 +       for (i = 0; i < config_files->len; i++)
36 +       {
37 +           f = g_array_index(config_files, watched_file, i);
38 +           stat(f.filename, &cfgstat);
39 +           if (cfgstat.st_mtime > f.mtime)
40 +           {
41 +               gtk_main_quit();
42 +           }
43 +       }
44 +       
45 +       last_config_poll = time(NULL);
46 +    }
47 +
48      if (e->width == p->cw && e->height == p->ch && e->x == p->cx && e->y == p->cy)
49          RET(TRUE);
50      p->cw = e->width;
51 @@ -700,17 +726,25 @@
52      fp = fopen(fname, "r");
53      LOG(LOG_INFO, "   %s %s\n", fname, fp ? "ok" : "no");
54      if (fp) {
55 +        watched_file f;
56 +        f.filename = fname;
57 +        f.mtime = time(NULL);
58 +        g_array_append_val(config_files, f);
59          cfgfile = fname;
60          RET(fp);
61      }
62      //ERR("Can't load %s\n", fname);
63      g_free(fname);
64      
65 -    /* check private configuration directory */
66 -    fname = g_strdup_printf("%s/share/fbpanel/%s", PREFIX, profile);
67 +    /* check system-wide configuration directory */
68 +    fname = g_strdup_printf("/etc/fbpanel/%s", profile);
69      fp = fopen(fname, "r");
70      LOG(LOG_INFO, "   %s %s\n", fname, fp ? "ok" : "no");
71      if (fp) {
72 +        watched_file f;
73 +        f.filename = fname;
74 +        f.mtime = time(NULL);
75 +        g_array_append_val(config_files, f);
76          cfgfile = fname;
77          RET(fp);
78      }
79 @@ -791,6 +825,19 @@
80      }
81      signal(SIGUSR1, sig_usr);
82      do {
83 +        if (config_files)
84 +        {
85 +          int i;
86 +          watched_file w;
87 +          for (i = 0; i < config_files->len; i++)
88 +          {
89 +              w = g_array_index(config_files, watched_file, i);
90 +              g_free(w.filename);
91 +          }
92 +          g_array_free(config_files, TRUE);
93 +        }
94 +        config_files = g_array_new(FALSE, FALSE, sizeof(watched_file));
95 +        
96          if (!(pfp = open_profile(cprofile)))
97              exit(1);
98          p = g_new0(panel, 1);
99 diff -aurN fbpanel-4.3.orig/panel.h fbpanel-4.3/panel.h
100 --- fbpanel-4.3.orig/panel.h    2005-05-07 12:26:55.000000000 +0200
101 +++ fbpanel-4.3/panel.h 2006-08-20 12:38:19.000000000 +0200
102 @@ -96,6 +96,13 @@
103  
104  extern command commands[];
105  
106 +typedef struct {
107 +    gchar *filename;
108 +    time_t mtime;
109 +} watched_file;
110 +
111 +extern GArray *config_files;
112 +
113  extern gchar *cprofile;
114  
115  extern Atom a_UTF8_STRING;
116 diff -aurN fbpanel-4.3.orig/plugin.c fbpanel-4.3/plugin.c
117 --- fbpanel-4.3.orig/plugin.c   2005-05-29 06:02:03.000000000 +0200
118 +++ fbpanel-4.3/plugin.c        2006-08-20 12:38:19.000000000 +0200
119 @@ -137,7 +137,7 @@
120          LOG(LOG_INFO, "   %s ... %s\n", str->str, m ? "ok" : "no");
121          if (!m) {
122              DBG("error is %s\n", g_module_error());
123 -            g_string_printf(str, "%s/share/fbpanel/plugins/%s.so", PREFIX, type);
124 +            g_string_printf(str, "%s/lib/fbpanel/plugins/%s.so", PREFIX, type);
125              m = g_module_open(str->str, G_MODULE_BIND_LAZY);
126              LOG(LOG_INFO, "   %s ... %s\n", str->str, m ? "ok" : "no");
127              if (!m) {
128 diff -aurN fbpanel-4.3.orig/plugins/menu.c fbpanel-4.3/plugins/menu.c
129 --- fbpanel-4.3.orig/plugins/menu.c     2005-05-21 06:58:55.000000000 +0200
130 +++ fbpanel-4.3/plugins/menu.c  2006-08-20 12:38:19.000000000 +0200
131 @@ -247,9 +247,13 @@
132          }
133      }
134      if ((fp = fopen(name, "r"))) {
135 +        watched_file f;
136          LOG(LOG_INFO, "Including %s\n", name);
137          m->files = g_slist_prepend(m->files, p->fp);
138          p->fp = fp;
139 +        f.filename = name;
140 +        f.mtime = time(NULL);
141 +        g_array_append_val(config_files, f);
142      } else {
143          ERR("Can't include %s\n", name);
144      }
This page took 0.057464 seconds and 2 git commands to generate.