]> Dogcows Code - chaz/tint2/commitdiff
clock command on rigt/left click by dmitry.medvinsky
authorThierry Lorthiois <lorthiois@bbsoft.fr>
Thu, 4 Jun 2009 18:41:14 +0000 (18:41 +0000)
committerThierry Lorthiois <lorthiois@bbsoft.fr>
Thu, 4 Jun 2009 18:41:14 +0000 (18:41 +0000)
ChangeLog
src/clock/clock.c
src/clock/clock.h
src/config.c
src/systray/systraybar.c
src/tint.c
src/tint2

index b00d399c27618d39655a60f01cb6c9fb28fdd62c..34ab28fa38c654a99553f13b7c71855ce05629f4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+2009-06-04
+- patch by dmitry.medvinsky : right/left clic command
+
 2009-06-02
 - Systray Temp_Fix from keshto
   not yet perfect, but a first step
index 79104c0d0df4adbf54207b8f25cac7aba6c66502..eaaf69cb83e8a3c493f39151f4d5778c8be72899 100644 (file)
@@ -22,6 +22,7 @@
 #include <cairo.h>
 #include <cairo-xlib.h>
 #include <pango/pangocairo.h>
+#include <unistd.h>
 
 #include "window.h"
 #include "server.h"
 #include "clock.h"
 
 
-char *time1_format = 0;
-char *time2_format = 0;
+char *time1_format;
+char *time2_format;
+char *clock_lclick_command;
+char *clock_rclick_command;
 struct timeval time_clock;
 int  time_precision;
 PangoFontDescription *time1_font_desc;
@@ -189,3 +192,25 @@ void resize_clock (void *obj)
    XFreePixmap (server.dsp, pmap);
 }
 
+
+void clock_action(int button)
+{
+       char *command = 0;
+       switch (button) {
+               case 1:
+               command = clock_lclick_command;
+               break;
+               case 3:
+               command = clock_rclick_command;
+               break;
+       }
+       if (command) {
+               pid_t pid;
+               pid = fork();
+               if (pid == 0) {
+                       execl("/bin/sh", "/bin/sh", "-c", command, NULL);
+                       _exit(0);
+               }
+       }
+}
+
index 90e1a89cd2553a63bbb93c58310dc991038f253c..7b28e854cf7758c4b81a790f6beb9a496c390615 100644 (file)
@@ -30,6 +30,8 @@ extern struct timeval time_clock;
 extern int  time_precision;
 extern PangoFontDescription *time1_font_desc;
 extern PangoFontDescription *time2_font_desc;
+extern char *clock_lclick_command;
+extern char *clock_rclick_command;
 
 
 // initialize clock : y position, precision, ...
@@ -39,4 +41,6 @@ void draw_clock (void *obj, cairo_t *c, int active);
 
 void resize_clock (void *obj);
 
+void clock_action(int button);
+
 #endif
index d861ba5672d02cd13a27722f7eb76f706dacc5df..bfe8801e035716b66451b370e4d23446db300b3e 100644 (file)
@@ -398,6 +398,16 @@ void add_entry (char *key, char *value)
       memcpy(&panel_config->clock.area.pix.back, &a->pix.back, sizeof(Color));
       memcpy(&panel_config->clock.area.pix.border, &a->pix.border, sizeof(Border));
    }
+       else if (strcmp(key, "clock_lclick_command") == 0) {
+               if (clock_lclick_command) g_free(clock_lclick_command);
+               if (strlen(value) > 0) clock_lclick_command = strdup(value);
+               else clock_lclick_command = 0;
+       }
+       else if (strcmp(key, "clock_rclick_command") == 0) {
+               if (clock_rclick_command) g_free(clock_rclick_command);
+               if (strlen(value) > 0) clock_rclick_command = strdup(value);
+               else clock_rclick_command = 0;
+       }
 
    /* Taskbar */
    else if (strcmp (key, "taskbar_mode") == 0) {
index 0a728e73c552ea721c14ca80d3ad3f2d7dacbfd8..ef1578fcf2791514fc868e474e2c87640ddfe5c6 100644 (file)
@@ -109,7 +109,8 @@ void draw_systray(void *obj, cairo_t *c, int active)
 
                // position and size the icon window
                XMoveResizeWindow(server.dsp, traywin->id, traywin->x, traywin->y, icon_size, icon_size);
-               XSetWindowBackgroundPixmap (server.dsp, panel->main_win, systray.area.pix.pmap);
+               // ceci intervertie les fonds : le premier icone prend le fond du dernier
+               // le dernier prend le fond de l'avant dernier, ...
 
                // resize our window so that the new window can fit in it
                //fix_geometry();
@@ -123,6 +124,7 @@ void draw_systray(void *obj, cairo_t *c, int active)
                // show the window
                XMapRaised(server.dsp, traywin->id);
        }
+       XSetWindowBackgroundPixmap (server.dsp, panel->main_win, systray.area.pix.pmap);
 }
 
 
index 28366cc9a57515c69ae30a9338f2e213dac302bb..cfe0c70bd0df50fd38c76226b021df411eb64b44 100644 (file)
@@ -99,6 +99,8 @@ void cleanup()
        if (path_energy_full) g_free(path_energy_full);
        if (path_current_now) g_free(path_current_now);
        if (path_status) g_free(path_status);
+       if (clock_lclick_command) g_free(clock_lclick_command);
+       if (clock_rclick_command) g_free(clock_rclick_command);
 
    if (server.monitor) free(server.monitor);
    XFreeGC(server.dsp, server.gc);
@@ -194,12 +196,17 @@ void event_button_release (XEvent *e)
    // search taskbar
    Taskbar *tskbar;
    GSList *l0;
-   for (l0 = panel->area.list; l0 ; l0 = l0->next) {
-      tskbar = l0->data;
-      if (!tskbar->area.on_screen) continue;
-      if (x >= tskbar->area.posx && x <= (tskbar->area.posx + tskbar->area.width))
-         goto suite;
-   }
+       Clock clk = panel->clock;
+       if (clk.area.on_screen && x >= clk.area.posx && x <= (clk.area.posx + clk.area.width))
+               clock_action(e->xbutton.button);
+       else {
+               for (l0 = panel->area.list; l0 ; l0 = l0->next) {
+                       tskbar = l0->data;
+                       if (!tskbar->area.on_screen) continue;
+                       if (x >= tskbar->area.posx && x <= (tskbar->area.posx + tskbar->area.width))
+                               goto suite;
+               }
+       }
 
    // TODO: check better solution to keep window below
    XLowerWindow (server.dsp, panel->main_win);
index 449ece2fee46c5c85549c7f43382e594aba5e5f5..35eeffa37a5b9c1ad9b17a6681ae1c2b3d2f2d0d 100755 (executable)
Binary files a/src/tint2 and b/src/tint2 differ
This page took 0.033554 seconds and 4 git commands to generate.