]> Dogcows Code - chaz/tint2/commitdiff
fixed issue 130 by maato
authorThierry Lorthiois <lorthiois@bbsoft.fr>
Sat, 29 Aug 2009 22:09:29 +0000 (22:09 +0000)
committerThierry Lorthiois <lorthiois@bbsoft.fr>
Sat, 29 Aug 2009 22:09:29 +0000 (22:09 +0000)
ChangeLog
src/config.c
src/systray/systraybar.c
src/systray/systraybar.h

index f78eedb1e716a36a1592213597c4084c764c727a..235dfcd62897891e06863f60eb31220c1ece08e8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2009-08-30
+- fixed issue 130 by maato
+  ordered systray icon with config "systray_sort = asc/desc"
+
 2009-08-29
 - fixed issue 134
 
index 10fd1aae0065baf90c8e7e8432b11f16754f75a3..a7d11a28645354ad66019e0c5b6f809ff33fa1bc 100644 (file)
@@ -84,6 +84,7 @@ void init_config()
    list_back = g_slist_append(0, calloc(1, sizeof(Area)));
 
        panel_config = calloc(1, sizeof(Panel));
+       systray.sort = 1;
        // window manager's menu default value == false
        wm_menu = 0;
        max_tick_urgent = 7;
@@ -557,6 +558,12 @@ void add_entry (char *key, char *value)
       memcpy(&systray.area.pix.back, &a->pix.back, sizeof(Color));
       memcpy(&systray.area.pix.border, &a->pix.border, sizeof(Border));
    }
+       else if (strcmp(key, "systray_sort") == 0) {
+               if (strcmp(value, "desc") == 0)
+                       systray.sort = -1;
+               else
+                       systray.sort = 1;
+       }
 
    /* Mouse actions */
    else if (strcmp (key, "mouse_middle") == 0)
index 069a3fc8aa998a7f103699d2889e2f310f85acc1..c135077eff6515485f375bd5dc3a0c9455ee017f 100644 (file)
@@ -227,6 +227,28 @@ int window_error_handler(Display *d, XErrorEvent *e)
 }
 
 
+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->id, &name_a) == 0) {
+               return -1;
+       }
+       else if(XGetWMName(server.dsp, traywin_b->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;
+               XFree(name_a.value);
+               XFree(name_b.value);
+               return retval;
+       }
+}
+
+
 gboolean add_icon(Window id)
 {
        TrayWindow *traywin;
@@ -276,7 +298,8 @@ gboolean add_icon(Window id)
        traywin = g_new0(TrayWindow, 1);
        traywin->id = id;
 
-       systray.list_icons = g_slist_prepend(systray.list_icons, traywin);
+//     systray.list_icons = g_slist_prepend(systray.list_icons, traywin);
+       systray.list_icons = g_slist_insert_sorted(systray.list_icons, traywin, compare_traywindows);
        systray.area.resize = 1;
        systray.area.redraw = 1;
        //printf("add_icon id %lx, %d\n", id, g_slist_length(systray.list_icons));
index 03c031362b77b3bd057ffead9c4caf479818ab0a..d9f43bb0d2ff4411210100c0a049f2e320b15df4 100644 (file)
@@ -24,6 +24,7 @@ typedef struct {
    Area area;
 
        GSList *list_icons;
+       int sort;
 } Systraybar;
 
 
This page took 0.051767 seconds and 4 git commands to generate.