]> Dogcows Code - chaz/tint2/commitdiff
added basic launcher by mrovi
authorThierry Lorthiois <lorthiois@bbsoft.fr>
Mon, 2 Aug 2010 17:12:07 +0000 (17:12 +0000)
committerThierry Lorthiois <lorthiois@bbsoft.fr>
Mon, 2 Aug 2010 17:12:07 +0000 (17:12 +0000)
CMakeLists.txt
src/config.c
src/panel.c
src/panel.h
src/tint.c

index 3c41921d23b9d4d630a8f08494befce730a80a5e..483834e1c160b5d7800483a303173e32c2945abc 100644 (file)
@@ -29,6 +29,7 @@ include_directories( ${PROJECT_BINARY_DIR}
                      src/clock
                      src/systray
                      src/taskbar
+                     src/launcher
                      src/tooltip
                      src/util
                      ${X11_INCLUDE_DIRS}
@@ -45,6 +46,7 @@ set( SOURCES src/config.c
              src/tint.c
              src/clock/clock.c
              src/systray/systraybar.c
+             src/launcher/launcher.c
              src/taskbar/task.c
              src/taskbar/taskbar.c
              src/tooltip/tooltip.c
index 22d6f6f241b10bea549c943614f12c09bf345732..756a6339ffa771e48d1e0a3dad3ab5f0227f3f15 100644 (file)
@@ -41,6 +41,7 @@
 #include "task.h"
 #include "taskbar.h"
 #include "systraybar.h"
+#include "launcher.h"
 #include "clock.h"
 #include "config.h"
 #include "window.h"
@@ -500,12 +501,13 @@ void add_entry (char *key, char *value)
        // systray disabled in snapshot mode
        else if (strcmp (key, "systray") == 0 && snapshot_path == 0) {
                systray_enabled = atoi(value);
-               // systray is latest option added. files without 'systray' are old.
                old_config_file = 0;
        }
        else if (strcmp (key, "systray_padding") == 0 && snapshot_path == 0) {
-               if (old_config_file)
+               if (old_config_file) {
+                       // if tint2rc is an old config file, systray_padding enabled the systray bar.
                        systray_enabled = 1;
+               }
                extract_values(value, &value1, &value2, &value3);
                systray.area.paddingxlr = systray.area.paddingx = atoi (value1);
                if (value2) systray.area.paddingy = atoi (value2);
@@ -536,6 +538,33 @@ void add_entry (char *key, char *value)
                systray.brightness = atoi(value3);
        }
 
+       /* Launcher */
+       else if (strcmp (key, "launcher") == 0) {
+               launcher_enabled = atoi(value);
+       }
+       else if (strcmp (key, "launcher_padding") == 0) {
+               extract_values(value, &value1, &value2, &value3);
+               panel_config.launcher.area.paddingxlr = panel_config.launcher.area.paddingx = atoi (value1);
+               if (value2) panel_config.launcher.area.paddingy = atoi (value2);
+               if (value3) panel_config.launcher.area.paddingx = atoi (value3);
+       }
+       else if (strcmp (key, "launcher_background_id") == 0) {
+               int id = atoi (value);
+               id = (id < backgrounds->len && id >= 0) ? id : 0;
+               panel_config.launcher.area.bg = &g_array_index(backgrounds, Background, id);
+       }
+       else if (strcmp(key, "launcher_icon_size") == 0) {
+               launcher_max_icon_size = atoi(value);
+       }
+       else if (strcmp(key, "launcher_item_icon") == 0) {
+               char *path = strdup(value);
+               panel_config.launcher.list_icon_paths = g_slist_append(panel_config.launcher.list_icon_paths, path);
+       }
+       else if (strcmp(key, "launcher_item_cmd") == 0) {
+               char *cmd = strdup(value);
+               panel_config.launcher.list_cmds = g_slist_append(panel_config.launcher.list_cmds, cmd);
+       }
+
        /* Tooltip */
        else if (strcmp (key, "tooltip") == 0)
                g_tooltip.enabled = atoi(value);
index 5e06fff0ef824cc89654a8af4a90f3b84278c0db..662c6c5d1f5406e85ce4fafaf5d1efe7e9dc263a 100644 (file)
@@ -134,6 +134,7 @@ void init_panel()
 
        init_tooltip();
        init_systray();
+       init_launcher();
        init_clock();
 #ifdef ENABLE_BATTERY
        init_battery();
@@ -178,6 +179,10 @@ void init_panel()
                        p->area.list = g_slist_append(p->area.list, &p->battery);
                }
 #endif
+               if (launcher_enabled) {
+                       init_launcher_panel(p);
+                       p->area.list = g_slist_append(p->area.list, &p->launcher);
+               }
                // systray only on first panel
                if (systray.area.on_screen && i == 0) {
                        init_systray_panel(p);
@@ -305,6 +310,8 @@ void resize_panel(void *obj)
                taskbar_width = panel->area.width - (2 * panel->area.paddingxlr) - (2 * panel->area.bg->border.width);
                if (panel->clock.area.on_screen && panel->clock.area.width)
                        taskbar_width -= (panel->clock.area.width + panel->area.paddingx);
+               if (panel->launcher.area.on_screen && panel->launcher.area.width)
+                       taskbar_width -= (panel->launcher.area.width + panel->area.paddingx);
        #ifdef ENABLE_BATTERY
                if (panel->battery.area.on_screen && panel->battery.area.width)
                        taskbar_width -= (panel->battery.area.width + panel->area.paddingx);
@@ -322,6 +329,8 @@ void resize_panel(void *obj)
                // change posx and width for all taskbar
                int i, posx;
                posx = panel->area.bg->border.width + panel->area.paddingxlr;
+               if (panel->launcher.area.on_screen && panel->launcher.area.width)
+                       posx += (panel->launcher.area.width + panel->area.paddingx);
                for (i=0 ; i < panel->nb_desktop ; i++) {
                        panel->taskbar[i].area.posx = posx;
                        panel->taskbar[i].area.width = taskbar_width;
@@ -342,6 +351,8 @@ void resize_panel(void *obj)
                taskbar_height = panel->area.height - (2 * panel->area.paddingxlr) - (2 * panel->area.bg->border.width);
                if (panel->clock.area.on_screen && panel->clock.area.height)
                        taskbar_height -= (panel->clock.area.height + panel->area.paddingx);
+               if (panel->launcher.area.on_screen && panel->launcher.area.height)
+                       taskbar_height -= (panel->launcher.area.height + panel->area.paddingx);
        #ifdef ENABLE_BATTERY
                if (panel->battery.area.on_screen && panel->battery.area.height)
                        taskbar_height -= (panel->battery.area.height + panel->area.paddingx);
@@ -351,6 +362,8 @@ void resize_panel(void *obj)
                        taskbar_height -= (systray.area.height + panel->area.paddingx);
 
                posy = panel->area.height - panel->area.bg->border.width - panel->area.paddingxlr - taskbar_height;
+               if (panel->launcher.area.on_screen && panel->launcher.area.height)
+                       posy -= (panel->launcher.area.height + panel->area.paddingx);
                if (panel_mode == MULTI_DESKTOP) {
                        int height = taskbar_height - ((panel->nb_desktop-1) * panel->area.paddingx);
                        taskbar_height = height / panel->nb_desktop;
@@ -647,6 +660,43 @@ Task *click_task (Panel *panel, int x, int y)
 }
 
 
+Launcher *click_launcher (Panel *panel, int x, int y)
+{
+       Launcher *launcher = &panel->launcher;
+       
+       if (panel_horizontal) {
+               if (launcher->area.on_screen && x >= launcher->area.posx && x <= (launcher->area.posx + launcher->area.width))
+                       return launcher;
+       }
+       else {
+               if (launcher->area.on_screen && y >= launcher->area.posy && y <= (launcher->area.posy + launcher->area.height))
+                       return launcher;
+       }
+       return NULL;
+}
+
+
+LauncherIcon *click_launcher_icon (Panel *panel, int x, int y)
+{
+       GSList *l0;
+       Launcher *launcher;
+
+       //printf("Click x=%d y=%d\n", x, y);
+       if ( (launcher = click_launcher(panel, x, y)) ) {
+               LauncherIcon *icon;
+               for (l0 = launcher->list_icons; l0 ; l0 = l0->next) {
+                       icon = l0->data;
+                       if (x >= (launcher->area.posx + icon->x) && x <= (launcher->area.posx + icon->x + icon->width) &&
+                               y >= (launcher->area.posy + icon->y) && y <= (launcher->area.posy + icon->y + icon->height)) {
+                               //printf("Hit rect x=%d y=%d xmax=%d ymax=%d\n", launcher->area.posx + icon->x, launcher->area.posy + icon->y, launcher->area.posx + icon->x + icon->width, launcher->area.posy + icon->y + icon->height);
+                               return icon;
+                       }
+               }
+       }
+       return NULL;
+}
+
+
 int click_padding(Panel *panel, int x, int y)
 {
        if (panel_horizontal) {
index c367213511807d698a80777e6ed17095d24d7440..8bad2e718948f4697af763499866061add107aa5 100644 (file)
@@ -19,6 +19,7 @@
 #include "task.h"
 #include "taskbar.h"
 #include "systraybar.h"
+#include "launcher.h"
 
 #ifdef ENABLE_BATTERY
 #include "battery.h"
@@ -107,6 +108,8 @@ typedef struct {
        Battery battery;
 #endif
 
+       Launcher launcher;
+
        // autohide
        int is_hidden;
        int hidden_width, hidden_height;
@@ -144,6 +147,8 @@ Panel *get_panel(Window win);
 
 Taskbar *click_taskbar (Panel *panel, int x, int y);
 Task *click_task (Panel *panel, int x, int y);
+Launcher *click_launcher (Panel *panel, int x, int y);
+LauncherIcon *click_launcher_icon (Panel *panel, int x, int y);
 int click_padding(Panel *panel, int x, int y);
 int click_clock(Panel *panel, int x, int y);
 Area* click_area(Panel *panel, int x, int y);
index 4f5c67372f18132a3f27b4f7c51e33001176888b..67cb81ca20ddbd5eea0bee9f9c461b6391ad4eb1 100644 (file)
@@ -38,6 +38,7 @@
 #include "task.h"
 #include "taskbar.h"
 #include "systraybar.h"
+#include "launcher.h"
 #include "panel.h"
 #include "tooltip.h"
 #include "timer.h"
@@ -63,6 +64,7 @@ void init (int argc, char *argv[])
        default_battery();
 #endif
        default_clock();
+       default_launcher();
        default_taskbar();
        default_tooltip();
        default_panel();
@@ -159,6 +161,7 @@ void cleanup()
        cleanup_panel();
        cleanup_tooltip();
        cleanup_clock();
+       cleanup_launcher();
 #ifdef ENABLE_BATTERY
        cleanup_battery();
 #endif
@@ -278,7 +281,15 @@ int tint2_handles_click(Panel* panel, XButtonEvent* e)
                else
                        return 0;
        }
-       // no task clicked --> check if taskbar clicked
+       LauncherIcon *icon = click_launcher_icon(panel, e->x, e->y);
+       if (icon) {
+               if (e->button == 1) {
+                       return 1;
+               } else {
+                       return 0;
+               }
+       }
+       // no launcher/task clicked --> check if taskbar clicked
        Taskbar *tskbar = click_taskbar(panel, e->x, e->y);
        if (tskbar && e->button == 1 && panel_mode == MULTI_DESKTOP)
                return 1;
@@ -421,6 +432,15 @@ void event_button_release (XEvent *e)
                return;
        }
 
+       if ( click_launcher(panel, e->xbutton.x, e->xbutton.y)) {
+               LauncherIcon *icon = click_launcher_icon(panel, e->xbutton.x, e->xbutton.y);
+               if (icon) {
+                       launcher_action(icon);
+               }
+               task_drag = 0;
+               return;
+       }
+
        Taskbar *tskbar;
        if ( !(tskbar = click_taskbar(panel, e->xbutton.x, e->xbutton.y)) ) {
                // TODO: check better solution to keep window below
This page took 0.031118 seconds and 4 git commands to generate.