clock command on rigt/left click by dmitry.medvinsky

git-svn-id: http://tint2.googlecode.com/svn/trunk@84 121b4492-b84c-0410-8b4c-0d4edfb3f3cc
This commit is contained in:
lorthiois@bbsoft.fr 2009-06-04 18:41:14 +00:00
parent fa749b7026
commit 26ab02d533
7 changed files with 60 additions and 9 deletions

View file

@ -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

View 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"
@ -31,8 +32,10 @@
#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);
}
}
}

View 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

View 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) {

View 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);
}

View 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);

BIN
src/tint2

Binary file not shown.