]> git.pld-linux.org Git - packages/fbpanel.git/blob - fbpanel-file_watcher.patch
0469d7bd0f6933b5aec2166278e74fff0dc90f22
[packages/fbpanel.git] / fbpanel-file_watcher.patch
1 diff -aurN fbpanel-4.1.orig/panel.c fbpanel-4.1/panel.c
2 --- fbpanel-4.1.orig/panel.c    2004-12-23 18:26:05.000000000 +0100
3 +++ fbpanel-4.1/panel.c 2005-05-02 18:56:09.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 @@ -257,6 +263,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 @@ -705,6 +731,10 @@
52      ENTER;
53      fname = g_strdup_printf("%s/.fbpanel/%s", getenv("HOME"), profile);
54      if ((fp = fopen(fname, "r"))) {
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          if (verbose)
61              ERR("Using %s\n", fname);
62 @@ -713,9 +743,13 @@
63      //ERR("Can't load %s\n", fname);
64      g_free(fname);
65      
66 -    /* check private configuration directory */
67 -    fname = g_strdup_printf("%s/share/fbpanel/%s", PREFIX, profile);
68 +    /* check system-wide configuration directory */
69 +    fname = g_strdup_printf("/etc/fbpanel/%s", profile);
70      if ((fp = fopen(fname, "r"))) {
71 +        watched_file f;
72 +        f.filename = fname;
73 +        f.mtime = time(NULL);
74 +        g_array_append_val(config_files, f);
75          cfgfile = fname;
76          if (verbose)
77              ERR("Using %s\n", fname);
78 @@ -793,6 +827,19 @@
79      do {
80          if (verbose)
81              ERR("starting panel\n");
82 +        if (config_files)
83 +        {
84 +           int i;
85 +           watched_file w;
86 +           for (i = 0; i < config_files->len; i++)
87 +           {
88 +               w = g_array_index(config_files, watched_file, i);
89 +               g_free(w.filename);
90 +           }
91 +           g_array_free(config_files, TRUE);
92 +       }
93 +        config_files = g_array_new(FALSE, FALSE, sizeof(watched_file));
94 +
95          if (!(pfp = open_profile(cprofile)))
96              exit(1);
97          p = g_new0(panel, 1);
98 diff -aurN fbpanel-4.1.orig/panel.h fbpanel-4.1/panel.h
99 --- fbpanel-4.1.orig/panel.h    2004-12-22 18:46:00.000000000 +0100
100 +++ fbpanel-4.1/panel.h 2005-05-02 18:56:09.000000000 +0200
101 @@ -95,6 +95,13 @@
102  
103  extern command commands[];
104  
105 +typedef struct {
106 +    gchar *filename;
107 +    time_t mtime;
108 +} watched_file;
109 +
110 +extern GArray *config_files;
111 +
112  extern gchar *cprofile;
113  
114  extern Atom a_UTF8_STRING;
115 diff -aurN fbpanel-4.1.orig/plugin.c fbpanel-4.1/plugin.c
116 --- fbpanel-4.1.orig/plugin.c   2004-12-22 20:58:55.000000000 +0100
117 +++ fbpanel-4.1/plugin.c        2005-05-02 18:56:09.000000000 +0200
118 @@ -129,7 +129,7 @@
119          DBG("opening %s\n", str->str);
120          if (!m) {
121              DBG("%s\n", g_module_error());
122 -            g_string_printf(str, "%s/share/fbpanel/plugins/%s.so", PREFIX, type);
123 +            g_string_printf(str, "%s/lib/fbpanel/plugins/%s.so", PREFIX, type);
124              m = g_module_open(str->str, G_MODULE_BIND_LOCAL | G_MODULE_BIND_LAZY);
125              DBG("opening %s\n", str->str);
126          }
127 diff -aurN fbpanel-4.1.orig/plugins/menu.c fbpanel-4.1/plugins/menu.c
128 --- fbpanel-4.1.orig/plugins/menu.c     2004-12-22 15:51:55.000000000 +0100
129 +++ fbpanel-4.1/plugins/menu.c  2005-05-02 19:02:01.000000000 +0200
130 @@ -105,8 +105,11 @@
131      }
132  
133      if ((fi = fopen(name, "r"))) {
134 +        watched_file f;
135 +        f.filename = name;
136 +        f.mtime = time(NULL);
137 +        g_array_append_val(config_files, f);
138          ERR("Including %s\n", name);
139 -        g_free(name);
140      }
141      else {
142          ERR("Can't include %s\n", name);
143 @@ -336,7 +339,7 @@
144      mi = read_submenu(p, 0);
145      //bg_set_transparent_background(mi, p->panel);
146      if (!mi) {
147 -        ERR("menu: plugin init failde\n");
148 +        ERR("menu: plugin init failed\n");
149          goto error;
150      }
151      gtk_menu_shell_append (GTK_MENU_SHELL (m->mainw), mi);
This page took 0.06331 seconds and 2 git commands to generate.