all repos — tint2 @ 3d07eeeb488cba603ddc9d5a071f0fe358c7d0a5

fork of the tint2 desktop panel for my custom setup - only minimized windows across all desktops for the taskbar

merge battery applet from Sebastian Reichel

git-svn-id: http://tint2.googlecode.com/svn/trunk@73 121b4492-b84c-0410-8b4c-0d4edfb3f3cc
lorthiois@bbsoft.fr lorthiois@bbsoft.fr@121b4492-b84c-0410-8b4c-0d4edfb3f3cc
commit

3d07eeeb488cba603ddc9d5a071f0fe358c7d0a5

parent

3be419b59b7239e5372e07cb6549249416eaacf0

M ChangeLogChangeLog

@@ -1,3 +1,7 @@

+ +2009-05-15 +- merge battery applet from Sebastian Reichel <elektranox@gmail.com> + 2009-03-14 - add systray option when convert tint-0.6 config file but you need to stop other systemtray program
M src/Makefilesrc/Makefile

@@ -2,7 +2,7 @@ CFLAGS= -O2

CC = gcc FLAGS=-Wall -g `pkg-config --cflags --libs cairo pangocairo x11 xinerama xrandr imlib2 glib-2.0` PROGNAME=tint2 -FILES=tint.c server.c panel.c config.c taskbar/task.c taskbar/taskbar.c clock/clock.c systray/systraybar.c util/window.c util/area.c +FILES=tint.c server.c panel.c config.c taskbar/task.c taskbar/taskbar.c battery/battery.c clock/clock.c systray/systraybar.c util/window.c util/area.c ifndef DESTDIR ifndef PREFIX

@@ -22,7 +22,7 @@ endif

$(PROGNAME): $(FILES) $(SYSTRAYOBJ) - $(CC) $(CFLAGS) -I. -Iutil -Iclock -Itaskbar -Isystray -o $(PROGNAME) $(FILES) $(FLAGS) + $(CC) $(CFLAGS) -I. -Iutil -Ibattery -Iclock -Itaskbar -Isystray -o $(PROGNAME) $(FILES) $(FLAGS) install: install-strip
M src/config.csrc/config.c

@@ -40,6 +40,7 @@ #include "task.h"

#include "taskbar.h" #include "systraybar.h" #include "clock.h" +#include "battery.h" #include "panel.h" #include "config.h" #include "window.h"

@@ -53,6 +54,8 @@ static char *old_time1_font;

static char *old_time2_font; static Area *area_task, *area_task_active; +static char *old_bat1_font; +static char *old_bat2_font; // temporary panel static Panel *panel_config = 0;

@@ -306,6 +309,50 @@ memcpy(&panel_config->area.pix.back, &a->pix.back, sizeof(Color));

