added basic launcher by mrovi
git-svn-id: http://tint2.googlecode.com/svn/trunk@521 121b4492-b84c-0410-8b4c-0d4edfb3f3cc
This commit is contained in:
parent
73c0b524af
commit
7e17a3c7f0
5 changed files with 109 additions and 3 deletions
|
@ -29,6 +29,7 @@ include_directories( ${PROJECT_BINARY_DIR}
|
||||||
src/clock
|
src/clock
|
||||||
src/systray
|
src/systray
|
||||||
src/taskbar
|
src/taskbar
|
||||||
|
src/launcher
|
||||||
src/tooltip
|
src/tooltip
|
||||||
src/util
|
src/util
|
||||||
${X11_INCLUDE_DIRS}
|
${X11_INCLUDE_DIRS}
|
||||||
|
@ -45,6 +46,7 @@ set( SOURCES src/config.c
|
||||||
src/tint.c
|
src/tint.c
|
||||||
src/clock/clock.c
|
src/clock/clock.c
|
||||||
src/systray/systraybar.c
|
src/systray/systraybar.c
|
||||||
|
src/launcher/launcher.c
|
||||||
src/taskbar/task.c
|
src/taskbar/task.c
|
||||||
src/taskbar/taskbar.c
|
src/taskbar/taskbar.c
|
||||||
src/tooltip/tooltip.c
|
src/tooltip/tooltip.c
|
||||||
|
|
33
src/config.c
33
src/config.c
|
@ -41,6 +41,7 @@
|
||||||
#include "task.h"
|
#include "task.h"
|
||||||
#include "taskbar.h"
|
#include "taskbar.h"
|
||||||
#include "systraybar.h"
|
#include "systraybar.h"
|
||||||
|
#include "launcher.h"
|
||||||
#include "clock.h"
|
#include "clock.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
|
@ -500,12 +501,13 @@ void add_entry (char *key, char *value)
|
||||||
// systray disabled in snapshot mode
|
// systray disabled in snapshot mode
|
||||||
else if (strcmp (key, "systray") == 0 && snapshot_path == 0) {
|
else if (strcmp (key, "systray") == 0 && snapshot_path == 0) {
|
||||||
systray_enabled = atoi(value);
|
systray_enabled = atoi(value);
|
||||||
// systray is latest option added. files without 'systray' are old.
|
|
||||||
old_config_file = 0;
|
old_config_file = 0;
|
||||||
}
|
}
|
||||||
else if (strcmp (key, "systray_padding") == 0 && snapshot_path == 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;
|
systray_enabled = 1;
|
||||||
|
}
|
||||||
extract_values(value, &value1, &value2, &value3);
|
extract_values(value, &value1, &value2, &value3);
|
||||||
systray.area.paddingxlr = systray.area.paddingx = atoi (value1);
|
systray.area.paddingxlr = systray.area.paddingx = atoi (value1);
|
||||||
if (value2) systray.area.paddingy = atoi (value2);
|
if (value2) systray.area.paddingy = atoi (value2);
|
||||||
|
@ -536,6 +538,33 @@ void add_entry (char *key, char *value)
|
||||||
systray.brightness = atoi(value3);
|
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 */
|
/* Tooltip */
|
||||||
else if (strcmp (key, "tooltip") == 0)
|
else if (strcmp (key, "tooltip") == 0)
|
||||||
g_tooltip.enabled = atoi(value);
|
g_tooltip.enabled = atoi(value);
|
||||||
|
|
50
src/panel.c
50
src/panel.c
|
@ -134,6 +134,7 @@ void init_panel()
|
||||||
|
|
||||||
init_tooltip();
|
init_tooltip();
|
||||||
init_systray();
|
init_systray();
|
||||||
|
init_launcher();
|
||||||
init_clock();
|
init_clock();
|
||||||
#ifdef ENABLE_BATTERY
|
#ifdef ENABLE_BATTERY
|
||||||
init_battery();
|
init_battery();
|
||||||
|
@ -178,6 +179,10 @@ void init_panel()
|
||||||
p->area.list = g_slist_append(p->area.list, &p->battery);
|
p->area.list = g_slist_append(p->area.list, &p->battery);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
if (launcher_enabled) {
|
||||||
|
init_launcher_panel(p);
|
||||||
|
p->area.list = g_slist_append(p->area.list, &p->launcher);
|
||||||
|
}
|
||||||
// systray only on first panel
|
// systray only on first panel
|
||||||
if (systray.area.on_screen && i == 0) {
|
if (systray.area.on_screen && i == 0) {
|
||||||
init_systray_panel(p);
|
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);
|
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)
|
if (panel->clock.area.on_screen && panel->clock.area.width)
|
||||||
taskbar_width -= (panel->clock.area.width + panel->area.paddingx);
|
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
|
#ifdef ENABLE_BATTERY
|
||||||
if (panel->battery.area.on_screen && panel->battery.area.width)
|
if (panel->battery.area.on_screen && panel->battery.area.width)
|
||||||
taskbar_width -= (panel->battery.area.width + panel->area.paddingx);
|
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
|
// change posx and width for all taskbar
|
||||||
int i, posx;
|
int i, posx;
|
||||||
posx = panel->area.bg->border.width + panel->area.paddingxlr;
|
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++) {
|
for (i=0 ; i < panel->nb_desktop ; i++) {
|
||||||
panel->taskbar[i].area.posx = posx;
|
panel->taskbar[i].area.posx = posx;
|
||||||
panel->taskbar[i].area.width = taskbar_width;
|
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);
|
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)
|
if (panel->clock.area.on_screen && panel->clock.area.height)
|
||||||
taskbar_height -= (panel->clock.area.height + panel->area.paddingx);
|
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
|
#ifdef ENABLE_BATTERY
|
||||||
if (panel->battery.area.on_screen && panel->battery.area.height)
|
if (panel->battery.area.on_screen && panel->battery.area.height)
|
||||||
taskbar_height -= (panel->battery.area.height + panel->area.paddingx);
|
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);
|
taskbar_height -= (systray.area.height + panel->area.paddingx);
|
||||||
|
|
||||||
posy = panel->area.height - panel->area.bg->border.width - panel->area.paddingxlr - taskbar_height;
|
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) {
|
if (panel_mode == MULTI_DESKTOP) {
|
||||||
int height = taskbar_height - ((panel->nb_desktop-1) * panel->area.paddingx);
|
int height = taskbar_height - ((panel->nb_desktop-1) * panel->area.paddingx);
|
||||||
taskbar_height = height / panel->nb_desktop;
|
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)
|
int click_padding(Panel *panel, int x, int y)
|
||||||
{
|
{
|
||||||
if (panel_horizontal) {
|
if (panel_horizontal) {
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include "task.h"
|
#include "task.h"
|
||||||
#include "taskbar.h"
|
#include "taskbar.h"
|
||||||
#include "systraybar.h"
|
#include "systraybar.h"
|
||||||
|
#include "launcher.h"
|
||||||
|
|
||||||
#ifdef ENABLE_BATTERY
|
#ifdef ENABLE_BATTERY
|
||||||
#include "battery.h"
|
#include "battery.h"
|
||||||
|
@ -107,6 +108,8 @@ typedef struct {
|
||||||
Battery battery;
|
Battery battery;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Launcher launcher;
|
||||||
|
|
||||||
// autohide
|
// autohide
|
||||||
int is_hidden;
|
int is_hidden;
|
||||||
int hidden_width, hidden_height;
|
int hidden_width, hidden_height;
|
||||||
|
@ -144,6 +147,8 @@ Panel *get_panel(Window win);
|
||||||
|
|
||||||
Taskbar *click_taskbar (Panel *panel, int x, int y);
|
Taskbar *click_taskbar (Panel *panel, int x, int y);
|
||||||
Task *click_task (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_padding(Panel *panel, int x, int y);
|
||||||
int click_clock(Panel *panel, int x, int y);
|
int click_clock(Panel *panel, int x, int y);
|
||||||
Area* click_area(Panel *panel, int x, int y);
|
Area* click_area(Panel *panel, int x, int y);
|
||||||
|
|
22
src/tint.c
22
src/tint.c
|
@ -38,6 +38,7 @@
|
||||||
#include "task.h"
|
#include "task.h"
|
||||||
#include "taskbar.h"
|
#include "taskbar.h"
|
||||||
#include "systraybar.h"
|
#include "systraybar.h"
|
||||||
|
#include "launcher.h"
|
||||||
#include "panel.h"
|
#include "panel.h"
|
||||||
#include "tooltip.h"
|
#include "tooltip.h"
|
||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
|
@ -63,6 +64,7 @@ void init (int argc, char *argv[])
|
||||||
default_battery();
|
default_battery();
|
||||||
#endif
|
#endif
|
||||||
default_clock();
|
default_clock();
|
||||||
|
default_launcher();
|
||||||
default_taskbar();
|
default_taskbar();
|
||||||
default_tooltip();
|
default_tooltip();
|
||||||
default_panel();
|
default_panel();
|
||||||
|
@ -159,6 +161,7 @@ void cleanup()
|
||||||
cleanup_panel();
|
cleanup_panel();
|
||||||
cleanup_tooltip();
|
cleanup_tooltip();
|
||||||
cleanup_clock();
|
cleanup_clock();
|
||||||
|
cleanup_launcher();
|
||||||
#ifdef ENABLE_BATTERY
|
#ifdef ENABLE_BATTERY
|
||||||
cleanup_battery();
|
cleanup_battery();
|
||||||
#endif
|
#endif
|
||||||
|
@ -278,7 +281,15 @@ int tint2_handles_click(Panel* panel, XButtonEvent* e)
|
||||||
else
|
else
|
||||||
return 0;
|
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);
|
Taskbar *tskbar = click_taskbar(panel, e->x, e->y);
|
||||||
if (tskbar && e->button == 1 && panel_mode == MULTI_DESKTOP)
|
if (tskbar && e->button == 1 && panel_mode == MULTI_DESKTOP)
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -421,6 +432,15 @@ void event_button_release (XEvent *e)
|
||||||
return;
|
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;
|
Taskbar *tskbar;
|
||||||
if ( !(tskbar = click_taskbar(panel, e->xbutton.x, e->xbutton.y)) ) {
|
if ( !(tskbar = click_taskbar(panel, e->xbutton.x, e->xbutton.y)) ) {
|
||||||
// TODO: check better solution to keep window below
|
// TODO: check better solution to keep window below
|
||||||
|
|
Loading…
Reference in a new issue