]> Dogcows Code - chaz/tint2/commitdiff
cleanup : global setting outside panel.c
authorThierry Lorthiois <lorthiois@bbsoft.fr>
Sat, 17 Oct 2009 19:52:44 +0000 (19:52 +0000)
committerThierry Lorthiois <lorthiois@bbsoft.fr>
Sat, 17 Oct 2009 19:52:44 +0000 (19:52 +0000)
src/config.c
src/panel.c
src/panel.h
src/tint.c

index 5630546e23e20adb308db0d393b7f382eefc3b98..6d9e7d0cc4e65bba7dc08820bf653e6b32b237af 100644 (file)
@@ -74,8 +74,6 @@ static GSList *list_back;
 
 void init_config()
 {
-       cleanup_panel();
-
        // get monitor and desktop config
        get_monitors();
        get_desktops();
index 9faa33a2ede8054c1a4edbf7c833ae68d0b0df2f..8a6af12713d1a6af7ccf3a907d2f233a48b48720 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include <X11/Xlib.h>
 #include <X11/Xutil.h>
 #include <X11/Xatom.h>
@@ -61,7 +62,8 @@ Panel panel_config;
 Panel *panel1 = 0;
 int  nb_panel;
 
-Imlib_Image default_icon;
+Imlib_Image default_icon = NULL;
+
 
 
 void init_panel()
@@ -69,19 +71,6 @@ void init_panel()
        int i;
        Panel *p;
 
-       // load default icon
-       char *path;
-       const gchar * const *data_dirs;
-       data_dirs = g_get_system_data_dirs ();
-       for (i = 0; data_dirs[i] != NULL; i++)  {
-               path = g_build_filename(data_dirs[i], "tint2", "default_icon.png", NULL);
-               if (g_file_test (path, G_FILE_TEST_EXISTS))
-                       default_icon = imlib_load_image(path);
-               g_free(path);
-       }
-
-       //if (panel1)
-       //      free(panel1);
        // alloc panels (one monitor or all monitors)
        if (panel_config.monitor >= 0)
                nb_panel = 1;
@@ -204,14 +193,8 @@ void cleanup_panel()
        task_active = 0;
        task_drag = 0;
        task_urgent = 0;
-       cleanup_systray();
        cleanup_taskbar();
 
-       if (default_icon) {
-               imlib_context_set_image(default_icon);
-               imlib_free_image();
-       }
-
        // font allocated once
        if (panel1[0].g_task.font_desc) {
                pango_font_description_free(panel1[0].g_task.font_desc);
@@ -224,8 +207,6 @@ void cleanup_panel()
                p = &panel1[i];
 
                free_area(&p->area);
-               free_area(&p->g_task.area);
-               free_area(&p->g_taskbar);
 
                if (p->temp_pmap) {
                        XFreePixmap(server.dsp, p->temp_pmap);
@@ -239,15 +220,6 @@ void cleanup_panel()
 
        if (panel1) free(panel1);
        panel1 = 0;
-
-       if (g_tooltip.window) {
-               XDestroyWindow(server.dsp, g_tooltip.window);
-               g_tooltip.window = 0;
-       }
-       if (g_tooltip.font_desc) {
-               pango_font_description_free(g_tooltip.font_desc);
-               g_tooltip.font_desc = 0;
-       }
 }
 
 
index 6a5b75700d6f9264389146d984ab1f2423e53790..1e7da9e83b7decb3b458015376a1d6c459180bc0 100644 (file)
@@ -105,7 +105,6 @@ extern Panel panel_config;
 extern Panel *panel1;
 extern int  nb_panel;
 
-
 void init_panel();
 void init_panel_size_and_position(Panel *panel);
 void cleanup_panel();
index a64f92f0d1a39245d29ec8e2125fd11937d2e5c2..260d93cdecdb610c9e448ca0b8c7570b2d47d285 100644 (file)
@@ -103,13 +103,38 @@ void init (int argc, char *argv[])
        XSelectInput (server.dsp, server.root_win, PropertyChangeMask|StructureNotifyMask);
 
        setlocale (LC_ALL, "");
+
+       // load default icon
+       int i;
+       char *path;
+       const gchar * const *data_dirs;
+       data_dirs = g_get_system_data_dirs ();
+       for (i = 0; data_dirs[i] != NULL; i++)  {
+               path = g_build_filename(data_dirs[i], "tint2", "default_icon.png", NULL);
+               if (g_file_test (path, G_FILE_TEST_EXISTS))
+                       default_icon = imlib_load_image(path);
+               g_free(path);
+       }
 }
 
 
 void cleanup()
 {
+       cleanup_systray();
        cleanup_panel();
 
+       if (default_icon) {
+               imlib_context_set_image(default_icon);
+               imlib_free_image();
+       }
+       if (g_tooltip.window) {
+               XDestroyWindow(server.dsp, g_tooltip.window);
+               g_tooltip.window = 0;
+       }
+       if (g_tooltip.font_desc) {
+               pango_font_description_free(g_tooltip.font_desc);
+               g_tooltip.font_desc = 0;
+       }
        if (time1_font_desc) pango_font_description_free(time1_font_desc);
        if (time2_font_desc) pango_font_description_free(time2_font_desc);
        if (time1_format) g_free(time1_format);
@@ -611,12 +636,20 @@ void event_configure_notify (Window win)
 {
        // change in root window (xrandr)
        if (win == server.root_win) {
-               int i, old_monitor = server.nb_monitor;
+               int i, old_nb_panel = nb_panel;
 
                get_monitors();
-               if (old_monitor != server.nb_monitor) {
+               if (panel_config.monitor >= 0)
+                       nb_panel = 1;
+               else
+                       nb_panel = server.nb_monitor;
+
+               if (old_nb_panel != nb_panel) {
+                       // changed number of panel
+                       printf("changed number of panel\n");
+                       //realloc(panel1, nb_panel * sizeof(Panel));
                }
-               for (i=0 ; i < nb_panel ; i++) {
+               for (i=0 ; i < nb_panel && i < old_nb_panel ; i++) {
                        Panel *panel = &panel1[i];
 
                        init_panel_size_and_position(panel);
@@ -743,7 +776,7 @@ int main (int argc, char *argv[])
        GSList *it;
 
        init (argc, argv);
-load_config:
+
        i = 0;
        init_config();
        if (config_path)
@@ -853,7 +886,7 @@ load_config:
                switch (signal_pending) {
                        case SIGUSR1:
                                signal_pending = 0;
-                               goto load_config;
+                               return 0;
                        case SIGINT:
                        case SIGTERM:
                        case SIGHUP:
This page took 0.029319 seconds and 4 git commands to generate.