memcpy(&panel_config->area.pix.border, &a->pix.border, sizeof(Border)); } + /* Battery */ + else if (strcmp (key, "battery") == 0) { + if(atoi(value) == 1) + panel_config->battery.area.on_screen = 1; + } + else if (strcmp (key, "battery_low_status") == 0) { + battery_low_status = atoi(value); + if(battery_low_status < 0 || battery_low_status > 100) + battery_low_status = 0; + } + else if (strcmp (key, "battery_low_cmd") == 0) { + if (battery_low_cmd) g_free(battery_low_cmd); + if (strlen(value) > 0) battery_low_cmd = strdup (value); + else battery_low_cmd = 0; + } + else if (strcmp (key, "bat1_font") == 0) { + if (save_file_config) old_bat1_font = strdup (value); + if (bat1_font_desc) pango_font_description_free(bat1_font_desc); + bat1_font_desc = pango_font_description_from_string (value); + } + else if (strcmp (key, "bat2_font") == 0) { + if (save_file_config) old_bat2_font = strdup (value); + if (bat2_font_desc) pango_font_description_free(bat2_font_desc); + bat2_font_desc = pango_font_description_from_string (value); + } + else if (strcmp (key, "battery_font_color") == 0) { + extract_values(value, &value1, &value2, &value3); + get_color (value1, panel_config->battery.font.color); + if (value2) panel_config->battery.font.alpha = (atoi (value2) / 100.0); + else panel_config->battery.font.alpha = 0.5; + } + else if (strcmp (key, "battery_padding") == 0) { + extract_values(value, &value1, &value2, &value3); + panel_config->battery.area.paddingxlr = panel_config->battery.area.paddingx = atoi (value1); + if (value2) panel_config->battery.area.paddingy = atoi (value2); + if (value3) panel_config->battery.area.paddingx = atoi (value3); + } + else if (strcmp (key, "battery_background_id") == 0) { + int id = atoi (value); + Area *a = g_slist_nth_data(list_back, id); + memcpy(&panel_config->battery.area.pix.back, &a->pix.back, sizeof(Color)); + memcpy(&panel_config->battery.area.pix.border, &a->pix.border, sizeof(Border)); + } + /* Clock */ else if (strcmp (key, "time1_format") == 0) { if (time1_format) g_free(time1_format);

@@ -586,9 +633,10 @@ // TODO: user can configure layout => ordered objects in panel.area.list

// clock and systray before taskbar because resize(clock) can resize others object ?? init_panel(); init_clock(); + init_battery(); init_systray(); - init_taskbar(); - visible_object(); + init_taskbar(); + visible_object(); cleanup_config();

@@ -776,6 +824,18 @@ fprintf(fp, "time2_font = %s\n", old_time2_font);

fprintf(fp, "clock_font_color = #%02x%02x%02x %d\n", (int)(panel_config->clock.font.color[0]*255), (int)(panel_config->clock.font.color[1]*255), (int)(panel_config->clock.font.color[2]*255), (int)(panel_config->clock.font.alpha*100)); fputs("clock_padding = 2 2\n", fp); fputs("clock_background_id = 0\n", fp); + + fputs("\n#---------------------------------------------\n", fp); + fputs("# BATTERY\n", fp); + fputs("#---------------------------------------------\n", fp); + fprintf(fp, "battery = %d\n", panel_config->battery.area.on_screen); + fprintf(fp, "battery_low_status = %d\n", battery_low_status); + fprintf(fp, "battery_low_cmd = %s\n", battery_low_cmd); + fprintf(fp, "bat1_font = %s\n", old_bat1_font); + fprintf(fp, "bat2_font = %s\n", old_bat2_font); + fprintf(fp, "battery_font_color = #%02x%02x%02x %d\n", (int)(panel_config->battery.font.color[0]*255), (int)(panel_config->battery.font.color[1]*255), (int)(panel_config->battery.font.color[2]*255), (int)(panel_config->battery.font.alpha*100)); + fputs("battery_padding = 2 2\n", fp); + fputs("battery_background_id = 0\n", fp); fputs("\n#---------------------------------------------\n", fp); fputs("# MOUSE ACTION ON TASK\n", fp);
M src/panel.csrc/panel.c

@@ -71,6 +71,8 @@

// add childs if (p->clock.area.on_screen) p->area.list = g_slist_append(p->area.list, &p->clock); + if (p->battery.area.on_screen) + p->area.list = g_slist_append(p->area.list, &p->battery); if (systray.area.on_screen && i == 0) { // systray only on first panel p->area.list = g_slist_append(p->area.list, &systray);

@@ -180,6 +182,8 @@

taskbar_width = panel->area.width - (2 * panel->area.paddingxlr) - (2 * panel->area.pix.border.width); if (panel->clock.area.on_screen && panel->clock.area.width) taskbar_width -= (panel->clock.area.width + panel->area.paddingx); + if (panel->battery.area.on_screen && panel->battery.area.width) + taskbar_width -= (panel->battery.area.width + panel->area.paddingx); // TODO : systray only on first panel. search better implementation ! if (systray.area.on_screen && systray.area.width && panel == &panel1[0]) taskbar_width -= (systray.area.width + panel->area.paddingx);
M src/panel.hsrc/panel.h

@@ -14,6 +14,7 @@

#include <pango/pangocairo.h> #include <sys/time.h> +#include "battery.h" #include "common.h" #include "clock.h" #include "task.h"

@@ -76,6 +77,10 @@

// -------------------------------------------------- // clock Clock clock; + + // -------------------------------------------------- + // battery + Battery battery; } Panel;
M src/systray/systraybar.csrc/systray/systraybar.c

@@ -66,6 +66,8 @@

systray.area.posx = panel->area.width - panel->area.paddingxlr - panel->area.pix.border.width - systray.area.width; if (panel->clock.area.on_screen) systray.area.posx -= (panel->clock.area.width + panel->area.paddingx); + if (panel->battery.area.on_screen) + systray.area.posx -= (panel->battery.area.width + panel->area.paddingx); systray.area.redraw = 1; }

@@ -141,6 +143,8 @@

systray.area.posx = panel->area.width - panel->area.pix.border.width - panel->area.paddingxlr - systray.area.width; if (panel->clock.area.on_screen) systray.area.posx -= (panel->clock.area.width + panel->area.paddingx); + if (panel->battery.area.on_screen) + systray.area.posx -= (panel->battery.area.width + panel->area.paddingx); systray.area.redraw = 1;
M src/tint.csrc/tint.c

@@ -92,6 +92,7 @@ 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); if (time2_format) g_free(time2_format); + if (battery_low_cmd) g_free(battery_low_cmd); if (server.monitor) free(server.monitor); XFreeGC(server.dsp, server.gc);

@@ -136,7 +137,7 @@

GSList *l0; Taskbar *tskbar; int x = e->xbutton.x; - int y = e->xbutton.y; + //int y = e->xbutton.y; // unused for (l0 = panel->area.list; l0 ; l0 = l0->next) { tskbar = l0->data; if (!tskbar->area.on_screen) continue;

