Compare commits
18 Commits
title-race
...
v0.12-rc5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cc826cbcb5 | ||
|
|
f59702054d | ||
|
|
06dfcf70be | ||
|
|
44785a49da | ||
|
|
e20448d6b5 | ||
|
|
6014b51850 | ||
|
|
5acda6a0c0 | ||
|
|
f4f028a773 | ||
|
|
66c98bc820 | ||
|
|
de1d255088 | ||
|
|
b381ad2905 | ||
|
|
a4894b8257 | ||
|
|
b7dbb919a9 | ||
|
|
a08491c122 | ||
|
|
8795f50bb8 | ||
|
|
3ab42f9b72 | ||
|
|
7bce19452e | ||
|
|
1ff028e99f |
@@ -1,4 +1,4 @@
|
||||
2015-05-03 master
|
||||
2015-05-23 master
|
||||
- Note: the changes listed here are based on the previous release tint2 0.11, however some distributions (e.g. Debian)
|
||||
offered packages using newer commits and/or patches; thus from the user's perspective some of these features are
|
||||
already present. They are marked with '(already released by distros)'.
|
||||
@@ -11,6 +11,8 @@
|
||||
- Experimental, testing/feedback needed
|
||||
- Icons (system tray, task buttons, launcher):
|
||||
- Changed rendering method to fix icon corruptions (please report any problems)
|
||||
- System tray:
|
||||
- Workaround for misbehaving applications leaving empty tray icons
|
||||
- Many bugfixes
|
||||
- New config options (see https://gitlab.com/o9000/tint2/wikis/Configure):
|
||||
- Panel:
|
||||
|
||||
12
README.md
12
README.md
@@ -1,14 +1,14 @@
|
||||
### New unstable release: 0.12-rc3
|
||||
### New unstable release: 0.12-rc5
|
||||
Changes: https://gitlab.com/o9000/tint2/blob/master/ChangeLog
|
||||
|
||||
Documentation: https://gitlab.com/o9000/tint2/wikis/home
|
||||
|
||||
Try it out with (see also [dependencies](https://gitlab.com/o9000/tint2/wikis/Install#dependencies)):
|
||||
```
|
||||
mkdir tint2-0.12-rc3
|
||||
cd tint2-0.12-rc3
|
||||
wget 'https://gitlab.com/o9000/tint2/repository/archive.tar.gz?ref=v0.12-rc3' --output-document tint2-0.12-rc3.tar.gz
|
||||
tar -xzf tint2-0.12-rc3.tar.gz
|
||||
mkdir tint2-0.12-rc5
|
||||
cd tint2-0.12-rc5
|
||||
wget 'https://gitlab.com/o9000/tint2/repository/archive.tar.gz?ref=v0.12-rc5' --output-document tint2-0.12-rc5.tar.gz
|
||||
tar -xzf tint2-0.12-rc5.tar.gz
|
||||
cd tint2.git
|
||||
mkdir build
|
||||
cd build
|
||||
@@ -49,7 +49,7 @@ tint2 is a simple panel/taskbar made for modern X window managers. It was specif
|
||||
* [Configure](https://gitlab.com/o9000/tint2/wikis/Configure)
|
||||
* [Add applet not supported by tint2](https://gitlab.com/o9000/tint2/wikis/ThirdPartyApplets)
|
||||
* [Other frequently asked questions](https://gitlab.com/o9000/tint2/wikis/FAQ)
|
||||
* [Debug](https://gitlab.com/o9000/tint2/wikis/Debug)
|
||||
* [Debug](https://gitlab.com/o9000/tint2/wikis/Debug)
|
||||
|
||||
### How can I help out?
|
||||
|
||||
|
||||
@@ -76,6 +76,9 @@ void update_battery_tick(void* arg)
|
||||
int16_t old_hours = battery_state.time.hours;
|
||||
int8_t old_minutes = battery_state.time.minutes;
|
||||
|
||||
if (!battery_found) {
|
||||
init_battery();
|
||||
}
|
||||
if (update_battery() != 0) {
|
||||
// Reconfigure
|
||||
init_battery();
|
||||
@@ -103,15 +106,23 @@ void update_battery_tick(void* arg)
|
||||
|
||||
int i;
|
||||
for (i = 0; i < nb_panel; i++) {
|
||||
if (!battery_found && panel1[i].battery.area.on_screen == 1) {
|
||||
hide(&panel1[i].battery.area);
|
||||
panel_refresh = 1;
|
||||
} else if (battery_state.percentage >= percentage_hide && panel1[i].battery.area.on_screen == 1) {
|
||||
hide(&panel1[i].battery.area);
|
||||
panel_refresh = 1;
|
||||
} else if (battery_state.percentage < percentage_hide && panel1[i].battery.area.on_screen == 0) {
|
||||
show(&panel1[i].battery.area);
|
||||
panel_refresh = 1;
|
||||
if (!battery_found) {
|
||||
if (panel1[i].battery.area.on_screen == 1) {
|
||||
hide(&panel1[i].battery.area);
|
||||
panel_refresh = 1;
|
||||
}
|
||||
} else {
|
||||
if (battery_state.percentage >= percentage_hide) {
|
||||
if (panel1[i].battery.area.on_screen == 1) {
|
||||
hide(&panel1[i].battery.area);
|
||||
panel_refresh = 1;
|
||||
}
|
||||
} else {
|
||||
if (panel1[i].battery.area.on_screen == 0) {
|
||||
show(&panel1[i].battery.area);
|
||||
panel_refresh = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (panel1[i].battery.area.on_screen == 1) {
|
||||
panel1[i].battery.area.resize = 1;
|
||||
@@ -279,7 +290,7 @@ void init_battery()
|
||||
#endif
|
||||
|
||||
if (!battery_timeout)
|
||||
battery_timeout = add_timeout(10, 10000, update_battery_tick, 0, &battery_timeout);
|
||||
battery_timeout = add_timeout(10, 30000, update_battery_tick, 0, &battery_timeout);
|
||||
}
|
||||
|
||||
|
||||
@@ -474,7 +485,7 @@ int update_battery() {
|
||||
battery_state.time.seconds = seconds;
|
||||
|
||||
if (energy_full > 0)
|
||||
new_percentage = ((energy_now <= energy_full ? energy_now : energy_full) * 100) / energy_full;
|
||||
new_percentage = 0.5 + ((energy_now <= energy_full ? energy_now : energy_full) * 100.0) / energy_full;
|
||||
|
||||
battery_state.percentage = new_percentage;
|
||||
|
||||
|
||||
@@ -613,13 +613,13 @@ void add_entry (char *key, char *value)
|
||||
}
|
||||
else if (strcmp(key, "systray_sort") == 0) {
|
||||
if (strcmp(value, "descending") == 0)
|
||||
systray.sort = -1;
|
||||
systray.sort = SYSTRAY_SORT_DESCENDING;
|
||||
else if (strcmp(value, "ascending") == 0)
|
||||
systray.sort = 1;
|
||||
systray.sort = SYSTRAY_SORT_ASCENDING;
|
||||
else if (strcmp(value, "left2right") == 0)
|
||||
systray.sort = 2;
|
||||
systray.sort = SYSTRAY_SORT_LEFT2RIGHT;
|
||||
else if (strcmp(value, "right2left") == 0)
|
||||
systray.sort = 3;
|
||||
systray.sort = SYSTRAY_SORT_RIGHT2LEFT;
|
||||
}
|
||||
else if (strcmp(key, "systray_icon_size") == 0) {
|
||||
systray_max_icon_size = atoi(value);
|
||||
|
||||
@@ -536,6 +536,9 @@ char *get_icon_path_helper(GSList *themes, const char *icon_name, int size)
|
||||
char *next_larger = NULL;
|
||||
GSList *next_larger_theme = NULL;
|
||||
|
||||
int file_name_size = 4096;
|
||||
char *file_name = calloc(file_name_size, 1);
|
||||
|
||||
for (theme = themes; theme; theme = g_slist_next(theme)) {
|
||||
((IconTheme*)theme->data)->list_directories = g_slist_sort_with_data(((IconTheme*)theme->data)->list_directories,
|
||||
compare_theme_directories,
|
||||
@@ -560,8 +563,13 @@ char *get_icon_path_helper(GSList *themes, const char *icon_name, int size)
|
||||
char *theme_name = ((IconTheme*)theme->data)->name;
|
||||
char *dir_name = ((IconThemeDir*)dir->data)->name;
|
||||
char *extension = (char*) ext->data;
|
||||
char *file_name = calloc(strlen(base_name) + strlen(theme_name) +
|
||||
strlen(dir_name) + strlen(icon_name) + strlen(extension) + 100, 1);
|
||||
if (strlen(base_name) + strlen(theme_name) +
|
||||
strlen(dir_name) + strlen(icon_name) + strlen(extension) + 100 > file_name_size) {
|
||||
file_name_size = strlen(base_name) + strlen(theme_name) +
|
||||
strlen(dir_name) + strlen(icon_name) + strlen(extension) + 100;
|
||||
file_name = realloc(file_name, file_name_size);
|
||||
}
|
||||
file_name[0] = 0;
|
||||
// filename = directory/$(themename)/subdirectory/iconname.extension
|
||||
sprintf(file_name, "%s/%s/%s/%s%s", base_name, theme_name, dir_name, icon_name, extension);
|
||||
if (DEBUG_ICON_SEARCH)
|
||||
@@ -596,11 +604,12 @@ char *get_icon_path_helper(GSList *themes, const char *icon_name, int size)
|
||||
printf("next_larger = %s; next_larger_size = %d\n", next_larger, next_larger_size);
|
||||
}
|
||||
}
|
||||
free(file_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
free(file_name);
|
||||
file_name = NULL;
|
||||
if (next_larger) {
|
||||
g_slist_free(extensions);
|
||||
free(best_file_name);
|
||||
|
||||
@@ -31,6 +31,8 @@
|
||||
#include <glib.h>
|
||||
#include <glib/gstdio.h>
|
||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
#ifdef HAVE_RSVG
|
||||
#include <librsvg/rsvg.h>
|
||||
@@ -150,8 +152,7 @@ void cleanup_launcher_theme(Launcher *launcher)
|
||||
for (l = launcher->list_icons; l ; l = l->next) {
|
||||
LauncherIcon *launcherIcon = (LauncherIcon*)l->data;
|
||||
if (launcherIcon) {
|
||||
free_icon(launcherIcon->icon_scaled);
|
||||
free_icon(launcherIcon->icon_original);
|
||||
free_icon(launcherIcon->image);
|
||||
free(launcherIcon->icon_name);
|
||||
free(launcherIcon->icon_path);
|
||||
free(launcherIcon->cmd);
|
||||
@@ -186,7 +187,7 @@ int resize_launcher(void *obj)
|
||||
// Resize icons if necessary
|
||||
for (l = launcher->list_icons; l ; l = l->next) {
|
||||
LauncherIcon *launcherIcon = (LauncherIcon *)l->data;
|
||||
if (launcherIcon->icon_size != icon_size || !launcherIcon->icon_original) {
|
||||
if (launcherIcon->icon_size != icon_size || !launcherIcon->image) {
|
||||
launcherIcon->icon_size = icon_size;
|
||||
launcherIcon->area.width = launcherIcon->icon_size;
|
||||
launcherIcon->area.height = launcherIcon->icon_size;
|
||||
@@ -195,69 +196,69 @@ int resize_launcher(void *obj)
|
||||
char *new_icon_path = get_icon_path(launcher->list_themes, launcherIcon->icon_name, launcherIcon->icon_size);
|
||||
if (!new_icon_path) {
|
||||
// Draw a blank icon
|
||||
free_icon(launcherIcon->icon_original);
|
||||
launcherIcon->icon_original = NULL;
|
||||
free_icon(launcherIcon->icon_scaled);
|
||||
launcherIcon->icon_scaled = NULL;
|
||||
free_icon(launcherIcon->image);
|
||||
launcherIcon->image = NULL;
|
||||
continue;
|
||||
}
|
||||
if (launcherIcon->icon_path && strcmp(new_icon_path, launcherIcon->icon_path) == 0) {
|
||||
// If it's the same file just rescale
|
||||
free_icon(launcherIcon->icon_scaled);
|
||||
launcherIcon->icon_scaled = scale_icon(launcherIcon->icon_original, icon_size);
|
||||
free(new_icon_path);
|
||||
fprintf(stderr, "launcher.c %d: Using icon %s\n", __LINE__, launcherIcon->icon_path);
|
||||
} else {
|
||||
// Free the old files
|
||||
free_icon(launcherIcon->icon_original);
|
||||
free_icon(launcherIcon->icon_scaled);
|
||||
launcherIcon->icon_original = launcherIcon->icon_scaled = NULL;
|
||||
// Load the new file and scale
|
||||
launcherIcon->icon_original = imlib_load_image_immediately(new_icon_path);
|
||||
|
||||
// Free the old files
|
||||
free_icon(launcherIcon->image);
|
||||
launcherIcon->image = NULL;
|
||||
// Load the new file and scale
|
||||
launcherIcon->image = imlib_load_image_immediately(new_icon_path);
|
||||
#ifdef HAVE_RSVG
|
||||
if (!launcherIcon->icon_original && g_str_has_suffix(new_icon_path, ".svg")) {
|
||||
if (!launcherIcon->image && g_str_has_suffix(new_icon_path, ".svg")) {
|
||||
char suffix[128];
|
||||
sprintf(suffix, "tmpicon-%d.png", getpid());
|
||||
// We fork here because librsvg allocates memory like crazy
|
||||
pid_t pid = fork();
|
||||
if (pid == 0) {
|
||||
// Child
|
||||
GError* err = NULL;
|
||||
RsvgHandle* svg = rsvg_handle_new_from_file(new_icon_path, &err);
|
||||
|
||||
if (err != NULL) {
|
||||
fprintf(stderr, "Could not load svg image!: %s", err->message);
|
||||
g_error_free(err);
|
||||
launcherIcon->icon_original = NULL;
|
||||
launcherIcon->image = NULL;
|
||||
} else {
|
||||
char suffix[128];
|
||||
sprintf(suffix, "tmpicon-%d.png", getpid());
|
||||
gchar *name = g_build_filename(g_get_user_config_dir(), "tint2", suffix, NULL);
|
||||
GdkPixbuf *pixbuf = rsvg_handle_get_pixbuf(svg);
|
||||
gdk_pixbuf_save(pixbuf, name, "png", NULL, NULL);
|
||||
launcherIcon->icon_original = imlib_load_image_immediately_without_cache(name);
|
||||
g_remove(name);
|
||||
g_free(name);
|
||||
g_object_unref(G_OBJECT(pixbuf));
|
||||
g_object_unref(G_OBJECT(svg));
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
launcherIcon->icon_original = imlib_load_image_immediately(new_icon_path);
|
||||
}
|
||||
// On loading error, fallback to default
|
||||
if (!launcherIcon->icon_original) {
|
||||
free(new_icon_path);
|
||||
new_icon_path = get_icon_path(launcher->list_themes, DEFAULT_ICON, launcherIcon->icon_size);
|
||||
if (new_icon_path)
|
||||
launcherIcon->icon_original = imlib_load_image_immediately(new_icon_path);
|
||||
}
|
||||
|
||||
if (!launcherIcon->icon_original) {
|
||||
// Loading default icon failed, draw a blank icon
|
||||
free(new_icon_path);
|
||||
exit(0);
|
||||
} else {
|
||||
// Loaded icon successfully
|
||||
launcherIcon->icon_scaled = scale_icon(launcherIcon->icon_original, launcherIcon->icon_size);
|
||||
free(launcherIcon->icon_path);
|
||||
launcherIcon->icon_path = new_icon_path;
|
||||
fprintf(stderr, "launcher.c %d: Using icon %s\n", __LINE__, launcherIcon->icon_path);
|
||||
// Parent
|
||||
waitpid(pid, 0, 0);
|
||||
gchar *name = g_build_filename(g_get_user_config_dir(), "tint2", suffix, NULL);
|
||||
launcherIcon->image = imlib_load_image_immediately_without_cache(name);
|
||||
g_remove(name);
|
||||
g_free(name);
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
launcherIcon->image = imlib_load_image_immediately(new_icon_path);
|
||||
}
|
||||
// On loading error, fallback to default
|
||||
if (!launcherIcon->image) {
|
||||
free(new_icon_path);
|
||||
new_icon_path = get_icon_path(launcher->list_themes, DEFAULT_ICON, launcherIcon->icon_size);
|
||||
if (new_icon_path)
|
||||
launcherIcon->image = imlib_load_image_immediately(new_icon_path);
|
||||
}
|
||||
|
||||
if (!launcherIcon->image) {
|
||||
// Loading default icon failed, draw a blank icon
|
||||
free(new_icon_path);
|
||||
} else {
|
||||
// Loaded icon successfully
|
||||
Imlib_Image original = launcherIcon->image;
|
||||
launcherIcon->image = scale_icon(launcherIcon->image, launcherIcon->icon_size);
|
||||
free_icon(original);
|
||||
free(launcherIcon->icon_path);
|
||||
launcherIcon->icon_path = new_icon_path;
|
||||
fprintf(stderr, "launcher.c %d: Using icon %s\n", __LINE__, launcherIcon->icon_path);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -331,6 +332,7 @@ int resize_launcher(void *obj)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -355,9 +357,8 @@ void draw_launcher_icon(void *obj, cairo_t *c)
|
||||
{
|
||||
LauncherIcon *launcherIcon = (LauncherIcon*)obj;
|
||||
|
||||
Imlib_Image icon_scaled = launcherIcon->icon_scaled;
|
||||
// Render
|
||||
imlib_context_set_image(icon_scaled);
|
||||
imlib_context_set_image(launcherIcon->image);
|
||||
if (server.real_transparency) {
|
||||
render_image(launcherIcon->area.pix, 0, 0);
|
||||
} else {
|
||||
@@ -403,7 +404,7 @@ void launcher_action(LauncherIcon *icon, XEvent* evt)
|
||||
char *cmd = calloc(strlen(icon->cmd) + 10, 1);
|
||||
sprintf(cmd, "(%s&)", icon->cmd);
|
||||
#if HAVE_SN
|
||||
SnLauncherContext* ctx;
|
||||
SnLauncherContext* ctx = 0;
|
||||
Time time;
|
||||
if (startup_notifications) {
|
||||
ctx = sn_launcher_context_new(server.sn_dsp, server.screen);
|
||||
|
||||
@@ -23,8 +23,7 @@ typedef struct Launcher {
|
||||
typedef struct LauncherIcon {
|
||||
// always start with area
|
||||
Area area;
|
||||
Imlib_Image icon_scaled;
|
||||
Imlib_Image icon_original;
|
||||
Imlib_Image image;
|
||||
char *cmd;
|
||||
char *icon_name;
|
||||
char *icon_path;
|
||||
|
||||
@@ -98,6 +98,7 @@ void server_init_atoms ()
|
||||
server.atom._NET_SYSTEM_TRAY_ORIENTATION = XInternAtom(server.dsp, "_NET_SYSTEM_TRAY_ORIENTATION", False);
|
||||
server.atom._XEMBED = XInternAtom(server.dsp, "_XEMBED", False);
|
||||
server.atom._XEMBED_INFO = XInternAtom(server.dsp, "_XEMBED_INFO", False);
|
||||
server.atom._NET_WM_PID = XInternAtom(server.dsp, "_NET_WM_PID", True);
|
||||
|
||||
// drag 'n' drop
|
||||
server.atom.XdndAware = XInternAtom(server.dsp, "XdndAware", False);
|
||||
|
||||
@@ -15,9 +15,8 @@
|
||||
|
||||
#ifdef HAVE_SN
|
||||
#include <libsn/sn.h>
|
||||
#include <glib.h>
|
||||
#endif
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
typedef struct Global_atom
|
||||
{
|
||||
@@ -74,6 +73,7 @@ typedef struct Global_atom
|
||||
Atom _NET_SYSTEM_TRAY_ORIENTATION;
|
||||
Atom _XEMBED;
|
||||
Atom _XEMBED_INFO;
|
||||
Atom _NET_WM_PID;
|
||||
Atom _XSETTINGS_SCREEN;
|
||||
Atom _XSETTINGS_SETTINGS;
|
||||
Atom XdndAware;
|
||||
@@ -154,4 +154,4 @@ void get_monitors();
|
||||
void get_desktops();
|
||||
int server_get_number_of_desktops();
|
||||
|
||||
#endif
|
||||
#endif
|
||||
@@ -52,7 +52,7 @@ int refresh_systray;
|
||||
int systray_enabled;
|
||||
int systray_max_icon_size;
|
||||
int systray_monitor;
|
||||
|
||||
int chrono;
|
||||
// background pixmap if we render ourselves the icons
|
||||
static Pixmap render_background;
|
||||
|
||||
@@ -61,8 +61,9 @@ void default_systray()
|
||||
{
|
||||
memset(&systray, 0, sizeof(Systraybar));
|
||||
render_background = 0;
|
||||
chrono = 0;
|
||||
systray.alpha = 100;
|
||||
systray.sort = 3;
|
||||
systray.sort = SYSTRAY_SORT_LEFT2RIGHT;
|
||||
systray.area._draw_foreground = draw_systray;
|
||||
systray.area._on_change_layout = on_change_systray;
|
||||
systray.area.size_mode = SIZE_BY_CONTENT;
|
||||
@@ -108,8 +109,9 @@ void init_systray_panel(void *p)
|
||||
GSList *l;
|
||||
int count = 0;
|
||||
for (l = systray.list_icons; l ; l = l->next) {
|
||||
if (!((TrayWindow*)l->data)->hide)
|
||||
count++;
|
||||
if (((TrayWindow*)l->data)->hide)
|
||||
continue;
|
||||
count++;
|
||||
}
|
||||
if (count == 0)
|
||||
hide(&systray.area);
|
||||
@@ -146,8 +148,9 @@ int resize_systray(void *obj)
|
||||
sysbar->icon_size = systray_max_icon_size;
|
||||
count = 0;
|
||||
for (l = systray.list_icons; l ; l = l->next) {
|
||||
if (!((TrayWindow*)l->data)->hide)
|
||||
count++;
|
||||
if (((TrayWindow*)l->data)->hide)
|
||||
continue;
|
||||
count++;
|
||||
}
|
||||
//printf("count %d\n", count);
|
||||
|
||||
@@ -194,11 +197,12 @@ void on_change_systray (void *obj)
|
||||
GSList *l;
|
||||
for (i=1, l = systray.list_icons; l ; i++, l = l->next) {
|
||||
traywin = (TrayWindow*)l->data;
|
||||
if (traywin->hide) continue;
|
||||
if (traywin->hide)
|
||||
continue;
|
||||
|
||||
traywin->y = posy;
|
||||
traywin->x = posx;
|
||||
//printf("systray %d : %d,%d\n", i, posx, posy);
|
||||
// printf("systray %d : pos %d, %d\n", traywin->tray_id, posx, posy);
|
||||
traywin->width = sysbar->icon_size;
|
||||
traywin->height = sysbar->icon_size;
|
||||
if (panel_horizontal) {
|
||||
@@ -336,21 +340,39 @@ static gint compare_traywindows(gconstpointer a, gconstpointer b)
|
||||
{
|
||||
const TrayWindow * traywin_a = (TrayWindow*)a;
|
||||
const TrayWindow * traywin_b = (TrayWindow*)b;
|
||||
XTextProperty name_a, name_b;
|
||||
|
||||
if(XGetWMName(server.dsp, traywin_a->tray_id, &name_a) == 0) {
|
||||
return -1;
|
||||
}
|
||||
else if(XGetWMName(server.dsp, traywin_b->tray_id, &name_b) == 0) {
|
||||
XFree(name_a.value);
|
||||
if (traywin_a->empty && !traywin_b->empty)
|
||||
return 1;
|
||||
if (!traywin_a->empty && traywin_b->empty)
|
||||
return -1;
|
||||
|
||||
if (systray.sort == SYSTRAY_SORT_ASCENDING ||
|
||||
systray.sort == SYSTRAY_SORT_DESCENDING) {
|
||||
XTextProperty name_a, name_b;
|
||||
|
||||
if (XGetWMName(server.dsp, traywin_a->tray_id, &name_a) == 0) {
|
||||
return -1;
|
||||
}
|
||||
else if (XGetWMName(server.dsp, traywin_b->tray_id, &name_b) == 0) {
|
||||
XFree(name_a.value);
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
gint retval = g_ascii_strncasecmp((char*)name_a.value, (char*)name_b.value, -1) *
|
||||
(systray.sort == SYSTRAY_SORT_ASCENDING ? 1 : -1);
|
||||
XFree(name_a.value);
|
||||
XFree(name_b.value);
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
else {
|
||||
gint retval = g_ascii_strncasecmp((char*)name_a.value, (char*)name_b.value, -1) * systray.sort;
|
||||
XFree(name_a.value);
|
||||
XFree(name_b.value);
|
||||
return retval;
|
||||
|
||||
if (systray.sort == SYSTRAY_SORT_LEFT2RIGHT ||
|
||||
systray.sort == SYSTRAY_SORT_RIGHT2LEFT) {
|
||||
return (traywin_a->chrono - traywin_b->chrono) *
|
||||
(systray.sort == SYSTRAY_SORT_LEFT2RIGHT ? 1 : -1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -361,12 +383,42 @@ gboolean add_icon(Window id)
|
||||
Panel *panel = systray.area.panel;
|
||||
int hide = 0;
|
||||
|
||||
int pid = 0;
|
||||
{
|
||||
Atom actual_type;
|
||||
int actual_format;
|
||||
unsigned long nitems;
|
||||
unsigned long bytes_after;
|
||||
unsigned char *prop = 0;
|
||||
int ret = XGetWindowProperty(server.dsp, id, server.atom._NET_WM_PID, 0, 1024, False, AnyPropertyType, &actual_type, &actual_format, &nitems, &bytes_after, &prop);
|
||||
if (ret == Success && prop) {
|
||||
pid = prop[1] * 256;
|
||||
pid += prop[0];
|
||||
}
|
||||
}
|
||||
|
||||
GSList *l;
|
||||
int num_empty_same_pid = 0;
|
||||
for (l = systray.list_icons; l; l = l->next) {
|
||||
if (((TrayWindow*)l->data)->tray_id == id)
|
||||
return FALSE;
|
||||
if (pid && ((TrayWindow*)l->data)->pid == pid && ((TrayWindow*)l->data)->empty)
|
||||
num_empty_same_pid++;
|
||||
}
|
||||
|
||||
const int max_num_empty_same_pid = 0;
|
||||
if (num_empty_same_pid > max_num_empty_same_pid) {
|
||||
for (l = systray.list_icons; l; l = l->next) {
|
||||
if (pid && ((TrayWindow*)l->data)->pid == pid && ((TrayWindow*)l->data)->empty) {
|
||||
num_empty_same_pid++;
|
||||
fprintf(stderr, "Removing tray icon %lu from misbehaving application with pid=%d\n", ((TrayWindow*)l->data)->tray_id, pid);
|
||||
remove_icon((TrayWindow*)l->data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
//printf("add_icon: %d, pid %d, %d\n", id, pid, num_empty_same_pid);
|
||||
|
||||
error = FALSE;
|
||||
XWindowAttributes attr;
|
||||
if ( XGetWindowAttributes(server.dsp, id, &attr) == False ) return FALSE;
|
||||
@@ -445,16 +497,19 @@ gboolean add_icon(Window id)
|
||||
traywin->hide = hide;
|
||||
traywin->depth = attr.depth;
|
||||
traywin->damage = 0;
|
||||
traywin->empty = 0;
|
||||
traywin->pid = pid;
|
||||
traywin->chrono = chrono;
|
||||
chrono++;
|
||||
|
||||
if (systray.area.on_screen == 0)
|
||||
show(&systray.area);
|
||||
|
||||
if (systray.sort == 3)
|
||||
if (systray.sort == SYSTRAY_SORT_RIGHT2LEFT)
|
||||
systray.list_icons = g_slist_prepend(systray.list_icons, traywin);
|
||||
else if (systray.sort == 2)
|
||||
systray.list_icons = g_slist_append(systray.list_icons, traywin);
|
||||
else
|
||||
systray.list_icons = g_slist_insert_sorted(systray.list_icons, traywin, compare_traywindows);
|
||||
systray.list_icons = g_slist_append(systray.list_icons, traywin);
|
||||
systray.list_icons = g_slist_sort(systray.list_icons, compare_traywindows);
|
||||
//printf("add_icon id %lx, %d\n", id, g_slist_length(systray.list_icons));
|
||||
|
||||
if (FORCE_COMPOSITED_RENDERING || server.real_transparency || systray.alpha != 100 || systray.brightness != 0 || systray.saturation != 0) {
|
||||
@@ -481,7 +536,7 @@ void remove_icon(TrayWindow *traywin)
|
||||
|
||||
// remove from our list
|
||||
systray.list_icons = g_slist_remove(systray.list_icons, traywin);
|
||||
//printf("remove_icon id %lx, %d\n", traywin->id);
|
||||
//printf("remove_icon: %d\n", traywin->tray_id);
|
||||
|
||||
XSelectInput(server.dsp, traywin->tray_id, NoEventMask);
|
||||
if (traywin->damage)
|
||||
@@ -503,8 +558,9 @@ void remove_icon(TrayWindow *traywin)
|
||||
int count = 0;
|
||||
GSList *l;
|
||||
for (l = systray.list_icons; l; l = l->next) {
|
||||
if (!((TrayWindow*)l->data)->hide)
|
||||
count++;
|
||||
if (((TrayWindow*)l->data)->hide)
|
||||
continue;
|
||||
count++;
|
||||
}
|
||||
if (count == 0)
|
||||
hide(&systray.area);
|
||||
@@ -546,6 +602,7 @@ void systray_render_icon_now(void* t)
|
||||
// we end up in this function only in real transparency mode or if systray_task_asb != 100 0 0
|
||||
// we made also sure, that we always have a 32 bit visual, i.e. we can safely create 32 bit pixmaps here
|
||||
TrayWindow* traywin = t;
|
||||
|
||||
traywin->render_timeout = 0;
|
||||
if ( traywin->width == 0 || traywin->height == 0 ) {
|
||||
// reschedule rendering since the geometry information has not yet been processed (can happen on slow cpu)
|
||||
@@ -553,6 +610,30 @@ void systray_render_icon_now(void* t)
|
||||
return;
|
||||
}
|
||||
|
||||
int empty = 1;
|
||||
XImage *ximage = XGetImage(server.dsp, traywin->tray_id, 0, 0, traywin->width, traywin->height, AllPlanes, XYPixmap);
|
||||
if (ximage) {
|
||||
XColor color;
|
||||
int x, y;
|
||||
for (x = 0; empty && x < traywin->width; x++) {
|
||||
for (y = 0; empty && y < traywin->height; y++) {
|
||||
color.pixel = XGetPixel(ximage, x, y);
|
||||
if (color.pixel != 0)
|
||||
empty = 0;
|
||||
}
|
||||
}
|
||||
XFree(ximage);
|
||||
}
|
||||
if (traywin->empty != empty) {
|
||||
traywin->empty = empty;
|
||||
systray.area.resize = 1;
|
||||
panel_refresh = 1;
|
||||
systray.list_icons = g_slist_sort(systray.list_icons, compare_traywindows);
|
||||
}
|
||||
//printf("systray_render_icon_now: %d empty %d\n", traywin->tray_id, empty);
|
||||
if (empty)
|
||||
return;
|
||||
|
||||
// good systray icons support 32 bit depth, but some icons are still 24 bit.
|
||||
// We create a heuristic mask for these icons, i.e. we get the rgb value in the top left corner, and
|
||||
// mask out all pixel with the same rgb value
|
||||
@@ -636,7 +717,8 @@ void refresh_systray_icon()
|
||||
GSList *l;
|
||||
for (l = systray.list_icons; l ; l = l->next) {
|
||||
traywin = (TrayWindow*)l->data;
|
||||
if (traywin->hide) continue;
|
||||
if (traywin->hide)
|
||||
continue;
|
||||
systray_render_icon(traywin);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
// Flags for _XEMBED_INFO
|
||||
#define XEMBED_MAPPED (1 << 0)
|
||||
|
||||
enum { SYSTRAY_SORT_ASCENDING, SYSTRAY_SORT_DESCENDING, SYSTRAY_SORT_LEFT2RIGHT, SYSTRAY_SORT_RIGHT2LEFT };
|
||||
|
||||
typedef struct {
|
||||
// always start with area
|
||||
@@ -43,6 +44,9 @@ typedef struct
|
||||
int depth;
|
||||
Damage damage;
|
||||
timeout* render_timeout;
|
||||
int empty;
|
||||
int pid;
|
||||
int chrono;
|
||||
} TrayWindow;
|
||||
|
||||
|
||||
|
||||
@@ -56,13 +56,17 @@ target_link_libraries( tint2conf ${X11_T2C_LIBRARIES}
|
||||
${RSVG_LIBRARIES} )
|
||||
|
||||
if ( NOT DATADIR )
|
||||
set( DATADIR share )
|
||||
set(DATADIR share)
|
||||
endif( NOT DATADIR )
|
||||
|
||||
add_definitions( -DINSTALL_PREFIX=\"${CMAKE_INSTALL_PREFIX}\" )
|
||||
add_definitions( -DLOCALEDIR=\"${CMAKE_INSTALL_PREFIX}/${DATADIR}/locale\" )
|
||||
add_definitions( -DGETTEXT_PACKAGE=\"tint2conf\" )
|
||||
set_target_properties( tint2conf PROPERTIES COMPILE_FLAGS "-Wall -pthread" )
|
||||
set_target_properties( tint2conf PROPERTIES LINK_FLAGS "-pthread" )
|
||||
|
||||
add_subdirectory(po)
|
||||
|
||||
install( TARGETS tint2conf DESTINATION bin )
|
||||
install( FILES tint2conf.svg DESTINATION ${DATADIR}/icons/hicolor/scalable/apps )
|
||||
install( FILES tint2conf.desktop DESTINATION ${DATADIR}/applications )
|
||||
|
||||
@@ -119,26 +119,12 @@ static const char *global_ui =
|
||||
" </popup>"
|
||||
"</ui>";
|
||||
|
||||
|
||||
// define menubar and toolbar action
|
||||
static GtkActionEntry entries[] = {
|
||||
{"ThemeMenu", NULL, _("Theme"), NULL, NULL, NULL},
|
||||
{"ThemeAdd", GTK_STOCK_ADD, _("_Import theme..."), "<Control>N", _("Import theme"), G_CALLBACK(menuImport)},
|
||||
{"ThemeDefault", GTK_STOCK_NEW, _("_Import default theme..."), NULL, _("Import default theme"), G_CALLBACK(menuImportDefault)},
|
||||
{"ThemeSaveAs", GTK_STOCK_SAVE_AS, _("_Save as..."), NULL, _("Save theme as"), G_CALLBACK(menuSaveAs)},
|
||||
{"ThemeDelete", GTK_STOCK_DELETE, _("_Delete"), NULL, _("Delete theme"), G_CALLBACK(menuDelete)},
|
||||
{"ThemeProperties", GTK_STOCK_PROPERTIES, _("_Edit theme..."), NULL, _("Edit selected theme"), G_CALLBACK(edit_current_theme)},
|
||||
{"ThemeQuit", GTK_STOCK_QUIT, _("_Quit"), "<control>Q", _("Quit"), G_CALLBACK(gtk_main_quit)},
|
||||
{"EditMenu", NULL, "Edit", NULL, NULL, NULL},
|
||||
{"EditRefresh", GTK_STOCK_REFRESH, _("Refresh"), NULL, _("Refresh"), G_CALLBACK(refresh_current_theme)},
|
||||
{"EditRefreshAll", GTK_STOCK_REFRESH, _("Refresh all"), NULL, _("Refresh all"), G_CALLBACK(load_all_themes)},
|
||||
{"HelpMenu", NULL, _("Help"), NULL, NULL, NULL},
|
||||
{"HelpAbout", GTK_STOCK_ABOUT, _("_About"), "<Control>A", _("About"), G_CALLBACK(menuAbout)}
|
||||
};
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
|
||||
bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
|
||||
textdomain(GETTEXT_PACKAGE);
|
||||
|
||||
GtkWidget *vBox = NULL, *scrollbar = NULL;
|
||||
GtkActionGroup *actionGroup;
|
||||
|
||||
@@ -167,6 +153,23 @@ int main(int argc, char **argv)
|
||||
gtk_container_add(GTK_CONTAINER(g_window), vBox);
|
||||
|
||||
actionGroup = gtk_action_group_new("menuActionGroup");
|
||||
|
||||
// Menubar and toolbar entries
|
||||
GtkActionEntry entries[] = {
|
||||
{"ThemeMenu", NULL, _("Theme"), NULL, NULL, NULL},
|
||||
{"ThemeAdd", GTK_STOCK_ADD, _("_Import theme..."), "<Control>N", _("Import theme"), G_CALLBACK(menuImport)},
|
||||
{"ThemeDefault", GTK_STOCK_NEW, _("_Import default theme..."), NULL, _("Import default theme"), G_CALLBACK(menuImportDefault)},
|
||||
{"ThemeSaveAs", GTK_STOCK_SAVE_AS, _("_Save as..."), NULL, _("Save theme as"), G_CALLBACK(menuSaveAs)},
|
||||
{"ThemeDelete", GTK_STOCK_DELETE, _("_Delete"), NULL, _("Delete theme"), G_CALLBACK(menuDelete)},
|
||||
{"ThemeProperties", GTK_STOCK_PROPERTIES, _("_Edit theme..."), NULL, _("Edit selected theme"), G_CALLBACK(edit_current_theme)},
|
||||
{"ThemeQuit", GTK_STOCK_QUIT, _("_Quit"), "<control>Q", _("Quit"), G_CALLBACK(gtk_main_quit)},
|
||||
{"EditMenu", NULL, _("Edit"), NULL, NULL, NULL},
|
||||
{"EditRefresh", GTK_STOCK_REFRESH, _("Refresh"), NULL, _("Refresh"), G_CALLBACK(refresh_current_theme)},
|
||||
{"EditRefreshAll", GTK_STOCK_REFRESH, _("Refresh all"), NULL, _("Refresh all"), G_CALLBACK(load_all_themes)},
|
||||
{"HelpMenu", NULL, _("Help"), NULL, NULL, NULL},
|
||||
{"HelpAbout", GTK_STOCK_ABOUT, _("_About"), "<Control>A", _("About"), G_CALLBACK(menuAbout)}
|
||||
};
|
||||
|
||||
gtk_action_group_add_actions(actionGroup, entries, G_N_ELEMENTS(entries), NULL);
|
||||
globalUIManager = gtk_ui_manager_new();
|
||||
gtk_ui_manager_insert_action_group(globalUIManager, actionGroup, 0);
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <glib/gi18n-lib.h>
|
||||
#else
|
||||
#define _(String) String
|
||||
#define GETTEXT_PACKAGE "tint2conf"
|
||||
#endif
|
||||
|
||||
#define SNAPSHOT_TICK 190
|
||||
|
||||
20
src/tint2conf/po/CMakeLists.txt
Normal file
20
src/tint2conf/po/CMakeLists.txt
Normal file
@@ -0,0 +1,20 @@
|
||||
include(FindGettext)
|
||||
if (GETTEXT_FOUND)
|
||||
set(GETTEXT_PACKAGE tint2conf)
|
||||
file(GLOB POTFILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.po")
|
||||
string(REPLACE ".po" " " LANGUAGES ${POTFILES})
|
||||
message(STATUS "gettext found languages: ${LANGUAGES}")
|
||||
string(REPLACE " " ";" LANGUAGES ${LANGUAGES})
|
||||
if ("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSION_LESS "2.8.8")
|
||||
GETTEXT_CREATE_TRANSLATIONS("${CMAKE_CURRENT_SOURCE_DIR}/tint2conf.pot" ALL ${POTFILES})
|
||||
else()
|
||||
foreach(LANG ${LANGUAGES})
|
||||
GETTEXT_PROCESS_PO_FILES(${LANG} ALL PO_FILES ${LANG}.po)
|
||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${LANG}.gmo"
|
||||
DESTINATION "${CMAKE_INSTALL_PREFIX}/${DATADIR}/locale/${LANG}/LC_MESSAGES"
|
||||
RENAME "${GETTEXT_PACKAGE}.mo")
|
||||
endforeach ()
|
||||
endif()
|
||||
else ()
|
||||
message(STATUS "gettext not found")
|
||||
endif ()
|
||||
1583
src/tint2conf/po/fr.po
Normal file
1583
src/tint2conf/po/fr.po
Normal file
File diff suppressed because it is too large
Load Diff
1583
src/tint2conf/po/tint2conf.pot
Normal file
1583
src/tint2conf/po/tint2conf.pot
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user