all repos — tint2 @ 737150d7e97df32b03eec062a3eb955145950663

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

Work better with empty config files
o9000 mrovi9000@gmail.com
commit

737150d7e97df32b03eec062a3eb955145950663

parent

80794109ae14d4ffaa2081125a02fdd145c83df6

4 files changed, 52 insertions(+), 20 deletions(-)

jump to
M src/clock/clock.hsrc/clock/clock.h

@@ -37,7 +37,7 @@ extern char *clock_mclick_command;

extern char *clock_rclick_command; extern char *clock_uwheel_command; extern char *clock_dwheel_command; -extern int clock_enabled; +extern gboolean clock_enabled; // default global data void default_clock();
M src/config.csrc/config.c

@@ -69,18 +69,20 @@

// -------------------------------------------------- // backward compatibility // detect if it's an old config file (==1) -static int new_config_file; +static gboolean new_config_file; -static int read_bg_color_hover; -static int read_border_color_hover; -static int read_bg_color_press; -static int read_border_color_press; +static gboolean read_bg_color_hover; +static gboolean read_border_color_hover; +static gboolean read_bg_color_press; +static gboolean read_border_color_press; +static gboolean read_panel_position; void default_config() { config_path = NULL; snapshot_path = NULL; - new_config_file = 0; + new_config_file = FALSE; + read_panel_position = FALSE; } void cleanup_config()

@@ -318,7 +320,7 @@ }

panel_config.area.height = atoi(value2); } } else if (strcmp(key, "panel_items") == 0) { - new_config_file = 1; + new_config_file = TRUE; panel_items_order = strdup(value); systray_enabled = 0; launcher_enabled = 0;

@@ -360,6 +362,7 @@ panel_config.area.paddingy = atoi(value2);

if (value3) panel_config.area.paddingx = atoi(value3); } else if (strcmp(key, "panel_position") == 0) { + read_panel_position = TRUE; extract_values(value, &value1, &value2, &value3); if (strcmp(value1, "top") == 0) panel_position = TOP;

@@ -620,19 +623,20 @@ }

/* Clock */ else if (strcmp(key, "time1_format") == 0) { - if (new_config_file == 0) { - clock_enabled = 1; + if (!new_config_file) { + clock_enabled = TRUE; if (panel_items_order) { gchar *tmp = g_strconcat(panel_items_order, "C", NULL); free(panel_items_order); panel_items_order = strdup(tmp); g_free(tmp); - } else + } else { panel_items_order = strdup("C"); + } } if (strlen(value) > 0) { time1_format = strdup(value); - clock_enabled = 1; + clock_enabled = TRUE; } } else if (strcmp(key, "time2_format") == 0) { if (strlen(value) > 0)

@@ -846,8 +850,8 @@ panel_config.g_task.tooltip_enabled = atoi(value);

/* Systray */ else if (strcmp(key, "systray_padding") == 0) { - if (new_config_file == 0 && systray_enabled == 0) { - systray_enabled = 1; + if (!new_config_file && systray_enabled == 0) { + systray_enabled = TRUE; if (panel_items_order) { gchar *tmp = g_strconcat(panel_items_order, "S", NULL); free(panel_items_order);

@@ -1006,7 +1010,7 @@ }

// old config option else if (strcmp(key, "systray") == 0) { - if (new_config_file == 0) { + if (!new_config_file) { systray_enabled = atoi(value); if (systray_enabled) { if (panel_items_order) {

@@ -1021,7 +1025,7 @@ }

} #ifdef ENABLE_BATTERY else if (strcmp(key, "battery") == 0) { - if (new_config_file == 0) { + if (!new_config_file) { battery_enabled = atoi(value); if (battery_enabled) { if (panel_items_order) {

@@ -1064,16 +1068,22 @@ }

} fclose(fp); + if (!read_panel_position) { + panel_horizontal = TRUE; + panel_position = BOTTOM; + } + // append Taskbar item - if (new_config_file == 0) { - taskbar_enabled = 1; + if (!new_config_file) { + taskbar_enabled = TRUE; if (panel_items_order) { gchar *tmp = g_strconcat("T", panel_items_order, NULL); free(panel_items_order); panel_items_order = strdup(tmp); g_free(tmp); - } else + } else { panel_items_order = strdup("T"); + } } if (backgrounds->len > 0) {
M src/panel.csrc/panel.c

@@ -156,6 +156,8 @@ fprintf(stderr, "warning : monitor not found. tint2 default to all monitors.\n");

panel_config.monitor = 0; } + fprintf(stderr, "panel items: %s\n", panel_items_order); + init_tooltip(); init_systray(); init_launcher();

@@ -269,6 +271,14 @@ void init_panel_size_and_position(Panel *panel)

{ // detect panel size if (panel_horizontal) { + if (panel->area.width == 0) { + panel->fractional_width = TRUE; + panel->area.width = 100; + } + if (panel->area.height == 0) { + panel->fractional_height = FALSE; + panel->area.height = 32; + } if (panel->fractional_width) panel->area.width = (float)server.monitors[panel->monitor].width * panel->area.width / 100; if (panel->fractional_height)

@@ -282,6 +292,14 @@ panel->area.bg = &g_array_index(backgrounds, Background, backgrounds->len - 1);

panel->area.bg->border.radius = panel->area.height / 2; } } else { + if (panel->area.height == 0) { + panel->fractional_height = TRUE; + panel->area.height = 100; + } + if (panel->area.width == 0) { + panel->fractional_width = FALSE; + panel->area.width = 140; + } int old_panel_height = panel->area.height; if (panel->fractional_width) panel->area.height = (float)server.monitors[panel->monitor].height * panel->area.width / 100;
M src/taskbar/taskbar.csrc/taskbar/taskbar.c

@@ -122,6 +122,10 @@ }

void init_taskbar() { + if (!panel_config.g_task.text && !panel_config.g_task.icon) { + panel_config.g_task.text = panel_config.g_task.icon = 1; + } + if (!win_to_task) win_to_task = g_hash_table_new_full(win_hash, win_compare, free, free_ptr_array);

@@ -204,7 +208,7 @@ panel->g_task.saturation[TASK_URGENT] = panel->g_task.saturation[TASK_ACTIVE];

panel->g_task.brightness[TASK_URGENT] = panel->g_task.brightness[TASK_ACTIVE]; } if ((panel->g_task.config_font_mask & (1 << TASK_NORMAL)) == 0) - panel->g_task.font[TASK_NORMAL] = (Color){{0, 0, 0}, 0}; + panel->g_task.font[TASK_NORMAL] = (Color){{1, 1, 1}, 1}; if ((panel->g_task.config_font_mask & (1 << TASK_ACTIVE)) == 0) panel->g_task.font[TASK_ACTIVE] = panel->g_task.font[TASK_NORMAL]; if ((panel->g_task.config_font_mask & (1 << TASK_ICONIFIED)) == 0)