@@ -168,7 +169,7 @@ if (!panel) return;

int action = TOGGLE_ICONIFY; int x = e->xbutton.x; - int y = e->xbutton.y; + //int y = e->xbutton.y; // unused switch (e->xbutton.button) { case 2: action = mouse_middle;

@@ -466,15 +467,19 @@ if (gettimeofday(&stv, 0)) return;

if (abs(stv.tv_sec - time_clock.tv_sec) < time_precision) return; - // update clock - time_clock.tv_sec = stv.tv_sec; - time_clock.tv_sec -= time_clock.tv_sec % time_precision; + // update battery + update_battery(&battery_state); + + // update clock + time_clock.tv_sec = stv.tv_sec; + time_clock.tv_sec -= time_clock.tv_sec % time_precision; int i; for (i=0 ; i < nb_panel ; i++) { panel1[i].clock.area.resize = 1; + panel1[i].battery.area.resize = 1; } - panel_refresh = 1; + panel_refresh = 1; }
M tintrc01tintrc01

@@ -70,6 +70,19 @@ clock_padding = 1 0

clock_background_id = 0 #--------------------------------------------- +# BATTERY +#--------------------------------------------- +battery = 0 +battery_low_status = 7 +battery_low_cmd = notify-send "battery low" +bat1_font = sans 8 +bat2_font = sans 6 +battery_font_color = #ffffff 76 +battery_padding = 1 0 +battery_background_id = 0 + + +#--------------------------------------------- # MOUSE ACTION ON TASK #--------------------------------------------- mouse_middle = none
M tintrc02tintrc02

@@ -72,6 +72,18 @@ clock_padding = 1 0

clock_background_id = 0 #--------------------------------------------- +# BATTERY +#--------------------------------------------- +battery = 1 +battery_low_status = 7 +battery_low_cmd = notify-send "battery low" +bat1_font = sans 7 +bat2_font = sans 7 +battery_font_color = #ffffff 100 +battery_padding = 1 0 +battery_background_id = 0 + +#--------------------------------------------- # MOUSE ACTION ON TASK #--------------------------------------------- mouse_middle = none
M tintrc03tintrc03

@@ -66,6 +66,18 @@ clock_padding = 8 0

clock_background_id = 1 #--------------------------------------------- +# BATTERY +#--------------------------------------------- +battery = 0 +battery_low_status = 7 +battery_low_cmd = notify-send "battery low" +bat1_font = sans 7 +bat2_font = sans 7 +battery_font_color = #ffffff 100 +battery_padding = 1 0 +battery_background_id = 0 + +#--------------------------------------------- # MOUSE ACTION ON TASK #--------------------------------------------- mouse_middle = none
M tintrc04tintrc04

@@ -65,6 +65,18 @@ clock_padding = 5 0

clock_background_id = 1 #--------------------------------------------- +# BATTERY +#--------------------------------------------- +battery = 0 +battery_low_status = 7 +battery_low_cmd = notify-send "battery low" +bat1_font = sans 7 +bat2_font = sans 7 +battery_font_color = #ffffff 100 +battery_padding = 1 0 +battery_background_id = 0 + +#--------------------------------------------- # MOUSE ACTION ON TASK #--------------------------------------------- mouse_middle = none
M tintrc05tintrc05

@@ -65,6 +65,18 @@ clock_padding = 4 0

clock_background_id = 0 #--------------------------------------------- +# BATTERY +#--------------------------------------------- +battery = 1 +battery_low_status = 7 +battery_low_cmd = notify-send "battery low" +bat1_font = sans 8 +bat2_font = sans 6 +battery_font_color = #ffffff 100 +battery_padding = 1 0 +battery_background_id = 0 + +#--------------------------------------------- # MOUSE ACTION ON TASK #--------------------------------------------- mouse_middle = none
M tintrc06tintrc06

@@ -71,6 +71,18 @@ clock_padding = 6 0

clock_background_id = 1 #--------------------------------------------- +# BATTERY +#--------------------------------------------- +battery = 0 +battery_low_status = 7 +battery_low_cmd = notify-send "battery low" +bat1_font = sans 8 +bat2_font = sans 6 +battery_font_color = #ffffff 100 +battery_padding = 1 0 +battery_background_id = 0 + +#--------------------------------------------- # MOUSE ACTION ON TASK #--------------------------------------------- mouse_middle = none
M tintrc07tintrc07

@@ -65,6 +65,18 @@ clock_padding = 2 0

clock_background_id = 1 #--------------------------------------------- +# BATTERY +#--------------------------------------------- +battery = 1 +battery_low_status = 7 +battery_low_cmd = notify-send "battery low" +bat1_font = sans bold 7 +bat2_font = sans 7 +battery_font_color = #ffffff 60 +battery_padding = 1 0 +battery_background_id = 1 + +#--------------------------------------------- # MOUSE ACTION ON TASK #--------------------------------------------- mouse_middle = none