all repos — tint2 @ affac4cfa6b1f1393070f60ad3173cd1da1e6ed0

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

Changed indentation everywhere
o9000 mrovi9000@gmail.com
commit

affac4cfa6b1f1393070f60ad3173cd1da1e6ed0

parent

c1e5a7b172a8a76dc89d57d178a1fb5df078a7ba

68 files changed, 23203 insertions(+), 22864 deletions(-)

jump to
M src/battery/battery.csrc/battery/battery.c

@@ -56,7 +56,7 @@ char *battery_uwheel_command;

char *battery_dwheel_command; gboolean battery_found; -char *battery_sys_prefix = (char*)""; +char *battery_sys_prefix = (char *)""; void battery_init_fonts(); char *battery_get_tooltip(void *obj);

@@ -65,407 +65,397 @@ void battery_dump_geometry(void *obj, int indent);

void default_battery() { - battery_enabled = FALSE; - battery_tooltip_enabled = TRUE; - battery_found = FALSE; - percentage_hide = 101; - battery_low_cmd_sent = FALSE; - battery_timeout = NULL; - bat1_has_font = FALSE; - bat1_font_desc = NULL; - bat2_has_font = FALSE; - bat2_font_desc = NULL; - ac_connected_cmd = NULL; - ac_disconnected_cmd = NULL; - battery_low_cmd = NULL; - battery_lclick_command = NULL; - battery_mclick_command = NULL; - battery_rclick_command = NULL; - battery_uwheel_command = NULL; - battery_dwheel_command = NULL; - battery_state.percentage = 0; - battery_state.time.hours = 0; - battery_state.time.minutes = 0; - battery_state.time.seconds = 0; - battery_state.state = BATTERY_UNKNOWN; + battery_enabled = FALSE; + battery_tooltip_enabled = TRUE; + battery_found = FALSE; + percentage_hide = 101; + battery_low_cmd_sent = FALSE; + battery_timeout = NULL; + bat1_has_font = FALSE; + bat1_font_desc = NULL; + bat2_has_font = FALSE; + bat2_font_desc = NULL; + ac_connected_cmd = NULL; + ac_disconnected_cmd = NULL; + battery_low_cmd = NULL; + battery_lclick_command = NULL; + battery_mclick_command = NULL; + battery_rclick_command = NULL; + battery_uwheel_command = NULL; + battery_dwheel_command = NULL; + battery_state.percentage = 0; + battery_state.time.hours = 0; + battery_state.time.minutes = 0; + battery_state.time.seconds = 0; + battery_state.state = BATTERY_UNKNOWN; } void cleanup_battery() { - pango_font_description_free(bat1_font_desc); - bat1_font_desc = NULL; - pango_font_description_free(bat2_font_desc); - bat2_font_desc = NULL; - free(battery_low_cmd); - battery_low_cmd = NULL; - free(battery_lclick_command); - battery_lclick_command = NULL; - free(battery_mclick_command); - battery_mclick_command = NULL; - free(battery_rclick_command); - battery_rclick_command = NULL; - free(battery_uwheel_command); - battery_uwheel_command = NULL; - free(battery_dwheel_command); - battery_dwheel_command = NULL; - free(ac_connected_cmd); - ac_connected_cmd = NULL; - free(ac_disconnected_cmd); - ac_disconnected_cmd = NULL; - stop_timeout(battery_timeout); - battery_timeout = NULL; - battery_found = FALSE; + pango_font_description_free(bat1_font_desc); + bat1_font_desc = NULL; + pango_font_description_free(bat2_font_desc); + bat2_font_desc = NULL; + free(battery_low_cmd); + battery_low_cmd = NULL; + free(battery_lclick_command); + battery_lclick_command = NULL; + free(battery_mclick_command); + battery_mclick_command = NULL; + free(battery_rclick_command); + battery_rclick_command = NULL; + free(battery_uwheel_command); + battery_uwheel_command = NULL; + free(battery_dwheel_command); + battery_dwheel_command = NULL; + free(ac_connected_cmd); + ac_connected_cmd = NULL; + free(ac_disconnected_cmd); + ac_disconnected_cmd = NULL; + stop_timeout(battery_timeout); + battery_timeout = NULL; + battery_found = FALSE; - battery_os_free(); + battery_os_free(); } void init_battery() { - if (!battery_enabled) - return; + if (!battery_enabled) + return; - battery_found = battery_os_init(); + battery_found = battery_os_init(); - if (!battery_timeout) - battery_timeout = add_timeout(10, 30000, update_battery_tick, 0, &battery_timeout); + if (!battery_timeout) + battery_timeout = add_timeout(10, 30000, update_battery_tick, 0, &battery_timeout); - update_battery(); + update_battery(); } void reinit_battery() { - battery_os_free(); - battery_found = battery_os_init(); - update_battery(); + battery_os_free(); + battery_found = battery_os_init(); + update_battery(); } void init_battery_panel(void *p) { - Panel *panel = (Panel *)p; - Battery *battery = &panel->battery; + Panel *panel = (Panel *)p; + Battery *battery = &panel->battery; - if (!battery_enabled) - return; + if (!battery_enabled) + return; - battery_init_fonts(); + battery_init_fonts(); - if (!battery->area.bg) - battery->area.bg = &g_array_index(backgrounds, Background, 0); + if (!battery->area.bg) + battery->area.bg = &g_array_index(backgrounds, Background, 0); - battery->area.parent = p; - battery->area.panel = p; - snprintf(battery->area.name, sizeof(battery->area.name), "Battery"); - battery->area._draw_foreground = draw_battery; - battery->area.size_mode = LAYOUT_FIXED; - battery->area._resize = resize_battery; - battery->area._compute_desired_size = battery_compute_desired_size; - battery->area._is_under_mouse = full_width_area_is_under_mouse; - battery->area.on_screen = TRUE; - battery->area.resize_needed = 1; - battery->area.has_mouse_over_effect = - panel_config.mouse_effects && (battery_lclick_command || battery_mclick_command || battery_rclick_command || - battery_uwheel_command || battery_dwheel_command); - battery->area.has_mouse_press_effect = battery->area.has_mouse_over_effect; - if (battery_tooltip_enabled) - battery->area._get_tooltip_text = battery_get_tooltip; - instantiate_area_gradients(&battery->area); + battery->area.parent = p; + battery->area.panel = p; + snprintf(battery->area.name, sizeof(battery->area.name), "Battery"); + battery->area._draw_foreground = draw_battery; + battery->area.size_mode = LAYOUT_FIXED; + battery->area._resize = resize_battery; + battery->area._compute_desired_size = battery_compute_desired_size; + battery->area._is_under_mouse = full_width_area_is_under_mouse; + battery->area.on_screen = TRUE; + battery->area.resize_needed = 1; + battery->area.has_mouse_over_effect = + panel_config.mouse_effects && (battery_lclick_command || battery_mclick_command || battery_rclick_command || + battery_uwheel_command || battery_dwheel_command); + battery->area.has_mouse_press_effect = battery->area.has_mouse_over_effect; + if (battery_tooltip_enabled) + battery->area._get_tooltip_text = battery_get_tooltip; + instantiate_area_gradients(&battery->area); } void battery_init_fonts() { - if (!bat1_font_desc) { - bat1_font_desc = pango_font_description_from_string(get_default_font()); - pango_font_description_set_size(bat1_font_desc, pango_font_description_get_size(bat1_font_desc) - PANGO_SCALE); - } - if (!bat2_font_desc) { - bat2_font_desc = pango_font_description_from_string(get_default_font()); - pango_font_description_set_size(bat2_font_desc, pango_font_description_get_size(bat2_font_desc) - PANGO_SCALE); - } + if (!bat1_font_desc) { + bat1_font_desc = pango_font_description_from_string(get_default_font()); + pango_font_description_set_size(bat1_font_desc, pango_font_description_get_size(bat1_font_desc) - PANGO_SCALE); + } + if (!bat2_font_desc) { + bat2_font_desc = pango_font_description_from_string(get_default_font()); + pango_font_description_set_size(bat2_font_desc, pango_font_description_get_size(bat2_font_desc) - PANGO_SCALE); + } } void battery_default_font_changed() { - if (!battery_enabled) - return; - if (bat1_has_font && bat2_has_font) - return; - if (!bat1_has_font) { - pango_font_description_free(bat1_font_desc); - bat1_font_desc = NULL; - } - if (!bat2_has_font) { - pango_font_description_free(bat2_font_desc); - bat2_font_desc = NULL; - } - battery_init_fonts(); - for (int i = 0; i < num_panels; i++) { - panels[i].battery.area.resize_needed = TRUE; - schedule_redraw(&panels[i].battery.area); - } - schedule_panel_redraw(); + if (!battery_enabled) + return; + if (bat1_has_font && bat2_has_font) + return; + if (!bat1_has_font) { + pango_font_description_free(bat1_font_desc); + bat1_font_desc = NULL; + } + if (!bat2_has_font) { + pango_font_description_free(bat2_font_desc); + bat2_font_desc = NULL; + } + battery_init_fonts(); + for (int i = 0; i < num_panels; i++) { + panels[i].battery.area.resize_needed = TRUE; + schedule_redraw(&panels[i].battery.area); + } + schedule_panel_redraw(); } void update_battery_tick(void *arg) { - if (!battery_enabled) - return; + if (!battery_enabled) + return; - gboolean old_found = battery_found; - int old_percentage = battery_state.percentage; - gboolean old_ac_connected = battery_state.ac_connected; - int16_t old_hours = battery_state.time.hours; - int8_t old_minutes = battery_state.time.minutes; + gboolean old_found = battery_found; + int old_percentage = battery_state.percentage; + gboolean old_ac_connected = battery_state.ac_connected; + int16_t old_hours = battery_state.time.hours; + int8_t old_minutes = battery_state.time.minutes; - if (!battery_found) { - init_battery(); - old_ac_connected = battery_state.ac_connected; - } - if (update_battery() != 0) { - // Try to reconfigure on failed update - init_battery(); - } + if (!battery_found) { + init_battery(); + old_ac_connected = battery_state.ac_connected; + } + if (update_battery() != 0) { + // Try to reconfigure on failed update + init_battery(); + } - if (old_ac_connected != battery_state.ac_connected) { - if (battery_state.ac_connected) - tint_exec(ac_connected_cmd); - else - tint_exec(ac_disconnected_cmd); - } + if (old_ac_connected != battery_state.ac_connected) { + if (battery_state.ac_connected) + tint_exec(ac_connected_cmd); + else + tint_exec(ac_disconnected_cmd); + } - if (battery_state.percentage < battery_low_status && battery_state.state == BATTERY_DISCHARGING && - !battery_low_cmd_sent) { - tint_exec(battery_low_cmd); - battery_low_cmd_sent = TRUE; - } - if (battery_state.percentage > battery_low_status && battery_state.state == BATTERY_CHARGING && - battery_low_cmd_sent) { - battery_low_cmd_sent = FALSE; - } + if (battery_state.percentage < battery_low_status && battery_state.state == BATTERY_DISCHARGING && + !battery_low_cmd_sent) { + tint_exec(battery_low_cmd); + battery_low_cmd_sent = TRUE; + } + if (battery_state.percentage > battery_low_status && battery_state.state == BATTERY_CHARGING && + battery_low_cmd_sent) { + battery_low_cmd_sent = FALSE; + } - for (int i = 0; i < num_panels; i++) { - // Show/hide if needed - if (!battery_found) { - hide(&panels[i].battery.area); - } else { - if (battery_state.percentage >= percentage_hide) - hide(&panels[i].battery.area); - else - show(&panels[i].battery.area); - } - // Redraw if needed - if (panels[i].battery.area.on_screen) { - if (old_found != battery_found || old_percentage != battery_state.percentage || - old_hours != battery_state.time.hours || old_minutes != battery_state.time.minutes) { - panels[i].battery.area.resize_needed = TRUE; - schedule_panel_redraw(); - } - } - } + for (int i = 0; i < num_panels; i++) { + // Show/hide if needed + if (!battery_found) { + hide(&panels[i].battery.area); + } else { + if (battery_state.percentage >= percentage_hide) + hide(&panels[i].battery.area); + else + show(&panels[i].battery.area); + } + // Redraw if needed + if (panels[i].battery.area.on_screen) { + if (old_found != battery_found || old_percentage != battery_state.percentage || + old_hours != battery_state.time.hours || old_minutes != battery_state.time.minutes) { + panels[i].battery.area.resize_needed = TRUE; + schedule_panel_redraw(); + } + } + } } int update_battery() { - // Reset - battery_state.state = BATTERY_UNKNOWN; - battery_state.percentage = 0; - battery_state.ac_connected = FALSE; - battery_state_set_time(&battery_state, 0); + // Reset + battery_state.state = BATTERY_UNKNOWN; + battery_state.percentage = 0; + battery_state.ac_connected = FALSE; + battery_state_set_time(&battery_state, 0); - int err = battery_os_update(&battery_state); + int err = battery_os_update(&battery_state); - // Clamp percentage to 100 in case battery is misreporting that its current charge is more than its max - if (battery_state.percentage > 100) { - battery_state.percentage = 100; - } + // Clamp percentage to 100 in case battery is misreporting that its current charge is more than its max + if (battery_state.percentage > 100) { + battery_state.percentage = 100; + } - return err; + return err; } int battery_compute_desired_size(void *obj) { - Battery *battery = (Battery *)obj; - Panel *panel = (Panel *)battery->area.panel; - int bat_percentage_height, bat_percentage_width, bat_percentage_height_ink; - int bat_time_height, bat_time_width, bat_time_height_ink; + Battery *battery = (Battery *)obj; + Panel *panel = (Panel *)battery->area.panel; + int bat_percentage_height, bat_percentage_width, bat_percentage_height_ink; + int bat_time_height, bat_time_width, bat_time_height_ink; - snprintf(buf_bat_percentage, sizeof(buf_bat_percentage), "%d%%", battery_state.percentage); - if (battery_state.state == BATTERY_FULL) { - strcpy(buf_bat_time, "Full"); - } else { - snprintf(buf_bat_time, sizeof(buf_bat_time), "%02d:%02d", battery_state.time.hours, battery_state.time.minutes); - } - get_text_size2(bat1_font_desc, - &bat_percentage_height_ink, - &bat_percentage_height, - &bat_percentage_width, - panel->area.height, - panel->area.width, - buf_bat_percentage, - strlen(buf_bat_percentage), - PANGO_WRAP_WORD_CHAR, - PANGO_ELLIPSIZE_NONE, - FALSE); - get_text_size2(bat2_font_desc, - &bat_time_height_ink, - &bat_time_height, - &bat_time_width, - panel->area.height, - panel->area.width, - buf_bat_time, - strlen(buf_bat_time), - PANGO_WRAP_WORD_CHAR, - PANGO_ELLIPSIZE_NONE, - FALSE); + snprintf(buf_bat_percentage, sizeof(buf_bat_percentage), "%d%%", battery_state.percentage); + if (battery_state.state == BATTERY_FULL) { + strcpy(buf_bat_time, "Full"); + } else { + snprintf(buf_bat_time, sizeof(buf_bat_time), "%02d:%02d", battery_state.time.hours, battery_state.time.minutes); + } + get_text_size2(bat1_font_desc, + &bat_percentage_height_ink, + &bat_percentage_height, + &bat_percentage_width, + panel->area.height, + panel->area.width, + buf_bat_percentage, + strlen(buf_bat_percentage), + PANGO_WRAP_WORD_CHAR, + PANGO_ELLIPSIZE_NONE, + FALSE); + get_text_size2(bat2_font_desc, + &bat_time_height_ink, + &bat_time_height, + &bat_time_width, + panel->area.height, + panel->area.width, + buf_bat_time, + strlen(buf_bat_time), + PANGO_WRAP_WORD_CHAR, + PANGO_ELLIPSIZE_NONE, + FALSE); - if (panel_horizontal) { - int new_size = (bat_percentage_width > bat_time_width) ? bat_percentage_width : bat_time_width; - new_size += 2 * battery->area.paddingxlr + left_right_border_width(&battery->area); - return new_size; - } else { - int new_size = bat_percentage_height + bat_time_height + 2 * battery->area.paddingxlr + - top_bottom_border_width(&battery->area); - return new_size; - } + if (panel_horizontal) { + int new_size = (bat_percentage_width > bat_time_width) ? bat_percentage_width : bat_time_width; + new_size += 2 * battery->area.paddingxlr + left_right_border_width(&battery->area); + return new_size; + } else { + int new_size = bat_percentage_height + bat_time_height + 2 * battery->area.paddingxlr + + top_bottom_border_width(&battery->area); + return new_size; + } } gboolean resize_battery(void *obj) { - Battery *battery = (Battery *)obj; - Panel *panel = (Panel *)battery->area.panel; - int bat_percentage_height, bat_percentage_width, bat_percentage_height_ink; - int bat_time_height, bat_time_width, bat_time_height_ink; - int ret = 0; + Battery *battery = (Battery *)obj; + Panel *panel = (Panel *)battery->area.panel; + int bat_percentage_height, bat_percentage_width, bat_percentage_height_ink; + int bat_time_height, bat_time_width, bat_time_height_ink; + int ret = 0; - snprintf(buf_bat_percentage, sizeof(buf_bat_percentage), "%d%%", battery_state.percentage); - if (battery_state.state == BATTERY_FULL) { - strcpy(buf_bat_time, "Full"); - } else { - snprintf(buf_bat_time, sizeof(buf_bat_time), "%02d:%02d", battery_state.time.hours, battery_state.time.minutes); - } - get_text_size2(bat1_font_desc, - &bat_percentage_height_ink, - &bat_percentage_height, - &bat_percentage_width, - panel->area.height, - panel->area.width, - buf_bat_percentage, - strlen(buf_bat_percentage), - PANGO_WRAP_WORD_CHAR, - PANGO_ELLIPSIZE_NONE, - FALSE); - get_text_size2(bat2_font_desc, - &bat_time_height_ink, - &bat_time_height, - &bat_time_width, - panel->area.height, - panel->area.width, - buf_bat_time, - strlen(buf_bat_time), - PANGO_WRAP_WORD_CHAR, - PANGO_ELLIPSIZE_NONE, - FALSE); + snprintf(buf_bat_percentage, sizeof(buf_bat_percentage), "%d%%", battery_state.percentage); + if (battery_state.state == BATTERY_FULL) { + strcpy(buf_bat_time, "Full"); + } else { + snprintf(buf_bat_time, sizeof(buf_bat_time), "%02d:%02d", battery_state.time.hours, battery_state.time.minutes); + } + get_text_size2(bat1_font_desc, + &bat_percentage_height_ink, + &bat_percentage_height, + &bat_percentage_width, + panel->area.height, + panel->area.width, + buf_bat_percentage, + strlen(buf_bat_percentage), + PANGO_WRAP_WORD_CHAR, + PANGO_ELLIPSIZE_NONE, + FALSE); + get_text_size2(bat2_font_desc, + &bat_time_height_ink, + &bat_time_height, + &bat_time_width, + panel->area.height, + panel->area.width, + buf_bat_time, + strlen(buf_bat_time), + PANGO_WRAP_WORD_CHAR, + PANGO_ELLIPSIZE_NONE, + FALSE); - if (panel_horizontal) { - int new_size = (bat_percentage_width > bat_time_width) ? bat_percentage_width : bat_time_width; - new_size += 2 * battery->area.paddingxlr + left_right_border_width(&battery->area); - if (new_size > battery->area.width || new_size < battery->area.width - 2) { - // we try to limit the number of resize - battery->area.width = new_size; - battery->bat1_posy = (battery->area.height - bat_percentage_height - bat_time_height) / 2; - battery->bat2_posy = battery->bat1_posy + bat_percentage_height; - ret = 1; - } - } else { - int new_size = bat_percentage_height + bat_time_height + 2 * battery->area.paddingxlr + - top_bottom_border_width(&battery->area); - if (new_size > battery->area.height || new_size < battery->area.height - 2) { - battery->area.height = new_size; - battery->bat1_posy = (battery->area.height - bat_percentage_height - bat_time_height - 2) / 2; - battery->bat2_posy = battery->bat1_posy + bat_percentage_height + 2; - ret = 1; - } - } + if (panel_horizontal) { + int new_size = (bat_percentage_width > bat_time_width) ? bat_percentage_width : bat_time_width; + new_size += 2 * battery->area.paddingxlr + left_right_border_width(&battery->area); + if (new_size > battery->area.width || new_size < battery->area.width - 2) { + // we try to limit the number of resize + battery->area.width = new_size; + battery->bat1_posy = (battery->area.height - bat_percentage_height - bat_time_height) / 2; + battery->bat2_posy = battery->bat1_posy + bat_percentage_height; + ret = 1; + } + } else { + int new_size = bat_percentage_height + bat_time_height + 2 * battery->area.paddingxlr + + top_bottom_border_width(&battery->area); + if (new_size > battery->area.height || new_size < battery->area.height - 2) { + battery->area.height = new_size; + battery->bat1_posy = (battery->area.height - bat_percentage_height - bat_time_height - 2) / 2; + battery->bat2_posy = battery->bat1_posy + bat_percentage_height + 2; + ret = 1; + } + } - schedule_redraw(&battery->area); - return ret; + schedule_redraw(&battery->area); + return ret; } void draw_battery(void *obj, cairo_t *c) { - Battery *battery = obj; + Battery *battery = obj; - PangoLayout *layout = pango_cairo_create_layout(c); - pango_layout_set_font_description(layout, bat1_font_desc); - pango_layout_set_width(layout, battery->area.width * PANGO_SCALE); - pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER); - pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR); - pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_NONE); - pango_layout_set_text(layout, buf_bat_percentage, strlen(buf_bat_percentage)); + PangoLayout *layout = pango_cairo_create_layout(c); + pango_layout_set_font_description(layout, bat1_font_desc); + pango_layout_set_width(layout, battery->area.width * PANGO_SCALE); + pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER); + pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR); + pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_NONE); + pango_layout_set_text(layout, buf_bat_percentage, strlen(buf_bat_percentage)); - cairo_set_source_rgba(c, - battery->font_color.rgb[0], - battery->font_color.rgb[1], - battery->font_color.rgb[2], - battery->font_color.alpha); + cairo_set_source_rgba(c, + battery->font_color.rgb[0], + battery->font_color.rgb[1], + battery->font_color.rgb[2], + battery->font_color.alpha); - pango_cairo_update_layout(c, layout); - draw_text(layout, c, 0, battery->bat1_posy, &battery->font_color, ((Panel *)battery->area.panel)->font_shadow); + pango_cairo_update_layout(c, layout); + draw_text(layout, c, 0, battery->bat1_posy, &battery->font_color, ((Panel *)battery->area.panel)->font_shadow); - pango_layout_set_font_description(layout, bat2_font_desc); - pango_layout_set_indent(layout, 0); - pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR); - pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_NONE); - pango_layout_set_text(layout, buf_bat_time, strlen(buf_bat_time)); - pango_layout_set_width(layout, battery->area.width * PANGO_SCALE); + pango_layout_set_font_description(layout, bat2_font_desc); + pango_layout_set_indent(layout, 0); + pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR); + pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_NONE); + pango_layout_set_text(layout, buf_bat_time, strlen(buf_bat_time)); + pango_layout_set_width(layout, battery->area.width * PANGO_SCALE); - pango_cairo_update_layout(c, layout); - draw_text(layout, c, 0, battery->bat2_posy, &battery->font_color, ((Panel *)battery->area.panel)->font_shadow); - pango_cairo_show_layout(c, layout); + pango_cairo_update_layout(c, layout); + draw_text(layout, c, 0, battery->bat2_posy, &battery->font_color, ((Panel *)battery->area.panel)->font_shadow); + pango_cairo_show_layout(c, layout); - g_object_unref(layout); + g_object_unref(layout); } void battery_dump_geometry(void *obj, int indent) { - Battery *battery = obj; - fprintf(stderr, - "%*sText 1: y = %d, text = %s\n", - indent, - "", - battery->bat1_posy, - buf_bat_percentage); - fprintf(stderr, - "%*sText 2: y = %d, text = %s\n", - indent, - "", - battery->bat2_posy, - buf_bat_time); + Battery *battery = obj; + fprintf(stderr, "%*sText 1: y = %d, text = %s\n", indent, "", battery->bat1_posy, buf_bat_percentage); + fprintf(stderr, "%*sText 2: y = %d, text = %s\n", indent, "", battery->bat2_posy, buf_bat_time); } char *battery_get_tooltip(void *obj) { - return battery_os_tooltip(); + return battery_os_tooltip(); } void battery_action(int button) { - char *command = NULL; - switch (button) { - case 1: - command = battery_lclick_command; - break; - case 2: - command = battery_mclick_command; - break; - case 3: - command = battery_rclick_command; - break; - case 4: - command = battery_uwheel_command; - break; - case 5: - command = battery_dwheel_command; - break; - } - tint_exec(command); + char *command = NULL; + switch (button) { + case 1: + command = battery_lclick_command; + break; + case 2: + command = battery_mclick_command; + break; + case 3: + command = battery_rclick_command; + break; + case 4: + command = battery_uwheel_command; + break; + case 5: + command = battery_dwheel_command; + break; + } + tint_exec(command); }
M src/battery/battery.hsrc/battery/battery.h

@@ -17,30 +17,30 @@ #include "common.h"

#include "area.h" typedef struct Battery { - Area area; - Color font_color; - int bat1_posy; - int bat2_posy; + Area area; + Color font_color; + int bat1_posy; + int bat2_posy; } Battery; typedef enum ChargeState { - BATTERY_UNKNOWN = 0, - BATTERY_CHARGING, - BATTERY_DISCHARGING, - BATTERY_FULL, + BATTERY_UNKNOWN = 0, + BATTERY_CHARGING, + BATTERY_DISCHARGING, + BATTERY_FULL, } ChargeState; typedef struct BatteryTime { - int16_t hours; - int8_t minutes; - int8_t seconds; + int16_t hours; + int8_t minutes; + int8_t seconds; } BatteryTime; typedef struct BatteryState { - int percentage; - BatteryTime time; - ChargeState state; - gboolean ac_connected; + int percentage; + BatteryTime time; + ChargeState state; + gboolean ac_connected; } BatteryState; extern struct BatteryState battery_state;

@@ -68,26 +68,26 @@ extern char *battery_sys_prefix;

static inline gchar *chargestate2str(ChargeState state) { - switch (state) { - case BATTERY_CHARGING: - return "Charging"; - case BATTERY_DISCHARGING: - return "Discharging"; - case BATTERY_FULL: - return "Full"; - case BATTERY_UNKNOWN: - default: - return "Unknown"; - }; + switch (state) { + case BATTERY_CHARGING: + return "Charging"; + case BATTERY_DISCHARGING: + return "Discharging"; + case BATTERY_FULL: + return "Full"; + case BATTERY_UNKNOWN: + default: + return "Unknown"; + }; } static inline void battery_state_set_time(BatteryState *state, int seconds) { - state->time.hours = seconds / 3600; - seconds -= 3600 * state->time.hours; - state->time.minutes = seconds / 60; - seconds -= 60 * state->time.minutes; - state->time.seconds = seconds; + state->time.hours = seconds / 3600; + seconds -= 3600 * state->time.hours; + state->time.minutes = seconds / 60; + seconds -= 60 * state->time.minutes; + state->time.seconds = seconds; } // default global data
M src/battery/dummy.csrc/battery/dummy.c

@@ -25,20 +25,20 @@ #warning tint2 has no battery support for this operating system!

gboolean battery_os_init() { - return FALSE; + return FALSE; } void battery_os_free() { - return; + return; } int battery_os_update(BatteryState *state) { - return -1; + return -1; } char *battery_os_tooltip() { - return strdup("Operating System not supported"); + return strdup("Operating System not supported"); }
M src/battery/freebsd.csrc/battery/freebsd.c

@@ -26,77 +26,77 @@ #include "battery.h"

gboolean battery_os_init() { - int sysctl_out = 0; - size_t len = sizeof(sysctl_out); + int sysctl_out = 0; + size_t len = sizeof(sysctl_out); - return (sysctlbyname("hw.acpi.battery.state", &sysctl_out, &len, NULL, 0) == 0) || - (sysctlbyname("hw.acpi.battery.time", &sysctl_out, &len, NULL, 0) == 0) || - (sysctlbyname("hw.acpi.battery.life", &sysctl_out, &len, NULL, 0) == 0); + return (sysctlbyname("hw.acpi.battery.state", &sysctl_out, &len, NULL, 0) == 0) || + (sysctlbyname("hw.acpi.battery.time", &sysctl_out, &len, NULL, 0) == 0) || + (sysctlbyname("hw.acpi.battery.life", &sysctl_out, &len, NULL, 0) == 0); } void battery_os_free() { - return; + return; } int battery_os_update(BatteryState *state) { - int sysctl_out = 0; - size_t len = sizeof(sysctl_out); - gboolean err = 0; + int sysctl_out = 0; + size_t len = sizeof(sysctl_out); + gboolean err = 0; - if (sysctlbyname("hw.acpi.battery.state", &sysctl_out, &len, NULL, 0) == 0) { - switch (sysctl_out) { - case 1: - state->state = BATTERY_DISCHARGING; - break; - case 2: - state->state = BATTERY_CHARGING; - break; - default: - state->state = BATTERY_FULL; - break; - } - } else { - fprintf(stderr, "power update: no such sysctl"); - err = -1; - } + if (sysctlbyname("hw.acpi.battery.state", &sysctl_out, &len, NULL, 0) == 0) { + switch (sysctl_out) { + case 1: + state->state = BATTERY_DISCHARGING; + break; + case 2: + state->state = BATTERY_CHARGING; + break; + default: + state->state = BATTERY_FULL; + break; + } + } else { + fprintf(stderr, "power update: no such sysctl"); + err = -1; + } - if (sysctlbyname("hw.acpi.battery.time", &sysctl_out, &len, NULL, 0) == 0) - battery_state_set_time(state, sysctl_out * 60); - else - err = -1; + if (sysctlbyname("hw.acpi.battery.time", &sysctl_out, &len, NULL, 0) == 0) + battery_state_set_time(state, sysctl_out * 60); + else + err = -1; - if (sysctlbyname("hw.acpi.battery.life", &sysctl_out, &len, NULL, 0) == 0) - state->percentage = sysctl_out; - else - err = -1; + if (sysctlbyname("hw.acpi.battery.life", &sysctl_out, &len, NULL, 0) == 0) + state->percentage = sysctl_out; + else + err = -1; - if (sysctlbyname("hw.acpi.acline", &sysctl_out, &len, NULL, 0) == 0) - state->ac_connected = sysctl_out; + if (sysctlbyname("hw.acpi.acline", &sysctl_out, &len, NULL, 0) == 0) + state->ac_connected = sysctl_out; - return err; + return err; } char *battery_os_tooltip() { - GString *tooltip = g_string_new(""); - gchar *result; + GString *tooltip = g_string_new(""); + gchar *result; - g_string_append_printf(tooltip, "Battery\n"); + g_string_append_printf(tooltip, "Battery\n"); - gchar *state = (battery_state.state == BATTERY_UNKNOWN) ? "Level" : chargestate2str(battery_state.state); + gchar *state = (battery_state.state == BATTERY_UNKNOWN) ? "Level" : chargestate2str(battery_state.state); - g_string_append_printf(tooltip, "\t%s: %d%%", state, battery_state.percentage); + g_string_append_printf(tooltip, "\t%s: %d%%", state, battery_state.percentage); - g_string_append_c(tooltip, '\n'); - g_string_append_printf(tooltip, "AC\n"); - g_string_append_printf(tooltip, battery_state.ac_connected ? "\tConnected" : "\tDisconnected"); + g_string_append_c(tooltip, '\n'); + g_string_append_printf(tooltip, "AC\n"); + g_string_append_printf(tooltip, battery_state.ac_connected ? "\tConnected" : "\tDisconnected"); - result = tooltip->str; - g_string_free(tooltip, FALSE); + result = tooltip->str; + g_string_free(tooltip, FALSE); - return result; + return result; } #endif
M src/battery/linux.csrc/battery/linux.c

@@ -26,513 +26,514 @@ #include "battery.h"

#include "uevent.h" enum psy_type { - PSY_UNKNOWN, - PSY_BATTERY, - PSY_MAINS, + PSY_UNKNOWN, + PSY_BATTERY, + PSY_MAINS, }; struct psy_battery { - /* generic properties */ - gchar *name; - /* monotonic time, in microseconds */ - gint64 timestamp; - /* sysfs files */ - gchar *path_present; - gchar *path_level_now; - gchar *path_level_full; - gchar *path_rate_now; - gchar *path_status; - /* values */ - gboolean present; - gint level_now; - gint level_full; - gint rate_now; - gchar unit; - ChargeState status; + /* generic properties */ + gchar *name; + /* monotonic time, in microseconds */ + gint64 timestamp; + /* sysfs files */ + gchar *path_present; + gchar *path_level_now; + gchar *path_level_full; + gchar *path_rate_now; + gchar *path_status; + /* values */ + gboolean present; + gint level_now; + gint level_full; + gint rate_now; + gchar unit; + ChargeState status; }; struct psy_mains { - /* generic properties */ - gchar *name; - /* sysfs files */ - gchar *path_online; - /* values */ - gboolean online; + /* generic properties */ + gchar *name; + /* sysfs files */ + gchar *path_online; + /* values */ + gboolean online; }; static void uevent_battery_update() { - update_battery_tick(NULL); + update_battery_tick(NULL); } static struct uevent_notify psy_change = {UEVENT_CHANGE, "power_supply", NULL, uevent_battery_update}; static void uevent_battery_plug() { - printf("reinitialize batteries after HW change\n"); - reinit_battery(); + printf("reinitialize batteries after HW change\n"); + reinit_battery(); } static struct uevent_notify psy_plug = {UEVENT_ADD | UEVENT_REMOVE, "power_supply", NULL, uevent_battery_plug}; -#define RETURN_ON_ERROR(err) \ - if (err) { \ - g_error_free(err); \ - fprintf(stderr, RED "%s:%d: errror" RESET "\n", __FILE__, __LINE__); \ - return FALSE; \ - } +#define RETURN_ON_ERROR(err) \ + if (err) { \ + g_error_free(err); \ + fprintf(stderr, RED "%s:%d: errror" RESET "\n", __FILE__, __LINE__); \ + return FALSE; \ + } static GList *batteries = NULL; static GList *mains = NULL; static guint8 level_to_percent(gint level_now, gint level_full) { - return 0.5 + ((level_now <= level_full ? level_now : level_full) * 100.0) / level_full; + return 0.5 + ((level_now <= level_full ? level_now : level_full) * 100.0) / level_full; } static enum psy_type power_supply_get_type(const gchar *entryname) { - gchar *path_type = g_build_filename(battery_sys_prefix, "/sys/class/power_supply", entryname, "type", NULL); - GError *error = NULL; - gchar *type; - gsize typelen; + gchar *path_type = g_build_filename(battery_sys_prefix, "/sys/class/power_supply", entryname, "type", NULL); + GError *error = NULL; + gchar *type; + gsize typelen; - g_file_get_contents(path_type, &type, &typelen, &error); - g_free(path_type); - if (error) { - fprintf(stderr, RED "%s:%d: read failed" RESET "\n", __FILE__, __LINE__); - g_error_free(error); - return PSY_UNKNOWN; - } + g_file_get_contents(path_type, &type, &typelen, &error); + g_free(path_type); + if (error) { + fprintf(stderr, RED "%s:%d: read failed" RESET "\n", __FILE__, __LINE__); + g_error_free(error); + return PSY_UNKNOWN; + } - if (!g_strcmp0(type, "Battery\n")) { - g_free(type); - return PSY_BATTERY; - } + if (!g_strcmp0(type, "Battery\n")) { + g_free(type); + return PSY_BATTERY; + } - if (!g_strcmp0(type, "Mains\n")) { - g_free(type); - return PSY_MAINS; - } + if (!g_strcmp0(type, "Mains\n")) { + g_free(type); + return PSY_MAINS; + } - g_free(type); + g_free(type); - return PSY_UNKNOWN; + return PSY_UNKNOWN; } static gboolean init_linux_battery(struct psy_battery *bat) { - const gchar *entryname = bat->name; + const gchar *entryname = bat->name; - bat->path_present = g_build_filename(battery_sys_prefix, "/sys/class/power_supply", entryname, "present", NULL); - if (!g_file_test(bat->path_present, G_FILE_TEST_EXISTS)) { - fprintf(stderr, RED "%s:%d: read failed" RESET "\n", __FILE__, __LINE__); - goto err0; - } + bat->path_present = g_build_filename(battery_sys_prefix, "/sys/class/power_supply", entryname, "present", NULL); + if (!g_file_test(bat->path_present, G_FILE_TEST_EXISTS)) { + fprintf(stderr, RED "%s:%d: read failed" RESET "\n", __FILE__, __LINE__); + goto err0; + } - bat->path_level_now = g_build_filename(battery_sys_prefix, "/sys/class/power_supply", entryname, "energy_now", NULL); - bat->path_level_full = - g_build_filename(battery_sys_prefix, "/sys/class/power_supply", entryname, "energy_full", NULL); - bat->path_rate_now = g_build_filename(battery_sys_prefix, "/sys/class/power_supply", entryname, "power_now", NULL); - bat->unit = 'W'; + bat->path_level_now = + g_build_filename(battery_sys_prefix, "/sys/class/power_supply", entryname, "energy_now", NULL); + bat->path_level_full = + g_build_filename(battery_sys_prefix, "/sys/class/power_supply", entryname, "energy_full", NULL); + bat->path_rate_now = g_build_filename(battery_sys_prefix, "/sys/class/power_supply", entryname, "power_now", NULL); + bat->unit = 'W'; - if (!g_file_test(bat->path_level_now, G_FILE_TEST_EXISTS) || - !g_file_test(bat->path_level_full, G_FILE_TEST_EXISTS) || - !g_file_test(bat->path_rate_now, G_FILE_TEST_EXISTS)) { - g_free(bat->path_level_now); - g_free(bat->path_level_full); - g_free(bat->path_rate_now); - bat->path_level_now = - g_build_filename(battery_sys_prefix, "/sys/class/power_supply", entryname, "charge_now", NULL); - bat->path_level_full = - g_build_filename(battery_sys_prefix, "/sys/class/power_supply", entryname, "charge_full", NULL); - bat->path_rate_now = - g_build_filename(battery_sys_prefix, "/sys/class/power_supply", entryname, "current_now", NULL); - bat->unit = 'A'; - } - if (!g_file_test(bat->path_level_now, G_FILE_TEST_EXISTS) || - !g_file_test(bat->path_level_full, G_FILE_TEST_EXISTS) || - !g_file_test(bat->path_rate_now, G_FILE_TEST_EXISTS)) { - fprintf(stderr, RED "%s:%d: read failed" RESET "\n", __FILE__, __LINE__); - goto err1; - } + if (!g_file_test(bat->path_level_now, G_FILE_TEST_EXISTS) || + !g_file_test(bat->path_level_full, G_FILE_TEST_EXISTS) || + !g_file_test(bat->path_rate_now, G_FILE_TEST_EXISTS)) { + g_free(bat->path_level_now); + g_free(bat->path_level_full); + g_free(bat->path_rate_now); + bat->path_level_now = + g_build_filename(battery_sys_prefix, "/sys/class/power_supply", entryname, "charge_now", NULL); + bat->path_level_full = + g_build_filename(battery_sys_prefix, "/sys/class/power_supply", entryname, "charge_full", NULL); + bat->path_rate_now = + g_build_filename(battery_sys_prefix, "/sys/class/power_supply", entryname, "current_now", NULL); + bat->unit = 'A'; + } + if (!g_file_test(bat->path_level_now, G_FILE_TEST_EXISTS) || + !g_file_test(bat->path_level_full, G_FILE_TEST_EXISTS) || + !g_file_test(bat->path_rate_now, G_FILE_TEST_EXISTS)) { + fprintf(stderr, RED "%s:%d: read failed" RESET "\n", __FILE__, __LINE__); + goto err1; + } - bat->path_status = g_build_filename(battery_sys_prefix, "/sys/class/power_supply", entryname, "status", NULL); - if (!g_file_test(bat->path_status, G_FILE_TEST_EXISTS)) { - fprintf(stderr, RED "%s:%d: read failed" RESET "\n", __FILE__, __LINE__); - goto err2; - } + bat->path_status = g_build_filename(battery_sys_prefix, "/sys/class/power_supply", entryname, "status", NULL); + if (!g_file_test(bat->path_status, G_FILE_TEST_EXISTS)) { + fprintf(stderr, RED "%s:%d: read failed" RESET "\n", __FILE__, __LINE__); + goto err2; + } - return TRUE; + return TRUE; err2: - g_free(bat->path_status); + g_free(bat->path_status); err1: - g_free(bat->path_level_now); - g_free(bat->path_level_full); - g_free(bat->path_rate_now); + g_free(bat->path_level_now); + g_free(bat->path_level_full); + g_free(bat->path_rate_now); err0: - g_free(bat->path_present); + g_free(bat->path_present); - return FALSE; + return FALSE; } static gboolean init_linux_mains(struct psy_mains *ac) { - const gchar *entryname = ac->name; + const gchar *entryname = ac->name; - ac->path_online = g_build_filename(battery_sys_prefix, "/sys/class/power_supply", entryname, "online", NULL); - if (!g_file_test(ac->path_online, G_FILE_TEST_EXISTS)) { - fprintf(stderr, RED "%s:%d: read failed" RESET "\n", __FILE__, __LINE__); - g_free(ac->path_online); - return FALSE; - } + ac->path_online = g_build_filename(battery_sys_prefix, "/sys/class/power_supply", entryname, "online", NULL); + if (!g_file_test(ac->path_online, G_FILE_TEST_EXISTS)) { + fprintf(stderr, RED "%s:%d: read failed" RESET "\n", __FILE__, __LINE__); + g_free(ac->path_online); + return FALSE; + } - return TRUE; + return TRUE; } static void psy_battery_free(gpointer data) { - struct psy_battery *bat = data; - g_free(bat->name); - g_free(bat->path_status); - g_free(bat->path_rate_now); - g_free(bat->path_level_full); - g_free(bat->path_level_now); - g_free(bat->path_present); - g_free(bat); + struct psy_battery *bat = data; + g_free(bat->name); + g_free(bat->path_status); + g_free(bat->path_rate_now); + g_free(bat->path_level_full); + g_free(bat->path_level_now); + g_free(bat->path_present); + g_free(bat); } static void psy_mains_free(gpointer data) { - struct psy_mains *ac = data; - g_free(ac->name); - g_free(ac->path_online); - g_free(ac); + struct psy_mains *ac = data; + g_free(ac->name); + g_free(ac->path_online); + g_free(ac); } void battery_os_free() { - uevent_unregister_notifier(&psy_change); - uevent_unregister_notifier(&psy_plug); + uevent_unregister_notifier(&psy_change); + uevent_unregister_notifier(&psy_plug); - g_list_free_full(batteries, psy_battery_free); - batteries = NULL; - g_list_free_full(mains, psy_mains_free); - mains = NULL; + g_list_free_full(batteries, psy_battery_free); + batteries = NULL; + g_list_free_full(mains, psy_mains_free); + mains = NULL; } static void add_battery(const char *entryname) { - struct psy_battery *bat = g_malloc0(sizeof(*bat)); - bat->name = g_strdup(entryname); + struct psy_battery *bat = g_malloc0(sizeof(*bat)); + bat->name = g_strdup(entryname); - if (init_linux_battery(bat)) { - batteries = g_list_append(batteries, bat); - fprintf(stdout, GREEN "Found battery \"%s\"" RESET "\n", bat->name); - } else { - g_free(bat); - fprintf(stderr, RED "Failed to initialize battery \"%s\"" RESET "\n", entryname); - } + if (init_linux_battery(bat)) { + batteries = g_list_append(batteries, bat); + fprintf(stdout, GREEN "Found battery \"%s\"" RESET "\n", bat->name); + } else { + g_free(bat); + fprintf(stderr, RED "Failed to initialize battery \"%s\"" RESET "\n", entryname); + } } static void add_mains(const char *entryname) { - struct psy_mains *ac = g_malloc0(sizeof(*ac)); - ac->name = g_strdup(entryname); + struct psy_mains *ac = g_malloc0(sizeof(*ac)); + ac->name = g_strdup(entryname); - if (init_linux_mains(ac)) { - mains = g_list_append(mains, ac); - fprintf(stdout, GREEN "Found mains \"%s\"" RESET "\n", ac->name); - } else { - g_free(ac); - fprintf(stderr, RED "Failed to initialize mains \"%s\"" RESET "\n", entryname); - } + if (init_linux_mains(ac)) { + mains = g_list_append(mains, ac); + fprintf(stdout, GREEN "Found mains \"%s\"" RESET "\n", ac->name); + } else { + g_free(ac); + fprintf(stderr, RED "Failed to initialize mains \"%s\"" RESET "\n", entryname); + } } gboolean battery_os_init() { - GDir *directory = 0; - GError *error = NULL; - const char *entryname; + GDir *directory = 0; + GError *error = NULL; + const char *entryname; - battery_os_free(); + battery_os_free(); - gchar *dir_path = g_build_filename(battery_sys_prefix, "/sys/class/power_supply", NULL); - directory = g_dir_open(dir_path, 0, &error); - g_free(dir_path); - RETURN_ON_ERROR(error); + gchar *dir_path = g_build_filename(battery_sys_prefix, "/sys/class/power_supply", NULL); + directory = g_dir_open(dir_path, 0, &error); + g_free(dir_path); + RETURN_ON_ERROR(error); - while ((entryname = g_dir_read_name(directory))) { - fprintf(stderr, GREEN "Found power device %s" RESET "\n", entryname); - enum psy_type type = power_supply_get_type(entryname); + while ((entryname = g_dir_read_name(directory))) { + fprintf(stderr, GREEN "Found power device %s" RESET "\n", entryname); + enum psy_type type = power_supply_get_type(entryname); - switch (type) { - case PSY_BATTERY: - add_battery(entryname); - break; - case PSY_MAINS: - add_mains(entryname); - break; - default: - break; - } - } + switch (type) { + case PSY_BATTERY: + add_battery(entryname); + break; + case PSY_MAINS: + add_mains(entryname); + break; + default: + break; + } + } - g_dir_close(directory); + g_dir_close(directory); - uevent_register_notifier(&psy_change); - uevent_register_notifier(&psy_plug); + uevent_register_notifier(&psy_change); + uevent_register_notifier(&psy_plug); - return batteries != NULL; + return batteries != NULL; } static gint estimate_rate_usage(struct psy_battery *bat, gint old_level_now, gint64 old_timestamp) { - gint64 diff_level = ABS(bat->level_now - old_level_now); - gint64 diff_time = bat->timestamp - old_timestamp; + gint64 diff_level = ABS(bat->level_now - old_level_now); + gint64 diff_time = bat->timestamp - old_timestamp; - /* µW = (µWh * 3600) / (µs / 1000000) */ - gint rate = diff_level * 3600 * 1000000 / MAX(1, diff_time); + /* µW = (µWh * 3600) / (µs / 1000000) */ + gint rate = diff_level * 3600 * 1000000 / MAX(1, diff_time); - return rate; + return rate; } static gboolean update_linux_battery(struct psy_battery *bat) { - GError *error = NULL; - gchar *data; - gsize datalen; + GError *error = NULL; + gchar *data; + gsize datalen; - gint64 old_timestamp = bat->timestamp; - int old_level_now = bat->level_now; - gint old_rate_now = bat->rate_now; + gint64 old_timestamp = bat->timestamp; + int old_level_now = bat->level_now; + gint old_rate_now = bat->rate_now; - /* reset values */ - bat->present = 0; - bat->status = BATTERY_UNKNOWN; - bat->level_now = 0; - bat->level_full = 0; - bat->rate_now = 0; - bat->timestamp = g_get_monotonic_time(); + /* reset values */ + bat->present = 0; + bat->status = BATTERY_UNKNOWN; + bat->level_now = 0; + bat->level_full = 0; + bat->rate_now = 0; + bat->timestamp = g_get_monotonic_time(); - /* present */ - g_file_get_contents(bat->path_present, &data, &datalen, &error); - RETURN_ON_ERROR(error); - bat->present = (atoi(data) == 1); - g_free(data); + /* present */ + g_file_get_contents(bat->path_present, &data, &datalen, &error); + RETURN_ON_ERROR(error); + bat->present = (atoi(data) == 1); + g_free(data); - /* we are done, if battery is not present */ - if (!bat->present) - return TRUE; + /* we are done, if battery is not present */ + if (!bat->present) + return TRUE; - /* status */ - bat->status = BATTERY_UNKNOWN; - g_file_get_contents(bat->path_status, &data, &datalen, &error); - RETURN_ON_ERROR(error); - if (!g_strcmp0(data, "Charging\n")) { - bat->status = BATTERY_CHARGING; - } else if (!g_strcmp0(data, "Discharging\n")) { - bat->status = BATTERY_DISCHARGING; - } else if (!g_strcmp0(data, "Full\n")) { - bat->status = BATTERY_FULL; - } - g_free(data); + /* status */ + bat->status = BATTERY_UNKNOWN; + g_file_get_contents(bat->path_status, &data, &datalen, &error); + RETURN_ON_ERROR(error); + if (!g_strcmp0(data, "Charging\n")) { + bat->status = BATTERY_CHARGING; + } else if (!g_strcmp0(data, "Discharging\n")) { + bat->status = BATTERY_DISCHARGING; + } else if (!g_strcmp0(data, "Full\n")) { + bat->status = BATTERY_FULL; + } + g_free(data); - /* level now */ - g_file_get_contents(bat->path_level_now, &data, &datalen, &error); - RETURN_ON_ERROR(error); - bat->level_now = atoi(data); - g_free(data); + /* level now */ + g_file_get_contents(bat->path_level_now, &data, &datalen, &error); + RETURN_ON_ERROR(error); + bat->level_now = atoi(data); + g_free(data); - /* level full */ - g_file_get_contents(bat->path_level_full, &data, &datalen, &error); - RETURN_ON_ERROR(error); - bat->level_full = atoi(data); - g_free(data); + /* level full */ + g_file_get_contents(bat->path_level_full, &data, &datalen, &error); + RETURN_ON_ERROR(error); + bat->level_full = atoi(data); + g_free(data); - /* rate now */ - g_file_get_contents(bat->path_rate_now, &data, &datalen, &error); - if (g_error_matches(error, G_FILE_ERROR, G_FILE_ERROR_NODEV)) { - /* some hardware does not support reading current rate consumption */ - g_error_free(error); - bat->rate_now = estimate_rate_usage(bat, old_level_now, old_timestamp); - if (bat->rate_now == 0 && bat->status != BATTERY_FULL) { - /* If the hardware updates the level slower than our sampling period, - * we need to sample more rarely */ - bat->rate_now = old_rate_now; - bat->timestamp = old_timestamp; - } - } else if (error) { - g_error_free(error); - return FALSE; - } else { - bat->rate_now = atoi(data); - g_free(data); - } + /* rate now */ + g_file_get_contents(bat->path_rate_now, &data, &datalen, &error); + if (g_error_matches(error, G_FILE_ERROR, G_FILE_ERROR_NODEV)) { + /* some hardware does not support reading current rate consumption */ + g_error_free(error); + bat->rate_now = estimate_rate_usage(bat, old_level_now, old_timestamp); + if (bat->rate_now == 0 && bat->status != BATTERY_FULL) { + /* If the hardware updates the level slower than our sampling period, + * we need to sample more rarely */ + bat->rate_now = old_rate_now; + bat->timestamp = old_timestamp; + } + } else if (error) { + g_error_free(error); + return FALSE; + } else { + bat->rate_now = atoi(data); + g_free(data); + } - return TRUE; + return TRUE; } static gboolean update_linux_mains(struct psy_mains *ac) { - GError *error = NULL; - gchar *data; - gsize datalen; - ac->online = FALSE; + GError *error = NULL; + gchar *data; + gsize datalen; + ac->online = FALSE; - /* online */ - g_file_get_contents(ac->path_online, &data, &datalen, &error); - RETURN_ON_ERROR(error); - ac->online = (atoi(data) == 1); - g_free(data); + /* online */ + g_file_get_contents(ac->path_online, &data, &datalen, &error); + RETURN_ON_ERROR(error); + ac->online = (atoi(data) == 1); + g_free(data); - return TRUE; + return TRUE; } int battery_os_update(BatteryState *state) { - GList *l; + GList *l; - gint64 total_level_now = 0; - gint64 total_level_full = 0; - gint64 total_rate_now = 0; - gint seconds = 0; + gint64 total_level_now = 0; + gint64 total_level_full = 0; + gint64 total_rate_now = 0; + gint seconds = 0; - gboolean charging = FALSE; - gboolean discharging = FALSE; - gboolean full = FALSE; - gboolean ac_connected = FALSE; + gboolean charging = FALSE; + gboolean discharging = FALSE; + gboolean full = FALSE; + gboolean ac_connected = FALSE; - for (l = batteries; l != NULL; l = l->next) { - struct psy_battery *bat = l->data; - update_linux_battery(bat); + for (l = batteries; l != NULL; l = l->next) { + struct psy_battery *bat = l->data; + update_linux_battery(bat); - total_level_now += bat->level_now; - total_level_full += bat->level_full; - total_rate_now += bat->rate_now; + total_level_now += bat->level_now; + total_level_full += bat->level_full; + total_rate_now += bat->rate_now; - charging |= (bat->status == BATTERY_CHARGING); - discharging |= (bat->status == BATTERY_DISCHARGING); - full |= (bat->status == BATTERY_FULL); - } + charging |= (bat->status == BATTERY_CHARGING); + discharging |= (bat->status == BATTERY_DISCHARGING); + full |= (bat->status == BATTERY_FULL); + } - for (l = mains; l != NULL; l = l->next) { - struct psy_mains *ac = l->data; - update_linux_mains(ac); - ac_connected |= (ac->online); - } + for (l = mains; l != NULL; l = l->next) { + struct psy_mains *ac = l->data; + update_linux_mains(ac); + ac_connected |= (ac->online); + } - /* build global state */ - if (charging && !discharging) - state->state = BATTERY_CHARGING; - else if (!charging && discharging) - state->state = BATTERY_DISCHARGING; - else if (!charging && !discharging && full) - state->state = BATTERY_FULL; + /* build global state */ + if (charging && !discharging) + state->state = BATTERY_CHARGING; + else if (!charging && discharging) + state->state = BATTERY_DISCHARGING; + else if (!charging && !discharging && full) + state->state = BATTERY_FULL; - /* calculate seconds */ - if (total_rate_now > 0) { - if (state->state == BATTERY_CHARGING) - seconds = 3600 * (total_level_full - total_level_now) / total_rate_now; - else if (state->state == BATTERY_DISCHARGING) - seconds = 3600 * total_level_now / total_rate_now; - seconds = MAX(0, seconds); - } - battery_state_set_time(state, seconds); + /* calculate seconds */ + if (total_rate_now > 0) { + if (state->state == BATTERY_CHARGING) + seconds = 3600 * (total_level_full - total_level_now) / total_rate_now; + else if (state->state == BATTERY_DISCHARGING) + seconds = 3600 * total_level_now / total_rate_now; + seconds = MAX(0, seconds); + } + battery_state_set_time(state, seconds); - /* calculate percentage */ - state->percentage = level_to_percent(total_level_now, total_level_full); + /* calculate percentage */ + state->percentage = level_to_percent(total_level_now, total_level_full); - /* AC state */ - state->ac_connected = ac_connected; + /* AC state */ + state->ac_connected = ac_connected; - return 0; + return 0; } static gchar *level_human_readable(struct psy_battery *bat) { - gint now = bat->level_now; - gint full = bat->level_full; + gint now = bat->level_now; + gint full = bat->level_full; - if (full >= 1000000) { - return g_strdup_printf("%d.%d / %d.%d %ch", - now / 1000000, - (now % 1000000) / 100000, - full / 1000000, - (full % 1000000) / 100000, - bat->unit); - } else if (full >= 1000) { - return g_strdup_printf("%d.%d / %d.%d m%ch", - now / 1000, - (now % 1000) / 100, - full / 1000, - (full % 1000) / 100, - bat->unit); - } else { - return g_strdup_printf("%d / %d µ%ch", now, full, bat->unit); - } + if (full >= 1000000) { + return g_strdup_printf("%d.%d / %d.%d %ch", + now / 1000000, + (now % 1000000) / 100000, + full / 1000000, + (full % 1000000) / 100000, + bat->unit); + } else if (full >= 1000) { + return g_strdup_printf("%d.%d / %d.%d m%ch", + now / 1000, + (now % 1000) / 100, + full / 1000, + (full % 1000) / 100, + bat->unit); + } else { + return g_strdup_printf("%d / %d µ%ch", now, full, bat->unit); + } } static gchar *rate_human_readable(struct psy_battery *bat) { - gint rate = bat->rate_now; - gchar unit = bat->unit; + gint rate = bat->rate_now; + gchar unit = bat->unit; - if (rate >= 1000000) { - return g_strdup_printf("%d.%d %c", rate / 1000000, (rate % 1000000) / 100000, unit); - } else if (rate >= 1000) { - return g_strdup_printf("%d.%d m%c", rate / 1000, (rate % 1000) / 100, unit); - } else if (rate > 0) { - return g_strdup_printf("%d µ%c", rate, unit); - } else { - return g_strdup_printf("0 %c", unit); - } + if (rate >= 1000000) { + return g_strdup_printf("%d.%d %c", rate / 1000000, (rate % 1000000) / 100000, unit); + } else if (rate >= 1000) { + return g_strdup_printf("%d.%d m%c", rate / 1000, (rate % 1000) / 100, unit); + } else if (rate > 0) { + return g_strdup_printf("%d µ%c", rate, unit); + } else { + return g_strdup_printf("0 %c", unit); + } } char *battery_os_tooltip() { - GList *l; - GString *tooltip = g_string_new(""); - gchar *result; + GList *l; + GString *tooltip = g_string_new(""); + gchar *result; - for (l = batteries; l != NULL; l = l->next) { - struct psy_battery *bat = l->data; + for (l = batteries; l != NULL; l = l->next) { + struct psy_battery *bat = l->data; - if (tooltip->len) - g_string_append_c(tooltip, '\n'); + if (tooltip->len) + g_string_append_c(tooltip, '\n'); - g_string_append_printf(tooltip, "%s\n", bat->name); + g_string_append_printf(tooltip, "%s\n", bat->name); - if (!bat->present) { - g_string_append_printf(tooltip, "\tnot connected"); - continue; - } + if (!bat->present) { + g_string_append_printf(tooltip, "\tnot connected"); + continue; + } - gchar *rate = rate_human_readable(bat); - gchar *level = level_human_readable(bat); - gchar *state = (bat->status == BATTERY_UNKNOWN) ? "energy" : chargestate2str(bat->status); + gchar *rate = rate_human_readable(bat); + gchar *level = level_human_readable(bat); + gchar *state = (bat->status == BATTERY_UNKNOWN) ? "energy" : chargestate2str(bat->status); - guint8 percentage = level_to_percent(bat->level_now, bat->level_full); + guint8 percentage = level_to_percent(bat->level_now, bat->level_full); - g_string_append_printf(tooltip, "\t%s: %s (%u %%)\n\trate: %s", state, level, percentage, rate); + g_string_append_printf(tooltip, "\t%s: %s (%u %%)\n\trate: %s", state, level, percentage, rate); - g_free(rate); - g_free(level); - } + g_free(rate); + g_free(level); + } - for (l = mains; l != NULL; l = l->next) { - struct psy_mains *ac = l->data; + for (l = mains; l != NULL; l = l->next) { + struct psy_mains *ac = l->data; - if (tooltip->len) - g_string_append_c(tooltip, '\n'); + if (tooltip->len) + g_string_append_c(tooltip, '\n'); - g_string_append_printf(tooltip, "%s\n", ac->name); - g_string_append_printf(tooltip, ac->online ? "\tConnected" : "\tDisconnected"); - } + g_string_append_printf(tooltip, "%s\n", ac->name); + g_string_append_printf(tooltip, ac->online ? "\tConnected" : "\tDisconnected"); + } - result = tooltip->str; - g_string_free(tooltip, FALSE); + result = tooltip->str; + g_string_free(tooltip, FALSE); - return result; + return result; } #endif
M src/battery/openbsd.csrc/battery/openbsd.c

@@ -31,78 +31,78 @@ int apm_fd = -1;

gboolean battery_os_init() { - if (apm_fd > 0) - close(apm_fd); + if (apm_fd > 0) + close(apm_fd); - apm_fd = open("/dev/apm", O_RDONLY); + apm_fd = open("/dev/apm", O_RDONLY); - if (apm_fd < 0) { - warn("ERROR: battery applet cannot open /dev/apm."); - return FALSE; - } else { - return TRUE; - } + if (apm_fd < 0) { + warn("ERROR: battery applet cannot open /dev/apm."); + return FALSE; + } else { + return TRUE; + } } void battery_os_free() { - if ((apm_fd != -1) && (close(apm_fd) == -1)) - warn("cannot close /dev/apm"); - apm_fd = -1; + if ((apm_fd != -1) && (close(apm_fd) == -1)) + warn("cannot close /dev/apm"); + apm_fd = -1; } int battery_os_update(BatteryState *state) { - struct apm_power_info info; + struct apm_power_info info; - if (apm_fd > 0 && ioctl(apm_fd, APM_IOC_GETPOWER, &(info)) == 0) { - // best attempt at mapping to Linux battery states - switch (info.battery_state) { - case APM_BATT_CHARGING: - state->state = BATTERY_CHARGING; - break; - default: - state->state = BATTERY_DISCHARGING; - break; - } + if (apm_fd > 0 && ioctl(apm_fd, APM_IOC_GETPOWER, &(info)) == 0) { + // best attempt at mapping to Linux battery states + switch (info.battery_state) { + case APM_BATT_CHARGING: + state->state = BATTERY_CHARGING; + break; + default: + state->state = BATTERY_DISCHARGING; + break; + } - if (info.battery_life > 100) - info.battery_life = 100; - if (info.battery_life == 100) - state->state = BATTERY_FULL; + if (info.battery_life > 100) + info.battery_life = 100; + if (info.battery_life == 100) + state->state = BATTERY_FULL; - state->percentage = info.battery_life; - if (info.minutes_left != -1) - battery_state_set_time(state, info.minutes_left * 60); + state->percentage = info.battery_life; + if (info.minutes_left != -1) + battery_state_set_time(state, info.minutes_left * 60); - state->ac_connected = info.ac_state == APM_AC_ON; - } else { - warn("power update: APM_IOC_GETPOWER"); - return -1; - } + state->ac_connected = info.ac_state == APM_AC_ON; + } else { + warn("power update: APM_IOC_GETPOWER"); + return -1; + } - return 0; + return 0; } char *battery_os_tooltip() { - GString *tooltip = g_string_new(""); - gchar *result; + GString *tooltip = g_string_new(""); + gchar *result; - g_string_append_printf(tooltip, "Battery\n"); + g_string_append_printf(tooltip, "Battery\n"); - gchar *state = (battery_state.state == BATTERY_UNKNOWN) ? "Level" : chargestate2str(battery_state.state); + gchar *state = (battery_state.state == BATTERY_UNKNOWN) ? "Level" : chargestate2str(battery_state.state); - g_string_append_printf(tooltip, "\t%s: %d%%", state, battery_state.percentage); + g_string_append_printf(tooltip, "\t%s: %d%%", state, battery_state.percentage); - g_string_append_c(tooltip, '\n'); - g_string_append_printf(tooltip, "AC\n"); - g_string_append_printf(tooltip, battery_state.ac_connected ? "\tConnected" : "\tDisconnected"); + g_string_append_c(tooltip, '\n'); + g_string_append_printf(tooltip, "AC\n"); + g_string_append_printf(tooltip, battery_state.ac_connected ? "\tConnected" : "\tDisconnected"); - result = tooltip->str; - g_string_free(tooltip, FALSE); + result = tooltip->str; + g_string_free(tooltip, FALSE); - return result; + return result; } #endif
M src/button/button.csrc/button/button.c

@@ -29,622 +29,623 @@ }

Button *create_button() { - Button *button = calloc(1, sizeof(Button)); - button->backend = calloc(1, sizeof(ButtonBackend)); - button->backend->centered = TRUE; - button->backend->font_color.alpha = 0.5; - return button; + Button *button = calloc(1, sizeof(Button)); + button->backend = calloc(1, sizeof(ButtonBackend)); + button->backend->centered = TRUE; + button->backend->font_color.alpha = 0.5; + return button; } gpointer create_button_frontend(gconstpointer arg, gpointer data) { - Button *button_backend = (Button *)arg; + Button *button_backend = (Button *)arg; - Button *button_frontend = calloc(1, sizeof(Button)); - button_frontend->backend = button_backend->backend; - button_backend->backend->instances = g_list_append(button_backend->backend->instances, button_frontend); - button_frontend->frontend = calloc(1, sizeof(ButtonFrontend)); - return button_frontend; + Button *button_frontend = calloc(1, sizeof(Button)); + button_frontend->backend = button_backend->backend; + button_backend->backend->instances = g_list_append(button_backend->backend->instances, button_frontend); + button_frontend->frontend = calloc(1, sizeof(ButtonFrontend)); + return button_frontend; } void destroy_button(void *obj) { - Button *button = (Button *)obj; - if (button->frontend) { - // This is a frontend element - if (button->frontend->icon) { - imlib_context_set_image(button->frontend->icon); - imlib_free_image(); - button->frontend->icon = NULL; - } - button->backend->instances = g_list_remove_all(button->backend->instances, button); - free_and_null(button->frontend); - remove_area(&button->area); - free_area(&button->area); - free_and_null(button); - } else { - // This is a backend element - free_and_null(button->backend->text); - free_and_null(button->backend->icon_name); - free_and_null(button->backend->tooltip); + Button *button = (Button *)obj; + if (button->frontend) { + // This is a frontend element + if (button->frontend->icon) { + imlib_context_set_image(button->frontend->icon); + imlib_free_image(); + button->frontend->icon = NULL; + } + button->backend->instances = g_list_remove_all(button->backend->instances, button); + free_and_null(button->frontend); + remove_area(&button->area); + free_area(&button->area); + free_and_null(button); + } else { + // This is a backend element + free_and_null(button->backend->text); + free_and_null(button->backend->icon_name); + free_and_null(button->backend->tooltip); - button->backend->bg = NULL; - pango_font_description_free(button->backend->font_desc); - button->backend->font_desc = NULL; - free_and_null(button->backend->lclick_command); - free_and_null(button->backend->mclick_command); - free_and_null(button->backend->rclick_command); - free_and_null(button->backend->dwheel_command); - free_and_null(button->backend->uwheel_command); + button->backend->bg = NULL; + pango_font_description_free(button->backend->font_desc); + button->backend->font_desc = NULL; + free_and_null(button->backend->lclick_command); + free_and_null(button->backend->mclick_command); + free_and_null(button->backend->rclick_command); + free_and_null(button->backend->dwheel_command); + free_and_null(button->backend->uwheel_command); - if (button->backend->instances) { - fprintf(stderr, "Error: Attempt to destroy backend while there are still frontend instances!\n"); - exit(-1); - } - free(button->backend); - free(button); - } + if (button->backend->instances) { + fprintf(stderr, "Error: Attempt to destroy backend while there are still frontend instances!\n"); + exit(-1); + } + free(button->backend); + free(button); + } } void init_button() { - GList *to_remove = panel_config.button_list; - for (int k = 0; k < strlen(panel_items_order) && to_remove; k++) { - if (panel_items_order[k] == 'P') { - to_remove = to_remove->next; - } - } + GList *to_remove = panel_config.button_list; + for (int k = 0; k < strlen(panel_items_order) && to_remove; k++) { + if (panel_items_order[k] == 'P') { + to_remove = to_remove->next; + } + } - if (to_remove) { - if (to_remove == panel_config.button_list) { - g_list_free_full(to_remove, destroy_button); - panel_config.button_list = NULL; - } else { - // Cut panel_config.button_list - if (to_remove->prev) - to_remove->prev->next = NULL; - to_remove->prev = NULL; - // Remove all elements of to_remove and to_remove itself - g_list_free_full(to_remove, destroy_button); - } - } + if (to_remove) { + if (to_remove == panel_config.button_list) { + g_list_free_full(to_remove, destroy_button); + panel_config.button_list = NULL; + } else { + // Cut panel_config.button_list + if (to_remove->prev) + to_remove->prev->next = NULL; + to_remove->prev = NULL; + // Remove all elements of to_remove and to_remove itself + g_list_free_full(to_remove, destroy_button); + } + } - button_init_fonts(); - for (GList *l = panel_config.button_list; l; l = l->next) { - Button *button = l->data; + button_init_fonts(); + for (GList *l = panel_config.button_list; l; l = l->next) { + Button *button = l->data; - // Set missing config options - if (!button->backend->bg) - button->backend->bg = &g_array_index(backgrounds, Background, 0); - } + // Set missing config options + if (!button->backend->bg) + button->backend->bg = &g_array_index(backgrounds, Background, 0); + } } void init_button_panel(void *p) { - Panel *panel = (Panel *)p; + Panel *panel = (Panel *)p; - // Make sure this is only done once if there are multiple items - if (panel->button_list && ((Button *)panel->button_list->data)->frontend) - return; + // Make sure this is only done once if there are multiple items + if (panel->button_list && ((Button *)panel->button_list->data)->frontend) + return; - // panel->button_list is now a copy of the pointer panel_config.button_list - // We make it a deep copy - panel->button_list = g_list_copy_deep(panel_config.button_list, create_button_frontend, NULL); + // panel->button_list is now a copy of the pointer panel_config.button_list + // We make it a deep copy + panel->button_list = g_list_copy_deep(panel_config.button_list, create_button_frontend, NULL); - load_icon_themes(); + load_icon_themes(); - for (GList *l = panel->button_list; l; l = l->next) { - Button *button = l->data; - button->area.bg = button->backend->bg; - button->area.paddingx = button->backend->paddingx; - button->area.paddingy = button->backend->paddingy; - button->area.paddingxlr = button->backend->paddingxlr; - button->area.parent = panel; - button->area.panel = panel; - button->area._dump_geometry = button_dump_geometry; - button->area._compute_desired_size = button_compute_desired_size; - snprintf(button->area.name, sizeof(button->area.name), "Button"); - button->area._draw_foreground = draw_button; - button->area.size_mode = LAYOUT_FIXED; - button->area._resize = resize_button; - button->area._get_tooltip_text = button_get_tooltip; - button->area._is_under_mouse = full_width_area_is_under_mouse; - button->area.has_mouse_press_effect = - panel_config.mouse_effects && - (button->area.has_mouse_over_effect = button->backend->lclick_command || button->backend->mclick_command || - button->backend->rclick_command || button->backend->uwheel_command || - button->backend->dwheel_command); + for (GList *l = panel->button_list; l; l = l->next) { + Button *button = l->data; + button->area.bg = button->backend->bg; + button->area.paddingx = button->backend->paddingx; + button->area.paddingy = button->backend->paddingy; + button->area.paddingxlr = button->backend->paddingxlr; + button->area.parent = panel; + button->area.panel = panel; + button->area._dump_geometry = button_dump_geometry; + button->area._compute_desired_size = button_compute_desired_size; + snprintf(button->area.name, sizeof(button->area.name), "Button"); + button->area._draw_foreground = draw_button; + button->area.size_mode = LAYOUT_FIXED; + button->area._resize = resize_button; + button->area._get_tooltip_text = button_get_tooltip; + button->area._is_under_mouse = full_width_area_is_under_mouse; + button->area.has_mouse_press_effect = + panel_config.mouse_effects && + (button->area.has_mouse_over_effect = button->backend->lclick_command || button->backend->mclick_command || + button->backend->rclick_command || button->backend->uwheel_command || + button->backend->dwheel_command); - button->area.resize_needed = TRUE; - button->area.on_screen = TRUE; - instantiate_area_gradients(&button->area); + button->area.resize_needed = TRUE; + button->area.on_screen = TRUE; + instantiate_area_gradients(&button->area); - button_reload_icon(button); - } + button_reload_icon(button); + } } void button_init_fonts() { - for (GList *l = panel_config.button_list; l; l = l->next) { - Button *button = l->data; - if (!button->backend->font_desc) - button->backend->font_desc = pango_font_description_from_string(get_default_font()); - } + for (GList *l = panel_config.button_list; l; l = l->next) { + Button *button = l->data; + if (!button->backend->font_desc) + button->backend->font_desc = pango_font_description_from_string(get_default_font()); + } } void button_default_font_changed() { - gboolean needs_update = FALSE; - for (GList *l = panel_config.button_list; l; l = l->next) { - Button *button = l->data; + gboolean needs_update = FALSE; + for (GList *l = panel_config.button_list; l; l = l->next) { + Button *button = l->data; - if (!button->backend->has_font) { - pango_font_description_free(button->backend->font_desc); - button->backend->font_desc = NULL; - needs_update = TRUE; - } - } - if (!needs_update) - return; + if (!button->backend->has_font) { + pango_font_description_free(button->backend->font_desc); + button->backend->font_desc = NULL; + needs_update = TRUE; + } + } + if (!needs_update) + return; - button_init_fonts(); - for (int i = 0; i < num_panels; i++) { - for (GList *l = panels[i].button_list; l; l = l->next) { - Button *button = l->data; + button_init_fonts(); + for (int i = 0; i < num_panels; i++) { + for (GList *l = panels[i].button_list; l; l = l->next) { + Button *button = l->data; - if (!button->backend->has_font) { - button->area.resize_needed = TRUE; - schedule_redraw(&button->area); - } - } - } - schedule_panel_redraw(); + if (!button->backend->has_font) { + button->area.resize_needed = TRUE; + schedule_redraw(&button->area); + } + } + } + schedule_panel_redraw(); } void button_reload_icon(Button *button) { - free_icon(button->frontend->icon); - free_icon(button->frontend->icon_hover); - free_icon(button->frontend->icon_pressed); - button->frontend->icon = NULL; - button->frontend->icon_hover = NULL; - button->frontend->icon_pressed = NULL; + free_icon(button->frontend->icon); + free_icon(button->frontend->icon_hover); + free_icon(button->frontend->icon_pressed); + button->frontend->icon = NULL; + button->frontend->icon_hover = NULL; + button->frontend->icon_pressed = NULL; - button->frontend->icon_load_size = button->frontend->iconw; + button->frontend->icon_load_size = button->frontend->iconw; - if (!button->backend->icon_name) - return; + if (!button->backend->icon_name) + return; - char *new_icon_path = get_icon_path(icon_theme_wrapper, button->backend->icon_name, button->frontend->iconw, TRUE); - if (new_icon_path) - button->frontend->icon = load_image(new_icon_path, TRUE); - free(new_icon_path); - // On loading error, fallback to default - if (!button->frontend->icon) { - new_icon_path = get_icon_path(icon_theme_wrapper, DEFAULT_ICON, button->frontend->iconw, TRUE); - if (new_icon_path) - button->frontend->icon = load_image(new_icon_path, TRUE); - free(new_icon_path); - } - Imlib_Image original = button->frontend->icon; - button->frontend->icon = scale_icon(button->frontend->icon, button->frontend->iconw); - free_icon(original); + char *new_icon_path = get_icon_path(icon_theme_wrapper, button->backend->icon_name, button->frontend->iconw, TRUE); + if (new_icon_path) + button->frontend->icon = load_image(new_icon_path, TRUE); + free(new_icon_path); + // On loading error, fallback to default + if (!button->frontend->icon) { + new_icon_path = get_icon_path(icon_theme_wrapper, DEFAULT_ICON, button->frontend->iconw, TRUE); + if (new_icon_path) + button->frontend->icon = load_image(new_icon_path, TRUE); + free(new_icon_path); + } + Imlib_Image original = button->frontend->icon; + button->frontend->icon = scale_icon(button->frontend->icon, button->frontend->iconw); + free_icon(original); - if (panel_config.mouse_effects) { - button->frontend->icon_hover = adjust_icon(button->frontend->icon, - panel_config.mouse_over_alpha, - panel_config.mouse_over_saturation, - panel_config.mouse_over_brightness); - button->frontend->icon_pressed = adjust_icon(button->frontend->icon, - panel_config.mouse_pressed_alpha, - panel_config.mouse_pressed_saturation, - panel_config.mouse_pressed_brightness); - } - schedule_redraw(&button->area); + if (panel_config.mouse_effects) { + button->frontend->icon_hover = adjust_icon(button->frontend->icon, + panel_config.mouse_over_alpha, + panel_config.mouse_over_saturation, + panel_config.mouse_over_brightness); + button->frontend->icon_pressed = adjust_icon(button->frontend->icon, + panel_config.mouse_pressed_alpha, + panel_config.mouse_pressed_saturation, + panel_config.mouse_pressed_brightness); + } + schedule_redraw(&button->area); } void button_default_icon_theme_changed() { - for (int i = 0; i < num_panels; i++) { - for (GList *l = panels[i].button_list; l; l = l->next) { - Button *button = l->data; - button_reload_icon(button); - } - } - schedule_panel_redraw(); + for (int i = 0; i < num_panels; i++) { + for (GList *l = panels[i].button_list; l; l = l->next) { + Button *button = l->data; + button_reload_icon(button); + } + } + schedule_panel_redraw(); } void cleanup_button() { - // Cleanup frontends - for (int i = 0; i < num_panels; i++) { - g_list_free_full(panels[i].button_list, destroy_button); - panels[i].button_list = NULL; - } + // Cleanup frontends + for (int i = 0; i < num_panels; i++) { + g_list_free_full(panels[i].button_list, destroy_button); + panels[i].button_list = NULL; + } - // Cleanup backends - g_list_free_full(panel_config.button_list, destroy_button); - panel_config.button_list = NULL; + // Cleanup backends + g_list_free_full(panel_config.button_list, destroy_button); + panel_config.button_list = NULL; } int button_compute_desired_size(void *obj) { - Button *button = (Button *)obj; - Panel *panel = (Panel *)button->area.panel; - int horiz_padding = (panel_horizontal ? button->area.paddingxlr : button->area.paddingy); - int vert_padding = (panel_horizontal ? button->area.paddingy : button->area.paddingxlr); - int interior_padding = button->area.paddingx; + Button *button = (Button *)obj; + Panel *panel = (Panel *)button->area.panel; + int horiz_padding = (panel_horizontal ? button->area.paddingxlr : button->area.paddingy); + int vert_padding = (panel_horizontal ? button->area.paddingy : button->area.paddingxlr); + int interior_padding = button->area.paddingx; - int icon_w, icon_h; - if (button->backend->icon_name) { - if (panel_horizontal) - icon_h = icon_w = button->area.height - top_bottom_border_width(&button->area) - 2 * vert_padding; - else - icon_h = icon_w = button->area.width - left_right_border_width(&button->area) - 2 * horiz_padding; - if (button->backend->max_icon_size) { - icon_w = MIN(icon_w, button->backend->max_icon_size); - icon_h = MIN(icon_h, button->backend->max_icon_size); - } - } else { - icon_h = icon_w = 0; - } + int icon_w, icon_h; + if (button->backend->icon_name) { + if (panel_horizontal) + icon_h = icon_w = button->area.height - top_bottom_border_width(&button->area) - 2 * vert_padding; + else + icon_h = icon_w = button->area.width - left_right_border_width(&button->area) - 2 * horiz_padding; + if (button->backend->max_icon_size) { + icon_w = MIN(icon_w, button->backend->max_icon_size); + icon_h = MIN(icon_h, button->backend->max_icon_size); + } + } else { + icon_h = icon_w = 0; + } - int txt_height_ink, txt_height, txt_width; - if (button->backend->text) { - if (panel_horizontal) { - get_text_size2(button->backend->font_desc, - &txt_height_ink, - &txt_height, - &txt_width, - panel->area.height, - panel->area.width, - button->backend->text, - strlen(button->backend->text), - PANGO_WRAP_WORD_CHAR, - PANGO_ELLIPSIZE_NONE, - FALSE); - } else { - get_text_size2(button->backend->font_desc, - &txt_height_ink, - &txt_height, - &txt_width, - panel->area.height, - button->area.width - icon_w - (icon_w ? interior_padding : 0) - - 2 * horiz_padding - left_right_border_width(&button->area), - button->backend->text, - strlen(button->backend->text), - PANGO_WRAP_WORD_CHAR, - PANGO_ELLIPSIZE_NONE, - FALSE); - } - } else { - txt_height_ink = txt_height = txt_width = 0; - } + int txt_height_ink, txt_height, txt_width; + if (button->backend->text) { + if (panel_horizontal) { + get_text_size2(button->backend->font_desc, + &txt_height_ink, + &txt_height, + &txt_width, + panel->area.height, + panel->area.width, + button->backend->text, + strlen(button->backend->text), + PANGO_WRAP_WORD_CHAR, + PANGO_ELLIPSIZE_NONE, + FALSE); + } else { + get_text_size2(button->backend->font_desc, + &txt_height_ink, + &txt_height, + &txt_width, + panel->area.height, + button->area.width - icon_w - (icon_w ? interior_padding : 0) - 2 * horiz_padding - + left_right_border_width(&button->area), + button->backend->text, + strlen(button->backend->text), + PANGO_WRAP_WORD_CHAR, + PANGO_ELLIPSIZE_NONE, + FALSE); + } + } else { + txt_height_ink = txt_height = txt_width = 0; + } - if (panel_horizontal) { - int new_size = txt_width + icon_w + (txt_width && icon_w ? interior_padding : 0); - new_size += 2 * horiz_padding + left_right_border_width(&button->area); - return new_size; - } else { - int new_size; - new_size = txt_height + 2 * vert_padding + top_bottom_border_width(&button->area); - new_size = MAX(new_size, icon_h + 2 * vert_padding + top_bottom_border_width(&button->area)); - return new_size; - } + if (panel_horizontal) { + int new_size = txt_width + icon_w + (txt_width && icon_w ? interior_padding : 0); + new_size += 2 * horiz_padding + left_right_border_width(&button->area); + return new_size; + } else { + int new_size; + new_size = txt_height + 2 * vert_padding + top_bottom_border_width(&button->area); + new_size = MAX(new_size, icon_h + 2 * vert_padding + top_bottom_border_width(&button->area)); + return new_size; + } } gboolean resize_button(void *obj) { - Button *button = (Button *)obj; - Panel *panel = (Panel *)button->area.panel; - int horiz_padding = (panel_horizontal ? button->area.paddingxlr : button->area.paddingy); - int vert_padding = (panel_horizontal ? button->area.paddingy : button->area.paddingxlr); - int interior_padding = button->area.paddingx; + Button *button = (Button *)obj; + Panel *panel = (Panel *)button->area.panel; + int horiz_padding = (panel_horizontal ? button->area.paddingxlr : button->area.paddingy); + int vert_padding = (panel_horizontal ? button->area.paddingy : button->area.paddingxlr); + int interior_padding = button->area.paddingx; - int icon_w, icon_h; - if (button->backend->icon_name) { - if (panel_horizontal) - icon_h = icon_w = button->area.height - top_bottom_border_width(&button->area) - 2 * vert_padding; - else - icon_h = icon_w = button->area.width - left_right_border_width(&button->area) - 2 * horiz_padding; - if (button->backend->max_icon_size) { - icon_w = MIN(icon_w, button->backend->max_icon_size); - icon_h = MIN(icon_h, button->backend->max_icon_size); - } - } else { - icon_h = icon_w = 0; - } + int icon_w, icon_h; + if (button->backend->icon_name) { + if (panel_horizontal) + icon_h = icon_w = button->area.height - top_bottom_border_width(&button->area) - 2 * vert_padding; + else + icon_h = icon_w = button->area.width - left_right_border_width(&button->area) - 2 * horiz_padding; + if (button->backend->max_icon_size) { + icon_w = MIN(icon_w, button->backend->max_icon_size); + icon_h = MIN(icon_h, button->backend->max_icon_size); + } + } else { + icon_h = icon_w = 0; + } - button->frontend->iconw = icon_w; - button->frontend->iconh = icon_h; - if (button->frontend->icon_load_size != button->frontend->iconw) - button_reload_icon(button); + button->frontend->iconw = icon_w; + button->frontend->iconh = icon_h; + if (button->frontend->icon_load_size != button->frontend->iconw) + button_reload_icon(button); - int txt_height_ink, txt_height, txt_width; - if (button->backend->text) { - if (panel_horizontal) { - get_text_size2(button->backend->font_desc, - &txt_height_ink, - &txt_height, - &txt_width, - panel->area.height, - panel->area.width, - button->backend->text, - strlen(button->backend->text), - PANGO_WRAP_WORD_CHAR, - PANGO_ELLIPSIZE_NONE, - FALSE); - } else { - get_text_size2(button->backend->font_desc, - &txt_height_ink, - &txt_height, - &txt_width, - panel->area.height, - button->area.width - icon_w - (icon_w ? interior_padding : 0) - - 2 * horiz_padding - left_right_border_width(&button->area), - button->backend->text, - strlen(button->backend->text), - PANGO_WRAP_WORD_CHAR, - PANGO_ELLIPSIZE_NONE, - FALSE); - } - } else { - txt_height_ink = txt_height = txt_width = 0; - } + int txt_height_ink, txt_height, txt_width; + if (button->backend->text) { + if (panel_horizontal) { + get_text_size2(button->backend->font_desc, + &txt_height_ink, + &txt_height, + &txt_width, + panel->area.height, + panel->area.width, + button->backend->text, + strlen(button->backend->text), + PANGO_WRAP_WORD_CHAR, + PANGO_ELLIPSIZE_NONE, + FALSE); + } else { + get_text_size2(button->backend->font_desc, + &txt_height_ink, + &txt_height, + &txt_width, + panel->area.height, + button->area.width - icon_w - (icon_w ? interior_padding : 0) - 2 * horiz_padding - + left_right_border_width(&button->area), + button->backend->text, + strlen(button->backend->text), + PANGO_WRAP_WORD_CHAR, + PANGO_ELLIPSIZE_NONE, + FALSE); + } + } else { + txt_height_ink = txt_height = txt_width = 0; + } - gboolean result = FALSE; - if (panel_horizontal) { - int new_size = txt_width + icon_w + (txt_width && icon_w ? interior_padding : 0); - new_size += 2 * horiz_padding + left_right_border_width(&button->area); - if (new_size != button->area.width) { - button->area.width = new_size; - result = TRUE; - } - } else { - int new_size; - new_size = txt_height + 2 * vert_padding + top_bottom_border_width(&button->area); - new_size = MAX(new_size, icon_h + 2 * vert_padding + top_bottom_border_width(&button->area)); - if (new_size != button->area.height) { - button->area.height = new_size; - result = TRUE; - } - } - button->frontend->textw = txt_width; - button->frontend->texth = txt_height; - if (button->backend->centered) { - if (icon_w) { - button->frontend->icony = (button->area.height - icon_h) / 2; - button->frontend->iconx = (button->area.width - txt_width - (txt_width ? interior_padding : 0) - icon_w) / 2; - button->frontend->texty = (button->area.height - txt_height) / 2; - button->frontend->textx = button->frontend->iconx + icon_w + interior_padding; - } else { - button->frontend->texty = (button->area.height - txt_height) / 2; - button->frontend->textx = (button->area.width - txt_width) / 2; - } - } else { - if (icon_w) { - button->frontend->icony = (button->area.height - icon_h) / 2; - button->frontend->iconx = left_border_width(&button->area) + horiz_padding; - button->frontend->texty = (button->area.height - txt_height) / 2; - button->frontend->textx = button->frontend->iconx + icon_w + interior_padding; - } else { - button->frontend->texty = (button->area.height - txt_height) / 2; - button->frontend->textx = left_border_width(&button->area) + horiz_padding; - } - } + gboolean result = FALSE; + if (panel_horizontal) { + int new_size = txt_width + icon_w + (txt_width && icon_w ? interior_padding : 0); + new_size += 2 * horiz_padding + left_right_border_width(&button->area); + if (new_size != button->area.width) { + button->area.width = new_size; + result = TRUE; + } + } else { + int new_size; + new_size = txt_height + 2 * vert_padding + top_bottom_border_width(&button->area); + new_size = MAX(new_size, icon_h + 2 * vert_padding + top_bottom_border_width(&button->area)); + if (new_size != button->area.height) { + button->area.height = new_size; + result = TRUE; + } + } + button->frontend->textw = txt_width; + button->frontend->texth = txt_height; + if (button->backend->centered) { + if (icon_w) { + button->frontend->icony = (button->area.height - icon_h) / 2; + button->frontend->iconx = + (button->area.width - txt_width - (txt_width ? interior_padding : 0) - icon_w) / 2; + button->frontend->texty = (button->area.height - txt_height) / 2; + button->frontend->textx = button->frontend->iconx + icon_w + interior_padding; + } else { + button->frontend->texty = (button->area.height - txt_height) / 2; + button->frontend->textx = (button->area.width - txt_width) / 2; + } + } else { + if (icon_w) { + button->frontend->icony = (button->area.height - icon_h) / 2; + button->frontend->iconx = left_border_width(&button->area) + horiz_padding; + button->frontend->texty = (button->area.height - txt_height) / 2; + button->frontend->textx = button->frontend->iconx + icon_w + interior_padding; + } else { + button->frontend->texty = (button->area.height - txt_height) / 2; + button->frontend->textx = left_border_width(&button->area) + horiz_padding; + } + } - schedule_redraw(&button->area); + schedule_redraw(&button->area); - return result; + return result; } void draw_button(void *obj, cairo_t *c) { - Button *button = obj; + Button *button = obj; - if (button->frontend->icon) { - // Render icon - Imlib_Image image; - if (panel_config.mouse_effects) { - if (button->area.mouse_state == MOUSE_OVER) - image = button->frontend->icon_hover ? button->frontend->icon_hover : button->frontend->icon; - else if (button->area.mouse_state == MOUSE_DOWN) - image = button->frontend->icon_pressed ? button->frontend->icon_pressed : button->frontend->icon; - else - image = button->frontend->icon; - } else { - image = button->frontend->icon; - } + if (button->frontend->icon) { + // Render icon + Imlib_Image image; + if (panel_config.mouse_effects) { + if (button->area.mouse_state == MOUSE_OVER) + image = button->frontend->icon_hover ? button->frontend->icon_hover : button->frontend->icon; + else if (button->area.mouse_state == MOUSE_DOWN) + image = button->frontend->icon_pressed ? button->frontend->icon_pressed : button->frontend->icon; + else + image = button->frontend->icon; + } else { + image = button->frontend->icon; + } - imlib_context_set_image(image); - render_image(button->area.pix, button->frontend->iconx, button->frontend->icony); - } + imlib_context_set_image(image); + render_image(button->area.pix, button->frontend->iconx, button->frontend->icony); + } - // Render text - if (button->backend->text) { - PangoLayout *layout = pango_cairo_create_layout(c); + // Render text + if (button->backend->text) { + PangoLayout *layout = pango_cairo_create_layout(c); - pango_layout_set_font_description(layout, button->backend->font_desc); - pango_layout_set_width(layout, button->frontend->textw * PANGO_SCALE); - pango_layout_set_alignment(layout, button->backend->centered ? PANGO_ALIGN_CENTER : PANGO_ALIGN_LEFT); - pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR); - pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_NONE); - pango_layout_set_text(layout, button->backend->text, strlen(button->backend->text)); + pango_layout_set_font_description(layout, button->backend->font_desc); + pango_layout_set_width(layout, button->frontend->textw * PANGO_SCALE); + pango_layout_set_alignment(layout, button->backend->centered ? PANGO_ALIGN_CENTER : PANGO_ALIGN_LEFT); + pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR); + pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_NONE); + pango_layout_set_text(layout, button->backend->text, strlen(button->backend->text)); - pango_cairo_update_layout(c, layout); - draw_text(layout, - c, - button->frontend->textx, - button->frontend->texty, - &button->backend->font_color, - panel_config.font_shadow); + pango_cairo_update_layout(c, layout); + draw_text(layout, + c, + button->frontend->textx, + button->frontend->texty, + &button->backend->font_color, + panel_config.font_shadow); - g_object_unref(layout); - } + g_object_unref(layout); + } } void button_dump_geometry(void *obj, int indent) { - Button *button = obj; + Button *button = obj; - if (button->frontend->icon) { - Imlib_Image tmp = imlib_context_get_image(); - imlib_context_set_image(button->frontend->icon); - fprintf(stderr, - "%*sIcon: x = %d, y = %d, w = %d, h = %d\n", - indent, - "", - button->frontend->iconx, - button->frontend->icony, - imlib_image_get_width(), - imlib_image_get_height()); - if (tmp) - imlib_context_set_image(tmp); - } - fprintf(stderr, - "%*sText: x = %d, y = %d, w = %d, align = %s, text = %s\n", - indent, - "", - button->frontend->textx, - button->frontend->texty, - button->frontend->textw, - button->backend->centered ? "center" : "left", - button->backend->text); + if (button->frontend->icon) { + Imlib_Image tmp = imlib_context_get_image(); + imlib_context_set_image(button->frontend->icon); + fprintf(stderr, + "%*sIcon: x = %d, y = %d, w = %d, h = %d\n", + indent, + "", + button->frontend->iconx, + button->frontend->icony, + imlib_image_get_width(), + imlib_image_get_height()); + if (tmp) + imlib_context_set_image(tmp); + } + fprintf(stderr, + "%*sText: x = %d, y = %d, w = %d, align = %s, text = %s\n", + indent, + "", + button->frontend->textx, + button->frontend->texty, + button->frontend->textw, + button->backend->centered ? "center" : "left", + button->backend->text); } void button_action(void *obj, int mouse_button, int x, int y) { - Button *button = (Button *)obj; - Panel *panel = (Panel *)button->area.panel; - char *command = NULL; - switch (mouse_button) { - case 1: - command = button->backend->lclick_command; - break; - case 2: - command = button->backend->mclick_command; - break; - case 3: - command = button->backend->rclick_command; - break; - case 4: - command = button->backend->uwheel_command; - break; - case 5: - command = button->backend->dwheel_command; - break; - } - if (command) { - int aligned_x, aligned_y, aligned_x1, aligned_y1, aligned_x2, aligned_y2; - int panel_x1, panel_x2, panel_y1, panel_y2; - if (panel_horizontal) { - if (area_is_first(button)) - aligned_x1 = panel->posx; - else - aligned_x1 = panel->posx + button->area.posx; + Button *button = (Button *)obj; + Panel *panel = (Panel *)button->area.panel; + char *command = NULL; + switch (mouse_button) { + case 1: + command = button->backend->lclick_command; + break; + case 2: + command = button->backend->mclick_command; + break; + case 3: + command = button->backend->rclick_command; + break; + case 4: + command = button->backend->uwheel_command; + break; + case 5: + command = button->backend->dwheel_command; + break; + } + if (command) { + int aligned_x, aligned_y, aligned_x1, aligned_y1, aligned_x2, aligned_y2; + int panel_x1, panel_x2, panel_y1, panel_y2; + if (panel_horizontal) { + if (area_is_first(button)) + aligned_x1 = panel->posx; + else + aligned_x1 = panel->posx + button->area.posx; - if (area_is_last(button)) - aligned_x2 = panel->posx + panel->area.width; - else - aligned_x2 = panel->posx + button->area.posx + button->area.width; + if (area_is_last(button)) + aligned_x2 = panel->posx + panel->area.width; + else + aligned_x2 = panel->posx + button->area.posx + button->area.width; - if (area_is_first(button)) - aligned_x = aligned_x1; - else if (area_is_last(button)) - aligned_x = aligned_x2; - else - aligned_x = aligned_x1; + if (area_is_first(button)) + aligned_x = aligned_x1; + else if (area_is_last(button)) + aligned_x = aligned_x2; + else + aligned_x = aligned_x1; - if (panel_position & BOTTOM) - aligned_y = panel->posy; - else - aligned_y = panel->posy + panel->area.height; + if (panel_position & BOTTOM) + aligned_y = panel->posy; + else + aligned_y = panel->posy + panel->area.height; - aligned_y1 = aligned_y2 = aligned_y; + aligned_y1 = aligned_y2 = aligned_y; - panel_x1 = panel->posx; - panel_x2 = panel->posx + panel->area.width; - panel_y1 = panel_y2 = aligned_y; - } else { - if (area_is_first(button)) - aligned_y1 = panel->posy; - else - aligned_y1 = panel->posy + button->area.posy; + panel_x1 = panel->posx; + panel_x2 = panel->posx + panel->area.width; + panel_y1 = panel_y2 = aligned_y; + } else { + if (area_is_first(button)) + aligned_y1 = panel->posy; + else + aligned_y1 = panel->posy + button->area.posy; - if (area_is_last(button)) - aligned_y2 = panel->posy + panel->area.height; - else - aligned_y2 = panel->posy + button->area.posy + button->area.height; + if (area_is_last(button)) + aligned_y2 = panel->posy + panel->area.height; + else + aligned_y2 = panel->posy + button->area.posy + button->area.height; - if (area_is_first(button)) - aligned_y = aligned_y1; - else if (area_is_last(button)) - aligned_y = aligned_y2; - else - aligned_y = aligned_y1; + if (area_is_first(button)) + aligned_y = aligned_y1; + else if (area_is_last(button)) + aligned_y = aligned_y2; + else + aligned_y = aligned_y1; - if (panel_position & RIGHT) - aligned_x = panel->posx; - else - aligned_x = panel->posx + panel->area.width; + if (panel_position & RIGHT) + aligned_x = panel->posx; + else + aligned_x = panel->posx + panel->area.width; - aligned_x1 = aligned_x2 = aligned_x; + aligned_x1 = aligned_x2 = aligned_x; - panel_x1 = panel_x2 = aligned_x; - panel_y1 = panel->posy; - panel_y2 = panel->posy + panel->area.height; - } + panel_x1 = panel_x2 = aligned_x; + panel_y1 = panel->posy; + panel_y2 = panel->posy + panel->area.height; + } - char *full_cmd = g_strdup_printf("export TINT2_BUTTON_X=%d;" - "export TINT2_BUTTON_Y=%d;" - "export TINT2_BUTTON_W=%d;" - "export TINT2_BUTTON_H=%d;" - "export TINT2_BUTTON_ALIGNED_X=%d;" - "export TINT2_BUTTON_ALIGNED_Y=%d;" - "export TINT2_BUTTON_ALIGNED_X1=%d;" - "export TINT2_BUTTON_ALIGNED_Y1=%d;" - "export TINT2_BUTTON_ALIGNED_X2=%d;" - "export TINT2_BUTTON_ALIGNED_Y2=%d;" - "export TINT2_BUTTON_PANEL_X1=%d;" - "export TINT2_BUTTON_PANEL_Y1=%d;" - "export TINT2_BUTTON_PANEL_X2=%d;" - "export TINT2_BUTTON_PANEL_Y2=%d;" - "%s", - x, - y, - button->area.width, - button->area.height, - aligned_x, - aligned_y, - aligned_x1, - aligned_y1, - aligned_x2, - aligned_y2, - panel_x1, - panel_y1, - panel_x2, - panel_y2, - command); - pid_t pid = fork(); - if (pid < 0) { - fprintf(stderr, "Could not fork\n"); - } else if (pid == 0) { - // Child process - // Allow children to exist after parent destruction - setsid(); - // Run the command - execl("/bin/sh", "/bin/sh", "-c", full_cmd, NULL); - fprintf(stderr, "Failed to execlp %s\n", full_cmd); - exit(1); - } - } + char *full_cmd = g_strdup_printf("export TINT2_BUTTON_X=%d;" + "export TINT2_BUTTON_Y=%d;" + "export TINT2_BUTTON_W=%d;" + "export TINT2_BUTTON_H=%d;" + "export TINT2_BUTTON_ALIGNED_X=%d;" + "export TINT2_BUTTON_ALIGNED_Y=%d;" + "export TINT2_BUTTON_ALIGNED_X1=%d;" + "export TINT2_BUTTON_ALIGNED_Y1=%d;" + "export TINT2_BUTTON_ALIGNED_X2=%d;" + "export TINT2_BUTTON_ALIGNED_Y2=%d;" + "export TINT2_BUTTON_PANEL_X1=%d;" + "export TINT2_BUTTON_PANEL_Y1=%d;" + "export TINT2_BUTTON_PANEL_X2=%d;" + "export TINT2_BUTTON_PANEL_Y2=%d;" + "%s", + x, + y, + button->area.width, + button->area.height, + aligned_x, + aligned_y, + aligned_x1, + aligned_y1, + aligned_x2, + aligned_y2, + panel_x1, + panel_y1, + panel_x2, + panel_y2, + command); + pid_t pid = fork(); + if (pid < 0) { + fprintf(stderr, "Could not fork\n"); + } else if (pid == 0) { + // Child process + // Allow children to exist after parent destruction + setsid(); + // Run the command + execl("/bin/sh", "/bin/sh", "-c", full_cmd, NULL); + fprintf(stderr, "Failed to execlp %s\n", full_cmd); + exit(1); + } + } } char *button_get_tooltip(void *obj) { - Button *button = obj; + Button *button = obj; - if (button->backend->tooltip && strlen(button->backend->tooltip) > 0) - return strdup(button->backend->tooltip); - return NULL; + if (button->backend->tooltip && strlen(button->backend->tooltip) > 0) + return strdup(button->backend->tooltip); + return NULL; }
M src/button/button.hsrc/button/button.h

@@ -17,55 +17,56 @@ // from panel_config. Each works as a frontend to the corresponding Button in panel_config as backend, using the

// backend's config and state variables. typedef struct ButtonBackend { - // Config: - char *icon_name; - char *text; - char *tooltip; - gboolean centered; - int max_icon_size; - gboolean has_font; - PangoFontDescription *font_desc; - Color font_color; - char *lclick_command; - char *mclick_command; - char *rclick_command; - char *uwheel_command; - char *dwheel_command; - // paddingxlr = horizontal padding left/right - // paddingx = horizontal padding between childs - int paddingxlr, paddingx, paddingy; - Background *bg; + // Config: + char *icon_name; + char *text; + char *tooltip; + gboolean centered; + int max_icon_size; + gboolean has_font; + PangoFontDescription *font_desc; + Color font_color; + char *lclick_command; + char *mclick_command; + char *rclick_command; + char *uwheel_command; + char *dwheel_command; + // paddingxlr = horizontal padding left/right + // paddingx = horizontal padding between childs + int paddingxlr, paddingx, paddingy; + Background *bg; - // List of Button which are frontends for this backend, one for each panel - GList *instances; + // List of Button which are frontends for this backend, one for each panel + GList *instances; } ButtonBackend; typedef struct ButtonFrontend { - // Frontend state: - Imlib_Image icon; - Imlib_Image icon_hover; - Imlib_Image icon_pressed; - int icon_load_size; - int iconx; - int icony; - int iconw; - int iconh; - int textx; - int texty; - int textw; - int texth; + // Frontend state: + Imlib_Image icon; + Imlib_Image icon_hover; + Imlib_Image icon_pressed; + int icon_load_size; + int iconx; + int icony; + int iconw; + int iconh; + int textx; + int texty; + int textw; + int texth; } ButtonFrontend; typedef struct Button { - Area area; - // All elements have the backend pointer set. However only backend elements have ownership. - ButtonBackend *backend; - // Set only for frontend Button items. - ButtonFrontend *frontend; + Area area; + // All elements have the backend pointer set. However only backend elements have ownership. + ButtonBackend *backend; + // Set only for frontend Button items. + ButtonFrontend *frontend; } Button; // Called before the config is read and panel_config/panels are created. -// Afterwards, the config parsing code creates the array of Button in panel_config and populates the configuration fields +// Afterwards, the config parsing code creates the array of Button in panel_config and populates the configuration +// fields // in the backend. // Probably does nothing. void default_button();
M src/clock/clock.csrc/clock/clock.c

@@ -60,105 +60,105 @@ void clock_dump_geometry(void *obj, int indent);

void default_clock() { - clock_enabled = 0; - clock_timeout = NULL; - time1_format = NULL; - time1_timezone = NULL; - time2_format = NULL; - time2_timezone = NULL; - time_tooltip_format = NULL; - time_tooltip_timezone = NULL; - clock_lclick_command = NULL; - clock_mclick_command = NULL; - clock_rclick_command = NULL; - clock_uwheel_command = NULL; - clock_dwheel_command = NULL; - time1_has_font = FALSE; - time1_font_desc = NULL; - time2_has_font = FALSE; - time2_font_desc = NULL; + clock_enabled = 0; + clock_timeout = NULL; + time1_format = NULL; + time1_timezone = NULL; + time2_format = NULL; + time2_timezone = NULL; + time_tooltip_format = NULL; + time_tooltip_timezone = NULL; + clock_lclick_command = NULL; + clock_mclick_command = NULL; + clock_rclick_command = NULL; + clock_uwheel_command = NULL; + clock_dwheel_command = NULL; + time1_has_font = FALSE; + time1_font_desc = NULL; + time2_has_font = FALSE; + time2_font_desc = NULL; } void cleanup_clock() { - pango_font_description_free(time1_font_desc); - time1_font_desc = NULL; - pango_font_description_free(time2_font_desc); - time2_font_desc = NULL; - free(time1_format); - time1_format = NULL; - free(time2_format); - time2_format = NULL; - free(time_tooltip_format); - time_tooltip_format = NULL; - free(time1_timezone); - time1_timezone = NULL; - free(time2_timezone); - time2_timezone = NULL; - free(time_tooltip_timezone); - time_tooltip_timezone = NULL; - free(clock_lclick_command); - clock_lclick_command = NULL; - free(clock_mclick_command); - clock_mclick_command = NULL; - free(clock_rclick_command); - clock_rclick_command = NULL; - free(clock_uwheel_command); - clock_uwheel_command = NULL; - free(clock_dwheel_command); - clock_dwheel_command = NULL; - stop_timeout(clock_timeout); - clock_timeout = NULL; + pango_font_description_free(time1_font_desc); + time1_font_desc = NULL; + pango_font_description_free(time2_font_desc); + time2_font_desc = NULL; + free(time1_format); + time1_format = NULL; + free(time2_format); + time2_format = NULL; + free(time_tooltip_format); + time_tooltip_format = NULL; + free(time1_timezone); + time1_timezone = NULL; + free(time2_timezone); + time2_timezone = NULL; + free(time_tooltip_timezone); + time_tooltip_timezone = NULL; + free(clock_lclick_command); + clock_lclick_command = NULL; + free(clock_mclick_command); + clock_mclick_command = NULL; + free(clock_rclick_command); + clock_rclick_command = NULL; + free(clock_uwheel_command); + clock_uwheel_command = NULL; + free(clock_dwheel_command); + clock_dwheel_command = NULL; + stop_timeout(clock_timeout); + clock_timeout = NULL; } void update_clocks_sec(void *arg) { - gettimeofday(&time_clock, 0); - if (time1_format) { - for (int i = 0; i < num_panels; i++) - panels[i].clock.area.resize_needed = 1; - } - schedule_panel_redraw(); + gettimeofday(&time_clock, 0); + if (time1_format) { + for (int i = 0; i < num_panels; i++) + panels[i].clock.area.resize_needed = 1; + } + schedule_panel_redraw(); } void update_clocks_min(void *arg) { - // remember old_sec because after suspend/hibernate the clock should be updated directly, and not - // on next minute change - time_t old_sec = time_clock.tv_sec; - gettimeofday(&time_clock, 0); - if (time_clock.tv_sec % 60 == 0 || time_clock.tv_sec - old_sec > 60) { - if (time1_format) { - for (int i = 0; i < num_panels; i++) - panels[i].clock.area.resize_needed = 1; - } - schedule_panel_redraw(); - } + // remember old_sec because after suspend/hibernate the clock should be updated directly, and not + // on next minute change + time_t old_sec = time_clock.tv_sec; + gettimeofday(&time_clock, 0); + if (time_clock.tv_sec % 60 == 0 || time_clock.tv_sec - old_sec > 60) { + if (time1_format) { + for (int i = 0; i < num_panels; i++) + panels[i].clock.area.resize_needed = 1; + } + schedule_panel_redraw(); + } } struct tm *clock_gettime_for_tz(const char *timezone) { - if (timezone) { - const char *old_tz = getenv("TZ"); - setenv("TZ", timezone, 1); - struct tm *result = localtime(&time_clock.tv_sec); - if (old_tz) - setenv("TZ", old_tz, 1); - else - unsetenv("TZ"); - return result; - } else { - return localtime(&time_clock.tv_sec); - } + if (timezone) { + const char *old_tz = getenv("TZ"); + setenv("TZ", timezone, 1); + struct tm *result = localtime(&time_clock.tv_sec); + if (old_tz) + setenv("TZ", old_tz, 1); + else + unsetenv("TZ"); + return result; + } else { + return localtime(&time_clock.tv_sec); + } } gboolean time_format_needs_sec_ticks(char *time_format) { - if (!time_format) - return FALSE; - if (strchr(time_format, 'S') || strchr(time_format, 'T') || strchr(time_format, 'r')) - return TRUE; - return FALSE; + if (!time_format) + return FALSE; + if (strchr(time_format, 'S') || strchr(time_format, 'T') || strchr(time_format, 'r')) + return TRUE; + return FALSE; } void init_clock()

@@ -167,80 +167,80 @@ }

void init_clock_panel(void *p) { - Panel *panel = (Panel *)p; - Clock *clock = &panel->clock; + Panel *panel = (Panel *)p; + Clock *clock = &panel->clock; - if (!clock_timeout) { - if (time_format_needs_sec_ticks(time1_format) || time_format_needs_sec_ticks(time2_format)) { - clock_timeout = add_timeout(10, 1000, update_clocks_sec, 0, &clock_timeout); - } else { - clock_timeout = add_timeout(10, 1000, update_clocks_min, 0, &clock_timeout); - } - } + if (!clock_timeout) { + if (time_format_needs_sec_ticks(time1_format) || time_format_needs_sec_ticks(time2_format)) { + clock_timeout = add_timeout(10, 1000, update_clocks_sec, 0, &clock_timeout); + } else { + clock_timeout = add_timeout(10, 1000, update_clocks_min, 0, &clock_timeout); + } + } - if (!clock->area.bg) - clock->area.bg = &g_array_index(backgrounds, Background, 0); - clock_init_fonts(); - clock->area.parent = p; - clock->area.panel = p; - snprintf(clock->area.name, sizeof(clock->area.name), "Clock"); - clock->area._is_under_mouse = full_width_area_is_under_mouse; - clock->area.has_mouse_press_effect = clock->area.has_mouse_over_effect = - panel_config.mouse_effects && (clock_lclick_command || clock_mclick_command || clock_rclick_command || - clock_uwheel_command || clock_dwheel_command); - clock->area._draw_foreground = draw_clock; - clock->area.size_mode = LAYOUT_FIXED; - clock->area._resize = resize_clock; - clock->area._compute_desired_size = clock_compute_desired_size; - clock->area._dump_geometry = clock_dump_geometry; - // check consistency - if (!time1_format) - return; + if (!clock->area.bg) + clock->area.bg = &g_array_index(backgrounds, Background, 0); + clock_init_fonts(); + clock->area.parent = p; + clock->area.panel = p; + snprintf(clock->area.name, sizeof(clock->area.name), "Clock"); + clock->area._is_under_mouse = full_width_area_is_under_mouse; + clock->area.has_mouse_press_effect = clock->area.has_mouse_over_effect = + panel_config.mouse_effects && (clock_lclick_command || clock_mclick_command || clock_rclick_command || + clock_uwheel_command || clock_dwheel_command); + clock->area._draw_foreground = draw_clock; + clock->area.size_mode = LAYOUT_FIXED; + clock->area._resize = resize_clock; + clock->area._compute_desired_size = clock_compute_desired_size; + clock->area._dump_geometry = clock_dump_geometry; + // check consistency + if (!time1_format) + return; - clock->area.resize_needed = 1; - clock->area.on_screen = TRUE; - instantiate_area_gradients(&clock->area); + clock->area.resize_needed = 1; + clock->area.on_screen = TRUE; + instantiate_area_gradients(&clock->area); - if (time_tooltip_format) { - clock->area._get_tooltip_text = clock_get_tooltip; - strftime(buf_tooltip, sizeof(buf_tooltip), time_tooltip_format, clock_gettime_for_tz(time_tooltip_timezone)); - } + if (time_tooltip_format) { + clock->area._get_tooltip_text = clock_get_tooltip; + strftime(buf_tooltip, sizeof(buf_tooltip), time_tooltip_format, clock_gettime_for_tz(time_tooltip_timezone)); + } } void clock_init_fonts() { - if (!time1_font_desc) { - time1_font_desc = pango_font_description_from_string(get_default_font()); - pango_font_description_set_weight(time1_font_desc, PANGO_WEIGHT_BOLD); - pango_font_description_set_size(time1_font_desc, pango_font_description_get_size(time1_font_desc)); - } - if (!time2_font_desc) { - time2_font_desc = pango_font_description_from_string(get_default_font()); - pango_font_description_set_size(time2_font_desc, - pango_font_description_get_size(time2_font_desc) - PANGO_SCALE); - } + if (!time1_font_desc) { + time1_font_desc = pango_font_description_from_string(get_default_font()); + pango_font_description_set_weight(time1_font_desc, PANGO_WEIGHT_BOLD); + pango_font_description_set_size(time1_font_desc, pango_font_description_get_size(time1_font_desc)); + } + if (!time2_font_desc) { + time2_font_desc = pango_font_description_from_string(get_default_font()); + pango_font_description_set_size(time2_font_desc, + pango_font_description_get_size(time2_font_desc) - PANGO_SCALE); + } } void clock_default_font_changed() { - if (!clock_enabled) - return; - if (time1_has_font && time2_has_font) - return; - if (!time1_has_font) { - pango_font_description_free(time1_font_desc); - time1_font_desc = NULL; - } - if (!time2_has_font) { - pango_font_description_free(time2_font_desc); - time2_font_desc = NULL; - } - clock_init_fonts(); - for (int i = 0; i < num_panels; i++) { - panels[i].clock.area.resize_needed = TRUE; - schedule_redraw(&panels[i].clock.area); - } - schedule_panel_redraw(); + if (!clock_enabled) + return; + if (time1_has_font && time2_has_font) + return; + if (!time1_has_font) { + pango_font_description_free(time1_font_desc); + time1_font_desc = NULL; + } + if (!time2_has_font) { + pango_font_description_free(time2_font_desc); + time2_font_desc = NULL; + } + clock_init_fonts(); + for (int i = 0; i < num_panels; i++) { + panels[i].clock.area.resize_needed = TRUE; + schedule_redraw(&panels[i].clock.area); + } + schedule_panel_redraw(); } void clock_compute_text_geometry(Panel *panel,

@@ -251,167 +251,167 @@ int *date_height_ink,

int *date_height, int *date_width) { - *date_height = *date_width = 0; - strftime(buf_time, sizeof(buf_time), time1_format, clock_gettime_for_tz(time1_timezone)); - get_text_size2(time1_font_desc, - time_height_ink, - time_height, - time_width, - panel->area.height, - panel->area.width, - buf_time, - strlen(buf_time), - PANGO_WRAP_WORD_CHAR, - PANGO_ELLIPSIZE_NONE, - FALSE); - if (time2_format) { - strftime(buf_date, sizeof(buf_date), time2_format, clock_gettime_for_tz(time2_timezone)); - get_text_size2(time2_font_desc, - date_height_ink, - date_height, - date_width, - panel->area.height, - panel->area.width, - buf_date, - strlen(buf_date), - PANGO_WRAP_WORD_CHAR, - PANGO_ELLIPSIZE_NONE, - FALSE); - } + *date_height = *date_width = 0; + strftime(buf_time, sizeof(buf_time), time1_format, clock_gettime_for_tz(time1_timezone)); + get_text_size2(time1_font_desc, + time_height_ink, + time_height, + time_width, + panel->area.height, + panel->area.width, + buf_time, + strlen(buf_time), + PANGO_WRAP_WORD_CHAR, + PANGO_ELLIPSIZE_NONE, + FALSE); + if (time2_format) { + strftime(buf_date, sizeof(buf_date), time2_format, clock_gettime_for_tz(time2_timezone)); + get_text_size2(time2_font_desc, + date_height_ink, + date_height, + date_width, + panel->area.height, + panel->area.width, + buf_date, + strlen(buf_date), + PANGO_WRAP_WORD_CHAR, + PANGO_ELLIPSIZE_NONE, + FALSE); + } } int clock_compute_desired_size(void *obj) { - Clock *clock = (Clock *)obj; - Panel *panel = (Panel *)clock->area.panel; - int time_height_ink, time_height, time_width, date_height_ink, date_height, date_width; - clock_compute_text_geometry(panel, - &time_height_ink, - &time_height, - &time_width, - &date_height_ink, - &date_height, - &date_width); + Clock *clock = (Clock *)obj; + Panel *panel = (Panel *)clock->area.panel; + int time_height_ink, time_height, time_width, date_height_ink, date_height, date_width; + clock_compute_text_geometry(panel, + &time_height_ink, + &time_height, + &time_width, + &date_height_ink, + &date_height, + &date_width); - if (panel_horizontal) { - int new_size = (time_width > date_width) ? time_width : date_width; - new_size += 2 * clock->area.paddingxlr + left_right_border_width(&clock->area); - return new_size; - } else { - int new_size = time_height + date_height + 2 * clock->area.paddingxlr + top_bottom_border_width(&clock->area); - return new_size; - } + if (panel_horizontal) { + int new_size = (time_width > date_width) ? time_width : date_width; + new_size += 2 * clock->area.paddingxlr + left_right_border_width(&clock->area); + return new_size; + } else { + int new_size = time_height + date_height + 2 * clock->area.paddingxlr + top_bottom_border_width(&clock->area); + return new_size; + } } gboolean resize_clock(void *obj) { - Clock *clock = (Clock *)obj; - Panel *panel = (Panel *)clock->area.panel; - gboolean result = FALSE; + Clock *clock = (Clock *)obj; + Panel *panel = (Panel *)clock->area.panel; + gboolean result = FALSE; - schedule_redraw(&clock->area); + schedule_redraw(&clock->area); - int time_height_ink, time_height, time_width, date_height_ink, date_height, date_width; - clock_compute_text_geometry(panel, - &time_height_ink, - &time_height, - &time_width, - &date_height_ink, - &date_height, - &date_width); + int time_height_ink, time_height, time_width, date_height_ink, date_height, date_width; + clock_compute_text_geometry(panel, + &time_height_ink, + &time_height, + &time_width, + &date_height_ink, + &date_height, + &date_width); - int new_size = clock_compute_desired_size(clock); - if (panel_horizontal) { - if (new_size > clock->area.width || new_size < (clock->area.width - 6)) { - // we try to limit the number of resizes - clock->area.width = new_size + 1; - clock->time1_posy = (clock->area.height - time_height) / 2; - if (time2_format) { - clock->time1_posy -= (date_height) / 2; - clock->time2_posy = clock->time1_posy + time_height; - } - result = TRUE; - } - } else { - if (new_size != clock->area.height) { - // we try to limit the number of resizes - clock->area.height = new_size; - clock->time1_posy = (clock->area.height - time_height) / 2; - if (time2_format) { - clock->time1_posy -= (date_height) / 2; - clock->time2_posy = clock->time1_posy + time_height; - } - result = TRUE; - } - } + int new_size = clock_compute_desired_size(clock); + if (panel_horizontal) { + if (new_size > clock->area.width || new_size < (clock->area.width - 6)) { + // we try to limit the number of resizes + clock->area.width = new_size + 1; + clock->time1_posy = (clock->area.height - time_height) / 2; + if (time2_format) { + clock->time1_posy -= (date_height) / 2; + clock->time2_posy = clock->time1_posy + time_height; + } + result = TRUE; + } + } else { + if (new_size != clock->area.height) { + // we try to limit the number of resizes + clock->area.height = new_size; + clock->time1_posy = (clock->area.height - time_height) / 2; + if (time2_format) { + clock->time1_posy -= (date_height) / 2; + clock->time2_posy = clock->time1_posy + time_height; + } + result = TRUE; + } + } - return result; + return result; } void draw_clock(void *obj, cairo_t *c) { - Clock *clock = obj; - PangoLayout *layout = pango_cairo_create_layout(c); + Clock *clock = obj; + PangoLayout *layout = pango_cairo_create_layout(c); - pango_layout_set_font_description(layout, time1_font_desc); - pango_layout_set_width(layout, clock->area.width * PANGO_SCALE); - pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER); - pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR); - pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_NONE); - pango_layout_set_text(layout, buf_time, strlen(buf_time)); + pango_layout_set_font_description(layout, time1_font_desc); + pango_layout_set_width(layout, clock->area.width * PANGO_SCALE); + pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER); + pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR); + pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_NONE); + pango_layout_set_text(layout, buf_time, strlen(buf_time)); - cairo_set_source_rgba(c, clock->font.rgb[0], clock->font.rgb[1], clock->font.rgb[2], clock->font.alpha); + cairo_set_source_rgba(c, clock->font.rgb[0], clock->font.rgb[1], clock->font.rgb[2], clock->font.alpha); - pango_cairo_update_layout(c, layout); - draw_text(layout, c, 0, clock->time1_posy, &clock->font, ((Panel *)clock->area.panel)->font_shadow); + pango_cairo_update_layout(c, layout); + draw_text(layout, c, 0, clock->time1_posy, &clock->font, ((Panel *)clock->area.panel)->font_shadow); - if (time2_format) { - pango_layout_set_font_description(layout, time2_font_desc); - pango_layout_set_indent(layout, 0); - pango_layout_set_text(layout, buf_date, strlen(buf_date)); - pango_layout_set_width(layout, clock->area.width * PANGO_SCALE); + if (time2_format) { + pango_layout_set_font_description(layout, time2_font_desc); + pango_layout_set_indent(layout, 0); + pango_layout_set_text(layout, buf_date, strlen(buf_date)); + pango_layout_set_width(layout, clock->area.width * PANGO_SCALE); - pango_cairo_update_layout(c, layout); - draw_text(layout, c, 0, clock->time2_posy, &clock->font, ((Panel *)clock->area.panel)->font_shadow); - } + pango_cairo_update_layout(c, layout); + draw_text(layout, c, 0, clock->time2_posy, &clock->font, ((Panel *)clock->area.panel)->font_shadow); + } - g_object_unref(layout); + g_object_unref(layout); } void clock_dump_geometry(void *obj, int indent) { - Clock *clock = (Clock *)obj; - fprintf(stderr, "%*sText 1: y = %d, text = %s\n", indent, "", clock->time1_posy, buf_time); - if (time2_format) { - fprintf(stderr, "%*sText 2: y = %d, text = %s\n", indent, "", clock->time2_posy, buf_date); - } + Clock *clock = (Clock *)obj; + fprintf(stderr, "%*sText 1: y = %d, text = %s\n", indent, "", clock->time1_posy, buf_time); + if (time2_format) { + fprintf(stderr, "%*sText 2: y = %d, text = %s\n", indent, "", clock->time2_posy, buf_date); + } } char *clock_get_tooltip(void *obj) { - strftime(buf_tooltip, sizeof(buf_tooltip), time_tooltip_format, clock_gettime_for_tz(time_tooltip_timezone)); - return strdup(buf_tooltip); + strftime(buf_tooltip, sizeof(buf_tooltip), time_tooltip_format, clock_gettime_for_tz(time_tooltip_timezone)); + return strdup(buf_tooltip); } void clock_action(int button) { - char *command = NULL; - switch (button) { - case 1: - command = clock_lclick_command; - break; - case 2: - command = clock_mclick_command; - break; - case 3: - command = clock_rclick_command; - break; - case 4: - command = clock_uwheel_command; - break; - case 5: - command = clock_dwheel_command; - break; - } - tint_exec(command); + char *command = NULL; + switch (button) { + case 1: + command = clock_lclick_command; + break; + case 2: + command = clock_mclick_command; + break; + case 3: + command = clock_rclick_command; + break; + case 4: + command = clock_uwheel_command; + break; + case 5: + command = clock_dwheel_command; + break; + } + tint_exec(command); }
M src/clock/clock.hsrc/clock/clock.h

@@ -14,12 +14,12 @@ #include "common.h"

#include "area.h" typedef struct Clock { - // always start with area - Area area; + // always start with area + Area area; - Color font; - int time1_posy; - int time2_posy; + Color font; + int time1_posy; + int time2_posy; } Clock; extern char *time1_format;
M src/config.csrc/config.c

@@ -80,1315 +80,1316 @@ static gboolean read_panel_position;

void default_config() { - config_path = NULL; - snapshot_path = NULL; - new_config_file = FALSE; - read_panel_position = FALSE; + config_path = NULL; + snapshot_path = NULL; + new_config_file = FALSE; + read_panel_position = FALSE; } void cleanup_config() { - free(config_path); - config_path = NULL; - free(snapshot_path); - snapshot_path = NULL; + free(config_path); + config_path = NULL; + free(snapshot_path); + snapshot_path = NULL; } void get_action(char *event, MouseAction *action) { - if (strcmp(event, "none") == 0) - *action = NONE; - else if (strcmp(event, "close") == 0) - *action = CLOSE; - else if (strcmp(event, "toggle") == 0) - *action = TOGGLE; - else if (strcmp(event, "iconify") == 0) - *action = ICONIFY; - else if (strcmp(event, "shade") == 0) - *action = SHADE; - else if (strcmp(event, "toggle_iconify") == 0) - *action = TOGGLE_ICONIFY; - else if (strcmp(event, "maximize_restore") == 0) - *action = MAXIMIZE_RESTORE; - else if (strcmp(event, "desktop_left") == 0) - *action = DESKTOP_LEFT; - else if (strcmp(event, "desktop_right") == 0) - *action = DESKTOP_RIGHT; - else if (strcmp(event, "next_task") == 0) - *action = NEXT_TASK; - else if (strcmp(event, "prev_task") == 0) - *action = PREV_TASK; - else - fprintf(stderr, "Error: unrecognized action '%s'. Please fix your config file.\n", event); + if (strcmp(event, "none") == 0) + *action = NONE; + else if (strcmp(event, "close") == 0) + *action = CLOSE; + else if (strcmp(event, "toggle") == 0) + *action = TOGGLE; + else if (strcmp(event, "iconify") == 0) + *action = ICONIFY; + else if (strcmp(event, "shade") == 0) + *action = SHADE; + else if (strcmp(event, "toggle_iconify") == 0) + *action = TOGGLE_ICONIFY; + else if (strcmp(event, "maximize_restore") == 0) + *action = MAXIMIZE_RESTORE; + else if (strcmp(event, "desktop_left") == 0) + *action = DESKTOP_LEFT; + else if (strcmp(event, "desktop_right") == 0) + *action = DESKTOP_RIGHT; + else if (strcmp(event, "next_task") == 0) + *action = NEXT_TASK; + else if (strcmp(event, "prev_task") == 0) + *action = PREV_TASK; + else + fprintf(stderr, "Error: unrecognized action '%s'. Please fix your config file.\n", event); } int get_task_status(char *status) { - if (strcmp(status, "active") == 0) - return TASK_ACTIVE; - if (strcmp(status, "iconified") == 0) - return TASK_ICONIFIED; - if (strcmp(status, "urgent") == 0) - return TASK_URGENT; - return -1; + if (strcmp(status, "active") == 0) + return TASK_ACTIVE; + if (strcmp(status, "iconified") == 0) + return TASK_ICONIFIED; + if (strcmp(status, "urgent") == 0) + return TASK_URGENT; + return -1; } int config_get_monitor(char *monitor) { - if (strcmp(monitor, "all") != 0) { - char *endptr; - int ret_int = strtol(monitor, &endptr, 10); - if (*endptr == 0) - return ret_int - 1; - else { - // monitor specified by name, not by index - int i, j; - for (i = 0; i < server.num_monitors; ++i) { - if (server.monitors[i].names == 0) - // xrandr can't identify monitors - continue; - j = 0; - while (server.monitors[i].names[j] != 0) { - if (strcmp(monitor, server.monitors[i].names[j++]) == 0) - return i; - } - } - } - } - // monitor == "all" or monitor not found or xrandr can't identify monitors - return -1; + if (strcmp(monitor, "all") != 0) { + char *endptr; + int ret_int = strtol(monitor, &endptr, 10); + if (*endptr == 0) + return ret_int - 1; + else { + // monitor specified by name, not by index + int i, j; + for (i = 0; i < server.num_monitors; ++i) { + if (server.monitors[i].names == 0) + // xrandr can't identify monitors + continue; + j = 0; + while (server.monitors[i].names[j] != 0) { + if (strcmp(monitor, server.monitors[i].names[j++]) == 0) + return i; + } + } + } + } + // monitor == "all" or monitor not found or xrandr can't identify monitors + return -1; } static gint compare_strings(gconstpointer a, gconstpointer b) { - return strnatcasecmp((const char *)a, (const char *)b); + return strnatcasecmp((const char *)a, (const char *)b); } void load_launcher_app_dir(const char *path) { - GList *subdirs = NULL; - GList *files = NULL; + GList *subdirs = NULL; + GList *files = NULL; - GDir *d = g_dir_open(path, 0, NULL); - if (d) { - const gchar *name; - while ((name = g_dir_read_name(d))) { - gchar *file = g_build_filename(path, name, NULL); - if (!g_file_test(file, G_FILE_TEST_IS_DIR) && g_str_has_suffix(file, ".desktop")) { - files = g_list_append(files, file); - } else if (g_file_test(file, G_FILE_TEST_IS_DIR)) { - subdirs = g_list_append(subdirs, file); - } else { - g_free(file); - } - } - g_dir_close(d); - } + GDir *d = g_dir_open(path, 0, NULL); + if (d) { + const gchar *name; + while ((name = g_dir_read_name(d))) { + gchar *file = g_build_filename(path, name, NULL); + if (!g_file_test(file, G_FILE_TEST_IS_DIR) && g_str_has_suffix(file, ".desktop")) { + files = g_list_append(files, file); + } else if (g_file_test(file, G_FILE_TEST_IS_DIR)) { + subdirs = g_list_append(subdirs, file); + } else { + g_free(file); + } + } + g_dir_close(d); + } - subdirs = g_list_sort(subdirs, compare_strings); - GList *l; - for (l = subdirs; l; l = g_list_next(l)) { - gchar *dir = (gchar *)l->data; - load_launcher_app_dir(dir); - g_free(dir); - } - g_list_free(subdirs); + subdirs = g_list_sort(subdirs, compare_strings); + GList *l; + for (l = subdirs; l; l = g_list_next(l)) { + gchar *dir = (gchar *)l->data; + load_launcher_app_dir(dir); + g_free(dir); + } + g_list_free(subdirs); - files = g_list_sort(files, compare_strings); - for (l = files; l; l = g_list_next(l)) { - gchar *file = (gchar *)l->data; - panel_config.launcher.list_apps = g_slist_append(panel_config.launcher.list_apps, strdup(file)); - g_free(file); - } - g_list_free(files); + files = g_list_sort(files, compare_strings); + for (l = files; l; l = g_list_next(l)) { + gchar *file = (gchar *)l->data; + panel_config.launcher.list_apps = g_slist_append(panel_config.launcher.list_apps, strdup(file)); + g_free(file); + } + g_list_free(files); } Separator *get_or_create_last_separator() { - if (!panel_config.separator_list) { - fprintf(stderr, "Warning: separator items should shart with 'separator = new'\n"); - panel_config.separator_list = g_list_append(panel_config.separator_list, create_separator()); - } - return (Separator *)g_list_last(panel_config.separator_list)->data; + if (!panel_config.separator_list) { + fprintf(stderr, "Warning: separator items should shart with 'separator = new'\n"); + panel_config.separator_list = g_list_append(panel_config.separator_list, create_separator()); + } + return (Separator *)g_list_last(panel_config.separator_list)->data; } Execp *get_or_create_last_execp() { - if (!panel_config.execp_list) { - fprintf(stderr, "Warning: execp items should start with 'execp = new'\n"); - panel_config.execp_list = g_list_append(panel_config.execp_list, create_execp()); - } - return (Execp *)g_list_last(panel_config.execp_list)->data; + if (!panel_config.execp_list) { + fprintf(stderr, "Warning: execp items should start with 'execp = new'\n"); + panel_config.execp_list = g_list_append(panel_config.execp_list, create_execp()); + } + return (Execp *)g_list_last(panel_config.execp_list)->data; } Button *get_or_create_last_button() { - if (!panel_config.button_list) { - fprintf(stderr, "Warning: button items should start with 'button = new'\n"); - panel_config.button_list = g_list_append(panel_config.button_list, create_button()); - } - return (Button *)g_list_last(panel_config.button_list)->data; + if (!panel_config.button_list) { + fprintf(stderr, "Warning: button items should start with 'button = new'\n"); + panel_config.button_list = g_list_append(panel_config.button_list, create_button()); + } + return (Button *)g_list_last(panel_config.button_list)->data; } void add_entry(char *key, char *value) { - char *value1 = 0, *value2 = 0, *value3 = 0; + char *value1 = 0, *value2 = 0, *value3 = 0; - /* Background and border */ - if (strcmp(key, "rounded") == 0) { - // 'rounded' is the first parameter => alloc a new background - if (backgrounds->len > 0) { - Background *bg = &g_array_index(backgrounds, Background, backgrounds->len - 1); - if (!read_bg_color_hover) - memcpy(&bg->fill_color_hover, &bg->fill_color, sizeof(Color)); - if (!read_border_color_hover) - memcpy(&bg->border_color_hover, &bg->border, sizeof(Color)); - if (!read_bg_color_press) - memcpy(&bg->fill_color_pressed, &bg->fill_color_hover, sizeof(Color)); - if (!read_border_color_press) - memcpy(&bg->border_color_pressed, &bg->border_color_hover, sizeof(Color)); - } - Background bg; - init_background(&bg); - bg.border.radius = atoi(value); - g_array_append_val(backgrounds, bg); - read_bg_color_hover = FALSE; - read_border_color_hover = FALSE; - read_bg_color_press = FALSE; - read_border_color_press = FALSE; - } else if (strcmp(key, "border_width") == 0) { - g_array_index(backgrounds, Background, backgrounds->len - 1).border.width = atoi(value); - } else if (strcmp(key, "border_sides") == 0) { - Background *bg = &g_array_index(backgrounds, Background, backgrounds->len - 1); - bg->border.mask = 0; - if (strchr(value, 'l') || strchr(value, 'L')) - bg->border.mask |= BORDER_LEFT; - if (strchr(value, 'r') || strchr(value, 'R')) - bg->border.mask |= BORDER_RIGHT; - if (strchr(value, 't') || strchr(value, 'T')) - bg->border.mask |= BORDER_TOP; - if (strchr(value, 'b') || strchr(value, 'B')) - bg->border.mask |= BORDER_BOTTOM; - if (!bg->border.mask) - bg->border.width = 0; - } else if (strcmp(key, "background_color") == 0) { - Background *bg = &g_array_index(backgrounds, Background, backgrounds->len - 1); - extract_values(value, &value1, &value2, &value3); - get_color(value1, bg->fill_color.rgb); - if (value2) - bg->fill_color.alpha = (atoi(value2) / 100.0); - else - bg->fill_color.alpha = 0.5; - } else if (strcmp(key, "border_color") == 0) { - Background *bg = &g_array_index(backgrounds, Background, backgrounds->len - 1); - extract_values(value, &value1, &value2, &value3); - get_color(value1, bg->border.color.rgb); - if (value2) - bg->border.color.alpha = (atoi(value2) / 100.0); - else - bg->border.color.alpha = 0.5; - } else if (strcmp(key, "background_color_hover") == 0) { - Background *bg = &g_array_index(backgrounds, Background, backgrounds->len - 1); - extract_values(value, &value1, &value2, &value3); - get_color(value1, bg->fill_color_hover.rgb); - if (value2) - bg->fill_color_hover.alpha = (atoi(value2) / 100.0); - else - bg->fill_color_hover.alpha = 0.5; - read_bg_color_hover = 1; - } else if (strcmp(key, "border_color_hover") == 0) { - Background *bg = &g_array_index(backgrounds, Background, backgrounds->len - 1); - extract_values(value, &value1, &value2, &value3); - get_color(value1, bg->border_color_hover.rgb); - if (value2) - bg->border_color_hover.alpha = (atoi(value2) / 100.0); - else - bg->border_color_hover.alpha = 0.5; - read_border_color_hover = 1; - } else if (strcmp(key, "background_color_pressed") == 0) { - Background *bg = &g_array_index(backgrounds, Background, backgrounds->len - 1); - extract_values(value, &value1, &value2, &value3); - get_color(value1, bg->fill_color_pressed.rgb); - if (value2) - bg->fill_color_pressed.alpha = (atoi(value2) / 100.0); - else - bg->fill_color_pressed.alpha = 0.5; - read_bg_color_press = 1; - } else if (strcmp(key, "border_color_pressed") == 0) { - Background *bg = &g_array_index(backgrounds, Background, backgrounds->len - 1); - extract_values(value, &value1, &value2, &value3); - get_color(value1, bg->border_color_pressed.rgb); - if (value2) - bg->border_color_pressed.alpha = (atoi(value2) / 100.0); - else - bg->border_color_pressed.alpha = 0.5; - read_border_color_press = 1; - } else if (strcmp(key, "gradient_id") == 0) { - Background *bg = &g_array_index(backgrounds, Background, backgrounds->len - 1); - int id = atoi(value); - id = (id < gradients->len && id >= 0) ? id : -1; - if (id >= 0) - bg->gradients[MOUSE_NORMAL] = &g_array_index(gradients, GradientClass, id); - } else if (strcmp(key, "gradient_id_hover") == 0 || strcmp(key, "hover_gradient_id") == 0) { - Background *bg = &g_array_index(backgrounds, Background, backgrounds->len - 1); - int id = atoi(value); - id = (id < gradients->len && id >= 0) ? id : -1; - if (id >= 0) - bg->gradients[MOUSE_OVER] = &g_array_index(gradients, GradientClass, id); - } else if (strcmp(key, "gradient_id_pressed") == 0 || strcmp(key, "pressed_gradient_id") == 0) { - Background *bg = &g_array_index(backgrounds, Background, backgrounds->len - 1); - int id = atoi(value); - id = (id < gradients->len && id >= 0) ? id : -1; - if (id >= 0) - bg->gradients[MOUSE_DOWN] = &g_array_index(gradients, GradientClass, id); - } + /* Background and border */ + if (strcmp(key, "rounded") == 0) { + // 'rounded' is the first parameter => alloc a new background + if (backgrounds->len > 0) { + Background *bg = &g_array_index(backgrounds, Background, backgrounds->len - 1); + if (!read_bg_color_hover) + memcpy(&bg->fill_color_hover, &bg->fill_color, sizeof(Color)); + if (!read_border_color_hover) + memcpy(&bg->border_color_hover, &bg->border, sizeof(Color)); + if (!read_bg_color_press) + memcpy(&bg->fill_color_pressed, &bg->fill_color_hover, sizeof(Color)); + if (!read_border_color_press) + memcpy(&bg->border_color_pressed, &bg->border_color_hover, sizeof(Color)); + } + Background bg; + init_background(&bg); + bg.border.radius = atoi(value); + g_array_append_val(backgrounds, bg); + read_bg_color_hover = FALSE; + read_border_color_hover = FALSE; + read_bg_color_press = FALSE; + read_border_color_press = FALSE; + } else if (strcmp(key, "border_width") == 0) { + g_array_index(backgrounds, Background, backgrounds->len - 1).border.width = atoi(value); + } else if (strcmp(key, "border_sides") == 0) { + Background *bg = &g_array_index(backgrounds, Background, backgrounds->len - 1); + bg->border.mask = 0; + if (strchr(value, 'l') || strchr(value, 'L')) + bg->border.mask |= BORDER_LEFT; + if (strchr(value, 'r') || strchr(value, 'R')) + bg->border.mask |= BORDER_RIGHT; + if (strchr(value, 't') || strchr(value, 'T')) + bg->border.mask |= BORDER_TOP; + if (strchr(value, 'b') || strchr(value, 'B')) + bg->border.mask |= BORDER_BOTTOM; + if (!bg->border.mask) + bg->border.width = 0; + } else if (strcmp(key, "background_color") == 0) { + Background *bg = &g_array_index(backgrounds, Background, backgrounds->len - 1); + extract_values(value, &value1, &value2, &value3); + get_color(value1, bg->fill_color.rgb); + if (value2) + bg->fill_color.alpha = (atoi(value2) / 100.0); + else + bg->fill_color.alpha = 0.5; + } else if (strcmp(key, "border_color") == 0) { + Background *bg = &g_array_index(backgrounds, Background, backgrounds->len - 1); + extract_values(value, &value1, &value2, &value3); + get_color(value1, bg->border.color.rgb); + if (value2) + bg->border.color.alpha = (atoi(value2) / 100.0); + else + bg->border.color.alpha = 0.5; + } else if (strcmp(key, "background_color_hover") == 0) { + Background *bg = &g_array_index(backgrounds, Background, backgrounds->len - 1); + extract_values(value, &value1, &value2, &value3); + get_color(value1, bg->fill_color_hover.rgb); + if (value2) + bg->fill_color_hover.alpha = (atoi(value2) / 100.0); + else + bg->fill_color_hover.alpha = 0.5; + read_bg_color_hover = 1; + } else if (strcmp(key, "border_color_hover") == 0) { + Background *bg = &g_array_index(backgrounds, Background, backgrounds->len - 1); + extract_values(value, &value1, &value2, &value3); + get_color(value1, bg->border_color_hover.rgb); + if (value2) + bg->border_color_hover.alpha = (atoi(value2) / 100.0); + else + bg->border_color_hover.alpha = 0.5; + read_border_color_hover = 1; + } else if (strcmp(key, "background_color_pressed") == 0) { + Background *bg = &g_array_index(backgrounds, Background, backgrounds->len - 1); + extract_values(value, &value1, &value2, &value3); + get_color(value1, bg->fill_color_pressed.rgb); + if (value2) + bg->fill_color_pressed.alpha = (atoi(value2) / 100.0); + else + bg->fill_color_pressed.alpha = 0.5; + read_bg_color_press = 1; + } else if (strcmp(key, "border_color_pressed") == 0) { + Background *bg = &g_array_index(backgrounds, Background, backgrounds->len - 1); + extract_values(value, &value1, &value2, &value3); + get_color(value1, bg->border_color_pressed.rgb); + if (value2) + bg->border_color_pressed.alpha = (atoi(value2) / 100.0); + else + bg->border_color_pressed.alpha = 0.5; + read_border_color_press = 1; + } else if (strcmp(key, "gradient_id") == 0) { + Background *bg = &g_array_index(backgrounds, Background, backgrounds->len - 1); + int id = atoi(value); + id = (id < gradients->len && id >= 0) ? id : -1; + if (id >= 0) + bg->gradients[MOUSE_NORMAL] = &g_array_index(gradients, GradientClass, id); + } else if (strcmp(key, "gradient_id_hover") == 0 || strcmp(key, "hover_gradient_id") == 0) { + Background *bg = &g_array_index(backgrounds, Background, backgrounds->len - 1); + int id = atoi(value); + id = (id < gradients->len && id >= 0) ? id : -1; + if (id >= 0) + bg->gradients[MOUSE_OVER] = &g_array_index(gradients, GradientClass, id); + } else if (strcmp(key, "gradient_id_pressed") == 0 || strcmp(key, "pressed_gradient_id") == 0) { + Background *bg = &g_array_index(backgrounds, Background, backgrounds->len - 1); + int id = atoi(value); + id = (id < gradients->len && id >= 0) ? id : -1; + if (id >= 0) + bg->gradients[MOUSE_DOWN] = &g_array_index(gradients, GradientClass, id); + } - /* Gradients */ - else if (strcmp(key, "gradient") == 0) { - // Create a new gradient - GradientClass g; - init_gradient(&g, gradient_type_from_string(value)); - g_array_append_val(gradients, g); - } else if (strcmp(key, "start_color") == 0) { - GradientClass *g = &g_array_index(gradients, GradientClass, gradients->len - 1); - extract_values(value, &value1, &value2, &value3); - get_color(value1, g->start_color.rgb); - if (value2) - g->start_color.alpha = (atoi(value2) / 100.0); - else - g->start_color.alpha = 0.5; - } else if (strcmp(key, "end_color") == 0) { - GradientClass *g = &g_array_index(gradients, GradientClass, gradients->len - 1); - extract_values(value, &value1, &value2, &value3); - get_color(value1, g->end_color.rgb); - if (value2) - g->end_color.alpha = (atoi(value2) / 100.0); - else - g->end_color.alpha = 0.5; - } else if (strcmp(key, "color_stop") == 0) { - GradientClass *g = &g_array_index(gradients, GradientClass, gradients->len - 1); - extract_values(value, &value1, &value2, &value3); - ColorStop *color_stop = (ColorStop *) calloc(1, sizeof(ColorStop)); - color_stop->offset = atof(value1) / 100.0; - get_color(value2, color_stop->color.rgb); - if (value3) - color_stop->color.alpha = (atoi(value3) / 100.0); - else - color_stop->color.alpha = 0.5; - g->extra_color_stops = g_list_append(g->extra_color_stops, color_stop); - } + /* Gradients */ + else if (strcmp(key, "gradient") == 0) { + // Create a new gradient + GradientClass g; + init_gradient(&g, gradient_type_from_string(value)); + g_array_append_val(gradients, g); + } else if (strcmp(key, "start_color") == 0) { + GradientClass *g = &g_array_index(gradients, GradientClass, gradients->len - 1); + extract_values(value, &value1, &value2, &value3); + get_color(value1, g->start_color.rgb); + if (value2) + g->start_color.alpha = (atoi(value2) / 100.0); + else + g->start_color.alpha = 0.5; + } else if (strcmp(key, "end_color") == 0) { + GradientClass *g = &g_array_index(gradients, GradientClass, gradients->len - 1); + extract_values(value, &value1, &value2, &value3); + get_color(value1, g->end_color.rgb); + if (value2) + g->end_color.alpha = (atoi(value2) / 100.0); + else + g->end_color.alpha = 0.5; + } else if (strcmp(key, "color_stop") == 0) { + GradientClass *g = &g_array_index(gradients, GradientClass, gradients->len - 1); + extract_values(value, &value1, &value2, &value3); + ColorStop *color_stop = (ColorStop *)calloc(1, sizeof(ColorStop)); + color_stop->offset = atof(value1) / 100.0; + get_color(value2, color_stop->color.rgb); + if (value3) + color_stop->color.alpha = (atoi(value3) / 100.0); + else + color_stop->color.alpha = 0.5; + g->extra_color_stops = g_list_append(g->extra_color_stops, color_stop); + } - /* Panel */ - else if (strcmp(key, "panel_monitor") == 0) { - panel_config.monitor = config_get_monitor(value); - } else if (strcmp(key, "primary_monitor_first") == 0) { - primary_monitor_first = atoi(value); - } else if (strcmp(key, "panel_shrink") == 0) { - panel_shrink = atoi(value); - } else if (strcmp(key, "panel_size") == 0) { - extract_values(value, &value1, &value2, &value3); + /* Panel */ + else if (strcmp(key, "panel_monitor") == 0) { + panel_config.monitor = config_get_monitor(value); + } else if (strcmp(key, "primary_monitor_first") == 0) { + primary_monitor_first = atoi(value); + } else if (strcmp(key, "panel_shrink") == 0) { + panel_shrink = atoi(value); + } else if (strcmp(key, "panel_size") == 0) { + extract_values(value, &value1, &value2, &value3); - char *b; - if ((b = strchr(value1, '%'))) { - b[0] = '\0'; - panel_config.fractional_width = TRUE; - } - panel_config.area.width = atoi(value1); - if (panel_config.area.width == 0) { - // full width mode - panel_config.area.width = 100; - panel_config.fractional_width = TRUE; - } - if (value2) { - if ((b = strchr(value2, '%'))) { - b[0] = '\0'; - panel_config.fractional_height = 1; - } - panel_config.area.height = atoi(value2); - } - } else if (strcmp(key, "panel_items") == 0) { - new_config_file = TRUE; - panel_items_order = strdup(value); - systray_enabled = 0; - launcher_enabled = 0; + char *b; + if ((b = strchr(value1, '%'))) { + b[0] = '\0'; + panel_config.fractional_width = TRUE; + } + panel_config.area.width = atoi(value1); + if (panel_config.area.width == 0) { + // full width mode + panel_config.area.width = 100; + panel_config.fractional_width = TRUE; + } + if (value2) { + if ((b = strchr(value2, '%'))) { + b[0] = '\0'; + panel_config.fractional_height = 1; + } + panel_config.area.height = atoi(value2); + } + } else if (strcmp(key, "panel_items") == 0) { + new_config_file = TRUE; + panel_items_order = strdup(value); + systray_enabled = 0; + launcher_enabled = 0; #ifdef ENABLE_BATTERY - battery_enabled = 0; + battery_enabled = 0; #endif - clock_enabled = 0; - taskbar_enabled = 0; - for (int j = 0; j < strlen(panel_items_order); j++) { - if (panel_items_order[j] == 'L') - launcher_enabled = 1; - if (panel_items_order[j] == 'T') - taskbar_enabled = 1; - if (panel_items_order[j] == 'B') { + clock_enabled = 0; + taskbar_enabled = 0; + for (int j = 0; j < strlen(panel_items_order); j++) { + if (panel_items_order[j] == 'L') + launcher_enabled = 1; + if (panel_items_order[j] == 'T') + taskbar_enabled = 1; + if (panel_items_order[j] == 'B') { #ifdef ENABLE_BATTERY - battery_enabled = 1; + battery_enabled = 1; #else - fprintf(stderr, "tint2 is build without battery support\n"); + fprintf(stderr, "tint2 is build without battery support\n"); #endif - } - if (panel_items_order[j] == 'S') { - // systray disabled in snapshot mode - if (snapshot_path == 0) - systray_enabled = 1; - } - if (panel_items_order[j] == 'C') - clock_enabled = 1; - } - } else if (strcmp(key, "panel_margin") == 0) { - extract_values(value, &value1, &value2, &value3); - panel_config.marginx = atoi(value1); - if (value2) - panel_config.marginy = atoi(value2); - } else if (strcmp(key, "panel_padding") == 0) { - extract_values(value, &value1, &value2, &value3); - panel_config.area.paddingxlr = panel_config.area.paddingx = atoi(value1); - if (value2) - 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; - else { - if (strcmp(value1, "bottom") == 0) - panel_position = BOTTOM; - else - panel_position = CENTER; - } + } + if (panel_items_order[j] == 'S') { + // systray disabled in snapshot mode + if (snapshot_path == 0) + systray_enabled = 1; + } + if (panel_items_order[j] == 'C') + clock_enabled = 1; + } + } else if (strcmp(key, "panel_margin") == 0) { + extract_values(value, &value1, &value2, &value3); + panel_config.marginx = atoi(value1); + if (value2) + panel_config.marginy = atoi(value2); + } else if (strcmp(key, "panel_padding") == 0) { + extract_values(value, &value1, &value2, &value3); + panel_config.area.paddingxlr = panel_config.area.paddingx = atoi(value1); + if (value2) + 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; + else { + if (strcmp(value1, "bottom") == 0) + panel_position = BOTTOM; + else + panel_position = CENTER; + } - if (!value2) - panel_position |= CENTER; - else { - if (strcmp(value2, "left") == 0) - panel_position |= LEFT; - else { - if (strcmp(value2, "right") == 0) - panel_position |= RIGHT; - else - panel_position |= CENTER; - } - } - if (!value3) - panel_horizontal = 1; - else { - if (strcmp(value3, "vertical") == 0) - panel_horizontal = 0; - else - panel_horizontal = 1; - } - } else if (strcmp(key, "font_shadow") == 0) - panel_config.font_shadow = atoi(value); - else if (strcmp(key, "panel_background_id") == 0) { - int id = atoi(value); - id = (id < backgrounds->len && id >= 0) ? id : 0; - panel_config.area.bg = &g_array_index(backgrounds, Background, id); - } else if (strcmp(key, "wm_menu") == 0) - wm_menu = atoi(value); - else if (strcmp(key, "panel_dock") == 0) - panel_dock = atoi(value); - else if (strcmp(key, "urgent_nb_of_blink") == 0) - max_tick_urgent = atoi(value); - else if (strcmp(key, "panel_layer") == 0) { - if (strcmp(value, "bottom") == 0) - panel_layer = BOTTOM_LAYER; - else if (strcmp(value, "top") == 0) - panel_layer = TOP_LAYER; - else - panel_layer = NORMAL_LAYER; - } else if (strcmp(key, "disable_transparency") == 0) { - server.disable_transparency = atoi(value); - } else if (strcmp(key, "panel_window_name") == 0) { - if (strlen(value) > 0) { - free(panel_window_name); - panel_window_name = strdup(value); - } - } + if (!value2) + panel_position |= CENTER; + else { + if (strcmp(value2, "left") == 0) + panel_position |= LEFT; + else { + if (strcmp(value2, "right") == 0) + panel_position |= RIGHT; + else + panel_position |= CENTER; + } + } + if (!value3) + panel_horizontal = 1; + else { + if (strcmp(value3, "vertical") == 0) + panel_horizontal = 0; + else + panel_horizontal = 1; + } + } else if (strcmp(key, "font_shadow") == 0) + panel_config.font_shadow = atoi(value); + else if (strcmp(key, "panel_background_id") == 0) { + int id = atoi(value); + id = (id < backgrounds->len && id >= 0) ? id : 0; + panel_config.area.bg = &g_array_index(backgrounds, Background, id); + } else if (strcmp(key, "wm_menu") == 0) + wm_menu = atoi(value); + else if (strcmp(key, "panel_dock") == 0) + panel_dock = atoi(value); + else if (strcmp(key, "urgent_nb_of_blink") == 0) + max_tick_urgent = atoi(value); + else if (strcmp(key, "panel_layer") == 0) { + if (strcmp(value, "bottom") == 0) + panel_layer = BOTTOM_LAYER; + else if (strcmp(value, "top") == 0) + panel_layer = TOP_LAYER; + else + panel_layer = NORMAL_LAYER; + } else if (strcmp(key, "disable_transparency") == 0) { + server.disable_transparency = atoi(value); + } else if (strcmp(key, "panel_window_name") == 0) { + if (strlen(value) > 0) { + free(panel_window_name); + panel_window_name = strdup(value); + } + } - /* Battery */ - else if (strcmp(key, "battery_low_status") == 0) { + /* Battery */ + else if (strcmp(key, "battery_low_status") == 0) { #ifdef ENABLE_BATTERY - battery_low_status = atoi(value); - if (battery_low_status < 0 || battery_low_status > 100) - battery_low_status = 0; + battery_low_status = atoi(value); + if (battery_low_status < 0 || battery_low_status > 100) + battery_low_status = 0; #endif - } else if (strcmp(key, "battery_lclick_command") == 0) { + } else if (strcmp(key, "battery_lclick_command") == 0) { #ifdef ENABLE_BATTERY - if (strlen(value) > 0) - battery_lclick_command = strdup(value); + if (strlen(value) > 0) + battery_lclick_command = strdup(value); #endif - } else if (strcmp(key, "battery_mclick_command") == 0) { + } else if (strcmp(key, "battery_mclick_command") == 0) { #ifdef ENABLE_BATTERY - if (strlen(value) > 0) - battery_mclick_command = strdup(value); + if (strlen(value) > 0) + battery_mclick_command = strdup(value); #endif - } else if (strcmp(key, "battery_rclick_command") == 0) { + } else if (strcmp(key, "battery_rclick_command") == 0) { #ifdef ENABLE_BATTERY - if (strlen(value) > 0) - battery_rclick_command = strdup(value); + if (strlen(value) > 0) + battery_rclick_command = strdup(value); #endif - } else if (strcmp(key, "battery_uwheel_command") == 0) { + } else if (strcmp(key, "battery_uwheel_command") == 0) { #ifdef ENABLE_BATTERY - if (strlen(value) > 0) - battery_uwheel_command = strdup(value); + if (strlen(value) > 0) + battery_uwheel_command = strdup(value); #endif - } else if (strcmp(key, "battery_dwheel_command") == 0) { + } else if (strcmp(key, "battery_dwheel_command") == 0) { #ifdef ENABLE_BATTERY - if (strlen(value) > 0) - battery_dwheel_command = strdup(value); + if (strlen(value) > 0) + battery_dwheel_command = strdup(value); #endif - } else if (strcmp(key, "battery_low_cmd") == 0) { + } else if (strcmp(key, "battery_low_cmd") == 0) { #ifdef ENABLE_BATTERY - if (strlen(value) > 0) - battery_low_cmd = strdup(value); + if (strlen(value) > 0) + battery_low_cmd = strdup(value); #endif - } else if (strcmp(key, "ac_connected_cmd") == 0) { + } else if (strcmp(key, "ac_connected_cmd") == 0) { #ifdef ENABLE_BATTERY - if (strlen(value) > 0) - ac_connected_cmd = strdup(value); + if (strlen(value) > 0) + ac_connected_cmd = strdup(value); #endif - } else if (strcmp(key, "ac_disconnected_cmd") == 0) { + } else if (strcmp(key, "ac_disconnected_cmd") == 0) { #ifdef ENABLE_BATTERY - if (strlen(value) > 0) - ac_disconnected_cmd = strdup(value); + if (strlen(value) > 0) + ac_disconnected_cmd = strdup(value); #endif - } else if (strcmp(key, "bat1_font") == 0) { + } else if (strcmp(key, "bat1_font") == 0) { #ifdef ENABLE_BATTERY - bat1_font_desc = pango_font_description_from_string(value); - bat1_has_font = TRUE; + bat1_font_desc = pango_font_description_from_string(value); + bat1_has_font = TRUE; #endif - } else if (strcmp(key, "bat2_font") == 0) { + } else if (strcmp(key, "bat2_font") == 0) { #ifdef ENABLE_BATTERY - bat2_font_desc = pango_font_description_from_string(value); - bat2_has_font = TRUE; + bat2_font_desc = pango_font_description_from_string(value); + bat2_has_font = TRUE; #endif - } else if (strcmp(key, "battery_font_color") == 0) { + } else if (strcmp(key, "battery_font_color") == 0) { #ifdef ENABLE_BATTERY - extract_values(value, &value1, &value2, &value3); - get_color(value1, panel_config.battery.font_color.rgb); - if (value2) - panel_config.battery.font_color.alpha = (atoi(value2) / 100.0); - else - panel_config.battery.font_color.alpha = 0.5; + extract_values(value, &value1, &value2, &value3); + get_color(value1, panel_config.battery.font_color.rgb); + if (value2) + panel_config.battery.font_color.alpha = (atoi(value2) / 100.0); + else + panel_config.battery.font_color.alpha = 0.5; #endif - } else if (strcmp(key, "battery_padding") == 0) { + } else if (strcmp(key, "battery_padding") == 0) { #ifdef ENABLE_BATTERY - extract_values(value, &value1, &value2, &value3); - panel_config.battery.area.paddingxlr = panel_config.battery.area.paddingx = atoi(value1); - if (value2) - panel_config.battery.area.paddingy = atoi(value2); - if (value3) - panel_config.battery.area.paddingx = atoi(value3); + extract_values(value, &value1, &value2, &value3); + panel_config.battery.area.paddingxlr = panel_config.battery.area.paddingx = atoi(value1); + if (value2) + panel_config.battery.area.paddingy = atoi(value2); + if (value3) + panel_config.battery.area.paddingx = atoi(value3); #endif - } else if (strcmp(key, "battery_background_id") == 0) { + } else if (strcmp(key, "battery_background_id") == 0) { #ifdef ENABLE_BATTERY - int id = atoi(value); - id = (id < backgrounds->len && id >= 0) ? id : 0; - panel_config.battery.area.bg = &g_array_index(backgrounds, Background, id); + int id = atoi(value); + id = (id < backgrounds->len && id >= 0) ? id : 0; + panel_config.battery.area.bg = &g_array_index(backgrounds, Background, id); #endif - } else if (strcmp(key, "battery_hide") == 0) { + } else if (strcmp(key, "battery_hide") == 0) { #ifdef ENABLE_BATTERY - percentage_hide = atoi(value); - if (percentage_hide == 0) - percentage_hide = 101; + percentage_hide = atoi(value); + if (percentage_hide == 0) + percentage_hide = 101; #endif - } else if (strcmp(key, "battery_tooltip") == 0) { + } else if (strcmp(key, "battery_tooltip") == 0) { #ifdef ENABLE_BATTERY - battery_tooltip_enabled = atoi(value); + battery_tooltip_enabled = atoi(value); #endif - } + } - /* Separator */ - else if (strcmp(key, "separator") == 0) { - panel_config.separator_list = g_list_append(panel_config.separator_list, create_separator()); - } else if (strcmp(key, "separator_background_id") == 0) { - Separator *separator = get_or_create_last_separator(); - int id = atoi(value); - id = (id < backgrounds->len && id >= 0) ? id : 0; - separator->area.bg = &g_array_index(backgrounds, Background, id); - } else if (strcmp(key, "separator_color") == 0) { - Separator *separator = get_or_create_last_separator(); - extract_values(value, &value1, &value2, &value3); - get_color(value1, separator->color.rgb); - if (value2) - separator->color.alpha = (atoi(value2) / 100.0); - else - separator->color.alpha = 0.5; - } else if (strcmp(key, "separator_style") == 0) { - Separator *separator = get_or_create_last_separator(); - if (g_str_equal(value, "empty")) - separator->style = SEPARATOR_EMPTY; - else if (g_str_equal(value, "line")) - separator->style = SEPARATOR_LINE; - else if (g_str_equal(value, "dots")) - separator->style = SEPARATOR_DOTS; - else - fprintf(stderr, RED "Invalid separator_style value: %s" RESET "\n", value); - } else if (strcmp(key, "separator_size") == 0) { - Separator *separator = get_or_create_last_separator(); - separator->thickness = atoi(value); - } else if (strcmp(key, "separator_padding") == 0) { - Separator *separator = get_or_create_last_separator(); - extract_values(value, &value1, &value2, &value3); - separator->area.paddingxlr = separator->area.paddingx = atoi(value1); - if (value2) - separator->area.paddingy = atoi(value2); - if (value3) - separator->area.paddingx = atoi(value3); - } + /* Separator */ + else if (strcmp(key, "separator") == 0) { + panel_config.separator_list = g_list_append(panel_config.separator_list, create_separator()); + } else if (strcmp(key, "separator_background_id") == 0) { + Separator *separator = get_or_create_last_separator(); + int id = atoi(value); + id = (id < backgrounds->len && id >= 0) ? id : 0; + separator->area.bg = &g_array_index(backgrounds, Background, id); + } else if (strcmp(key, "separator_color") == 0) { + Separator *separator = get_or_create_last_separator(); + extract_values(value, &value1, &value2, &value3); + get_color(value1, separator->color.rgb); + if (value2) + separator->color.alpha = (atoi(value2) / 100.0); + else + separator->color.alpha = 0.5; + } else if (strcmp(key, "separator_style") == 0) { + Separator *separator = get_or_create_last_separator(); + if (g_str_equal(value, "empty")) + separator->style = SEPARATOR_EMPTY; + else if (g_str_equal(value, "line")) + separator->style = SEPARATOR_LINE; + else if (g_str_equal(value, "dots")) + separator->style = SEPARATOR_DOTS; + else + fprintf(stderr, RED "Invalid separator_style value: %s" RESET "\n", value); + } else if (strcmp(key, "separator_size") == 0) { + Separator *separator = get_or_create_last_separator(); + separator->thickness = atoi(value); + } else if (strcmp(key, "separator_padding") == 0) { + Separator *separator = get_or_create_last_separator(); + extract_values(value, &value1, &value2, &value3); + separator->area.paddingxlr = separator->area.paddingx = atoi(value1); + if (value2) + separator->area.paddingy = atoi(value2); + if (value3) + separator->area.paddingx = atoi(value3); + } - /* Execp */ - else if (strcmp(key, "execp") == 0) { - panel_config.execp_list = g_list_append(panel_config.execp_list, create_execp()); - } else if (strcmp(key, "execp_command") == 0) { - Execp *execp = get_or_create_last_execp(); - free_and_null(execp->backend->command); - if (strlen(value) > 0) - execp->backend->command = strdup(value); - } else if (strcmp(key, "execp_interval") == 0) { - Execp *execp = get_or_create_last_execp(); - execp->backend->interval = 0; - int v = atoi(value); - if (v < 1) { - fprintf(stderr, "execp_interval must be an integer >= 1\n"); - } else { - execp->backend->interval = v; - } - } else if (strcmp(key, "execp_has_icon") == 0) { - Execp *execp = get_or_create_last_execp(); - execp->backend->has_icon = atoi(value); - } else if (strcmp(key, "execp_continuous") == 0) { - Execp *execp = get_or_create_last_execp(); - execp->backend->continuous = atoi(value); - } else if (strcmp(key, "execp_markup") == 0) { - Execp *execp = get_or_create_last_execp(); - execp->backend->has_markup = atoi(value); - } else if (strcmp(key, "execp_cache_icon") == 0) { - Execp *execp = get_or_create_last_execp(); - execp->backend->cache_icon = atoi(value); - } else if (strcmp(key, "execp_tooltip") == 0) { - Execp *execp = get_or_create_last_execp(); - free_and_null(execp->backend->tooltip); - execp->backend->tooltip = strdup(value); - } else if (strcmp(key, "execp_font") == 0) { - Execp *execp = get_or_create_last_execp(); - pango_font_description_free(execp->backend->font_desc); - execp->backend->font_desc = pango_font_description_from_string(value); - execp->backend->has_font = TRUE; - } else if (strcmp(key, "execp_font_color") == 0) { - Execp *execp = get_or_create_last_execp(); - extract_values(value, &value1, &value2, &value3); - get_color(value1, execp->backend->font_color.rgb); - if (value2) - execp->backend->font_color.alpha = atoi(value2) / 100.0; - else - execp->backend->font_color.alpha = 0.5; - } else if (strcmp(key, "execp_padding") == 0) { - Execp *execp = get_or_create_last_execp(); - extract_values(value, &value1, &value2, &value3); - execp->backend->paddingxlr = execp->backend->paddingx = atoi(value1); - if (value2) - execp->backend->paddingy = atoi(value2); - else - execp->backend->paddingy = 0; - if (value3) - execp->backend->paddingx = atoi(value3); - } else if (strcmp(key, "execp_background_id") == 0) { - Execp *execp = get_or_create_last_execp(); - int id = atoi(value); - id = (id < backgrounds->len && id >= 0) ? id : 0; - execp->backend->bg = &g_array_index(backgrounds, Background, id); - } else if (strcmp(key, "execp_centered") == 0) { - Execp *execp = get_or_create_last_execp(); - execp->backend->centered = atoi(value); - } else if (strcmp(key, "execp_icon_w") == 0) { - Execp *execp = get_or_create_last_execp(); - int v = atoi(value); - if (v < 0) { - fprintf(stderr, "execp_icon_w must be an integer >= 0\n"); - } else { - execp->backend->icon_w = v; - } - } else if (strcmp(key, "execp_icon_h") == 0) { - Execp *execp = get_or_create_last_execp(); - int v = atoi(value); - if (v < 0) { - fprintf(stderr, "execp_icon_h must be an integer >= 0\n"); - } else { - execp->backend->icon_h = v; - } - } else if (strcmp(key, "execp_lclick_command") == 0) { - Execp *execp = get_or_create_last_execp(); - free_and_null(execp->backend->lclick_command); - if (strlen(value) > 0) - execp->backend->lclick_command = strdup(value); - } else if (strcmp(key, "execp_mclick_command") == 0) { - Execp *execp = get_or_create_last_execp(); - free_and_null(execp->backend->mclick_command); - if (strlen(value) > 0) - execp->backend->mclick_command = strdup(value); - } else if (strcmp(key, "execp_rclick_command") == 0) { - Execp *execp = get_or_create_last_execp(); - free_and_null(execp->backend->rclick_command); - if (strlen(value) > 0) - execp->backend->rclick_command = strdup(value); - } else if (strcmp(key, "execp_uwheel_command") == 0) { - Execp *execp = get_or_create_last_execp(); - free_and_null(execp->backend->uwheel_command); - if (strlen(value) > 0) - execp->backend->uwheel_command = strdup(value); - } else if (strcmp(key, "execp_dwheel_command") == 0) { - Execp *execp = get_or_create_last_execp(); - free_and_null(execp->backend->dwheel_command); - if (strlen(value) > 0) - execp->backend->dwheel_command = strdup(value); - } + /* Execp */ + else if (strcmp(key, "execp") == 0) { + panel_config.execp_list = g_list_append(panel_config.execp_list, create_execp()); + } else if (strcmp(key, "execp_command") == 0) { + Execp *execp = get_or_create_last_execp(); + free_and_null(execp->backend->command); + if (strlen(value) > 0) + execp->backend->command = strdup(value); + } else if (strcmp(key, "execp_interval") == 0) { + Execp *execp = get_or_create_last_execp(); + execp->backend->interval = 0; + int v = atoi(value); + if (v < 1) { + fprintf(stderr, "execp_interval must be an integer >= 1\n"); + } else { + execp->backend->interval = v; + } + } else if (strcmp(key, "execp_has_icon") == 0) { + Execp *execp = get_or_create_last_execp(); + execp->backend->has_icon = atoi(value); + } else if (strcmp(key, "execp_continuous") == 0) { + Execp *execp = get_or_create_last_execp(); + execp->backend->continuous = atoi(value); + } else if (strcmp(key, "execp_markup") == 0) { + Execp *execp = get_or_create_last_execp(); + execp->backend->has_markup = atoi(value); + } else if (strcmp(key, "execp_cache_icon") == 0) { + Execp *execp = get_or_create_last_execp(); + execp->backend->cache_icon = atoi(value); + } else if (strcmp(key, "execp_tooltip") == 0) { + Execp *execp = get_or_create_last_execp(); + free_and_null(execp->backend->tooltip); + execp->backend->tooltip = strdup(value); + } else if (strcmp(key, "execp_font") == 0) { + Execp *execp = get_or_create_last_execp(); + pango_font_description_free(execp->backend->font_desc); + execp->backend->font_desc = pango_font_description_from_string(value); + execp->backend->has_font = TRUE; + } else if (strcmp(key, "execp_font_color") == 0) { + Execp *execp = get_or_create_last_execp(); + extract_values(value, &value1, &value2, &value3); + get_color(value1, execp->backend->font_color.rgb); + if (value2) + execp->backend->font_color.alpha = atoi(value2) / 100.0; + else + execp->backend->font_color.alpha = 0.5; + } else if (strcmp(key, "execp_padding") == 0) { + Execp *execp = get_or_create_last_execp(); + extract_values(value, &value1, &value2, &value3); + execp->backend->paddingxlr = execp->backend->paddingx = atoi(value1); + if (value2) + execp->backend->paddingy = atoi(value2); + else + execp->backend->paddingy = 0; + if (value3) + execp->backend->paddingx = atoi(value3); + } else if (strcmp(key, "execp_background_id") == 0) { + Execp *execp = get_or_create_last_execp(); + int id = atoi(value); + id = (id < backgrounds->len && id >= 0) ? id : 0; + execp->backend->bg = &g_array_index(backgrounds, Background, id); + } else if (strcmp(key, "execp_centered") == 0) { + Execp *execp = get_or_create_last_execp(); + execp->backend->centered = atoi(value); + } else if (strcmp(key, "execp_icon_w") == 0) { + Execp *execp = get_or_create_last_execp(); + int v = atoi(value); + if (v < 0) { + fprintf(stderr, "execp_icon_w must be an integer >= 0\n"); + } else { + execp->backend->icon_w = v; + } + } else if (strcmp(key, "execp_icon_h") == 0) { + Execp *execp = get_or_create_last_execp(); + int v = atoi(value); + if (v < 0) { + fprintf(stderr, "execp_icon_h must be an integer >= 0\n"); + } else { + execp->backend->icon_h = v; + } + } else if (strcmp(key, "execp_lclick_command") == 0) { + Execp *execp = get_or_create_last_execp(); + free_and_null(execp->backend->lclick_command); + if (strlen(value) > 0) + execp->backend->lclick_command = strdup(value); + } else if (strcmp(key, "execp_mclick_command") == 0) { + Execp *execp = get_or_create_last_execp(); + free_and_null(execp->backend->mclick_command); + if (strlen(value) > 0) + execp->backend->mclick_command = strdup(value); + } else if (strcmp(key, "execp_rclick_command") == 0) { + Execp *execp = get_or_create_last_execp(); + free_and_null(execp->backend->rclick_command); + if (strlen(value) > 0) + execp->backend->rclick_command = strdup(value); + } else if (strcmp(key, "execp_uwheel_command") == 0) { + Execp *execp = get_or_create_last_execp(); + free_and_null(execp->backend->uwheel_command); + if (strlen(value) > 0) + execp->backend->uwheel_command = strdup(value); + } else if (strcmp(key, "execp_dwheel_command") == 0) { + Execp *execp = get_or_create_last_execp(); + free_and_null(execp->backend->dwheel_command); + if (strlen(value) > 0) + execp->backend->dwheel_command = strdup(value); + } - /* Button */ - else if (strcmp(key, "button") == 0) { - panel_config.button_list = g_list_append(panel_config.button_list, create_button()); - } else if (strcmp(key, "button_icon") == 0 && strlen(value)) { - Button *button = get_or_create_last_button(); - button->backend->icon_name = strdup(value); - } else if (strcmp(key, "button_text") == 0 && strlen(value)) { - Button *button = get_or_create_last_button(); - free_and_null(button->backend->text); - button->backend->text = strdup(value); - } else if (strcmp(key, "button_tooltip") == 0 && strlen(value)) { - Button *button = get_or_create_last_button(); - free_and_null(button->backend->tooltip); - button->backend->tooltip = strdup(value); - } else if (strcmp(key, "button_font") == 0) { - Button *button = get_or_create_last_button(); - pango_font_description_free(button->backend->font_desc); - button->backend->font_desc = pango_font_description_from_string(value); - button->backend->has_font = TRUE; - } else if (strcmp(key, "button_font_color") == 0) { - Button *button = get_or_create_last_button(); - extract_values(value, &value1, &value2, &value3); - get_color(value1, button->backend->font_color.rgb); - if (value2) - button->backend->font_color.alpha = atoi(value2) / 100.0; - else - button->backend->font_color.alpha = 0.5; - } else if (strcmp(key, "button_padding") == 0) { - Button *button = get_or_create_last_button(); - extract_values(value, &value1, &value2, &value3); - button->backend->paddingxlr = button->backend->paddingx = atoi(value1); - if (value2) - button->backend->paddingy = atoi(value2); - else - button->backend->paddingy = 0; - if (value3) - button->backend->paddingx = atoi(value3); - } else if (strcmp(key, "button_max_icon_size") == 0) { - Button *button = get_or_create_last_button(); - extract_values(value, &value1, &value2, &value3); - button->backend->max_icon_size = MAX(0, atoi(value)); - } else if (strcmp(key, "button_background_id") == 0) { - Button *button = get_or_create_last_button(); - int id = atoi(value); - id = (id < backgrounds->len && id >= 0) ? id : 0; - button->backend->bg = &g_array_index(backgrounds, Background, id); - } else if (strcmp(key, "button_centered") == 0) { - Button *button = get_or_create_last_button(); - button->backend->centered = atoi(value); - } else if (strcmp(key, "button_lclick_command") == 0) { - Button *button = get_or_create_last_button(); - free_and_null(button->backend->lclick_command); - if (strlen(value) > 0) - button->backend->lclick_command = strdup(value); - } else if (strcmp(key, "button_mclick_command") == 0) { - Button *button = get_or_create_last_button(); - free_and_null(button->backend->mclick_command); - if (strlen(value) > 0) - button->backend->mclick_command = strdup(value); - } else if (strcmp(key, "button_rclick_command") == 0) { - Button *button = get_or_create_last_button(); - free_and_null(button->backend->rclick_command); - if (strlen(value) > 0) - button->backend->rclick_command = strdup(value); - } else if (strcmp(key, "button_uwheel_command") == 0) { - Button *button = get_or_create_last_button(); - free_and_null(button->backend->uwheel_command); - if (strlen(value) > 0) - button->backend->uwheel_command = strdup(value); - } else if (strcmp(key, "button_dwheel_command") == 0) { - Button *button = get_or_create_last_button(); - free_and_null(button->backend->dwheel_command); - if (strlen(value) > 0) - button->backend->dwheel_command = strdup(value); - } + /* Button */ + else if (strcmp(key, "button") == 0) { + panel_config.button_list = g_list_append(panel_config.button_list, create_button()); + } else if (strcmp(key, "button_icon") == 0 && strlen(value)) { + Button *button = get_or_create_last_button(); + button->backend->icon_name = strdup(value); + } else if (strcmp(key, "button_text") == 0 && strlen(value)) { + Button *button = get_or_create_last_button(); + free_and_null(button->backend->text); + button->backend->text = strdup(value); + } else if (strcmp(key, "button_tooltip") == 0 && strlen(value)) { + Button *button = get_or_create_last_button(); + free_and_null(button->backend->tooltip); + button->backend->tooltip = strdup(value); + } else if (strcmp(key, "button_font") == 0) { + Button *button = get_or_create_last_button(); + pango_font_description_free(button->backend->font_desc); + button->backend->font_desc = pango_font_description_from_string(value); + button->backend->has_font = TRUE; + } else if (strcmp(key, "button_font_color") == 0) { + Button *button = get_or_create_last_button(); + extract_values(value, &value1, &value2, &value3); + get_color(value1, button->backend->font_color.rgb); + if (value2) + button->backend->font_color.alpha = atoi(value2) / 100.0; + else + button->backend->font_color.alpha = 0.5; + } else if (strcmp(key, "button_padding") == 0) { + Button *button = get_or_create_last_button(); + extract_values(value, &value1, &value2, &value3); + button->backend->paddingxlr = button->backend->paddingx = atoi(value1); + if (value2) + button->backend->paddingy = atoi(value2); + else + button->backend->paddingy = 0; + if (value3) + button->backend->paddingx = atoi(value3); + } else if (strcmp(key, "button_max_icon_size") == 0) { + Button *button = get_or_create_last_button(); + extract_values(value, &value1, &value2, &value3); + button->backend->max_icon_size = MAX(0, atoi(value)); + } else if (strcmp(key, "button_background_id") == 0) { + Button *button = get_or_create_last_button(); + int id = atoi(value); + id = (id < backgrounds->len && id >= 0) ? id : 0; + button->backend->bg = &g_array_index(backgrounds, Background, id); + } else if (strcmp(key, "button_centered") == 0) { + Button *button = get_or_create_last_button(); + button->backend->centered = atoi(value); + } else if (strcmp(key, "button_lclick_command") == 0) { + Button *button = get_or_create_last_button(); + free_and_null(button->backend->lclick_command); + if (strlen(value) > 0) + button->backend->lclick_command = strdup(value); + } else if (strcmp(key, "button_mclick_command") == 0) { + Button *button = get_or_create_last_button(); + free_and_null(button->backend->mclick_command); + if (strlen(value) > 0) + button->backend->mclick_command = strdup(value); + } else if (strcmp(key, "button_rclick_command") == 0) { + Button *button = get_or_create_last_button(); + free_and_null(button->backend->rclick_command); + if (strlen(value) > 0) + button->backend->rclick_command = strdup(value); + } else if (strcmp(key, "button_uwheel_command") == 0) { + Button *button = get_or_create_last_button(); + free_and_null(button->backend->uwheel_command); + if (strlen(value) > 0) + button->backend->uwheel_command = strdup(value); + } else if (strcmp(key, "button_dwheel_command") == 0) { + Button *button = get_or_create_last_button(); + free_and_null(button->backend->dwheel_command); + if (strlen(value) > 0) + button->backend->dwheel_command = strdup(value); + } - /* Clock */ - else if (strcmp(key, "time1_format") == 0) { - 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 { - panel_items_order = strdup("C"); - } - } - if (strlen(value) > 0) { - time1_format = strdup(value); - clock_enabled = TRUE; - } - } else if (strcmp(key, "time2_format") == 0) { - if (strlen(value) > 0) - time2_format = strdup(value); - } else if (strcmp(key, "time1_font") == 0) { - time1_font_desc = pango_font_description_from_string(value); - time1_has_font = TRUE; - } else if (strcmp(key, "time1_timezone") == 0) { - if (strlen(value) > 0) - time1_timezone = strdup(value); - } else if (strcmp(key, "time2_timezone") == 0) { - if (strlen(value) > 0) - time2_timezone = strdup(value); - } else if (strcmp(key, "time2_font") == 0) { - time2_font_desc = pango_font_description_from_string(value); - time2_has_font = TRUE; - } else if (strcmp(key, "clock_font_color") == 0) { - extract_values(value, &value1, &value2, &value3); - get_color(value1, panel_config.clock.font.rgb); - if (value2) - panel_config.clock.font.alpha = (atoi(value2) / 100.0); - else - panel_config.clock.font.alpha = 0.5; - } else if (strcmp(key, "clock_padding") == 0) { - extract_values(value, &value1, &value2, &value3); - panel_config.clock.area.paddingxlr = panel_config.clock.area.paddingx = atoi(value1); - if (value2) - panel_config.clock.area.paddingy = atoi(value2); - if (value3) - panel_config.clock.area.paddingx = atoi(value3); - } else if (strcmp(key, "clock_background_id") == 0) { - int id = atoi(value); - id = (id < backgrounds->len && id >= 0) ? id : 0; - panel_config.clock.area.bg = &g_array_index(backgrounds, Background, id); - } else if (strcmp(key, "clock_tooltip") == 0) { - if (strlen(value) > 0) - time_tooltip_format = strdup(value); - } else if (strcmp(key, "clock_tooltip_timezone") == 0) { - if (strlen(value) > 0) - time_tooltip_timezone = strdup(value); - } else if (strcmp(key, "clock_lclick_command") == 0) { - if (strlen(value) > 0) - clock_lclick_command = strdup(value); - } else if (strcmp(key, "clock_mclick_command") == 0) { - if (strlen(value) > 0) - clock_mclick_command = strdup(value); - } else if (strcmp(key, "clock_rclick_command") == 0) { - if (strlen(value) > 0) - clock_rclick_command = strdup(value); - } else if (strcmp(key, "clock_uwheel_command") == 0) { - if (strlen(value) > 0) - clock_uwheel_command = strdup(value); - } else if (strcmp(key, "clock_dwheel_command") == 0) { - if (strlen(value) > 0) - clock_dwheel_command = strdup(value); - } + /* Clock */ + else if (strcmp(key, "time1_format") == 0) { + 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 { + panel_items_order = strdup("C"); + } + } + if (strlen(value) > 0) { + time1_format = strdup(value); + clock_enabled = TRUE; + } + } else if (strcmp(key, "time2_format") == 0) { + if (strlen(value) > 0) + time2_format = strdup(value); + } else if (strcmp(key, "time1_font") == 0) { + time1_font_desc = pango_font_description_from_string(value); + time1_has_font = TRUE; + } else if (strcmp(key, "time1_timezone") == 0) { + if (strlen(value) > 0) + time1_timezone = strdup(value); + } else if (strcmp(key, "time2_timezone") == 0) { + if (strlen(value) > 0) + time2_timezone = strdup(value); + } else if (strcmp(key, "time2_font") == 0) { + time2_font_desc = pango_font_description_from_string(value); + time2_has_font = TRUE; + } else if (strcmp(key, "clock_font_color") == 0) { + extract_values(value, &value1, &value2, &value3); + get_color(value1, panel_config.clock.font.rgb); + if (value2) + panel_config.clock.font.alpha = (atoi(value2) / 100.0); + else + panel_config.clock.font.alpha = 0.5; + } else if (strcmp(key, "clock_padding") == 0) { + extract_values(value, &value1, &value2, &value3); + panel_config.clock.area.paddingxlr = panel_config.clock.area.paddingx = atoi(value1); + if (value2) + panel_config.clock.area.paddingy = atoi(value2); + if (value3) + panel_config.clock.area.paddingx = atoi(value3); + } else if (strcmp(key, "clock_background_id") == 0) { + int id = atoi(value); + id = (id < backgrounds->len && id >= 0) ? id : 0; + panel_config.clock.area.bg = &g_array_index(backgrounds, Background, id); + } else if (strcmp(key, "clock_tooltip") == 0) { + if (strlen(value) > 0) + time_tooltip_format = strdup(value); + } else if (strcmp(key, "clock_tooltip_timezone") == 0) { + if (strlen(value) > 0) + time_tooltip_timezone = strdup(value); + } else if (strcmp(key, "clock_lclick_command") == 0) { + if (strlen(value) > 0) + clock_lclick_command = strdup(value); + } else if (strcmp(key, "clock_mclick_command") == 0) { + if (strlen(value) > 0) + clock_mclick_command = strdup(value); + } else if (strcmp(key, "clock_rclick_command") == 0) { + if (strlen(value) > 0) + clock_rclick_command = strdup(value); + } else if (strcmp(key, "clock_uwheel_command") == 0) { + if (strlen(value) > 0) + clock_uwheel_command = strdup(value); + } else if (strcmp(key, "clock_dwheel_command") == 0) { + if (strlen(value) > 0) + clock_dwheel_command = strdup(value); + } - /* Taskbar */ - else if (strcmp(key, "taskbar_mode") == 0) { - if (strcmp(value, "multi_desktop") == 0) - taskbar_mode = MULTI_DESKTOP; - else - taskbar_mode = SINGLE_DESKTOP; - } else if (strcmp(key, "taskbar_distribute_size") == 0) { - taskbar_distribute_size = atoi(value); - } else if (strcmp(key, "taskbar_padding") == 0) { - extract_values(value, &value1, &value2, &value3); - panel_config.g_taskbar.area.paddingxlr = panel_config.g_taskbar.area.paddingx = atoi(value1); - if (value2) - panel_config.g_taskbar.area.paddingy = atoi(value2); - if (value3) - panel_config.g_taskbar.area.paddingx = atoi(value3); - } else if (strcmp(key, "taskbar_background_id") == 0) { - int id = atoi(value); - id = (id < backgrounds->len && id >= 0) ? id : 0; - panel_config.g_taskbar.background[TASKBAR_NORMAL] = &g_array_index(backgrounds, Background, id); - if (panel_config.g_taskbar.background[TASKBAR_ACTIVE] == 0) - panel_config.g_taskbar.background[TASKBAR_ACTIVE] = panel_config.g_taskbar.background[TASKBAR_NORMAL]; - } else if (strcmp(key, "taskbar_active_background_id") == 0) { - int id = atoi(value); - id = (id < backgrounds->len && id >= 0) ? id : 0; - panel_config.g_taskbar.background[TASKBAR_ACTIVE] = &g_array_index(backgrounds, Background, id); - } else if (strcmp(key, "taskbar_name") == 0) { - taskbarname_enabled = atoi(value); - } else if (strcmp(key, "taskbar_name_padding") == 0) { - extract_values(value, &value1, &value2, &value3); - panel_config.g_taskbar.area_name.paddingxlr = panel_config.g_taskbar.area_name.paddingx = atoi(value1); - if (value2) - panel_config.g_taskbar.area_name.paddingy = atoi(value2); - } else if (strcmp(key, "taskbar_name_background_id") == 0) { - int id = atoi(value); - id = (id < backgrounds->len && id >= 0) ? id : 0; - panel_config.g_taskbar.background_name[TASKBAR_NORMAL] = &g_array_index(backgrounds, Background, id); - if (panel_config.g_taskbar.background_name[TASKBAR_ACTIVE] == 0) - panel_config.g_taskbar.background_name[TASKBAR_ACTIVE] = - panel_config.g_taskbar.background_name[TASKBAR_NORMAL]; - } else if (strcmp(key, "taskbar_name_active_background_id") == 0) { - int id = atoi(value); - id = (id < backgrounds->len && id >= 0) ? id : 0; - panel_config.g_taskbar.background_name[TASKBAR_ACTIVE] = &g_array_index(backgrounds, Background, id); - } else if (strcmp(key, "taskbar_name_font") == 0) { - panel_config.taskbarname_font_desc = pango_font_description_from_string(value); - panel_config.taskbarname_has_font = TRUE; - } else if (strcmp(key, "taskbar_name_font_color") == 0) { - extract_values(value, &value1, &value2, &value3); - get_color(value1, taskbarname_font.rgb); - if (value2) - taskbarname_font.alpha = (atoi(value2) / 100.0); - else - taskbarname_font.alpha = 0.5; - } else if (strcmp(key, "taskbar_name_active_font_color") == 0) { - extract_values(value, &value1, &value2, &value3); - get_color(value1, taskbarname_active_font.rgb); - if (value2) - taskbarname_active_font.alpha = (atoi(value2) / 100.0); - else - taskbarname_active_font.alpha = 0.5; - } else if (strcmp(key, "taskbar_hide_inactive_tasks") == 0) { - hide_inactive_tasks = atoi(value); - } else if (strcmp(key, "taskbar_hide_different_monitor") == 0) { - hide_task_diff_monitor = atoi(value); - } else if (strcmp(key, "taskbar_hide_if_empty") == 0) { - hide_taskbar_if_empty = atoi(value); - } else if (strcmp(key, "taskbar_always_show_all_desktop_tasks") == 0) { - always_show_all_desktop_tasks = atoi(value); - } else if (strcmp(key, "taskbar_sort_order") == 0) { - if (strcmp(value, "center") == 0) { - taskbar_sort_method = TASKBAR_SORT_CENTER; - } else if (strcmp(value, "title") == 0) { - taskbar_sort_method = TASKBAR_SORT_TITLE; - } else if (strcmp(value, "lru") == 0) { - taskbar_sort_method = TASKBAR_SORT_LRU; - } else if (strcmp(value, "mru") == 0) { - taskbar_sort_method = TASKBAR_SORT_MRU; - } else { - taskbar_sort_method = TASKBAR_NOSORT; - } - } else if (strcmp(key, "task_align") == 0) { - if (strcmp(value, "center") == 0) { - taskbar_alignment = ALIGN_CENTER; - } else if (strcmp(value, "right") == 0) { - taskbar_alignment = ALIGN_RIGHT; - } else { - taskbar_alignment = ALIGN_LEFT; - } - } + /* Taskbar */ + else if (strcmp(key, "taskbar_mode") == 0) { + if (strcmp(value, "multi_desktop") == 0) + taskbar_mode = MULTI_DESKTOP; + else + taskbar_mode = SINGLE_DESKTOP; + } else if (strcmp(key, "taskbar_distribute_size") == 0) { + taskbar_distribute_size = atoi(value); + } else if (strcmp(key, "taskbar_padding") == 0) { + extract_values(value, &value1, &value2, &value3); + panel_config.g_taskbar.area.paddingxlr = panel_config.g_taskbar.area.paddingx = atoi(value1); + if (value2) + panel_config.g_taskbar.area.paddingy = atoi(value2); + if (value3) + panel_config.g_taskbar.area.paddingx = atoi(value3); + } else if (strcmp(key, "taskbar_background_id") == 0) { + int id = atoi(value); + id = (id < backgrounds->len && id >= 0) ? id : 0; + panel_config.g_taskbar.background[TASKBAR_NORMAL] = &g_array_index(backgrounds, Background, id); + if (panel_config.g_taskbar.background[TASKBAR_ACTIVE] == 0) + panel_config.g_taskbar.background[TASKBAR_ACTIVE] = panel_config.g_taskbar.background[TASKBAR_NORMAL]; + } else if (strcmp(key, "taskbar_active_background_id") == 0) { + int id = atoi(value); + id = (id < backgrounds->len && id >= 0) ? id : 0; + panel_config.g_taskbar.background[TASKBAR_ACTIVE] = &g_array_index(backgrounds, Background, id); + } else if (strcmp(key, "taskbar_name") == 0) { + taskbarname_enabled = atoi(value); + } else if (strcmp(key, "taskbar_name_padding") == 0) { + extract_values(value, &value1, &value2, &value3); + panel_config.g_taskbar.area_name.paddingxlr = panel_config.g_taskbar.area_name.paddingx = atoi(value1); + if (value2) + panel_config.g_taskbar.area_name.paddingy = atoi(value2); + } else if (strcmp(key, "taskbar_name_background_id") == 0) { + int id = atoi(value); + id = (id < backgrounds->len && id >= 0) ? id : 0; + panel_config.g_taskbar.background_name[TASKBAR_NORMAL] = &g_array_index(backgrounds, Background, id); + if (panel_config.g_taskbar.background_name[TASKBAR_ACTIVE] == 0) + panel_config.g_taskbar.background_name[TASKBAR_ACTIVE] = + panel_config.g_taskbar.background_name[TASKBAR_NORMAL]; + } else if (strcmp(key, "taskbar_name_active_background_id") == 0) { + int id = atoi(value); + id = (id < backgrounds->len && id >= 0) ? id : 0; + panel_config.g_taskbar.background_name[TASKBAR_ACTIVE] = &g_array_index(backgrounds, Background, id); + } else if (strcmp(key, "taskbar_name_font") == 0) { + panel_config.taskbarname_font_desc = pango_font_description_from_string(value); + panel_config.taskbarname_has_font = TRUE; + } else if (strcmp(key, "taskbar_name_font_color") == 0) { + extract_values(value, &value1, &value2, &value3); + get_color(value1, taskbarname_font.rgb); + if (value2) + taskbarname_font.alpha = (atoi(value2) / 100.0); + else + taskbarname_font.alpha = 0.5; + } else if (strcmp(key, "taskbar_name_active_font_color") == 0) { + extract_values(value, &value1, &value2, &value3); + get_color(value1, taskbarname_active_font.rgb); + if (value2) + taskbarname_active_font.alpha = (atoi(value2) / 100.0); + else + taskbarname_active_font.alpha = 0.5; + } else if (strcmp(key, "taskbar_hide_inactive_tasks") == 0) { + hide_inactive_tasks = atoi(value); + } else if (strcmp(key, "taskbar_hide_different_monitor") == 0) { + hide_task_diff_monitor = atoi(value); + } else if (strcmp(key, "taskbar_hide_if_empty") == 0) { + hide_taskbar_if_empty = atoi(value); + } else if (strcmp(key, "taskbar_always_show_all_desktop_tasks") == 0) { + always_show_all_desktop_tasks = atoi(value); + } else if (strcmp(key, "taskbar_sort_order") == 0) { + if (strcmp(value, "center") == 0) { + taskbar_sort_method = TASKBAR_SORT_CENTER; + } else if (strcmp(value, "title") == 0) { + taskbar_sort_method = TASKBAR_SORT_TITLE; + } else if (strcmp(value, "lru") == 0) { + taskbar_sort_method = TASKBAR_SORT_LRU; + } else if (strcmp(value, "mru") == 0) { + taskbar_sort_method = TASKBAR_SORT_MRU; + } else { + taskbar_sort_method = TASKBAR_NOSORT; + } + } else if (strcmp(key, "task_align") == 0) { + if (strcmp(value, "center") == 0) { + taskbar_alignment = ALIGN_CENTER; + } else if (strcmp(value, "right") == 0) { + taskbar_alignment = ALIGN_RIGHT; + } else { + taskbar_alignment = ALIGN_LEFT; + } + } - /* Task */ - else if (strcmp(key, "task_text") == 0) - panel_config.g_task.has_text = atoi(value); - else if (strcmp(key, "task_icon") == 0) - panel_config.g_task.has_icon = atoi(value); - else if (strcmp(key, "task_centered") == 0) - panel_config.g_task.centered = atoi(value); - else if (strcmp(key, "task_width") == 0) { - // old parameter : just for backward compatibility - panel_config.g_task.maximum_width = atoi(value); - panel_config.g_task.maximum_height = 30; - } else if (strcmp(key, "task_maximum_size") == 0) { - extract_values(value, &value1, &value2, &value3); - panel_config.g_task.maximum_width = atoi(value1); - if (value2) - panel_config.g_task.maximum_height = atoi(value2); - else - panel_config.g_task.maximum_height = panel_config.g_task.maximum_width; - } else if (strcmp(key, "task_padding") == 0) { - extract_values(value, &value1, &value2, &value3); - panel_config.g_task.area.paddingxlr = panel_config.g_task.area.paddingx = atoi(value1); - if (value2) - panel_config.g_task.area.paddingy = atoi(value2); - if (value3) - panel_config.g_task.area.paddingx = atoi(value3); - } else if (strcmp(key, "task_font") == 0) { - panel_config.g_task.font_desc = pango_font_description_from_string(value); - panel_config.g_task.has_font = TRUE; - } else if (g_regex_match_simple("task.*_font_color", key, 0, 0)) { - gchar **split = g_regex_split_simple("_", key, 0, 0); - int status = g_strv_length(split) == 3 ? TASK_NORMAL : get_task_status(split[1]); - g_strfreev(split); - if (status >= 0) { - extract_values(value, &value1, &value2, &value3); - float alpha = 1; - if (value2) - alpha = (atoi(value2) / 100.0); - get_color(value1, panel_config.g_task.font[status].rgb); - panel_config.g_task.font[status].alpha = alpha; - panel_config.g_task.config_font_mask |= (1 << status); - } - } else if (g_regex_match_simple("task.*_icon_asb", key, 0, 0)) { - gchar **split = g_regex_split_simple("_", key, 0, 0); - int status = g_strv_length(split) == 3 ? TASK_NORMAL : get_task_status(split[1]); - g_strfreev(split); - if (status >= 0) { - extract_values(value, &value1, &value2, &value3); - panel_config.g_task.alpha[status] = atoi(value1); - panel_config.g_task.saturation[status] = atoi(value2); - panel_config.g_task.brightness[status] = atoi(value3); - panel_config.g_task.config_asb_mask |= (1 << status); - } - } else if (g_regex_match_simple("task.*_background_id", key, 0, 0)) { - gchar **split = g_regex_split_simple("_", key, 0, 0); - int status = g_strv_length(split) == 3 ? TASK_NORMAL : get_task_status(split[1]); - g_strfreev(split); - if (status >= 0) { - int id = atoi(value); - id = (id < backgrounds->len && id >= 0) ? id : 0; - panel_config.g_task.background[status] = &g_array_index(backgrounds, Background, id); - panel_config.g_task.config_background_mask |= (1 << status); - if (status == TASK_NORMAL) - panel_config.g_task.area.bg = panel_config.g_task.background[TASK_NORMAL]; - } - } - // "tooltip" is deprecated but here for backwards compatibility - else if (strcmp(key, "task_tooltip") == 0 || strcmp(key, "tooltip") == 0) - panel_config.g_task.tooltip_enabled = atoi(value); + /* Task */ + else if (strcmp(key, "task_text") == 0) + panel_config.g_task.has_text = atoi(value); + else if (strcmp(key, "task_icon") == 0) + panel_config.g_task.has_icon = atoi(value); + else if (strcmp(key, "task_centered") == 0) + panel_config.g_task.centered = atoi(value); + else if (strcmp(key, "task_width") == 0) { + // old parameter : just for backward compatibility + panel_config.g_task.maximum_width = atoi(value); + panel_config.g_task.maximum_height = 30; + } else if (strcmp(key, "task_maximum_size") == 0) { + extract_values(value, &value1, &value2, &value3); + panel_config.g_task.maximum_width = atoi(value1); + if (value2) + panel_config.g_task.maximum_height = atoi(value2); + else + panel_config.g_task.maximum_height = panel_config.g_task.maximum_width; + } else if (strcmp(key, "task_padding") == 0) { + extract_values(value, &value1, &value2, &value3); + panel_config.g_task.area.paddingxlr = panel_config.g_task.area.paddingx = atoi(value1); + if (value2) + panel_config.g_task.area.paddingy = atoi(value2); + if (value3) + panel_config.g_task.area.paddingx = atoi(value3); + } else if (strcmp(key, "task_font") == 0) { + panel_config.g_task.font_desc = pango_font_description_from_string(value); + panel_config.g_task.has_font = TRUE; + } else if (g_regex_match_simple("task.*_font_color", key, 0, 0)) { + gchar **split = g_regex_split_simple("_", key, 0, 0); + int status = g_strv_length(split) == 3 ? TASK_NORMAL : get_task_status(split[1]); + g_strfreev(split); + if (status >= 0) { + extract_values(value, &value1, &value2, &value3); + float alpha = 1; + if (value2) + alpha = (atoi(value2) / 100.0); + get_color(value1, panel_config.g_task.font[status].rgb); + panel_config.g_task.font[status].alpha = alpha; + panel_config.g_task.config_font_mask |= (1 << status); + } + } else if (g_regex_match_simple("task.*_icon_asb", key, 0, 0)) { + gchar **split = g_regex_split_simple("_", key, 0, 0); + int status = g_strv_length(split) == 3 ? TASK_NORMAL : get_task_status(split[1]); + g_strfreev(split); + if (status >= 0) { + extract_values(value, &value1, &value2, &value3); + panel_config.g_task.alpha[status] = atoi(value1); + panel_config.g_task.saturation[status] = atoi(value2); + panel_config.g_task.brightness[status] = atoi(value3); + panel_config.g_task.config_asb_mask |= (1 << status); + } + } else if (g_regex_match_simple("task.*_background_id", key, 0, 0)) { + gchar **split = g_regex_split_simple("_", key, 0, 0); + int status = g_strv_length(split) == 3 ? TASK_NORMAL : get_task_status(split[1]); + g_strfreev(split); + if (status >= 0) { + int id = atoi(value); + id = (id < backgrounds->len && id >= 0) ? id : 0; + panel_config.g_task.background[status] = &g_array_index(backgrounds, Background, id); + panel_config.g_task.config_background_mask |= (1 << status); + if (status == TASK_NORMAL) + panel_config.g_task.area.bg = panel_config.g_task.background[TASK_NORMAL]; + } + } + // "tooltip" is deprecated but here for backwards compatibility + else if (strcmp(key, "task_tooltip") == 0 || strcmp(key, "tooltip") == 0) + panel_config.g_task.tooltip_enabled = atoi(value); - /* Systray */ - else if (strcmp(key, "systray_padding") == 0) { - 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); - panel_items_order = strdup(tmp); - g_free(tmp); - } else - panel_items_order = strdup("S"); - } - extract_values(value, &value1, &value2, &value3); - systray.area.paddingxlr = systray.area.paddingx = atoi(value1); - if (value2) - systray.area.paddingy = atoi(value2); - if (value3) - systray.area.paddingx = atoi(value3); - } else if (strcmp(key, "systray_background_id") == 0) { - int id = atoi(value); - id = (id < backgrounds->len && id >= 0) ? id : 0; - systray.area.bg = &g_array_index(backgrounds, Background, id); - } else if (strcmp(key, "systray_sort") == 0) { - if (strcmp(value, "descending") == 0) - systray.sort = SYSTRAY_SORT_DESCENDING; - else if (strcmp(value, "ascending") == 0) - systray.sort = SYSTRAY_SORT_ASCENDING; - else if (strcmp(value, "left2right") == 0) - systray.sort = SYSTRAY_SORT_LEFT2RIGHT; - else if (strcmp(value, "right2left") == 0) - systray.sort = SYSTRAY_SORT_RIGHT2LEFT; - } else if (strcmp(key, "systray_icon_size") == 0) { - systray_max_icon_size = atoi(value); - } else if (strcmp(key, "systray_icon_asb") == 0) { - extract_values(value, &value1, &value2, &value3); - systray.alpha = atoi(value1); - systray.saturation = atoi(value2); - systray.brightness = atoi(value3); - } else if (strcmp(key, "systray_monitor") == 0) { - systray_monitor = atoi(value) - 1; - } else if (strcmp(key, "systray_name_filter") == 0) { - if (systray_hide_name_filter) - free(systray_hide_name_filter); - systray_hide_name_filter = strdup(value); - } + /* Systray */ + else if (strcmp(key, "systray_padding") == 0) { + 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); + panel_items_order = strdup(tmp); + g_free(tmp); + } else + panel_items_order = strdup("S"); + } + extract_values(value, &value1, &value2, &value3); + systray.area.paddingxlr = systray.area.paddingx = atoi(value1); + if (value2) + systray.area.paddingy = atoi(value2); + if (value3) + systray.area.paddingx = atoi(value3); + } else if (strcmp(key, "systray_background_id") == 0) { + int id = atoi(value); + id = (id < backgrounds->len && id >= 0) ? id : 0; + systray.area.bg = &g_array_index(backgrounds, Background, id); + } else if (strcmp(key, "systray_sort") == 0) { + if (strcmp(value, "descending") == 0) + systray.sort = SYSTRAY_SORT_DESCENDING; + else if (strcmp(value, "ascending") == 0) + systray.sort = SYSTRAY_SORT_ASCENDING; + else if (strcmp(value, "left2right") == 0) + systray.sort = SYSTRAY_SORT_LEFT2RIGHT; + else if (strcmp(value, "right2left") == 0) + systray.sort = SYSTRAY_SORT_RIGHT2LEFT; + } else if (strcmp(key, "systray_icon_size") == 0) { + systray_max_icon_size = atoi(value); + } else if (strcmp(key, "systray_icon_asb") == 0) { + extract_values(value, &value1, &value2, &value3); + systray.alpha = atoi(value1); + systray.saturation = atoi(value2); + systray.brightness = atoi(value3); + } else if (strcmp(key, "systray_monitor") == 0) { + systray_monitor = atoi(value) - 1; + } else if (strcmp(key, "systray_name_filter") == 0) { + if (systray_hide_name_filter) + free(systray_hide_name_filter); + systray_hide_name_filter = strdup(value); + } - /* Launcher */ - 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_background_id") == 0) { - int id = atoi(value); - id = (id < backgrounds->len && id >= 0) ? id : 0; - launcher_icon_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_app") == 0) { - char *app = expand_tilde(value); - panel_config.launcher.list_apps = g_slist_append(panel_config.launcher.list_apps, app); - } else if (strcmp(key, "launcher_apps_dir") == 0) { - char *path = expand_tilde(value); - load_launcher_app_dir(path); - free(path); - } else if (strcmp(key, "launcher_icon_theme") == 0) { - // if XSETTINGS manager running, tint2 use it. - if (icon_theme_name_config) - free(icon_theme_name_config); - icon_theme_name_config = strdup(value); - } else if (strcmp(key, "launcher_icon_theme_override") == 0) { - launcher_icon_theme_override = atoi(value); - } else if (strcmp(key, "launcher_icon_asb") == 0) { - extract_values(value, &value1, &value2, &value3); - launcher_alpha = atoi(value1); - launcher_saturation = atoi(value2); - launcher_brightness = atoi(value3); - } else if (strcmp(key, "launcher_tooltip") == 0) { - launcher_tooltip_enabled = atoi(value); - } else if (strcmp(key, "startup_notifications") == 0) { - startup_notifications = atoi(value); - } + /* Launcher */ + 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_background_id") == 0) { + int id = atoi(value); + id = (id < backgrounds->len && id >= 0) ? id : 0; + launcher_icon_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_app") == 0) { + char *app = expand_tilde(value); + panel_config.launcher.list_apps = g_slist_append(panel_config.launcher.list_apps, app); + } else if (strcmp(key, "launcher_apps_dir") == 0) { + char *path = expand_tilde(value); + load_launcher_app_dir(path); + free(path); + } else if (strcmp(key, "launcher_icon_theme") == 0) { + // if XSETTINGS manager running, tint2 use it. + if (icon_theme_name_config) + free(icon_theme_name_config); + icon_theme_name_config = strdup(value); + } else if (strcmp(key, "launcher_icon_theme_override") == 0) { + launcher_icon_theme_override = atoi(value); + } else if (strcmp(key, "launcher_icon_asb") == 0) { + extract_values(value, &value1, &value2, &value3); + launcher_alpha = atoi(value1); + launcher_saturation = atoi(value2); + launcher_brightness = atoi(value3); + } else if (strcmp(key, "launcher_tooltip") == 0) { + launcher_tooltip_enabled = atoi(value); + } else if (strcmp(key, "startup_notifications") == 0) { + startup_notifications = atoi(value); + } - /* Tooltip */ - else if (strcmp(key, "tooltip_show_timeout") == 0) { - int timeout_msec = 1000 * atof(value); - g_tooltip.show_timeout_msec = timeout_msec; - } else if (strcmp(key, "tooltip_hide_timeout") == 0) { - int timeout_msec = 1000 * atof(value); - g_tooltip.hide_timeout_msec = timeout_msec; - } else if (strcmp(key, "tooltip_padding") == 0) { - extract_values(value, &value1, &value2, &value3); - if (value1) - g_tooltip.paddingx = atoi(value1); - if (value2) - g_tooltip.paddingy = atoi(value2); - } else if (strcmp(key, "tooltip_background_id") == 0) { - int id = atoi(value); - id = (id < backgrounds->len && id >= 0) ? id : 0; - g_tooltip.bg = &g_array_index(backgrounds, Background, id); - } else if (strcmp(key, "tooltip_font_color") == 0) { - extract_values(value, &value1, &value2, &value3); - get_color(value1, g_tooltip.font_color.rgb); - if (value2) - g_tooltip.font_color.alpha = (atoi(value2) / 100.0); - else - g_tooltip.font_color.alpha = 0.1; - } else if (strcmp(key, "tooltip_font") == 0) { - g_tooltip.font_desc = pango_font_description_from_string(value); - } + /* Tooltip */ + else if (strcmp(key, "tooltip_show_timeout") == 0) { + int timeout_msec = 1000 * atof(value); + g_tooltip.show_timeout_msec = timeout_msec; + } else if (strcmp(key, "tooltip_hide_timeout") == 0) { + int timeout_msec = 1000 * atof(value); + g_tooltip.hide_timeout_msec = timeout_msec; + } else if (strcmp(key, "tooltip_padding") == 0) { + extract_values(value, &value1, &value2, &value3); + if (value1) + g_tooltip.paddingx = atoi(value1); + if (value2) + g_tooltip.paddingy = atoi(value2); + } else if (strcmp(key, "tooltip_background_id") == 0) { + int id = atoi(value); + id = (id < backgrounds->len && id >= 0) ? id : 0; + g_tooltip.bg = &g_array_index(backgrounds, Background, id); + } else if (strcmp(key, "tooltip_font_color") == 0) { + extract_values(value, &value1, &value2, &value3); + get_color(value1, g_tooltip.font_color.rgb); + if (value2) + g_tooltip.font_color.alpha = (atoi(value2) / 100.0); + else + g_tooltip.font_color.alpha = 0.1; + } else if (strcmp(key, "tooltip_font") == 0) { + g_tooltip.font_desc = pango_font_description_from_string(value); + } - /* Mouse actions */ - else if (strcmp(key, "mouse_left") == 0) - get_action(value, &mouse_left); - else if (strcmp(key, "mouse_middle") == 0) - get_action(value, &mouse_middle); - else if (strcmp(key, "mouse_right") == 0) - get_action(value, &mouse_right); - else if (strcmp(key, "mouse_scroll_up") == 0) - get_action(value, &mouse_scroll_up); - else if (strcmp(key, "mouse_scroll_down") == 0) - get_action(value, &mouse_scroll_down); - else if (strcmp(key, "mouse_effects") == 0) - panel_config.mouse_effects = atoi(value); - else if (strcmp(key, "mouse_hover_icon_asb") == 0) { - extract_values(value, &value1, &value2, &value3); - panel_config.mouse_over_alpha = atoi(value1); - panel_config.mouse_over_saturation = atoi(value2); - panel_config.mouse_over_brightness = atoi(value3); - } else if (strcmp(key, "mouse_pressed_icon_asb") == 0) { - extract_values(value, &value1, &value2, &value3); - panel_config.mouse_pressed_alpha = atoi(value1); - panel_config.mouse_pressed_saturation = atoi(value2); - panel_config.mouse_pressed_brightness = atoi(value3); - } + /* Mouse actions */ + else if (strcmp(key, "mouse_left") == 0) + get_action(value, &mouse_left); + else if (strcmp(key, "mouse_middle") == 0) + get_action(value, &mouse_middle); + else if (strcmp(key, "mouse_right") == 0) + get_action(value, &mouse_right); + else if (strcmp(key, "mouse_scroll_up") == 0) + get_action(value, &mouse_scroll_up); + else if (strcmp(key, "mouse_scroll_down") == 0) + get_action(value, &mouse_scroll_down); + else if (strcmp(key, "mouse_effects") == 0) + panel_config.mouse_effects = atoi(value); + else if (strcmp(key, "mouse_hover_icon_asb") == 0) { + extract_values(value, &value1, &value2, &value3); + panel_config.mouse_over_alpha = atoi(value1); + panel_config.mouse_over_saturation = atoi(value2); + panel_config.mouse_over_brightness = atoi(value3); + } else if (strcmp(key, "mouse_pressed_icon_asb") == 0) { + extract_values(value, &value1, &value2, &value3); + panel_config.mouse_pressed_alpha = atoi(value1); + panel_config.mouse_pressed_saturation = atoi(value2); + panel_config.mouse_pressed_brightness = atoi(value3); + } - /* autohide options */ - else if (strcmp(key, "autohide") == 0) - panel_autohide = atoi(value); - else if (strcmp(key, "autohide_show_timeout") == 0) - panel_autohide_show_timeout = 1000 * atof(value); - else if (strcmp(key, "autohide_hide_timeout") == 0) - panel_autohide_hide_timeout = 1000 * atof(value); - else if (strcmp(key, "strut_policy") == 0) { - if (strcmp(value, "follow_size") == 0) - panel_strut_policy = STRUT_FOLLOW_SIZE; - else if (strcmp(value, "none") == 0) - panel_strut_policy = STRUT_NONE; - else - panel_strut_policy = STRUT_MINIMUM; - } else if (strcmp(key, "autohide_height") == 0) { - panel_autohide_height = atoi(value); - if (panel_autohide_height == 0) { - // autohide need height > 0 - panel_autohide_height = 1; - } - } + /* autohide options */ + else if (strcmp(key, "autohide") == 0) + panel_autohide = atoi(value); + else if (strcmp(key, "autohide_show_timeout") == 0) + panel_autohide_show_timeout = 1000 * atof(value); + else if (strcmp(key, "autohide_hide_timeout") == 0) + panel_autohide_hide_timeout = 1000 * atof(value); + else if (strcmp(key, "strut_policy") == 0) { + if (strcmp(value, "follow_size") == 0) + panel_strut_policy = STRUT_FOLLOW_SIZE; + else if (strcmp(value, "none") == 0) + panel_strut_policy = STRUT_NONE; + else + panel_strut_policy = STRUT_MINIMUM; + } else if (strcmp(key, "autohide_height") == 0) { + panel_autohide_height = atoi(value); + if (panel_autohide_height == 0) { + // autohide need height > 0 + panel_autohide_height = 1; + } + } - // old config option - else if (strcmp(key, "systray") == 0) { - if (!new_config_file) { - systray_enabled = atoi(value); - if (systray_enabled) { - if (panel_items_order) { - gchar *tmp = g_strconcat(panel_items_order, "S", NULL); - free(panel_items_order); - panel_items_order = strdup(tmp); - g_free(tmp); - } else - panel_items_order = strdup("S"); - } - } - } + // old config option + else if (strcmp(key, "systray") == 0) { + if (!new_config_file) { + systray_enabled = atoi(value); + if (systray_enabled) { + if (panel_items_order) { + gchar *tmp = g_strconcat(panel_items_order, "S", NULL); + free(panel_items_order); + panel_items_order = strdup(tmp); + g_free(tmp); + } else + panel_items_order = strdup("S"); + } + } + } #ifdef ENABLE_BATTERY - else if (strcmp(key, "battery") == 0) { - if (!new_config_file) { - battery_enabled = atoi(value); - if (battery_enabled) { - if (panel_items_order) { - gchar *tmp = g_strconcat(panel_items_order, "B", NULL); - free(panel_items_order); - panel_items_order = strdup(tmp); - g_free(tmp); - } else - panel_items_order = strdup("B"); - } - } - } + else if (strcmp(key, "battery") == 0) { + if (!new_config_file) { + battery_enabled = atoi(value); + if (battery_enabled) { + if (panel_items_order) { + gchar *tmp = g_strconcat(panel_items_order, "B", NULL); + free(panel_items_order); + panel_items_order = strdup(tmp); + g_free(tmp); + } else + panel_items_order = strdup("B"); + } + } + } #endif - else - fprintf(stderr, "tint2 : invalid option \"%s\",\n upgrade tint2 or correct your config file\n", key); + else + fprintf(stderr, "tint2 : invalid option \"%s\",\n upgrade tint2 or correct your config file\n", key); - if (value1) - free(value1); - if (value2) - free(value2); - if (value3) - free(value3); + if (value1) + free(value1); + if (value2) + free(value2); + if (value3) + free(value3); } gboolean config_read_file(const char *path) { - FILE *fp = fopen(path, "r"); - if (!fp) - return FALSE; + FILE *fp = fopen(path, "r"); + if (!fp) + return FALSE; - char* line = NULL; - size_t line_size = 0; - while (getline(&line, &line_size, fp) >= 0) { - char *key, *value; - if (parse_line(line, &key, &value)) { - add_entry(key, value); - free(key); - free(value); - } - } - free(line); - fclose(fp); + char *line = NULL; + size_t line_size = 0; + while (getline(&line, &line_size, fp) >= 0) { + char *key, *value; + if (parse_line(line, &key, &value)) { + add_entry(key, value); + free(key); + free(value); + } + } + free(line); + fclose(fp); - if (!read_panel_position) { - panel_horizontal = TRUE; - panel_position = BOTTOM; - } + if (!read_panel_position) { + panel_horizontal = TRUE; + panel_position = BOTTOM; + } - // append Taskbar item - 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 { - panel_items_order = strdup("T"); - } - } + // append Taskbar item + 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 { + panel_items_order = strdup("T"); + } + } - if (backgrounds->len > 0) { - Background *bg = &g_array_index(backgrounds, Background, backgrounds->len - 1); - if (!read_bg_color_hover) - memcpy(&bg->fill_color_hover, &bg->fill_color, sizeof(Color)); - if (!read_border_color_hover) - memcpy(&bg->border_color_hover, &bg->border, sizeof(Color)); - if (!read_bg_color_press) - memcpy(&bg->fill_color_pressed, &bg->fill_color_hover, sizeof(Color)); - if (!read_border_color_press) - memcpy(&bg->border_color_pressed, &bg->border_color_hover, sizeof(Color)); - } + if (backgrounds->len > 0) { + Background *bg = &g_array_index(backgrounds, Background, backgrounds->len - 1); + if (!read_bg_color_hover) + memcpy(&bg->fill_color_hover, &bg->fill_color, sizeof(Color)); + if (!read_border_color_hover) + memcpy(&bg->border_color_hover, &bg->border, sizeof(Color)); + if (!read_bg_color_press) + memcpy(&bg->fill_color_pressed, &bg->fill_color_hover, sizeof(Color)); + if (!read_border_color_press) + memcpy(&bg->border_color_pressed, &bg->border_color_hover, sizeof(Color)); + } - return TRUE; + return TRUE; } gboolean config_read_default_path() { - const gchar *const *system_dirs; - gchar *path1; + const gchar *const *system_dirs; + gchar *path1; - // follow XDG specification - // check tint2rc in user directory - path1 = g_build_filename(g_get_user_config_dir(), "tint2", "tint2rc", NULL); - if (g_file_test(path1, G_FILE_TEST_EXISTS)) { - gboolean result = config_read_file(path1); - config_path = strdup(path1); - g_free(path1); - return result; - } - g_free(path1); + // follow XDG specification + // check tint2rc in user directory + path1 = g_build_filename(g_get_user_config_dir(), "tint2", "tint2rc", NULL); + if (g_file_test(path1, G_FILE_TEST_EXISTS)) { + gboolean result = config_read_file(path1); + config_path = strdup(path1); + g_free(path1); + return result; + } + g_free(path1); - // copy tint2rc from system directory to user directory + // copy tint2rc from system directory to user directory - fprintf(stderr, "tint2 warning: could not find a config file! Creating a default one.\n"); - // According to the XDG Base Directory Specification (https://specifications.freedesktop.org/basedir-spec/basedir-spec-0.6.html) - // if the user's config directory does not exist, we should create it with permissions set to 0700. - if (!g_file_test(g_get_user_config_dir(), G_FILE_TEST_IS_DIR)) - g_mkdir(g_get_user_config_dir(), 0700); + fprintf(stderr, "tint2 warning: could not find a config file! Creating a default one.\n"); + // According to the XDG Base Directory Specification + // (https://specifications.freedesktop.org/basedir-spec/basedir-spec-0.6.html) + // if the user's config directory does not exist, we should create it with permissions set to 0700. + if (!g_file_test(g_get_user_config_dir(), G_FILE_TEST_IS_DIR)) + g_mkdir(g_get_user_config_dir(), 0700); - gchar *path2 = 0; - system_dirs = g_get_system_config_dirs(); - for (int i = 0; system_dirs[i]; i++) { - path2 = g_build_filename(system_dirs[i], "tint2", "tint2rc", NULL); + gchar *path2 = 0; + system_dirs = g_get_system_config_dirs(); + for (int i = 0; system_dirs[i]; i++) { + path2 = g_build_filename(system_dirs[i], "tint2", "tint2rc", NULL); - if (g_file_test(path2, G_FILE_TEST_EXISTS)) - break; - g_free(path2); - path2 = 0; - } + if (g_file_test(path2, G_FILE_TEST_EXISTS)) + break; + g_free(path2); + path2 = 0; + } - if (path2) { - // copy file in user directory (path1) - gchar *dir = g_build_filename(g_get_user_config_dir(), "tint2", NULL); - if (!g_file_test(dir, G_FILE_TEST_IS_DIR)) - g_mkdir(dir, 0700); - g_free(dir); + if (path2) { + // copy file in user directory (path1) + gchar *dir = g_build_filename(g_get_user_config_dir(), "tint2", NULL); + if (!g_file_test(dir, G_FILE_TEST_IS_DIR)) + g_mkdir(dir, 0700); + g_free(dir); - path1 = g_build_filename(g_get_user_config_dir(), "tint2", "tint2rc", NULL); - copy_file(path2, path1); - g_free(path2); + path1 = g_build_filename(g_get_user_config_dir(), "tint2", "tint2rc", NULL); + copy_file(path2, path1); + g_free(path2); - gboolean result = config_read_file(path1); - config_path = strdup(path1); - g_free(path1); - return result; - } + gboolean result = config_read_file(path1); + config_path = strdup(path1); + g_free(path1); + return result; + } - // generate config file - gchar *dir = g_build_filename(g_get_user_config_dir(), "tint2", NULL); - if (!g_file_test(dir, G_FILE_TEST_IS_DIR)) - g_mkdir(dir, 0700); - g_free(dir); + // generate config file + gchar *dir = g_build_filename(g_get_user_config_dir(), "tint2", NULL); + if (!g_file_test(dir, G_FILE_TEST_IS_DIR)) + g_mkdir(dir, 0700); + g_free(dir); - path1 = g_build_filename(g_get_user_config_dir(), "tint2", "tint2rc", NULL); - FILE *f = fopen(path1, "w"); - if (f) { - fwrite(themes_tint2rc, 1, themes_tint2rc_len, f); - fclose(f); - } + path1 = g_build_filename(g_get_user_config_dir(), "tint2", "tint2rc", NULL); + FILE *f = fopen(path1, "w"); + if (f) { + fwrite(themes_tint2rc, 1, themes_tint2rc_len, f); + fclose(f); + } - gboolean result = config_read_file(path1); - config_path = strdup(path1); - g_free(path1); - return result; + gboolean result = config_read_file(path1); + config_path = strdup(path1); + g_free(path1); + return result; } gboolean config_read() { - if (config_path) - return config_read_file(config_path); - return config_read_default_path(); + if (config_path) + return config_read_file(config_path); + return config_read_default_path(); } #endif
M src/execplugin/execplugin.csrc/execplugin/execplugin.c

@@ -30,844 +30,844 @@ }

Execp *create_execp() { - Execp *execp = calloc(1, sizeof(Execp)); - execp->backend = calloc(1, sizeof(ExecpBackend)); - execp->backend->child_pipe = -1; - execp->backend->cmd_pids = g_tree_new(cmp_ptr); - execp->backend->interval = 30; - execp->backend->cache_icon = TRUE; - execp->backend->centered = TRUE; - execp->backend->font_color.alpha = 0.5; - return execp; + Execp *execp = calloc(1, sizeof(Execp)); + execp->backend = calloc(1, sizeof(ExecpBackend)); + execp->backend->child_pipe = -1; + execp->backend->cmd_pids = g_tree_new(cmp_ptr); + execp->backend->interval = 30; + execp->backend->cache_icon = TRUE; + execp->backend->centered = TRUE; + execp->backend->font_color.alpha = 0.5; + return execp; } gpointer create_execp_frontend(gconstpointer arg, gpointer data) { - Execp *execp_backend = (Execp *)arg; + Execp *execp_backend = (Execp *)arg; - Execp *execp_frontend = calloc(1, sizeof(Execp)); - execp_frontend->backend = execp_backend->backend; - execp_backend->backend->instances = g_list_append(execp_backend->backend->instances, execp_frontend); - execp_frontend->frontend = calloc(1, sizeof(ExecpFrontend)); - return execp_frontend; + Execp *execp_frontend = calloc(1, sizeof(Execp)); + execp_frontend->backend = execp_backend->backend; + execp_backend->backend->instances = g_list_append(execp_backend->backend->instances, execp_frontend); + execp_frontend->frontend = calloc(1, sizeof(ExecpFrontend)); + return execp_frontend; } void destroy_execp(void *obj) { - Execp *execp = (Execp *)obj; - if (execp->frontend) { - // This is a frontend element - execp->backend->instances = g_list_remove_all(execp->backend->instances, execp); - free_and_null(execp->frontend); - remove_area(&execp->area); - free_area(&execp->area); - free_and_null(execp); - } else { - // This is a backend element - stop_timeout(execp->backend->timer); - execp->backend->timer = NULL; + Execp *execp = (Execp *)obj; + if (execp->frontend) { + // This is a frontend element + execp->backend->instances = g_list_remove_all(execp->backend->instances, execp); + free_and_null(execp->frontend); + remove_area(&execp->area); + free_area(&execp->area); + free_and_null(execp); + } else { + // This is a backend element + stop_timeout(execp->backend->timer); + execp->backend->timer = NULL; - if (execp->backend->icon) { - imlib_context_set_image(execp->backend->icon); - imlib_free_image(); - execp->backend->icon = NULL; - } - free_and_null(execp->backend->buf_output); - free_and_null(execp->backend->text); - free_and_null(execp->backend->icon_path); - if (execp->backend->child) { - kill(-execp->backend->child, SIGHUP); - execp->backend->child = 0; - } - if (execp->backend->child_pipe >= 0) { - close(execp->backend->child_pipe); - execp->backend->child_pipe = -1; - } - if (execp->backend->cmd_pids) { - g_tree_destroy(execp->backend->cmd_pids); - execp->backend->cmd_pids = NULL; - } + if (execp->backend->icon) { + imlib_context_set_image(execp->backend->icon); + imlib_free_image(); + execp->backend->icon = NULL; + } + free_and_null(execp->backend->buf_output); + free_and_null(execp->backend->text); + free_and_null(execp->backend->icon_path); + if (execp->backend->child) { + kill(-execp->backend->child, SIGHUP); + execp->backend->child = 0; + } + if (execp->backend->child_pipe >= 0) { + close(execp->backend->child_pipe); + execp->backend->child_pipe = -1; + } + if (execp->backend->cmd_pids) { + g_tree_destroy(execp->backend->cmd_pids); + execp->backend->cmd_pids = NULL; + } - execp->backend->bg = NULL; - pango_font_description_free(execp->backend->font_desc); - execp->backend->font_desc = NULL; - free_and_null(execp->backend->command); - free_and_null(execp->backend->tooltip); - free_and_null(execp->backend->lclick_command); - free_and_null(execp->backend->mclick_command); - free_and_null(execp->backend->rclick_command); - free_and_null(execp->backend->dwheel_command); - free_and_null(execp->backend->uwheel_command); + execp->backend->bg = NULL; + pango_font_description_free(execp->backend->font_desc); + execp->backend->font_desc = NULL; + free_and_null(execp->backend->command); + free_and_null(execp->backend->tooltip); + free_and_null(execp->backend->lclick_command); + free_and_null(execp->backend->mclick_command); + free_and_null(execp->backend->rclick_command); + free_and_null(execp->backend->dwheel_command); + free_and_null(execp->backend->uwheel_command); - if (execp->backend->instances) { - fprintf(stderr, "Error: Attempt to destroy backend while there are still frontend instances!\n"); - exit(-1); - } - free(execp->backend); - free(execp); - } + if (execp->backend->instances) { + fprintf(stderr, "Error: Attempt to destroy backend while there are still frontend instances!\n"); + exit(-1); + } + free(execp->backend); + free(execp); + } } void init_execp() { - GList *to_remove = panel_config.execp_list; - for (int k = 0; k < strlen(panel_items_order) && to_remove; k++) { - if (panel_items_order[k] == 'E') { - to_remove = to_remove->next; - } - } + GList *to_remove = panel_config.execp_list; + for (int k = 0; k < strlen(panel_items_order) && to_remove; k++) { + if (panel_items_order[k] == 'E') { + to_remove = to_remove->next; + } + } - if (to_remove) { - if (to_remove == panel_config.execp_list) { - g_list_free_full(to_remove, destroy_execp); - panel_config.execp_list = NULL; - } else { - // Cut panel_config.execp_list - if (to_remove->prev) - to_remove->prev->next = NULL; - to_remove->prev = NULL; - // Remove all elements of to_remove and to_remove itself - g_list_free_full(to_remove, destroy_execp); - } - } + if (to_remove) { + if (to_remove == panel_config.execp_list) { + g_list_free_full(to_remove, destroy_execp); + panel_config.execp_list = NULL; + } else { + // Cut panel_config.execp_list + if (to_remove->prev) + to_remove->prev->next = NULL; + to_remove->prev = NULL; + // Remove all elements of to_remove and to_remove itself + g_list_free_full(to_remove, destroy_execp); + } + } - execp_init_fonts(); - for (GList *l = panel_config.execp_list; l; l = l->next) { - Execp *execp = l->data; + execp_init_fonts(); + for (GList *l = panel_config.execp_list; l; l = l->next) { + Execp *execp = l->data; - // Set missing config options - if (!execp->backend->bg) - execp->backend->bg = &g_array_index(backgrounds, Background, 0); - execp->backend->buf_capacity = 1024; - execp->backend->buf_output = calloc(execp->backend->buf_capacity, 1); - execp->backend->text = strdup(" "); - execp->backend->icon_path = NULL; - } + // Set missing config options + if (!execp->backend->bg) + execp->backend->bg = &g_array_index(backgrounds, Background, 0); + execp->backend->buf_capacity = 1024; + execp->backend->buf_output = calloc(execp->backend->buf_capacity, 1); + execp->backend->text = strdup(" "); + execp->backend->icon_path = NULL; + } } void init_execp_panel(void *p) { - Panel *panel = (Panel *)p; + Panel *panel = (Panel *)p; - // Make sure this is only done once if there are multiple items - if (panel->execp_list && ((Execp *)panel->execp_list->data)->frontend) - return; + // Make sure this is only done once if there are multiple items + if (panel->execp_list && ((Execp *)panel->execp_list->data)->frontend) + return; - // panel->execp_list is now a copy of the pointer panel_config.execp_list - // We make it a deep copy - panel->execp_list = g_list_copy_deep(panel_config.execp_list, create_execp_frontend, NULL); + // panel->execp_list is now a copy of the pointer panel_config.execp_list + // We make it a deep copy + panel->execp_list = g_list_copy_deep(panel_config.execp_list, create_execp_frontend, NULL); - for (GList *l = panel->execp_list; l; l = l->next) { - Execp *execp = l->data; - execp->area.bg = execp->backend->bg; - execp->area.paddingx = execp->backend->paddingx; - execp->area.paddingy = execp->backend->paddingy; - execp->area.paddingxlr = execp->backend->paddingxlr; - execp->area.parent = panel; - execp->area.panel = panel; - execp->area._dump_geometry = execp_dump_geometry; - execp->area._compute_desired_size = execp_compute_desired_size; - snprintf(execp->area.name, - sizeof(execp->area.name), - "Execp %s", - execp->backend->command ? execp->backend->command : "null"); - execp->area._draw_foreground = draw_execp; - execp->area.size_mode = LAYOUT_FIXED; - execp->area._resize = resize_execp; - execp->area._get_tooltip_text = execp_get_tooltip; - execp->area._is_under_mouse = full_width_area_is_under_mouse; - execp->area.has_mouse_press_effect = - panel_config.mouse_effects && - (execp->area.has_mouse_over_effect = execp->backend->lclick_command || execp->backend->mclick_command || - execp->backend->rclick_command || execp->backend->uwheel_command || - execp->backend->dwheel_command); + for (GList *l = panel->execp_list; l; l = l->next) { + Execp *execp = l->data; + execp->area.bg = execp->backend->bg; + execp->area.paddingx = execp->backend->paddingx; + execp->area.paddingy = execp->backend->paddingy; + execp->area.paddingxlr = execp->backend->paddingxlr; + execp->area.parent = panel; + execp->area.panel = panel; + execp->area._dump_geometry = execp_dump_geometry; + execp->area._compute_desired_size = execp_compute_desired_size; + snprintf(execp->area.name, + sizeof(execp->area.name), + "Execp %s", + execp->backend->command ? execp->backend->command : "null"); + execp->area._draw_foreground = draw_execp; + execp->area.size_mode = LAYOUT_FIXED; + execp->area._resize = resize_execp; + execp->area._get_tooltip_text = execp_get_tooltip; + execp->area._is_under_mouse = full_width_area_is_under_mouse; + execp->area.has_mouse_press_effect = + panel_config.mouse_effects && + (execp->area.has_mouse_over_effect = execp->backend->lclick_command || execp->backend->mclick_command || + execp->backend->rclick_command || execp->backend->uwheel_command || + execp->backend->dwheel_command); - execp->area.resize_needed = TRUE; - execp->area.on_screen = TRUE; - instantiate_area_gradients(&execp->area); + execp->area.resize_needed = TRUE; + execp->area.on_screen = TRUE; + instantiate_area_gradients(&execp->area); - if (!execp->backend->timer) - execp->backend->timer = add_timeout(10, 0, execp_timer_callback, execp, &execp->backend->timer); - } + if (!execp->backend->timer) + execp->backend->timer = add_timeout(10, 0, execp_timer_callback, execp, &execp->backend->timer); + } } void execp_init_fonts() { - for (GList *l = panel_config.execp_list; l; l = l->next) { - Execp *execp = l->data; - if (!execp->backend->font_desc) - execp->backend->font_desc = pango_font_description_from_string(get_default_font()); - } + for (GList *l = panel_config.execp_list; l; l = l->next) { + Execp *execp = l->data; + if (!execp->backend->font_desc) + execp->backend->font_desc = pango_font_description_from_string(get_default_font()); + } } void execp_default_font_changed() { - gboolean needs_update = FALSE; - for (GList *l = panel_config.execp_list; l; l = l->next) { - Execp *execp = l->data; + gboolean needs_update = FALSE; + for (GList *l = panel_config.execp_list; l; l = l->next) { + Execp *execp = l->data; - if (!execp->backend->has_font) { - pango_font_description_free(execp->backend->font_desc); - execp->backend->font_desc = NULL; - needs_update = TRUE; - } - } - if (!needs_update) - return; + if (!execp->backend->has_font) { + pango_font_description_free(execp->backend->font_desc); + execp->backend->font_desc = NULL; + needs_update = TRUE; + } + } + if (!needs_update) + return; - execp_init_fonts(); - for (int i = 0; i < num_panels; i++) { - for (GList *l = panels[i].execp_list; l; l = l->next) { - Execp *execp = l->data; + execp_init_fonts(); + for (int i = 0; i < num_panels; i++) { + for (GList *l = panels[i].execp_list; l; l = l->next) { + Execp *execp = l->data; - if (!execp->backend->has_font) { - execp->area.resize_needed = TRUE; - schedule_redraw(&execp->area); - } - } - } - schedule_panel_redraw(); + if (!execp->backend->has_font) { + execp->area.resize_needed = TRUE; + schedule_redraw(&execp->area); + } + } + } + schedule_panel_redraw(); } void cleanup_execp() { - // Cleanup frontends - for (int i = 0; i < num_panels; i++) { - g_list_free_full(panels[i].execp_list, destroy_execp); - panels[i].execp_list = NULL; - } + // Cleanup frontends + for (int i = 0; i < num_panels; i++) { + g_list_free_full(panels[i].execp_list, destroy_execp); + panels[i].execp_list = NULL; + } - // Cleanup backends - g_list_free_full(panel_config.execp_list, destroy_execp); - panel_config.execp_list = NULL; + // Cleanup backends + g_list_free_full(panel_config.execp_list, destroy_execp); + panel_config.execp_list = NULL; } // Called from backend functions. gboolean reload_icon(Execp *execp) { - char *icon_path = execp->backend->icon_path; + char *icon_path = execp->backend->icon_path; - if (execp->backend->has_icon && icon_path) { - if (execp->backend->icon) { - imlib_context_set_image(execp->backend->icon); - imlib_free_image(); - } - execp->backend->icon = load_image(icon_path, execp->backend->cache_icon); - if (execp->backend->icon) { - imlib_context_set_image(execp->backend->icon); - int w = imlib_image_get_width(); - int h = imlib_image_get_height(); - if (w && h) { - if (execp->backend->icon_w) { - if (!execp->backend->icon_h) { - h = (int)(0.5 + h * execp->backend->icon_w / (float)(w)); - w = execp->backend->icon_w; - } else { - w = execp->backend->icon_w; - h = execp->backend->icon_h; - } - } else { - if (execp->backend->icon_h) { - w = (int)(0.5 + w * execp->backend->icon_h / (float)(h)); - h = execp->backend->icon_h; - } - } - if (w < 1) - w = 1; - if (h < 1) - h = 1; - } - if (w != imlib_image_get_width() || h != imlib_image_get_height()) { - Imlib_Image icon_scaled = - imlib_create_cropped_scaled_image(0, 0, imlib_image_get_width(), imlib_image_get_height(), w, h); - imlib_context_set_image(execp->backend->icon); - imlib_free_image(); - execp->backend->icon = icon_scaled; - } - return TRUE; - } - } - return FALSE; + if (execp->backend->has_icon && icon_path) { + if (execp->backend->icon) { + imlib_context_set_image(execp->backend->icon); + imlib_free_image(); + } + execp->backend->icon = load_image(icon_path, execp->backend->cache_icon); + if (execp->backend->icon) { + imlib_context_set_image(execp->backend->icon); + int w = imlib_image_get_width(); + int h = imlib_image_get_height(); + if (w && h) { + if (execp->backend->icon_w) { + if (!execp->backend->icon_h) { + h = (int)(0.5 + h * execp->backend->icon_w / (float)(w)); + w = execp->backend->icon_w; + } else { + w = execp->backend->icon_w; + h = execp->backend->icon_h; + } + } else { + if (execp->backend->icon_h) { + w = (int)(0.5 + w * execp->backend->icon_h / (float)(h)); + h = execp->backend->icon_h; + } + } + if (w < 1) + w = 1; + if (h < 1) + h = 1; + } + if (w != imlib_image_get_width() || h != imlib_image_get_height()) { + Imlib_Image icon_scaled = + imlib_create_cropped_scaled_image(0, 0, imlib_image_get_width(), imlib_image_get_height(), w, h); + imlib_context_set_image(execp->backend->icon); + imlib_free_image(); + execp->backend->icon = icon_scaled; + } + return TRUE; + } + } + return FALSE; } int execp_compute_desired_size(void *obj) { - Execp *execp = (Execp *)obj; - Panel *panel = (Panel *)execp->area.panel; - int horiz_padding = (panel_horizontal ? execp->area.paddingxlr : execp->area.paddingy); - int vert_padding = (panel_horizontal ? execp->area.paddingy : execp->area.paddingxlr); - int interior_padding = execp->area.paddingx; + Execp *execp = (Execp *)obj; + Panel *panel = (Panel *)execp->area.panel; + int horiz_padding = (panel_horizontal ? execp->area.paddingxlr : execp->area.paddingy); + int vert_padding = (panel_horizontal ? execp->area.paddingy : execp->area.paddingxlr); + int interior_padding = execp->area.paddingx; - int icon_w, icon_h; - if (reload_icon(execp)) { - if (execp->backend->icon) { - imlib_context_set_image(execp->backend->icon); - icon_w = imlib_image_get_width(); - icon_h = imlib_image_get_height(); - } else { - icon_w = icon_h = 0; - } - } else { - icon_w = icon_h = 0; - } + int icon_w, icon_h; + if (reload_icon(execp)) { + if (execp->backend->icon) { + imlib_context_set_image(execp->backend->icon); + icon_w = imlib_image_get_width(); + icon_h = imlib_image_get_height(); + } else { + icon_w = icon_h = 0; + } + } else { + icon_w = icon_h = 0; + } - int text_next_line = !panel_horizontal && icon_w > execp->area.width / 2; + int text_next_line = !panel_horizontal && icon_w > execp->area.width / 2; - int txt_height_ink, txt_height, txt_width; - if (panel_horizontal) { - get_text_size2(execp->backend->font_desc, - &txt_height_ink, - &txt_height, - &txt_width, - panel->area.height, - panel->area.width, - execp->backend->text, - strlen(execp->backend->text), - PANGO_WRAP_WORD_CHAR, - PANGO_ELLIPSIZE_NONE, - execp->backend->has_markup); - } else { - get_text_size2(execp->backend->font_desc, - &txt_height_ink, - &txt_height, - &txt_width, - panel->area.height, - !text_next_line - ? execp->area.width - icon_w - (icon_w ? interior_padding : 0) - 2 * horiz_padding - - left_right_border_width(&execp->area) - : execp->area.width - 2 * horiz_padding - left_right_border_width(&execp->area), - execp->backend->text, - strlen(execp->backend->text), - PANGO_WRAP_WORD_CHAR, - PANGO_ELLIPSIZE_NONE, - execp->backend->has_markup); - } + int txt_height_ink, txt_height, txt_width; + if (panel_horizontal) { + get_text_size2(execp->backend->font_desc, + &txt_height_ink, + &txt_height, + &txt_width, + panel->area.height, + panel->area.width, + execp->backend->text, + strlen(execp->backend->text), + PANGO_WRAP_WORD_CHAR, + PANGO_ELLIPSIZE_NONE, + execp->backend->has_markup); + } else { + get_text_size2(execp->backend->font_desc, + &txt_height_ink, + &txt_height, + &txt_width, + panel->area.height, + !text_next_line + ? execp->area.width - icon_w - (icon_w ? interior_padding : 0) - 2 * horiz_padding - + left_right_border_width(&execp->area) + : execp->area.width - 2 * horiz_padding - left_right_border_width(&execp->area), + execp->backend->text, + strlen(execp->backend->text), + PANGO_WRAP_WORD_CHAR, + PANGO_ELLIPSIZE_NONE, + execp->backend->has_markup); + } - if (panel_horizontal) { - int new_size = txt_width; - if (icon_w) - new_size += interior_padding + icon_w; - new_size += 2 * horiz_padding + left_right_border_width(&execp->area); - return new_size; - } else { - int new_size; - if (!text_next_line) { - new_size = txt_height + 2 * vert_padding + top_bottom_border_width(&execp->area); - new_size = MAX(new_size, icon_h + 2 * vert_padding + top_bottom_border_width(&execp->area)); - } else { - new_size = - icon_h + interior_padding + txt_height + 2 * vert_padding + top_bottom_border_width(&execp->area); - } - return new_size; - } + if (panel_horizontal) { + int new_size = txt_width; + if (icon_w) + new_size += interior_padding + icon_w; + new_size += 2 * horiz_padding + left_right_border_width(&execp->area); + return new_size; + } else { + int new_size; + if (!text_next_line) { + new_size = txt_height + 2 * vert_padding + top_bottom_border_width(&execp->area); + new_size = MAX(new_size, icon_h + 2 * vert_padding + top_bottom_border_width(&execp->area)); + } else { + new_size = + icon_h + interior_padding + txt_height + 2 * vert_padding + top_bottom_border_width(&execp->area); + } + return new_size; + } } gboolean resize_execp(void *obj) { - Execp *execp = (Execp *)obj; - Panel *panel = (Panel *)execp->area.panel; - int horiz_padding = (panel_horizontal ? execp->area.paddingxlr : execp->area.paddingy); - int vert_padding = (panel_horizontal ? execp->area.paddingy : execp->area.paddingxlr); - int interior_padding = execp->area.paddingx; + Execp *execp = (Execp *)obj; + Panel *panel = (Panel *)execp->area.panel; + int horiz_padding = (panel_horizontal ? execp->area.paddingxlr : execp->area.paddingy); + int vert_padding = (panel_horizontal ? execp->area.paddingy : execp->area.paddingxlr); + int interior_padding = execp->area.paddingx; - int icon_w, icon_h; - if (reload_icon(execp)) { - if (execp->backend->icon) { - imlib_context_set_image(execp->backend->icon); - icon_w = imlib_image_get_width(); - icon_h = imlib_image_get_height(); - } else { - icon_w = icon_h = 0; - } - } else { - icon_w = icon_h = 0; - } + int icon_w, icon_h; + if (reload_icon(execp)) { + if (execp->backend->icon) { + imlib_context_set_image(execp->backend->icon); + icon_w = imlib_image_get_width(); + icon_h = imlib_image_get_height(); + } else { + icon_w = icon_h = 0; + } + } else { + icon_w = icon_h = 0; + } - int text_next_line = !panel_horizontal && icon_w > execp->area.width / 2; + int text_next_line = !panel_horizontal && icon_w > execp->area.width / 2; - int txt_height_ink, txt_height, txt_width; - if (panel_horizontal) { - get_text_size2(execp->backend->font_desc, - &txt_height_ink, - &txt_height, - &txt_width, - panel->area.height, - panel->area.width, - execp->backend->text, - strlen(execp->backend->text), - PANGO_WRAP_WORD_CHAR, - PANGO_ELLIPSIZE_NONE, - execp->backend->has_markup); - } else { - get_text_size2(execp->backend->font_desc, - &txt_height_ink, - &txt_height, - &txt_width, - panel->area.height, - !text_next_line - ? execp->area.width - icon_w - (icon_w ? interior_padding : 0) - 2 * horiz_padding - - left_right_border_width(&execp->area) - : execp->area.width - 2 * horiz_padding - left_right_border_width(&execp->area), - execp->backend->text, - strlen(execp->backend->text), - PANGO_WRAP_WORD_CHAR, - PANGO_ELLIPSIZE_NONE, - execp->backend->has_markup); - } + int txt_height_ink, txt_height, txt_width; + if (panel_horizontal) { + get_text_size2(execp->backend->font_desc, + &txt_height_ink, + &txt_height, + &txt_width, + panel->area.height, + panel->area.width, + execp->backend->text, + strlen(execp->backend->text), + PANGO_WRAP_WORD_CHAR, + PANGO_ELLIPSIZE_NONE, + execp->backend->has_markup); + } else { + get_text_size2(execp->backend->font_desc, + &txt_height_ink, + &txt_height, + &txt_width, + panel->area.height, + !text_next_line + ? execp->area.width - icon_w - (icon_w ? interior_padding : 0) - 2 * horiz_padding - + left_right_border_width(&execp->area) + : execp->area.width - 2 * horiz_padding - left_right_border_width(&execp->area), + execp->backend->text, + strlen(execp->backend->text), + PANGO_WRAP_WORD_CHAR, + PANGO_ELLIPSIZE_NONE, + execp->backend->has_markup); + } - gboolean result = FALSE; - if (panel_horizontal) { - int new_size = txt_width; - if (icon_w) - new_size += interior_padding + icon_w; - new_size += 2 * horiz_padding + left_right_border_width(&execp->area); - if (new_size > execp->area.width || new_size < (execp->area.width - 6)) { - // we try to limit the number of resize - execp->area.width = new_size + 1; - result = TRUE; - } - } else { - int new_size; - if (!text_next_line) { - new_size = txt_height + 2 * vert_padding + top_bottom_border_width(&execp->area); - new_size = MAX(new_size, icon_h + 2 * vert_padding + top_bottom_border_width(&execp->area)); - } else { - new_size = - icon_h + interior_padding + txt_height + 2 * vert_padding + top_bottom_border_width(&execp->area); - } - if (new_size != execp->area.height) { - execp->area.height = new_size; - result = TRUE; - } - } - execp->frontend->textw = txt_width; - execp->frontend->texth = txt_height; - if (execp->backend->centered) { - if (icon_w) { - if (!text_next_line) { - execp->frontend->icony = (execp->area.height - icon_h) / 2; - execp->frontend->iconx = (execp->area.width - txt_width - interior_padding - icon_w) / 2; - execp->frontend->texty = (execp->area.height - txt_height) / 2; - execp->frontend->textx = execp->frontend->iconx + icon_w + interior_padding; - } else { - execp->frontend->icony = (execp->area.height - icon_h - interior_padding - txt_height) / 2; - execp->frontend->iconx = (execp->area.width - icon_w) / 2; - execp->frontend->texty = execp->frontend->icony + icon_h + interior_padding; - execp->frontend->textx = (execp->area.width - txt_width) / 2; - } - } else { - execp->frontend->texty = (execp->area.height - txt_height) / 2; - execp->frontend->textx = (execp->area.width - txt_width) / 2; - } - } else { - if (icon_w) { - if (!text_next_line) { - execp->frontend->icony = (execp->area.height - icon_h) / 2; - execp->frontend->iconx = left_border_width(&execp->area) + horiz_padding; - execp->frontend->texty = (execp->area.height - txt_height) / 2; - execp->frontend->textx = execp->frontend->iconx + icon_w + interior_padding; - } else { - execp->frontend->icony = (execp->area.height - icon_h - interior_padding - txt_height) / 2; - execp->frontend->iconx = left_border_width(&execp->area) + horiz_padding; - execp->frontend->texty = execp->frontend->icony + icon_h + interior_padding; - execp->frontend->textx = execp->frontend->iconx; - } - } else { - execp->frontend->texty = (execp->area.height - txt_height) / 2; - execp->frontend->textx = left_border_width(&execp->area) + horiz_padding; - } - } + gboolean result = FALSE; + if (panel_horizontal) { + int new_size = txt_width; + if (icon_w) + new_size += interior_padding + icon_w; + new_size += 2 * horiz_padding + left_right_border_width(&execp->area); + if (new_size > execp->area.width || new_size < (execp->area.width - 6)) { + // we try to limit the number of resize + execp->area.width = new_size + 1; + result = TRUE; + } + } else { + int new_size; + if (!text_next_line) { + new_size = txt_height + 2 * vert_padding + top_bottom_border_width(&execp->area); + new_size = MAX(new_size, icon_h + 2 * vert_padding + top_bottom_border_width(&execp->area)); + } else { + new_size = + icon_h + interior_padding + txt_height + 2 * vert_padding + top_bottom_border_width(&execp->area); + } + if (new_size != execp->area.height) { + execp->area.height = new_size; + result = TRUE; + } + } + execp->frontend->textw = txt_width; + execp->frontend->texth = txt_height; + if (execp->backend->centered) { + if (icon_w) { + if (!text_next_line) { + execp->frontend->icony = (execp->area.height - icon_h) / 2; + execp->frontend->iconx = (execp->area.width - txt_width - interior_padding - icon_w) / 2; + execp->frontend->texty = (execp->area.height - txt_height) / 2; + execp->frontend->textx = execp->frontend->iconx + icon_w + interior_padding; + } else { + execp->frontend->icony = (execp->area.height - icon_h - interior_padding - txt_height) / 2; + execp->frontend->iconx = (execp->area.width - icon_w) / 2; + execp->frontend->texty = execp->frontend->icony + icon_h + interior_padding; + execp->frontend->textx = (execp->area.width - txt_width) / 2; + } + } else { + execp->frontend->texty = (execp->area.height - txt_height) / 2; + execp->frontend->textx = (execp->area.width - txt_width) / 2; + } + } else { + if (icon_w) { + if (!text_next_line) { + execp->frontend->icony = (execp->area.height - icon_h) / 2; + execp->frontend->iconx = left_border_width(&execp->area) + horiz_padding; + execp->frontend->texty = (execp->area.height - txt_height) / 2; + execp->frontend->textx = execp->frontend->iconx + icon_w + interior_padding; + } else { + execp->frontend->icony = (execp->area.height - icon_h - interior_padding - txt_height) / 2; + execp->frontend->iconx = left_border_width(&execp->area) + horiz_padding; + execp->frontend->texty = execp->frontend->icony + icon_h + interior_padding; + execp->frontend->textx = execp->frontend->iconx; + } + } else { + execp->frontend->texty = (execp->area.height - txt_height) / 2; + execp->frontend->textx = left_border_width(&execp->area) + horiz_padding; + } + } - schedule_redraw(&execp->area); + schedule_redraw(&execp->area); - return result; + return result; } void draw_execp(void *obj, cairo_t *c) { - Execp *execp = obj; - PangoLayout *layout = pango_cairo_create_layout(c); + Execp *execp = obj; + PangoLayout *layout = pango_cairo_create_layout(c); - if (execp->backend->has_icon && execp->backend->icon) { - imlib_context_set_image(execp->backend->icon); - // Render icon - render_image(execp->area.pix, execp->frontend->iconx, execp->frontend->icony); - } + if (execp->backend->has_icon && execp->backend->icon) { + imlib_context_set_image(execp->backend->icon); + // Render icon + render_image(execp->area.pix, execp->frontend->iconx, execp->frontend->icony); + } - // draw layout - pango_layout_set_font_description(layout, execp->backend->font_desc); - pango_layout_set_width(layout, execp->frontend->textw * PANGO_SCALE); - pango_layout_set_alignment(layout, execp->backend->centered ? PANGO_ALIGN_CENTER : PANGO_ALIGN_LEFT); - pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR); - pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_NONE); - if (!execp->backend->has_markup) - pango_layout_set_text(layout, execp->backend->text, strlen(execp->backend->text)); - else - pango_layout_set_markup(layout, execp->backend->text, strlen(execp->backend->text)); + // draw layout + pango_layout_set_font_description(layout, execp->backend->font_desc); + pango_layout_set_width(layout, execp->frontend->textw * PANGO_SCALE); + pango_layout_set_alignment(layout, execp->backend->centered ? PANGO_ALIGN_CENTER : PANGO_ALIGN_LEFT); + pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR); + pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_NONE); + if (!execp->backend->has_markup) + pango_layout_set_text(layout, execp->backend->text, strlen(execp->backend->text)); + else + pango_layout_set_markup(layout, execp->backend->text, strlen(execp->backend->text)); - pango_cairo_update_layout(c, layout); - draw_text(layout, - c, - execp->frontend->textx, - execp->frontend->texty, - &execp->backend->font_color, - panel_config.font_shadow); + pango_cairo_update_layout(c, layout); + draw_text(layout, + c, + execp->frontend->textx, + execp->frontend->texty, + &execp->backend->font_color, + panel_config.font_shadow); - g_object_unref(layout); + g_object_unref(layout); } void execp_dump_geometry(void *obj, int indent) { - Execp *execp = obj; + Execp *execp = obj; - if (execp->backend->has_icon && execp->backend->icon) { - Imlib_Image tmp = imlib_context_get_image(); - imlib_context_set_image(execp->backend->icon); - fprintf(stderr, - "%*sIcon: x = %d, y = %d, w = %d, h = %d\n", - indent, - "", - execp->frontend->iconx, - execp->frontend->icony, - imlib_image_get_width(), - imlib_image_get_height()); - if (tmp) - imlib_context_set_image(tmp); - } - fprintf(stderr, - "%*sText: x = %d, y = %d, w = %d, align = %s, text = %s\n", - indent, - "", - execp->frontend->textx, - execp->frontend->texty, - execp->frontend->textw, - execp->backend->centered ? "center" : "left", - execp->backend->text); + if (execp->backend->has_icon && execp->backend->icon) { + Imlib_Image tmp = imlib_context_get_image(); + imlib_context_set_image(execp->backend->icon); + fprintf(stderr, + "%*sIcon: x = %d, y = %d, w = %d, h = %d\n", + indent, + "", + execp->frontend->iconx, + execp->frontend->icony, + imlib_image_get_width(), + imlib_image_get_height()); + if (tmp) + imlib_context_set_image(tmp); + } + fprintf(stderr, + "%*sText: x = %d, y = %d, w = %d, align = %s, text = %s\n", + indent, + "", + execp->frontend->textx, + execp->frontend->texty, + execp->frontend->textw, + execp->backend->centered ? "center" : "left", + execp->backend->text); } void execp_force_update(Execp *execp) { - if (execp->backend->child_pipe > 0) { - // Command currently running, nothing to do - } else { - if (execp->backend->timer) - stop_timeout(execp->backend->timer); - // Run command right away - execp->backend->timer = add_timeout(10, 0, execp_timer_callback, execp, &execp->backend->timer); - } + if (execp->backend->child_pipe > 0) { + // Command currently running, nothing to do + } else { + if (execp->backend->timer) + stop_timeout(execp->backend->timer); + // Run command right away + execp->backend->timer = add_timeout(10, 0, execp_timer_callback, execp, &execp->backend->timer); + } } void execp_action(void *obj, int button, int x, int y) { - Execp *execp = obj; - char *command = NULL; - switch (button) { - case 1: - command = execp->backend->lclick_command; - break; - case 2: - command = execp->backend->mclick_command; - break; - case 3: - command = execp->backend->rclick_command; - break; - case 4: - command = execp->backend->uwheel_command; - break; - case 5: - command = execp->backend->dwheel_command; - break; - } - if (command) { - char *full_cmd = g_strdup_printf("export EXECP_X=%d;" - "export EXECP_Y=%d;" - "export EXECP_W=%d;" - "export EXECP_H=%d; %s", - x, - y, - execp->area.width, - execp->area.height, - command); - pid_t pid = fork(); - if (pid < 0) { - fprintf(stderr, "Could not fork\n"); - } else if (pid == 0) { - // Child process - // Allow children to exist after parent destruction - setsid(); - // Run the command - execl("/bin/sh", "/bin/sh", "-c", full_cmd, NULL); - fprintf(stderr, "Failed to execlp %s\n", full_cmd); - exit(1); - } - // Parent process - g_tree_insert(execp->backend->cmd_pids, GINT_TO_POINTER(pid), GINT_TO_POINTER(1)); - g_free(full_cmd); - } else { - execp_force_update(execp); - } + Execp *execp = obj; + char *command = NULL; + switch (button) { + case 1: + command = execp->backend->lclick_command; + break; + case 2: + command = execp->backend->mclick_command; + break; + case 3: + command = execp->backend->rclick_command; + break; + case 4: + command = execp->backend->uwheel_command; + break; + case 5: + command = execp->backend->dwheel_command; + break; + } + if (command) { + char *full_cmd = g_strdup_printf("export EXECP_X=%d;" + "export EXECP_Y=%d;" + "export EXECP_W=%d;" + "export EXECP_H=%d; %s", + x, + y, + execp->area.width, + execp->area.height, + command); + pid_t pid = fork(); + if (pid < 0) { + fprintf(stderr, "Could not fork\n"); + } else if (pid == 0) { + // Child process + // Allow children to exist after parent destruction + setsid(); + // Run the command + execl("/bin/sh", "/bin/sh", "-c", full_cmd, NULL); + fprintf(stderr, "Failed to execlp %s\n", full_cmd); + exit(1); + } + // Parent process + g_tree_insert(execp->backend->cmd_pids, GINT_TO_POINTER(pid), GINT_TO_POINTER(1)); + g_free(full_cmd); + } else { + execp_force_update(execp); + } } void execp_cmd_completed(Execp *execp, pid_t pid) { - g_tree_remove(execp->backend->cmd_pids, GINT_TO_POINTER(pid)); - execp_force_update(execp); + g_tree_remove(execp->backend->cmd_pids, GINT_TO_POINTER(pid)); + execp_force_update(execp); } void execp_timer_callback(void *arg) { - Execp *execp = arg; + Execp *execp = arg; - if (!execp->backend->command) - return; + if (!execp->backend->command) + return; - // Still running! - if (execp->backend->child_pipe > 0) - return; + // Still running! + if (execp->backend->child_pipe > 0) + return; - int pipe_fd[2]; - if (pipe(pipe_fd)) { - // TODO maybe write this in tooltip, but if this happens we're screwed anyways - fprintf(stderr, "Execp: Creating pipe failed!\n"); - return; - } + int pipe_fd[2]; + if (pipe(pipe_fd)) { + // TODO maybe write this in tooltip, but if this happens we're screwed anyways + fprintf(stderr, "Execp: Creating pipe failed!\n"); + return; + } - fcntl(pipe_fd[0], F_SETFL, O_NONBLOCK | fcntl(pipe_fd[0], F_GETFL)); + fcntl(pipe_fd[0], F_SETFL, O_NONBLOCK | fcntl(pipe_fd[0], F_GETFL)); - // Fork and run command, capturing stdout in pipe - pid_t child = fork(); - if (child == -1) { - // TODO maybe write this in tooltip, but if this happens we're screwed anyways - fprintf(stderr, "Fork failed.\n"); - close(pipe_fd[1]); - close(pipe_fd[0]); - return; - } else if (child == 0) { - fprintf(stderr, "Executing: %s\n", execp->backend->command); - // We are in the child - close(pipe_fd[0]); - dup2(pipe_fd[1], 1); // 1 is stdout - close(pipe_fd[1]); - setpgid(0, 0); - execl("/bin/sh", "/bin/sh", "-c", execp->backend->command, NULL); - // This should never happen! - fprintf(stdout, "execl() failed\nexecl() failed\n"); - fflush(stdout); - exit(0); - } - close(pipe_fd[1]); - execp->backend->child = child; - execp->backend->child_pipe = pipe_fd[0]; - execp->backend->buf_length = 0; - execp->backend->buf_output[execp->backend->buf_length] = '\0'; - execp->backend->last_update_start_time = time(NULL); + // Fork and run command, capturing stdout in pipe + pid_t child = fork(); + if (child == -1) { + // TODO maybe write this in tooltip, but if this happens we're screwed anyways + fprintf(stderr, "Fork failed.\n"); + close(pipe_fd[1]); + close(pipe_fd[0]); + return; + } else if (child == 0) { + fprintf(stderr, "Executing: %s\n", execp->backend->command); + // We are in the child + close(pipe_fd[0]); + dup2(pipe_fd[1], 1); // 1 is stdout + close(pipe_fd[1]); + setpgid(0, 0); + execl("/bin/sh", "/bin/sh", "-c", execp->backend->command, NULL); + // This should never happen! + fprintf(stdout, "execl() failed\nexecl() failed\n"); + fflush(stdout); + exit(0); + } + close(pipe_fd[1]); + execp->backend->child = child; + execp->backend->child_pipe = pipe_fd[0]; + execp->backend->buf_length = 0; + execp->backend->buf_output[execp->backend->buf_length] = '\0'; + execp->backend->last_update_start_time = time(NULL); } gboolean read_execp(void *obj) { - Execp *execp = (Execp *)obj; + Execp *execp = (Execp *)obj; - if (execp->backend->child_pipe < 0) - return FALSE; + if (execp->backend->child_pipe < 0) + return FALSE; - gboolean command_finished = FALSE; - while (1) { - // Make sure there is free space in the buffer - if (execp->backend->buf_capacity - execp->backend->buf_length < 1024) { - execp->backend->buf_capacity *= 2; - execp->backend->buf_output = realloc(execp->backend->buf_output, execp->backend->buf_capacity); - } - ssize_t count = read(execp->backend->child_pipe, - execp->backend->buf_output + execp->backend->buf_length, - execp->backend->buf_capacity - execp->backend->buf_length - 1); - if (count > 0) { - // Successful read - execp->backend->buf_length += count; - execp->backend->buf_output[execp->backend->buf_length] = '\0'; - continue; - } else if (count == 0) { - // End of file - command_finished = TRUE; - break; - } else if (errno == EAGAIN || errno == EWOULDBLOCK) { - // No more data available at the moment - break; - } else if (errno == EINTR) { - // Harmless interruption by signal - continue; - } else { - // Error - command_finished = TRUE; - break; - } - break; - } + gboolean command_finished = FALSE; + while (1) { + // Make sure there is free space in the buffer + if (execp->backend->buf_capacity - execp->backend->buf_length < 1024) { + execp->backend->buf_capacity *= 2; + execp->backend->buf_output = realloc(execp->backend->buf_output, execp->backend->buf_capacity); + } + ssize_t count = read(execp->backend->child_pipe, + execp->backend->buf_output + execp->backend->buf_length, + execp->backend->buf_capacity - execp->backend->buf_length - 1); + if (count > 0) { + // Successful read + execp->backend->buf_length += count; + execp->backend->buf_output[execp->backend->buf_length] = '\0'; + continue; + } else if (count == 0) { + // End of file + command_finished = TRUE; + break; + } else if (errno == EAGAIN || errno == EWOULDBLOCK) { + // No more data available at the moment + break; + } else if (errno == EINTR) { + // Harmless interruption by signal + continue; + } else { + // Error + command_finished = TRUE; + break; + } + break; + } - if (command_finished) { - execp->backend->child = 0; - close(execp->backend->child_pipe); - execp->backend->child_pipe = -1; - if (execp->backend->interval) - execp->backend->timer = - add_timeout(execp->backend->interval * 1000, 0, execp_timer_callback, execp, &execp->backend->timer); - } + if (command_finished) { + execp->backend->child = 0; + close(execp->backend->child_pipe); + execp->backend->child_pipe = -1; + if (execp->backend->interval) + execp->backend->timer = + add_timeout(execp->backend->interval * 1000, 0, execp_timer_callback, execp, &execp->backend->timer); + } - if (!execp->backend->continuous && command_finished) { - free_and_null(execp->backend->text); - free_and_null(execp->backend->icon_path); - if (!execp->backend->has_icon) { - execp->backend->text = strdup(execp->backend->buf_output); - } else { - char *text = strchr(execp->backend->buf_output, '\n'); - if (text) { - *text = '\0'; - text++; - execp->backend->text = strdup(text); - } else { - execp->backend->text = strdup(""); - } - execp->backend->icon_path = strdup(execp->backend->buf_output); - } - int len = strlen(execp->backend->text); - if (len > 0 && execp->backend->text[len - 1] == '\n') - execp->backend->text[len - 1] = '\0'; - execp->backend->buf_length = 0; - execp->backend->buf_output[execp->backend->buf_length] = '\0'; - execp->backend->last_update_finish_time = time(NULL); - execp->backend->last_update_duration = - execp->backend->last_update_finish_time - execp->backend->last_update_start_time; - return TRUE; - } else if (execp->backend->continuous > 0) { - // Count lines in buffer - int num_lines = 0; - char *last = execp->backend->buf_output; - char *end = NULL; - for (char *c = execp->backend->buf_output; *c; c++) { - if (*c == '\n') { - num_lines++; - if (num_lines == execp->backend->continuous) - end = c; - } - last = c; - } - if (*last && *last != '\n') - num_lines++; - if (num_lines >= execp->backend->continuous) { - if (end) - *end = '\0'; - free_and_null(execp->backend->text); - free_and_null(execp->backend->icon_path); - if (!execp->backend->has_icon) { - execp->backend->text = strdup(execp->backend->buf_output); - } else { - char *text = strchr(execp->backend->buf_output, '\n'); - if (text) { - *text = '\0'; - text++; - execp->backend->text = strdup(text); - } else { - execp->backend->text = strdup(""); - } - execp->backend->icon_path = strdup(execp->backend->buf_output); - } - int len = strlen(execp->backend->text); - if (len > 0 && execp->backend->text[len - 1] == '\n') - execp->backend->text[len - 1] = '\0'; + if (!execp->backend->continuous && command_finished) { + free_and_null(execp->backend->text); + free_and_null(execp->backend->icon_path); + if (!execp->backend->has_icon) { + execp->backend->text = strdup(execp->backend->buf_output); + } else { + char *text = strchr(execp->backend->buf_output, '\n'); + if (text) { + *text = '\0'; + text++; + execp->backend->text = strdup(text); + } else { + execp->backend->text = strdup(""); + } + execp->backend->icon_path = strdup(execp->backend->buf_output); + } + int len = strlen(execp->backend->text); + if (len > 0 && execp->backend->text[len - 1] == '\n') + execp->backend->text[len - 1] = '\0'; + execp->backend->buf_length = 0; + execp->backend->buf_output[execp->backend->buf_length] = '\0'; + execp->backend->last_update_finish_time = time(NULL); + execp->backend->last_update_duration = + execp->backend->last_update_finish_time - execp->backend->last_update_start_time; + return TRUE; + } else if (execp->backend->continuous > 0) { + // Count lines in buffer + int num_lines = 0; + char *last = execp->backend->buf_output; + char *end = NULL; + for (char *c = execp->backend->buf_output; *c; c++) { + if (*c == '\n') { + num_lines++; + if (num_lines == execp->backend->continuous) + end = c; + } + last = c; + } + if (*last && *last != '\n') + num_lines++; + if (num_lines >= execp->backend->continuous) { + if (end) + *end = '\0'; + free_and_null(execp->backend->text); + free_and_null(execp->backend->icon_path); + if (!execp->backend->has_icon) { + execp->backend->text = strdup(execp->backend->buf_output); + } else { + char *text = strchr(execp->backend->buf_output, '\n'); + if (text) { + *text = '\0'; + text++; + execp->backend->text = strdup(text); + } else { + execp->backend->text = strdup(""); + } + execp->backend->icon_path = strdup(execp->backend->buf_output); + } + int len = strlen(execp->backend->text); + if (len > 0 && execp->backend->text[len - 1] == '\n') + execp->backend->text[len - 1] = '\0'; - if (end) { - char *next = end + 1; - int copied = next - execp->backend->buf_output; - int remaining = execp->backend->buf_length - copied; - if (remaining > 0) { - memmove(execp->backend->buf_output, next, remaining); - execp->backend->buf_length = remaining; - execp->backend->buf_output[execp->backend->buf_length] = '\0'; - } else { - execp->backend->buf_length = 0; - execp->backend->buf_output[execp->backend->buf_length] = '\0'; - } - } + if (end) { + char *next = end + 1; + int copied = next - execp->backend->buf_output; + int remaining = execp->backend->buf_length - copied; + if (remaining > 0) { + memmove(execp->backend->buf_output, next, remaining); + execp->backend->buf_length = remaining; + execp->backend->buf_output[execp->backend->buf_length] = '\0'; + } else { + execp->backend->buf_length = 0; + execp->backend->buf_output[execp->backend->buf_length] = '\0'; + } + } - execp->backend->last_update_finish_time = time(NULL); - execp->backend->last_update_duration = - execp->backend->last_update_finish_time - execp->backend->last_update_start_time; - return TRUE; - } - } - return FALSE; + execp->backend->last_update_finish_time = time(NULL); + execp->backend->last_update_duration = + execp->backend->last_update_finish_time - execp->backend->last_update_start_time; + return TRUE; + } + } + return FALSE; } const char *time_to_string(int seconds, char *buffer) { - if (seconds < 60) { - sprintf(buffer, "%ds", seconds); - } else if (seconds < 60 * 60) { - int m = seconds / 60; - seconds = seconds % 60; - int s = seconds; - sprintf(buffer, "%d:%ds", m, s); - } else { - int h = seconds / (60 * 60); - seconds = seconds % (60 * 60); - int m = seconds / 60; - seconds = seconds % 60; - int s = seconds; - sprintf(buffer, "%d:%d:%ds", h, m, s); - } - return buffer; + if (seconds < 60) { + sprintf(buffer, "%ds", seconds); + } else if (seconds < 60 * 60) { + int m = seconds / 60; + seconds = seconds % 60; + int s = seconds; + sprintf(buffer, "%d:%ds", m, s); + } else { + int h = seconds / (60 * 60); + seconds = seconds % (60 * 60); + int m = seconds / 60; + seconds = seconds % 60; + int s = seconds; + sprintf(buffer, "%d:%d:%ds", h, m, s); + } + return buffer; } char *execp_get_tooltip(void *obj) { - Execp *execp = obj; + Execp *execp = obj; - if (execp->backend->tooltip) { - if (strlen(execp->backend->tooltip) > 0) - return strdup(execp->backend->tooltip); - else - return NULL; - } + if (execp->backend->tooltip) { + if (strlen(execp->backend->tooltip) > 0) + return strdup(execp->backend->tooltip); + else + return NULL; + } - time_t now = time(NULL); + time_t now = time(NULL); - char tmp_buf1[256]; - char tmp_buf2[256]; - char tmp_buf3[256]; - if (execp->backend->child_pipe < 0) { - // Not executing command - if (execp->backend->last_update_finish_time) { - // We updated at least once - if (execp->backend->interval > 0) { - sprintf(execp->backend->tooltip_text, - "Last update finished %s ago (took %s). Next update starting in %s.", - time_to_string((int)(now - execp->backend->last_update_finish_time), tmp_buf1), - time_to_string((int)execp->backend->last_update_duration, tmp_buf2), - time_to_string((int)(execp->backend->interval - (now - execp->backend->last_update_finish_time)), - tmp_buf3)); - } else { - sprintf(execp->backend->tooltip_text, - "Last update finished %s ago (took %s).", - time_to_string((int)(now - execp->backend->last_update_finish_time), tmp_buf1), - time_to_string((int)execp->backend->last_update_duration, tmp_buf2)); - } - } else { - // we never requested an update - sprintf(execp->backend->tooltip_text, "Never updated. No update scheduled."); - } - } else { - // Currently executing command - if (execp->backend->last_update_finish_time) { - // we finished updating at least once - sprintf(execp->backend->tooltip_text, - "Last update finished %s ago. Update in progress (started %s ago).", - time_to_string((int)(now - execp->backend->last_update_finish_time), tmp_buf1), - time_to_string((int)(now - execp->backend->last_update_start_time), tmp_buf3)); - } else { - // we never finished an update - sprintf(execp->backend->tooltip_text, - "First update in progress (started %s seconds ago).", - time_to_string((int)(now - execp->backend->last_update_start_time), tmp_buf1)); - } - } - return strdup(execp->backend->tooltip_text); + char tmp_buf1[256]; + char tmp_buf2[256]; + char tmp_buf3[256]; + if (execp->backend->child_pipe < 0) { + // Not executing command + if (execp->backend->last_update_finish_time) { + // We updated at least once + if (execp->backend->interval > 0) { + sprintf(execp->backend->tooltip_text, + "Last update finished %s ago (took %s). Next update starting in %s.", + time_to_string((int)(now - execp->backend->last_update_finish_time), tmp_buf1), + time_to_string((int)execp->backend->last_update_duration, tmp_buf2), + time_to_string((int)(execp->backend->interval - (now - execp->backend->last_update_finish_time)), + tmp_buf3)); + } else { + sprintf(execp->backend->tooltip_text, + "Last update finished %s ago (took %s).", + time_to_string((int)(now - execp->backend->last_update_finish_time), tmp_buf1), + time_to_string((int)execp->backend->last_update_duration, tmp_buf2)); + } + } else { + // we never requested an update + sprintf(execp->backend->tooltip_text, "Never updated. No update scheduled."); + } + } else { + // Currently executing command + if (execp->backend->last_update_finish_time) { + // we finished updating at least once + sprintf(execp->backend->tooltip_text, + "Last update finished %s ago. Update in progress (started %s ago).", + time_to_string((int)(now - execp->backend->last_update_finish_time), tmp_buf1), + time_to_string((int)(now - execp->backend->last_update_start_time), tmp_buf3)); + } else { + // we never finished an update + sprintf(execp->backend->tooltip_text, + "First update in progress (started %s seconds ago).", + time_to_string((int)(now - execp->backend->last_update_start_time), tmp_buf1)); + } + } + return strdup(execp->backend->tooltip_text); }
M src/execplugin/execplugin.hsrc/execplugin/execplugin.h

@@ -17,78 +17,78 @@ // from panel_config. Each works as a frontend to the corresponding Execp in panel_config as backend, using the

// backend's config and state variables. typedef struct ExecpBackend { - // Config: - // Command to execute at a specified interval - char *command; - // Interval in seconds - int interval; - // 1 if first line of output is an icon path - gboolean has_icon; - gboolean cache_icon; - int icon_w; - int icon_h; - char *tooltip; - gboolean centered; - gboolean has_font; - PangoFontDescription *font_desc; - Color font_color; - int continuous; - gboolean has_markup; - char *lclick_command; - char *mclick_command; - char *rclick_command; - char *uwheel_command; - char *dwheel_command; - // paddingxlr = horizontal padding left/right - // paddingx = horizontal padding between childs - int paddingxlr, paddingx, paddingy; - Background *bg; + // Config: + // Command to execute at a specified interval + char *command; + // Interval in seconds + int interval; + // 1 if first line of output is an icon path + gboolean has_icon; + gboolean cache_icon; + int icon_w; + int icon_h; + char *tooltip; + gboolean centered; + gboolean has_font; + PangoFontDescription *font_desc; + Color font_color; + int continuous; + gboolean has_markup; + char *lclick_command; + char *mclick_command; + char *rclick_command; + char *uwheel_command; + char *dwheel_command; + // paddingxlr = horizontal padding left/right + // paddingx = horizontal padding between childs + int paddingxlr, paddingx, paddingy; + Background *bg; - // Backend state: - timeout *timer; - int child_pipe; - pid_t child; + // Backend state: + timeout *timer; + int child_pipe; + pid_t child; - // Command output buffer - char *buf_output; - int buf_length; - int buf_capacity; + // Command output buffer + char *buf_output; + int buf_length; + int buf_capacity; - // Text extracted from the output buffer - char *text; - // Icon path extracted from the output buffer - char *icon_path; - Imlib_Image icon; - char tooltip_text[512]; + // Text extracted from the output buffer + char *text; + // Icon path extracted from the output buffer + char *icon_path; + Imlib_Image icon; + char tooltip_text[512]; - // The time the last command was started - time_t last_update_start_time; - // The time the last output was obtained - time_t last_update_finish_time; - // The time it took to execute last command - time_t last_update_duration; + // The time the last command was started + time_t last_update_start_time; + // The time the last output was obtained + time_t last_update_finish_time; + // The time it took to execute last command + time_t last_update_duration; - // List of Execp which are frontends for this backend, one for each panel - GList *instances; - GTree *cmd_pids; + // List of Execp which are frontends for this backend, one for each panel + GList *instances; + GTree *cmd_pids; } ExecpBackend; typedef struct ExecpFrontend { - // Frontend state: - int iconx; - int icony; - int textx; - int texty; - int textw; - int texth; + // Frontend state: + int iconx; + int icony; + int textx; + int texty; + int textw; + int texth; } ExecpFrontend; typedef struct Execp { - Area area; - // All elements have the backend pointer set. However only backend elements have ownership. - ExecpBackend *backend; - // Set only for frontend Execp items. - ExecpFrontend *frontend; + Area area; + // All elements have the backend pointer set. However only backend elements have ownership. + ExecpBackend *backend; + // Set only for frontend Execp items. + ExecpFrontend *frontend; } Execp; // Called before the config is read and panel_config/panels are created.
M src/freespace/freespace.csrc/freespace/freespace.c

@@ -34,93 +34,93 @@ int freespace_area_compute_desired_size(void *obj);

void init_freespace_panel(void *p) { - Panel *panel = (Panel *)p; + Panel *panel = (Panel *)p; - // Make sure this is only done once if there are multiple items - if (panel->freespace_list) - return; + // Make sure this is only done once if there are multiple items + if (panel->freespace_list) + return; - for (size_t k = 0; k < strlen(panel_items_order); k++) { - if (panel_items_order[k] == 'F') { - FreeSpace *freespace = (FreeSpace *) calloc(1, sizeof(FreeSpace)); - panel->freespace_list = g_list_append(panel->freespace_list, freespace); - if (!freespace->area.bg) - freespace->area.bg = &g_array_index(backgrounds, Background, 0); - freespace->area.parent = p; - freespace->area.panel = p; - snprintf(freespace->area.name, sizeof(freespace->area.name), "Freespace"); - freespace->area.size_mode = LAYOUT_FIXED; - freespace->area.resize_needed = 1; - freespace->area.on_screen = TRUE; - freespace->area._resize = resize_freespace; - freespace->area._compute_desired_size = freespace_area_compute_desired_size; - } - } + for (size_t k = 0; k < strlen(panel_items_order); k++) { + if (panel_items_order[k] == 'F') { + FreeSpace *freespace = (FreeSpace *)calloc(1, sizeof(FreeSpace)); + panel->freespace_list = g_list_append(panel->freespace_list, freespace); + if (!freespace->area.bg) + freespace->area.bg = &g_array_index(backgrounds, Background, 0); + freespace->area.parent = p; + freespace->area.panel = p; + snprintf(freespace->area.name, sizeof(freespace->area.name), "Freespace"); + freespace->area.size_mode = LAYOUT_FIXED; + freespace->area.resize_needed = 1; + freespace->area.on_screen = TRUE; + freespace->area._resize = resize_freespace; + freespace->area._compute_desired_size = freespace_area_compute_desired_size; + } + } } void cleanup_freespace(Panel *panel) { - if (panel->freespace_list) - g_list_free_full(panel->freespace_list, free); - panel->freespace_list = NULL; + if (panel->freespace_list) + g_list_free_full(panel->freespace_list, free); + panel->freespace_list = NULL; } int freespace_get_max_size(Panel *p) { - if (panel_shrink) - return 0; - // Get space used by every element except the freespace - int size = 0; - int spacers = 0; - for (GList *walk = p->area.children; walk; walk = g_list_next(walk)) { - Area *a = (Area *)walk->data; + if (panel_shrink) + return 0; + // Get space used by every element except the freespace + int size = 0; + int spacers = 0; + for (GList *walk = p->area.children; walk; walk = g_list_next(walk)) { + Area *a = (Area *)walk->data; - if (!a->on_screen) - continue; - if (a->_resize == resize_freespace) { - spacers++; - continue; - } + if (!a->on_screen) + continue; + if (a->_resize == resize_freespace) { + spacers++; + continue; + } - if (panel_horizontal) - size += a->width + p->area.paddingx; - else - size += a->height + p->area.paddingy; - } + if (panel_horizontal) + size += a->width + p->area.paddingx; + else + size += a->height + p->area.paddingy; + } - if (panel_horizontal) - size = p->area.width - size - left_right_border_width(&p->area) - p->area.paddingxlr; - else - size = p->area.height - size - top_bottom_border_width(&p->area) - p->area.paddingxlr; + if (panel_horizontal) + size = p->area.width - size - left_right_border_width(&p->area) - p->area.paddingxlr; + else + size = p->area.height - size - top_bottom_border_width(&p->area) - p->area.paddingxlr; - return size / spacers; + return size / spacers; } int freespace_area_compute_desired_size(void *obj) { - FreeSpace *freespace = (FreeSpace *) obj; - return freespace_get_max_size((Panel *)freespace->area.panel); + FreeSpace *freespace = (FreeSpace *)obj; + return freespace_get_max_size((Panel *)freespace->area.panel); } gboolean resize_freespace(void *obj) { - FreeSpace *freespace = (FreeSpace *)obj; - Panel *panel = (Panel *)freespace->area.panel; - if (!freespace->area.on_screen) - return FALSE; + FreeSpace *freespace = (FreeSpace *)obj; + Panel *panel = (Panel *)freespace->area.panel; + if (!freespace->area.on_screen) + return FALSE; - int old_size = panel_horizontal ? freespace->area.width : freespace->area.height; - int size = freespace_get_max_size(panel); - if (old_size == size) - return FALSE; + int old_size = panel_horizontal ? freespace->area.width : freespace->area.height; + int size = freespace_get_max_size(panel); + if (old_size == size) + return FALSE; - if (panel_horizontal) { - freespace->area.width = size; - } else { - freespace->area.height = size; - } + if (panel_horizontal) { + freespace->area.width = size; + } else { + freespace->area.height = size; + } - schedule_redraw(&freespace->area); - schedule_panel_redraw(); - return TRUE; + schedule_redraw(&freespace->area); + schedule_panel_redraw(); + return TRUE; }
M src/freespace/freespace.hsrc/freespace/freespace.h

@@ -9,7 +9,7 @@ #include "common.h"

#include "area.h" typedef struct FreeSpace { - Area area; + Area area; } FreeSpace; struct Panel;
M src/launcher/apps-common.csrc/launcher/apps-common.c

@@ -30,280 +30,280 @@ #include <strings.h>

static gint compare_strings(gconstpointer a, gconstpointer b) { - return strnatcasecmp((const char *)a, (const char *)b); + return strnatcasecmp((const char *)a, (const char *)b); } int parse_dektop_line(char *line, char **key, char **value) { - char *p; - int found = 0; - *key = line; - for (p = line; *p; p++) { - if (*p == '=') { - *value = p + 1; - *p = 0; - found = 1; - break; - } - } - if (!found) - return 0; - if (found && (strlen(*key) == 0 || strlen(*value) == 0)) - return 0; - return 1; + char *p; + int found = 0; + *key = line; + for (p = line; *p; p++) { + if (*p == '=') { + *value = p + 1; + *p = 0; + found = 1; + break; + } + } + if (!found) + return 0; + if (found && (strlen(*key) == 0 || strlen(*value) == 0)) + return 0; + return 1; } void expand_exec(DesktopEntry *entry, const char *path) { - // Expand % in exec - // %i -> --icon Icon - // %c -> Name - // %k -> path - if (entry->exec) { - char *exec2 = calloc(strlen(entry->exec) + (entry->name ? strlen(entry->name) : 1) + - (entry->icon ? strlen(entry->icon) : 1) + 100, - 1); - char *p, *q; - // p will never point to an escaped char - for (p = entry->exec, q = exec2; *p; p++, q++) { - *q = *p; // Copy - if (*p == '\\') { - p++, q++; - // Copy the escaped char - if (*p == '%') // For % we delete the backslash, i.e. write % over it - q--; - *q = *p; - if (!*p) - break; - continue; - } - if (*p == '%') { - p++; - if (!*p) - break; - if (*p == 'i' && entry->icon != NULL) { - sprintf(q, "--icon '%s'", entry->icon); - q += strlen("--icon ''"); - q += strlen(entry->icon); - q--; // To balance the q++ in the for - } else if (*p == 'c' && entry->name != NULL) { - sprintf(q, "'%s'", entry->name); - q += strlen("''"); - q += strlen(entry->name); - q--; // To balance the q++ in the for - } else if (*p == 'c') { - sprintf(q, "'%s'", path); - q += strlen("''"); - q += strlen(path); - q--; // To balance the q++ in the for - } else { - // We don't care about other expansions - q--; // Delete the last % from q - } - continue; - } - } - *q = '\0'; - free(entry->exec); - entry->exec = exec2; - } + // Expand % in exec + // %i -> --icon Icon + // %c -> Name + // %k -> path + if (entry->exec) { + char *exec2 = calloc(strlen(entry->exec) + (entry->name ? strlen(entry->name) : 1) + + (entry->icon ? strlen(entry->icon) : 1) + 100, + 1); + char *p, *q; + // p will never point to an escaped char + for (p = entry->exec, q = exec2; *p; p++, q++) { + *q = *p; // Copy + if (*p == '\\') { + p++, q++; + // Copy the escaped char + if (*p == '%') // For % we delete the backslash, i.e. write % over it + q--; + *q = *p; + if (!*p) + break; + continue; + } + if (*p == '%') { + p++; + if (!*p) + break; + if (*p == 'i' && entry->icon != NULL) { + sprintf(q, "--icon '%s'", entry->icon); + q += strlen("--icon ''"); + q += strlen(entry->icon); + q--; // To balance the q++ in the for + } else if (*p == 'c' && entry->name != NULL) { + sprintf(q, "'%s'", entry->name); + q += strlen("''"); + q += strlen(entry->name); + q--; // To balance the q++ in the for + } else if (*p == 'c') { + sprintf(q, "'%s'", path); + q += strlen("''"); + q += strlen(path); + q--; // To balance the q++ in the for + } else { + // We don't care about other expansions + q--; // Delete the last % from q + } + continue; + } + } + *q = '\0'; + free(entry->exec); + entry->exec = exec2; + } } gboolean read_desktop_file_full_path(const char *path, DesktopEntry *entry) { - entry->name = entry->generic_name = entry->icon = entry->exec = entry->cwd = NULL; - entry->hidden_from_menus = FALSE; + entry->name = entry->generic_name = entry->icon = entry->exec = entry->cwd = NULL; + entry->hidden_from_menus = FALSE; - FILE *fp = fopen(path, "rt"); - if (fp == NULL) { - fprintf(stderr, "Could not open file %s\n", path); - return FALSE; - } + FILE *fp = fopen(path, "rt"); + if (fp == NULL) { + fprintf(stderr, "Could not open file %s\n", path); + return FALSE; + } - const gchar **languages = (const gchar **)g_get_language_names(); - // lang_index is the index of the language for the best Name key in the language vector - // lang_index_default is a constant that encodes the Name key without a language - int lang_index_default = 1; + const gchar **languages = (const gchar **)g_get_language_names(); + // lang_index is the index of the language for the best Name key in the language vector + // lang_index_default is a constant that encodes the Name key without a language + int lang_index_default = 1; #define LANG_DBG 0 - if (LANG_DBG) - printf("Languages:"); - for (int i = 0; languages[i]; i++) { - lang_index_default = i + 1; - if (LANG_DBG) - printf(" %s", languages[i]); - } - if (LANG_DBG) - printf("\n"); - // we currently do not know about any Name key at all, so use an invalid index - int lang_index_name = lang_index_default + 1; - int lang_index_generic_name = lang_index_default + 1; + if (LANG_DBG) + printf("Languages:"); + for (int i = 0; languages[i]; i++) { + lang_index_default = i + 1; + if (LANG_DBG) + printf(" %s", languages[i]); + } + if (LANG_DBG) + printf("\n"); + // we currently do not know about any Name key at all, so use an invalid index + int lang_index_name = lang_index_default + 1; + int lang_index_generic_name = lang_index_default + 1; - gboolean inside_desktop_entry = 0; - char *line = NULL; - size_t line_size; - while (getline(&line, &line_size, fp) >= 0) { - int len = strlen(line); - if (len == 0) - continue; - if (line[len - 1] == '\n') - line[len - 1] = '\0'; - if (line[0] == '[') { - inside_desktop_entry = (strcmp(line, "[Desktop Entry]") == 0); - } - char *key, *value; - if (inside_desktop_entry && parse_dektop_line(line, &key, &value)) { - if (strstr(key, "Name") == key) { - if (strcmp(key, "Name") == 0 && lang_index_name > lang_index_default) { - entry->name = strdup(value); - lang_index_name = lang_index_default; - } else { - for (int i = 0; languages[i] && i < lang_index_name; i++) { - gchar *localized_key = g_strdup_printf("Name[%s]", languages[i]); - if (strcmp(key, localized_key) == 0) { - if (entry->name) - free(entry->name); - entry->name = strdup(value); - lang_index_name = i; - } - g_free(localized_key); - } - } - } else if (strstr(key, "GenericName") == key) { - if (strcmp(key, "GenericName") == 0 && lang_index_generic_name > lang_index_default) { - entry->generic_name = strdup(value); - lang_index_generic_name = lang_index_default; - } else { - for (int i = 0; languages[i] && i < lang_index_generic_name; i++) { - gchar *localized_key = g_strdup_printf("GenericName[%s]", languages[i]); - if (strcmp(key, localized_key) == 0) { - if (entry->generic_name) - free(entry->generic_name); - entry->generic_name = strdup(value); - lang_index_generic_name = i; - } - g_free(localized_key); - } - } - } else if (!entry->exec && strcmp(key, "Exec") == 0) { - entry->exec = strdup(value); - } else if (!entry->cwd && strcmp(key, "Path") == 0) { - entry->cwd = strdup(value); - } else if (!entry->icon && strcmp(key, "Icon") == 0) { - entry->icon = strdup(value); - } else if (strcmp(key, "NoDisplay") == 0) { - entry->hidden_from_menus = strcasecmp(value, "true") == 0; - } - } - } - fclose(fp); - // From this point: - // entry->name, entry->generic_name, entry->icon, entry->exec will never be empty strings (can be NULL though) + gboolean inside_desktop_entry = 0; + char *line = NULL; + size_t line_size; + while (getline(&line, &line_size, fp) >= 0) { + int len = strlen(line); + if (len == 0) + continue; + if (line[len - 1] == '\n') + line[len - 1] = '\0'; + if (line[0] == '[') { + inside_desktop_entry = (strcmp(line, "[Desktop Entry]") == 0); + } + char *key, *value; + if (inside_desktop_entry && parse_dektop_line(line, &key, &value)) { + if (strstr(key, "Name") == key) { + if (strcmp(key, "Name") == 0 && lang_index_name > lang_index_default) { + entry->name = strdup(value); + lang_index_name = lang_index_default; + } else { + for (int i = 0; languages[i] && i < lang_index_name; i++) { + gchar *localized_key = g_strdup_printf("Name[%s]", languages[i]); + if (strcmp(key, localized_key) == 0) { + if (entry->name) + free(entry->name); + entry->name = strdup(value); + lang_index_name = i; + } + g_free(localized_key); + } + } + } else if (strstr(key, "GenericName") == key) { + if (strcmp(key, "GenericName") == 0 && lang_index_generic_name > lang_index_default) { + entry->generic_name = strdup(value); + lang_index_generic_name = lang_index_default; + } else { + for (int i = 0; languages[i] && i < lang_index_generic_name; i++) { + gchar *localized_key = g_strdup_printf("GenericName[%s]", languages[i]); + if (strcmp(key, localized_key) == 0) { + if (entry->generic_name) + free(entry->generic_name); + entry->generic_name = strdup(value); + lang_index_generic_name = i; + } + g_free(localized_key); + } + } + } else if (!entry->exec && strcmp(key, "Exec") == 0) { + entry->exec = strdup(value); + } else if (!entry->cwd && strcmp(key, "Path") == 0) { + entry->cwd = strdup(value); + } else if (!entry->icon && strcmp(key, "Icon") == 0) { + entry->icon = strdup(value); + } else if (strcmp(key, "NoDisplay") == 0) { + entry->hidden_from_menus = strcasecmp(value, "true") == 0; + } + } + } + fclose(fp); + // From this point: + // entry->name, entry->generic_name, entry->icon, entry->exec will never be empty strings (can be NULL though) - expand_exec(entry, entry->path); + expand_exec(entry, entry->path); - free(line); - return entry->exec != NULL; + free(line); + return entry->exec != NULL; } gboolean read_desktop_file_from_dir(const char *path, const char *file_name, DesktopEntry *entry) { - gchar *full_path = g_build_filename(path, file_name, NULL); - if (read_desktop_file_full_path(full_path, entry)) { - g_free(full_path); - return TRUE; - } - free_and_null(entry->name); - free_and_null(entry->generic_name); - free_and_null(entry->icon); - free_and_null(entry->exec); - free_and_null(entry->cwd); + gchar *full_path = g_build_filename(path, file_name, NULL); + if (read_desktop_file_full_path(full_path, entry)) { + g_free(full_path); + return TRUE; + } + free_and_null(entry->name); + free_and_null(entry->generic_name); + free_and_null(entry->icon); + free_and_null(entry->exec); + free_and_null(entry->cwd); - GList *subdirs = NULL; + GList *subdirs = NULL; - GDir *d = g_dir_open(path, 0, NULL); - if (d) { - const gchar *name; - while ((name = g_dir_read_name(d))) { - gchar *child = g_build_filename(path, name, NULL); - if (g_file_test(child, G_FILE_TEST_IS_DIR)) { - subdirs = g_list_append(subdirs, child); - } else { - g_free(child); - } - } - g_dir_close(d); - } + GDir *d = g_dir_open(path, 0, NULL); + if (d) { + const gchar *name; + while ((name = g_dir_read_name(d))) { + gchar *child = g_build_filename(path, name, NULL); + if (g_file_test(child, G_FILE_TEST_IS_DIR)) { + subdirs = g_list_append(subdirs, child); + } else { + g_free(child); + } + } + g_dir_close(d); + } - subdirs = g_list_sort(subdirs, compare_strings); - gboolean found = FALSE; - for (GList *l = subdirs; l; l = g_list_next(l)) { - if (read_desktop_file_from_dir(l->data, file_name, entry)) { - found = TRUE; - break; - } - } + subdirs = g_list_sort(subdirs, compare_strings); + gboolean found = FALSE; + for (GList *l = subdirs; l; l = g_list_next(l)) { + if (read_desktop_file_from_dir(l->data, file_name, entry)) { + found = TRUE; + break; + } + } - for (GList *l = subdirs; l; l = g_list_next(l)) { - g_free(l->data); - } - g_list_free(subdirs); - g_free(full_path); + for (GList *l = subdirs; l; l = g_list_next(l)) { + g_free(l->data); + } + g_list_free(subdirs); + g_free(full_path); - return found; + return found; } gboolean read_desktop_file(const char *path, DesktopEntry *entry) { - entry->path = strdup(path); - entry->name = entry->generic_name = entry->icon = entry->exec = entry->cwd = NULL; + entry->path = strdup(path); + entry->name = entry->generic_name = entry->icon = entry->exec = entry->cwd = NULL; - if (strchr(path, '/')) - return read_desktop_file_full_path(path, entry); - for (const GSList *location = get_apps_locations(); location; location = g_slist_next(location)) { - if (read_desktop_file_from_dir(location->data, path, entry)) - return TRUE; - } - return FALSE; + if (strchr(path, '/')) + return read_desktop_file_full_path(path, entry); + for (const GSList *location = get_apps_locations(); location; location = g_slist_next(location)) { + if (read_desktop_file_from_dir(location->data, path, entry)) + return TRUE; + } + return FALSE; } void free_desktop_entry(DesktopEntry *entry) { - free_and_null(entry->name); - free_and_null(entry->generic_name); - free_and_null(entry->icon); - free_and_null(entry->exec); - free_and_null(entry->path); - free_and_null(entry->cwd); + free_and_null(entry->name); + free_and_null(entry->generic_name); + free_and_null(entry->icon); + free_and_null(entry->exec); + free_and_null(entry->path); + free_and_null(entry->cwd); } void test_read_desktop_file() { - fprintf(stdout, "\033[1;33m"); - DesktopEntry entry; - read_desktop_file("/usr/share/applications/firefox.desktop", &entry); - printf("Name:%s GenericName:%s Icon:%s Exec:%s\n", entry.name, entry.generic_name, entry.icon, entry.exec); - fprintf(stdout, "\033[0m"); + fprintf(stdout, "\033[1;33m"); + DesktopEntry entry; + read_desktop_file("/usr/share/applications/firefox.desktop", &entry); + printf("Name:%s GenericName:%s Icon:%s Exec:%s\n", entry.name, entry.generic_name, entry.icon, entry.exec); + fprintf(stdout, "\033[0m"); } GSList *apps_locations = NULL; // Do not free the result. const GSList *get_apps_locations() { - if (apps_locations) - return apps_locations; + if (apps_locations) + return apps_locations; - apps_locations = load_locations_from_env(apps_locations, "XDG_DATA_HOME", "applications", NULL); + apps_locations = load_locations_from_env(apps_locations, "XDG_DATA_HOME", "applications", NULL); - apps_locations = - g_slist_append(apps_locations, g_build_filename(g_get_home_dir(), ".local/share/applications", NULL)); + apps_locations = + g_slist_append(apps_locations, g_build_filename(g_get_home_dir(), ".local/share/applications", NULL)); - apps_locations = load_locations_from_env(apps_locations, "XDG_DATA_DIRS", "applications", NULL); + apps_locations = load_locations_from_env(apps_locations, "XDG_DATA_DIRS", "applications", NULL); - apps_locations = g_slist_append(apps_locations, g_strdup("/usr/local/share/applications")); - apps_locations = g_slist_append(apps_locations, g_strdup("/usr/share/applications")); - apps_locations = g_slist_append(apps_locations, g_strdup("/opt/share/applications")); + apps_locations = g_slist_append(apps_locations, g_strdup("/usr/local/share/applications")); + apps_locations = g_slist_append(apps_locations, g_strdup("/usr/share/applications")); + apps_locations = g_slist_append(apps_locations, g_strdup("/opt/share/applications")); - apps_locations = slist_remove_duplicates(apps_locations, g_str_equal, g_free); + apps_locations = slist_remove_duplicates(apps_locations, g_str_equal, g_free); - return apps_locations; + return apps_locations; }
M src/launcher/apps-common.hsrc/launcher/apps-common.h

@@ -10,13 +10,13 @@

#include <glib.h> typedef struct DesktopEntry { - char *name; - char *generic_name; - char *exec; - char *icon; - char *path; - char *cwd; - gboolean hidden_from_menus; + char *name; + char *generic_name; + char *exec; + char *icon; + char *path; + char *cwd; + gboolean hidden_from_menus; } DesktopEntry; // Parses a line of the form "key = value". Modifies the line.
M src/launcher/icon-theme-common.csrc/launcher/icon-theme-common.c

@@ -33,750 +33,750 @@ #define ICON_DIR_TYPE_SCALABLE 0

#define ICON_DIR_TYPE_FIXED 1 #define ICON_DIR_TYPE_THRESHOLD 2 typedef struct IconThemeDir { - char *name; - int size; - int type; - int max_size; - int min_size; - int threshold; + char *name; + int size; + int type; + int max_size; + int min_size; + int threshold; } IconThemeDir; int parse_theme_line(char *line, char **key, char **value) { - return parse_dektop_line(line, key, value); + return parse_dektop_line(line, key, value); } GSList *icon_locations = NULL; // Do not free the result. const GSList *get_icon_locations() { - if (icon_locations) - return icon_locations; + if (icon_locations) + return icon_locations; - icon_locations = load_locations_from_env(icon_locations, "XDG_DATA_HOME", ".icons", NULL); + icon_locations = load_locations_from_env(icon_locations, "XDG_DATA_HOME", ".icons", NULL); - icon_locations = g_slist_append(icon_locations, g_build_filename(g_get_home_dir(), ".icons", NULL)); - icon_locations = g_slist_append(icon_locations, g_build_filename(g_get_home_dir(), ".local/share/icons", NULL)); + icon_locations = g_slist_append(icon_locations, g_build_filename(g_get_home_dir(), ".icons", NULL)); + icon_locations = g_slist_append(icon_locations, g_build_filename(g_get_home_dir(), ".local/share/icons", NULL)); - icon_locations = load_locations_from_env(icon_locations, "XDG_DATA_DIRS", ".icons", ".pixmaps", NULL); + icon_locations = load_locations_from_env(icon_locations, "XDG_DATA_DIRS", ".icons", ".pixmaps", NULL); - icon_locations = g_slist_append(icon_locations, g_strdup("/usr/local/share/icons")); - icon_locations = g_slist_append(icon_locations, g_strdup("/usr/local/share/pixmaps")); - icon_locations = g_slist_append(icon_locations, g_strdup("/usr/share/icons")); - icon_locations = g_slist_append(icon_locations, g_strdup("/usr/share/pixmaps")); - icon_locations = g_slist_append(icon_locations, g_strdup("/opt/share/icons")); - icon_locations = g_slist_append(icon_locations, g_strdup("/opt/share/pixmaps")); + icon_locations = g_slist_append(icon_locations, g_strdup("/usr/local/share/icons")); + icon_locations = g_slist_append(icon_locations, g_strdup("/usr/local/share/pixmaps")); + icon_locations = g_slist_append(icon_locations, g_strdup("/usr/share/icons")); + icon_locations = g_slist_append(icon_locations, g_strdup("/usr/share/pixmaps")); + icon_locations = g_slist_append(icon_locations, g_strdup("/opt/share/icons")); + icon_locations = g_slist_append(icon_locations, g_strdup("/opt/share/pixmaps")); - icon_locations = slist_remove_duplicates(icon_locations, g_str_equal, g_free); + icon_locations = slist_remove_duplicates(icon_locations, g_str_equal, g_free); - return icon_locations; + return icon_locations; } IconTheme *make_theme(const char *name) { - IconTheme *theme = calloc(1, sizeof(IconTheme)); - theme->name = strdup(name); - theme->list_inherits = NULL; - theme->list_directories = NULL; - return theme; + IconTheme *theme = calloc(1, sizeof(IconTheme)); + theme->name = strdup(name); + theme->list_inherits = NULL; + theme->list_directories = NULL; + return theme; } // TODO Use UTF8 when parsing the file IconTheme *load_theme_from_index(const char *file_name, const char *name) { - IconTheme *theme; - FILE *f; - char *line = NULL; - size_t line_size; + IconTheme *theme; + FILE *f; + char *line = NULL; + size_t line_size; - if ((f = fopen(file_name, "rt")) == NULL) { - fprintf(stderr, "Could not open theme '%s'\n", file_name); - return NULL; - } + if ((f = fopen(file_name, "rt")) == NULL) { + fprintf(stderr, "Could not open theme '%s'\n", file_name); + return NULL; + } - theme = make_theme(name); + theme = make_theme(name); - IconThemeDir *current_dir = NULL; - int inside_header = 1; - while (getline(&line, &line_size, f) >= 0) { - char *key, *value; + IconThemeDir *current_dir = NULL; + int inside_header = 1; + while (getline(&line, &line_size, f) >= 0) { + char *key, *value; - int line_len = strlen(line); - if (line_len >= 1) { - if (line[line_len - 1] == '\n') { - line[line_len - 1] = '\0'; - line_len--; - } - } + int line_len = strlen(line); + if (line_len >= 1) { + if (line[line_len - 1] == '\n') { + line[line_len - 1] = '\0'; + line_len--; + } + } - if (line_len == 0) - continue; + if (line_len == 0) + continue; - if (inside_header) { - if (parse_theme_line(line, &key, &value)) { - if (strcmp(key, "Inherits") == 0) { - // value is like oxygen,wood,default - char *token; - token = strtok(value, ",\n"); - while (token != NULL) { - theme->list_inherits = g_slist_append(theme->list_inherits, strdup(token)); - token = strtok(NULL, ",\n"); - } - } else if (strcmp(key, "Directories") == 0) { - // value is like 48x48/apps,48x48/mimetypes,32x32/apps,scalable/apps,scalable/mimetypes - char *token; - token = strtok(value, ",\n"); - while (token != NULL) { - IconThemeDir *dir = calloc(1, sizeof(IconThemeDir)); - dir->name = strdup(token); - dir->max_size = dir->min_size = dir->size = -1; - dir->type = ICON_DIR_TYPE_THRESHOLD; - dir->threshold = 2; - theme->list_directories = g_slist_append(theme->list_directories, dir); - token = strtok(NULL, ",\n"); - } - } - } - } else if (current_dir != NULL) { - if (parse_theme_line(line, &key, &value)) { - if (strcmp(key, "Size") == 0) { - // value is like 24 - sscanf(value, "%d", &current_dir->size); - if (current_dir->max_size == -1) - current_dir->max_size = current_dir->size; - if (current_dir->min_size == -1) - current_dir->min_size = current_dir->size; - } else if (strcmp(key, "MaxSize") == 0) { - // value is like 24 - sscanf(value, "%d", &current_dir->max_size); - } else if (strcmp(key, "MinSize") == 0) { - // value is like 24 - sscanf(value, "%d", &current_dir->min_size); - } else if (strcmp(key, "Threshold") == 0) { - // value is like 2 - sscanf(value, "%d", &current_dir->threshold); - } else if (strcmp(key, "Type") == 0) { - // value is Fixed, Scalable or Threshold : default to scalable for unknown Type. - if (strcmp(value, "Fixed") == 0) { - current_dir->type = ICON_DIR_TYPE_FIXED; - } else if (strcmp(value, "Threshold") == 0) { - current_dir->type = ICON_DIR_TYPE_THRESHOLD; - } else { - current_dir->type = ICON_DIR_TYPE_SCALABLE; - } - } - } - } + if (inside_header) { + if (parse_theme_line(line, &key, &value)) { + if (strcmp(key, "Inherits") == 0) { + // value is like oxygen,wood,default + char *token; + token = strtok(value, ",\n"); + while (token != NULL) { + theme->list_inherits = g_slist_append(theme->list_inherits, strdup(token)); + token = strtok(NULL, ",\n"); + } + } else if (strcmp(key, "Directories") == 0) { + // value is like 48x48/apps,48x48/mimetypes,32x32/apps,scalable/apps,scalable/mimetypes + char *token; + token = strtok(value, ",\n"); + while (token != NULL) { + IconThemeDir *dir = calloc(1, sizeof(IconThemeDir)); + dir->name = strdup(token); + dir->max_size = dir->min_size = dir->size = -1; + dir->type = ICON_DIR_TYPE_THRESHOLD; + dir->threshold = 2; + theme->list_directories = g_slist_append(theme->list_directories, dir); + token = strtok(NULL, ",\n"); + } + } + } + } else if (current_dir != NULL) { + if (parse_theme_line(line, &key, &value)) { + if (strcmp(key, "Size") == 0) { + // value is like 24 + sscanf(value, "%d", &current_dir->size); + if (current_dir->max_size == -1) + current_dir->max_size = current_dir->size; + if (current_dir->min_size == -1) + current_dir->min_size = current_dir->size; + } else if (strcmp(key, "MaxSize") == 0) { + // value is like 24 + sscanf(value, "%d", &current_dir->max_size); + } else if (strcmp(key, "MinSize") == 0) { + // value is like 24 + sscanf(value, "%d", &current_dir->min_size); + } else if (strcmp(key, "Threshold") == 0) { + // value is like 2 + sscanf(value, "%d", &current_dir->threshold); + } else if (strcmp(key, "Type") == 0) { + // value is Fixed, Scalable or Threshold : default to scalable for unknown Type. + if (strcmp(value, "Fixed") == 0) { + current_dir->type = ICON_DIR_TYPE_FIXED; + } else if (strcmp(value, "Threshold") == 0) { + current_dir->type = ICON_DIR_TYPE_THRESHOLD; + } else { + current_dir->type = ICON_DIR_TYPE_SCALABLE; + } + } + } + } - if (line[0] == '[' && line[line_len - 1] == ']' && strcmp(line, "[Icon Theme]") != 0) { - inside_header = 0; - current_dir = NULL; - line[line_len - 1] = '\0'; - char *dir_name = line + 1; - GSList *dir_item = theme->list_directories; - while (dir_item != NULL) { - IconThemeDir *dir = dir_item->data; - if (strcmp(dir->name, dir_name) == 0) { - current_dir = dir; - break; - } - dir_item = g_slist_next(dir_item); - } - } - } - fclose(f); + if (line[0] == '[' && line[line_len - 1] == ']' && strcmp(line, "[Icon Theme]") != 0) { + inside_header = 0; + current_dir = NULL; + line[line_len - 1] = '\0'; + char *dir_name = line + 1; + GSList *dir_item = theme->list_directories; + while (dir_item != NULL) { + IconThemeDir *dir = dir_item->data; + if (strcmp(dir->name, dir_name) == 0) { + current_dir = dir; + break; + } + dir_item = g_slist_next(dir_item); + } + } + } + fclose(f); - free(line); - return theme; + free(line); + return theme; } void load_theme_from_fs_dir(IconTheme *theme, const char *dir_name) { - gchar *file_name = g_build_filename(dir_name, "index.theme", NULL); - if (g_file_test(file_name, G_FILE_TEST_EXISTS)) { - g_free(file_name); - return; - } + gchar *file_name = g_build_filename(dir_name, "index.theme", NULL); + if (g_file_test(file_name, G_FILE_TEST_EXISTS)) { + g_free(file_name); + return; + } - GDir *d = g_dir_open(dir_name, 0, NULL); - if (d) { - const gchar *size_name; - while ((size_name = g_dir_read_name(d))) { - gchar *full_size_name = g_build_filename(dir_name, size_name, NULL); - if (g_file_test(file_name, G_FILE_TEST_IS_DIR)) { - int size, size2; - if ((sscanf(size_name, "%dx%d", &size, &size2) == 2 && size == size2) || - (sscanf(size_name, "%d", &size) == 1)) { - GDir *dSize = g_dir_open(full_size_name, 0, NULL); - if (dSize) { - const gchar *subdir_name; - while ((subdir_name = g_dir_read_name(dSize))) { - IconThemeDir *dir = calloc(1, sizeof(IconThemeDir)); - // value is like 48x48/apps - gchar *value = g_build_filename(size_name, subdir_name, NULL); - dir->name = strdup(value); - g_free(value); - dir->max_size = dir->min_size = dir->size = size; - dir->type = ICON_DIR_TYPE_FIXED; - theme->list_directories = g_slist_append(theme->list_directories, dir); - } - g_dir_close(dSize); - } - } - } - g_free(full_size_name); - } - g_dir_close(d); - } + GDir *d = g_dir_open(dir_name, 0, NULL); + if (d) { + const gchar *size_name; + while ((size_name = g_dir_read_name(d))) { + gchar *full_size_name = g_build_filename(dir_name, size_name, NULL); + if (g_file_test(file_name, G_FILE_TEST_IS_DIR)) { + int size, size2; + if ((sscanf(size_name, "%dx%d", &size, &size2) == 2 && size == size2) || + (sscanf(size_name, "%d", &size) == 1)) { + GDir *dSize = g_dir_open(full_size_name, 0, NULL); + if (dSize) { + const gchar *subdir_name; + while ((subdir_name = g_dir_read_name(dSize))) { + IconThemeDir *dir = calloc(1, sizeof(IconThemeDir)); + // value is like 48x48/apps + gchar *value = g_build_filename(size_name, subdir_name, NULL); + dir->name = strdup(value); + g_free(value); + dir->max_size = dir->min_size = dir->size = size; + dir->type = ICON_DIR_TYPE_FIXED; + theme->list_directories = g_slist_append(theme->list_directories, dir); + } + g_dir_close(dSize); + } + } + } + g_free(full_size_name); + } + g_dir_close(d); + } } IconTheme *load_theme_from_fs(const char *name, IconTheme *theme) { - gchar *dir_name = NULL; - for (const GSList *location = get_icon_locations(); location; location = g_slist_next(location)) { - gchar *path = (gchar *)location->data; - dir_name = g_build_filename(path, name, NULL); - if (g_file_test(dir_name, G_FILE_TEST_IS_DIR)) { - if (!theme) { - theme = make_theme(name); - } - load_theme_from_fs_dir(theme, dir_name); - } - g_free(dir_name); - dir_name = NULL; - } + gchar *dir_name = NULL; + for (const GSList *location = get_icon_locations(); location; location = g_slist_next(location)) { + gchar *path = (gchar *)location->data; + dir_name = g_build_filename(path, name, NULL); + if (g_file_test(dir_name, G_FILE_TEST_IS_DIR)) { + if (!theme) { + theme = make_theme(name); + } + load_theme_from_fs_dir(theme, dir_name); + } + g_free(dir_name); + dir_name = NULL; + } - return theme; + return theme; } IconTheme *load_theme(const char *name) { - // Look for name/index.theme in $HOME/.icons, /usr/share/icons, /usr/share/pixmaps (stop at the first found) - // Parse index.theme -> list of IconThemeDir with attributes - // Return IconTheme* + // Look for name/index.theme in $HOME/.icons, /usr/share/icons, /usr/share/pixmaps (stop at the first found) + // Parse index.theme -> list of IconThemeDir with attributes + // Return IconTheme* - if (name == NULL) - return NULL; + if (name == NULL) + return NULL; - gchar *file_name = NULL; - for (const GSList *location = get_icon_locations(); location; location = g_slist_next(location)) { - gchar *path = (gchar *)location->data; - file_name = g_build_filename(path, name, "index.theme", NULL); - if (!g_file_test(file_name, G_FILE_TEST_EXISTS)) { - g_free(file_name); - file_name = NULL; - } - if (file_name) - break; - } + gchar *file_name = NULL; + for (const GSList *location = get_icon_locations(); location; location = g_slist_next(location)) { + gchar *path = (gchar *)location->data; + file_name = g_build_filename(path, name, "index.theme", NULL); + if (!g_file_test(file_name, G_FILE_TEST_EXISTS)) { + g_free(file_name); + file_name = NULL; + } + if (file_name) + break; + } - IconTheme *theme = NULL; - if (file_name) { - theme = load_theme_from_index(file_name, name); - g_free(file_name); - } + IconTheme *theme = NULL; + if (file_name) { + theme = load_theme_from_index(file_name, name); + g_free(file_name); + } - return load_theme_from_fs(name, theme); + return load_theme_from_fs(name, theme); } void free_icon_theme(IconTheme *theme) { - if (!theme) - return; - free(theme->name); - theme->name = NULL; - free(theme->description); - theme->description = NULL; - for (GSList *l_inherits = theme->list_inherits; l_inherits; l_inherits = l_inherits->next) { - free(l_inherits->data); - } - g_slist_free(theme->list_inherits); - theme->list_inherits = NULL; - for (GSList *l_dir = theme->list_directories; l_dir; l_dir = l_dir->next) { - IconThemeDir *dir = (IconThemeDir *)l_dir->data; - free(dir->name); - free(l_dir->data); - } - g_slist_free(theme->list_directories); - theme->list_directories = NULL; + if (!theme) + return; + free(theme->name); + theme->name = NULL; + free(theme->description); + theme->description = NULL; + for (GSList *l_inherits = theme->list_inherits; l_inherits; l_inherits = l_inherits->next) { + free(l_inherits->data); + } + g_slist_free(theme->list_inherits); + theme->list_inherits = NULL; + for (GSList *l_dir = theme->list_directories; l_dir; l_dir = l_dir->next) { + IconThemeDir *dir = (IconThemeDir *)l_dir->data; + free(dir->name); + free(l_dir->data); + } + g_slist_free(theme->list_directories); + theme->list_directories = NULL; } void free_themes(IconThemeWrapper *wrapper) { - if (!wrapper) - return; - free(wrapper->icon_theme_name); - for (GSList *l = wrapper->themes; l; l = l->next) { - IconTheme *theme = (IconTheme *)l->data; - free_icon_theme(theme); - free(theme); - } - g_slist_free(wrapper->themes); - for (GSList *l = wrapper->themes_fallback; l; l = l->next) { - IconTheme *theme = (IconTheme *)l->data; - free_icon_theme(theme); - free(theme); - } - g_slist_free(wrapper->themes_fallback); - g_slist_free_full(wrapper->_queued, free); - free_cache(&wrapper->_cache); - free(wrapper); + if (!wrapper) + return; + free(wrapper->icon_theme_name); + for (GSList *l = wrapper->themes; l; l = l->next) { + IconTheme *theme = (IconTheme *)l->data; + free_icon_theme(theme); + free(theme); + } + g_slist_free(wrapper->themes); + for (GSList *l = wrapper->themes_fallback; l; l = l->next) { + IconTheme *theme = (IconTheme *)l->data; + free_icon_theme(theme); + free(theme); + } + g_slist_free(wrapper->themes_fallback); + g_slist_free_full(wrapper->_queued, free); + free_cache(&wrapper->_cache); + free(wrapper); } void test_launcher_read_theme_file() { - fprintf(stdout, "\033[1;33m"); - IconTheme *theme = load_theme("oxygen"); - if (!theme) { - printf("Could not load theme\n"); - return; - } - printf("Loaded theme: %s\n", theme->name); - GSList *item = theme->list_inherits; - while (item != NULL) { - printf("Inherits:%s\n", (char *)item->data); - item = g_slist_next(item); - } - item = theme->list_directories; - while (item != NULL) { - IconThemeDir *dir = item->data; - printf("Dir:%s Size=%d MinSize=%d MaxSize=%d Threshold=%d Type=%s\n", - dir->name, - dir->size, - dir->min_size, - dir->max_size, - dir->threshold, - dir->type == ICON_DIR_TYPE_FIXED ? "Fixed" : dir->type == ICON_DIR_TYPE_SCALABLE - ? "Scalable" - : dir->type == ICON_DIR_TYPE_THRESHOLD ? "Threshold" - : "?????"); - item = g_slist_next(item); - } - fprintf(stdout, "\033[0m"); + fprintf(stdout, "\033[1;33m"); + IconTheme *theme = load_theme("oxygen"); + if (!theme) { + printf("Could not load theme\n"); + return; + } + printf("Loaded theme: %s\n", theme->name); + GSList *item = theme->list_inherits; + while (item != NULL) { + printf("Inherits:%s\n", (char *)item->data); + item = g_slist_next(item); + } + item = theme->list_directories; + while (item != NULL) { + IconThemeDir *dir = item->data; + printf("Dir:%s Size=%d MinSize=%d MaxSize=%d Threshold=%d Type=%s\n", + dir->name, + dir->size, + dir->min_size, + dir->max_size, + dir->threshold, + dir->type == ICON_DIR_TYPE_FIXED ? "Fixed" : dir->type == ICON_DIR_TYPE_SCALABLE + ? "Scalable" + : dir->type == ICON_DIR_TYPE_THRESHOLD ? "Threshold" + : "?????"); + item = g_slist_next(item); + } + fprintf(stdout, "\033[0m"); } gboolean str_list_contains(const GSList *list, const char *value) { - const GSList *item = list; - while (item != NULL) { - if (g_str_equal(item->data, value)) { - return TRUE; - } - item = g_slist_next(item); - } - return FALSE; + const GSList *item = list; + while (item != NULL) { + if (g_str_equal(item->data, value)) { + return TRUE; + } + item = g_slist_next(item); + } + return FALSE; } void load_themes_helper(const char *name, GSList **themes, GSList **queued) { - if (str_list_contains(*queued, name)) - return; - GSList *queue = g_slist_append(NULL, strdup(name)); - *queued = g_slist_append(*queued, strdup(name)); + if (str_list_contains(*queued, name)) + return; + GSList *queue = g_slist_append(NULL, strdup(name)); + *queued = g_slist_append(*queued, strdup(name)); - // Load wrapper->themes - while (queue) { - char *queued_name = queue->data; - queue = g_slist_remove(queue, queued_name); + // Load wrapper->themes + while (queue) { + char *queued_name = queue->data; + queue = g_slist_remove(queue, queued_name); - fprintf(stderr, " '%s',", queued_name); - IconTheme *theme = load_theme(queued_name); - if (theme != NULL) { - *themes = g_slist_append(*themes, theme); + fprintf(stderr, " '%s',", queued_name); + IconTheme *theme = load_theme(queued_name); + if (theme != NULL) { + *themes = g_slist_append(*themes, theme); - GSList *item = theme->list_inherits; - int pos = 0; - while (item != NULL) { - char *parent = item->data; - if (!str_list_contains(*queued, parent)) { - queue = g_slist_insert(queue, strdup(parent), pos); - pos++; - *queued = g_slist_append(*queued, strdup(parent)); - } - item = g_slist_next(item); - } - } + GSList *item = theme->list_inherits; + int pos = 0; + while (item != NULL) { + char *parent = item->data; + if (!str_list_contains(*queued, parent)) { + queue = g_slist_insert(queue, strdup(parent), pos); + pos++; + *queued = g_slist_append(*queued, strdup(parent)); + } + item = g_slist_next(item); + } + } - free(queued_name); - } - fprintf(stderr, "\n"); + free(queued_name); + } + fprintf(stderr, "\n"); - // Free the queue - GSList *l; - for (l = queue; l; l = l->next) - free(l->data); - g_slist_free(queue); + // Free the queue + GSList *l; + for (l = queue; l; l = l->next) + free(l->data); + g_slist_free(queue); } void load_default_theme(IconThemeWrapper *wrapper) { - if (wrapper->_themes_loaded) - return; + if (wrapper->_themes_loaded) + return; - fprintf(stderr, GREEN "Loading icon theme %s:" RESET "\n", wrapper->icon_theme_name); + fprintf(stderr, GREEN "Loading icon theme %s:" RESET "\n", wrapper->icon_theme_name); - load_themes_helper(wrapper->icon_theme_name, &wrapper->themes, &wrapper->_queued); - load_themes_helper("hicolor", &wrapper->themes, &wrapper->_queued); + load_themes_helper(wrapper->icon_theme_name, &wrapper->themes, &wrapper->_queued); + load_themes_helper("hicolor", &wrapper->themes, &wrapper->_queued); - wrapper->_themes_loaded = TRUE; + wrapper->_themes_loaded = TRUE; } void load_fallbacks(IconThemeWrapper *wrapper) { - if (wrapper->_fallback_loaded) - return; + if (wrapper->_fallback_loaded) + return; - fprintf(stderr, RED "Loading additional icon themes (this means your icon theme is incomplete)..." RESET "\n"); + fprintf(stderr, RED "Loading additional icon themes (this means your icon theme is incomplete)..." RESET "\n"); - // Load wrapper->themes_fallback - const GSList *location; - for (location = get_icon_locations(); location; location = g_slist_next(location)) { - gchar *path = (gchar *)location->data; - GDir *d = g_dir_open(path, 0, NULL); - if (d) { - const gchar *name; - while ((name = g_dir_read_name(d))) { - gchar *file_name = g_build_filename(path, name, "index.theme", NULL); - if (g_file_test(file_name, G_FILE_TEST_EXISTS) && !g_file_test(file_name, G_FILE_TEST_IS_DIR)) { - load_themes_helper(name, &wrapper->themes_fallback, &wrapper->_queued); - } - g_free(file_name); - } - g_dir_close(d); - } - } + // Load wrapper->themes_fallback + const GSList *location; + for (location = get_icon_locations(); location; location = g_slist_next(location)) { + gchar *path = (gchar *)location->data; + GDir *d = g_dir_open(path, 0, NULL); + if (d) { + const gchar *name; + while ((name = g_dir_read_name(d))) { + gchar *file_name = g_build_filename(path, name, "index.theme", NULL); + if (g_file_test(file_name, G_FILE_TEST_EXISTS) && !g_file_test(file_name, G_FILE_TEST_IS_DIR)) { + load_themes_helper(name, &wrapper->themes_fallback, &wrapper->_queued); + } + g_free(file_name); + } + g_dir_close(d); + } + } - wrapper->_fallback_loaded = TRUE; + wrapper->_fallback_loaded = TRUE; } gchar *get_icon_cache_path() { - return g_build_filename(g_get_user_cache_dir(), "tint2", "icon.cache", NULL); + return g_build_filename(g_get_user_cache_dir(), "tint2", "icon.cache", NULL); } void load_icon_cache(IconThemeWrapper *wrapper) { - if (wrapper->_cache.loaded) - return; + if (wrapper->_cache.loaded) + return; - fprintf(stderr, GREEN "Loading icon theme cache..." RESET "\n"); + fprintf(stderr, GREEN "Loading icon theme cache..." RESET "\n"); - gchar *cache_path = get_icon_cache_path(); - load_cache(&wrapper->_cache, cache_path); - g_free(cache_path); + gchar *cache_path = get_icon_cache_path(); + load_cache(&wrapper->_cache, cache_path); + g_free(cache_path); } void save_icon_cache(IconThemeWrapper *wrapper) { - if (!wrapper || !wrapper->_cache.dirty) - return; + if (!wrapper || !wrapper->_cache.dirty) + return; - fprintf(stderr, GREEN "Saving icon theme cache..." RESET "\n"); - gchar *cache_path = get_icon_cache_path(); - save_cache(&wrapper->_cache, cache_path); - g_free(cache_path); + fprintf(stderr, GREEN "Saving icon theme cache..." RESET "\n"); + gchar *cache_path = get_icon_cache_path(); + save_cache(&wrapper->_cache, cache_path); + g_free(cache_path); } IconThemeWrapper *load_themes(const char *icon_theme_name) { - IconThemeWrapper *wrapper = calloc(1, sizeof(IconThemeWrapper)); + IconThemeWrapper *wrapper = calloc(1, sizeof(IconThemeWrapper)); - if (!icon_theme_name) { - fprintf(stderr, "Missing icon_theme_name theme, default to 'hicolor'.\n"); - icon_theme_name = "hicolor"; - } + if (!icon_theme_name) { + fprintf(stderr, "Missing icon_theme_name theme, default to 'hicolor'.\n"); + icon_theme_name = "hicolor"; + } - wrapper->icon_theme_name = strdup(icon_theme_name); + wrapper->icon_theme_name = strdup(icon_theme_name); - return wrapper; + return wrapper; } int directory_matches_size(IconThemeDir *dir, int size) { - if (dir->type == ICON_DIR_TYPE_FIXED) { - return dir->size == size; - } else if (dir->type == ICON_DIR_TYPE_SCALABLE) { - return dir->min_size <= size && size <= dir->max_size; - } else /*if (dir->type == ICON_DIR_TYPE_THRESHOLD)*/ { - return dir->size - dir->threshold <= size && size <= dir->size + dir->threshold; - } + if (dir->type == ICON_DIR_TYPE_FIXED) { + return dir->size == size; + } else if (dir->type == ICON_DIR_TYPE_SCALABLE) { + return dir->min_size <= size && size <= dir->max_size; + } else /*if (dir->type == ICON_DIR_TYPE_THRESHOLD)*/ { + return dir->size - dir->threshold <= size && size <= dir->size + dir->threshold; + } } int directory_size_distance(IconThemeDir *dir, int size) { - if (dir->type == ICON_DIR_TYPE_FIXED) { - return abs(dir->size - size); - } else if (dir->type == ICON_DIR_TYPE_SCALABLE) { - if (size < dir->min_size) { - return dir->min_size - size; - } else if (size > dir->max_size) { - return size - dir->max_size; - } else { - return 0; - } - } else /*if (dir->type == ICON_DIR_TYPE_THRESHOLD)*/ { - if (size < dir->size - dir->threshold) { - return dir->min_size - size; - } else if (size > dir->size + dir->threshold) { - return size - dir->max_size; - } else { - return 0; - } - } + if (dir->type == ICON_DIR_TYPE_FIXED) { + return abs(dir->size - size); + } else if (dir->type == ICON_DIR_TYPE_SCALABLE) { + if (size < dir->min_size) { + return dir->min_size - size; + } else if (size > dir->max_size) { + return size - dir->max_size; + } else { + return 0; + } + } else /*if (dir->type == ICON_DIR_TYPE_THRESHOLD)*/ { + if (size < dir->size - dir->threshold) { + return dir->min_size - size; + } else if (size > dir->size + dir->threshold) { + return size - dir->max_size; + } else { + return 0; + } + } } gint compare_theme_directories(gconstpointer a, gconstpointer b, gpointer size_query) { - int size = GPOINTER_TO_INT(size_query); - const IconThemeDir *da = (const IconThemeDir *)a; - const IconThemeDir *db = (const IconThemeDir *)b; - return abs(da->size - size) - abs(db->size - size); + int size = GPOINTER_TO_INT(size_query); + const IconThemeDir *da = (const IconThemeDir *)a; + const IconThemeDir *db = (const IconThemeDir *)b; + return abs(da->size - size) - abs(db->size - size); } #define DEBUG_ICON_SEARCH 0 char *get_icon_path_helper(GSList *themes, const char *icon_name, int size) { - if (icon_name == NULL) - return NULL; + if (icon_name == NULL) + return NULL; - // If the icon_name is already a path and the file exists, return it - if (strstr(icon_name, "/") == icon_name) { - if (g_file_test(icon_name, G_FILE_TEST_EXISTS)) - return strdup(icon_name); - else - return NULL; - } + // If the icon_name is already a path and the file exists, return it + if (strstr(icon_name, "/") == icon_name) { + if (g_file_test(icon_name, G_FILE_TEST_EXISTS)) + return strdup(icon_name); + else + return NULL; + } - const GSList *basenames = get_icon_locations(); - GSList *extensions = NULL; - extensions = g_slist_append(extensions, ".png"); - extensions = g_slist_append(extensions, ".xpm"); + const GSList *basenames = get_icon_locations(); + GSList *extensions = NULL; + extensions = g_slist_append(extensions, ".png"); + extensions = g_slist_append(extensions, ".xpm"); #ifdef HAVE_RSVG - extensions = g_slist_append(extensions, ".svg"); + extensions = g_slist_append(extensions, ".svg"); #endif - // if the icon name already contains one of the extensions (e.g. vlc.png instead of vlc) add a special entry - for (GSList *ext = extensions; ext; ext = g_slist_next(ext)) { - char *extension = (char *)ext->data; - if (strlen(icon_name) > strlen(extension) && - strcmp(extension, icon_name + strlen(icon_name) - strlen(extension)) == 0) { - extensions = g_slist_append(extensions, ""); - break; - } - } + // if the icon name already contains one of the extensions (e.g. vlc.png instead of vlc) add a special entry + for (GSList *ext = extensions; ext; ext = g_slist_next(ext)) { + char *extension = (char *)ext->data; + if (strlen(icon_name) > strlen(extension) && + strcmp(extension, icon_name + strlen(icon_name) - strlen(extension)) == 0) { + extensions = g_slist_append(extensions, ""); + break; + } + } - GSList *theme; + GSList *theme; - // Best size match - // Contrary to the freedesktop spec, we are not choosing the closest icon in size, but the next larger icon - // otherwise the quality is usually crap (for size 22, if you can choose 16 or 32, you're better with 32) - // We do fallback to the closest size if we cannot find a larger or equal icon + // Best size match + // Contrary to the freedesktop spec, we are not choosing the closest icon in size, but the next larger icon + // otherwise the quality is usually crap (for size 22, if you can choose 16 or 32, you're better with 32) + // We do fallback to the closest size if we cannot find a larger or equal icon - // These 3 variables are used for keeping the closest size match - int minimal_size = INT_MAX; - char *best_file_name = NULL; - GSList *best_file_theme = NULL; + // These 3 variables are used for keeping the closest size match + int minimal_size = INT_MAX; + char *best_file_name = NULL; + GSList *best_file_theme = NULL; - // These 3 variables are used for keeping the next larger match - int next_larger_size = -1; - char *next_larger = NULL; - GSList *next_larger_theme = NULL; + // These 3 variables are used for keeping the next larger match + int next_larger_size = -1; + char *next_larger = NULL; + GSList *next_larger_theme = NULL; - int file_name_size = 4096; - char *file_name = calloc(file_name_size, 1); + 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, - GINT_TO_POINTER(size)); - GSList *dir; - for (dir = ((IconTheme *)theme->data)->list_directories; dir; dir = g_slist_next(dir)) { - // Closest match - gboolean possible = directory_size_distance((IconThemeDir *)dir->data, size) < minimal_size && - (!best_file_theme ? TRUE : theme == best_file_theme); - // Next larger match - possible = possible || (((IconThemeDir *)dir->data)->size >= size && - (next_larger_size == -1 || ((IconThemeDir *)dir->data)->size < next_larger_size) && - (!next_larger_theme ? 1 : theme == next_larger_theme)); - if (!possible) - continue; - const GSList *base; - for (base = basenames; base; base = g_slist_next(base)) { - for (GSList *ext = extensions; ext; ext = g_slist_next(ext)) { - char *base_name = (char *)base->data; - char *theme_name = ((IconTheme *)theme->data)->name; - char *dir_name = ((IconThemeDir *)dir->data)->name; - char *extension = (char *)ext->data; - 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) - printf("checking %s\n", file_name); - if (g_file_test(file_name, G_FILE_TEST_EXISTS)) { - if (DEBUG_ICON_SEARCH) - printf("found: %s\n", file_name); - // Closest match - if (directory_size_distance((IconThemeDir *)dir->data, size) < minimal_size && - (!best_file_theme ? 1 : theme == best_file_theme)) { - if (best_file_name) { - free(best_file_name); - best_file_name = NULL; - } - best_file_name = strdup(file_name); - minimal_size = directory_size_distance((IconThemeDir *)dir->data, size); - best_file_theme = theme; - if (DEBUG_ICON_SEARCH) - printf("best_file_name = %s; minimal_size = %d\n", best_file_name, minimal_size); - } - // Next larger match - if (((IconThemeDir *)dir->data)->size >= size && - (next_larger_size == -1 || ((IconThemeDir *)dir->data)->size < next_larger_size) && - (!next_larger_theme ? 1 : theme == next_larger_theme)) { - if (next_larger) { - free(next_larger); - next_larger = NULL; - } - next_larger = strdup(file_name); - next_larger_size = ((IconThemeDir *)dir->data)->size; - next_larger_theme = theme; - if (DEBUG_ICON_SEARCH) - printf("next_larger = %s; next_larger_size = %d\n", next_larger, next_larger_size); - } - } - } - } - } - } - free(file_name); - file_name = NULL; - if (next_larger) { - g_slist_free(extensions); - free(best_file_name); - return next_larger; - } - if (best_file_name) { - g_slist_free(extensions); - return best_file_name; - } + 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, + GINT_TO_POINTER(size)); + GSList *dir; + for (dir = ((IconTheme *)theme->data)->list_directories; dir; dir = g_slist_next(dir)) { + // Closest match + gboolean possible = directory_size_distance((IconThemeDir *)dir->data, size) < minimal_size && + (!best_file_theme ? TRUE : theme == best_file_theme); + // Next larger match + possible = possible || (((IconThemeDir *)dir->data)->size >= size && + (next_larger_size == -1 || ((IconThemeDir *)dir->data)->size < next_larger_size) && + (!next_larger_theme ? 1 : theme == next_larger_theme)); + if (!possible) + continue; + const GSList *base; + for (base = basenames; base; base = g_slist_next(base)) { + for (GSList *ext = extensions; ext; ext = g_slist_next(ext)) { + char *base_name = (char *)base->data; + char *theme_name = ((IconTheme *)theme->data)->name; + char *dir_name = ((IconThemeDir *)dir->data)->name; + char *extension = (char *)ext->data; + 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) + printf("checking %s\n", file_name); + if (g_file_test(file_name, G_FILE_TEST_EXISTS)) { + if (DEBUG_ICON_SEARCH) + printf("found: %s\n", file_name); + // Closest match + if (directory_size_distance((IconThemeDir *)dir->data, size) < minimal_size && + (!best_file_theme ? 1 : theme == best_file_theme)) { + if (best_file_name) { + free(best_file_name); + best_file_name = NULL; + } + best_file_name = strdup(file_name); + minimal_size = directory_size_distance((IconThemeDir *)dir->data, size); + best_file_theme = theme; + if (DEBUG_ICON_SEARCH) + printf("best_file_name = %s; minimal_size = %d\n", best_file_name, minimal_size); + } + // Next larger match + if (((IconThemeDir *)dir->data)->size >= size && + (next_larger_size == -1 || ((IconThemeDir *)dir->data)->size < next_larger_size) && + (!next_larger_theme ? 1 : theme == next_larger_theme)) { + if (next_larger) { + free(next_larger); + next_larger = NULL; + } + next_larger = strdup(file_name); + next_larger_size = ((IconThemeDir *)dir->data)->size; + next_larger_theme = theme; + if (DEBUG_ICON_SEARCH) + printf("next_larger = %s; next_larger_size = %d\n", next_larger, next_larger_size); + } + } + } + } + } + } + free(file_name); + file_name = NULL; + if (next_larger) { + g_slist_free(extensions); + free(best_file_name); + return next_larger; + } + if (best_file_name) { + g_slist_free(extensions); + return best_file_name; + } - // Look in unthemed icons - { - for (const GSList *base = basenames; base; base = g_slist_next(base)) { - for (GSList *ext = extensions; ext; ext = g_slist_next(ext)) { - char *base_name = (char *)base->data; - char *extension = (char *)ext->data; - file_name = calloc(strlen(base_name) + strlen(icon_name) + strlen(extension) + 100, 1); - // filename = directory/iconname.extension - sprintf(file_name, "%s/%s%s", base_name, icon_name, extension); - if (DEBUG_ICON_SEARCH) - printf("checking %s\n", file_name); - if (g_file_test(file_name, G_FILE_TEST_EXISTS)) { - g_slist_free(extensions); - return file_name; - } else { - free(file_name); - file_name = NULL; - } - } - } - } + // Look in unthemed icons + { + for (const GSList *base = basenames; base; base = g_slist_next(base)) { + for (GSList *ext = extensions; ext; ext = g_slist_next(ext)) { + char *base_name = (char *)base->data; + char *extension = (char *)ext->data; + file_name = calloc(strlen(base_name) + strlen(icon_name) + strlen(extension) + 100, 1); + // filename = directory/iconname.extension + sprintf(file_name, "%s/%s%s", base_name, icon_name, extension); + if (DEBUG_ICON_SEARCH) + printf("checking %s\n", file_name); + if (g_file_test(file_name, G_FILE_TEST_EXISTS)) { + g_slist_free(extensions); + return file_name; + } else { + free(file_name); + file_name = NULL; + } + } + } + } - g_slist_free(extensions); - return NULL; + g_slist_free(extensions); + return NULL; } char *get_icon_path_from_cache(IconThemeWrapper *wrapper, const char *icon_name, int size) { - if (!wrapper || !icon_name || strlen(icon_name) == 0) - return NULL; + if (!wrapper || !icon_name || strlen(icon_name) == 0) + return NULL; - load_icon_cache(wrapper); + load_icon_cache(wrapper); - gchar *key = g_strdup_printf("%s\t%s\t%d", wrapper->icon_theme_name, icon_name, size); - const gchar *value = get_from_cache(&wrapper->_cache, key); - g_free(key); + gchar *key = g_strdup_printf("%s\t%s\t%d", wrapper->icon_theme_name, icon_name, size); + const gchar *value = get_from_cache(&wrapper->_cache, key); + g_free(key); - if (!value) { - fprintf(stderr, - YELLOW "Icon path not found in cache: theme = %s, icon = %s, size = %d" RESET "\n", - wrapper->icon_theme_name, - icon_name, - size); - return NULL; - } + if (!value) { + fprintf(stderr, + YELLOW "Icon path not found in cache: theme = %s, icon = %s, size = %d" RESET "\n", + wrapper->icon_theme_name, + icon_name, + size); + return NULL; + } - if (!g_file_test(value, G_FILE_TEST_EXISTS)) - return NULL; + if (!g_file_test(value, G_FILE_TEST_EXISTS)) + return NULL; - // fprintf(stderr, "Icon path found in cache: theme = %s, icon = %s, size = %d, path = %s\n", - // wrapper->icon_theme_name, icon_name, size, value); + // fprintf(stderr, "Icon path found in cache: theme = %s, icon = %s, size = %d, path = %s\n", + // wrapper->icon_theme_name, icon_name, size, value); - return strdup(value); + return strdup(value); } void add_icon_path_to_cache(IconThemeWrapper *wrapper, const char *icon_name, int size, const char *path) { - if (!wrapper || !icon_name || strlen(icon_name) == 0 || !path || strlen(path) == 0) - return; + if (!wrapper || !icon_name || strlen(icon_name) == 0 || !path || strlen(path) == 0) + return; - fprintf(stderr, - "Adding icon path to cache: theme = %s, icon = %s, size = %d, path = %s\n", - wrapper->icon_theme_name, - icon_name, - size, - path); + fprintf(stderr, + "Adding icon path to cache: theme = %s, icon = %s, size = %d, path = %s\n", + wrapper->icon_theme_name, + icon_name, + size, + path); - load_icon_cache(wrapper); + load_icon_cache(wrapper); - gchar *key = g_strdup_printf("%s\t%s\t%d", wrapper->icon_theme_name, icon_name, size); - add_to_cache(&wrapper->_cache, key, path); - g_free(key); + gchar *key = g_strdup_printf("%s\t%s\t%d", wrapper->icon_theme_name, icon_name, size); + add_to_cache(&wrapper->_cache, key, path); + g_free(key); } char *get_icon_path(IconThemeWrapper *wrapper, const char *icon_name, int size, gboolean use_fallbacks) { - if (!wrapper) - return NULL; + if (!wrapper) + return NULL; - if (!icon_name || strlen(icon_name) == 0) - goto notfound; + if (!icon_name || strlen(icon_name) == 0) + goto notfound; - char *path = get_icon_path_from_cache(wrapper, icon_name, size); - if (path) - return path; + char *path = get_icon_path_from_cache(wrapper, icon_name, size); + if (path) + return path; - load_default_theme(wrapper); + load_default_theme(wrapper); - icon_name = icon_name ? icon_name : DEFAULT_ICON; - path = get_icon_path_helper(wrapper->themes, icon_name, size); - if (path) { - add_icon_path_to_cache(wrapper, icon_name, size, path); - return path; - } + icon_name = icon_name ? icon_name : DEFAULT_ICON; + path = get_icon_path_helper(wrapper->themes, icon_name, size); + if (path) { + add_icon_path_to_cache(wrapper, icon_name, size, path); + return path; + } - if (!use_fallbacks) - goto notfound; - fprintf(stderr, YELLOW "Icon not found in default theme: %s" RESET "\n", icon_name); - load_fallbacks(wrapper); + if (!use_fallbacks) + goto notfound; + fprintf(stderr, YELLOW "Icon not found in default theme: %s" RESET "\n", icon_name); + load_fallbacks(wrapper); - path = get_icon_path_helper(wrapper->themes_fallback, icon_name, size); - if (path) { - add_icon_path_to_cache(wrapper, icon_name, size, path); - return path; - } + path = get_icon_path_helper(wrapper->themes_fallback, icon_name, size); + if (path) { + add_icon_path_to_cache(wrapper, icon_name, size, path); + return path; + } notfound: - fprintf(stderr, RED "Could not find icon '%s', using default." RESET "\n", icon_name); - path = get_icon_path_helper(wrapper->themes, DEFAULT_ICON, size); - if (path) - return path; - path = get_icon_path_helper(wrapper->themes_fallback, DEFAULT_ICON, size); - return path; + fprintf(stderr, RED "Could not find icon '%s', using default." RESET "\n", icon_name); + path = get_icon_path_helper(wrapper->themes, DEFAULT_ICON, size); + if (path) + return path; + path = get_icon_path_helper(wrapper->themes_fallback, DEFAULT_ICON, size); + return path; }
M src/launcher/icon-theme-common.hsrc/launcher/icon-theme-common.h

@@ -10,27 +10,27 @@ #include <glib.h>

#include "cache.h" typedef struct IconThemeWrapper { - // The icon theme name for which this wrapper was created - char *icon_theme_name; - // List of IconTheme* - GSList *themes; - // Themes are loaded lazily when needed. - gboolean _themes_loaded; - // List of IconTheme* - GSList *themes_fallback; - // Fallback themes are loaded lazily when needed. - gboolean _fallback_loaded; - Cache _cache; - // List of icon theme names that have been queued for loading. - // Used to avoid loading the same theme twice, and to avoid cycles. - GSList *_queued; + // The icon theme name for which this wrapper was created + char *icon_theme_name; + // List of IconTheme* + GSList *themes; + // Themes are loaded lazily when needed. + gboolean _themes_loaded; + // List of IconTheme* + GSList *themes_fallback; + // Fallback themes are loaded lazily when needed. + gboolean _fallback_loaded; + Cache _cache; + // List of icon theme names that have been queued for loading. + // Used to avoid loading the same theme twice, and to avoid cycles. + GSList *_queued; } IconThemeWrapper; typedef struct IconTheme { - char *name; - char *description; - GSList *list_inherits; // each item is a char* (theme name) - GSList *list_directories; // each item is an IconThemeDir* + char *name; + char *description; + GSList *list_inherits; // each item is a char* (theme name) + GSList *list_directories; // each item is an IconThemeDir* } IconTheme; // Parses a line of the form "key = value". Modifies the line.
M src/launcher/launcher.csrc/launcher/launcher.c

@@ -67,18 +67,18 @@ int launcher_compute_desired_size(void *obj);

void default_launcher() { - launcher_enabled = 0; - launcher_max_icon_size = 0; - launcher_tooltip_enabled = 0; - launcher_alpha = 100; - launcher_saturation = 0; - launcher_brightness = 0; - icon_theme_name_config = NULL; - icon_theme_name_xsettings = NULL; - launcher_icon_theme_override = 0; - startup_notifications = 0; - launcher_icon_bg = NULL; - launcher_icon_gradients = NULL; + launcher_enabled = 0; + launcher_max_icon_size = 0; + launcher_tooltip_enabled = 0; + launcher_alpha = 100; + launcher_saturation = 0; + launcher_brightness = 0; + icon_theme_name_config = NULL; + icon_theme_name_xsettings = NULL; + launcher_icon_theme_override = 0; + startup_notifications = 0; + launcher_icon_bg = NULL; + launcher_icon_gradients = NULL; } void init_launcher()

@@ -87,97 +87,97 @@ }

void init_launcher_panel(void *p) { - Panel *panel = (Panel *)p; - Launcher *launcher = &panel->launcher; + Panel *panel = (Panel *)p; + Launcher *launcher = &panel->launcher; - launcher->area.parent = p; - launcher->area.panel = p; - snprintf(launcher->area.name, sizeof(launcher->area.name), "Launcher"); - launcher->area._draw_foreground = NULL; - launcher->area.size_mode = LAYOUT_FIXED; - launcher->area._resize = resize_launcher; - launcher->area._compute_desired_size = launcher_compute_desired_size; - launcher->area.resize_needed = 1; - schedule_redraw(&launcher->area); - if (!launcher->area.bg) - launcher->area.bg = &g_array_index(backgrounds, Background, 0); + launcher->area.parent = p; + launcher->area.panel = p; + snprintf(launcher->area.name, sizeof(launcher->area.name), "Launcher"); + launcher->area._draw_foreground = NULL; + launcher->area.size_mode = LAYOUT_FIXED; + launcher->area._resize = resize_launcher; + launcher->area._compute_desired_size = launcher_compute_desired_size; + launcher->area.resize_needed = 1; + schedule_redraw(&launcher->area); + if (!launcher->area.bg) + launcher->area.bg = &g_array_index(backgrounds, Background, 0); - if (!launcher_icon_bg) - launcher_icon_bg = &g_array_index(backgrounds, Background, 0); + if (!launcher_icon_bg) + launcher_icon_bg = &g_array_index(backgrounds, Background, 0); - // check consistency - if (launcher->list_apps == NULL) - return; + // check consistency + if (launcher->list_apps == NULL) + return; - // This will be recomputed on resize, we just initialize to a non-zero value - launcher->icon_size = launcher_max_icon_size > 0 ? launcher_max_icon_size : 24; + // This will be recomputed on resize, we just initialize to a non-zero value + launcher->icon_size = launcher_max_icon_size > 0 ? launcher_max_icon_size : 24; - launcher->area.on_screen = TRUE; - schedule_panel_redraw(); - instantiate_area_gradients(&launcher->area); + launcher->area.on_screen = TRUE; + schedule_panel_redraw(); + instantiate_area_gradients(&launcher->area); - load_icon_themes(); - launcher_load_icons(launcher); + load_icon_themes(); + launcher_load_icons(launcher); } void free_icon_themes() { - free_themes(icon_theme_wrapper); - icon_theme_wrapper = NULL; + free_themes(icon_theme_wrapper); + icon_theme_wrapper = NULL; } void cleanup_launcher() { - for (int i = 0; i < num_panels; i++) { - Panel *panel = &panels[i]; - Launcher *launcher = &panel->launcher; - cleanup_launcher_theme(launcher); - } + for (int i = 0; i < num_panels; i++) { + Panel *panel = &panels[i]; + Launcher *launcher = &panel->launcher; + cleanup_launcher_theme(launcher); + } - for (GSList *l = panel_config.launcher.list_apps; l; l = l->next) { - free(l->data); - } - g_slist_free(panel_config.launcher.list_apps); - panel_config.launcher.list_apps = NULL; + for (GSList *l = panel_config.launcher.list_apps; l; l = l->next) { + free(l->data); + } + g_slist_free(panel_config.launcher.list_apps); + panel_config.launcher.list_apps = NULL; - free(icon_theme_name_config); - icon_theme_name_config = NULL; + free(icon_theme_name_config); + icon_theme_name_config = NULL; - free(icon_theme_name_xsettings); - icon_theme_name_xsettings = NULL; + free(icon_theme_name_xsettings); + icon_theme_name_xsettings = NULL; - launcher_enabled = FALSE; + launcher_enabled = FALSE; } void cleanup_launcher_theme(Launcher *launcher) { - free_area(&launcher->area); - for (GSList *l = launcher->list_icons; l; l = l->next) { - LauncherIcon *launcherIcon = (LauncherIcon *)l->data; - if (launcherIcon) { - free_icon(launcherIcon->image); - free_icon(launcherIcon->image_hover); - free_icon(launcherIcon->image_pressed); - free(launcherIcon->icon_name); - free(launcherIcon->icon_path); - free(launcherIcon->cmd); - g_free(launcherIcon->icon_tooltip); - free(launcherIcon->config_path); - } - free(launcherIcon); - } - g_slist_free(launcher->list_icons); - launcher->list_icons = NULL; + free_area(&launcher->area); + for (GSList *l = launcher->list_icons; l; l = l->next) { + LauncherIcon *launcherIcon = (LauncherIcon *)l->data; + if (launcherIcon) { + free_icon(launcherIcon->image); + free_icon(launcherIcon->image_hover); + free_icon(launcherIcon->image_pressed); + free(launcherIcon->icon_name); + free(launcherIcon->icon_path); + free(launcherIcon->cmd); + g_free(launcherIcon->icon_tooltip); + free(launcherIcon->config_path); + } + free(launcherIcon); + } + g_slist_free(launcher->list_icons); + launcher->list_icons = NULL; } int launcher_compute_icon_size(Launcher *launcher) { - int icon_size = panel_horizontal ? launcher->area.height : launcher->area.width; - icon_size = icon_size - MAX(left_right_border_width(&launcher->area), top_bottom_border_width(&launcher->area)) - - (2 * launcher->area.paddingy); - if (launcher_max_icon_size > 0 && icon_size > launcher_max_icon_size) - icon_size = launcher_max_icon_size; - return icon_size; + int icon_size = panel_horizontal ? launcher->area.height : launcher->area.width; + icon_size = icon_size - MAX(left_right_border_width(&launcher->area), top_bottom_border_width(&launcher->area)) - + (2 * launcher->area.paddingy); + if (launcher_max_icon_size > 0 && icon_size > launcher_max_icon_size) + icon_size = launcher_max_icon_size; + return icon_size; } void launcher_compute_geometry(Launcher *launcher,

@@ -187,438 +187,436 @@ int *icons_per_column,

int *icons_per_row, int *margin) { - int count = 0; - for (GSList *l = launcher->list_icons; l; l = l->next) { - LauncherIcon *launcherIcon = (LauncherIcon *)l->data; - if (launcherIcon->area.on_screen) - count++; - } + int count = 0; + for (GSList *l = launcher->list_icons; l; l = l->next) { + LauncherIcon *launcherIcon = (LauncherIcon *)l->data; + if (launcherIcon->area.on_screen) + count++; + } - *icon_size = launcher_compute_icon_size(launcher); - *icons_per_column = 1; - *icons_per_row = 1; - *margin = 0; - if (panel_horizontal) { - if (!count) { - *size = 0; - } else { - int height = launcher->area.height - top_bottom_border_width(&launcher->area) - 2 * launcher->area.paddingy; - // here icons_per_column always higher than 0 - *icons_per_column = (height + launcher->area.paddingx) / (*icon_size + launcher->area.paddingx); - *margin = height - (*icons_per_column - 1) * (*icon_size + launcher->area.paddingx) - *icon_size; - *icons_per_row = count / *icons_per_column + (count % *icons_per_column != 0); - *size = left_right_border_width(&launcher->area) + 2 * launcher->area.paddingxlr + - (*icon_size * *icons_per_row) + ((*icons_per_row - 1) * launcher->area.paddingx); - } - } else { - if (!count) { - *size = 0; - } else { - int width = launcher->area.width - top_bottom_border_width(&launcher->area) - 2 * launcher->area.paddingy; - // here icons_per_row always higher than 0 - *icons_per_row = (width + launcher->area.paddingx) / (*icon_size + launcher->area.paddingx); - *margin = width - (*icons_per_row - 1) * (*icon_size + launcher->area.paddingx) - *icon_size; - *icons_per_column = count / *icons_per_row + (count % *icons_per_row != 0); - *size = top_bottom_border_width(&launcher->area) + 2 * launcher->area.paddingxlr + - (*icon_size * *icons_per_column) + ((*icons_per_column - 1) * launcher->area.paddingx); - } - } + *icon_size = launcher_compute_icon_size(launcher); + *icons_per_column = 1; + *icons_per_row = 1; + *margin = 0; + if (panel_horizontal) { + if (!count) { + *size = 0; + } else { + int height = launcher->area.height - top_bottom_border_width(&launcher->area) - 2 * launcher->area.paddingy; + // here icons_per_column always higher than 0 + *icons_per_column = (height + launcher->area.paddingx) / (*icon_size + launcher->area.paddingx); + *margin = height - (*icons_per_column - 1) * (*icon_size + launcher->area.paddingx) - *icon_size; + *icons_per_row = count / *icons_per_column + (count % *icons_per_column != 0); + *size = left_right_border_width(&launcher->area) + 2 * launcher->area.paddingxlr + + (*icon_size * *icons_per_row) + ((*icons_per_row - 1) * launcher->area.paddingx); + } + } else { + if (!count) { + *size = 0; + } else { + int width = launcher->area.width - top_bottom_border_width(&launcher->area) - 2 * launcher->area.paddingy; + // here icons_per_row always higher than 0 + *icons_per_row = (width + launcher->area.paddingx) / (*icon_size + launcher->area.paddingx); + *margin = width - (*icons_per_row - 1) * (*icon_size + launcher->area.paddingx) - *icon_size; + *icons_per_column = count / *icons_per_row + (count % *icons_per_row != 0); + *size = top_bottom_border_width(&launcher->area) + 2 * launcher->area.paddingxlr + + (*icon_size * *icons_per_column) + ((*icons_per_column - 1) * launcher->area.paddingx); + } + } } int launcher_compute_desired_size(void *obj) { - Launcher *launcher = (Launcher *)obj; + Launcher *launcher = (Launcher *)obj; - int size, icon_size, icons_per_column, icons_per_row, margin; - launcher_compute_geometry(launcher, &size, &icon_size, &icons_per_column, &icons_per_row, &margin); - return size; + int size, icon_size, icons_per_column, icons_per_row, margin; + launcher_compute_geometry(launcher, &size, &icon_size, &icons_per_column, &icons_per_row, &margin); + return size; } gboolean resize_launcher(void *obj) { - Launcher *launcher = (Launcher *)obj; + Launcher *launcher = (Launcher *)obj; - int size, icons_per_column, icons_per_row, margin; - launcher_compute_geometry(launcher, &size, &launcher->icon_size, &icons_per_column, &icons_per_row, &margin); + int size, icons_per_column, icons_per_row, margin; + launcher_compute_geometry(launcher, &size, &launcher->icon_size, &icons_per_column, &icons_per_row, &margin); - // Resize icons if necessary - for (GSList *l = launcher->list_icons; l; l = l->next) { - LauncherIcon *launcherIcon = (LauncherIcon *)l->data; - if (launcherIcon->icon_size != launcher->icon_size || !launcherIcon->image) { - launcherIcon->icon_size = launcher->icon_size; - launcherIcon->area.width = launcherIcon->icon_size; - launcherIcon->area.height = launcherIcon->icon_size; - launcher_reload_icon_image(launcher, launcherIcon); - } - } - save_icon_cache(icon_theme_wrapper); + // Resize icons if necessary + for (GSList *l = launcher->list_icons; l; l = l->next) { + LauncherIcon *launcherIcon = (LauncherIcon *)l->data; + if (launcherIcon->icon_size != launcher->icon_size || !launcherIcon->image) { + launcherIcon->icon_size = launcher->icon_size; + launcherIcon->area.width = launcherIcon->icon_size; + launcherIcon->area.height = launcherIcon->icon_size; + launcher_reload_icon_image(launcher, launcherIcon); + } + } + save_icon_cache(icon_theme_wrapper); - int count = 0; - gboolean needs_repositioning = FALSE; - for (GSList *l = launcher->list_icons; l; l = l->next) { - LauncherIcon *launcherIcon = (LauncherIcon *)l->data; - if (launcherIcon->area.on_screen) { - count++; - if (launcherIcon->area.posx < 0 || launcherIcon->area.posy < 0) - needs_repositioning = TRUE; - } - } + int count = 0; + gboolean needs_repositioning = FALSE; + for (GSList *l = launcher->list_icons; l; l = l->next) { + LauncherIcon *launcherIcon = (LauncherIcon *)l->data; + if (launcherIcon->area.on_screen) { + count++; + if (launcherIcon->area.posx < 0 || launcherIcon->area.posy < 0) + needs_repositioning = TRUE; + } + } - if (!needs_repositioning) { - if (panel_horizontal) { - if (launcher->area.width == size) - return FALSE; - launcher->area.width = size; - } else { - if (launcher->area.height == size) - return FALSE; - launcher->area.height = size; - } - } + if (!needs_repositioning) { + if (panel_horizontal) { + if (launcher->area.width == size) + return FALSE; + launcher->area.width = size; + } else { + if (launcher->area.height == size) + return FALSE; + launcher->area.height = size; + } + } - int posx, posy; - int start; - if (panel_horizontal) { - posy = start = top_border_width(&launcher->area) + launcher->area.paddingy + margin / 2; - posx = left_border_width(&launcher->area) + launcher->area.paddingxlr; - } else { - posx = start = left_border_width(&launcher->area) + launcher->area.paddingy + margin / 2; - posy = top_border_width(&launcher->area) + launcher->area.paddingxlr; - } + int posx, posy; + int start; + if (panel_horizontal) { + posy = start = top_border_width(&launcher->area) + launcher->area.paddingy + margin / 2; + posx = left_border_width(&launcher->area) + launcher->area.paddingxlr; + } else { + posx = start = left_border_width(&launcher->area) + launcher->area.paddingy + margin / 2; + posy = top_border_width(&launcher->area) + launcher->area.paddingxlr; + } - int i = 0; - for (GSList *l = launcher->list_icons; l; l = l->next) { - LauncherIcon *launcherIcon = (LauncherIcon *)l->data; - if (!launcherIcon->area.on_screen) - continue; - i++; - launcherIcon->y = posy; - launcherIcon->x = posx; - launcher_icon_on_change_layout(launcherIcon); - // printf("launcher %d : %d,%d\n", i, posx, posy); - if (panel_horizontal) { - if (i % icons_per_column) { - posy += launcher->icon_size + launcher->area.paddingx; - } else { - posy = start; - posx += (launcher->icon_size + launcher->area.paddingx); - } - } else { - if (i % icons_per_row) { - posx += launcher->icon_size + launcher->area.paddingx; - } else { - posx = start; - posy += (launcher->icon_size + launcher->area.paddingx); - } - } - } + int i = 0; + for (GSList *l = launcher->list_icons; l; l = l->next) { + LauncherIcon *launcherIcon = (LauncherIcon *)l->data; + if (!launcherIcon->area.on_screen) + continue; + i++; + launcherIcon->y = posy; + launcherIcon->x = posx; + launcher_icon_on_change_layout(launcherIcon); + // printf("launcher %d : %d,%d\n", i, posx, posy); + if (panel_horizontal) { + if (i % icons_per_column) { + posy += launcher->icon_size + launcher->area.paddingx; + } else { + posy = start; + posx += (launcher->icon_size + launcher->area.paddingx); + } + } else { + if (i % icons_per_row) { + posx += launcher->icon_size + launcher->area.paddingx; + } else { + posx = start; + posy += (launcher->icon_size + launcher->area.paddingx); + } + } + } - if ((panel_horizontal && icons_per_column == 1) || (!panel_horizontal && icons_per_row == 1)) { - launcher->area._is_under_mouse = full_width_area_is_under_mouse; - for (GSList *l = launcher->list_icons; l; l = l->next) - ((LauncherIcon *)l->data)->area._is_under_mouse = full_width_area_is_under_mouse; - } else { - launcher->area._is_under_mouse = NULL; - for (GSList *l = launcher->list_icons; l; l = l->next) - ((LauncherIcon *)l->data)->area._is_under_mouse = NULL; - } + if ((panel_horizontal && icons_per_column == 1) || (!panel_horizontal && icons_per_row == 1)) { + launcher->area._is_under_mouse = full_width_area_is_under_mouse; + for (GSList *l = launcher->list_icons; l; l = l->next) + ((LauncherIcon *)l->data)->area._is_under_mouse = full_width_area_is_under_mouse; + } else { + launcher->area._is_under_mouse = NULL; + for (GSList *l = launcher->list_icons; l; l = l->next) + ((LauncherIcon *)l->data)->area._is_under_mouse = NULL; + } - return TRUE; + return TRUE; } // Here we override the default layout of the icons; normally Area layouts its children // in a stack; we need to layout them in a kind of table void launcher_icon_on_change_layout(void *obj) { - LauncherIcon *launcherIcon = (LauncherIcon *)obj; - launcherIcon->area.posy = ((Area *)launcherIcon->area.parent)->posy + launcherIcon->y; - launcherIcon->area.posx = ((Area *)launcherIcon->area.parent)->posx + launcherIcon->x; - launcherIcon->area.width = launcherIcon->icon_size; - launcherIcon->area.height = launcherIcon->icon_size; + LauncherIcon *launcherIcon = (LauncherIcon *)obj; + launcherIcon->area.posy = ((Area *)launcherIcon->area.parent)->posy + launcherIcon->y; + launcherIcon->area.posx = ((Area *)launcherIcon->area.parent)->posx + launcherIcon->x; + launcherIcon->area.width = launcherIcon->icon_size; + launcherIcon->area.height = launcherIcon->icon_size; } int launcher_icon_compute_desired_size(void *obj) { - LauncherIcon *icon = (LauncherIcon *)obj; - return icon->icon_size; + LauncherIcon *icon = (LauncherIcon *)obj; + return icon->icon_size; } char *launcher_icon_get_tooltip_text(void *obj) { - LauncherIcon *launcherIcon = (LauncherIcon *)obj; - return strdup(launcherIcon->icon_tooltip); + LauncherIcon *launcherIcon = (LauncherIcon *)obj; + return strdup(launcherIcon->icon_tooltip); } void draw_launcher_icon(void *obj, cairo_t *c) { - LauncherIcon *launcherIcon = (LauncherIcon *)obj; + LauncherIcon *launcherIcon = (LauncherIcon *)obj; - Imlib_Image image; - // Render - if (panel_config.mouse_effects) { - if (launcherIcon->area.mouse_state == MOUSE_OVER) - image = launcherIcon->image_hover ? launcherIcon->image_hover : launcherIcon->image; - else if (launcherIcon->area.mouse_state == MOUSE_DOWN) - image = launcherIcon->image_pressed ? launcherIcon->image_pressed : launcherIcon->image; - else - image = launcherIcon->image; - } else { - image = launcherIcon->image; - } - imlib_context_set_image(image); - render_image(launcherIcon->area.pix, 0, 0); + Imlib_Image image; + // Render + if (panel_config.mouse_effects) { + if (launcherIcon->area.mouse_state == MOUSE_OVER) + image = launcherIcon->image_hover ? launcherIcon->image_hover : launcherIcon->image; + else if (launcherIcon->area.mouse_state == MOUSE_DOWN) + image = launcherIcon->image_pressed ? launcherIcon->image_pressed : launcherIcon->image; + else + image = launcherIcon->image; + } else { + image = launcherIcon->image; + } + imlib_context_set_image(image); + render_image(launcherIcon->area.pix, 0, 0); } void launcher_icon_dump_geometry(void *obj, int indent) { - LauncherIcon *launcherIcon = (LauncherIcon *)obj; - fprintf(stderr, "%*sIcon: w = h = %d, name = %s\n", indent, "", launcherIcon->icon_size, launcherIcon->icon_name); + LauncherIcon *launcherIcon = (LauncherIcon *)obj; + fprintf(stderr, "%*sIcon: w = h = %d, name = %s\n", indent, "", launcherIcon->icon_size, launcherIcon->icon_name); } Imlib_Image scale_icon(Imlib_Image original, int icon_size) { - Imlib_Image icon_scaled; - if (original) { - imlib_context_set_image(original); - icon_scaled = imlib_create_cropped_scaled_image(0, - 0, - imlib_image_get_width(), - imlib_image_get_height(), - icon_size, - icon_size); + Imlib_Image icon_scaled; + if (original) { + imlib_context_set_image(original); + icon_scaled = imlib_create_cropped_scaled_image(0, + 0, + imlib_image_get_width(), + imlib_image_get_height(), + icon_size, + icon_size); - imlib_context_set_image(icon_scaled); - imlib_image_set_has_alpha(1); - DATA32 *data = imlib_image_get_data(); - adjust_asb(data, - icon_size, - icon_size, - launcher_alpha / 100.0, - launcher_saturation / 100.0, - launcher_brightness / 100.0); - imlib_image_put_back_data(data); + imlib_context_set_image(icon_scaled); + imlib_image_set_has_alpha(1); + DATA32 *data = imlib_image_get_data(); + adjust_asb(data, + icon_size, + icon_size, + launcher_alpha / 100.0, + launcher_saturation / 100.0, + launcher_brightness / 100.0); + imlib_image_put_back_data(data); - imlib_context_set_image(icon_scaled); - } else { - icon_scaled = imlib_create_image(icon_size, icon_size); - imlib_context_set_image(icon_scaled); - imlib_context_set_color(255, 255, 255, 255); - imlib_image_fill_rectangle(0, 0, icon_size, icon_size); - } - return icon_scaled; + imlib_context_set_image(icon_scaled); + } else { + icon_scaled = imlib_create_image(icon_size, icon_size); + imlib_context_set_image(icon_scaled); + imlib_context_set_color(255, 255, 255, 255); + imlib_image_fill_rectangle(0, 0, icon_size, icon_size); + } + return icon_scaled; } void free_icon(Imlib_Image icon) { - if (icon) { - imlib_context_set_image(icon); - imlib_free_image(); - } + if (icon) { + imlib_context_set_image(icon); + imlib_free_image(); + } } void launcher_action(LauncherIcon *icon, XEvent *evt) { - launcher_reload_icon((Launcher *)icon->area.parent, icon); - launcher_reload_hidden_icons((Launcher *)icon->area.parent); - char *cmd = calloc(strlen(icon->cmd) + 10, 1); - sprintf(cmd, "(%s&)", icon->cmd); + launcher_reload_icon((Launcher *)icon->area.parent, icon); + launcher_reload_hidden_icons((Launcher *)icon->area.parent); + char *cmd = calloc(strlen(icon->cmd) + 10, 1); + sprintf(cmd, "(%s&)", icon->cmd); #if HAVE_SN - SnLauncherContext *ctx = 0; - Time time; - if (startup_notifications) { - ctx = sn_launcher_context_new(server.sn_display, server.screen); - sn_launcher_context_set_name(ctx, icon->icon_tooltip); - sn_launcher_context_set_description(ctx, "Application launched from tint2"); - sn_launcher_context_set_binary_name(ctx, icon->cmd); - // Get a timestamp from the X event - if (evt->type == ButtonPress || evt->type == ButtonRelease) { - time = evt->xbutton.time; - } else { - fprintf(stderr, "Unknown X event: %d\n", evt->type); - free(cmd); - return; - } - sn_launcher_context_initiate(ctx, "tint2", icon->cmd, time); - } + SnLauncherContext *ctx = 0; + Time time; + if (startup_notifications) { + ctx = sn_launcher_context_new(server.sn_display, server.screen); + sn_launcher_context_set_name(ctx, icon->icon_tooltip); + sn_launcher_context_set_description(ctx, "Application launched from tint2"); + sn_launcher_context_set_binary_name(ctx, icon->cmd); + // Get a timestamp from the X event + if (evt->type == ButtonPress || evt->type == ButtonRelease) { + time = evt->xbutton.time; + } else { + fprintf(stderr, "Unknown X event: %d\n", evt->type); + free(cmd); + return; + } + sn_launcher_context_initiate(ctx, "tint2", icon->cmd, time); + } #endif /* HAVE_SN */ - pid_t pid; - pid = fork(); - if (pid < 0) { - fprintf(stderr, "Could not fork\n"); - } else if (pid == 0) { + pid_t pid; + pid = fork(); + if (pid < 0) { + fprintf(stderr, "Could not fork\n"); + } else if (pid == 0) { // Child process #if HAVE_SN - if (startup_notifications) { - sn_launcher_context_setup_child_process(ctx); - } + if (startup_notifications) { + sn_launcher_context_setup_child_process(ctx); + } #endif // HAVE_SN - // Allow children to exist after parent destruction - setsid(); - // Run the command - if (icon->cwd) - chdir(icon->cwd); - execl("/bin/sh", "/bin/sh", "-c", icon->cmd, NULL); - fprintf(stderr, "Failed to execlp %s\n", icon->cmd); + // Allow children to exist after parent destruction + setsid(); + // Run the command + if (icon->cwd) + chdir(icon->cwd); + execl("/bin/sh", "/bin/sh", "-c", icon->cmd, NULL); + fprintf(stderr, "Failed to execlp %s\n", icon->cmd); #if HAVE_SN - if (startup_notifications) { - sn_launcher_context_unref(ctx); - } + if (startup_notifications) { + sn_launcher_context_unref(ctx); + } #endif // HAVE_SN - exit(1); - } else { + exit(1); + } else { // Parent process #if HAVE_SN - if (startup_notifications) { - g_tree_insert(server.pids, GINT_TO_POINTER(pid), ctx); - } + if (startup_notifications) { + g_tree_insert(server.pids, GINT_TO_POINTER(pid), ctx); + } #endif // HAVE_SN - } - free(cmd); + } + free(cmd); } - - // Populates the list_icons list from the list_apps list void launcher_load_icons(Launcher *launcher) { - // Load apps (.desktop style launcher items) - GSList *app = launcher->list_apps; - int index = 0; - while (app != NULL) { - index++; - LauncherIcon *launcherIcon = (LauncherIcon *)calloc(1, sizeof(LauncherIcon)); - launcherIcon->area.panel = launcher->area.panel; - launcherIcon->area._draw_foreground = draw_launcher_icon; - launcherIcon->area.size_mode = LAYOUT_FIXED; - launcherIcon->area._resize = NULL; - launcherIcon->area._compute_desired_size = launcher_icon_compute_desired_size; - sprintf(launcherIcon->area.name, "LauncherIcon %d", index); - launcherIcon->area.resize_needed = 0; - launcherIcon->area.has_mouse_over_effect = panel_config.mouse_effects; - launcherIcon->area.has_mouse_press_effect = launcherIcon->area.has_mouse_over_effect; - launcherIcon->area.bg = launcher_icon_bg; - launcherIcon->area.on_screen = TRUE; - launcherIcon->area.posx = -1; - launcherIcon->area._on_change_layout = launcher_icon_on_change_layout; - launcherIcon->area._dump_geometry = launcher_icon_dump_geometry; - if (launcher_tooltip_enabled) { - launcherIcon->area._get_tooltip_text = launcher_icon_get_tooltip_text; - } else { - launcherIcon->area._get_tooltip_text = NULL; - } - launcherIcon->config_path = strdup(app->data); - add_area(&launcherIcon->area, (Area *)launcher); - launcher->list_icons = g_slist_append(launcher->list_icons, launcherIcon); - launcherIcon->icon_size = launcher->icon_size; - launcher_reload_icon(launcher, launcherIcon); - instantiate_area_gradients(&launcherIcon->area); - app = g_slist_next(app); - } + // Load apps (.desktop style launcher items) + GSList *app = launcher->list_apps; + int index = 0; + while (app != NULL) { + index++; + LauncherIcon *launcherIcon = (LauncherIcon *)calloc(1, sizeof(LauncherIcon)); + launcherIcon->area.panel = launcher->area.panel; + launcherIcon->area._draw_foreground = draw_launcher_icon; + launcherIcon->area.size_mode = LAYOUT_FIXED; + launcherIcon->area._resize = NULL; + launcherIcon->area._compute_desired_size = launcher_icon_compute_desired_size; + sprintf(launcherIcon->area.name, "LauncherIcon %d", index); + launcherIcon->area.resize_needed = 0; + launcherIcon->area.has_mouse_over_effect = panel_config.mouse_effects; + launcherIcon->area.has_mouse_press_effect = launcherIcon->area.has_mouse_over_effect; + launcherIcon->area.bg = launcher_icon_bg; + launcherIcon->area.on_screen = TRUE; + launcherIcon->area.posx = -1; + launcherIcon->area._on_change_layout = launcher_icon_on_change_layout; + launcherIcon->area._dump_geometry = launcher_icon_dump_geometry; + if (launcher_tooltip_enabled) { + launcherIcon->area._get_tooltip_text = launcher_icon_get_tooltip_text; + } else { + launcherIcon->area._get_tooltip_text = NULL; + } + launcherIcon->config_path = strdup(app->data); + add_area(&launcherIcon->area, (Area *)launcher); + launcher->list_icons = g_slist_append(launcher->list_icons, launcherIcon); + launcherIcon->icon_size = launcher->icon_size; + launcher_reload_icon(launcher, launcherIcon); + instantiate_area_gradients(&launcherIcon->area); + app = g_slist_next(app); + } } void launcher_reload_icon(Launcher *launcher, LauncherIcon *launcherIcon) { - DesktopEntry entry; - if (read_desktop_file(launcherIcon->config_path, &entry) && entry.exec) { - schedule_redraw(&launcherIcon->area); - if (launcherIcon->cmd) - free(launcherIcon->cmd); - launcherIcon->cmd = strdup(entry.exec); - if (launcherIcon->cwd) - free(launcherIcon->cwd); - if (entry.cwd) - launcherIcon->cwd = strdup(entry.cwd); - else - launcherIcon->cwd = NULL; - if (launcherIcon->icon_name) - free(launcherIcon->icon_name); - launcherIcon->icon_name = entry.icon ? strdup(entry.icon) : strdup(DEFAULT_ICON); - if (entry.name) { - if (entry.generic_name) { - launcherIcon->icon_tooltip = g_strdup_printf("%s (%s)", entry.name, entry.generic_name); - } else { - launcherIcon->icon_tooltip = g_strdup_printf("%s", entry.name); - } - } else { - if (entry.generic_name) { - launcherIcon->icon_tooltip = g_strdup_printf("%s", entry.generic_name); - } else if (entry.exec) { - launcherIcon->icon_tooltip = g_strdup_printf("%s", entry.exec); - } - } - launcher_reload_icon_image(launcher, launcherIcon); - show(&launcherIcon->area); - } else { - hide(&launcherIcon->area); - } - free_desktop_entry(&entry); + DesktopEntry entry; + if (read_desktop_file(launcherIcon->config_path, &entry) && entry.exec) { + schedule_redraw(&launcherIcon->area); + if (launcherIcon->cmd) + free(launcherIcon->cmd); + launcherIcon->cmd = strdup(entry.exec); + if (launcherIcon->cwd) + free(launcherIcon->cwd); + if (entry.cwd) + launcherIcon->cwd = strdup(entry.cwd); + else + launcherIcon->cwd = NULL; + if (launcherIcon->icon_name) + free(launcherIcon->icon_name); + launcherIcon->icon_name = entry.icon ? strdup(entry.icon) : strdup(DEFAULT_ICON); + if (entry.name) { + if (entry.generic_name) { + launcherIcon->icon_tooltip = g_strdup_printf("%s (%s)", entry.name, entry.generic_name); + } else { + launcherIcon->icon_tooltip = g_strdup_printf("%s", entry.name); + } + } else { + if (entry.generic_name) { + launcherIcon->icon_tooltip = g_strdup_printf("%s", entry.generic_name); + } else if (entry.exec) { + launcherIcon->icon_tooltip = g_strdup_printf("%s", entry.exec); + } + } + launcher_reload_icon_image(launcher, launcherIcon); + show(&launcherIcon->area); + } else { + hide(&launcherIcon->area); + } + free_desktop_entry(&entry); } void launcher_reload_hidden_icons(Launcher *launcher) { - for (GSList *l = launcher->list_icons; l; l = l->next) { - LauncherIcon *launcherIcon = (LauncherIcon *)l->data; - if (!launcherIcon->area.on_screen) - launcher_reload_icon(launcher, launcherIcon); - } + for (GSList *l = launcher->list_icons; l; l = l->next) { + LauncherIcon *launcherIcon = (LauncherIcon *)l->data; + if (!launcherIcon->area.on_screen) + launcher_reload_icon(launcher, launcherIcon); + } } void launcher_reload_icon_image(Launcher *launcher, LauncherIcon *launcherIcon) { - free_icon(launcherIcon->image); - free_icon(launcherIcon->image_hover); - free_icon(launcherIcon->image_pressed); - launcherIcon->image = NULL; + free_icon(launcherIcon->image); + free_icon(launcherIcon->image_hover); + free_icon(launcherIcon->image_pressed); + launcherIcon->image = NULL; - char *new_icon_path = get_icon_path(icon_theme_wrapper, launcherIcon->icon_name, launcherIcon->icon_size, TRUE); - if (new_icon_path) - launcherIcon->image = load_image(new_icon_path, TRUE); - // On loading error, fallback to default - if (!launcherIcon->image) { - free(new_icon_path); - new_icon_path = get_icon_path(icon_theme_wrapper, DEFAULT_ICON, launcherIcon->icon_size, TRUE); - if (new_icon_path) - launcherIcon->image = load_image(new_icon_path, TRUE); - } - 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); + char *new_icon_path = get_icon_path(icon_theme_wrapper, launcherIcon->icon_name, launcherIcon->icon_size, TRUE); + if (new_icon_path) + launcherIcon->image = load_image(new_icon_path, TRUE); + // On loading error, fallback to default + if (!launcherIcon->image) { + free(new_icon_path); + new_icon_path = get_icon_path(icon_theme_wrapper, DEFAULT_ICON, launcherIcon->icon_size, TRUE); + if (new_icon_path) + launcherIcon->image = load_image(new_icon_path, TRUE); + } + 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); - if (panel_config.mouse_effects) { - launcherIcon->image_hover = adjust_icon(launcherIcon->image, - panel_config.mouse_over_alpha, - panel_config.mouse_over_saturation, - panel_config.mouse_over_brightness); - launcherIcon->image_pressed = adjust_icon(launcherIcon->image, - panel_config.mouse_pressed_alpha, - panel_config.mouse_pressed_saturation, - panel_config.mouse_pressed_brightness); - } - schedule_redraw(&launcherIcon->area); + if (panel_config.mouse_effects) { + launcherIcon->image_hover = adjust_icon(launcherIcon->image, + panel_config.mouse_over_alpha, + panel_config.mouse_over_saturation, + panel_config.mouse_over_brightness); + launcherIcon->image_pressed = adjust_icon(launcherIcon->image, + panel_config.mouse_pressed_alpha, + panel_config.mouse_pressed_saturation, + panel_config.mouse_pressed_brightness); + } + schedule_redraw(&launcherIcon->area); } void load_icon_themes() { - if (icon_theme_wrapper) - return; - icon_theme_wrapper = - load_themes(launcher_icon_theme_override - ? (icon_theme_name_config ? icon_theme_name_config - : icon_theme_name_xsettings ? icon_theme_name_xsettings : "hicolor") - : (icon_theme_name_xsettings ? icon_theme_name_xsettings - : icon_theme_name_config ? icon_theme_name_config : "hicolor")); + if (icon_theme_wrapper) + return; + icon_theme_wrapper = + load_themes(launcher_icon_theme_override + ? (icon_theme_name_config ? icon_theme_name_config + : icon_theme_name_xsettings ? icon_theme_name_xsettings : "hicolor") + : (icon_theme_name_xsettings ? icon_theme_name_xsettings + : icon_theme_name_config ? icon_theme_name_config : "hicolor")); } void launcher_default_icon_theme_changed() { - for (int i = 0; i < num_panels; i++) { - Launcher *launcher = &panels[i].launcher; - cleanup_launcher_theme(launcher); - launcher_load_icons(launcher); - launcher->area.resize_needed = 1; - } - schedule_panel_redraw(); + for (int i = 0; i < num_panels; i++) { + Launcher *launcher = &panels[i].launcher; + cleanup_launcher_theme(launcher); + launcher_load_icons(launcher); + launcher->area.resize_needed = 1; + } + schedule_panel_redraw(); }
M src/launcher/launcher.hsrc/launcher/launcher.h

@@ -17,27 +17,27 @@ void load_icon_themes();

void free_icon_themes(); typedef struct Launcher { - // always start with area - Area area; - GSList *list_apps; // List of char*, each is a path to a app.desktop file - GSList *list_icons; // List of LauncherIcon* - int icon_size; + // always start with area + Area area; + GSList *list_apps; // List of char*, each is a path to a app.desktop file + GSList *list_icons; // List of LauncherIcon* + int icon_size; } Launcher; typedef struct LauncherIcon { - // always start with area - Area area; - char *config_path; - Imlib_Image image; - Imlib_Image image_hover; - Imlib_Image image_pressed; - char *cmd; - char *cwd; - char *icon_name; - char *icon_path; - char *icon_tooltip; - int icon_size; - int x, y; + // always start with area + Area area; + char *config_path; + Imlib_Image image; + Imlib_Image image_hover; + Imlib_Image image_pressed; + char *cmd; + char *cwd; + char *icon_name; + char *icon_path; + char *icon_tooltip; + int icon_size; + int x, y; } LauncherIcon; extern gboolean launcher_enabled;
M src/launcher/xsettings-client.csrc/launcher/xsettings-client.c

@@ -34,78 +34,78 @@ #include "panel.h"

#include "launcher.h" struct _XSettingsClient { - Display *display; - int screen; - XSettingsNotifyFunc notify; - XSettingsWatchFunc watch; - void *cb_data; + Display *display; + int screen; + XSettingsNotifyFunc notify; + XSettingsWatchFunc watch; + void *cb_data; - Window manager_window; - XSettingsList *settings; + Window manager_window; + XSettingsList *settings; }; void xsettings_notify_cb(const char *name, XSettingsAction action, XSettingsSetting *setting, void *data) { - if ((action == XSETTINGS_ACTION_NEW || action == XSETTINGS_ACTION_CHANGED) && name != NULL && setting != NULL) { - if (strcmp(name, "Net/IconThemeName") == 0 && setting->type == XSETTINGS_TYPE_STRING) { - fprintf(stderr, "xsettings: %s = %s\n", name, setting->data.v_string); - if (icon_theme_name_xsettings) { - if (strcmp(icon_theme_name_xsettings, setting->data.v_string) == 0) - return; - free(icon_theme_name_xsettings); - } - icon_theme_name_xsettings = strdup(setting->data.v_string); - default_icon_theme_changed(); - } else if (strcmp(name, "Gtk/FontName") == 0 && setting->type == XSETTINGS_TYPE_STRING) { - fprintf(stderr, "xsettings: %s = %s\n", name, setting->data.v_string); - if (default_font) { - if (strcmp(default_font, setting->data.v_string) == 0) - return; - free(default_font); - } - default_font = strdup(setting->data.v_string); - default_font_changed(); - } - } + if ((action == XSETTINGS_ACTION_NEW || action == XSETTINGS_ACTION_CHANGED) && name != NULL && setting != NULL) { + if (strcmp(name, "Net/IconThemeName") == 0 && setting->type == XSETTINGS_TYPE_STRING) { + fprintf(stderr, "xsettings: %s = %s\n", name, setting->data.v_string); + if (icon_theme_name_xsettings) { + if (strcmp(icon_theme_name_xsettings, setting->data.v_string) == 0) + return; + free(icon_theme_name_xsettings); + } + icon_theme_name_xsettings = strdup(setting->data.v_string); + default_icon_theme_changed(); + } else if (strcmp(name, "Gtk/FontName") == 0 && setting->type == XSETTINGS_TYPE_STRING) { + fprintf(stderr, "xsettings: %s = %s\n", name, setting->data.v_string); + if (default_font) { + if (strcmp(default_font, setting->data.v_string) == 0) + return; + free(default_font); + } + default_font = strdup(setting->data.v_string); + default_font_changed(); + } + } } static void notify_changes(XSettingsClient *client, XSettingsList *old_list) { - XSettingsList *old_iter = old_list; - XSettingsList *new_iter = client->settings; + XSettingsList *old_iter = old_list; + XSettingsList *new_iter = client->settings; - if (!client->notify) - return; + if (!client->notify) + return; - while (old_iter || new_iter) { - int cmp; + while (old_iter || new_iter) { + int cmp; - if (old_iter && new_iter) - cmp = strcmp(old_iter->setting->name, new_iter->setting->name); - else if (old_iter) - cmp = -1; - else - cmp = 1; + if (old_iter && new_iter) + cmp = strcmp(old_iter->setting->name, new_iter->setting->name); + else if (old_iter) + cmp = -1; + else + cmp = 1; - if (cmp < 0) { - client->notify(old_iter->setting->name, XSETTINGS_ACTION_DELETED, NULL, client->cb_data); - } else if (cmp == 0) { - if (!xsettings_setting_equal(old_iter->setting, new_iter->setting)) - client->notify(old_iter->setting->name, XSETTINGS_ACTION_CHANGED, new_iter->setting, client->cb_data); - } else { - client->notify(new_iter->setting->name, XSETTINGS_ACTION_NEW, new_iter->setting, client->cb_data); - } + if (cmp < 0) { + client->notify(old_iter->setting->name, XSETTINGS_ACTION_DELETED, NULL, client->cb_data); + } else if (cmp == 0) { + if (!xsettings_setting_equal(old_iter->setting, new_iter->setting)) + client->notify(old_iter->setting->name, XSETTINGS_ACTION_CHANGED, new_iter->setting, client->cb_data); + } else { + client->notify(new_iter->setting->name, XSETTINGS_ACTION_NEW, new_iter->setting, client->cb_data); + } - if (old_iter) - old_iter = old_iter->next; - if (new_iter) - new_iter = new_iter->next; - } + if (old_iter) + old_iter = old_iter->next; + if (new_iter) + new_iter = new_iter->next; + } } static int ignore_errors(Display *display, XErrorEvent *event) { - return True; + return True; } static char local_byte_order = '\0';

@@ -114,364 +114,364 @@ #define BYTES_LEFT(buffer) ((buffer)->data + (buffer)->len - (buffer)->pos)

static XSettingsResult fetch_card16(XSettingsBuffer *buffer, CARD16 *result) { - CARD16 x; + CARD16 x; - if (BYTES_LEFT(buffer) < 2) - return XSETTINGS_ACCESS; + if (BYTES_LEFT(buffer) < 2) + return XSETTINGS_ACCESS; - x = *(CARD16 *)buffer->pos; - buffer->pos += 2; + x = *(CARD16 *)buffer->pos; + buffer->pos += 2; - if (buffer->byte_order == local_byte_order) - *result = x; - else - *result = (x << 8) | (x >> 8); + if (buffer->byte_order == local_byte_order) + *result = x; + else + *result = (x << 8) | (x >> 8); - return XSETTINGS_SUCCESS; + return XSETTINGS_SUCCESS; } static XSettingsResult fetch_ushort(XSettingsBuffer *buffer, unsigned short *result) { - CARD16 x; - XSettingsResult r; + CARD16 x; + XSettingsResult r; - r = fetch_card16(buffer, &x); - if (r == XSETTINGS_SUCCESS) - *result = x; + r = fetch_card16(buffer, &x); + if (r == XSETTINGS_SUCCESS) + *result = x; - return r; + return r; } static XSettingsResult fetch_card32(XSettingsBuffer *buffer, CARD32 *result) { - CARD32 x; + CARD32 x; - if (BYTES_LEFT(buffer) < 4) - return XSETTINGS_ACCESS; + if (BYTES_LEFT(buffer) < 4) + return XSETTINGS_ACCESS; - x = *(CARD32 *)buffer->pos; - buffer->pos += 4; + x = *(CARD32 *)buffer->pos; + buffer->pos += 4; - if (buffer->byte_order == local_byte_order) - *result = x; - else - *result = (x << 24) | ((x & 0xff00) << 8) | ((x & 0xff0000) >> 8) | (x >> 24); + if (buffer->byte_order == local_byte_order) + *result = x; + else + *result = (x << 24) | ((x & 0xff00) << 8) | ((x & 0xff0000) >> 8) | (x >> 24); - return XSETTINGS_SUCCESS; + return XSETTINGS_SUCCESS; } static XSettingsResult fetch_card8(XSettingsBuffer *buffer, CARD8 *result) { - if (BYTES_LEFT(buffer) < 1) - return XSETTINGS_ACCESS; + if (BYTES_LEFT(buffer) < 1) + return XSETTINGS_ACCESS; - *result = *(CARD8 *)buffer->pos; - buffer->pos += 1; + *result = *(CARD8 *)buffer->pos; + buffer->pos += 1; - return XSETTINGS_SUCCESS; + return XSETTINGS_SUCCESS; } #define XSETTINGS_PAD(n, m) ((n + m - 1) & (~(m - 1))) static XSettingsList *parse_settings(unsigned char *data, size_t len) { - XSettingsBuffer buffer; - XSettingsResult result = XSETTINGS_SUCCESS; - XSettingsList *settings = NULL; - CARD32 serial; - CARD32 n_entries; - CARD32 i; - XSettingsSetting *setting = NULL; + XSettingsBuffer buffer; + XSettingsResult result = XSETTINGS_SUCCESS; + XSettingsList *settings = NULL; + CARD32 serial; + CARD32 n_entries; + CARD32 i; + XSettingsSetting *setting = NULL; - local_byte_order = xsettings_byte_order(); + local_byte_order = xsettings_byte_order(); - buffer.byte_order = local_byte_order; - buffer.pos = buffer.data = data; - buffer.len = len; + buffer.byte_order = local_byte_order; + buffer.pos = buffer.data = data; + buffer.len = len; - result = fetch_card8(&buffer, (CARD8 *)&buffer.byte_order); - if (buffer.byte_order != MSBFirst && buffer.byte_order != LSBFirst) { - fprintf(stderr, "Invalid byte order %x in XSETTINGS property\n", buffer.byte_order); - result = XSETTINGS_FAILED; - goto out; - } + result = fetch_card8(&buffer, (CARD8 *)&buffer.byte_order); + if (buffer.byte_order != MSBFirst && buffer.byte_order != LSBFirst) { + fprintf(stderr, "Invalid byte order %x in XSETTINGS property\n", buffer.byte_order); + result = XSETTINGS_FAILED; + goto out; + } - buffer.pos += 3; + buffer.pos += 3; - result = fetch_card32(&buffer, &serial); - if (result != XSETTINGS_SUCCESS) - goto out; + result = fetch_card32(&buffer, &serial); + if (result != XSETTINGS_SUCCESS) + goto out; - result = fetch_card32(&buffer, &n_entries); - if (result != XSETTINGS_SUCCESS) - goto out; + result = fetch_card32(&buffer, &n_entries); + if (result != XSETTINGS_SUCCESS) + goto out; - for (i = 0; i < n_entries; i++) { - CARD8 type; - CARD16 name_len; - CARD32 v_int; - size_t pad_len; + for (i = 0; i < n_entries; i++) { + CARD8 type; + CARD16 name_len; + CARD32 v_int; + size_t pad_len; - result = fetch_card8(&buffer, &type); - if (result != XSETTINGS_SUCCESS) - goto out; + result = fetch_card8(&buffer, &type); + if (result != XSETTINGS_SUCCESS) + goto out; - buffer.pos += 1; + buffer.pos += 1; - result = fetch_card16(&buffer, &name_len); - if (result != XSETTINGS_SUCCESS) - goto out; + result = fetch_card16(&buffer, &name_len); + if (result != XSETTINGS_SUCCESS) + goto out; - pad_len = XSETTINGS_PAD(name_len, 4); - if (BYTES_LEFT(&buffer) < pad_len) { - result = XSETTINGS_ACCESS; - goto out; - } + pad_len = XSETTINGS_PAD(name_len, 4); + if (BYTES_LEFT(&buffer) < pad_len) { + result = XSETTINGS_ACCESS; + goto out; + } - setting = calloc(1, sizeof *setting); - if (!setting) { - result = XSETTINGS_NO_MEM; - goto out; - } - setting->type = XSETTINGS_TYPE_INT; /* No allocated memory */ + setting = calloc(1, sizeof *setting); + if (!setting) { + result = XSETTINGS_NO_MEM; + goto out; + } + setting->type = XSETTINGS_TYPE_INT; /* No allocated memory */ - setting->name = calloc(name_len + 1, 1); - if (!setting->name) { - result = XSETTINGS_NO_MEM; - goto out; - } + setting->name = calloc(name_len + 1, 1); + if (!setting->name) { + result = XSETTINGS_NO_MEM; + goto out; + } - memcpy(setting->name, buffer.pos, name_len); - setting->name[name_len] = '\0'; - buffer.pos += pad_len; + memcpy(setting->name, buffer.pos, name_len); + setting->name[name_len] = '\0'; + buffer.pos += pad_len; - result = fetch_card32(&buffer, &v_int); - if (result != XSETTINGS_SUCCESS) - goto out; - setting->last_change_serial = v_int; + result = fetch_card32(&buffer, &v_int); + if (result != XSETTINGS_SUCCESS) + goto out; + setting->last_change_serial = v_int; - switch (type) { - case XSETTINGS_TYPE_INT: - result = fetch_card32(&buffer, &v_int); - if (result != XSETTINGS_SUCCESS) - goto out; - setting->data.v_int = (INT32)v_int; - break; - case XSETTINGS_TYPE_STRING: - result = fetch_card32(&buffer, &v_int); - if (result != XSETTINGS_SUCCESS) - goto out; + switch (type) { + case XSETTINGS_TYPE_INT: + result = fetch_card32(&buffer, &v_int); + if (result != XSETTINGS_SUCCESS) + goto out; + setting->data.v_int = (INT32)v_int; + break; + case XSETTINGS_TYPE_STRING: + result = fetch_card32(&buffer, &v_int); + if (result != XSETTINGS_SUCCESS) + goto out; - pad_len = XSETTINGS_PAD(v_int, 4); - if (v_int + 1 == 0 || /* Guard against wrap-around */ - BYTES_LEFT(&buffer) < pad_len) { - result = XSETTINGS_ACCESS; - goto out; - } + pad_len = XSETTINGS_PAD(v_int, 4); + if (v_int + 1 == 0 || /* Guard against wrap-around */ + BYTES_LEFT(&buffer) < pad_len) { + result = XSETTINGS_ACCESS; + goto out; + } - setting->data.v_string = calloc(v_int + 1, 1); - if (!setting->data.v_string) { - result = XSETTINGS_NO_MEM; - goto out; - } + setting->data.v_string = calloc(v_int + 1, 1); + if (!setting->data.v_string) { + result = XSETTINGS_NO_MEM; + goto out; + } - memcpy(setting->data.v_string, buffer.pos, v_int); - setting->data.v_string[v_int] = '\0'; - buffer.pos += pad_len; - break; - case XSETTINGS_TYPE_COLOR: - result = fetch_ushort(&buffer, &setting->data.v_color.red); - if (result != XSETTINGS_SUCCESS) - goto out; - result = fetch_ushort(&buffer, &setting->data.v_color.green); - if (result != XSETTINGS_SUCCESS) - goto out; - result = fetch_ushort(&buffer, &setting->data.v_color.blue); - if (result != XSETTINGS_SUCCESS) - goto out; - result = fetch_ushort(&buffer, &setting->data.v_color.alpha); - if (result != XSETTINGS_SUCCESS) - goto out; - break; - default: - /* Quietly ignore unknown types */ - break; - } + memcpy(setting->data.v_string, buffer.pos, v_int); + setting->data.v_string[v_int] = '\0'; + buffer.pos += pad_len; + break; + case XSETTINGS_TYPE_COLOR: + result = fetch_ushort(&buffer, &setting->data.v_color.red); + if (result != XSETTINGS_SUCCESS) + goto out; + result = fetch_ushort(&buffer, &setting->data.v_color.green); + if (result != XSETTINGS_SUCCESS) + goto out; + result = fetch_ushort(&buffer, &setting->data.v_color.blue); + if (result != XSETTINGS_SUCCESS) + goto out; + result = fetch_ushort(&buffer, &setting->data.v_color.alpha); + if (result != XSETTINGS_SUCCESS) + goto out; + break; + default: + /* Quietly ignore unknown types */ + break; + } - setting->type = type; + setting->type = type; - result = xsettings_list_insert(&settings, setting); - if (result != XSETTINGS_SUCCESS) - goto out; + result = xsettings_list_insert(&settings, setting); + if (result != XSETTINGS_SUCCESS) + goto out; - setting = NULL; - } + setting = NULL; + } out: - if (result != XSETTINGS_SUCCESS) { - switch (result) { - case XSETTINGS_NO_MEM: - fprintf(stderr, "Out of memory reading XSETTINGS property\n"); - break; - case XSETTINGS_ACCESS: - fprintf(stderr, "Invalid XSETTINGS property (read off end)\n"); - break; - case XSETTINGS_DUPLICATE_ENTRY: - fprintf(stderr, "Duplicate XSETTINGS entry for '%s'\n", setting->name); - case XSETTINGS_FAILED: - case XSETTINGS_SUCCESS: - case XSETTINGS_NO_ENTRY: - break; - } + if (result != XSETTINGS_SUCCESS) { + switch (result) { + case XSETTINGS_NO_MEM: + fprintf(stderr, "Out of memory reading XSETTINGS property\n"); + break; + case XSETTINGS_ACCESS: + fprintf(stderr, "Invalid XSETTINGS property (read off end)\n"); + break; + case XSETTINGS_DUPLICATE_ENTRY: + fprintf(stderr, "Duplicate XSETTINGS entry for '%s'\n", setting->name); + case XSETTINGS_FAILED: + case XSETTINGS_SUCCESS: + case XSETTINGS_NO_ENTRY: + break; + } - if (setting) - xsettings_setting_free(setting); + if (setting) + xsettings_setting_free(setting); - xsettings_list_free(settings); - settings = NULL; - } + xsettings_list_free(settings); + settings = NULL; + } - return settings; + return settings; } static void read_settings(XSettingsClient *client) { - Atom type; - int format; - unsigned long n_items; - unsigned long bytes_after; - unsigned char *data; + Atom type; + int format; + unsigned long n_items; + unsigned long bytes_after; + unsigned char *data; - int (*old_handler)(Display *, XErrorEvent *); + int (*old_handler)(Display *, XErrorEvent *); - XSettingsList *old_list = client->settings; - client->settings = NULL; + XSettingsList *old_list = client->settings; + client->settings = NULL; - old_handler = XSetErrorHandler(ignore_errors); - int result = XGetWindowProperty(client->display, - client->manager_window, - server.atom._XSETTINGS_SETTINGS, - 0, - LONG_MAX, - False, - server.atom._XSETTINGS_SETTINGS, - &type, - &format, - &n_items, - &bytes_after, - &data); - XSetErrorHandler(old_handler); + old_handler = XSetErrorHandler(ignore_errors); + int result = XGetWindowProperty(client->display, + client->manager_window, + server.atom._XSETTINGS_SETTINGS, + 0, + LONG_MAX, + False, + server.atom._XSETTINGS_SETTINGS, + &type, + &format, + &n_items, + &bytes_after, + &data); + XSetErrorHandler(old_handler); - if (result == Success && type == server.atom._XSETTINGS_SETTINGS) { - if (format != 8) { - fprintf(stderr, "Invalid format for XSETTINGS property %d", format); - } else - client->settings = parse_settings(data, n_items); - XFree(data); - } + if (result == Success && type == server.atom._XSETTINGS_SETTINGS) { + if (format != 8) { + fprintf(stderr, "Invalid format for XSETTINGS property %d", format); + } else + client->settings = parse_settings(data, n_items); + XFree(data); + } - notify_changes(client, old_list); - xsettings_list_free(old_list); + notify_changes(client, old_list); + xsettings_list_free(old_list); } static void check_manager_window(XSettingsClient *client) { - if (client->manager_window && client->watch) - client->watch(client->manager_window, False, 0, client->cb_data); + if (client->manager_window && client->watch) + client->watch(client->manager_window, False, 0, client->cb_data); - XGrabServer(client->display); + XGrabServer(client->display); - client->manager_window = XGetSelectionOwner(server.display, server.atom._XSETTINGS_SCREEN); - if (client->manager_window) - XSelectInput(server.display, client->manager_window, PropertyChangeMask | StructureNotifyMask); + client->manager_window = XGetSelectionOwner(server.display, server.atom._XSETTINGS_SCREEN); + if (client->manager_window) + XSelectInput(server.display, client->manager_window, PropertyChangeMask | StructureNotifyMask); - XUngrabServer(client->display); - XFlush(client->display); + XUngrabServer(client->display); + XFlush(client->display); - if (client->manager_window && client->watch) - client->watch(client->manager_window, True, PropertyChangeMask | StructureNotifyMask, client->cb_data); + if (client->manager_window && client->watch) + client->watch(client->manager_window, True, PropertyChangeMask | StructureNotifyMask, client->cb_data); - read_settings(client); + read_settings(client); } XSettingsClient *xsettings_client_new(Display *display, - int screen, - XSettingsNotifyFunc notify, - XSettingsWatchFunc watch, - void *cb_data) + int screen, + XSettingsNotifyFunc notify, + XSettingsWatchFunc watch, + void *cb_data) { - XSettingsClient *client = calloc(1, sizeof *client); - if (!client) - return NULL; + XSettingsClient *client = calloc(1, sizeof *client); + if (!client) + return NULL; - client->display = display; - client->screen = screen; - client->notify = notify; - client->watch = watch; - client->cb_data = cb_data; + client->display = display; + client->screen = screen; + client->notify = notify; + client->watch = watch; + client->cb_data = cb_data; - client->manager_window = None; - client->settings = NULL; + client->manager_window = None; + client->settings = NULL; - if (client->watch) - client->watch(RootWindow(display, screen), True, StructureNotifyMask, client->cb_data); + if (client->watch) + client->watch(RootWindow(display, screen), True, StructureNotifyMask, client->cb_data); - check_manager_window(client); + check_manager_window(client); - if (client->manager_window == None) { - printf("No XSETTINGS manager, tint2 uses config option 'launcher_icon_theme'.\n"); - free(client); - return NULL; - } else { - return client; - } + if (client->manager_window == None) { + printf("No XSETTINGS manager, tint2 uses config option 'launcher_icon_theme'.\n"); + free(client); + return NULL; + } else { + return client; + } } void xsettings_client_destroy(XSettingsClient *client) { - if (!client) - return; - if (client->watch) - client->watch(RootWindow(client->display, client->screen), False, 0, client->cb_data); - if (client->manager_window && client->watch) - client->watch(client->manager_window, False, 0, client->cb_data); + if (!client) + return; + if (client->watch) + client->watch(RootWindow(client->display, client->screen), False, 0, client->cb_data); + if (client->manager_window && client->watch) + client->watch(client->manager_window, False, 0, client->cb_data); - xsettings_list_free(client->settings); - free(client); + xsettings_list_free(client->settings); + free(client); } XSettingsResult xsettings_client_get_setting(XSettingsClient *client, const char *name, XSettingsSetting **setting) { - XSettingsSetting *search = xsettings_list_lookup(client->settings, name); - if (search) { - *setting = xsettings_setting_copy(search); - return *setting ? XSETTINGS_SUCCESS : XSETTINGS_NO_MEM; - } else - return XSETTINGS_NO_ENTRY; + XSettingsSetting *search = xsettings_list_lookup(client->settings, name); + if (search) { + *setting = xsettings_setting_copy(search); + return *setting ? XSETTINGS_SUCCESS : XSETTINGS_NO_MEM; + } else + return XSETTINGS_NO_ENTRY; } Bool xsettings_client_process_event(XSettingsClient *client, XEvent *xev) { - /* The checks here will not unlikely cause us to reread - * the properties from the manager window a number of - * times when the manager changes from A->B. But manager changes - * are going to be pretty rare. - */ - if (xev->xany.window == RootWindow(server.display, server.screen)) { - if (xev->xany.type == ClientMessage && xev->xclient.message_type == server.atom.MANAGER) { - check_manager_window(client); - return True; - } - } else if (xev->xany.window == client->manager_window) { - if (xev->xany.type == DestroyNotify) { - check_manager_window(client); - return True; - } else if (xev->xany.type == PropertyNotify) { - read_settings(client); - return True; - } - } + /* The checks here will not unlikely cause us to reread + * the properties from the manager window a number of + * times when the manager changes from A->B. But manager changes + * are going to be pretty rare. + */ + if (xev->xany.window == RootWindow(server.display, server.screen)) { + if (xev->xany.type == ClientMessage && xev->xclient.message_type == server.atom.MANAGER) { + check_manager_window(client); + return True; + } + } else if (xev->xany.window == client->manager_window) { + if (xev->xany.type == DestroyNotify) { + check_manager_window(client); + return True; + } else if (xev->xany.type == PropertyNotify) { + read_settings(client); + return True; + } + } - return False; + return False; }
M src/launcher/xsettings-client.hsrc/launcher/xsettings-client.h

@@ -38,10 +38,10 @@ typedef void (*XSettingsNotifyFunc)(const char *name, XSettingsAction action, XSettingsSetting *setting, void *cb_data);

typedef void (*XSettingsWatchFunc)(Window window, Bool is_start, long mask, void *cb_data); XSettingsClient *xsettings_client_new(Display *display, - int screen, - XSettingsNotifyFunc notify, - XSettingsWatchFunc watch, - void *cb_data); + int screen, + XSettingsNotifyFunc notify, + XSettingsWatchFunc watch, + void *cb_data); void xsettings_client_destroy(XSettingsClient *client); Bool xsettings_client_process_event(XSettingsClient *client, XEvent *xev);
M src/launcher/xsettings-common.csrc/launcher/xsettings-common.c

@@ -30,216 +30,216 @@ #include "xsettings-common.h"

XSettingsSetting *xsettings_setting_copy(XSettingsSetting *setting) { - XSettingsSetting *result; - size_t str_len; + XSettingsSetting *result; + size_t str_len; - result = calloc(1, sizeof *result); - if (!result) - return NULL; + result = calloc(1, sizeof *result); + if (!result) + return NULL; - str_len = strlen(setting->name); - result->name = calloc(str_len + 1, 1); - if (!result->name) - goto err; + str_len = strlen(setting->name); + result->name = calloc(str_len + 1, 1); + if (!result->name) + goto err; - memcpy(result->name, setting->name, str_len + 1); + memcpy(result->name, setting->name, str_len + 1); - result->type = setting->type; + result->type = setting->type; - switch (setting->type) { - case XSETTINGS_TYPE_INT: - result->data.v_int = setting->data.v_int; - break; - case XSETTINGS_TYPE_COLOR: - result->data.v_color = setting->data.v_color; - break; - case XSETTINGS_TYPE_STRING: - str_len = strlen(setting->data.v_string); - result->data.v_string = calloc(str_len + 1, 1); - if (!result->data.v_string) - goto err; + switch (setting->type) { + case XSETTINGS_TYPE_INT: + result->data.v_int = setting->data.v_int; + break; + case XSETTINGS_TYPE_COLOR: + result->data.v_color = setting->data.v_color; + break; + case XSETTINGS_TYPE_STRING: + str_len = strlen(setting->data.v_string); + result->data.v_string = calloc(str_len + 1, 1); + if (!result->data.v_string) + goto err; - memcpy(result->data.v_string, setting->data.v_string, str_len + 1); - break; - default: - break; - } + memcpy(result->data.v_string, setting->data.v_string, str_len + 1); + break; + default: + break; + } - result->last_change_serial = setting->last_change_serial; + result->last_change_serial = setting->last_change_serial; - return result; + return result; err: - if (result->name) - free(result->name); - free(result); + if (result->name) + free(result->name); + free(result); - return NULL; + return NULL; } XSettingsList *xsettings_list_copy(XSettingsList *list) { - XSettingsList *new = NULL; - XSettingsList *old_iter = list; - XSettingsList *new_iter = NULL; + XSettingsList *new = NULL; + XSettingsList *old_iter = list; + XSettingsList *new_iter = NULL; - while (old_iter) { - XSettingsList *new_node; + while (old_iter) { + XSettingsList *new_node; - new_node = calloc(1, sizeof *new_node); - if (!new_node) - goto error; + new_node = calloc(1, sizeof *new_node); + if (!new_node) + goto error; - new_node->setting = xsettings_setting_copy(old_iter->setting); - if (!new_node->setting) { - free(new_node); - goto error; - } + new_node->setting = xsettings_setting_copy(old_iter->setting); + if (!new_node->setting) { + free(new_node); + goto error; + } - if (new_iter) - new_iter->next = new_node; - else - new = new_node; + if (new_iter) + new_iter->next = new_node; + else + new = new_node; - new_iter = new_node; + new_iter = new_node; - old_iter = old_iter->next; - } + old_iter = old_iter->next; + } - return new; + return new; error: - xsettings_list_free(new); - return NULL; + xsettings_list_free(new); + return NULL; } int xsettings_setting_equal(XSettingsSetting *setting_a, XSettingsSetting *setting_b) { - if (setting_a->type != setting_b->type) - return 0; + if (setting_a->type != setting_b->type) + return 0; - if (strcmp(setting_a->name, setting_b->name) != 0) - return 0; + if (strcmp(setting_a->name, setting_b->name) != 0) + return 0; - switch (setting_a->type) { - case XSETTINGS_TYPE_INT: - return setting_a->data.v_int == setting_b->data.v_int; - case XSETTINGS_TYPE_COLOR: - return (setting_a->data.v_color.red == setting_b->data.v_color.red && - setting_a->data.v_color.green == setting_b->data.v_color.green && - setting_a->data.v_color.blue == setting_b->data.v_color.blue && - setting_a->data.v_color.alpha == setting_b->data.v_color.alpha); - case XSETTINGS_TYPE_STRING: - return strcmp(setting_a->data.v_string, setting_b->data.v_string) == 0; - default: - break; - } + switch (setting_a->type) { + case XSETTINGS_TYPE_INT: + return setting_a->data.v_int == setting_b->data.v_int; + case XSETTINGS_TYPE_COLOR: + return (setting_a->data.v_color.red == setting_b->data.v_color.red && + setting_a->data.v_color.green == setting_b->data.v_color.green && + setting_a->data.v_color.blue == setting_b->data.v_color.blue && + setting_a->data.v_color.alpha == setting_b->data.v_color.alpha); + case XSETTINGS_TYPE_STRING: + return strcmp(setting_a->data.v_string, setting_b->data.v_string) == 0; + default: + break; + } - return 0; + return 0; } void xsettings_setting_free(XSettingsSetting *setting) { - if (setting->type == XSETTINGS_TYPE_STRING) - free(setting->data.v_string); + if (setting->type == XSETTINGS_TYPE_STRING) + free(setting->data.v_string); - if (setting->name) - free(setting->name); + if (setting->name) + free(setting->name); - free(setting); + free(setting); } void xsettings_list_free(XSettingsList *list) { - while (list) { - XSettingsList *next = list->next; + while (list) { + XSettingsList *next = list->next; - xsettings_setting_free(list->setting); - free(list); + xsettings_setting_free(list->setting); + free(list); - list = next; - } + list = next; + } } XSettingsResult xsettings_list_insert(XSettingsList **list, XSettingsSetting *setting) { - XSettingsList *node; - XSettingsList *iter; - XSettingsList *last = NULL; + XSettingsList *node; + XSettingsList *iter; + XSettingsList *last = NULL; - node = calloc(1, sizeof *node); - if (!node) - return XSETTINGS_NO_MEM; - node->setting = setting; + node = calloc(1, sizeof *node); + if (!node) + return XSETTINGS_NO_MEM; + node->setting = setting; - iter = *list; - while (iter) { - int cmp = strcmp(setting->name, iter->setting->name); + iter = *list; + while (iter) { + int cmp = strcmp(setting->name, iter->setting->name); - if (cmp < 0) - break; - else if (cmp == 0) { - free(node); - return XSETTINGS_DUPLICATE_ENTRY; - } + if (cmp < 0) + break; + else if (cmp == 0) { + free(node); + return XSETTINGS_DUPLICATE_ENTRY; + } - last = iter; - iter = iter->next; - } + last = iter; + iter = iter->next; + } - if (last) - last->next = node; - else - *list = node; + if (last) + last->next = node; + else + *list = node; - node->next = iter; + node->next = iter; - return XSETTINGS_SUCCESS; + return XSETTINGS_SUCCESS; } XSettingsResult xsettings_list_delete(XSettingsList **list, const char *name) { - XSettingsList *iter; - XSettingsList *last = NULL; + XSettingsList *iter; + XSettingsList *last = NULL; - iter = *list; - while (iter) { - if (strcmp(name, iter->setting->name) == 0) { - if (last) - last->next = iter->next; - else - *list = iter->next; + iter = *list; + while (iter) { + if (strcmp(name, iter->setting->name) == 0) { + if (last) + last->next = iter->next; + else + *list = iter->next; - xsettings_setting_free(iter->setting); - free(iter); + xsettings_setting_free(iter->setting); + free(iter); - return XSETTINGS_SUCCESS; - } + return XSETTINGS_SUCCESS; + } - last = iter; - iter = iter->next; - } + last = iter; + iter = iter->next; + } - return XSETTINGS_FAILED; + return XSETTINGS_FAILED; } XSettingsSetting *xsettings_list_lookup(XSettingsList *list, const char *name) { - XSettingsList *iter; + XSettingsList *iter; - iter = list; - while (iter) { - if (strcmp(name, iter->setting->name) == 0) - return iter->setting; + iter = list; + while (iter) { + if (strcmp(name, iter->setting->name) == 0) + return iter->setting; - iter = iter->next; - } + iter = iter->next; + } - return NULL; + return NULL; } char xsettings_byte_order(void) { - CARD32 myint = 0x01020304; - return (*(char *)&myint == 1) ? MSBFirst : LSBFirst; + CARD32 myint = 0x01020304; + return (*(char *)&myint == 1) ? MSBFirst : LSBFirst; }
M src/launcher/xsettings-common.hsrc/launcher/xsettings-common.h

@@ -36,48 +36,48 @@ /* Types of settings possible. Enum values correspond to

* protocol values. */ typedef enum { - XSETTINGS_TYPE_INT = 0, - XSETTINGS_TYPE_STRING = 1, - XSETTINGS_TYPE_COLOR = 2, - XSETTINGS_TYPE_NONE = 0xff + XSETTINGS_TYPE_INT = 0, + XSETTINGS_TYPE_STRING = 1, + XSETTINGS_TYPE_COLOR = 2, + XSETTINGS_TYPE_NONE = 0xff } XSettingsType; typedef enum { - XSETTINGS_SUCCESS, - XSETTINGS_NO_MEM, - XSETTINGS_ACCESS, - XSETTINGS_FAILED, - XSETTINGS_NO_ENTRY, - XSETTINGS_DUPLICATE_ENTRY + XSETTINGS_SUCCESS, + XSETTINGS_NO_MEM, + XSETTINGS_ACCESS, + XSETTINGS_FAILED, + XSETTINGS_NO_ENTRY, + XSETTINGS_DUPLICATE_ENTRY } XSettingsResult; struct _XSettingsBuffer { - char byte_order; - size_t len; - unsigned char *data; - unsigned char *pos; + char byte_order; + size_t len; + unsigned char *data; + unsigned char *pos; }; struct _XSettingsColor { - unsigned short red, green, blue, alpha; + unsigned short red, green, blue, alpha; }; struct _XSettingsList { - XSettingsSetting *setting; - XSettingsList *next; + XSettingsSetting *setting; + XSettingsList *next; }; struct _XSettingsSetting { - char *name; - XSettingsType type; + char *name; + XSettingsType type; - union { - int v_int; - char *v_string; - XSettingsColor v_color; - } data; + union { + int v_int; + char *v_string; + XSettingsColor v_color; + } data; - unsigned long last_change_serial; + unsigned long last_change_serial; }; XSettingsSetting *xsettings_setting_copy(XSettingsSetting *setting);
M src/panel.csrc/panel.c

@@ -82,1058 +82,1058 @@ char *default_font = NULL;

void default_panel() { - panels = NULL; - num_panels = 0; - default_icon = NULL; - task_dragged = FALSE; - panel_horizontal = TRUE; - panel_position = CENTER; - panel_items_order = NULL; - panel_autohide = FALSE; - panel_autohide_show_timeout = 0; - panel_autohide_hide_timeout = 0; - panel_autohide_height = 5; // for vertical panels this is of course the width - panel_shrink = FALSE; - panel_strut_policy = STRUT_FOLLOW_SIZE; - panel_dock = FALSE; // default not in the dock - panel_layer = BOTTOM_LAYER; // default is bottom layer - panel_window_name = strdup("tint2"); - wm_menu = FALSE; - max_tick_urgent = 14; - mouse_left = TOGGLE_ICONIFY; - backgrounds = g_array_new(0, 0, sizeof(Background)); - gradients = g_array_new(0, 0, sizeof(GradientClass)); + panels = NULL; + num_panels = 0; + default_icon = NULL; + task_dragged = FALSE; + panel_horizontal = TRUE; + panel_position = CENTER; + panel_items_order = NULL; + panel_autohide = FALSE; + panel_autohide_show_timeout = 0; + panel_autohide_hide_timeout = 0; + panel_autohide_height = 5; // for vertical panels this is of course the width + panel_shrink = FALSE; + panel_strut_policy = STRUT_FOLLOW_SIZE; + panel_dock = FALSE; // default not in the dock + panel_layer = BOTTOM_LAYER; // default is bottom layer + panel_window_name = strdup("tint2"); + wm_menu = FALSE; + max_tick_urgent = 14; + mouse_left = TOGGLE_ICONIFY; + backgrounds = g_array_new(0, 0, sizeof(Background)); + gradients = g_array_new(0, 0, sizeof(GradientClass)); - memset(&panel_config, 0, sizeof(Panel)); - snprintf(panel_config.area.name, sizeof(panel_config.area.name), "Panel"); - panel_config.mouse_over_alpha = 100; - panel_config.mouse_over_saturation = 0; - panel_config.mouse_over_brightness = 10; - panel_config.mouse_pressed_alpha = 100; - panel_config.mouse_pressed_saturation = 0; - panel_config.mouse_pressed_brightness = 0; - panel_config.mouse_effects = 1; + memset(&panel_config, 0, sizeof(Panel)); + snprintf(panel_config.area.name, sizeof(panel_config.area.name), "Panel"); + panel_config.mouse_over_alpha = 100; + panel_config.mouse_over_saturation = 0; + panel_config.mouse_over_brightness = 10; + panel_config.mouse_pressed_alpha = 100; + panel_config.mouse_pressed_saturation = 0; + panel_config.mouse_pressed_brightness = 0; + panel_config.mouse_effects = 1; - // First background is always fully transparent - Background transparent_bg; - init_background(&transparent_bg); - g_array_append_val(backgrounds, transparent_bg); - GradientClass transparent_gradient; - init_gradient(&transparent_gradient, GRADIENT_VERTICAL); - g_array_append_val(gradients, transparent_gradient); + // First background is always fully transparent + Background transparent_bg; + init_background(&transparent_bg); + g_array_append_val(backgrounds, transparent_bg); + GradientClass transparent_gradient; + init_gradient(&transparent_gradient, GRADIENT_VERTICAL); + g_array_append_val(gradients, transparent_gradient); } void cleanup_panel() { - if (!panels) - return; + if (!panels) + return; - cleanup_taskbar(); + cleanup_taskbar(); - for (int i = 0; i < num_panels; i++) { - Panel *p = &panels[i]; + for (int i = 0; i < num_panels; i++) { + Panel *p = &panels[i]; - free_area(&p->area); - if (p->temp_pmap) - XFreePixmap(server.display, p->temp_pmap); - p->temp_pmap = 0; - if (p->hidden_pixmap) - XFreePixmap(server.display, p->hidden_pixmap); - p->hidden_pixmap = 0; - if (p->main_win) - XDestroyWindow(server.display, p->main_win); - p->main_win = 0; - stop_timeout(p->autohide_timeout); - cleanup_freespace(p); - } + free_area(&p->area); + if (p->temp_pmap) + XFreePixmap(server.display, p->temp_pmap); + p->temp_pmap = 0; + if (p->hidden_pixmap) + XFreePixmap(server.display, p->hidden_pixmap); + p->hidden_pixmap = 0; + if (p->main_win) + XDestroyWindow(server.display, p->main_win); + p->main_win = 0; + stop_timeout(p->autohide_timeout); + cleanup_freespace(p); + } - free(panel_items_order); - panel_items_order = NULL; - free(panel_window_name); - panel_window_name = NULL; - free(panels); - panels = NULL; + free(panel_items_order); + panel_items_order = NULL; + free(panel_window_name); + panel_window_name = NULL; + free(panels); + panels = NULL; - free_area(&panel_config.area); + free_area(&panel_config.area); - g_array_free(backgrounds, TRUE); - backgrounds = NULL; - if (gradients) { - for (guint i = 0; i < gradients->len; i++) - cleanup_gradient(&g_array_index(gradients, GradientClass, i)); - g_array_free(gradients, TRUE); - } - gradients = NULL; - pango_font_description_free(panel_config.g_task.font_desc); - panel_config.g_task.font_desc = NULL; - pango_font_description_free(panel_config.taskbarname_font_desc); - panel_config.taskbarname_font_desc = NULL; + g_array_free(backgrounds, TRUE); + backgrounds = NULL; + if (gradients) { + for (guint i = 0; i < gradients->len; i++) + cleanup_gradient(&g_array_index(gradients, GradientClass, i)); + g_array_free(gradients, TRUE); + } + gradients = NULL; + pango_font_description_free(panel_config.g_task.font_desc); + panel_config.g_task.font_desc = NULL; + pango_font_description_free(panel_config.taskbarname_font_desc); + panel_config.taskbarname_font_desc = NULL; } void init_panel() { - if (panel_config.monitor > (server.num_monitors - 1)) { - // server.num_monitors minimum value is 1 (see get_monitors()) - fprintf(stderr, "warning : monitor not found. tint2 default to all monitors.\n"); - panel_config.monitor = 0; - } + if (panel_config.monitor > (server.num_monitors - 1)) { + // server.num_monitors minimum value is 1 (see get_monitors()) + 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); + fprintf(stderr, "panel items: %s\n", panel_items_order); - icon_theme_wrapper = NULL; + icon_theme_wrapper = NULL; - init_tooltip(); - init_systray(); - init_launcher(); - init_clock(); + init_tooltip(); + init_systray(); + init_launcher(); + init_clock(); #ifdef ENABLE_BATTERY - init_battery(); + init_battery(); #endif - init_taskbar(); - init_separator(); - init_execp(); - init_button(); + init_taskbar(); + init_separator(); + init_execp(); + init_button(); - // number of panels (one monitor or 'all' monitors) - if (panel_config.monitor >= 0) - num_panels = 1; - else - num_panels = server.num_monitors; + // number of panels (one monitor or 'all' monitors) + if (panel_config.monitor >= 0) + num_panels = 1; + else + num_panels = server.num_monitors; - panels = calloc(num_panels, sizeof(Panel)); - for (int i = 0; i < num_panels; i++) { - memcpy(&panels[i], &panel_config, sizeof(Panel)); - } + panels = calloc(num_panels, sizeof(Panel)); + for (int i = 0; i < num_panels; i++) { + memcpy(&panels[i], &panel_config, sizeof(Panel)); + } - fprintf(stderr, - "tint2 : nb monitor %d, nb monitor used %d, nb desktop %d\n", - server.num_monitors, - num_panels, - server.num_desktops); - for (int i = 0; i < num_panels; i++) { - Panel *p = &panels[i]; + fprintf(stderr, + "tint2 : nb monitor %d, nb monitor used %d, nb desktop %d\n", + server.num_monitors, + num_panels, + server.num_desktops); + for (int i = 0; i < num_panels; i++) { + Panel *p = &panels[i]; - if (panel_config.monitor < 0) - p->monitor = i; - if (!p->area.bg) - p->area.bg = &g_array_index(backgrounds, Background, 0); - p->area.parent = p; - p->area.panel = p; - snprintf(p->area.name, sizeof(p->area.name), "Panel %d", i); - p->area.on_screen = TRUE; - p->area.resize_needed = 1; - p->area.size_mode = LAYOUT_DYNAMIC; - p->area._resize = resize_panel; - p->area._clear = panel_clear_background; - p->separator_list = NULL; - init_panel_size_and_position(p); - instantiate_area_gradients(&p->area); - // add children according to panel_items - for (int k = 0; k < strlen(panel_items_order); k++) { - if (panel_items_order[k] == 'L') - init_launcher_panel(p); - if (panel_items_order[k] == 'T') - init_taskbar_panel(p); + if (panel_config.monitor < 0) + p->monitor = i; + if (!p->area.bg) + p->area.bg = &g_array_index(backgrounds, Background, 0); + p->area.parent = p; + p->area.panel = p; + snprintf(p->area.name, sizeof(p->area.name), "Panel %d", i); + p->area.on_screen = TRUE; + p->area.resize_needed = 1; + p->area.size_mode = LAYOUT_DYNAMIC; + p->area._resize = resize_panel; + p->area._clear = panel_clear_background; + p->separator_list = NULL; + init_panel_size_and_position(p); + instantiate_area_gradients(&p->area); + // add children according to panel_items + for (int k = 0; k < strlen(panel_items_order); k++) { + if (panel_items_order[k] == 'L') + init_launcher_panel(p); + if (panel_items_order[k] == 'T') + init_taskbar_panel(p); #ifdef ENABLE_BATTERY - if (panel_items_order[k] == 'B') - init_battery_panel(p); + if (panel_items_order[k] == 'B') + init_battery_panel(p); #endif - if (panel_items_order[k] == 'S' && systray_on_monitor(i, num_panels)) { - init_systray_panel(p); - refresh_systray = 1; - } - if (panel_items_order[k] == 'C') - init_clock_panel(p); - if (panel_items_order[k] == 'F' && !strstr(panel_items_order, "T")) - init_freespace_panel(p); - if (panel_items_order[k] == ':') - init_separator_panel(p); - if (panel_items_order[k] == 'E') - init_execp_panel(p); - if (panel_items_order[k] == 'P') - init_button_panel(p); - } - set_panel_items_order(p); + if (panel_items_order[k] == 'S' && systray_on_monitor(i, num_panels)) { + init_systray_panel(p); + refresh_systray = 1; + } + if (panel_items_order[k] == 'C') + init_clock_panel(p); + if (panel_items_order[k] == 'F' && !strstr(panel_items_order, "T")) + init_freespace_panel(p); + if (panel_items_order[k] == ':') + init_separator_panel(p); + if (panel_items_order[k] == 'E') + init_execp_panel(p); + if (panel_items_order[k] == 'P') + init_button_panel(p); + } + set_panel_items_order(p); - // catch some events - XSetWindowAttributes att = {.colormap = server.colormap, .background_pixel = 0, .border_pixel = 0}; - unsigned long mask = CWEventMask | CWColormap | CWBackPixel | CWBorderPixel; - p->main_win = XCreateWindow(server.display, - server.root_win, - p->posx, - p->posy, - p->area.width, - p->area.height, - 0, - server.depth, - InputOutput, - server.visual, - mask, - &att); + // catch some events + XSetWindowAttributes att = {.colormap = server.colormap, .background_pixel = 0, .border_pixel = 0}; + unsigned long mask = CWEventMask | CWColormap | CWBackPixel | CWBorderPixel; + p->main_win = XCreateWindow(server.display, + server.root_win, + p->posx, + p->posy, + p->area.width, + p->area.height, + 0, + server.depth, + InputOutput, + server.visual, + mask, + &att); - long event_mask = ExposureMask | ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | PropertyChangeMask; - if (p->mouse_effects || p->g_task.tooltip_enabled || p->clock.area._get_tooltip_text || - (launcher_enabled && launcher_tooltip_enabled)) - event_mask |= PointerMotionMask | LeaveWindowMask; - if (panel_autohide) - event_mask |= LeaveWindowMask | EnterWindowMask; - XChangeWindowAttributes(server.display, - p->main_win, - CWEventMask, - &(XSetWindowAttributes){.event_mask = event_mask}); + long event_mask = ExposureMask | ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | PropertyChangeMask; + if (p->mouse_effects || p->g_task.tooltip_enabled || p->clock.area._get_tooltip_text || + (launcher_enabled && launcher_tooltip_enabled)) + event_mask |= PointerMotionMask | LeaveWindowMask; + if (panel_autohide) + event_mask |= LeaveWindowMask | EnterWindowMask; + XChangeWindowAttributes(server.display, + p->main_win, + CWEventMask, + &(XSetWindowAttributes){.event_mask = event_mask}); - if (!server.gc) { - XGCValues gcv; - server.gc = XCreateGC(server.display, p->main_win, 0, &gcv); - } - // printf("panel %d : %d, %d, %d, %d\n", i, p->posx, p->posy, p->area.width, p->area.height); - set_panel_properties(p); - set_panel_background(p); - if (!snapshot_path) { - // if we are not in 'snapshot' mode then map new panel - XMapWindow(server.display, p->main_win); - } + if (!server.gc) { + XGCValues gcv; + server.gc = XCreateGC(server.display, p->main_win, 0, &gcv); + } + // printf("panel %d : %d, %d, %d, %d\n", i, p->posx, p->posy, p->area.width, p->area.height); + set_panel_properties(p); + set_panel_background(p); + if (!snapshot_path) { + // if we are not in 'snapshot' mode then map new panel + XMapWindow(server.display, p->main_win); + } - if (panel_autohide) - autohide_trigger_hide(p); - } + if (panel_autohide) + autohide_trigger_hide(p); + } - taskbar_refresh_tasklist(); - reset_active_task(); - update_all_taskbars_visibility(); + taskbar_refresh_tasklist(); + reset_active_task(); + update_all_taskbars_visibility(); } void panel_compute_size(Panel *panel) { - 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 = (server.monitors[panel->monitor].width - panel->marginx) * panel->area.width / 100; - if (panel->fractional_height) - panel->area.height = (server.monitors[panel->monitor].height - panel->marginy) * panel->area.height / 100; - if (panel->area.bg->border.radius > panel->area.height / 2) { - printf("panel_background_id rounded is too big... please fix your tint2rc\n"); - g_array_append_val(backgrounds, *panel->area.bg); - 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 = (server.monitors[panel->monitor].height - panel->marginy) * panel->area.width / 100; - else - panel->area.height = panel->area.width; + 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 = (server.monitors[panel->monitor].width - panel->marginx) * panel->area.width / 100; + if (panel->fractional_height) + panel->area.height = (server.monitors[panel->monitor].height - panel->marginy) * panel->area.height / 100; + if (panel->area.bg->border.radius > panel->area.height / 2) { + printf("panel_background_id rounded is too big... please fix your tint2rc\n"); + g_array_append_val(backgrounds, *panel->area.bg); + 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 = (server.monitors[panel->monitor].height - panel->marginy) * panel->area.width / 100; + else + panel->area.height = panel->area.width; - if (panel->fractional_height) - panel->area.width = (server.monitors[panel->monitor].width - panel->marginx) * old_panel_height / 100; - else - panel->area.width = old_panel_height; + if (panel->fractional_height) + panel->area.width = (server.monitors[panel->monitor].width - panel->marginx) * old_panel_height / 100; + else + panel->area.width = old_panel_height; - if (panel->area.bg->border.radius > panel->area.width / 2) { - printf("panel_background_id rounded is too big... please fix your tint2rc\n"); - g_array_append_val(backgrounds, *panel->area.bg); - panel->area.bg = &g_array_index(backgrounds, Background, backgrounds->len - 1); - panel->area.bg->border.radius = panel->area.width / 2; - } - } + if (panel->area.bg->border.radius > panel->area.width / 2) { + printf("panel_background_id rounded is too big... please fix your tint2rc\n"); + g_array_append_val(backgrounds, *panel->area.bg); + panel->area.bg = &g_array_index(backgrounds, Background, backgrounds->len - 1); + panel->area.bg->border.radius = panel->area.width / 2; + } + } - if (panel->area.width + panel->marginx > server.monitors[panel->monitor].width) - panel->area.width = server.monitors[panel->monitor].width - panel->marginx; - if (panel->area.height + panel->marginy > server.monitors[panel->monitor].height) - panel->area.height = server.monitors[panel->monitor].height - panel->marginy; + if (panel->area.width + panel->marginx > server.monitors[panel->monitor].width) + panel->area.width = server.monitors[panel->monitor].width - panel->marginx; + if (panel->area.height + panel->marginy > server.monitors[panel->monitor].height) + panel->area.height = server.monitors[panel->monitor].height - panel->marginy; - panel->max_size = panel_horizontal ? panel->area.width : panel->area.height; + panel->max_size = panel_horizontal ? panel->area.width : panel->area.height; } void panel_compute_position(Panel *panel) { - // panel position determined here - if (panel_position & LEFT) { - panel->posx = server.monitors[panel->monitor].x + panel->marginx; - } else { - if (panel_position & RIGHT) { - panel->posx = server.monitors[panel->monitor].x + server.monitors[panel->monitor].width - - panel->area.width - panel->marginx; - } else { - if (panel_horizontal) - panel->posx = server.monitors[panel->monitor].x + - ((server.monitors[panel->monitor].width - panel->area.width) / 2); - else - panel->posx = server.monitors[panel->monitor].x + panel->marginx; - } - } - if (panel_position & TOP) { - panel->posy = server.monitors[panel->monitor].y + panel->marginy; - } else { - if (panel_position & BOTTOM) { - panel->posy = server.monitors[panel->monitor].y + server.monitors[panel->monitor].height - - panel->area.height - panel->marginy; - } else { - panel->posy = - server.monitors[panel->monitor].y + ((server.monitors[panel->monitor].height - panel->area.height) / 2); - } - } + // panel position determined here + if (panel_position & LEFT) { + panel->posx = server.monitors[panel->monitor].x + panel->marginx; + } else { + if (panel_position & RIGHT) { + panel->posx = server.monitors[panel->monitor].x + server.monitors[panel->monitor].width - + panel->area.width - panel->marginx; + } else { + if (panel_horizontal) + panel->posx = server.monitors[panel->monitor].x + + ((server.monitors[panel->monitor].width - panel->area.width) / 2); + else + panel->posx = server.monitors[panel->monitor].x + panel->marginx; + } + } + if (panel_position & TOP) { + panel->posy = server.monitors[panel->monitor].y + panel->marginy; + } else { + if (panel_position & BOTTOM) { + panel->posy = server.monitors[panel->monitor].y + server.monitors[panel->monitor].height - + panel->area.height - panel->marginy; + } else { + panel->posy = + server.monitors[panel->monitor].y + ((server.monitors[panel->monitor].height - panel->area.height) / 2); + } + } - // autohide or strut_policy=minimum - int diff = (panel_horizontal ? panel->area.height : panel->area.width) - panel_autohide_height; - if (panel_horizontal) { - panel->hidden_width = panel->area.width; - panel->hidden_height = panel->area.height - diff; - } else { - panel->hidden_width = panel->area.width - diff; - panel->hidden_height = panel->area.height; - } - // printf("panel : posx %d, posy %d, width %d, height %d\n", panel->posx, panel->posy, panel->area.width, - // panel->area.height); + // autohide or strut_policy=minimum + int diff = (panel_horizontal ? panel->area.height : panel->area.width) - panel_autohide_height; + if (panel_horizontal) { + panel->hidden_width = panel->area.width; + panel->hidden_height = panel->area.height - diff; + } else { + panel->hidden_width = panel->area.width - diff; + panel->hidden_height = panel->area.height; + } + // printf("panel : posx %d, posy %d, width %d, height %d\n", panel->posx, panel->posy, panel->area.width, + // panel->area.height); } void init_panel_size_and_position(Panel *panel) { - panel_compute_size(panel); - panel_compute_position(panel); + panel_compute_size(panel); + panel_compute_position(panel); } gboolean resize_panel(void *obj) { - Panel *panel = (Panel *)obj; - relayout_with_constraint(&panel->area, 0); + Panel *panel = (Panel *)obj; + relayout_with_constraint(&panel->area, 0); - // printf("resize_panel\n"); - if (taskbar_mode != MULTI_DESKTOP && taskbar_enabled) { - // propagate width/height on hidden taskbar - int width = panel->taskbar[server.desktop].area.width; - int height = panel->taskbar[server.desktop].area.height; - for (int i = 0; i < panel->num_desktops; i++) { - panel->taskbar[i].area.resize_needed = - panel->taskbar[i].area.width != width || panel->taskbar[i].area.height != height; - panel->taskbar[i].area.width = width; - panel->taskbar[i].area.height = height; - } - } else if (taskbar_mode == MULTI_DESKTOP && taskbar_enabled && taskbar_distribute_size) { - for (int i = 0; i < panel->num_desktops; i++) { - Taskbar *taskbar = &panel->taskbar[i]; - taskbar->area.old_width = taskbar->area.width; - taskbar->area.old_height = taskbar->area.height; - } + // printf("resize_panel\n"); + if (taskbar_mode != MULTI_DESKTOP && taskbar_enabled) { + // propagate width/height on hidden taskbar + int width = panel->taskbar[server.desktop].area.width; + int height = panel->taskbar[server.desktop].area.height; + for (int i = 0; i < panel->num_desktops; i++) { + panel->taskbar[i].area.resize_needed = + panel->taskbar[i].area.width != width || panel->taskbar[i].area.height != height; + panel->taskbar[i].area.width = width; + panel->taskbar[i].area.height = height; + } + } else if (taskbar_mode == MULTI_DESKTOP && taskbar_enabled && taskbar_distribute_size) { + for (int i = 0; i < panel->num_desktops; i++) { + Taskbar *taskbar = &panel->taskbar[i]; + taskbar->area.old_width = taskbar->area.width; + taskbar->area.old_height = taskbar->area.height; + } - // The total available size - int total_size = 0; - for (int i = 0; i < panel->num_desktops; i++) { - Taskbar *taskbar = &panel->taskbar[i]; - if (!taskbar->area.on_screen) - continue; - total_size += panel_horizontal ? taskbar->area.width : taskbar->area.height; - } + // The total available size + int total_size = 0; + for (int i = 0; i < panel->num_desktops; i++) { + Taskbar *taskbar = &panel->taskbar[i]; + if (!taskbar->area.on_screen) + continue; + total_size += panel_horizontal ? taskbar->area.width : taskbar->area.height; + } - // Reserve size for padding, taskbarname and spacings - for (int i = 0; i < panel->num_desktops; i++) { - Taskbar *taskbar = &panel->taskbar[i]; - if (!taskbar->area.on_screen) - continue; - if (panel_horizontal) - taskbar->area.width = 2 * taskbar->area.paddingxlr; - else - taskbar->area.height = 2 * taskbar->area.paddingxlr; - if (taskbarname_enabled && taskbar->area.children) { - Area *name = (Area *)taskbar->area.children->data; - if (name->on_screen) { - if (panel_horizontal) - taskbar->area.width += name->width; - else - taskbar->area.height += name->height; - } - } - gboolean first_child = TRUE; - for (GList *l = taskbar->area.children; l; l = l->next) { - Area *child = (Area *)l->data; - if (!child->on_screen) - continue; - if (!first_child) { - if (panel_horizontal) - taskbar->area.width += taskbar->area.paddingx; - else - taskbar->area.height += taskbar->area.paddingy; - } - first_child = FALSE; - } - total_size -= panel_horizontal ? taskbar->area.width : taskbar->area.height; - } + // Reserve size for padding, taskbarname and spacings + for (int i = 0; i < panel->num_desktops; i++) { + Taskbar *taskbar = &panel->taskbar[i]; + if (!taskbar->area.on_screen) + continue; + if (panel_horizontal) + taskbar->area.width = 2 * taskbar->area.paddingxlr; + else + taskbar->area.height = 2 * taskbar->area.paddingxlr; + if (taskbarname_enabled && taskbar->area.children) { + Area *name = (Area *)taskbar->area.children->data; + if (name->on_screen) { + if (panel_horizontal) + taskbar->area.width += name->width; + else + taskbar->area.height += name->height; + } + } + gboolean first_child = TRUE; + for (GList *l = taskbar->area.children; l; l = l->next) { + Area *child = (Area *)l->data; + if (!child->on_screen) + continue; + if (!first_child) { + if (panel_horizontal) + taskbar->area.width += taskbar->area.paddingx; + else + taskbar->area.height += taskbar->area.paddingy; + } + first_child = FALSE; + } + total_size -= panel_horizontal ? taskbar->area.width : taskbar->area.height; + } - // Compute the total number of tasks - int num_tasks = 0; - for (int i = 0; i < panel->num_desktops; i++) { - Taskbar *taskbar = &panel->taskbar[i]; - if (!taskbar->area.on_screen) - continue; - for (GList *l = taskbar->area.children; l; l = l->next) { - Area *child = (Area *)l->data; - if (!child->on_screen) - continue; - if (taskbarname_enabled && l == taskbar->area.children) - continue; - num_tasks++; - } - } + // Compute the total number of tasks + int num_tasks = 0; + for (int i = 0; i < panel->num_desktops; i++) { + Taskbar *taskbar = &panel->taskbar[i]; + if (!taskbar->area.on_screen) + continue; + for (GList *l = taskbar->area.children; l; l = l->next) { + Area *child = (Area *)l->data; + if (!child->on_screen) + continue; + if (taskbarname_enabled && l == taskbar->area.children) + continue; + num_tasks++; + } + } - // Distribute the remaining size between tasks - if (num_tasks > 0) { - int task_size = total_size / num_tasks; - for (int i = 0; i < panel->num_desktops; i++) { - Taskbar *taskbar = &panel->taskbar[i]; - if (!taskbar->area.on_screen) - continue; - for (GList *l = taskbar->area.children; l; l = l->next) { - Area *child = (Area *)l->data; - if (!child->on_screen) - continue; - if (taskbarname_enabled && l == taskbar->area.children) - continue; - if (panel_horizontal) - taskbar->area.width += task_size; - else - taskbar->area.height += task_size; - } - } - } else { - // No tasks => expand the first visible taskbar - for (int i = 0; i < panel->num_desktops; i++) { - Taskbar *taskbar = &panel->taskbar[i]; - if (!taskbar->area.on_screen) - continue; - if (panel_horizontal) - taskbar->area.width += total_size; - else - taskbar->area.height += total_size; - break; - } - } - for (int i = 0; i < panel->num_desktops; i++) { - Taskbar *taskbar = &panel->taskbar[i]; - taskbar->area.resize_needed = - taskbar->area.old_width != taskbar->area.width || taskbar->area.old_height != taskbar->area.height; - } - } - for (GList *l = panel->freespace_list; l; l = g_list_next(l)) - resize_freespace(l->data); - return FALSE; + // Distribute the remaining size between tasks + if (num_tasks > 0) { + int task_size = total_size / num_tasks; + for (int i = 0; i < panel->num_desktops; i++) { + Taskbar *taskbar = &panel->taskbar[i]; + if (!taskbar->area.on_screen) + continue; + for (GList *l = taskbar->area.children; l; l = l->next) { + Area *child = (Area *)l->data; + if (!child->on_screen) + continue; + if (taskbarname_enabled && l == taskbar->area.children) + continue; + if (panel_horizontal) + taskbar->area.width += task_size; + else + taskbar->area.height += task_size; + } + } + } else { + // No tasks => expand the first visible taskbar + for (int i = 0; i < panel->num_desktops; i++) { + Taskbar *taskbar = &panel->taskbar[i]; + if (!taskbar->area.on_screen) + continue; + if (panel_horizontal) + taskbar->area.width += total_size; + else + taskbar->area.height += total_size; + break; + } + } + for (int i = 0; i < panel->num_desktops; i++) { + Taskbar *taskbar = &panel->taskbar[i]; + taskbar->area.resize_needed = + taskbar->area.old_width != taskbar->area.width || taskbar->area.old_height != taskbar->area.height; + } + } + for (GList *l = panel->freespace_list; l; l = g_list_next(l)) + resize_freespace(l->data); + return FALSE; } void update_strut(Panel *p) { - if (panel_strut_policy == STRUT_NONE) { - XDeleteProperty(server.display, p->main_win, server.atom._NET_WM_STRUT); - XDeleteProperty(server.display, p->main_win, server.atom._NET_WM_STRUT_PARTIAL); - return; - } + if (panel_strut_policy == STRUT_NONE) { + XDeleteProperty(server.display, p->main_win, server.atom._NET_WM_STRUT); + XDeleteProperty(server.display, p->main_win, server.atom._NET_WM_STRUT_PARTIAL); + return; + } - // Reserved space - unsigned int d1, screen_width, screen_height; - Window d2; - int d3; - XGetGeometry(server.display, server.root_win, &d2, &d3, &d3, &screen_width, &screen_height, &d1, &d1); - Monitor monitor = server.monitors[p->monitor]; - long struts[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - if (panel_horizontal) { - int height = p->area.height + p->marginy; - if (panel_strut_policy == STRUT_MINIMUM || (panel_strut_policy == STRUT_FOLLOW_SIZE && panel_autohide)) - height = p->hidden_height; - if (panel_position & TOP) { - struts[2] = height + monitor.y; - struts[8] = p->posx; - // p->area.width - 1 allowed full screen on monitor 2 - struts[9] = p->posx + p->area.width - 1; - } else { - struts[3] = height + screen_height - monitor.y - monitor.height; - struts[10] = p->posx; - // p->area.width - 1 allowed full screen on monitor 2 - struts[11] = p->posx + p->area.width - 1; - } - } else { - int width = p->area.width + p->marginx; - if (panel_strut_policy == STRUT_MINIMUM || (panel_strut_policy == STRUT_FOLLOW_SIZE && panel_autohide)) - width = p->hidden_width; - if (panel_position & LEFT) { - struts[0] = width + monitor.x; - struts[4] = p->posy; - // p->area.width - 1 allowed full screen on monitor 2 - struts[5] = p->posy + p->area.height - 1; - } else { - struts[1] = width + screen_width - monitor.x - monitor.width; - struts[6] = p->posy; - // p->area.width - 1 allowed full screen on monitor 2 - struts[7] = p->posy + p->area.height - 1; - } - } - // Old specification : fluxbox need _NET_WM_STRUT. - XChangeProperty(server.display, - p->main_win, - server.atom._NET_WM_STRUT, - XA_CARDINAL, - 32, - PropModeReplace, - (unsigned char *)&struts, - 4); - XChangeProperty(server.display, - p->main_win, - server.atom._NET_WM_STRUT_PARTIAL, - XA_CARDINAL, - 32, - PropModeReplace, - (unsigned char *)&struts, - 12); + // Reserved space + unsigned int d1, screen_width, screen_height; + Window d2; + int d3; + XGetGeometry(server.display, server.root_win, &d2, &d3, &d3, &screen_width, &screen_height, &d1, &d1); + Monitor monitor = server.monitors[p->monitor]; + long struts[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + if (panel_horizontal) { + int height = p->area.height + p->marginy; + if (panel_strut_policy == STRUT_MINIMUM || (panel_strut_policy == STRUT_FOLLOW_SIZE && panel_autohide)) + height = p->hidden_height; + if (panel_position & TOP) { + struts[2] = height + monitor.y; + struts[8] = p->posx; + // p->area.width - 1 allowed full screen on monitor 2 + struts[9] = p->posx + p->area.width - 1; + } else { + struts[3] = height + screen_height - monitor.y - monitor.height; + struts[10] = p->posx; + // p->area.width - 1 allowed full screen on monitor 2 + struts[11] = p->posx + p->area.width - 1; + } + } else { + int width = p->area.width + p->marginx; + if (panel_strut_policy == STRUT_MINIMUM || (panel_strut_policy == STRUT_FOLLOW_SIZE && panel_autohide)) + width = p->hidden_width; + if (panel_position & LEFT) { + struts[0] = width + monitor.x; + struts[4] = p->posy; + // p->area.width - 1 allowed full screen on monitor 2 + struts[5] = p->posy + p->area.height - 1; + } else { + struts[1] = width + screen_width - monitor.x - monitor.width; + struts[6] = p->posy; + // p->area.width - 1 allowed full screen on monitor 2 + struts[7] = p->posy + p->area.height - 1; + } + } + // Old specification : fluxbox need _NET_WM_STRUT. + XChangeProperty(server.display, + p->main_win, + server.atom._NET_WM_STRUT, + XA_CARDINAL, + 32, + PropModeReplace, + (unsigned char *)&struts, + 4); + XChangeProperty(server.display, + p->main_win, + server.atom._NET_WM_STRUT_PARTIAL, + XA_CARDINAL, + 32, + PropModeReplace, + (unsigned char *)&struts, + 12); } void set_panel_items_order(Panel *p) { - if (p->area.children) { - g_list_free(p->area.children); - p->area.children = 0; - } + if (p->area.children) { + g_list_free(p->area.children); + p->area.children = 0; + } - int i_execp = 0; - int i_separator = 0; - int i_freespace = 0; - int i_button = 0; - for (int k = 0; k < strlen(panel_items_order); k++) { - if (panel_items_order[k] == 'L') { - p->area.children = g_list_append(p->area.children, &p->launcher); - p->launcher.area.resize_needed = 1; - } - if (panel_items_order[k] == 'T') { - for (int j = 0; j < p->num_desktops; j++) - p->area.children = g_list_append(p->area.children, &p->taskbar[j]); - } + int i_execp = 0; + int i_separator = 0; + int i_freespace = 0; + int i_button = 0; + for (int k = 0; k < strlen(panel_items_order); k++) { + if (panel_items_order[k] == 'L') { + p->area.children = g_list_append(p->area.children, &p->launcher); + p->launcher.area.resize_needed = 1; + } + if (panel_items_order[k] == 'T') { + for (int j = 0; j < p->num_desktops; j++) + p->area.children = g_list_append(p->area.children, &p->taskbar[j]); + } #ifdef ENABLE_BATTERY - if (panel_items_order[k] == 'B') - p->area.children = g_list_append(p->area.children, &p->battery); + if (panel_items_order[k] == 'B') + p->area.children = g_list_append(p->area.children, &p->battery); #endif - int i = p - panels; - if (panel_items_order[k] == 'S' && systray_on_monitor(i, num_panels)) { - p->area.children = g_list_append(p->area.children, &systray); - } - if (panel_items_order[k] == 'C') - p->area.children = g_list_append(p->area.children, &p->clock); - if (panel_items_order[k] == 'F') { - GList *item = g_list_nth(p->freespace_list, i_freespace); - i_freespace++; - if (item) - p->area.children = g_list_append(p->area.children, (Area *)item->data); - } - if (panel_items_order[k] == ':') { - GList *item = g_list_nth(p->separator_list, i_separator); - i_separator++; - if (item) - p->area.children = g_list_append(p->area.children, (Area *)item->data); - } - if (panel_items_order[k] == 'E') { - GList *item = g_list_nth(p->execp_list, i_execp); - i_execp++; - if (item) - p->area.children = g_list_append(p->area.children, (Area *)item->data); - } - if (panel_items_order[k] == 'P') { - GList *item = g_list_nth(p->button_list, i_button); - i_button++; - if (item) - p->area.children = g_list_append(p->area.children, (Area *)item->data); - } - } - initialize_positions(&p->area, 0); + int i = p - panels; + if (panel_items_order[k] == 'S' && systray_on_monitor(i, num_panels)) { + p->area.children = g_list_append(p->area.children, &systray); + } + if (panel_items_order[k] == 'C') + p->area.children = g_list_append(p->area.children, &p->clock); + if (panel_items_order[k] == 'F') { + GList *item = g_list_nth(p->freespace_list, i_freespace); + i_freespace++; + if (item) + p->area.children = g_list_append(p->area.children, (Area *)item->data); + } + if (panel_items_order[k] == ':') { + GList *item = g_list_nth(p->separator_list, i_separator); + i_separator++; + if (item) + p->area.children = g_list_append(p->area.children, (Area *)item->data); + } + if (panel_items_order[k] == 'E') { + GList *item = g_list_nth(p->execp_list, i_execp); + i_execp++; + if (item) + p->area.children = g_list_append(p->area.children, (Area *)item->data); + } + if (panel_items_order[k] == 'P') { + GList *item = g_list_nth(p->button_list, i_button); + i_button++; + if (item) + p->area.children = g_list_append(p->area.children, (Area *)item->data); + } + } + initialize_positions(&p->area, 0); } void place_panel_all_desktops(Panel *p) { - long val = ALL_DESKTOPS; - XChangeProperty(server.display, - p->main_win, - server.atom._NET_WM_DESKTOP, - XA_CARDINAL, - 32, - PropModeReplace, - (unsigned char *)&val, - 1); + long val = ALL_DESKTOPS; + XChangeProperty(server.display, + p->main_win, + server.atom._NET_WM_DESKTOP, + XA_CARDINAL, + 32, + PropModeReplace, + (unsigned char *)&val, + 1); } void set_panel_layer(Panel *p, Layer layer) { - Atom state[4]; - state[0] = server.atom._NET_WM_STATE_SKIP_PAGER; - state[1] = server.atom._NET_WM_STATE_SKIP_TASKBAR; - state[2] = server.atom._NET_WM_STATE_STICKY; - state[3] = layer == BOTTOM_LAYER ? server.atom._NET_WM_STATE_BELOW : server.atom._NET_WM_STATE_ABOVE; - int num_atoms = layer == NORMAL_LAYER ? 3 : 4; - XChangeProperty(server.display, - p->main_win, - server.atom._NET_WM_STATE, - XA_ATOM, - 32, - PropModeReplace, - (unsigned char *)state, - num_atoms); + Atom state[4]; + state[0] = server.atom._NET_WM_STATE_SKIP_PAGER; + state[1] = server.atom._NET_WM_STATE_SKIP_TASKBAR; + state[2] = server.atom._NET_WM_STATE_STICKY; + state[3] = layer == BOTTOM_LAYER ? server.atom._NET_WM_STATE_BELOW : server.atom._NET_WM_STATE_ABOVE; + int num_atoms = layer == NORMAL_LAYER ? 3 : 4; + XChangeProperty(server.display, + p->main_win, + server.atom._NET_WM_STATE, + XA_ATOM, + 32, + PropModeReplace, + (unsigned char *)state, + num_atoms); } void replace_panel_all_desktops(Panel *p) { - XClientMessageEvent m; - memset(&m, 0, sizeof(m)); - m.type = ClientMessage; - m.send_event = True; - m.display = server.display; - m.window = p->main_win; - m.message_type = server.atom._NET_WM_DESKTOP; - m.format = 32; - m.data.l[0] = ALL_DESKTOPS; - XSendEvent(server.display, server.root_win, False, SubstructureRedirectMask | SubstructureNotifyMask, (XEvent *)&m); - XSync(server.display, False); + XClientMessageEvent m; + memset(&m, 0, sizeof(m)); + m.type = ClientMessage; + m.send_event = True; + m.display = server.display; + m.window = p->main_win; + m.message_type = server.atom._NET_WM_DESKTOP; + m.format = 32; + m.data.l[0] = ALL_DESKTOPS; + XSendEvent(server.display, server.root_win, False, SubstructureRedirectMask | SubstructureNotifyMask, (XEvent *)&m); + XSync(server.display, False); } void set_panel_window_geometry(Panel *panel) { - update_strut(panel); + update_strut(panel); - // Fixed position and non-resizable window - // Allow panel move and resize when tint2 reload config file - int minwidth = panel_autohide ? panel->hidden_width : panel->area.width; - int minheight = panel_autohide ? panel->hidden_height : panel->area.height; - XSizeHints size_hints; - size_hints.flags = PPosition | PMinSize | PMaxSize; - size_hints.min_width = minwidth; - size_hints.max_width = panel->area.width; - size_hints.min_height = minheight; - size_hints.max_height = panel->area.height; - XSetWMNormalHints(server.display, panel->main_win, &size_hints); + // Fixed position and non-resizable window + // Allow panel move and resize when tint2 reload config file + int minwidth = panel_autohide ? panel->hidden_width : panel->area.width; + int minheight = panel_autohide ? panel->hidden_height : panel->area.height; + XSizeHints size_hints; + size_hints.flags = PPosition | PMinSize | PMaxSize; + size_hints.min_width = minwidth; + size_hints.max_width = panel->area.width; + size_hints.min_height = minheight; + size_hints.max_height = panel->area.height; + XSetWMNormalHints(server.display, panel->main_win, &size_hints); - if (!panel->is_hidden) { - if (panel_horizontal) { - if (panel_position & TOP) - XMoveResizeWindow(server.display, - panel->main_win, - panel->posx, - panel->posy, - panel->area.width, - panel->area.height); - else - XMoveResizeWindow(server.display, - panel->main_win, - panel->posx, - panel->posy, - panel->area.width, - panel->area.height); - } else { - if (panel_position & LEFT) - XMoveResizeWindow(server.display, - panel->main_win, - panel->posx, - panel->posy, - panel->area.width, - panel->area.height); - else - XMoveResizeWindow(server.display, - panel->main_win, - panel->posx, - panel->posy, - panel->area.width, - panel->area.height); - } - } else { - int diff = (panel_horizontal ? panel->area.height : panel->area.width) - panel_autohide_height; - if (panel_horizontal) { - if (panel_position & TOP) - XMoveResizeWindow(server.display, - panel->main_win, - panel->posx, - panel->posy, - panel->hidden_width, - panel->hidden_height); - else - XMoveResizeWindow(server.display, - panel->main_win, - panel->posx, - panel->posy + diff, - panel->hidden_width, - panel->hidden_height); - } else { - if (panel_position & LEFT) - XMoveResizeWindow(server.display, - panel->main_win, - panel->posx, - panel->posy, - panel->hidden_width, - panel->hidden_height); - else - XMoveResizeWindow(server.display, - panel->main_win, - panel->posx + diff, - panel->posy, - panel->hidden_width, - panel->hidden_height); - } - } + if (!panel->is_hidden) { + if (panel_horizontal) { + if (panel_position & TOP) + XMoveResizeWindow(server.display, + panel->main_win, + panel->posx, + panel->posy, + panel->area.width, + panel->area.height); + else + XMoveResizeWindow(server.display, + panel->main_win, + panel->posx, + panel->posy, + panel->area.width, + panel->area.height); + } else { + if (panel_position & LEFT) + XMoveResizeWindow(server.display, + panel->main_win, + panel->posx, + panel->posy, + panel->area.width, + panel->area.height); + else + XMoveResizeWindow(server.display, + panel->main_win, + panel->posx, + panel->posy, + panel->area.width, + panel->area.height); + } + } else { + int diff = (panel_horizontal ? panel->area.height : panel->area.width) - panel_autohide_height; + if (panel_horizontal) { + if (panel_position & TOP) + XMoveResizeWindow(server.display, + panel->main_win, + panel->posx, + panel->posy, + panel->hidden_width, + panel->hidden_height); + else + XMoveResizeWindow(server.display, + panel->main_win, + panel->posx, + panel->posy + diff, + panel->hidden_width, + panel->hidden_height); + } else { + if (panel_position & LEFT) + XMoveResizeWindow(server.display, + panel->main_win, + panel->posx, + panel->posy, + panel->hidden_width, + panel->hidden_height); + else + XMoveResizeWindow(server.display, + panel->main_win, + panel->posx + diff, + panel->posy, + panel->hidden_width, + panel->hidden_height); + } + } } void set_panel_properties(Panel *p) { - XStoreName(server.display, p->main_win, panel_window_name); - XSetIconName(server.display, p->main_win, panel_window_name); + XStoreName(server.display, p->main_win, panel_window_name); + XSetIconName(server.display, p->main_win, panel_window_name); - gsize len; - gchar *name = g_locale_to_utf8(panel_window_name, -1, NULL, &len, NULL); - if (name != NULL) { - XChangeProperty(server.display, - p->main_win, - server.atom._NET_WM_NAME, - server.atom.UTF8_STRING, - 8, - PropModeReplace, - (unsigned char *)name, - (int)len); - XChangeProperty(server.display, - p->main_win, - server.atom._NET_WM_ICON_NAME, - server.atom.UTF8_STRING, - 8, - PropModeReplace, - (unsigned char *)name, - (int)len); - g_free(name); - } + gsize len; + gchar *name = g_locale_to_utf8(panel_window_name, -1, NULL, &len, NULL); + if (name != NULL) { + XChangeProperty(server.display, + p->main_win, + server.atom._NET_WM_NAME, + server.atom.UTF8_STRING, + 8, + PropModeReplace, + (unsigned char *)name, + (int)len); + XChangeProperty(server.display, + p->main_win, + server.atom._NET_WM_ICON_NAME, + server.atom.UTF8_STRING, + 8, + PropModeReplace, + (unsigned char *)name, + (int)len); + g_free(name); + } - // Dock - long val = server.atom._NET_WM_WINDOW_TYPE_DOCK; - XChangeProperty(server.display, - p->main_win, - server.atom._NET_WM_WINDOW_TYPE, - XA_ATOM, - 32, - PropModeReplace, - (unsigned char *)&val, - 1); + // Dock + long val = server.atom._NET_WM_WINDOW_TYPE_DOCK; + XChangeProperty(server.display, + p->main_win, + server.atom._NET_WM_WINDOW_TYPE, + XA_ATOM, + 32, + PropModeReplace, + (unsigned char *)&val, + 1); - place_panel_all_desktops(p); - set_panel_layer(p, panel_layer); + place_panel_all_desktops(p); + set_panel_layer(p, panel_layer); - XWMHints wmhints; - memset(&wmhints, 0, sizeof(wmhints)); - if (panel_dock) { - // Necessary for placing the panel into the dock on Openbox and Fluxbox. - // See https://gitlab.com/o9000/tint2/issues/465 - wmhints.flags = IconWindowHint | WindowGroupHint | StateHint; - wmhints.icon_window = wmhints.window_group = p->main_win; - wmhints.initial_state = WithdrawnState; - } - // We do not need keyboard input focus. - wmhints.flags |= InputHint; - wmhints.input = False; - XSetWMHints(server.display, p->main_win, &wmhints); + XWMHints wmhints; + memset(&wmhints, 0, sizeof(wmhints)); + if (panel_dock) { + // Necessary for placing the panel into the dock on Openbox and Fluxbox. + // See https://gitlab.com/o9000/tint2/issues/465 + wmhints.flags = IconWindowHint | WindowGroupHint | StateHint; + wmhints.icon_window = wmhints.window_group = p->main_win; + wmhints.initial_state = WithdrawnState; + } + // We do not need keyboard input focus. + wmhints.flags |= InputHint; + wmhints.input = False; + XSetWMHints(server.display, p->main_win, &wmhints); - // Undecorated - long prop[5] = {2, 0, 0, 0, 0}; - XChangeProperty(server.display, - p->main_win, - server.atom._MOTIF_WM_HINTS, - server.atom._MOTIF_WM_HINTS, - 32, - PropModeReplace, - (unsigned char *)prop, - 5); + // Undecorated + long prop[5] = {2, 0, 0, 0, 0}; + XChangeProperty(server.display, + p->main_win, + server.atom._MOTIF_WM_HINTS, + server.atom._MOTIF_WM_HINTS, + 32, + PropModeReplace, + (unsigned char *)prop, + 5); - // XdndAware - Register for Xdnd events - Atom version = 4; - XChangeProperty(server.display, - p->main_win, - server.atom.XdndAware, - XA_ATOM, - 32, - PropModeReplace, - (unsigned char *)&version, - 1); + // XdndAware - Register for Xdnd events + Atom version = 4; + XChangeProperty(server.display, + p->main_win, + server.atom.XdndAware, + XA_ATOM, + 32, + PropModeReplace, + (unsigned char *)&version, + 1); - // Set WM_CLASS - XClassHint *classhint = XAllocClassHint(); - classhint->res_name = (char *)"tint2"; - classhint->res_class = (char *)"Tint2"; - XSetClassHint(server.display, p->main_win, classhint); - XFree(classhint); + // Set WM_CLASS + XClassHint *classhint = XAllocClassHint(); + classhint->res_name = (char *)"tint2"; + classhint->res_class = (char *)"Tint2"; + XSetClassHint(server.display, p->main_win, classhint); + XFree(classhint); - set_panel_window_geometry(p); + set_panel_window_geometry(p); } void panel_clear_background(void *obj) { - Panel *p = obj; - clear_pixmap(p->area.pix, 0, 0, p->area.width, p->area.height); - if (!server.real_transparency) { - get_root_pixmap(); - // copy background (server.root_pmap) in panel.area.pix - Window dummy; - int x, y; - XTranslateCoordinates(server.display, p->main_win, server.root_win, 0, 0, &x, &y, &dummy); + Panel *p = obj; + clear_pixmap(p->area.pix, 0, 0, p->area.width, p->area.height); + if (!server.real_transparency) { + get_root_pixmap(); + // copy background (server.root_pmap) in panel.area.pix + Window dummy; + int x, y; + XTranslateCoordinates(server.display, p->main_win, server.root_win, 0, 0, &x, &y, &dummy); - if (panel_autohide && p->is_hidden) { - int xoff = 0, yoff = 0; - if (panel_horizontal && panel_position & BOTTOM) - yoff = p->area.height - p->hidden_height; - else if (!panel_horizontal && panel_position & RIGHT) - xoff = p->area.width - p->hidden_width; - x -= xoff; - y -= yoff; - } + if (panel_autohide && p->is_hidden) { + int xoff = 0, yoff = 0; + if (panel_horizontal && panel_position & BOTTOM) + yoff = p->area.height - p->hidden_height; + else if (!panel_horizontal && panel_position & RIGHT) + xoff = p->area.width - p->hidden_width; + x -= xoff; + y -= yoff; + } - XSetTSOrigin(server.display, server.gc, -x, -y); - XFillRectangle(server.display, p->area.pix, server.gc, 0, 0, p->area.width, p->area.height); - } + XSetTSOrigin(server.display, server.gc, -x, -y); + XFillRectangle(server.display, p->area.pix, server.gc, 0, 0, p->area.width, p->area.height); + } } void set_panel_background(Panel *p) { - panel_clear_background(p); - schedule_redraw(&p->area); + panel_clear_background(p); + schedule_redraw(&p->area); - if (p->hidden_pixmap) { - XFreePixmap(server.display, p->hidden_pixmap); - p->hidden_pixmap = 0; - } + if (p->hidden_pixmap) { + XFreePixmap(server.display, p->hidden_pixmap); + p->hidden_pixmap = 0; + } } Panel *get_panel(Window win) { - for (int i = 0; i < num_panels; i++) { - if (panels[i].main_win == win) { - return &panels[i]; - } - } - return 0; + for (int i = 0; i < num_panels; i++) { + if (panels[i].main_win == win) { + return &panels[i]; + } + } + return 0; } Taskbar *click_taskbar(Panel *panel, int x, int y) { - for (int i = 0; i < panel->num_desktops; i++) { - Taskbar *taskbar = &panel->taskbar[i]; - if (area_is_under_mouse(taskbar, x, y)) - return taskbar; - } - return NULL; + for (int i = 0; i < panel->num_desktops; i++) { + Taskbar *taskbar = &panel->taskbar[i]; + if (area_is_under_mouse(taskbar, x, y)) + return taskbar; + } + return NULL; } Task *click_task(Panel *panel, int x, int y) { - Taskbar *taskbar = click_taskbar(panel, x, y); - if (taskbar) { - GList *l = taskbar->area.children; - if (taskbarname_enabled) - l = l->next; - for (; l; l = l->next) { - Task *task = (Task *)l->data; - if (area_is_under_mouse(task, x, y)) { - return task; - } - } - } - return NULL; + Taskbar *taskbar = click_taskbar(panel, x, y); + if (taskbar) { + GList *l = taskbar->area.children; + if (taskbarname_enabled) + l = l->next; + for (; l; l = l->next) { + Task *task = (Task *)l->data; + if (area_is_under_mouse(task, x, y)) { + return task; + } + } + } + return NULL; } Launcher *click_launcher(Panel *panel, int x, int y) { - Launcher *launcher = &panel->launcher; + Launcher *launcher = &panel->launcher; - if (area_is_under_mouse(launcher, x, y)) - return launcher; + if (area_is_under_mouse(launcher, x, y)) + return launcher; - return NULL; + return NULL; } LauncherIcon *click_launcher_icon(Panel *panel, int x, int y) { - Launcher *launcher = click_launcher(panel, x, y); - if (launcher) { - for (GSList *l = launcher->list_icons; l; l = l->next) { - LauncherIcon *icon = (LauncherIcon *)l->data; - if (area_is_under_mouse(icon, x, y)) - return icon; - } - } - return NULL; + Launcher *launcher = click_launcher(panel, x, y); + if (launcher) { + for (GSList *l = launcher->list_icons; l; l = l->next) { + LauncherIcon *icon = (LauncherIcon *)l->data; + if (area_is_under_mouse(icon, x, y)) + return icon; + } + } + return NULL; } Clock *click_clock(Panel *panel, int x, int y) { - Clock *clock = &panel->clock; - if (area_is_under_mouse(clock, x, y)) - return clock; - return NULL; + Clock *clock = &panel->clock; + if (area_is_under_mouse(clock, x, y)) + return clock; + return NULL; } #ifdef ENABLE_BATTERY Battery *click_battery(Panel *panel, int x, int y) { - Battery *bat = &panel->battery; - if (area_is_under_mouse(bat, x, y)) - return bat; - return NULL; + Battery *bat = &panel->battery; + if (area_is_under_mouse(bat, x, y)) + return bat; + return NULL; } #endif Execp *click_execp(Panel *panel, int x, int y) { - for (GList *l = panel->execp_list; l; l = l->next) { - Execp *execp = (Execp *)l->data; - if (area_is_under_mouse(execp, x, y)) - return execp; - } - return NULL; + for (GList *l = panel->execp_list; l; l = l->next) { + Execp *execp = (Execp *)l->data; + if (area_is_under_mouse(execp, x, y)) + return execp; + } + return NULL; } Button *click_button(Panel *panel, int x, int y) { - for (GList *l = panel->button_list; l; l = l->next) { - Button *button = (Button *)l->data; - if (area_is_under_mouse(button, x, y)) - return button; - } - return NULL; + for (GList *l = panel->button_list; l; l = l->next) { + Button *button = (Button *)l->data; + if (area_is_under_mouse(button, x, y)) + return button; + } + return NULL; } void stop_autohide_timeout(Panel *p) { - stop_timeout(p->autohide_timeout); + stop_timeout(p->autohide_timeout); } void autohide_show(void *p) { - Panel *panel = (Panel *)p; - stop_autohide_timeout(panel); - panel->is_hidden = 0; - XMapSubwindows(server.display, panel->main_win); // systray windows - set_panel_window_geometry(panel); - set_panel_layer(panel, TOP_LAYER); - refresh_systray = TRUE; // ugly hack, because we actually only need to call XSetBackgroundPixmap - schedule_panel_redraw(); + Panel *panel = (Panel *)p; + stop_autohide_timeout(panel); + panel->is_hidden = 0; + XMapSubwindows(server.display, panel->main_win); // systray windows + set_panel_window_geometry(panel); + set_panel_layer(panel, TOP_LAYER); + refresh_systray = TRUE; // ugly hack, because we actually only need to call XSetBackgroundPixmap + schedule_panel_redraw(); } void autohide_hide(void *p) { - Panel *panel = (Panel *)p; - stop_autohide_timeout(panel); - set_panel_layer(panel, panel_layer); - panel->is_hidden = TRUE; - XUnmapSubwindows(server.display, panel->main_win); // systray windows - set_panel_window_geometry(panel); - schedule_panel_redraw(); + Panel *panel = (Panel *)p; + stop_autohide_timeout(panel); + set_panel_layer(panel, panel_layer); + panel->is_hidden = TRUE; + XUnmapSubwindows(server.display, panel->main_win); // systray windows + set_panel_window_geometry(panel); + schedule_panel_redraw(); } void autohide_trigger_show(Panel *p) { - if (!p) - return; - change_timeout(&p->autohide_timeout, panel_autohide_show_timeout, 0, autohide_show, p); + if (!p) + return; + change_timeout(&p->autohide_timeout, panel_autohide_show_timeout, 0, autohide_show, p); } void autohide_trigger_hide(Panel *p) { - if (!p) - return; + if (!p) + return; - Window root, child; - int xr, yr, xw, yw; - unsigned int mask; - if (XQueryPointer(server.display, p->main_win, &root, &child, &xr, &yr, &xw, &yw, &mask)) - if (child) - return; // mouse over one of the system tray icons + Window root, child; + int xr, yr, xw, yw; + unsigned int mask; + if (XQueryPointer(server.display, p->main_win, &root, &child, &xr, &yr, &xw, &yw, &mask)) + if (child) + return; // mouse over one of the system tray icons - change_timeout(&p->autohide_timeout, panel_autohide_hide_timeout, 0, autohide_hide, p); + change_timeout(&p->autohide_timeout, panel_autohide_hide_timeout, 0, autohide_hide, p); } void shrink_panel(Panel *panel) { - if (!panel_shrink) - return; - int size = MIN(compute_desired_size(&panel->area), panel->max_size); - gboolean update = FALSE; - if (panel_horizontal) { - if (panel->area.width != size) { - panel->area.width = size; - update = TRUE; - } - } else { - if (panel->area.height != size) { - panel->area.height = size; - update = TRUE; - } - } - if (update) { - panel_compute_position(panel); - set_panel_window_geometry(panel); - set_panel_background(panel); - panel->area.resize_needed = TRUE; - systray.area.resize_needed = TRUE; - schedule_redraw(&systray.area); - refresh_systray = TRUE; - update_minimized_icon_positions(panel); - } + if (!panel_shrink) + return; + int size = MIN(compute_desired_size(&panel->area), panel->max_size); + gboolean update = FALSE; + if (panel_horizontal) { + if (panel->area.width != size) { + panel->area.width = size; + update = TRUE; + } + } else { + if (panel->area.height != size) { + panel->area.height = size; + update = TRUE; + } + } + if (update) { + panel_compute_position(panel); + set_panel_window_geometry(panel); + set_panel_background(panel); + panel->area.resize_needed = TRUE; + systray.area.resize_needed = TRUE; + schedule_redraw(&systray.area); + refresh_systray = TRUE; + update_minimized_icon_positions(panel); + } } void render_panel(Panel *panel) { - relayout(&panel->area); - if (debug_geometry) - area_dump_geometry(&panel->area, 0); - update_dependent_gradients(&panel->area); - draw_tree(&panel->area); + relayout(&panel->area); + if (debug_geometry) + area_dump_geometry(&panel->area, 0); + update_dependent_gradients(&panel->area); + draw_tree(&panel->area); } const char *get_default_font() { - if (default_font) - return default_font; - return DEFAULT_FONT; + if (default_font) + return default_font; + return DEFAULT_FONT; } void default_icon_theme_changed() { - if (!launcher_enabled && !panel_config.button_list) - return; - if (launcher_icon_theme_override && icon_theme_name_config) - return; + if (!launcher_enabled && !panel_config.button_list) + return; + if (launcher_icon_theme_override && icon_theme_name_config) + return; - free_icon_themes(); - load_icon_themes(); + free_icon_themes(); + load_icon_themes(); - launcher_default_icon_theme_changed(); - button_default_icon_theme_changed(); + launcher_default_icon_theme_changed(); + button_default_icon_theme_changed(); } void default_font_changed() { #ifdef ENABLE_BATTERY - battery_default_font_changed(); + battery_default_font_changed(); #endif - clock_default_font_changed(); - execp_default_font_changed(); - button_default_font_changed(); - taskbar_default_font_changed(); - taskbarname_default_font_changed(); - tooltip_default_font_changed(); + clock_default_font_changed(); + execp_default_font_changed(); + button_default_font_changed(); + taskbar_default_font_changed(); + taskbarname_default_font_changed(); + tooltip_default_font_changed(); } void _schedule_panel_redraw(const char *file, const char *function, const int line) { - panel_refresh = TRUE; - if (debug_fps) { - fprintf(stderr, YELLOW "%s %s %d: triggering panel redraw" RESET "\n", file, function, line); - } + panel_refresh = TRUE; + if (debug_fps) { + fprintf(stderr, YELLOW "%s %s %d: triggering panel redraw" RESET "\n", file, function, line); + } }
M src/panel.hsrc/panel.h

@@ -42,29 +42,29 @@ extern MouseAction mouse_tilt_right;

// panel mode typedef enum TaskbarMode { - SINGLE_DESKTOP = 0, - MULTI_DESKTOP, + SINGLE_DESKTOP = 0, + MULTI_DESKTOP, } TaskbarMode; typedef enum Layer { - BOTTOM_LAYER, - NORMAL_LAYER, - TOP_LAYER, + BOTTOM_LAYER, + NORMAL_LAYER, + TOP_LAYER, } Layer; // panel position typedef enum PanelPosition { - LEFT = 0x01, - RIGHT = 0x02, - CENTER = 0X04, - TOP = 0X08, - BOTTOM = 0x10, + LEFT = 0x01, + RIGHT = 0x02, + CENTER = 0X04, + TOP = 0X08, + BOTTOM = 0x10, } PanelPosition; typedef enum Strut { - STRUT_MINIMUM, - STRUT_FOLLOW_SIZE, - STRUT_NONE, + STRUT_MINIMUM, + STRUT_FOLLOW_SIZE, + STRUT_NONE, } Strut; extern TaskbarMode taskbar_mode;

@@ -95,54 +95,54 @@ extern gboolean debug_fps;

extern gboolean debug_frames; typedef struct Panel { - Area area; + Area area; - Window main_win; - Pixmap temp_pmap; + Window main_win; + Pixmap temp_pmap; - // position relative to root window - int posx, posy; - int marginx, marginy; - gboolean fractional_width, fractional_height; - int max_size; - int monitor; - int font_shadow; - gboolean mouse_effects; - // Mouse effects for icons - int mouse_over_alpha; - int mouse_over_saturation; - int mouse_over_brightness; - int mouse_pressed_alpha; - int mouse_pressed_saturation; - int mouse_pressed_brightness; + // position relative to root window + int posx, posy; + int marginx, marginy; + gboolean fractional_width, fractional_height; + int max_size; + int monitor; + int font_shadow; + gboolean mouse_effects; + // Mouse effects for icons + int mouse_over_alpha; + int mouse_over_saturation; + int mouse_over_brightness; + int mouse_pressed_alpha; + int mouse_pressed_saturation; + int mouse_pressed_brightness; - // Per-panel parameters and states for Taskbar and Task - GlobalTaskbar g_taskbar; - GlobalTask g_task; + // Per-panel parameters and states for Taskbar and Task + GlobalTaskbar g_taskbar; + GlobalTask g_task; - // Array of Taskbar, with num_desktops items - Taskbar *taskbar; - int num_desktops; - gboolean taskbarname_has_font; - PangoFontDescription *taskbarname_font_desc; + // Array of Taskbar, with num_desktops items + Taskbar *taskbar; + int num_desktops; + gboolean taskbarname_has_font; + PangoFontDescription *taskbarname_font_desc; - Clock clock; + Clock clock; #ifdef ENABLE_BATTERY - Battery battery; + Battery battery; #endif - Launcher launcher; - GList *freespace_list; - GList *separator_list; - GList *execp_list; - GList *button_list; + Launcher launcher; + GList *freespace_list; + GList *separator_list; + GList *execp_list; + GList *button_list; - // Autohide - gboolean is_hidden; - int hidden_width, hidden_height; - Pixmap hidden_pixmap; - timeout *autohide_timeout; + // Autohide + gboolean is_hidden; + int hidden_width, hidden_height; + Pixmap hidden_pixmap; + timeout *autohide_timeout; } Panel; extern Panel panel_config;
M src/separator/separator.csrc/separator/separator.c

@@ -19,132 +19,132 @@ int separator_compute_desired_size(void *obj);

Separator *create_separator() { - Separator *separator = (Separator *)calloc(1, sizeof(Separator)); - separator->color.rgb[0] = 0.5; - separator->color.rgb[1] = 0.5; - separator->color.rgb[2] = 0.5; - separator->color.alpha = 0.9; - separator->style = SEPARATOR_DOTS; - separator->thickness = 3; - separator->area.paddingxlr = 1; - return separator; + Separator *separator = (Separator *)calloc(1, sizeof(Separator)); + separator->color.rgb[0] = 0.5; + separator->color.rgb[1] = 0.5; + separator->color.rgb[2] = 0.5; + separator->color.alpha = 0.9; + separator->style = SEPARATOR_DOTS; + separator->thickness = 3; + separator->area.paddingxlr = 1; + return separator; } void destroy_separator(void *obj) { - Separator *separator = (Separator *)obj; - remove_area(&separator->area); - free_area(&separator->area); - free_and_null(separator); + Separator *separator = (Separator *)obj; + remove_area(&separator->area); + free_area(&separator->area); + free_and_null(separator); } gpointer copy_separator(gconstpointer arg, gpointer data) { - Separator *old = (Separator *)arg; - Separator *copy = (Separator *)calloc(1, sizeof(Separator)); - memcpy(copy, old, sizeof(Separator)); - return copy; + Separator *old = (Separator *)arg; + Separator *copy = (Separator *)calloc(1, sizeof(Separator)); + memcpy(copy, old, sizeof(Separator)); + return copy; } void init_separator() { - GList *to_remove = panel_config.separator_list; - for (int k = 0; k < strlen(panel_items_order) && to_remove; k++) { - if (panel_items_order[k] == ':') { - to_remove = to_remove->next; - } - } + GList *to_remove = panel_config.separator_list; + for (int k = 0; k < strlen(panel_items_order) && to_remove; k++) { + if (panel_items_order[k] == ':') { + to_remove = to_remove->next; + } + } - if (to_remove) { - if (to_remove == panel_config.separator_list) { - g_list_free_full(to_remove, destroy_separator); - panel_config.separator_list = NULL; - } else { - // Cut panel_config.separator_list - if (to_remove->prev) - to_remove->prev->next = NULL; - to_remove->prev = NULL; - // Remove all elements of to_remove and to_remove itself - g_list_free_full(to_remove, destroy_separator); - } - } + if (to_remove) { + if (to_remove == panel_config.separator_list) { + g_list_free_full(to_remove, destroy_separator); + panel_config.separator_list = NULL; + } else { + // Cut panel_config.separator_list + if (to_remove->prev) + to_remove->prev->next = NULL; + to_remove->prev = NULL; + // Remove all elements of to_remove and to_remove itself + g_list_free_full(to_remove, destroy_separator); + } + } } void init_separator_panel(void *p) { - Panel *panel = (Panel *)p; + Panel *panel = (Panel *)p; - // Make sure this is only done once if there are multiple items - if (panel->separator_list) - return; + // Make sure this is only done once if there are multiple items + if (panel->separator_list) + return; - // panel->separator_list is now a copy of the pointer panel_config.separator_list - // We make it a deep copy - panel->separator_list = g_list_copy_deep(panel_config.separator_list, copy_separator, NULL); + // panel->separator_list is now a copy of the pointer panel_config.separator_list + // We make it a deep copy + panel->separator_list = g_list_copy_deep(panel_config.separator_list, copy_separator, NULL); - for (GList *l = panel->separator_list; l; l = l->next) { - Separator *separator = (Separator *)l->data; - if (!separator->area.bg) - separator->area.bg = &g_array_index(backgrounds, Background, 0); - separator->area.parent = p; - separator->area.panel = p; - snprintf(separator->area.name, sizeof(separator->area.name), "separator"); - separator->area.size_mode = LAYOUT_FIXED; - separator->area.resize_needed = 1; - separator->area.on_screen = TRUE; - separator->area._resize = resize_separator; - separator->area._compute_desired_size = separator_compute_desired_size; - separator->area._draw_foreground = draw_separator; - instantiate_area_gradients(&separator->area); - } + for (GList *l = panel->separator_list; l; l = l->next) { + Separator *separator = (Separator *)l->data; + if (!separator->area.bg) + separator->area.bg = &g_array_index(backgrounds, Background, 0); + separator->area.parent = p; + separator->area.panel = p; + snprintf(separator->area.name, sizeof(separator->area.name), "separator"); + separator->area.size_mode = LAYOUT_FIXED; + separator->area.resize_needed = 1; + separator->area.on_screen = TRUE; + separator->area._resize = resize_separator; + separator->area._compute_desired_size = separator_compute_desired_size; + separator->area._draw_foreground = draw_separator; + instantiate_area_gradients(&separator->area); + } } void cleanup_separator() { - // Cleanup frontends - for (int i = 0; i < num_panels; i++) { - g_list_free_full(panels[i].separator_list, destroy_separator); - panels[i].separator_list = NULL; - } + // Cleanup frontends + for (int i = 0; i < num_panels; i++) { + g_list_free_full(panels[i].separator_list, destroy_separator); + panels[i].separator_list = NULL; + } - // Cleanup backends - g_list_free_full(panel_config.separator_list, destroy_separator); - panel_config.separator_list = NULL; + // Cleanup backends + g_list_free_full(panel_config.separator_list, destroy_separator); + panel_config.separator_list = NULL; } int separator_compute_desired_size(void *obj) { - Separator *separator = (Separator *)obj; - if (!separator->area.on_screen) - return 0; + Separator *separator = (Separator *)obj; + if (!separator->area.on_screen) + return 0; - if (panel_horizontal) - return separator->thickness + 2 * separator->area.paddingxlr + left_right_border_width(&separator->area); - else - return separator->thickness + 2 * separator->area.paddingxlr + top_bottom_border_width(&separator->area); + if (panel_horizontal) + return separator->thickness + 2 * separator->area.paddingxlr + left_right_border_width(&separator->area); + else + return separator->thickness + 2 * separator->area.paddingxlr + top_bottom_border_width(&separator->area); } gboolean resize_separator(void *obj) { - Separator *separator = (Separator *)obj; - if (!separator->area.on_screen) - return FALSE; + Separator *separator = (Separator *)obj; + if (!separator->area.on_screen) + return FALSE; - if (panel_horizontal) { - separator->area.width = - separator->thickness + 2 * separator->area.paddingxlr + left_right_border_width(&separator->area); - separator->length = - separator->area.height - 2 * separator->area.paddingy - top_bottom_border_width(&separator->area); - } else { - separator->area.height = - separator->thickness + 2 * separator->area.paddingxlr + top_bottom_border_width(&separator->area); - separator->length = - separator->area.width - 2 * separator->area.paddingy - left_right_border_width(&separator->area); - } + if (panel_horizontal) { + separator->area.width = + separator->thickness + 2 * separator->area.paddingxlr + left_right_border_width(&separator->area); + separator->length = + separator->area.height - 2 * separator->area.paddingy - top_bottom_border_width(&separator->area); + } else { + separator->area.height = + separator->thickness + 2 * separator->area.paddingxlr + top_bottom_border_width(&separator->area); + separator->length = + separator->area.width - 2 * separator->area.paddingy - left_right_border_width(&separator->area); + } - schedule_redraw(&separator->area); - schedule_panel_redraw(); - return TRUE; + schedule_redraw(&separator->area); + schedule_panel_redraw(); + return TRUE; } void draw_separator_line(void *obj, cairo_t *c);

@@ -152,80 +152,80 @@ void draw_separator_dots(void *obj, cairo_t *c);

void draw_separator(void *obj, cairo_t *c) { - Separator *separator = (Separator *)obj; + Separator *separator = (Separator *)obj; - if (separator->style == SEPARATOR_EMPTY) - return; - else if (separator->style == SEPARATOR_LINE) - draw_separator_line(separator, c); - else if (separator->style == SEPARATOR_DOTS) - draw_separator_dots(separator, c); + if (separator->style == SEPARATOR_EMPTY) + return; + else if (separator->style == SEPARATOR_LINE) + draw_separator_line(separator, c); + else if (separator->style == SEPARATOR_DOTS) + draw_separator_dots(separator, c); } void draw_separator_line(void *obj, cairo_t *c) { - Separator *separator = (Separator *)obj; + Separator *separator = (Separator *)obj; - if (separator->thickness <= 0) - return; + if (separator->thickness <= 0) + return; - cairo_set_source_rgba(c, - separator->color.rgb[0], - separator->color.rgb[1], - separator->color.rgb[2], - separator->color.alpha); - cairo_set_line_width(c, separator->thickness); - cairo_set_line_cap(c, CAIRO_LINE_CAP_ROUND); - if (panel_horizontal) { - cairo_move_to(c, separator->area.width / 2.0, separator->area.height / 2.0 - separator->length / 2.0); - cairo_line_to(c, separator->area.width / 2.0, separator->area.height / 2.0 + separator->length / 2.0); - } else { - cairo_move_to(c, separator->area.width / 2.0 - separator->length / 2.0, separator->area.height / 2.0); - cairo_line_to(c, separator->area.width / 2.0 + separator->length / 2.0, separator->area.height / 2.0); - } - cairo_stroke(c); + cairo_set_source_rgba(c, + separator->color.rgb[0], + separator->color.rgb[1], + separator->color.rgb[2], + separator->color.alpha); + cairo_set_line_width(c, separator->thickness); + cairo_set_line_cap(c, CAIRO_LINE_CAP_ROUND); + if (panel_horizontal) { + cairo_move_to(c, separator->area.width / 2.0, separator->area.height / 2.0 - separator->length / 2.0); + cairo_line_to(c, separator->area.width / 2.0, separator->area.height / 2.0 + separator->length / 2.0); + } else { + cairo_move_to(c, separator->area.width / 2.0 - separator->length / 2.0, separator->area.height / 2.0); + cairo_line_to(c, separator->area.width / 2.0 + separator->length / 2.0, separator->area.height / 2.0); + } + cairo_stroke(c); } void draw_separator_dots(void *obj, cairo_t *c) { - const double PI = 3.14159265359; - Separator *separator = (Separator *)obj; - if (separator->thickness <= 0) - return; + const double PI = 3.14159265359; + Separator *separator = (Separator *)obj; + if (separator->thickness <= 0) + return; - cairo_set_source_rgba(c, - separator->color.rgb[0], - separator->color.rgb[1], - separator->color.rgb[2], - separator->color.alpha); - cairo_set_line_width(c, 0); + cairo_set_source_rgba(c, + separator->color.rgb[0], + separator->color.rgb[1], + separator->color.rgb[2], + separator->color.alpha); + cairo_set_line_width(c, 0); - int num_circles = separator->length / (1.618 * separator->thickness - 1); - double spacing = (separator->length - num_circles * separator->thickness) / MAX(1.0, num_circles - 1.0); - if (spacing > separator->thickness) - num_circles++; - spacing = (separator->length - num_circles * separator->thickness) / MAX(1.0, num_circles - 1.0); - double offset = (panel_horizontal ? separator->area.height : separator->area.width) / 2.0 - separator->length / 2.0; - if (num_circles == 1) - offset += spacing / 2.0; - for (int i = 0; i < num_circles; i++) { - if (panel_horizontal) { - cairo_arc(c, - separator->area.width / 2.0, - offset + separator->thickness / 2.0, - separator->thickness / 2.0, - 0, - 2 * PI); - } else { - cairo_arc(c, - offset + separator->thickness / 2.0, - separator->area.height / 2.0, - separator->thickness / 2.0, - 0, - 2 * PI); - } - cairo_stroke_preserve(c); - cairo_fill(c); - offset += separator->thickness + spacing; - } + int num_circles = separator->length / (1.618 * separator->thickness - 1); + double spacing = (separator->length - num_circles * separator->thickness) / MAX(1.0, num_circles - 1.0); + if (spacing > separator->thickness) + num_circles++; + spacing = (separator->length - num_circles * separator->thickness) / MAX(1.0, num_circles - 1.0); + double offset = (panel_horizontal ? separator->area.height : separator->area.width) / 2.0 - separator->length / 2.0; + if (num_circles == 1) + offset += spacing / 2.0; + for (int i = 0; i < num_circles; i++) { + if (panel_horizontal) { + cairo_arc(c, + separator->area.width / 2.0, + offset + separator->thickness / 2.0, + separator->thickness / 2.0, + 0, + 2 * PI); + } else { + cairo_arc(c, + offset + separator->thickness / 2.0, + separator->area.height / 2.0, + separator->thickness / 2.0, + 0, + 2 * PI); + } + cairo_stroke_preserve(c); + cairo_fill(c); + offset += separator->thickness + spacing; + } }
M src/separator/separator.hsrc/separator/separator.h

@@ -7,18 +7,14 @@

#include "common.h" #include "area.h" -typedef enum SeparatorStyle { - SEPARATOR_EMPTY = 0, - SEPARATOR_LINE, - SEPARATOR_DOTS -} SeparatorStyle; +typedef enum SeparatorStyle { SEPARATOR_EMPTY = 0, SEPARATOR_LINE, SEPARATOR_DOTS } SeparatorStyle; typedef struct Separator { - Area area; - SeparatorStyle style; - Color color; - int thickness; - int length; + Area area; + SeparatorStyle style; + Color color; + int thickness; + int length; } Separator; Separator *create_separator();
M src/server.csrc/server.c

@@ -39,570 +39,570 @@ }

void server_init_atoms() { - server.atom._XROOTPMAP_ID = XInternAtom(server.display, "_XROOTPMAP_ID", False); - server.atom._XROOTMAP_ID = XInternAtom(server.display, "_XROOTMAP_ID", False); - server.atom._NET_CURRENT_DESKTOP = XInternAtom(server.display, "_NET_CURRENT_DESKTOP", False); - server.atom._NET_NUMBER_OF_DESKTOPS = XInternAtom(server.display, "_NET_NUMBER_OF_DESKTOPS", False); - server.atom._NET_DESKTOP_NAMES = XInternAtom(server.display, "_NET_DESKTOP_NAMES", False); - server.atom._NET_DESKTOP_GEOMETRY = XInternAtom(server.display, "_NET_DESKTOP_GEOMETRY", False); - server.atom._NET_DESKTOP_VIEWPORT = XInternAtom(server.display, "_NET_DESKTOP_VIEWPORT", False); - server.atom._NET_WORKAREA = XInternAtom(server.display, "_NET_WORKAREA", False); - server.atom._NET_ACTIVE_WINDOW = XInternAtom(server.display, "_NET_ACTIVE_WINDOW", False); - server.atom._NET_WM_WINDOW_TYPE = XInternAtom(server.display, "_NET_WM_WINDOW_TYPE", False); - server.atom._NET_WM_STATE_SKIP_PAGER = XInternAtom(server.display, "_NET_WM_STATE_SKIP_PAGER", False); - server.atom._NET_WM_STATE_SKIP_TASKBAR = XInternAtom(server.display, "_NET_WM_STATE_SKIP_TASKBAR", False); - server.atom._NET_WM_STATE_STICKY = XInternAtom(server.display, "_NET_WM_STATE_STICKY", False); - server.atom._NET_WM_STATE_DEMANDS_ATTENTION = XInternAtom(server.display, "_NET_WM_STATE_DEMANDS_ATTENTION", False); - server.atom._NET_WM_WINDOW_TYPE_DOCK = XInternAtom(server.display, "_NET_WM_WINDOW_TYPE_DOCK", False); - server.atom._NET_WM_WINDOW_TYPE_DESKTOP = XInternAtom(server.display, "_NET_WM_WINDOW_TYPE_DESKTOP", False); - server.atom._NET_WM_WINDOW_TYPE_TOOLBAR = XInternAtom(server.display, "_NET_WM_WINDOW_TYPE_TOOLBAR", False); - server.atom._NET_WM_WINDOW_TYPE_MENU = XInternAtom(server.display, "_NET_WM_WINDOW_TYPE_MENU", False); - server.atom._NET_WM_WINDOW_TYPE_SPLASH = XInternAtom(server.display, "_NET_WM_WINDOW_TYPE_SPLASH", False); - server.atom._NET_WM_WINDOW_TYPE_DIALOG = XInternAtom(server.display, "_NET_WM_WINDOW_TYPE_DIALOG", False); - server.atom._NET_WM_WINDOW_TYPE_NORMAL = XInternAtom(server.display, "_NET_WM_WINDOW_TYPE_NORMAL", False); - server.atom._NET_WM_DESKTOP = XInternAtom(server.display, "_NET_WM_DESKTOP", False); - server.atom.WM_STATE = XInternAtom(server.display, "WM_STATE", False); - server.atom._NET_WM_STATE = XInternAtom(server.display, "_NET_WM_STATE", False); - server.atom._NET_WM_STATE_MAXIMIZED_VERT = XInternAtom(server.display, "_NET_WM_STATE_MAXIMIZED_VERT", False); - server.atom._NET_WM_STATE_MAXIMIZED_HORZ = XInternAtom(server.display, "_NET_WM_STATE_MAXIMIZED_HORZ", False); - server.atom._NET_WM_STATE_SHADED = XInternAtom(server.display, "_NET_WM_STATE_SHADED", False); - server.atom._NET_WM_STATE_HIDDEN = XInternAtom(server.display, "_NET_WM_STATE_HIDDEN", False); - server.atom._NET_WM_STATE_BELOW = XInternAtom(server.display, "_NET_WM_STATE_BELOW", False); - server.atom._NET_WM_STATE_ABOVE = XInternAtom(server.display, "_NET_WM_STATE_ABOVE", False); - server.atom._NET_WM_STATE_MODAL = XInternAtom(server.display, "_NET_WM_STATE_MODAL", False); - server.atom._NET_CLIENT_LIST = XInternAtom(server.display, "_NET_CLIENT_LIST", False); - server.atom._NET_WM_VISIBLE_NAME = XInternAtom(server.display, "_NET_WM_VISIBLE_NAME", False); - server.atom._NET_WM_NAME = XInternAtom(server.display, "_NET_WM_NAME", False); - server.atom._NET_WM_STRUT = XInternAtom(server.display, "_NET_WM_STRUT", False); - server.atom._NET_WM_ICON = XInternAtom(server.display, "_NET_WM_ICON", False); - server.atom._NET_WM_ICON_GEOMETRY = XInternAtom(server.display, "_NET_WM_ICON_GEOMETRY", False); - server.atom._NET_WM_ICON_NAME = XInternAtom(server.display, "_NET_WM_ICON_NAME", False); - server.atom._NET_CLOSE_WINDOW = XInternAtom(server.display, "_NET_CLOSE_WINDOW", False); - server.atom.UTF8_STRING = XInternAtom(server.display, "UTF8_STRING", False); - server.atom._NET_SUPPORTING_WM_CHECK = XInternAtom(server.display, "_NET_SUPPORTING_WM_CHECK", False); - server.atom._NET_WM_CM_S0 = XInternAtom(server.display, "_NET_WM_CM_S0", False); - server.atom._NET_SUPPORTING_WM_CHECK = XInternAtom(server.display, "_NET_WM_NAME", False); - server.atom._NET_WM_STRUT_PARTIAL = XInternAtom(server.display, "_NET_WM_STRUT_PARTIAL", False); - server.atom.WM_NAME = XInternAtom(server.display, "WM_NAME", False); - server.atom.__SWM_VROOT = XInternAtom(server.display, "__SWM_VROOT", False); - server.atom._MOTIF_WM_HINTS = XInternAtom(server.display, "_MOTIF_WM_HINTS", False); - server.atom.WM_HINTS = XInternAtom(server.display, "WM_HINTS", False); - gchar *name = g_strdup_printf("_XSETTINGS_S%d", DefaultScreen(server.display)); - server.atom._XSETTINGS_SCREEN = XInternAtom(server.display, name, False); - g_free(name); - server.atom._XSETTINGS_SETTINGS = XInternAtom(server.display, "_XSETTINGS_SETTINGS", False); + server.atom._XROOTPMAP_ID = XInternAtom(server.display, "_XROOTPMAP_ID", False); + server.atom._XROOTMAP_ID = XInternAtom(server.display, "_XROOTMAP_ID", False); + server.atom._NET_CURRENT_DESKTOP = XInternAtom(server.display, "_NET_CURRENT_DESKTOP", False); + server.atom._NET_NUMBER_OF_DESKTOPS = XInternAtom(server.display, "_NET_NUMBER_OF_DESKTOPS", False); + server.atom._NET_DESKTOP_NAMES = XInternAtom(server.display, "_NET_DESKTOP_NAMES", False); + server.atom._NET_DESKTOP_GEOMETRY = XInternAtom(server.display, "_NET_DESKTOP_GEOMETRY", False); + server.atom._NET_DESKTOP_VIEWPORT = XInternAtom(server.display, "_NET_DESKTOP_VIEWPORT", False); + server.atom._NET_WORKAREA = XInternAtom(server.display, "_NET_WORKAREA", False); + server.atom._NET_ACTIVE_WINDOW = XInternAtom(server.display, "_NET_ACTIVE_WINDOW", False); + server.atom._NET_WM_WINDOW_TYPE = XInternAtom(server.display, "_NET_WM_WINDOW_TYPE", False); + server.atom._NET_WM_STATE_SKIP_PAGER = XInternAtom(server.display, "_NET_WM_STATE_SKIP_PAGER", False); + server.atom._NET_WM_STATE_SKIP_TASKBAR = XInternAtom(server.display, "_NET_WM_STATE_SKIP_TASKBAR", False); + server.atom._NET_WM_STATE_STICKY = XInternAtom(server.display, "_NET_WM_STATE_STICKY", False); + server.atom._NET_WM_STATE_DEMANDS_ATTENTION = XInternAtom(server.display, "_NET_WM_STATE_DEMANDS_ATTENTION", False); + server.atom._NET_WM_WINDOW_TYPE_DOCK = XInternAtom(server.display, "_NET_WM_WINDOW_TYPE_DOCK", False); + server.atom._NET_WM_WINDOW_TYPE_DESKTOP = XInternAtom(server.display, "_NET_WM_WINDOW_TYPE_DESKTOP", False); + server.atom._NET_WM_WINDOW_TYPE_TOOLBAR = XInternAtom(server.display, "_NET_WM_WINDOW_TYPE_TOOLBAR", False); + server.atom._NET_WM_WINDOW_TYPE_MENU = XInternAtom(server.display, "_NET_WM_WINDOW_TYPE_MENU", False); + server.atom._NET_WM_WINDOW_TYPE_SPLASH = XInternAtom(server.display, "_NET_WM_WINDOW_TYPE_SPLASH", False); + server.atom._NET_WM_WINDOW_TYPE_DIALOG = XInternAtom(server.display, "_NET_WM_WINDOW_TYPE_DIALOG", False); + server.atom._NET_WM_WINDOW_TYPE_NORMAL = XInternAtom(server.display, "_NET_WM_WINDOW_TYPE_NORMAL", False); + server.atom._NET_WM_DESKTOP = XInternAtom(server.display, "_NET_WM_DESKTOP", False); + server.atom.WM_STATE = XInternAtom(server.display, "WM_STATE", False); + server.atom._NET_WM_STATE = XInternAtom(server.display, "_NET_WM_STATE", False); + server.atom._NET_WM_STATE_MAXIMIZED_VERT = XInternAtom(server.display, "_NET_WM_STATE_MAXIMIZED_VERT", False); + server.atom._NET_WM_STATE_MAXIMIZED_HORZ = XInternAtom(server.display, "_NET_WM_STATE_MAXIMIZED_HORZ", False); + server.atom._NET_WM_STATE_SHADED = XInternAtom(server.display, "_NET_WM_STATE_SHADED", False); + server.atom._NET_WM_STATE_HIDDEN = XInternAtom(server.display, "_NET_WM_STATE_HIDDEN", False); + server.atom._NET_WM_STATE_BELOW = XInternAtom(server.display, "_NET_WM_STATE_BELOW", False); + server.atom._NET_WM_STATE_ABOVE = XInternAtom(server.display, "_NET_WM_STATE_ABOVE", False); + server.atom._NET_WM_STATE_MODAL = XInternAtom(server.display, "_NET_WM_STATE_MODAL", False); + server.atom._NET_CLIENT_LIST = XInternAtom(server.display, "_NET_CLIENT_LIST", False); + server.atom._NET_WM_VISIBLE_NAME = XInternAtom(server.display, "_NET_WM_VISIBLE_NAME", False); + server.atom._NET_WM_NAME = XInternAtom(server.display, "_NET_WM_NAME", False); + server.atom._NET_WM_STRUT = XInternAtom(server.display, "_NET_WM_STRUT", False); + server.atom._NET_WM_ICON = XInternAtom(server.display, "_NET_WM_ICON", False); + server.atom._NET_WM_ICON_GEOMETRY = XInternAtom(server.display, "_NET_WM_ICON_GEOMETRY", False); + server.atom._NET_WM_ICON_NAME = XInternAtom(server.display, "_NET_WM_ICON_NAME", False); + server.atom._NET_CLOSE_WINDOW = XInternAtom(server.display, "_NET_CLOSE_WINDOW", False); + server.atom.UTF8_STRING = XInternAtom(server.display, "UTF8_STRING", False); + server.atom._NET_SUPPORTING_WM_CHECK = XInternAtom(server.display, "_NET_SUPPORTING_WM_CHECK", False); + server.atom._NET_WM_CM_S0 = XInternAtom(server.display, "_NET_WM_CM_S0", False); + server.atom._NET_SUPPORTING_WM_CHECK = XInternAtom(server.display, "_NET_WM_NAME", False); + server.atom._NET_WM_STRUT_PARTIAL = XInternAtom(server.display, "_NET_WM_STRUT_PARTIAL", False); + server.atom.WM_NAME = XInternAtom(server.display, "WM_NAME", False); + server.atom.__SWM_VROOT = XInternAtom(server.display, "__SWM_VROOT", False); + server.atom._MOTIF_WM_HINTS = XInternAtom(server.display, "_MOTIF_WM_HINTS", False); + server.atom.WM_HINTS = XInternAtom(server.display, "WM_HINTS", False); + gchar *name = g_strdup_printf("_XSETTINGS_S%d", DefaultScreen(server.display)); + server.atom._XSETTINGS_SCREEN = XInternAtom(server.display, name, False); + g_free(name); + server.atom._XSETTINGS_SETTINGS = XInternAtom(server.display, "_XSETTINGS_SETTINGS", False); - // systray protocol - name = g_strdup_printf("_NET_SYSTEM_TRAY_S%d", DefaultScreen(server.display)); - server.atom._NET_SYSTEM_TRAY_SCREEN = XInternAtom(server.display, name, False); - g_free(name); - server.atom._NET_SYSTEM_TRAY_OPCODE = XInternAtom(server.display, "_NET_SYSTEM_TRAY_OPCODE", False); - server.atom.MANAGER = XInternAtom(server.display, "MANAGER", False); - server.atom._NET_SYSTEM_TRAY_MESSAGE_DATA = XInternAtom(server.display, "_NET_SYSTEM_TRAY_MESSAGE_DATA", False); - server.atom._NET_SYSTEM_TRAY_ORIENTATION = XInternAtom(server.display, "_NET_SYSTEM_TRAY_ORIENTATION", False); - server.atom._NET_SYSTEM_TRAY_ICON_SIZE = XInternAtom(server.display, "_NET_SYSTEM_TRAY_ICON_SIZE", False); - server.atom._NET_SYSTEM_TRAY_PADDING = XInternAtom(server.display, "_NET_SYSTEM_TRAY_PADDING", False); - server.atom._XEMBED = XInternAtom(server.display, "_XEMBED", False); - server.atom._XEMBED_INFO = XInternAtom(server.display, "_XEMBED_INFO", False); - server.atom._NET_WM_PID = XInternAtom(server.display, "_NET_WM_PID", True); + // systray protocol + name = g_strdup_printf("_NET_SYSTEM_TRAY_S%d", DefaultScreen(server.display)); + server.atom._NET_SYSTEM_TRAY_SCREEN = XInternAtom(server.display, name, False); + g_free(name); + server.atom._NET_SYSTEM_TRAY_OPCODE = XInternAtom(server.display, "_NET_SYSTEM_TRAY_OPCODE", False); + server.atom.MANAGER = XInternAtom(server.display, "MANAGER", False); + server.atom._NET_SYSTEM_TRAY_MESSAGE_DATA = XInternAtom(server.display, "_NET_SYSTEM_TRAY_MESSAGE_DATA", False); + server.atom._NET_SYSTEM_TRAY_ORIENTATION = XInternAtom(server.display, "_NET_SYSTEM_TRAY_ORIENTATION", False); + server.atom._NET_SYSTEM_TRAY_ICON_SIZE = XInternAtom(server.display, "_NET_SYSTEM_TRAY_ICON_SIZE", False); + server.atom._NET_SYSTEM_TRAY_PADDING = XInternAtom(server.display, "_NET_SYSTEM_TRAY_PADDING", False); + server.atom._XEMBED = XInternAtom(server.display, "_XEMBED", False); + server.atom._XEMBED_INFO = XInternAtom(server.display, "_XEMBED_INFO", False); + server.atom._NET_WM_PID = XInternAtom(server.display, "_NET_WM_PID", True); - // drag 'n' drop - server.atom.XdndAware = XInternAtom(server.display, "XdndAware", False); - server.atom.XdndEnter = XInternAtom(server.display, "XdndEnter", False); - server.atom.XdndPosition = XInternAtom(server.display, "XdndPosition", False); - server.atom.XdndStatus = XInternAtom(server.display, "XdndStatus", False); - server.atom.XdndDrop = XInternAtom(server.display, "XdndDrop", False); - server.atom.XdndLeave = XInternAtom(server.display, "XdndLeave", False); - server.atom.XdndSelection = XInternAtom(server.display, "XdndSelection", False); - server.atom.XdndTypeList = XInternAtom(server.display, "XdndTypeList", False); - server.atom.XdndActionCopy = XInternAtom(server.display, "XdndActionCopy", False); - server.atom.XdndFinished = XInternAtom(server.display, "XdndFinished", False); - server.atom.TARGETS = XInternAtom(server.display, "TARGETS", False); + // drag 'n' drop + server.atom.XdndAware = XInternAtom(server.display, "XdndAware", False); + server.atom.XdndEnter = XInternAtom(server.display, "XdndEnter", False); + server.atom.XdndPosition = XInternAtom(server.display, "XdndPosition", False); + server.atom.XdndStatus = XInternAtom(server.display, "XdndStatus", False); + server.atom.XdndDrop = XInternAtom(server.display, "XdndDrop", False); + server.atom.XdndLeave = XInternAtom(server.display, "XdndLeave", False); + server.atom.XdndSelection = XInternAtom(server.display, "XdndSelection", False); + server.atom.XdndTypeList = XInternAtom(server.display, "XdndTypeList", False); + server.atom.XdndActionCopy = XInternAtom(server.display, "XdndActionCopy", False); + server.atom.XdndFinished = XInternAtom(server.display, "XdndFinished", False); + server.atom.TARGETS = XInternAtom(server.display, "TARGETS", False); } void cleanup_server() { - if (server.colormap) - XFreeColormap(server.display, server.colormap); - server.colormap = 0; - if (server.colormap32) - XFreeColormap(server.display, server.colormap32); - server.colormap32 = 0; - if (server.monitors) { - for (int i = 0; i < server.num_monitors; ++i) { - g_strfreev(server.monitors[i].names); - server.monitors[i].names = NULL; - } - free(server.monitors); - server.monitors = NULL; - } - if (server.gc) - XFreeGC(server.display, server.gc); - server.gc = NULL; - server.disable_transparency = FALSE; + if (server.colormap) + XFreeColormap(server.display, server.colormap); + server.colormap = 0; + if (server.colormap32) + XFreeColormap(server.display, server.colormap32); + server.colormap32 = 0; + if (server.monitors) { + for (int i = 0; i < server.num_monitors; ++i) { + g_strfreev(server.monitors[i].names); + server.monitors[i].names = NULL; + } + free(server.monitors); + server.monitors = NULL; + } + if (server.gc) + XFreeGC(server.display, server.gc); + server.gc = NULL; + server.disable_transparency = FALSE; #ifdef HAVE_SN - if (server.pids) - g_tree_destroy(server.pids); - server.pids = NULL; + if (server.pids) + g_tree_destroy(server.pids); + server.pids = NULL; #endif } void send_event32(Window win, Atom at, long data1, long data2, long data3) { - XEvent event; + XEvent event; - event.xclient.type = ClientMessage; - event.xclient.serial = 0; - event.xclient.send_event = True; - event.xclient.display = server.display; - event.xclient.window = win; - event.xclient.message_type = at; + event.xclient.type = ClientMessage; + event.xclient.serial = 0; + event.xclient.send_event = True; + event.xclient.display = server.display; + event.xclient.window = win; + event.xclient.message_type = at; - event.xclient.format = 32; - event.xclient.data.l[0] = data1; - event.xclient.data.l[1] = data2; - event.xclient.data.l[2] = data3; - event.xclient.data.l[3] = 0; - event.xclient.data.l[4] = 0; + event.xclient.format = 32; + event.xclient.data.l[0] = data1; + event.xclient.data.l[1] = data2; + event.xclient.data.l[2] = data3; + event.xclient.data.l[3] = 0; + event.xclient.data.l[4] = 0; - XSendEvent(server.display, server.root_win, False, SubstructureRedirectMask | SubstructureNotifyMask, &event); + XSendEvent(server.display, server.root_win, False, SubstructureRedirectMask | SubstructureNotifyMask, &event); } int get_property32(Window win, Atom at, Atom type) { - Atom type_ret; - int format_ret = 0, data = 0; - unsigned long nitems_ret = 0; - unsigned long bafter_ret = 0; - unsigned char *prop_value = 0; - int result; + Atom type_ret; + int format_ret = 0, data = 0; + unsigned long nitems_ret = 0; + unsigned long bafter_ret = 0; + unsigned char *prop_value = 0; + int result; - if (!win) - return 0; + if (!win) + return 0; - result = XGetWindowProperty(server.display, - win, - at, - 0, - 0x7fffffff, - False, - type, - &type_ret, - &format_ret, - &nitems_ret, - &bafter_ret, - &prop_value); + result = XGetWindowProperty(server.display, + win, + at, + 0, + 0x7fffffff, + False, + type, + &type_ret, + &format_ret, + &nitems_ret, + &bafter_ret, + &prop_value); - if (result == Success && prop_value) { - data = ((gulong *)prop_value)[0]; - XFree(prop_value); - } - return data; + if (result == Success && prop_value) { + data = ((gulong *)prop_value)[0]; + XFree(prop_value); + } + return data; } void *server_get_property(Window win, Atom at, Atom type, int *num_results) { - Atom type_ret; - int format_ret = 0; - unsigned long nitems_ret = 0; - unsigned long bafter_ret = 0; - unsigned char *prop_value; + Atom type_ret; + int format_ret = 0; + unsigned long nitems_ret = 0; + unsigned long bafter_ret = 0; + unsigned char *prop_value; - if (!win) - return NULL; + if (!win) + return NULL; - int result = XGetWindowProperty(server.display, - win, - at, - 0, - 0x7fffffff, - False, - type, - &type_ret, - &format_ret, - &nitems_ret, - &bafter_ret, - &prop_value); + int result = XGetWindowProperty(server.display, + win, + at, + 0, + 0x7fffffff, + False, + type, + &type_ret, + &format_ret, + &nitems_ret, + &bafter_ret, + &prop_value); - // Send fill_color resultcount - if (num_results) - *num_results = (int)nitems_ret; + // Send fill_color resultcount + if (num_results) + *num_results = (int)nitems_ret; - if (result == Success && prop_value) - return prop_value; - else - return NULL; + if (result == Success && prop_value) + return prop_value; + else + return NULL; } void get_root_pixmap() { - Pixmap ret = None; + Pixmap ret = None; - Atom pixmap_atoms[] = {server.atom._XROOTPMAP_ID, server.atom._XROOTMAP_ID}; - for (int i = 0; i < sizeof(pixmap_atoms) / sizeof(Atom); ++i) { - unsigned long *res = (unsigned long *)server_get_property(server.root_win, pixmap_atoms[i], XA_PIXMAP, NULL); - if (res) { - ret = *((Pixmap *)res); - XFree(res); - break; - } - } - server.root_pmap = ret; + Atom pixmap_atoms[] = {server.atom._XROOTPMAP_ID, server.atom._XROOTMAP_ID}; + for (int i = 0; i < sizeof(pixmap_atoms) / sizeof(Atom); ++i) { + unsigned long *res = (unsigned long *)server_get_property(server.root_win, pixmap_atoms[i], XA_PIXMAP, NULL); + if (res) { + ret = *((Pixmap *)res); + XFree(res); + break; + } + } + server.root_pmap = ret; - if (server.root_pmap == None) { - fprintf(stderr, "tint2 : pixmap background detection failed\n"); - } else { - XGCValues gcv; - gcv.ts_x_origin = 0; - gcv.ts_y_origin = 0; - gcv.fill_style = FillTiled; - unsigned mask = GCTileStipXOrigin | GCTileStipYOrigin | GCFillStyle | GCTile; + if (server.root_pmap == None) { + fprintf(stderr, "tint2 : pixmap background detection failed\n"); + } else { + XGCValues gcv; + gcv.ts_x_origin = 0; + gcv.ts_y_origin = 0; + gcv.fill_style = FillTiled; + unsigned mask = GCTileStipXOrigin | GCTileStipYOrigin | GCFillStyle | GCTile; - gcv.tile = server.root_pmap; - XChangeGC(server.display, server.gc, mask, &gcv); - } + gcv.tile = server.root_pmap; + XChangeGC(server.display, server.gc, mask, &gcv); + } } int compare_monitor_pos(const void *monitor1, const void *monitor2) { - const Monitor *m1 = (const Monitor *)monitor1; - const Monitor *m2 = (const Monitor *)monitor2; + const Monitor *m1 = (const Monitor *)monitor1; + const Monitor *m2 = (const Monitor *)monitor2; - if (primary_monitor_first) { - if (m1->primary && !m2->primary) - return -1; - if (!m1->primary && m2->primary) - return 1; - } + if (primary_monitor_first) { + if (m1->primary && !m2->primary) + return -1; + if (!m1->primary && m2->primary) + return 1; + } - if (m1->x < m2->x) { - return -1; - } else if (m1->x > m2->x) { - return 1; - } else if (m1->y < m2->y) { - return -1; - } else if (m1->y > m2->y) { - return 1; - } else { - return 0; - } + if (m1->x < m2->x) { + return -1; + } else if (m1->x > m2->x) { + return 1; + } else if (m1->y < m2->y) { + return -1; + } else if (m1->y > m2->y) { + return 1; + } else { + return 0; + } } int monitor_includes_monitor(const void *monitor1, const void *monitor2) { - const Monitor *m1 = (const Monitor *)monitor1; - const Monitor *m2 = (const Monitor *)monitor2; + const Monitor *m1 = (const Monitor *)monitor1; + const Monitor *m2 = (const Monitor *)monitor2; - if (m1->x >= m2->x && m1->y >= m2->y && (m1->x + m1->width) <= (m2->x + m2->width) && - (m1->y + m1->height) <= (m2->y + m2->height)) { - // m1 included inside m2 - return 1; - } else { - return -1; - } + if (m1->x >= m2->x && m1->y >= m2->y && (m1->x + m1->width) <= (m2->x + m2->width) && + (m1->y + m1->height) <= (m2->y + m2->height)) { + // m1 included inside m2 + return 1; + } else { + return -1; + } } void sort_monitors() { - qsort(server.monitors, server.num_monitors, sizeof(Monitor), compare_monitor_pos); + qsort(server.monitors, server.num_monitors, sizeof(Monitor), compare_monitor_pos); } void get_monitors() { - if (XineramaIsActive(server.display)) { - int num_monitors; - XineramaScreenInfo *info = XineramaQueryScreens(server.display, &num_monitors); - XRRScreenResources *res = XRRGetScreenResourcesCurrent(server.display, server.root_win); - RROutput primary_output = XRRGetOutputPrimary(server.display, server.root_win); + if (XineramaIsActive(server.display)) { + int num_monitors; + XineramaScreenInfo *info = XineramaQueryScreens(server.display, &num_monitors); + XRRScreenResources *res = XRRGetScreenResourcesCurrent(server.display, server.root_win); + RROutput primary_output = XRRGetOutputPrimary(server.display, server.root_win); - if (res && res->ncrtc >= num_monitors) { - // use xrandr to identify monitors (does not work with proprietery nvidia drivers) - printf("xRandr: Found crtc's: %d\n", res->ncrtc); - server.monitors = calloc(res->ncrtc, sizeof(Monitor)); - num_monitors = 0; - for (int i = 0; i < res->ncrtc; ++i) { - XRRCrtcInfo *crtc_info = XRRGetCrtcInfo(server.display, res, res->crtcs[i]); - // Ignore empty crtc - if (!crtc_info->width || !crtc_info->height) { - printf("xRandr: crtc %d seems disabled\n", i); - XRRFreeCrtcInfo(crtc_info); - continue; - } - int i_monitor = num_monitors; - num_monitors++; - server.monitors[i_monitor].x = crtc_info->x; - server.monitors[i_monitor].y = crtc_info->y; - server.monitors[i_monitor].width = crtc_info->width; - server.monitors[i_monitor].height = crtc_info->height; - server.monitors[i_monitor].names = calloc((crtc_info->noutput + 1), sizeof(gchar *)); - for (int j = 0; j < crtc_info->noutput; ++j) { - XRROutputInfo *output_info = XRRGetOutputInfo(server.display, res, crtc_info->outputs[j]); - printf("xRandr: Linking output %s with crtc %d\n", output_info->name, i); - server.monitors[i_monitor].names[j] = g_strdup(output_info->name); - XRRFreeOutputInfo(output_info); - server.monitors[i_monitor].primary = crtc_info->outputs[j] == primary_output; - } - server.monitors[i_monitor].names[crtc_info->noutput] = NULL; - XRRFreeCrtcInfo(crtc_info); - } - } else if (info && num_monitors > 0) { - server.monitors = calloc(num_monitors, sizeof(Monitor)); - for (int i = 0; i < num_monitors; i++) { - server.monitors[i].x = info[i].x_org; - server.monitors[i].y = info[i].y_org; - server.monitors[i].width = info[i].width; - server.monitors[i].height = info[i].height; - server.monitors[i].names = NULL; - } - } + if (res && res->ncrtc >= num_monitors) { + // use xrandr to identify monitors (does not work with proprietery nvidia drivers) + printf("xRandr: Found crtc's: %d\n", res->ncrtc); + server.monitors = calloc(res->ncrtc, sizeof(Monitor)); + num_monitors = 0; + for (int i = 0; i < res->ncrtc; ++i) { + XRRCrtcInfo *crtc_info = XRRGetCrtcInfo(server.display, res, res->crtcs[i]); + // Ignore empty crtc + if (!crtc_info->width || !crtc_info->height) { + printf("xRandr: crtc %d seems disabled\n", i); + XRRFreeCrtcInfo(crtc_info); + continue; + } + int i_monitor = num_monitors; + num_monitors++; + server.monitors[i_monitor].x = crtc_info->x; + server.monitors[i_monitor].y = crtc_info->y; + server.monitors[i_monitor].width = crtc_info->width; + server.monitors[i_monitor].height = crtc_info->height; + server.monitors[i_monitor].names = calloc((crtc_info->noutput + 1), sizeof(gchar *)); + for (int j = 0; j < crtc_info->noutput; ++j) { + XRROutputInfo *output_info = XRRGetOutputInfo(server.display, res, crtc_info->outputs[j]); + printf("xRandr: Linking output %s with crtc %d\n", output_info->name, i); + server.monitors[i_monitor].names[j] = g_strdup(output_info->name); + XRRFreeOutputInfo(output_info); + server.monitors[i_monitor].primary = crtc_info->outputs[j] == primary_output; + } + server.monitors[i_monitor].names[crtc_info->noutput] = NULL; + XRRFreeCrtcInfo(crtc_info); + } + } else if (info && num_monitors > 0) { + server.monitors = calloc(num_monitors, sizeof(Monitor)); + for (int i = 0; i < num_monitors; i++) { + server.monitors[i].x = info[i].x_org; + server.monitors[i].y = info[i].y_org; + server.monitors[i].width = info[i].width; + server.monitors[i].height = info[i].height; + server.monitors[i].names = NULL; + } + } - // Sort monitors by inclusion - qsort(server.monitors, num_monitors, sizeof(Monitor), monitor_includes_monitor); + // Sort monitors by inclusion + qsort(server.monitors, num_monitors, sizeof(Monitor), monitor_includes_monitor); - // Remove monitors included in other ones - int i = 0; - while (i < num_monitors) { - for (int j = 0; j < i; j++) { - if (monitor_includes_monitor(&server.monitors[i], &server.monitors[j]) > 0) { - goto next; - } - } - i++; - } - next: - for (int j = i; j < num_monitors; ++j) - if (server.monitors[j].names) - g_strfreev(server.monitors[j].names); - server.num_monitors = i; - server.monitors = realloc(server.monitors, server.num_monitors * sizeof(Monitor)); - qsort(server.monitors, server.num_monitors, sizeof(Monitor), compare_monitor_pos); + // Remove monitors included in other ones + int i = 0; + while (i < num_monitors) { + for (int j = 0; j < i; j++) { + if (monitor_includes_monitor(&server.monitors[i], &server.monitors[j]) > 0) { + goto next; + } + } + i++; + } + next: + for (int j = i; j < num_monitors; ++j) + if (server.monitors[j].names) + g_strfreev(server.monitors[j].names); + server.num_monitors = i; + server.monitors = realloc(server.monitors, server.num_monitors * sizeof(Monitor)); + qsort(server.monitors, server.num_monitors, sizeof(Monitor), compare_monitor_pos); - if (res) - XRRFreeScreenResources(res); - XFree(info); - } + if (res) + XRRFreeScreenResources(res); + XFree(info); + } - if (!server.num_monitors) { - server.num_monitors = 1; - server.monitors = calloc(1, sizeof(Monitor)); - server.monitors[0].x = server.monitors[0].y = 0; - server.monitors[0].width = DisplayWidth(server.display, server.screen); - server.monitors[0].height = DisplayHeight(server.display, server.screen); - server.monitors[0].names = 0; - } + if (!server.num_monitors) { + server.num_monitors = 1; + server.monitors = calloc(1, sizeof(Monitor)); + server.monitors[0].x = server.monitors[0].y = 0; + server.monitors[0].width = DisplayWidth(server.display, server.screen); + server.monitors[0].height = DisplayHeight(server.display, server.screen); + server.monitors[0].names = 0; + } } void print_monitors() { - fprintf(stderr, "Number of monitors: %d\n", server.num_monitors); - for (int i = 0; i < server.num_monitors; i++) { - fprintf(stderr, - "Monitor %d: x = %d, y = %d, w = %d, h = %d\n", - i + 1, - server.monitors[i].x, - server.monitors[i].y, - server.monitors[i].width, - server.monitors[i].height); - } + fprintf(stderr, "Number of monitors: %d\n", server.num_monitors); + for (int i = 0; i < server.num_monitors; i++) { + fprintf(stderr, + "Monitor %d: x = %d, y = %d, w = %d, h = %d\n", + i + 1, + server.monitors[i].x, + server.monitors[i].y, + server.monitors[i].width, + server.monitors[i].height); + } } void server_get_number_of_desktops() { - if (server.viewports) { - free(server.viewports); - server.viewports = NULL; - } + if (server.viewports) { + free(server.viewports); + server.viewports = NULL; + } - server.num_desktops = get_property32(server.root_win, server.atom._NET_NUMBER_OF_DESKTOPS, XA_CARDINAL); - if (server.num_desktops > 1) - return; + server.num_desktops = get_property32(server.root_win, server.atom._NET_NUMBER_OF_DESKTOPS, XA_CARDINAL); + if (server.num_desktops > 1) + return; - int num_results; - long *work_area_size = server_get_property(server.root_win, server.atom._NET_WORKAREA, XA_CARDINAL, &num_results); - if (!work_area_size) - return; - int work_area_width = work_area_size[0] + work_area_size[2]; - int work_area_height = work_area_size[1] + work_area_size[3]; - XFree(work_area_size); + int num_results; + long *work_area_size = server_get_property(server.root_win, server.atom._NET_WORKAREA, XA_CARDINAL, &num_results); + if (!work_area_size) + return; + int work_area_width = work_area_size[0] + work_area_size[2]; + int work_area_height = work_area_size[1] + work_area_size[3]; + XFree(work_area_size); - long *x_screen_size = - server_get_property(server.root_win, server.atom._NET_DESKTOP_GEOMETRY, XA_CARDINAL, &num_results); - if (!x_screen_size) - return; - int x_screen_width = x_screen_size[0]; - int x_screen_height = x_screen_size[1]; - XFree(x_screen_size); + long *x_screen_size = + server_get_property(server.root_win, server.atom._NET_DESKTOP_GEOMETRY, XA_CARDINAL, &num_results); + if (!x_screen_size) + return; + int x_screen_width = x_screen_size[0]; + int x_screen_height = x_screen_size[1]; + XFree(x_screen_size); - int num_viewports = MAX(x_screen_width / work_area_width, 1) * MAX(x_screen_height / work_area_height, 1); - if (num_viewports <= 1) { - server.num_desktops = 1; - return; - } + int num_viewports = MAX(x_screen_width / work_area_width, 1) * MAX(x_screen_height / work_area_height, 1); + if (num_viewports <= 1) { + server.num_desktops = 1; + return; + } - server.viewports = calloc(num_viewports, sizeof(Viewport)); - int k = 0; - for (int i = 0; i < MAX(x_screen_height / work_area_height, 1); i++) { - for (int j = 0; j < MAX(x_screen_width / work_area_width, 1); j++) { - server.viewports[k].x = j * work_area_width; - server.viewports[k].y = i * work_area_height; - server.viewports[k].width = work_area_width; - server.viewports[k].height = work_area_height; - k++; - } - } + server.viewports = calloc(num_viewports, sizeof(Viewport)); + int k = 0; + for (int i = 0; i < MAX(x_screen_height / work_area_height, 1); i++) { + for (int j = 0; j < MAX(x_screen_width / work_area_width, 1); j++) { + server.viewports[k].x = j * work_area_width; + server.viewports[k].y = i * work_area_height; + server.viewports[k].width = work_area_width; + server.viewports[k].height = work_area_height; + k++; + } + } - server.num_desktops = num_viewports; + server.num_desktops = num_viewports; } GSList *get_desktop_names() { - if (server.viewports) { - GSList *list = NULL; - for (int j = 0; j < server.num_desktops; j++) { - list = g_slist_append(list, g_strdup_printf("%d", j + 1)); - } - return list; - } + if (server.viewports) { + GSList *list = NULL; + for (int j = 0; j < server.num_desktops; j++) { + list = g_slist_append(list, g_strdup_printf("%d", j + 1)); + } + return list; + } - int count; - GSList *list = NULL; - gchar *data_ptr = - server_get_property(server.root_win, server.atom._NET_DESKTOP_NAMES, server.atom.UTF8_STRING, &count); - if (data_ptr) { - list = g_slist_append(list, g_strdup(data_ptr)); - for (int j = 0; j < count - 1; j++) { - if (*(data_ptr + j) == '\0') { - gchar *ptr = (gchar *)data_ptr + j + 1; - list = g_slist_append(list, g_strdup(ptr)); - } - } - XFree(data_ptr); - } - return list; + int count; + GSList *list = NULL; + gchar *data_ptr = + server_get_property(server.root_win, server.atom._NET_DESKTOP_NAMES, server.atom.UTF8_STRING, &count); + if (data_ptr) { + list = g_slist_append(list, g_strdup(data_ptr)); + for (int j = 0; j < count - 1; j++) { + if (*(data_ptr + j) == '\0') { + gchar *ptr = (gchar *)data_ptr + j + 1; + list = g_slist_append(list, g_strdup(ptr)); + } + } + XFree(data_ptr); + } + return list; } int get_current_desktop() { - if (!server.viewports) { - return MAX(0, - MIN(server.num_desktops - 1, - get_property32(server.root_win, server.atom._NET_CURRENT_DESKTOP, XA_CARDINAL))); - } + if (!server.viewports) { + return MAX(0, + MIN(server.num_desktops - 1, + get_property32(server.root_win, server.atom._NET_CURRENT_DESKTOP, XA_CARDINAL))); + } - int num_results; - long *work_area_size = server_get_property(server.root_win, server.atom._NET_WORKAREA, XA_CARDINAL, &num_results); - if (!work_area_size) - return 0; - int work_area_width = work_area_size[0] + work_area_size[2]; - int work_area_height = work_area_size[1] + work_area_size[3]; - XFree(work_area_size); + int num_results; + long *work_area_size = server_get_property(server.root_win, server.atom._NET_WORKAREA, XA_CARDINAL, &num_results); + if (!work_area_size) + return 0; + int work_area_width = work_area_size[0] + work_area_size[2]; + int work_area_height = work_area_size[1] + work_area_size[3]; + XFree(work_area_size); - if (work_area_width <= 0 || work_area_height <= 0) - return 0; + if (work_area_width <= 0 || work_area_height <= 0) + return 0; - long *viewport = server_get_property(server.root_win, server.atom._NET_DESKTOP_VIEWPORT, XA_CARDINAL, &num_results); - if (!viewport) - return 0; - int viewport_x = viewport[0]; - int viewport_y = viewport[1]; - XFree(viewport); + long *viewport = server_get_property(server.root_win, server.atom._NET_DESKTOP_VIEWPORT, XA_CARDINAL, &num_results); + if (!viewport) + return 0; + int viewport_x = viewport[0]; + int viewport_y = viewport[1]; + XFree(viewport); - long *x_screen_size = - server_get_property(server.root_win, server.atom._NET_DESKTOP_GEOMETRY, XA_CARDINAL, &num_results); - if (!x_screen_size) - return 0; - int x_screen_width = x_screen_size[0]; - XFree(x_screen_size); + long *x_screen_size = + server_get_property(server.root_win, server.atom._NET_DESKTOP_GEOMETRY, XA_CARDINAL, &num_results); + if (!x_screen_size) + return 0; + int x_screen_width = x_screen_size[0]; + XFree(x_screen_size); - int ncols = x_screen_width / work_area_width; + int ncols = x_screen_width / work_area_width; - // fprintf(stderr, "\n"); - // fprintf(stderr, "Work area size: %d x %d\n", work_area_width, work_area_height); - // fprintf(stderr, "Viewport pos: %d x %d\n", viewport_x, viewport_y); - // fprintf(stderr, "Viewport i: %d\n", (viewport_y / work_area_height) * ncols + viewport_x / work_area_width); + // fprintf(stderr, "\n"); + // fprintf(stderr, "Work area size: %d x %d\n", work_area_width, work_area_height); + // fprintf(stderr, "Viewport pos: %d x %d\n", viewport_x, viewport_y); + // fprintf(stderr, "Viewport i: %d\n", (viewport_y / work_area_height) * ncols + viewport_x / work_area_width); - int result = (viewport_y / work_area_height) * ncols + viewport_x / work_area_width; - return MAX(0, MIN(server.num_desktops - 1, result)); + int result = (viewport_y / work_area_height) * ncols + viewport_x / work_area_width; + return MAX(0, MIN(server.num_desktops - 1, result)); } void change_desktop(int desktop) { - if (!server.viewports) { - send_event32(server.root_win, server.atom._NET_CURRENT_DESKTOP, desktop, 0, 0); - } else { - send_event32(server.root_win, - server.atom._NET_DESKTOP_VIEWPORT, - server.viewports[desktop].x, - server.viewports[desktop].y, - 0); - } + if (!server.viewports) { + send_event32(server.root_win, server.atom._NET_CURRENT_DESKTOP, desktop, 0, 0); + } else { + send_event32(server.root_win, + server.atom._NET_DESKTOP_VIEWPORT, + server.viewports[desktop].x, + server.viewports[desktop].y, + 0); + } } void get_desktops() { - // detect number of desktops - // wait 15s to leave some time for window manager startup - for (int i = 0; i < 15; i++) { - server_get_number_of_desktops(); - if (server.num_desktops > 0) - break; - sleep(1); - } - if (server.num_desktops == 0) { - server.num_desktops = 1; - fprintf(stderr, "warning : WM doesn't respect NETWM specs. tint2 default to 1 desktop.\n"); - } + // detect number of desktops + // wait 15s to leave some time for window manager startup + for (int i = 0; i < 15; i++) { + server_get_number_of_desktops(); + if (server.num_desktops > 0) + break; + sleep(1); + } + if (server.num_desktops == 0) { + server.num_desktops = 1; + fprintf(stderr, "warning : WM doesn't respect NETWM specs. tint2 default to 1 desktop.\n"); + } } void server_init_visual() { - // inspired by freedesktops fdclock ;) - XVisualInfo templ = {.screen = server.screen, .depth = 32, .class = TrueColor}; - int nvi; - XVisualInfo *xvi = - XGetVisualInfo(server.display, VisualScreenMask | VisualDepthMask | VisualClassMask, &templ, &nvi); + // inspired by freedesktops fdclock ;) + XVisualInfo templ = {.screen = server.screen, .depth = 32, .class = TrueColor}; + int nvi; + XVisualInfo *xvi = + XGetVisualInfo(server.display, VisualScreenMask | VisualDepthMask | VisualClassMask, &templ, &nvi); - Visual *visual = NULL; - if (xvi) { - XRenderPictFormat *format; - for (int i = 0; i < nvi; i++) { - format = XRenderFindVisualFormat(server.display, xvi[i].visual); - if (format->type == PictTypeDirect && format->direct.alphaMask) { - visual = xvi[i].visual; - break; - } - } - } - XFree(xvi); + Visual *visual = NULL; + if (xvi) { + XRenderPictFormat *format; + for (int i = 0; i < nvi; i++) { + format = XRenderFindVisualFormat(server.display, xvi[i].visual); + if (format->type == PictTypeDirect && format->direct.alphaMask) { + visual = xvi[i].visual; + break; + } + } + } + XFree(xvi); - // check composite manager - server.composite_manager = XGetSelectionOwner(server.display, server.atom._NET_WM_CM_S0); - if (server.colormap) - XFreeColormap(server.display, server.colormap); - if (server.colormap32) - XFreeColormap(server.display, server.colormap32); + // check composite manager + server.composite_manager = XGetSelectionOwner(server.display, server.atom._NET_WM_CM_S0); + if (server.colormap) + XFreeColormap(server.display, server.colormap); + if (server.colormap32) + XFreeColormap(server.display, server.colormap32); - if (visual) { - server.visual32 = visual; - server.colormap32 = XCreateColormap(server.display, server.root_win, visual, AllocNone); - } + if (visual) { + server.visual32 = visual; + server.colormap32 = XCreateColormap(server.display, server.root_win, visual, AllocNone); + } - if (!server.disable_transparency && visual && server.composite_manager != None && !snapshot_path) { - XSetWindowAttributes attrs; - attrs.event_mask = StructureNotifyMask; - XChangeWindowAttributes(server.display, server.composite_manager, CWEventMask, &attrs); + if (!server.disable_transparency && visual && server.composite_manager != None && !snapshot_path) { + XSetWindowAttributes attrs; + attrs.event_mask = StructureNotifyMask; + XChangeWindowAttributes(server.display, server.composite_manager, CWEventMask, &attrs); - server.real_transparency = TRUE; - server.depth = 32; - printf("real transparency on... depth: %d\n", server.depth); - server.colormap = XCreateColormap(server.display, server.root_win, visual, AllocNone); - server.visual = visual; - } else { - // no composite manager or snapshot mode => fake transparency - server.real_transparency = FALSE; - server.depth = DefaultDepth(server.display, server.screen); - printf("real transparency off.... depth: %d\n", server.depth); - server.colormap = DefaultColormap(server.display, server.screen); - server.visual = DefaultVisual(server.display, server.screen); - } + server.real_transparency = TRUE; + server.depth = 32; + printf("real transparency on... depth: %d\n", server.depth); + server.colormap = XCreateColormap(server.display, server.root_win, visual, AllocNone); + server.visual = visual; + } else { + // no composite manager or snapshot mode => fake transparency + server.real_transparency = FALSE; + server.depth = DefaultDepth(server.display, server.screen); + printf("real transparency off.... depth: %d\n", server.depth); + server.colormap = DefaultColormap(server.display, server.screen); + server.visual = DefaultVisual(server.display, server.screen); + } }
M src/server.hsrc/server.h

@@ -21,123 +21,123 @@

extern gboolean primary_monitor_first; typedef struct Global_atom { - Atom _XROOTPMAP_ID; - Atom _XROOTMAP_ID; - Atom _NET_CURRENT_DESKTOP; - Atom _NET_NUMBER_OF_DESKTOPS; - Atom _NET_DESKTOP_NAMES; - Atom _NET_DESKTOP_GEOMETRY; - Atom _NET_DESKTOP_VIEWPORT; - Atom _NET_WORKAREA; - Atom _NET_ACTIVE_WINDOW; - Atom _NET_WM_WINDOW_TYPE; - Atom _NET_WM_STATE_SKIP_PAGER; - Atom _NET_WM_STATE_SKIP_TASKBAR; - Atom _NET_WM_STATE_STICKY; - Atom _NET_WM_STATE_DEMANDS_ATTENTION; - Atom _NET_WM_WINDOW_TYPE_DOCK; - Atom _NET_WM_WINDOW_TYPE_DESKTOP; - Atom _NET_WM_WINDOW_TYPE_TOOLBAR; - Atom _NET_WM_WINDOW_TYPE_MENU; - Atom _NET_WM_WINDOW_TYPE_SPLASH; - Atom _NET_WM_WINDOW_TYPE_DIALOG; - Atom _NET_WM_WINDOW_TYPE_NORMAL; - Atom _NET_WM_DESKTOP; - Atom WM_STATE; - Atom _NET_WM_STATE; - Atom _NET_WM_STATE_MAXIMIZED_VERT; - Atom _NET_WM_STATE_MAXIMIZED_HORZ; - Atom _NET_WM_STATE_SHADED; - Atom _NET_WM_STATE_HIDDEN; - Atom _NET_WM_STATE_BELOW; - Atom _NET_WM_STATE_ABOVE; - Atom _NET_WM_STATE_MODAL; - Atom _NET_CLIENT_LIST; - Atom _NET_WM_NAME; - Atom _NET_WM_VISIBLE_NAME; - Atom _NET_WM_STRUT; - Atom _NET_WM_ICON; - Atom _NET_WM_ICON_GEOMETRY; - Atom _NET_WM_ICON_NAME; - Atom _NET_CLOSE_WINDOW; - Atom UTF8_STRING; - Atom _NET_SUPPORTING_WM_CHECK; - Atom _NET_WM_CM_S0; - Atom _NET_WM_STRUT_PARTIAL; - Atom WM_NAME; - Atom __SWM_VROOT; - Atom _MOTIF_WM_HINTS; - Atom WM_HINTS; - Atom _NET_SYSTEM_TRAY_SCREEN; - Atom _NET_SYSTEM_TRAY_OPCODE; - Atom MANAGER; - Atom _NET_SYSTEM_TRAY_MESSAGE_DATA; - Atom _NET_SYSTEM_TRAY_ORIENTATION; - Atom _NET_SYSTEM_TRAY_ICON_SIZE; - Atom _NET_SYSTEM_TRAY_PADDING; - Atom _XEMBED; - Atom _XEMBED_INFO; - Atom _NET_WM_PID; - Atom _XSETTINGS_SCREEN; - Atom _XSETTINGS_SETTINGS; - Atom XdndAware; - Atom XdndEnter; - Atom XdndPosition; - Atom XdndStatus; - Atom XdndDrop; - Atom XdndLeave; - Atom XdndSelection; - Atom XdndTypeList; - Atom XdndActionCopy; - Atom XdndFinished; - Atom TARGETS; + Atom _XROOTPMAP_ID; + Atom _XROOTMAP_ID; + Atom _NET_CURRENT_DESKTOP; + Atom _NET_NUMBER_OF_DESKTOPS; + Atom _NET_DESKTOP_NAMES; + Atom _NET_DESKTOP_GEOMETRY; + Atom _NET_DESKTOP_VIEWPORT; + Atom _NET_WORKAREA; + Atom _NET_ACTIVE_WINDOW; + Atom _NET_WM_WINDOW_TYPE; + Atom _NET_WM_STATE_SKIP_PAGER; + Atom _NET_WM_STATE_SKIP_TASKBAR; + Atom _NET_WM_STATE_STICKY; + Atom _NET_WM_STATE_DEMANDS_ATTENTION; + Atom _NET_WM_WINDOW_TYPE_DOCK; + Atom _NET_WM_WINDOW_TYPE_DESKTOP; + Atom _NET_WM_WINDOW_TYPE_TOOLBAR; + Atom _NET_WM_WINDOW_TYPE_MENU; + Atom _NET_WM_WINDOW_TYPE_SPLASH; + Atom _NET_WM_WINDOW_TYPE_DIALOG; + Atom _NET_WM_WINDOW_TYPE_NORMAL; + Atom _NET_WM_DESKTOP; + Atom WM_STATE; + Atom _NET_WM_STATE; + Atom _NET_WM_STATE_MAXIMIZED_VERT; + Atom _NET_WM_STATE_MAXIMIZED_HORZ; + Atom _NET_WM_STATE_SHADED; + Atom _NET_WM_STATE_HIDDEN; + Atom _NET_WM_STATE_BELOW; + Atom _NET_WM_STATE_ABOVE; + Atom _NET_WM_STATE_MODAL; + Atom _NET_CLIENT_LIST; + Atom _NET_WM_NAME; + Atom _NET_WM_VISIBLE_NAME; + Atom _NET_WM_STRUT; + Atom _NET_WM_ICON; + Atom _NET_WM_ICON_GEOMETRY; + Atom _NET_WM_ICON_NAME; + Atom _NET_CLOSE_WINDOW; + Atom UTF8_STRING; + Atom _NET_SUPPORTING_WM_CHECK; + Atom _NET_WM_CM_S0; + Atom _NET_WM_STRUT_PARTIAL; + Atom WM_NAME; + Atom __SWM_VROOT; + Atom _MOTIF_WM_HINTS; + Atom WM_HINTS; + Atom _NET_SYSTEM_TRAY_SCREEN; + Atom _NET_SYSTEM_TRAY_OPCODE; + Atom MANAGER; + Atom _NET_SYSTEM_TRAY_MESSAGE_DATA; + Atom _NET_SYSTEM_TRAY_ORIENTATION; + Atom _NET_SYSTEM_TRAY_ICON_SIZE; + Atom _NET_SYSTEM_TRAY_PADDING; + Atom _XEMBED; + Atom _XEMBED_INFO; + Atom _NET_WM_PID; + Atom _XSETTINGS_SCREEN; + Atom _XSETTINGS_SETTINGS; + Atom XdndAware; + Atom XdndEnter; + Atom XdndPosition; + Atom XdndStatus; + Atom XdndDrop; + Atom XdndLeave; + Atom XdndSelection; + Atom XdndTypeList; + Atom XdndActionCopy; + Atom XdndFinished; + Atom TARGETS; } Global_atom; typedef struct Monitor { - int x; - int y; - int width; - int height; - gboolean primary; - gchar **names; + int x; + int y; + int width; + int height; + gboolean primary; + gchar **names; } Monitor; typedef struct Viewport { - int x; - int y; - int width; - int height; + int x; + int y; + int width; + int height; } Viewport; typedef struct Server { - Display *display; - Window root_win; - Window composite_manager; - gboolean real_transparency; - gboolean disable_transparency; - // current desktop - int desktop; - int screen; - int depth; - int num_desktops; - // number of monitor (without monitor included into another one) - int num_monitors; - // Non-null only if WM uses viewports (compiz) and number of viewports > 1. - // In that case there are num_desktops viewports. - Viewport *viewports; - Monitor *monitors; - gboolean got_root_win; - Visual *visual; - Visual *visual32; - // root background - Pixmap root_pmap; - GC gc; - Colormap colormap; - Colormap colormap32; - Global_atom atom; + Display *display; + Window root_win; + Window composite_manager; + gboolean real_transparency; + gboolean disable_transparency; + // current desktop + int desktop; + int screen; + int depth; + int num_desktops; + // number of monitor (without monitor included into another one) + int num_monitors; + // Non-null only if WM uses viewports (compiz) and number of viewports > 1. + // In that case there are num_desktops viewports. + Viewport *viewports; + Monitor *monitors; + gboolean got_root_win; + Visual *visual; + Visual *visual32; + // root background + Pixmap root_pmap; + GC gc; + Colormap colormap; + Colormap colormap32; + Global_atom atom; #ifdef HAVE_SN - SnDisplay *sn_display; - GTree *pids; + SnDisplay *sn_display; + GTree *pids; #endif // HAVE_SN } Server;
M src/systray/systraybar.csrc/systray/systraybar.c

@@ -73,287 +73,283 @@ void systray_dump_geometry(void *obj, int indent);

void default_systray() { - systray_enabled = 0; - memset(&systray, 0, sizeof(systray)); - render_background = 0; - chrono = 0; - systray.alpha = 100; - systray.sort = SYSTRAY_SORT_LEFT2RIGHT; - systray.area._draw_foreground = draw_systray; - systray.area._on_change_layout = on_change_systray; - systray.area.size_mode = LAYOUT_FIXED; - systray.area._resize = resize_systray; - systray_profile = getenv("SYSTRAY_PROFILING") != NULL; - systray_hide_name_filter = NULL; - systray_hide_name_regex = NULL; + systray_enabled = 0; + memset(&systray, 0, sizeof(systray)); + render_background = 0; + chrono = 0; + systray.alpha = 100; + systray.sort = SYSTRAY_SORT_LEFT2RIGHT; + systray.area._draw_foreground = draw_systray; + systray.area._on_change_layout = on_change_systray; + systray.area.size_mode = LAYOUT_FIXED; + systray.area._resize = resize_systray; + systray_profile = getenv("SYSTRAY_PROFILING") != NULL; + systray_hide_name_filter = NULL; + systray_hide_name_regex = NULL; } void cleanup_systray() { - stop_net(); - systray_enabled = 0; - systray_max_icon_size = 0; - systray_monitor = 0; - systray.area.on_screen = FALSE; - free_area(&systray.area); - if (render_background) { - XFreePixmap(server.display, render_background); - render_background = 0; - } - if (systray_hide_name_regex) { - regfree(systray_hide_name_regex); - free_and_null(systray_hide_name_regex); - } - if (systray_hide_name_filter) - free_and_null(systray_hide_name_filter); + stop_net(); + systray_enabled = 0; + systray_max_icon_size = 0; + systray_monitor = 0; + systray.area.on_screen = FALSE; + free_area(&systray.area); + if (render_background) { + XFreePixmap(server.display, render_background); + render_background = 0; + } + if (systray_hide_name_regex) { + regfree(systray_hide_name_regex); + free_and_null(systray_hide_name_regex); + } + if (systray_hide_name_filter) + free_and_null(systray_hide_name_filter); } void init_systray() { - if (!systray_enabled) - return; + if (!systray_enabled) + return; - systray_composited = !server.disable_transparency && server.visual32 && server.colormap32; - fprintf(stderr, "Systray composited rendering %s\n", systray_composited ? "on" : "off"); + systray_composited = !server.disable_transparency && server.visual32 && server.colormap32; + fprintf(stderr, "Systray composited rendering %s\n", systray_composited ? "on" : "off"); - if (!systray_composited) { - fprintf(stderr, "systray_asb forced to 100 0 0\n"); - systray.alpha = 100; - systray.brightness = systray.saturation = 0; - } + if (!systray_composited) { + fprintf(stderr, "systray_asb forced to 100 0 0\n"); + systray.alpha = 100; + systray.brightness = systray.saturation = 0; + } } void init_systray_panel(void *p) { - Panel *panel = (Panel *)p; - systray.area.parent = panel; - systray.area.panel = panel; - systray.area._dump_geometry = systray_dump_geometry; - systray.area._compute_desired_size = systray_compute_desired_size; - snprintf(systray.area.name, sizeof(systray.area.name), "Systray"); - if (!systray.area.bg) - systray.area.bg = &g_array_index(backgrounds, Background, 0); - show(&systray.area); - schedule_redraw(&systray.area); - refresh_systray = TRUE; - instantiate_area_gradients(&systray.area); + Panel *panel = (Panel *)p; + systray.area.parent = panel; + systray.area.panel = panel; + systray.area._dump_geometry = systray_dump_geometry; + systray.area._compute_desired_size = systray_compute_desired_size; + snprintf(systray.area.name, sizeof(systray.area.name), "Systray"); + if (!systray.area.bg) + systray.area.bg = &g_array_index(backgrounds, Background, 0); + show(&systray.area); + schedule_redraw(&systray.area); + refresh_systray = TRUE; + instantiate_area_gradients(&systray.area); } void systray_compute_geometry(int *size) { - systray.icon_size = panel_horizontal ? systray.area.height : systray.area.width; - systray.icon_size -= MAX(left_right_border_width(&systray.area), top_bottom_border_width(&systray.area)) + - 2 * systray.area.paddingy; - if (systray_max_icon_size > 0) - systray.icon_size = MIN(systray.icon_size, systray_max_icon_size); + systray.icon_size = panel_horizontal ? systray.area.height : systray.area.width; + systray.icon_size -= + MAX(left_right_border_width(&systray.area), top_bottom_border_width(&systray.area)) + 2 * systray.area.paddingy; + if (systray_max_icon_size > 0) + systray.icon_size = MIN(systray.icon_size, systray_max_icon_size); - int count = 0; - for (GSList *l = systray.list_icons; l; l = l->next) { - count++; - } + int count = 0; + for (GSList *l = systray.list_icons; l; l = l->next) { + count++; + } - if (panel_horizontal) { - int height = systray.area.height - top_bottom_border_width(&systray.area) - 2 * systray.area.paddingy; - // here icons_per_column always higher than 0 - systray.icons_per_column = (height + systray.area.paddingx) / (systray.icon_size + systray.area.paddingx); - systray.margin = - height - (systray.icons_per_column - 1) * (systray.icon_size + systray.area.paddingx) - systray.icon_size; - systray.icons_per_row = count / systray.icons_per_column + (count % systray.icons_per_column != 0); - *size = left_right_border_width(&systray.area) + 2 * systray.area.paddingxlr + - (systray.icon_size * systray.icons_per_row) + - ((systray.icons_per_row - 1) * systray.area.paddingx); - } else { - int width = systray.area.width - left_right_border_width(&systray.area) - 2 * systray.area.paddingy; - // here icons_per_row always higher than 0 - systray.icons_per_row = (width + systray.area.paddingx) / (systray.icon_size + systray.area.paddingx); - systray.margin = - width - (systray.icons_per_row - 1) * (systray.icon_size + systray.area.paddingx) - systray.icon_size; - systray.icons_per_column = count / systray.icons_per_row + (count % systray.icons_per_row != 0); - *size = top_bottom_border_width(&systray.area) + (2 * systray.area.paddingxlr) + - (systray.icon_size * systray.icons_per_column) + - ((systray.icons_per_column - 1) * systray.area.paddingx); - } + if (panel_horizontal) { + int height = systray.area.height - top_bottom_border_width(&systray.area) - 2 * systray.area.paddingy; + // here icons_per_column always higher than 0 + systray.icons_per_column = (height + systray.area.paddingx) / (systray.icon_size + systray.area.paddingx); + systray.margin = + height - (systray.icons_per_column - 1) * (systray.icon_size + systray.area.paddingx) - systray.icon_size; + systray.icons_per_row = count / systray.icons_per_column + (count % systray.icons_per_column != 0); + *size = left_right_border_width(&systray.area) + 2 * systray.area.paddingxlr + + (systray.icon_size * systray.icons_per_row) + ((systray.icons_per_row - 1) * systray.area.paddingx); + } else { + int width = systray.area.width - left_right_border_width(&systray.area) - 2 * systray.area.paddingy; + // here icons_per_row always higher than 0 + systray.icons_per_row = (width + systray.area.paddingx) / (systray.icon_size + systray.area.paddingx); + systray.margin = + width - (systray.icons_per_row - 1) * (systray.icon_size + systray.area.paddingx) - systray.icon_size; + systray.icons_per_column = count / systray.icons_per_row + (count % systray.icons_per_row != 0); + *size = top_bottom_border_width(&systray.area) + (2 * systray.area.paddingxlr) + + (systray.icon_size * systray.icons_per_column) + + ((systray.icons_per_column - 1) * systray.area.paddingx); + } } int systray_compute_desired_size(void *obj) { - int size; - systray_compute_geometry(&size); - return size; + int size; + systray_compute_geometry(&size); + return size; } gboolean resize_systray(void *obj) { - if (systray_profile) - fprintf(stderr, "[%f] %s:%d\n", profiling_get_time(), __FUNCTION__, __LINE__); + if (systray_profile) + fprintf(stderr, "[%f] %s:%d\n", profiling_get_time(), __FUNCTION__, __LINE__); - int size; - systray_compute_geometry(&size); + int size; + systray_compute_geometry(&size); - if (systray.icon_size > 0) { - long icon_size = systray.icon_size; - XChangeProperty(server.display, - net_sel_win, - server.atom._NET_SYSTEM_TRAY_ICON_SIZE, - XA_CARDINAL, - 32, - PropModeReplace, - (unsigned char *)&icon_size, - 1); - } + if (systray.icon_size > 0) { + long icon_size = systray.icon_size; + XChangeProperty(server.display, + net_sel_win, + server.atom._NET_SYSTEM_TRAY_ICON_SIZE, + XA_CARDINAL, + 32, + PropModeReplace, + (unsigned char *)&icon_size, + 1); + } - gboolean result = refresh_systray; - if (net_sel_win == None) { - start_net(); - result = TRUE; - } + gboolean result = refresh_systray; + if (net_sel_win == None) { + start_net(); + result = TRUE; + } - if (panel_horizontal) { - if (systray.area.width != size) { - systray.area.width = size; - result = TRUE; - } - } else { - if (systray.area.height != size) { - systray.area.height = size; - result = TRUE; - } - } + if (panel_horizontal) { + if (systray.area.width != size) { + systray.area.width = size; + result = TRUE; + } + } else { + if (systray.area.height != size) { + systray.area.height = size; + result = TRUE; + } + } - on_change_systray(&systray.area); + on_change_systray(&systray.area); - return result; + return result; } void draw_systray(void *obj, cairo_t *c) { - if (systray_profile) - fprintf(stderr, BLUE "[%f] %s:%d" RESET "\n", profiling_get_time(), __FUNCTION__, __LINE__); - if (systray_composited) { - if (render_background) - XFreePixmap(server.display, render_background); - render_background = - XCreatePixmap(server.display, server.root_win, systray.area.width, systray.area.height, server.depth); - XCopyArea(server.display, - systray.area.pix, - render_background, - server.gc, - 0, - 0, - systray.area.width, - systray.area.height, - 0, - 0); - } + if (systray_profile) + fprintf(stderr, BLUE "[%f] %s:%d" RESET "\n", profiling_get_time(), __FUNCTION__, __LINE__); + if (systray_composited) { + if (render_background) + XFreePixmap(server.display, render_background); + render_background = + XCreatePixmap(server.display, server.root_win, systray.area.width, systray.area.height, server.depth); + XCopyArea(server.display, + systray.area.pix, + render_background, + server.gc, + 0, + 0, + systray.area.width, + systray.area.height, + 0, + 0); + } - refresh_systray = TRUE; + refresh_systray = TRUE; } void systray_dump_geometry(void *obj, int indent) { - Systray *tray = (Systray *)obj; + Systray *tray = (Systray *)obj; - fprintf(stderr, - "%*sIcons:\n", - indent, - ""); - indent += 2; - for (GSList *l = tray->list_icons; l; l = l->next) { - TrayWindow *traywin = (TrayWindow *)l->data; - fprintf(stderr, - "%*sIcon: x = %d, y = %d, w = %d, h = %d, name = %s\n", - indent, - "", - traywin->x, - traywin->y, - traywin->width, - traywin->height, - traywin->name); - } + fprintf(stderr, "%*sIcons:\n", indent, ""); + indent += 2; + for (GSList *l = tray->list_icons; l; l = l->next) { + TrayWindow *traywin = (TrayWindow *)l->data; + fprintf(stderr, + "%*sIcon: x = %d, y = %d, w = %d, h = %d, name = %s\n", + indent, + "", + traywin->x, + traywin->y, + traywin->width, + traywin->height, + traywin->name); + } } void on_change_systray(void *obj) { - if (systray_profile) - fprintf(stderr, "[%f] %s:%d\n", profiling_get_time(), __FUNCTION__, __LINE__); - if (systray.icons_per_column == 0 || systray.icons_per_row == 0) - return; + if (systray_profile) + fprintf(stderr, "[%f] %s:%d\n", profiling_get_time(), __FUNCTION__, __LINE__); + if (systray.icons_per_column == 0 || systray.icons_per_row == 0) + return; - // systray.area.posx/posy are computed by rendering engine. - // Based on this we calculate the positions of the tray icons. - Panel *panel = systray.area.panel; - int posx, posy; - int start; - if (panel_horizontal) { - posy = start = top_border_width(&panel->area) + panel->area.paddingy + top_border_width(&systray.area) + - systray.area.paddingy + systray.margin / 2; - posx = systray.area.posx + left_border_width(&systray.area) + systray.area.paddingxlr; - } else { - posx = start = left_border_width(&panel->area) + panel->area.paddingy + left_border_width(&systray.area) + - systray.area.paddingy + systray.margin / 2; - posy = systray.area.posy + top_border_width(&systray.area) + systray.area.paddingxlr; - } + // systray.area.posx/posy are computed by rendering engine. + // Based on this we calculate the positions of the tray icons. + Panel *panel = systray.area.panel; + int posx, posy; + int start; + if (panel_horizontal) { + posy = start = top_border_width(&panel->area) + panel->area.paddingy + top_border_width(&systray.area) + + systray.area.paddingy + systray.margin / 2; + posx = systray.area.posx + left_border_width(&systray.area) + systray.area.paddingxlr; + } else { + posx = start = left_border_width(&panel->area) + panel->area.paddingy + left_border_width(&systray.area) + + systray.area.paddingy + systray.margin / 2; + posy = systray.area.posy + top_border_width(&systray.area) + systray.area.paddingxlr; + } - TrayWindow *traywin; - GSList *l; - int i; - for (i = 1, l = systray.list_icons; l; i++, l = l->next) { - traywin = (TrayWindow *)l->data; + TrayWindow *traywin; + GSList *l; + int i; + for (i = 1, l = systray.list_icons; l; i++, l = l->next) { + traywin = (TrayWindow *)l->data; - traywin->y = posy; - traywin->x = posx; - if (systray_profile) - fprintf(stderr, - "%s:%d win = %lu (%s), parent = %lu, x = %d, y = %d\n", - __FUNCTION__, - __LINE__, - traywin->win, - traywin->name, - traywin->parent, - posx, - posy); - traywin->width = systray.icon_size; - traywin->height = systray.icon_size; - if (panel_horizontal) { - if (i % systray.icons_per_column) { - posy += systray.icon_size + systray.area.paddingx; - } else { - posy = start; - posx += (systray.icon_size + systray.area.paddingx); - } - } else { - if (i % systray.icons_per_row) { - posx += systray.icon_size + systray.area.paddingx; - } else { - posx = start; - posy += (systray.icon_size + systray.area.paddingx); - } - } + traywin->y = posy; + traywin->x = posx; + if (systray_profile) + fprintf(stderr, + "%s:%d win = %lu (%s), parent = %lu, x = %d, y = %d\n", + __FUNCTION__, + __LINE__, + traywin->win, + traywin->name, + traywin->parent, + posx, + posy); + traywin->width = systray.icon_size; + traywin->height = systray.icon_size; + if (panel_horizontal) { + if (i % systray.icons_per_column) { + posy += systray.icon_size + systray.area.paddingx; + } else { + posy = start; + posx += (systray.icon_size + systray.area.paddingx); + } + } else { + if (i % systray.icons_per_row) { + posx += systray.icon_size + systray.area.paddingx; + } else { + posx = start; + posy += (systray.icon_size + systray.area.paddingx); + } + } - // position and size the icon window - unsigned int border_width; - int xpos, ypos; - unsigned int width, height, depth; - Window root; - if (!XGetGeometry(server.display, traywin->parent, &root, &xpos, &ypos, &width, &height, &border_width, &depth)) { - fprintf(stderr, RED "Couldn't get geometry of window!" RESET "\n"); - } - if (width != traywin->width || height != traywin->height || xpos != traywin->x || ypos != traywin->y) { - if (systray_profile) - fprintf(stderr, - "XMoveResizeWindow(server.display, traywin->parent = %ld, traywin->x = %d, traywin->y = %d, " - "traywin->width = %d, traywin->height = %d)\n", - traywin->parent, - traywin->x, - traywin->y, - traywin->width, - traywin->height); - XMoveResizeWindow(server.display, traywin->parent, traywin->x, traywin->y, traywin->width, traywin->height); - } - if (!traywin->reparented) - reparent_icon(traywin); - } - refresh_systray = TRUE; + // position and size the icon window + unsigned int border_width; + int xpos, ypos; + unsigned int width, height, depth; + Window root; + if (!XGetGeometry(server.display, traywin->parent, &root, &xpos, &ypos, &width, &height, &border_width, &depth)) { + fprintf(stderr, RED "Couldn't get geometry of window!" RESET "\n"); + } + if (width != traywin->width || height != traywin->height || xpos != traywin->x || ypos != traywin->y) { + if (systray_profile) + fprintf(stderr, + "XMoveResizeWindow(server.display, traywin->parent = %ld, traywin->x = %d, traywin->y = %d, " + "traywin->width = %d, traywin->height = %d)\n", + traywin->parent, + traywin->x, + traywin->y, + traywin->width, + traywin->height); + XMoveResizeWindow(server.display, traywin->parent, traywin->x, traywin->y, traywin->width, traywin->height); + } + if (!traywin->reparented) + reparent_icon(traywin); + } + refresh_systray = TRUE; } // ***********************************************

@@ -361,190 +357,190 @@ // systray protocol

void start_net() { - if (systray_profile) - fprintf(stderr, "[%f] %s:%d\n", profiling_get_time(), __FUNCTION__, __LINE__); - if (net_sel_win) { - // protocol already started - if (!systray_enabled) - stop_net(); - return; - } else { - if (!systray_enabled) - return; - } + if (systray_profile) + fprintf(stderr, "[%f] %s:%d\n", profiling_get_time(), __FUNCTION__, __LINE__); + if (net_sel_win) { + // protocol already started + if (!systray_enabled) + stop_net(); + return; + } else { + if (!systray_enabled) + return; + } - Window win = XGetSelectionOwner(server.display, server.atom._NET_SYSTEM_TRAY_SCREEN); + Window win = XGetSelectionOwner(server.display, server.atom._NET_SYSTEM_TRAY_SCREEN); - // freedesktop systray specification - if (win != None) { - // search pid - Atom _NET_WM_PID, actual_type; - int actual_format; - unsigned long nitems; - unsigned long bytes_after; - unsigned char *prop = 0; - int pid; + // freedesktop systray specification + if (win != None) { + // search pid + Atom _NET_WM_PID, actual_type; + int actual_format; + unsigned long nitems; + unsigned long bytes_after; + unsigned char *prop = 0; + int pid; - _NET_WM_PID = XInternAtom(server.display, "_NET_WM_PID", True); - int ret = XGetWindowProperty(server.display, - win, - _NET_WM_PID, - 0, - 1024, - False, - AnyPropertyType, - &actual_type, - &actual_format, - &nitems, - &bytes_after, - &prop); + _NET_WM_PID = XInternAtom(server.display, "_NET_WM_PID", True); + int ret = XGetWindowProperty(server.display, + win, + _NET_WM_PID, + 0, + 1024, + False, + AnyPropertyType, + &actual_type, + &actual_format, + &nitems, + &bytes_after, + &prop); - fprintf(stderr, RED "tint2 : another systray is running" RESET); - if (ret == Success && prop) { - pid = prop[1] * 256; - pid += prop[0]; - fprintf(stderr, " pid=%d", pid); - } - fprintf(stderr, RESET "\n"); - return; - } + fprintf(stderr, RED "tint2 : another systray is running" RESET); + if (ret == Success && prop) { + pid = prop[1] * 256; + pid += prop[0]; + fprintf(stderr, " pid=%d", pid); + } + fprintf(stderr, RESET "\n"); + return; + } - // init systray protocol - net_sel_win = XCreateSimpleWindow(server.display, server.root_win, -1, -1, 1, 1, 0, 0, 0); - fprintf(stderr, "systray window %ld\n", net_sel_win); + // init systray protocol + net_sel_win = XCreateSimpleWindow(server.display, server.root_win, -1, -1, 1, 1, 0, 0, 0); + fprintf(stderr, "systray window %ld\n", net_sel_win); - // v0.3 trayer specification. tint2 always horizontal. - // Vertical panel will draw the systray horizontal. - long orientation = 0; - XChangeProperty(server.display, - net_sel_win, - server.atom._NET_SYSTEM_TRAY_ORIENTATION, - XA_CARDINAL, - 32, - PropModeReplace, - (unsigned char *)&orientation, - 1); - if (systray.icon_size > 0) { - long icon_size = systray.icon_size; - XChangeProperty(server.display, - net_sel_win, - server.atom._NET_SYSTEM_TRAY_ICON_SIZE, - XA_CARDINAL, - 32, - PropModeReplace, - (unsigned char *)&icon_size, - 1); - } - long padding = 0; - XChangeProperty(server.display, - net_sel_win, - server.atom._NET_SYSTEM_TRAY_PADDING, - XA_CARDINAL, - 32, - PropModeReplace, - (unsigned char *)&padding, - 1); + // v0.3 trayer specification. tint2 always horizontal. + // Vertical panel will draw the systray horizontal. + long orientation = 0; + XChangeProperty(server.display, + net_sel_win, + server.atom._NET_SYSTEM_TRAY_ORIENTATION, + XA_CARDINAL, + 32, + PropModeReplace, + (unsigned char *)&orientation, + 1); + if (systray.icon_size > 0) { + long icon_size = systray.icon_size; + XChangeProperty(server.display, + net_sel_win, + server.atom._NET_SYSTEM_TRAY_ICON_SIZE, + XA_CARDINAL, + 32, + PropModeReplace, + (unsigned char *)&icon_size, + 1); + } + long padding = 0; + XChangeProperty(server.display, + net_sel_win, + server.atom._NET_SYSTEM_TRAY_PADDING, + XA_CARDINAL, + 32, + PropModeReplace, + (unsigned char *)&padding, + 1); - VisualID vid; - if (systray_composited) - vid = XVisualIDFromVisual(server.visual32); - else - vid = XVisualIDFromVisual(server.visual); - XChangeProperty(server.display, - net_sel_win, - XInternAtom(server.display, "_NET_SYSTEM_TRAY_VISUAL", False), - XA_VISUALID, - 32, - PropModeReplace, - (unsigned char *)&vid, - 1); + VisualID vid; + if (systray_composited) + vid = XVisualIDFromVisual(server.visual32); + else + vid = XVisualIDFromVisual(server.visual); + XChangeProperty(server.display, + net_sel_win, + XInternAtom(server.display, "_NET_SYSTEM_TRAY_VISUAL", False), + XA_VISUALID, + 32, + PropModeReplace, + (unsigned char *)&vid, + 1); - XSetSelectionOwner(server.display, server.atom._NET_SYSTEM_TRAY_SCREEN, net_sel_win, CurrentTime); - if (XGetSelectionOwner(server.display, server.atom._NET_SYSTEM_TRAY_SCREEN) != net_sel_win) { - stop_net(); - fprintf(stderr, RED "tint2 : can't get systray manager" RESET "\n"); - return; - } + XSetSelectionOwner(server.display, server.atom._NET_SYSTEM_TRAY_SCREEN, net_sel_win, CurrentTime); + if (XGetSelectionOwner(server.display, server.atom._NET_SYSTEM_TRAY_SCREEN) != net_sel_win) { + stop_net(); + fprintf(stderr, RED "tint2 : can't get systray manager" RESET "\n"); + return; + } - fprintf(stderr, GREEN "tint2 : systray started" RESET "\n"); - if (systray_profile) - fprintf(stderr, "[%f] %s:%d\n", profiling_get_time(), __FUNCTION__, __LINE__); - XClientMessageEvent ev; - ev.type = ClientMessage; - ev.window = server.root_win; - ev.message_type = server.atom.MANAGER; - ev.format = 32; - ev.data.l[0] = CurrentTime; - ev.data.l[1] = server.atom._NET_SYSTEM_TRAY_SCREEN; - ev.data.l[2] = net_sel_win; - ev.data.l[3] = 0; - ev.data.l[4] = 0; - XSendEvent(server.display, server.root_win, False, StructureNotifyMask, (XEvent *)&ev); + fprintf(stderr, GREEN "tint2 : systray started" RESET "\n"); + if (systray_profile) + fprintf(stderr, "[%f] %s:%d\n", profiling_get_time(), __FUNCTION__, __LINE__); + XClientMessageEvent ev; + ev.type = ClientMessage; + ev.window = server.root_win; + ev.message_type = server.atom.MANAGER; + ev.format = 32; + ev.data.l[0] = CurrentTime; + ev.data.l[1] = server.atom._NET_SYSTEM_TRAY_SCREEN; + ev.data.l[2] = net_sel_win; + ev.data.l[3] = 0; + ev.data.l[4] = 0; + XSendEvent(server.display, server.root_win, False, StructureNotifyMask, (XEvent *)&ev); } void net_message(XClientMessageEvent *e) { - if (systray_profile) - fprintf(stderr, "[%f] %s:%d\n", profiling_get_time(), __FUNCTION__, __LINE__); + if (systray_profile) + fprintf(stderr, "[%f] %s:%d\n", profiling_get_time(), __FUNCTION__, __LINE__); - Window win; - unsigned long opcode = e->data.l[1]; - switch (opcode) { - case SYSTEM_TRAY_REQUEST_DOCK: - win = e->data.l[2]; - if (win) - add_icon(win); - break; + Window win; + unsigned long opcode = e->data.l[1]; + switch (opcode) { + case SYSTEM_TRAY_REQUEST_DOCK: + win = e->data.l[2]; + if (win) + add_icon(win); + break; - case SYSTEM_TRAY_BEGIN_MESSAGE: - case SYSTEM_TRAY_CANCEL_MESSAGE: - // we don't show baloons messages. - break; + case SYSTEM_TRAY_BEGIN_MESSAGE: + case SYSTEM_TRAY_CANCEL_MESSAGE: + // we don't show baloons messages. + break; - default: - if (opcode == server.atom._NET_SYSTEM_TRAY_MESSAGE_DATA) - fprintf(stderr, "message from dockapp: %s\n", e->data.b); - else - fprintf(stderr, RED "SYSTEM_TRAY : unknown message type" RESET "\n"); - break; - } + default: + if (opcode == server.atom._NET_SYSTEM_TRAY_MESSAGE_DATA) + fprintf(stderr, "message from dockapp: %s\n", e->data.b); + else + fprintf(stderr, RED "SYSTEM_TRAY : unknown message type" RESET "\n"); + break; + } } void stop_net() { - if (systray_profile) - fprintf(stderr, "[%f] %s:%d\n", profiling_get_time(), __FUNCTION__, __LINE__); - if (systray.list_icons) { - // remove_icon change systray.list_icons - while (systray.list_icons) - remove_icon((TrayWindow *)systray.list_icons->data); + if (systray_profile) + fprintf(stderr, "[%f] %s:%d\n", profiling_get_time(), __FUNCTION__, __LINE__); + if (systray.list_icons) { + // remove_icon change systray.list_icons + while (systray.list_icons) + remove_icon((TrayWindow *)systray.list_icons->data); - g_slist_free(systray.list_icons); - systray.list_icons = NULL; - } + g_slist_free(systray.list_icons); + systray.list_icons = NULL; + } - if (net_sel_win != None) { - XDestroyWindow(server.display, net_sel_win); - net_sel_win = None; - } + if (net_sel_win != None) { + XDestroyWindow(server.display, net_sel_win); + net_sel_win = None; + } } gboolean error; int window_error_handler(Display *d, XErrorEvent *e) { - if (systray_profile) - fprintf(stderr, RED "[%f] %s:%d" RESET "\n", profiling_get_time(), __FUNCTION__, __LINE__); - error = TRUE; - if (e->error_code != BadWindow) { - fprintf(stderr, RED "systray: error code %d" RESET "\n", e->error_code); - } - return 0; + if (systray_profile) + fprintf(stderr, RED "[%f] %s:%d" RESET "\n", profiling_get_time(), __FUNCTION__, __LINE__); + error = TRUE; + if (e->error_code != BadWindow) { + fprintf(stderr, RED "systray: error code %d" RESET "\n", e->error_code); + } + return 0; } static gint compare_traywindows(gconstpointer a, gconstpointer b) { - const TrayWindow *traywin_a = (const TrayWindow *)a; - const TrayWindow *traywin_b = (const TrayWindow *)b; + const TrayWindow *traywin_a = (const TrayWindow *)a; + const TrayWindow *traywin_b = (const TrayWindow *)b; #if 0 // This breaks pygtk2 StatusIcon with blinking activated

@@ -554,1026 +550,1025 @@ if (!traywin_a->empty && traywin_b->empty)

return -1 * (systray.sort == SYSTRAY_SORT_RIGHT2LEFT ? -1 : 1); #endif - if (systray.sort == SYSTRAY_SORT_ASCENDING || systray.sort == SYSTRAY_SORT_DESCENDING) { - return g_ascii_strncasecmp(traywin_a->name, traywin_b->name, -1) * - (systray.sort == SYSTRAY_SORT_ASCENDING ? 1 : -1); - } + if (systray.sort == SYSTRAY_SORT_ASCENDING || systray.sort == SYSTRAY_SORT_DESCENDING) { + return g_ascii_strncasecmp(traywin_a->name, traywin_b->name, -1) * + (systray.sort == SYSTRAY_SORT_ASCENDING ? 1 : -1); + } - 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); - } + 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; + return 0; } void print_icons() { - fprintf(stderr, "systray.list_icons: \n"); - for (GSList *l = systray.list_icons; l; l = l->next) { - TrayWindow *t = l->data; - fprintf(stderr, "%s\n", t->name); - } - fprintf(stderr, "systray.list_icons order: \n"); - for (GSList *l = systray.list_icons; l; l = l->next) { - if (l->next) { - TrayWindow *t = l->data; - TrayWindow *u = l->next->data; - int cmp = compare_traywindows(t, u); - fprintf(stderr, "%s %s %s\n", t->name, cmp < 0 ? "<" : cmp == 0 ? "=" : ">", u->name); - } - } + fprintf(stderr, "systray.list_icons: \n"); + for (GSList *l = systray.list_icons; l; l = l->next) { + TrayWindow *t = l->data; + fprintf(stderr, "%s\n", t->name); + } + fprintf(stderr, "systray.list_icons order: \n"); + for (GSList *l = systray.list_icons; l; l = l->next) { + if (l->next) { + TrayWindow *t = l->data; + TrayWindow *u = l->next->data; + int cmp = compare_traywindows(t, u); + fprintf(stderr, "%s %s %s\n", t->name, cmp < 0 ? "<" : cmp == 0 ? "=" : ">", u->name); + } + } } gboolean reject_icon(Window win) { - if (systray_hide_name_filter && strlen(systray_hide_name_filter)) { - if (!systray_hide_name_regex) { - systray_hide_name_regex = (regex_t *) calloc(1, sizeof(*systray_hide_name_regex)); - if (regcomp(systray_hide_name_regex, systray_hide_name_filter, 0) != 0) { - fprintf(stderr, RED "Could not compile regex %s" RESET "\n", systray_hide_name_filter); - free_and_null(systray_hide_name_regex); - return FALSE; - } - } - char *name = get_window_name(win); - if (regexec(systray_hide_name_regex, name, 0, NULL, 0) == 0) { - fprintf(stderr, GREEN "Filtering out systray icon '%s'" RESET "\n", name); - return TRUE; - } - } - return FALSE; + if (systray_hide_name_filter && strlen(systray_hide_name_filter)) { + if (!systray_hide_name_regex) { + systray_hide_name_regex = (regex_t *)calloc(1, sizeof(*systray_hide_name_regex)); + if (regcomp(systray_hide_name_regex, systray_hide_name_filter, 0) != 0) { + fprintf(stderr, RED "Could not compile regex %s" RESET "\n", systray_hide_name_filter); + free_and_null(systray_hide_name_regex); + return FALSE; + } + } + char *name = get_window_name(win); + if (regexec(systray_hide_name_regex, name, 0, NULL, 0) == 0) { + fprintf(stderr, GREEN "Filtering out systray icon '%s'" RESET "\n", name); + return TRUE; + } + } + return FALSE; } gboolean add_icon(Window win) { - // Avoid duplicates - for (GSList *l = systray.list_icons; l; l = l->next) { - TrayWindow *other = (TrayWindow *)l->data; - if (other->win == win) { - return FALSE; - } - } + // Avoid duplicates + for (GSList *l = systray.list_icons; l; l = l->next) { + TrayWindow *other = (TrayWindow *)l->data; + if (other->win == win) { + return FALSE; + } + } - // Filter out systray_hide_by_icon_name - if (reject_icon(win)) - return FALSE; - - // Dangerous actions begin - XSync(server.display, False); - error = FALSE; - XErrorHandler old = XSetErrorHandler(window_error_handler); + // Filter out systray_hide_by_icon_name + if (reject_icon(win)) + return FALSE; - XSelectInput(server.display, win, StructureNotifyMask | PropertyChangeMask | ResizeRedirectMask); + // Dangerous actions begin + XSync(server.display, False); + error = FALSE; + XErrorHandler old = XSetErrorHandler(window_error_handler); - char *name = get_window_name(win); - if (systray_profile) - fprintf(stderr, "[%f] %s:%d win = %lu (%s)\n", profiling_get_time(), __FUNCTION__, __LINE__, win, name); - Panel *panel = systray.area.panel; + XSelectInput(server.display, win, StructureNotifyMask | PropertyChangeMask | ResizeRedirectMask); - // Get the process ID of the application that created the window - int pid = 0; - { - Atom actual_type; - int actual_format; - unsigned long nitems; - unsigned long bytes_after; - unsigned char *prop = 0; - int ret = XGetWindowProperty(server.display, - win, - 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]; - } - } + char *name = get_window_name(win); + if (systray_profile) + fprintf(stderr, "[%f] %s:%d win = %lu (%s)\n", profiling_get_time(), __FUNCTION__, __LINE__, win, name); + Panel *panel = systray.area.panel; - // Create the parent window that will embed the icon - XWindowAttributes attr; - if (systray_profile) - fprintf(stderr, "XGetWindowAttributes(server.display, win = %ld, &attr)\n", win); - if (XGetWindowAttributes(server.display, win, &attr) == False) { - free(name); - XSelectInput(server.display, win, NoEventMask); + // Get the process ID of the application that created the window + int pid = 0; + { + Atom actual_type; + int actual_format; + unsigned long nitems; + unsigned long bytes_after; + unsigned char *prop = 0; + int ret = XGetWindowProperty(server.display, + win, + 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]; + } + } - // Dangerous actions end - XSync(server.display, False); - XSetErrorHandler(old); + // Create the parent window that will embed the icon + XWindowAttributes attr; + if (systray_profile) + fprintf(stderr, "XGetWindowAttributes(server.display, win = %ld, &attr)\n", win); + if (XGetWindowAttributes(server.display, win, &attr) == False) { + free(name); + XSelectInput(server.display, win, NoEventMask); - return FALSE; - } + // Dangerous actions end + XSync(server.display, False); + XSetErrorHandler(old); - // Dangerous actions end - XSync(server.display, False); - XSetErrorHandler(old); + return FALSE; + } - unsigned long mask = 0; - XSetWindowAttributes set_attr; - Visual *visual = server.visual; - fprintf(stderr, - GREEN "add_icon: %lu (%s), pid %d, visual %p, colormap %lu, depth %d, width %d, height %d" RESET "\n", - win, - name, - pid, - attr.visual, - attr.colormap, - attr.depth, - attr.width, - attr.height); - if (server.disable_transparency) { - set_attr.background_pixmap = ParentRelative; - mask = CWBackPixmap; - if (systray_composited || attr.depth != server.depth) { - visual = attr.visual; - set_attr.colormap = attr.colormap; - mask |= CWColormap; - } - } else { - if (systray_composited || attr.depth != server.depth) { - visual = attr.visual; - set_attr.background_pixel = 0; - set_attr.border_pixel = 0; - set_attr.colormap = attr.colormap; - mask = CWColormap | CWBackPixel | CWBorderPixel; - } else { - set_attr.background_pixmap = ParentRelative; - mask = CWBackPixmap; - } - } + // Dangerous actions end + XSync(server.display, False); + XSetErrorHandler(old); - if (systray_profile) - fprintf(stderr, "XCreateWindow(...)\n"); - Window parent = XCreateWindow(server.display, - panel->main_win, - 0, - 0, - systray.icon_size, - systray.icon_size, - 0, - attr.depth, - InputOutput, - visual, - mask, - &set_attr); + unsigned long mask = 0; + XSetWindowAttributes set_attr; + Visual *visual = server.visual; + fprintf(stderr, + GREEN "add_icon: %lu (%s), pid %d, visual %p, colormap %lu, depth %d, width %d, height %d" RESET "\n", + win, + name, + pid, + attr.visual, + attr.colormap, + attr.depth, + attr.width, + attr.height); + if (server.disable_transparency) { + set_attr.background_pixmap = ParentRelative; + mask = CWBackPixmap; + if (systray_composited || attr.depth != server.depth) { + visual = attr.visual; + set_attr.colormap = attr.colormap; + mask |= CWColormap; + } + } else { + if (systray_composited || attr.depth != server.depth) { + visual = attr.visual; + set_attr.background_pixel = 0; + set_attr.border_pixel = 0; + set_attr.colormap = attr.colormap; + mask = CWColormap | CWBackPixel | CWBorderPixel; + } else { + set_attr.background_pixmap = ParentRelative; + mask = CWBackPixmap; + } + } - // Add the icon to the list - TrayWindow *traywin = g_new0(TrayWindow, 1); - traywin->parent = parent; - traywin->win = win; - traywin->depth = attr.depth; - // Reparenting is done at the first paint event when the window is positioned correctly over its empty background, - // to prevent graphical corruptions in icons with fake transparency - traywin->pid = pid; - traywin->name = name; - traywin->chrono = chrono; - chrono++; + if (systray_profile) + fprintf(stderr, "XCreateWindow(...)\n"); + Window parent = XCreateWindow(server.display, + panel->main_win, + 0, + 0, + systray.icon_size, + systray.icon_size, + 0, + attr.depth, + InputOutput, + visual, + mask, + &set_attr); + + // Add the icon to the list + TrayWindow *traywin = g_new0(TrayWindow, 1); + traywin->parent = parent; + traywin->win = win; + traywin->depth = attr.depth; + // Reparenting is done at the first paint event when the window is positioned correctly over its empty background, + // to prevent graphical corruptions in icons with fake transparency + traywin->pid = pid; + traywin->name = name; + traywin->chrono = chrono; + chrono++; - show(&systray.area); + show(&systray.area); - if (systray.sort == SYSTRAY_SORT_RIGHT2LEFT) - systray.list_icons = g_slist_prepend(systray.list_icons, traywin); - else - systray.list_icons = g_slist_append(systray.list_icons, traywin); - systray.list_icons = g_slist_sort(systray.list_icons, compare_traywindows); - // print_icons(); + if (systray.sort == SYSTRAY_SORT_RIGHT2LEFT) + systray.list_icons = g_slist_prepend(systray.list_icons, traywin); + else + systray.list_icons = g_slist_append(systray.list_icons, traywin); + systray.list_icons = g_slist_sort(systray.list_icons, compare_traywindows); + // print_icons(); - if (!panel->is_hidden) { - if (systray_profile) - fprintf(stderr, "XMapRaised(server.display, traywin->parent)\n"); - XMapRaised(server.display, traywin->parent); - } + if (!panel->is_hidden) { + if (systray_profile) + fprintf(stderr, "XMapRaised(server.display, traywin->parent)\n"); + XMapRaised(server.display, traywin->parent); + } - if (systray_profile) - fprintf(stderr, "[%f] %s:%d\n", profiling_get_time(), __FUNCTION__, __LINE__); + if (systray_profile) + fprintf(stderr, "[%f] %s:%d\n", profiling_get_time(), __FUNCTION__, __LINE__); - // Resize and redraw the systray - if (systray_profile) - fprintf(stderr, - BLUE "[%f] %s:%d trigger resize & redraw" RESET "\n", - profiling_get_time(), - __FUNCTION__, - __LINE__); - systray.area.resize_needed = TRUE; - panel->area.resize_needed = TRUE; - schedule_redraw(&systray.area); - refresh_systray = TRUE; - return TRUE; + // Resize and redraw the systray + if (systray_profile) + fprintf(stderr, + BLUE "[%f] %s:%d trigger resize & redraw" RESET "\n", + profiling_get_time(), + __FUNCTION__, + __LINE__); + systray.area.resize_needed = TRUE; + panel->area.resize_needed = TRUE; + schedule_redraw(&systray.area); + refresh_systray = TRUE; + return TRUE; } gboolean reparent_icon(TrayWindow *traywin) { - if (systray_profile) - fprintf(stderr, - "[%f] %s:%d win = %lu (%s)\n", - profiling_get_time(), - __FUNCTION__, - __LINE__, - traywin->win, - traywin->name); - if (traywin->reparented) - return TRUE; + if (systray_profile) + fprintf(stderr, + "[%f] %s:%d win = %lu (%s)\n", + profiling_get_time(), + __FUNCTION__, + __LINE__, + traywin->win, + traywin->name); + if (traywin->reparented) + return TRUE; - // Watch for the icon trying to resize itself / closing again - XSync(server.display, False); - error = FALSE; - XErrorHandler old = XSetErrorHandler(window_error_handler); - XWithdrawWindow(server.display, traywin->win, server.screen); - XReparentWindow(server.display, traywin->win, traywin->parent, 0, 0); + // Watch for the icon trying to resize itself / closing again + XSync(server.display, False); + error = FALSE; + XErrorHandler old = XSetErrorHandler(window_error_handler); + XWithdrawWindow(server.display, traywin->win, server.screen); + XReparentWindow(server.display, traywin->win, traywin->parent, 0, 0); - if (systray_profile) - fprintf(stderr, - "XMoveResizeWindow(server.display, traywin->win = %ld, 0, 0, traywin->width = %d, traywin->height = " - "%d)\n", - traywin->win, - traywin->width, - traywin->height); - XMoveResizeWindow(server.display, traywin->win, 0, 0, traywin->width, traywin->height); + if (systray_profile) + fprintf(stderr, + "XMoveResizeWindow(server.display, traywin->win = %ld, 0, 0, traywin->width = %d, traywin->height = " + "%d)\n", + traywin->win, + traywin->width, + traywin->height); + XMoveResizeWindow(server.display, traywin->win, 0, 0, traywin->width, traywin->height); - // Embed into parent - { - XEvent e; - e.xclient.type = ClientMessage; - e.xclient.serial = 0; - e.xclient.send_event = True; - e.xclient.message_type = server.atom._XEMBED; - e.xclient.window = traywin->win; - e.xclient.format = 32; - e.xclient.data.l[0] = CurrentTime; - e.xclient.data.l[1] = XEMBED_EMBEDDED_NOTIFY; - e.xclient.data.l[2] = 0; - e.xclient.data.l[3] = traywin->parent; - e.xclient.data.l[4] = 0; - if (systray_profile) - fprintf(stderr, "XSendEvent(server.display, traywin->win, False, NoEventMask, &e)\n"); - XSendEvent(server.display, traywin->win, False, NoEventMask, &e); - } + // Embed into parent + { + XEvent e; + e.xclient.type = ClientMessage; + e.xclient.serial = 0; + e.xclient.send_event = True; + e.xclient.message_type = server.atom._XEMBED; + e.xclient.window = traywin->win; + e.xclient.format = 32; + e.xclient.data.l[0] = CurrentTime; + e.xclient.data.l[1] = XEMBED_EMBEDDED_NOTIFY; + e.xclient.data.l[2] = 0; + e.xclient.data.l[3] = traywin->parent; + e.xclient.data.l[4] = 0; + if (systray_profile) + fprintf(stderr, "XSendEvent(server.display, traywin->win, False, NoEventMask, &e)\n"); + XSendEvent(server.display, traywin->win, False, NoEventMask, &e); + } - XSync(server.display, False); - XSetErrorHandler(old); - if (error != FALSE) { - fprintf(stderr, - RED "systray %d: cannot embed icon for window %lu (%s) parent %lu pid %d" RESET "\n", - __LINE__, - traywin->win, - traywin->name, - traywin->parent, - traywin->pid); - remove_icon(traywin); - return FALSE; - } + XSync(server.display, False); + XSetErrorHandler(old); + if (error != FALSE) { + fprintf(stderr, + RED "systray %d: cannot embed icon for window %lu (%s) parent %lu pid %d" RESET "\n", + __LINE__, + traywin->win, + traywin->name, + traywin->parent, + traywin->pid); + remove_icon(traywin); + return FALSE; + } - traywin->reparented = TRUE; + traywin->reparented = TRUE; - if (systray_profile) - fprintf(stderr, - "[%f] %s:%d win = %lu (%s)\n", - profiling_get_time(), - __FUNCTION__, - __LINE__, - traywin->win, - traywin->name); + if (systray_profile) + fprintf(stderr, + "[%f] %s:%d win = %lu (%s)\n", + profiling_get_time(), + __FUNCTION__, + __LINE__, + traywin->win, + traywin->name); - return TRUE; + return TRUE; } gboolean embed_icon(TrayWindow *traywin) { - if (systray_profile) - fprintf(stderr, - "[%f] %s:%d win = %lu (%s)\n", - profiling_get_time(), - __FUNCTION__, - __LINE__, - traywin->win, - traywin->name); - if (traywin->embedded) - return TRUE; + if (systray_profile) + fprintf(stderr, + "[%f] %s:%d win = %lu (%s)\n", + profiling_get_time(), + __FUNCTION__, + __LINE__, + traywin->win, + traywin->name); + if (traywin->embedded) + return TRUE; - Panel *panel = systray.area.panel; + Panel *panel = systray.area.panel; - XSync(server.display, False); - error = FALSE; - XErrorHandler old = XSetErrorHandler(window_error_handler); + XSync(server.display, False); + error = FALSE; + XErrorHandler old = XSetErrorHandler(window_error_handler); - if (0) { - Atom acttype; - int actfmt; - unsigned long nbitem, bytes; - unsigned long *data = 0; - int ret; + if (0) { + Atom acttype; + int actfmt; + unsigned long nbitem, bytes; + unsigned long *data = 0; + int ret; - if (systray_profile) - fprintf(stderr, - "XGetWindowProperty(server.display, traywin->win, server.atom._XEMBED_INFO, 0, 2, False, " - "server.atom._XEMBED_INFO, &acttype, &actfmt, &nbitem, &bytes, &data)\n"); - ret = XGetWindowProperty(server.display, - traywin->win, - server.atom._XEMBED_INFO, - 0, - 2, - False, - server.atom._XEMBED_INFO, - &acttype, - &actfmt, - &nbitem, - &bytes, - (unsigned char **)&data); - if (ret == Success) { - if (data) { - if (nbitem >= 2) { - int hide = ((data[1] & XEMBED_MAPPED) == 0); - if (hide) { - // In theory we have to check the embedding with this and remove icons that refuse embedding. - // In practice we have no idea when the other application processes the event and accepts the - // embed so we cannot check now without a race. - // Race can be triggered with PyGtk(2) apps. - // We could defer this for later (if we set PropertyChangeMask in XSelectInput we get notified) - // but for some reason it breaks transparency for Qt icons. So we don't. - // fprintf(stderr, RED "tint2: window refused embedding" RESET "\n"); - // remove_icon(traywin); - // XFree(data); - // return FALSE; - } - } - XFree(data); - } - } else { - fprintf(stderr, RED "tint2 : xembed error" RESET "\n"); - remove_icon(traywin); - return FALSE; - } - } + if (systray_profile) + fprintf(stderr, + "XGetWindowProperty(server.display, traywin->win, server.atom._XEMBED_INFO, 0, 2, False, " + "server.atom._XEMBED_INFO, &acttype, &actfmt, &nbitem, &bytes, &data)\n"); + ret = XGetWindowProperty(server.display, + traywin->win, + server.atom._XEMBED_INFO, + 0, + 2, + False, + server.atom._XEMBED_INFO, + &acttype, + &actfmt, + &nbitem, + &bytes, + (unsigned char **)&data); + if (ret == Success) { + if (data) { + if (nbitem >= 2) { + int hide = ((data[1] & XEMBED_MAPPED) == 0); + if (hide) { + // In theory we have to check the embedding with this and remove icons that refuse embedding. + // In practice we have no idea when the other application processes the event and accepts the + // embed so we cannot check now without a race. + // Race can be triggered with PyGtk(2) apps. + // We could defer this for later (if we set PropertyChangeMask in XSelectInput we get notified) + // but for some reason it breaks transparency for Qt icons. So we don't. + // fprintf(stderr, RED "tint2: window refused embedding" RESET "\n"); + // remove_icon(traywin); + // XFree(data); + // return FALSE; + } + } + XFree(data); + } + } else { + fprintf(stderr, RED "tint2 : xembed error" RESET "\n"); + remove_icon(traywin); + return FALSE; + } + } - // Redirect rendering when using compositing - if (systray_composited) { - if (systray_profile) - fprintf(stderr, "XDamageCreate(server.display, traywin->parent, XDamageReportRawRectangles)\n"); - traywin->damage = XDamageCreate(server.display, traywin->parent, XDamageReportRawRectangles); - if (systray_profile) - fprintf(stderr, "XCompositeRedirectWindow(server.display, traywin->parent, CompositeRedirectManual)\n"); - XCompositeRedirectWindow(server.display, traywin->parent, CompositeRedirectManual); - } + // Redirect rendering when using compositing + if (systray_composited) { + if (systray_profile) + fprintf(stderr, "XDamageCreate(server.display, traywin->parent, XDamageReportRawRectangles)\n"); + traywin->damage = XDamageCreate(server.display, traywin->parent, XDamageReportRawRectangles); + if (systray_profile) + fprintf(stderr, "XCompositeRedirectWindow(server.display, traywin->parent, CompositeRedirectManual)\n"); + XCompositeRedirectWindow(server.display, traywin->parent, CompositeRedirectManual); + } - XRaiseWindow(server.display, traywin->win); + XRaiseWindow(server.display, traywin->win); - // Make the icon visible - if (systray_profile) - fprintf(stderr, "XMapWindow(server.display, traywin->win)\n"); - XMapWindow(server.display, traywin->win); - if (!panel->is_hidden) { - if (systray_profile) - fprintf(stderr, "XMapRaised(server.display, traywin->parent)\n"); - XMapRaised(server.display, traywin->parent); - } + // Make the icon visible + if (systray_profile) + fprintf(stderr, "XMapWindow(server.display, traywin->win)\n"); + XMapWindow(server.display, traywin->win); + if (!panel->is_hidden) { + if (systray_profile) + fprintf(stderr, "XMapRaised(server.display, traywin->parent)\n"); + XMapRaised(server.display, traywin->parent); + } - if (systray_profile) - fprintf(stderr, "XSync(server.display, False)\n"); - XSync(server.display, False); - XSetErrorHandler(old); - if (error != FALSE) { - fprintf(stderr, - RED "systray %d: cannot embed icon for window %lu (%s) parent %lu pid %d" RESET "\n", - __LINE__, - traywin->win, - traywin->name, - traywin->parent, - traywin->pid); - remove_icon(traywin); - return FALSE; - } + if (systray_profile) + fprintf(stderr, "XSync(server.display, False)\n"); + XSync(server.display, False); + XSetErrorHandler(old); + if (error != FALSE) { + fprintf(stderr, + RED "systray %d: cannot embed icon for window %lu (%s) parent %lu pid %d" RESET "\n", + __LINE__, + traywin->win, + traywin->name, + traywin->parent, + traywin->pid); + remove_icon(traywin); + return FALSE; + } - traywin->embedded = TRUE; + traywin->embedded = TRUE; - if (systray_profile) - fprintf(stderr, - "[%f] %s:%d win = %lu (%s)\n", - profiling_get_time(), - __FUNCTION__, - __LINE__, - traywin->win, - traywin->name); + if (systray_profile) + fprintf(stderr, + "[%f] %s:%d win = %lu (%s)\n", + profiling_get_time(), + __FUNCTION__, + __LINE__, + traywin->win, + traywin->name); - return TRUE; + return TRUE; } void remove_icon(TrayWindow *traywin) { - if (systray_profile) - fprintf(stderr, - "[%f] %s:%d win = %lu (%s)\n", - profiling_get_time(), - __FUNCTION__, - __LINE__, - traywin->win, - traywin->name); - Panel *panel = systray.area.panel; + if (systray_profile) + fprintf(stderr, + "[%f] %s:%d win = %lu (%s)\n", + profiling_get_time(), + __FUNCTION__, + __LINE__, + traywin->win, + traywin->name); + Panel *panel = systray.area.panel; - // remove from our list - systray.list_icons = g_slist_remove(systray.list_icons, traywin); - fprintf(stderr, YELLOW "remove_icon: %lu (%s)" RESET "\n", traywin->win, traywin->name); + // remove from our list + systray.list_icons = g_slist_remove(systray.list_icons, traywin); + fprintf(stderr, YELLOW "remove_icon: %lu (%s)" RESET "\n", traywin->win, traywin->name); - XSelectInput(server.display, traywin->win, NoEventMask); - if (traywin->damage) - XDamageDestroy(server.display, traywin->damage); + XSelectInput(server.display, traywin->win, NoEventMask); + if (traywin->damage) + XDamageDestroy(server.display, traywin->damage); - // reparent to root - XSync(server.display, False); - error = FALSE; - XErrorHandler old = XSetErrorHandler(window_error_handler); - XUnmapWindow(server.display, traywin->win); - XReparentWindow(server.display, traywin->win, server.root_win, 0, 0); - XDestroyWindow(server.display, traywin->parent); - XSync(server.display, False); - XSetErrorHandler(old); - stop_timeout(traywin->render_timeout); - stop_timeout(traywin->resize_timeout); - free(traywin->name); - if (traywin->image) { - imlib_context_set_image(traywin->image); - imlib_free_image_and_decache(); - } - g_free(traywin); + // reparent to root + XSync(server.display, False); + error = FALSE; + XErrorHandler old = XSetErrorHandler(window_error_handler); + XUnmapWindow(server.display, traywin->win); + XReparentWindow(server.display, traywin->win, server.root_win, 0, 0); + XDestroyWindow(server.display, traywin->parent); + XSync(server.display, False); + XSetErrorHandler(old); + stop_timeout(traywin->render_timeout); + stop_timeout(traywin->resize_timeout); + free(traywin->name); + if (traywin->image) { + imlib_context_set_image(traywin->image); + imlib_free_image_and_decache(); + } + g_free(traywin); - // check empty systray - int count = 0; - GSList *l; - for (l = systray.list_icons; l; l = l->next) { - count++; - } - if (count == 0) - hide(&systray.area); + // check empty systray + int count = 0; + GSList *l; + for (l = systray.list_icons; l; l = l->next) { + count++; + } + if (count == 0) + hide(&systray.area); - // Resize and redraw the systray - if (systray_profile) - fprintf(stderr, - BLUE "[%f] %s:%d trigger resize & redraw" RESET "\n", - profiling_get_time(), - __FUNCTION__, - __LINE__); - systray.area.resize_needed = TRUE; - panel->area.resize_needed = TRUE; - schedule_redraw(&systray.area); - refresh_systray = TRUE; + // Resize and redraw the systray + if (systray_profile) + fprintf(stderr, + BLUE "[%f] %s:%d trigger resize & redraw" RESET "\n", + profiling_get_time(), + __FUNCTION__, + __LINE__); + systray.area.resize_needed = TRUE; + panel->area.resize_needed = TRUE; + schedule_redraw(&systray.area); + refresh_systray = TRUE; } void systray_resize_icon(void *t) { - TrayWindow *traywin = t; + TrayWindow *traywin = t; - unsigned int border_width; - int xpos, ypos; - unsigned int width, height, depth; - Window root; - if (!XGetGeometry(server.display, traywin->win, &root, &xpos, &ypos, &width, &height, &border_width, &depth)) { - return; - } else { - if (systray_profile) - fprintf(stderr, - "systray_resize_icon win = %ld, w = %d, h = %d\n", - traywin->win, - traywin->width, - traywin->height); - // This is the obvious thing to do but GTK tray icons do not respect the new size - if (0) { - XMoveResizeWindow(server.display, traywin->win, 0, 0, traywin->width, traywin->height); - } - // This is similar but GTK tray icons still do not respect the new size - if (0) { - XWindowChanges changes; - changes.x = changes.y = 0; - changes.width = traywin->width; - changes.height = traywin->height; - XConfigureWindow(server.display, traywin->win, CWX | CWY | CWWidth | CWHeight, &changes); - } - // This is what WMs send to windows to resize them, the new size must not be ignored. - // A bit brutal but works with GTK and everything else. - if (1) { - XConfigureEvent ev; - ev.type = ConfigureNotify; - ev.serial = 0; - ev.send_event = True; - ev.event = traywin->win; - ev.window = traywin->win; - ev.x = 0; - ev.y = 0; - ev.width = traywin->width; - ev.height = traywin->height; - ev.border_width = 0; - ev.above = None; - ev.override_redirect = False; - XSendEvent(server.display, traywin->win, False, StructureNotifyMask, (XEvent *)&ev); - } - XSync(server.display, False); - } + unsigned int border_width; + int xpos, ypos; + unsigned int width, height, depth; + Window root; + if (!XGetGeometry(server.display, traywin->win, &root, &xpos, &ypos, &width, &height, &border_width, &depth)) { + return; + } else { + if (systray_profile) + fprintf(stderr, + "systray_resize_icon win = %ld, w = %d, h = %d\n", + traywin->win, + traywin->width, + traywin->height); + // This is the obvious thing to do but GTK tray icons do not respect the new size + if (0) { + XMoveResizeWindow(server.display, traywin->win, 0, 0, traywin->width, traywin->height); + } + // This is similar but GTK tray icons still do not respect the new size + if (0) { + XWindowChanges changes; + changes.x = changes.y = 0; + changes.width = traywin->width; + changes.height = traywin->height; + XConfigureWindow(server.display, traywin->win, CWX | CWY | CWWidth | CWHeight, &changes); + } + // This is what WMs send to windows to resize them, the new size must not be ignored. + // A bit brutal but works with GTK and everything else. + if (1) { + XConfigureEvent ev; + ev.type = ConfigureNotify; + ev.serial = 0; + ev.send_event = True; + ev.event = traywin->win; + ev.window = traywin->win; + ev.x = 0; + ev.y = 0; + ev.width = traywin->width; + ev.height = traywin->height; + ev.border_width = 0; + ev.above = None; + ev.override_redirect = False; + XSendEvent(server.display, traywin->win, False, StructureNotifyMask, (XEvent *)&ev); + } + XSync(server.display, False); + } } void systray_reconfigure_event(TrayWindow *traywin, XEvent *e) { - if (systray_profile) - fprintf(stderr, - "XConfigure event: win = %lu (%s), x = %d, y = %d, w = %d, h = %d\n", - traywin->win, - traywin->name, - e->xconfigure.x, - e->xconfigure.y, - e->xconfigure.width, - e->xconfigure.height); + if (systray_profile) + fprintf(stderr, + "XConfigure event: win = %lu (%s), x = %d, y = %d, w = %d, h = %d\n", + traywin->win, + traywin->name, + e->xconfigure.x, + e->xconfigure.y, + e->xconfigure.width, + e->xconfigure.height); - if (!traywin->reparented) - return; + if (!traywin->reparented) + return; - if (e->xconfigure.width != traywin->width || e->xconfigure.height != traywin->height || e->xconfigure.x != 0 || - e->xconfigure.y != 0) { - if (traywin->bad_size_counter < max_bad_resize_events) { - struct timespec now; - clock_gettime(CLOCK_MONOTONIC, &now); - struct timespec earliest_resize = add_msec_to_timespec(traywin->time_last_resize, resize_period_threshold); - if (compare_timespecs(&earliest_resize, &now) > 0) { - // Fast resize, but below the threshold - traywin->bad_size_counter++; - } else { - // Slow resize, reset counter - traywin->time_last_resize.tv_sec = now.tv_sec; - traywin->time_last_resize.tv_nsec = now.tv_nsec; - traywin->bad_size_counter = 0; - } - if (traywin->bad_size_counter < min_bad_resize_events) { - systray_resize_icon(traywin); - } else { - if (!traywin->resize_timeout) - traywin->resize_timeout = - add_timeout(fast_resize_period, 0, systray_resize_icon, traywin, &traywin->resize_timeout); - } - } else { - if (traywin->bad_size_counter == max_bad_resize_events) { - traywin->bad_size_counter++; - fprintf(stderr, - RED "Detected resize loop for tray icon %lu (%s), throttling resize events" RESET "\n", - traywin->win, - traywin->name); - } - // Delayed resize - // FIXME Normally we should force the icon to resize fill_color to the size we resized it to when we - // embedded it. - // However this triggers a resize loop in new versions of GTK, which we must avoid. - if (!traywin->resize_timeout) - traywin->resize_timeout = - add_timeout(slow_resize_period, 0, systray_resize_icon, traywin, &traywin->resize_timeout); - return; - } - } else { - // Correct size - stop_timeout(traywin->resize_timeout); - } + if (e->xconfigure.width != traywin->width || e->xconfigure.height != traywin->height || e->xconfigure.x != 0 || + e->xconfigure.y != 0) { + if (traywin->bad_size_counter < max_bad_resize_events) { + struct timespec now; + clock_gettime(CLOCK_MONOTONIC, &now); + struct timespec earliest_resize = add_msec_to_timespec(traywin->time_last_resize, resize_period_threshold); + if (compare_timespecs(&earliest_resize, &now) > 0) { + // Fast resize, but below the threshold + traywin->bad_size_counter++; + } else { + // Slow resize, reset counter + traywin->time_last_resize.tv_sec = now.tv_sec; + traywin->time_last_resize.tv_nsec = now.tv_nsec; + traywin->bad_size_counter = 0; + } + if (traywin->bad_size_counter < min_bad_resize_events) { + systray_resize_icon(traywin); + } else { + if (!traywin->resize_timeout) + traywin->resize_timeout = + add_timeout(fast_resize_period, 0, systray_resize_icon, traywin, &traywin->resize_timeout); + } + } else { + if (traywin->bad_size_counter == max_bad_resize_events) { + traywin->bad_size_counter++; + fprintf(stderr, + RED "Detected resize loop for tray icon %lu (%s), throttling resize events" RESET "\n", + traywin->win, + traywin->name); + } + // Delayed resize + // FIXME Normally we should force the icon to resize fill_color to the size we resized it to when we + // embedded it. + // However this triggers a resize loop in new versions of GTK, which we must avoid. + if (!traywin->resize_timeout) + traywin->resize_timeout = + add_timeout(slow_resize_period, 0, systray_resize_icon, traywin, &traywin->resize_timeout); + return; + } + } else { + // Correct size + stop_timeout(traywin->resize_timeout); + } - // Resize and redraw the systray - if (systray_profile) - fprintf(stderr, - BLUE "[%f] %s:%d trigger resize & redraw" RESET "\n", - profiling_get_time(), - __FUNCTION__, - __LINE__); - schedule_panel_redraw(); - refresh_systray = TRUE; + // Resize and redraw the systray + if (systray_profile) + fprintf(stderr, + BLUE "[%f] %s:%d trigger resize & redraw" RESET "\n", + profiling_get_time(), + __FUNCTION__, + __LINE__); + schedule_panel_redraw(); + refresh_systray = TRUE; } void systray_property_notify(TrayWindow *traywin, XEvent *e) { - Atom at = e->xproperty.atom; - if (at == server.atom.WM_NAME) { - free(traywin->name); - traywin->name = get_window_name(traywin->win); - if (systray.sort == SYSTRAY_SORT_ASCENDING || systray.sort == SYSTRAY_SORT_DESCENDING) { - systray.list_icons = g_slist_sort(systray.list_icons, compare_traywindows); - // print_icons(); - } - } + Atom at = e->xproperty.atom; + if (at == server.atom.WM_NAME) { + free(traywin->name); + traywin->name = get_window_name(traywin->win); + if (systray.sort == SYSTRAY_SORT_ASCENDING || systray.sort == SYSTRAY_SORT_DESCENDING) { + systray.list_icons = g_slist_sort(systray.list_icons, compare_traywindows); + // print_icons(); + } + } } void systray_resize_request_event(TrayWindow *traywin, XEvent *e) { - if (systray_profile) - fprintf(stderr, - "XResizeRequest event: win = %lu (%s), w = %d, h = %d\n", - traywin->win, - traywin->name, - e->xresizerequest.width, - e->xresizerequest.height); + if (systray_profile) + fprintf(stderr, + "XResizeRequest event: win = %lu (%s), w = %d, h = %d\n", + traywin->win, + traywin->name, + e->xresizerequest.width, + e->xresizerequest.height); - if (!traywin->reparented) - return; + if (!traywin->reparented) + return; - if (e->xresizerequest.width != traywin->width || e->xresizerequest.height != traywin->height) { - if (traywin->bad_size_counter < max_bad_resize_events) { - struct timespec now; - clock_gettime(CLOCK_MONOTONIC, &now); - struct timespec earliest_resize = add_msec_to_timespec(traywin->time_last_resize, resize_period_threshold); - if (compare_timespecs(&earliest_resize, &now) > 0) { - // Fast resize, but below the threshold - traywin->bad_size_counter++; - } else { - // Slow resize, reset counter - traywin->time_last_resize.tv_sec = now.tv_sec; - traywin->time_last_resize.tv_nsec = now.tv_nsec; - traywin->bad_size_counter = 0; - } - if (traywin->bad_size_counter < min_bad_resize_events) { - systray_resize_icon(traywin); - } else { - if (!traywin->resize_timeout) - traywin->resize_timeout = - add_timeout(fast_resize_period, 0, systray_resize_icon, traywin, &traywin->resize_timeout); - } - } else { - if (traywin->bad_size_counter == max_bad_resize_events) { - traywin->bad_size_counter++; - fprintf(stderr, - RED "Detected resize loop for tray icon %lu (%s), throttling resize events" RESET "\n", - traywin->win, - traywin->name); - } - // Delayed resize - // FIXME Normally we should force the icon to resize to the size we resized it to when we embedded it. - // However this triggers a resize loop in some versions of GTK, which we must avoid. - if (!traywin->resize_timeout) - traywin->resize_timeout = - add_timeout(slow_resize_period, 0, systray_resize_icon, traywin, &traywin->resize_timeout); - return; - } - } else { - // Correct size - stop_timeout(traywin->resize_timeout); - } + if (e->xresizerequest.width != traywin->width || e->xresizerequest.height != traywin->height) { + if (traywin->bad_size_counter < max_bad_resize_events) { + struct timespec now; + clock_gettime(CLOCK_MONOTONIC, &now); + struct timespec earliest_resize = add_msec_to_timespec(traywin->time_last_resize, resize_period_threshold); + if (compare_timespecs(&earliest_resize, &now) > 0) { + // Fast resize, but below the threshold + traywin->bad_size_counter++; + } else { + // Slow resize, reset counter + traywin->time_last_resize.tv_sec = now.tv_sec; + traywin->time_last_resize.tv_nsec = now.tv_nsec; + traywin->bad_size_counter = 0; + } + if (traywin->bad_size_counter < min_bad_resize_events) { + systray_resize_icon(traywin); + } else { + if (!traywin->resize_timeout) + traywin->resize_timeout = + add_timeout(fast_resize_period, 0, systray_resize_icon, traywin, &traywin->resize_timeout); + } + } else { + if (traywin->bad_size_counter == max_bad_resize_events) { + traywin->bad_size_counter++; + fprintf(stderr, + RED "Detected resize loop for tray icon %lu (%s), throttling resize events" RESET "\n", + traywin->win, + traywin->name); + } + // Delayed resize + // FIXME Normally we should force the icon to resize to the size we resized it to when we embedded it. + // However this triggers a resize loop in some versions of GTK, which we must avoid. + if (!traywin->resize_timeout) + traywin->resize_timeout = + add_timeout(slow_resize_period, 0, systray_resize_icon, traywin, &traywin->resize_timeout); + return; + } + } else { + // Correct size + stop_timeout(traywin->resize_timeout); + } - // Resize and redraw the systray - if (systray_profile) - fprintf(stderr, - BLUE "[%f] %s:%d trigger resize & redraw" RESET "\n", - profiling_get_time(), - __FUNCTION__, - __LINE__); - schedule_panel_redraw(); - refresh_systray = TRUE; + // Resize and redraw the systray + if (systray_profile) + fprintf(stderr, + BLUE "[%f] %s:%d trigger resize & redraw" RESET "\n", + profiling_get_time(), + __FUNCTION__, + __LINE__); + schedule_panel_redraw(); + refresh_systray = TRUE; } void systray_destroy_event(TrayWindow *traywin) { - if (systray_profile) - fprintf(stderr, - "[%f] %s:%d win = %lu (%s)\n", - profiling_get_time(), - __FUNCTION__, - __LINE__, - traywin->win, - traywin->name); - remove_icon(traywin); + if (systray_profile) + fprintf(stderr, + "[%f] %s:%d win = %lu (%s)\n", + profiling_get_time(), + __FUNCTION__, + __LINE__, + traywin->win, + traywin->name); + remove_icon(traywin); } void systray_render_icon_from_image(TrayWindow *traywin) { - if (!traywin->image) - return; - imlib_context_set_image(traywin->image); - XCopyArea(server.display, - render_background, - systray.area.pix, - server.gc, - traywin->x - systray.area.posx, - traywin->y - systray.area.posy, - traywin->width, - traywin->height, - traywin->x - systray.area.posx, - traywin->y - systray.area.posy); - render_image(systray.area.pix, traywin->x - systray.area.posx, traywin->y - systray.area.posy); + if (!traywin->image) + return; + imlib_context_set_image(traywin->image); + XCopyArea(server.display, + render_background, + systray.area.pix, + server.gc, + traywin->x - systray.area.posx, + traywin->y - systray.area.posy, + traywin->width, + traywin->height, + traywin->x - systray.area.posx, + traywin->y - systray.area.posy); + render_image(systray.area.pix, traywin->x - systray.area.posx, traywin->y - systray.area.posy); } void systray_render_icon_composited(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; + // 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; - if (systray_profile) - fprintf(stderr, - "[%f] %s:%d win = %lu (%s)\n", - profiling_get_time(), - __FUNCTION__, - __LINE__, - traywin->win, - traywin->name); + if (systray_profile) + fprintf(stderr, + "[%f] %s:%d win = %lu (%s)\n", + profiling_get_time(), + __FUNCTION__, + __LINE__, + traywin->win, + traywin->name); - // wine tray icons update whenever mouse is over them, so we limit the updates to 50 ms - struct timespec now; - clock_gettime(CLOCK_MONOTONIC, &now); - struct timespec earliest_render = add_msec_to_timespec(traywin->time_last_render, min_refresh_period); - if (compare_timespecs(&earliest_render, &now) > 0) { - traywin->num_fast_renders++; - if (traywin->num_fast_renders > max_fast_refreshes) { - traywin->render_timeout = - add_timeout(min_refresh_period, 0, systray_render_icon_composited, traywin, &traywin->render_timeout); - if (systray_profile) - fprintf(stderr, - YELLOW "[%f] %s:%d win = %lu (%s) delaying rendering" RESET "\n", - profiling_get_time(), - __FUNCTION__, - __LINE__, - traywin->win, - traywin->name); - return; - } - } else { - traywin->time_last_render.tv_sec = now.tv_sec; - traywin->time_last_render.tv_nsec = now.tv_nsec; - traywin->num_fast_renders = 0; - } + // wine tray icons update whenever mouse is over them, so we limit the updates to 50 ms + struct timespec now; + clock_gettime(CLOCK_MONOTONIC, &now); + struct timespec earliest_render = add_msec_to_timespec(traywin->time_last_render, min_refresh_period); + if (compare_timespecs(&earliest_render, &now) > 0) { + traywin->num_fast_renders++; + if (traywin->num_fast_renders > max_fast_refreshes) { + traywin->render_timeout = + add_timeout(min_refresh_period, 0, systray_render_icon_composited, traywin, &traywin->render_timeout); + if (systray_profile) + fprintf(stderr, + YELLOW "[%f] %s:%d win = %lu (%s) delaying rendering" RESET "\n", + profiling_get_time(), + __FUNCTION__, + __LINE__, + traywin->win, + traywin->name); + return; + } + } else { + traywin->time_last_render.tv_sec = now.tv_sec; + traywin->time_last_render.tv_nsec = now.tv_nsec; + traywin->num_fast_renders = 0; + } - if (traywin->width == 0 || traywin->height == 0) { - // reschedule rendering since the geometry information has not yet been processed (can happen on slow cpu) - traywin->render_timeout = - add_timeout(min_refresh_period, 0, systray_render_icon_composited, traywin, &traywin->render_timeout); - if (systray_profile) - fprintf(stderr, - YELLOW "[%f] %s:%d win = %lu (%s) delaying rendering" RESET "\n", - profiling_get_time(), - __FUNCTION__, - __LINE__, - traywin->win, - traywin->name); - return; - } + if (traywin->width == 0 || traywin->height == 0) { + // reschedule rendering since the geometry information has not yet been processed (can happen on slow cpu) + traywin->render_timeout = + add_timeout(min_refresh_period, 0, systray_render_icon_composited, traywin, &traywin->render_timeout); + if (systray_profile) + fprintf(stderr, + YELLOW "[%f] %s:%d win = %lu (%s) delaying rendering" RESET "\n", + profiling_get_time(), + __FUNCTION__, + __LINE__, + traywin->win, + traywin->name); + return; + } - if (traywin->render_timeout) { - stop_timeout(traywin->render_timeout); - traywin->render_timeout = NULL; - } + if (traywin->render_timeout) { + stop_timeout(traywin->render_timeout); + traywin->render_timeout = NULL; + } - // 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 + // 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 - // Very ugly hack, but somehow imlib2 is not able to get the image from the traywindow itself, - // so we first render the tray window onto a pixmap, and then we tell imlib2 to use this pixmap as - // drawable. If someone knows why it does not work with the traywindow itself, please tell me ;) - Pixmap tmp_pmap = XCreatePixmap(server.display, traywin->win, traywin->width, traywin->height, 32); - if (!tmp_pmap) { - goto on_systray_error; - } - XRenderPictFormat *f; - if (traywin->depth == 24) { - f = XRenderFindStandardFormat(server.display, PictStandardRGB24); - } else if (traywin->depth == 32) { - f = XRenderFindStandardFormat(server.display, PictStandardARGB32); - } else { - fprintf(stderr, RED "Strange tray icon found with depth: %d" RESET "\n", traywin->depth); - XFreePixmap(server.display, tmp_pmap); - return; - } - XRenderPictFormat *f32 = XRenderFindVisualFormat(server.display, server.visual32); - if (!f || !f32) { - XFreePixmap(server.display, tmp_pmap); - goto on_systray_error; - } + // Very ugly hack, but somehow imlib2 is not able to get the image from the traywindow itself, + // so we first render the tray window onto a pixmap, and then we tell imlib2 to use this pixmap as + // drawable. If someone knows why it does not work with the traywindow itself, please tell me ;) + Pixmap tmp_pmap = XCreatePixmap(server.display, traywin->win, traywin->width, traywin->height, 32); + if (!tmp_pmap) { + goto on_systray_error; + } + XRenderPictFormat *f; + if (traywin->depth == 24) { + f = XRenderFindStandardFormat(server.display, PictStandardRGB24); + } else if (traywin->depth == 32) { + f = XRenderFindStandardFormat(server.display, PictStandardARGB32); + } else { + fprintf(stderr, RED "Strange tray icon found with depth: %d" RESET "\n", traywin->depth); + XFreePixmap(server.display, tmp_pmap); + return; + } + XRenderPictFormat *f32 = XRenderFindVisualFormat(server.display, server.visual32); + if (!f || !f32) { + XFreePixmap(server.display, tmp_pmap); + goto on_systray_error; + } - XSync(server.display, False); - error = FALSE; - XErrorHandler old = XSetErrorHandler(window_error_handler); + XSync(server.display, False); + error = FALSE; + XErrorHandler old = XSetErrorHandler(window_error_handler); - // if (server.real_transparency) - // Picture pict_image = XRenderCreatePicture(server.display, traywin->parent, f, 0, 0); - // reverted Rev 407 because here it's breaking alls icon with systray + xcompmgr - Picture pict_image = XRenderCreatePicture(server.display, traywin->win, f, 0, 0); - if (!pict_image) { - XFreePixmap(server.display, tmp_pmap); - XSetErrorHandler(old); - goto on_error; - } - Picture pict_drawable = - XRenderCreatePicture(server.display, tmp_pmap, XRenderFindVisualFormat(server.display, server.visual32), 0, 0); - if (!pict_drawable) { - XRenderFreePicture(server.display, pict_image); - XFreePixmap(server.display, tmp_pmap); - XSetErrorHandler(old); - goto on_error; - } - XRenderComposite(server.display, - PictOpSrc, - pict_image, - None, - pict_drawable, - 0, - 0, - 0, - 0, - 0, - 0, - traywin->width, - traywin->height); - XRenderFreePicture(server.display, pict_image); - XRenderFreePicture(server.display, pict_drawable); - // end of the ugly hack and we can continue as before + // if (server.real_transparency) + // Picture pict_image = XRenderCreatePicture(server.display, traywin->parent, f, 0, 0); + // reverted Rev 407 because here it's breaking alls icon with systray + xcompmgr + Picture pict_image = XRenderCreatePicture(server.display, traywin->win, f, 0, 0); + if (!pict_image) { + XFreePixmap(server.display, tmp_pmap); + XSetErrorHandler(old); + goto on_error; + } + Picture pict_drawable = + XRenderCreatePicture(server.display, tmp_pmap, XRenderFindVisualFormat(server.display, server.visual32), 0, 0); + if (!pict_drawable) { + XRenderFreePicture(server.display, pict_image); + XFreePixmap(server.display, tmp_pmap); + XSetErrorHandler(old); + goto on_error; + } + XRenderComposite(server.display, + PictOpSrc, + pict_image, + None, + pict_drawable, + 0, + 0, + 0, + 0, + 0, + 0, + traywin->width, + traywin->height); + XRenderFreePicture(server.display, pict_image); + XRenderFreePicture(server.display, pict_drawable); + // end of the ugly hack and we can continue as before - imlib_context_set_visual(server.visual32); - imlib_context_set_colormap(server.colormap32); - imlib_context_set_drawable(tmp_pmap); - Imlib_Image image = imlib_create_image_from_drawable(0, 0, 0, traywin->width, traywin->height, 1); - imlib_context_set_visual(server.visual); - imlib_context_set_colormap(server.colormap); - XFreePixmap(server.display, tmp_pmap); - if (!image) { - imlib_context_set_visual(server.visual); - imlib_context_set_colormap(server.colormap); - XSetErrorHandler(old); - goto on_error; - } else { - if (traywin->image) { - imlib_context_set_image(traywin->image); - imlib_free_image_and_decache(); - } - traywin->image = image; - } + imlib_context_set_visual(server.visual32); + imlib_context_set_colormap(server.colormap32); + imlib_context_set_drawable(tmp_pmap); + Imlib_Image image = imlib_create_image_from_drawable(0, 0, 0, traywin->width, traywin->height, 1); + imlib_context_set_visual(server.visual); + imlib_context_set_colormap(server.colormap); + XFreePixmap(server.display, tmp_pmap); + if (!image) { + imlib_context_set_visual(server.visual); + imlib_context_set_colormap(server.colormap); + XSetErrorHandler(old); + goto on_error; + } else { + if (traywin->image) { + imlib_context_set_image(traywin->image); + imlib_free_image_and_decache(); + } + traywin->image = image; + } - imlib_context_set_image(traywin->image); - // if (traywin->depth == 24) - // imlib_save_image("/home/thil77/test.jpg"); - imlib_image_set_has_alpha(1); - DATA32 *data = imlib_image_get_data(); - if (traywin->depth == 24) { - create_heuristic_mask(data, traywin->width, traywin->height); - } + imlib_context_set_image(traywin->image); + // if (traywin->depth == 24) + // imlib_save_image("/home/thil77/test.jpg"); + imlib_image_set_has_alpha(1); + DATA32 *data = imlib_image_get_data(); + if (traywin->depth == 24) { + create_heuristic_mask(data, traywin->width, traywin->height); + } - if (systray.alpha != 100 || systray.brightness != 0 || systray.saturation != 0) - adjust_asb(data, - traywin->width, - traywin->height, - systray.alpha / 100.0, - systray.saturation / 100.0, - systray.brightness / 100.0); - imlib_image_put_back_data(data); + if (systray.alpha != 100 || systray.brightness != 0 || systray.saturation != 0) + adjust_asb(data, + traywin->width, + traywin->height, + systray.alpha / 100.0, + systray.saturation / 100.0, + systray.brightness / 100.0); + imlib_image_put_back_data(data); - systray_render_icon_from_image(traywin); + systray_render_icon_from_image(traywin); - if (traywin->damage) - XDamageSubtract(server.display, traywin->damage, None, None); - XSync(server.display, False); - XSetErrorHandler(old); + if (traywin->damage) + XDamageSubtract(server.display, traywin->damage, None, None); + XSync(server.display, False); + XSetErrorHandler(old); - if (error) - goto on_error; + if (error) + goto on_error; - schedule_panel_redraw(); + schedule_panel_redraw(); - if (systray_profile) - fprintf(stderr, - "[%f] %s:%d win = %lu (%s)\n", - profiling_get_time(), - __FUNCTION__, - __LINE__, - traywin->win, - traywin->name); + if (systray_profile) + fprintf(stderr, + "[%f] %s:%d win = %lu (%s)\n", + profiling_get_time(), + __FUNCTION__, + __LINE__, + traywin->win, + traywin->name); - return; + return; on_error: - fprintf(stderr, - RED "systray %d: rendering error for icon %lu (%s) pid %d" RESET "\n", - __LINE__, - traywin->win, - traywin->name, - traywin->pid); - return; + fprintf(stderr, + RED "systray %d: rendering error for icon %lu (%s) pid %d" RESET "\n", + __LINE__, + traywin->win, + traywin->name, + traywin->pid); + return; on_systray_error: - fprintf(stderr, - RED "systray %d: rendering error for icon %lu (%s) pid %d. " - "Disabling compositing and restarting systray..." RESET "\n", - __LINE__, - traywin->win, - traywin->name, - traywin->pid); - systray_composited = 0; - stop_net(); - start_net(); - return; + fprintf(stderr, + RED "systray %d: rendering error for icon %lu (%s) pid %d. " + "Disabling compositing and restarting systray..." RESET "\n", + __LINE__, + traywin->win, + traywin->name, + traywin->pid); + systray_composited = 0; + stop_net(); + start_net(); + return; } void systray_render_icon(void *t) { - TrayWindow *traywin = t; - if (!traywin->reparented || !traywin->embedded) { -// if (systray_profile) -// fprintf(stderr, -// YELLOW "[%f] %s:%d win = %lu (%s) delaying rendering" RESET "\n", -// profiling_get_time(), -// __FUNCTION__, -// __LINE__, -// traywin->win, -// traywin->name); - stop_timeout(traywin->render_timeout); - traywin->render_timeout = - add_timeout(min_refresh_period, 0, systray_render_icon, traywin, &traywin->render_timeout); - return; - } - - if (systray_profile) - fprintf(stderr, - "[%f] %s:%d win = %lu (%s)\n", - profiling_get_time(), - __FUNCTION__, - __LINE__, - traywin->win, - traywin->name); + TrayWindow *traywin = t; + if (!traywin->reparented || !traywin->embedded) { + // if (systray_profile) + // fprintf(stderr, + // YELLOW "[%f] %s:%d win = %lu (%s) delaying rendering" RESET "\n", + // profiling_get_time(), + // __FUNCTION__, + // __LINE__, + // traywin->win, + // traywin->name); + stop_timeout(traywin->render_timeout); + traywin->render_timeout = + add_timeout(min_refresh_period, 0, systray_render_icon, traywin, &traywin->render_timeout); + return; + } + if (systray_profile) + fprintf(stderr, + "[%f] %s:%d win = %lu (%s)\n", + profiling_get_time(), + __FUNCTION__, + __LINE__, + traywin->win, + traywin->name); - if (systray_composited) { - XSync(server.display, False); - error = FALSE; - XErrorHandler old = XSetErrorHandler(window_error_handler); + if (systray_composited) { + XSync(server.display, False); + error = FALSE; + XErrorHandler old = XSetErrorHandler(window_error_handler); - unsigned int border_width; - int xpos, ypos; - unsigned int width, height, depth; - Window root; - if (!XGetGeometry(server.display, traywin->win, &root, &xpos, &ypos, &width, &height, &border_width, &depth)) { - stop_timeout(traywin->render_timeout); - if (!traywin->resize_timeout) - traywin->render_timeout = - add_timeout(min_refresh_period, 0, systray_render_icon, traywin, &traywin->render_timeout); - systray_render_icon_from_image(traywin); - XSetErrorHandler(old); - return; - } else { - if (xpos != 0 || ypos != 0 || width != traywin->width || height != traywin->height) { - stop_timeout(traywin->render_timeout); - if (!traywin->resize_timeout) - traywin->render_timeout = - add_timeout(min_refresh_period, 0, systray_render_icon, traywin, &traywin->render_timeout); - systray_render_icon_from_image(traywin); - if (systray_profile) - fprintf(stderr, - YELLOW "[%f] %s:%d win = %lu (%s) delaying rendering" RESET "\n", - profiling_get_time(), - __FUNCTION__, - __LINE__, - traywin->win, - traywin->name); - XSetErrorHandler(old); - return; - } - } - XSetErrorHandler(old); - } + unsigned int border_width; + int xpos, ypos; + unsigned int width, height, depth; + Window root; + if (!XGetGeometry(server.display, traywin->win, &root, &xpos, &ypos, &width, &height, &border_width, &depth)) { + stop_timeout(traywin->render_timeout); + if (!traywin->resize_timeout) + traywin->render_timeout = + add_timeout(min_refresh_period, 0, systray_render_icon, traywin, &traywin->render_timeout); + systray_render_icon_from_image(traywin); + XSetErrorHandler(old); + return; + } else { + if (xpos != 0 || ypos != 0 || width != traywin->width || height != traywin->height) { + stop_timeout(traywin->render_timeout); + if (!traywin->resize_timeout) + traywin->render_timeout = + add_timeout(min_refresh_period, 0, systray_render_icon, traywin, &traywin->render_timeout); + systray_render_icon_from_image(traywin); + if (systray_profile) + fprintf(stderr, + YELLOW "[%f] %s:%d win = %lu (%s) delaying rendering" RESET "\n", + profiling_get_time(), + __FUNCTION__, + __LINE__, + traywin->win, + traywin->name); + XSetErrorHandler(old); + return; + } + } + XSetErrorHandler(old); + } - if (systray_profile) - fprintf(stderr, "rendering tray icon\n"); + if (systray_profile) + fprintf(stderr, "rendering tray icon\n"); - if (systray_composited) { - systray_render_icon_composited(traywin); - } else { - // Trigger window repaint - if (systray_profile) - fprintf(stderr, - "XClearArea(server.display, traywin->parent = %ld, 0, 0, traywin->width, traywin->height, True)\n", - traywin->parent); - XClearArea(server.display, traywin->parent, 0, 0, 0, 0, True); - if (systray_profile) - fprintf(stderr, - "XClearArea(server.display, traywin->win = %ld, 0, 0, traywin->width, traywin->height, True)\n", - traywin->win); - XClearArea(server.display, traywin->win, 0, 0, 0, 0, True); - } + if (systray_composited) { + systray_render_icon_composited(traywin); + } else { + // Trigger window repaint + if (systray_profile) + fprintf(stderr, + "XClearArea(server.display, traywin->parent = %ld, 0, 0, traywin->width, traywin->height, True)\n", + traywin->parent); + XClearArea(server.display, traywin->parent, 0, 0, 0, 0, True); + if (systray_profile) + fprintf(stderr, + "XClearArea(server.display, traywin->win = %ld, 0, 0, traywin->width, traywin->height, True)\n", + traywin->win); + XClearArea(server.display, traywin->win, 0, 0, 0, 0, True); + } } void refresh_systray_icons() { - if (systray_profile) - fprintf(stderr, BLUE "[%f] %s:%d" RESET "\n", profiling_get_time(), __FUNCTION__, __LINE__); - TrayWindow *traywin; - GSList *l; - for (l = systray.list_icons; l; l = l->next) { - traywin = (TrayWindow *)l->data; - systray_render_icon(traywin); - } + if (systray_profile) + fprintf(stderr, BLUE "[%f] %s:%d" RESET "\n", profiling_get_time(), __FUNCTION__, __LINE__); + TrayWindow *traywin; + GSList *l; + for (l = systray.list_icons; l; l = l->next) { + traywin = (TrayWindow *)l->data; + systray_render_icon(traywin); + } } gboolean systray_on_monitor(int i_monitor, int n_panels) { - return (i_monitor == systray_monitor) || (i_monitor == 0 && (systray_monitor >= n_panels || systray_monitor < 0)); + return (i_monitor == systray_monitor) || (i_monitor == 0 && (systray_monitor >= n_panels || systray_monitor < 0)); } TrayWindow *systray_find_icon(Window win) { - for (GSList *l = systray.list_icons; l; l = l->next) { - TrayWindow *traywin = (TrayWindow *)l->data; - if (traywin->win == win || traywin->parent == win) - return traywin; - } - return NULL; + for (GSList *l = systray.list_icons; l; l = l->next) { + TrayWindow *traywin = (TrayWindow *)l->data; + if (traywin->win == win || traywin->parent == win) + return traywin; + } + return NULL; }
M src/systray/systraybar.hsrc/systray/systraybar.h

@@ -21,50 +21,50 @@ // Flags for _XEMBED_INFO

#define XEMBED_MAPPED (1 << 0) typedef enum SystraySortMethod { - SYSTRAY_SORT_ASCENDING = 0, - SYSTRAY_SORT_DESCENDING, - SYSTRAY_SORT_LEFT2RIGHT, - SYSTRAY_SORT_RIGHT2LEFT, + SYSTRAY_SORT_ASCENDING = 0, + SYSTRAY_SORT_DESCENDING, + SYSTRAY_SORT_LEFT2RIGHT, + SYSTRAY_SORT_RIGHT2LEFT, } SystraySortMethod; typedef struct { - // always start with area - Area area; + // always start with area + Area area; - GSList *list_icons; - SystraySortMethod sort; - int alpha, saturation, brightness; - int icon_size, icons_per_column, icons_per_row, margin; + GSList *list_icons; + SystraySortMethod sort; + int alpha, saturation, brightness; + int icon_size, icons_per_column, icons_per_row, margin; } Systray; typedef struct { - // The actual tray icon window (created by the application) - Window win; - // The parent window created by tint2 to embed the icon - Window parent; - int x, y; - int width, height; - int depth; - gboolean reparented; - gboolean embedded; - // Process PID or zero. - int pid; - // A number that is incremented for each new icon, used to sort them by the order in which they were created. - int chrono; - // Name of the tray icon window. - char *name; - // Members used for rendering - struct timespec time_last_render; - int num_fast_renders; - timeout *render_timeout; - // Members used for resizing - int bad_size_counter; - struct timespec time_last_resize; - timeout *resize_timeout; - // Icon contents if we are compositing the icon, otherwise null - Imlib_Image image; - // XDamage - Damage damage; + // The actual tray icon window (created by the application) + Window win; + // The parent window created by tint2 to embed the icon + Window parent; + int x, y; + int width, height; + int depth; + gboolean reparented; + gboolean embedded; + // Process PID or zero. + int pid; + // A number that is incremented for each new icon, used to sort them by the order in which they were created. + int chrono; + // Name of the tray icon window. + char *name; + // Members used for rendering + struct timespec time_last_render; + int num_fast_renders; + timeout *render_timeout; + // Members used for resizing + int bad_size_counter; + struct timespec time_last_resize; + timeout *resize_timeout; + // Icon contents if we are compositing the icon, otherwise null + Imlib_Image image; + // XDamage + Damage damage; } TrayWindow; // net_sel_win != None when protocol started
M src/taskbar/task.csrc/taskbar/task.c

@@ -43,674 +43,672 @@ int task_compute_desired_size(void *obj);

char *task_get_tooltip(void *obj) { - Task *t = (Task *)obj; - return strdup(t->title); + Task *t = (Task *)obj; + return strdup(t->title); } Task *add_task(Window win) { - if (!win) - return NULL; - if (window_is_hidden(win)) - return NULL; + if (!win) + return NULL; + if (window_is_hidden(win)) + return NULL; - XSelectInput(server.display, win, PropertyChangeMask | StructureNotifyMask); - XFlush(server.display); + XSelectInput(server.display, win, PropertyChangeMask | StructureNotifyMask); + XFlush(server.display); - int monitor = 0; - if (num_panels > 1) { - monitor = get_window_monitor(win); - if (monitor >= num_panels) - monitor = 0; - } + int monitor = 0; + if (num_panels > 1) { + monitor = get_window_monitor(win); + if (monitor >= num_panels) + monitor = 0; + } - // TODO why do we add the task only to the panel for the current monitor, without checking hide_task_diff_monitor? + // TODO why do we add the task only to the panel for the current monitor, without checking hide_task_diff_monitor? - Task task_template; - memset(&task_template, 0, sizeof(task_template)); - snprintf(task_template.area.name, sizeof(task_template.area.name), "Task %d", (int)win); - task_template.area.has_mouse_over_effect = panel_config.mouse_effects; - task_template.area.has_mouse_press_effect = panel_config.mouse_effects; - task_template.area._dump_geometry = task_dump_geometry; - task_template.area._is_under_mouse = full_width_area_is_under_mouse; - task_template.win = win; - task_template.desktop = get_window_desktop(win); - task_template.area.panel = &panels[monitor]; - task_template.current_state = window_is_iconified(win) ? TASK_ICONIFIED : TASK_NORMAL; - get_window_coordinates(win, &task_template.win_x, &task_template.win_y, &task_template.win_w, &task_template.win_h); + Task task_template; + memset(&task_template, 0, sizeof(task_template)); + snprintf(task_template.area.name, sizeof(task_template.area.name), "Task %d", (int)win); + task_template.area.has_mouse_over_effect = panel_config.mouse_effects; + task_template.area.has_mouse_press_effect = panel_config.mouse_effects; + task_template.area._dump_geometry = task_dump_geometry; + task_template.area._is_under_mouse = full_width_area_is_under_mouse; + task_template.win = win; + task_template.desktop = get_window_desktop(win); + task_template.area.panel = &panels[monitor]; + task_template.current_state = window_is_iconified(win) ? TASK_ICONIFIED : TASK_NORMAL; + get_window_coordinates(win, &task_template.win_x, &task_template.win_y, &task_template.win_w, &task_template.win_h); - // allocate only one title and one icon - // even with task_on_all_desktop and with task_on_all_panel - task_template.title = NULL; - for (int k = 0; k < TASK_STATE_COUNT; ++k) { - task_template.icon[k] = NULL; - } - task_update_title(&task_template); - task_update_icon(&task_template); - snprintf(task_template.area.name, - sizeof(task_template.area.name), - "Task %d %s", - (int)win, - task_template.title ? task_template.title : "null"); + // allocate only one title and one icon + // even with task_on_all_desktop and with task_on_all_panel + task_template.title = NULL; + for (int k = 0; k < TASK_STATE_COUNT; ++k) { + task_template.icon[k] = NULL; + } + task_update_title(&task_template); + task_update_icon(&task_template); + snprintf(task_template.area.name, + sizeof(task_template.area.name), + "Task %d %s", + (int)win, + task_template.title ? task_template.title : "null"); - // fprintf(stderr, "%s %d: win = %ld, task = %s\n", __FUNCTION__, __LINE__, win, task_template.title ? - // task_template.title : "??"); - // fprintf(stderr, "new task %s win %u: desktop %d, monitor %d\n", new_task.title, win, new_task.desktop, monitor); + // fprintf(stderr, "%s %d: win = %ld, task = %s\n", __FUNCTION__, __LINE__, win, task_template.title ? + // task_template.title : "??"); + // fprintf(stderr, "new task %s win %u: desktop %d, monitor %d\n", new_task.title, win, new_task.desktop, monitor); - GPtrArray *task_buttons = g_ptr_array_new(); - for (int j = 0; j < panels[monitor].num_desktops; j++) { - if (task_template.desktop != ALL_DESKTOPS && task_template.desktop != j) - continue; + GPtrArray *task_buttons = g_ptr_array_new(); + for (int j = 0; j < panels[monitor].num_desktops; j++) { + if (task_template.desktop != ALL_DESKTOPS && task_template.desktop != j) + continue; - Taskbar *taskbar = &panels[monitor].taskbar[j]; - Task *task_instance = calloc(1, sizeof(Task)); - memcpy(&task_instance->area, &panels[monitor].g_task.area, sizeof(Area)); - task_instance->area.has_mouse_over_effect = panel_config.mouse_effects; - task_instance->area.has_mouse_press_effect = panel_config.mouse_effects; - task_instance->area._dump_geometry = task_dump_geometry; - task_instance->area._is_under_mouse = full_width_area_is_under_mouse; - task_instance->area._compute_desired_size = task_compute_desired_size; - task_instance->win = task_template.win; - task_instance->desktop = task_template.desktop; - task_instance->win_x = task_template.win_x; - task_instance->win_y = task_template.win_y; - task_instance->win_w = task_template.win_w; - task_instance->win_h = task_template.win_h; - task_instance->current_state = TASK_UNDEFINED; // to update the current state later in set_task_state... - if (task_instance->desktop == ALL_DESKTOPS && server.desktop != j) { - // fprintf(stderr, "%s %d: win = %ld hiding task: another desktop\n", __FUNCTION__, __LINE__, win); - task_instance->area.on_screen = always_show_all_desktop_tasks; - } - task_instance->title = task_template.title; - if (panels[monitor].g_task.tooltip_enabled) - task_instance->area._get_tooltip_text = task_get_tooltip; - for (int k = 0; k < TASK_STATE_COUNT; ++k) { - task_instance->icon[k] = task_template.icon[k]; - task_instance->icon_hover[k] = task_template.icon_hover[k]; - task_instance->icon_press[k] = task_template.icon_press[k]; - } - task_instance->icon_width = task_template.icon_width; - task_instance->icon_height = task_template.icon_height; + Taskbar *taskbar = &panels[monitor].taskbar[j]; + Task *task_instance = calloc(1, sizeof(Task)); + memcpy(&task_instance->area, &panels[monitor].g_task.area, sizeof(Area)); + task_instance->area.has_mouse_over_effect = panel_config.mouse_effects; + task_instance->area.has_mouse_press_effect = panel_config.mouse_effects; + task_instance->area._dump_geometry = task_dump_geometry; + task_instance->area._is_under_mouse = full_width_area_is_under_mouse; + task_instance->area._compute_desired_size = task_compute_desired_size; + task_instance->win = task_template.win; + task_instance->desktop = task_template.desktop; + task_instance->win_x = task_template.win_x; + task_instance->win_y = task_template.win_y; + task_instance->win_w = task_template.win_w; + task_instance->win_h = task_template.win_h; + task_instance->current_state = TASK_UNDEFINED; // to update the current state later in set_task_state... + if (task_instance->desktop == ALL_DESKTOPS && server.desktop != j) { + // fprintf(stderr, "%s %d: win = %ld hiding task: another desktop\n", __FUNCTION__, __LINE__, win); + task_instance->area.on_screen = always_show_all_desktop_tasks; + } + task_instance->title = task_template.title; + if (panels[monitor].g_task.tooltip_enabled) + task_instance->area._get_tooltip_text = task_get_tooltip; + for (int k = 0; k < TASK_STATE_COUNT; ++k) { + task_instance->icon[k] = task_template.icon[k]; + task_instance->icon_hover[k] = task_template.icon_hover[k]; + task_instance->icon_press[k] = task_template.icon_press[k]; + } + task_instance->icon_width = task_template.icon_width; + task_instance->icon_height = task_template.icon_height; - add_area(&task_instance->area, &taskbar->area); - g_ptr_array_add(task_buttons, task_instance); - } - Window *key = calloc(1, sizeof(Window)); - *key = task_template.win; - g_hash_table_insert(win_to_task, key, task_buttons); + add_area(&task_instance->area, &taskbar->area); + g_ptr_array_add(task_buttons, task_instance); + } + Window *key = calloc(1, sizeof(Window)); + *key = task_template.win; + g_hash_table_insert(win_to_task, key, task_buttons); - set_task_state((Task *)g_ptr_array_index(task_buttons, 0), task_template.current_state); + set_task_state((Task *)g_ptr_array_index(task_buttons, 0), task_template.current_state); - sort_taskbar_for_win(win); + sort_taskbar_for_win(win); - if (taskbar_mode == MULTI_DESKTOP) { - Panel *panel = (Panel *)task_template.area.panel; - panel->area.resize_needed = TRUE; - } + if (taskbar_mode == MULTI_DESKTOP) { + Panel *panel = (Panel *)task_template.area.panel; + panel->area.resize_needed = TRUE; + } - if (window_is_urgent(win)) { - add_urgent((Task *)g_ptr_array_index(task_buttons, 0)); - } + if (window_is_urgent(win)) { + add_urgent((Task *)g_ptr_array_index(task_buttons, 0)); + } - if (hide_taskbar_if_empty) - update_all_taskbars_visibility(); + if (hide_taskbar_if_empty) + update_all_taskbars_visibility(); - return (Task *)g_ptr_array_index(task_buttons, 0); + return (Task *)g_ptr_array_index(task_buttons, 0); } void remove_task(Task *task) { - if (!task) - return; + if (!task) + return; - // fprintf(stderr, "%s %d: win = %ld, task = %s\n", __FUNCTION__, __LINE__, task->win, task->title ? task->title : - // "??"); + // fprintf(stderr, "%s %d: win = %ld, task = %s\n", __FUNCTION__, __LINE__, task->win, task->title ? task->title : + // "??"); - if (taskbar_mode == MULTI_DESKTOP) { - Panel *panel = task->area.panel; - panel->area.resize_needed = 1; - } + if (taskbar_mode == MULTI_DESKTOP) { + Panel *panel = task->area.panel; + panel->area.resize_needed = 1; + } - Window win = task->win; + Window win = task->win; - // free title and icon just for the first task - // even with task_on_all_desktop and with task_on_all_panel - // printf("remove_task %s %d\n", task->title, task->desktop); - if (task->title) - free(task->title); - for (int k = 0; k < TASK_STATE_COUNT; ++k) { - if (task->icon[k]) { - imlib_context_set_image(task->icon[k]); - imlib_free_image(); - task->icon[k] = 0; - } - if (task->icon_hover[k]) { - imlib_context_set_image(task->icon_hover[k]); - imlib_free_image(); - task->icon_hover[k] = 0; - } - if (task->icon_press[k]) { - imlib_context_set_image(task->icon_press[k]); - imlib_free_image(); - task->icon_press[k] = 0; - } - } + // free title and icon just for the first task + // even with task_on_all_desktop and with task_on_all_panel + // printf("remove_task %s %d\n", task->title, task->desktop); + if (task->title) + free(task->title); + for (int k = 0; k < TASK_STATE_COUNT; ++k) { + if (task->icon[k]) { + imlib_context_set_image(task->icon[k]); + imlib_free_image(); + task->icon[k] = 0; + } + if (task->icon_hover[k]) { + imlib_context_set_image(task->icon_hover[k]); + imlib_free_image(); + task->icon_hover[k] = 0; + } + if (task->icon_press[k]) { + imlib_context_set_image(task->icon_press[k]); + imlib_free_image(); + task->icon_press[k] = 0; + } + } - GPtrArray *task_buttons = g_hash_table_lookup(win_to_task, &win); - for (int i = 0; i < task_buttons->len; ++i) { - Task *task2 = g_ptr_array_index(task_buttons, i); - if (task2 == active_task) - active_task = 0; - if (task2 == task_drag) - task_drag = 0; - if (g_slist_find(urgent_list, task2)) - del_urgent(task2); - remove_area((Area *)task2); - free(task2); - } - g_hash_table_remove(win_to_task, &win); - if (hide_taskbar_if_empty) - update_all_taskbars_visibility(); + GPtrArray *task_buttons = g_hash_table_lookup(win_to_task, &win); + for (int i = 0; i < task_buttons->len; ++i) { + Task *task2 = g_ptr_array_index(task_buttons, i); + if (task2 == active_task) + active_task = 0; + if (task2 == task_drag) + task_drag = 0; + if (g_slist_find(urgent_list, task2)) + del_urgent(task2); + remove_area((Area *)task2); + free(task2); + } + g_hash_table_remove(win_to_task, &win); + if (hide_taskbar_if_empty) + update_all_taskbars_visibility(); } gboolean task_update_title(Task *task) { - Panel *panel = task->area.panel; + Panel *panel = task->area.panel; - if (!panel->g_task.has_text && !panel->g_task.tooltip_enabled && taskbar_sort_method != TASKBAR_SORT_TITLE) - return FALSE; + if (!panel->g_task.has_text && !panel->g_task.tooltip_enabled && taskbar_sort_method != TASKBAR_SORT_TITLE) + return FALSE; - char *name = server_get_property(task->win, server.atom._NET_WM_VISIBLE_NAME, server.atom.UTF8_STRING, 0); - if (!name || !strlen(name)) { - name = server_get_property(task->win, server.atom._NET_WM_NAME, server.atom.UTF8_STRING, 0); - if (!name || !strlen(name)) { - name = server_get_property(task->win, server.atom.WM_NAME, XA_STRING, 0); - } - } + char *name = server_get_property(task->win, server.atom._NET_WM_VISIBLE_NAME, server.atom.UTF8_STRING, 0); + if (!name || !strlen(name)) { + name = server_get_property(task->win, server.atom._NET_WM_NAME, server.atom.UTF8_STRING, 0); + if (!name || !strlen(name)) { + name = server_get_property(task->win, server.atom.WM_NAME, XA_STRING, 0); + } + } - char *title; - if (name && strlen(name)) { - title = strdup(name); - } else { - title = strdup("Untitled"); - } - if (name) - XFree(name); + char *title; + if (name && strlen(name)) { + title = strdup(name); + } else { + title = strdup("Untitled"); + } + if (name) + XFree(name); - if (task->title) { - // check unecessary title change - if (strcmp(task->title, title) == 0) { - free(title); - return FALSE; - } else { - free(task->title); - } - } + if (task->title) { + // check unecessary title change + if (strcmp(task->title, title) == 0) { + free(title); + return FALSE; + } else { + free(task->title); + } + } - task->title = title; - GPtrArray *task_buttons = get_task_buttons(task->win); - if (task_buttons) { - for (int i = 0; i < task_buttons->len; ++i) { - Task *task2 = g_ptr_array_index(task_buttons, i); - task2->title = task->title; - schedule_redraw(&task2->area); - } - } - return TRUE; + task->title = title; + GPtrArray *task_buttons = get_task_buttons(task->win); + if (task_buttons) { + for (int i = 0; i < task_buttons->len; ++i) { + Task *task2 = g_ptr_array_index(task_buttons, i); + task2->title = task->title; + schedule_redraw(&task2->area); + } + } + return TRUE; } void task_update_icon(Task *task) { - Panel *panel = task->area.panel; - if (!panel->g_task.has_icon) - return; + Panel *panel = task->area.panel; + if (!panel->g_task.has_icon) + return; - for (int k = 0; k < TASK_STATE_COUNT; ++k) { - if (task->icon[k]) { - imlib_context_set_image(task->icon[k]); - imlib_free_image(); - task->icon[k] = 0; - } - } + for (int k = 0; k < TASK_STATE_COUNT; ++k) { + if (task->icon[k]) { + imlib_context_set_image(task->icon[k]); + imlib_free_image(); + task->icon[k] = 0; + } + } - Imlib_Image img = NULL; + Imlib_Image img = NULL; - if (!img) { - int i; - gulong *data = server_get_property(task->win, server.atom._NET_WM_ICON, XA_CARDINAL, &i); - if (data) { - // get ARGB icon - int w, h; - gulong *tmp_data; + if (!img) { + int i; + gulong *data = server_get_property(task->win, server.atom._NET_WM_ICON, XA_CARDINAL, &i); + if (data) { + // get ARGB icon + int w, h; + gulong *tmp_data; - tmp_data = get_best_icon(data, get_icon_count(data, i), i, &w, &h, panel->g_task.icon_size1); - DATA32 icon_data[w * h]; - for (int j = 0; j < w * h; ++j) - icon_data[j] = tmp_data[j]; - img = imlib_create_image_using_copied_data(w, h, icon_data); - if (0 && img) - fprintf(stderr, - "%s: Got %dx%d icon via _NET_WM_ICON for %s\n", - __FUNCTION__, - w, - h, - task->title ? task->title : "task"); - XFree(data); - } - } + tmp_data = get_best_icon(data, get_icon_count(data, i), i, &w, &h, panel->g_task.icon_size1); + DATA32 icon_data[w * h]; + for (int j = 0; j < w * h; ++j) + icon_data[j] = tmp_data[j]; + img = imlib_create_image_using_copied_data(w, h, icon_data); + if (0 && img) + fprintf(stderr, + "%s: Got %dx%d icon via _NET_WM_ICON for %s\n", + __FUNCTION__, + w, + h, + task->title ? task->title : "task"); + XFree(data); + } + } - if (!img) { - XWMHints *hints = XGetWMHints(server.display, task->win); - if (hints) { - if (hints->flags & IconPixmapHint && hints->icon_pixmap != 0) { - // get width, height and depth for the pixmap - Window root; - int icon_x, icon_y; - unsigned border_width, bpp; - unsigned w, h; + if (!img) { + XWMHints *hints = XGetWMHints(server.display, task->win); + if (hints) { + if (hints->flags & IconPixmapHint && hints->icon_pixmap != 0) { + // get width, height and depth for the pixmap + Window root; + int icon_x, icon_y; + unsigned border_width, bpp; + unsigned w, h; - XGetGeometry(server.display, hints->icon_pixmap, &root, &icon_x, &icon_y, &w, &h, &border_width, &bpp); - imlib_context_set_drawable(hints->icon_pixmap); - img = imlib_create_image_from_drawable(hints->icon_mask, 0, 0, w, h, 0); - if (0 && img) - fprintf(stderr, - "%s: Got %dx%d pixmap icon via WM_HINTS for %s\n", - __FUNCTION__, - w, - h, - task->title ? task->title : "task"); - } - XFree(hints); - } - } + XGetGeometry(server.display, hints->icon_pixmap, &root, &icon_x, &icon_y, &w, &h, &border_width, &bpp); + imlib_context_set_drawable(hints->icon_pixmap); + img = imlib_create_image_from_drawable(hints->icon_mask, 0, 0, w, h, 0); + if (0 && img) + fprintf(stderr, + "%s: Got %dx%d pixmap icon via WM_HINTS for %s\n", + __FUNCTION__, + w, + h, + task->title ? task->title : "task"); + } + XFree(hints); + } + } - if (img == NULL) { - imlib_context_set_image(default_icon); - img = imlib_clone_image(); - if (0) - fprintf(stderr, "%s: Using default icon for %s\n", __FUNCTION__, task->title ? task->title : "task"); - } + if (img == NULL) { + imlib_context_set_image(default_icon); + img = imlib_clone_image(); + if (0) + fprintf(stderr, "%s: Using default icon for %s\n", __FUNCTION__, task->title ? task->title : "task"); + } - // transform icons - imlib_context_set_image(img); - imlib_image_set_has_alpha(1); - int w = imlib_image_get_width(); - int h = imlib_image_get_height(); - Imlib_Image orig_image = - imlib_create_cropped_scaled_image(0, 0, w, h, panel->g_task.icon_size1, panel->g_task.icon_size1); - imlib_free_image(); + // transform icons + imlib_context_set_image(img); + imlib_image_set_has_alpha(1); + int w = imlib_image_get_width(); + int h = imlib_image_get_height(); + Imlib_Image orig_image = + imlib_create_cropped_scaled_image(0, 0, w, h, panel->g_task.icon_size1, panel->g_task.icon_size1); + imlib_free_image(); - imlib_context_set_image(orig_image); - task->icon_width = imlib_image_get_width(); - task->icon_height = imlib_image_get_height(); - for (int k = 0; k < TASK_STATE_COUNT; ++k) { - imlib_context_set_image(orig_image); - task->icon[k] = imlib_clone_image(); - imlib_context_set_image(task->icon[k]); - DATA32 *data32; - if (panel->g_task.alpha[k] != 100 || panel->g_task.saturation[k] != 0 || panel->g_task.brightness[k] != 0) { - data32 = imlib_image_get_data(); - adjust_asb(data32, - task->icon_width, - task->icon_height, - panel->g_task.alpha[k] / 100.0, - panel->g_task.saturation[k] / 100.0, - panel->g_task.brightness[k] / 100.0); - imlib_image_put_back_data(data32); - } - if (panel_config.mouse_effects) { - task->icon_hover[k] = adjust_icon(task->icon[k], - panel_config.mouse_over_alpha, - panel_config.mouse_over_saturation, - panel_config.mouse_over_brightness); - task->icon_press[k] = adjust_icon(task->icon[k], - panel_config.mouse_pressed_alpha, - panel_config.mouse_pressed_saturation, - panel_config.mouse_pressed_brightness); - } - } - imlib_context_set_image(orig_image); - imlib_free_image(); + imlib_context_set_image(orig_image); + task->icon_width = imlib_image_get_width(); + task->icon_height = imlib_image_get_height(); + for (int k = 0; k < TASK_STATE_COUNT; ++k) { + imlib_context_set_image(orig_image); + task->icon[k] = imlib_clone_image(); + imlib_context_set_image(task->icon[k]); + DATA32 *data32; + if (panel->g_task.alpha[k] != 100 || panel->g_task.saturation[k] != 0 || panel->g_task.brightness[k] != 0) { + data32 = imlib_image_get_data(); + adjust_asb(data32, + task->icon_width, + task->icon_height, + panel->g_task.alpha[k] / 100.0, + panel->g_task.saturation[k] / 100.0, + panel->g_task.brightness[k] / 100.0); + imlib_image_put_back_data(data32); + } + if (panel_config.mouse_effects) { + task->icon_hover[k] = adjust_icon(task->icon[k], + panel_config.mouse_over_alpha, + panel_config.mouse_over_saturation, + panel_config.mouse_over_brightness); + task->icon_press[k] = adjust_icon(task->icon[k], + panel_config.mouse_pressed_alpha, + panel_config.mouse_pressed_saturation, + panel_config.mouse_pressed_brightness); + } + } + imlib_context_set_image(orig_image); + imlib_free_image(); - GPtrArray *task_buttons = get_task_buttons(task->win); - if (task_buttons) { - for (int i = 0; i < task_buttons->len; ++i) { - Task *task2 = g_ptr_array_index(task_buttons, i); - task2->icon_width = task->icon_width; - task2->icon_height = task->icon_height; - for (int k = 0; k < TASK_STATE_COUNT; ++k) { - task2->icon[k] = task->icon[k]; - task2->icon_hover[k] = task->icon_hover[k]; - task2->icon_press[k] = task->icon_press[k]; - } - schedule_redraw(&task2->area); - } - } + GPtrArray *task_buttons = get_task_buttons(task->win); + if (task_buttons) { + for (int i = 0; i < task_buttons->len; ++i) { + Task *task2 = g_ptr_array_index(task_buttons, i); + task2->icon_width = task->icon_width; + task2->icon_height = task->icon_height; + for (int k = 0; k < TASK_STATE_COUNT; ++k) { + task2->icon[k] = task->icon[k]; + task2->icon_hover[k] = task->icon_hover[k]; + task2->icon_press[k] = task->icon_press[k]; + } + schedule_redraw(&task2->area); + } + } } // TODO icons look too large when the panel is large void draw_task_icon(Task *task, int text_width) { - if (!task->icon[task->current_state]) - return; + if (!task->icon[task->current_state]) + return; - // Find pos - Panel *panel = (Panel *)task->area.panel; - if (panel->g_task.centered) { - if (panel->g_task.has_text) - task->_icon_x = (task->area.width - text_width - panel->g_task.icon_size1) / 2; - else - task->_icon_x = (task->area.width - panel->g_task.icon_size1) / 2; - } else { - task->_icon_x = left_border_width(&task->area) + task->area.paddingxlr; - } + // Find pos + Panel *panel = (Panel *)task->area.panel; + if (panel->g_task.centered) { + if (panel->g_task.has_text) + task->_icon_x = (task->area.width - text_width - panel->g_task.icon_size1) / 2; + else + task->_icon_x = (task->area.width - panel->g_task.icon_size1) / 2; + } else { + task->_icon_x = left_border_width(&task->area) + task->area.paddingxlr; + } - // Render + // Render - Imlib_Image image; - // Render - if (panel_config.mouse_effects) { - if (task->area.mouse_state == MOUSE_OVER) - image = task->icon_hover[task->current_state]; - else if (task->area.mouse_state == MOUSE_DOWN) - image = task->icon_press[task->current_state]; - else - image = task->icon[task->current_state]; - } else { - image = task->icon[task->current_state]; - } + Imlib_Image image; + // Render + if (panel_config.mouse_effects) { + if (task->area.mouse_state == MOUSE_OVER) + image = task->icon_hover[task->current_state]; + else if (task->area.mouse_state == MOUSE_DOWN) + image = task->icon_press[task->current_state]; + else + image = task->icon[task->current_state]; + } else { + image = task->icon[task->current_state]; + } - imlib_context_set_image(image); - task->_icon_y = (task->area.height - panel->g_task.icon_size1) / 2; - render_image(task->area.pix, task->_icon_x, task->_icon_y); + imlib_context_set_image(image); + task->_icon_y = (task->area.height - panel->g_task.icon_size1) / 2; + render_image(task->area.pix, task->_icon_x, task->_icon_y); } void draw_task(void *obj, cairo_t *c) { - Task *task = (Task *)obj; - Panel *panel = (Panel *)task->area.panel; + Task *task = (Task *)obj; + Panel *panel = (Panel *)task->area.panel; - task->_text_width = 0; - if (panel->g_task.has_text) { - PangoLayout *layout = pango_cairo_create_layout(c); - pango_layout_set_font_description(layout, panel->g_task.font_desc); - pango_layout_set_text(layout, task->title, -1); + task->_text_width = 0; + if (panel->g_task.has_text) { + PangoLayout *layout = pango_cairo_create_layout(c); + pango_layout_set_font_description(layout, panel->g_task.font_desc); + pango_layout_set_text(layout, task->title, -1); - pango_layout_set_width(layout, ((Taskbar *)task->area.parent)->text_width * PANGO_SCALE); - pango_layout_set_height(layout, panel->g_task.text_height * PANGO_SCALE); - pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR); - pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END); + pango_layout_set_width(layout, ((Taskbar *)task->area.parent)->text_width * PANGO_SCALE); + pango_layout_set_height(layout, panel->g_task.text_height * PANGO_SCALE); + pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR); + pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END); - if (panel->g_task.centered) - pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER); - else - pango_layout_set_alignment(layout, PANGO_ALIGN_LEFT); + if (panel->g_task.centered) + pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER); + else + pango_layout_set_alignment(layout, PANGO_ALIGN_LEFT); - pango_layout_get_pixel_size(layout, &task->_text_width, &task->_text_height); - task->_text_posy = (panel->g_task.area.height - task->_text_height) / 2.0; + pango_layout_get_pixel_size(layout, &task->_text_width, &task->_text_height); + task->_text_posy = (panel->g_task.area.height - task->_text_height) / 2.0; - Color *config_text = &panel->g_task.font[task->current_state]; - draw_text(layout, c, panel->g_task.text_posx, task->_text_posy, config_text, panel->font_shadow); + Color *config_text = &panel->g_task.font[task->current_state]; + draw_text(layout, c, panel->g_task.text_posx, task->_text_posy, config_text, panel->font_shadow); - g_object_unref(layout); - } + g_object_unref(layout); + } - if (panel->g_task.has_icon) - draw_task_icon(task, task->_text_width); + if (panel->g_task.has_icon) + draw_task_icon(task, task->_text_width); } void task_dump_geometry(void *obj, int indent) { - Task *task = (Task *)obj; - Panel *panel = (Panel *)task->area.panel; + Task *task = (Task *)obj; + Panel *panel = (Panel *)task->area.panel; - fprintf(stderr, - "%*sText: x = %d, y = %d, w = %d, h = %d, align = %s, text = %s\n", - indent, - "", - (int)panel->g_task.text_posx, - (int)task->_text_posy, - task->_text_width, - task->_text_height, - panel->g_task.centered ? "center" : "left", - task->title); - fprintf(stderr, - "%*sIcon: x = %d, y = %d, w = h = %d\n", - indent, - "", - task->_icon_x, - task->_icon_y, - panel->g_task.icon_size1); + fprintf(stderr, + "%*sText: x = %d, y = %d, w = %d, h = %d, align = %s, text = %s\n", + indent, + "", + (int)panel->g_task.text_posx, + (int)task->_text_posy, + task->_text_width, + task->_text_height, + panel->g_task.centered ? "center" : "left", + task->title); + fprintf(stderr, + "%*sIcon: x = %d, y = %d, w = h = %d\n", + indent, + "", + task->_icon_x, + task->_icon_y, + panel->g_task.icon_size1); } int task_compute_desired_size(void *obj) { - Task *task = (Task *)obj; - Panel *panel = (Panel *)task->area.panel; - int size = panel_horizontal ? panel->g_task.maximum_width : panel->g_task.maximum_height; - return size; + Task *task = (Task *)obj; + Panel *panel = (Panel *)task->area.panel; + int size = panel_horizontal ? panel->g_task.maximum_width : panel->g_task.maximum_height; + return size; } void on_change_task(void *obj) { - Task *task = (Task *)obj; - Panel *panel = (Panel *)task->area.panel; + Task *task = (Task *)obj; + Panel *panel = (Panel *)task->area.panel; - if (task->area.on_screen) { - long value[] = {panel->posx + task->area.posx, - panel->posy + task->area.posy, - task->area.width, - task->area.height}; - XChangeProperty(server.display, - task->win, - server.atom._NET_WM_ICON_GEOMETRY, - XA_CARDINAL, - 32, - PropModeReplace, - (unsigned char *)value, - 4); - } else { - XDeleteProperty(server.display, - task->win, - server.atom._NET_WM_ICON_GEOMETRY); - } + if (task->area.on_screen) { + long value[] = {panel->posx + task->area.posx, + panel->posy + task->area.posy, + task->area.width, + task->area.height}; + XChangeProperty(server.display, + task->win, + server.atom._NET_WM_ICON_GEOMETRY, + XA_CARDINAL, + 32, + PropModeReplace, + (unsigned char *)value, + 4); + } else { + XDeleteProperty(server.display, task->win, server.atom._NET_WM_ICON_GEOMETRY); + } } Task *find_active_task(Task *current_task) { - if (active_task == NULL) - return current_task; + if (active_task == NULL) + return current_task; - Taskbar *taskbar = (Taskbar *)current_task->area.parent; + Taskbar *taskbar = (Taskbar *)current_task->area.parent; - GList *l0 = taskbar->area.children; - if (taskbarname_enabled) - l0 = l0->next; - for (; l0; l0 = l0->next) { - Task *task = (Task *)l0->data; - if (task->win == active_task->win) - return task; - } + GList *l0 = taskbar->area.children; + if (taskbarname_enabled) + l0 = l0->next; + for (; l0; l0 = l0->next) { + Task *task = (Task *)l0->data; + if (task->win == active_task->win) + return task; + } - return current_task; + return current_task; } Task *next_task(Task *task) { - if (!task) - return NULL; + if (!task) + return NULL; - Taskbar *taskbar = task->area.parent; + Taskbar *taskbar = task->area.parent; - GList *l0 = taskbar->area.children; - if (taskbarname_enabled) - l0 = l0->next; - GList *lfirst_task = l0; - for (; l0; l0 = l0->next) { - Task *task1 = l0->data; - if (task1 == task) { - l0 = l0->next ? l0->next : lfirst_task; - return l0->data; - } - } + GList *l0 = taskbar->area.children; + if (taskbarname_enabled) + l0 = l0->next; + GList *lfirst_task = l0; + for (; l0; l0 = l0->next) { + Task *task1 = l0->data; + if (task1 == task) { + l0 = l0->next ? l0->next : lfirst_task; + return l0->data; + } + } - return NULL; + return NULL; } Task *prev_task(Task *task) { - if (!task) - return 0; + if (!task) + return 0; - Taskbar *taskbar = task->area.parent; + Taskbar *taskbar = task->area.parent; - Task *task2 = NULL; - GList *l0 = taskbar->area.children; - if (taskbarname_enabled) - l0 = l0->next; - GList *lfirst_task = l0; - for (; l0; l0 = l0->next) { - Task *task1 = l0->data; - if (task1 == task) { - if (l0 == lfirst_task) { - l0 = g_list_last(l0); - task2 = l0->data; - } - return task2; - } - task2 = task1; - } + Task *task2 = NULL; + GList *l0 = taskbar->area.children; + if (taskbarname_enabled) + l0 = l0->next; + GList *lfirst_task = l0; + for (; l0; l0 = l0->next) { + Task *task1 = l0->data; + if (task1 == task) { + if (l0 == lfirst_task) { + l0 = g_list_last(l0); + task2 = l0->data; + } + return task2; + } + task2 = task1; + } - return NULL; + return NULL; } void reset_active_task() { - if (active_task) { - set_task_state(active_task, window_is_iconified(active_task->win) ? TASK_ICONIFIED : TASK_NORMAL); - active_task = NULL; - } + if (active_task) { + set_task_state(active_task, window_is_iconified(active_task->win) ? TASK_ICONIFIED : TASK_NORMAL); + active_task = NULL; + } - Window w1 = get_active_window(); - // printf("Change active task %ld\n", w1); + Window w1 = get_active_window(); + // printf("Change active task %ld\n", w1); - if (w1) { - if (!get_task_buttons(w1)) { - Window w2; - while (XGetTransientForHint(server.display, w1, &w2)) - w1 = w2; - } - set_task_state((active_task = get_task(w1)), TASK_ACTIVE); - } + if (w1) { + if (!get_task_buttons(w1)) { + Window w2; + while (XGetTransientForHint(server.display, w1, &w2)) + w1 = w2; + } + set_task_state((active_task = get_task(w1)), TASK_ACTIVE); + } } void set_task_state(Task *task, TaskState state) { - if (!task || state == TASK_UNDEFINED || state >= TASK_STATE_COUNT) - return; + if (!task || state == TASK_UNDEFINED || state >= TASK_STATE_COUNT) + return; - if (state == TASK_ACTIVE && task->current_state != state) { - clock_gettime(CLOCK_MONOTONIC, &task->last_activation_time); - if (taskbar_sort_method == TASKBAR_SORT_LRU || taskbar_sort_method == TASKBAR_SORT_MRU) { - GPtrArray *task_buttons = get_task_buttons(task->win); - if (task_buttons) { - for (int i = 0; i < task_buttons->len; ++i) { - Task *task1 = g_ptr_array_index(task_buttons, i); - Taskbar *taskbar = (Taskbar *)task1->area.parent; - sort_tasks(taskbar); - } - } - } - } + if (state == TASK_ACTIVE && task->current_state != state) { + clock_gettime(CLOCK_MONOTONIC, &task->last_activation_time); + if (taskbar_sort_method == TASKBAR_SORT_LRU || taskbar_sort_method == TASKBAR_SORT_MRU) { + GPtrArray *task_buttons = get_task_buttons(task->win); + if (task_buttons) { + for (int i = 0; i < task_buttons->len; ++i) { + Task *task1 = g_ptr_array_index(task_buttons, i); + Taskbar *taskbar = (Taskbar *)task1->area.parent; + sort_tasks(taskbar); + } + } + } + } - if (task->current_state != state || hide_task_diff_monitor) { - GPtrArray *task_buttons = get_task_buttons(task->win); - if (task_buttons) { - for (int i = 0; i < task_buttons->len; ++i) { - Task *task1 = g_ptr_array_index(task_buttons, i); - task1->current_state = state; - task1->area.bg = panels[0].g_task.background[state]; - free_area_gradient_instances(&task1->area); - instantiate_area_gradients(&task1->area); - schedule_redraw(&task1->area); - if (state == TASK_ACTIVE && g_slist_find(urgent_list, task1)) - del_urgent(task1); - gboolean hide = FALSE; - Taskbar *taskbar = (Taskbar *)task1->area.parent; - if (task->desktop == ALL_DESKTOPS && server.desktop != taskbar->desktop) { - // Hide ALL_DESKTOPS task on non-current desktop - hide = !always_show_all_desktop_tasks; - } - if (hide_inactive_tasks) { - // Show only the active task - if (state != TASK_ACTIVE) { - hide = TRUE; - } - } - if (get_window_monitor(task->win) != ((Panel *)task->area.panel)->monitor && - (hide_task_diff_monitor || num_panels > 1)) { - hide = TRUE; - } - if ((!hide) != task1->area.on_screen) { - task1->area.on_screen = !hide; - schedule_redraw(&task1->area); - Panel *p = (Panel *)task->area.panel; - task->area.resize_needed = TRUE; - p->taskbar->area.resize_needed = TRUE; - p->area.resize_needed = TRUE; - } - } - schedule_panel_redraw(); - } - } + if (task->current_state != state || hide_task_diff_monitor) { + GPtrArray *task_buttons = get_task_buttons(task->win); + if (task_buttons) { + for (int i = 0; i < task_buttons->len; ++i) { + Task *task1 = g_ptr_array_index(task_buttons, i); + task1->current_state = state; + task1->area.bg = panels[0].g_task.background[state]; + free_area_gradient_instances(&task1->area); + instantiate_area_gradients(&task1->area); + schedule_redraw(&task1->area); + if (state == TASK_ACTIVE && g_slist_find(urgent_list, task1)) + del_urgent(task1); + gboolean hide = FALSE; + Taskbar *taskbar = (Taskbar *)task1->area.parent; + if (task->desktop == ALL_DESKTOPS && server.desktop != taskbar->desktop) { + // Hide ALL_DESKTOPS task on non-current desktop + hide = !always_show_all_desktop_tasks; + } + if (hide_inactive_tasks) { + // Show only the active task + if (state != TASK_ACTIVE) { + hide = TRUE; + } + } + if (get_window_monitor(task->win) != ((Panel *)task->area.panel)->monitor && + (hide_task_diff_monitor || num_panels > 1)) { + hide = TRUE; + } + if ((!hide) != task1->area.on_screen) { + task1->area.on_screen = !hide; + schedule_redraw(&task1->area); + Panel *p = (Panel *)task->area.panel; + task->area.resize_needed = TRUE; + p->taskbar->area.resize_needed = TRUE; + p->area.resize_needed = TRUE; + } + } + schedule_panel_redraw(); + } + } } void blink_urgent(void *arg) { - GSList *urgent_task = urgent_list; - while (urgent_task) { - Task *t = urgent_task->data; - if (t->urgent_tick < max_tick_urgent) { - if (t->urgent_tick++ % 2) - set_task_state(t, TASK_URGENT); - else - set_task_state(t, window_is_iconified(t->win) ? TASK_ICONIFIED : TASK_NORMAL); - } - urgent_task = urgent_task->next; - } - schedule_panel_redraw(); + GSList *urgent_task = urgent_list; + while (urgent_task) { + Task *t = urgent_task->data; + if (t->urgent_tick < max_tick_urgent) { + if (t->urgent_tick++ % 2) + set_task_state(t, TASK_URGENT); + else + set_task_state(t, window_is_iconified(t->win) ? TASK_ICONIFIED : TASK_NORMAL); + } + urgent_task = urgent_task->next; + } + schedule_panel_redraw(); } void add_urgent(Task *task) { - if (!task) - return; + if (!task) + return; - // some programs set urgency hint although they are active - if (active_task && active_task->win == task->win) - return; + // some programs set urgency hint although they are active + if (active_task && active_task->win == task->win) + return; - task = get_task(task->win); // always add the first task for the task buttons (omnipresent windows) - task->urgent_tick = 0; - if (g_slist_find(urgent_list, task)) - return; + task = get_task(task->win); // always add the first task for the task buttons (omnipresent windows) + task->urgent_tick = 0; + if (g_slist_find(urgent_list, task)) + return; - // not yet in the list, so we have to add it - urgent_list = g_slist_prepend(urgent_list, task); + // not yet in the list, so we have to add it + urgent_list = g_slist_prepend(urgent_list, task); - if (!urgent_timeout) - urgent_timeout = add_timeout(10, 1000, blink_urgent, 0, &urgent_timeout); + if (!urgent_timeout) + urgent_timeout = add_timeout(10, 1000, blink_urgent, 0, &urgent_timeout); - Panel *panel = task->area.panel; - if (panel->is_hidden) - autohide_show(panel); + Panel *panel = task->area.panel; + if (panel->is_hidden) + autohide_show(panel); } void del_urgent(Task *task) { - urgent_list = g_slist_remove(urgent_list, task); - if (!urgent_list) { - stop_timeout(urgent_timeout); - urgent_timeout = NULL; - } + urgent_list = g_slist_remove(urgent_list, task); + if (!urgent_list) { + stop_timeout(urgent_timeout); + urgent_timeout = NULL; + } }
M src/taskbar/task.hsrc/taskbar/task.h

@@ -14,65 +14,65 @@ #include "common.h"

#include "timer.h" typedef enum TaskState { - TASK_NORMAL = 0, - TASK_ACTIVE, - TASK_ICONIFIED, - TASK_URGENT, - TASK_UNDEFINED, - TASK_STATE_COUNT, + TASK_NORMAL = 0, + TASK_ACTIVE, + TASK_ICONIFIED, + TASK_URGENT, + TASK_UNDEFINED, + TASK_STATE_COUNT, } TaskState; typedef struct GlobalTask { - Area area; - gboolean has_text; - gboolean has_icon; - gboolean centered; - int icon_posy; - int icon_size1; - int maximum_width; - int maximum_height; - int alpha[TASK_STATE_COUNT]; - int saturation[TASK_STATE_COUNT]; - int brightness[TASK_STATE_COUNT]; - int config_asb_mask; - Background *background[TASK_STATE_COUNT]; - GList *gradient[TASK_STATE_COUNT]; - int config_background_mask; - // starting position for text ~ task_padding + task_border + icon_size - double text_posx, text_height; - gboolean has_font; - PangoFontDescription *font_desc; - Color font[TASK_STATE_COUNT]; - int config_font_mask; - gboolean tooltip_enabled; + Area area; + gboolean has_text; + gboolean has_icon; + gboolean centered; + int icon_posy; + int icon_size1; + int maximum_width; + int maximum_height; + int alpha[TASK_STATE_COUNT]; + int saturation[TASK_STATE_COUNT]; + int brightness[TASK_STATE_COUNT]; + int config_asb_mask; + Background *background[TASK_STATE_COUNT]; + GList *gradient[TASK_STATE_COUNT]; + int config_background_mask; + // starting position for text ~ task_padding + task_border + icon_size + double text_posx, text_height; + gboolean has_font; + PangoFontDescription *font_desc; + Color font[TASK_STATE_COUNT]; + int config_font_mask; + gboolean tooltip_enabled; } GlobalTask; // Stores information about a task. // Warning: any dynamically allocated members are shared between the Task instances created for the same window // (if the task appears on all desktops, there will be a different instance on each desktop's taskbar). typedef struct Task { - Area area; - Window win; - int desktop; - TaskState current_state; - Imlib_Image icon[TASK_STATE_COUNT]; - Imlib_Image icon_hover[TASK_STATE_COUNT]; - Imlib_Image icon_press[TASK_STATE_COUNT]; - unsigned int icon_width; - unsigned int icon_height; - char *title; - int urgent_tick; - // These may not be up-to-date - int win_x; - int win_y; - int win_w; - int win_h; - struct timespec last_activation_time; - int _text_width; - int _text_height; - double _text_posy; - int _icon_x; - int _icon_y; + Area area; + Window win; + int desktop; + TaskState current_state; + Imlib_Image icon[TASK_STATE_COUNT]; + Imlib_Image icon_hover[TASK_STATE_COUNT]; + Imlib_Image icon_press[TASK_STATE_COUNT]; + unsigned int icon_width; + unsigned int icon_height; + char *title; + int urgent_tick; + // These may not be up-to-date + int win_x; + int win_y; + int win_w; + int win_h; + struct timespec last_activation_time; + int _text_width; + int _text_height; + double _text_posy; + int _icon_x; + int _icon_y; } Task; extern timeout *urgent_timeout;
M src/taskbar/taskbar.csrc/taskbar/taskbar.c

@@ -54,638 +54,637 @@ void taskbar_remove_task(Window *win);

guint win_hash(gconstpointer key) { - return *((const Window *)key); + return *((const Window *)key); } gboolean win_compare(gconstpointer a, gconstpointer b) { - return (*((const Window *)a) == *((const Window *)b)); + return (*((const Window *)a) == *((const Window *)b)); } void free_ptr_array(gpointer data) { - g_ptr_array_free(data, 1); + g_ptr_array_free(data, 1); } void default_taskbar() { - win_to_task = NULL; - urgent_timeout = NULL; - urgent_list = NULL; - taskbar_enabled = FALSE; - taskbar_distribute_size = FALSE; - hide_inactive_tasks = FALSE; - hide_task_diff_monitor = FALSE; - hide_taskbar_if_empty = FALSE; - always_show_all_desktop_tasks = FALSE; - taskbar_sort_method = TASKBAR_NOSORT; - taskbar_alignment = ALIGN_LEFT; - default_taskbarname(); + win_to_task = NULL; + urgent_timeout = NULL; + urgent_list = NULL; + taskbar_enabled = FALSE; + taskbar_distribute_size = FALSE; + hide_inactive_tasks = FALSE; + hide_task_diff_monitor = FALSE; + hide_taskbar_if_empty = FALSE; + always_show_all_desktop_tasks = FALSE; + taskbar_sort_method = TASKBAR_NOSORT; + taskbar_alignment = ALIGN_LEFT; + default_taskbarname(); } void cleanup_taskbar() { - if (win_to_task) { - while (g_hash_table_size(win_to_task)) { - GHashTableIter iter; - gpointer key, value; + if (win_to_task) { + while (g_hash_table_size(win_to_task)) { + GHashTableIter iter; + gpointer key, value; - g_hash_table_iter_init(&iter, win_to_task); - if (g_hash_table_iter_next(&iter, &key, &value)) { - taskbar_remove_task(key); - } - } - g_hash_table_destroy(win_to_task); - win_to_task = NULL; - } - cleanup_taskbarname(); - for (int i = 0; i < num_panels; i++) { - Panel *panel = &panels[i]; - for (int j = 0; j < panel->num_desktops; j++) { - Taskbar *taskbar = &panel->taskbar[j]; - free_area(&taskbar->area); - // remove taskbar from the panel - remove_area((Area *)taskbar); - } - if (panel->taskbar) { - free(panel->taskbar); - panel->taskbar = NULL; - } - } + g_hash_table_iter_init(&iter, win_to_task); + if (g_hash_table_iter_next(&iter, &key, &value)) { + taskbar_remove_task(key); + } + } + g_hash_table_destroy(win_to_task); + win_to_task = NULL; + } + cleanup_taskbarname(); + for (int i = 0; i < num_panels; i++) { + Panel *panel = &panels[i]; + for (int j = 0; j < panel->num_desktops; j++) { + Taskbar *taskbar = &panel->taskbar[j]; + free_area(&taskbar->area); + // remove taskbar from the panel + remove_area((Area *)taskbar); + } + if (panel->taskbar) { + free(panel->taskbar); + panel->taskbar = NULL; + } + } - g_slist_free(urgent_list); - urgent_list = NULL; + g_slist_free(urgent_list); + urgent_list = NULL; - stop_timeout(urgent_timeout); + stop_timeout(urgent_timeout); - for (int state = 0; state < TASK_STATE_COUNT; state++) { - g_list_free(panel_config.g_task.gradient[state]); - } + for (int state = 0; state < TASK_STATE_COUNT; state++) { + g_list_free(panel_config.g_task.gradient[state]); + } - for (int state = 0; state < TASKBAR_STATE_COUNT; state++) { - g_list_free(panel_config.g_taskbar.gradient[state]); - g_list_free(panel_config.g_taskbar.gradient_name[state]); - } + for (int state = 0; state < TASKBAR_STATE_COUNT; state++) { + g_list_free(panel_config.g_taskbar.gradient[state]); + g_list_free(panel_config.g_taskbar.gradient_name[state]); + } } void init_taskbar() { - if (!panel_config.g_task.has_text && !panel_config.g_task.has_icon) { - panel_config.g_task.has_text = panel_config.g_task.has_icon = 1; - } + if (!panel_config.g_task.has_text && !panel_config.g_task.has_icon) { + panel_config.g_task.has_text = panel_config.g_task.has_icon = 1; + } - if (!win_to_task) - win_to_task = g_hash_table_new_full(win_hash, win_compare, free, free_ptr_array); + if (!win_to_task) + win_to_task = g_hash_table_new_full(win_hash, win_compare, free, free_ptr_array); - active_task = 0; - task_drag = 0; + active_task = 0; + task_drag = 0; } void init_taskbar_panel(void *p) { - Panel *panel = (Panel *)p; + Panel *panel = (Panel *)p; - if (!panel->g_taskbar.background[TASKBAR_NORMAL]) { - panel->g_taskbar.background[TASKBAR_NORMAL] = &g_array_index(backgrounds, Background, 0); - panel->g_taskbar.background[TASKBAR_ACTIVE] = &g_array_index(backgrounds, Background, 0); - } - if (!panel->g_taskbar.background_name[TASKBAR_NORMAL]) { - panel->g_taskbar.background_name[TASKBAR_NORMAL] = &g_array_index(backgrounds, Background, 0); - panel->g_taskbar.background_name[TASKBAR_ACTIVE] = &g_array_index(backgrounds, Background, 0); - } - if (!panel->g_task.area.bg) - panel->g_task.area.bg = &g_array_index(backgrounds, Background, 0); - taskbar_init_fonts(); + if (!panel->g_taskbar.background[TASKBAR_NORMAL]) { + panel->g_taskbar.background[TASKBAR_NORMAL] = &g_array_index(backgrounds, Background, 0); + panel->g_taskbar.background[TASKBAR_ACTIVE] = &g_array_index(backgrounds, Background, 0); + } + if (!panel->g_taskbar.background_name[TASKBAR_NORMAL]) { + panel->g_taskbar.background_name[TASKBAR_NORMAL] = &g_array_index(backgrounds, Background, 0); + panel->g_taskbar.background_name[TASKBAR_ACTIVE] = &g_array_index(backgrounds, Background, 0); + } + if (!panel->g_task.area.bg) + panel->g_task.area.bg = &g_array_index(backgrounds, Background, 0); + taskbar_init_fonts(); - // taskbar name - panel->g_taskbar.area_name.panel = panel; - snprintf(panel->g_taskbar.area_name.name, sizeof(panel->g_taskbar.area_name.name), "Taskbarname"); - panel->g_taskbar.area_name.size_mode = LAYOUT_FIXED; - panel->g_taskbar.area_name._resize = resize_taskbarname; - panel->g_taskbar.area_name._is_under_mouse = full_width_area_is_under_mouse; - panel->g_taskbar.area_name._draw_foreground = draw_taskbarname; - panel->g_taskbar.area_name._on_change_layout = 0; - panel->g_taskbar.area_name.resize_needed = 1; - panel->g_taskbar.area_name.on_screen = TRUE; + // taskbar name + panel->g_taskbar.area_name.panel = panel; + snprintf(panel->g_taskbar.area_name.name, sizeof(panel->g_taskbar.area_name.name), "Taskbarname"); + panel->g_taskbar.area_name.size_mode = LAYOUT_FIXED; + panel->g_taskbar.area_name._resize = resize_taskbarname; + panel->g_taskbar.area_name._is_under_mouse = full_width_area_is_under_mouse; + panel->g_taskbar.area_name._draw_foreground = draw_taskbarname; + panel->g_taskbar.area_name._on_change_layout = 0; + panel->g_taskbar.area_name.resize_needed = 1; + panel->g_taskbar.area_name.on_screen = TRUE; - // taskbar - panel->g_taskbar.area.parent = panel; - panel->g_taskbar.area.panel = panel; - snprintf(panel->g_taskbar.area.name, sizeof(panel->g_taskbar.area.name), "Taskbar"); - panel->g_taskbar.area.size_mode = LAYOUT_DYNAMIC; - panel->g_taskbar.area.alignment = taskbar_alignment; - panel->g_taskbar.area._resize = resize_taskbar; - panel->g_taskbar.area._compute_desired_size = taskbar_compute_desired_size; - panel->g_taskbar.area._is_under_mouse = full_width_area_is_under_mouse; - panel->g_taskbar.area.resize_needed = 1; - panel->g_taskbar.area.on_screen = TRUE; - if (panel_horizontal) { - panel->g_taskbar.area.posy = top_border_width(&panel->area) + panel->area.paddingy; - panel->g_taskbar.area.height = - panel->area.height - top_bottom_border_width(&panel->area) - 2 * panel->area.paddingy; - panel->g_taskbar.area_name.posy = panel->g_taskbar.area.posy; - panel->g_taskbar.area_name.height = panel->g_taskbar.area.height; - } else { - panel->g_taskbar.area.posx = left_border_width(&panel->area) + panel->area.paddingy; - panel->g_taskbar.area.width = - panel->area.width - left_right_border_width(&panel->area) - 2 * panel->area.paddingy; - panel->g_taskbar.area_name.posx = panel->g_taskbar.area.posx; - panel->g_taskbar.area_name.width = panel->g_taskbar.area.width; - } + // taskbar + panel->g_taskbar.area.parent = panel; + panel->g_taskbar.area.panel = panel; + snprintf(panel->g_taskbar.area.name, sizeof(panel->g_taskbar.area.name), "Taskbar"); + panel->g_taskbar.area.size_mode = LAYOUT_DYNAMIC; + panel->g_taskbar.area.alignment = taskbar_alignment; + panel->g_taskbar.area._resize = resize_taskbar; + panel->g_taskbar.area._compute_desired_size = taskbar_compute_desired_size; + panel->g_taskbar.area._is_under_mouse = full_width_area_is_under_mouse; + panel->g_taskbar.area.resize_needed = 1; + panel->g_taskbar.area.on_screen = TRUE; + if (panel_horizontal) { + panel->g_taskbar.area.posy = top_border_width(&panel->area) + panel->area.paddingy; + panel->g_taskbar.area.height = + panel->area.height - top_bottom_border_width(&panel->area) - 2 * panel->area.paddingy; + panel->g_taskbar.area_name.posy = panel->g_taskbar.area.posy; + panel->g_taskbar.area_name.height = panel->g_taskbar.area.height; + } else { + panel->g_taskbar.area.posx = left_border_width(&panel->area) + panel->area.paddingy; + panel->g_taskbar.area.width = + panel->area.width - left_right_border_width(&panel->area) - 2 * panel->area.paddingy; + panel->g_taskbar.area_name.posx = panel->g_taskbar.area.posx; + panel->g_taskbar.area_name.width = panel->g_taskbar.area.width; + } - // task - panel->g_task.area.panel = panel; - snprintf(panel->g_task.area.name, sizeof(panel->g_task.area.name), "Task"); - panel->g_task.area.size_mode = LAYOUT_DYNAMIC; - panel->g_task.area._draw_foreground = draw_task; - panel->g_task.area._on_change_layout = on_change_task; - panel->g_task.area.resize_needed = 1; - panel->g_task.area.on_screen = TRUE; - if ((panel->g_task.config_asb_mask & (1 << TASK_NORMAL)) == 0) { - panel->g_task.alpha[TASK_NORMAL] = 100; - panel->g_task.saturation[TASK_NORMAL] = 0; - panel->g_task.brightness[TASK_NORMAL] = 0; - } - if ((panel->g_task.config_asb_mask & (1 << TASK_ACTIVE)) == 0) { - panel->g_task.alpha[TASK_ACTIVE] = panel->g_task.alpha[TASK_NORMAL]; - panel->g_task.saturation[TASK_ACTIVE] = panel->g_task.saturation[TASK_NORMAL]; - panel->g_task.brightness[TASK_ACTIVE] = panel->g_task.brightness[TASK_NORMAL]; - } - if ((panel->g_task.config_asb_mask & (1 << TASK_ICONIFIED)) == 0) { - panel->g_task.alpha[TASK_ICONIFIED] = panel->g_task.alpha[TASK_NORMAL]; - panel->g_task.saturation[TASK_ICONIFIED] = panel->g_task.saturation[TASK_NORMAL]; - panel->g_task.brightness[TASK_ICONIFIED] = panel->g_task.brightness[TASK_NORMAL]; - } - if ((panel->g_task.config_asb_mask & (1 << TASK_URGENT)) == 0) { - panel->g_task.alpha[TASK_URGENT] = panel->g_task.alpha[TASK_ACTIVE]; - 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){{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) - panel->g_task.font[TASK_ICONIFIED] = panel->g_task.font[TASK_NORMAL]; - if ((panel->g_task.config_font_mask & (1 << TASK_URGENT)) == 0) - panel->g_task.font[TASK_URGENT] = panel->g_task.font[TASK_ACTIVE]; - if ((panel->g_task.config_background_mask & (1 << TASK_NORMAL)) == 0) - panel->g_task.background[TASK_NORMAL] = &g_array_index(backgrounds, Background, 0); - if ((panel->g_task.config_background_mask & (1 << TASK_ACTIVE)) == 0) - panel->g_task.background[TASK_ACTIVE] = panel->g_task.background[TASK_NORMAL]; - if ((panel->g_task.config_background_mask & (1 << TASK_ICONIFIED)) == 0) - panel->g_task.background[TASK_ICONIFIED] = panel->g_task.background[TASK_NORMAL]; - if ((panel->g_task.config_background_mask & (1 << TASK_URGENT)) == 0) - panel->g_task.background[TASK_URGENT] = panel->g_task.background[TASK_ACTIVE]; + // task + panel->g_task.area.panel = panel; + snprintf(panel->g_task.area.name, sizeof(panel->g_task.area.name), "Task"); + panel->g_task.area.size_mode = LAYOUT_DYNAMIC; + panel->g_task.area._draw_foreground = draw_task; + panel->g_task.area._on_change_layout = on_change_task; + panel->g_task.area.resize_needed = 1; + panel->g_task.area.on_screen = TRUE; + if ((panel->g_task.config_asb_mask & (1 << TASK_NORMAL)) == 0) { + panel->g_task.alpha[TASK_NORMAL] = 100; + panel->g_task.saturation[TASK_NORMAL] = 0; + panel->g_task.brightness[TASK_NORMAL] = 0; + } + if ((panel->g_task.config_asb_mask & (1 << TASK_ACTIVE)) == 0) { + panel->g_task.alpha[TASK_ACTIVE] = panel->g_task.alpha[TASK_NORMAL]; + panel->g_task.saturation[TASK_ACTIVE] = panel->g_task.saturation[TASK_NORMAL]; + panel->g_task.brightness[TASK_ACTIVE] = panel->g_task.brightness[TASK_NORMAL]; + } + if ((panel->g_task.config_asb_mask & (1 << TASK_ICONIFIED)) == 0) { + panel->g_task.alpha[TASK_ICONIFIED] = panel->g_task.alpha[TASK_NORMAL]; + panel->g_task.saturation[TASK_ICONIFIED] = panel->g_task.saturation[TASK_NORMAL]; + panel->g_task.brightness[TASK_ICONIFIED] = panel->g_task.brightness[TASK_NORMAL]; + } + if ((panel->g_task.config_asb_mask & (1 << TASK_URGENT)) == 0) { + panel->g_task.alpha[TASK_URGENT] = panel->g_task.alpha[TASK_ACTIVE]; + 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){{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) + panel->g_task.font[TASK_ICONIFIED] = panel->g_task.font[TASK_NORMAL]; + if ((panel->g_task.config_font_mask & (1 << TASK_URGENT)) == 0) + panel->g_task.font[TASK_URGENT] = panel->g_task.font[TASK_ACTIVE]; + if ((panel->g_task.config_background_mask & (1 << TASK_NORMAL)) == 0) + panel->g_task.background[TASK_NORMAL] = &g_array_index(backgrounds, Background, 0); + if ((panel->g_task.config_background_mask & (1 << TASK_ACTIVE)) == 0) + panel->g_task.background[TASK_ACTIVE] = panel->g_task.background[TASK_NORMAL]; + if ((panel->g_task.config_background_mask & (1 << TASK_ICONIFIED)) == 0) + panel->g_task.background[TASK_ICONIFIED] = panel->g_task.background[TASK_NORMAL]; + if ((panel->g_task.config_background_mask & (1 << TASK_URGENT)) == 0) + panel->g_task.background[TASK_URGENT] = panel->g_task.background[TASK_ACTIVE]; - if (!panel->g_task.maximum_width) - panel->g_task.maximum_width = server.monitors[panel->monitor].width; - if (!panel->g_task.maximum_height) - panel->g_task.maximum_height = server.monitors[panel->monitor].height; - - if (panel_horizontal) { - panel->g_task.area.posy = panel->g_taskbar.area.posy + - top_bg_border_width(panel->g_taskbar.background[TASKBAR_NORMAL]) + - panel->g_taskbar.area.paddingy; - panel->g_task.area.width = panel->g_task.maximum_width; - panel->g_task.area.height = panel->g_taskbar.area.height - - top_bottom_bg_border_width(panel->g_taskbar.background[TASKBAR_NORMAL]) - - 2 * panel->g_taskbar.area.paddingy; - } else { - panel->g_task.area.posx = panel->g_taskbar.area.posx + - left_bg_border_width(panel->g_taskbar.background[TASKBAR_NORMAL]) + - panel->g_taskbar.area.paddingy; - panel->g_task.area.width = panel->g_taskbar.area.width - - left_right_bg_border_width(panel->g_taskbar.background[TASKBAR_NORMAL]) - - 2 * panel->g_taskbar.area.paddingy; - panel->g_task.area.height = panel->g_task.maximum_height; - } + if (!panel->g_task.maximum_width) + panel->g_task.maximum_width = server.monitors[panel->monitor].width; + if (!panel->g_task.maximum_height) + panel->g_task.maximum_height = server.monitors[panel->monitor].height; - for (int j = 0; j < TASK_STATE_COUNT; ++j) { - if (!panel->g_task.background[j]) - panel->g_task.background[j] = &g_array_index(backgrounds, Background, 0); - if (panel->g_task.background[j]->border.radius > panel->g_task.area.height / 2) { - printf("task%sbackground_id has a too large rounded value. Please fix your tint2rc\n", - j == 0 ? "_" : j == 1 ? "_active_" : j == 2 ? "_iconified_" : "_urgent_"); - g_array_append_val(backgrounds, *panel->g_task.background[j]); - panel->g_task.background[j] = &g_array_index(backgrounds, Background, backgrounds->len - 1); - panel->g_task.background[j]->border.radius = panel->g_task.area.height / 2; - } - } + if (panel_horizontal) { + panel->g_task.area.posy = panel->g_taskbar.area.posy + + top_bg_border_width(panel->g_taskbar.background[TASKBAR_NORMAL]) + + panel->g_taskbar.area.paddingy; + panel->g_task.area.width = panel->g_task.maximum_width; + panel->g_task.area.height = panel->g_taskbar.area.height - + top_bottom_bg_border_width(panel->g_taskbar.background[TASKBAR_NORMAL]) - + 2 * panel->g_taskbar.area.paddingy; + } else { + panel->g_task.area.posx = panel->g_taskbar.area.posx + + left_bg_border_width(panel->g_taskbar.background[TASKBAR_NORMAL]) + + panel->g_taskbar.area.paddingy; + panel->g_task.area.width = panel->g_taskbar.area.width - + left_right_bg_border_width(panel->g_taskbar.background[TASKBAR_NORMAL]) - + 2 * panel->g_taskbar.area.paddingy; + panel->g_task.area.height = panel->g_task.maximum_height; + } - // compute vertical position : text and icon - int height_ink, height, width; - get_text_size2(panel->g_task.font_desc, - &height_ink, - &height, - &width, - panel->area.height, - panel->area.width, - "TAjpg", - 5, - PANGO_WRAP_WORD_CHAR, - PANGO_ELLIPSIZE_END, - FALSE); + for (int j = 0; j < TASK_STATE_COUNT; ++j) { + if (!panel->g_task.background[j]) + panel->g_task.background[j] = &g_array_index(backgrounds, Background, 0); + if (panel->g_task.background[j]->border.radius > panel->g_task.area.height / 2) { + printf("task%sbackground_id has a too large rounded value. Please fix your tint2rc\n", + j == 0 ? "_" : j == 1 ? "_active_" : j == 2 ? "_iconified_" : "_urgent_"); + g_array_append_val(backgrounds, *panel->g_task.background[j]); + panel->g_task.background[j] = &g_array_index(backgrounds, Background, backgrounds->len - 1); + panel->g_task.background[j]->border.radius = panel->g_task.area.height / 2; + } + } - panel->g_task.text_posx = left_bg_border_width(panel->g_task.background[0]) + panel->g_task.area.paddingxlr; - panel->g_task.text_height = panel->g_task.area.height - (2 * panel->g_task.area.paddingy); - if (panel->g_task.has_icon) { - panel->g_task.icon_size1 = MIN(MIN(panel->g_task.maximum_width, panel->g_task.maximum_height), - MIN(panel->g_task.area.width, panel->g_task.area.height)) - - 2 * panel->g_task.area.paddingy - MAX(left_right_border_width(&panel->g_task.area), - top_bottom_border_width(&panel->g_task.area)); - panel->g_task.text_posx += panel->g_task.icon_size1 + panel->g_task.area.paddingx; - panel->g_task.icon_posy = (panel->g_task.area.height - panel->g_task.icon_size1) / 2; - if (0) - printf("task: icon_size = %d, textx = %f, texth = %f, icony = %d, w = %d, h = %d, maxw = %d, maxh = %d\n", - panel->g_task.icon_size1, - panel->g_task.text_posx, - panel->g_task.text_height, - panel->g_task.icon_posy, - panel->g_task.area.width, - panel->g_task.area.height, - panel->g_task.maximum_width, - panel->g_task.maximum_height); - } + // compute vertical position : text and icon + int height_ink, height, width; + get_text_size2(panel->g_task.font_desc, + &height_ink, + &height, + &width, + panel->area.height, + panel->area.width, + "TAjpg", + 5, + PANGO_WRAP_WORD_CHAR, + PANGO_ELLIPSIZE_END, + FALSE); - Taskbar *taskbar; - panel->num_desktops = server.num_desktops; - panel->taskbar = calloc(server.num_desktops, sizeof(Taskbar)); - for (int j = 0; j < panel->num_desktops; j++) { - taskbar = &panel->taskbar[j]; - memcpy(&taskbar->area, &panel->g_taskbar.area, sizeof(Area)); - taskbar->desktop = j; - if (j == server.desktop) { - taskbar->area.bg = panel->g_taskbar.background[TASKBAR_ACTIVE]; - free_area_gradient_instances(&taskbar->area); - instantiate_area_gradients(&taskbar->area); - } else { - taskbar->area.bg = panel->g_taskbar.background[TASKBAR_NORMAL]; - free_area_gradient_instances(&taskbar->area); - instantiate_area_gradients(&taskbar->area); - } + panel->g_task.text_posx = left_bg_border_width(panel->g_task.background[0]) + panel->g_task.area.paddingxlr; + panel->g_task.text_height = panel->g_task.area.height - (2 * panel->g_task.area.paddingy); + if (panel->g_task.has_icon) { + panel->g_task.icon_size1 = MIN(MIN(panel->g_task.maximum_width, panel->g_task.maximum_height), + MIN(panel->g_task.area.width, panel->g_task.area.height)) - + 2 * panel->g_task.area.paddingy - MAX(left_right_border_width(&panel->g_task.area), + top_bottom_border_width(&panel->g_task.area)); + panel->g_task.text_posx += panel->g_task.icon_size1 + panel->g_task.area.paddingx; + panel->g_task.icon_posy = (panel->g_task.area.height - panel->g_task.icon_size1) / 2; + if (0) + printf("task: icon_size = %d, textx = %f, texth = %f, icony = %d, w = %d, h = %d, maxw = %d, maxh = %d\n", + panel->g_task.icon_size1, + panel->g_task.text_posx, + panel->g_task.text_height, + panel->g_task.icon_posy, + panel->g_task.area.width, + panel->g_task.area.height, + panel->g_task.maximum_width, + panel->g_task.maximum_height); + } - } - init_taskbarname_panel(panel); + Taskbar *taskbar; + panel->num_desktops = server.num_desktops; + panel->taskbar = calloc(server.num_desktops, sizeof(Taskbar)); + for (int j = 0; j < panel->num_desktops; j++) { + taskbar = &panel->taskbar[j]; + memcpy(&taskbar->area, &panel->g_taskbar.area, sizeof(Area)); + taskbar->desktop = j; + if (j == server.desktop) { + taskbar->area.bg = panel->g_taskbar.background[TASKBAR_ACTIVE]; + free_area_gradient_instances(&taskbar->area); + instantiate_area_gradients(&taskbar->area); + } else { + taskbar->area.bg = panel->g_taskbar.background[TASKBAR_NORMAL]; + free_area_gradient_instances(&taskbar->area); + instantiate_area_gradients(&taskbar->area); + } + } + init_taskbarname_panel(panel); } void taskbar_init_fonts() { - for (int i = 0; i < num_panels; i++) { - if (!panels[i].g_task.font_desc) { - panels[i].g_task.font_desc = pango_font_description_from_string(get_default_font()); - pango_font_description_set_size(panels[i].g_task.font_desc, - pango_font_description_get_size(panels[i].g_task.font_desc) - PANGO_SCALE); - } - } + for (int i = 0; i < num_panels; i++) { + if (!panels[i].g_task.font_desc) { + panels[i].g_task.font_desc = pango_font_description_from_string(get_default_font()); + pango_font_description_set_size(panels[i].g_task.font_desc, + pango_font_description_get_size(panels[i].g_task.font_desc) - PANGO_SCALE); + } + } } void taskbar_default_font_changed() { - if (!taskbar_enabled) - return; + if (!taskbar_enabled) + return; - gboolean needs_update = FALSE; - for (int i = 0; i < num_panels; i++) { - if (!panels[i].g_task.has_font) { - pango_font_description_free(panels[i].g_task.font_desc); - panels[i].g_task.font_desc = NULL; - needs_update = TRUE; - } - } - if (!needs_update) - return; - taskbar_init_fonts(); - for (int i = 0; i < num_panels; i++) { - for (int j = 0; j < panels[i].num_desktops; j++) { - Taskbar *taskbar = &panels[i].taskbar[j]; - for (GList *c = taskbar->area.children; c; c = c->next) { - Task *t = c->data; - t->area.resize_needed = TRUE; - schedule_redraw(&t->area); - } - } - } - schedule_panel_redraw(); + gboolean needs_update = FALSE; + for (int i = 0; i < num_panels; i++) { + if (!panels[i].g_task.has_font) { + pango_font_description_free(panels[i].g_task.font_desc); + panels[i].g_task.font_desc = NULL; + needs_update = TRUE; + } + } + if (!needs_update) + return; + taskbar_init_fonts(); + for (int i = 0; i < num_panels; i++) { + for (int j = 0; j < panels[i].num_desktops; j++) { + Taskbar *taskbar = &panels[i].taskbar[j]; + for (GList *c = taskbar->area.children; c; c = c->next) { + Task *t = c->data; + t->area.resize_needed = TRUE; + schedule_redraw(&t->area); + } + } + } + schedule_panel_redraw(); } void taskbar_remove_task(Window *win) { - remove_task(get_task(*win)); + remove_task(get_task(*win)); } Task *get_task(Window win) { - GPtrArray *task_buttons = get_task_buttons(win); - if (task_buttons) - return g_ptr_array_index(task_buttons, 0); - return NULL; + GPtrArray *task_buttons = get_task_buttons(win); + if (task_buttons) + return g_ptr_array_index(task_buttons, 0); + return NULL; } GPtrArray *get_task_buttons(Window win) { - if (win_to_task && taskbar_enabled) - return g_hash_table_lookup(win_to_task, &win); - return NULL; + if (win_to_task && taskbar_enabled) + return g_hash_table_lookup(win_to_task, &win); + return NULL; } void taskbar_refresh_tasklist() { - if (!taskbar_enabled) - return; - // fprintf(stderr, "%s %d:\n", __FUNCTION__, __LINE__); + if (!taskbar_enabled) + return; + // fprintf(stderr, "%s %d:\n", __FUNCTION__, __LINE__); - int num_results; - Window *win = server_get_property(server.root_win, server.atom._NET_CLIENT_LIST, XA_WINDOW, &num_results); - if (!win) - return; + int num_results; + Window *win = server_get_property(server.root_win, server.atom._NET_CLIENT_LIST, XA_WINDOW, &num_results); + if (!win) + return; - GList *win_list = g_hash_table_get_keys(win_to_task); - for (GList *it = win_list; it; it = it->next) { - int i; - for (i = 0; i < num_results; i++) - if (*((Window *)it->data) == win[i]) - break; - if (i == num_results) - taskbar_remove_task(it->data); - } - g_list_free(win_list); + GList *win_list = g_hash_table_get_keys(win_to_task); + for (GList *it = win_list; it; it = it->next) { + int i; + for (i = 0; i < num_results; i++) + if (*((Window *)it->data) == win[i]) + break; + if (i == num_results) + taskbar_remove_task(it->data); + } + g_list_free(win_list); - // Add any new - for (int i = 0; i < num_results; i++) - if (!get_task(win[i])) - add_task(win[i]); + // Add any new + for (int i = 0; i < num_results; i++) + if (!get_task(win[i])) + add_task(win[i]); - XFree(win); + XFree(win); } int taskbar_compute_desired_size(void *obj) { - Taskbar *taskbar = (Taskbar *)obj; - Panel *panel = (Panel *)taskbar->area.panel; + Taskbar *taskbar = (Taskbar *)obj; + Panel *panel = (Panel *)taskbar->area.panel; - if (taskbar_mode == MULTI_DESKTOP && !taskbar_distribute_size) { - int result = 0; - for (int i = 0; i < panel->num_desktops; i++) { - Taskbar *t = &panel->taskbar[i]; - result = MAX(result, container_compute_desired_size(&t->area)); - } - return result; - } - return container_compute_desired_size(&taskbar->area); + if (taskbar_mode == MULTI_DESKTOP && !taskbar_distribute_size) { + int result = 0; + for (int i = 0; i < panel->num_desktops; i++) { + Taskbar *t = &panel->taskbar[i]; + result = MAX(result, container_compute_desired_size(&t->area)); + } + return result; + } + return container_compute_desired_size(&taskbar->area); } gboolean resize_taskbar(void *obj) { - Taskbar *taskbar = (Taskbar *)obj; - Panel *panel = (Panel *)taskbar->area.panel; + Taskbar *taskbar = (Taskbar *)obj; + Panel *panel = (Panel *)taskbar->area.panel; - // printf("resize_taskbar %d %d\n", taskbar->area.posx, taskbar->area.posy); - if (panel_horizontal) { - relayout_with_constraint(&taskbar->area, panel->g_task.maximum_width); + // printf("resize_taskbar %d %d\n", taskbar->area.posx, taskbar->area.posy); + if (panel_horizontal) { + relayout_with_constraint(&taskbar->area, panel->g_task.maximum_width); - int text_width = panel->g_task.maximum_width; - GList *l = taskbar->area.children; - if (taskbarname_enabled) - l = l->next; - for (; l != NULL; l = l->next) { - if (((Task *)l->data)->area.on_screen) { - text_width = ((Task *)l->data)->area.width; - break; - } - } - taskbar->text_width = text_width - panel->g_task.text_posx - right_border_width(&panel->g_task.area) - - panel->g_task.area.paddingxlr; - } else { - relayout_with_constraint(&taskbar->area, panel->g_task.maximum_height); + int text_width = panel->g_task.maximum_width; + GList *l = taskbar->area.children; + if (taskbarname_enabled) + l = l->next; + for (; l != NULL; l = l->next) { + if (((Task *)l->data)->area.on_screen) { + text_width = ((Task *)l->data)->area.width; + break; + } + } + taskbar->text_width = text_width - panel->g_task.text_posx - right_border_width(&panel->g_task.area) - + panel->g_task.area.paddingxlr; + } else { + relayout_with_constraint(&taskbar->area, panel->g_task.maximum_height); - taskbar->text_width = taskbar->area.width - (2 * panel->g_taskbar.area.paddingy) - panel->g_task.text_posx - - right_border_width(&panel->g_task.area) - panel->g_task.area.paddingxlr; - } - return FALSE; + taskbar->text_width = taskbar->area.width - (2 * panel->g_taskbar.area.paddingy) - panel->g_task.text_posx - + right_border_width(&panel->g_task.area) - panel->g_task.area.paddingxlr; + } + return FALSE; } gboolean taskbar_is_empty(Taskbar *taskbar) { - GList *l = taskbar->area.children; - if (taskbarname_enabled) - l = l->next; - for (; l != NULL; l = l->next) { - if (((Task *)l->data)->area.on_screen) { - return FALSE; - } - } - return TRUE; + GList *l = taskbar->area.children; + if (taskbarname_enabled) + l = l->next; + for (; l != NULL; l = l->next) { + if (((Task *)l->data)->area.on_screen) { + return FALSE; + } + } + return TRUE; } void update_taskbar_visibility(Taskbar *taskbar) { - if (taskbar->desktop == server.desktop) { - // Taskbar for current desktop is always shown - show(&taskbar->area); - } else if (taskbar_mode == MULTI_DESKTOP) { - if (hide_taskbar_if_empty) { - if (taskbar_is_empty(taskbar)) { - hide(&taskbar->area); - } else { - show(&taskbar->area); - } - } else { - show(&taskbar->area); - } - } else { - hide(&taskbar->area); - } + if (taskbar->desktop == server.desktop) { + // Taskbar for current desktop is always shown + show(&taskbar->area); + } else if (taskbar_mode == MULTI_DESKTOP) { + if (hide_taskbar_if_empty) { + if (taskbar_is_empty(taskbar)) { + hide(&taskbar->area); + } else { + show(&taskbar->area); + } + } else { + show(&taskbar->area); + } + } else { + hide(&taskbar->area); + } } void update_all_taskbars_visibility() { - for (int i = 0; i < num_panels; i++) { - Panel *panel = &panels[i]; - for (int j = 0; j < panel->num_desktops; j++) { - update_taskbar_visibility(&panel->taskbar[j]); - } - } + for (int i = 0; i < num_panels; i++) { + Panel *panel = &panels[i]; + for (int j = 0; j < panel->num_desktops; j++) { + update_taskbar_visibility(&panel->taskbar[j]); + } + } } void set_taskbar_state(Taskbar *taskbar, TaskbarState state) { - taskbar->area.bg = panels[0].g_taskbar.background[state]; - free_area_gradient_instances(&taskbar->area); - instantiate_area_gradients(&taskbar->area); + taskbar->area.bg = panels[0].g_taskbar.background[state]; + free_area_gradient_instances(&taskbar->area); + instantiate_area_gradients(&taskbar->area); - if (taskbarname_enabled) { - taskbar->bar_name.area.bg = panels[0].g_taskbar.background_name[state]; - free_area_gradient_instances(&taskbar->bar_name.area); - instantiate_area_gradients(&taskbar->bar_name.area); - } + if (taskbarname_enabled) { + taskbar->bar_name.area.bg = panels[0].g_taskbar.background_name[state]; + free_area_gradient_instances(&taskbar->bar_name.area); + instantiate_area_gradients(&taskbar->bar_name.area); + } - update_taskbar_visibility(taskbar); + update_taskbar_visibility(taskbar); - if (taskbar->area.on_screen) { - schedule_redraw(&taskbar->area); - if (taskbarname_enabled) { - schedule_redraw(&taskbar->bar_name.area); - } - if (taskbar_mode == MULTI_DESKTOP && - panels[0].g_taskbar.background[TASKBAR_NORMAL] != panels[0].g_taskbar.background[TASKBAR_ACTIVE]) { - GList *l = taskbar->area.children; - if (taskbarname_enabled) - l = l->next; - for (; l; l = l->next) - schedule_redraw((Area *)l->data); - } - } - schedule_panel_redraw(); + if (taskbar->area.on_screen) { + schedule_redraw(&taskbar->area); + if (taskbarname_enabled) { + schedule_redraw(&taskbar->bar_name.area); + } + if (taskbar_mode == MULTI_DESKTOP && + panels[0].g_taskbar.background[TASKBAR_NORMAL] != panels[0].g_taskbar.background[TASKBAR_ACTIVE]) { + GList *l = taskbar->area.children; + if (taskbarname_enabled) + l = l->next; + for (; l; l = l->next) + schedule_redraw((Area *)l->data); + } + } + schedule_panel_redraw(); } #define NONTRIVIAL 2 gint compare_tasks_trivial(Task *a, Task *b, Taskbar *taskbar) { - if (a == b) - return 0; - if (taskbarname_enabled) { - if (a == taskbar->area.children->data) - return -1; - if (b == taskbar->area.children->data) - return 1; - } - return NONTRIVIAL; + if (a == b) + return 0; + if (taskbarname_enabled) { + if (a == taskbar->area.children->data) + return -1; + if (b == taskbar->area.children->data) + return 1; + } + return NONTRIVIAL; } gboolean contained_within(Task *a, Task *b) { - if ((a->win_x <= b->win_x) && (a->win_y <= b->win_y) && (a->win_x + a->win_w >= b->win_x + b->win_w) && - (a->win_y + a->win_h >= b->win_y + b->win_h)) { - return TRUE; - } - return FALSE; + if ((a->win_x <= b->win_x) && (a->win_y <= b->win_y) && (a->win_x + a->win_w >= b->win_x + b->win_w) && + (a->win_y + a->win_h >= b->win_y + b->win_h)) { + return TRUE; + } + return FALSE; } gint compare_task_centers(Task *a, Task *b, Taskbar *taskbar) { - int trivial = compare_tasks_trivial(a, b, taskbar); - if (trivial != NONTRIVIAL) - return trivial; + int trivial = compare_tasks_trivial(a, b, taskbar); + if (trivial != NONTRIVIAL) + return trivial; - // If a window has the same coordinates and size as the other, - // they are considered to be equal in the comparison. - if ((a->win_x == b->win_x) && (a->win_y == b->win_y) && (a->win_w == b->win_w) && (a->win_h == b->win_h)) { - return 0; - } + // If a window has the same coordinates and size as the other, + // they are considered to be equal in the comparison. + if ((a->win_x == b->win_x) && (a->win_y == b->win_y) && (a->win_w == b->win_w) && (a->win_h == b->win_h)) { + return 0; + } - // If a window is completely contained in another, - // then it is considered to come after (to the right/bottom) of the other. - if (contained_within(a, b)) - return -1; - if (contained_within(b, a)) - return 1; + // If a window is completely contained in another, + // then it is considered to come after (to the right/bottom) of the other. + if (contained_within(a, b)) + return -1; + if (contained_within(b, a)) + return 1; - // Compare centers - int a_horiz_c = a->win_x + a->win_w / 2; - int b_horiz_c = b->win_x + b->win_w / 2; - int a_vert_c = a->win_y + a->win_h / 2; - int b_vert_c = b->win_y + b->win_h / 2; - if (panel_horizontal) { - if (a_horiz_c != b_horiz_c) { - return a_horiz_c - b_horiz_c; - } - return a_vert_c - b_vert_c; - } else { - if (a_vert_c != b_vert_c) { - return a_vert_c - b_vert_c; - } - return a_horiz_c - b_horiz_c; - } + // Compare centers + int a_horiz_c = a->win_x + a->win_w / 2; + int b_horiz_c = b->win_x + b->win_w / 2; + int a_vert_c = a->win_y + a->win_h / 2; + int b_vert_c = b->win_y + b->win_h / 2; + if (panel_horizontal) { + if (a_horiz_c != b_horiz_c) { + return a_horiz_c - b_horiz_c; + } + return a_vert_c - b_vert_c; + } else { + if (a_vert_c != b_vert_c) { + return a_vert_c - b_vert_c; + } + return a_horiz_c - b_horiz_c; + } } gint compare_task_titles(Task *a, Task *b, Taskbar *taskbar) { - int trivial = compare_tasks_trivial(a, b, taskbar); - if (trivial != NONTRIVIAL) - return trivial; - return strnatcasecmp(a->title ? a->title : "", b->title ? b->title : ""); + int trivial = compare_tasks_trivial(a, b, taskbar); + if (trivial != NONTRIVIAL) + return trivial; + return strnatcasecmp(a->title ? a->title : "", b->title ? b->title : ""); } gint compare_tasks(Task *a, Task *b, Taskbar *taskbar) { - int trivial = compare_tasks_trivial(a, b, taskbar); - if (trivial != NONTRIVIAL) - return trivial; - if (taskbar_sort_method == TASKBAR_NOSORT) { - return 0; - } else if (taskbar_sort_method == TASKBAR_SORT_CENTER) { - return compare_task_centers(a, b, taskbar); - } else if (taskbar_sort_method == TASKBAR_SORT_TITLE) { - return compare_task_titles(a, b, taskbar); - } else if (taskbar_sort_method == TASKBAR_SORT_LRU) { - return compare_timespecs(&a->last_activation_time, &b->last_activation_time); - } else if (taskbar_sort_method == TASKBAR_SORT_MRU) { - return -compare_timespecs(&a->last_activation_time, &b->last_activation_time); - } - return 0; + int trivial = compare_tasks_trivial(a, b, taskbar); + if (trivial != NONTRIVIAL) + return trivial; + if (taskbar_sort_method == TASKBAR_NOSORT) { + return 0; + } else if (taskbar_sort_method == TASKBAR_SORT_CENTER) { + return compare_task_centers(a, b, taskbar); + } else if (taskbar_sort_method == TASKBAR_SORT_TITLE) { + return compare_task_titles(a, b, taskbar); + } else if (taskbar_sort_method == TASKBAR_SORT_LRU) { + return compare_timespecs(&a->last_activation_time, &b->last_activation_time); + } else if (taskbar_sort_method == TASKBAR_SORT_MRU) { + return -compare_timespecs(&a->last_activation_time, &b->last_activation_time); + } + return 0; } gboolean taskbar_needs_sort(Taskbar *taskbar) { - if (taskbar_sort_method == TASKBAR_NOSORT) - return FALSE; + if (taskbar_sort_method == TASKBAR_NOSORT) + return FALSE; - for (GList *i = taskbar->area.children, *j = i ? i->next : NULL; i && j; i = i->next, j = j->next) { - if (compare_tasks(i->data, j->data, taskbar) > 0) { - return TRUE; - } - } + for (GList *i = taskbar->area.children, *j = i ? i->next : NULL; i && j; i = i->next, j = j->next) { + if (compare_tasks(i->data, j->data, taskbar) > 0) { + return TRUE; + } + } - return FALSE; + return FALSE; } void sort_tasks(Taskbar *taskbar) { - if (!taskbar) - return; - if (!taskbar_needs_sort(taskbar)) - return; + if (!taskbar) + return; + if (!taskbar_needs_sort(taskbar)) + return; - taskbar->area.children = g_list_sort_with_data(taskbar->area.children, (GCompareDataFunc)compare_tasks, taskbar); - taskbar->area.resize_needed = TRUE; - schedule_panel_redraw(); - ((Panel *)taskbar->area.panel)->area.resize_needed = TRUE; + taskbar->area.children = g_list_sort_with_data(taskbar->area.children, (GCompareDataFunc)compare_tasks, taskbar); + taskbar->area.resize_needed = TRUE; + schedule_panel_redraw(); + ((Panel *)taskbar->area.panel)->area.resize_needed = TRUE; } void sort_taskbar_for_win(Window win) { - if (taskbar_sort_method == TASKBAR_NOSORT) - return; + if (taskbar_sort_method == TASKBAR_NOSORT) + return; - GPtrArray *task_buttons = get_task_buttons(win); - if (task_buttons) { - Task *task0 = g_ptr_array_index(task_buttons, 0); - if (task0) { - get_window_coordinates(win, &task0->win_x, &task0->win_y, &task0->win_w, &task0->win_h); - } - for (int i = 0; i < task_buttons->len; ++i) { - Task *task = g_ptr_array_index(task_buttons, i); - task->win_x = task0->win_x; - task->win_y = task0->win_y; - task->win_w = task0->win_w; - task->win_h = task0->win_h; - sort_tasks(task->area.parent); - } - } + GPtrArray *task_buttons = get_task_buttons(win); + if (task_buttons) { + Task *task0 = g_ptr_array_index(task_buttons, 0); + if (task0) { + get_window_coordinates(win, &task0->win_x, &task0->win_y, &task0->win_w, &task0->win_h); + } + for (int i = 0; i < task_buttons->len; ++i) { + Task *task = g_ptr_array_index(task_buttons, i); + task->win_x = task0->win_x; + task->win_y = task0->win_y; + task->win_w = task0->win_w; + task->win_h = task0->win_h; + sort_tasks(task->area.parent); + } + } } void update_minimized_icon_positions(void *p) { - Panel *panel = (Panel *)p; - for (int i = 0; i < panel->num_desktops; i++) { - Taskbar *taskbar = &panel->taskbar[i]; - if (!taskbar->area.on_screen) - continue; - for (GList *c = taskbar->area.children; c; c = c->next) { - Area *area = (Area *)c->data; - if (area->_on_change_layout) - area->_on_change_layout(area); - } - } + Panel *panel = (Panel *)p; + for (int i = 0; i < panel->num_desktops; i++) { + Taskbar *taskbar = &panel->taskbar[i]; + if (!taskbar->area.on_screen) + continue; + for (GList *c = taskbar->area.children; c; c = c->next) { + Area *area = (Area *)c->data; + if (area->_on_change_layout) + area->_on_change_layout(area); + } + } }
M src/taskbar/taskbar.hsrc/taskbar/taskbar.h

@@ -12,39 +12,39 @@ #include "task.h"

#include "taskbarname.h" typedef enum TaskbarState { - TASKBAR_NORMAL = 0, - TASKBAR_ACTIVE, - TASKBAR_STATE_COUNT, + TASKBAR_NORMAL = 0, + TASKBAR_ACTIVE, + TASKBAR_STATE_COUNT, } TaskbarState; typedef enum TaskbarSortMethod { - TASKBAR_NOSORT = 0, - TASKBAR_SORT_CENTER, - TASKBAR_SORT_TITLE, - TASKBAR_SORT_LRU, - TASKBAR_SORT_MRU, + TASKBAR_NOSORT = 0, + TASKBAR_SORT_CENTER, + TASKBAR_SORT_TITLE, + TASKBAR_SORT_LRU, + TASKBAR_SORT_MRU, } TaskbarSortMethod; typedef struct { - Area area; - gchar *name; - int posy; + Area area; + gchar *name; + int posy; } TaskbarName; typedef struct { - Area area; - int desktop; - TaskbarName bar_name; - int text_width; + Area area; + int desktop; + TaskbarName bar_name; + int text_width; } Taskbar; typedef struct GlobalTaskbar { - Area area; - Area area_name; - Background *background[TASKBAR_STATE_COUNT]; - Background *background_name[TASKBAR_STATE_COUNT]; - GList *gradient[TASKBAR_STATE_COUNT]; - GList *gradient_name[TASKBAR_STATE_COUNT]; + Area area; + Area area_name; + Background *background[TASKBAR_STATE_COUNT]; + Background *background_name[TASKBAR_STATE_COUNT]; + GList *gradient[TASKBAR_STATE_COUNT]; + GList *gradient_name[TASKBAR_STATE_COUNT]; } GlobalTaskbar; extern gboolean taskbar_enabled;
M src/taskbar/taskbarname.csrc/taskbar/taskbarname.c

@@ -41,176 +41,176 @@ int taskbarname_compute_desired_size(void *obj);

void default_taskbarname() { - taskbarname_enabled = FALSE; + taskbarname_enabled = FALSE; } void init_taskbarname_panel(void *p) { - if (!taskbarname_enabled) - return; + if (!taskbarname_enabled) + return; - Panel *panel = (Panel *)p; + Panel *panel = (Panel *)p; - taskbarname_init_fonts(); + taskbarname_init_fonts(); - GSList *list = get_desktop_names(); - GSList *l = list; - for (int j = 0; j < panel->num_desktops; j++) { - Taskbar *taskbar = &panel->taskbar[j]; - memcpy(&taskbar->bar_name.area, &panel->g_taskbar.area_name, sizeof(Area)); - taskbar->bar_name.area.parent = taskbar; - taskbar->bar_name.area.has_mouse_over_effect = panel_config.mouse_effects; - taskbar->bar_name.area.has_mouse_press_effect = panel_config.mouse_effects; - taskbar->bar_name.area._compute_desired_size = taskbarname_compute_desired_size; - if (j == server.desktop) { - taskbar->bar_name.area.bg = panel->g_taskbar.background_name[TASKBAR_ACTIVE]; - } else { - taskbar->bar_name.area.bg = panel->g_taskbar.background_name[TASKBAR_NORMAL]; - } + GSList *list = get_desktop_names(); + GSList *l = list; + for (int j = 0; j < panel->num_desktops; j++) { + Taskbar *taskbar = &panel->taskbar[j]; + memcpy(&taskbar->bar_name.area, &panel->g_taskbar.area_name, sizeof(Area)); + taskbar->bar_name.area.parent = taskbar; + taskbar->bar_name.area.has_mouse_over_effect = panel_config.mouse_effects; + taskbar->bar_name.area.has_mouse_press_effect = panel_config.mouse_effects; + taskbar->bar_name.area._compute_desired_size = taskbarname_compute_desired_size; + if (j == server.desktop) { + taskbar->bar_name.area.bg = panel->g_taskbar.background_name[TASKBAR_ACTIVE]; + } else { + taskbar->bar_name.area.bg = panel->g_taskbar.background_name[TASKBAR_NORMAL]; + } - // use desktop number if name is missing - if (l) { - taskbar->bar_name.name = g_strdup(l->data); - l = l->next; - } else { - taskbar->bar_name.name = g_strdup_printf("%d", j + 1); - } + // use desktop number if name is missing + if (l) { + taskbar->bar_name.name = g_strdup(l->data); + l = l->next; + } else { + taskbar->bar_name.name = g_strdup_printf("%d", j + 1); + } - // append the name at the beginning of taskbar - taskbar->area.children = g_list_append(taskbar->area.children, &taskbar->bar_name); - instantiate_area_gradients(&taskbar->bar_name.area); - } + // append the name at the beginning of taskbar + taskbar->area.children = g_list_append(taskbar->area.children, &taskbar->bar_name); + instantiate_area_gradients(&taskbar->bar_name.area); + } - for (l = list; l; l = l->next) - g_free(l->data); - g_slist_free(list); + for (l = list; l; l = l->next) + g_free(l->data); + g_slist_free(list); } void taskbarname_init_fonts() { - if (!panel_config.taskbarname_font_desc) { - panel_config.taskbarname_font_desc = pango_font_description_from_string(get_default_font()); - pango_font_description_set_weight(panel_config.taskbarname_font_desc, PANGO_WEIGHT_BOLD); - } + if (!panel_config.taskbarname_font_desc) { + panel_config.taskbarname_font_desc = pango_font_description_from_string(get_default_font()); + pango_font_description_set_weight(panel_config.taskbarname_font_desc, PANGO_WEIGHT_BOLD); + } } void taskbarname_default_font_changed() { - if (!taskbar_enabled) - return; - if (!taskbarname_enabled) - return; - if (panel_config.taskbarname_has_font) - return; + if (!taskbar_enabled) + return; + if (!taskbarname_enabled) + return; + if (panel_config.taskbarname_has_font) + return; - pango_font_description_free(panel_config.taskbarname_font_desc); - panel_config.taskbarname_font_desc = NULL; - taskbarname_init_fonts(); - for (int i = 0; i < num_panels; i++) { - for (int j = 0; j < panels[i].num_desktops; j++) { - Taskbar *taskbar = &panels[i].taskbar[j]; - taskbar->bar_name.area.resize_needed = TRUE; - schedule_redraw(&taskbar->bar_name.area); - } - } - schedule_panel_redraw(); + pango_font_description_free(panel_config.taskbarname_font_desc); + panel_config.taskbarname_font_desc = NULL; + taskbarname_init_fonts(); + for (int i = 0; i < num_panels; i++) { + for (int j = 0; j < panels[i].num_desktops; j++) { + Taskbar *taskbar = &panels[i].taskbar[j]; + taskbar->bar_name.area.resize_needed = TRUE; + schedule_redraw(&taskbar->bar_name.area); + } + } + schedule_panel_redraw(); } void cleanup_taskbarname() { - for (int i = 0; i < num_panels; i++) { - Panel *panel = &panels[i]; - for (int j = 0; j < panel->num_desktops; j++) { - Taskbar *taskbar = &panel->taskbar[j]; - g_free(taskbar->bar_name.name); - taskbar->bar_name.name = NULL; - free_area(&taskbar->bar_name.area); - remove_area((Area *)&taskbar->bar_name); - } - } + for (int i = 0; i < num_panels; i++) { + Panel *panel = &panels[i]; + for (int j = 0; j < panel->num_desktops; j++) { + Taskbar *taskbar = &panel->taskbar[j]; + g_free(taskbar->bar_name.name); + taskbar->bar_name.name = NULL; + free_area(&taskbar->bar_name.area); + remove_area((Area *)&taskbar->bar_name); + } + } } int taskbarname_compute_desired_size(void *obj) { - TaskbarName *taskbar_name = (TaskbarName *)obj; - Panel *panel = (Panel *)taskbar_name->area.panel; - int name_height, name_width, name_height_ink; - get_text_size2(panel_config.taskbarname_font_desc, - &name_height_ink, - &name_height, - &name_width, - panel->area.height, - panel->area.width, - taskbar_name->name, - strlen(taskbar_name->name), - PANGO_WRAP_WORD_CHAR, - PANGO_ELLIPSIZE_NONE, - FALSE); + TaskbarName *taskbar_name = (TaskbarName *)obj; + Panel *panel = (Panel *)taskbar_name->area.panel; + int name_height, name_width, name_height_ink; + get_text_size2(panel_config.taskbarname_font_desc, + &name_height_ink, + &name_height, + &name_width, + panel->area.height, + panel->area.width, + taskbar_name->name, + strlen(taskbar_name->name), + PANGO_WRAP_WORD_CHAR, + PANGO_ELLIPSIZE_NONE, + FALSE); - if (panel_horizontal) { - return name_width + 2 * taskbar_name->area.paddingxlr + left_right_border_width(&taskbar_name->area); - } else { - return name_height + 2 * taskbar_name->area.paddingxlr + top_bottom_border_width(&taskbar_name->area); - } + if (panel_horizontal) { + return name_width + 2 * taskbar_name->area.paddingxlr + left_right_border_width(&taskbar_name->area); + } else { + return name_height + 2 * taskbar_name->area.paddingxlr + top_bottom_border_width(&taskbar_name->area); + } } gboolean resize_taskbarname(void *obj) { - TaskbarName *taskbar_name = (TaskbarName *)obj; - Panel *panel = (Panel *)taskbar_name->area.panel; + TaskbarName *taskbar_name = (TaskbarName *)obj; + Panel *panel = (Panel *)taskbar_name->area.panel; - schedule_redraw(&taskbar_name->area); + schedule_redraw(&taskbar_name->area); - int name_height, name_width, name_height_ink; - get_text_size2(panel_config.taskbarname_font_desc, - &name_height_ink, - &name_height, - &name_width, - panel->area.height, - panel->area.width, - taskbar_name->name, - strlen(taskbar_name->name), - PANGO_WRAP_WORD_CHAR, - PANGO_ELLIPSIZE_NONE, - FALSE); + int name_height, name_width, name_height_ink; + get_text_size2(panel_config.taskbarname_font_desc, + &name_height_ink, + &name_height, + &name_width, + panel->area.height, + panel->area.width, + taskbar_name->name, + strlen(taskbar_name->name), + PANGO_WRAP_WORD_CHAR, + PANGO_ELLIPSIZE_NONE, + FALSE); - gboolean result = FALSE; - int new_size = taskbarname_compute_desired_size(obj); - if (panel_horizontal) { - if (new_size != taskbar_name->area.width) { - taskbar_name->area.width = new_size; - taskbar_name->posy = (taskbar_name->area.height - name_height) / 2; - result = TRUE; - } - } else { - if (new_size != taskbar_name->area.height) { - taskbar_name->area.height = new_size; - taskbar_name->posy = (taskbar_name->area.height - name_height) / 2; - result = TRUE; - } - } - return result; + gboolean result = FALSE; + int new_size = taskbarname_compute_desired_size(obj); + if (panel_horizontal) { + if (new_size != taskbar_name->area.width) { + taskbar_name->area.width = new_size; + taskbar_name->posy = (taskbar_name->area.height - name_height) / 2; + result = TRUE; + } + } else { + if (new_size != taskbar_name->area.height) { + taskbar_name->area.height = new_size; + taskbar_name->posy = (taskbar_name->area.height - name_height) / 2; + result = TRUE; + } + } + return result; } void draw_taskbarname(void *obj, cairo_t *c) { - TaskbarName *taskbar_name = obj; - Taskbar *taskbar = taskbar_name->area.parent; - Color *config_text = (taskbar->desktop == server.desktop) ? &taskbarname_active_font : &taskbarname_font; + TaskbarName *taskbar_name = obj; + Taskbar *taskbar = taskbar_name->area.parent; + Color *config_text = (taskbar->desktop == server.desktop) ? &taskbarname_active_font : &taskbarname_font; - // draw content - PangoLayout *layout = pango_cairo_create_layout(c); - pango_layout_set_font_description(layout, panel_config.taskbarname_font_desc); - pango_layout_set_width(layout, taskbar_name->area.width * PANGO_SCALE); - pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER); - pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR); - pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_NONE); - pango_layout_set_text(layout, taskbar_name->name, strlen(taskbar_name->name)); + // draw content + PangoLayout *layout = pango_cairo_create_layout(c); + pango_layout_set_font_description(layout, panel_config.taskbarname_font_desc); + pango_layout_set_width(layout, taskbar_name->area.width * PANGO_SCALE); + pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER); + pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR); + pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_NONE); + pango_layout_set_text(layout, taskbar_name->name, strlen(taskbar_name->name)); - cairo_set_source_rgba(c, config_text->rgb[0], config_text->rgb[1], config_text->rgb[2], config_text->alpha); + cairo_set_source_rgba(c, config_text->rgb[0], config_text->rgb[1], config_text->rgb[2], config_text->alpha); - pango_cairo_update_layout(c, layout); - draw_text(layout, c, 0, taskbar_name->posy, config_text, ((Panel *)taskbar_name->area.panel)->font_shadow); + pango_cairo_update_layout(c, layout); + draw_text(layout, c, 0, taskbar_name->posy, config_text, ((Panel *)taskbar_name->area.panel)->font_shadow); - g_object_unref(layout); + g_object_unref(layout); }
M src/tint.csrc/tint.c

@@ -86,247 +86,247 @@ int frame = 0;

void create_fps_distribution() { - // measure FPS with resolution: - // 0-59: 1 (60 samples) - // 60-199: 10 (14) - // 200-1,999: 25 (72) - // 1k-19,999: 1000 (19) - // 20x+: inf (1) - // => 166 samples - if (fps_distribution) - return; - fps_distribution = calloc(170, sizeof(float)); + // measure FPS with resolution: + // 0-59: 1 (60 samples) + // 60-199: 10 (14) + // 200-1,999: 25 (72) + // 1k-19,999: 1000 (19) + // 20x+: inf (1) + // => 166 samples + if (fps_distribution) + return; + fps_distribution = calloc(170, sizeof(float)); } void cleanup_fps_distribution() { - free(fps_distribution); - fps_distribution = NULL; + free(fps_distribution); + fps_distribution = NULL; } void sample_fps(double fps) { - int fps_rounded = (int)(fps + 0.5); - int i = 1; - if (fps_rounded < 60) { - i += fps_rounded; - } else { - i += 60; - if (fps_rounded < 200) { - i += (fps_rounded - 60) / 10; - } else { - i += 14; - if (fps_rounded < 2000) { - i += (fps_rounded - 200) / 25; - } else { - i += 72; - if (fps_rounded < 20000) { - i += (fps_rounded - 2000) / 1000; - } else { - i += 20; - } - } - } - } - // fprintf(stderr, "fps = %.0f => i = %d\n", fps, i); - fps_distribution[i] += 1.; - fps_distribution[0] += 1.; + int fps_rounded = (int)(fps + 0.5); + int i = 1; + if (fps_rounded < 60) { + i += fps_rounded; + } else { + i += 60; + if (fps_rounded < 200) { + i += (fps_rounded - 60) / 10; + } else { + i += 14; + if (fps_rounded < 2000) { + i += (fps_rounded - 200) / 25; + } else { + i += 72; + if (fps_rounded < 20000) { + i += (fps_rounded - 2000) / 1000; + } else { + i += 20; + } + } + } + } + // fprintf(stderr, "fps = %.0f => i = %d\n", fps, i); + fps_distribution[i] += 1.; + fps_distribution[0] += 1.; } void fps_compute_stats(double *low, double *median, double *high, double *samples) { - *median = *low = *high = *samples = -1; - if (!fps_distribution || fps_distribution[0] < 1) - return; - float total = fps_distribution[0]; - *samples = (double) fps_distribution[0]; - float cum_low = 0.05f * total; - float cum_median = 0.5f * total; - float cum_high = 0.95f * total; - float cum = 0; - for (int i = 1; i <= 166; i++) { - double value = - (i < 60) ? i : (i < 74) ? (60 + (i - 60) * 10) : (i < 146) ? (200 + (i - 74) * 25) - : (i < 165) ? (2000 + (i - 146) * 1000) : 20000; - // fprintf(stderr, "%6.0f (i = %3d) : %.0f | ", value, i, (double)fps_distribution[i]); - cum += fps_distribution[i]; - if (*low < 0 && cum >= cum_low) - *low = value; - if (*median < 0 && cum >= cum_median) - *median = value; - if (*high < 0 && cum >= cum_high) - *high = value; - } + *median = *low = *high = *samples = -1; + if (!fps_distribution || fps_distribution[0] < 1) + return; + float total = fps_distribution[0]; + *samples = (double)fps_distribution[0]; + float cum_low = 0.05f * total; + float cum_median = 0.5f * total; + float cum_high = 0.95f * total; + float cum = 0; + for (int i = 1; i <= 166; i++) { + double value = + (i < 60) ? i : (i < 74) ? (60 + (i - 60) * 10) : (i < 146) ? (200 + (i - 74) * 25) + : (i < 165) ? (2000 + (i - 146) * 1000) : 20000; + // fprintf(stderr, "%6.0f (i = %3d) : %.0f | ", value, i, (double)fps_distribution[i]); + cum += fps_distribution[i]; + if (*low < 0 && cum >= cum_low) + *low = value; + if (*median < 0 && cum >= cum_median) + *median = value; + if (*high < 0 && cum >= cum_high) + *high = value; + } } void detect_compositor(void *arg) { - if (server.composite_manager) { - stop_timeout(detect_compositor_timer); - return; - } + if (server.composite_manager) { + stop_timeout(detect_compositor_timer); + return; + } - detect_compositor_timer_counter--; - if (detect_compositor_timer_counter < 0) { - stop_timeout(detect_compositor_timer); - return; - } + detect_compositor_timer_counter--; + if (detect_compositor_timer_counter < 0) { + stop_timeout(detect_compositor_timer); + return; + } - // No compositor, check for one - if (XGetSelectionOwner(server.display, server.atom._NET_WM_CM_S0) != None) { - stop_timeout(detect_compositor_timer); - // Restart tint2 - fprintf(stderr, "Detected compositor, restarting tint2...\n"); - kill(getpid(), SIGUSR1); - } + // No compositor, check for one + if (XGetSelectionOwner(server.display, server.atom._NET_WM_CM_S0) != None) { + stop_timeout(detect_compositor_timer); + // Restart tint2 + fprintf(stderr, "Detected compositor, restarting tint2...\n"); + kill(getpid(), SIGUSR1); + } } void start_detect_compositor() { - // Already have a compositor, nothing to do - if (server.composite_manager) - return; + // Already have a compositor, nothing to do + if (server.composite_manager) + return; - stop_timeout(detect_compositor_timer); - // Check every 0.5 seconds for up to 30 seconds - detect_compositor_timer_counter = 60; - detect_compositor_timer = add_timeout(500, 500, detect_compositor, 0, &detect_compositor_timer); + stop_timeout(detect_compositor_timer); + // Check every 0.5 seconds for up to 30 seconds + detect_compositor_timer_counter = 60; + detect_compositor_timer = add_timeout(500, 500, detect_compositor, 0, &detect_compositor_timer); } void signal_handler(int sig) { - // signal handler is light as it should be - signal_pending = sig; + // signal handler is light as it should be + signal_pending = sig; } void write_string(int fd, const char *s) { - int len = strlen(s); - while (len > 0) { - int count = write(fd, s, len); - if (count >= 0) { - s += count; - len -= count; - } else { - break; - } - } + int len = strlen(s); + while (len > 0) { + int count = write(fd, s, len); + if (count >= 0) { + s += count; + len -= count; + } else { + break; + } + } } const char *signal_name(int sig) { - switch (sig) { - case SIGHUP: - return "SIGHUP: Hangup (POSIX)."; - case SIGINT: - return "SIGINT: Interrupt (ANSI)."; - case SIGQUIT: - return "SIGQUIT: Quit (POSIX)."; - case SIGILL: - return "SIGILL: Illegal instruction (ANSI)."; - case SIGTRAP: - return "SIGTRAP: Trace trap (POSIX)."; - case SIGABRT: - return "SIGABRT/SIGIOT: Abort (ANSI) / IOT trap (4.2 BSD)."; - case SIGBUS: - return "SIGBUS: BUS error (4.2 BSD)."; - case SIGFPE: - return "SIGFPE: Floating-point exception (ANSI)."; - case SIGKILL: - return "SIGKILL: Kill, unblockable (POSIX)."; - case SIGUSR1: - return "SIGUSR1: User-defined signal 1 (POSIX)."; - case SIGSEGV: - return "SIGSEGV: Segmentation violation (ANSI)."; - case SIGUSR2: - return "SIGUSR2: User-defined signal 2 (POSIX)."; - case SIGPIPE: - return "SIGPIPE: Broken pipe (POSIX)."; - case SIGALRM: - return "SIGALRM: Alarm clock (POSIX)."; - case SIGTERM: - return "SIGTERM: Termination (ANSI)."; - // case SIGSTKFLT: return "SIGSTKFLT: Stack fault."; - case SIGCHLD: - return "SIGCHLD: Child status has changed (POSIX)."; - case SIGCONT: - return "SIGCONT: Continue (POSIX)."; - case SIGSTOP: - return "SIGSTOP: Stop, unblockable (POSIX)."; - case SIGTSTP: - return "SIGTSTP: Keyboard stop (POSIX)."; - case SIGTTIN: - return "SIGTTIN: Background read from tty (POSIX)."; - case SIGTTOU: - return "SIGTTOU: Background write to tty (POSIX)."; - case SIGURG: - return "SIGURG: Urgent condition on socket (4.2 BSD)."; - case SIGXCPU: - return "SIGXCPU: CPU limit exceeded (4.2 BSD)."; - case SIGXFSZ: - return "SIGXFSZ: File size limit exceeded (4.2 BSD)."; - case SIGVTALRM: - return "SIGVTALRM: Virtual alarm clock (4.2 BSD)."; - case SIGPROF: - return "SIGPROF: Profiling alarm clock (4.2 BSD)."; - // case SIGPWR: return "SIGPWR: Power failure restart (System V)."; - case SIGSYS: - return "SIGSYS: Bad system call."; - } - static char s[64]; - sprintf(s, "SIG=%d: Unknown", sig); - return s; + switch (sig) { + case SIGHUP: + return "SIGHUP: Hangup (POSIX)."; + case SIGINT: + return "SIGINT: Interrupt (ANSI)."; + case SIGQUIT: + return "SIGQUIT: Quit (POSIX)."; + case SIGILL: + return "SIGILL: Illegal instruction (ANSI)."; + case SIGTRAP: + return "SIGTRAP: Trace trap (POSIX)."; + case SIGABRT: + return "SIGABRT/SIGIOT: Abort (ANSI) / IOT trap (4.2 BSD)."; + case SIGBUS: + return "SIGBUS: BUS error (4.2 BSD)."; + case SIGFPE: + return "SIGFPE: Floating-point exception (ANSI)."; + case SIGKILL: + return "SIGKILL: Kill, unblockable (POSIX)."; + case SIGUSR1: + return "SIGUSR1: User-defined signal 1 (POSIX)."; + case SIGSEGV: + return "SIGSEGV: Segmentation violation (ANSI)."; + case SIGUSR2: + return "SIGUSR2: User-defined signal 2 (POSIX)."; + case SIGPIPE: + return "SIGPIPE: Broken pipe (POSIX)."; + case SIGALRM: + return "SIGALRM: Alarm clock (POSIX)."; + case SIGTERM: + return "SIGTERM: Termination (ANSI)."; + // case SIGSTKFLT: return "SIGSTKFLT: Stack fault."; + case SIGCHLD: + return "SIGCHLD: Child status has changed (POSIX)."; + case SIGCONT: + return "SIGCONT: Continue (POSIX)."; + case SIGSTOP: + return "SIGSTOP: Stop, unblockable (POSIX)."; + case SIGTSTP: + return "SIGTSTP: Keyboard stop (POSIX)."; + case SIGTTIN: + return "SIGTTIN: Background read from tty (POSIX)."; + case SIGTTOU: + return "SIGTTOU: Background write to tty (POSIX)."; + case SIGURG: + return "SIGURG: Urgent condition on socket (4.2 BSD)."; + case SIGXCPU: + return "SIGXCPU: CPU limit exceeded (4.2 BSD)."; + case SIGXFSZ: + return "SIGXFSZ: File size limit exceeded (4.2 BSD)."; + case SIGVTALRM: + return "SIGVTALRM: Virtual alarm clock (4.2 BSD)."; + case SIGPROF: + return "SIGPROF: Profiling alarm clock (4.2 BSD)."; + // case SIGPWR: return "SIGPWR: Power failure restart (System V)."; + case SIGSYS: + return "SIGSYS: Bad system call."; + } + static char s[64]; + sprintf(s, "SIG=%d: Unknown", sig); + return s; } void log_string(int fd, const char *s) { - write_string(2, s); - write_string(fd, s); + write_string(2, s); + write_string(fd, s); } const char *get_home_dir() { - const char *s = getenv("HOME"); - if (s) - return s; - struct passwd *pw = getpwuid(getuid()); - if (!pw) - return NULL; - return pw->pw_dir; + const char *s = getenv("HOME"); + if (s) + return s; + struct passwd *pw = getpwuid(getuid()); + if (!pw) + return NULL; + return pw->pw_dir; } void dump_backtrace(int log_fd) { #ifndef DISABLE_BACKTRACE - log_string(log_fd, "\n" YELLOW "Backtrace:" RESET "\n"); + log_string(log_fd, "\n" YELLOW "Backtrace:" RESET "\n"); #ifdef ENABLE_LIBUNWIND - unw_cursor_t cursor; - unw_context_t context; - unw_getcontext(&context); - unw_init_local(&cursor, &context); + unw_cursor_t cursor; + unw_context_t context; + unw_getcontext(&context); + unw_init_local(&cursor, &context); - while (unw_step(&cursor) > 0) { - unw_word_t offset; - char fname[128]; - fname[0] = '\0'; - (void)unw_get_proc_name(&cursor, fname, sizeof(fname), &offset); - log_string(log_fd, fname); - log_string(log_fd, "\n"); - } + while (unw_step(&cursor) > 0) { + unw_word_t offset; + char fname[128]; + fname[0] = '\0'; + (void)unw_get_proc_name(&cursor, fname, sizeof(fname), &offset); + log_string(log_fd, fname); + log_string(log_fd, "\n"); + } #else #ifdef ENABLE_EXECINFO #define MAX_TRACE_SIZE 128 - void *array[MAX_TRACE_SIZE]; - size_t size = backtrace(array, MAX_TRACE_SIZE); - char **strings = backtrace_symbols(array, size); + void *array[MAX_TRACE_SIZE]; + size_t size = backtrace(array, MAX_TRACE_SIZE); + char **strings = backtrace_symbols(array, size); - for (size_t i = 0; i < size; i++) { - log_string(log_fd, strings[i]); - log_string(log_fd, "\n"); - } + for (size_t i = 0; i < size; i++) { + log_string(log_fd, strings[i]); + log_string(log_fd, "\n"); + } - free(strings); + free(strings); #endif // ENABLE_EXECINFO #endif // ENABLE_LIBUNWIND #endif // DISABLE_BACKTRACE

@@ -335,155 +335,154 @@

// sleep() returns early when signals arrive. This function does not. void safe_sleep(int seconds) { - double t0 = get_time(); - while (1) { - double t = get_time(); - if (t > t0 + seconds) - return; - sleep(1); - } + double t0 = get_time(); + while (1) { + double t = get_time(); + if (t > t0 + seconds) + return; + sleep(1); + } } void handle_crash(const char *reason) { #ifndef DISABLE_BACKTRACE - char path[4096]; - sprintf(path, "%s/.tint2-crash.log", get_home_dir()); - int log_fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0600); - log_string(log_fd, RED "tint2 crashed, reason: "); - log_string(log_fd, reason); - log_string(log_fd, RESET "\n"); - dump_backtrace(log_fd); - log_string(log_fd, RED "Please create a bug report with this log output." RESET "\n"); - close(log_fd); + char path[4096]; + sprintf(path, "%s/.tint2-crash.log", get_home_dir()); + int log_fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0600); + log_string(log_fd, RED "tint2 crashed, reason: "); + log_string(log_fd, reason); + log_string(log_fd, RESET "\n"); + dump_backtrace(log_fd); + log_string(log_fd, RED "Please create a bug report with this log output." RESET "\n"); + close(log_fd); #endif } #ifdef BACKTRACE_ON_SIGNAL void crash_handler(int sig) { - handle_crash(signal_name(sig)); - struct sigaction sa = {.sa_handler = SIG_DFL}; - sigaction(sig, &sa, 0); - raise(sig); + handle_crash(signal_name(sig)); + struct sigaction sa = {.sa_handler = SIG_DFL}; + sigaction(sig, &sa, 0); + raise(sig); } #endif void x11_io_error(Display *display) { - handle_crash("X11 I/O error"); + handle_crash("X11 I/O error"); } void print_usage() { - printf("Usage: tint2 [OPTION...]\n" - "\n" - "Options:\n" - " -c path_to_config_file Loads the configuration file from a\n" - " custom location.\n" - " -v, --version Prints version information and exits.\n" - " -h, --help Display this help and exits.\n" - "\n" - "For more information, run `man tint2` or visit the project page\n" - "<https://gitlab.com/o9000/tint2>.\n"); + printf("Usage: tint2 [OPTION...]\n" + "\n" + "Options:\n" + " -c path_to_config_file Loads the configuration file from a\n" + " custom location.\n" + " -v, --version Prints version information and exits.\n" + " -h, --help Display this help and exits.\n" + "\n" + "For more information, run `man tint2` or visit the project page\n" + "<https://gitlab.com/o9000/tint2>.\n"); } void init(int argc, char *argv[]) { - // Make stdout/stderr flush after a newline (for some reason they don't even if tint2 is started from a terminal) - setlinebuf(stdout); - setlinebuf(stderr); + // Make stdout/stderr flush after a newline (for some reason they don't even if tint2 is started from a terminal) + setlinebuf(stdout); + setlinebuf(stderr); - // set global data - default_config(); - default_timeout(); - default_systray(); - memset(&server, 0, sizeof(server)); + // set global data + default_config(); + default_timeout(); + default_systray(); + memset(&server, 0, sizeof(server)); #ifdef ENABLE_BATTERY - default_battery(); + default_battery(); #endif - default_clock(); - default_launcher(); - default_taskbar(); - default_tooltip(); - default_execp(); - default_button(); - default_panel(); + default_clock(); + default_launcher(); + default_taskbar(); + default_tooltip(); + default_execp(); + default_button(); + default_panel(); - // Read command line arguments - for (int i = 1; i < argc; ++i) { - int error = 0; - if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) { - print_usage(); - exit(0); - } else if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--version") == 0) { - printf("tint2 version %s\n", VERSION_STRING); - exit(0); - } else if (strcmp(argv[i], "-c") == 0) { - if (i + 1 < argc) { - i++; - config_path = strdup(argv[i]); - } else { - error = 1; - } - } else if (strcmp(argv[i], "-s") == 0) { - if (i + 1 < argc) { - i++; - snapshot_path = strdup(argv[i]); - } else { - error = 1; - } - } else if (i + 1 == argc) { - config_path = strdup(argv[i]); - } + // Read command line arguments + for (int i = 1; i < argc; ++i) { + int error = 0; + if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) { + print_usage(); + exit(0); + } else if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--version") == 0) { + printf("tint2 version %s\n", VERSION_STRING); + exit(0); + } else if (strcmp(argv[i], "-c") == 0) { + if (i + 1 < argc) { + i++; + config_path = strdup(argv[i]); + } else { + error = 1; + } + } else if (strcmp(argv[i], "-s") == 0) { + if (i + 1 < argc) { + i++; + snapshot_path = strdup(argv[i]); + } else { + error = 1; + } + } else if (i + 1 == argc) { + config_path = strdup(argv[i]); + } #ifdef ENABLE_BATTERY - else if (strcmp(argv[i], "--battery-sys-prefix") == 0) { - if (i + 1 < argc) { - i++; - battery_sys_prefix = strdup(argv[i]); - } else { - error = 1; - } - } + else if (strcmp(argv[i], "--battery-sys-prefix") == 0) { + if (i + 1 < argc) { + i++; + battery_sys_prefix = strdup(argv[i]); + } else { + error = 1; + } + } #endif - - else { - error = 1; - } - if (error) { - print_usage(); - exit(1); - } - } - // Set signal handlers - signal_pending = 0; + else { + error = 1; + } + if (error) { + print_usage(); + exit(1); + } + } + // Set signal handlers + signal_pending = 0; - struct sigaction sa_chld = {.sa_handler = SIG_DFL, .sa_flags = SA_NOCLDWAIT | SA_RESTART}; - sigaction(SIGCHLD, &sa_chld, 0); + struct sigaction sa_chld = {.sa_handler = SIG_DFL, .sa_flags = SA_NOCLDWAIT | SA_RESTART}; + sigaction(SIGCHLD, &sa_chld, 0); - struct sigaction sa = {.sa_handler = signal_handler, .sa_flags = SA_RESTART}; - sigaction(SIGUSR1, &sa, 0); - sigaction(SIGINT, &sa, 0); - sigaction(SIGTERM, &sa, 0); - sigaction(SIGHUP, &sa, 0); + struct sigaction sa = {.sa_handler = signal_handler, .sa_flags = SA_RESTART}; + sigaction(SIGUSR1, &sa, 0); + sigaction(SIGINT, &sa, 0); + sigaction(SIGTERM, &sa, 0); + sigaction(SIGHUP, &sa, 0); #ifdef BACKTRACE_ON_SIGNAL - struct sigaction sa_crash = {.sa_handler = crash_handler}; - sigaction(SIGSEGV, &sa_crash, 0); - sigaction(SIGFPE, &sa_crash, 0); - sigaction(SIGPIPE, &sa_crash, 0); - sigaction(SIGBUS, &sa_crash, 0); - sigaction(SIGABRT, &sa_crash, 0); - sigaction(SIGSYS, &sa_crash, 0); + struct sigaction sa_crash = {.sa_handler = crash_handler}; + sigaction(SIGSEGV, &sa_crash, 0); + sigaction(SIGFPE, &sa_crash, 0); + sigaction(SIGPIPE, &sa_crash, 0); + sigaction(SIGBUS, &sa_crash, 0); + sigaction(SIGABRT, &sa_crash, 0); + sigaction(SIGSYS, &sa_crash, 0); #endif - debug_geometry = getenv("DEBUG_GEOMETRY") != NULL; - debug_gradients = getenv("DEBUG_GRADIENTS") != NULL; - debug_fps = getenv("DEBUG_FPS") != NULL; - debug_frames = getenv("DEBUG_FRAMES") != NULL; - if (debug_fps) - create_fps_distribution(); + debug_geometry = getenv("DEBUG_GEOMETRY") != NULL; + debug_gradients = getenv("DEBUG_GRADIENTS") != NULL; + debug_fps = getenv("DEBUG_FPS") != NULL; + debug_frames = getenv("DEBUG_FRAMES") != NULL; + if (debug_fps) + create_fps_distribution(); } static int sigchild_pipe_valid = FALSE;

@@ -494,990 +493,990 @@ static int error_trap_depth = 0;

static void error_trap_push(SnDisplay *display, Display *xdisplay) { - ++error_trap_depth; + ++error_trap_depth; } static void error_trap_pop(SnDisplay *display, Display *xdisplay) { - if (error_trap_depth == 0) { - fprintf(stderr, "Error trap underflow!\n"); - return; - } + if (error_trap_depth == 0) { + fprintf(stderr, "Error trap underflow!\n"); + return; + } - XSync(xdisplay, False); /* get all errors out of the queue */ - --error_trap_depth; + XSync(xdisplay, False); /* get all errors out of the queue */ + --error_trap_depth; } #endif // HAVE_SN static void sigchld_handler(int sig) { - if (!sigchild_pipe_valid) - return; - int savedErrno = errno; - ssize_t unused = write(sigchild_pipe[1], "x", 1); - (void)unused; - fsync(sigchild_pipe[1]); - errno = savedErrno; + if (!sigchild_pipe_valid) + return; + int savedErrno = errno; + ssize_t unused = write(sigchild_pipe[1], "x", 1); + (void)unused; + fsync(sigchild_pipe[1]); + errno = savedErrno; } static void sigchld_handler_async() { - // Wait for all dead processes - pid_t pid; - int status; - while ((pid = waitpid(-1, &status, WNOHANG)) != -1 && pid != 0) { + // Wait for all dead processes + pid_t pid; + int status; + while ((pid = waitpid(-1, &status, WNOHANG)) != -1 && pid != 0) { #ifdef HAVE_SN - if (startup_notifications) { - SnLauncherContext *ctx = (SnLauncherContext *)g_tree_lookup(server.pids, GINT_TO_POINTER(pid)); - if (ctx) { - g_tree_remove(server.pids, GINT_TO_POINTER(pid)); - sn_launcher_context_complete(ctx); - sn_launcher_context_unref(ctx); - } - } + if (startup_notifications) { + SnLauncherContext *ctx = (SnLauncherContext *)g_tree_lookup(server.pids, GINT_TO_POINTER(pid)); + if (ctx) { + g_tree_remove(server.pids, GINT_TO_POINTER(pid)); + sn_launcher_context_complete(ctx); + sn_launcher_context_unref(ctx); + } + } #endif - for (GList *l = panel_config.execp_list; l; l = l->next) { - Execp *execp = (Execp *)l->data; - if (g_tree_lookup(execp->backend->cmd_pids, GINT_TO_POINTER(pid))) - execp_cmd_completed(execp, pid); - } - } + for (GList *l = panel_config.execp_list; l; l = l->next) { + Execp *execp = (Execp *)l->data; + if (g_tree_lookup(execp->backend->cmd_pids, GINT_TO_POINTER(pid))) + execp_cmd_completed(execp, pid); + } + } } void init_X11_pre_config() { - server.display = XOpenDisplay(NULL); - if (!server.display) { - fprintf(stderr, "tint2: could not open display.\n"); - exit(1); - } - XSetErrorHandler((XErrorHandler)server_catch_error); - XSetIOErrorHandler((XIOErrorHandler)x11_io_error); - server_init_atoms(); - server.screen = DefaultScreen(server.display); - server.root_win = RootWindow(server.display, server.screen); - server.desktop = get_current_desktop(); + server.display = XOpenDisplay(NULL); + if (!server.display) { + fprintf(stderr, "tint2: could not open display.\n"); + exit(1); + } + XSetErrorHandler((XErrorHandler)server_catch_error); + XSetIOErrorHandler((XIOErrorHandler)x11_io_error); + server_init_atoms(); + server.screen = DefaultScreen(server.display); + server.root_win = RootWindow(server.display, server.screen); + server.desktop = get_current_desktop(); - setlocale(LC_ALL, ""); - // config file use '.' as decimal separator - setlocale(LC_NUMERIC, "POSIX"); + setlocale(LC_ALL, ""); + // config file use '.' as decimal separator + setlocale(LC_NUMERIC, "POSIX"); - /* Catch events */ - XSelectInput(server.display, server.root_win, PropertyChangeMask | StructureNotifyMask); + /* Catch events */ + XSelectInput(server.display, server.root_win, PropertyChangeMask | StructureNotifyMask); - // get monitor and desktop config - get_monitors(); - get_desktops(); + // get monitor and desktop config + get_monitors(); + get_desktops(); - server.disable_transparency = 0; + server.disable_transparency = 0; - xsettings_client = xsettings_client_new(server.display, server.screen, xsettings_notify_cb, NULL, NULL); + xsettings_client = xsettings_client_new(server.display, server.screen, xsettings_notify_cb, NULL, NULL); } void init_X11_post_config() { - if (primary_monitor_first) - sort_monitors(); + if (primary_monitor_first) + sort_monitors(); - server_init_visual(); + server_init_visual(); - gboolean need_sigchld = FALSE; + gboolean need_sigchld = FALSE; #ifdef HAVE_SN - // Initialize startup-notification - if (startup_notifications) { - server.sn_display = sn_display_new(server.display, error_trap_push, error_trap_pop); - server.pids = g_tree_new(cmp_ptr); - need_sigchld = TRUE; - } + // Initialize startup-notification + if (startup_notifications) { + server.sn_display = sn_display_new(server.display, error_trap_push, error_trap_pop); + server.pids = g_tree_new(cmp_ptr); + need_sigchld = TRUE; + } #endif // HAVE_SN - if (panel_config.execp_list) - need_sigchld = TRUE; + if (panel_config.execp_list) + need_sigchld = TRUE; - if (need_sigchld) { - // Setup a handler for child termination - if (pipe(sigchild_pipe) != 0) { - fprintf(stderr, "Creating pipe failed.\n"); - } else { - fcntl(sigchild_pipe[0], F_SETFL, O_NONBLOCK | fcntl(sigchild_pipe[0], F_GETFL)); - fcntl(sigchild_pipe[1], F_SETFL, O_NONBLOCK | fcntl(sigchild_pipe[1], F_GETFL)); - sigchild_pipe_valid = 1; - struct sigaction act = {.sa_handler = sigchld_handler, .sa_flags = SA_RESTART}; - if (sigaction(SIGCHLD, &act, 0)) { - perror("sigaction"); - } - } - } + if (need_sigchld) { + // Setup a handler for child termination + if (pipe(sigchild_pipe) != 0) { + fprintf(stderr, "Creating pipe failed.\n"); + } else { + fcntl(sigchild_pipe[0], F_SETFL, O_NONBLOCK | fcntl(sigchild_pipe[0], F_GETFL)); + fcntl(sigchild_pipe[1], F_SETFL, O_NONBLOCK | fcntl(sigchild_pipe[1], F_GETFL)); + sigchild_pipe_valid = 1; + struct sigaction act = {.sa_handler = sigchld_handler, .sa_flags = SA_RESTART}; + if (sigaction(SIGCHLD, &act, 0)) { + perror("sigaction"); + } + } + } - imlib_context_set_display(server.display); - imlib_context_set_visual(server.visual); - imlib_context_set_colormap(server.colormap); + imlib_context_set_display(server.display); + imlib_context_set_visual(server.visual); + imlib_context_set_colormap(server.colormap); - // load default icon - const gchar *const *data_dirs = g_get_system_data_dirs(); - for (int i = 0; data_dirs[i] != NULL; i++) { - gchar *path = g_build_filename(data_dirs[i], "tint2", "default_icon.png", NULL); - if (g_file_test(path, G_FILE_TEST_EXISTS)) - default_icon = load_image(path, TRUE); - g_free(path); - } - if (!default_icon) { - fprintf(stderr, - RED "Could not load default_icon.png. Please check that tint2 has been installed correctly!" RESET - "\n"); - } + // load default icon + const gchar *const *data_dirs = g_get_system_data_dirs(); + for (int i = 0; data_dirs[i] != NULL; i++) { + gchar *path = g_build_filename(data_dirs[i], "tint2", "default_icon.png", NULL); + if (g_file_test(path, G_FILE_TEST_EXISTS)) + default_icon = load_image(path, TRUE); + g_free(path); + } + if (!default_icon) { + fprintf(stderr, + RED "Could not load default_icon.png. Please check that tint2 has been installed correctly!" RESET + "\n"); + } } void cleanup() { - cleanup_button(); - cleanup_execp(); - cleanup_systray(); - cleanup_tooltip(); - cleanup_clock(); - cleanup_launcher(); + cleanup_button(); + cleanup_execp(); + cleanup_systray(); + cleanup_tooltip(); + cleanup_clock(); + cleanup_launcher(); #ifdef ENABLE_BATTERY - cleanup_battery(); + cleanup_battery(); #endif - cleanup_panel(); - cleanup_config(); + cleanup_panel(); + cleanup_config(); - if (default_icon) { - imlib_context_set_image(default_icon); - imlib_free_image(); - default_icon = NULL; - } - imlib_context_disconnect_display(); + if (default_icon) { + imlib_context_set_image(default_icon); + imlib_free_image(); + default_icon = NULL; + } + imlib_context_disconnect_display(); - xsettings_client_destroy(xsettings_client); - xsettings_client = NULL; + xsettings_client_destroy(xsettings_client); + xsettings_client = NULL; - cleanup_server(); - cleanup_timeout(); - if (server.display) - XCloseDisplay(server.display); - server.display = NULL; + cleanup_server(); + cleanup_timeout(); + if (server.display) + XCloseDisplay(server.display); + server.display = NULL; - if (sigchild_pipe_valid) { - sigchild_pipe_valid = FALSE; - close(sigchild_pipe[1]); - close(sigchild_pipe[0]); - } + if (sigchild_pipe_valid) { + sigchild_pipe_valid = FALSE; + close(sigchild_pipe[1]); + close(sigchild_pipe[0]); + } - uevent_cleanup(); - cleanup_fps_distribution(); + uevent_cleanup(); + cleanup_fps_distribution(); } void dump_panel_to_file(const Panel *panel, const char *path) { - imlib_context_set_drawable(panel->temp_pmap); - Imlib_Image img = imlib_create_image_from_drawable(0, 0, 0, panel->area.width, panel->area.height, 1); + imlib_context_set_drawable(panel->temp_pmap); + Imlib_Image img = imlib_create_image_from_drawable(0, 0, 0, panel->area.width, panel->area.height, 1); - if (!img) { - XImage *ximg = - XGetImage(server.display, panel->temp_pmap, 0, 0, panel->area.width, panel->area.height, AllPlanes, ZPixmap); + if (!img) { + XImage *ximg = + XGetImage(server.display, panel->temp_pmap, 0, 0, panel->area.width, panel->area.height, AllPlanes, ZPixmap); - if (ximg) { - DATA32 *pixels = (DATA32 *)calloc(panel->area.width * panel->area.height, sizeof(DATA32)); - for (int x = 0; x < panel->area.width; x++) { - for (int y = 0; y < panel->area.height; y++) { - DATA32 xpixel = XGetPixel(ximg, x, y); + if (ximg) { + DATA32 *pixels = (DATA32 *)calloc(panel->area.width * panel->area.height, sizeof(DATA32)); + for (int x = 0; x < panel->area.width; x++) { + for (int y = 0; y < panel->area.height; y++) { + DATA32 xpixel = XGetPixel(ximg, x, y); - DATA32 r = (xpixel >> 16) & 0xff; - DATA32 g = (xpixel >> 8) & 0xff; - DATA32 b = (xpixel >> 0) & 0xff; - DATA32 a = 0x0; + DATA32 r = (xpixel >> 16) & 0xff; + DATA32 g = (xpixel >> 8) & 0xff; + DATA32 b = (xpixel >> 0) & 0xff; + DATA32 a = 0x0; - DATA32 argb = (a << 24) | (r << 16) | (g << 8) | b; - pixels[y * panel->area.width + x] = argb; - } - } - XDestroyImage(ximg); - img = imlib_create_image_using_data(panel->area.width, panel->area.height, pixels); - } - } + DATA32 argb = (a << 24) | (r << 16) | (g << 8) | b; + pixels[y * panel->area.width + x] = argb; + } + } + XDestroyImage(ximg); + img = imlib_create_image_using_data(panel->area.width, panel->area.height, pixels); + } + } - if (img) { - imlib_context_set_image(img); - if (!panel_horizontal) { - // rotate 90° vertical panel - imlib_image_flip_horizontal(); - imlib_image_flip_diagonal(); - } - imlib_save_image(path); - imlib_free_image(); - } + if (img) { + imlib_context_set_image(img); + if (!panel_horizontal) { + // rotate 90° vertical panel + imlib_image_flip_horizontal(); + imlib_image_flip_diagonal(); + } + imlib_save_image(path); + imlib_free_image(); + } } void get_snapshot(const char *path) { - Panel *panel = &panels[0]; + Panel *panel = &panels[0]; - if (panel->area.width > server.monitors[0].width) - panel->area.width = server.monitors[0].width; + if (panel->area.width > server.monitors[0].width) + panel->area.width = server.monitors[0].width; - panel->temp_pmap = - XCreatePixmap(server.display, server.root_win, panel->area.width, panel->area.height, server.depth); - render_panel(panel); + panel->temp_pmap = + XCreatePixmap(server.display, server.root_win, panel->area.width, panel->area.height, server.depth); + render_panel(panel); - XSync(server.display, False); + XSync(server.display, False); - dump_panel_to_file(panel, path); + dump_panel_to_file(panel, path); } void window_action(Task *task, MouseAction action) { - if (!task) - return; - switch (action) { - case NONE: - break; - case CLOSE: - close_window(task->win); - break; - case TOGGLE: - activate_window(task->win); - break; - case ICONIFY: - XIconifyWindow(server.display, task->win, server.screen); - break; - case TOGGLE_ICONIFY: - if (active_task && task->win == active_task->win) - XIconifyWindow(server.display, task->win, server.screen); - else - activate_window(task->win); - break; - case SHADE: - toggle_window_shade(task->win); - break; - case MAXIMIZE_RESTORE: - toggle_window_maximized(task->win); - break; - case MAXIMIZE: - toggle_window_maximized(task->win); - break; - case RESTORE: - toggle_window_maximized(task->win); - break; - case DESKTOP_LEFT: { - if (task->desktop == 0) - break; - int desktop = task->desktop - 1; - change_window_desktop(task->win, desktop); - if (desktop == server.desktop) - activate_window(task->win); - break; - } - case DESKTOP_RIGHT: { - if (task->desktop == server.num_desktops) - break; - int desktop = task->desktop + 1; - change_window_desktop(task->win, desktop); - if (desktop == server.desktop) - activate_window(task->win); - break; - } - case NEXT_TASK: { - Task *task1 = next_task(find_active_task(task)); - activate_window(task1->win); - } break; - case PREV_TASK: { - Task *task1 = prev_task(find_active_task(task)); - activate_window(task1->win); - } - } + if (!task) + return; + switch (action) { + case NONE: + break; + case CLOSE: + close_window(task->win); + break; + case TOGGLE: + activate_window(task->win); + break; + case ICONIFY: + XIconifyWindow(server.display, task->win, server.screen); + break; + case TOGGLE_ICONIFY: + if (active_task && task->win == active_task->win) + XIconifyWindow(server.display, task->win, server.screen); + else + activate_window(task->win); + break; + case SHADE: + toggle_window_shade(task->win); + break; + case MAXIMIZE_RESTORE: + toggle_window_maximized(task->win); + break; + case MAXIMIZE: + toggle_window_maximized(task->win); + break; + case RESTORE: + toggle_window_maximized(task->win); + break; + case DESKTOP_LEFT: { + if (task->desktop == 0) + break; + int desktop = task->desktop - 1; + change_window_desktop(task->win, desktop); + if (desktop == server.desktop) + activate_window(task->win); + break; + } + case DESKTOP_RIGHT: { + if (task->desktop == server.num_desktops) + break; + int desktop = task->desktop + 1; + change_window_desktop(task->win, desktop); + if (desktop == server.desktop) + activate_window(task->win); + break; + } + case NEXT_TASK: { + Task *task1 = next_task(find_active_task(task)); + activate_window(task1->win); + } break; + case PREV_TASK: { + Task *task1 = prev_task(find_active_task(task)); + activate_window(task1->win); + } + } } int tint2_handles_click(Panel *panel, XButtonEvent *e) { - Task *task = click_task(panel, e->x, e->y); - if (task) { - if ((e->button == 1 && mouse_left != 0) || (e->button == 2 && mouse_middle != 0) || - (e->button == 3 && mouse_right != 0) || (e->button == 4 && mouse_scroll_up != 0) || - (e->button == 5 && mouse_scroll_down != 0)) { - return 1; - } else - return 0; - } - 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 *taskbar = click_taskbar(panel, e->x, e->y); - if (taskbar && e->button == 1 && taskbar_mode == MULTI_DESKTOP) - return 1; - if (click_clock(panel, e->x, e->y)) { - if ((e->button == 1 && clock_lclick_command) || (e->button == 2 && clock_mclick_command) || - (e->button == 3 && clock_rclick_command) || (e->button == 4 && clock_uwheel_command) || - (e->button == 5 && clock_dwheel_command)) - return 1; - else - return 0; - } + Task *task = click_task(panel, e->x, e->y); + if (task) { + if ((e->button == 1 && mouse_left != 0) || (e->button == 2 && mouse_middle != 0) || + (e->button == 3 && mouse_right != 0) || (e->button == 4 && mouse_scroll_up != 0) || + (e->button == 5 && mouse_scroll_down != 0)) { + return 1; + } else + return 0; + } + 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 *taskbar = click_taskbar(panel, e->x, e->y); + if (taskbar && e->button == 1 && taskbar_mode == MULTI_DESKTOP) + return 1; + if (click_clock(panel, e->x, e->y)) { + if ((e->button == 1 && clock_lclick_command) || (e->button == 2 && clock_mclick_command) || + (e->button == 3 && clock_rclick_command) || (e->button == 4 && clock_uwheel_command) || + (e->button == 5 && clock_dwheel_command)) + return 1; + else + return 0; + } #ifdef ENABLE_BATTERY - if (click_battery(panel, e->x, e->y)) { - if ((e->button == 1 && battery_lclick_command) || (e->button == 2 && battery_mclick_command) || - (e->button == 3 && battery_rclick_command) || (e->button == 4 && battery_uwheel_command) || - (e->button == 5 && battery_dwheel_command)) - return 1; - else - return 0; - } + if (click_battery(panel, e->x, e->y)) { + if ((e->button == 1 && battery_lclick_command) || (e->button == 2 && battery_mclick_command) || + (e->button == 3 && battery_rclick_command) || (e->button == 4 && battery_uwheel_command) || + (e->button == 5 && battery_dwheel_command)) + return 1; + else + return 0; + } #endif - if (click_execp(panel, e->x, e->y)) - return 1; - if (click_button(panel, e->x, e->y)) - return 1; - return 0; + if (click_execp(panel, e->x, e->y)) + return 1; + if (click_button(panel, e->x, e->y)) + return 1; + return 0; } void forward_click(XEvent *e) { - // forward the click to the desktop window (thanks conky) - XUngrabPointer(server.display, e->xbutton.time); - e->xbutton.window = server.root_win; - // icewm doesn't open under the mouse. - // and xfce doesn't open at all. - e->xbutton.x = e->xbutton.x_root; - e->xbutton.y = e->xbutton.y_root; - // printf("**** %d, %d\n", e->xbutton.x, e->xbutton.y); - // XSetInputFocus(server.display, e->xbutton.window, RevertToParent, e->xbutton.time); - XSendEvent(server.display, e->xbutton.window, False, ButtonPressMask, e); + // forward the click to the desktop window (thanks conky) + XUngrabPointer(server.display, e->xbutton.time); + e->xbutton.window = server.root_win; + // icewm doesn't open under the mouse. + // and xfce doesn't open at all. + e->xbutton.x = e->xbutton.x_root; + e->xbutton.y = e->xbutton.y_root; + // printf("**** %d, %d\n", e->xbutton.x, e->xbutton.y); + // XSetInputFocus(server.display, e->xbutton.window, RevertToParent, e->xbutton.time); + XSendEvent(server.display, e->xbutton.window, False, ButtonPressMask, e); } void event_button_press(XEvent *e) { - Panel *panel = get_panel(e->xany.window); - if (!panel) - return; + Panel *panel = get_panel(e->xany.window); + if (!panel) + return; - if (wm_menu && !tint2_handles_click(panel, &e->xbutton)) { - forward_click(e); - return; - } - task_drag = click_task(panel, e->xbutton.x, e->xbutton.y); + if (wm_menu && !tint2_handles_click(panel, &e->xbutton)) { + forward_click(e); + return; + } + task_drag = click_task(panel, e->xbutton.x, e->xbutton.y); - if (panel_layer == BOTTOM_LAYER) - XLowerWindow(server.display, panel->main_win); + if (panel_layer == BOTTOM_LAYER) + XLowerWindow(server.display, panel->main_win); } void event_button_motion_notify(XEvent *e) { - Panel *panel = get_panel(e->xany.window); - if (!panel || !task_drag) - return; + Panel *panel = get_panel(e->xany.window); + if (!panel || !task_drag) + return; - // Find the taskbar on the event's location - Taskbar *event_taskbar = click_taskbar(panel, e->xbutton.x, e->xbutton.y); - if (event_taskbar == NULL) - return; + // Find the taskbar on the event's location + Taskbar *event_taskbar = click_taskbar(panel, e->xbutton.x, e->xbutton.y); + if (event_taskbar == NULL) + return; - // Find the task on the event's location - Task *event_task = click_task(panel, e->xbutton.x, e->xbutton.y); + // Find the task on the event's location + Task *event_task = click_task(panel, e->xbutton.x, e->xbutton.y); - // If the event takes place on the same taskbar as the task being dragged - if (&event_taskbar->area == task_drag->area.parent) { - if (taskbar_sort_method != TASKBAR_NOSORT) { - sort_tasks(event_taskbar); - } else { - // Swap the task_drag with the task on the event's location (if they differ) - if (event_task && event_task != task_drag) { - GList *drag_iter = g_list_find(event_taskbar->area.children, task_drag); - GList *task_iter = g_list_find(event_taskbar->area.children, event_task); - if (drag_iter && task_iter) { - gpointer temp = task_iter->data; - task_iter->data = drag_iter->data; - drag_iter->data = temp; - event_taskbar->area.resize_needed = 1; - schedule_panel_redraw(); - task_dragged = 1; - } - } - } - } else { // The event is on another taskbar than the task being dragged - if (task_drag->desktop == ALL_DESKTOPS || taskbar_mode != MULTI_DESKTOP) - return; + // If the event takes place on the same taskbar as the task being dragged + if (&event_taskbar->area == task_drag->area.parent) { + if (taskbar_sort_method != TASKBAR_NOSORT) { + sort_tasks(event_taskbar); + } else { + // Swap the task_drag with the task on the event's location (if they differ) + if (event_task && event_task != task_drag) { + GList *drag_iter = g_list_find(event_taskbar->area.children, task_drag); + GList *task_iter = g_list_find(event_taskbar->area.children, event_task); + if (drag_iter && task_iter) { + gpointer temp = task_iter->data; + task_iter->data = drag_iter->data; + drag_iter->data = temp; + event_taskbar->area.resize_needed = 1; + schedule_panel_redraw(); + task_dragged = 1; + } + } + } + } else { // The event is on another taskbar than the task being dragged + if (task_drag->desktop == ALL_DESKTOPS || taskbar_mode != MULTI_DESKTOP) + return; - Taskbar *drag_taskbar = (Taskbar *)task_drag->area.parent; - remove_area((Area *)task_drag); + Taskbar *drag_taskbar = (Taskbar *)task_drag->area.parent; + remove_area((Area *)task_drag); - if (event_taskbar->area.posx > drag_taskbar->area.posx || event_taskbar->area.posy > drag_taskbar->area.posy) { - int i = (taskbarname_enabled) ? 1 : 0; - event_taskbar->area.children = g_list_insert(event_taskbar->area.children, task_drag, i); - } else - event_taskbar->area.children = g_list_append(event_taskbar->area.children, task_drag); + if (event_taskbar->area.posx > drag_taskbar->area.posx || event_taskbar->area.posy > drag_taskbar->area.posy) { + int i = (taskbarname_enabled) ? 1 : 0; + event_taskbar->area.children = g_list_insert(event_taskbar->area.children, task_drag, i); + } else + event_taskbar->area.children = g_list_append(event_taskbar->area.children, task_drag); - // Move task to other desktop (but avoid the 'Window desktop changed' code in 'event_property_notify') - task_drag->area.parent = &event_taskbar->area; - task_drag->desktop = event_taskbar->desktop; + // Move task to other desktop (but avoid the 'Window desktop changed' code in 'event_property_notify') + task_drag->area.parent = &event_taskbar->area; + task_drag->desktop = event_taskbar->desktop; - change_window_desktop(task_drag->win, event_taskbar->desktop); + change_window_desktop(task_drag->win, event_taskbar->desktop); - if (taskbar_sort_method != TASKBAR_NOSORT) { - sort_tasks(event_taskbar); - } + if (taskbar_sort_method != TASKBAR_NOSORT) { + sort_tasks(event_taskbar); + } - event_taskbar->area.resize_needed = 1; - drag_taskbar->area.resize_needed = 1; - task_dragged = 1; - schedule_panel_redraw(); - panel->area.resize_needed = 1; - } + event_taskbar->area.resize_needed = 1; + drag_taskbar->area.resize_needed = 1; + task_dragged = 1; + schedule_panel_redraw(); + panel->area.resize_needed = 1; + } } void event_button_release(XEvent *e) { - Panel *panel = get_panel(e->xany.window); - if (!panel) - return; + Panel *panel = get_panel(e->xany.window); + if (!panel) + return; - if (wm_menu && !tint2_handles_click(panel, &e->xbutton)) { - forward_click(e); - if (panel_layer == BOTTOM_LAYER) - XLowerWindow(server.display, panel->main_win); - task_drag = 0; - return; - } + if (wm_menu && !tint2_handles_click(panel, &e->xbutton)) { + forward_click(e); + if (panel_layer == BOTTOM_LAYER) + XLowerWindow(server.display, panel->main_win); + task_drag = 0; + return; + } - int action = TOGGLE_ICONIFY; - switch (e->xbutton.button) { - case 1: - action = mouse_left; - break; - case 2: - action = mouse_middle; - break; - case 3: - action = mouse_right; - break; - case 4: - action = mouse_scroll_up; - break; - case 5: - action = mouse_scroll_down; - break; - case 6: - action = mouse_tilt_left; - break; - case 7: - action = mouse_tilt_right; - break; - } + int action = TOGGLE_ICONIFY; + switch (e->xbutton.button) { + case 1: + action = mouse_left; + break; + case 2: + action = mouse_middle; + break; + case 3: + action = mouse_right; + break; + case 4: + action = mouse_scroll_up; + break; + case 5: + action = mouse_scroll_down; + break; + case 6: + action = mouse_tilt_left; + break; + case 7: + action = mouse_tilt_right; + break; + } - if (click_clock(panel, e->xbutton.x, e->xbutton.y)) { - clock_action(e->xbutton.button); - if (panel_layer == BOTTOM_LAYER) - XLowerWindow(server.display, panel->main_win); - task_drag = 0; - return; - } + if (click_clock(panel, e->xbutton.x, e->xbutton.y)) { + clock_action(e->xbutton.button); + if (panel_layer == BOTTOM_LAYER) + XLowerWindow(server.display, panel->main_win); + task_drag = 0; + return; + } #ifdef ENABLE_BATTERY - if (click_battery(panel, e->xbutton.x, e->xbutton.y)) { - battery_action(e->xbutton.button); - if (panel_layer == BOTTOM_LAYER) - XLowerWindow(server.display, panel->main_win); - task_drag = 0; - return; - } + if (click_battery(panel, e->xbutton.x, e->xbutton.y)) { + battery_action(e->xbutton.button); + if (panel_layer == BOTTOM_LAYER) + XLowerWindow(server.display, panel->main_win); + task_drag = 0; + return; + } #endif - Execp *execp = click_execp(panel, e->xbutton.x, e->xbutton.y); - if (execp) { - execp_action(execp, e->xbutton.button, e->xbutton.x - execp->area.posx, e->xbutton.y - execp->area.posy); - if (panel_layer == BOTTOM_LAYER) - XLowerWindow(server.display, panel->main_win); - task_drag = 0; - return; - } + Execp *execp = click_execp(panel, e->xbutton.x, e->xbutton.y); + if (execp) { + execp_action(execp, e->xbutton.button, e->xbutton.x - execp->area.posx, e->xbutton.y - execp->area.posy); + if (panel_layer == BOTTOM_LAYER) + XLowerWindow(server.display, panel->main_win); + task_drag = 0; + return; + } - Button *button = click_button(panel, e->xbutton.x, e->xbutton.y); - if (button) { - button_action(button, e->xbutton.button, e->xbutton.x - button->area.posx, e->xbutton.y - button->area.posy); - if (panel_layer == BOTTOM_LAYER) - XLowerWindow(server.display, panel->main_win); - task_drag = 0; - return; - } + Button *button = click_button(panel, e->xbutton.x, e->xbutton.y); + if (button) { + button_action(button, e->xbutton.button, e->xbutton.x - button->area.posx, e->xbutton.y - button->area.posy); + if (panel_layer == BOTTOM_LAYER) + XLowerWindow(server.display, panel->main_win); + task_drag = 0; + return; + } - if (e->xbutton.button == 1 && 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, e); - } - task_drag = 0; - return; - } + if (e->xbutton.button == 1 && 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, e); + } + task_drag = 0; + return; + } - Taskbar *taskbar; - if (!(taskbar = click_taskbar(panel, e->xbutton.x, e->xbutton.y))) { - // TODO: check better solution to keep window below - if (panel_layer == BOTTOM_LAYER) - XLowerWindow(server.display, panel->main_win); - task_drag = 0; - return; - } + Taskbar *taskbar; + if (!(taskbar = click_taskbar(panel, e->xbutton.x, e->xbutton.y))) { + // TODO: check better solution to keep window below + if (panel_layer == BOTTOM_LAYER) + XLowerWindow(server.display, panel->main_win); + task_drag = 0; + return; + } - // drag and drop task - if (task_dragged) { - task_drag = 0; - task_dragged = 0; - return; - } + // drag and drop task + if (task_dragged) { + task_drag = 0; + task_dragged = 0; + return; + } - // switch desktop - if (taskbar_mode == MULTI_DESKTOP) { - gboolean diff_desktop = FALSE; - if (taskbar->desktop != server.desktop && action != CLOSE && action != DESKTOP_LEFT && - action != DESKTOP_RIGHT) { - diff_desktop = TRUE; - change_desktop(taskbar->desktop); - } - Task *task = click_task(panel, e->xbutton.x, e->xbutton.y); - if (task) { - if (diff_desktop) { - if (action == TOGGLE_ICONIFY) { - if (!window_is_active(task->win)) - activate_window(task->win); - } else { - window_action(task, action); - } - } else { - window_action(task, action); - } - } - } else { - window_action(click_task(panel, e->xbutton.x, e->xbutton.y), action); - } + // switch desktop + if (taskbar_mode == MULTI_DESKTOP) { + gboolean diff_desktop = FALSE; + if (taskbar->desktop != server.desktop && action != CLOSE && action != DESKTOP_LEFT && + action != DESKTOP_RIGHT) { + diff_desktop = TRUE; + change_desktop(taskbar->desktop); + } + Task *task = click_task(panel, e->xbutton.x, e->xbutton.y); + if (task) { + if (diff_desktop) { + if (action == TOGGLE_ICONIFY) { + if (!window_is_active(task->win)) + activate_window(task->win); + } else { + window_action(task, action); + } + } else { + window_action(task, action); + } + } + } else { + window_action(click_task(panel, e->xbutton.x, e->xbutton.y), action); + } - // to keep window below - if (panel_layer == BOTTOM_LAYER) - XLowerWindow(server.display, panel->main_win); + // to keep window below + if (panel_layer == BOTTOM_LAYER) + XLowerWindow(server.display, panel->main_win); } void update_desktop_names() { - if (!taskbarname_enabled) - return; - GSList *list = get_desktop_names(); - for (int i = 0; i < num_panels; i++) { - int j; - GSList *l; - for (j = 0, l = list; j < panels[i].num_desktops; j++) { - gchar *name; - if (l) { - name = g_strdup(l->data); - l = l->next; - } else { - name = g_strdup_printf("%d", j + 1); - } - Taskbar *taskbar = &panels[i].taskbar[j]; - if (strcmp(name, taskbar->bar_name.name) != 0) { - g_free(taskbar->bar_name.name); - taskbar->bar_name.name = name; - taskbar->bar_name.area.resize_needed = 1; - } else { - g_free(name); - } - } - } - for (GSList *l = list; l; l = l->next) - g_free(l->data); - g_slist_free(list); - schedule_panel_redraw(); + if (!taskbarname_enabled) + return; + GSList *list = get_desktop_names(); + for (int i = 0; i < num_panels; i++) { + int j; + GSList *l; + for (j = 0, l = list; j < panels[i].num_desktops; j++) { + gchar *name; + if (l) { + name = g_strdup(l->data); + l = l->next; + } else { + name = g_strdup_printf("%d", j + 1); + } + Taskbar *taskbar = &panels[i].taskbar[j]; + if (strcmp(name, taskbar->bar_name.name) != 0) { + g_free(taskbar->bar_name.name); + taskbar->bar_name.name = name; + taskbar->bar_name.area.resize_needed = 1; + } else { + g_free(name); + } + } + } + for (GSList *l = list; l; l = l->next) + g_free(l->data); + g_slist_free(list); + schedule_panel_redraw(); } void update_task_desktop(Task *task) { - // fprintf(stderr, "%s %d:\n", __FUNCTION__, __LINE__); - Window win = task->win; - remove_task(task); - task = add_task(win); - reset_active_task(); - schedule_panel_redraw(); + // fprintf(stderr, "%s %d:\n", __FUNCTION__, __LINE__); + Window win = task->win; + remove_task(task); + task = add_task(win); + reset_active_task(); + schedule_panel_redraw(); } void event_property_notify(XEvent *e) { - gboolean debug = FALSE; + gboolean debug = FALSE; - Window win = e->xproperty.window; - Atom at = e->xproperty.atom; + Window win = e->xproperty.window; + Atom at = e->xproperty.atom; - if (xsettings_client) - xsettings_client_process_event(xsettings_client, e); - for (int i = 0; i < num_panels; i++) { - Panel *p = &panels[i]; - if (win == p->main_win) { - if (at == server.atom._NET_WM_DESKTOP && get_window_desktop(p->main_win) != ALL_DESKTOPS) - replace_panel_all_desktops(p); - return; - } - } - if (win == server.root_win) { - if (!server.got_root_win) { - XSelectInput(server.display, server.root_win, PropertyChangeMask | StructureNotifyMask); - server.got_root_win = TRUE; - } + if (xsettings_client) + xsettings_client_process_event(xsettings_client, e); + for (int i = 0; i < num_panels; i++) { + Panel *p = &panels[i]; + if (win == p->main_win) { + if (at == server.atom._NET_WM_DESKTOP && get_window_desktop(p->main_win) != ALL_DESKTOPS) + replace_panel_all_desktops(p); + return; + } + } + if (win == server.root_win) { + if (!server.got_root_win) { + XSelectInput(server.display, server.root_win, PropertyChangeMask | StructureNotifyMask); + server.got_root_win = TRUE; + } - // Change name of desktops - else if (at == server.atom._NET_DESKTOP_NAMES) { - if (debug) - fprintf(stderr, "%s %d: win = root, atom = _NET_DESKTOP_NAMES\n", __FUNCTION__, __LINE__); - update_desktop_names(); - } - // Change desktops - else if (at == server.atom._NET_NUMBER_OF_DESKTOPS || at == server.atom._NET_DESKTOP_GEOMETRY || - at == server.atom._NET_DESKTOP_VIEWPORT || at == server.atom._NET_WORKAREA || - at == server.atom._NET_CURRENT_DESKTOP) { - if (debug) - fprintf(stderr, "%s %d: win = root, atom = ?? desktops changed\n", __FUNCTION__, __LINE__); - if (!taskbar_enabled) - return; - int old_num_desktops = server.num_desktops; - int old_desktop = server.desktop; - server_get_number_of_desktops(); - server.desktop = get_current_desktop(); - if (old_num_desktops != server.num_desktops) { // If number of desktop changed - if (server.num_desktops <= server.desktop) { - server.desktop = server.num_desktops - 1; - } - cleanup_taskbar(); - init_taskbar(); - for (int i = 0; i < num_panels; i++) { - init_taskbar_panel(&panels[i]); - set_panel_items_order(&panels[i]); - panels[i].area.resize_needed = 1; - } - taskbar_refresh_tasklist(); - reset_active_task(); - update_all_taskbars_visibility(); - if (old_desktop != server.desktop) - tooltip_trigger_hide(); - schedule_panel_redraw(); - } else if (old_desktop != server.desktop) { - tooltip_trigger_hide(); - for (int i = 0; i < num_panels; i++) { - Panel *panel = &panels[i]; - set_taskbar_state(&panel->taskbar[old_desktop], TASKBAR_NORMAL); - set_taskbar_state(&panel->taskbar[server.desktop], TASKBAR_ACTIVE); - // check ALL_DESKTOPS task => resize taskbar - Taskbar *taskbar; - if (server.num_desktops > old_desktop) { - taskbar = &panel->taskbar[old_desktop]; - GList *l = taskbar->area.children; - if (taskbarname_enabled) - l = l->next; - for (; l; l = l->next) { - Task *task = l->data; - if (task->desktop == ALL_DESKTOPS) { - task->area.on_screen = always_show_all_desktop_tasks; - taskbar->area.resize_needed = 1; - schedule_panel_redraw(); - if (taskbar_mode == MULTI_DESKTOP) - panel->area.resize_needed = 1; - } - } - } - taskbar = &panel->taskbar[server.desktop]; - GList *l = taskbar->area.children; - if (taskbarname_enabled) - l = l->next; - for (; l; l = l->next) { - Task *task = l->data; - if (task->desktop == ALL_DESKTOPS) { - task->area.on_screen = TRUE; - taskbar->area.resize_needed = 1; - if (taskbar_mode == MULTI_DESKTOP) - panel->area.resize_needed = 1; - } - } + // Change name of desktops + else if (at == server.atom._NET_DESKTOP_NAMES) { + if (debug) + fprintf(stderr, "%s %d: win = root, atom = _NET_DESKTOP_NAMES\n", __FUNCTION__, __LINE__); + update_desktop_names(); + } + // Change desktops + else if (at == server.atom._NET_NUMBER_OF_DESKTOPS || at == server.atom._NET_DESKTOP_GEOMETRY || + at == server.atom._NET_DESKTOP_VIEWPORT || at == server.atom._NET_WORKAREA || + at == server.atom._NET_CURRENT_DESKTOP) { + if (debug) + fprintf(stderr, "%s %d: win = root, atom = ?? desktops changed\n", __FUNCTION__, __LINE__); + if (!taskbar_enabled) + return; + int old_num_desktops = server.num_desktops; + int old_desktop = server.desktop; + server_get_number_of_desktops(); + server.desktop = get_current_desktop(); + if (old_num_desktops != server.num_desktops) { // If number of desktop changed + if (server.num_desktops <= server.desktop) { + server.desktop = server.num_desktops - 1; + } + cleanup_taskbar(); + init_taskbar(); + for (int i = 0; i < num_panels; i++) { + init_taskbar_panel(&panels[i]); + set_panel_items_order(&panels[i]); + panels[i].area.resize_needed = 1; + } + taskbar_refresh_tasklist(); + reset_active_task(); + update_all_taskbars_visibility(); + if (old_desktop != server.desktop) + tooltip_trigger_hide(); + schedule_panel_redraw(); + } else if (old_desktop != server.desktop) { + tooltip_trigger_hide(); + for (int i = 0; i < num_panels; i++) { + Panel *panel = &panels[i]; + set_taskbar_state(&panel->taskbar[old_desktop], TASKBAR_NORMAL); + set_taskbar_state(&panel->taskbar[server.desktop], TASKBAR_ACTIVE); + // check ALL_DESKTOPS task => resize taskbar + Taskbar *taskbar; + if (server.num_desktops > old_desktop) { + taskbar = &panel->taskbar[old_desktop]; + GList *l = taskbar->area.children; + if (taskbarname_enabled) + l = l->next; + for (; l; l = l->next) { + Task *task = l->data; + if (task->desktop == ALL_DESKTOPS) { + task->area.on_screen = always_show_all_desktop_tasks; + taskbar->area.resize_needed = 1; + schedule_panel_redraw(); + if (taskbar_mode == MULTI_DESKTOP) + panel->area.resize_needed = 1; + } + } + } + taskbar = &panel->taskbar[server.desktop]; + GList *l = taskbar->area.children; + if (taskbarname_enabled) + l = l->next; + for (; l; l = l->next) { + Task *task = l->data; + if (task->desktop == ALL_DESKTOPS) { + task->area.on_screen = TRUE; + taskbar->area.resize_needed = 1; + if (taskbar_mode == MULTI_DESKTOP) + panel->area.resize_needed = 1; + } + } - if (server.viewports) { - GList *need_update = NULL; + if (server.viewports) { + GList *need_update = NULL; - GHashTableIter iter; - gpointer key, value; + GHashTableIter iter; + gpointer key, value; - g_hash_table_iter_init(&iter, win_to_task); - while (g_hash_table_iter_next(&iter, &key, &value)) { - Window task_win = *(Window *)key; - Task *task = get_task(task_win); - if (task) { - int desktop = get_window_desktop(task_win); - if (desktop != task->desktop) { - need_update = g_list_append(need_update, task); - } - } - } - for (l = need_update; l; l = l->next) { - Task *task = l->data; - update_task_desktop(task); - } - } - } - } - } - // Window list - else if (at == server.atom._NET_CLIENT_LIST) { - if (debug) - fprintf(stderr, "%s %d: win = root, atom = _NET_CLIENT_LIST\n", __FUNCTION__, __LINE__); - taskbar_refresh_tasklist(); - update_all_taskbars_visibility(); - schedule_panel_redraw(); - } - // Change active - else if (at == server.atom._NET_ACTIVE_WINDOW) { - if (debug) - fprintf(stderr, "%s %d: win = root, atom = _NET_ACTIVE_WINDOW\n", __FUNCTION__, __LINE__); - reset_active_task(); - schedule_panel_redraw(); - } else if (at == server.atom._XROOTPMAP_ID || at == server.atom._XROOTMAP_ID) { - if (debug) - fprintf(stderr, "%s %d: win = root, atom = _XROOTPMAP_ID\n", __FUNCTION__, __LINE__); - // change Wallpaper - for (int i = 0; i < num_panels; i++) { - set_panel_background(&panels[i]); - } - schedule_panel_redraw(); - } - } else { - TrayWindow *traywin = systray_find_icon(win); - if (traywin) { - systray_property_notify(traywin, e); - return; - } + g_hash_table_iter_init(&iter, win_to_task); + while (g_hash_table_iter_next(&iter, &key, &value)) { + Window task_win = *(Window *)key; + Task *task = get_task(task_win); + if (task) { + int desktop = get_window_desktop(task_win); + if (desktop != task->desktop) { + need_update = g_list_append(need_update, task); + } + } + } + for (l = need_update; l; l = l->next) { + Task *task = l->data; + update_task_desktop(task); + } + } + } + } + } + // Window list + else if (at == server.atom._NET_CLIENT_LIST) { + if (debug) + fprintf(stderr, "%s %d: win = root, atom = _NET_CLIENT_LIST\n", __FUNCTION__, __LINE__); + taskbar_refresh_tasklist(); + update_all_taskbars_visibility(); + schedule_panel_redraw(); + } + // Change active + else if (at == server.atom._NET_ACTIVE_WINDOW) { + if (debug) + fprintf(stderr, "%s %d: win = root, atom = _NET_ACTIVE_WINDOW\n", __FUNCTION__, __LINE__); + reset_active_task(); + schedule_panel_redraw(); + } else if (at == server.atom._XROOTPMAP_ID || at == server.atom._XROOTMAP_ID) { + if (debug) + fprintf(stderr, "%s %d: win = root, atom = _XROOTPMAP_ID\n", __FUNCTION__, __LINE__); + // change Wallpaper + for (int i = 0; i < num_panels; i++) { + set_panel_background(&panels[i]); + } + schedule_panel_redraw(); + } + } else { + TrayWindow *traywin = systray_find_icon(win); + if (traywin) { + systray_property_notify(traywin, e); + return; + } - Task *task = get_task(win); - if (debug) { - char *atom_name = XGetAtomName(server.display, at); - fprintf(stderr, - "%s %d: win = %ld, task = %s, atom = %s\n", - __FUNCTION__, - __LINE__, - win, - task ? (task->title ? task->title : "??") : "null", - atom_name); - XFree(atom_name); - } - if (!task) { - if (debug) - fprintf(stderr, "%s %d\n", __FUNCTION__, __LINE__); - if (at == server.atom._NET_WM_STATE) { - // xfce4 sends _NET_WM_STATE after minimized to tray, so we need to check if window is mapped - // if it is mapped and not set as skip_taskbar, we must add it to our task list - XWindowAttributes wa; - XGetWindowAttributes(server.display, win, &wa); - if (wa.map_state == IsViewable && !window_is_skip_taskbar(win)) { - if ((task = add_task(win))) - schedule_panel_redraw(); - } - } - return; - } - // printf("atom root_win = %s, %s\n", XGetAtomName(server.display, at), task->title); + Task *task = get_task(win); + if (debug) { + char *atom_name = XGetAtomName(server.display, at); + fprintf(stderr, + "%s %d: win = %ld, task = %s, atom = %s\n", + __FUNCTION__, + __LINE__, + win, + task ? (task->title ? task->title : "??") : "null", + atom_name); + XFree(atom_name); + } + if (!task) { + if (debug) + fprintf(stderr, "%s %d\n", __FUNCTION__, __LINE__); + if (at == server.atom._NET_WM_STATE) { + // xfce4 sends _NET_WM_STATE after minimized to tray, so we need to check if window is mapped + // if it is mapped and not set as skip_taskbar, we must add it to our task list + XWindowAttributes wa; + XGetWindowAttributes(server.display, win, &wa); + if (wa.map_state == IsViewable && !window_is_skip_taskbar(win)) { + if ((task = add_task(win))) + schedule_panel_redraw(); + } + } + return; + } + // printf("atom root_win = %s, %s\n", XGetAtomName(server.display, at), task->title); - // Window title changed - if (at == server.atom._NET_WM_VISIBLE_NAME || at == server.atom._NET_WM_NAME || at == server.atom.WM_NAME) { - if (task_update_title(task)) { - if (g_tooltip.mapped && (g_tooltip.area == (Area *)task)) { - tooltip_copy_text((Area *)task); - tooltip_update(); - } - if (taskbar_sort_method == TASKBAR_SORT_TITLE) - sort_taskbar_for_win(win); - schedule_panel_redraw(); - } - } - // Demand attention - else if (at == server.atom._NET_WM_STATE) { - if (debug) { - int count; - Atom *atom_state = server_get_property(win, server.atom._NET_WM_STATE, XA_ATOM, &count); - for (int j = 0; j < count; j++) { - char *atom_state_name = XGetAtomName(server.display, atom_state[j]); - fprintf(stderr, "%s %d: _NET_WM_STATE = %s\n", __FUNCTION__, __LINE__, atom_state_name); - XFree(atom_state_name); - } - XFree(atom_state); - } - if (window_is_urgent(win)) { - add_urgent(task); - } - if (window_is_skip_taskbar(win)) { - remove_task(task); - schedule_panel_redraw(); - } - } else if (at == server.atom.WM_STATE) { - // Iconic state - TaskState state = (active_task && task->win == active_task->win ? TASK_ACTIVE : TASK_NORMAL); - if (window_is_iconified(win)) - state = TASK_ICONIFIED; - set_task_state(task, state); - schedule_panel_redraw(); - } - // Window icon changed - else if (at == server.atom._NET_WM_ICON) { - task_update_icon(task); - schedule_panel_redraw(); - } - // Window desktop changed - else if (at == server.atom._NET_WM_DESKTOP) { - int desktop = get_window_desktop(win); - // printf(" Window desktop changed %d, %d\n", task->desktop, desktop); - // bug in windowmaker : send unecessary 'desktop changed' when focus changed - if (desktop != task->desktop) { - update_task_desktop(task); - } - } else if (at == server.atom.WM_HINTS) { - XWMHints *wmhints = XGetWMHints(server.display, win); - if (wmhints && wmhints->flags & XUrgencyHint) { - add_urgent(task); - } - XFree(wmhints); - task_update_icon(task); - schedule_panel_redraw(); - } + // Window title changed + if (at == server.atom._NET_WM_VISIBLE_NAME || at == server.atom._NET_WM_NAME || at == server.atom.WM_NAME) { + if (task_update_title(task)) { + if (g_tooltip.mapped && (g_tooltip.area == (Area *)task)) { + tooltip_copy_text((Area *)task); + tooltip_update(); + } + if (taskbar_sort_method == TASKBAR_SORT_TITLE) + sort_taskbar_for_win(win); + schedule_panel_redraw(); + } + } + // Demand attention + else if (at == server.atom._NET_WM_STATE) { + if (debug) { + int count; + Atom *atom_state = server_get_property(win, server.atom._NET_WM_STATE, XA_ATOM, &count); + for (int j = 0; j < count; j++) { + char *atom_state_name = XGetAtomName(server.display, atom_state[j]); + fprintf(stderr, "%s %d: _NET_WM_STATE = %s\n", __FUNCTION__, __LINE__, atom_state_name); + XFree(atom_state_name); + } + XFree(atom_state); + } + if (window_is_urgent(win)) { + add_urgent(task); + } + if (window_is_skip_taskbar(win)) { + remove_task(task); + schedule_panel_redraw(); + } + } else if (at == server.atom.WM_STATE) { + // Iconic state + TaskState state = (active_task && task->win == active_task->win ? TASK_ACTIVE : TASK_NORMAL); + if (window_is_iconified(win)) + state = TASK_ICONIFIED; + set_task_state(task, state); + schedule_panel_redraw(); + } + // Window icon changed + else if (at == server.atom._NET_WM_ICON) { + task_update_icon(task); + schedule_panel_redraw(); + } + // Window desktop changed + else if (at == server.atom._NET_WM_DESKTOP) { + int desktop = get_window_desktop(win); + // printf(" Window desktop changed %d, %d\n", task->desktop, desktop); + // bug in windowmaker : send unecessary 'desktop changed' when focus changed + if (desktop != task->desktop) { + update_task_desktop(task); + } + } else if (at == server.atom.WM_HINTS) { + XWMHints *wmhints = XGetWMHints(server.display, win); + if (wmhints && wmhints->flags & XUrgencyHint) { + add_urgent(task); + } + XFree(wmhints); + task_update_icon(task); + schedule_panel_redraw(); + } - if (!server.got_root_win) - server.root_win = RootWindow(server.display, server.screen); - } + if (!server.got_root_win) + server.root_win = RootWindow(server.display, server.screen); + } } void event_expose(XEvent *e) { - Panel *panel; - panel = get_panel(e->xany.window); - if (!panel) - return; - // TODO : one panel_refresh per panel ? - schedule_panel_redraw(); + Panel *panel; + panel = get_panel(e->xany.window); + if (!panel) + return; + // TODO : one panel_refresh per panel ? + schedule_panel_redraw(); } void event_configure_notify(XEvent *e) { - Window win = e->xconfigure.window; + Window win = e->xconfigure.window; - if (0) { - Task *task = get_task(win); - fprintf(stderr, - "%s %d: win = %ld, task = %s\n", - __FUNCTION__, - __LINE__, - win, - task ? (task->title ? task->title : "??") : "null"); - } + if (0) { + Task *task = get_task(win); + fprintf(stderr, + "%s %d: win = %ld, task = %s\n", + __FUNCTION__, + __LINE__, + win, + task ? (task->title ? task->title : "??") : "null"); + } - // change in root window (xrandr) - if (win == server.root_win) { - fprintf(stderr, - YELLOW "%s %d: triggering tint2 restart due to configuration change in the root window" RESET "\n", - __FILE__, - __LINE__); - signal_pending = SIGUSR1; - return; - } + // change in root window (xrandr) + if (win == server.root_win) { + fprintf(stderr, + YELLOW "%s %d: triggering tint2 restart due to configuration change in the root window" RESET "\n", + __FILE__, + __LINE__); + signal_pending = SIGUSR1; + return; + } - TrayWindow *traywin = systray_find_icon(win); - if (traywin) { - systray_reconfigure_event(traywin, e); - return; - } + TrayWindow *traywin = systray_find_icon(win); + if (traywin) { + systray_reconfigure_event(traywin, e); + return; + } - // 'win' move in another monitor - if (num_panels > 1 || hide_task_diff_monitor) { - Task *task = get_task(win); - if (task) { - Panel *p = task->area.panel; - int monitor = get_window_monitor(win); - if ((hide_task_diff_monitor && p->monitor != monitor && task->area.on_screen) || - (hide_task_diff_monitor && p->monitor == monitor && !task->area.on_screen) || - (p->monitor != monitor && num_panels > 1)) { - remove_task(task); - task = add_task(win); - if (win == get_active_window()) { - set_task_state(task, TASK_ACTIVE); - active_task = task; - } - schedule_panel_redraw(); - } - } - } + // 'win' move in another monitor + if (num_panels > 1 || hide_task_diff_monitor) { + Task *task = get_task(win); + if (task) { + Panel *p = task->area.panel; + int monitor = get_window_monitor(win); + if ((hide_task_diff_monitor && p->monitor != monitor && task->area.on_screen) || + (hide_task_diff_monitor && p->monitor == monitor && !task->area.on_screen) || + (p->monitor != monitor && num_panels > 1)) { + remove_task(task); + task = add_task(win); + if (win == get_active_window()) { + set_task_state(task, TASK_ACTIVE); + active_task = task; + } + schedule_panel_redraw(); + } + } + } - if (server.viewports) { - Task *task = get_task(win); - if (task) { - int desktop = get_window_desktop(win); - if (task->desktop != desktop) { - update_task_desktop(task); - } - } - } + if (server.viewports) { + Task *task = get_task(win); + if (task) { + int desktop = get_window_desktop(win); + if (task->desktop != desktop) { + update_task_desktop(task); + } + } + } - sort_taskbar_for_win(win); + sort_taskbar_for_win(win); } const char *GetAtomName(Display *disp, Atom a) { - if (a == None) - return "None"; - else - return XGetAtomName(disp, a); + if (a == None) + return "None"; + else + return XGetAtomName(disp, a); } typedef struct Property { - unsigned char *data; - int format, nitems; - Atom type; + unsigned char *data; + int format, nitems; + Atom type; } Property; // This fetches all the data from a property struct Property read_property(Display *disp, Window w, Atom property) { - Atom actual_type; - int actual_format; - unsigned long nitems; - unsigned long bytes_after; - unsigned char *ret = 0; + Atom actual_type; + int actual_format; + unsigned long nitems; + unsigned long bytes_after; + unsigned char *ret = 0; - int read_bytes = 1024; + int read_bytes = 1024; - // Keep trying to read the property until there are no - // bytes unread. - do { - if (ret != 0) - XFree(ret); - XGetWindowProperty(disp, - w, - property, - 0, - read_bytes, - False, - AnyPropertyType, - &actual_type, - &actual_format, - &nitems, - &bytes_after, - &ret); - read_bytes *= 2; - } while (bytes_after != 0); + // Keep trying to read the property until there are no + // bytes unread. + do { + if (ret != 0) + XFree(ret); + XGetWindowProperty(disp, + w, + property, + 0, + read_bytes, + False, + AnyPropertyType, + &actual_type, + &actual_format, + &nitems, + &bytes_after, + &ret); + read_bytes *= 2; + } while (bytes_after != 0); - fprintf(stderr, "DnD %s:%d: Property:\n", __FILE__, __LINE__); - fprintf(stderr, "DnD %s:%d: Actual type: %s\n", __FILE__, __LINE__, GetAtomName(disp, actual_type)); - fprintf(stderr, "DnD %s:%d: Actual format: %d\n", __FILE__, __LINE__, actual_format); - fprintf(stderr, "DnD %s:%d: Number of items: %lu\n", __FILE__, __LINE__, nitems); + fprintf(stderr, "DnD %s:%d: Property:\n", __FILE__, __LINE__); + fprintf(stderr, "DnD %s:%d: Actual type: %s\n", __FILE__, __LINE__, GetAtomName(disp, actual_type)); + fprintf(stderr, "DnD %s:%d: Actual format: %d\n", __FILE__, __LINE__, actual_format); + fprintf(stderr, "DnD %s:%d: Number of items: %lu\n", __FILE__, __LINE__, nitems); - Property p; - p.data = ret; - p.format = actual_format; - p.nitems = nitems; - p.type = actual_type; + Property p; + p.data = ret; + p.format = actual_format; + p.nitems = nitems; + p.type = actual_type; - return p; + return p; } // This function takes a list of targets which can be converted to (atom_list, nitems)

@@ -1485,700 +1484,700 @@ // and a list of acceptable targets with prioritees (datatypes). It returns the highest

// entry in datatypes which is also in atom_list: ie it finds the best match. Atom pick_target_from_list(Display *disp, Atom *atom_list, int nitems) { - Atom to_be_requested = None; - int i; - for (i = 0; i < nitems; i++) { - const char *atom_name = GetAtomName(disp, atom_list[i]); - fprintf(stderr, "DnD %s:%d: Type %d = %s\n", __FILE__, __LINE__, i, atom_name); + Atom to_be_requested = None; + int i; + for (i = 0; i < nitems; i++) { + const char *atom_name = GetAtomName(disp, atom_list[i]); + fprintf(stderr, "DnD %s:%d: Type %d = %s\n", __FILE__, __LINE__, i, atom_name); - // See if this data type is allowed and of higher priority (closer to zero) - // than the present one. - if (strcmp(atom_name, "STRING") == 0) { - to_be_requested = atom_list[i]; - } - } + // See if this data type is allowed and of higher priority (closer to zero) + // than the present one. + if (strcmp(atom_name, "STRING") == 0) { + to_be_requested = atom_list[i]; + } + } - return to_be_requested; + return to_be_requested; } // Finds the best target given up to three atoms provided (any can be None). // Useful for part of the Xdnd protocol. Atom pick_target_from_atoms(Display *disp, Atom t1, Atom t2, Atom t3) { - Atom atoms[3]; - int n = 0; + Atom atoms[3]; + int n = 0; - if (t1 != None) - atoms[n++] = t1; + if (t1 != None) + atoms[n++] = t1; - if (t2 != None) - atoms[n++] = t2; + if (t2 != None) + atoms[n++] = t2; - if (t3 != None) - atoms[n++] = t3; + if (t3 != None) + atoms[n++] = t3; - return pick_target_from_list(disp, atoms, n); + return pick_target_from_list(disp, atoms, n); } // Finds the best target given a local copy of a property. Atom pick_target_from_targets(Display *disp, Property p) { - // The list of targets is a list of atoms, so it should have type XA_ATOM - // but it may have the type TARGETS instead. + // The list of targets is a list of atoms, so it should have type XA_ATOM + // but it may have the type TARGETS instead. - if ((p.type != XA_ATOM && p.type != server.atom.TARGETS) || p.format != 32) { - // This would be really broken. Targets have to be an atom list - // and applications should support this. Nevertheless, some - // seem broken (MATLAB 7, for instance), so ask for STRING - // next instead as the lowest common denominator - return XA_STRING; - } else { - Atom *atom_list = (Atom *)p.data; + if ((p.type != XA_ATOM && p.type != server.atom.TARGETS) || p.format != 32) { + // This would be really broken. Targets have to be an atom list + // and applications should support this. Nevertheless, some + // seem broken (MATLAB 7, for instance), so ask for STRING + // next instead as the lowest common denominator + return XA_STRING; + } else { + Atom *atom_list = (Atom *)p.data; - return pick_target_from_list(disp, atom_list, p.nitems); - } + return pick_target_from_list(disp, atom_list, p.nitems); + } } void dnd_enter(XClientMessageEvent *e) { - dnd_atom = None; - int more_than_3 = e->data.l[1] & 1; - dnd_source_window = e->data.l[0]; - dnd_version = (e->data.l[1] >> 24); + dnd_atom = None; + int more_than_3 = e->data.l[1] & 1; + dnd_source_window = e->data.l[0]; + dnd_version = (e->data.l[1] >> 24); - fprintf(stderr, "DnD %s:%d: DnDEnter\n", __FILE__, __LINE__); - fprintf(stderr, "DnD %s:%d: DnDEnter. Supports > 3 types = %s\n", __FILE__, __LINE__, more_than_3 ? "yes" : "no"); - fprintf(stderr, "DnD %s:%d: Protocol version = %d\n", __FILE__, __LINE__, dnd_version); - fprintf(stderr, "DnD %s:%d: Type 1 = %s\n", __FILE__, __LINE__, GetAtomName(server.display, e->data.l[2])); - fprintf(stderr, "DnD %s:%d: Type 2 = %s\n", __FILE__, __LINE__, GetAtomName(server.display, e->data.l[3])); - fprintf(stderr, "DnD %s:%d: Type 3 = %s\n", __FILE__, __LINE__, GetAtomName(server.display, e->data.l[4])); + fprintf(stderr, "DnD %s:%d: DnDEnter\n", __FILE__, __LINE__); + fprintf(stderr, "DnD %s:%d: DnDEnter. Supports > 3 types = %s\n", __FILE__, __LINE__, more_than_3 ? "yes" : "no"); + fprintf(stderr, "DnD %s:%d: Protocol version = %d\n", __FILE__, __LINE__, dnd_version); + fprintf(stderr, "DnD %s:%d: Type 1 = %s\n", __FILE__, __LINE__, GetAtomName(server.display, e->data.l[2])); + fprintf(stderr, "DnD %s:%d: Type 2 = %s\n", __FILE__, __LINE__, GetAtomName(server.display, e->data.l[3])); + fprintf(stderr, "DnD %s:%d: Type 3 = %s\n", __FILE__, __LINE__, GetAtomName(server.display, e->data.l[4])); - // Query which conversions are available and pick the best + // Query which conversions are available and pick the best - if (more_than_3) { - // Fetch the list of possible conversions - // Notice the similarity to TARGETS with paste. - Property p = read_property(server.display, dnd_source_window, server.atom.XdndTypeList); - dnd_atom = pick_target_from_targets(server.display, p); - XFree(p.data); - } else { - // Use the available list - dnd_atom = pick_target_from_atoms(server.display, e->data.l[2], e->data.l[3], e->data.l[4]); - } + if (more_than_3) { + // Fetch the list of possible conversions + // Notice the similarity to TARGETS with paste. + Property p = read_property(server.display, dnd_source_window, server.atom.XdndTypeList); + dnd_atom = pick_target_from_targets(server.display, p); + XFree(p.data); + } else { + // Use the available list + dnd_atom = pick_target_from_atoms(server.display, e->data.l[2], e->data.l[3], e->data.l[4]); + } - fprintf(stderr, "DnD %s:%d: Requested type = %s\n", __FILE__, __LINE__, GetAtomName(server.display, dnd_atom)); + fprintf(stderr, "DnD %s:%d: Requested type = %s\n", __FILE__, __LINE__, GetAtomName(server.display, dnd_atom)); } void dnd_position(XClientMessageEvent *e) { - dnd_target_window = e->window; - int accept = 0; - Panel *panel = get_panel(e->window); - int x, y, mapX, mapY; - Window child; - x = (e->data.l[2] >> 16) & 0xFFFF; - y = e->data.l[2] & 0xFFFF; - XTranslateCoordinates(server.display, server.root_win, e->window, x, y, &mapX, &mapY, &child); - Task *task = click_task(panel, mapX, mapY); - if (task) { - if (task->desktop != server.desktop) - change_desktop(task->desktop); - window_action(task, TOGGLE); - } else { - LauncherIcon *icon = click_launcher_icon(panel, mapX, mapY); - if (icon) { - accept = 1; - dnd_launcher_exec = icon->cmd; - } else { - dnd_launcher_exec = 0; - } - } + dnd_target_window = e->window; + int accept = 0; + Panel *panel = get_panel(e->window); + int x, y, mapX, mapY; + Window child; + x = (e->data.l[2] >> 16) & 0xFFFF; + y = e->data.l[2] & 0xFFFF; + XTranslateCoordinates(server.display, server.root_win, e->window, x, y, &mapX, &mapY, &child); + Task *task = click_task(panel, mapX, mapY); + if (task) { + if (task->desktop != server.desktop) + change_desktop(task->desktop); + window_action(task, TOGGLE); + } else { + LauncherIcon *icon = click_launcher_icon(panel, mapX, mapY); + if (icon) { + accept = 1; + dnd_launcher_exec = icon->cmd; + } else { + dnd_launcher_exec = 0; + } + } - // send XdndStatus event to get more XdndPosition events - XClientMessageEvent se; - se.type = ClientMessage; - se.window = e->data.l[0]; - se.message_type = server.atom.XdndStatus; - se.format = 32; - se.data.l[0] = e->window; // XID of the target window - se.data.l[1] = accept ? 1 : 0; // bit 0: accept drop bit 1: send XdndPosition events if inside rectangle - se.data.l[2] = 0; // Rectangle x,y for which no more XdndPosition events - se.data.l[3] = (1 << 16) | 1; // Rectangle w,h for which no more XdndPosition events - if (accept) { - se.data.l[4] = dnd_version >= 2 ? e->data.l[4] : server.atom.XdndActionCopy; - } else { - se.data.l[4] = None; // None = drop will not be accepted - } + // send XdndStatus event to get more XdndPosition events + XClientMessageEvent se; + se.type = ClientMessage; + se.window = e->data.l[0]; + se.message_type = server.atom.XdndStatus; + se.format = 32; + se.data.l[0] = e->window; // XID of the target window + se.data.l[1] = accept ? 1 : 0; // bit 0: accept drop bit 1: send XdndPosition events if inside rectangle + se.data.l[2] = 0; // Rectangle x,y for which no more XdndPosition events + se.data.l[3] = (1 << 16) | 1; // Rectangle w,h for which no more XdndPosition events + if (accept) { + se.data.l[4] = dnd_version >= 2 ? e->data.l[4] : server.atom.XdndActionCopy; + } else { + se.data.l[4] = None; // None = drop will not be accepted + } - XSendEvent(server.display, e->data.l[0], False, NoEventMask, (XEvent *)&se); + XSendEvent(server.display, e->data.l[0], False, NoEventMask, (XEvent *)&se); } void dnd_drop(XClientMessageEvent *e) { - if (dnd_target_window && dnd_launcher_exec) { - if (dnd_version >= 1) { - XConvertSelection(server.display, - server.atom.XdndSelection, - XA_STRING, - dnd_selection, - dnd_target_window, - e->data.l[2]); - } else { - XConvertSelection(server.display, - server.atom.XdndSelection, - XA_STRING, - dnd_selection, - dnd_target_window, - CurrentTime); - } - } else { - // The source is sending anyway, despite instructions to the contrary. - // So reply that we're not interested. - XClientMessageEvent m; - memset(&m, 0, sizeof(m)); - m.type = ClientMessage; - m.display = e->display; - m.window = e->data.l[0]; - m.message_type = server.atom.XdndFinished; - m.format = 32; - m.data.l[0] = dnd_target_window; - m.data.l[1] = 0; - m.data.l[2] = None; // Failed. - XSendEvent(server.display, e->data.l[0], False, NoEventMask, (XEvent *)&m); - } + if (dnd_target_window && dnd_launcher_exec) { + if (dnd_version >= 1) { + XConvertSelection(server.display, + server.atom.XdndSelection, + XA_STRING, + dnd_selection, + dnd_target_window, + e->data.l[2]); + } else { + XConvertSelection(server.display, + server.atom.XdndSelection, + XA_STRING, + dnd_selection, + dnd_target_window, + CurrentTime); + } + } else { + // The source is sending anyway, despite instructions to the contrary. + // So reply that we're not interested. + XClientMessageEvent m; + memset(&m, 0, sizeof(m)); + m.type = ClientMessage; + m.display = e->display; + m.window = e->data.l[0]; + m.message_type = server.atom.XdndFinished; + m.format = 32; + m.data.l[0] = dnd_target_window; + m.data.l[1] = 0; + m.data.l[2] = None; // Failed. + XSendEvent(server.display, e->data.l[0], False, NoEventMask, (XEvent *)&m); + } } int main(int argc, char *argv[]) { start: - init(argc, argv); + init(argc, argv); - init_X11_pre_config(); + init_X11_pre_config(); - if (!config_read()) { - fprintf(stderr, - "Could not read config file.\n"); - print_usage(); - cleanup(); - exit(1); - } + if (!config_read()) { + fprintf(stderr, "Could not read config file.\n"); + print_usage(); + cleanup(); + exit(1); + } - init_X11_post_config(); - start_detect_compositor(); + init_X11_post_config(); + start_detect_compositor(); - init_panel(); + init_panel(); - if (snapshot_path) { - get_snapshot(snapshot_path); - cleanup(); - exit(0); - } + if (snapshot_path) { + get_snapshot(snapshot_path); + cleanup(); + exit(0); + } - int damage_event, damage_error; - XDamageQueryExtension(server.display, &damage_event, &damage_error); - int x11_fd = ConnectionNumber(server.display); - XSync(server.display, False); + int damage_event, damage_error; + XDamageQueryExtension(server.display, &damage_event, &damage_error); + int x11_fd = ConnectionNumber(server.display); + XSync(server.display, False); - // XDND initialization - dnd_source_window = 0; - dnd_target_window = 0; - dnd_version = 0; - dnd_selection = XInternAtom(server.display, "PRIMARY", 0); - dnd_atom = None; - dnd_sent_request = 0; - dnd_launcher_exec = 0; + // XDND initialization + dnd_source_window = 0; + dnd_target_window = 0; + dnd_version = 0; + dnd_selection = XInternAtom(server.display, "PRIMARY", 0); + dnd_atom = None; + dnd_sent_request = 0; + dnd_launcher_exec = 0; - int ufd = uevent_init(); - int hidden_dnd = 0; + int ufd = uevent_init(); + int hidden_dnd = 0; - double ts_event_read = 0; - double ts_event_processed = 0; - double ts_render_finished = 0; - double ts_flush_finished = 0; - gboolean first_render = TRUE; - while (1) { - if (panel_refresh) { - if (debug_fps) - ts_event_processed = get_time(); - if (systray_profile) - fprintf(stderr, - BLUE "[%f] %s:%d redrawing panel" RESET "\n", - profiling_get_time(), - __FUNCTION__, - __LINE__); - panel_refresh = FALSE; + double ts_event_read = 0; + double ts_event_processed = 0; + double ts_render_finished = 0; + double ts_flush_finished = 0; + gboolean first_render = TRUE; + while (1) { + if (panel_refresh) { + if (debug_fps) + ts_event_processed = get_time(); + if (systray_profile) + fprintf(stderr, + BLUE "[%f] %s:%d redrawing panel" RESET "\n", + profiling_get_time(), + __FUNCTION__, + __LINE__); + panel_refresh = FALSE; - for (int i = 0; i < num_panels; i++) { - Panel *panel = &panels[i]; - if (!first_render) - shrink_panel(panel); + for (int i = 0; i < num_panels; i++) { + Panel *panel = &panels[i]; + if (!first_render) + shrink_panel(panel); - if (!panel->is_hidden || panel->area.resize_needed) { - if (panel->temp_pmap) - XFreePixmap(server.display, panel->temp_pmap); - panel->temp_pmap = XCreatePixmap(server.display, - server.root_win, - panel->area.width, - panel->area.height, - server.depth); - render_panel(panel); - } + if (!panel->is_hidden || panel->area.resize_needed) { + if (panel->temp_pmap) + XFreePixmap(server.display, panel->temp_pmap); + panel->temp_pmap = XCreatePixmap(server.display, + server.root_win, + panel->area.width, + panel->area.height, + server.depth); + render_panel(panel); + } - if (panel->is_hidden) { - if (!panel->hidden_pixmap) { - panel->hidden_pixmap = XCreatePixmap(server.display, - server.root_win, - panel->hidden_width, - panel->hidden_height, - server.depth); - int xoff = 0, yoff = 0; - if (panel_horizontal && panel_position & BOTTOM) - yoff = panel->area.height - panel->hidden_height; - else if (!panel_horizontal && panel_position & RIGHT) - xoff = panel->area.width - panel->hidden_width; - XCopyArea(server.display, - panel->area.pix, - panel->hidden_pixmap, - server.gc, - xoff, - yoff, - panel->hidden_width, - panel->hidden_height, - 0, - 0); - } - XCopyArea(server.display, - panel->hidden_pixmap, - panel->main_win, - server.gc, - 0, - 0, - panel->hidden_width, - panel->hidden_height, - 0, - 0); - XSetWindowBackgroundPixmap(server.display, panel->main_win, panel->hidden_pixmap); - } else { - XCopyArea(server.display, - panel->temp_pmap, - panel->main_win, - server.gc, - 0, - 0, - panel->area.width, - panel->area.height, - 0, - 0); - if (panel == (Panel *)systray.area.panel) { - if (refresh_systray && panel && !panel->is_hidden) { - refresh_systray = FALSE; - XSetWindowBackgroundPixmap(server.display, panel->main_win, panel->temp_pmap); - refresh_systray_icons(); - } - } - } - } - if (first_render) { - first_render = FALSE; - if (panel_shrink) - schedule_panel_redraw(); - } - if (debug_fps) - ts_render_finished = get_time(); - XFlush(server.display); - if (debug_fps && ts_event_read > 0) { - ts_flush_finished = get_time(); - double period = ts_flush_finished - ts_event_read; - double fps = 1.0 / period; - sample_fps(fps); - double proc_ratio = (ts_event_processed - ts_event_read) / period; - double render_ratio = (ts_render_finished - ts_event_processed) / period; - double flush_ratio = (ts_flush_finished - ts_render_finished) / period; - double fps_low, fps_median, fps_high, fps_samples; - fps_compute_stats(&fps_low, &fps_median, &fps_high, &fps_samples); - fprintf(stderr, - BLUE "frame %d: fps = %.0f (low %.0f, med %.0f, high %.0f, samples %.0f) : processing %.0f%%, rendering %.0f%%, " - "flushing %.0f%%" RESET "\n", - frame, - fps, - fps_low, - fps_median, - fps_high, - fps_samples, - proc_ratio * 100, - render_ratio * 100, - flush_ratio * 100); - } - if (debug_frames) { - for (int i = 0; i < num_panels; i++) { - char path[256]; - sprintf(path, "tint2-%d-panel-%d-frame-%d.png", getpid(), i, frame); - dump_panel_to_file(&panels[i], path); - } - } - frame++; - } + if (panel->is_hidden) { + if (!panel->hidden_pixmap) { + panel->hidden_pixmap = XCreatePixmap(server.display, + server.root_win, + panel->hidden_width, + panel->hidden_height, + server.depth); + int xoff = 0, yoff = 0; + if (panel_horizontal && panel_position & BOTTOM) + yoff = panel->area.height - panel->hidden_height; + else if (!panel_horizontal && panel_position & RIGHT) + xoff = panel->area.width - panel->hidden_width; + XCopyArea(server.display, + panel->area.pix, + panel->hidden_pixmap, + server.gc, + xoff, + yoff, + panel->hidden_width, + panel->hidden_height, + 0, + 0); + } + XCopyArea(server.display, + panel->hidden_pixmap, + panel->main_win, + server.gc, + 0, + 0, + panel->hidden_width, + panel->hidden_height, + 0, + 0); + XSetWindowBackgroundPixmap(server.display, panel->main_win, panel->hidden_pixmap); + } else { + XCopyArea(server.display, + panel->temp_pmap, + panel->main_win, + server.gc, + 0, + 0, + panel->area.width, + panel->area.height, + 0, + 0); + if (panel == (Panel *)systray.area.panel) { + if (refresh_systray && panel && !panel->is_hidden) { + refresh_systray = FALSE; + XSetWindowBackgroundPixmap(server.display, panel->main_win, panel->temp_pmap); + refresh_systray_icons(); + } + } + } + } + if (first_render) { + first_render = FALSE; + if (panel_shrink) + schedule_panel_redraw(); + } + if (debug_fps) + ts_render_finished = get_time(); + XFlush(server.display); + if (debug_fps && ts_event_read > 0) { + ts_flush_finished = get_time(); + double period = ts_flush_finished - ts_event_read; + double fps = 1.0 / period; + sample_fps(fps); + double proc_ratio = (ts_event_processed - ts_event_read) / period; + double render_ratio = (ts_render_finished - ts_event_processed) / period; + double flush_ratio = (ts_flush_finished - ts_render_finished) / period; + double fps_low, fps_median, fps_high, fps_samples; + fps_compute_stats(&fps_low, &fps_median, &fps_high, &fps_samples); + fprintf(stderr, + BLUE "frame %d: fps = %.0f (low %.0f, med %.0f, high %.0f, samples %.0f) : processing %.0f%%, " + "rendering %.0f%%, " + "flushing %.0f%%" RESET "\n", + frame, + fps, + fps_low, + fps_median, + fps_high, + fps_samples, + proc_ratio * 100, + render_ratio * 100, + flush_ratio * 100); + } + if (debug_frames) { + for (int i = 0; i < num_panels; i++) { + char path[256]; + sprintf(path, "tint2-%d-panel-%d-frame-%d.png", getpid(), i, frame); + dump_panel_to_file(&panels[i], path); + } + } + frame++; + } - // Create a File Description Set containing x11_fd - fd_set fdset; - FD_ZERO(&fdset); - FD_SET(x11_fd, &fdset); - int maxfd = x11_fd; - if (sigchild_pipe_valid) { - FD_SET(sigchild_pipe[0], &fdset); - maxfd = maxfd < sigchild_pipe[0] ? sigchild_pipe[0] : maxfd; - } - for (GList *l = panel_config.execp_list; l; l = l->next) { - Execp *execp = (Execp *)l->data; - int fd = execp->backend->child_pipe; - if (fd > 0) { - FD_SET(fd, &fdset); - maxfd = maxfd < fd ? fd : maxfd; - } - } - if (ufd > 0) { - FD_SET(ufd, &fdset); - maxfd = maxfd < ufd ? ufd : maxfd; - } - update_next_timeout(); - struct timeval *select_timeout = (next_timeout.tv_sec >= 0 && next_timeout.tv_usec >= 0) ? &next_timeout : NULL; + // Create a File Description Set containing x11_fd + fd_set fdset; + FD_ZERO(&fdset); + FD_SET(x11_fd, &fdset); + int maxfd = x11_fd; + if (sigchild_pipe_valid) { + FD_SET(sigchild_pipe[0], &fdset); + maxfd = maxfd < sigchild_pipe[0] ? sigchild_pipe[0] : maxfd; + } + for (GList *l = panel_config.execp_list; l; l = l->next) { + Execp *execp = (Execp *)l->data; + int fd = execp->backend->child_pipe; + if (fd > 0) { + FD_SET(fd, &fdset); + maxfd = maxfd < fd ? fd : maxfd; + } + } + if (ufd > 0) { + FD_SET(ufd, &fdset); + maxfd = maxfd < ufd ? ufd : maxfd; + } + update_next_timeout(); + struct timeval *select_timeout = (next_timeout.tv_sec >= 0 && next_timeout.tv_usec >= 0) ? &next_timeout : NULL; - // Wait for X Event or a Timer - ts_event_read = 0; - if (XPending(server.display) > 0 || select(maxfd + 1, &fdset, 0, 0, select_timeout) >= 0) { - uevent_handler(); + // Wait for X Event or a Timer + ts_event_read = 0; + if (XPending(server.display) > 0 || select(maxfd + 1, &fdset, 0, 0, select_timeout) >= 0) { + uevent_handler(); - if (sigchild_pipe_valid) { - char buffer[1]; - while (read(sigchild_pipe[0], buffer, sizeof(buffer)) > 0) { - sigchld_handler_async(); - } - } - for (GList *l = panel_config.execp_list; l; l = l->next) { - Execp *execp = (Execp *)l->data; - if (read_execp(execp)) { - GList *l_instance; - for (l_instance = execp->backend->instances; l_instance; l_instance = l_instance->next) { - Execp *instance = l_instance->data; - instance->area.resize_needed = TRUE; - schedule_panel_redraw(); - } - } - } - if (XPending(server.display) > 0) { - XEvent e; - XNextEvent(server.display, &e); - if (debug_fps) - ts_event_read = get_time(); + if (sigchild_pipe_valid) { + char buffer[1]; + while (read(sigchild_pipe[0], buffer, sizeof(buffer)) > 0) { + sigchld_handler_async(); + } + } + for (GList *l = panel_config.execp_list; l; l = l->next) { + Execp *execp = (Execp *)l->data; + if (read_execp(execp)) { + GList *l_instance; + for (l_instance = execp->backend->instances; l_instance; l_instance = l_instance->next) { + Execp *instance = l_instance->data; + instance->area.resize_needed = TRUE; + schedule_panel_redraw(); + } + } + } + if (XPending(server.display) > 0) { + XEvent e; + XNextEvent(server.display, &e); + if (debug_fps) + ts_event_read = get_time(); #if HAVE_SN - if (startup_notifications) - sn_display_process_event(server.sn_display, &e); + if (startup_notifications) + sn_display_process_event(server.sn_display, &e); #endif // HAVE_SN - Panel *panel = get_panel(e.xany.window); - if (panel && panel_autohide) { - if (e.type == EnterNotify) - autohide_trigger_show(panel); - else if (e.type == LeaveNotify) - autohide_trigger_hide(panel); - if (panel->is_hidden) { - if (e.type == ClientMessage && e.xclient.message_type == server.atom.XdndPosition) { - hidden_dnd = 1; - autohide_show(panel); - } else - continue; // discard further processing of this event because the panel is not visible yet - } else if (hidden_dnd && e.type == ClientMessage && - e.xclient.message_type == server.atom.XdndLeave) { - hidden_dnd = 0; - autohide_hide(panel); - } - } + Panel *panel = get_panel(e.xany.window); + if (panel && panel_autohide) { + if (e.type == EnterNotify) + autohide_trigger_show(panel); + else if (e.type == LeaveNotify) + autohide_trigger_hide(panel); + if (panel->is_hidden) { + if (e.type == ClientMessage && e.xclient.message_type == server.atom.XdndPosition) { + hidden_dnd = 1; + autohide_show(panel); + } else + continue; // discard further processing of this event because the panel is not visible yet + } else if (hidden_dnd && e.type == ClientMessage && + e.xclient.message_type == server.atom.XdndLeave) { + hidden_dnd = 0; + autohide_hide(panel); + } + } - switch (e.type) { - case ButtonPress: { - tooltip_hide(0); - event_button_press(&e); - Area *area = find_area_under_mouse(panel, e.xbutton.x, e.xbutton.y); - if (panel_config.mouse_effects) - mouse_over(area, 1); - break; - } + switch (e.type) { + case ButtonPress: { + tooltip_hide(0); + event_button_press(&e); + Area *area = find_area_under_mouse(panel, e.xbutton.x, e.xbutton.y); + if (panel_config.mouse_effects) + mouse_over(area, 1); + break; + } - case ButtonRelease: { - event_button_release(&e); - Area *area = find_area_under_mouse(panel, e.xbutton.x, e.xbutton.y); - if (panel_config.mouse_effects) - mouse_over(area, 0); - break; - } + case ButtonRelease: { + event_button_release(&e); + Area *area = find_area_under_mouse(panel, e.xbutton.x, e.xbutton.y); + if (panel_config.mouse_effects) + mouse_over(area, 0); + break; + } - case MotionNotify: { - unsigned int button_mask = Button1Mask | Button2Mask | Button3Mask | Button4Mask | Button5Mask; - if (e.xmotion.state & button_mask) - event_button_motion_notify(&e); + case MotionNotify: { + unsigned int button_mask = Button1Mask | Button2Mask | Button3Mask | Button4Mask | Button5Mask; + if (e.xmotion.state & button_mask) + event_button_motion_notify(&e); - Area *area = find_area_under_mouse(panel, e.xmotion.x, e.xmotion.y); - if (area->_get_tooltip_text) - tooltip_trigger_show(area, panel, &e); - else - tooltip_trigger_hide(); - if (panel_config.mouse_effects) - mouse_over(area, e.xmotion.state & button_mask); - break; - } + Area *area = find_area_under_mouse(panel, e.xmotion.x, e.xmotion.y); + if (area->_get_tooltip_text) + tooltip_trigger_show(area, panel, &e); + else + tooltip_trigger_hide(); + if (panel_config.mouse_effects) + mouse_over(area, e.xmotion.state & button_mask); + break; + } - case LeaveNotify: - tooltip_trigger_hide(); - if (panel_config.mouse_effects) - mouse_out(); - break; + case LeaveNotify: + tooltip_trigger_hide(); + if (panel_config.mouse_effects) + mouse_out(); + break; - case Expose: - event_expose(&e); - break; + case Expose: + event_expose(&e); + break; - case PropertyNotify: - event_property_notify(&e); - break; + case PropertyNotify: + event_property_notify(&e); + break; - case ConfigureNotify: - event_configure_notify(&e); - break; + case ConfigureNotify: + event_configure_notify(&e); + break; - case ConfigureRequest: { - TrayWindow *traywin = systray_find_icon(e.xany.window); - if (traywin) - systray_reconfigure_event(traywin, &e); - break; - } + case ConfigureRequest: { + TrayWindow *traywin = systray_find_icon(e.xany.window); + if (traywin) + systray_reconfigure_event(traywin, &e); + break; + } - case ResizeRequest: { - TrayWindow *traywin = systray_find_icon(e.xany.window); - if (traywin) - systray_resize_request_event(traywin, &e); - break; - } + case ResizeRequest: { + TrayWindow *traywin = systray_find_icon(e.xany.window); + if (traywin) + systray_resize_request_event(traywin, &e); + break; + } - case ReparentNotify: { - if (!systray_enabled) - break; - Panel *systray_panel = (Panel *)systray.area.panel; - if (e.xany.window == systray_panel->main_win) // don't care - break; - TrayWindow *traywin = systray_find_icon(e.xreparent.window); - if (traywin) { - if (traywin->win == e.xreparent.window) { - if (traywin->parent == e.xreparent.parent) { - embed_icon(traywin); - } else { - remove_icon(traywin); - } - break; - } - } - break; - } + case ReparentNotify: { + if (!systray_enabled) + break; + Panel *systray_panel = (Panel *)systray.area.panel; + if (e.xany.window == systray_panel->main_win) // don't care + break; + TrayWindow *traywin = systray_find_icon(e.xreparent.window); + if (traywin) { + if (traywin->win == e.xreparent.window) { + if (traywin->parent == e.xreparent.parent) { + embed_icon(traywin); + } else { + remove_icon(traywin); + } + break; + } + } + break; + } - case UnmapNotify: - break; + case UnmapNotify: + break; - case DestroyNotify: - if (e.xany.window == server.composite_manager) { - // Stop real_transparency - fprintf(stderr, - YELLOW "%s %d: triggering tint2 restart due to compositor shutdown" RESET "\n", - __FILE__, - __LINE__); - signal_pending = SIGUSR1; - break; - } - if (e.xany.window == g_tooltip.window || !systray_enabled) - break; - for (GSList *it = systray.list_icons; it; it = g_slist_next(it)) { - if (((TrayWindow *)it->data)->win == e.xany.window) { - systray_destroy_event((TrayWindow *)it->data); - break; - } - } - break; + case DestroyNotify: + if (e.xany.window == server.composite_manager) { + // Stop real_transparency + fprintf(stderr, + YELLOW "%s %d: triggering tint2 restart due to compositor shutdown" RESET "\n", + __FILE__, + __LINE__); + signal_pending = SIGUSR1; + break; + } + if (e.xany.window == g_tooltip.window || !systray_enabled) + break; + for (GSList *it = systray.list_icons; it; it = g_slist_next(it)) { + if (((TrayWindow *)it->data)->win == e.xany.window) { + systray_destroy_event((TrayWindow *)it->data); + break; + } + } + break; - case ClientMessage: { - XClientMessageEvent *ev = &e.xclient; - if (ev->data.l[1] == server.atom._NET_WM_CM_S0) { - if (ev->data.l[2] == None) { - // Stop real_transparency - fprintf(stderr, - YELLOW "%s %d: triggering tint2 restart due to change in transparency" RESET "\n", - __FILE__, - __LINE__); - signal_pending = SIGUSR1; - } else { - // Start real_transparency - fprintf(stderr, - YELLOW "%s %d: triggering tint2 restart due to change in transparency" RESET "\n", - __FILE__, - __LINE__); - signal_pending = SIGUSR1; - } - } - if (systray_enabled && e.xclient.message_type == server.atom._NET_SYSTEM_TRAY_OPCODE && - e.xclient.format == 32 && e.xclient.window == net_sel_win) { - net_message(&e.xclient); - } else if (e.xclient.message_type == server.atom.XdndEnter) { - dnd_enter(&e.xclient); - } else if (e.xclient.message_type == server.atom.XdndPosition) { - dnd_position(&e.xclient); - } else if (e.xclient.message_type == server.atom.XdndDrop) { - dnd_drop(&e.xclient); - } - break; - } + case ClientMessage: { + XClientMessageEvent *ev = &e.xclient; + if (ev->data.l[1] == server.atom._NET_WM_CM_S0) { + if (ev->data.l[2] == None) { + // Stop real_transparency + fprintf(stderr, + YELLOW "%s %d: triggering tint2 restart due to change in transparency" RESET "\n", + __FILE__, + __LINE__); + signal_pending = SIGUSR1; + } else { + // Start real_transparency + fprintf(stderr, + YELLOW "%s %d: triggering tint2 restart due to change in transparency" RESET "\n", + __FILE__, + __LINE__); + signal_pending = SIGUSR1; + } + } + if (systray_enabled && e.xclient.message_type == server.atom._NET_SYSTEM_TRAY_OPCODE && + e.xclient.format == 32 && e.xclient.window == net_sel_win) { + net_message(&e.xclient); + } else if (e.xclient.message_type == server.atom.XdndEnter) { + dnd_enter(&e.xclient); + } else if (e.xclient.message_type == server.atom.XdndPosition) { + dnd_position(&e.xclient); + } else if (e.xclient.message_type == server.atom.XdndDrop) { + dnd_drop(&e.xclient); + } + break; + } - case SelectionNotify: { - Atom target = e.xselection.target; + case SelectionNotify: { + Atom target = e.xselection.target; - fprintf(stderr, "DnD %s:%d: A selection notify has arrived!\n", __FILE__, __LINE__); - fprintf(stderr, "DnD %s:%d: Requestor = %lu\n", __FILE__, __LINE__, e.xselectionrequest.requestor); - fprintf(stderr, - "DnD %s:%d: Selection atom = %s\n", - __FILE__, - __LINE__, - GetAtomName(server.display, e.xselection.selection)); - fprintf(stderr, - "DnD %s:%d: Target atom = %s\n", - __FILE__, - __LINE__, - GetAtomName(server.display, target)); - fprintf(stderr, - "DnD %s:%d: Property atom = %s\n", - __FILE__, - __LINE__, - GetAtomName(server.display, e.xselection.property)); + fprintf(stderr, "DnD %s:%d: A selection notify has arrived!\n", __FILE__, __LINE__); + fprintf(stderr, "DnD %s:%d: Requestor = %lu\n", __FILE__, __LINE__, e.xselectionrequest.requestor); + fprintf(stderr, + "DnD %s:%d: Selection atom = %s\n", + __FILE__, + __LINE__, + GetAtomName(server.display, e.xselection.selection)); + fprintf(stderr, + "DnD %s:%d: Target atom = %s\n", + __FILE__, + __LINE__, + GetAtomName(server.display, target)); + fprintf(stderr, + "DnD %s:%d: Property atom = %s\n", + __FILE__, + __LINE__, + GetAtomName(server.display, e.xselection.property)); - if (e.xselection.property != None && dnd_launcher_exec) { - Property prop = read_property(server.display, dnd_target_window, dnd_selection); + if (e.xselection.property != None && dnd_launcher_exec) { + Property prop = read_property(server.display, dnd_target_window, dnd_selection); - // If we're being given a list of targets (possible conversions) - if (target == server.atom.TARGETS && !dnd_sent_request) { - dnd_sent_request = 1; - dnd_atom = pick_target_from_targets(server.display, prop); + // If we're being given a list of targets (possible conversions) + if (target == server.atom.TARGETS && !dnd_sent_request) { + dnd_sent_request = 1; + dnd_atom = pick_target_from_targets(server.display, prop); - if (dnd_atom == None) { - fprintf(stderr, "No matching datatypes.\n"); - } else { - // Request the data type we are able to select - fprintf(stderr, "Now requsting type %s", GetAtomName(server.display, dnd_atom)); - XConvertSelection(server.display, - dnd_selection, - dnd_atom, - dnd_selection, - dnd_target_window, - CurrentTime); - } - } else if (target == dnd_atom) { - // Dump the binary data - fprintf(stderr, "DnD %s:%d: Data begins:\n", __FILE__, __LINE__); - fprintf(stderr, "--------\n"); - for (int i = 0; i < prop.nitems * prop.format / 8; i++) - fprintf(stderr, "%c", ((char *)prop.data)[i]); - fprintf(stderr, "--------\n"); + if (dnd_atom == None) { + fprintf(stderr, "No matching datatypes.\n"); + } else { + // Request the data type we are able to select + fprintf(stderr, "Now requsting type %s", GetAtomName(server.display, dnd_atom)); + XConvertSelection(server.display, + dnd_selection, + dnd_atom, + dnd_selection, + dnd_target_window, + CurrentTime); + } + } else if (target == dnd_atom) { + // Dump the binary data + fprintf(stderr, "DnD %s:%d: Data begins:\n", __FILE__, __LINE__); + fprintf(stderr, "--------\n"); + for (int i = 0; i < prop.nitems * prop.format / 8; i++) + fprintf(stderr, "%c", ((char *)prop.data)[i]); + fprintf(stderr, "--------\n"); - int cmd_length = 0; - cmd_length += 1; // ( - cmd_length += strlen(dnd_launcher_exec) + 1; // exec + space - cmd_length += 1; // open double quotes - for (int i = 0; i < prop.nitems * prop.format / 8; i++) { - char c = ((char *)prop.data)[i]; - if (c == '\n') { - if (i < prop.nitems * prop.format / 8 - 1) { - cmd_length += 3; // close double quotes, space, open double quotes - } - } else if (c == '\r') { - // Nothing to do - } else { - cmd_length += 1; // 1 character - if (c == '`' || c == '$' || c == '\\') { - cmd_length += 1; // escape with one backslash - } - } - } - cmd_length += 1; // close double quotes - cmd_length += 2; // &) - cmd_length += 1; // terminator + int cmd_length = 0; + cmd_length += 1; // ( + cmd_length += strlen(dnd_launcher_exec) + 1; // exec + space + cmd_length += 1; // open double quotes + for (int i = 0; i < prop.nitems * prop.format / 8; i++) { + char c = ((char *)prop.data)[i]; + if (c == '\n') { + if (i < prop.nitems * prop.format / 8 - 1) { + cmd_length += 3; // close double quotes, space, open double quotes + } + } else if (c == '\r') { + // Nothing to do + } else { + cmd_length += 1; // 1 character + if (c == '`' || c == '$' || c == '\\') { + cmd_length += 1; // escape with one backslash + } + } + } + cmd_length += 1; // close double quotes + cmd_length += 2; // &) + cmd_length += 1; // terminator - char *cmd = calloc(cmd_length, 1); - cmd[0] = '\0'; - strcat(cmd, "("); - strcat(cmd, dnd_launcher_exec); - strcat(cmd, " \""); - for (int i = 0; i < prop.nitems * prop.format / 8; i++) { - char c = ((char *)prop.data)[i]; - if (c == '\n') { - if (i < prop.nitems * prop.format / 8 - 1) { - strcat(cmd, "\" \""); - } - } else if (c == '\r') { - // Nothing to do - } else { - if (c == '`' || c == '$' || c == '\\') { - strcat(cmd, "\\"); - } - char sc[2]; - sc[0] = c; - sc[1] = '\0'; - strcat(cmd, sc); - } - } - strcat(cmd, "\""); - strcat(cmd, "&)"); - fprintf(stderr, "DnD %s:%d: Running command: %s\n", __FILE__, __LINE__, cmd); - tint_exec(cmd); - free(cmd); + char *cmd = calloc(cmd_length, 1); + cmd[0] = '\0'; + strcat(cmd, "("); + strcat(cmd, dnd_launcher_exec); + strcat(cmd, " \""); + for (int i = 0; i < prop.nitems * prop.format / 8; i++) { + char c = ((char *)prop.data)[i]; + if (c == '\n') { + if (i < prop.nitems * prop.format / 8 - 1) { + strcat(cmd, "\" \""); + } + } else if (c == '\r') { + // Nothing to do + } else { + if (c == '`' || c == '$' || c == '\\') { + strcat(cmd, "\\"); + } + char sc[2]; + sc[0] = c; + sc[1] = '\0'; + strcat(cmd, sc); + } + } + strcat(cmd, "\""); + strcat(cmd, "&)"); + fprintf(stderr, "DnD %s:%d: Running command: %s\n", __FILE__, __LINE__, cmd); + tint_exec(cmd); + free(cmd); - // Reply OK. - XClientMessageEvent m; - memset(&m, 0, sizeof(m)); - m.type = ClientMessage; - m.display = server.display; - m.window = dnd_source_window; - m.message_type = server.atom.XdndFinished; - m.format = 32; - m.data.l[0] = dnd_target_window; - m.data.l[1] = 1; - m.data.l[2] = server.atom.XdndActionCopy; // We only ever copy. - XSendEvent(server.display, dnd_source_window, False, NoEventMask, (XEvent *)&m); - XSync(server.display, False); - } + // Reply OK. + XClientMessageEvent m; + memset(&m, 0, sizeof(m)); + m.type = ClientMessage; + m.display = server.display; + m.window = dnd_source_window; + m.message_type = server.atom.XdndFinished; + m.format = 32; + m.data.l[0] = dnd_target_window; + m.data.l[1] = 1; + m.data.l[2] = server.atom.XdndActionCopy; // We only ever copy. + XSendEvent(server.display, dnd_source_window, False, NoEventMask, (XEvent *)&m); + XSync(server.display, False); + } - XFree(prop.data); - } - break; - } + XFree(prop.data); + } + break; + } - default: - if (e.type == XDamageNotify + damage_event) { - XDamageNotifyEvent *de = (XDamageNotifyEvent *)&e; - TrayWindow *traywin = systray_find_icon(de->drawable); - if (traywin) - systray_render_icon(traywin); - } - } - } - } + default: + if (e.type == XDamageNotify + damage_event) { + XDamageNotifyEvent *de = (XDamageNotifyEvent *)&e; + TrayWindow *traywin = systray_find_icon(de->drawable); + if (traywin) + systray_render_icon(traywin); + } + } + } + } - callback_timeout_expired(); + callback_timeout_expired(); - if (signal_pending) { - cleanup(); - if (signal_pending == SIGUSR1) { - fprintf(stderr, YELLOW "%s %d: restarting tint2..." RESET "\n", __FILE__, __LINE__); - // restart tint2 - // SIGUSR1 used when : user's signal, composite manager stop/start or xrandr - goto start; - } else { - // SIGINT, SIGTERM, SIGHUP - exit(0); - } - } - } + if (signal_pending) { + cleanup(); + if (signal_pending == SIGUSR1) { + fprintf(stderr, YELLOW "%s %d: restarting tint2..." RESET "\n", __FILE__, __LINE__); + // restart tint2 + // SIGUSR1 used when : user's signal, composite manager stop/start or xrandr + goto start; + } else { + // SIGINT, SIGTERM, SIGHUP + exit(0); + } + } + } }
M src/tint2conf/background_gui.csrc/tint2conf/background_gui.c

@@ -10,1029 +10,1029 @@ *background_border_sides_right;

GtkWidget *create_background_combo(const char *label) { - GtkWidget *combo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(backgrounds)); - GtkCellRenderer *renderer = gtk_cell_renderer_pixbuf_new(); - gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), renderer, FALSE); - gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo), renderer, "pixbuf", bgColPixbuf, NULL); - renderer = gtk_cell_renderer_text_new(); - g_object_set(renderer, "wrap-mode", PANGO_WRAP_WORD, NULL); - g_object_set(renderer, "wrap-width", 300, NULL); - gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), renderer, FALSE); - gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo), renderer, "text", bgColText, NULL); - g_signal_connect(G_OBJECT(combo), "changed", G_CALLBACK(background_combo_changed), (void *)label); - return combo; + GtkWidget *combo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(backgrounds)); + GtkCellRenderer *renderer = gtk_cell_renderer_pixbuf_new(); + gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), renderer, FALSE); + gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo), renderer, "pixbuf", bgColPixbuf, NULL); + renderer = gtk_cell_renderer_text_new(); + g_object_set(renderer, "wrap-mode", PANGO_WRAP_WORD, NULL); + g_object_set(renderer, "wrap-width", 300, NULL); + gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), renderer, FALSE); + gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo), renderer, "text", bgColText, NULL); + g_signal_connect(G_OBJECT(combo), "changed", G_CALLBACK(background_combo_changed), (void *)label); + return combo; } void background_combo_changed(GtkWidget *widget, gpointer data) { - gchar *combo_text = (gchar *)data; - if (!combo_text || g_str_equal(combo_text, "")) - return; - int selected_index = gtk_combo_box_get_active(GTK_COMBO_BOX(widget)); + gchar *combo_text = (gchar *)data; + if (!combo_text || g_str_equal(combo_text, "")) + return; + int selected_index = gtk_combo_box_get_active(GTK_COMBO_BOX(widget)); - int index; - for (index = 0;; index++) { - GtkTreePath *path; - GtkTreeIter iter; + int index; + for (index = 0;; index++) { + GtkTreePath *path; + GtkTreeIter iter; - path = gtk_tree_path_new_from_indices(index, -1); - gboolean found = gtk_tree_model_get_iter(GTK_TREE_MODEL(backgrounds), &iter, path); - gtk_tree_path_free(path); + path = gtk_tree_path_new_from_indices(index, -1); + gboolean found = gtk_tree_model_get_iter(GTK_TREE_MODEL(backgrounds), &iter, path); + gtk_tree_path_free(path); - if (!found) { - break; - } + if (!found) { + break; + } - gchar *text; - gtk_tree_model_get(GTK_TREE_MODEL(backgrounds), &iter, bgColText, &text, -1); - gchar **parts = g_strsplit(text, ", ", -1); - int ifound; - for (ifound = 0; parts[ifound]; ifound++) { - if (g_str_equal(parts[ifound], combo_text)) - break; - } - if (parts[ifound] && index != selected_index) { - for (; parts[ifound + 1]; ifound++) { - gchar *tmp = parts[ifound]; - parts[ifound] = parts[ifound + 1]; - parts[ifound + 1] = tmp; - } - g_free(parts[ifound]); - parts[ifound] = NULL; - text = g_strjoinv(", ", parts); - g_strfreev(parts); - gtk_list_store_set(backgrounds, &iter, bgColText, text, -1); - g_free(text); - } else if (!parts[ifound] && index == selected_index) { - if (!ifound) { - text = g_strdup(combo_text); - } else { - for (ifound = 0; parts[ifound]; ifound++) { - if (compare_strings(combo_text, parts[ifound]) < 0) - break; - } - if (parts[ifound]) { - gchar *tmp = parts[ifound]; - parts[ifound] = g_strconcat(combo_text, ", ", tmp, NULL); - g_free(tmp); - } else { - ifound--; - gchar *tmp = parts[ifound]; - parts[ifound] = g_strconcat(tmp, ", ", combo_text, NULL); - g_free(tmp); - } - text = g_strjoinv(", ", parts); - g_strfreev(parts); - } - gtk_list_store_set(backgrounds, &iter, bgColText, text, -1); - g_free(text); - } - } + gchar *text; + gtk_tree_model_get(GTK_TREE_MODEL(backgrounds), &iter, bgColText, &text, -1); + gchar **parts = g_strsplit(text, ", ", -1); + int ifound; + for (ifound = 0; parts[ifound]; ifound++) { + if (g_str_equal(parts[ifound], combo_text)) + break; + } + if (parts[ifound] && index != selected_index) { + for (; parts[ifound + 1]; ifound++) { + gchar *tmp = parts[ifound]; + parts[ifound] = parts[ifound + 1]; + parts[ifound + 1] = tmp; + } + g_free(parts[ifound]); + parts[ifound] = NULL; + text = g_strjoinv(", ", parts); + g_strfreev(parts); + gtk_list_store_set(backgrounds, &iter, bgColText, text, -1); + g_free(text); + } else if (!parts[ifound] && index == selected_index) { + if (!ifound) { + text = g_strdup(combo_text); + } else { + for (ifound = 0; parts[ifound]; ifound++) { + if (compare_strings(combo_text, parts[ifound]) < 0) + break; + } + if (parts[ifound]) { + gchar *tmp = parts[ifound]; + parts[ifound] = g_strconcat(combo_text, ", ", tmp, NULL); + g_free(tmp); + } else { + ifound--; + gchar *tmp = parts[ifound]; + parts[ifound] = g_strconcat(tmp, ", ", combo_text, NULL); + g_free(tmp); + } + text = g_strjoinv(", ", parts); + g_strfreev(parts); + } + gtk_list_store_set(backgrounds, &iter, bgColText, text, -1); + g_free(text); + } + } } void create_background(GtkWidget *parent) { - backgrounds = gtk_list_store_new(bgNumCols, - GDK_TYPE_PIXBUF, - GDK_TYPE_COLOR, - GTK_TYPE_INT, - GDK_TYPE_COLOR, - GTK_TYPE_INT, - GTK_TYPE_INT, - GTK_TYPE_INT, - GTK_TYPE_INT, - GTK_TYPE_STRING, - GDK_TYPE_COLOR, - GTK_TYPE_INT, - GDK_TYPE_COLOR, - GTK_TYPE_INT, - GTK_TYPE_INT, - GDK_TYPE_COLOR, - GTK_TYPE_INT, - GDK_TYPE_COLOR, - GTK_TYPE_INT, - GTK_TYPE_INT, - GTK_TYPE_BOOL, - GTK_TYPE_BOOL, - GTK_TYPE_BOOL, - GTK_TYPE_BOOL); + backgrounds = gtk_list_store_new(bgNumCols, + GDK_TYPE_PIXBUF, + GDK_TYPE_COLOR, + GTK_TYPE_INT, + GDK_TYPE_COLOR, + GTK_TYPE_INT, + GTK_TYPE_INT, + GTK_TYPE_INT, + GTK_TYPE_INT, + GTK_TYPE_STRING, + GDK_TYPE_COLOR, + GTK_TYPE_INT, + GDK_TYPE_COLOR, + GTK_TYPE_INT, + GTK_TYPE_INT, + GDK_TYPE_COLOR, + GTK_TYPE_INT, + GDK_TYPE_COLOR, + GTK_TYPE_INT, + GTK_TYPE_INT, + GTK_TYPE_BOOL, + GTK_TYPE_BOOL, + GTK_TYPE_BOOL, + GTK_TYPE_BOOL); - GtkWidget *table, *label, *button; - int row, col; - GtkTooltips *tooltips = gtk_tooltips_new(); + GtkWidget *table, *label, *button; + int row, col; + GtkTooltips *tooltips = gtk_tooltips_new(); - table = gtk_table_new(1, 4, FALSE); - gtk_widget_show(table); - gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); - gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); - gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); + table = gtk_table_new(1, 4, FALSE); + gtk_widget_show(table); + gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); + gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); + gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); - row = 0, col = 0; - label = gtk_label_new(_("<b>Background</b>")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_label_set_use_markup(GTK_LABEL(label), TRUE); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); - col++; + row = 0, col = 0; + label = gtk_label_new(_("<b>Background</b>")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_label_set_use_markup(GTK_LABEL(label), TRUE); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - current_background = create_background_combo(NULL); - gtk_widget_show(current_background); - gtk_table_attach(GTK_TABLE(table), current_background, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, current_background, _("Selects the background you would like to modify"), NULL); + current_background = create_background_combo(NULL); + gtk_widget_show(current_background); + gtk_table_attach(GTK_TABLE(table), current_background, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, current_background, _("Selects the background you would like to modify"), NULL); - button = gtk_button_new_from_stock("gtk-add"); - gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(background_duplicate), NULL); - gtk_widget_show(button); - gtk_table_attach(GTK_TABLE(table), button, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, button, _("Creates a copy of the current background"), NULL); + button = gtk_button_new_from_stock("gtk-add"); + gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(background_duplicate), NULL); + gtk_widget_show(button); + gtk_table_attach(GTK_TABLE(table), button, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, button, _("Creates a copy of the current background"), NULL); - button = gtk_button_new_from_stock("gtk-remove"); - gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(background_delete), NULL); - gtk_widget_show(button); - gtk_table_attach(GTK_TABLE(table), button, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, button, _("Deletes the current background"), NULL); + button = gtk_button_new_from_stock("gtk-remove"); + gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(background_delete), NULL); + gtk_widget_show(button); + gtk_table_attach(GTK_TABLE(table), button, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, button, _("Deletes the current background"), NULL); - table = gtk_table_new(4, 4, FALSE); - gtk_widget_show(table); - gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); - gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); - gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); + table = gtk_table_new(4, 4, FALSE); + gtk_widget_show(table); + gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); + gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); + gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); - row++, col = 2; - label = gtk_label_new(_("Fill color")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Fill color")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - background_fill_color = gtk_color_button_new(); - gtk_color_button_set_use_alpha(GTK_COLOR_BUTTON(background_fill_color), TRUE); - gtk_widget_show(background_fill_color); - gtk_table_attach(GTK_TABLE(table), background_fill_color, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, background_fill_color, _("The fill color of the current background"), NULL); + background_fill_color = gtk_color_button_new(); + gtk_color_button_set_use_alpha(GTK_COLOR_BUTTON(background_fill_color), TRUE); + gtk_widget_show(background_fill_color); + gtk_table_attach(GTK_TABLE(table), background_fill_color, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, background_fill_color, _("The fill color of the current background"), NULL); - row++, col = 2; - label = gtk_label_new(_("Border color")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Border color")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - background_border_color = gtk_color_button_new(); - gtk_color_button_set_use_alpha(GTK_COLOR_BUTTON(background_border_color), TRUE); - gtk_widget_show(background_border_color); - gtk_table_attach(GTK_TABLE(table), background_border_color, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, background_border_color, _("The border color of the current background"), NULL); + background_border_color = gtk_color_button_new(); + gtk_color_button_set_use_alpha(GTK_COLOR_BUTTON(background_border_color), TRUE); + gtk_widget_show(background_border_color); + gtk_table_attach(GTK_TABLE(table), background_border_color, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, background_border_color, _("The border color of the current background"), NULL); - row++, col = 2; - label = gtk_label_new(_("Gradient")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Gradient")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - background_gradient = create_gradient_combo(); - gtk_widget_show(background_gradient); - gtk_table_attach(GTK_TABLE(table), background_gradient, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); - col++; + background_gradient = create_gradient_combo(); + gtk_widget_show(background_gradient); + gtk_table_attach(GTK_TABLE(table), background_gradient, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - row++, col = 2; - label = gtk_label_new(_("Fill color (mouse over)")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Fill color (mouse over)")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - background_fill_color_over = gtk_color_button_new(); - gtk_color_button_set_use_alpha(GTK_COLOR_BUTTON(background_fill_color_over), TRUE); - gtk_widget_show(background_fill_color_over); - gtk_table_attach(GTK_TABLE(table), background_fill_color_over, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, - background_fill_color_over, - _("The fill color of the current background on mouse over"), - NULL); + background_fill_color_over = gtk_color_button_new(); + gtk_color_button_set_use_alpha(GTK_COLOR_BUTTON(background_fill_color_over), TRUE); + gtk_widget_show(background_fill_color_over); + gtk_table_attach(GTK_TABLE(table), background_fill_color_over, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + background_fill_color_over, + _("The fill color of the current background on mouse over"), + NULL); - row++, col = 2; - label = gtk_label_new(_("Border color (mouse over)")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Border color (mouse over)")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - background_border_color_over = gtk_color_button_new(); - gtk_color_button_set_use_alpha(GTK_COLOR_BUTTON(background_border_color_over), TRUE); - gtk_widget_show(background_border_color_over); - gtk_table_attach(GTK_TABLE(table), background_border_color_over, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, - background_border_color_over, - _("The border color of the current background on mouse over"), - NULL); + background_border_color_over = gtk_color_button_new(); + gtk_color_button_set_use_alpha(GTK_COLOR_BUTTON(background_border_color_over), TRUE); + gtk_widget_show(background_border_color_over); + gtk_table_attach(GTK_TABLE(table), background_border_color_over, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + background_border_color_over, + _("The border color of the current background on mouse over"), + NULL); - row++, col = 2; - label = gtk_label_new(_("Gradient (mouse over)")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Gradient (mouse over)")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - background_gradient_over = create_gradient_combo(); - gtk_widget_show(background_gradient_over); - gtk_table_attach(GTK_TABLE(table), background_gradient_over, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); - col++; + background_gradient_over = create_gradient_combo(); + gtk_widget_show(background_gradient_over); + gtk_table_attach(GTK_TABLE(table), background_gradient_over, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - row++, col = 2; - label = gtk_label_new(_("Fill color (pressed)")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Fill color (pressed)")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - background_fill_color_press = gtk_color_button_new(); - gtk_color_button_set_use_alpha(GTK_COLOR_BUTTON(background_fill_color_press), TRUE); - gtk_widget_show(background_fill_color_press); - gtk_table_attach(GTK_TABLE(table), background_fill_color_press, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, - background_fill_color_press, - _("The fill color of the current background on mouse button press"), - NULL); + background_fill_color_press = gtk_color_button_new(); + gtk_color_button_set_use_alpha(GTK_COLOR_BUTTON(background_fill_color_press), TRUE); + gtk_widget_show(background_fill_color_press); + gtk_table_attach(GTK_TABLE(table), background_fill_color_press, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + background_fill_color_press, + _("The fill color of the current background on mouse button press"), + NULL); - row++, col = 2; - label = gtk_label_new(_("Border color (pressed)")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Border color (pressed)")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - background_border_color_press = gtk_color_button_new(); - gtk_color_button_set_use_alpha(GTK_COLOR_BUTTON(background_border_color_press), TRUE); - gtk_widget_show(background_border_color_press); - gtk_table_attach(GTK_TABLE(table), background_border_color_press, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, - background_border_color_press, - _("The border color of the current background on mouse button press"), - NULL); + background_border_color_press = gtk_color_button_new(); + gtk_color_button_set_use_alpha(GTK_COLOR_BUTTON(background_border_color_press), TRUE); + gtk_widget_show(background_border_color_press); + gtk_table_attach(GTK_TABLE(table), background_border_color_press, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + background_border_color_press, + _("The border color of the current background on mouse button press"), + NULL); - row++, col = 2; - label = gtk_label_new(_("Gradient (pressed)")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Gradient (pressed)")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - background_gradient_press = create_gradient_combo(); - gtk_widget_show(background_gradient_press); - gtk_table_attach(GTK_TABLE(table), background_gradient_press, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); - col++; + background_gradient_press = create_gradient_combo(); + gtk_widget_show(background_gradient_press); + gtk_table_attach(GTK_TABLE(table), background_gradient_press, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - row++, col = 2; - label = gtk_label_new(_("Border width")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Border width")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - background_border_width = gtk_spin_button_new_with_range(0, 100, 1); - gtk_widget_show(background_border_width); - gtk_table_attach(GTK_TABLE(table), background_border_width, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, - background_border_width, - _("The width of the border of the current background, in pixels"), - NULL); + background_border_width = gtk_spin_button_new_with_range(0, 100, 1); + gtk_widget_show(background_border_width); + gtk_table_attach(GTK_TABLE(table), background_border_width, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + background_border_width, + _("The width of the border of the current background, in pixels"), + NULL); - row++, col = 2; - label = gtk_label_new(_("Corner radius")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Corner radius")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - background_corner_radius = gtk_spin_button_new_with_range(0, 100, 1); - gtk_widget_show(background_corner_radius); - gtk_table_attach(GTK_TABLE(table), background_corner_radius, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, background_corner_radius, _("The corner radius of the current background"), NULL); + background_corner_radius = gtk_spin_button_new_with_range(0, 100, 1); + gtk_widget_show(background_corner_radius); + gtk_table_attach(GTK_TABLE(table), background_corner_radius, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, background_corner_radius, _("The corner radius of the current background"), NULL); - row++; - col = 2; - label = gtk_label_new(_("Border sides")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); - col++; + row++; + col = 2; + label = gtk_label_new(_("Border sides")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - background_border_sides_top = gtk_check_button_new_with_label(_("Top")); - gtk_widget_show(background_border_sides_top); - gtk_table_attach(GTK_TABLE(table), background_border_sides_top, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); - col++; + background_border_sides_top = gtk_check_button_new_with_label(_("Top")); + gtk_widget_show(background_border_sides_top); + gtk_table_attach(GTK_TABLE(table), background_border_sides_top, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - background_border_sides_bottom = gtk_check_button_new_with_label(_("Bottom")); - gtk_widget_show(background_border_sides_bottom); - gtk_table_attach(GTK_TABLE(table), background_border_sides_bottom, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); - col++; + background_border_sides_bottom = gtk_check_button_new_with_label(_("Bottom")); + gtk_widget_show(background_border_sides_bottom); + gtk_table_attach(GTK_TABLE(table), background_border_sides_bottom, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - background_border_sides_left = gtk_check_button_new_with_label(_("Left")); - gtk_widget_show(background_border_sides_left); - gtk_table_attach(GTK_TABLE(table), background_border_sides_left, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); - col++; + background_border_sides_left = gtk_check_button_new_with_label(_("Left")); + gtk_widget_show(background_border_sides_left); + gtk_table_attach(GTK_TABLE(table), background_border_sides_left, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - background_border_sides_right = gtk_check_button_new_with_label(_("Right")); - gtk_widget_show(background_border_sides_right); - gtk_table_attach(GTK_TABLE(table), background_border_sides_right, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); - col++; + background_border_sides_right = gtk_check_button_new_with_label(_("Right")); + gtk_widget_show(background_border_sides_right); + gtk_table_attach(GTK_TABLE(table), background_border_sides_right, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - g_signal_connect(G_OBJECT(current_background), "changed", G_CALLBACK(current_background_changed), NULL); - g_signal_connect(G_OBJECT(background_fill_color), "color-set", G_CALLBACK(background_update), NULL); - g_signal_connect(G_OBJECT(background_border_color), "color-set", G_CALLBACK(background_update), NULL); - g_signal_connect(G_OBJECT(background_gradient), "changed", G_CALLBACK(background_update), NULL); - g_signal_connect(G_OBJECT(background_fill_color_over), "color-set", G_CALLBACK(background_update), NULL); - g_signal_connect(G_OBJECT(background_border_color_over), "color-set", G_CALLBACK(background_update), NULL); - g_signal_connect(G_OBJECT(background_gradient_over), "changed", G_CALLBACK(background_update), NULL); - g_signal_connect(G_OBJECT(background_fill_color_press), "color-set", G_CALLBACK(background_update), NULL); - g_signal_connect(G_OBJECT(background_border_color_press), "color-set", G_CALLBACK(background_update), NULL); - g_signal_connect(G_OBJECT(background_gradient_press), "changed", G_CALLBACK(background_update), NULL); - g_signal_connect(G_OBJECT(background_border_width), "value-changed", G_CALLBACK(background_update), NULL); - g_signal_connect(G_OBJECT(background_corner_radius), "value-changed", G_CALLBACK(background_update), NULL); - g_signal_connect(G_OBJECT(background_border_sides_top), "toggled", G_CALLBACK(background_update), NULL); - g_signal_connect(G_OBJECT(background_border_sides_bottom), "toggled", G_CALLBACK(background_update), NULL); - g_signal_connect(G_OBJECT(background_border_sides_left), "toggled", G_CALLBACK(background_update), NULL); - g_signal_connect(G_OBJECT(background_border_sides_right), "toggled", G_CALLBACK(background_update), NULL); + g_signal_connect(G_OBJECT(current_background), "changed", G_CALLBACK(current_background_changed), NULL); + g_signal_connect(G_OBJECT(background_fill_color), "color-set", G_CALLBACK(background_update), NULL); + g_signal_connect(G_OBJECT(background_border_color), "color-set", G_CALLBACK(background_update), NULL); + g_signal_connect(G_OBJECT(background_gradient), "changed", G_CALLBACK(background_update), NULL); + g_signal_connect(G_OBJECT(background_fill_color_over), "color-set", G_CALLBACK(background_update), NULL); + g_signal_connect(G_OBJECT(background_border_color_over), "color-set", G_CALLBACK(background_update), NULL); + g_signal_connect(G_OBJECT(background_gradient_over), "changed", G_CALLBACK(background_update), NULL); + g_signal_connect(G_OBJECT(background_fill_color_press), "color-set", G_CALLBACK(background_update), NULL); + g_signal_connect(G_OBJECT(background_border_color_press), "color-set", G_CALLBACK(background_update), NULL); + g_signal_connect(G_OBJECT(background_gradient_press), "changed", G_CALLBACK(background_update), NULL); + g_signal_connect(G_OBJECT(background_border_width), "value-changed", G_CALLBACK(background_update), NULL); + g_signal_connect(G_OBJECT(background_corner_radius), "value-changed", G_CALLBACK(background_update), NULL); + g_signal_connect(G_OBJECT(background_border_sides_top), "toggled", G_CALLBACK(background_update), NULL); + g_signal_connect(G_OBJECT(background_border_sides_bottom), "toggled", G_CALLBACK(background_update), NULL); + g_signal_connect(G_OBJECT(background_border_sides_left), "toggled", G_CALLBACK(background_update), NULL); + g_signal_connect(G_OBJECT(background_border_sides_right), "toggled", G_CALLBACK(background_update), NULL); - change_paragraph(parent); + change_paragraph(parent); } int background_index_safe(int index) { - if (index <= 0) - index = 0; - if (index >= get_model_length(GTK_TREE_MODEL(backgrounds))) - index = 0; - return index; + if (index <= 0) + index = 0; + if (index >= get_model_length(GTK_TREE_MODEL(backgrounds))) + index = 0; + return index; } void background_create_new() { - int r = 0; - int b = 0; - gboolean sideTop = TRUE; - gboolean sideBottom = TRUE; - gboolean sideLeft = TRUE; - gboolean sideRight = TRUE; - GdkColor fillColor; - cairoColor2GdkColor(0, 0, 0, &fillColor); - int fillOpacity = 0; - GdkColor fillColor2; - cairoColor2GdkColor(0, 0, 0, &fillColor2); - GdkColor borderColor; - cairoColor2GdkColor(0, 0, 0, &borderColor); - int borderOpacity = 0; + int r = 0; + int b = 0; + gboolean sideTop = TRUE; + gboolean sideBottom = TRUE; + gboolean sideLeft = TRUE; + gboolean sideRight = TRUE; + GdkColor fillColor; + cairoColor2GdkColor(0, 0, 0, &fillColor); + int fillOpacity = 0; + GdkColor fillColor2; + cairoColor2GdkColor(0, 0, 0, &fillColor2); + GdkColor borderColor; + cairoColor2GdkColor(0, 0, 0, &borderColor); + int borderOpacity = 0; - GdkColor fillColorOver; - cairoColor2GdkColor(0, 0, 0, &fillColorOver); - int fillOpacityOver = 0; - GdkColor borderColorOver; - cairoColor2GdkColor(0, 0, 0, &borderColorOver); - int borderOpacityOver = 0; + GdkColor fillColorOver; + cairoColor2GdkColor(0, 0, 0, &fillColorOver); + int fillOpacityOver = 0; + GdkColor borderColorOver; + cairoColor2GdkColor(0, 0, 0, &borderColorOver); + int borderOpacityOver = 0; - GdkColor fillColorPress; - cairoColor2GdkColor(0, 0, 0, &fillColorPress); - int fillOpacityPress = 0; - GdkColor borderColorPress; - cairoColor2GdkColor(0, 0, 0, &borderColorPress); - int borderOpacityPress = 0; + GdkColor fillColorPress; + cairoColor2GdkColor(0, 0, 0, &fillColorPress); + int fillOpacityPress = 0; + GdkColor borderColorPress; + cairoColor2GdkColor(0, 0, 0, &borderColorPress); + int borderOpacityPress = 0; - int index = 0; - GtkTreeIter iter; + int index = 0; + GtkTreeIter iter; - gtk_list_store_append(backgrounds, &iter); - gtk_list_store_set(backgrounds, - &iter, - bgColPixbuf, - NULL, - bgColFillColor, - &fillColor, - bgColFillOpacity, - fillOpacity, - bgColBorderColor, - &borderColor, - bgColBorderOpacity, - borderOpacity, - bgColGradientId, - -1, - bgColBorderWidth, - b, - bgColCornerRadius, - r, - bgColText, - "", - bgColFillColorOver, - &fillColorOver, - bgColFillOpacityOver, - fillOpacityOver, - bgColBorderColorOver, - &borderColorOver, - bgColBorderOpacityOver, - borderOpacityOver, - bgColGradientIdOver, - -1, - bgColFillColorPress, - &fillColorPress, - bgColFillOpacityPress, - fillOpacityPress, - bgColBorderColorPress, - &borderColorPress, - bgColBorderOpacityPress, - borderOpacityPress, - bgColGradientIdPress, - -1, - bgColBorderSidesTop, - sideTop, - bgColBorderSidesBottom, - sideBottom, - bgColBorderSidesLeft, - sideLeft, - bgColBorderSidesRight, - sideRight, - -1); + gtk_list_store_append(backgrounds, &iter); + gtk_list_store_set(backgrounds, + &iter, + bgColPixbuf, + NULL, + bgColFillColor, + &fillColor, + bgColFillOpacity, + fillOpacity, + bgColBorderColor, + &borderColor, + bgColBorderOpacity, + borderOpacity, + bgColGradientId, + -1, + bgColBorderWidth, + b, + bgColCornerRadius, + r, + bgColText, + "", + bgColFillColorOver, + &fillColorOver, + bgColFillOpacityOver, + fillOpacityOver, + bgColBorderColorOver, + &borderColorOver, + bgColBorderOpacityOver, + borderOpacityOver, + bgColGradientIdOver, + -1, + bgColFillColorPress, + &fillColorPress, + bgColFillOpacityPress, + fillOpacityPress, + bgColBorderColorPress, + &borderColorPress, + bgColBorderOpacityPress, + borderOpacityPress, + bgColGradientIdPress, + -1, + bgColBorderSidesTop, + sideTop, + bgColBorderSidesBottom, + sideBottom, + bgColBorderSidesLeft, + sideLeft, + bgColBorderSidesRight, + sideRight, + -1); - background_update_image(index); - gtk_combo_box_set_active(GTK_COMBO_BOX(current_background), get_model_length(GTK_TREE_MODEL(backgrounds)) - 1); - current_background_changed(0, 0); + background_update_image(index); + gtk_combo_box_set_active(GTK_COMBO_BOX(current_background), get_model_length(GTK_TREE_MODEL(backgrounds)) - 1); + current_background_changed(0, 0); } void background_duplicate(GtkWidget *widget, gpointer data) { - int index = gtk_combo_box_get_active(GTK_COMBO_BOX(current_background)); - if (index < 0) { - background_create_new(); - return; - } + int index = gtk_combo_box_get_active(GTK_COMBO_BOX(current_background)); + if (index < 0) { + background_create_new(); + return; + } - GtkTreePath *path; - GtkTreeIter iter; + GtkTreePath *path; + GtkTreeIter iter; - path = gtk_tree_path_new_from_indices(index, -1); - gtk_tree_model_get_iter(GTK_TREE_MODEL(backgrounds), &iter, path); - gtk_tree_path_free(path); + path = gtk_tree_path_new_from_indices(index, -1); + gtk_tree_model_get_iter(GTK_TREE_MODEL(backgrounds), &iter, path); + gtk_tree_path_free(path); - int r; - int b; - gboolean sideTop; - gboolean sideBottom; - gboolean sideLeft; - gboolean sideRight; - GdkColor *fillColor; - int fillOpacity; - GdkColor *borderColor; - int borderOpacity; - GdkColor *fillColorOver; - int fillOpacityOver; - GdkColor *borderColorOver; - int borderOpacityOver; - GdkColor *fillColorPress; - int fillOpacityPress; - GdkColor *borderColorPress; - int borderOpacityPress; - int gradient_id, gradient_id_over, gradient_id_press; + int r; + int b; + gboolean sideTop; + gboolean sideBottom; + gboolean sideLeft; + gboolean sideRight; + GdkColor *fillColor; + int fillOpacity; + GdkColor *borderColor; + int borderOpacity; + GdkColor *fillColorOver; + int fillOpacityOver; + GdkColor *borderColorOver; + int borderOpacityOver; + GdkColor *fillColorPress; + int fillOpacityPress; + GdkColor *borderColorPress; + int borderOpacityPress; + int gradient_id, gradient_id_over, gradient_id_press; - gtk_tree_model_get(GTK_TREE_MODEL(backgrounds), - &iter, - bgColFillColor, - &fillColor, - bgColFillOpacity, - &fillOpacity, - bgColBorderColor, - &borderColor, - bgColBorderOpacity, - &borderOpacity, - bgColFillColorOver, - &fillColorOver, - bgColFillOpacityOver, - &fillOpacityOver, - bgColBorderColorOver, - &borderColorOver, - bgColBorderOpacityOver, - &borderOpacityOver, - bgColFillColorPress, - &fillColorPress, - bgColFillOpacityPress, - &fillOpacityPress, - bgColBorderColorPress, - &borderColorPress, - bgColBorderOpacityPress, - &borderOpacityPress, - bgColBorderWidth, - &b, - bgColCornerRadius, - &r, - bgColBorderSidesTop, - &sideTop, - bgColBorderSidesBottom, - &sideBottom, - bgColBorderSidesLeft, - &sideLeft, - bgColBorderSidesRight, - &sideRight, - bgColGradientId, - &gradient_id, - bgColGradientIdOver, - &gradient_id_over, - bgColGradientIdPress, - &gradient_id_press, - -1); + gtk_tree_model_get(GTK_TREE_MODEL(backgrounds), + &iter, + bgColFillColor, + &fillColor, + bgColFillOpacity, + &fillOpacity, + bgColBorderColor, + &borderColor, + bgColBorderOpacity, + &borderOpacity, + bgColFillColorOver, + &fillColorOver, + bgColFillOpacityOver, + &fillOpacityOver, + bgColBorderColorOver, + &borderColorOver, + bgColBorderOpacityOver, + &borderOpacityOver, + bgColFillColorPress, + &fillColorPress, + bgColFillOpacityPress, + &fillOpacityPress, + bgColBorderColorPress, + &borderColorPress, + bgColBorderOpacityPress, + &borderOpacityPress, + bgColBorderWidth, + &b, + bgColCornerRadius, + &r, + bgColBorderSidesTop, + &sideTop, + bgColBorderSidesBottom, + &sideBottom, + bgColBorderSidesLeft, + &sideLeft, + bgColBorderSidesRight, + &sideRight, + bgColGradientId, + &gradient_id, + bgColGradientIdOver, + &gradient_id_over, + bgColGradientIdPress, + &gradient_id_press, + -1); - gtk_list_store_append(backgrounds, &iter); - gtk_list_store_set(backgrounds, - &iter, - bgColPixbuf, - NULL, - bgColFillColor, - fillColor, - bgColFillOpacity, - fillOpacity, - bgColBorderColor, - borderColor, - bgColGradientId, - gradient_id, - bgColBorderOpacity, - borderOpacity, - bgColText, - "", - bgColFillColorOver, - fillColorOver, - bgColFillOpacityOver, - fillOpacityOver, - bgColBorderColorOver, - borderColorOver, - bgColBorderOpacityOver, - borderOpacityOver, - bgColGradientIdOver, - gradient_id_over, - bgColFillColorPress, - fillColorPress, - bgColFillOpacityPress, - fillOpacityPress, - bgColBorderColorPress, - borderColorPress, - bgColBorderOpacityPress, - borderOpacityPress, - bgColGradientIdPress, - gradient_id_press, - bgColBorderWidth, - b, - bgColCornerRadius, - r, - bgColBorderSidesTop, - sideTop, - bgColBorderSidesBottom, - sideBottom, - bgColBorderSidesLeft, - sideLeft, - bgColBorderSidesRight, - sideRight, - -1); - g_boxed_free(GDK_TYPE_COLOR, fillColor); - g_boxed_free(GDK_TYPE_COLOR, borderColor); - g_boxed_free(GDK_TYPE_COLOR, fillColorOver); - g_boxed_free(GDK_TYPE_COLOR, borderColorOver); - g_boxed_free(GDK_TYPE_COLOR, fillColorPress); - g_boxed_free(GDK_TYPE_COLOR, borderColorPress); - background_update_image(get_model_length(GTK_TREE_MODEL(backgrounds)) - 1); - gtk_combo_box_set_active(GTK_COMBO_BOX(current_background), get_model_length(GTK_TREE_MODEL(backgrounds)) - 1); + gtk_list_store_append(backgrounds, &iter); + gtk_list_store_set(backgrounds, + &iter, + bgColPixbuf, + NULL, + bgColFillColor, + fillColor, + bgColFillOpacity, + fillOpacity, + bgColBorderColor, + borderColor, + bgColGradientId, + gradient_id, + bgColBorderOpacity, + borderOpacity, + bgColText, + "", + bgColFillColorOver, + fillColorOver, + bgColFillOpacityOver, + fillOpacityOver, + bgColBorderColorOver, + borderColorOver, + bgColBorderOpacityOver, + borderOpacityOver, + bgColGradientIdOver, + gradient_id_over, + bgColFillColorPress, + fillColorPress, + bgColFillOpacityPress, + fillOpacityPress, + bgColBorderColorPress, + borderColorPress, + bgColBorderOpacityPress, + borderOpacityPress, + bgColGradientIdPress, + gradient_id_press, + bgColBorderWidth, + b, + bgColCornerRadius, + r, + bgColBorderSidesTop, + sideTop, + bgColBorderSidesBottom, + sideBottom, + bgColBorderSidesLeft, + sideLeft, + bgColBorderSidesRight, + sideRight, + -1); + g_boxed_free(GDK_TYPE_COLOR, fillColor); + g_boxed_free(GDK_TYPE_COLOR, borderColor); + g_boxed_free(GDK_TYPE_COLOR, fillColorOver); + g_boxed_free(GDK_TYPE_COLOR, borderColorOver); + g_boxed_free(GDK_TYPE_COLOR, fillColorPress); + g_boxed_free(GDK_TYPE_COLOR, borderColorPress); + background_update_image(get_model_length(GTK_TREE_MODEL(backgrounds)) - 1); + gtk_combo_box_set_active(GTK_COMBO_BOX(current_background), get_model_length(GTK_TREE_MODEL(backgrounds)) - 1); } void background_delete(GtkWidget *widget, gpointer data) { - int index = gtk_combo_box_get_active(GTK_COMBO_BOX(current_background)); - if (index < 0) - return; + int index = gtk_combo_box_get_active(GTK_COMBO_BOX(current_background)); + if (index < 0) + return; - if (get_model_length(GTK_TREE_MODEL(backgrounds)) <= 1) - return; + if (get_model_length(GTK_TREE_MODEL(backgrounds)) <= 1) + return; - GtkTreePath *path; - GtkTreeIter iter; + GtkTreePath *path; + GtkTreeIter iter; - path = gtk_tree_path_new_from_indices(index, -1); - gtk_tree_model_get_iter(GTK_TREE_MODEL(backgrounds), &iter, path); - gtk_tree_path_free(path); + path = gtk_tree_path_new_from_indices(index, -1); + gtk_tree_model_get_iter(GTK_TREE_MODEL(backgrounds), &iter, path); + gtk_tree_path_free(path); - gtk_list_store_remove(backgrounds, &iter); + gtk_list_store_remove(backgrounds, &iter); - if (index == get_model_length(GTK_TREE_MODEL(backgrounds))) - index--; - gtk_combo_box_set_active(GTK_COMBO_BOX(current_background), index); + if (index == get_model_length(GTK_TREE_MODEL(backgrounds))) + index--; + gtk_combo_box_set_active(GTK_COMBO_BOX(current_background), index); } void background_update_image(int index) { - GtkTreePath *path; - GtkTreeIter iter; + GtkTreePath *path; + GtkTreeIter iter; - path = gtk_tree_path_new_from_indices(index, -1); - gtk_tree_model_get_iter(GTK_TREE_MODEL(backgrounds), &iter, path); - gtk_tree_path_free(path); + path = gtk_tree_path_new_from_indices(index, -1); + gtk_tree_model_get_iter(GTK_TREE_MODEL(backgrounds), &iter, path); + gtk_tree_path_free(path); - int w = 70; - int h = 30; - int r; - int b; - GdkPixbuf *pixbuf; - GdkColor *fillColor; - int fillOpacity = 50; - GdkColor *borderColor; - int borderOpacity = 100; - int gradient_id; + int w = 70; + int h = 30; + int r; + int b; + GdkPixbuf *pixbuf; + GdkColor *fillColor; + int fillOpacity = 50; + GdkColor *borderColor; + int borderOpacity = 100; + int gradient_id; - gtk_tree_model_get(GTK_TREE_MODEL(backgrounds), - &iter, - bgColFillColor, - &fillColor, - bgColFillOpacity, - &fillOpacity, - bgColBorderColor, - &borderColor, - bgColBorderOpacity, - &borderOpacity, - bgColBorderWidth, - &b, - bgColCornerRadius, - &r, - bgColGradientId, - &gradient_id, - -1); + gtk_tree_model_get(GTK_TREE_MODEL(backgrounds), + &iter, + bgColFillColor, + &fillColor, + bgColFillOpacity, + &fillOpacity, + bgColBorderColor, + &borderColor, + bgColBorderOpacity, + &borderOpacity, + bgColBorderWidth, + &b, + bgColCornerRadius, + &r, + bgColGradientId, + &gradient_id, + -1); - double bg_r, bg_g, bg_b, bg_a; - gdkColor2CairoColor(*fillColor, &bg_r, &bg_g, &bg_b); - bg_a = fillOpacity / 100.0; + double bg_r, bg_g, bg_b, bg_a; + gdkColor2CairoColor(*fillColor, &bg_r, &bg_g, &bg_b); + bg_a = fillOpacity / 100.0; - double b_r, b_g, b_b, b_a; - gdkColor2CairoColor(*borderColor, &b_r, &b_g, &b_b); - b_a = borderOpacity / 100.0; + double b_r, b_g, b_b, b_a; + gdkColor2CairoColor(*borderColor, &b_r, &b_g, &b_b); + b_a = borderOpacity / 100.0; - g_boxed_free(GDK_TYPE_COLOR, fillColor); - g_boxed_free(GDK_TYPE_COLOR, borderColor); + g_boxed_free(GDK_TYPE_COLOR, fillColor); + g_boxed_free(GDK_TYPE_COLOR, borderColor); - GdkPixmap *pixmap = gdk_pixmap_new(NULL, w, h, 24); + GdkPixmap *pixmap = gdk_pixmap_new(NULL, w, h, 24); - cairo_t *cr = gdk_cairo_create(pixmap); - cairo_set_line_width(cr, b); + cairo_t *cr = gdk_cairo_create(pixmap); + cairo_set_line_width(cr, b); - cairo_set_source_rgb(cr, 0.5, 0.5, 0.5); - cairo_rectangle(cr, 0, 0, w, h); - cairo_fill(cr); + cairo_set_source_rgb(cr, 0.5, 0.5, 0.5); + cairo_rectangle(cr, 0, 0, w, h); + cairo_fill(cr); - double degrees = 3.1415926 / 180.0; + double degrees = 3.1415926 / 180.0; - cairo_new_sub_path(cr); - cairo_arc(cr, w - r - b, r + b, r, -90 * degrees, 0 * degrees); - cairo_arc(cr, w - r - b, h - r - b, r, 0 * degrees, 90 * degrees); - cairo_arc(cr, r + b, h - r - b, r, 90 * degrees, 180 * degrees); - cairo_arc(cr, r + b, r + b, r, 180 * degrees, 270 * degrees); - cairo_close_path(cr); + cairo_new_sub_path(cr); + cairo_arc(cr, w - r - b, r + b, r, -90 * degrees, 0 * degrees); + cairo_arc(cr, w - r - b, h - r - b, r, 0 * degrees, 90 * degrees); + cairo_arc(cr, r + b, h - r - b, r, 90 * degrees, 180 * degrees); + cairo_arc(cr, r + b, r + b, r, 180 * degrees, 270 * degrees); + cairo_close_path(cr); - if (index >= 1 && gradient_id >= 1) { - GradientConfig *g = (GradientConfig *)g_list_nth(gradients, (guint)gradient_id)->data; - gradient_draw(cr, g, w, h, TRUE); - } + if (index >= 1 && gradient_id >= 1) { + GradientConfig *g = (GradientConfig *)g_list_nth(gradients, (guint)gradient_id)->data; + gradient_draw(cr, g, w, h, TRUE); + } - cairo_set_source_rgba(cr, bg_r, bg_g, bg_b, bg_a); - cairo_fill_preserve(cr); + cairo_set_source_rgba(cr, bg_r, bg_g, bg_b, bg_a); + cairo_fill_preserve(cr); - cairo_set_source_rgba(cr, b_r, b_g, b_b, b_a); - cairo_set_line_width(cr, b); - cairo_stroke(cr); - cairo_destroy(cr); - cr = NULL; + cairo_set_source_rgba(cr, b_r, b_g, b_b, b_a); + cairo_set_line_width(cr, b); + cairo_stroke(cr); + cairo_destroy(cr); + cr = NULL; - pixbuf = gdk_pixbuf_get_from_drawable(NULL, pixmap, gdk_colormap_get_system(), 0, 0, 0, 0, w, h); - if (pixmap) - g_object_unref(pixmap); + pixbuf = gdk_pixbuf_get_from_drawable(NULL, pixmap, gdk_colormap_get_system(), 0, 0, 0, 0, w, h); + if (pixmap) + g_object_unref(pixmap); - gtk_list_store_set(backgrounds, &iter, bgColPixbuf, pixbuf, -1); - if (pixbuf) - g_object_unref(pixbuf); + gtk_list_store_set(backgrounds, &iter, bgColPixbuf, pixbuf, -1); + if (pixbuf) + g_object_unref(pixbuf); } void background_force_update() { - background_update(NULL, NULL); + background_update(NULL, NULL); } static gboolean background_updates_disabled = FALSE; void background_update(GtkWidget *widget, gpointer data) { - if (background_updates_disabled) - return; - int index = gtk_combo_box_get_active(GTK_COMBO_BOX(current_background)); - if (index < 0) - return; + if (background_updates_disabled) + return; + int index = gtk_combo_box_get_active(GTK_COMBO_BOX(current_background)); + if (index < 0) + return; - GtkTreePath *path; - GtkTreeIter iter; + GtkTreePath *path; + GtkTreeIter iter; - path = gtk_tree_path_new_from_indices(index, -1); - gtk_tree_model_get_iter(GTK_TREE_MODEL(backgrounds), &iter, path); - gtk_tree_path_free(path); + path = gtk_tree_path_new_from_indices(index, -1); + gtk_tree_model_get_iter(GTK_TREE_MODEL(backgrounds), &iter, path); + gtk_tree_path_free(path); - int r; - int b; + int r; + int b; - r = gtk_spin_button_get_value(GTK_SPIN_BUTTON(background_corner_radius)); - b = gtk_spin_button_get_value(GTK_SPIN_BUTTON(background_border_width)); + r = gtk_spin_button_get_value(GTK_SPIN_BUTTON(background_corner_radius)); + b = gtk_spin_button_get_value(GTK_SPIN_BUTTON(background_border_width)); - gboolean sideTop = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(background_border_sides_top)); - gboolean sideBottom = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(background_border_sides_bottom)); - gboolean sideLeft = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(background_border_sides_left)); - gboolean sideRight = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(background_border_sides_right)); + gboolean sideTop = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(background_border_sides_top)); + gboolean sideBottom = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(background_border_sides_bottom)); + gboolean sideLeft = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(background_border_sides_left)); + gboolean sideRight = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(background_border_sides_right)); - GdkColor fillColor; - int fillOpacity; - GdkColor borderColor; - int borderOpacity; - gtk_color_button_get_color(GTK_COLOR_BUTTON(background_fill_color), &fillColor); - fillOpacity = MIN(100, 0.5 + gtk_color_button_get_alpha(GTK_COLOR_BUTTON(background_fill_color)) * 100.0 / 0xffff); - gtk_color_button_get_color(GTK_COLOR_BUTTON(background_border_color), &borderColor); - borderOpacity = - MIN(100, 0.5 + gtk_color_button_get_alpha(GTK_COLOR_BUTTON(background_border_color)) * 100.0 / 0xffff); - int gradient_id = gtk_combo_box_get_active(GTK_COMBO_BOX(background_gradient)); + GdkColor fillColor; + int fillOpacity; + GdkColor borderColor; + int borderOpacity; + gtk_color_button_get_color(GTK_COLOR_BUTTON(background_fill_color), &fillColor); + fillOpacity = MIN(100, 0.5 + gtk_color_button_get_alpha(GTK_COLOR_BUTTON(background_fill_color)) * 100.0 / 0xffff); + gtk_color_button_get_color(GTK_COLOR_BUTTON(background_border_color), &borderColor); + borderOpacity = + MIN(100, 0.5 + gtk_color_button_get_alpha(GTK_COLOR_BUTTON(background_border_color)) * 100.0 / 0xffff); + int gradient_id = gtk_combo_box_get_active(GTK_COMBO_BOX(background_gradient)); - GdkColor fillColorOver; - int fillOpacityOver; - GdkColor borderColorOver; - int borderOpacityOver; - gtk_color_button_get_color(GTK_COLOR_BUTTON(background_fill_color_over), &fillColorOver); - fillOpacityOver = - MIN(100, 0.5 + gtk_color_button_get_alpha(GTK_COLOR_BUTTON(background_fill_color_over)) * 100.0 / 0xffff); - gtk_color_button_get_color(GTK_COLOR_BUTTON(background_border_color_over), &borderColorOver); - borderOpacityOver = - MIN(100, 0.5 + gtk_color_button_get_alpha(GTK_COLOR_BUTTON(background_border_color_over)) * 100.0 / 0xffff); - int gradient_id_over = gtk_combo_box_get_active(GTK_COMBO_BOX(background_gradient_over)); + GdkColor fillColorOver; + int fillOpacityOver; + GdkColor borderColorOver; + int borderOpacityOver; + gtk_color_button_get_color(GTK_COLOR_BUTTON(background_fill_color_over), &fillColorOver); + fillOpacityOver = + MIN(100, 0.5 + gtk_color_button_get_alpha(GTK_COLOR_BUTTON(background_fill_color_over)) * 100.0 / 0xffff); + gtk_color_button_get_color(GTK_COLOR_BUTTON(background_border_color_over), &borderColorOver); + borderOpacityOver = + MIN(100, 0.5 + gtk_color_button_get_alpha(GTK_COLOR_BUTTON(background_border_color_over)) * 100.0 / 0xffff); + int gradient_id_over = gtk_combo_box_get_active(GTK_COMBO_BOX(background_gradient_over)); - GdkColor fillColorPress; - int fillOpacityPress; - GdkColor borderColorPress; - int borderOpacityPress; - gtk_color_button_get_color(GTK_COLOR_BUTTON(background_fill_color_press), &fillColorPress); - fillOpacityPress = - MIN(100, 0.5 + gtk_color_button_get_alpha(GTK_COLOR_BUTTON(background_fill_color_press)) * 100.0 / 0xffff); - gtk_color_button_get_color(GTK_COLOR_BUTTON(background_border_color_press), &borderColorPress); - borderOpacityPress = - MIN(100, 0.5 + gtk_color_button_get_alpha(GTK_COLOR_BUTTON(background_border_color_press)) * 100.0 / 0xffff); - int gradient_id_press = gtk_combo_box_get_active(GTK_COMBO_BOX(background_gradient_press)); + GdkColor fillColorPress; + int fillOpacityPress; + GdkColor borderColorPress; + int borderOpacityPress; + gtk_color_button_get_color(GTK_COLOR_BUTTON(background_fill_color_press), &fillColorPress); + fillOpacityPress = + MIN(100, 0.5 + gtk_color_button_get_alpha(GTK_COLOR_BUTTON(background_fill_color_press)) * 100.0 / 0xffff); + gtk_color_button_get_color(GTK_COLOR_BUTTON(background_border_color_press), &borderColorPress); + borderOpacityPress = + MIN(100, 0.5 + gtk_color_button_get_alpha(GTK_COLOR_BUTTON(background_border_color_press)) * 100.0 / 0xffff); + int gradient_id_press = gtk_combo_box_get_active(GTK_COMBO_BOX(background_gradient_press)); - gtk_list_store_set(backgrounds, - &iter, - bgColPixbuf, - NULL, - bgColFillColor, - &fillColor, - bgColFillOpacity, - fillOpacity, - bgColBorderColor, - &borderColor, - bgColBorderOpacity, - borderOpacity, - bgColGradientId, - gradient_id, - bgColFillColorOver, - &fillColorOver, - bgColFillOpacityOver, - fillOpacityOver, - bgColBorderColorOver, - &borderColorOver, - bgColBorderOpacityOver, - borderOpacityOver, - bgColGradientIdOver, - gradient_id_over, - bgColFillColorPress, - &fillColorPress, - bgColFillOpacityPress, - fillOpacityPress, - bgColBorderColorPress, - &borderColorPress, - bgColBorderOpacityPress, - borderOpacityPress, - bgColGradientIdPress, - gradient_id_press, - bgColBorderWidth, - b, - bgColCornerRadius, - r, - bgColBorderSidesTop, - sideTop, - bgColBorderSidesBottom, - sideBottom, - bgColBorderSidesLeft, - sideLeft, - bgColBorderSidesRight, - sideRight, - -1); - background_update_image(index); + gtk_list_store_set(backgrounds, + &iter, + bgColPixbuf, + NULL, + bgColFillColor, + &fillColor, + bgColFillOpacity, + fillOpacity, + bgColBorderColor, + &borderColor, + bgColBorderOpacity, + borderOpacity, + bgColGradientId, + gradient_id, + bgColFillColorOver, + &fillColorOver, + bgColFillOpacityOver, + fillOpacityOver, + bgColBorderColorOver, + &borderColorOver, + bgColBorderOpacityOver, + borderOpacityOver, + bgColGradientIdOver, + gradient_id_over, + bgColFillColorPress, + &fillColorPress, + bgColFillOpacityPress, + fillOpacityPress, + bgColBorderColorPress, + &borderColorPress, + bgColBorderOpacityPress, + borderOpacityPress, + bgColGradientIdPress, + gradient_id_press, + bgColBorderWidth, + b, + bgColCornerRadius, + r, + bgColBorderSidesTop, + sideTop, + bgColBorderSidesBottom, + sideBottom, + bgColBorderSidesLeft, + sideLeft, + bgColBorderSidesRight, + sideRight, + -1); + background_update_image(index); } void current_background_changed(GtkWidget *widget, gpointer data) { - int index = gtk_combo_box_get_active(GTK_COMBO_BOX(current_background)); - if (index < 0) - return; + int index = gtk_combo_box_get_active(GTK_COMBO_BOX(current_background)); + if (index < 0) + return; - gtk_widget_set_sensitive(gradient_combo_type, index > 0); - gtk_widget_set_sensitive(background_fill_color, index > 0); - gtk_widget_set_sensitive(background_border_color, index > 0); - gtk_widget_set_sensitive(background_gradient, index > 0); - gtk_widget_set_sensitive(background_fill_color_over, index > 0); - gtk_widget_set_sensitive(background_border_color_over, index > 0); - gtk_widget_set_sensitive(background_gradient_over, index > 0); - gtk_widget_set_sensitive(background_fill_color_press, index > 0); - gtk_widget_set_sensitive(background_border_color_press, index > 0); - gtk_widget_set_sensitive(background_gradient_press, index > 0); - gtk_widget_set_sensitive(background_border_width, index > 0); - gtk_widget_set_sensitive(background_border_sides_top, index > 0); - gtk_widget_set_sensitive(background_border_sides_bottom, index > 0); - gtk_widget_set_sensitive(background_border_sides_left, index > 0); - gtk_widget_set_sensitive(background_border_sides_right, index > 0); - gtk_widget_set_sensitive(background_corner_radius, index > 0); + gtk_widget_set_sensitive(gradient_combo_type, index > 0); + gtk_widget_set_sensitive(background_fill_color, index > 0); + gtk_widget_set_sensitive(background_border_color, index > 0); + gtk_widget_set_sensitive(background_gradient, index > 0); + gtk_widget_set_sensitive(background_fill_color_over, index > 0); + gtk_widget_set_sensitive(background_border_color_over, index > 0); + gtk_widget_set_sensitive(background_gradient_over, index > 0); + gtk_widget_set_sensitive(background_fill_color_press, index > 0); + gtk_widget_set_sensitive(background_border_color_press, index > 0); + gtk_widget_set_sensitive(background_gradient_press, index > 0); + gtk_widget_set_sensitive(background_border_width, index > 0); + gtk_widget_set_sensitive(background_border_sides_top, index > 0); + gtk_widget_set_sensitive(background_border_sides_bottom, index > 0); + gtk_widget_set_sensitive(background_border_sides_left, index > 0); + gtk_widget_set_sensitive(background_border_sides_right, index > 0); + gtk_widget_set_sensitive(background_corner_radius, index > 0); - background_updates_disabled = TRUE; + background_updates_disabled = TRUE; - GtkTreePath *path; - GtkTreeIter iter; + GtkTreePath *path; + GtkTreeIter iter; - path = gtk_tree_path_new_from_indices(index, -1); - gtk_tree_model_get_iter(GTK_TREE_MODEL(backgrounds), &iter, path); - gtk_tree_path_free(path); + path = gtk_tree_path_new_from_indices(index, -1); + gtk_tree_model_get_iter(GTK_TREE_MODEL(backgrounds), &iter, path); + gtk_tree_path_free(path); - int r; - int b; + int r; + int b; - gboolean sideTop; - gboolean sideBottom; - gboolean sideLeft; - gboolean sideRight; + gboolean sideTop; + gboolean sideBottom; + gboolean sideLeft; + gboolean sideRight; - GdkColor *fillColor; - int fillOpacity; - GdkColor *borderColor; - int borderOpacity; - GdkColor *fillColorOver; - int fillOpacityOver; - GdkColor *borderColorOver; - int borderOpacityOver; - GdkColor *fillColorPress; - int fillOpacityPress; - GdkColor *borderColorPress; - int borderOpacityPress; - int gradient_id, gradient_id_over, gradient_id_press; + GdkColor *fillColor; + int fillOpacity; + GdkColor *borderColor; + int borderOpacity; + GdkColor *fillColorOver; + int fillOpacityOver; + GdkColor *borderColorOver; + int borderOpacityOver; + GdkColor *fillColorPress; + int fillOpacityPress; + GdkColor *borderColorPress; + int borderOpacityPress; + int gradient_id, gradient_id_over, gradient_id_press; - gtk_tree_model_get(GTK_TREE_MODEL(backgrounds), - &iter, - bgColFillColor, - &fillColor, - bgColFillOpacity, - &fillOpacity, - bgColBorderColor, - &borderColor, - bgColBorderOpacity, - &borderOpacity, - bgColGradientId, - &gradient_id, - bgColFillColorOver, - &fillColorOver, - bgColFillOpacityOver, - &fillOpacityOver, - bgColBorderColorOver, - &borderColorOver, - bgColBorderOpacityOver, - &borderOpacityOver, - bgColGradientIdOver, - &gradient_id_over, - bgColFillColorPress, - &fillColorPress, - bgColFillOpacityPress, - &fillOpacityPress, - bgColBorderColorPress, - &borderColorPress, - bgColBorderOpacityPress, - &borderOpacityPress, - bgColGradientIdPress, - &gradient_id_press, - bgColBorderWidth, - &b, - bgColCornerRadius, - &r, - bgColBorderSidesTop, - &sideTop, - bgColBorderSidesBottom, - &sideBottom, - bgColBorderSidesLeft, - &sideLeft, - bgColBorderSidesRight, - &sideRight, - -1); + gtk_tree_model_get(GTK_TREE_MODEL(backgrounds), + &iter, + bgColFillColor, + &fillColor, + bgColFillOpacity, + &fillOpacity, + bgColBorderColor, + &borderColor, + bgColBorderOpacity, + &borderOpacity, + bgColGradientId, + &gradient_id, + bgColFillColorOver, + &fillColorOver, + bgColFillOpacityOver, + &fillOpacityOver, + bgColBorderColorOver, + &borderColorOver, + bgColBorderOpacityOver, + &borderOpacityOver, + bgColGradientIdOver, + &gradient_id_over, + bgColFillColorPress, + &fillColorPress, + bgColFillOpacityPress, + &fillOpacityPress, + bgColBorderColorPress, + &borderColorPress, + bgColBorderOpacityPress, + &borderOpacityPress, + bgColGradientIdPress, + &gradient_id_press, + bgColBorderWidth, + &b, + bgColCornerRadius, + &r, + bgColBorderSidesTop, + &sideTop, + bgColBorderSidesBottom, + &sideBottom, + bgColBorderSidesLeft, + &sideLeft, + bgColBorderSidesRight, + &sideRight, + -1); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(background_border_sides_top), sideTop); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(background_border_sides_bottom), sideBottom); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(background_border_sides_left), sideLeft); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(background_border_sides_right), sideRight); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(background_border_sides_top), sideTop); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(background_border_sides_bottom), sideBottom); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(background_border_sides_left), sideLeft); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(background_border_sides_right), sideRight); - gtk_color_button_set_color(GTK_COLOR_BUTTON(background_fill_color), fillColor); - gtk_color_button_set_alpha(GTK_COLOR_BUTTON(background_fill_color), (fillOpacity * 0xffff) / 100); + gtk_color_button_set_color(GTK_COLOR_BUTTON(background_fill_color), fillColor); + gtk_color_button_set_alpha(GTK_COLOR_BUTTON(background_fill_color), (fillOpacity * 0xffff) / 100); - gtk_color_button_set_color(GTK_COLOR_BUTTON(background_border_color), borderColor); - gtk_color_button_set_alpha(GTK_COLOR_BUTTON(background_border_color), (borderOpacity * 0xffff) / 100); + gtk_color_button_set_color(GTK_COLOR_BUTTON(background_border_color), borderColor); + gtk_color_button_set_alpha(GTK_COLOR_BUTTON(background_border_color), (borderOpacity * 0xffff) / 100); - gtk_combo_box_set_active(GTK_COMBO_BOX(background_gradient), gradient_id); + gtk_combo_box_set_active(GTK_COMBO_BOX(background_gradient), gradient_id); - gtk_color_button_set_color(GTK_COLOR_BUTTON(background_fill_color_over), fillColorOver); - gtk_color_button_set_alpha(GTK_COLOR_BUTTON(background_fill_color_over), (fillOpacityOver * 0xffff) / 100); - gtk_color_button_set_color(GTK_COLOR_BUTTON(background_border_color_over), borderColorOver); - gtk_color_button_set_alpha(GTK_COLOR_BUTTON(background_border_color_over), (borderOpacityOver * 0xffff) / 100); - gtk_combo_box_set_active(GTK_COMBO_BOX(background_gradient_over), gradient_id_over); + gtk_color_button_set_color(GTK_COLOR_BUTTON(background_fill_color_over), fillColorOver); + gtk_color_button_set_alpha(GTK_COLOR_BUTTON(background_fill_color_over), (fillOpacityOver * 0xffff) / 100); + gtk_color_button_set_color(GTK_COLOR_BUTTON(background_border_color_over), borderColorOver); + gtk_color_button_set_alpha(GTK_COLOR_BUTTON(background_border_color_over), (borderOpacityOver * 0xffff) / 100); + gtk_combo_box_set_active(GTK_COMBO_BOX(background_gradient_over), gradient_id_over); - gtk_color_button_set_color(GTK_COLOR_BUTTON(background_fill_color_press), fillColorPress); - gtk_color_button_set_alpha(GTK_COLOR_BUTTON(background_fill_color_press), (fillOpacityPress * 0xffff) / 100); - gtk_color_button_set_color(GTK_COLOR_BUTTON(background_border_color_press), borderColorPress); - gtk_color_button_set_alpha(GTK_COLOR_BUTTON(background_border_color_press), (borderOpacityPress * 0xffff) / 100); - gtk_combo_box_set_active(GTK_COMBO_BOX(background_gradient_press), gradient_id_press); + gtk_color_button_set_color(GTK_COLOR_BUTTON(background_fill_color_press), fillColorPress); + gtk_color_button_set_alpha(GTK_COLOR_BUTTON(background_fill_color_press), (fillOpacityPress * 0xffff) / 100); + gtk_color_button_set_color(GTK_COLOR_BUTTON(background_border_color_press), borderColorPress); + gtk_color_button_set_alpha(GTK_COLOR_BUTTON(background_border_color_press), (borderOpacityPress * 0xffff) / 100); + gtk_combo_box_set_active(GTK_COMBO_BOX(background_gradient_press), gradient_id_press); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(background_border_width), b); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(background_corner_radius), r); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(background_border_width), b); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(background_corner_radius), r); - g_boxed_free(GDK_TYPE_COLOR, fillColor); - g_boxed_free(GDK_TYPE_COLOR, borderColor); - g_boxed_free(GDK_TYPE_COLOR, fillColorOver); - g_boxed_free(GDK_TYPE_COLOR, borderColorOver); - g_boxed_free(GDK_TYPE_COLOR, fillColorPress); - g_boxed_free(GDK_TYPE_COLOR, borderColorPress); + g_boxed_free(GDK_TYPE_COLOR, fillColor); + g_boxed_free(GDK_TYPE_COLOR, borderColor); + g_boxed_free(GDK_TYPE_COLOR, fillColorOver); + g_boxed_free(GDK_TYPE_COLOR, borderColorOver); + g_boxed_free(GDK_TYPE_COLOR, fillColorPress); + g_boxed_free(GDK_TYPE_COLOR, borderColorPress); - background_updates_disabled = FALSE; - background_update_image(index); + background_updates_disabled = FALSE; + background_update_image(index); } void background_update_for_gradient(int gradient_id_changed) { - gboolean deleted = gradient_id_changed >= get_model_length(GTK_TREE_MODEL(gradient_ids)); - int current_bg_index = gtk_combo_box_get_active(GTK_COMBO_BOX(current_background)); - for (int index = 1;; index++) { - GtkTreePath *path; - GtkTreeIter iter; + gboolean deleted = gradient_id_changed >= get_model_length(GTK_TREE_MODEL(gradient_ids)); + int current_bg_index = gtk_combo_box_get_active(GTK_COMBO_BOX(current_background)); + for (int index = 1;; index++) { + GtkTreePath *path; + GtkTreeIter iter; - path = gtk_tree_path_new_from_indices(index, -1); - gboolean found = gtk_tree_model_get_iter(GTK_TREE_MODEL(backgrounds), &iter, path); - gtk_tree_path_free(path); + path = gtk_tree_path_new_from_indices(index, -1); + gboolean found = gtk_tree_model_get_iter(GTK_TREE_MODEL(backgrounds), &iter, path); + gtk_tree_path_free(path); - if (!found) { - break; - } + if (!found) { + break; + } - int gradient_id, gradient_id_over, gradient_id_press; + int gradient_id, gradient_id_over, gradient_id_press; - gtk_tree_model_get(GTK_TREE_MODEL(backgrounds), - &iter, - bgColGradientId, - &gradient_id, - bgColGradientIdOver, - &gradient_id_over, - bgColGradientIdPress, - &gradient_id_press, - -1); - gboolean changed = FALSE; - if (gradient_id == gradient_id_changed && deleted) - gradient_id = -1, changed = TRUE; - if (gradient_id_over == gradient_id_changed && deleted) - gradient_id_over = -1, changed = TRUE; - if (gradient_id_press == gradient_id_changed && deleted) - gradient_id_press = -1, changed = TRUE; - if (changed) { - gtk_list_store_set(GTK_LIST_STORE(backgrounds), - &iter, - bgColGradientId, - gradient_id, - bgColGradientIdOver, - gradient_id_over, - bgColGradientIdPress, - gradient_id_press, - -1); - if (index == current_bg_index) { - gtk_combo_box_set_active(GTK_COMBO_BOX(background_gradient), gradient_id); - gtk_combo_box_set_active(GTK_COMBO_BOX(background_gradient_over), gradient_id_over); - gtk_combo_box_set_active(GTK_COMBO_BOX(background_gradient_press), gradient_id_press); - background_force_update(); - } else { - background_update_image(index); - } - } else { - background_update_image(index); - } - } + gtk_tree_model_get(GTK_TREE_MODEL(backgrounds), + &iter, + bgColGradientId, + &gradient_id, + bgColGradientIdOver, + &gradient_id_over, + bgColGradientIdPress, + &gradient_id_press, + -1); + gboolean changed = FALSE; + if (gradient_id == gradient_id_changed && deleted) + gradient_id = -1, changed = TRUE; + if (gradient_id_over == gradient_id_changed && deleted) + gradient_id_over = -1, changed = TRUE; + if (gradient_id_press == gradient_id_changed && deleted) + gradient_id_press = -1, changed = TRUE; + if (changed) { + gtk_list_store_set(GTK_LIST_STORE(backgrounds), + &iter, + bgColGradientId, + gradient_id, + bgColGradientIdOver, + gradient_id_over, + bgColGradientIdPress, + gradient_id_press, + -1); + if (index == current_bg_index) { + gtk_combo_box_set_active(GTK_COMBO_BOX(background_gradient), gradient_id); + gtk_combo_box_set_active(GTK_COMBO_BOX(background_gradient_over), gradient_id_over); + gtk_combo_box_set_active(GTK_COMBO_BOX(background_gradient_press), gradient_id_press); + background_force_update(); + } else { + background_update_image(index); + } + } else { + background_update_image(index); + } + } }
M src/tint2conf/gradient_gui.csrc/tint2conf/gradient_gui.c

@@ -5,608 +5,607 @@

GtkListStore *gradient_ids, *gradient_stop_ids; GList *gradients; GtkWidget *current_gradient, *gradient_combo_type, *gradient_start_color, *gradient_end_color, *current_gradient_stop, -*gradient_stop_color, *gradient_stop_offset; + *gradient_stop_color, *gradient_stop_offset; int gradient_index_safe(int index) { - if (index <= 0) - index = 0; - if (index >= get_model_length(GTK_TREE_MODEL(gradient_ids))) - index = 0; - return index; + if (index <= 0) + index = 0; + if (index >= get_model_length(GTK_TREE_MODEL(gradient_ids))) + index = 0; + return index; } GtkWidget *create_gradient_combo() { - GtkWidget *combo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(gradient_ids)); - GtkCellRenderer *renderer = gtk_cell_renderer_pixbuf_new(); - gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), renderer, FALSE); - gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo), renderer, "pixbuf", grColPixbuf, NULL); - renderer = gtk_cell_renderer_text_new(); - g_object_set(renderer, "wrap-mode", PANGO_WRAP_WORD, NULL); - g_object_set(renderer, "wrap-width", 300, NULL); - gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), renderer, FALSE); - gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo), renderer, "text", grColText, NULL); - return combo; + GtkWidget *combo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(gradient_ids)); + GtkCellRenderer *renderer = gtk_cell_renderer_pixbuf_new(); + gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), renderer, FALSE); + gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo), renderer, "pixbuf", grColPixbuf, NULL); + renderer = gtk_cell_renderer_text_new(); + g_object_set(renderer, "wrap-mode", PANGO_WRAP_WORD, NULL); + g_object_set(renderer, "wrap-width", 300, NULL); + gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), renderer, FALSE); + gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo), renderer, "text", grColText, NULL); + return combo; } void create_gradient(GtkWidget *parent) { - gradient_ids = gtk_list_store_new(grNumCols, GDK_TYPE_PIXBUF, GTK_TYPE_INT, GTK_TYPE_STRING); - gradients = NULL; + gradient_ids = gtk_list_store_new(grNumCols, GDK_TYPE_PIXBUF, GTK_TYPE_INT, GTK_TYPE_STRING); + gradients = NULL; - gradient_stop_ids = gtk_list_store_new(grStopNumCols, GDK_TYPE_PIXBUF); + gradient_stop_ids = gtk_list_store_new(grStopNumCols, GDK_TYPE_PIXBUF); - GtkWidget *table, *label, *button; - int row, col; - // GtkTooltips *tooltips = gtk_tooltips_new(); + GtkWidget *table, *label, *button; + int row, col; + // GtkTooltips *tooltips = gtk_tooltips_new(); - table = gtk_table_new(1, 4, FALSE); - gtk_widget_show(table); - gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); - gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); - gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); + table = gtk_table_new(1, 4, FALSE); + gtk_widget_show(table); + gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); + gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); + gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); - row = 0, col = 0; - label = gtk_label_new(_("<b>Gradient</b>")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_label_set_use_markup(GTK_LABEL(label), TRUE); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); - col++; + row = 0, col = 0; + label = gtk_label_new(_("<b>Gradient</b>")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_label_set_use_markup(GTK_LABEL(label), TRUE); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - current_gradient = create_gradient_combo(); - gtk_widget_show(current_gradient); - gtk_table_attach(GTK_TABLE(table), current_gradient, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); - col++; + current_gradient = create_gradient_combo(); + gtk_widget_show(current_gradient); + gtk_table_attach(GTK_TABLE(table), current_gradient, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - button = gtk_button_new_from_stock("gtk-add"); - gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(gradient_duplicate), NULL); - gtk_widget_show(button); - gtk_table_attach(GTK_TABLE(table), button, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); - col++; + button = gtk_button_new_from_stock("gtk-add"); + gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(gradient_duplicate), NULL); + gtk_widget_show(button); + gtk_table_attach(GTK_TABLE(table), button, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - button = gtk_button_new_from_stock("gtk-remove"); - gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(gradient_delete), NULL); - gtk_widget_show(button); - gtk_table_attach(GTK_TABLE(table), button, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); - col++; + button = gtk_button_new_from_stock("gtk-remove"); + gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(gradient_delete), NULL); + gtk_widget_show(button); + gtk_table_attach(GTK_TABLE(table), button, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - table = gtk_table_new(3, 4, FALSE); - gtk_widget_show(table); - gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); - gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); - gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); + table = gtk_table_new(3, 4, FALSE); + gtk_widget_show(table); + gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); + gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); + gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); - row = 0, col = 2; - label = gtk_label_new(_("Type")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); - col++; + row = 0, col = 2; + label = gtk_label_new(_("Type")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - gradient_combo_type = gtk_combo_box_new_text(); - gtk_widget_show(gradient_combo_type); - gtk_table_attach(GTK_TABLE(table), gradient_combo_type, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); - col++; - gtk_combo_box_append_text(GTK_COMBO_BOX(gradient_combo_type), _("Vertical")); - gtk_combo_box_append_text(GTK_COMBO_BOX(gradient_combo_type), _("Horizontal")); - gtk_combo_box_append_text(GTK_COMBO_BOX(gradient_combo_type), _("Radial")); - gtk_combo_box_set_active(GTK_COMBO_BOX(gradient_combo_type), 0); + gradient_combo_type = gtk_combo_box_new_text(); + gtk_widget_show(gradient_combo_type); + gtk_table_attach(GTK_TABLE(table), gradient_combo_type, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_combo_box_append_text(GTK_COMBO_BOX(gradient_combo_type), _("Vertical")); + gtk_combo_box_append_text(GTK_COMBO_BOX(gradient_combo_type), _("Horizontal")); + gtk_combo_box_append_text(GTK_COMBO_BOX(gradient_combo_type), _("Radial")); + gtk_combo_box_set_active(GTK_COMBO_BOX(gradient_combo_type), 0); - row++, col = 2; - label = gtk_label_new(_("Start color")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Start color")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - gradient_start_color = gtk_color_button_new(); - gtk_color_button_set_use_alpha(GTK_COLOR_BUTTON(gradient_start_color), TRUE); - gtk_widget_show(gradient_start_color); - gtk_table_attach(GTK_TABLE(table), gradient_start_color, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); - col++; + gradient_start_color = gtk_color_button_new(); + gtk_color_button_set_use_alpha(GTK_COLOR_BUTTON(gradient_start_color), TRUE); + gtk_widget_show(gradient_start_color); + gtk_table_attach(GTK_TABLE(table), gradient_start_color, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - row++, col = 2; - label = gtk_label_new(_("End color")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("End color")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - gradient_end_color = gtk_color_button_new(); - gtk_color_button_set_use_alpha(GTK_COLOR_BUTTON(gradient_end_color), TRUE); - gtk_widget_show(gradient_end_color); - gtk_table_attach(GTK_TABLE(table), gradient_end_color, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); - col++; + gradient_end_color = gtk_color_button_new(); + gtk_color_button_set_use_alpha(GTK_COLOR_BUTTON(gradient_end_color), TRUE); + gtk_widget_show(gradient_end_color); + gtk_table_attach(GTK_TABLE(table), gradient_end_color, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - change_paragraph(parent); + change_paragraph(parent); - table = gtk_table_new(1, 4, FALSE); - gtk_widget_show(table); - gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); - gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); - gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); + table = gtk_table_new(1, 4, FALSE); + gtk_widget_show(table); + gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); + gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); + gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); - row = 0, col = 0; - label = gtk_label_new(_("<b>Color stop</b>")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_label_set_use_markup(GTK_LABEL(label), TRUE); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); - col++; + row = 0, col = 0; + label = gtk_label_new(_("<b>Color stop</b>")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_label_set_use_markup(GTK_LABEL(label), TRUE); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - current_gradient_stop = create_gradient_stop_combo(NULL); - gtk_widget_show(current_gradient_stop); - gtk_table_attach(GTK_TABLE(table), current_gradient_stop, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); - col++; + current_gradient_stop = create_gradient_stop_combo(NULL); + gtk_widget_show(current_gradient_stop); + gtk_table_attach(GTK_TABLE(table), current_gradient_stop, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - button = gtk_button_new_from_stock("gtk-add"); - gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(gradient_stop_duplicate), NULL); - gtk_widget_show(button); - gtk_table_attach(GTK_TABLE(table), button, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); - col++; + button = gtk_button_new_from_stock("gtk-add"); + gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(gradient_stop_duplicate), NULL); + gtk_widget_show(button); + gtk_table_attach(GTK_TABLE(table), button, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - button = gtk_button_new_from_stock("gtk-remove"); - gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(gradient_stop_delete), NULL); - gtk_widget_show(button); - gtk_table_attach(GTK_TABLE(table), button, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); - col++; + button = gtk_button_new_from_stock("gtk-remove"); + gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(gradient_stop_delete), NULL); + gtk_widget_show(button); + gtk_table_attach(GTK_TABLE(table), button, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - table = gtk_table_new(3, 4, FALSE); - gtk_widget_show(table); - gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); - gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); - gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); + table = gtk_table_new(3, 4, FALSE); + gtk_widget_show(table); + gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); + gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); + gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); - row = 0, col = 2; - label = gtk_label_new(_("Color")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); - col++; + row = 0, col = 2; + label = gtk_label_new(_("Color")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - gradient_stop_color = gtk_color_button_new(); - gtk_color_button_set_use_alpha(GTK_COLOR_BUTTON(gradient_stop_color), TRUE); - gtk_widget_show(gradient_stop_color); - gtk_table_attach(GTK_TABLE(table), gradient_stop_color, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); - col++; + gradient_stop_color = gtk_color_button_new(); + gtk_color_button_set_use_alpha(GTK_COLOR_BUTTON(gradient_stop_color), TRUE); + gtk_widget_show(gradient_stop_color); + gtk_table_attach(GTK_TABLE(table), gradient_stop_color, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - row++, col = 2; - label = gtk_label_new(_("Position")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Position")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - gradient_stop_offset = gtk_spin_button_new_with_range(0, 100, 1); - gtk_widget_show(gradient_stop_offset); - gtk_table_attach(GTK_TABLE(table), gradient_stop_offset, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + gradient_stop_offset = gtk_spin_button_new_with_range(0, 100, 1); + gtk_widget_show(gradient_stop_offset); + gtk_table_attach(GTK_TABLE(table), gradient_stop_offset, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - g_signal_connect(G_OBJECT(current_gradient), "changed", G_CALLBACK(current_gradient_changed), NULL); - g_signal_connect(G_OBJECT(gradient_combo_type), "changed", G_CALLBACK(gradient_update), NULL); - g_signal_connect(G_OBJECT(gradient_start_color), "color-set", G_CALLBACK(gradient_update), NULL); - g_signal_connect(G_OBJECT(gradient_end_color), "color-set", G_CALLBACK(gradient_update), NULL); + g_signal_connect(G_OBJECT(current_gradient), "changed", G_CALLBACK(current_gradient_changed), NULL); + g_signal_connect(G_OBJECT(gradient_combo_type), "changed", G_CALLBACK(gradient_update), NULL); + g_signal_connect(G_OBJECT(gradient_start_color), "color-set", G_CALLBACK(gradient_update), NULL); + g_signal_connect(G_OBJECT(gradient_end_color), "color-set", G_CALLBACK(gradient_update), NULL); - g_signal_connect(G_OBJECT(current_gradient_stop), "changed", G_CALLBACK(current_gradient_stop_changed), NULL); - g_signal_connect(G_OBJECT(gradient_stop_color), "color-set", G_CALLBACK(gradient_stop_update), NULL); - g_signal_connect(G_OBJECT(gradient_stop_offset), "value-changed", G_CALLBACK(gradient_stop_update), NULL); + g_signal_connect(G_OBJECT(current_gradient_stop), "changed", G_CALLBACK(current_gradient_stop_changed), NULL); + g_signal_connect(G_OBJECT(gradient_stop_color), "color-set", G_CALLBACK(gradient_stop_update), NULL); + g_signal_connect(G_OBJECT(gradient_stop_offset), "value-changed", G_CALLBACK(gradient_stop_update), NULL); - change_paragraph(parent); + change_paragraph(parent); } void gradient_create_new(GradientConfigType t) { - int index = get_model_length(GTK_TREE_MODEL(gradient_ids)); + int index = get_model_length(GTK_TREE_MODEL(gradient_ids)); - GradientConfig *g = (GradientConfig *)calloc(1, sizeof(GradientConfig)); - g->type = t; - gradients = g_list_append(gradients, g); - GtkTreeIter iter; - gtk_list_store_append(gradient_ids, &iter); - gtk_list_store_set(gradient_ids, &iter, - grColPixbuf, NULL, - grColId, &index, - grColText, index == 0 ? _("None") : "", - -1); + GradientConfig *g = (GradientConfig *)calloc(1, sizeof(GradientConfig)); + g->type = t; + gradients = g_list_append(gradients, g); + GtkTreeIter iter; + gtk_list_store_append(gradient_ids, &iter); + gtk_list_store_set(gradient_ids, + &iter, + grColPixbuf, + NULL, + grColId, + &index, + grColText, + index == 0 ? _("None") : "", + -1); - gradient_update_image(index); - gtk_combo_box_set_active(GTK_COMBO_BOX(current_gradient), index); - current_gradient_changed(0, 0); + gradient_update_image(index); + gtk_combo_box_set_active(GTK_COMBO_BOX(current_gradient), index); + current_gradient_changed(0, 0); } gpointer copy_GradientConfigColorStop(gconstpointer arg, gpointer data) { - GradientConfigColorStop *old = (GradientConfigColorStop *)arg; + GradientConfigColorStop *old = (GradientConfigColorStop *)arg; - GradientConfigColorStop *copy = (GradientConfigColorStop *)calloc(1, sizeof(GradientConfigColorStop)); - memcpy(copy, old, sizeof(GradientConfigColorStop)); - return copy; + GradientConfigColorStop *copy = (GradientConfigColorStop *)calloc(1, sizeof(GradientConfigColorStop)); + memcpy(copy, old, sizeof(GradientConfigColorStop)); + return copy; } void gradient_duplicate(GtkWidget *widget, gpointer data) { - int old_index = gtk_combo_box_get_active(GTK_COMBO_BOX(current_gradient)); - if (old_index < 0) { - gradient_create_new(GRADIENT_CONFIG_VERTICAL); - return; - } + int old_index = gtk_combo_box_get_active(GTK_COMBO_BOX(current_gradient)); + if (old_index < 0) { + gradient_create_new(GRADIENT_CONFIG_VERTICAL); + return; + } - GradientConfig *g_old = (GradientConfig*)g_list_nth(gradients, (guint)old_index)->data; + GradientConfig *g_old = (GradientConfig *)g_list_nth(gradients, (guint)old_index)->data; - int index = get_model_length(GTK_TREE_MODEL(gradient_ids)); + int index = get_model_length(GTK_TREE_MODEL(gradient_ids)); - GradientConfig *g = (GradientConfig *)calloc(1, sizeof(GradientConfig)); - g->type = g_old->type; - g->start_color = g_old->start_color; - g->end_color = g_old->end_color; - g->extra_color_stops = g_list_copy_deep(g->extra_color_stops, copy_GradientConfigColorStop, NULL); - gradients = g_list_append(gradients, g); - GtkTreeIter iter; - gtk_list_store_append(gradient_ids, &iter); - gtk_list_store_set(gradient_ids, &iter, - grColPixbuf, NULL, - grColId, &index, - grColText, "", - -1); + GradientConfig *g = (GradientConfig *)calloc(1, sizeof(GradientConfig)); + g->type = g_old->type; + g->start_color = g_old->start_color; + g->end_color = g_old->end_color; + g->extra_color_stops = g_list_copy_deep(g->extra_color_stops, copy_GradientConfigColorStop, NULL); + gradients = g_list_append(gradients, g); + GtkTreeIter iter; + gtk_list_store_append(gradient_ids, &iter); + gtk_list_store_set(gradient_ids, &iter, grColPixbuf, NULL, grColId, &index, grColText, "", -1); - gradient_update_image(index); - gtk_combo_box_set_active(GTK_COMBO_BOX(current_gradient), index); - current_gradient_changed(0, 0); + gradient_update_image(index); + gtk_combo_box_set_active(GTK_COMBO_BOX(current_gradient), index); + current_gradient_changed(0, 0); } void gradient_delete(GtkWidget *widget, gpointer data) { - int index = gtk_combo_box_get_active(GTK_COMBO_BOX(current_gradient)); - if (index < 0) - return; + int index = gtk_combo_box_get_active(GTK_COMBO_BOX(current_gradient)); + if (index < 0) + return; - if (get_model_length(GTK_TREE_MODEL(gradient_ids)) <= 1) - return; + if (get_model_length(GTK_TREE_MODEL(gradient_ids)) <= 1) + return; - GtkTreePath *path; - GtkTreeIter iter; + GtkTreePath *path; + GtkTreeIter iter; - path = gtk_tree_path_new_from_indices(index, -1); - gtk_tree_model_get_iter(GTK_TREE_MODEL(gradient_ids), &iter, path); - gtk_tree_path_free(path); + path = gtk_tree_path_new_from_indices(index, -1); + gtk_tree_model_get_iter(GTK_TREE_MODEL(gradient_ids), &iter, path); + gtk_tree_path_free(path); - gradients = g_list_remove(gradients, g_list_nth(gradients, (guint)index)->data); - gtk_list_store_remove(gradient_ids, &iter); + gradients = g_list_remove(gradients, g_list_nth(gradients, (guint)index)->data); + gtk_list_store_remove(gradient_ids, &iter); - background_update_for_gradient(index); + background_update_for_gradient(index); - if (index >= get_model_length(GTK_TREE_MODEL(gradient_ids))) - index--; - gtk_combo_box_set_active(GTK_COMBO_BOX(current_gradient), index); + if (index >= get_model_length(GTK_TREE_MODEL(gradient_ids))) + index--; + gtk_combo_box_set_active(GTK_COMBO_BOX(current_gradient), index); } void gradient_draw(cairo_t *c, GradientConfig *g, int w, int h, gboolean preserve) { - cairo_pattern_t *gpat; - if (g->type == GRADIENT_CONFIG_VERTICAL) - gpat = cairo_pattern_create_linear(0, 0, 0, h); - else if (g->type == GRADIENT_CONFIG_HORIZONTAL) - gpat = cairo_pattern_create_linear(0, 0, w, 0); - else gpat = cairo_pattern_create_radial(w/2, h/2, 0, w/2, h/2, sqrt(w * w + h * h) / 2); - cairo_pattern_add_color_stop_rgba(gpat, 0.0, g->start_color.color.rgb[0], g->start_color.color.rgb[1], g->start_color.color.rgb[2], g->start_color.color.alpha); - for (GList *l = g->extra_color_stops; l; l = l->next) { - GradientConfigColorStop *stop = (GradientConfigColorStop *)l->data; - cairo_pattern_add_color_stop_rgba(gpat, - stop->offset, - stop->color.rgb[0], - stop->color.rgb[1], - stop->color.rgb[2], - stop->color.alpha); - } - cairo_pattern_add_color_stop_rgba(gpat, 1.0, g->end_color.color.rgb[0], g->end_color.color.rgb[1], g->end_color.color.rgb[2], g->end_color.color.alpha); - cairo_set_source(c, gpat); - cairo_rectangle(c, 0, 0, w, h); - if (preserve) - cairo_fill_preserve(c); - else - cairo_fill(c); - cairo_pattern_destroy(gpat); + cairo_pattern_t *gpat; + if (g->type == GRADIENT_CONFIG_VERTICAL) + gpat = cairo_pattern_create_linear(0, 0, 0, h); + else if (g->type == GRADIENT_CONFIG_HORIZONTAL) + gpat = cairo_pattern_create_linear(0, 0, w, 0); + else + gpat = cairo_pattern_create_radial(w / 2, h / 2, 0, w / 2, h / 2, sqrt(w * w + h * h) / 2); + cairo_pattern_add_color_stop_rgba(gpat, + 0.0, + g->start_color.color.rgb[0], + g->start_color.color.rgb[1], + g->start_color.color.rgb[2], + g->start_color.color.alpha); + for (GList *l = g->extra_color_stops; l; l = l->next) { + GradientConfigColorStop *stop = (GradientConfigColorStop *)l->data; + cairo_pattern_add_color_stop_rgba(gpat, + stop->offset, + stop->color.rgb[0], + stop->color.rgb[1], + stop->color.rgb[2], + stop->color.alpha); + } + cairo_pattern_add_color_stop_rgba(gpat, + 1.0, + g->end_color.color.rgb[0], + g->end_color.color.rgb[1], + g->end_color.color.rgb[2], + g->end_color.color.alpha); + cairo_set_source(c, gpat); + cairo_rectangle(c, 0, 0, w, h); + if (preserve) + cairo_fill_preserve(c); + else + cairo_fill(c); + cairo_pattern_destroy(gpat); } void gradient_update_image(int index) { - GradientConfig *g = (GradientConfig *)g_list_nth(gradients, (guint)index)->data; + GradientConfig *g = (GradientConfig *)g_list_nth(gradients, (guint)index)->data; - int w = 70; - int h = 30; - GdkPixmap *pixmap = gdk_pixmap_new(NULL, w, h, 24); + int w = 70; + int h = 30; + GdkPixmap *pixmap = gdk_pixmap_new(NULL, w, h, 24); - cairo_t *cr = gdk_cairo_create(pixmap); - cairo_set_source_rgb(cr, 0.5, 0.5, 0.5); - cairo_rectangle(cr, 0, 0, w, h); - cairo_fill(cr); + cairo_t *cr = gdk_cairo_create(pixmap); + cairo_set_source_rgb(cr, 0.5, 0.5, 0.5); + cairo_rectangle(cr, 0, 0, w, h); + cairo_fill(cr); - gradient_draw(cr, g, w, h, FALSE); + gradient_draw(cr, g, w, h, FALSE); - GdkPixbuf *pixbuf = gdk_pixbuf_get_from_drawable(NULL, pixmap, gdk_colormap_get_system(), 0, 0, 0, 0, w, h); - if (pixmap) - g_object_unref(pixmap); + GdkPixbuf *pixbuf = gdk_pixbuf_get_from_drawable(NULL, pixmap, gdk_colormap_get_system(), 0, 0, 0, 0, w, h); + if (pixmap) + g_object_unref(pixmap); - GtkTreePath *path; - GtkTreeIter iter; + GtkTreePath *path; + GtkTreeIter iter; - path = gtk_tree_path_new_from_indices(index, -1); - gtk_tree_model_get_iter(GTK_TREE_MODEL(gradient_ids), &iter, path); - gtk_tree_path_free(path); + path = gtk_tree_path_new_from_indices(index, -1); + gtk_tree_model_get_iter(GTK_TREE_MODEL(gradient_ids), &iter, path); + gtk_tree_path_free(path); - gtk_list_store_set(gradient_ids, &iter, - grColPixbuf, pixbuf, - -1); - if (pixbuf) - g_object_unref(pixbuf); + gtk_list_store_set(gradient_ids, &iter, grColPixbuf, pixbuf, -1); + if (pixbuf) + g_object_unref(pixbuf); } void gradient_force_update() { - gradient_update(NULL, NULL); + gradient_update(NULL, NULL); } static gboolean gradient_updates_disabled = FALSE; void gradient_update(GtkWidget *widget, gpointer data) { - if (gradient_updates_disabled) - return; - int index = gtk_combo_box_get_active(GTK_COMBO_BOX(current_gradient)); - if (index <= 0) - return; + if (gradient_updates_disabled) + return; + int index = gtk_combo_box_get_active(GTK_COMBO_BOX(current_gradient)); + if (index <= 0) + return; - GtkTreePath *path; - GtkTreeIter iter; + GtkTreePath *path; + GtkTreeIter iter; - path = gtk_tree_path_new_from_indices(index, -1); - gtk_tree_model_get_iter(GTK_TREE_MODEL(gradient_ids), &iter, path); - gtk_tree_path_free(path); + path = gtk_tree_path_new_from_indices(index, -1); + gtk_tree_model_get_iter(GTK_TREE_MODEL(gradient_ids), &iter, path); + gtk_tree_path_free(path); - GradientConfig *g = (GradientConfig *)g_list_nth(gradients, (guint)index)->data; + GradientConfig *g = (GradientConfig *)g_list_nth(gradients, (guint)index)->data; - g->type = (GradientConfigType)MAX(0, gtk_combo_box_get_active(GTK_COMBO_BOX(gradient_combo_type))); + g->type = (GradientConfigType)MAX(0, gtk_combo_box_get_active(GTK_COMBO_BOX(gradient_combo_type))); - GdkColor color; - int opacity; + GdkColor color; + int opacity; - gtk_color_button_get_color(GTK_COLOR_BUTTON(gradient_start_color), &color); - opacity = MIN(100, 0.5 + gtk_color_button_get_alpha(GTK_COLOR_BUTTON(gradient_start_color)) * 100.0 / 0xffff); - gdkColor2CairoColor(color, &g->start_color.color.rgb[0], &g->start_color.color.rgb[1], &g->start_color.color.rgb[2]); - g->start_color.color.alpha = opacity / 100.0; + gtk_color_button_get_color(GTK_COLOR_BUTTON(gradient_start_color), &color); + opacity = MIN(100, 0.5 + gtk_color_button_get_alpha(GTK_COLOR_BUTTON(gradient_start_color)) * 100.0 / 0xffff); + gdkColor2CairoColor(color, &g->start_color.color.rgb[0], &g->start_color.color.rgb[1], &g->start_color.color.rgb[2]); + g->start_color.color.alpha = opacity / 100.0; - gtk_color_button_get_color(GTK_COLOR_BUTTON(gradient_end_color), &color); - opacity = MIN(100, 0.5 + gtk_color_button_get_alpha(GTK_COLOR_BUTTON(gradient_end_color)) * 100.0 / 0xffff); - gdkColor2CairoColor(color, &g->end_color.color.rgb[0], &g->end_color.color.rgb[1], &g->end_color.color.rgb[2]); - g->end_color.color.alpha = opacity / 100.0; + gtk_color_button_get_color(GTK_COLOR_BUTTON(gradient_end_color), &color); + opacity = MIN(100, 0.5 + gtk_color_button_get_alpha(GTK_COLOR_BUTTON(gradient_end_color)) * 100.0 / 0xffff); + gdkColor2CairoColor(color, &g->end_color.color.rgb[0], &g->end_color.color.rgb[1], &g->end_color.color.rgb[2]); + g->end_color.color.alpha = opacity / 100.0; - gtk_list_store_set(gradient_ids, &iter, - grColPixbuf, NULL, - grColId, &index, - grColText, "", - -1); - gradient_update_image(index); - background_update_for_gradient(index); + gtk_list_store_set(gradient_ids, &iter, grColPixbuf, NULL, grColId, &index, grColText, "", -1); + gradient_update_image(index); + background_update_for_gradient(index); } void current_gradient_changed(GtkWidget *widget, gpointer data) { - int index = gtk_combo_box_get_active(GTK_COMBO_BOX(current_gradient)); - if (index < 0) - return; + int index = gtk_combo_box_get_active(GTK_COMBO_BOX(current_gradient)); + if (index < 0) + return; - gtk_widget_set_sensitive(gradient_combo_type, index > 0); - gtk_widget_set_sensitive(gradient_start_color, index > 0); - gtk_widget_set_sensitive(gradient_end_color, index > 0); - gtk_widget_set_sensitive(current_gradient_stop, index > 0); - gtk_widget_set_sensitive(gradient_stop_color, index > 0); - gtk_widget_set_sensitive(gradient_stop_offset, index > 0); + gtk_widget_set_sensitive(gradient_combo_type, index > 0); + gtk_widget_set_sensitive(gradient_start_color, index > 0); + gtk_widget_set_sensitive(gradient_end_color, index > 0); + gtk_widget_set_sensitive(current_gradient_stop, index > 0); + gtk_widget_set_sensitive(gradient_stop_color, index > 0); + gtk_widget_set_sensitive(gradient_stop_offset, index > 0); - gradient_updates_disabled = TRUE; + gradient_updates_disabled = TRUE; - GradientConfig *g = (GradientConfig *)g_list_nth(gradients, (guint)index)->data; + GradientConfig *g = (GradientConfig *)g_list_nth(gradients, (guint)index)->data; - gtk_combo_box_set_active(GTK_COMBO_BOX(gradient_combo_type), g->type); + gtk_combo_box_set_active(GTK_COMBO_BOX(gradient_combo_type), g->type); - GdkColor color; - int opacity; + GdkColor color; + int opacity; - cairoColor2GdkColor(g->start_color.color.rgb[0], g->start_color.color.rgb[1], g->start_color.color.rgb[2], &color); - opacity = g->start_color.color.alpha * 65535; - gtk_color_button_set_color(GTK_COLOR_BUTTON(gradient_start_color), &color); - gtk_color_button_set_alpha(GTK_COLOR_BUTTON(gradient_start_color), opacity); + cairoColor2GdkColor(g->start_color.color.rgb[0], g->start_color.color.rgb[1], g->start_color.color.rgb[2], &color); + opacity = g->start_color.color.alpha * 65535; + gtk_color_button_set_color(GTK_COLOR_BUTTON(gradient_start_color), &color); + gtk_color_button_set_alpha(GTK_COLOR_BUTTON(gradient_start_color), opacity); - cairoColor2GdkColor(g->end_color.color.rgb[0], g->end_color.color.rgb[1], g->end_color.color.rgb[2], &color); - opacity = g->end_color.color.alpha * 65535; - gtk_color_button_set_color(GTK_COLOR_BUTTON(gradient_end_color), &color); - gtk_color_button_set_alpha(GTK_COLOR_BUTTON(gradient_end_color), opacity); + cairoColor2GdkColor(g->end_color.color.rgb[0], g->end_color.color.rgb[1], g->end_color.color.rgb[2], &color); + opacity = g->end_color.color.alpha * 65535; + gtk_color_button_set_color(GTK_COLOR_BUTTON(gradient_end_color), &color); + gtk_color_button_set_alpha(GTK_COLOR_BUTTON(gradient_end_color), opacity); - int old_stop_index = gtk_combo_box_get_active(GTK_COMBO_BOX(current_gradient_stop)); - gtk_list_store_clear(gradient_stop_ids); - int stop_index = 0; - for (GList *l = g->extra_color_stops; l; l = l->next, stop_index++) { - GtkTreeIter iter; - gtk_list_store_append(gradient_stop_ids, &iter); - gtk_list_store_set(gradient_stop_ids, &iter, - grStopColPixbuf, NULL, - -1); - gradient_stop_update_image(stop_index); - } - if (old_stop_index >= 0 && old_stop_index < stop_index) - gtk_combo_box_set_active(GTK_COMBO_BOX(current_gradient_stop), old_stop_index); - else - gtk_combo_box_set_active(GTK_COMBO_BOX(current_gradient_stop), stop_index - 1); + int old_stop_index = gtk_combo_box_get_active(GTK_COMBO_BOX(current_gradient_stop)); + gtk_list_store_clear(gradient_stop_ids); + int stop_index = 0; + for (GList *l = g->extra_color_stops; l; l = l->next, stop_index++) { + GtkTreeIter iter; + gtk_list_store_append(gradient_stop_ids, &iter); + gtk_list_store_set(gradient_stop_ids, &iter, grStopColPixbuf, NULL, -1); + gradient_stop_update_image(stop_index); + } + if (old_stop_index >= 0 && old_stop_index < stop_index) + gtk_combo_box_set_active(GTK_COMBO_BOX(current_gradient_stop), old_stop_index); + else + gtk_combo_box_set_active(GTK_COMBO_BOX(current_gradient_stop), stop_index - 1); - gradient_updates_disabled = FALSE; - gradient_update_image(index); + gradient_updates_disabled = FALSE; + gradient_update_image(index); } //////// Gradient stops GtkWidget *create_gradient_stop_combo() { - GtkWidget *combo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(gradient_stop_ids)); - GtkCellRenderer *renderer = gtk_cell_renderer_pixbuf_new(); - gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), renderer, FALSE); - gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo), renderer, "pixbuf", grStopColPixbuf, NULL); - return combo; + GtkWidget *combo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(gradient_stop_ids)); + GtkCellRenderer *renderer = gtk_cell_renderer_pixbuf_new(); + gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), renderer, FALSE); + gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo), renderer, "pixbuf", grStopColPixbuf, NULL); + return combo; } void gradient_stop_create_new() { - int g_index = gtk_combo_box_get_active(GTK_COMBO_BOX(current_gradient)); - if (g_index < 0) - return; + int g_index = gtk_combo_box_get_active(GTK_COMBO_BOX(current_gradient)); + if (g_index < 0) + return; - GradientConfig *g = (GradientConfig *)g_list_nth(gradients, (guint)g_index)->data; - GradientConfigColorStop *stop = (GradientConfigColorStop *)calloc(1, sizeof(GradientConfigColorStop)); - if (g->extra_color_stops) - memcpy(stop, g_list_last(g->extra_color_stops)->data, sizeof(GradientConfigColorStop)); - else - memcpy(stop, &g->start_color, sizeof(GradientConfigColorStop)); - g->extra_color_stops = g_list_append(g->extra_color_stops, stop); - GtkTreeIter iter; - gtk_list_store_append(gradient_stop_ids, &iter); - gtk_list_store_set(gradient_stop_ids, &iter, - grStopColPixbuf, NULL, - -1); + GradientConfig *g = (GradientConfig *)g_list_nth(gradients, (guint)g_index)->data; + GradientConfigColorStop *stop = (GradientConfigColorStop *)calloc(1, sizeof(GradientConfigColorStop)); + if (g->extra_color_stops) + memcpy(stop, g_list_last(g->extra_color_stops)->data, sizeof(GradientConfigColorStop)); + else + memcpy(stop, &g->start_color, sizeof(GradientConfigColorStop)); + g->extra_color_stops = g_list_append(g->extra_color_stops, stop); + GtkTreeIter iter; + gtk_list_store_append(gradient_stop_ids, &iter); + gtk_list_store_set(gradient_stop_ids, &iter, grStopColPixbuf, NULL, -1); - int stop_index = g_list_length(g->extra_color_stops) - 1; - gradient_stop_update_image(stop_index); - gtk_combo_box_set_active(GTK_COMBO_BOX(current_gradient_stop), stop_index); - current_gradient_stop_changed(0, 0); - gradient_update_image(g_index); - background_update_for_gradient(g_index); + int stop_index = g_list_length(g->extra_color_stops) - 1; + gradient_stop_update_image(stop_index); + gtk_combo_box_set_active(GTK_COMBO_BOX(current_gradient_stop), stop_index); + current_gradient_stop_changed(0, 0); + gradient_update_image(g_index); + background_update_for_gradient(g_index); } void gradient_stop_duplicate(GtkWidget *widget, gpointer data) { - gradient_stop_create_new(); + gradient_stop_create_new(); } void gradient_stop_delete(GtkWidget *widget, gpointer data) { - int g_index = gtk_combo_box_get_active(GTK_COMBO_BOX(current_gradient)); - if (g_index < 0) - return; + int g_index = gtk_combo_box_get_active(GTK_COMBO_BOX(current_gradient)); + if (g_index < 0) + return; - GradientConfig *g = (GradientConfig *)g_list_nth(gradients, (guint)g_index)->data; - if (!g->extra_color_stops) - return; + GradientConfig *g = (GradientConfig *)g_list_nth(gradients, (guint)g_index)->data; + if (!g->extra_color_stops) + return; - int index = gtk_combo_box_get_active(GTK_COMBO_BOX(current_gradient_stop)); - if (index < 0) - return; + int index = gtk_combo_box_get_active(GTK_COMBO_BOX(current_gradient_stop)); + if (index < 0) + return; - GtkTreePath *path; - GtkTreeIter iter; + GtkTreePath *path; + GtkTreeIter iter; - path = gtk_tree_path_new_from_indices(index, -1); - gtk_tree_model_get_iter(GTK_TREE_MODEL(gradient_stop_ids), &iter, path); - gtk_tree_path_free(path); + path = gtk_tree_path_new_from_indices(index, -1); + gtk_tree_model_get_iter(GTK_TREE_MODEL(gradient_stop_ids), &iter, path); + gtk_tree_path_free(path); - g->extra_color_stops = g_list_remove(g->extra_color_stops, g_list_nth(g->extra_color_stops, (guint)index)->data); - gtk_list_store_remove(gradient_stop_ids, &iter); + g->extra_color_stops = g_list_remove(g->extra_color_stops, g_list_nth(g->extra_color_stops, (guint)index)->data); + gtk_list_store_remove(gradient_stop_ids, &iter); - if (index >= get_model_length(GTK_TREE_MODEL(gradient_stop_ids))) - index--; - gtk_combo_box_set_active(GTK_COMBO_BOX(current_gradient_stop), index); + if (index >= get_model_length(GTK_TREE_MODEL(gradient_stop_ids))) + index--; + gtk_combo_box_set_active(GTK_COMBO_BOX(current_gradient_stop), index); - gradient_update_image(g_index); - background_update_for_gradient(g_index); + gradient_update_image(g_index); + background_update_for_gradient(g_index); } void gradient_stop_update_image(int index) { - int g_index = gtk_combo_box_get_active(GTK_COMBO_BOX(current_gradient)); - if (g_index < 0) - return; - GradientConfig *g = (GradientConfig *)g_list_nth(gradients, (guint)g_index)->data; - GradientConfigColorStop *stop = (GradientConfigColorStop *)g_list_nth(g->extra_color_stops, (guint)index)->data; + int g_index = gtk_combo_box_get_active(GTK_COMBO_BOX(current_gradient)); + if (g_index < 0) + return; + GradientConfig *g = (GradientConfig *)g_list_nth(gradients, (guint)g_index)->data; + GradientConfigColorStop *stop = (GradientConfigColorStop *)g_list_nth(g->extra_color_stops, (guint)index)->data; - int w = 70; - int h = 30; - GdkPixmap *pixmap = gdk_pixmap_new(NULL, w, h, 24); + int w = 70; + int h = 30; + GdkPixmap *pixmap = gdk_pixmap_new(NULL, w, h, 24); - cairo_t *cr = gdk_cairo_create(pixmap); - cairo_set_source_rgba(cr, stop->color.rgb[0], stop->color.rgb[1], stop->color.rgb[2], stop->color.alpha); - cairo_rectangle(cr, 0, 0, w, h); - cairo_fill(cr); + cairo_t *cr = gdk_cairo_create(pixmap); + cairo_set_source_rgba(cr, stop->color.rgb[0], stop->color.rgb[1], stop->color.rgb[2], stop->color.alpha); + cairo_rectangle(cr, 0, 0, w, h); + cairo_fill(cr); - GdkPixbuf *pixbuf = gdk_pixbuf_get_from_drawable(NULL, pixmap, gdk_colormap_get_system(), 0, 0, 0, 0, w, h); - if (pixmap) - g_object_unref(pixmap); + GdkPixbuf *pixbuf = gdk_pixbuf_get_from_drawable(NULL, pixmap, gdk_colormap_get_system(), 0, 0, 0, 0, w, h); + if (pixmap) + g_object_unref(pixmap); - GtkTreePath *path; - GtkTreeIter iter; + GtkTreePath *path; + GtkTreeIter iter; - path = gtk_tree_path_new_from_indices(index, -1); - gtk_tree_model_get_iter(GTK_TREE_MODEL(gradient_stop_ids), &iter, path); - gtk_tree_path_free(path); + path = gtk_tree_path_new_from_indices(index, -1); + gtk_tree_model_get_iter(GTK_TREE_MODEL(gradient_stop_ids), &iter, path); + gtk_tree_path_free(path); - gtk_list_store_set(gradient_stop_ids, &iter, - grStopColPixbuf, pixbuf, - -1); - if (pixbuf) - g_object_unref(pixbuf); + gtk_list_store_set(gradient_stop_ids, &iter, grStopColPixbuf, pixbuf, -1); + if (pixbuf) + g_object_unref(pixbuf); } void current_gradient_stop_changed(GtkWidget *widget, gpointer data) { - int g_index = gtk_combo_box_get_active(GTK_COMBO_BOX(current_gradient)); - if (g_index < 0) - return; - GradientConfig *g = (GradientConfig *)g_list_nth(gradients, (guint)g_index)->data; + int g_index = gtk_combo_box_get_active(GTK_COMBO_BOX(current_gradient)); + if (g_index < 0) + return; + GradientConfig *g = (GradientConfig *)g_list_nth(gradients, (guint)g_index)->data; - int index = gtk_combo_box_get_active(GTK_COMBO_BOX(current_gradient_stop)); - if (index < 0) - return; + int index = gtk_combo_box_get_active(GTK_COMBO_BOX(current_gradient_stop)); + if (index < 0) + return; - GradientConfigColorStop *stop = (GradientConfigColorStop *)g_list_nth(g->extra_color_stops, (guint)index)->data; + GradientConfigColorStop *stop = (GradientConfigColorStop *)g_list_nth(g->extra_color_stops, (guint)index)->data; - gradient_updates_disabled = TRUE; + gradient_updates_disabled = TRUE; - GdkColor color; - int opacity; + GdkColor color; + int opacity; - cairoColor2GdkColor(stop->color.rgb[0], stop->color.rgb[1], stop->color.rgb[2], &color); - opacity = stop->color.alpha * 65535; - gtk_color_button_set_color(GTK_COLOR_BUTTON(gradient_stop_color), &color); - gtk_color_button_set_alpha(GTK_COLOR_BUTTON(gradient_stop_color), opacity); + cairoColor2GdkColor(stop->color.rgb[0], stop->color.rgb[1], stop->color.rgb[2], &color); + opacity = stop->color.alpha * 65535; + gtk_color_button_set_color(GTK_COLOR_BUTTON(gradient_stop_color), &color); + gtk_color_button_set_alpha(GTK_COLOR_BUTTON(gradient_stop_color), opacity); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(gradient_stop_offset), stop->offset * 100); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(gradient_stop_offset), stop->offset * 100); - gradient_updates_disabled = FALSE; + gradient_updates_disabled = FALSE; } void gradient_stop_update(GtkWidget *widget, gpointer data) { - if (gradient_updates_disabled) - return; + if (gradient_updates_disabled) + return; - int g_index = gtk_combo_box_get_active(GTK_COMBO_BOX(current_gradient)); - if (g_index < 0) - return; - GradientConfig *g = (GradientConfig *)g_list_nth(gradients, (guint)g_index)->data; + int g_index = gtk_combo_box_get_active(GTK_COMBO_BOX(current_gradient)); + if (g_index < 0) + return; + GradientConfig *g = (GradientConfig *)g_list_nth(gradients, (guint)g_index)->data; - int index = gtk_combo_box_get_active(GTK_COMBO_BOX(current_gradient_stop)); - if (index < 0) - return; + int index = gtk_combo_box_get_active(GTK_COMBO_BOX(current_gradient_stop)); + if (index < 0) + return; - GradientConfigColorStop *stop = (GradientConfigColorStop *)g_list_nth(g->extra_color_stops, (guint)index)->data; + GradientConfigColorStop *stop = (GradientConfigColorStop *)g_list_nth(g->extra_color_stops, (guint)index)->data; - GdkColor color; - int opacity; + GdkColor color; + int opacity; - gtk_color_button_get_color(GTK_COLOR_BUTTON(gradient_stop_color), &color); - opacity = MIN(100, 0.5 + gtk_color_button_get_alpha(GTK_COLOR_BUTTON(gradient_stop_color)) * 100.0 / 0xffff); - gdkColor2CairoColor(color, &stop->color.rgb[0], &stop->color.rgb[1], &stop->color.rgb[2]); - stop->color.alpha = opacity / 100.0; + gtk_color_button_get_color(GTK_COLOR_BUTTON(gradient_stop_color), &color); + opacity = MIN(100, 0.5 + gtk_color_button_get_alpha(GTK_COLOR_BUTTON(gradient_stop_color)) * 100.0 / 0xffff); + gdkColor2CairoColor(color, &stop->color.rgb[0], &stop->color.rgb[1], &stop->color.rgb[2]); + stop->color.alpha = opacity / 100.0; - stop->offset = gtk_spin_button_get_value(GTK_SPIN_BUTTON(gradient_stop_offset)) / 100.; + stop->offset = gtk_spin_button_get_value(GTK_SPIN_BUTTON(gradient_stop_offset)) / 100.; - gradient_stop_update_image(index); - gradient_update_image(g_index); - background_update_for_gradient(g_index); + gradient_stop_update_image(index); + gradient_update_image(g_index); + background_update_for_gradient(g_index); }
M src/tint2conf/gradient_gui.hsrc/tint2conf/gradient_gui.h

@@ -22,23 +22,23 @@ void gradient_stop_update_image(int index);

void current_gradient_stop_changed(GtkWidget *widget, gpointer data); typedef enum GradientConfigType { - GRADIENT_CONFIG_VERTICAL = 0, - GRADIENT_CONFIG_HORIZONTAL, - GRADIENT_CONFIG_RADIAL + GRADIENT_CONFIG_VERTICAL = 0, + GRADIENT_CONFIG_HORIZONTAL, + GRADIENT_CONFIG_RADIAL } GradientConfigType; typedef struct GradientConfigColorStop { - Color color; - // offset in 0-1 - double offset; + Color color; + // offset in 0-1 + double offset; } GradientConfigColorStop; typedef struct GradientConfig { - GradientConfigType type; - GradientConfigColorStop start_color; - GradientConfigColorStop end_color; - // Each element is a GradientConfigColorStop - GList *extra_color_stops; + GradientConfigType type; + GradientConfigColorStop start_color; + GradientConfigColorStop end_color; + // Each element is a GradientConfigColorStop + GList *extra_color_stops; } GradientConfig; void gradient_create_new(GradientConfigType t);
M src/tint2conf/main.csrc/tint2conf/main.c

@@ -42,67 +42,67 @@ // Returns ~/.config/tint2/tint2rc (or equivalent).

// Needs gfree. gchar *get_home_config_path() { - return g_build_filename(g_get_user_config_dir(), "tint2", "tint2rc", NULL); + return g_build_filename(g_get_user_config_dir(), "tint2", "tint2rc", NULL); } // Returns /etc/xdg/tint2/tint2rc (or equivalent). // Needs gfree. gchar *get_etc_config_path() { - gchar *path = NULL; - const gchar *const *system_dirs = g_get_system_config_dirs(); - for (int i = 0; system_dirs[i]; i++) { - path = g_build_filename(system_dirs[i], "tint2", "tint2rc", NULL); - if (g_file_test(path, G_FILE_TEST_EXISTS)) - return path; - g_free(path); - path = NULL; - } - return g_strdup("/dev/null"); + gchar *path = NULL; + const gchar *const *system_dirs = g_get_system_config_dirs(); + for (int i = 0; system_dirs[i]; i++) { + path = g_build_filename(system_dirs[i], "tint2", "tint2rc", NULL); + if (g_file_test(path, G_FILE_TEST_EXISTS)) + return path; + g_free(path); + path = NULL; + } + return g_strdup("/dev/null"); } gboolean startswith(const char *str, const char *prefix) { - return strstr(str, prefix) == str; + return strstr(str, prefix) == str; } gboolean endswith(const char *str, const char *suffix) { - return strlen(str) >= strlen(suffix) && g_str_equal(str + strlen(str) - strlen(suffix), suffix); + return strlen(str) >= strlen(suffix) && g_str_equal(str + strlen(str) - strlen(suffix), suffix); } // Returns TRUE if the theme file is in ~/.config. gboolean theme_is_editable(const char *filepath) { - return startswith(filepath, g_get_user_config_dir()); + return startswith(filepath, g_get_user_config_dir()); } // Returns TRUE if the theme file is ~/.config/tint2/tint2rc. gboolean theme_is_default(const char *filepath) { - gchar *default_path = get_home_config_path(); - gboolean result = g_str_equal(default_path, filepath); - g_free(default_path); - return result; + gchar *default_path = get_home_config_path(); + gboolean result = g_str_equal(default_path, filepath); + g_free(default_path); + return result; } // Extracts the file name from the path. Do not free! char *file_name_from_path(const char *filepath) { - char *name = strrchr(filepath, '/'); - if (!name) - return NULL; - name++; - if (!*name) - return NULL; - return name; + char *name = strrchr(filepath, '/'); + if (!name) + return NULL; + name++; + if (!*name) + return NULL; + return name; } void make_backup(const char *filepath) { - gchar *backup_path = g_strdup_printf("%s.backup.%ld", filepath, time(NULL)); - copy_file(filepath, backup_path); - g_free(backup_path); + gchar *backup_path = g_strdup_printf("%s.backup.%ld", filepath, time(NULL)); + copy_file(filepath, backup_path); + g_free(backup_path); } // Imports a file to ~/.config/tint2/.

@@ -111,46 +111,46 @@ // Takes care of updating the theme list in the GUI.

// Returns the new location. Needs gfree. gchar *import_no_overwrite(const char *filepath) { - gchar *filename = file_name_from_path(filepath); - if (!filename) - return NULL; + gchar *filename = file_name_from_path(filepath); + if (!filename) + return NULL; - gchar *newpath = g_build_filename(g_get_user_config_dir(), "tint2", filename, NULL); - if (!g_file_test(newpath, G_FILE_TEST_EXISTS)) { - copy_file(filepath, newpath); - theme_list_append(newpath); - g_timeout_add(SNAPSHOT_TICK, update_snapshot, NULL); - } + gchar *newpath = g_build_filename(g_get_user_config_dir(), "tint2", filename, NULL); + if (!g_file_test(newpath, G_FILE_TEST_EXISTS)) { + copy_file(filepath, newpath); + theme_list_append(newpath); + g_timeout_add(SNAPSHOT_TICK, update_snapshot, NULL); + } - return newpath; + return newpath; } // Copies a theme file from filepath to newpath. // Takes care of updating the theme list in the GUI. void import_with_overwrite(const char *filepath, const char *newpath) { - gboolean theme_existed = g_file_test(newpath, G_FILE_TEST_EXISTS); - if (theme_existed) - make_backup(newpath); + gboolean theme_existed = g_file_test(newpath, G_FILE_TEST_EXISTS); + if (theme_existed) + make_backup(newpath); - copy_file(filepath, newpath); + copy_file(filepath, newpath); - if (theme_is_editable(newpath)) { - if (!theme_existed) { - theme_list_append(newpath); - g_timeout_add(SNAPSHOT_TICK, update_snapshot, NULL); - } else { - int unused = system("killall -SIGUSR1 tint2 || pkill -SIGUSR1 -x tint2"); - (void)unused; - refresh_theme(newpath); - } - } + if (theme_is_editable(newpath)) { + if (!theme_existed) { + theme_list_append(newpath); + g_timeout_add(SNAPSHOT_TICK, update_snapshot, NULL); + } else { + int unused = system("killall -SIGUSR1 tint2 || pkill -SIGUSR1 -x tint2"); + (void)unused; + refresh_theme(newpath); + } + } } static void menuAddWidget(GtkUIManager *ui_manager, GtkWidget *p_widget, GtkContainer *p_box) { - gtk_box_pack_start(GTK_BOX(p_box), p_widget, FALSE, FALSE, 0); - gtk_widget_show(p_widget); + gtk_box_pack_start(GTK_BOX(p_box), p_widget, FALSE, FALSE, 0); + gtk_widget_show(p_widget); } static void menuAddWidget(GtkUIManager *, GtkWidget *, GtkContainer *);

@@ -178,173 +178,203 @@

GtkActionGroup *actionGroup = NULL; static const char *global_ui = "<ui>" - " <menubar name='MenuBar'>" - " <menu action='ThemeMenu'>" - " <menuitem action='ThemeImportFile'/>" - " <separator/>" - " <menuitem action='ThemeEdit'/>" - " <menuitem action='ThemeSaveAs'/>" - " <menuitem action='ThemeMakeDefault'/>" - " <menuitem action='ThemeReset'/>" - " <menuitem action='ThemeDelete'/>" - " <separator/>" - " <menuitem action='ThemeRefresh'/>" - " <menuitem action='RefreshAll'/>" - " <separator/>" - " <menuitem action='Quit'/>" - " </menu>" - " <menu action='HelpMenu'>" - " <menuitem action='HelpAbout'/>" - " </menu>" - " </menubar>" - " <toolbar name='ToolBar'>" - " <toolitem action='ThemeEdit'/>" - " <toolitem action='ThemeMakeDefault'/>" - " </toolbar>" - " <popup name='ThemePopup'>" - " <menuitem action='ThemeEdit'/>" - " <menuitem action='ThemeRefresh'/>" - " <separator/>" - " <menuitem action='ThemeReset'/>" - " <menuitem action='ThemeDelete'/>" - " </popup>" - "</ui>"; + " <menubar name='MenuBar'>" + " <menu action='ThemeMenu'>" + " <menuitem action='ThemeImportFile'/>" + " <separator/>" + " <menuitem action='ThemeEdit'/>" + " <menuitem action='ThemeSaveAs'/>" + " <menuitem action='ThemeMakeDefault'/>" + " <menuitem action='ThemeReset'/>" + " <menuitem action='ThemeDelete'/>" + " <separator/>" + " <menuitem action='ThemeRefresh'/>" + " <menuitem action='RefreshAll'/>" + " <separator/>" + " <menuitem action='Quit'/>" + " </menu>" + " <menu action='HelpMenu'>" + " <menuitem action='HelpAbout'/>" + " </menu>" + " </menubar>" + " <toolbar name='ToolBar'>" + " <toolitem action='ThemeEdit'/>" + " <toolitem action='ThemeMakeDefault'/>" + " </toolbar>" + " <popup name='ThemePopup'>" + " <menuitem action='ThemeEdit'/>" + " <menuitem action='ThemeRefresh'/>" + " <separator/>" + " <menuitem action='ThemeReset'/>" + " <menuitem action='ThemeDelete'/>" + " </popup>" + "</ui>"; int main(int argc, char **argv) { - setlocale(LC_ALL, ""); - bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR); - bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); - textdomain(GETTEXT_PACKAGE); + setlocale(LC_ALL, ""); + bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR); + bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); + textdomain(GETTEXT_PACKAGE); - GtkWidget *vBox = NULL, *scrollbar = NULL; - gtk_init(&argc, &argv); + GtkWidget *vBox = NULL, *scrollbar = NULL; + gtk_init(&argc, &argv); #if !GLIB_CHECK_VERSION(2, 31, 0) - g_thread_init(NULL); + g_thread_init(NULL); #endif - { - gchar *tint2_config_dir = g_build_filename(g_get_user_config_dir(), "tint2", NULL); - if (!g_file_test(tint2_config_dir, G_FILE_TEST_IS_DIR)) - g_mkdir(tint2_config_dir, 0700); - g_free(tint2_config_dir); - } + { + gchar *tint2_config_dir = g_build_filename(g_get_user_config_dir(), "tint2", NULL); + if (!g_file_test(tint2_config_dir, G_FILE_TEST_IS_DIR)) + g_mkdir(tint2_config_dir, 0700); + g_free(tint2_config_dir); + } - g_set_application_name(_("tint2conf")); - gtk_window_set_default_icon_name("tint2conf"); + g_set_application_name(_("tint2conf")); + gtk_window_set_default_icon_name("tint2conf"); - // config file uses '.' as decimal separator - setlocale(LC_NUMERIC, "POSIX"); + // config file uses '.' as decimal separator + setlocale(LC_NUMERIC, "POSIX"); - // define main layout : container, menubar, toolbar - g_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); - gtk_window_set_title(GTK_WINDOW(g_window), _("Tint2 panel themes")); - gtk_window_resize(GTK_WINDOW(g_window), 920, 600); - g_signal_connect(G_OBJECT(g_window), "destroy", G_CALLBACK(gtk_main_quit), NULL); - vBox = gtk_vbox_new(FALSE, 0); - gtk_container_add(GTK_CONTAINER(g_window), vBox); + // define main layout : container, menubar, toolbar + g_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); + gtk_window_set_title(GTK_WINDOW(g_window), _("Tint2 panel themes")); + gtk_window_resize(GTK_WINDOW(g_window), 920, 600); + g_signal_connect(G_OBJECT(g_window), "destroy", G_CALLBACK(gtk_main_quit), NULL); + vBox = gtk_vbox_new(FALSE, 0); + gtk_container_add(GTK_CONTAINER(g_window), vBox); - actionGroup = gtk_action_group_new("menuActionGroup"); + actionGroup = gtk_action_group_new("menuActionGroup"); - // Menubar and toolbar entries - GtkActionEntry entries[] = - {{"ThemeMenu", NULL, _("_Theme"), NULL, NULL, NULL}, - {"ThemeImportFile", GTK_STOCK_ADD, _("_Import theme..."), "<Control>N", _("Import theme(s) from file system"), G_CALLBACK(menuImportFile)}, - {"ThemeSaveAs", GTK_STOCK_SAVE_AS, _("_Save as..."), NULL, _("Save the theme with a new name"), G_CALLBACK(menuSaveAs)}, - {"ThemeDelete", GTK_STOCK_DELETE, _("_Delete"), NULL, _("Delete the selected theme"), G_CALLBACK(menuDelete)}, - {"ThemeReset", GTK_STOCK_REVERT_TO_SAVED, _("_Reset"), NULL, _("Reset the selected theme to default"), G_CALLBACK(menuReset)}, - {"ThemeEdit", GTK_STOCK_PROPERTIES, _("_Edit theme..."), NULL, _("Edit the selected theme"), G_CALLBACK(edit_theme)}, - {"ThemeMakeDefault", GTK_STOCK_APPLY, _("_Make default"), NULL, _("Replace the default theme with the selected one"), G_CALLBACK(make_selected_theme_default)}, - {"ThemeRefresh", GTK_STOCK_REFRESH, _("Refresh"), NULL, _("Redraw the selected theme"), G_CALLBACK(refresh_current_theme)}, - {"RefreshAll", GTK_STOCK_REFRESH, _("Refresh all"), NULL, _("Redraw all themes"), G_CALLBACK(reload_all_themes)}, - {"Quit", GTK_STOCK_QUIT, _("_Quit"), "<control>Q", _("Quit"), G_CALLBACK(gtk_main_quit)}, - {"HelpMenu", NULL, _("_Help"), NULL, NULL, NULL}, - {"HelpAbout", GTK_STOCK_ABOUT, _("_About"), "<Control>A", _("About"), G_CALLBACK(menuAbout)}}; + // Menubar and toolbar entries + GtkActionEntry entries[] = + {{"ThemeMenu", NULL, _("_Theme"), NULL, NULL, NULL}, + {"ThemeImportFile", + GTK_STOCK_ADD, + _("_Import theme..."), + "<Control>N", + _("Import theme(s) from file system"), + G_CALLBACK(menuImportFile)}, + {"ThemeSaveAs", + GTK_STOCK_SAVE_AS, + _("_Save as..."), + NULL, + _("Save the theme with a new name"), + G_CALLBACK(menuSaveAs)}, + {"ThemeDelete", GTK_STOCK_DELETE, _("_Delete"), NULL, _("Delete the selected theme"), G_CALLBACK(menuDelete)}, + {"ThemeReset", + GTK_STOCK_REVERT_TO_SAVED, + _("_Reset"), + NULL, + _("Reset the selected theme to default"), + G_CALLBACK(menuReset)}, + {"ThemeEdit", + GTK_STOCK_PROPERTIES, + _("_Edit theme..."), + NULL, + _("Edit the selected theme"), + G_CALLBACK(edit_theme)}, + {"ThemeMakeDefault", + GTK_STOCK_APPLY, + _("_Make default"), + NULL, + _("Replace the default theme with the selected one"), + G_CALLBACK(make_selected_theme_default)}, + {"ThemeRefresh", + GTK_STOCK_REFRESH, + _("Refresh"), + NULL, + _("Redraw the selected theme"), + G_CALLBACK(refresh_current_theme)}, + {"RefreshAll", GTK_STOCK_REFRESH, _("Refresh all"), NULL, _("Redraw all themes"), G_CALLBACK(reload_all_themes)}, + {"Quit", GTK_STOCK_QUIT, _("_Quit"), "<control>Q", _("Quit"), G_CALLBACK(gtk_main_quit)}, + {"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); - gtk_window_add_accel_group(GTK_WINDOW(g_window), gtk_ui_manager_get_accel_group(globalUIManager)); - gtk_ui_manager_add_ui_from_string(globalUIManager, global_ui, -1, (NULL)); - g_signal_connect(globalUIManager, "add_widget", G_CALLBACK(menuAddWidget), vBox); - gtk_ui_manager_ensure_update(globalUIManager); + 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); + gtk_window_add_accel_group(GTK_WINDOW(g_window), gtk_ui_manager_get_accel_group(globalUIManager)); + gtk_ui_manager_add_ui_from_string(globalUIManager, global_ui, -1, (NULL)); + g_signal_connect(globalUIManager, "add_widget", G_CALLBACK(menuAddWidget), vBox); + gtk_ui_manager_ensure_update(globalUIManager); - GtkWidget *table, *label; - int row, col; + GtkWidget *table, *label; + int row, col; - row = col = 0; - table = gtk_table_new(1, 2, FALSE); - gtk_widget_show(table); - gtk_box_pack_start(GTK_BOX(vBox), table, FALSE, TRUE, 0); - gtk_table_set_row_spacings(GTK_TABLE(table), 8); - gtk_table_set_col_spacings(GTK_TABLE(table), 8); + row = col = 0; + table = gtk_table_new(1, 2, FALSE); + gtk_widget_show(table); + gtk_box_pack_start(GTK_BOX(vBox), table, FALSE, TRUE, 0); + gtk_table_set_row_spacings(GTK_TABLE(table), 8); + gtk_table_set_col_spacings(GTK_TABLE(table), 8); - label = gtk_label_new(_("Command to run tint2: ")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); - col++; + label = gtk_label_new(_("Command to run tint2: ")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - tint_cmd = gtk_entry_new(); - gtk_widget_show(tint_cmd); - gtk_entry_set_text(GTK_ENTRY(tint_cmd), ""); - gtk_table_attach(GTK_TABLE(table), tint_cmd, col, col + 1, row, row + 1, GTK_FILL | GTK_EXPAND, 0, 0, 0); + tint_cmd = gtk_entry_new(); + gtk_widget_show(tint_cmd); + gtk_entry_set_text(GTK_ENTRY(tint_cmd), ""); + gtk_table_attach(GTK_TABLE(table), tint_cmd, col, col + 1, row, row + 1, GTK_FILL | GTK_EXPAND, 0, 0, 0); - scrollbar = gtk_scrolled_window_new(NULL, NULL); - gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollbar), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_box_pack_start(GTK_BOX(vBox), scrollbar, TRUE, TRUE, 0); + scrollbar = gtk_scrolled_window_new(NULL, NULL); + gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollbar), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); + gtk_box_pack_start(GTK_BOX(vBox), scrollbar, TRUE, TRUE, 0); - // define theme view - g_theme_view = create_view(); - gtk_container_add(GTK_CONTAINER(scrollbar), g_theme_view); - gtk_widget_show(g_theme_view); - g_signal_connect(g_theme_view, "button-press-event", (GCallback)view_onButtonPressed, NULL); - g_signal_connect(g_theme_view, "popup-menu", (GCallback)view_onPopupMenu, NULL); - g_signal_connect(g_theme_view, "row-activated", G_CALLBACK(viewRowActivated), NULL); - g_signal_connect(g_theme_view, "cursor-changed", G_CALLBACK(theme_selection_changed), NULL); + // define theme view + g_theme_view = create_view(); + gtk_container_add(GTK_CONTAINER(scrollbar), g_theme_view); + gtk_widget_show(g_theme_view); + g_signal_connect(g_theme_view, "button-press-event", (GCallback)view_onButtonPressed, NULL); + g_signal_connect(g_theme_view, "popup-menu", (GCallback)view_onPopupMenu, NULL); + g_signal_connect(g_theme_view, "row-activated", G_CALLBACK(viewRowActivated), NULL); + g_signal_connect(g_theme_view, "cursor-changed", G_CALLBACK(theme_selection_changed), NULL); - // load themes - load_all_themes(); - argc--, argv++; - if (argc > 0) { - load_specific_themes(argv, argc); - g_timeout_add(SNAPSHOT_TICK, edit_theme, NULL); - } + // load themes + load_all_themes(); + argc--, argv++; + if (argc > 0) { + load_specific_themes(argv, argc); + g_timeout_add(SNAPSHOT_TICK, edit_theme, NULL); + } - gtk_widget_show_all(g_window); - gtk_main(); + gtk_widget_show_all(g_window); + gtk_main(); - return 0; + return 0; } static void menuAbout() { - const char *authors[] = {"Thierry Lorthiois <lorthiois@bbsoft.fr>", - "Andreas Fink <andreas.fink85@googlemail.com>", - "Christian Ruppert <Spooky85@gmail.com> (Build system)", - "Euan Freeman <euan04@gmail.com> (tintwizard http://code.google.com/p/tintwizard)", - (NULL)}; + const char *authors[] = {"Thierry Lorthiois <lorthiois@bbsoft.fr>", + "Andreas Fink <andreas.fink85@googlemail.com>", + "Christian Ruppert <Spooky85@gmail.com> (Build system)", + "Euan Freeman <euan04@gmail.com> (tintwizard http://code.google.com/p/tintwizard)", + (NULL)}; - gtk_show_about_dialog(GTK_WINDOW(g_window), - "name", - g_get_application_name(), - "comments", - _("Theming tool for tint2 panel"), - "version", - VERSION_STRING, - "copyright", - _("Copyright 2009-2017 tint2 team\nTint2 License GNU GPL version 2\nTintwizard License GNU " - "GPL version 3"), - "logo-icon-name", - "tint2conf", - "authors", - authors, - /* Translators: translate "translator-credits" as your name to have it appear in the credits - in the "About" dialog */ - "translator-credits", - _("translator-credits"), - NULL); + gtk_show_about_dialog(GTK_WINDOW(g_window), + "name", + g_get_application_name(), + "comments", + _("Theming tool for tint2 panel"), + "version", + VERSION_STRING, + "copyright", + _("Copyright 2009-2017 tint2 team\nTint2 License GNU GPL version 2\nTintwizard License GNU " + "GPL version 3"), + "logo-icon-name", + "tint2conf", + "authors", + authors, + /* Translators: translate "translator-credits" as your name to have it appear in the credits + in the "About" dialog */ + "translator-credits", + _("translator-credits"), + NULL); } // ====== Theme import/copy/delete ======

@@ -352,606 +382,608 @@

// Shows open dialog and copies the selected files to ~ without overwrite. static void menuImportFile() { - GtkWidget *dialog = gtk_file_chooser_dialog_new(_("Import theme(s)"), - GTK_WINDOW(g_window), - GTK_FILE_CHOOSER_ACTION_OPEN, - GTK_STOCK_CANCEL, - GTK_RESPONSE_CANCEL, - GTK_STOCK_ADD, - GTK_RESPONSE_ACCEPT, - NULL); - GtkFileChooser *chooser = GTK_FILE_CHOOSER(dialog); - gtk_file_chooser_set_select_multiple(chooser, TRUE); + GtkWidget *dialog = gtk_file_chooser_dialog_new(_("Import theme(s)"), + GTK_WINDOW(g_window), + GTK_FILE_CHOOSER_ACTION_OPEN, + GTK_STOCK_CANCEL, + GTK_RESPONSE_CANCEL, + GTK_STOCK_ADD, + GTK_RESPONSE_ACCEPT, + NULL); + GtkFileChooser *chooser = GTK_FILE_CHOOSER(dialog); + gtk_file_chooser_set_select_multiple(chooser, TRUE); - if (gtk_dialog_run(GTK_DIALOG(dialog)) != GTK_RESPONSE_ACCEPT) { - gtk_widget_destroy(dialog); - return; - } + if (gtk_dialog_run(GTK_DIALOG(dialog)) != GTK_RESPONSE_ACCEPT) { + gtk_widget_destroy(dialog); + return; + } - GSList *list = gtk_file_chooser_get_filenames(chooser); - for (GSList *l = list; l; l = l->next) { - gchar *newpath = import_no_overwrite(l->data); - g_free(newpath); - } - g_slist_foreach(list, (GFunc)g_free, NULL); - g_slist_free(list); - gtk_widget_destroy(dialog); + GSList *list = gtk_file_chooser_get_filenames(chooser); + for (GSList *l = list; l; l = l->next) { + gchar *newpath = import_no_overwrite(l->data); + g_free(newpath); + } + g_slist_foreach(list, (GFunc)g_free, NULL); + g_slist_free(list); + gtk_widget_destroy(dialog); } // Returns the path to the currently selected theme, or NULL if no theme is selected. Needs gfree. gchar *get_current_theme_path() { - GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(g_theme_view)); - GtkTreeIter iter; - GtkTreeModel *model; - if (gtk_tree_selection_get_selected(GTK_TREE_SELECTION(sel), &model, &iter)) { - gchar *filepath; - gtk_tree_model_get(model, &iter, COL_THEME_FILE, &filepath, -1); - return filepath; - } - return NULL; + GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(g_theme_view)); + GtkTreeIter iter; + GtkTreeModel *model; + if (gtk_tree_selection_get_selected(GTK_TREE_SELECTION(sel), &model, &iter)) { + gchar *filepath; + gtk_tree_model_get(model, &iter, COL_THEME_FILE, &filepath, -1); + return filepath; + } + return NULL; } // Returns the path to the currently selected theme, or NULL if no theme is selected. Needs gfree. // Shows an error box if not theme is selected. gchar *get_selected_theme_or_warn() { - gchar *filepath = get_current_theme_path(); - if (!filepath) { - GtkWidget *w = gtk_message_dialog_new(GTK_WINDOW(g_window), - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_CLOSE, - _("Please select a theme.")); - g_signal_connect_swapped(w, "response", G_CALLBACK(gtk_widget_destroy), w); - gtk_widget_show(w); - } - return filepath; + gchar *filepath = get_current_theme_path(); + if (!filepath) { + GtkWidget *w = gtk_message_dialog_new(GTK_WINDOW(g_window), + GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_ERROR, + GTK_BUTTONS_CLOSE, + _("Please select a theme.")); + g_signal_connect_swapped(w, "response", G_CALLBACK(gtk_widget_destroy), w); + gtk_widget_show(w); + } + return filepath; } -// For the selected theme, shows save dialog (with overwrite confirmation) and copies to the selected file with overwrite. +// For the selected theme, shows save dialog (with overwrite confirmation) and copies to the selected file with +// overwrite. // Shows error box if no theme is selected. static void menuSaveAs() { - gchar *filepath = get_selected_theme_or_warn(); - if (!filepath) - return; + gchar *filepath = get_selected_theme_or_warn(); + if (!filepath) + return; - gchar *filename = file_name_from_path(filepath); - GtkWidget *dialog = gtk_file_chooser_dialog_new(_("Save theme as"), - GTK_WINDOW(g_window), - GTK_FILE_CHOOSER_ACTION_SAVE, - GTK_STOCK_CANCEL, - GTK_RESPONSE_CANCEL, - GTK_STOCK_SAVE, - GTK_RESPONSE_ACCEPT, - NULL); - GtkFileChooser *chooser = GTK_FILE_CHOOSER(dialog); - gtk_file_chooser_set_do_overwrite_confirmation(chooser, FALSE); - gchar *config_dir = g_build_filename(g_get_home_dir(), ".config", "tint2", NULL); - gtk_file_chooser_set_current_folder(chooser, config_dir); - g_free(config_dir); - GtkFileFilter *filter = gtk_file_filter_new(); - gtk_file_filter_add_pattern(filter, "*.tint2rc"); - gtk_file_filter_add_pattern(filter, "tint2rc"); - gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(dialog), filter); - gtk_file_chooser_set_current_name(chooser, filename); - if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) { - gchar *newpath = gtk_file_chooser_get_filename(chooser); - if (!endswith(newpath, ".tint2rc") && !endswith(newpath, "/tint2rc")) { - gchar *proper_path = g_strdup_printf("%s.tint2rc", newpath); - g_free(newpath); - newpath = proper_path; - } - if (g_file_test(newpath, G_FILE_TEST_EXISTS)) { - GtkWidget *w = gtk_message_dialog_new(GTK_WINDOW(g_window), - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_QUESTION, - GTK_BUTTONS_YES_NO, - _("A file named \"%s\" already exists. Do you want to replace it?"), - newpath); - gint response = gtk_dialog_run(GTK_DIALOG(w)); - gtk_widget_destroy(w); - if (response != GTK_RESPONSE_YES) { - g_free(newpath); - gtk_widget_destroy(dialog); - g_free(filepath); - return; - } - } - import_with_overwrite(filepath, newpath); - g_free(newpath); - } - gtk_widget_destroy(dialog); - g_free(filepath); + gchar *filename = file_name_from_path(filepath); + GtkWidget *dialog = gtk_file_chooser_dialog_new(_("Save theme as"), + GTK_WINDOW(g_window), + GTK_FILE_CHOOSER_ACTION_SAVE, + GTK_STOCK_CANCEL, + GTK_RESPONSE_CANCEL, + GTK_STOCK_SAVE, + GTK_RESPONSE_ACCEPT, + NULL); + GtkFileChooser *chooser = GTK_FILE_CHOOSER(dialog); + gtk_file_chooser_set_do_overwrite_confirmation(chooser, FALSE); + gchar *config_dir = g_build_filename(g_get_home_dir(), ".config", "tint2", NULL); + gtk_file_chooser_set_current_folder(chooser, config_dir); + g_free(config_dir); + GtkFileFilter *filter = gtk_file_filter_new(); + gtk_file_filter_add_pattern(filter, "*.tint2rc"); + gtk_file_filter_add_pattern(filter, "tint2rc"); + gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(dialog), filter); + gtk_file_chooser_set_current_name(chooser, filename); + if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) { + gchar *newpath = gtk_file_chooser_get_filename(chooser); + if (!endswith(newpath, ".tint2rc") && !endswith(newpath, "/tint2rc")) { + gchar *proper_path = g_strdup_printf("%s.tint2rc", newpath); + g_free(newpath); + newpath = proper_path; + } + if (g_file_test(newpath, G_FILE_TEST_EXISTS)) { + GtkWidget *w = gtk_message_dialog_new(GTK_WINDOW(g_window), + GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_QUESTION, + GTK_BUTTONS_YES_NO, + _("A file named \"%s\" already exists. Do you want to replace it?"), + newpath); + gint response = gtk_dialog_run(GTK_DIALOG(w)); + gtk_widget_destroy(w); + if (response != GTK_RESPONSE_YES) { + g_free(newpath); + gtk_widget_destroy(dialog); + g_free(filepath); + return; + } + } + import_with_overwrite(filepath, newpath); + g_free(newpath); + } + gtk_widget_destroy(dialog); + g_free(filepath); } // Deletes the selected theme with confirmation. static void menuDelete() { - gchar *filepath = get_selected_theme_or_warn(); - if (!filepath) - return; + gchar *filepath = get_selected_theme_or_warn(); + if (!filepath) + return; - GtkWidget *w = gtk_message_dialog_new(GTK_WINDOW(g_window), - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_QUESTION, - GTK_BUTTONS_YES_NO, - _("Do you really want to delete the selected theme?")); - gint response = gtk_dialog_run(GTK_DIALOG(w)); - gtk_widget_destroy(w); - if (response != GTK_RESPONSE_YES) { - g_free(filepath); - return; - } + GtkWidget *w = gtk_message_dialog_new(GTK_WINDOW(g_window), + GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_QUESTION, + GTK_BUTTONS_YES_NO, + _("Do you really want to delete the selected theme?")); + gint response = gtk_dialog_run(GTK_DIALOG(w)); + gtk_widget_destroy(w); + if (response != GTK_RESPONSE_YES) { + g_free(filepath); + return; + } - GFile *file = g_file_new_for_path(filepath); - if (g_file_trash(file, NULL, NULL)) { - remove_theme(filepath); - } - g_object_unref(G_OBJECT(file)); - g_free(filepath); + GFile *file = g_file_new_for_path(filepath); + if (g_file_trash(file, NULL, NULL)) { + remove_theme(filepath); + } + g_object_unref(G_OBJECT(file)); + g_free(filepath); } static void menuReset() { - gchar *filepath = get_selected_theme_or_warn(); - if (!filepath) - return; - gchar *filename = file_name_from_path(filepath); - if (!filename) { - g_free(filepath); - return; - } + gchar *filepath = get_selected_theme_or_warn(); + if (!filepath) + return; + gchar *filename = file_name_from_path(filepath); + if (!filename) { + g_free(filepath); + return; + } - gchar *syspath = find_theme_in_system_dirs(filename); - if (!syspath) - syspath = find_theme_in_system_dirs("tint2rc"); - if (!syspath) { - g_free(filepath); - return; - } + gchar *syspath = find_theme_in_system_dirs(filename); + if (!syspath) + syspath = find_theme_in_system_dirs("tint2rc"); + if (!syspath) { + g_free(filepath); + return; + } - GtkWidget *w = gtk_message_dialog_new(GTK_WINDOW(g_window), - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_QUESTION, - GTK_BUTTONS_YES_NO, - _("Do you really want to reset the selected theme to default?")); - gint response = gtk_dialog_run(GTK_DIALOG(w)); - gtk_widget_destroy(w); - if (response != GTK_RESPONSE_YES) { - g_free(filepath); - g_free(syspath); - return; - } + GtkWidget *w = gtk_message_dialog_new(GTK_WINDOW(g_window), + GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_QUESTION, + GTK_BUTTONS_YES_NO, + _("Do you really want to reset the selected theme to default?")); + gint response = gtk_dialog_run(GTK_DIALOG(w)); + gtk_widget_destroy(w); + if (response != GTK_RESPONSE_YES) { + g_free(filepath); + g_free(syspath); + return; + } - import_with_overwrite(syspath, filepath); - g_free(filepath); - g_free(syspath); + import_with_overwrite(syspath, filepath); + g_free(filepath); + g_free(syspath); } // ====== Theme popup menu ====== static void show_popup_menu(GtkWidget *treeview, GdkEventButton *event, gpointer userdata) { - gtk_menu_popup(GTK_MENU(gtk_ui_manager_get_widget(globalUIManager, "/ThemePopup")), - NULL, - NULL, - NULL, - NULL, - (event != NULL) ? event->button : 0, - gdk_event_get_time((GdkEvent *)event)); + gtk_menu_popup(GTK_MENU(gtk_ui_manager_get_widget(globalUIManager, "/ThemePopup")), + NULL, + NULL, + NULL, + NULL, + (event != NULL) ? event->button : 0, + gdk_event_get_time((GdkEvent *)event)); } static gboolean view_onButtonPressed(GtkWidget *treeview, GdkEventButton *event, gpointer userdata) { - // single click with the right mouse button? - if (event->type == GDK_BUTTON_PRESS && event->button == 3) { - GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview)); - if (gtk_tree_selection_count_selected_rows(selection) <= 1) { - // Get tree path for row that was clicked - GtkTreePath *path; - if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(treeview), - (gint)event->x, - (gint)event->y, - &path, - NULL, - NULL, - NULL)) { - gtk_tree_selection_unselect_all(selection); - gtk_tree_selection_select_path(selection, path); - gtk_tree_path_free(path); - } - } - show_popup_menu(treeview, event, userdata); - return TRUE; - } - return FALSE; + // single click with the right mouse button? + if (event->type == GDK_BUTTON_PRESS && event->button == 3) { + GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview)); + if (gtk_tree_selection_count_selected_rows(selection) <= 1) { + // Get tree path for row that was clicked + GtkTreePath *path; + if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(treeview), + (gint)event->x, + (gint)event->y, + &path, + NULL, + NULL, + NULL)) { + gtk_tree_selection_unselect_all(selection); + gtk_tree_selection_select_path(selection, path); + gtk_tree_path_free(path); + } + } + show_popup_menu(treeview, event, userdata); + return TRUE; + } + return FALSE; } static gboolean view_onPopupMenu(GtkWidget *treeview, gpointer userdata) { - show_popup_menu(treeview, NULL, userdata); - return TRUE; + show_popup_menu(treeview, NULL, userdata); + return TRUE; } static void theme_selection_changed(GtkWidget *treeview, gpointer userdata) { - GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(g_theme_view)); - GtkTreeIter iter; - GtkTreeModel *model; - if (gtk_tree_selection_get_selected(GTK_TREE_SELECTION(sel), &model, &iter)) { - gchar *filepath; - gtk_tree_model_get(model, &iter, COL_THEME_FILE, &filepath, -1); - gboolean isdefault = theme_is_default(filepath); - gchar *text = isdefault ? g_strdup_printf("tint2") : g_strdup_printf("tint2 -c %s", filepath); - gtk_entry_set_text(GTK_ENTRY(tint_cmd), text); - g_free(text); - gboolean editable = theme_is_editable(filepath); - g_free(filepath); - gtk_action_set_sensitive(gtk_action_group_get_action(actionGroup, "ThemeSaveAs"), TRUE); - gtk_action_set_sensitive(gtk_action_group_get_action(actionGroup, "ThemeDelete"), editable); - gtk_action_set_sensitive(gtk_action_group_get_action(actionGroup, "ThemeReset"), editable); - gtk_action_set_sensitive(gtk_action_group_get_action(actionGroup, "ThemeMakeDefault"), !isdefault); - gtk_action_set_sensitive(gtk_action_group_get_action(actionGroup, "ThemeEdit"), TRUE); - gtk_action_set_sensitive(gtk_action_group_get_action(actionGroup, "ThemeRefresh"), TRUE); - } else { - gtk_entry_set_text(GTK_ENTRY(tint_cmd), ""); - gtk_action_set_sensitive(gtk_action_group_get_action(actionGroup, "ThemeSaveAs"), FALSE); - gtk_action_set_sensitive(gtk_action_group_get_action(actionGroup, "ThemeDelete"), FALSE); - gtk_action_set_sensitive(gtk_action_group_get_action(actionGroup, "ThemeReset"), FALSE); - gtk_action_set_sensitive(gtk_action_group_get_action(actionGroup, "ThemeMakeDefault"), FALSE); - gtk_action_set_sensitive(gtk_action_group_get_action(actionGroup, "ThemeEdit"), FALSE); - gtk_action_set_sensitive(gtk_action_group_get_action(actionGroup, "ThemeRefresh"), FALSE); - } + GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(g_theme_view)); + GtkTreeIter iter; + GtkTreeModel *model; + if (gtk_tree_selection_get_selected(GTK_TREE_SELECTION(sel), &model, &iter)) { + gchar *filepath; + gtk_tree_model_get(model, &iter, COL_THEME_FILE, &filepath, -1); + gboolean isdefault = theme_is_default(filepath); + gchar *text = isdefault ? g_strdup_printf("tint2") : g_strdup_printf("tint2 -c %s", filepath); + gtk_entry_set_text(GTK_ENTRY(tint_cmd), text); + g_free(text); + gboolean editable = theme_is_editable(filepath); + g_free(filepath); + gtk_action_set_sensitive(gtk_action_group_get_action(actionGroup, "ThemeSaveAs"), TRUE); + gtk_action_set_sensitive(gtk_action_group_get_action(actionGroup, "ThemeDelete"), editable); + gtk_action_set_sensitive(gtk_action_group_get_action(actionGroup, "ThemeReset"), editable); + gtk_action_set_sensitive(gtk_action_group_get_action(actionGroup, "ThemeMakeDefault"), !isdefault); + gtk_action_set_sensitive(gtk_action_group_get_action(actionGroup, "ThemeEdit"), TRUE); + gtk_action_set_sensitive(gtk_action_group_get_action(actionGroup, "ThemeRefresh"), TRUE); + } else { + gtk_entry_set_text(GTK_ENTRY(tint_cmd), ""); + gtk_action_set_sensitive(gtk_action_group_get_action(actionGroup, "ThemeSaveAs"), FALSE); + gtk_action_set_sensitive(gtk_action_group_get_action(actionGroup, "ThemeDelete"), FALSE); + gtk_action_set_sensitive(gtk_action_group_get_action(actionGroup, "ThemeReset"), FALSE); + gtk_action_set_sensitive(gtk_action_group_get_action(actionGroup, "ThemeMakeDefault"), FALSE); + gtk_action_set_sensitive(gtk_action_group_get_action(actionGroup, "ThemeEdit"), FALSE); + gtk_action_set_sensitive(gtk_action_group_get_action(actionGroup, "ThemeRefresh"), FALSE); + } } void select_first_theme() { - GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(g_theme_view)); - GtkTreeIter iter; - if (gtk_tree_model_get_iter_first(model, &iter)) { - GtkTreePath *path = gtk_tree_model_get_path(model, &iter); - gtk_tree_selection_select_iter(gtk_tree_view_get_selection(GTK_TREE_VIEW(g_theme_view)), &iter); - gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(g_theme_view), path, NULL, FALSE, 0, 0); - gtk_tree_path_free(path); - } - theme_selection_changed(NULL, NULL); + GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(g_theme_view)); + GtkTreeIter iter; + if (gtk_tree_model_get_iter_first(model, &iter)) { + GtkTreePath *path = gtk_tree_model_get_path(model, &iter); + gtk_tree_selection_select_iter(gtk_tree_view_get_selection(GTK_TREE_VIEW(g_theme_view)), &iter); + gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(g_theme_view), path, NULL, FALSE, 0, 0); + gtk_tree_path_free(path); + } + theme_selection_changed(NULL, NULL); } void select_theme(const char *given_path) { - GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(g_theme_view)); - GtkTreeIter iter; + GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(g_theme_view)); + GtkTreeIter iter; - gboolean have_iter = gtk_tree_model_get_iter_first(model, &iter); - while (have_iter) { - gchar *filepath; - gtk_tree_model_get(model, &iter, COL_THEME_FILE, &filepath, -1); - if (g_str_equal(filepath, given_path)) { - GtkTreePath *path = gtk_tree_model_get_path(model, &iter); - gtk_tree_selection_select_iter(gtk_tree_view_get_selection(GTK_TREE_VIEW(g_theme_view)), &iter); - gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(g_theme_view), path, NULL, FALSE, 0, 0); - gtk_tree_path_free(path); - g_free(filepath); - break; - } - g_free(filepath); - have_iter = gtk_tree_model_iter_next(model, &iter); - } - theme_selection_changed(NULL, NULL); + gboolean have_iter = gtk_tree_model_get_iter_first(model, &iter); + while (have_iter) { + gchar *filepath; + gtk_tree_model_get(model, &iter, COL_THEME_FILE, &filepath, -1); + if (g_str_equal(filepath, given_path)) { + GtkTreePath *path = gtk_tree_model_get_path(model, &iter); + gtk_tree_selection_select_iter(gtk_tree_view_get_selection(GTK_TREE_VIEW(g_theme_view)), &iter); + gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(g_theme_view), path, NULL, FALSE, 0, 0); + gtk_tree_path_free(path); + g_free(filepath); + break; + } + g_free(filepath); + have_iter = gtk_tree_model_iter_next(model, &iter); + } + theme_selection_changed(NULL, NULL); } // Edits the selected theme. If it is read-only, it copies first to ~. static gboolean edit_theme(gpointer ignored) { - gchar *filepath = get_selected_theme_or_warn(); - if (!filepath) - return FALSE; + gchar *filepath = get_selected_theme_or_warn(); + if (!filepath) + return FALSE; - gboolean editable = theme_is_editable(filepath); - if (!editable) { - gchar *newpath = import_no_overwrite(filepath); - g_free(filepath); - filepath = newpath; - select_theme(filepath); - } - create_please_wait(GTK_WINDOW(g_window)); - process_events(); - GtkWidget *prop = create_properties(); - config_read_file(filepath); - save_icon_cache(icon_theme); - gtk_window_present(GTK_WINDOW(prop)); - g_free(filepath); + gboolean editable = theme_is_editable(filepath); + if (!editable) { + gchar *newpath = import_no_overwrite(filepath); + g_free(filepath); + filepath = newpath; + select_theme(filepath); + } + create_please_wait(GTK_WINDOW(g_window)); + process_events(); + GtkWidget *prop = create_properties(); + config_read_file(filepath); + save_icon_cache(icon_theme); + gtk_window_present(GTK_WINDOW(prop)); + g_free(filepath); - destroy_please_wait(); + destroy_please_wait(); - return FALSE; + return FALSE; } static void make_selected_theme_default() { - gchar *filepath = get_selected_theme_or_warn(); - if (!filepath) - return; + gchar *filepath = get_selected_theme_or_warn(); + if (!filepath) + return; - gchar *default_path = get_home_config_path(); - if (g_str_equal(filepath, default_path)) { - g_free(filepath); - g_free(default_path); - return; - } + gchar *default_path = get_home_config_path(); + if (g_str_equal(filepath, default_path)) { + g_free(filepath); + g_free(default_path); + return; + } - GtkWidget *w = gtk_message_dialog_new(GTK_WINDOW(g_window), - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_QUESTION, - GTK_BUTTONS_YES_NO, - _("Do you really want to replace the default theme with the selected theme?")); - gint response = gtk_dialog_run(GTK_DIALOG(w)); - gtk_widget_destroy(w); - if (response != GTK_RESPONSE_YES) { - g_free(filepath); - g_free(default_path); - return; - } + GtkWidget *w = + gtk_message_dialog_new(GTK_WINDOW(g_window), + GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_QUESTION, + GTK_BUTTONS_YES_NO, + _("Do you really want to replace the default theme with the selected theme?")); + gint response = gtk_dialog_run(GTK_DIALOG(w)); + gtk_widget_destroy(w); + if (response != GTK_RESPONSE_YES) { + g_free(filepath); + g_free(default_path); + return; + } - import_with_overwrite(filepath, default_path); - select_first_theme(); + import_with_overwrite(filepath, default_path); + select_first_theme(); - g_free(filepath); - g_free(default_path); + g_free(filepath); + g_free(default_path); } static void viewRowActivated(GtkTreeView *tree_view, GtkTreePath *path, GtkTreeViewColumn *column, gpointer user_data) { - edit_theme(NULL); + edit_theme(NULL); } // ====== Theme load/reload ====== static void ensure_default_theme_exists() { - // Without a user tint2rc file, copy the default - gchar *path_home = g_build_filename(g_get_user_config_dir(), "tint2", "tint2rc", NULL); - if (!g_file_test(path_home, G_FILE_TEST_EXISTS)) { - const gchar *const *system_dirs = g_get_system_config_dirs(); - for (int i = 0; system_dirs[i]; i++) { - gchar *path = g_build_filename(system_dirs[i], "tint2", "tint2rc", NULL); - if (g_file_test(path, G_FILE_TEST_EXISTS)) { - copy_file(path, path_home); - break; - } - g_free(path); - } - } - g_free(path_home); + // Without a user tint2rc file, copy the default + gchar *path_home = g_build_filename(g_get_user_config_dir(), "tint2", "tint2rc", NULL); + if (!g_file_test(path_home, G_FILE_TEST_EXISTS)) { + const gchar *const *system_dirs = g_get_system_config_dirs(); + for (int i = 0; system_dirs[i]; i++) { + gchar *path = g_build_filename(system_dirs[i], "tint2", "tint2rc", NULL); + if (g_file_test(path, G_FILE_TEST_EXISTS)) { + copy_file(path, path_home); + break; + } + g_free(path); + } + } + g_free(path_home); } static gboolean load_user_themes() { - // Load configs from home directory - gchar *tint2_config_dir = g_build_filename(g_get_user_config_dir(), "tint2", NULL); - GDir *dir = g_dir_open(tint2_config_dir, 0, NULL); - if (dir == NULL) { - g_free(tint2_config_dir); - return FALSE; - } - gboolean found_theme = FALSE; + // Load configs from home directory + gchar *tint2_config_dir = g_build_filename(g_get_user_config_dir(), "tint2", NULL); + GDir *dir = g_dir_open(tint2_config_dir, 0, NULL); + if (dir == NULL) { + g_free(tint2_config_dir); + return FALSE; + } + gboolean found_theme = FALSE; - const gchar *file_name; - while ((file_name = g_dir_read_name(dir))) { - if (!g_file_test(file_name, G_FILE_TEST_IS_DIR) && !strstr(file_name, "backup") && !strstr(file_name, "copy") && - !strstr(file_name, "~") && (endswith(file_name, "tint2rc") || endswith(file_name, ".conf"))) { - found_theme = TRUE; - gchar *path = g_build_filename(tint2_config_dir, file_name, NULL); - theme_list_append(path); - g_free(path); - } - } - g_dir_close(dir); - g_free(tint2_config_dir); + const gchar *file_name; + while ((file_name = g_dir_read_name(dir))) { + if (!g_file_test(file_name, G_FILE_TEST_IS_DIR) && !strstr(file_name, "backup") && !strstr(file_name, "copy") && + !strstr(file_name, "~") && (endswith(file_name, "tint2rc") || endswith(file_name, ".conf"))) { + found_theme = TRUE; + gchar *path = g_build_filename(tint2_config_dir, file_name, NULL); + theme_list_append(path); + g_free(path); + } + } + g_dir_close(dir); + g_free(tint2_config_dir); - return found_theme; + return found_theme; } static gboolean load_themes_from_dirs(const gchar *const *dirs) { - gboolean found_theme = FALSE; - for (int i = 0; dirs[i]; i++) { - gchar *path_tint2 = g_build_filename(dirs[i], "tint2", NULL); - GDir *dir = g_dir_open(path_tint2, 0, NULL); - if (dir) { - const gchar *file_name; - while ((file_name = g_dir_read_name(dir))) { - if (!g_file_test(file_name, G_FILE_TEST_IS_DIR) && !strstr(file_name, "backup") && - !strstr(file_name, "copy") && !strstr(file_name, "~") && - (endswith(file_name, "tint2rc") || endswith(file_name, ".conf"))) { - found_theme = TRUE; - gchar *path = g_build_filename(path_tint2, file_name, NULL); - theme_list_append(path); - g_free(path); - } - } - g_dir_close(dir); - } - g_free(path_tint2); - } - return found_theme; + gboolean found_theme = FALSE; + for (int i = 0; dirs[i]; i++) { + gchar *path_tint2 = g_build_filename(dirs[i], "tint2", NULL); + GDir *dir = g_dir_open(path_tint2, 0, NULL); + if (dir) { + const gchar *file_name; + while ((file_name = g_dir_read_name(dir))) { + if (!g_file_test(file_name, G_FILE_TEST_IS_DIR) && !strstr(file_name, "backup") && + !strstr(file_name, "copy") && !strstr(file_name, "~") && + (endswith(file_name, "tint2rc") || endswith(file_name, ".conf"))) { + found_theme = TRUE; + gchar *path = g_build_filename(path_tint2, file_name, NULL); + theme_list_append(path); + g_free(path); + } + } + g_dir_close(dir); + } + g_free(path_tint2); + } + return found_theme; } static gboolean load_system_themes() { - gboolean found_theme = FALSE; - if (load_themes_from_dirs(g_get_system_config_dirs())) - found_theme = TRUE; - if (load_themes_from_dirs(g_get_system_data_dirs())) - found_theme = TRUE; - return found_theme; + gboolean found_theme = FALSE; + if (load_themes_from_dirs(g_get_system_config_dirs())) + found_theme = TRUE; + if (load_themes_from_dirs(g_get_system_data_dirs())) + found_theme = TRUE; + return found_theme; } static gchar *find_theme_in_dirs(const gchar *const *dirs, const gchar *given_name) { - for (int i = 0; dirs[i]; i++) { - gchar *filepath = g_build_filename(dirs[i], "tint2", given_name, NULL); - if (g_file_test(filepath, G_FILE_TEST_EXISTS)) { - return filepath; - } - g_free(filepath); - } - return NULL; + for (int i = 0; dirs[i]; i++) { + gchar *filepath = g_build_filename(dirs[i], "tint2", given_name, NULL); + if (g_file_test(filepath, G_FILE_TEST_EXISTS)) { + return filepath; + } + g_free(filepath); + } + return NULL; } static gchar *find_theme_in_system_dirs(const gchar *given_name) { - gchar *result = find_theme_in_dirs(g_get_system_config_dirs(), given_name); - if (result) - return result; - return find_theme_in_dirs(g_get_system_data_dirs(), given_name); + gchar *result = find_theme_in_dirs(g_get_system_config_dirs(), given_name); + if (result) + return result; + return find_theme_in_dirs(g_get_system_data_dirs(), given_name); } static void load_all_themes() { - ensure_default_theme_exists(); + ensure_default_theme_exists(); - gtk_list_store_clear(GTK_LIST_STORE(theme_list_store)); - theme_selection_changed(NULL, NULL); + gtk_list_store_clear(GTK_LIST_STORE(theme_list_store)); + theme_selection_changed(NULL, NULL); - gboolean found_themes = FALSE; - if (load_user_themes()) - found_themes = TRUE; - if (load_system_themes()) - found_themes = TRUE; + gboolean found_themes = FALSE; + if (load_user_themes()) + found_themes = TRUE; + if (load_system_themes()) + found_themes = TRUE; - if (found_themes) { - select_first_theme(); + if (found_themes) { + select_first_theme(); - GtkTreeIter iter; - GtkTreeModel *model; - gboolean have_iter; + GtkTreeIter iter; + GtkTreeModel *model; + gboolean have_iter; - model = gtk_tree_view_get_model(GTK_TREE_VIEW(g_theme_view)); - have_iter = gtk_tree_model_get_iter_first(model, &iter); - while (have_iter) { - gtk_list_store_set(theme_list_store, &iter, COL_SNAPSHOT, NULL, -1); - have_iter = gtk_tree_model_iter_next(model, &iter); - } + model = gtk_tree_view_get_model(GTK_TREE_VIEW(g_theme_view)); + have_iter = gtk_tree_model_get_iter_first(model, &iter); + while (have_iter) { + gtk_list_store_set(theme_list_store, &iter, COL_SNAPSHOT, NULL, -1); + have_iter = gtk_tree_model_iter_next(model, &iter); + } - g_timeout_add(SNAPSHOT_TICK, update_snapshot, NULL); - } + g_timeout_add(SNAPSHOT_TICK, update_snapshot, NULL); + } } static void reload_all_themes() { - ensure_default_theme_exists(); + ensure_default_theme_exists(); - gtk_list_store_clear(GTK_LIST_STORE(theme_list_store)); - theme_selection_changed(NULL, NULL); + gtk_list_store_clear(GTK_LIST_STORE(theme_list_store)); + theme_selection_changed(NULL, NULL); - gboolean found_themes = FALSE; - if (load_user_themes()) - found_themes = TRUE; - if (load_system_themes()) - found_themes = TRUE; + gboolean found_themes = FALSE; + if (load_user_themes()) + found_themes = TRUE; + if (load_system_themes()) + found_themes = TRUE; - if (found_themes) { - select_first_theme(); + if (found_themes) { + select_first_theme(); - GtkTreeIter iter; - GtkTreeModel *model; - gboolean have_iter; + GtkTreeIter iter; + GtkTreeModel *model; + gboolean have_iter; - model = gtk_tree_view_get_model(GTK_TREE_VIEW(g_theme_view)); - have_iter = gtk_tree_model_get_iter_first(model, &iter); - while (have_iter) { - gtk_list_store_set(theme_list_store, &iter, COL_SNAPSHOT, NULL, COL_FORCE_REFRESH, TRUE, -1); - have_iter = gtk_tree_model_iter_next(model, &iter); - } + model = gtk_tree_view_get_model(GTK_TREE_VIEW(g_theme_view)); + have_iter = gtk_tree_model_get_iter_first(model, &iter); + while (have_iter) { + gtk_list_store_set(theme_list_store, &iter, COL_SNAPSHOT, NULL, COL_FORCE_REFRESH, TRUE, -1); + have_iter = gtk_tree_model_iter_next(model, &iter); + } - g_timeout_add(SNAPSHOT_TICK, update_snapshot, NULL); - } + g_timeout_add(SNAPSHOT_TICK, update_snapshot, NULL); + } } static void load_specific_themes(char **paths, int count) { - ensure_default_theme_exists(); + ensure_default_theme_exists(); - gboolean found_themes = FALSE; - while (count > 0) { - // Load configs - const char *file_name = paths[0]; - paths++, count--; - if (g_file_test(file_name, G_FILE_TEST_IS_REGULAR) || g_file_test(file_name, G_FILE_TEST_IS_SYMLINK) ) { - theme_list_append(file_name); - if (!found_themes) { - select_theme(file_name); - found_themes = TRUE; - } - } - } + gboolean found_themes = FALSE; + while (count > 0) { + // Load configs + const char *file_name = paths[0]; + paths++, count--; + if (g_file_test(file_name, G_FILE_TEST_IS_REGULAR) || g_file_test(file_name, G_FILE_TEST_IS_SYMLINK)) { + theme_list_append(file_name); + if (!found_themes) { + select_theme(file_name); + found_themes = TRUE; + } + } + } - if (found_themes) { - GtkTreeIter iter; - GtkTreeModel *model; - gboolean have_iter; + if (found_themes) { + GtkTreeIter iter; + GtkTreeModel *model; + gboolean have_iter; - model = gtk_tree_view_get_model(GTK_TREE_VIEW(g_theme_view)); - have_iter = gtk_tree_model_get_iter_first(model, &iter); - while (have_iter) { - gtk_list_store_set(theme_list_store, &iter, COL_SNAPSHOT, NULL, -1); - have_iter = gtk_tree_model_iter_next(model, &iter); - } + model = gtk_tree_view_get_model(GTK_TREE_VIEW(g_theme_view)); + have_iter = gtk_tree_model_get_iter_first(model, &iter); + while (have_iter) { + gtk_list_store_set(theme_list_store, &iter, COL_SNAPSHOT, NULL, -1); + have_iter = gtk_tree_model_iter_next(model, &iter); + } - g_timeout_add(SNAPSHOT_TICK, update_snapshot, NULL); - } + g_timeout_add(SNAPSHOT_TICK, update_snapshot, NULL); + } } void refresh_current_theme() { - GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(g_theme_view)); - GtkTreeIter iter; - GtkTreeModel *model; - if (gtk_tree_selection_get_selected(GTK_TREE_SELECTION(sel), &model, &iter)) { - gtk_list_store_set(theme_list_store, &iter, COL_SNAPSHOT, NULL, -1); - g_timeout_add(SNAPSHOT_TICK, update_snapshot, NULL); - } + GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(g_theme_view)); + GtkTreeIter iter; + GtkTreeModel *model; + if (gtk_tree_selection_get_selected(GTK_TREE_SELECTION(sel), &model, &iter)) { + gtk_list_store_set(theme_list_store, &iter, COL_SNAPSHOT, NULL, -1); + g_timeout_add(SNAPSHOT_TICK, update_snapshot, NULL); + } } void refresh_theme(const char *given_path) { - GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(g_theme_view)); - GtkTreeIter iter; + GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(g_theme_view)); + GtkTreeIter iter; - gboolean have_iter = gtk_tree_model_get_iter_first(model, &iter); - while (have_iter) { - gchar *filepath; - gtk_tree_model_get(model, &iter, COL_THEME_FILE, &filepath, -1); - if (g_str_equal(filepath, given_path)) { - gtk_list_store_set(theme_list_store, &iter, COL_SNAPSHOT, NULL, -1); - g_timeout_add(SNAPSHOT_TICK, update_snapshot, NULL); - g_free(filepath); - break; - } - g_free(filepath); - have_iter = gtk_tree_model_iter_next(model, &iter); - } + gboolean have_iter = gtk_tree_model_get_iter_first(model, &iter); + while (have_iter) { + gchar *filepath; + gtk_tree_model_get(model, &iter, COL_THEME_FILE, &filepath, -1); + if (g_str_equal(filepath, given_path)) { + gtk_list_store_set(theme_list_store, &iter, COL_SNAPSHOT, NULL, -1); + g_timeout_add(SNAPSHOT_TICK, update_snapshot, NULL); + g_free(filepath); + break; + } + g_free(filepath); + have_iter = gtk_tree_model_iter_next(model, &iter); + } } void remove_theme(const char *given_path) { - GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(g_theme_view)); - GtkTreeIter iter; + GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(g_theme_view)); + GtkTreeIter iter; - gboolean have_iter = gtk_tree_model_get_iter_first(model, &iter); - while (have_iter) { - gchar *filepath; - gtk_tree_model_get(model, &iter, COL_THEME_FILE, &filepath, -1); - if (g_str_equal(filepath, given_path)) { - gtk_list_store_remove(GTK_LIST_STORE(model), &iter); - theme_selection_changed(NULL, NULL); - g_free(filepath); - break; - } - g_free(filepath); - have_iter = gtk_tree_model_iter_next(model, &iter); - } + gboolean have_iter = gtk_tree_model_get_iter_first(model, &iter); + while (have_iter) { + gchar *filepath; + gtk_tree_model_get(model, &iter, COL_THEME_FILE, &filepath, -1); + if (g_str_equal(filepath, given_path)) { + gtk_list_store_remove(GTK_LIST_STORE(model), &iter); + theme_selection_changed(NULL, NULL); + g_free(filepath); + break; + } + g_free(filepath); + have_iter = gtk_tree_model_iter_next(model, &iter); + } }
M src/tint2conf/md4.csrc/tint2conf/md4.c

@@ -40,235 +40,232 @@

#define shash_desc md4_ctx #define shash_desc_ctx(x) (x) -#define MD4_DIGEST_SIZE 16 -#define MD4_HMAC_BLOCK_SIZE 64 -#define MD4_BLOCK_WORDS 16 -#define MD4_HASH_WORDS 4 +#define MD4_DIGEST_SIZE 16 +#define MD4_HMAC_BLOCK_SIZE 64 +#define MD4_BLOCK_WORDS 16 +#define MD4_HASH_WORDS 4 struct md4_ctx { - u32 hash[MD4_HASH_WORDS]; - u32 block[MD4_BLOCK_WORDS]; - u64 byte_count; + u32 hash[MD4_HASH_WORDS]; + u32 block[MD4_BLOCK_WORDS]; + u64 byte_count; }; static inline u32 lshift(u32 x, unsigned int s) { - x &= 0xFFFFFFFF; - return ((x << s) & 0xFFFFFFFF) | (x >> (32 - s)); + x &= 0xFFFFFFFF; + return ((x << s) & 0xFFFFFFFF) | (x >> (32 - s)); } static inline u32 F(u32 x, u32 y, u32 z) { - return (x & y) | ((~x) & z); + return (x & y) | ((~x) & z); } static inline u32 G(u32 x, u32 y, u32 z) { - return (x & y) | (x & z) | (y & z); + return (x & y) | (x & z) | (y & z); } static inline u32 H(u32 x, u32 y, u32 z) { - return x ^ y ^ z; + return x ^ y ^ z; } -#define ROUND1(a,b,c,d,k,s) (a = lshift(a + F(b,c,d) + k, s)) -#define ROUND2(a,b,c,d,k,s) (a = lshift(a + G(b,c,d) + k + (u32)0x5A827999,s)) -#define ROUND3(a,b,c,d,k,s) (a = lshift(a + H(b,c,d) + k + (u32)0x6ED9EBA1,s)) +#define ROUND1(a, b, c, d, k, s) (a = lshift(a + F(b, c, d) + k, s)) +#define ROUND2(a, b, c, d, k, s) (a = lshift(a + G(b, c, d) + k + (u32)0x5A827999, s)) +#define ROUND3(a, b, c, d, k, s) (a = lshift(a + H(b, c, d) + k + (u32)0x6ED9EBA1, s)) /* XXX: this stuff can be optimized */ static inline void le32_to_cpu_array(u32 *buf, unsigned int words) { - while (words--) { - *buf = ntohl(*buf); - buf++; - } + while (words--) { + *buf = ntohl(*buf); + buf++; + } } static inline void cpu_to_le32_array(u32 *buf, unsigned int words) { - while (words--) { - *buf = htonl(*buf); - buf++; - } + while (words--) { + *buf = htonl(*buf); + buf++; + } } static void md4_transform(u32 *hash, u32 const *in) { - u32 a, b, c, d; + u32 a, b, c, d; - a = hash[0]; - b = hash[1]; - c = hash[2]; - d = hash[3]; + a = hash[0]; + b = hash[1]; + c = hash[2]; + d = hash[3]; - ROUND1(a, b, c, d, in[0], 3); - ROUND1(d, a, b, c, in[1], 7); - ROUND1(c, d, a, b, in[2], 11); - ROUND1(b, c, d, a, in[3], 19); - ROUND1(a, b, c, d, in[4], 3); - ROUND1(d, a, b, c, in[5], 7); - ROUND1(c, d, a, b, in[6], 11); - ROUND1(b, c, d, a, in[7], 19); - ROUND1(a, b, c, d, in[8], 3); - ROUND1(d, a, b, c, in[9], 7); - ROUND1(c, d, a, b, in[10], 11); - ROUND1(b, c, d, a, in[11], 19); - ROUND1(a, b, c, d, in[12], 3); - ROUND1(d, a, b, c, in[13], 7); - ROUND1(c, d, a, b, in[14], 11); - ROUND1(b, c, d, a, in[15], 19); + ROUND1(a, b, c, d, in[0], 3); + ROUND1(d, a, b, c, in[1], 7); + ROUND1(c, d, a, b, in[2], 11); + ROUND1(b, c, d, a, in[3], 19); + ROUND1(a, b, c, d, in[4], 3); + ROUND1(d, a, b, c, in[5], 7); + ROUND1(c, d, a, b, in[6], 11); + ROUND1(b, c, d, a, in[7], 19); + ROUND1(a, b, c, d, in[8], 3); + ROUND1(d, a, b, c, in[9], 7); + ROUND1(c, d, a, b, in[10], 11); + ROUND1(b, c, d, a, in[11], 19); + ROUND1(a, b, c, d, in[12], 3); + ROUND1(d, a, b, c, in[13], 7); + ROUND1(c, d, a, b, in[14], 11); + ROUND1(b, c, d, a, in[15], 19); - ROUND2(a, b, c, d,in[ 0], 3); - ROUND2(d, a, b, c, in[4], 5); - ROUND2(c, d, a, b, in[8], 9); - ROUND2(b, c, d, a, in[12], 13); - ROUND2(a, b, c, d, in[1], 3); - ROUND2(d, a, b, c, in[5], 5); - ROUND2(c, d, a, b, in[9], 9); - ROUND2(b, c, d, a, in[13], 13); - ROUND2(a, b, c, d, in[2], 3); - ROUND2(d, a, b, c, in[6], 5); - ROUND2(c, d, a, b, in[10], 9); - ROUND2(b, c, d, a, in[14], 13); - ROUND2(a, b, c, d, in[3], 3); - ROUND2(d, a, b, c, in[7], 5); - ROUND2(c, d, a, b, in[11], 9); - ROUND2(b, c, d, a, in[15], 13); + ROUND2(a, b, c, d, in[0], 3); + ROUND2(d, a, b, c, in[4], 5); + ROUND2(c, d, a, b, in[8], 9); + ROUND2(b, c, d, a, in[12], 13); + ROUND2(a, b, c, d, in[1], 3); + ROUND2(d, a, b, c, in[5], 5); + ROUND2(c, d, a, b, in[9], 9); + ROUND2(b, c, d, a, in[13], 13); + ROUND2(a, b, c, d, in[2], 3); + ROUND2(d, a, b, c, in[6], 5); + ROUND2(c, d, a, b, in[10], 9); + ROUND2(b, c, d, a, in[14], 13); + ROUND2(a, b, c, d, in[3], 3); + ROUND2(d, a, b, c, in[7], 5); + ROUND2(c, d, a, b, in[11], 9); + ROUND2(b, c, d, a, in[15], 13); - ROUND3(a, b, c, d,in[ 0], 3); - ROUND3(d, a, b, c, in[8], 9); - ROUND3(c, d, a, b, in[4], 11); - ROUND3(b, c, d, a, in[12], 15); - ROUND3(a, b, c, d, in[2], 3); - ROUND3(d, a, b, c, in[10], 9); - ROUND3(c, d, a, b, in[6], 11); - ROUND3(b, c, d, a, in[14], 15); - ROUND3(a, b, c, d, in[1], 3); - ROUND3(d, a, b, c, in[9], 9); - ROUND3(c, d, a, b, in[5], 11); - ROUND3(b, c, d, a, in[13], 15); - ROUND3(a, b, c, d, in[3], 3); - ROUND3(d, a, b, c, in[11], 9); - ROUND3(c, d, a, b, in[7], 11); - ROUND3(b, c, d, a, in[15], 15); + ROUND3(a, b, c, d, in[0], 3); + ROUND3(d, a, b, c, in[8], 9); + ROUND3(c, d, a, b, in[4], 11); + ROUND3(b, c, d, a, in[12], 15); + ROUND3(a, b, c, d, in[2], 3); + ROUND3(d, a, b, c, in[10], 9); + ROUND3(c, d, a, b, in[6], 11); + ROUND3(b, c, d, a, in[14], 15); + ROUND3(a, b, c, d, in[1], 3); + ROUND3(d, a, b, c, in[9], 9); + ROUND3(c, d, a, b, in[5], 11); + ROUND3(b, c, d, a, in[13], 15); + ROUND3(a, b, c, d, in[3], 3); + ROUND3(d, a, b, c, in[11], 9); + ROUND3(c, d, a, b, in[7], 11); + ROUND3(b, c, d, a, in[15], 15); - hash[0] += a; - hash[1] += b; - hash[2] += c; - hash[3] += d; + hash[0] += a; + hash[1] += b; + hash[2] += c; + hash[3] += d; } static inline void md4_transform_helper(struct md4_ctx *ctx) { - le32_to_cpu_array(ctx->block, ARRAY_SIZE(ctx->block)); - md4_transform(ctx->hash, ctx->block); + le32_to_cpu_array(ctx->block, ARRAY_SIZE(ctx->block)); + md4_transform(ctx->hash, ctx->block); } static int md4_init(struct shash_desc *desc) { - struct md4_ctx *mctx = shash_desc_ctx(desc); + struct md4_ctx *mctx = shash_desc_ctx(desc); - mctx->hash[0] = 0x67452301; - mctx->hash[1] = 0xefcdab89; - mctx->hash[2] = 0x98badcfe; - mctx->hash[3] = 0x10325476; - mctx->byte_count = 0; + mctx->hash[0] = 0x67452301; + mctx->hash[1] = 0xefcdab89; + mctx->hash[2] = 0x98badcfe; + mctx->hash[3] = 0x10325476; + mctx->byte_count = 0; - return 0; + return 0; } static int md4_update(struct shash_desc *desc, const u8 *data, unsigned int len) { - struct md4_ctx *mctx = shash_desc_ctx(desc); - const u32 avail = sizeof(mctx->block) - (mctx->byte_count & 0x3f); + struct md4_ctx *mctx = shash_desc_ctx(desc); + const u32 avail = sizeof(mctx->block) - (mctx->byte_count & 0x3f); - mctx->byte_count += len; + mctx->byte_count += len; - if (avail > len) { - memcpy((char *)mctx->block + (sizeof(mctx->block) - avail), - data, len); - return 0; - } + if (avail > len) { + memcpy((char *)mctx->block + (sizeof(mctx->block) - avail), data, len); + return 0; + } - memcpy((char *)mctx->block + (sizeof(mctx->block) - avail), - data, avail); + memcpy((char *)mctx->block + (sizeof(mctx->block) - avail), data, avail); - md4_transform_helper(mctx); - data += avail; - len -= avail; + md4_transform_helper(mctx); + data += avail; + len -= avail; - while (len >= sizeof(mctx->block)) { - memcpy(mctx->block, data, sizeof(mctx->block)); - md4_transform_helper(mctx); - data += sizeof(mctx->block); - len -= sizeof(mctx->block); - } + while (len >= sizeof(mctx->block)) { + memcpy(mctx->block, data, sizeof(mctx->block)); + md4_transform_helper(mctx); + data += sizeof(mctx->block); + len -= sizeof(mctx->block); + } - memcpy(mctx->block, data, len); + memcpy(mctx->block, data, len); - return 0; + return 0; } static int md4_final(struct shash_desc *desc, u8 *out) { - struct md4_ctx *mctx = shash_desc_ctx(desc); - const unsigned int offset = mctx->byte_count & 0x3f; - char *p = (char *)mctx->block + offset; - int padding = 56 - (offset + 1); + struct md4_ctx *mctx = shash_desc_ctx(desc); + const unsigned int offset = mctx->byte_count & 0x3f; + char *p = (char *)mctx->block + offset; + int padding = 56 - (offset + 1); - *p++ = 0x80; - if (padding < 0) { - memset(p, 0x00, padding + sizeof (u64)); - md4_transform_helper(mctx); - p = (char *)mctx->block; - padding = 56; - } + *p++ = 0x80; + if (padding < 0) { + memset(p, 0x00, padding + sizeof(u64)); + md4_transform_helper(mctx); + p = (char *)mctx->block; + padding = 56; + } - memset(p, 0, padding); - mctx->block[14] = mctx->byte_count << 3; - mctx->block[15] = mctx->byte_count >> 29; - le32_to_cpu_array(mctx->block, (sizeof(mctx->block) - - sizeof(u64)) / sizeof(u32)); - md4_transform(mctx->hash, mctx->block); - cpu_to_le32_array(mctx->hash, ARRAY_SIZE(mctx->hash)); - memcpy(out, mctx->hash, sizeof(mctx->hash)); - memset(mctx, 0, sizeof(*mctx)); + memset(p, 0, padding); + mctx->block[14] = mctx->byte_count << 3; + mctx->block[15] = mctx->byte_count >> 29; + le32_to_cpu_array(mctx->block, (sizeof(mctx->block) - sizeof(u64)) / sizeof(u32)); + md4_transform(mctx->hash, mctx->block); + cpu_to_le32_array(mctx->hash, ARRAY_SIZE(mctx->hash)); + memcpy(out, mctx->hash, sizeof(mctx->hash)); + memset(mctx, 0, sizeof(*mctx)); - return 0; + return 0; } static char to_hex(u8 v) { - v = v & 0xf; - if (v < 0xa) - return '0' + v; - return 'a' + v - 0xa; + v = v & 0xf; + if (v < 0xa) + return '0' + v; + return 'a' + v - 0xa; } void md4hexf(const char *path, char *hash) { - struct md4_ctx mctx; - md4_init(&mctx); + struct md4_ctx mctx; + md4_init(&mctx); - int fd = open(path, O_RDONLY); - if (fd >= 0) { - u8 buffer[MD4_HMAC_BLOCK_SIZE]; - while (1) { - ssize_t count = read(fd, buffer, sizeof(buffer)); - if (count <= 0) - break; - md4_update(&mctx, buffer, (unsigned)count); - } - close(fd); - } + int fd = open(path, O_RDONLY); + if (fd >= 0) { + u8 buffer[MD4_HMAC_BLOCK_SIZE]; + while (1) { + ssize_t count = read(fd, buffer, sizeof(buffer)); + if (count <= 0) + break; + md4_update(&mctx, buffer, (unsigned)count); + } + close(fd); + } - u8 out[MD4_DIGEST_SIZE]; - md4_final(&mctx, out); + u8 out[MD4_DIGEST_SIZE]; + md4_final(&mctx, out); - for (int i = 0; i < MD4_DIGEST_SIZE; i++) { - hash[2*i+0] = to_hex(out[i] >> 4); - hash[2*i+1] = to_hex(out[i] & 0xf); - } - hash[2*MD4_DIGEST_SIZE] = 0; + for (int i = 0; i < MD4_DIGEST_SIZE; i++) { + hash[2 * i + 0] = to_hex(out[i] >> 4); + hash[2 * i + 1] = to_hex(out[i] & 0xf); + } + hash[2 * MD4_DIGEST_SIZE] = 0; }
M src/tint2conf/properties.csrc/tint2conf/properties.c

@@ -21,9 +21,12 @@ #include "gui.h"

#include "background_gui.h" #include "gradient_gui.h" -GtkWidget *panel_width, *panel_height, *panel_margin_x, *panel_margin_y, *panel_padding_x, *panel_padding_y, *panel_spacing; -GtkWidget *panel_wm_menu, *panel_dock, *panel_autohide, *panel_autohide_show_time, *panel_autohide_hide_time, *panel_autohide_size; -GtkWidget *panel_combo_strut_policy, *panel_combo_layer, *panel_combo_width_type, *panel_combo_height_type, *panel_combo_monitor; +GtkWidget *panel_width, *panel_height, *panel_margin_x, *panel_margin_y, *panel_padding_x, *panel_padding_y, + *panel_spacing; +GtkWidget *panel_wm_menu, *panel_dock, *panel_autohide, *panel_autohide_show_time, *panel_autohide_hide_time, + *panel_autohide_size; +GtkWidget *panel_combo_strut_policy, *panel_combo_layer, *panel_combo_width_type, *panel_combo_height_type, + *panel_combo_monitor; GtkWidget *panel_window_name, *disable_transparency; GtkWidget *panel_mouse_effects; GtkWidget *mouse_hover_icon_opacity, *mouse_hover_icon_saturation, *mouse_hover_icon_brightness;

@@ -54,32 +57,19 @@ GtkWidget *task_mouse_left, *task_mouse_middle, *task_mouse_right, *task_mouse_scroll_up, *task_mouse_scroll_down;

GtkWidget *task_show_icon, *task_show_text, *task_align_center, *font_shadow; GtkWidget *task_maximum_width, *task_maximum_height, *task_padding_x, *task_padding_y, *task_spacing; GtkWidget *task_font, *task_font_set; -GtkWidget *task_default_color, *task_default_color_set, - *task_default_icon_opacity, *task_default_icon_osb_set, - *task_default_icon_saturation, - *task_default_icon_brightness, - *task_default_background, *task_default_background_set; -GtkWidget *task_normal_color, *task_normal_color_set, - *task_normal_icon_opacity, *task_normal_icon_osb_set, - *task_normal_icon_saturation, - *task_normal_icon_brightness, - *task_normal_background, *task_normal_background_set; -GtkWidget *task_active_color, *task_active_color_set, - *task_active_icon_opacity, *task_active_icon_osb_set, - *task_active_icon_saturation, - *task_active_icon_brightness, - *task_active_background, *task_active_background_set; -GtkWidget *task_urgent_color, *task_urgent_color_set, - *task_urgent_icon_opacity, *task_urgent_icon_osb_set, - *task_urgent_icon_saturation, - *task_urgent_icon_brightness, - *task_urgent_background, *task_urgent_background_set; +GtkWidget *task_default_color, *task_default_color_set, *task_default_icon_opacity, *task_default_icon_osb_set, + *task_default_icon_saturation, *task_default_icon_brightness, *task_default_background, + *task_default_background_set; +GtkWidget *task_normal_color, *task_normal_color_set, *task_normal_icon_opacity, *task_normal_icon_osb_set, + *task_normal_icon_saturation, *task_normal_icon_brightness, *task_normal_background, *task_normal_background_set; +GtkWidget *task_active_color, *task_active_color_set, *task_active_icon_opacity, *task_active_icon_osb_set, + *task_active_icon_saturation, *task_active_icon_brightness, *task_active_background, *task_active_background_set; +GtkWidget *task_urgent_color, *task_urgent_color_set, *task_urgent_icon_opacity, *task_urgent_icon_osb_set, + *task_urgent_icon_saturation, *task_urgent_icon_brightness, *task_urgent_background, *task_urgent_background_set; GtkWidget *task_urgent_blinks; -GtkWidget *task_iconified_color, *task_iconified_color_set, - *task_iconified_icon_opacity, *task_iconified_icon_osb_set, - *task_iconified_icon_saturation, - *task_iconified_icon_brightness, - *task_iconified_background, *task_iconified_background_set; +GtkWidget *task_iconified_color, *task_iconified_color_set, *task_iconified_icon_opacity, *task_iconified_icon_osb_set, + *task_iconified_icon_saturation, *task_iconified_icon_brightness, *task_iconified_background, + *task_iconified_background_set; // clock GtkWidget *clock_format_line1, *clock_format_line2, *clock_tmz_line1, *clock_tmz_line2;

@@ -92,10 +82,12 @@

// battery GtkWidget *battery_hide_if_higher, *battery_alert_if_lower, *battery_alert_cmd; GtkWidget *battery_padding_x, *battery_padding_y; -GtkWidget *battery_font_line1, *battery_font_line1_set, *battery_font_line2, *battery_font_line2_set, *battery_font_color; +GtkWidget *battery_font_line1, *battery_font_line1_set, *battery_font_line2, *battery_font_line2_set, + *battery_font_color; GtkWidget *battery_background; GtkWidget *battery_tooltip; -GtkWidget *battery_left_command, *battery_mclick_command, *battery_right_command, *battery_uwheel_command, *battery_dwheel_command; +GtkWidget *battery_left_command, *battery_mclick_command, *battery_right_command, *battery_uwheel_command, + *battery_dwheel_command; GtkWidget *ac_connected_cmd, *ac_disconnected_cmd; // systray

@@ -146,16 +138,16 @@ void load_icons(GtkListStore *apps);

void create_taskbar(GtkWidget *parent); void create_task(GtkWidget *parent); void create_task_status(GtkWidget *notebook, - char *name, - char *text, - GtkWidget **task_status_color, - GtkWidget **task_status_color_set, - GtkWidget **task_status_icon_opacity, - GtkWidget **task_status_icon_osb_set, - GtkWidget **task_status_icon_saturation, - GtkWidget **task_status_icon_brightness, - GtkWidget **task_status_background, - GtkWidget **task_status_background_set); + char *name, + char *text, + GtkWidget **task_status_color, + GtkWidget **task_status_color_set, + GtkWidget **task_status_icon_opacity, + GtkWidget **task_status_icon_osb_set, + GtkWidget **task_status_icon_saturation, + GtkWidget **task_status_icon_brightness, + GtkWidget **task_status_background, + GtkWidget **task_status_background_set); void create_separator(GtkWidget *parent, int i); void create_execp(GtkWidget *parent, int i); void create_button(GtkWidget *parent, int i);

@@ -170,5281 +162,5795 @@ void panel_move_item_up(GtkWidget *widget, gpointer data);

gint compare_strings(gconstpointer a, gconstpointer b) { - return strnatcasecmp((const char*)a, (const char*)b); + return strnatcasecmp((const char *)a, (const char *)b); } const gchar *get_default_font() { - GtkSettings *settings = gtk_settings_get_default(); - gchar *default_font; - g_object_get(settings, "gtk-font-name", &default_font, NULL); - if (default_font) - return default_font; - return "sans 10"; + GtkSettings *settings = gtk_settings_get_default(); + gchar *default_font; + g_object_get(settings, "gtk-font-name", &default_font, NULL); + if (default_font) + return default_font; + return "sans 10"; } void applyClicked(GtkWidget *widget, gpointer data) { - gchar *filepath = get_current_theme_path(); - if (filepath) { - if (config_is_manual(filepath)) { - gchar *backup_path = g_strdup_printf("%s.backup.%ld", filepath, time(NULL)); - copy_file(filepath, backup_path); - g_free(backup_path); - } + gchar *filepath = get_current_theme_path(); + if (filepath) { + if (config_is_manual(filepath)) { + gchar *backup_path = g_strdup_printf("%s.backup.%ld", filepath, time(NULL)); + copy_file(filepath, backup_path); + g_free(backup_path); + } - config_save_file(filepath); - } - int unused = system("killall -SIGUSR1 tint2 || pkill -SIGUSR1 -x tint2"); - (void)unused; - g_free(filepath); - refresh_current_theme(); + config_save_file(filepath); + } + int unused = system("killall -SIGUSR1 tint2 || pkill -SIGUSR1 -x tint2"); + (void)unused; + g_free(filepath); + refresh_current_theme(); } void cancelClicked(GtkWidget *widget, gpointer data) { - GtkWidget *view = (GtkWidget *)data; - gtk_widget_destroy(view); + GtkWidget *view = (GtkWidget *)data; + gtk_widget_destroy(view); } void okClicked(GtkWidget *widget, gpointer data) { - applyClicked(widget, data); - cancelClicked(widget, data); + applyClicked(widget, data); + cancelClicked(widget, data); } void font_set_callback(GtkWidget *widget, gpointer data) { - gtk_widget_set_sensitive(data, GTK_TOGGLE_BUTTON(widget)->active); + gtk_widget_set_sensitive(data, GTK_TOGGLE_BUTTON(widget)->active); } GtkWidget *create_properties() { - GtkWidget *view, *dialog_vbox3, *button; - GtkTooltips *tooltips; - GtkWidget *page_panel, *page_panel_items, *page_launcher, *page_taskbar, *page_battery, *page_clock, - *page_tooltip, *page_systemtray, *page_task, *page_background, *page_gradient; - GtkWidget *label; + GtkWidget *view, *dialog_vbox3, *button; + GtkTooltips *tooltips; + GtkWidget *page_panel, *page_panel_items, *page_launcher, *page_taskbar, *page_battery, *page_clock, *page_tooltip, + *page_systemtray, *page_task, *page_background, *page_gradient; + GtkWidget *label; - tooltips = gtk_tooltips_new(); - (void) tooltips; + tooltips = gtk_tooltips_new(); + (void)tooltips; - separators = g_array_new(FALSE, TRUE, sizeof(Separator)); - executors = g_array_new(FALSE, TRUE, sizeof(Executor)); - buttons = g_array_new(FALSE, TRUE, sizeof(Button)); + separators = g_array_new(FALSE, TRUE, sizeof(Separator)); + executors = g_array_new(FALSE, TRUE, sizeof(Executor)); + buttons = g_array_new(FALSE, TRUE, sizeof(Button)); - // global layer - view = gtk_dialog_new(); - gtk_window_set_title(GTK_WINDOW(view), _("Properties")); - gtk_window_set_modal(GTK_WINDOW(view), TRUE); - gtk_window_set_default_size(GTK_WINDOW(view), 920, 600); - gtk_window_set_skip_pager_hint(GTK_WINDOW(view), TRUE); - gtk_window_set_type_hint(GTK_WINDOW(view), GDK_WINDOW_TYPE_HINT_DIALOG); + // global layer + view = gtk_dialog_new(); + gtk_window_set_title(GTK_WINDOW(view), _("Properties")); + gtk_window_set_modal(GTK_WINDOW(view), TRUE); + gtk_window_set_default_size(GTK_WINDOW(view), 920, 600); + gtk_window_set_skip_pager_hint(GTK_WINDOW(view), TRUE); + gtk_window_set_type_hint(GTK_WINDOW(view), GDK_WINDOW_TYPE_HINT_DIALOG); - dialog_vbox3 = GTK_DIALOG(view)->vbox; - gtk_widget_show(dialog_vbox3); + dialog_vbox3 = GTK_DIALOG(view)->vbox; + gtk_widget_show(dialog_vbox3); - notebook = gtk_notebook_new(); - gtk_widget_show(notebook); - gtk_container_set_border_width(GTK_CONTAINER(notebook), 5); - gtk_box_pack_start(GTK_BOX(dialog_vbox3), notebook, TRUE, TRUE, 6); - gtk_notebook_set_tab_pos(GTK_NOTEBOOK(notebook), GTK_POS_LEFT); + notebook = gtk_notebook_new(); + gtk_widget_show(notebook); + gtk_container_set_border_width(GTK_CONTAINER(notebook), 5); + gtk_box_pack_start(GTK_BOX(dialog_vbox3), notebook, TRUE, TRUE, 6); + gtk_notebook_set_tab_pos(GTK_NOTEBOOK(notebook), GTK_POS_LEFT); - button = gtk_button_new_from_stock("gtk-apply"); - gtk_widget_show(button); - gtk_dialog_add_action_widget(GTK_DIALOG(view), button, GTK_RESPONSE_APPLY); - gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(applyClicked), NULL); - GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); + button = gtk_button_new_from_stock("gtk-apply"); + gtk_widget_show(button); + gtk_dialog_add_action_widget(GTK_DIALOG(view), button, GTK_RESPONSE_APPLY); + gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(applyClicked), NULL); + GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); - button = gtk_button_new_from_stock("gtk-cancel"); - gtk_widget_show(button); - gtk_dialog_add_action_widget(GTK_DIALOG(view), button, GTK_RESPONSE_CANCEL); - gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(cancelClicked), view); - GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); + button = gtk_button_new_from_stock("gtk-cancel"); + gtk_widget_show(button); + gtk_dialog_add_action_widget(GTK_DIALOG(view), button, GTK_RESPONSE_CANCEL); + gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(cancelClicked), view); + GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); - button = gtk_button_new_from_stock("gtk-ok"); - gtk_widget_show(button); - gtk_dialog_add_action_widget(GTK_DIALOG(view), button, GTK_RESPONSE_OK); - gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(okClicked), view); - GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); + button = gtk_button_new_from_stock("gtk-ok"); + gtk_widget_show(button); + gtk_dialog_add_action_widget(GTK_DIALOG(view), button, GTK_RESPONSE_OK); + gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(okClicked), view); + GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); - // notebook - label = gtk_label_new(_("Gradients")); - gtk_widget_show(label); - page_gradient = gtk_vbox_new(FALSE, DEFAULT_HOR_SPACING); - gtk_container_set_border_width(GTK_CONTAINER(page_gradient), 10); - gtk_widget_show(page_gradient); - gtk_notebook_append_page(GTK_NOTEBOOK(notebook), addScrollBarToWidget(page_gradient), label); - create_gradient(page_gradient); + // notebook + label = gtk_label_new(_("Gradients")); + gtk_widget_show(label); + page_gradient = gtk_vbox_new(FALSE, DEFAULT_HOR_SPACING); + gtk_container_set_border_width(GTK_CONTAINER(page_gradient), 10); + gtk_widget_show(page_gradient); + gtk_notebook_append_page(GTK_NOTEBOOK(notebook), addScrollBarToWidget(page_gradient), label); + create_gradient(page_gradient); - label = gtk_label_new(_("Backgrounds")); - gtk_widget_show(label); - page_background = gtk_vbox_new(FALSE, DEFAULT_HOR_SPACING); - gtk_container_set_border_width(GTK_CONTAINER(page_background), 10); - gtk_widget_show(page_background); - gtk_notebook_append_page(GTK_NOTEBOOK(notebook), addScrollBarToWidget(page_background), label); - create_background(page_background); + label = gtk_label_new(_("Backgrounds")); + gtk_widget_show(label); + page_background = gtk_vbox_new(FALSE, DEFAULT_HOR_SPACING); + gtk_container_set_border_width(GTK_CONTAINER(page_background), 10); + gtk_widget_show(page_background); + gtk_notebook_append_page(GTK_NOTEBOOK(notebook), addScrollBarToWidget(page_background), label); + create_background(page_background); - label = gtk_label_new(_("Panel")); - gtk_widget_show(label); - page_panel = gtk_vbox_new(FALSE, DEFAULT_HOR_SPACING); - gtk_container_set_border_width(GTK_CONTAINER(page_panel), 10); - gtk_widget_show(page_panel); - gtk_notebook_append_page(GTK_NOTEBOOK(notebook), addScrollBarToWidget(page_panel), label); - create_panel(page_panel); + label = gtk_label_new(_("Panel")); + gtk_widget_show(label); + page_panel = gtk_vbox_new(FALSE, DEFAULT_HOR_SPACING); + gtk_container_set_border_width(GTK_CONTAINER(page_panel), 10); + gtk_widget_show(page_panel); + gtk_notebook_append_page(GTK_NOTEBOOK(notebook), addScrollBarToWidget(page_panel), label); + create_panel(page_panel); - label = gtk_label_new(_("Panel items")); - gtk_widget_show(label); - page_panel_items = gtk_vbox_new(FALSE, DEFAULT_HOR_SPACING); - gtk_container_set_border_width(GTK_CONTAINER(page_panel_items), 10); - gtk_widget_show(page_panel_items); - gtk_notebook_append_page(GTK_NOTEBOOK(notebook), addScrollBarToWidget(page_panel_items), label); - create_panel_items(page_panel_items); + label = gtk_label_new(_("Panel items")); + gtk_widget_show(label); + page_panel_items = gtk_vbox_new(FALSE, DEFAULT_HOR_SPACING); + gtk_container_set_border_width(GTK_CONTAINER(page_panel_items), 10); + gtk_widget_show(page_panel_items); + gtk_notebook_append_page(GTK_NOTEBOOK(notebook), addScrollBarToWidget(page_panel_items), label); + create_panel_items(page_panel_items); - label = gtk_label_new(_("Taskbar")); - gtk_widget_show(label); - page_taskbar = gtk_vbox_new(FALSE, DEFAULT_HOR_SPACING); - gtk_container_set_border_width(GTK_CONTAINER(page_taskbar), 10); - gtk_widget_show(page_taskbar); - gtk_notebook_append_page(GTK_NOTEBOOK(notebook), addScrollBarToWidget(page_taskbar), label); - create_taskbar(page_taskbar); + label = gtk_label_new(_("Taskbar")); + gtk_widget_show(label); + page_taskbar = gtk_vbox_new(FALSE, DEFAULT_HOR_SPACING); + gtk_container_set_border_width(GTK_CONTAINER(page_taskbar), 10); + gtk_widget_show(page_taskbar); + gtk_notebook_append_page(GTK_NOTEBOOK(notebook), addScrollBarToWidget(page_taskbar), label); + create_taskbar(page_taskbar); - label = gtk_label_new(_("Task buttons")); - gtk_widget_show(label); - page_task = gtk_vbox_new(FALSE, DEFAULT_HOR_SPACING); - gtk_container_set_border_width(GTK_CONTAINER(page_task), 10); - gtk_widget_show(page_task); - gtk_notebook_append_page(GTK_NOTEBOOK(notebook), addScrollBarToWidget(page_task), label); - create_task(page_task); + label = gtk_label_new(_("Task buttons")); + gtk_widget_show(label); + page_task = gtk_vbox_new(FALSE, DEFAULT_HOR_SPACING); + gtk_container_set_border_width(GTK_CONTAINER(page_task), 10); + gtk_widget_show(page_task); + gtk_notebook_append_page(GTK_NOTEBOOK(notebook), addScrollBarToWidget(page_task), label); + create_task(page_task); - label = gtk_label_new(_("Launcher")); - gtk_widget_show(label); - page_launcher = gtk_vbox_new(FALSE, DEFAULT_HOR_SPACING); - gtk_container_set_border_width(GTK_CONTAINER(page_launcher), 10); - gtk_widget_show(page_launcher); - gtk_notebook_append_page(GTK_NOTEBOOK(notebook), addScrollBarToWidget(page_launcher), label); - create_launcher(page_launcher, GTK_WINDOW(view)); + label = gtk_label_new(_("Launcher")); + gtk_widget_show(label); + page_launcher = gtk_vbox_new(FALSE, DEFAULT_HOR_SPACING); + gtk_container_set_border_width(GTK_CONTAINER(page_launcher), 10); + gtk_widget_show(page_launcher); + gtk_notebook_append_page(GTK_NOTEBOOK(notebook), addScrollBarToWidget(page_launcher), label); + create_launcher(page_launcher, GTK_WINDOW(view)); - label = gtk_label_new(_("Clock")); - gtk_widget_show(label); - page_clock = gtk_vbox_new(FALSE, DEFAULT_HOR_SPACING); - gtk_container_set_border_width(GTK_CONTAINER(page_clock), 10); - gtk_widget_show(page_clock); - gtk_notebook_append_page(GTK_NOTEBOOK(notebook), addScrollBarToWidget(page_clock), label); - create_clock(page_clock); + label = gtk_label_new(_("Clock")); + gtk_widget_show(label); + page_clock = gtk_vbox_new(FALSE, DEFAULT_HOR_SPACING); + gtk_container_set_border_width(GTK_CONTAINER(page_clock), 10); + gtk_widget_show(page_clock); + gtk_notebook_append_page(GTK_NOTEBOOK(notebook), addScrollBarToWidget(page_clock), label); + create_clock(page_clock); - label = gtk_label_new(_("System tray")); - gtk_widget_show(label); - page_systemtray = gtk_vbox_new(FALSE, DEFAULT_HOR_SPACING); - gtk_container_set_border_width(GTK_CONTAINER(page_systemtray), 10); - gtk_widget_show(page_systemtray); - gtk_notebook_append_page(GTK_NOTEBOOK(notebook), addScrollBarToWidget(page_systemtray), label); - create_systemtray(page_systemtray); + label = gtk_label_new(_("System tray")); + gtk_widget_show(label); + page_systemtray = gtk_vbox_new(FALSE, DEFAULT_HOR_SPACING); + gtk_container_set_border_width(GTK_CONTAINER(page_systemtray), 10); + gtk_widget_show(page_systemtray); + gtk_notebook_append_page(GTK_NOTEBOOK(notebook), addScrollBarToWidget(page_systemtray), label); + create_systemtray(page_systemtray); - label = gtk_label_new(_("Battery")); - gtk_widget_show(label); - page_battery = gtk_vbox_new(FALSE, DEFAULT_HOR_SPACING); - gtk_container_set_border_width(GTK_CONTAINER(page_battery), 10); - gtk_widget_show(page_battery); - gtk_notebook_append_page(GTK_NOTEBOOK(notebook), addScrollBarToWidget(page_battery), label); - create_battery(page_battery); + label = gtk_label_new(_("Battery")); + gtk_widget_show(label); + page_battery = gtk_vbox_new(FALSE, DEFAULT_HOR_SPACING); + gtk_container_set_border_width(GTK_CONTAINER(page_battery), 10); + gtk_widget_show(page_battery); + gtk_notebook_append_page(GTK_NOTEBOOK(notebook), addScrollBarToWidget(page_battery), label); + create_battery(page_battery); - label = gtk_label_new(_("Tooltip")); - gtk_widget_show(label); - page_tooltip = gtk_vbox_new(FALSE, DEFAULT_HOR_SPACING); - gtk_container_set_border_width(GTK_CONTAINER(page_tooltip), 10); - gtk_widget_show(page_tooltip); - gtk_notebook_append_page(GTK_NOTEBOOK(notebook), addScrollBarToWidget(page_tooltip), label); - create_tooltip(page_tooltip); + label = gtk_label_new(_("Tooltip")); + gtk_widget_show(label); + page_tooltip = gtk_vbox_new(FALSE, DEFAULT_HOR_SPACING); + gtk_container_set_border_width(GTK_CONTAINER(page_tooltip), 10); + gtk_widget_show(page_tooltip); + gtk_notebook_append_page(GTK_NOTEBOOK(notebook), addScrollBarToWidget(page_tooltip), label); + create_tooltip(page_tooltip); - return view; + return view; } void change_paragraph(GtkWidget *widget) { - GtkWidget *hbox; - hbox = gtk_hbox_new(FALSE, 0); - gtk_widget_show(hbox); - gtk_box_pack_start(GTK_BOX(widget), hbox, FALSE, FALSE, 0); - gtk_container_set_border_width(GTK_CONTAINER(hbox), 6); + GtkWidget *hbox; + hbox = gtk_hbox_new(FALSE, 0); + gtk_widget_show(hbox); + gtk_box_pack_start(GTK_BOX(widget), hbox, FALSE, FALSE, 0); + gtk_container_set_border_width(GTK_CONTAINER(hbox), 6); } void gdkColor2CairoColor(GdkColor color, double *red, double *green, double *blue) { - *red = color.red / (double)0xffff; - *green = color.green / (double)0xffff; - *blue = color.blue / (double)0xffff; + *red = color.red / (double)0xffff; + *green = color.green / (double)0xffff; + *blue = color.blue / (double)0xffff; } void cairoColor2GdkColor(double red, double green, double blue, GdkColor *color) { - color->pixel = 0; - color->red = red * 0xffff; - color->green = green * 0xffff; - color->blue = blue * 0xffff; + color->pixel = 0; + color->red = red * 0xffff; + color->green = green * 0xffff; + color->blue = blue * 0xffff; } int get_model_length(GtkTreeModel *model) { - int i; - for (i = 0; ; i++) { - GtkTreePath *path; - GtkTreeIter iter; + int i; + for (i = 0;; i++) { + GtkTreePath *path; + GtkTreeIter iter; - path = gtk_tree_path_new_from_indices(i, -1); - gboolean end = gtk_tree_model_get_iter(model, &iter, path); - gtk_tree_path_free(path); + path = gtk_tree_path_new_from_indices(i, -1); + gboolean end = gtk_tree_model_get_iter(model, &iter, path); + gtk_tree_path_free(path); - if (!end) { - return i; - } - } + if (!end) { + return i; + } + } } - void create_panel(GtkWidget *parent) { - int i; - GtkWidget *table, *hbox, *position; - GtkWidget *label; - int row, col; - GtkTooltips *tooltips = gtk_tooltips_new(); + int i; + GtkWidget *table, *hbox, *position; + GtkWidget *label; + int row, col; + GtkTooltips *tooltips = gtk_tooltips_new(); - label = gtk_label_new(_("<b>Geometry</b>")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_label_set_use_markup(GTK_LABEL(label), TRUE); - gtk_widget_show(label); - gtk_box_pack_start(GTK_BOX(parent), label, FALSE, FALSE, 0); - hbox = gtk_hbox_new(FALSE, 20); - gtk_widget_show(hbox); - gtk_box_pack_start(GTK_BOX(parent), hbox, FALSE, FALSE, 0); + label = gtk_label_new(_("<b>Geometry</b>")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_label_set_use_markup(GTK_LABEL(label), TRUE); + gtk_widget_show(label); + gtk_box_pack_start(GTK_BOX(parent), label, FALSE, FALSE, 0); + hbox = gtk_hbox_new(FALSE, 20); + gtk_widget_show(hbox); + gtk_box_pack_start(GTK_BOX(parent), hbox, FALSE, FALSE, 0); - table = gtk_table_new(2, 10, FALSE); - gtk_widget_show(table); - gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); - gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); - gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); + table = gtk_table_new(2, 10, FALSE); + gtk_widget_show(table); + gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); + gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); + gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); - row = 0; - col = 2; - label = gtk_label_new(_("Position")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row = 0; + col = 2; + label = gtk_label_new(_("Position")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - position = gtk_table_new(5, 5, FALSE); - gtk_widget_show(position); - for (i = 0; i < 12; ++i) { - GSList *group = i == 0 ? NULL : gtk_radio_button_get_group(GTK_RADIO_BUTTON(screen_position[0])); - screen_position[i] = gtk_radio_button_new(group); - g_object_set(screen_position[i], "draw-indicator", FALSE, NULL); - gtk_widget_show(screen_position[i]); + position = gtk_table_new(5, 5, FALSE); + gtk_widget_show(position); + for (i = 0; i < 12; ++i) { + GSList *group = i == 0 ? NULL : gtk_radio_button_get_group(GTK_RADIO_BUTTON(screen_position[0])); + screen_position[i] = gtk_radio_button_new(group); + g_object_set(screen_position[i], "draw-indicator", FALSE, NULL); + gtk_widget_show(screen_position[i]); - if (i <= 2 || i >= 9) { - gtk_widget_set_size_request(screen_position[i], 30, 15); - } else { - gtk_widget_set_size_request(screen_position[i], 15, 25); - } - } - gtk_table_attach_defaults(GTK_TABLE(position), screen_position[0], 1, 2, 0, 1); - gtk_tooltips_set_tip(tooltips, screen_position[0], _("Position on screen: top-left, horizontal panel"), NULL); - gtk_table_attach_defaults(GTK_TABLE(position), screen_position[1], 2, 3, 0, 1); - gtk_tooltips_set_tip(tooltips, screen_position[1], _("Position on screen: top-center, horizontal panel"), NULL); - gtk_table_attach_defaults(GTK_TABLE(position), screen_position[2], 3, 4, 0, 1); - gtk_tooltips_set_tip(tooltips, screen_position[2], _("Position on screen: top-right, horizontal panel"), NULL); - gtk_table_attach_defaults(GTK_TABLE(position), screen_position[3], 0, 1, 1, 2); - gtk_tooltips_set_tip(tooltips, screen_position[3], _("Position on screen: top-left, vertical panel"), NULL); - gtk_table_attach_defaults(GTK_TABLE(position), screen_position[4], 0, 1, 2, 3); - gtk_tooltips_set_tip(tooltips, screen_position[4], _("Position on screen: center-left, vertical panel"), NULL); - gtk_table_attach_defaults(GTK_TABLE(position), screen_position[5], 0, 1, 3, 4); - gtk_tooltips_set_tip(tooltips, screen_position[5], _("Position on screen: bottom-left, vertical panel"), NULL); - gtk_table_attach_defaults(GTK_TABLE(position), screen_position[6], 4, 5, 1, 2); - gtk_tooltips_set_tip(tooltips, screen_position[6], _("Position on screen: top-right, vertical panel"), NULL); - gtk_table_attach_defaults(GTK_TABLE(position), screen_position[7], 4, 5, 2, 3); - gtk_tooltips_set_tip(tooltips, screen_position[7], _("Position on screen: center-right, vertical panel"), NULL); - gtk_table_attach_defaults(GTK_TABLE(position), screen_position[8], 4, 5, 3, 4); - gtk_tooltips_set_tip(tooltips, screen_position[8], _("Position on screen: bottom-right, vertical panel"), NULL); - gtk_table_attach_defaults(GTK_TABLE(position), screen_position[9], 1, 2, 4, 5); - gtk_tooltips_set_tip(tooltips, screen_position[9], _("Position on screen: bottom-left, horizontal panel"), NULL); - gtk_table_attach_defaults(GTK_TABLE(position), screen_position[10], 2, 3, 4, 5); - gtk_tooltips_set_tip(tooltips, screen_position[10], _("Position on screen: bottom-center, horizontal panel"), NULL); - gtk_table_attach_defaults(GTK_TABLE(position), screen_position[11], 3, 4, 4, 5); - gtk_tooltips_set_tip(tooltips, screen_position[11], _("Position on screen: bottom-right, horizontal panel"), NULL); - gtk_table_attach(GTK_TABLE(table), position, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); + if (i <= 2 || i >= 9) { + gtk_widget_set_size_request(screen_position[i], 30, 15); + } else { + gtk_widget_set_size_request(screen_position[i], 15, 25); + } + } + gtk_table_attach_defaults(GTK_TABLE(position), screen_position[0], 1, 2, 0, 1); + gtk_tooltips_set_tip(tooltips, screen_position[0], _("Position on screen: top-left, horizontal panel"), NULL); + gtk_table_attach_defaults(GTK_TABLE(position), screen_position[1], 2, 3, 0, 1); + gtk_tooltips_set_tip(tooltips, screen_position[1], _("Position on screen: top-center, horizontal panel"), NULL); + gtk_table_attach_defaults(GTK_TABLE(position), screen_position[2], 3, 4, 0, 1); + gtk_tooltips_set_tip(tooltips, screen_position[2], _("Position on screen: top-right, horizontal panel"), NULL); + gtk_table_attach_defaults(GTK_TABLE(position), screen_position[3], 0, 1, 1, 2); + gtk_tooltips_set_tip(tooltips, screen_position[3], _("Position on screen: top-left, vertical panel"), NULL); + gtk_table_attach_defaults(GTK_TABLE(position), screen_position[4], 0, 1, 2, 3); + gtk_tooltips_set_tip(tooltips, screen_position[4], _("Position on screen: center-left, vertical panel"), NULL); + gtk_table_attach_defaults(GTK_TABLE(position), screen_position[5], 0, 1, 3, 4); + gtk_tooltips_set_tip(tooltips, screen_position[5], _("Position on screen: bottom-left, vertical panel"), NULL); + gtk_table_attach_defaults(GTK_TABLE(position), screen_position[6], 4, 5, 1, 2); + gtk_tooltips_set_tip(tooltips, screen_position[6], _("Position on screen: top-right, vertical panel"), NULL); + gtk_table_attach_defaults(GTK_TABLE(position), screen_position[7], 4, 5, 2, 3); + gtk_tooltips_set_tip(tooltips, screen_position[7], _("Position on screen: center-right, vertical panel"), NULL); + gtk_table_attach_defaults(GTK_TABLE(position), screen_position[8], 4, 5, 3, 4); + gtk_tooltips_set_tip(tooltips, screen_position[8], _("Position on screen: bottom-right, vertical panel"), NULL); + gtk_table_attach_defaults(GTK_TABLE(position), screen_position[9], 1, 2, 4, 5); + gtk_tooltips_set_tip(tooltips, screen_position[9], _("Position on screen: bottom-left, horizontal panel"), NULL); + gtk_table_attach_defaults(GTK_TABLE(position), screen_position[10], 2, 3, 4, 5); + gtk_tooltips_set_tip(tooltips, screen_position[10], _("Position on screen: bottom-center, horizontal panel"), NULL); + gtk_table_attach_defaults(GTK_TABLE(position), screen_position[11], 3, 4, 4, 5); + gtk_tooltips_set_tip(tooltips, screen_position[11], _("Position on screen: bottom-right, horizontal panel"), NULL); + gtk_table_attach(GTK_TABLE(table), position, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); - row++; - col = 2; - label = gtk_label_new(_("Monitor")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++; + col = 2; + label = gtk_label_new(_("Monitor")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - panel_combo_monitor = gtk_combo_box_new_text(); - gtk_widget_show(panel_combo_monitor); - gtk_table_attach(GTK_TABLE(table), panel_combo_monitor, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_combo_box_append_text(GTK_COMBO_BOX(panel_combo_monitor), _("All")); - gtk_combo_box_append_text(GTK_COMBO_BOX(panel_combo_monitor), _("1")); - gtk_combo_box_append_text(GTK_COMBO_BOX(panel_combo_monitor), _("2")); - gtk_combo_box_append_text(GTK_COMBO_BOX(panel_combo_monitor), _("3")); - gtk_combo_box_append_text(GTK_COMBO_BOX(panel_combo_monitor), _("4")); - gtk_combo_box_append_text(GTK_COMBO_BOX(panel_combo_monitor), _("5")); - gtk_combo_box_append_text(GTK_COMBO_BOX(panel_combo_monitor), _("6")); - gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_monitor), 0); - gtk_tooltips_set_tip(tooltips, panel_combo_monitor, _("The monitor on which the panel is placed"), NULL); + panel_combo_monitor = gtk_combo_box_new_text(); + gtk_widget_show(panel_combo_monitor); + gtk_table_attach(GTK_TABLE(table), panel_combo_monitor, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_combo_box_append_text(GTK_COMBO_BOX(panel_combo_monitor), _("All")); + gtk_combo_box_append_text(GTK_COMBO_BOX(panel_combo_monitor), _("1")); + gtk_combo_box_append_text(GTK_COMBO_BOX(panel_combo_monitor), _("2")); + gtk_combo_box_append_text(GTK_COMBO_BOX(panel_combo_monitor), _("3")); + gtk_combo_box_append_text(GTK_COMBO_BOX(panel_combo_monitor), _("4")); + gtk_combo_box_append_text(GTK_COMBO_BOX(panel_combo_monitor), _("5")); + gtk_combo_box_append_text(GTK_COMBO_BOX(panel_combo_monitor), _("6")); + gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_monitor), 0); + gtk_tooltips_set_tip(tooltips, panel_combo_monitor, _("The monitor on which the panel is placed"), NULL); - row++; - col = 2; - label = gtk_label_new(_("Primary monitor first")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++; + col = 2; + label = gtk_label_new(_("Primary monitor first")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - panel_primary_monitor_first = gtk_check_button_new(); - gtk_widget_show(panel_primary_monitor_first); - gtk_table_attach(GTK_TABLE(table), panel_primary_monitor_first, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, panel_primary_monitor_first, _("If enabled, the primary monitor will have index 1 in the monitor list even if it is not top-left."), NULL); + panel_primary_monitor_first = gtk_check_button_new(); + gtk_widget_show(panel_primary_monitor_first); + gtk_table_attach(GTK_TABLE(table), panel_primary_monitor_first, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + panel_primary_monitor_first, + _("If enabled, the primary monitor will have index 1 in the monitor list even if it is not " + "top-left."), + NULL); - row++; - col = 2; - label = gtk_label_new(_("Length")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++; + col = 2; + label = gtk_label_new(_("Length")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - panel_width = gtk_spin_button_new_with_range(0, 9000, 1); - gtk_widget_show(panel_width); - gtk_table_attach(GTK_TABLE(table), panel_width, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, panel_width, _("The length of the panel (width for horizontal panels, height for vertical panels)"), NULL); + panel_width = gtk_spin_button_new_with_range(0, 9000, 1); + gtk_widget_show(panel_width); + gtk_table_attach(GTK_TABLE(table), panel_width, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + panel_width, + _("The length of the panel (width for horizontal panels, height for vertical panels)"), + NULL); - panel_combo_width_type = gtk_combo_box_new_text(); - gtk_widget_show(panel_combo_width_type); - gtk_table_attach(GTK_TABLE(table), panel_combo_width_type, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_combo_box_append_text(GTK_COMBO_BOX(panel_combo_width_type), _("Percent")); - gtk_combo_box_append_text(GTK_COMBO_BOX(panel_combo_width_type), _("Pixels")); - gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_width_type), 0); - gtk_tooltips_set_tip(tooltips, panel_combo_width_type, _("The units used to specify the length of the panel: pixels or percentage of the monitor size"), NULL); + panel_combo_width_type = gtk_combo_box_new_text(); + gtk_widget_show(panel_combo_width_type); + gtk_table_attach(GTK_TABLE(table), panel_combo_width_type, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_combo_box_append_text(GTK_COMBO_BOX(panel_combo_width_type), _("Percent")); + gtk_combo_box_append_text(GTK_COMBO_BOX(panel_combo_width_type), _("Pixels")); + gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_width_type), 0); + gtk_tooltips_set_tip(tooltips, + panel_combo_width_type, + _("The units used to specify the length of the panel: pixels or percentage of the monitor " + "size"), + NULL); - row++; - col = 2; - label = gtk_label_new(_("Compact")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++; + col = 2; + label = gtk_label_new(_("Compact")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - panel_shrink = gtk_check_button_new(); - gtk_widget_show(panel_shrink); - gtk_table_attach(GTK_TABLE(table), panel_shrink, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + panel_shrink = gtk_check_button_new(); + gtk_widget_show(panel_shrink); + gtk_table_attach(GTK_TABLE(table), panel_shrink, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - row++; - col = 2; - label = gtk_label_new(_("Size")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++; + col = 2; + label = gtk_label_new(_("Size")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - panel_height = gtk_spin_button_new_with_range(0, 9000, 1); - gtk_widget_show(panel_height); - gtk_table_attach(GTK_TABLE(table), panel_height, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, panel_height, _("The size of the panel (height for horizontal panels, width for vertical panels)"), NULL); + panel_height = gtk_spin_button_new_with_range(0, 9000, 1); + gtk_widget_show(panel_height); + gtk_table_attach(GTK_TABLE(table), panel_height, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + panel_height, + _("The size of the panel (height for horizontal panels, width for vertical panels)"), + NULL); - panel_combo_height_type = gtk_combo_box_new_text(); - gtk_widget_show(panel_combo_height_type); - gtk_table_attach(GTK_TABLE(table), panel_combo_height_type, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_combo_box_append_text(GTK_COMBO_BOX(panel_combo_height_type), _("Percent")); - gtk_combo_box_append_text(GTK_COMBO_BOX(panel_combo_height_type), _("Pixels")); - gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_height_type), 0); - gtk_tooltips_set_tip(tooltips, panel_combo_height_type, _("The units used to specify the size of the panel: pixels or percentage of the monitor size"), NULL); + panel_combo_height_type = gtk_combo_box_new_text(); + gtk_widget_show(panel_combo_height_type); + gtk_table_attach(GTK_TABLE(table), panel_combo_height_type, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_combo_box_append_text(GTK_COMBO_BOX(panel_combo_height_type), _("Percent")); + gtk_combo_box_append_text(GTK_COMBO_BOX(panel_combo_height_type), _("Pixels")); + gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_height_type), 0); + gtk_tooltips_set_tip(tooltips, + panel_combo_height_type, + _("The units used to specify the size of the panel: pixels or percentage of the monitor size"), + NULL); - row++; - col = 2; - label = gtk_label_new(_("Horizontal margin")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++; + col = 2; + label = gtk_label_new(_("Horizontal margin")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - panel_margin_x = gtk_spin_button_new_with_range(0, 500, 1); - gtk_widget_show(panel_margin_x); - gtk_table_attach(GTK_TABLE(table), panel_margin_x, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, panel_margin_x, _("Creates a space between the panel and the edge of the monitor. " - "For left-aligned panels, the space is created on the right of the panel; " - "for right-aligned panels, it is created on the left; " - "for centered panels, it is evenly distributed on both sides of the panel."), NULL); + panel_margin_x = gtk_spin_button_new_with_range(0, 500, 1); + gtk_widget_show(panel_margin_x); + gtk_table_attach(GTK_TABLE(table), panel_margin_x, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + panel_margin_x, + _("Creates a space between the panel and the edge of the monitor. " + "For left-aligned panels, the space is created on the right of the panel; " + "for right-aligned panels, it is created on the left; " + "for centered panels, it is evenly distributed on both sides of the panel."), + NULL); - row++; - col = 2; - label = gtk_label_new(_("Vertical margin")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++; + col = 2; + label = gtk_label_new(_("Vertical margin")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - panel_margin_y = gtk_spin_button_new_with_range(0, 500, 1); - gtk_widget_show(panel_margin_y); - gtk_table_attach(GTK_TABLE(table), panel_margin_y, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, panel_margin_y, _("Creates a space between the panel and the edge of the monitor. " - "For top-aligned panels, the space is created on the bottom of the panel; " - "for bottom-aligned panels, it is created on the top; " - "for centered panels, it is evenly distributed on both sides of the panel."), NULL); + panel_margin_y = gtk_spin_button_new_with_range(0, 500, 1); + gtk_widget_show(panel_margin_y); + gtk_table_attach(GTK_TABLE(table), panel_margin_y, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + panel_margin_y, + _("Creates a space between the panel and the edge of the monitor. " + "For top-aligned panels, the space is created on the bottom of the panel; " + "for bottom-aligned panels, it is created on the top; " + "for centered panels, it is evenly distributed on both sides of the panel."), + NULL); - change_paragraph(parent); + change_paragraph(parent); - label = gtk_label_new(_("<b>Appearance</b>")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_label_set_use_markup(GTK_LABEL(label), TRUE); - gtk_widget_show(label); - gtk_box_pack_start(GTK_BOX(parent), label, FALSE, FALSE, 0); + label = gtk_label_new(_("<b>Appearance</b>")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_label_set_use_markup(GTK_LABEL(label), TRUE); + gtk_widget_show(label); + gtk_box_pack_start(GTK_BOX(parent), label, FALSE, FALSE, 0); - table = gtk_table_new(2, 10, FALSE); - gtk_widget_show(table); - gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); - gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); - gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); + table = gtk_table_new(2, 10, FALSE); + gtk_widget_show(table); + gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); + gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); + gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); - row = 0; - col = 2; - label = gtk_label_new(_("Background")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row = 0; + col = 2; + label = gtk_label_new(_("Background")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - panel_background = create_background_combo(_("Panel")); - gtk_widget_show(panel_background); - gtk_table_attach(GTK_TABLE(table), panel_background, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, panel_background, _("Selects the background used to display the panel. " - "Backgrounds can be edited in the Backgrounds tab."), NULL); + panel_background = create_background_combo(_("Panel")); + gtk_widget_show(panel_background); + gtk_table_attach(GTK_TABLE(table), panel_background, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + panel_background, + _("Selects the background used to display the panel. " + "Backgrounds can be edited in the Backgrounds tab."), + NULL); - row++; - col = 2; - label = gtk_label_new(_("Horizontal padding")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++; + col = 2; + label = gtk_label_new(_("Horizontal padding")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - panel_padding_x = gtk_spin_button_new_with_range(0, 500, 1); - gtk_widget_show(panel_padding_x); - gtk_table_attach(GTK_TABLE(table), panel_padding_x, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, panel_padding_x, _("Specifies the horizontal padding of the panel. " - "This is the space between the border of the panel and the elements inside."), NULL); + panel_padding_x = gtk_spin_button_new_with_range(0, 500, 1); + gtk_widget_show(panel_padding_x); + gtk_table_attach(GTK_TABLE(table), panel_padding_x, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + panel_padding_x, + _("Specifies the horizontal padding of the panel. " + "This is the space between the border of the panel and the elements inside."), + NULL); - row++; - col = 2; - label = gtk_label_new(_("Vertical padding")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++; + col = 2; + label = gtk_label_new(_("Vertical padding")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - panel_padding_y = gtk_spin_button_new_with_range(0, 500, 1); - gtk_widget_show(panel_padding_y); - gtk_table_attach(GTK_TABLE(table), panel_padding_y, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, panel_padding_y, _("Specifies the vertical padding of the panel. " - "This is the space between the border of the panel and the elements inside."), NULL); + panel_padding_y = gtk_spin_button_new_with_range(0, 500, 1); + gtk_widget_show(panel_padding_y); + gtk_table_attach(GTK_TABLE(table), panel_padding_y, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + panel_padding_y, + _("Specifies the vertical padding of the panel. " + "This is the space between the border of the panel and the elements inside."), + NULL); - row++; - col = 2; - label = gtk_label_new(_("Spacing")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++; + col = 2; + label = gtk_label_new(_("Spacing")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - panel_spacing = gtk_spin_button_new_with_range(0, 500, 1); - gtk_widget_show(panel_spacing); - gtk_table_attach(GTK_TABLE(table), panel_spacing, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, panel_spacing, _("Specifies the spacing between elements inside the panel."), NULL); + panel_spacing = gtk_spin_button_new_with_range(0, 500, 1); + gtk_widget_show(panel_spacing); + gtk_table_attach(GTK_TABLE(table), panel_spacing, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, panel_spacing, _("Specifies the spacing between elements inside the panel."), NULL); - row++; - col = 2; - label = gtk_label_new(_("Ignore compositor")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++; + col = 2; + label = gtk_label_new(_("Ignore compositor")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - disable_transparency = gtk_check_button_new(); - gtk_widget_show(disable_transparency); - gtk_table_attach(GTK_TABLE(table), disable_transparency, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, disable_transparency, _("If enabled, the compositor will not be used to draw a transparent panel. " - "May fix display corruption problems on broken graphics stacks."), NULL); + disable_transparency = gtk_check_button_new(); + gtk_widget_show(disable_transparency); + gtk_table_attach(GTK_TABLE(table), disable_transparency, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + disable_transparency, + _("If enabled, the compositor will not be used to draw a transparent panel. " + "May fix display corruption problems on broken graphics stacks."), + NULL); - row++, col = 2; - label = gtk_label_new(_("Font shadows")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Font shadows")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - font_shadow = gtk_check_button_new(); - gtk_widget_show(font_shadow); - gtk_table_attach(GTK_TABLE(table), font_shadow, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, font_shadow, _("If enabled, a shadow will be drawn behind text. " - "This may improve legibility on transparent panels."), NULL); + font_shadow = gtk_check_button_new(); + gtk_widget_show(font_shadow); + gtk_table_attach(GTK_TABLE(table), font_shadow, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + font_shadow, + _("If enabled, a shadow will be drawn behind text. " + "This may improve legibility on transparent panels."), + NULL); - row++; - col = 2; - label = gtk_label_new(_("Mouse effects")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++; + col = 2; + label = gtk_label_new(_("Mouse effects")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - panel_mouse_effects = gtk_check_button_new(); - gtk_widget_show(panel_mouse_effects); - gtk_table_attach(GTK_TABLE(table), panel_mouse_effects, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, panel_mouse_effects, _("Clickable interface items change appearance when the mouse is moved over them."), NULL); + panel_mouse_effects = gtk_check_button_new(); + gtk_widget_show(panel_mouse_effects); + gtk_table_attach(GTK_TABLE(table), panel_mouse_effects, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + panel_mouse_effects, + _("Clickable interface items change appearance when the mouse is moved over them."), + NULL); - row++; - col = 2; - label = gtk_label_new(_("Icon opacity (hovered)")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++; + col = 2; + label = gtk_label_new(_("Icon opacity (hovered)")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - mouse_hover_icon_opacity = gtk_spin_button_new_with_range(0, 100, 1); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(mouse_hover_icon_opacity), 100); - gtk_widget_show(mouse_hover_icon_opacity); - gtk_table_attach(GTK_TABLE(table), mouse_hover_icon_opacity, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, mouse_hover_icon_opacity, _("Specifies the opacity adjustment of the icons under the mouse, in percent."), NULL); + mouse_hover_icon_opacity = gtk_spin_button_new_with_range(0, 100, 1); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(mouse_hover_icon_opacity), 100); + gtk_widget_show(mouse_hover_icon_opacity); + gtk_table_attach(GTK_TABLE(table), mouse_hover_icon_opacity, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + mouse_hover_icon_opacity, + _("Specifies the opacity adjustment of the icons under the mouse, in percent."), + NULL); - row++; - col = 2; - label = gtk_label_new(_("Icon saturation (hovered)")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++; + col = 2; + label = gtk_label_new(_("Icon saturation (hovered)")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - mouse_hover_icon_saturation = gtk_spin_button_new_with_range(-100, 100, 1); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(mouse_hover_icon_saturation), 0); - gtk_widget_show(mouse_hover_icon_saturation); - gtk_table_attach(GTK_TABLE(table), mouse_hover_icon_saturation, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, mouse_hover_icon_saturation, _("Specifies the saturation adjustment of the icons under the mouse, in percent."), NULL); + mouse_hover_icon_saturation = gtk_spin_button_new_with_range(-100, 100, 1); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(mouse_hover_icon_saturation), 0); + gtk_widget_show(mouse_hover_icon_saturation); + gtk_table_attach(GTK_TABLE(table), mouse_hover_icon_saturation, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + mouse_hover_icon_saturation, + _("Specifies the saturation adjustment of the icons under the mouse, in percent."), + NULL); - row++; - col = 2; - label = gtk_label_new(_("Icon brightness (hovered)")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++; + col = 2; + label = gtk_label_new(_("Icon brightness (hovered)")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - mouse_hover_icon_brightness = gtk_spin_button_new_with_range(-100, 100, 1); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(mouse_hover_icon_brightness), 10); - gtk_widget_show(mouse_hover_icon_brightness); - gtk_table_attach(GTK_TABLE(table), mouse_hover_icon_brightness, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, mouse_hover_icon_brightness, _("Specifies the brightness adjustment of the icons under the mouse, in percent."), NULL); + mouse_hover_icon_brightness = gtk_spin_button_new_with_range(-100, 100, 1); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(mouse_hover_icon_brightness), 10); + gtk_widget_show(mouse_hover_icon_brightness); + gtk_table_attach(GTK_TABLE(table), mouse_hover_icon_brightness, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + mouse_hover_icon_brightness, + _("Specifies the brightness adjustment of the icons under the mouse, in percent."), + NULL); - row++; - col = 2; - label = gtk_label_new(_("Icon opacity (pressed)")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++; + col = 2; + label = gtk_label_new(_("Icon opacity (pressed)")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - mouse_pressed_icon_opacity = gtk_spin_button_new_with_range(0, 100, 1); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(mouse_pressed_icon_opacity), 100); - gtk_widget_show(mouse_pressed_icon_opacity); - gtk_table_attach(GTK_TABLE(table), mouse_pressed_icon_opacity, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, mouse_pressed_icon_opacity, _("Specifies the opacity adjustment of the icons on mouse button press, in percent."), NULL); + mouse_pressed_icon_opacity = gtk_spin_button_new_with_range(0, 100, 1); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(mouse_pressed_icon_opacity), 100); + gtk_widget_show(mouse_pressed_icon_opacity); + gtk_table_attach(GTK_TABLE(table), mouse_pressed_icon_opacity, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + mouse_pressed_icon_opacity, + _("Specifies the opacity adjustment of the icons on mouse button press, in percent."), + NULL); - row++; - col = 2; - label = gtk_label_new(_("Icon saturation (pressed)")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++; + col = 2; + label = gtk_label_new(_("Icon saturation (pressed)")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - mouse_pressed_icon_saturation = gtk_spin_button_new_with_range(-100, 100, 1); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(mouse_pressed_icon_saturation), 0); - gtk_widget_show(mouse_pressed_icon_saturation); - gtk_table_attach(GTK_TABLE(table), mouse_pressed_icon_saturation, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, mouse_pressed_icon_saturation, _("Specifies the saturation adjustment of the icons on mouse button press, in percent."), NULL); + mouse_pressed_icon_saturation = gtk_spin_button_new_with_range(-100, 100, 1); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(mouse_pressed_icon_saturation), 0); + gtk_widget_show(mouse_pressed_icon_saturation); + gtk_table_attach(GTK_TABLE(table), mouse_pressed_icon_saturation, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + mouse_pressed_icon_saturation, + _("Specifies the saturation adjustment of the icons on mouse button press, in percent."), + NULL); - row++; - col = 2; - label = gtk_label_new(_("Icon brightness (pressed)")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++; + col = 2; + label = gtk_label_new(_("Icon brightness (pressed)")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - mouse_pressed_icon_brightness = gtk_spin_button_new_with_range(-100, 100, 1); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(mouse_pressed_icon_brightness), 0); - gtk_widget_show(mouse_pressed_icon_brightness); - gtk_table_attach(GTK_TABLE(table), mouse_pressed_icon_brightness, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, mouse_pressed_icon_brightness, _("Specifies the brightness adjustment of the icons on mouse button press, in percent."), NULL); + mouse_pressed_icon_brightness = gtk_spin_button_new_with_range(-100, 100, 1); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(mouse_pressed_icon_brightness), 0); + gtk_widget_show(mouse_pressed_icon_brightness); + gtk_table_attach(GTK_TABLE(table), mouse_pressed_icon_brightness, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + mouse_pressed_icon_brightness, + _("Specifies the brightness adjustment of the icons on mouse button press, in percent."), + NULL); - change_paragraph(parent); + change_paragraph(parent); - label = gtk_label_new(_("<b>Autohide</b>")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_label_set_use_markup(GTK_LABEL(label), TRUE); - gtk_widget_show(label); - gtk_box_pack_start(GTK_BOX(parent), label, FALSE, FALSE, 0); + label = gtk_label_new(_("<b>Autohide</b>")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_label_set_use_markup(GTK_LABEL(label), TRUE); + gtk_widget_show(label); + gtk_box_pack_start(GTK_BOX(parent), label, FALSE, FALSE, 0); - table = gtk_table_new(2, 10, FALSE); - gtk_widget_show(table); - gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); - gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); - gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); + table = gtk_table_new(2, 10, FALSE); + gtk_widget_show(table); + gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); + gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); + gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); - row = 0; - col = 2; - label = gtk_label_new(_("Autohide")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row = 0; + col = 2; + label = gtk_label_new(_("Autohide")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - panel_autohide = gtk_check_button_new(); - gtk_widget_show(panel_autohide); - gtk_table_attach(GTK_TABLE(table), panel_autohide, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, panel_autohide, _("If enabled, the panel is hidden when the mouse cursor leaves the panel."), NULL); + panel_autohide = gtk_check_button_new(); + gtk_widget_show(panel_autohide); + gtk_table_attach(GTK_TABLE(table), panel_autohide, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + panel_autohide, + _("If enabled, the panel is hidden when the mouse cursor leaves the panel."), + NULL); - row++; - col = 2; - label = gtk_label_new(_("Show panel after")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++; + col = 2; + label = gtk_label_new(_("Show panel after")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - panel_autohide_show_time = gtk_spin_button_new_with_range(0, 10000, 0.1); - gtk_widget_show(panel_autohide_show_time); - gtk_table_attach(GTK_TABLE(table), panel_autohide_show_time, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, panel_autohide_show_time, _("Specifies a delay after which the panel is shown when the mouse cursor enters the panel."), NULL); + panel_autohide_show_time = gtk_spin_button_new_with_range(0, 10000, 0.1); + gtk_widget_show(panel_autohide_show_time); + gtk_table_attach(GTK_TABLE(table), panel_autohide_show_time, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + panel_autohide_show_time, + _("Specifies a delay after which the panel is shown when the mouse cursor enters the panel."), + NULL); - label = gtk_label_new(_("seconds")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + label = gtk_label_new(_("seconds")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - row++; - col = 2; - label = gtk_label_new(_("Hidden size")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++; + col = 2; + label = gtk_label_new(_("Hidden size")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - panel_autohide_size = gtk_spin_button_new_with_range(1, 500, 1); - gtk_widget_show(panel_autohide_size); - gtk_table_attach(GTK_TABLE(table), panel_autohide_size, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, panel_autohide_size, _("Specifies the size of the panel when hidden, in pixels."), NULL); + panel_autohide_size = gtk_spin_button_new_with_range(1, 500, 1); + gtk_widget_show(panel_autohide_size); + gtk_table_attach(GTK_TABLE(table), panel_autohide_size, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + panel_autohide_size, + _("Specifies the size of the panel when hidden, in pixels."), + NULL); - row++; - col = 2; - label = gtk_label_new(_("Hide panel after")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++; + col = 2; + label = gtk_label_new(_("Hide panel after")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - panel_autohide_hide_time = gtk_spin_button_new_with_range(0, 10000, 0.1); - gtk_widget_show(panel_autohide_hide_time); - gtk_table_attach(GTK_TABLE(table), panel_autohide_hide_time, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, panel_autohide_hide_time, _("Specifies a delay after which the panel is hidden when the mouse cursor leaves the panel."), NULL); + panel_autohide_hide_time = gtk_spin_button_new_with_range(0, 10000, 0.1); + gtk_widget_show(panel_autohide_hide_time); + gtk_table_attach(GTK_TABLE(table), panel_autohide_hide_time, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + panel_autohide_hide_time, + _("Specifies a delay after which the panel is hidden when the mouse cursor leaves the panel."), + NULL); - label = gtk_label_new(_("seconds")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + label = gtk_label_new(_("seconds")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - change_paragraph(parent); + change_paragraph(parent); - label = gtk_label_new(_("<b>Window manager interaction</b>")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_label_set_use_markup(GTK_LABEL(label), TRUE); - gtk_widget_show(label); - gtk_box_pack_start(GTK_BOX(parent), label, FALSE, FALSE, 0); + label = gtk_label_new(_("<b>Window manager interaction</b>")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_label_set_use_markup(GTK_LABEL(label), TRUE); + gtk_widget_show(label); + gtk_box_pack_start(GTK_BOX(parent), label, FALSE, FALSE, 0); - table = gtk_table_new(2, 12, FALSE); - gtk_widget_show(table); - gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); - gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); - gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); + table = gtk_table_new(2, 12, FALSE); + gtk_widget_show(table); + gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); + gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); + gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); - row = 0; - col = 2; - label = gtk_label_new(_("Forward mouse events")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row = 0; + col = 2; + label = gtk_label_new(_("Forward mouse events")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - panel_wm_menu = gtk_check_button_new(); - gtk_widget_show(panel_wm_menu); - gtk_table_attach(GTK_TABLE(table), panel_wm_menu, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, panel_wm_menu, _("If enabled, mouse events not handled by panel elements are forwarded to the desktop. " - "Useful on desktop environments that show a start menu when right clicking the desktop, " - "or switch the desktop when rotating the mouse wheel over the desktop."), NULL); + panel_wm_menu = gtk_check_button_new(); + gtk_widget_show(panel_wm_menu); + gtk_table_attach(GTK_TABLE(table), panel_wm_menu, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + panel_wm_menu, + _("If enabled, mouse events not handled by panel elements are forwarded to the desktop. " + "Useful on desktop environments that show a start menu when right clicking the desktop, " + "or switch the desktop when rotating the mouse wheel over the desktop."), + NULL); - row++; - col = 2; - label = gtk_label_new(_("Place panel in dock")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++; + col = 2; + label = gtk_label_new(_("Place panel in dock")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - panel_dock = gtk_check_button_new(); - gtk_widget_show(panel_dock); - gtk_table_attach(GTK_TABLE(table), panel_dock, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, panel_dock, _("If enabled, places the panel in the dock area of the window manager. " - "Windows placed in the dock are usually treated differently than normal windows. " - "The exact behavior depends on the window manager and its configuration."), NULL); + panel_dock = gtk_check_button_new(); + gtk_widget_show(panel_dock); + gtk_table_attach(GTK_TABLE(table), panel_dock, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + panel_dock, + _("If enabled, places the panel in the dock area of the window manager. " + "Windows placed in the dock are usually treated differently than normal windows. " + "The exact behavior depends on the window manager and its configuration."), + NULL); - row++; - col = 2; - label = gtk_label_new(_("Panel layer")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++; + col = 2; + label = gtk_label_new(_("Panel layer")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - panel_combo_layer = gtk_combo_box_new_text(); - gtk_widget_show(panel_combo_layer); - gtk_table_attach(GTK_TABLE(table), panel_combo_layer, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_combo_box_append_text(GTK_COMBO_BOX(panel_combo_layer), _("Top")); - gtk_combo_box_append_text(GTK_COMBO_BOX(panel_combo_layer), _("Normal")); - gtk_combo_box_append_text(GTK_COMBO_BOX(panel_combo_layer), _("Bottom")); - gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_layer), 1); - gtk_tooltips_set_tip(tooltips, panel_combo_layer, _("Specifies the layer on which the panel window should be placed. \n" - "Top means the panel should always cover other windows. \n" - "Bottom means other windows should always cover the panel. \n" - "Normal means that other windows may or may not cover the panel, depending on which has focus. \n" - "Note that some window managers prevent this option from working correctly if the panel is placed in the dock."), NULL); + panel_combo_layer = gtk_combo_box_new_text(); + gtk_widget_show(panel_combo_layer); + gtk_table_attach(GTK_TABLE(table), panel_combo_layer, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_combo_box_append_text(GTK_COMBO_BOX(panel_combo_layer), _("Top")); + gtk_combo_box_append_text(GTK_COMBO_BOX(panel_combo_layer), _("Normal")); + gtk_combo_box_append_text(GTK_COMBO_BOX(panel_combo_layer), _("Bottom")); + gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_layer), 1); + gtk_tooltips_set_tip(tooltips, + panel_combo_layer, + _("Specifies the layer on which the panel window should be placed. \n" + "Top means the panel should always cover other windows. \n" + "Bottom means other windows should always cover the panel. \n" + "Normal means that other windows may or may not cover the panel, depending on which has " + "focus. \n" + "Note that some window managers prevent this option from working correctly if the panel is " + "placed in the dock."), + NULL); - row++; - col = 2; - label = gtk_label_new(_("Maximized windows")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++; + col = 2; + label = gtk_label_new(_("Maximized windows")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - panel_combo_strut_policy = gtk_combo_box_new_text(); - gtk_widget_show(panel_combo_strut_policy); - gtk_table_attach(GTK_TABLE(table), panel_combo_strut_policy, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_combo_box_append_text(GTK_COMBO_BOX(panel_combo_strut_policy), _("Match the panel size")); - gtk_combo_box_append_text(GTK_COMBO_BOX(panel_combo_strut_policy), _("Match the hidden panel size")); - gtk_combo_box_append_text(GTK_COMBO_BOX(panel_combo_strut_policy), _("Fill the screen")); - gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_strut_policy), 0); - gtk_tooltips_set_tip(tooltips, panel_combo_strut_policy, _("Specifies the size of maximized windows. \n" - "Match the panel size means that maximized windows should extend to the edge of the panel. \n" - "Match the hidden panel size means that maximized windows should extend to the edge of the panel when hidden; " - "when visible, the panel and the windows will overlap. \n" - "Fill the screen means that maximized windows will always have the same size as the screen. \n" - "\n" - "Note: on multi-monitor (Xinerama) setups, the panel must be placed at the edge (not in the middle) " - "of the virtual screen for this to work correctly."), NULL); + panel_combo_strut_policy = gtk_combo_box_new_text(); + gtk_widget_show(panel_combo_strut_policy); + gtk_table_attach(GTK_TABLE(table), panel_combo_strut_policy, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_combo_box_append_text(GTK_COMBO_BOX(panel_combo_strut_policy), _("Match the panel size")); + gtk_combo_box_append_text(GTK_COMBO_BOX(panel_combo_strut_policy), _("Match the hidden panel size")); + gtk_combo_box_append_text(GTK_COMBO_BOX(panel_combo_strut_policy), _("Fill the screen")); + gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_strut_policy), 0); + gtk_tooltips_set_tip(tooltips, + panel_combo_strut_policy, + _("Specifies the size of maximized windows. \n" + "Match the panel size means that maximized windows should extend to the edge of the panel. " + "\n" + "Match the hidden panel size means that maximized windows should extend to the edge of the " + "panel when hidden; " + "when visible, the panel and the windows will overlap. \n" + "Fill the screen means that maximized windows will always have the same size as the screen. " + "\n" + "\n" + "Note: on multi-monitor (Xinerama) setups, the panel must be placed at the edge (not in the " + "middle) " + "of the virtual screen for this to work correctly."), + NULL); - row++; - col = 2; - label = gtk_label_new(_("Window name")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++; + col = 2; + label = gtk_label_new(_("Window name")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - panel_window_name = gtk_entry_new(); - gtk_widget_show(panel_window_name); - gtk_entry_set_width_chars(GTK_ENTRY(panel_window_name), 28); - gtk_entry_set_text(GTK_ENTRY(panel_window_name), "tint2"); - gtk_table_attach(GTK_TABLE(table), panel_window_name, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, panel_window_name, _("Specifies the name of the panel window. " - "This is useful if you want to configure special treatment of tint2 windows in your " - "window manager or compositor."), NULL); + panel_window_name = gtk_entry_new(); + gtk_widget_show(panel_window_name); + gtk_entry_set_width_chars(GTK_ENTRY(panel_window_name), 28); + gtk_entry_set_text(GTK_ENTRY(panel_window_name), "tint2"); + gtk_table_attach(GTK_TABLE(table), panel_window_name, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + panel_window_name, + _("Specifies the name of the panel window. " + "This is useful if you want to configure special treatment of tint2 windows in your " + "window manager or compositor."), + NULL); - change_paragraph(parent); + change_paragraph(parent); } void create_panel_items(GtkWidget *parent) { - GtkWidget *table, *label, *button, *image; - GtkTooltips *tooltips = gtk_tooltips_new(); + GtkWidget *table, *label, *button, *image; + GtkTooltips *tooltips = gtk_tooltips_new(); - panel_items = gtk_list_store_new(itemsNumCols, G_TYPE_STRING, G_TYPE_STRING); - all_items = gtk_list_store_new(itemsNumCols, G_TYPE_STRING, G_TYPE_STRING); + panel_items = gtk_list_store_new(itemsNumCols, G_TYPE_STRING, G_TYPE_STRING); + all_items = gtk_list_store_new(itemsNumCols, G_TYPE_STRING, G_TYPE_STRING); - GtkTreeIter iter; - gtk_list_store_append(all_items, &iter); - gtk_list_store_set(all_items, &iter, - itemsColName, _("Battery"), - itemsColValue, "B", - -1); - gtk_list_store_append(all_items, &iter); - gtk_list_store_set(all_items, &iter, - itemsColName, _("Clock"), - itemsColValue, "C", - -1); - gtk_list_store_append(all_items, &iter); - gtk_list_store_set(all_items, &iter, - itemsColName, _("System tray"), - itemsColValue, "S", - -1); - gtk_list_store_append(all_items, &iter); - gtk_list_store_set(all_items, &iter, - itemsColName, _("Taskbar"), - itemsColValue, "T", - -1); - gtk_list_store_append(all_items, &iter); - gtk_list_store_set(all_items, &iter, - itemsColName, _("Launcher"), - itemsColValue, "L", - -1); - gtk_list_store_append(all_items, &iter); - gtk_list_store_set(all_items, &iter, - itemsColName, _("Free space"), - itemsColValue, "F", - -1); - gtk_list_store_append(all_items, &iter); - gtk_list_store_set(all_items, &iter, - itemsColName, _("Separator"), - itemsColValue, ":", - -1); - gtk_list_store_append(all_items, &iter); - gtk_list_store_set(all_items, &iter, - itemsColName, _("Executor"), - itemsColValue, "E", - -1); - gtk_list_store_append(all_items, &iter); - gtk_list_store_set(all_items, &iter, - itemsColName, _("Button"), - itemsColValue, "P", - -1); + GtkTreeIter iter; + gtk_list_store_append(all_items, &iter); + gtk_list_store_set(all_items, &iter, itemsColName, _("Battery"), itemsColValue, "B", -1); + gtk_list_store_append(all_items, &iter); + gtk_list_store_set(all_items, &iter, itemsColName, _("Clock"), itemsColValue, "C", -1); + gtk_list_store_append(all_items, &iter); + gtk_list_store_set(all_items, &iter, itemsColName, _("System tray"), itemsColValue, "S", -1); + gtk_list_store_append(all_items, &iter); + gtk_list_store_set(all_items, &iter, itemsColName, _("Taskbar"), itemsColValue, "T", -1); + gtk_list_store_append(all_items, &iter); + gtk_list_store_set(all_items, &iter, itemsColName, _("Launcher"), itemsColValue, "L", -1); + gtk_list_store_append(all_items, &iter); + gtk_list_store_set(all_items, &iter, itemsColName, _("Free space"), itemsColValue, "F", -1); + gtk_list_store_append(all_items, &iter); + gtk_list_store_set(all_items, &iter, itemsColName, _("Separator"), itemsColValue, ":", -1); + gtk_list_store_append(all_items, &iter); + gtk_list_store_set(all_items, &iter, itemsColName, _("Executor"), itemsColValue, "E", -1); + gtk_list_store_append(all_items, &iter); + gtk_list_store_set(all_items, &iter, itemsColName, _("Button"), itemsColValue, "P", -1); - panel_items_view = gtk_tree_view_new(); - gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(panel_items_view), - -1, - "", - gtk_cell_renderer_text_new(), - "text", itemsColName, - NULL); - gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(panel_items_view), FALSE); - gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(panel_items_view)), GTK_SELECTION_SINGLE); - gtk_tree_view_set_model(GTK_TREE_VIEW(panel_items_view), GTK_TREE_MODEL(panel_items)); - g_object_unref(panel_items); - gtk_tooltips_set_tip(tooltips, panel_items_view, _("Specifies the elements that will appear in the panel and their order. " - "Elements can be added by selecting them in the list of available elements, then clicking on " - "the add left button."), NULL); + panel_items_view = gtk_tree_view_new(); + gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(panel_items_view), + -1, + "", + gtk_cell_renderer_text_new(), + "text", + itemsColName, + NULL); + gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(panel_items_view), FALSE); + gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(panel_items_view)), GTK_SELECTION_SINGLE); + gtk_tree_view_set_model(GTK_TREE_VIEW(panel_items_view), GTK_TREE_MODEL(panel_items)); + g_object_unref(panel_items); + gtk_tooltips_set_tip(tooltips, + panel_items_view, + _("Specifies the elements that will appear in the panel and their order. " + "Elements can be added by selecting them in the list of available elements, then clicking " + "on " + "the add left button."), + NULL); + all_items_view = gtk_tree_view_new(); + gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(all_items_view), + -1, + "", + gtk_cell_renderer_text_new(), + "text", + itemsColName, + NULL); + gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(all_items_view), FALSE); + gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(all_items_view)), GTK_SELECTION_SINGLE); + gtk_tree_view_set_model(GTK_TREE_VIEW(all_items_view), GTK_TREE_MODEL(all_items)); + g_object_unref(all_items); + gtk_tooltips_set_tip(tooltips, + all_items_view, + _("Lists all the possible elements that can appear in the panel. " + "Elements can be added to the panel by selecting them, then clicking on " + "the add left button."), + NULL); - all_items_view = gtk_tree_view_new(); - gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(all_items_view), - -1, - "", - gtk_cell_renderer_text_new(), - "text", itemsColName, - NULL); - gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(all_items_view), FALSE); - gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(all_items_view)), GTK_SELECTION_SINGLE); - gtk_tree_view_set_model(GTK_TREE_VIEW(all_items_view), GTK_TREE_MODEL(all_items)); - g_object_unref(all_items); - gtk_tooltips_set_tip(tooltips, all_items_view, _("Lists all the possible elements that can appear in the panel. " - "Elements can be added to the panel by selecting them, then clicking on " - "the add left button."), NULL); + table = gtk_table_new(2, 3, FALSE); + gtk_widget_show(table); + gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); + gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); + gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); - table = gtk_table_new(2, 3, FALSE); - gtk_widget_show(table); - gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); - gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); - gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); + label = gtk_label_new(_("<b>Elements selected</b>")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_label_set_use_markup(GTK_LABEL(label), TRUE); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, GTK_FILL, 0, 0, 0); - label = gtk_label_new(_("<b>Elements selected</b>")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_label_set_use_markup(GTK_LABEL(label), TRUE); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, GTK_FILL, 0, 0, 0); + label = gtk_label_new(_("<b>Elements available</b>")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_label_set_use_markup(GTK_LABEL(label), TRUE); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, 2, 3, 0, 1, GTK_FILL, 0, 0, 0); - label = gtk_label_new(_("<b>Elements available</b>")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_label_set_use_markup(GTK_LABEL(label), TRUE); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, 2, 3, 0, 1, GTK_FILL, 0, 0, 0); + GtkWidget *vbox; + vbox = gtk_vbox_new(FALSE, 0); + gtk_widget_show(vbox); + gtk_container_set_border_width(GTK_CONTAINER(vbox), 0); - GtkWidget *vbox; - vbox = gtk_vbox_new(FALSE, 0); - gtk_widget_show(vbox); - gtk_container_set_border_width(GTK_CONTAINER(vbox), 0); + button = gtk_button_new(); + image = gtk_image_new_from_stock(GTK_STOCK_GO_UP, GTK_ICON_SIZE_BUTTON); + gtk_button_set_image(GTK_BUTTON(button), image); + gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(panel_move_item_up), NULL); + gtk_widget_show(button); + gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0); + gtk_tooltips_set_tip(tooltips, button, _("Moves up the current element in the list of selected elements."), NULL); - button = gtk_button_new(); - image = gtk_image_new_from_stock(GTK_STOCK_GO_UP, GTK_ICON_SIZE_BUTTON); - gtk_button_set_image(GTK_BUTTON(button), image); - gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(panel_move_item_up), NULL); - gtk_widget_show(button); - gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0); - gtk_tooltips_set_tip(tooltips, button, _("Moves up the current element in the list of selected elements."), NULL); + button = gtk_button_new(); + image = gtk_image_new_from_stock(GTK_STOCK_GO_DOWN, GTK_ICON_SIZE_BUTTON); + gtk_button_set_image(GTK_BUTTON(button), image); + gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(panel_move_item_down), NULL); + gtk_widget_show(button); + gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0); + gtk_tooltips_set_tip(tooltips, button, _("Moves down the current element in the list of selected elements."), NULL); - button = gtk_button_new(); - image = gtk_image_new_from_stock(GTK_STOCK_GO_DOWN, GTK_ICON_SIZE_BUTTON); - gtk_button_set_image(GTK_BUTTON(button), image); - gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(panel_move_item_down), NULL); - gtk_widget_show(button); - gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0); - gtk_tooltips_set_tip(tooltips, button, _("Moves down the current element in the list of selected elements."), NULL); + label = gtk_label_new(_(" ")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); - label = gtk_label_new(_(" ")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); + button = gtk_button_new(); + image = gtk_image_new_from_stock(GTK_STOCK_GO_BACK, GTK_ICON_SIZE_BUTTON); + gtk_button_set_image(GTK_BUTTON(button), image); + gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(panel_add_item), NULL); + gtk_widget_show(button); + gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0); + gtk_tooltips_set_tip(tooltips, + button, + _("Copies the current element in the list of available elements to the list of selected " + "elements."), + NULL); - button = gtk_button_new(); - image = gtk_image_new_from_stock(GTK_STOCK_GO_BACK, GTK_ICON_SIZE_BUTTON); - gtk_button_set_image(GTK_BUTTON(button), image); - gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(panel_add_item), NULL); - gtk_widget_show(button); - gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0); - gtk_tooltips_set_tip(tooltips, button, _("Copies the current element in the list of available elements to the list of selected elements."), NULL); + button = gtk_button_new(); + image = gtk_image_new_from_stock(GTK_STOCK_GO_FORWARD, GTK_ICON_SIZE_BUTTON); + gtk_button_set_image(GTK_BUTTON(button), image); + gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(panel_remove_item), NULL); + gtk_widget_show(button); + gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0); + gtk_tooltips_set_tip(tooltips, button, _("Removes the current element from the list of selected elements."), NULL); - button = gtk_button_new(); - image = gtk_image_new_from_stock(GTK_STOCK_GO_FORWARD, GTK_ICON_SIZE_BUTTON); - gtk_button_set_image(GTK_BUTTON(button), image); - gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(panel_remove_item), NULL); - gtk_widget_show(button); - gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0); - gtk_tooltips_set_tip(tooltips, button, _("Removes the current element from the list of selected elements."), NULL); + gtk_table_attach(GTK_TABLE(table), vbox, 1, 2, 1, 2, GTK_FILL, GTK_FILL, 0, 0); - gtk_table_attach(GTK_TABLE(table), vbox, 1, 2, 1, 2, GTK_FILL, GTK_FILL, 0, 0); - - gtk_widget_show(panel_items_view); - gtk_table_attach(GTK_TABLE(table), addScrollBarToWidget(panel_items_view), 0, 1, 1, 2, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); + gtk_widget_show(panel_items_view); + gtk_table_attach(GTK_TABLE(table), + addScrollBarToWidget(panel_items_view), + 0, + 1, + 1, + 2, + GTK_FILL | GTK_EXPAND, + GTK_FILL, + 0, + 0); - gtk_widget_show(all_items_view); - gtk_table_attach(GTK_TABLE(table), addScrollBarToWidget(all_items_view), 2, 3, 1, 2, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); + gtk_widget_show(all_items_view); + gtk_table_attach(GTK_TABLE(table), + addScrollBarToWidget(all_items_view), + 2, + 3, + 1, + 2, + GTK_FILL | GTK_EXPAND, + GTK_FILL, + 0, + 0); - change_paragraph(parent); + change_paragraph(parent); } gboolean panel_contains(const char *value) { - GtkTreeModel *model = GTK_TREE_MODEL(panel_items); + GtkTreeModel *model = GTK_TREE_MODEL(panel_items); - GtkTreeIter i; - if (!gtk_tree_model_get_iter_first(model, &i)) { - return FALSE; - } + GtkTreeIter i; + if (!gtk_tree_model_get_iter_first(model, &i)) { + return FALSE; + } - while (1) { - gchar *v; - gtk_tree_model_get(model, &i, - itemsColValue, &v, - -1); - if (g_str_equal(value, v)) { - return TRUE; - } + while (1) { + gchar *v; + gtk_tree_model_get(model, &i, itemsColValue, &v, -1); + if (g_str_equal(value, v)) { + return TRUE; + } - if (!gtk_tree_model_iter_next(model, &i)) { - break; - } - } + if (!gtk_tree_model_iter_next(model, &i)) { + break; + } + } - return FALSE; + return FALSE; } char *get_panel_items() { - char *result = calloc(1, 256 * sizeof(char)); - GtkTreeModel *model = GTK_TREE_MODEL(panel_items); + char *result = calloc(1, 256 * sizeof(char)); + GtkTreeModel *model = GTK_TREE_MODEL(panel_items); - GtkTreeIter i; - if (!gtk_tree_model_get_iter_first(model, &i)) { - return FALSE; - } + GtkTreeIter i; + if (!gtk_tree_model_get_iter_first(model, &i)) { + return FALSE; + } - while (1) { - gchar *v; - gtk_tree_model_get(model, &i, - itemsColValue, &v, - -1); - strcat(result, v); + while (1) { + gchar *v; + gtk_tree_model_get(model, &i, itemsColValue, &v, -1); + strcat(result, v); - if (!gtk_tree_model_iter_next(model, &i)) { - break; - } - } + if (!gtk_tree_model_iter_next(model, &i)) { + break; + } + } - return result; + return result; } void set_panel_items(const char *items) { - gtk_list_store_clear(panel_items); + gtk_list_store_clear(panel_items); - int separator_index = -1; - int execp_index = -1; - int button_index = -1; + int separator_index = -1; + int execp_index = -1; + int button_index = -1; - for (; items && *items; items++) { - const char *value = NULL; - const char *name = NULL; - char buffer[256]; + for (; items && *items; items++) { + const char *value = NULL; + const char *name = NULL; + char buffer[256]; - char v = *items; - if (v == 'B') { - value = "B"; - name = _("Battery"); - } else if (v == 'C') { - value = "C"; - name = _("Clock"); - } else if (v == 'S') { - value = "S"; - name = _("System tray"); - } else if (v == 'T') { - value = "T"; - name = _("Taskbar"); - } else if (v == 'L') { - value = "L"; - name = _("Launcher"); - } else if (v == 'F') { - value = "F"; - name = _("Free space"); - } else if (v == ':') { - separator_index++; - buffer[0] = 0; - sprintf(buffer, "%s %d", _("Separator"), separator_index + 1); - name = buffer; - value = ":"; - } else if (v == 'E') { - execp_index++; - buffer[0] = 0; - sprintf(buffer, "%s %d", _("Executor"), execp_index + 1); - name = buffer; - value = "E"; - } else if (v == 'P') { - button_index++; - buffer[0] = 0; - sprintf(buffer, "%s %d", _("Button"), button_index + 1); - name = buffer; - value = "P"; - } else { - continue; - } + char v = *items; + if (v == 'B') { + value = "B"; + name = _("Battery"); + } else if (v == 'C') { + value = "C"; + name = _("Clock"); + } else if (v == 'S') { + value = "S"; + name = _("System tray"); + } else if (v == 'T') { + value = "T"; + name = _("Taskbar"); + } else if (v == 'L') { + value = "L"; + name = _("Launcher"); + } else if (v == 'F') { + value = "F"; + name = _("Free space"); + } else if (v == ':') { + separator_index++; + buffer[0] = 0; + sprintf(buffer, "%s %d", _("Separator"), separator_index + 1); + name = buffer; + value = ":"; + } else if (v == 'E') { + execp_index++; + buffer[0] = 0; + sprintf(buffer, "%s %d", _("Executor"), execp_index + 1); + name = buffer; + value = "E"; + } else if (v == 'P') { + button_index++; + buffer[0] = 0; + sprintf(buffer, "%s %d", _("Button"), button_index + 1); + name = buffer; + value = "P"; + } else { + continue; + } - GtkTreeIter iter; - gtk_list_store_append(panel_items, &iter); - gtk_list_store_set(panel_items, &iter, - itemsColName, name, - itemsColValue, value, - -1); - } + GtkTreeIter iter; + gtk_list_store_append(panel_items, &iter); + gtk_list_store_set(panel_items, &iter, itemsColName, name, itemsColValue, value, -1); + } } void panel_add_item(GtkWidget *widget, gpointer data) { - GtkTreeIter iter; - GtkTreeModel *model; + GtkTreeIter iter; + GtkTreeModel *model; - if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(all_items_view)), &model, &iter)) { - gchar *name; - gchar *value; + if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(all_items_view)), &model, &iter)) { + gchar *name; + gchar *value; - gtk_tree_model_get(model, &iter, - itemsColName, &name, - itemsColValue, &value, - -1); + gtk_tree_model_get(model, &iter, itemsColName, &name, itemsColValue, &value, -1); - if (!panel_contains(value) || g_str_equal(value, ":") || g_str_equal(value, "E") || g_str_equal(value, "F") || g_str_equal(value, "P")) { - GtkTreeIter iter; - gtk_list_store_append(panel_items, &iter); - gtk_list_store_set(panel_items, &iter, - itemsColName, g_strdup(name), - itemsColValue, g_strdup(value), - -1); - if (g_str_equal(value, ":")) { - separator_create_new(); - } else if (g_str_equal(value, "E")) { - execp_create_new(); - } else if (g_str_equal(value, "P")) { - button_create_new(); - } - } - } - separator_update_indices(); - execp_update_indices(); - button_update_indices(); + if (!panel_contains(value) || g_str_equal(value, ":") || g_str_equal(value, "E") || g_str_equal(value, "F") || + g_str_equal(value, "P")) { + GtkTreeIter iter; + gtk_list_store_append(panel_items, &iter); + gtk_list_store_set(panel_items, &iter, itemsColName, g_strdup(name), itemsColValue, g_strdup(value), -1); + if (g_str_equal(value, ":")) { + separator_create_new(); + } else if (g_str_equal(value, "E")) { + execp_create_new(); + } else if (g_str_equal(value, "P")) { + button_create_new(); + } + } + } + separator_update_indices(); + execp_update_indices(); + button_update_indices(); } void panel_remove_item(GtkWidget *widget, gpointer data) { - GtkTreeIter iter; - GtkTreeModel *model; + GtkTreeIter iter; + GtkTreeModel *model; - if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(panel_items_view)), &model, &iter)) { - gchar *name; - gchar *value; + if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(panel_items_view)), &model, &iter)) { + gchar *name; + gchar *value; - gtk_tree_model_get(model, &iter, - itemsColName, &name, - itemsColValue, &value, - -1); + gtk_tree_model_get(model, &iter, itemsColName, &name, itemsColValue, &value, -1); - if (g_str_equal(value, ":")) { - for (int i = 0; i < separators->len; i++) { - Separator *separator = &g_array_index(separators, Separator, i); - if (g_str_equal(name, separator->name)) { - separator_remove(i); - break; - } - } - } else if (g_str_equal(value, "E")) { - for (int i = 0; i < executors->len; i++) { - Executor *executor = &g_array_index(executors, Executor, i); - if (g_str_equal(name, executor->name)) { - execp_remove(i); - break; - } - } - } else if (g_str_equal(value, "P")) { - for (int i = 0; i < buttons->len; i++) { - Button *button = &g_array_index(buttons, Button, i); - if (g_str_equal(name, button->name)) { - button_remove(i); - break; - } - } - } + if (g_str_equal(value, ":")) { + for (int i = 0; i < separators->len; i++) { + Separator *separator = &g_array_index(separators, Separator, i); + if (g_str_equal(name, separator->name)) { + separator_remove(i); + break; + } + } + } else if (g_str_equal(value, "E")) { + for (int i = 0; i < executors->len; i++) { + Executor *executor = &g_array_index(executors, Executor, i); + if (g_str_equal(name, executor->name)) { + execp_remove(i); + break; + } + } + } else if (g_str_equal(value, "P")) { + for (int i = 0; i < buttons->len; i++) { + Button *button = &g_array_index(buttons, Button, i); + if (g_str_equal(name, button->name)) { + button_remove(i); + break; + } + } + } - gtk_list_store_remove(panel_items, &iter); - } + gtk_list_store_remove(panel_items, &iter); + } - separator_update_indices(); - execp_update_indices(); - button_update_indices(); + separator_update_indices(); + execp_update_indices(); + button_update_indices(); } void panel_move_item_down(GtkWidget *widget, gpointer data) { - GtkTreeIter iter; - GtkTreeModel *model; + GtkTreeIter iter; + GtkTreeModel *model; - if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(panel_items_view)), &model, &iter)) { - GtkTreeIter next = iter; - if (gtk_tree_model_iter_next(model, &next)) { - gchar *name1; - gchar *value1; - gtk_tree_model_get(model, &iter, - itemsColName, &name1, - itemsColValue, &value1, - -1); - gchar *name2; - gchar *value2; - gtk_tree_model_get(model, &next, - itemsColName, &name2, - itemsColValue, &value2, - -1); + if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(panel_items_view)), &model, &iter)) { + GtkTreeIter next = iter; + if (gtk_tree_model_iter_next(model, &next)) { + gchar *name1; + gchar *value1; + gtk_tree_model_get(model, &iter, itemsColName, &name1, itemsColValue, &value1, -1); + gchar *name2; + gchar *value2; + gtk_tree_model_get(model, &next, itemsColName, &name2, itemsColValue, &value2, -1); - if (g_str_equal(value1, ":") && g_str_equal(value2, ":")) { - Separator *separator1 = NULL; - Separator *separator2 = NULL; - for (int i = 0; i < separators->len; i++) { - Separator *separator = &g_array_index(separators, Separator, i); - if (g_str_equal(name1, separator->name)) { - separator1 = separator; - } - if (g_str_equal(name2, separator->name)) { - separator2 = separator; - } - } - Separator tmp = *separator1; - *separator1 = *separator2; - *separator2 = tmp; - } else if (g_str_equal(value1, "E") && g_str_equal(value2, "E")) { - Executor *executor1 = NULL; - Executor *executor2 = NULL; - for (int i = 0; i < executors->len; i++) { - Executor *executor = &g_array_index(executors, Executor, i); - if (g_str_equal(name1, executor->name)) { - executor1 = executor; - } - if (g_str_equal(name2, executor->name)) { - executor2 = executor; - } - } - Executor tmp = *executor1; - *executor1 = *executor2; - *executor2 = tmp; - } else if (g_str_equal(value1, "P") && g_str_equal(value2, "P")) { - Button *button1 = NULL; - Button *button2 = NULL; - for (int i = 0; i < buttons->len; i++) { - Button *button = &g_array_index(buttons, Button, i); - if (g_str_equal(name1, button->name)) { - button1 = button; - } - if (g_str_equal(name2, button->name)) { - button2 = button; - } - } - Button tmp = *button1; - *button1 = *button2; - *button2 = tmp; - } + if (g_str_equal(value1, ":") && g_str_equal(value2, ":")) { + Separator *separator1 = NULL; + Separator *separator2 = NULL; + for (int i = 0; i < separators->len; i++) { + Separator *separator = &g_array_index(separators, Separator, i); + if (g_str_equal(name1, separator->name)) { + separator1 = separator; + } + if (g_str_equal(name2, separator->name)) { + separator2 = separator; + } + } + Separator tmp = *separator1; + *separator1 = *separator2; + *separator2 = tmp; + } else if (g_str_equal(value1, "E") && g_str_equal(value2, "E")) { + Executor *executor1 = NULL; + Executor *executor2 = NULL; + for (int i = 0; i < executors->len; i++) { + Executor *executor = &g_array_index(executors, Executor, i); + if (g_str_equal(name1, executor->name)) { + executor1 = executor; + } + if (g_str_equal(name2, executor->name)) { + executor2 = executor; + } + } + Executor tmp = *executor1; + *executor1 = *executor2; + *executor2 = tmp; + } else if (g_str_equal(value1, "P") && g_str_equal(value2, "P")) { + Button *button1 = NULL; + Button *button2 = NULL; + for (int i = 0; i < buttons->len; i++) { + Button *button = &g_array_index(buttons, Button, i); + if (g_str_equal(name1, button->name)) { + button1 = button; + } + if (g_str_equal(name2, button->name)) { + button2 = button; + } + } + Button tmp = *button1; + *button1 = *button2; + *button2 = tmp; + } - gtk_list_store_swap(panel_items, &iter, &next); - } - } - separator_update_indices(); - execp_update_indices(); - button_update_indices(); + gtk_list_store_swap(panel_items, &iter, &next); + } + } + separator_update_indices(); + execp_update_indices(); + button_update_indices(); } void panel_move_item_up(GtkWidget *widget, gpointer data) { - { - GtkTreeIter iter; - GtkTreeModel *model; + { + GtkTreeIter iter; + GtkTreeModel *model; - if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(panel_items_view)), &model, &iter)) { - GtkTreeIter prev = iter; - if (gtk_tree_model_iter_prev_tint2(model, &prev)) { - gchar *name1; - gchar *value1; - gtk_tree_model_get(model, &iter, - itemsColName, &name1, - itemsColValue, &value1, - -1); - gchar *name2; - gchar *value2; - gtk_tree_model_get(model, &prev, - itemsColName, &name2, - itemsColValue, &value2, - -1); + if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(panel_items_view)), + &model, + &iter)) { + GtkTreeIter prev = iter; + if (gtk_tree_model_iter_prev_tint2(model, &prev)) { + gchar *name1; + gchar *value1; + gtk_tree_model_get(model, &iter, itemsColName, &name1, itemsColValue, &value1, -1); + gchar *name2; + gchar *value2; + gtk_tree_model_get(model, &prev, itemsColName, &name2, itemsColValue, &value2, -1); - if (g_str_equal(value1, ":") && g_str_equal(value2, ":")) { - Separator *separator1 = NULL; - Separator *separator2 = NULL; - for (int i = 0; i < separators->len; i++) { - Separator *separator = &g_array_index(separators, Separator, i); - if (g_str_equal(name1, separator->name)) { - separator1 = separator; - } - if (g_str_equal(name2, separator->name)) { - separator2 = separator; - } - } - Separator tmp = *separator1; - *separator1 = *separator2; - *separator2 = tmp; - } else if (g_str_equal(value1, "E") && g_str_equal(value2, "E")) { - Executor *executor1 = NULL; - Executor *executor2 = NULL; - for (int i = 0; i < executors->len; i++) { - Executor *executor = &g_array_index(executors, Executor, i); - if (g_str_equal(name1, executor->name)) { - executor1 = executor; - } - if (g_str_equal(name2, executor->name)) { - executor2 = executor; - } - } - Executor tmp = *executor1; - *executor1 = *executor2; - *executor2 = tmp; - } else if (g_str_equal(value1, "P") && g_str_equal(value2, "P")) { - Button *button1 = NULL; - Button *button2 = NULL; - for (int i = 0; i < buttons->len; i++) { - Button *button = &g_array_index(buttons, Button, i); - if (g_str_equal(name1, button->name)) { - button1 = button; - } - if (g_str_equal(name2, button->name)) { - button2 = button; - } - } - Button tmp = *button1; - *button1 = *button2; - *button2 = tmp; - } + if (g_str_equal(value1, ":") && g_str_equal(value2, ":")) { + Separator *separator1 = NULL; + Separator *separator2 = NULL; + for (int i = 0; i < separators->len; i++) { + Separator *separator = &g_array_index(separators, Separator, i); + if (g_str_equal(name1, separator->name)) { + separator1 = separator; + } + if (g_str_equal(name2, separator->name)) { + separator2 = separator; + } + } + Separator tmp = *separator1; + *separator1 = *separator2; + *separator2 = tmp; + } else if (g_str_equal(value1, "E") && g_str_equal(value2, "E")) { + Executor *executor1 = NULL; + Executor *executor2 = NULL; + for (int i = 0; i < executors->len; i++) { + Executor *executor = &g_array_index(executors, Executor, i); + if (g_str_equal(name1, executor->name)) { + executor1 = executor; + } + if (g_str_equal(name2, executor->name)) { + executor2 = executor; + } + } + Executor tmp = *executor1; + *executor1 = *executor2; + *executor2 = tmp; + } else if (g_str_equal(value1, "P") && g_str_equal(value2, "P")) { + Button *button1 = NULL; + Button *button2 = NULL; + for (int i = 0; i < buttons->len; i++) { + Button *button = &g_array_index(buttons, Button, i); + if (g_str_equal(name1, button->name)) { + button1 = button; + } + if (g_str_equal(name2, button->name)) { + button2 = button; + } + } + Button tmp = *button1; + *button1 = *button2; + *button2 = tmp; + } - gtk_list_store_swap(panel_items, &iter, &prev); - } - } - } - separator_update_indices(); - execp_update_indices(); - button_update_indices(); + gtk_list_store_swap(panel_items, &iter, &prev); + } + } + } + separator_update_indices(); + execp_update_indices(); + button_update_indices(); } -enum { - iconsColName = 0, - iconsColDescr, - iconsNumCols -}; +enum { iconsColName = 0, iconsColDescr, iconsNumCols }; GtkListStore *icon_themes; void launcher_add_app(GtkWidget *widget, gpointer data) { - GtkTreeIter iter; - GtkTreeModel *model; + GtkTreeIter iter; + GtkTreeModel *model; - if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(all_apps_view)), &model, &iter)) { - GdkPixbuf *pixbuf; - gchar *name; - gchar *path; - gchar *iconName; + if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(all_apps_view)), &model, &iter)) { + GdkPixbuf *pixbuf; + gchar *name; + gchar *path; + gchar *iconName; - gtk_tree_model_get(model, &iter, - appsColIcon, &pixbuf, - appsColText, &name, - appsColPath, &path, - appsColIconName, &iconName, - -1); + gtk_tree_model_get(model, + &iter, + appsColIcon, + &pixbuf, + appsColText, + &name, + appsColPath, + &path, + appsColIconName, + &iconName, + -1); - GtkTreeIter iter; - gtk_list_store_append(launcher_apps, &iter); - gtk_list_store_set(launcher_apps, &iter, - appsColIcon, pixbuf, - appsColIconName, g_strdup(iconName), - appsColText, g_strdup(name), - appsColPath, g_strdup(path), - -1); - if (pixbuf) - g_object_unref(pixbuf); - } + GtkTreeIter iter; + gtk_list_store_append(launcher_apps, &iter); + gtk_list_store_set(launcher_apps, + &iter, + appsColIcon, + pixbuf, + appsColIconName, + g_strdup(iconName), + appsColText, + g_strdup(name), + appsColPath, + g_strdup(path), + -1); + if (pixbuf) + g_object_unref(pixbuf); + } } void launcher_remove_app(GtkWidget *widget, gpointer data) { - GtkTreeIter iter; - GtkTreeModel *model; + GtkTreeIter iter; + GtkTreeModel *model; - if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(launcher_apps_view)), &model, &iter)) { - gtk_list_store_remove(launcher_apps, &iter); - } + if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(launcher_apps_view)), &model, &iter)) { + gtk_list_store_remove(launcher_apps, &iter); + } } void launcher_move_app_down(GtkWidget *widget, gpointer data) { - GtkTreeIter iter; - GtkTreeModel *model; + GtkTreeIter iter; + GtkTreeModel *model; - if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(launcher_apps_view)), &model, &iter)) { - GtkTreeIter next = iter; - if (gtk_tree_model_iter_next(model, &next)) { - gtk_list_store_swap(launcher_apps, &iter, &next); - } - } + if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(launcher_apps_view)), &model, &iter)) { + GtkTreeIter next = iter; + if (gtk_tree_model_iter_next(model, &next)) { + gtk_list_store_swap(launcher_apps, &iter, &next); + } + } } void launcher_move_app_up(GtkWidget *widget, gpointer data) { - GtkTreeIter iter; - GtkTreeModel *model; + GtkTreeIter iter; + GtkTreeModel *model; - if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(launcher_apps_view)), &model, &iter)) { - GtkTreeIter prev = iter; - if (gtk_tree_model_iter_prev_tint2(model, &prev)) { - gtk_list_store_swap(launcher_apps, &iter, &prev); - } - } + if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(launcher_apps_view)), &model, &iter)) { + GtkTreeIter prev = iter; + if (gtk_tree_model_iter_prev_tint2(model, &prev)) { + gtk_list_store_swap(launcher_apps, &iter, &prev); + } + } } gboolean gtk_tree_model_iter_prev_tint2(GtkTreeModel *model, GtkTreeIter *iter) { - GtkTreeIter i; - if (!gtk_tree_model_get_iter_first(model, &i)) { - return FALSE; - } - GtkTreePath *piter = gtk_tree_model_get_path(model, iter); - if (!piter) - return FALSE; + GtkTreeIter i; + if (!gtk_tree_model_get_iter_first(model, &i)) { + return FALSE; + } + GtkTreePath *piter = gtk_tree_model_get_path(model, iter); + if (!piter) + return FALSE; - while (1) { - GtkTreeIter next = i; - if (gtk_tree_model_iter_next(model, &next)) { - GtkTreePath *pn = gtk_tree_model_get_path(model, &next); - if (!pn) - continue; - if (gtk_tree_path_compare(piter, pn) == 0) { - gtk_tree_path_free(piter); - gtk_tree_path_free(pn); - *iter = i; - return TRUE; - } - gtk_tree_path_free(pn); - i = next; - } else { - break; - } - } - gtk_tree_path_free(piter); - return FALSE; + while (1) { + GtkTreeIter next = i; + if (gtk_tree_model_iter_next(model, &next)) { + GtkTreePath *pn = gtk_tree_model_get_path(model, &next); + if (!pn) + continue; + if (gtk_tree_path_compare(piter, pn) == 0) { + gtk_tree_path_free(piter); + gtk_tree_path_free(pn); + *iter = i; + return TRUE; + } + gtk_tree_path_free(pn); + i = next; + } else { + break; + } + } + gtk_tree_path_free(piter); + return FALSE; } // Note: the returned pointer must be released with g_free! gchar *get_current_icon_theme() { - int index = gtk_combo_box_get_active(GTK_COMBO_BOX(launcher_icon_theme)); - if (index <= 0) { - return NULL; - } + int index = gtk_combo_box_get_active(GTK_COMBO_BOX(launcher_icon_theme)); + if (index <= 0) { + return NULL; + } - GtkTreePath *path; - GtkTreeIter iter; + GtkTreePath *path; + GtkTreeIter iter; - path = gtk_tree_path_new_from_indices(index, -1); - gtk_tree_model_get_iter(GTK_TREE_MODEL(icon_themes), &iter, path); - gtk_tree_path_free(path); + path = gtk_tree_path_new_from_indices(index, -1); + gtk_tree_model_get_iter(GTK_TREE_MODEL(icon_themes), &iter, path); + gtk_tree_path_free(path); - gchar *name; - gtk_tree_model_get(GTK_TREE_MODEL(icon_themes), &iter, - iconsColName, &name, - -1); - return name; + gchar *name; + gtk_tree_model_get(GTK_TREE_MODEL(icon_themes), &iter, iconsColName, &name, -1); + return name; } void set_current_icon_theme(const char *theme) { - int i; - for (i = 0; ; i++) { - GtkTreePath *path; - GtkTreeIter iter; + int i; + for (i = 0;; i++) { + GtkTreePath *path; + GtkTreeIter iter; - path = gtk_tree_path_new_from_indices(i, -1); - gboolean end = gtk_tree_model_get_iter(GTK_TREE_MODEL(icon_themes), &iter, path); - gtk_tree_path_free(path); + path = gtk_tree_path_new_from_indices(i, -1); + gboolean end = gtk_tree_model_get_iter(GTK_TREE_MODEL(icon_themes), &iter, path); + gtk_tree_path_free(path); - if (!end) { - break; - } + if (!end) { + break; + } - gchar *name; - gtk_tree_model_get(GTK_TREE_MODEL(icon_themes), &iter, - iconsColName, &name, - -1); - if (g_str_equal(name, theme)) { - gtk_combo_box_set_active(GTK_COMBO_BOX(launcher_icon_theme), i); - g_free(name); - break; - } - g_free(name); - } + gchar *name; + gtk_tree_model_get(GTK_TREE_MODEL(icon_themes), &iter, iconsColName, &name, -1); + if (g_str_equal(name, theme)) { + gtk_combo_box_set_active(GTK_COMBO_BOX(launcher_icon_theme), i); + g_free(name); + break; + } + g_free(name); + } } void icon_theme_changed(gpointer data) { - create_please_wait(GTK_WINDOW(data)); - process_events(); + create_please_wait(GTK_WINDOW(data)); + process_events(); - if (icon_theme) - free_themes(icon_theme); + if (icon_theme) + free_themes(icon_theme); - gchar *icon_theme_name = get_current_icon_theme(); - if (!icon_theme_name || g_str_equal(icon_theme_name, "")) { - g_free(icon_theme_name); - icon_theme_name = get_default_theme_name(); - } - icon_theme = load_themes(icon_theme_name); - g_free(icon_theme_name); + gchar *icon_theme_name = get_current_icon_theme(); + if (!icon_theme_name || g_str_equal(icon_theme_name, "")) { + g_free(icon_theme_name); + icon_theme_name = get_default_theme_name(); + } + icon_theme = load_themes(icon_theme_name); + g_free(icon_theme_name); - load_icons(launcher_apps); - load_icons(all_apps); - save_icon_cache(icon_theme); + load_icons(launcher_apps); + load_icons(all_apps); + save_icon_cache(icon_theme); - destroy_please_wait(); + destroy_please_wait(); } void launcher_icon_theme_changed(GtkWidget *widget, gpointer data) { - icon_theme_changed(data); + icon_theme_changed(data); } GdkPixbuf *load_icon(const gchar *name) { - process_events(); + process_events(); - int size = 22; - char *path = get_icon_path(icon_theme, name, size, FALSE); - GdkPixbuf *pixbuf = path ? gdk_pixbuf_new_from_file_at_size(path, size, size, NULL) : NULL; - free(path); - return pixbuf; + int size = 22; + char *path = get_icon_path(icon_theme, name, size, FALSE); + GdkPixbuf *pixbuf = path ? gdk_pixbuf_new_from_file_at_size(path, size, size, NULL) : NULL; + free(path); + return pixbuf; } void load_icons(GtkListStore *apps) { - int i; - for (i = 0; ; i++) { - GtkTreePath *path; - GtkTreeIter iter; + int i; + for (i = 0;; i++) { + GtkTreePath *path; + GtkTreeIter iter; - path = gtk_tree_path_new_from_indices(i, -1); - gboolean found = gtk_tree_model_get_iter(GTK_TREE_MODEL(apps), &iter, path); - gtk_tree_path_free(path); + path = gtk_tree_path_new_from_indices(i, -1); + gboolean found = gtk_tree_model_get_iter(GTK_TREE_MODEL(apps), &iter, path); + gtk_tree_path_free(path); - if (!found) - break; + if (!found) + break; - gchar *iconName; - gtk_tree_model_get(GTK_TREE_MODEL(apps), &iter, - appsColIconName, &iconName, - -1); - GdkPixbuf *pixbuf = load_icon(iconName); - gtk_list_store_set(apps, &iter, - appsColIcon, pixbuf, - -1); - if (pixbuf) - g_object_unref(pixbuf); - g_free(iconName); - } + gchar *iconName; + gtk_tree_model_get(GTK_TREE_MODEL(apps), &iter, appsColIconName, &iconName, -1); + GdkPixbuf *pixbuf = load_icon(iconName); + gtk_list_store_set(apps, &iter, appsColIcon, pixbuf, -1); + if (pixbuf) + g_object_unref(pixbuf); + g_free(iconName); + } } void load_desktop_file(const char *file, gboolean selected) { - char *file_contracted = contract_tilde(file); + char *file_contracted = contract_tilde(file); - GtkListStore *store = selected ? launcher_apps : all_apps; - gboolean duplicate = FALSE; - for (int index = 0; ; index++) { - GtkTreePath *path = gtk_tree_path_new_from_indices(index, -1); - GtkTreeIter iter; - gboolean found = gtk_tree_model_get_iter(GTK_TREE_MODEL(store), &iter, path); - gtk_tree_path_free(path); - if (!found) - break; + GtkListStore *store = selected ? launcher_apps : all_apps; + gboolean duplicate = FALSE; + for (int index = 0;; index++) { + GtkTreePath *path = gtk_tree_path_new_from_indices(index, -1); + GtkTreeIter iter; + gboolean found = gtk_tree_model_get_iter(GTK_TREE_MODEL(store), &iter, path); + gtk_tree_path_free(path); + if (!found) + break; - gchar *app_path; - gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, appsColPath, &app_path, -1); - char *contracted = contract_tilde(app_path); - if (strcmp(contracted, file_contracted) == 0) { - duplicate = TRUE; - break; - } - free(contracted); - g_free(app_path); - } + gchar *app_path; + gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, appsColPath, &app_path, -1); + char *contracted = contract_tilde(app_path); + if (strcmp(contracted, file_contracted) == 0) { + duplicate = TRUE; + break; + } + free(contracted); + g_free(app_path); + } - if (!duplicate) { - DesktopEntry entry; - if (read_desktop_file(file, &entry)) { - int index; - gboolean stop = FALSE; - for (index = 0; !stop || selected; index++) { - GtkTreePath *path = gtk_tree_path_new_from_indices(index, -1); - GtkTreeIter iter; - gboolean found = gtk_tree_model_get_iter(GTK_TREE_MODEL(store), &iter, path); - gtk_tree_path_free(path); - if (!found) - break; + if (!duplicate) { + DesktopEntry entry; + if (read_desktop_file(file, &entry)) { + int index; + gboolean stop = FALSE; + for (index = 0; !stop || selected; index++) { + GtkTreePath *path = gtk_tree_path_new_from_indices(index, -1); + GtkTreeIter iter; + gboolean found = gtk_tree_model_get_iter(GTK_TREE_MODEL(store), &iter, path); + gtk_tree_path_free(path); + if (!found) + break; - gchar *app_name; - gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, appsColText, &app_name, -1); - if (strnatcasecmp(app_name, entry.name) >= 0) - stop = TRUE; - g_free(app_name); - } + gchar *app_name; + gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, appsColText, &app_name, -1); + if (strnatcasecmp(app_name, entry.name) >= 0) + stop = TRUE; + g_free(app_name); + } - GdkPixbuf *pixbuf = load_icon(entry.icon); - GtkTreeIter iter; - gtk_list_store_insert(store, &iter, index); - gtk_list_store_set(store, &iter, - appsColIcon, pixbuf, - appsColIconName, g_strdup(entry.icon), - appsColText, g_strdup(entry.name), - appsColPath, g_strdup(file), - -1); - if (pixbuf) - g_object_unref(pixbuf); - } else { - printf("Could not load %s\n", file); - GdkPixbuf *pixbuf = load_icon(DEFAULT_ICON); - GtkTreeIter iter; - gtk_list_store_append(store, &iter); - gtk_list_store_set(store, &iter, - appsColIcon, pixbuf, - appsColIconName, g_strdup(""), - appsColText, g_strdup(file), - appsColPath, g_strdup(file), - -1); - if (pixbuf) - g_object_unref(pixbuf); - } - free_desktop_entry(&entry); - } + GdkPixbuf *pixbuf = load_icon(entry.icon); + GtkTreeIter iter; + gtk_list_store_insert(store, &iter, index); + gtk_list_store_set(store, + &iter, + appsColIcon, + pixbuf, + appsColIconName, + g_strdup(entry.icon), + appsColText, + g_strdup(entry.name), + appsColPath, + g_strdup(file), + -1); + if (pixbuf) + g_object_unref(pixbuf); + } else { + printf("Could not load %s\n", file); + GdkPixbuf *pixbuf = load_icon(DEFAULT_ICON); + GtkTreeIter iter; + gtk_list_store_append(store, &iter); + gtk_list_store_set(store, + &iter, + appsColIcon, + pixbuf, + appsColIconName, + g_strdup(""), + appsColText, + g_strdup(file), + appsColPath, + g_strdup(file), + -1); + if (pixbuf) + g_object_unref(pixbuf); + } + free_desktop_entry(&entry); + } - free(file_contracted); + free(file_contracted); } void populate_from_entries(GList *entries, gboolean selected) { - for (GList *l = entries; l; l = l->next) { - DesktopEntry *entry = (DesktopEntry *)l->data; - GdkPixbuf *pixbuf = load_icon(entry->icon); - GtkTreeIter iter; - gtk_list_store_append(selected ? launcher_apps : all_apps, &iter); - gtk_list_store_set(selected ? launcher_apps :all_apps, &iter, - appsColIcon, pixbuf, - appsColIconName, g_strdup(entry->icon), - appsColText, g_strdup(entry->name), - appsColPath, g_strdup(entry->path), - -1); - if (pixbuf) - g_object_unref(pixbuf); - } + for (GList *l = entries; l; l = l->next) { + DesktopEntry *entry = (DesktopEntry *)l->data; + GdkPixbuf *pixbuf = load_icon(entry->icon); + GtkTreeIter iter; + gtk_list_store_append(selected ? launcher_apps : all_apps, &iter); + gtk_list_store_set(selected ? launcher_apps : all_apps, + &iter, + appsColIcon, + pixbuf, + appsColIconName, + g_strdup(entry->icon), + appsColText, + g_strdup(entry->name), + appsColPath, + g_strdup(entry->path), + -1); + if (pixbuf) + g_object_unref(pixbuf); + } } static gint compare_entries(gconstpointer a, gconstpointer b) { - return strnatcasecmp(((DesktopEntry*)a)->name, ((DesktopEntry*)b)->name); + return strnatcasecmp(((DesktopEntry *)a)->name, ((DesktopEntry *)b)->name); } void load_desktop_entry(const char *file, GList **entries) { - process_events(); + process_events(); - DesktopEntry *entry = calloc(1, sizeof(DesktopEntry)); - if (!read_desktop_file(file, entry)) - printf("Could not load %s\n", file); - if (entry->hidden_from_menus) { - free(entry); - return; - } - if (!entry->name) - entry->name = strdup(file); - if (!entry->icon) - entry->icon = strdup(""); - *entries = g_list_append(*entries, entry); + DesktopEntry *entry = calloc(1, sizeof(DesktopEntry)); + if (!read_desktop_file(file, entry)) + printf("Could not load %s\n", file); + if (entry->hidden_from_menus) { + free(entry); + return; + } + if (!entry->name) + entry->name = strdup(file); + if (!entry->icon) + entry->icon = strdup(""); + *entries = g_list_append(*entries, entry); } void load_desktop_entries(const char *path, GList **entries) { - process_events(); + process_events(); - GList *subdirs = NULL; - GList *files = NULL; + GList *subdirs = NULL; + GList *files = NULL; - GDir *d = g_dir_open(path, 0, NULL); - if (d) { - const gchar *name; - while ((name = g_dir_read_name(d))) { - gchar *file = g_build_filename(path, name, NULL); - if (!g_file_test(file, G_FILE_TEST_IS_DIR) && g_str_has_suffix(file, ".desktop")) { - files = g_list_append(files, file); - } else if (g_file_test(file, G_FILE_TEST_IS_DIR)) { - subdirs = g_list_append(subdirs, file); - } else { - g_free(file); - } - } - g_dir_close(d); - } + GDir *d = g_dir_open(path, 0, NULL); + if (d) { + const gchar *name; + while ((name = g_dir_read_name(d))) { + gchar *file = g_build_filename(path, name, NULL); + if (!g_file_test(file, G_FILE_TEST_IS_DIR) && g_str_has_suffix(file, ".desktop")) { + files = g_list_append(files, file); + } else if (g_file_test(file, G_FILE_TEST_IS_DIR)) { + subdirs = g_list_append(subdirs, file); + } else { + g_free(file); + } + } + g_dir_close(d); + } - subdirs = g_list_sort(subdirs, compare_strings); - GList *l; - for (l = subdirs; l; l = g_list_next(l)) { - gchar *dir = (gchar *)l->data; - load_desktop_entries(dir, entries); - g_free(dir); - } - g_list_free(subdirs); + subdirs = g_list_sort(subdirs, compare_strings); + GList *l; + for (l = subdirs; l; l = g_list_next(l)) { + gchar *dir = (gchar *)l->data; + load_desktop_entries(dir, entries); + g_free(dir); + } + g_list_free(subdirs); - files = g_list_sort(files, compare_strings); - for (l = files; l; l = g_list_next(l)) { - gchar *file = (gchar *)l->data; - load_desktop_entry(file, entries); - g_free(file); - } - g_list_free(files); + files = g_list_sort(files, compare_strings); + for (l = files; l; l = g_list_next(l)) { + gchar *file = (gchar *)l->data; + load_desktop_entry(file, entries); + g_free(file); + } + g_list_free(files); } static gint compare_themes(gconstpointer a, gconstpointer b) { - gint result = strnatcasecmp(((IconTheme*)a)->description, ((IconTheme*)b)->description); - if (result) - return result; - return strnatcasecmp(((IconTheme*)a)->name, ((IconTheme*)b)->name); + gint result = strnatcasecmp(((IconTheme *)a)->description, ((IconTheme *)b)->description); + if (result) + return result; + return strnatcasecmp(((IconTheme *)a)->name, ((IconTheme *)b)->name); } void load_theme_file(const char *file_name, const char *theme_name, GList **themes) { - process_events(); + process_events(); - if (!file_name || !theme_name) { - return; - } + if (!file_name || !theme_name) { + return; + } - FILE *f; - if ((f = fopen(file_name, "rt")) == NULL) { - return; - } + FILE *f; + if ((f = fopen(file_name, "rt")) == NULL) { + return; + } - char *line = NULL; - size_t line_size; + char *line = NULL; + size_t line_size; - while (getline(&line, &line_size, f) >= 0) { - char *key, *value; + while (getline(&line, &line_size, f) >= 0) { + char *key, *value; - int line_len = strlen(line); - if (line_len >= 1) { - if (line[line_len - 1] == '\n') { - line[line_len - 1] = '\0'; - line_len--; - } - } + int line_len = strlen(line); + if (line_len >= 1) { + if (line[line_len - 1] == '\n') { + line[line_len - 1] = '\0'; + line_len--; + } + } - if (line_len == 0) - continue; + if (line_len == 0) + continue; - if (parse_theme_line(line, &key, &value)) { - if (strcmp(key, "Name") == 0) { - IconTheme *theme = calloc(1, sizeof(IconTheme)); - theme->name = strdup(theme_name); - theme->description = strdup(value); - *themes = g_list_append(*themes, theme); - break; - } - } + if (parse_theme_line(line, &key, &value)) { + if (strcmp(key, "Name") == 0) { + IconTheme *theme = calloc(1, sizeof(IconTheme)); + theme->name = strdup(theme_name); + theme->description = strdup(value); + *themes = g_list_append(*themes, theme); + break; + } + } - if (line[0] == '[' && line[line_len - 1] == ']' && strcmp(line, "[Icon Theme]") != 0) { - break; - } - } - fclose(f); - free(line); + if (line[0] == '[' && line[line_len - 1] == ']' && strcmp(line, "[Icon Theme]") != 0) { + break; + } + } + fclose(f); + free(line); } void load_icon_themes(const gchar *path, const gchar *parent, GList **themes) { - process_events(); + process_events(); - GDir *d = g_dir_open(path, 0, NULL); - if (!d) - return; - const gchar *name; - while ((name = g_dir_read_name(d))) { - gchar *file = g_build_filename(path, name, NULL); - if (parent && - g_file_test(file, G_FILE_TEST_IS_REGULAR) && - g_str_equal(name, "index.theme")) { - load_theme_file(file, parent, themes); - } else if (g_file_test(file, G_FILE_TEST_IS_DIR)) { - gboolean duplicate = FALSE; - if (g_file_test(file, G_FILE_TEST_IS_SYMLINK)) { + GDir *d = g_dir_open(path, 0, NULL); + if (!d) + return; + const gchar *name; + while ((name = g_dir_read_name(d))) { + gchar *file = g_build_filename(path, name, NULL); + if (parent && g_file_test(file, G_FILE_TEST_IS_REGULAR) && g_str_equal(name, "index.theme")) { + load_theme_file(file, parent, themes); + } else if (g_file_test(file, G_FILE_TEST_IS_DIR)) { + gboolean duplicate = FALSE; + if (g_file_test(file, G_FILE_TEST_IS_SYMLINK)) { #ifdef PATH_MAX - char real_path[PATH_MAX]; + char real_path[PATH_MAX]; #else - char real_path[65536]; + char real_path[65536]; #endif - if (realpath(file, real_path)) { - if (strstr(real_path, path) == real_path) - duplicate = TRUE; - } - } - if (!duplicate) - load_icon_themes(file, name, themes); - } - g_free(file); - } - g_dir_close(d); + if (realpath(file, real_path)) { + if (strstr(real_path, path) == real_path) + duplicate = TRUE; + } + } + if (!duplicate) + load_icon_themes(file, name, themes); + } + g_free(file); + } + g_dir_close(d); } gchar *get_default_theme_name() { - gchar *name = NULL; - g_object_get(gtk_settings_get_default(), - "gtk-icon-theme-name", - &name, - NULL); - if (!name) { - name = g_strdup("hicolor"); - } - return name; + gchar *name = NULL; + g_object_get(gtk_settings_get_default(), "gtk-icon-theme-name", &name, NULL); + if (!name) { + name = g_strdup("hicolor"); + } + return name; } GtkWidget *addScrollBarToWidget(GtkWidget *widget) { - GtkWidget *scrolled_window = gtk_scrolled_window_new(NULL, NULL); - gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (scrolled_window), - GTK_POLICY_NEVER, - GTK_POLICY_AUTOMATIC); + GtkWidget *scrolled_window = gtk_scrolled_window_new(NULL, NULL); + gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); - gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window), widget); + gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window), widget); - gtk_widget_set_size_request(scrolled_window, 100, 300); + gtk_widget_set_size_request(scrolled_window, 100, 300); - gtk_widget_show(widget); - gtk_widget_show(scrolled_window); + gtk_widget_show(widget); + gtk_widget_show(scrolled_window); - return scrolled_window; + return scrolled_window; } void create_launcher(GtkWidget *parent, GtkWindow *window) { - GtkWidget *image; - GtkTooltips *tooltips = gtk_tooltips_new(); + GtkWidget *image; + GtkTooltips *tooltips = gtk_tooltips_new(); - icon_theme = NULL; + icon_theme = NULL; - launcher_apps = gtk_list_store_new(appsNumCols, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); - all_apps = gtk_list_store_new(appsNumCols, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); - icon_themes = gtk_list_store_new(iconsNumCols, G_TYPE_STRING, G_TYPE_STRING); + launcher_apps = gtk_list_store_new(appsNumCols, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); + all_apps = gtk_list_store_new(appsNumCols, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); + icon_themes = gtk_list_store_new(iconsNumCols, G_TYPE_STRING, G_TYPE_STRING); - launcher_apps_view = gtk_tree_view_new(); - gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(launcher_apps_view), - -1, - "", - gtk_cell_renderer_pixbuf_new(), - "pixbuf", appsColIcon, - NULL); - gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(launcher_apps_view), - -1, - "", - gtk_cell_renderer_text_new(), - "text", appsColText, - NULL); - gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(launcher_apps_view), FALSE); - gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(launcher_apps_view)), GTK_SELECTION_SINGLE); - gtk_tree_view_set_model(GTK_TREE_VIEW(launcher_apps_view), GTK_TREE_MODEL(launcher_apps)); - g_object_unref(launcher_apps); - gtk_tooltips_set_tip(tooltips, launcher_apps_view, _("Specifies the application launchers that will appear in the launcher and their order. " - "Launchers can be added by selecting an item in the list of available applications, then clicking on " - "the add left button."), NULL); + launcher_apps_view = gtk_tree_view_new(); + gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(launcher_apps_view), + -1, + "", + gtk_cell_renderer_pixbuf_new(), + "pixbuf", + appsColIcon, + NULL); + gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(launcher_apps_view), + -1, + "", + gtk_cell_renderer_text_new(), + "text", + appsColText, + NULL); + gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(launcher_apps_view), FALSE); + gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(launcher_apps_view)), GTK_SELECTION_SINGLE); + gtk_tree_view_set_model(GTK_TREE_VIEW(launcher_apps_view), GTK_TREE_MODEL(launcher_apps)); + g_object_unref(launcher_apps); + gtk_tooltips_set_tip(tooltips, + launcher_apps_view, + _("Specifies the application launchers that will appear in the launcher and their order. " + "Launchers can be added by selecting an item in the list of available applications, then " + "clicking on " + "the add left button."), + NULL); - all_apps_view = gtk_tree_view_new(); - gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(all_apps_view), - -1, - "", - gtk_cell_renderer_pixbuf_new(), - "pixbuf", appsColIcon, - NULL); - gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(all_apps_view), - -1, - "", - gtk_cell_renderer_text_new(), - "text", appsColText, - NULL); - gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(all_apps_view), FALSE); - gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(all_apps_view)), GTK_SELECTION_SINGLE); - gtk_tree_view_set_model(GTK_TREE_VIEW(all_apps_view), GTK_TREE_MODEL(all_apps)); - g_object_unref(all_apps); - gtk_tooltips_set_tip(tooltips, all_apps_view, _("Lists all the applications detected on the system. " - "Launchers can be added to the launcher by selecting an application, then clicking on " - "the add left button."), NULL); + all_apps_view = gtk_tree_view_new(); + gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(all_apps_view), + -1, + "", + gtk_cell_renderer_pixbuf_new(), + "pixbuf", + appsColIcon, + NULL); + gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(all_apps_view), + -1, + "", + gtk_cell_renderer_text_new(), + "text", + appsColText, + NULL); + gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(all_apps_view), FALSE); + gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(all_apps_view)), GTK_SELECTION_SINGLE); + gtk_tree_view_set_model(GTK_TREE_VIEW(all_apps_view), GTK_TREE_MODEL(all_apps)); + g_object_unref(all_apps); + gtk_tooltips_set_tip(tooltips, + all_apps_view, + _("Lists all the applications detected on the system. " + "Launchers can be added to the launcher by selecting an application, then clicking on " + "the add left button."), + NULL); - GtkWidget *table, *label, *button; - int row, col; + GtkWidget *table, *label, *button; + int row, col; - table = gtk_table_new(2, 3, FALSE); - gtk_widget_show(table); - gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); - gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); - gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); + table = gtk_table_new(2, 3, FALSE); + gtk_widget_show(table); + gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); + gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); + gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); - label = gtk_label_new(_("<b>Applications selected</b>")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_label_set_use_markup(GTK_LABEL(label), TRUE); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, GTK_FILL, 0, 0, 0); + label = gtk_label_new(_("<b>Applications selected</b>")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_label_set_use_markup(GTK_LABEL(label), TRUE); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, GTK_FILL, 0, 0, 0); - label = gtk_label_new(_("<b>Applications available</b>")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_label_set_use_markup(GTK_LABEL(label), TRUE); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, 2, 3, 0, 1, GTK_FILL, 0, 0, 0); + label = gtk_label_new(_("<b>Applications available</b>")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_label_set_use_markup(GTK_LABEL(label), TRUE); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, 2, 3, 0, 1, GTK_FILL, 0, 0, 0); - GtkWidget *vbox; - vbox = gtk_vbox_new(FALSE, 0); - gtk_widget_show(vbox); - gtk_container_set_border_width(GTK_CONTAINER(vbox), 0); + GtkWidget *vbox; + vbox = gtk_vbox_new(FALSE, 0); + gtk_widget_show(vbox); + gtk_container_set_border_width(GTK_CONTAINER(vbox), 0); - button = gtk_button_new(); - image = gtk_image_new_from_stock(GTK_STOCK_GO_UP, GTK_ICON_SIZE_BUTTON); - gtk_button_set_image(GTK_BUTTON(button), image); - gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(launcher_move_app_up), NULL); - gtk_widget_show(button); - gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0); - gtk_tooltips_set_tip(tooltips, button, _("Moves up the current launcher in the list of selected applications."), NULL); + button = gtk_button_new(); + image = gtk_image_new_from_stock(GTK_STOCK_GO_UP, GTK_ICON_SIZE_BUTTON); + gtk_button_set_image(GTK_BUTTON(button), image); + gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(launcher_move_app_up), NULL); + gtk_widget_show(button); + gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0); + gtk_tooltips_set_tip(tooltips, + button, + _("Moves up the current launcher in the list of selected applications."), + NULL); - button = gtk_button_new(); - image = gtk_image_new_from_stock(GTK_STOCK_GO_DOWN, GTK_ICON_SIZE_BUTTON); - gtk_button_set_image(GTK_BUTTON(button), image); - gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(launcher_move_app_down), NULL); - gtk_widget_show(button); - gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0); - gtk_tooltips_set_tip(tooltips, button, _("Moves down the current launcher in the list of selected applications."), NULL); + button = gtk_button_new(); + image = gtk_image_new_from_stock(GTK_STOCK_GO_DOWN, GTK_ICON_SIZE_BUTTON); + gtk_button_set_image(GTK_BUTTON(button), image); + gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(launcher_move_app_down), NULL); + gtk_widget_show(button); + gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0); + gtk_tooltips_set_tip(tooltips, + button, + _("Moves down the current launcher in the list of selected applications."), + NULL); - label = gtk_label_new(_(" ")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); + label = gtk_label_new(_(" ")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); - button = gtk_button_new(); - image = gtk_image_new_from_stock(GTK_STOCK_GO_BACK, GTK_ICON_SIZE_BUTTON); - gtk_button_set_image(GTK_BUTTON(button), image); - gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(launcher_add_app), NULL); - gtk_widget_show(button); - gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0); - gtk_tooltips_set_tip(tooltips, button, _("Copies the current application in the list of available applications to the list of selected applications."), NULL); + button = gtk_button_new(); + image = gtk_image_new_from_stock(GTK_STOCK_GO_BACK, GTK_ICON_SIZE_BUTTON); + gtk_button_set_image(GTK_BUTTON(button), image); + gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(launcher_add_app), NULL); + gtk_widget_show(button); + gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0); + gtk_tooltips_set_tip(tooltips, + button, + _("Copies the current application in the list of available applications to the list of " + "selected applications."), + NULL); - button = gtk_button_new(); - image = gtk_image_new_from_stock(GTK_STOCK_GO_FORWARD, GTK_ICON_SIZE_BUTTON); - gtk_button_set_image(GTK_BUTTON(button), image); - gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(launcher_remove_app), NULL); - gtk_widget_show(button); - gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0); - gtk_tooltips_set_tip(tooltips, button, _("Removes the current application from the list of selected application."), NULL); + button = gtk_button_new(); + image = gtk_image_new_from_stock(GTK_STOCK_GO_FORWARD, GTK_ICON_SIZE_BUTTON); + gtk_button_set_image(GTK_BUTTON(button), image); + gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(launcher_remove_app), NULL); + gtk_widget_show(button); + gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0); + gtk_tooltips_set_tip(tooltips, + button, + _("Removes the current application from the list of selected application."), + NULL); - gtk_table_attach(GTK_TABLE(table), vbox, 1, 2, 1, 2, GTK_FILL, GTK_FILL, 0, 0); + gtk_table_attach(GTK_TABLE(table), vbox, 1, 2, 1, 2, GTK_FILL, GTK_FILL, 0, 0); - gtk_widget_show(launcher_apps_view); - gtk_table_attach(GTK_TABLE(table), addScrollBarToWidget(launcher_apps_view), 0, 1, 1, 2, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); + gtk_widget_show(launcher_apps_view); + gtk_table_attach(GTK_TABLE(table), + addScrollBarToWidget(launcher_apps_view), + 0, + 1, + 1, + 2, + GTK_FILL | GTK_EXPAND, + GTK_FILL, + 0, + 0); - gtk_widget_show(all_apps_view); - gtk_table_attach(GTK_TABLE(table), addScrollBarToWidget(all_apps_view), 2, 3, 1, 2, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); + gtk_widget_show(all_apps_view); + gtk_table_attach(GTK_TABLE(table), + addScrollBarToWidget(all_apps_view), + 2, + 3, + 1, + 2, + GTK_FILL | GTK_EXPAND, + GTK_FILL, + 0, + 0); - change_paragraph(parent); + change_paragraph(parent); - label = gtk_label_new(_("<b>Additional application directories</b>")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_label_set_use_markup(GTK_LABEL(label), TRUE); - gtk_widget_show(label); - gtk_box_pack_start(GTK_BOX(parent), label, FALSE, FALSE, 0); + label = gtk_label_new(_("<b>Additional application directories</b>")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_label_set_use_markup(GTK_LABEL(label), TRUE); + gtk_widget_show(label); + gtk_box_pack_start(GTK_BOX(parent), label, FALSE, FALSE, 0); - launcher_apps_dirs = gtk_entry_new(); - gtk_widget_show(launcher_apps_dirs); - gtk_box_pack_start(GTK_BOX(parent), launcher_apps_dirs, FALSE, FALSE, 0); - gtk_tooltips_set_tip(tooltips, launcher_apps_dirs, _("Specifies a path to a directory from which the launcher is loading all .desktop files (all subdirectories are explored recursively). " - "Can be used multiple times, in which case the paths must be separated by commas. Leading ~ is expaned to the path of the user's home directory."), NULL); + launcher_apps_dirs = gtk_entry_new(); + gtk_widget_show(launcher_apps_dirs); + gtk_box_pack_start(GTK_BOX(parent), launcher_apps_dirs, FALSE, FALSE, 0); + gtk_tooltips_set_tip(tooltips, + launcher_apps_dirs, + _("Specifies a path to a directory from which the launcher is loading all .desktop files (all " + "subdirectories are explored recursively). " + "Can be used multiple times, in which case the paths must be separated by commas. Leading ~ " + "is expaned to the path of the user's home directory."), + NULL); - label = gtk_label_new(_("<b>Appearance</b>")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_label_set_use_markup(GTK_LABEL(label), TRUE); - gtk_widget_show(label); - gtk_box_pack_start(GTK_BOX(parent), label, FALSE, FALSE, 0); + label = gtk_label_new(_("<b>Appearance</b>")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_label_set_use_markup(GTK_LABEL(label), TRUE); + gtk_widget_show(label); + gtk_box_pack_start(GTK_BOX(parent), label, FALSE, FALSE, 0); - table = gtk_table_new(7, 10, FALSE); - gtk_widget_show(table); - gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); - gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); - gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); + table = gtk_table_new(7, 10, FALSE); + gtk_widget_show(table); + gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); + gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); + gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); - row = 0, col = 2; - label = gtk_label_new(_("Background")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row = 0, col = 2; + label = gtk_label_new(_("Background")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - launcher_background = create_background_combo(_("Launcher")); - gtk_widget_show(launcher_background); - gtk_table_attach(GTK_TABLE(table), launcher_background, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, launcher_background, _("Selects the background used to display the launcher. " - "Backgrounds can be edited in the Backgrounds tab."), NULL); + launcher_background = create_background_combo(_("Launcher")); + gtk_widget_show(launcher_background); + gtk_table_attach(GTK_TABLE(table), launcher_background, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + launcher_background, + _("Selects the background used to display the launcher. " + "Backgrounds can be edited in the Backgrounds tab."), + NULL); - row++, col = 2; - label = gtk_label_new(_("Icon background")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Icon background")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - launcher_icon_background = create_background_combo(_("Launcher icon")); - gtk_widget_show(launcher_icon_background); - gtk_table_attach(GTK_TABLE(table), launcher_icon_background, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, launcher_icon_background, _("Selects the background used to display the launcher icon. " - "Backgrounds can be edited in the Backgrounds tab."), NULL); + launcher_icon_background = create_background_combo(_("Launcher icon")); + gtk_widget_show(launcher_icon_background); + gtk_table_attach(GTK_TABLE(table), launcher_icon_background, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + launcher_icon_background, + _("Selects the background used to display the launcher icon. " + "Backgrounds can be edited in the Backgrounds tab."), + NULL); - row++, col = 2; - label = gtk_label_new(_("Horizontal padding")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Horizontal padding")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - launcher_padding_x = gtk_spin_button_new_with_range(0, 500, 1); - gtk_widget_show(launcher_padding_x); - gtk_table_attach(GTK_TABLE(table), launcher_padding_x, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, launcher_padding_x, _("Specifies the horizontal padding of the launcher. " - "This is the space between the border and the elements inside."), NULL); + launcher_padding_x = gtk_spin_button_new_with_range(0, 500, 1); + gtk_widget_show(launcher_padding_x); + gtk_table_attach(GTK_TABLE(table), launcher_padding_x, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + launcher_padding_x, + _("Specifies the horizontal padding of the launcher. " + "This is the space between the border and the elements inside."), + NULL); - row++, col = 2; - label = gtk_label_new(_("Vertical padding")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Vertical padding")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - launcher_padding_y = gtk_spin_button_new_with_range(0, 500, 1); - gtk_widget_show(launcher_padding_y); - gtk_table_attach(GTK_TABLE(table), launcher_padding_y, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, launcher_padding_y, _("Specifies the vertical padding of the launcher. " - "This is the space between the border and the elements inside."), NULL); + launcher_padding_y = gtk_spin_button_new_with_range(0, 500, 1); + gtk_widget_show(launcher_padding_y); + gtk_table_attach(GTK_TABLE(table), launcher_padding_y, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + launcher_padding_y, + _("Specifies the vertical padding of the launcher. " + "This is the space between the border and the elements inside."), + NULL); - row++, col = 2; - label = gtk_label_new(_("Spacing")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Spacing")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - launcher_spacing = gtk_spin_button_new_with_range(0, 500, 1); - gtk_widget_show(launcher_spacing); - gtk_table_attach(GTK_TABLE(table), launcher_spacing, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, launcher_spacing, _("Specifies the spacing between the elements inside the launcher."), NULL); + launcher_spacing = gtk_spin_button_new_with_range(0, 500, 1); + gtk_widget_show(launcher_spacing); + gtk_table_attach(GTK_TABLE(table), launcher_spacing, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + launcher_spacing, + _("Specifies the spacing between the elements inside the launcher."), + NULL); - row++, col = 2; - label = gtk_label_new(_("Icon size")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Icon size")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - launcher_icon_size = gtk_spin_button_new_with_range(0, 500, 1); - gtk_widget_show(launcher_icon_size); - gtk_table_attach(GTK_TABLE(table), launcher_icon_size, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, launcher_icon_size, _("Specifies the size of the launcher icons, in pixels."), NULL); + launcher_icon_size = gtk_spin_button_new_with_range(0, 500, 1); + gtk_widget_show(launcher_icon_size); + gtk_table_attach(GTK_TABLE(table), launcher_icon_size, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, launcher_icon_size, _("Specifies the size of the launcher icons, in pixels."), NULL); - row++; - col = 2; - label = gtk_label_new(_("Icon opacity")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++; + col = 2; + label = gtk_label_new(_("Icon opacity")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - launcher_icon_opacity = gtk_spin_button_new_with_range(0, 100, 1); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(launcher_icon_opacity), 100); - gtk_widget_show(launcher_icon_opacity); - gtk_table_attach(GTK_TABLE(table), launcher_icon_opacity, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, launcher_icon_opacity, _("Specifies the opacity of the launcher icons, in percent."), NULL); + launcher_icon_opacity = gtk_spin_button_new_with_range(0, 100, 1); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(launcher_icon_opacity), 100); + gtk_widget_show(launcher_icon_opacity); + gtk_table_attach(GTK_TABLE(table), launcher_icon_opacity, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + launcher_icon_opacity, + _("Specifies the opacity of the launcher icons, in percent."), + NULL); - row++; - col = 2; - label = gtk_label_new(_("Icon saturation")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++; + col = 2; + label = gtk_label_new(_("Icon saturation")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - launcher_icon_saturation = gtk_spin_button_new_with_range(-100, 100, 1); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(launcher_icon_saturation), 0); - gtk_widget_show(launcher_icon_saturation); - gtk_table_attach(GTK_TABLE(table), launcher_icon_saturation, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, launcher_icon_saturation, _("Specifies the saturation adjustment of the launcher icons, in percent."), NULL); + launcher_icon_saturation = gtk_spin_button_new_with_range(-100, 100, 1); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(launcher_icon_saturation), 0); + gtk_widget_show(launcher_icon_saturation); + gtk_table_attach(GTK_TABLE(table), launcher_icon_saturation, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + launcher_icon_saturation, + _("Specifies the saturation adjustment of the launcher icons, in percent."), + NULL); - row++; - col = 2; - label = gtk_label_new(_("Icon brightness")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++; + col = 2; + label = gtk_label_new(_("Icon brightness")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - launcher_icon_brightness = gtk_spin_button_new_with_range(-100, 100, 1); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(launcher_icon_brightness), 0); - gtk_widget_show(launcher_icon_brightness); - gtk_table_attach(GTK_TABLE(table), launcher_icon_brightness, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, launcher_icon_brightness, _("Specifies the brightness adjustment of the launcher icons, in percent."), NULL); + launcher_icon_brightness = gtk_spin_button_new_with_range(-100, 100, 1); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(launcher_icon_brightness), 0); + gtk_widget_show(launcher_icon_brightness); + gtk_table_attach(GTK_TABLE(table), launcher_icon_brightness, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + launcher_icon_brightness, + _("Specifies the brightness adjustment of the launcher icons, in percent."), + NULL); - row++, col = 2; - label = gtk_label_new(_("Icon theme")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+3, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Icon theme")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 3, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - launcher_icon_theme = gtk_combo_box_new_with_model(GTK_TREE_MODEL(icon_themes)); - GtkCellRenderer *renderer = gtk_cell_renderer_text_new(); - gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(launcher_icon_theme), renderer, FALSE); - gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(launcher_icon_theme), renderer, "text", iconsColDescr, NULL); - g_signal_connect(G_OBJECT(launcher_icon_theme), "changed", G_CALLBACK(launcher_icon_theme_changed), window); - gtk_widget_show(launcher_icon_theme); - gtk_table_attach(GTK_TABLE(table), launcher_icon_theme, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, launcher_icon_theme, _("The icon theme used to display launcher icons. If left blank, " - "tint2 will detect and use the icon theme of your desktop as long as you have " - "an XSETTINGS manager running (most desktop environments do)."), NULL); + launcher_icon_theme = gtk_combo_box_new_with_model(GTK_TREE_MODEL(icon_themes)); + GtkCellRenderer *renderer = gtk_cell_renderer_text_new(); + gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(launcher_icon_theme), renderer, FALSE); + gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(launcher_icon_theme), renderer, "text", iconsColDescr, NULL); + g_signal_connect(G_OBJECT(launcher_icon_theme), "changed", G_CALLBACK(launcher_icon_theme_changed), window); + gtk_widget_show(launcher_icon_theme); + gtk_table_attach(GTK_TABLE(table), launcher_icon_theme, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + launcher_icon_theme, + _("The icon theme used to display launcher icons. If left blank, " + "tint2 will detect and use the icon theme of your desktop as long as you have " + "an XSETTINGS manager running (most desktop environments do)."), + NULL); - launcher_icon_theme_override = gtk_check_button_new_with_label(_("Overrides XSETTINGS")); - gtk_widget_show(launcher_icon_theme_override); - gtk_table_attach(GTK_TABLE(table), launcher_icon_theme_override, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, launcher_icon_theme_override, _("If enabled, the icon theme selected here will override the one provided by XSETTINGS."), NULL); + launcher_icon_theme_override = gtk_check_button_new_with_label(_("Overrides XSETTINGS")); + gtk_widget_show(launcher_icon_theme_override); + gtk_table_attach(GTK_TABLE(table), launcher_icon_theme_override, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + launcher_icon_theme_override, + _("If enabled, the icon theme selected here will override the one provided by XSETTINGS."), + NULL); - row++, col = 2; - label = gtk_label_new(_("Startup notifications")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Startup notifications")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - startup_notifications = gtk_check_button_new(); - gtk_widget_show(startup_notifications); - gtk_table_attach(GTK_TABLE(table), startup_notifications, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, startup_notifications, _("If enabled, startup notifications are shown when starting applications from the launcher. " - "The appearance may vary depending on your desktop environment configuration; normally, a busy mouse cursor is displayed until the application starts."), NULL); + startup_notifications = gtk_check_button_new(); + gtk_widget_show(startup_notifications); + gtk_table_attach(GTK_TABLE(table), startup_notifications, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + startup_notifications, + _("If enabled, startup notifications are shown when starting applications from the launcher. " + "The appearance may vary depending on your desktop environment configuration; normally, a " + "busy mouse cursor is displayed until the application starts."), + NULL); - row++, col = 2; - label = gtk_label_new(_("Tooltips")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Tooltips")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - launcher_tooltip = gtk_check_button_new(); - gtk_widget_show(launcher_tooltip); - gtk_table_attach(GTK_TABLE(table), launcher_tooltip, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, launcher_tooltip, _("If enabled, shows a tooltip with the application name when the mouse is moved over an application launcher."), NULL); + launcher_tooltip = gtk_check_button_new(); + gtk_widget_show(launcher_tooltip); + gtk_table_attach(GTK_TABLE(table), launcher_tooltip, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + launcher_tooltip, + _("If enabled, shows a tooltip with the application name when the mouse is moved over an " + "application launcher."), + NULL); - change_paragraph(parent); + change_paragraph(parent); - fprintf(stderr, "Loading icon themes\n"); - GList *themes = NULL; - const GSList *location; - for (location = get_icon_locations(); location; location = g_slist_next(location)) { - const gchar *path = (gchar*) location->data; - load_icon_themes(path, NULL, &themes); - } - themes = g_list_sort(themes, compare_themes); + fprintf(stderr, "Loading icon themes\n"); + GList *themes = NULL; + const GSList *location; + for (location = get_icon_locations(); location; location = g_slist_next(location)) { + const gchar *path = (gchar *)location->data; + load_icon_themes(path, NULL, &themes); + } + themes = g_list_sort(themes, compare_themes); - GtkTreeIter iter; - gtk_list_store_append(icon_themes, &iter); - gtk_list_store_set(icon_themes, &iter, - 0, "", - -1); - for (GList *l = themes; l; l = l->next) { - IconTheme *theme = (IconTheme*)l->data; - GtkTreeIter iter; - gtk_list_store_append(icon_themes, &iter); - gtk_list_store_set(icon_themes, &iter, - iconsColName, g_strdup(theme->name), - iconsColDescr, g_strdup(theme->description), - -1); - } + GtkTreeIter iter; + gtk_list_store_append(icon_themes, &iter); + gtk_list_store_set(icon_themes, &iter, 0, "", -1); + for (GList *l = themes; l; l = l->next) { + IconTheme *theme = (IconTheme *)l->data; + GtkTreeIter iter; + gtk_list_store_append(icon_themes, &iter); + gtk_list_store_set(icon_themes, + &iter, + iconsColName, + g_strdup(theme->name), + iconsColDescr, + g_strdup(theme->description), + -1); + } - for (GList *l = themes; l; l = l->next) { - free_icon_theme((IconTheme*)l->data); - } - g_list_free(themes); - fprintf(stderr, "Icon themes loaded\n"); + for (GList *l = themes; l; l = l->next) { + free_icon_theme((IconTheme *)l->data); + } + g_list_free(themes); + fprintf(stderr, "Icon themes loaded\n"); - fprintf(stderr, "Loading .desktop files\n"); - GList *entries = NULL; - for (location = get_apps_locations(); location; location = g_slist_next(location)) { - const gchar *path = (gchar*) location->data; - load_desktop_entries(path, &entries); - } - entries = g_list_sort(entries, compare_entries); - populate_from_entries(entries, FALSE); + fprintf(stderr, "Loading .desktop files\n"); + GList *entries = NULL; + for (location = get_apps_locations(); location; location = g_slist_next(location)) { + const gchar *path = (gchar *)location->data; + load_desktop_entries(path, &entries); + } + entries = g_list_sort(entries, compare_entries); + populate_from_entries(entries, FALSE); - for (GList *l = entries; l; l = l->next) { - free_desktop_entry((DesktopEntry*)l->data); - } - g_list_free(entries); + for (GList *l = entries; l; l = l->next) { + free_desktop_entry((DesktopEntry *)l->data); + } + g_list_free(entries); - icon_theme_changed(window); - load_icons(launcher_apps); - load_icons(all_apps); - fprintf(stderr, "Desktop files loaded\n"); + icon_theme_changed(window); + load_icons(launcher_apps); + load_icons(all_apps); + fprintf(stderr, "Desktop files loaded\n"); } void create_taskbar(GtkWidget *parent) { - GtkWidget *table, *label; - int row, col; - GtkTooltips *tooltips = gtk_tooltips_new(); + GtkWidget *table, *label; + int row, col; + GtkTooltips *tooltips = gtk_tooltips_new(); - label = gtk_label_new(_("<b>Options</b>")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_label_set_use_markup(GTK_LABEL(label), TRUE); - gtk_widget_show(label); - gtk_box_pack_start(GTK_BOX(parent), label, FALSE, FALSE, 0); + label = gtk_label_new(_("<b>Options</b>")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_label_set_use_markup(GTK_LABEL(label), TRUE); + gtk_widget_show(label); + gtk_box_pack_start(GTK_BOX(parent), label, FALSE, FALSE, 0); - table = gtk_table_new(4, 2, FALSE); - gtk_widget_show(table); - gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); - gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); - gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); - row = col = 0; + table = gtk_table_new(4, 2, FALSE); + gtk_widget_show(table); + gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); + gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); + gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); + row = col = 0; - col = 2; - row++; - label = gtk_label_new(_("Show a taskbar for each desktop")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + col = 2; + row++; + label = gtk_label_new(_("Show a taskbar for each desktop")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - taskbar_show_desktop = gtk_check_button_new(); - gtk_widget_show(taskbar_show_desktop); - gtk_table_attach(GTK_TABLE(table), taskbar_show_desktop, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, taskbar_show_desktop, _("If enabled, the taskbar is split into multiple smaller taskbars, one for each virtual desktop."), NULL); + taskbar_show_desktop = gtk_check_button_new(); + gtk_widget_show(taskbar_show_desktop); + gtk_table_attach(GTK_TABLE(table), taskbar_show_desktop, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + taskbar_show_desktop, + _("If enabled, the taskbar is split into multiple smaller taskbars, one for each virtual " + "desktop."), + NULL); - col = 2; - row++; - label = gtk_label_new(_("Hide taskbars for empty desktops")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + col = 2; + row++; + label = gtk_label_new(_("Hide taskbars for empty desktops")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - taskbar_hide_empty = gtk_check_button_new(); - gtk_widget_show(taskbar_hide_empty); - gtk_table_attach(GTK_TABLE(table), taskbar_hide_empty, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + taskbar_hide_empty = gtk_check_button_new(); + gtk_widget_show(taskbar_hide_empty); + gtk_table_attach(GTK_TABLE(table), taskbar_hide_empty, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - col = 2; - row++; - label = gtk_label_new(_("Distribute size between taskbars")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + col = 2; + row++; + label = gtk_label_new(_("Distribute size between taskbars")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - taskbar_distribute_size = gtk_check_button_new(); - gtk_widget_show(taskbar_distribute_size); - gtk_table_attach(GTK_TABLE(table), taskbar_distribute_size, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, taskbar_distribute_size, _("If enabled and 'Show a taskbar for each desktop' is also enabled, " - "the available size is distributed between taskbars proportionally to the number of tasks."), NULL); + taskbar_distribute_size = gtk_check_button_new(); + gtk_widget_show(taskbar_distribute_size); + gtk_table_attach(GTK_TABLE(table), taskbar_distribute_size, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + taskbar_distribute_size, + _("If enabled and 'Show a taskbar for each desktop' is also enabled, " + "the available size is distributed between taskbars proportionally to the number of tasks."), + NULL); - col = 2; - row++; - label = gtk_label_new(_("Hide inactive tasks")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + col = 2; + row++; + label = gtk_label_new(_("Hide inactive tasks")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - taskbar_hide_inactive_tasks = gtk_check_button_new(); - gtk_widget_show(taskbar_hide_inactive_tasks); - gtk_table_attach(GTK_TABLE(table), taskbar_hide_inactive_tasks, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, taskbar_hide_inactive_tasks, _("If enabled, only the active task will be shown in the taskbar."), NULL); + taskbar_hide_inactive_tasks = gtk_check_button_new(); + gtk_widget_show(taskbar_hide_inactive_tasks); + gtk_table_attach(GTK_TABLE(table), taskbar_hide_inactive_tasks, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + taskbar_hide_inactive_tasks, + _("If enabled, only the active task will be shown in the taskbar."), + NULL); - col = 2; - row++; - label = gtk_label_new(_("Hide tasks from different monitors")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + col = 2; + row++; + label = gtk_label_new(_("Hide tasks from different monitors")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - taskbar_hide_diff_monitor = gtk_check_button_new(); - gtk_widget_show(taskbar_hide_diff_monitor); - gtk_table_attach(GTK_TABLE(table), taskbar_hide_diff_monitor, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, taskbar_hide_diff_monitor, _("If enabled, tasks that are not on the same monitor as the panel will not be displayed. " - "This behavior is enabled automatically if the panel monitor is set to 'All'."), NULL); + taskbar_hide_diff_monitor = gtk_check_button_new(); + gtk_widget_show(taskbar_hide_diff_monitor); + gtk_table_attach(GTK_TABLE(table), taskbar_hide_diff_monitor, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + taskbar_hide_diff_monitor, + _("If enabled, tasks that are not on the same monitor as the panel will not be displayed. " + "This behavior is enabled automatically if the panel monitor is set to 'All'."), + NULL); + col = 2; + row++; + label = gtk_label_new(_("Always show all desktop tasks")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - col = 2; - row++; - label = gtk_label_new(_("Always show all desktop tasks")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + taskbar_always_show_all_desktop_tasks = gtk_check_button_new(); + gtk_widget_show(taskbar_always_show_all_desktop_tasks); + gtk_table_attach(GTK_TABLE(table), + taskbar_always_show_all_desktop_tasks, + col, + col + 1, + row, + row + 1, + GTK_FILL, + 0, + 0, + 0); + col++; + gtk_tooltips_set_tip(tooltips, + taskbar_always_show_all_desktop_tasks, + _("Has effect only if 'Show a taskbar for each desktop' is enabled. " + "If enabled, tasks that appear on all desktops are shown on all taskbars. " + "Otherwise, they are shown only on the taskbar of the current desktop."), + NULL); - taskbar_always_show_all_desktop_tasks = gtk_check_button_new(); - gtk_widget_show(taskbar_always_show_all_desktop_tasks); - gtk_table_attach(GTK_TABLE(table), taskbar_always_show_all_desktop_tasks, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, taskbar_always_show_all_desktop_tasks, _("Has effect only if 'Show a taskbar for each desktop' is enabled. " - "If enabled, tasks that appear on all desktops are shown on all taskbars. " - "Otherwise, they are shown only on the taskbar of the current desktop."), NULL); + row++; + col = 2; + label = gtk_label_new(_("Task sorting")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - row++; - col = 2; - label = gtk_label_new(_("Task sorting")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + taskbar_sort_order = gtk_combo_box_new_text(); + gtk_widget_show(taskbar_sort_order); + gtk_table_attach(GTK_TABLE(table), taskbar_sort_order, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_combo_box_append_text(GTK_COMBO_BOX(taskbar_sort_order), _("None")); + gtk_combo_box_append_text(GTK_COMBO_BOX(taskbar_sort_order), _("By title")); + gtk_combo_box_append_text(GTK_COMBO_BOX(taskbar_sort_order), _("By center")); + gtk_combo_box_append_text(GTK_COMBO_BOX(taskbar_sort_order), _("Most recently used first")); + gtk_combo_box_append_text(GTK_COMBO_BOX(taskbar_sort_order), _("Most recently used last")); + gtk_combo_box_set_active(GTK_COMBO_BOX(taskbar_sort_order), 0); + gtk_tooltips_set_tip(tooltips, + taskbar_sort_order, + _("Specifies how tasks should be sorted on the taskbar. \n" + "'None' means that new tasks are added to the end, and the user can also reorder task " + "buttons by mouse dragging. \n" + "'By title' means that tasks are sorted by their window titles. \n" + "'By center' means that tasks are sorted geometrically by their window centers."), + NULL); - taskbar_sort_order = gtk_combo_box_new_text(); - gtk_widget_show(taskbar_sort_order); - gtk_table_attach(GTK_TABLE(table), taskbar_sort_order, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_combo_box_append_text(GTK_COMBO_BOX(taskbar_sort_order), _("None")); - gtk_combo_box_append_text(GTK_COMBO_BOX(taskbar_sort_order), _("By title")); - gtk_combo_box_append_text(GTK_COMBO_BOX(taskbar_sort_order), _("By center")); - gtk_combo_box_append_text(GTK_COMBO_BOX(taskbar_sort_order), _("Most recently used first")); - gtk_combo_box_append_text(GTK_COMBO_BOX(taskbar_sort_order), _("Most recently used last")); - gtk_combo_box_set_active(GTK_COMBO_BOX(taskbar_sort_order), 0); - gtk_tooltips_set_tip(tooltips, taskbar_sort_order, _("Specifies how tasks should be sorted on the taskbar. \n" - "'None' means that new tasks are added to the end, and the user can also reorder task buttons by mouse dragging. \n" - "'By title' means that tasks are sorted by their window titles. \n" - "'By center' means that tasks are sorted geometrically by their window centers."), NULL); + row++; + col = 2; + label = gtk_label_new(_("Task alignment")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - row++; - col = 2; - label = gtk_label_new(_("Task alignment")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + taskbar_alignment = gtk_combo_box_new_text(); + gtk_widget_show(taskbar_alignment); + gtk_table_attach(GTK_TABLE(table), taskbar_alignment, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_combo_box_append_text(GTK_COMBO_BOX(taskbar_alignment), _("Left")); + gtk_combo_box_append_text(GTK_COMBO_BOX(taskbar_alignment), _("Center")); + gtk_combo_box_append_text(GTK_COMBO_BOX(taskbar_alignment), _("Right")); + gtk_combo_box_set_active(GTK_COMBO_BOX(taskbar_alignment), 0); + gtk_tooltips_set_tip(tooltips, + taskbar_alignment, + _("Specifies how tasks should be positioned on the taskbar."), + NULL); - taskbar_alignment = gtk_combo_box_new_text(); - gtk_widget_show(taskbar_alignment); - gtk_table_attach(GTK_TABLE(table), taskbar_alignment, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_combo_box_append_text(GTK_COMBO_BOX(taskbar_alignment), _("Left")); - gtk_combo_box_append_text(GTK_COMBO_BOX(taskbar_alignment), _("Center")); - gtk_combo_box_append_text(GTK_COMBO_BOX(taskbar_alignment), _("Right")); - gtk_combo_box_set_active(GTK_COMBO_BOX(taskbar_alignment), 0); - gtk_tooltips_set_tip(tooltips, taskbar_alignment, _("Specifies how tasks should be positioned on the taskbar."), NULL); + change_paragraph(parent); - change_paragraph(parent); + label = gtk_label_new(_("<b>Appearance</b>")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_label_set_use_markup(GTK_LABEL(label), TRUE); + gtk_widget_show(label); + gtk_box_pack_start(GTK_BOX(parent), label, FALSE, FALSE, 0); - label = gtk_label_new(_("<b>Appearance</b>")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_label_set_use_markup(GTK_LABEL(label), TRUE); - gtk_widget_show(label); - gtk_box_pack_start(GTK_BOX(parent), label, FALSE, FALSE, 0); + table = gtk_table_new(3, 12, FALSE); + gtk_widget_show(table); + gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); + gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); + gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); + row = col = 0; - table = gtk_table_new(3, 12, FALSE); - gtk_widget_show(table); - gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); - gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); - gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); - row = col = 0; + col = 2; + label = gtk_label_new(_("Horizontal padding")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - col = 2; - label = gtk_label_new(_("Horizontal padding")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + taskbar_padding_x = gtk_spin_button_new_with_range(0, 500, 1); + gtk_widget_show(taskbar_padding_x); + gtk_table_attach(GTK_TABLE(table), taskbar_padding_x, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + taskbar_padding_x, + _("Specifies the horizontal padding of the taskbar. " + "This is the space between the border and the elements inside."), + NULL); - taskbar_padding_x = gtk_spin_button_new_with_range(0, 500, 1); - gtk_widget_show(taskbar_padding_x); - gtk_table_attach(GTK_TABLE(table), taskbar_padding_x, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, taskbar_padding_x, _("Specifies the horizontal padding of the taskbar. " - "This is the space between the border and the elements inside."), NULL); + col = 2; + row++; + label = gtk_label_new(_("Vertical padding")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - col = 2; - row++; - label = gtk_label_new(_("Vertical padding")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + taskbar_padding_y = gtk_spin_button_new_with_range(0, 500, 1); + gtk_widget_show(taskbar_padding_y); + gtk_table_attach(GTK_TABLE(table), taskbar_padding_y, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + taskbar_padding_y, + _("Specifies the vertical padding of the taskbar. " + "This is the space between the border and the elements inside."), + NULL); - taskbar_padding_y = gtk_spin_button_new_with_range(0, 500, 1); - gtk_widget_show(taskbar_padding_y); - gtk_table_attach(GTK_TABLE(table), taskbar_padding_y, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, taskbar_padding_y, _("Specifies the vertical padding of the taskbar. " - "This is the space between the border and the elements inside."), NULL); + col = 2; + row++; + label = gtk_label_new(_("Spacing")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - col = 2; - row++; - label = gtk_label_new(_("Spacing")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + taskbar_spacing = gtk_spin_button_new_with_range(0, 500, 1); + gtk_widget_show(taskbar_spacing); + gtk_table_attach(GTK_TABLE(table), taskbar_spacing, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + taskbar_spacing, + _("Specifies the spacing between the elements inside the taskbar."), + NULL); - taskbar_spacing = gtk_spin_button_new_with_range(0, 500, 1); - gtk_widget_show(taskbar_spacing); - gtk_table_attach(GTK_TABLE(table), taskbar_spacing, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, taskbar_spacing, _("Specifies the spacing between the elements inside the taskbar."), NULL); + col = 2; + row++; + label = gtk_label_new(_("Active background")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - col = 2; - row++; - label = gtk_label_new(_("Active background")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + taskbar_active_background = create_background_combo(_("Active taskbar")); + gtk_widget_show(taskbar_active_background); + gtk_table_attach(GTK_TABLE(table), taskbar_active_background, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + taskbar_active_background, + _("Selects the background used to display the taskbar of the current desktop. " + "Backgrounds can be edited in the Backgrounds tab."), + NULL); + col = 2; + row++; + label = gtk_label_new(_("Inactive background")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - taskbar_active_background = create_background_combo(_("Active taskbar")); - gtk_widget_show(taskbar_active_background); - gtk_table_attach(GTK_TABLE(table), taskbar_active_background, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, taskbar_active_background, _("Selects the background used to display the taskbar of the current desktop. " - "Backgrounds can be edited in the Backgrounds tab."), NULL); - col = 2; - row++; - label = gtk_label_new(_("Inactive background")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + taskbar_inactive_background = create_background_combo(_("Inactive taskbar")); + gtk_widget_show(taskbar_inactive_background); + gtk_table_attach(GTK_TABLE(table), taskbar_inactive_background, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + taskbar_inactive_background, + _("Selects the background used to display taskbars of inactive desktops. " + "Backgrounds can be edited in the Backgrounds tab."), + NULL); - taskbar_inactive_background = create_background_combo(_("Inactive taskbar")); - gtk_widget_show(taskbar_inactive_background); - gtk_table_attach(GTK_TABLE(table), taskbar_inactive_background, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, taskbar_inactive_background, _("Selects the background used to display taskbars of inactive desktops. " - "Backgrounds can be edited in the Backgrounds tab."), NULL); + change_paragraph(parent); - change_paragraph(parent); + label = gtk_label_new(_("<b>Desktop name</b>")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_label_set_use_markup(GTK_LABEL(label), TRUE); + gtk_widget_show(label); + gtk_box_pack_start(GTK_BOX(parent), label, FALSE, FALSE, 0); - label = gtk_label_new(_("<b>Desktop name</b>")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_label_set_use_markup(GTK_LABEL(label), TRUE); - gtk_widget_show(label); - gtk_box_pack_start(GTK_BOX(parent), label, FALSE, FALSE, 0); + table = gtk_table_new(6, 22, FALSE); + gtk_widget_show(table); + gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); + gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); + gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); + row = col = 0; - table = gtk_table_new(6, 22, FALSE); - gtk_widget_show(table); - gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); - gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); - gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); - row = col = 0; + col = 2; + row++; + label = gtk_label_new(_("Show desktop name")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - col = 2; - row++; - label = gtk_label_new(_("Show desktop name")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + taskbar_show_name = gtk_check_button_new(); + gtk_widget_show(taskbar_show_name); + gtk_table_attach(GTK_TABLE(table), taskbar_show_name, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + taskbar_show_name, + _("If enabled, displays the name of the desktop at the top/left of the taskbar. " + "The name is set by your window manager; you might be able to configure it there."), + NULL); - taskbar_show_name = gtk_check_button_new(); - gtk_widget_show(taskbar_show_name); - gtk_table_attach(GTK_TABLE(table), taskbar_show_name, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, taskbar_show_name, _("If enabled, displays the name of the desktop at the top/left of the taskbar. " - "The name is set by your window manager; you might be able to configure it there."), NULL); + col = 2; + row++; + label = gtk_label_new(_("Horizontal padding")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - col = 2; - row++; - label = gtk_label_new(_("Horizontal padding")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + taskbar_name_padding_x = gtk_spin_button_new_with_range(0, 500, 1); + gtk_widget_show(taskbar_name_padding_x); + gtk_table_attach(GTK_TABLE(table), taskbar_name_padding_x, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + taskbar_name_padding_x, + _("Specifies the horizontal padding of the desktop name. " + "This is the space between the border and the text inside."), + NULL); - taskbar_name_padding_x = gtk_spin_button_new_with_range(0, 500, 1); - gtk_widget_show(taskbar_name_padding_x); - gtk_table_attach(GTK_TABLE(table), taskbar_name_padding_x, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, taskbar_name_padding_x, _("Specifies the horizontal padding of the desktop name. " - "This is the space between the border and the text inside."), NULL); + col = 2; + row++; + label = gtk_label_new(_("Vertical padding")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - col = 2; - row++; - label = gtk_label_new(_("Vertical padding")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + taskbar_name_padding_y = gtk_spin_button_new_with_range(0, 500, 1); + gtk_widget_show(taskbar_name_padding_y); + gtk_table_attach(GTK_TABLE(table), taskbar_name_padding_y, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + taskbar_name_padding_y, + _("Specifies the vertical padding of the desktop name. " + "This is the space between the border and the text inside."), + NULL); - taskbar_name_padding_y = gtk_spin_button_new_with_range(0, 500, 1); - gtk_widget_show(taskbar_name_padding_y); - gtk_table_attach(GTK_TABLE(table), taskbar_name_padding_y, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, taskbar_name_padding_y, _("Specifies the vertical padding of the desktop name. " - "This is the space between the border and the text inside."), NULL); + col = 2; + row++; + label = gtk_label_new(_("Active font color")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - col = 2; - row++; - label = gtk_label_new(_("Active font color")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + taskbar_name_active_color = gtk_color_button_new(); + gtk_color_button_set_use_alpha(GTK_COLOR_BUTTON(taskbar_name_active_color), TRUE); + gtk_widget_show(taskbar_name_active_color); + gtk_table_attach(GTK_TABLE(table), taskbar_name_active_color, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + taskbar_name_active_color, + _("Specifies the font color used to display the name of the current desktop."), + NULL); - taskbar_name_active_color = gtk_color_button_new(); - gtk_color_button_set_use_alpha(GTK_COLOR_BUTTON(taskbar_name_active_color), TRUE); - gtk_widget_show(taskbar_name_active_color); - gtk_table_attach(GTK_TABLE(table), taskbar_name_active_color, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, taskbar_name_active_color, _("Specifies the font color used to display the name of the current desktop."), NULL); - - col = 2; - row++; - label = gtk_label_new(_("Inactive font color")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + col = 2; + row++; + label = gtk_label_new(_("Inactive font color")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - taskbar_name_inactive_color = gtk_color_button_new(); - gtk_color_button_set_use_alpha(GTK_COLOR_BUTTON(taskbar_name_inactive_color), TRUE); - gtk_widget_show(taskbar_name_inactive_color); - gtk_table_attach(GTK_TABLE(table), taskbar_name_inactive_color, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, taskbar_name_inactive_color, _("Specifies the font color used to display the name of inactive desktops."), NULL); + taskbar_name_inactive_color = gtk_color_button_new(); + gtk_color_button_set_use_alpha(GTK_COLOR_BUTTON(taskbar_name_inactive_color), TRUE); + gtk_widget_show(taskbar_name_inactive_color); + gtk_table_attach(GTK_TABLE(table), taskbar_name_inactive_color, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + taskbar_name_inactive_color, + _("Specifies the font color used to display the name of inactive desktops."), + NULL); - col = 1; - row++; - taskbar_name_font_set = gtk_check_button_new(); - gtk_widget_show(taskbar_name_font_set); - gtk_table_attach(GTK_TABLE(table), taskbar_name_font_set, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - gtk_tooltips_set_tip(tooltips, taskbar_name_font_set, _("If not checked, the desktop theme font is used. If checked, the custom font specified here is used."), NULL); - col++; + col = 1; + row++; + taskbar_name_font_set = gtk_check_button_new(); + gtk_widget_show(taskbar_name_font_set); + gtk_table_attach(GTK_TABLE(table), taskbar_name_font_set, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + gtk_tooltips_set_tip(tooltips, + taskbar_name_font_set, + _("If not checked, the desktop theme font is used. If checked, the custom font specified here " + "is used."), + NULL); + col++; - label = gtk_label_new(_("Font")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + label = gtk_label_new(_("Font")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - PangoFontDescription *taskbar_name_font_desc = pango_font_description_from_string(get_default_font()); - pango_font_description_set_weight(taskbar_name_font_desc, PANGO_WEIGHT_BOLD); - taskbar_name_font = gtk_font_button_new_with_font(pango_font_description_to_string(taskbar_name_font_desc)); - pango_font_description_free(taskbar_name_font_desc); - gtk_widget_show(taskbar_name_font); - gtk_table_attach(GTK_TABLE(table), taskbar_name_font, col, col+3, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_font_button_set_show_style(GTK_FONT_BUTTON(taskbar_name_font), TRUE); - gtk_tooltips_set_tip(tooltips, taskbar_name_font, _("Specifies the font used to display the desktop name."), NULL); - gtk_signal_connect(GTK_OBJECT(taskbar_name_font_set), "toggled", GTK_SIGNAL_FUNC(font_set_callback), taskbar_name_font); - font_set_callback(taskbar_name_font_set, taskbar_name_font); + PangoFontDescription *taskbar_name_font_desc = pango_font_description_from_string(get_default_font()); + pango_font_description_set_weight(taskbar_name_font_desc, PANGO_WEIGHT_BOLD); + taskbar_name_font = gtk_font_button_new_with_font(pango_font_description_to_string(taskbar_name_font_desc)); + pango_font_description_free(taskbar_name_font_desc); + gtk_widget_show(taskbar_name_font); + gtk_table_attach(GTK_TABLE(table), taskbar_name_font, col, col + 3, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_font_button_set_show_style(GTK_FONT_BUTTON(taskbar_name_font), TRUE); + gtk_tooltips_set_tip(tooltips, taskbar_name_font, _("Specifies the font used to display the desktop name."), NULL); + gtk_signal_connect(GTK_OBJECT(taskbar_name_font_set), + "toggled", + GTK_SIGNAL_FUNC(font_set_callback), + taskbar_name_font); + font_set_callback(taskbar_name_font_set, taskbar_name_font); - col = 2; - row++; - label = gtk_label_new(_("Active background")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + col = 2; + row++; + label = gtk_label_new(_("Active background")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - taskbar_name_active_background = create_background_combo(_("Active desktop name")); - gtk_widget_show(taskbar_name_active_background); - gtk_table_attach(GTK_TABLE(table), taskbar_name_active_background, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, taskbar_name_active_background, _("Selects the background used to display the name of the current desktop. " - "Backgrounds can be edited in the Backgrounds tab."), NULL); + taskbar_name_active_background = create_background_combo(_("Active desktop name")); + gtk_widget_show(taskbar_name_active_background); + gtk_table_attach(GTK_TABLE(table), taskbar_name_active_background, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + taskbar_name_active_background, + _("Selects the background used to display the name of the current desktop. " + "Backgrounds can be edited in the Backgrounds tab."), + NULL); - col = 2; - row++; - label = gtk_label_new(_("Inactive background")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + col = 2; + row++; + label = gtk_label_new(_("Inactive background")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - taskbar_name_inactive_background = create_background_combo(_("Inactive desktop name")); - gtk_widget_show(taskbar_name_inactive_background); - gtk_table_attach(GTK_TABLE(table), taskbar_name_inactive_background, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, taskbar_name_inactive_background, _("Selects the background used to display the name of inactive desktops. " - "Backgrounds can be edited in the Backgrounds tab."), NULL); + taskbar_name_inactive_background = create_background_combo(_("Inactive desktop name")); + gtk_widget_show(taskbar_name_inactive_background); + gtk_table_attach(GTK_TABLE(table), taskbar_name_inactive_background, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + taskbar_name_inactive_background, + _("Selects the background used to display the name of inactive desktops. " + "Backgrounds can be edited in the Backgrounds tab."), + NULL); - change_paragraph(parent); + change_paragraph(parent); } void create_task(GtkWidget *parent) { - GtkWidget *table, *label, *notebook; - int row, col; - GtkTooltips *tooltips = gtk_tooltips_new(); + GtkWidget *table, *label, *notebook; + int row, col; + GtkTooltips *tooltips = gtk_tooltips_new(); - label = gtk_label_new(_("<b>Mouse events</b>")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_label_set_use_markup(GTK_LABEL(label), TRUE); - gtk_widget_show(label); - gtk_box_pack_start(GTK_BOX(parent), label, FALSE, FALSE, 0); + label = gtk_label_new(_("<b>Mouse events</b>")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_label_set_use_markup(GTK_LABEL(label), TRUE); + gtk_widget_show(label); + gtk_box_pack_start(GTK_BOX(parent), label, FALSE, FALSE, 0); - table = gtk_table_new(3, 10, FALSE); - gtk_widget_show(table); - gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); - gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); - gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); - row = 0, col = 2; + table = gtk_table_new(3, 10, FALSE); + gtk_widget_show(table); + gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); + gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); + gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); + row = 0, col = 2; - label = gtk_label_new(_("Left click")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + label = gtk_label_new(_("Left click")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - task_mouse_left = gtk_combo_box_new_text(); - gtk_widget_show(task_mouse_left); - gtk_table_attach(GTK_TABLE(table), task_mouse_left, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_left), _("None")); - gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_left), _("Close")); - gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_left), _("Toggle")); - gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_left), _("Iconify")); - gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_left), _("Shade")); - gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_left), _("Toggle or iconify")); - gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_left), _("Maximize or restore")); - gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_left), _("Desktop left")); - gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_left), _("Desktop right")); - gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_left), _("Next task")); - gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_left), _("Previous task")); - gtk_combo_box_set_active(GTK_COMBO_BOX(task_mouse_left), 5); - gtk_tooltips_set_tip(tooltips, task_mouse_left, _("Specifies the action performed when task buttons receive a left click event: \n" - "'None' means that no action is taken. \n" - "'Close' closes the task. \n" - "'Toggle' toggles the task. \n" - "'Iconify' iconifies (minimizes) the task. \n" - "'Shade' shades (collapses) the task. \n" - "'Toggle or iconify' toggles or iconifies the task. \n" - "'Maximize or restore' maximizes or minimizes the task. \n" - "'Desktop left' sends the task to the previous desktop. \n" - "'Desktop right' sends the task to the next desktop. \n" - "'Next task' sends the focus to the next task. \n" - "'Previous task' sends the focus to the previous task."), NULL); + task_mouse_left = gtk_combo_box_new_text(); + gtk_widget_show(task_mouse_left); + gtk_table_attach(GTK_TABLE(table), task_mouse_left, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_left), _("None")); + gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_left), _("Close")); + gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_left), _("Toggle")); + gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_left), _("Iconify")); + gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_left), _("Shade")); + gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_left), _("Toggle or iconify")); + gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_left), _("Maximize or restore")); + gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_left), _("Desktop left")); + gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_left), _("Desktop right")); + gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_left), _("Next task")); + gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_left), _("Previous task")); + gtk_combo_box_set_active(GTK_COMBO_BOX(task_mouse_left), 5); + gtk_tooltips_set_tip(tooltips, + task_mouse_left, + _("Specifies the action performed when task buttons receive a left click event: \n" + "'None' means that no action is taken. \n" + "'Close' closes the task. \n" + "'Toggle' toggles the task. \n" + "'Iconify' iconifies (minimizes) the task. \n" + "'Shade' shades (collapses) the task. \n" + "'Toggle or iconify' toggles or iconifies the task. \n" + "'Maximize or restore' maximizes or minimizes the task. \n" + "'Desktop left' sends the task to the previous desktop. \n" + "'Desktop right' sends the task to the next desktop. \n" + "'Next task' sends the focus to the next task. \n" + "'Previous task' sends the focus to the previous task."), + NULL); - row++, col = 2; - label = gtk_label_new(_("Wheel scroll up")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Wheel scroll up")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - task_mouse_scroll_up = gtk_combo_box_new_text(); - gtk_widget_show(task_mouse_scroll_up); - gtk_table_attach(GTK_TABLE(table), task_mouse_scroll_up, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_scroll_up), _("None")); - gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_scroll_up), _("Close")); - gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_scroll_up), _("Toggle")); - gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_scroll_up), _("Iconify")); - gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_scroll_up), _("Shade")); - gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_scroll_up), _("Toggle or iconify")); - gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_scroll_up), _("Maximize or restore")); - gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_scroll_up), _("Desktop left")); - gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_scroll_up), _("Desktop right")); - gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_scroll_up), _("Next task")); - gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_scroll_up), _("Previous task")); - gtk_combo_box_set_active(GTK_COMBO_BOX(task_mouse_scroll_up), 0); - gtk_tooltips_set_tip(tooltips, task_mouse_scroll_up, _("Specifies the action performed when task buttons receive a scroll up event: \n" - "'None' means that no action is taken. \n" - "'Close' closes the task. \n" - "'Toggle' toggles the task. \n" - "'Iconify' iconifies (minimizes) the task. \n" - "'Shade' shades (collapses) the task. \n" - "'Toggle or iconify' toggles or iconifies the task. \n" - "'Maximize or restore' maximizes or minimizes the task. \n" - "'Desktop left' sends the task to the previous desktop. \n" - "'Desktop right' sends the task to the next desktop. \n" - "'Next task' sends the focus to the next task. \n" - "'Previous task' sends the focus to the previous task."), NULL); + task_mouse_scroll_up = gtk_combo_box_new_text(); + gtk_widget_show(task_mouse_scroll_up); + gtk_table_attach(GTK_TABLE(table), task_mouse_scroll_up, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_scroll_up), _("None")); + gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_scroll_up), _("Close")); + gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_scroll_up), _("Toggle")); + gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_scroll_up), _("Iconify")); + gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_scroll_up), _("Shade")); + gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_scroll_up), _("Toggle or iconify")); + gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_scroll_up), _("Maximize or restore")); + gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_scroll_up), _("Desktop left")); + gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_scroll_up), _("Desktop right")); + gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_scroll_up), _("Next task")); + gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_scroll_up), _("Previous task")); + gtk_combo_box_set_active(GTK_COMBO_BOX(task_mouse_scroll_up), 0); + gtk_tooltips_set_tip(tooltips, + task_mouse_scroll_up, + _("Specifies the action performed when task buttons receive a scroll up event: \n" + "'None' means that no action is taken. \n" + "'Close' closes the task. \n" + "'Toggle' toggles the task. \n" + "'Iconify' iconifies (minimizes) the task. \n" + "'Shade' shades (collapses) the task. \n" + "'Toggle or iconify' toggles or iconifies the task. \n" + "'Maximize or restore' maximizes or minimizes the task. \n" + "'Desktop left' sends the task to the previous desktop. \n" + "'Desktop right' sends the task to the next desktop. \n" + "'Next task' sends the focus to the next task. \n" + "'Previous task' sends the focus to the previous task."), + NULL); - row++, col = 2; - label = gtk_label_new(_("Middle click")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Middle click")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - task_mouse_middle = gtk_combo_box_new_text(); - gtk_widget_show(task_mouse_middle); - gtk_table_attach(GTK_TABLE(table), task_mouse_middle, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_middle), _("None")); - gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_middle), _("Close")); - gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_middle), _("Toggle")); - gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_middle), _("Iconify")); - gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_middle), _("Shade")); - gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_middle), _("Toggle or iconify")); - gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_middle), _("Maximize or restore")); - gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_middle), _("Desktop left")); - gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_middle), _("Desktop right")); - gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_middle), _("Next task")); - gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_middle), _("Previous task")); - gtk_combo_box_set_active(GTK_COMBO_BOX(task_mouse_middle), 0); - gtk_tooltips_set_tip(tooltips, task_mouse_middle, _("Specifies the action performed when task buttons receive a middle click event: \n" - "'None' means that no action is taken. \n" - "'Close' closes the task. \n" - "'Toggle' toggles the task. \n" - "'Iconify' iconifies (minimizes) the task. \n" - "'Shade' shades (collapses) the task. \n" - "'Toggle or iconify' toggles or iconifies the task. \n" - "'Maximize or restore' maximizes or minimizes the task. \n" - "'Desktop left' sends the task to the previous desktop. \n" - "'Desktop right' sends the task to the next desktop. \n" - "'Next task' sends the focus to the next task. \n" - "'Previous task' sends the focus to the previous task."), NULL); + task_mouse_middle = gtk_combo_box_new_text(); + gtk_widget_show(task_mouse_middle); + gtk_table_attach(GTK_TABLE(table), task_mouse_middle, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_middle), _("None")); + gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_middle), _("Close")); + gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_middle), _("Toggle")); + gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_middle), _("Iconify")); + gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_middle), _("Shade")); + gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_middle), _("Toggle or iconify")); + gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_middle), _("Maximize or restore")); + gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_middle), _("Desktop left")); + gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_middle), _("Desktop right")); + gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_middle), _("Next task")); + gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_middle), _("Previous task")); + gtk_combo_box_set_active(GTK_COMBO_BOX(task_mouse_middle), 0); + gtk_tooltips_set_tip(tooltips, + task_mouse_middle, + _("Specifies the action performed when task buttons receive a middle click event: \n" + "'None' means that no action is taken. \n" + "'Close' closes the task. \n" + "'Toggle' toggles the task. \n" + "'Iconify' iconifies (minimizes) the task. \n" + "'Shade' shades (collapses) the task. \n" + "'Toggle or iconify' toggles or iconifies the task. \n" + "'Maximize or restore' maximizes or minimizes the task. \n" + "'Desktop left' sends the task to the previous desktop. \n" + "'Desktop right' sends the task to the next desktop. \n" + "'Next task' sends the focus to the next task. \n" + "'Previous task' sends the focus to the previous task."), + NULL); - row++, col = 2; - label = gtk_label_new(_("Wheel scroll down")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Wheel scroll down")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - task_mouse_scroll_down = gtk_combo_box_new_text(); - gtk_widget_show(task_mouse_scroll_down); - gtk_table_attach(GTK_TABLE(table), task_mouse_scroll_down, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_scroll_down), _("None")); - gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_scroll_down), _("Close")); - gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_scroll_down), _("Toggle")); - gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_scroll_down), _("Iconify")); - gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_scroll_down), _("Shade")); - gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_scroll_down), _("Toggle or iconify")); - gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_scroll_down), _("Maximize or restore")); - gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_scroll_down), _("Desktop left")); - gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_scroll_down), _("Desktop right")); - gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_scroll_down), _("Next task")); - gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_scroll_down), _("Previous task")); - gtk_combo_box_set_active(GTK_COMBO_BOX(task_mouse_scroll_down), 0); - gtk_tooltips_set_tip(tooltips, task_mouse_scroll_down, _("Specifies the action performed when task buttons receive a scroll down event: \n" - "'None' means that no action is taken. \n" - "'Close' closes the task. \n" - "'Toggle' toggles the task. \n" - "'Iconify' iconifies (minimizes) the task. \n" - "'Shade' shades (collapses) the task. \n" - "'Toggle or iconify' toggles or iconifies the task. \n" - "'Maximize or restore' maximizes or minimizes the task. \n" - "'Desktop left' sends the task to the previous desktop. \n" - "'Desktop right' sends the task to the next desktop. \n" - "'Next task' sends the focus to the next task. \n" - "'Previous task' sends the focus to the previous task."), NULL); + task_mouse_scroll_down = gtk_combo_box_new_text(); + gtk_widget_show(task_mouse_scroll_down); + gtk_table_attach(GTK_TABLE(table), task_mouse_scroll_down, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_scroll_down), _("None")); + gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_scroll_down), _("Close")); + gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_scroll_down), _("Toggle")); + gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_scroll_down), _("Iconify")); + gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_scroll_down), _("Shade")); + gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_scroll_down), _("Toggle or iconify")); + gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_scroll_down), _("Maximize or restore")); + gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_scroll_down), _("Desktop left")); + gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_scroll_down), _("Desktop right")); + gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_scroll_down), _("Next task")); + gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_scroll_down), _("Previous task")); + gtk_combo_box_set_active(GTK_COMBO_BOX(task_mouse_scroll_down), 0); + gtk_tooltips_set_tip(tooltips, + task_mouse_scroll_down, + _("Specifies the action performed when task buttons receive a scroll down event: \n" + "'None' means that no action is taken. \n" + "'Close' closes the task. \n" + "'Toggle' toggles the task. \n" + "'Iconify' iconifies (minimizes) the task. \n" + "'Shade' shades (collapses) the task. \n" + "'Toggle or iconify' toggles or iconifies the task. \n" + "'Maximize or restore' maximizes or minimizes the task. \n" + "'Desktop left' sends the task to the previous desktop. \n" + "'Desktop right' sends the task to the next desktop. \n" + "'Next task' sends the focus to the next task. \n" + "'Previous task' sends the focus to the previous task."), + NULL); - row++, col = 2; - label = gtk_label_new(_("Right click")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Right click")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - task_mouse_right = gtk_combo_box_new_text(); - gtk_widget_show(task_mouse_right); - gtk_table_attach(GTK_TABLE(table), task_mouse_right, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_right), _("None")); - gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_right), _("Close")); - gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_right), _("Toggle")); - gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_right), _("Iconify")); - gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_right), _("Shade")); - gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_right), _("Toggle or iconify")); - gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_right), _("Maximize or restore")); - gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_right), _("Desktop left")); - gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_right), _("Desktop right")); - gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_right), _("Next task")); - gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_right), _("Previous task")); - gtk_combo_box_set_active(GTK_COMBO_BOX(task_mouse_right), 1); - gtk_tooltips_set_tip(tooltips, task_mouse_right, _("Specifies the action performed when task buttons receive a right click event: \n" - "'None' means that no action is taken. \n" - "'Close' closes the task. \n" - "'Toggle' toggles the task. \n" - "'Iconify' iconifies (minimizes) the task. \n" - "'Shade' shades (collapses) the task. \n" - "'Toggle or iconify' toggles or iconifies the task. \n" - "'Maximize or restore' maximizes or minimizes the task. \n" - "'Desktop left' sends the task to the previous desktop. \n" - "'Desktop right' sends the task to the next desktop. \n" - "'Next task' sends the focus to the next task. \n" - "'Previous task' sends the focus to the previous task."), NULL); + task_mouse_right = gtk_combo_box_new_text(); + gtk_widget_show(task_mouse_right); + gtk_table_attach(GTK_TABLE(table), task_mouse_right, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_right), _("None")); + gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_right), _("Close")); + gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_right), _("Toggle")); + gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_right), _("Iconify")); + gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_right), _("Shade")); + gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_right), _("Toggle or iconify")); + gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_right), _("Maximize or restore")); + gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_right), _("Desktop left")); + gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_right), _("Desktop right")); + gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_right), _("Next task")); + gtk_combo_box_append_text(GTK_COMBO_BOX(task_mouse_right), _("Previous task")); + gtk_combo_box_set_active(GTK_COMBO_BOX(task_mouse_right), 1); + gtk_tooltips_set_tip(tooltips, + task_mouse_right, + _("Specifies the action performed when task buttons receive a right click event: \n" + "'None' means that no action is taken. \n" + "'Close' closes the task. \n" + "'Toggle' toggles the task. \n" + "'Iconify' iconifies (minimizes) the task. \n" + "'Shade' shades (collapses) the task. \n" + "'Toggle or iconify' toggles or iconifies the task. \n" + "'Maximize or restore' maximizes or minimizes the task. \n" + "'Desktop left' sends the task to the previous desktop. \n" + "'Desktop right' sends the task to the next desktop. \n" + "'Next task' sends the focus to the next task. \n" + "'Previous task' sends the focus to the previous task."), + NULL); - change_paragraph(parent); + change_paragraph(parent); - label = gtk_label_new(_("<b>Appearance</b>")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_label_set_use_markup(GTK_LABEL(label), TRUE); - gtk_widget_show(label); - gtk_box_pack_start(GTK_BOX(parent), label, FALSE, FALSE, 0); + label = gtk_label_new(_("<b>Appearance</b>")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_label_set_use_markup(GTK_LABEL(label), TRUE); + gtk_widget_show(label); + gtk_box_pack_start(GTK_BOX(parent), label, FALSE, FALSE, 0); - table = gtk_table_new(4, 13, FALSE); - gtk_widget_show(table); - gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); - gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); - gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); - row = 0, col = 2; + table = gtk_table_new(4, 13, FALSE); + gtk_widget_show(table); + gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); + gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); + gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); + row = 0, col = 2; - label = gtk_label_new(_("Show icon")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + label = gtk_label_new(_("Show icon")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - task_show_icon = gtk_check_button_new(); - gtk_widget_show(task_show_icon); - gtk_table_attach(GTK_TABLE(table), task_show_icon, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, task_show_icon, _("If enabled, the window icon is shown on task buttons."), NULL); + task_show_icon = gtk_check_button_new(); + gtk_widget_show(task_show_icon); + gtk_table_attach(GTK_TABLE(table), task_show_icon, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, task_show_icon, _("If enabled, the window icon is shown on task buttons."), NULL); - row++, col = 2; - label = gtk_label_new(_("Show text")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Show text")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - task_show_text = gtk_check_button_new(); - gtk_widget_show(task_show_text); - gtk_table_attach(GTK_TABLE(table), task_show_text, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, task_show_text, _("If enabled, the window title is shown on task buttons."), NULL); + task_show_text = gtk_check_button_new(); + gtk_widget_show(task_show_text); + gtk_table_attach(GTK_TABLE(table), task_show_text, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, task_show_text, _("If enabled, the window title is shown on task buttons."), NULL); - row++, col = 2; - label = gtk_label_new(_("Center text")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Center text")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - task_align_center = gtk_check_button_new(); - gtk_widget_show(task_align_center); - gtk_table_attach(GTK_TABLE(table), task_align_center, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, task_align_center, _("If enabled, the text is centered on task buttons. Otherwise, it is left-aligned."), NULL); + task_align_center = gtk_check_button_new(); + gtk_widget_show(task_align_center); + gtk_table_attach(GTK_TABLE(table), task_align_center, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + task_align_center, + _("If enabled, the text is centered on task buttons. Otherwise, it is left-aligned."), + NULL); - row++, col = 2; - label = gtk_label_new(_("Show tooltips")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Show tooltips")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - tooltip_task_show = gtk_check_button_new(); - gtk_widget_show(tooltip_task_show); - gtk_table_attach(GTK_TABLE(table), tooltip_task_show, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, tooltip_task_show, _("If enabled, a tooltip showing the window title is displayed when the mouse cursor moves over task buttons."), NULL); + tooltip_task_show = gtk_check_button_new(); + gtk_widget_show(tooltip_task_show); + gtk_table_attach(GTK_TABLE(table), tooltip_task_show, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + tooltip_task_show, + _("If enabled, a tooltip showing the window title is displayed when the mouse cursor moves " + "over task buttons."), + NULL); - row++, col = 2; - label = gtk_label_new(_("Maximum width")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Maximum width")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - task_maximum_width = gtk_spin_button_new_with_range(0, 9000, 1); - gtk_widget_show(task_maximum_width); - gtk_table_attach(GTK_TABLE(table), task_maximum_width, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, task_maximum_width, _("Specifies the maximum width of the task buttons."), NULL); + task_maximum_width = gtk_spin_button_new_with_range(0, 9000, 1); + gtk_widget_show(task_maximum_width); + gtk_table_attach(GTK_TABLE(table), task_maximum_width, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, task_maximum_width, _("Specifies the maximum width of the task buttons."), NULL); - row++, col = 2; - label = gtk_label_new(_("Maximum height")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Maximum height")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - task_maximum_height = gtk_spin_button_new_with_range(0, 9000, 1); - gtk_widget_show(task_maximum_height); - gtk_table_attach(GTK_TABLE(table), task_maximum_height, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, task_maximum_height, _("Specifies the maximum height of the task buttons."), NULL); + task_maximum_height = gtk_spin_button_new_with_range(0, 9000, 1); + gtk_widget_show(task_maximum_height); + gtk_table_attach(GTK_TABLE(table), task_maximum_height, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, task_maximum_height, _("Specifies the maximum height of the task buttons."), NULL); - row++, col = 2; - label = gtk_label_new(_("Horizontal padding")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Horizontal padding")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - task_padding_x = gtk_spin_button_new_with_range(0, 9000, 1); - gtk_widget_show(task_padding_x); - gtk_table_attach(GTK_TABLE(table), task_padding_x, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, task_padding_x, _("Specifies the horizontal padding of the task buttons. " - "This is the space between the border and the content inside."), NULL); + task_padding_x = gtk_spin_button_new_with_range(0, 9000, 1); + gtk_widget_show(task_padding_x); + gtk_table_attach(GTK_TABLE(table), task_padding_x, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + task_padding_x, + _("Specifies the horizontal padding of the task buttons. " + "This is the space between the border and the content inside."), + NULL); - row++, col = 2; - label = gtk_label_new(_("Vertical padding")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Vertical padding")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - task_padding_y = gtk_spin_button_new_with_range(0, 9000, 1); - gtk_widget_show(task_padding_y); - gtk_table_attach(GTK_TABLE(table), task_padding_y, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, task_padding_y, _("Specifies the vertical padding of the task buttons. " - "This is the space between the border and the content inside."), NULL); + task_padding_y = gtk_spin_button_new_with_range(0, 9000, 1); + gtk_widget_show(task_padding_y); + gtk_table_attach(GTK_TABLE(table), task_padding_y, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + task_padding_y, + _("Specifies the vertical padding of the task buttons. " + "This is the space between the border and the content inside."), + NULL); - row++, col = 2; - label = gtk_label_new(_("Spacing")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Spacing")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - task_spacing = gtk_spin_button_new_with_range(0, 9000, 1); - gtk_widget_show(task_spacing); - gtk_table_attach(GTK_TABLE(table), task_spacing, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, task_spacing, _("Specifies the spacing between the icon and the text."), NULL); + task_spacing = gtk_spin_button_new_with_range(0, 9000, 1); + gtk_widget_show(task_spacing); + gtk_table_attach(GTK_TABLE(table), task_spacing, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, task_spacing, _("Specifies the spacing between the icon and the text."), NULL); - row++, col = 1; - task_font_set = gtk_check_button_new(); - gtk_widget_show(task_font_set); - gtk_table_attach(GTK_TABLE(table), task_font_set, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - gtk_tooltips_set_tip(tooltips, task_font_set, _("If not checked, the desktop theme font is used. If checked, the custom font specified here is used."), NULL); - col++; + row++, col = 1; + task_font_set = gtk_check_button_new(); + gtk_widget_show(task_font_set); + gtk_table_attach(GTK_TABLE(table), task_font_set, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + gtk_tooltips_set_tip(tooltips, + task_font_set, + _("If not checked, the desktop theme font is used. If checked, the custom font specified here " + "is used."), + NULL); + col++; - label = gtk_label_new(_("Font")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + label = gtk_label_new(_("Font")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - task_font = gtk_font_button_new_with_font(get_default_font()); - gtk_widget_show(task_font); - gtk_table_attach(GTK_TABLE(table), task_font, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_font_button_set_show_style(GTK_FONT_BUTTON(task_font), TRUE); - gtk_tooltips_set_tip(tooltips, task_font, _("Specifies the font used to display the task button text."), NULL); - gtk_signal_connect(GTK_OBJECT(task_font_set), "toggled", GTK_SIGNAL_FUNC(font_set_callback), task_font); - font_set_callback(task_font_set, task_font); + task_font = gtk_font_button_new_with_font(get_default_font()); + gtk_widget_show(task_font); + gtk_table_attach(GTK_TABLE(table), task_font, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_font_button_set_show_style(GTK_FONT_BUTTON(task_font), TRUE); + gtk_tooltips_set_tip(tooltips, task_font, _("Specifies the font used to display the task button text."), NULL); + gtk_signal_connect(GTK_OBJECT(task_font_set), "toggled", GTK_SIGNAL_FUNC(font_set_callback), task_font); + font_set_callback(task_font_set, task_font); - change_paragraph(parent); + change_paragraph(parent); - notebook = gtk_notebook_new(); - gtk_widget_show(notebook); - gtk_container_set_border_width(GTK_CONTAINER(notebook), 0); - gtk_box_pack_start(GTK_BOX(parent), notebook, TRUE, TRUE, 0); + notebook = gtk_notebook_new(); + gtk_widget_show(notebook); + gtk_container_set_border_width(GTK_CONTAINER(notebook), 0); + gtk_box_pack_start(GTK_BOX(parent), notebook, TRUE, TRUE, 0); - create_task_status(notebook, - _("Default style"), - _("Default task"), - &task_default_color, - &task_default_color_set, - &task_default_icon_opacity, - &task_default_icon_osb_set, - &task_default_icon_saturation, - &task_default_icon_brightness, - &task_default_background, - &task_default_background_set); - create_task_status(notebook, - _("Normal task"), - _("Normal task"), - &task_normal_color, - &task_normal_color_set, - &task_normal_icon_opacity, - &task_normal_icon_osb_set, - &task_normal_icon_saturation, - &task_normal_icon_brightness, - &task_normal_background, - &task_normal_background_set); - create_task_status(notebook, - _("Active task"), - _("Active task"), - &task_active_color, - &task_active_color_set, - &task_active_icon_opacity, - &task_active_icon_osb_set, - &task_active_icon_saturation, - &task_active_icon_brightness, - &task_active_background, - &task_active_background_set); - create_task_status(notebook, - _("Urgent task"), - _("Urgent task"), - &task_urgent_color, - &task_urgent_color_set, - &task_urgent_icon_opacity, - &task_urgent_icon_osb_set, - &task_urgent_icon_saturation, - &task_urgent_icon_brightness, - &task_urgent_background, - &task_urgent_background_set); - create_task_status(notebook, - _("Iconified task"), - _("Iconified task"), - &task_iconified_color, - &task_iconified_color_set, - &task_iconified_icon_opacity, - &task_iconified_icon_osb_set, - &task_iconified_icon_saturation, - &task_iconified_icon_brightness, - &task_iconified_background, - &task_iconified_background_set); + create_task_status(notebook, + _("Default style"), + _("Default task"), + &task_default_color, + &task_default_color_set, + &task_default_icon_opacity, + &task_default_icon_osb_set, + &task_default_icon_saturation, + &task_default_icon_brightness, + &task_default_background, + &task_default_background_set); + create_task_status(notebook, + _("Normal task"), + _("Normal task"), + &task_normal_color, + &task_normal_color_set, + &task_normal_icon_opacity, + &task_normal_icon_osb_set, + &task_normal_icon_saturation, + &task_normal_icon_brightness, + &task_normal_background, + &task_normal_background_set); + create_task_status(notebook, + _("Active task"), + _("Active task"), + &task_active_color, + &task_active_color_set, + &task_active_icon_opacity, + &task_active_icon_osb_set, + &task_active_icon_saturation, + &task_active_icon_brightness, + &task_active_background, + &task_active_background_set); + create_task_status(notebook, + _("Urgent task"), + _("Urgent task"), + &task_urgent_color, + &task_urgent_color_set, + &task_urgent_icon_opacity, + &task_urgent_icon_osb_set, + &task_urgent_icon_saturation, + &task_urgent_icon_brightness, + &task_urgent_background, + &task_urgent_background_set); + create_task_status(notebook, + _("Iconified task"), + _("Iconified task"), + &task_iconified_color, + &task_iconified_color_set, + &task_iconified_icon_opacity, + &task_iconified_icon_osb_set, + &task_iconified_icon_saturation, + &task_iconified_icon_brightness, + &task_iconified_background, + &task_iconified_background_set); } void task_status_toggle_button_callback(GtkWidget *widget, gpointer data) { - GtkWidget *child1, *child2, *child3; - child1 = child2 = child3 = NULL; + GtkWidget *child1, *child2, *child3; + child1 = child2 = child3 = NULL; - if (widget == task_default_color_set) { - child1 = task_default_color; - } else if (widget == task_default_icon_osb_set) { - child1 = task_default_icon_opacity; - child2 = task_default_icon_saturation; - child3 = task_default_icon_brightness; - } else if (widget == task_default_background_set) { - child1 = task_default_background; - } - else - if (widget == task_normal_color_set) { - child1 = task_normal_color; - } else if (widget == task_normal_icon_osb_set) { - child1 = task_normal_icon_opacity; - child2 = task_normal_icon_saturation; - child3 = task_normal_icon_brightness; - } else if (widget == task_normal_background_set) { - child1 = task_normal_background; - } - else - if (widget == task_active_color_set) { - child1 = task_active_color; - } else if (widget == task_active_icon_osb_set) { - child1 = task_active_icon_opacity; - child2 = task_active_icon_saturation; - child3 = task_active_icon_brightness; - } else if (widget == task_active_background_set) { - child1 = task_active_background; - } - else - if (widget == task_urgent_color_set) { - child1 = task_urgent_color; - } else if (widget == task_urgent_icon_osb_set) { - child1 = task_urgent_icon_opacity; - child2 = task_urgent_icon_saturation; - child3 = task_urgent_icon_brightness; - } else if (widget == task_urgent_background_set) { - child1 = task_urgent_background; - } - else - if (widget == task_iconified_color_set) { - child1 = task_iconified_color; - } else if (widget == task_iconified_icon_osb_set) { - child1 = task_iconified_icon_opacity; - child2 = task_iconified_icon_saturation; - child3 = task_iconified_icon_brightness; - } else if (widget == task_iconified_background_set) { - child1 = task_iconified_background; - } + if (widget == task_default_color_set) { + child1 = task_default_color; + } else if (widget == task_default_icon_osb_set) { + child1 = task_default_icon_opacity; + child2 = task_default_icon_saturation; + child3 = task_default_icon_brightness; + } else if (widget == task_default_background_set) { + child1 = task_default_background; + } else if (widget == task_normal_color_set) { + child1 = task_normal_color; + } else if (widget == task_normal_icon_osb_set) { + child1 = task_normal_icon_opacity; + child2 = task_normal_icon_saturation; + child3 = task_normal_icon_brightness; + } else if (widget == task_normal_background_set) { + child1 = task_normal_background; + } else if (widget == task_active_color_set) { + child1 = task_active_color; + } else if (widget == task_active_icon_osb_set) { + child1 = task_active_icon_opacity; + child2 = task_active_icon_saturation; + child3 = task_active_icon_brightness; + } else if (widget == task_active_background_set) { + child1 = task_active_background; + } else if (widget == task_urgent_color_set) { + child1 = task_urgent_color; + } else if (widget == task_urgent_icon_osb_set) { + child1 = task_urgent_icon_opacity; + child2 = task_urgent_icon_saturation; + child3 = task_urgent_icon_brightness; + } else if (widget == task_urgent_background_set) { + child1 = task_urgent_background; + } else if (widget == task_iconified_color_set) { + child1 = task_iconified_color; + } else if (widget == task_iconified_icon_osb_set) { + child1 = task_iconified_icon_opacity; + child2 = task_iconified_icon_saturation; + child3 = task_iconified_icon_brightness; + } else if (widget == task_iconified_background_set) { + child1 = task_iconified_background; + } - if (child1) - gtk_widget_set_sensitive(child1, GTK_TOGGLE_BUTTON(widget)->active); - if (child2) - gtk_widget_set_sensitive(child2, GTK_TOGGLE_BUTTON(widget)->active); - if (child3) - gtk_widget_set_sensitive(child3, GTK_TOGGLE_BUTTON(widget)->active); + if (child1) + gtk_widget_set_sensitive(child1, GTK_TOGGLE_BUTTON(widget)->active); + if (child2) + gtk_widget_set_sensitive(child2, GTK_TOGGLE_BUTTON(widget)->active); + if (child3) + gtk_widget_set_sensitive(child3, GTK_TOGGLE_BUTTON(widget)->active); } void create_task_status(GtkWidget *notebook, - char *name, - char *text, - GtkWidget **task_status_color, - GtkWidget **task_status_color_set, - GtkWidget **task_status_icon_opacity, - GtkWidget **task_status_icon_osb_set, - GtkWidget **task_status_icon_saturation, - GtkWidget **task_status_icon_brightness, - GtkWidget **task_status_background, - GtkWidget **task_status_background_set) + char *name, + char *text, + GtkWidget **task_status_color, + GtkWidget **task_status_color_set, + GtkWidget **task_status_icon_opacity, + GtkWidget **task_status_icon_osb_set, + GtkWidget **task_status_icon_saturation, + GtkWidget **task_status_icon_brightness, + GtkWidget **task_status_background, + GtkWidget **task_status_background_set) { - GtkTooltips *tooltips = gtk_tooltips_new(); - GtkWidget *label = gtk_label_new(_(name)); - gtk_widget_show(label); - GtkWidget *page_task = gtk_vbox_new(FALSE, DEFAULT_HOR_SPACING); - gtk_container_set_border_width(GTK_CONTAINER(page_task), 10); - gtk_widget_show(page_task); - gtk_notebook_append_page(GTK_NOTEBOOK(notebook), page_task, label); + GtkTooltips *tooltips = gtk_tooltips_new(); + GtkWidget *label = gtk_label_new(_(name)); + gtk_widget_show(label); + GtkWidget *page_task = gtk_vbox_new(FALSE, DEFAULT_HOR_SPACING); + gtk_container_set_border_width(GTK_CONTAINER(page_task), 10); + gtk_widget_show(page_task); + gtk_notebook_append_page(GTK_NOTEBOOK(notebook), page_task, label); - GtkWidget *table = gtk_table_new(6, 3, FALSE); - gtk_widget_show(table); - gtk_box_pack_start(GTK_BOX(page_task), table, FALSE, FALSE, 0); - gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); - gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); + GtkWidget *table = gtk_table_new(6, 3, FALSE); + gtk_widget_show(table); + gtk_box_pack_start(GTK_BOX(page_task), table, FALSE, FALSE, 0); + gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); + gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); - *task_status_color_set = gtk_check_button_new(); - gtk_widget_show(*task_status_color_set); - gtk_table_attach(GTK_TABLE(table), *task_status_color_set, 0, 1, 0, 1, GTK_FILL, 0, 0, 0); - gtk_signal_connect(GTK_OBJECT(*task_status_color_set), "toggled", GTK_SIGNAL_FUNC(task_status_toggle_button_callback), NULL); - gtk_tooltips_set_tip(tooltips, *task_status_color_set, _("If enabled, a custom font color is used to display the task text."), NULL); + *task_status_color_set = gtk_check_button_new(); + gtk_widget_show(*task_status_color_set); + gtk_table_attach(GTK_TABLE(table), *task_status_color_set, 0, 1, 0, 1, GTK_FILL, 0, 0, 0); + gtk_signal_connect(GTK_OBJECT(*task_status_color_set), + "toggled", + GTK_SIGNAL_FUNC(task_status_toggle_button_callback), + NULL); + gtk_tooltips_set_tip(tooltips, + *task_status_color_set, + _("If enabled, a custom font color is used to display the task text."), + NULL); - label = gtk_label_new(_("Font color")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, 1, 2, 0, 1, GTK_FILL, 0, 0, 0); + label = gtk_label_new(_("Font color")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, 1, 2, 0, 1, GTK_FILL, 0, 0, 0); - *task_status_color = gtk_color_button_new(); - gtk_color_button_set_use_alpha(GTK_COLOR_BUTTON(*task_status_color), TRUE); - gtk_widget_show(*task_status_color); - gtk_table_attach(GTK_TABLE(table), *task_status_color, 2, 3, 0, 1, GTK_FILL, 0, 0, 0); - gtk_tooltips_set_tip(tooltips, *task_status_color, _("Specifies the font color used to display the task text."), NULL); + *task_status_color = gtk_color_button_new(); + gtk_color_button_set_use_alpha(GTK_COLOR_BUTTON(*task_status_color), TRUE); + gtk_widget_show(*task_status_color); + gtk_table_attach(GTK_TABLE(table), *task_status_color, 2, 3, 0, 1, GTK_FILL, 0, 0, 0); + gtk_tooltips_set_tip(tooltips, + *task_status_color, + _("Specifies the font color used to display the task text."), + NULL); - *task_status_icon_osb_set = gtk_check_button_new(); - gtk_widget_show(*task_status_icon_osb_set); - gtk_table_attach(GTK_TABLE(table), *task_status_icon_osb_set, 0, 1, 1, 2, GTK_FILL, 0, 0, 0); - gtk_signal_connect(GTK_OBJECT(*task_status_icon_osb_set), "toggled", GTK_SIGNAL_FUNC(task_status_toggle_button_callback), NULL); - gtk_tooltips_set_tip(tooltips, *task_status_icon_osb_set, _("If enabled, a custom opacity/saturation/brightness is used to display the task icon."), NULL); + *task_status_icon_osb_set = gtk_check_button_new(); + gtk_widget_show(*task_status_icon_osb_set); + gtk_table_attach(GTK_TABLE(table), *task_status_icon_osb_set, 0, 1, 1, 2, GTK_FILL, 0, 0, 0); + gtk_signal_connect(GTK_OBJECT(*task_status_icon_osb_set), + "toggled", + GTK_SIGNAL_FUNC(task_status_toggle_button_callback), + NULL); + gtk_tooltips_set_tip(tooltips, + *task_status_icon_osb_set, + _("If enabled, a custom opacity/saturation/brightness is used to display the task icon."), + NULL); - label = gtk_label_new(_("Icon opacity")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, 1, 2, 1, 2, GTK_FILL, 0, 0, 0); + label = gtk_label_new(_("Icon opacity")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, 1, 2, 1, 2, GTK_FILL, 0, 0, 0); - *task_status_icon_opacity = gtk_spin_button_new_with_range(0, 100, 1); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(*task_status_icon_opacity), 100); - gtk_widget_show(*task_status_icon_opacity); - gtk_table_attach(GTK_TABLE(table), *task_status_icon_opacity, 2, 3, 1, 2, GTK_FILL, 0, 0, 0); - gtk_tooltips_set_tip(tooltips, *task_status_icon_opacity, _("Specifies the opacity (in %) used to display the task icon."), NULL); + *task_status_icon_opacity = gtk_spin_button_new_with_range(0, 100, 1); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(*task_status_icon_opacity), 100); + gtk_widget_show(*task_status_icon_opacity); + gtk_table_attach(GTK_TABLE(table), *task_status_icon_opacity, 2, 3, 1, 2, GTK_FILL, 0, 0, 0); + gtk_tooltips_set_tip(tooltips, + *task_status_icon_opacity, + _("Specifies the opacity (in %) used to display the task icon."), + NULL); - label = gtk_label_new(_("Icon saturation")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, 1, 2, 2, 3, GTK_FILL, 0, 0, 0); + label = gtk_label_new(_("Icon saturation")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, 1, 2, 2, 3, GTK_FILL, 0, 0, 0); - *task_status_icon_saturation = gtk_spin_button_new_with_range(-100, 100, 1); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(*task_status_icon_saturation), 0); - gtk_widget_show(*task_status_icon_saturation); - gtk_table_attach(GTK_TABLE(table), *task_status_icon_saturation, 2, 3, 2, 3, GTK_FILL, 0, 0, 0); - gtk_tooltips_set_tip(tooltips, *task_status_icon_saturation, _("Specifies the saturation adjustment (in %) used to display the task icon."), NULL); + *task_status_icon_saturation = gtk_spin_button_new_with_range(-100, 100, 1); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(*task_status_icon_saturation), 0); + gtk_widget_show(*task_status_icon_saturation); + gtk_table_attach(GTK_TABLE(table), *task_status_icon_saturation, 2, 3, 2, 3, GTK_FILL, 0, 0, 0); + gtk_tooltips_set_tip(tooltips, + *task_status_icon_saturation, + _("Specifies the saturation adjustment (in %) used to display the task icon."), + NULL); - label = gtk_label_new(_("Icon brightness")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, 1, 2, 3, 4, GTK_FILL, 0, 0, 0); + label = gtk_label_new(_("Icon brightness")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, 1, 2, 3, 4, GTK_FILL, 0, 0, 0); - *task_status_icon_brightness = gtk_spin_button_new_with_range(-100, 100, 1); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(*task_status_icon_brightness), 0); - gtk_widget_show(*task_status_icon_brightness); - gtk_table_attach(GTK_TABLE(table), *task_status_icon_brightness, 2, 3, 3, 4, GTK_FILL, 0, 0, 0); - gtk_tooltips_set_tip(tooltips, *task_status_icon_brightness, _("Specifies the brightness adjustment (in %) used to display the task icon."), NULL); + *task_status_icon_brightness = gtk_spin_button_new_with_range(-100, 100, 1); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(*task_status_icon_brightness), 0); + gtk_widget_show(*task_status_icon_brightness); + gtk_table_attach(GTK_TABLE(table), *task_status_icon_brightness, 2, 3, 3, 4, GTK_FILL, 0, 0, 0); + gtk_tooltips_set_tip(tooltips, + *task_status_icon_brightness, + _("Specifies the brightness adjustment (in %) used to display the task icon."), + NULL); - *task_status_background_set = gtk_check_button_new(); - gtk_widget_show(*task_status_background_set); - gtk_table_attach(GTK_TABLE(table), *task_status_background_set, 0, 1, 4, 5, GTK_FILL, 0, 0, 0); - gtk_signal_connect(GTK_OBJECT(*task_status_background_set), "toggled", GTK_SIGNAL_FUNC(task_status_toggle_button_callback), NULL); - gtk_tooltips_set_tip(tooltips, *task_status_background_set, _("If enabled, a custom background is used to display the task."), NULL); + *task_status_background_set = gtk_check_button_new(); + gtk_widget_show(*task_status_background_set); + gtk_table_attach(GTK_TABLE(table), *task_status_background_set, 0, 1, 4, 5, GTK_FILL, 0, 0, 0); + gtk_signal_connect(GTK_OBJECT(*task_status_background_set), + "toggled", + GTK_SIGNAL_FUNC(task_status_toggle_button_callback), + NULL); + gtk_tooltips_set_tip(tooltips, + *task_status_background_set, + _("If enabled, a custom background is used to display the task."), + NULL); - label = gtk_label_new(_("Background")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, 1, 2, 4, 5, GTK_FILL, 0, 0, 0); + label = gtk_label_new(_("Background")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, 1, 2, 4, 5, GTK_FILL, 0, 0, 0); - *task_status_background = create_background_combo(text); - gtk_widget_show(*task_status_background); - gtk_table_attach(GTK_TABLE(table), *task_status_background, 2, 3, 4, 5, GTK_FILL, 0, 0, 0); - gtk_tooltips_set_tip(tooltips, *task_status_background, _("Selects the background used to display the task. " - "Backgrounds can be edited in the Backgrounds tab."), NULL); + *task_status_background = create_background_combo(text); + gtk_widget_show(*task_status_background); + gtk_table_attach(GTK_TABLE(table), *task_status_background, 2, 3, 4, 5, GTK_FILL, 0, 0, 0); + gtk_tooltips_set_tip(tooltips, + *task_status_background, + _("Selects the background used to display the task. " + "Backgrounds can be edited in the Backgrounds tab."), + NULL); - if (*task_status_color == task_urgent_color) { - label = gtk_label_new(_("Blinks")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, 1, 2, 5, 6, GTK_FILL, 0, 0, 0); + if (*task_status_color == task_urgent_color) { + label = gtk_label_new(_("Blinks")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, 1, 2, 5, 6, GTK_FILL, 0, 0, 0); - task_urgent_blinks = gtk_spin_button_new_with_range(0, 1000000, 1); - gtk_widget_show(task_urgent_blinks); - gtk_table_attach(GTK_TABLE(table), task_urgent_blinks, 2, 3, 5, 6, GTK_FILL, 0, 0, 0); - gtk_tooltips_set_tip(tooltips, task_urgent_blinks, _("Specifies how many times urgent tasks blink."), NULL); - } + task_urgent_blinks = gtk_spin_button_new_with_range(0, 1000000, 1); + gtk_widget_show(task_urgent_blinks); + gtk_table_attach(GTK_TABLE(table), task_urgent_blinks, 2, 3, 5, 6, GTK_FILL, 0, 0, 0); + gtk_tooltips_set_tip(tooltips, task_urgent_blinks, _("Specifies how many times urgent tasks blink."), NULL); + } - task_status_toggle_button_callback(*task_status_color_set, NULL); - task_status_toggle_button_callback(*task_status_icon_osb_set, NULL); - task_status_toggle_button_callback(*task_status_background_set, NULL); + task_status_toggle_button_callback(*task_status_color_set, NULL); + task_status_toggle_button_callback(*task_status_icon_osb_set, NULL); + task_status_toggle_button_callback(*task_status_background_set, NULL); } void create_clock(GtkWidget *parent) { - GtkWidget *table; - GtkWidget *label; - int row, col; - GtkTooltips *tooltips = gtk_tooltips_new(); + GtkWidget *table; + GtkWidget *label; + int row, col; + GtkTooltips *tooltips = gtk_tooltips_new(); - table = gtk_table_new(1, 2, FALSE); - gtk_widget_show(table); - gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); - gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); - gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); - row = 0, col = 2; + table = gtk_table_new(1, 2, FALSE); + gtk_widget_show(table); + gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); + gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); + gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); + row = 0, col = 2; - label = gtk_label_new(_("<b>Format</b>")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_label_set_use_markup(GTK_LABEL(label), TRUE); gtk_widget_show(label); - gtk_box_pack_start(GTK_BOX(parent), label, FALSE, FALSE, 0); + label = gtk_label_new(_("<b>Format</b>")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_label_set_use_markup(GTK_LABEL(label), TRUE); + gtk_widget_show(label); + gtk_box_pack_start(GTK_BOX(parent), label, FALSE, FALSE, 0); - table = gtk_table_new(3, 10, FALSE); - gtk_widget_show(table); - gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); - gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); - gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); - row = 0, col = 2; + table = gtk_table_new(3, 10, FALSE); + gtk_widget_show(table); + gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); + gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); + gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); + row = 0, col = 2; - label = gtk_label_new(_("First line format")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + label = gtk_label_new(_("First line format")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - clock_format_line1 = gtk_entry_new(); - gtk_widget_show(clock_format_line1); - gtk_entry_set_width_chars(GTK_ENTRY(clock_format_line1), 16); - gtk_table_attach(GTK_TABLE(table), clock_format_line1, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, clock_format_line1, - _("Specifies the format used to display the first line of the clock text. " - "See 'man date' for all the available options."), NULL); + clock_format_line1 = gtk_entry_new(); + gtk_widget_show(clock_format_line1); + gtk_entry_set_width_chars(GTK_ENTRY(clock_format_line1), 16); + gtk_table_attach(GTK_TABLE(table), clock_format_line1, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + clock_format_line1, + _("Specifies the format used to display the first line of the clock text. " + "See 'man date' for all the available options."), + NULL); - row++, col = 2; - label = gtk_label_new(_("Second line format")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Second line format")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - clock_format_line2 = gtk_entry_new(); - gtk_widget_show(clock_format_line2); - gtk_entry_set_width_chars(GTK_ENTRY(clock_format_line2), 16); - gtk_table_attach(GTK_TABLE(table), clock_format_line2, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, clock_format_line2, - _("Specifies the format used to display the second line of the clock text. " - "See 'man date' for all the available options."), NULL); + clock_format_line2 = gtk_entry_new(); + gtk_widget_show(clock_format_line2); + gtk_entry_set_width_chars(GTK_ENTRY(clock_format_line2), 16); + gtk_table_attach(GTK_TABLE(table), clock_format_line2, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + clock_format_line2, + _("Specifies the format used to display the second line of the clock text. " + "See 'man date' for all the available options."), + NULL); - row++, col = 2; - label = gtk_label_new(_("First line timezone")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("First line timezone")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - clock_tmz_line1 = gtk_entry_new(); - gtk_widget_show(clock_tmz_line1); - gtk_entry_set_width_chars(GTK_ENTRY(clock_tmz_line1), 16); - gtk_table_attach(GTK_TABLE(table), clock_tmz_line1, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, clock_tmz_line1, - _("Specifies the timezone used to display the first line of the clock text. If empty, the current timezone is used. " - "Otherwise, it must be set to a valid value of the TZ environment variable."), NULL); + clock_tmz_line1 = gtk_entry_new(); + gtk_widget_show(clock_tmz_line1); + gtk_entry_set_width_chars(GTK_ENTRY(clock_tmz_line1), 16); + gtk_table_attach(GTK_TABLE(table), clock_tmz_line1, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + clock_tmz_line1, + _("Specifies the timezone used to display the first line of the clock text. If empty, the " + "current timezone is used. " + "Otherwise, it must be set to a valid value of the TZ environment variable."), + NULL); - row++, col = 2; - label = gtk_label_new(_("Second line timezone")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Second line timezone")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - clock_tmz_line2 = gtk_entry_new(); - gtk_widget_show(clock_tmz_line2); - gtk_entry_set_width_chars(GTK_ENTRY(clock_tmz_line2), 16); - gtk_table_attach(GTK_TABLE(table), clock_tmz_line2, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, clock_tmz_line2, - _("Specifies the timezone used to display the second line of the clock text. If empty, the current timezone is used. " - "Otherwise, it must be set to a valid value of the TZ environment variable."), NULL); + clock_tmz_line2 = gtk_entry_new(); + gtk_widget_show(clock_tmz_line2); + gtk_entry_set_width_chars(GTK_ENTRY(clock_tmz_line2), 16); + gtk_table_attach(GTK_TABLE(table), clock_tmz_line2, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + clock_tmz_line2, + _("Specifies the timezone used to display the second line of the clock text. If empty, the " + "current timezone is used. " + "Otherwise, it must be set to a valid value of the TZ environment variable."), + NULL); - change_paragraph(parent); + change_paragraph(parent); - label = gtk_label_new(_("<b>Mouse events</b>")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_label_set_use_markup(GTK_LABEL(label), TRUE); - gtk_widget_show(label); - gtk_box_pack_start(GTK_BOX(parent), label, FALSE, FALSE, 0); + label = gtk_label_new(_("<b>Mouse events</b>")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_label_set_use_markup(GTK_LABEL(label), TRUE); + gtk_widget_show(label); + gtk_box_pack_start(GTK_BOX(parent), label, FALSE, FALSE, 0); - table = gtk_table_new(5, 10, FALSE); - gtk_widget_show(table); - gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); - gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); - gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); - row = 0, col = 2; + table = gtk_table_new(5, 10, FALSE); + gtk_widget_show(table); + gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); + gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); + gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); + row = 0, col = 2; - label = gtk_label_new(_("Left click command")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + label = gtk_label_new(_("Left click command")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - clock_left_command = gtk_entry_new(); - gtk_widget_show(clock_left_command); - gtk_entry_set_width_chars(GTK_ENTRY(clock_left_command), 50); - gtk_table_attach(GTK_TABLE(table), clock_left_command, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, clock_left_command, - _("Specifies a command that will be executed when the clock receives a left click."), NULL); + clock_left_command = gtk_entry_new(); + gtk_widget_show(clock_left_command); + gtk_entry_set_width_chars(GTK_ENTRY(clock_left_command), 50); + gtk_table_attach(GTK_TABLE(table), clock_left_command, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + clock_left_command, + _("Specifies a command that will be executed when the clock receives a left click."), + NULL); - row++, col = 2; - label = gtk_label_new(_("Right click command")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Right click command")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - clock_right_command = gtk_entry_new(); - gtk_widget_show(clock_right_command); - gtk_entry_set_width_chars(GTK_ENTRY(clock_right_command), 50); - gtk_table_attach(GTK_TABLE(table), clock_right_command, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, clock_right_command, - _("Specifies a command that will be executed when the clock receives a right click."), NULL); + clock_right_command = gtk_entry_new(); + gtk_widget_show(clock_right_command); + gtk_entry_set_width_chars(GTK_ENTRY(clock_right_command), 50); + gtk_table_attach(GTK_TABLE(table), clock_right_command, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + clock_right_command, + _("Specifies a command that will be executed when the clock receives a right click."), + NULL); - row++, col = 2; - label = gtk_label_new(_("Middle click command")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Middle click command")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - clock_mclick_command = gtk_entry_new(); - gtk_widget_show(clock_mclick_command); - gtk_entry_set_width_chars(GTK_ENTRY(clock_mclick_command), 50); - gtk_table_attach(GTK_TABLE(table), clock_mclick_command, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, clock_mclick_command, - _("Specifies a command that will be executed when the clock receives a middle click."), NULL); + clock_mclick_command = gtk_entry_new(); + gtk_widget_show(clock_mclick_command); + gtk_entry_set_width_chars(GTK_ENTRY(clock_mclick_command), 50); + gtk_table_attach(GTK_TABLE(table), clock_mclick_command, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + clock_mclick_command, + _("Specifies a command that will be executed when the clock receives a middle click."), + NULL); - row++, col = 2; - label = gtk_label_new(_("Wheel scroll up command")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Wheel scroll up command")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - clock_uwheel_command = gtk_entry_new(); - gtk_widget_show(clock_uwheel_command); - gtk_entry_set_width_chars(GTK_ENTRY(clock_uwheel_command), 50); - gtk_table_attach(GTK_TABLE(table), clock_uwheel_command, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, clock_uwheel_command, - _("Specifies a command that will be executed when the clock receives a mouse scroll up."), NULL); + clock_uwheel_command = gtk_entry_new(); + gtk_widget_show(clock_uwheel_command); + gtk_entry_set_width_chars(GTK_ENTRY(clock_uwheel_command), 50); + gtk_table_attach(GTK_TABLE(table), clock_uwheel_command, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + clock_uwheel_command, + _("Specifies a command that will be executed when the clock receives a mouse scroll up."), + NULL); - row++, col = 2; - label = gtk_label_new(_("Wheel scroll down command")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Wheel scroll down command")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - clock_dwheel_command = gtk_entry_new(); - gtk_widget_show(clock_dwheel_command); - gtk_entry_set_width_chars(GTK_ENTRY(clock_dwheel_command), 50); - gtk_table_attach(GTK_TABLE(table), clock_dwheel_command, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, clock_dwheel_command, - _("Specifies a command that will be executed when the clock receives a mouse scroll down."), NULL); + clock_dwheel_command = gtk_entry_new(); + gtk_widget_show(clock_dwheel_command); + gtk_entry_set_width_chars(GTK_ENTRY(clock_dwheel_command), 50); + gtk_table_attach(GTK_TABLE(table), clock_dwheel_command, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + clock_dwheel_command, + _("Specifies a command that will be executed when the clock receives a mouse scroll down."), + NULL); - change_paragraph(parent); + change_paragraph(parent); - label = gtk_label_new(_("<b>Appearance</b>")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_label_set_use_markup(GTK_LABEL(label), TRUE); - gtk_widget_show(label); - gtk_box_pack_start(GTK_BOX(parent), label, FALSE, FALSE, 0); + label = gtk_label_new(_("<b>Appearance</b>")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_label_set_use_markup(GTK_LABEL(label), TRUE); + gtk_widget_show(label); + gtk_box_pack_start(GTK_BOX(parent), label, FALSE, FALSE, 0); - table = gtk_table_new(3, 22, FALSE); - gtk_widget_show(table); - gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); - gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); - gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); - row = 0, col = 2; + table = gtk_table_new(3, 22, FALSE); + gtk_widget_show(table); + gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); + gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); + gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); + row = 0, col = 2; - label = gtk_label_new(_("Background")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + label = gtk_label_new(_("Background")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - clock_background = create_background_combo(_("Clock")); - gtk_widget_show(clock_background); - gtk_table_attach(GTK_TABLE(table), clock_background, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, clock_background, _("Selects the background used to display the clock. " - "Backgrounds can be edited in the Backgrounds tab."), NULL); + clock_background = create_background_combo(_("Clock")); + gtk_widget_show(clock_background); + gtk_table_attach(GTK_TABLE(table), clock_background, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + clock_background, + _("Selects the background used to display the clock. " + "Backgrounds can be edited in the Backgrounds tab."), + NULL); - row++, col = 2; - label = gtk_label_new(_("Horizontal padding")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Horizontal padding")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - clock_padding_x = gtk_spin_button_new_with_range(0, 500, 1); - gtk_widget_show(clock_padding_x); - gtk_table_attach(GTK_TABLE(table), clock_padding_x, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, clock_padding_x, _("Specifies the horizontal padding of the clock. " - "This is the space between the border and the content inside."), NULL); + clock_padding_x = gtk_spin_button_new_with_range(0, 500, 1); + gtk_widget_show(clock_padding_x); + gtk_table_attach(GTK_TABLE(table), clock_padding_x, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + clock_padding_x, + _("Specifies the horizontal padding of the clock. " + "This is the space between the border and the content inside."), + NULL); - row++, col = 2; - label = gtk_label_new(_("Vertical padding")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Vertical padding")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - clock_padding_y = gtk_spin_button_new_with_range(0, 500, 1); - gtk_widget_show(clock_padding_y); - gtk_table_attach(GTK_TABLE(table), clock_padding_y, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, clock_padding_y, _("Specifies the vertical padding of the clock. " - "This is the space between the border and the content inside."), NULL); + clock_padding_y = gtk_spin_button_new_with_range(0, 500, 1); + gtk_widget_show(clock_padding_y); + gtk_table_attach(GTK_TABLE(table), clock_padding_y, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + clock_padding_y, + _("Specifies the vertical padding of the clock. " + "This is the space between the border and the content inside."), + NULL); - row++, col = 1; - clock_font_line1_set = gtk_check_button_new(); - gtk_widget_show(clock_font_line1_set); - gtk_table_attach(GTK_TABLE(table), clock_font_line1_set, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - gtk_tooltips_set_tip(tooltips, clock_font_line1_set, _("If not checked, the desktop theme font is used. If checked, the custom font specified here is used."), NULL); - col++; + row++, col = 1; + clock_font_line1_set = gtk_check_button_new(); + gtk_widget_show(clock_font_line1_set); + gtk_table_attach(GTK_TABLE(table), clock_font_line1_set, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + gtk_tooltips_set_tip(tooltips, + clock_font_line1_set, + _("If not checked, the desktop theme font is used. If checked, the custom font specified here " + "is used."), + NULL); + col++; - label = gtk_label_new(_("Font first line")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + label = gtk_label_new(_("Font first line")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - PangoFontDescription *time1_font_desc = pango_font_description_from_string(get_default_font()); - pango_font_description_set_weight(time1_font_desc, PANGO_WEIGHT_BOLD); - pango_font_description_set_size(time1_font_desc, pango_font_description_get_size(time1_font_desc)); - clock_font_line1 = gtk_font_button_new_with_font(pango_font_description_to_string(time1_font_desc)); - pango_font_description_free(time1_font_desc); - gtk_widget_show(clock_font_line1); - gtk_table_attach(GTK_TABLE(table), clock_font_line1, col, col+3, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_font_button_set_show_style(GTK_FONT_BUTTON(clock_font_line1), TRUE); - gtk_tooltips_set_tip(tooltips, clock_font_line1, _("Specifies the font used to display the first line of the clock."), NULL); - gtk_signal_connect(GTK_OBJECT(clock_font_line1_set), "toggled", GTK_SIGNAL_FUNC(font_set_callback), clock_font_line1); - font_set_callback(clock_font_line1_set, clock_font_line1); + PangoFontDescription *time1_font_desc = pango_font_description_from_string(get_default_font()); + pango_font_description_set_weight(time1_font_desc, PANGO_WEIGHT_BOLD); + pango_font_description_set_size(time1_font_desc, pango_font_description_get_size(time1_font_desc)); + clock_font_line1 = gtk_font_button_new_with_font(pango_font_description_to_string(time1_font_desc)); + pango_font_description_free(time1_font_desc); + gtk_widget_show(clock_font_line1); + gtk_table_attach(GTK_TABLE(table), clock_font_line1, col, col + 3, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_font_button_set_show_style(GTK_FONT_BUTTON(clock_font_line1), TRUE); + gtk_tooltips_set_tip(tooltips, + clock_font_line1, + _("Specifies the font used to display the first line of the clock."), + NULL); + gtk_signal_connect(GTK_OBJECT(clock_font_line1_set), + "toggled", + GTK_SIGNAL_FUNC(font_set_callback), + clock_font_line1); + font_set_callback(clock_font_line1_set, clock_font_line1); - row++, col = 1; - clock_font_line2_set = gtk_check_button_new(); - gtk_widget_show(clock_font_line2_set); - gtk_table_attach(GTK_TABLE(table), clock_font_line2_set, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - gtk_tooltips_set_tip(tooltips, clock_font_line2_set, _("If not checked, the desktop theme font is used. If checked, the custom font specified here is used."), NULL); - col++; + row++, col = 1; + clock_font_line2_set = gtk_check_button_new(); + gtk_widget_show(clock_font_line2_set); + gtk_table_attach(GTK_TABLE(table), clock_font_line2_set, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + gtk_tooltips_set_tip(tooltips, + clock_font_line2_set, + _("If not checked, the desktop theme font is used. If checked, the custom font specified here " + "is used."), + NULL); + col++; - label = gtk_label_new(_("Font second line")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + label = gtk_label_new(_("Font second line")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - PangoFontDescription *time2_font_desc = pango_font_description_from_string(get_default_font()); - pango_font_description_set_size(time2_font_desc, pango_font_description_get_size(time2_font_desc) - PANGO_SCALE); - clock_font_line2 = gtk_font_button_new_with_font(pango_font_description_to_string(time2_font_desc));; - pango_font_description_free(time2_font_desc); - gtk_widget_show(clock_font_line2); - gtk_table_attach(GTK_TABLE(table), clock_font_line2, col, col+3, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_font_button_set_show_style(GTK_FONT_BUTTON(clock_font_line2), TRUE); - gtk_tooltips_set_tip(tooltips, clock_font_line2, _("Specifies the font used to display the second line of the clock."), NULL); - gtk_signal_connect(GTK_OBJECT(clock_font_line2_set), "toggled", GTK_SIGNAL_FUNC(font_set_callback), clock_font_line2); - font_set_callback(clock_font_line2_set, clock_font_line2); + PangoFontDescription *time2_font_desc = pango_font_description_from_string(get_default_font()); + pango_font_description_set_size(time2_font_desc, pango_font_description_get_size(time2_font_desc) - PANGO_SCALE); + clock_font_line2 = gtk_font_button_new_with_font(pango_font_description_to_string(time2_font_desc)); + ; + pango_font_description_free(time2_font_desc); + gtk_widget_show(clock_font_line2); + gtk_table_attach(GTK_TABLE(table), clock_font_line2, col, col + 3, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_font_button_set_show_style(GTK_FONT_BUTTON(clock_font_line2), TRUE); + gtk_tooltips_set_tip(tooltips, + clock_font_line2, + _("Specifies the font used to display the second line of the clock."), + NULL); + gtk_signal_connect(GTK_OBJECT(clock_font_line2_set), + "toggled", + GTK_SIGNAL_FUNC(font_set_callback), + clock_font_line2); + font_set_callback(clock_font_line2_set, clock_font_line2); - row++, col = 2; - label = gtk_label_new(_("Font color")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Font color")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - clock_font_color = gtk_color_button_new(); - gtk_color_button_set_use_alpha(GTK_COLOR_BUTTON(clock_font_color), TRUE); - gtk_widget_show(clock_font_color); - gtk_table_attach(GTK_TABLE(table), clock_font_color, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, clock_font_color, _("Specifies the font color used to display the clock."), NULL); + clock_font_color = gtk_color_button_new(); + gtk_color_button_set_use_alpha(GTK_COLOR_BUTTON(clock_font_color), TRUE); + gtk_widget_show(clock_font_color); + gtk_table_attach(GTK_TABLE(table), clock_font_color, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, clock_font_color, _("Specifies the font color used to display the clock."), NULL); - change_paragraph(parent); + change_paragraph(parent); - label = gtk_label_new(_("<b>Tooltip</b>")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_label_set_use_markup(GTK_LABEL(label), TRUE); - gtk_widget_show(label); - gtk_box_pack_start(GTK_BOX(parent), label, FALSE, FALSE, 0); + label = gtk_label_new(_("<b>Tooltip</b>")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_label_set_use_markup(GTK_LABEL(label), TRUE); + gtk_widget_show(label); + gtk_box_pack_start(GTK_BOX(parent), label, FALSE, FALSE, 0); - table = gtk_table_new(3, 10, FALSE); - gtk_widget_show(table); - gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); - gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); - gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); - row = 0, col = 2; + table = gtk_table_new(3, 10, FALSE); + gtk_widget_show(table); + gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); + gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); + gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); + row = 0, col = 2; - label = gtk_label_new(_("Format")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + label = gtk_label_new(_("Format")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - clock_format_tooltip = gtk_entry_new(); - gtk_widget_show(clock_format_tooltip); - gtk_entry_set_width_chars(GTK_ENTRY(clock_format_tooltip), 30); - gtk_table_attach(GTK_TABLE(table), clock_format_tooltip, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, clock_format_tooltip, _("Specifies the format used to display the clock tooltip. " - "See 'man date' for the available options."), NULL); + clock_format_tooltip = gtk_entry_new(); + gtk_widget_show(clock_format_tooltip); + gtk_entry_set_width_chars(GTK_ENTRY(clock_format_tooltip), 30); + gtk_table_attach(GTK_TABLE(table), clock_format_tooltip, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + clock_format_tooltip, + _("Specifies the format used to display the clock tooltip. " + "See 'man date' for the available options."), + NULL); - row++, col = 2; - label = gtk_label_new(_("Timezone")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Timezone")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - clock_tmz_tooltip = gtk_entry_new(); - gtk_widget_show(clock_tmz_tooltip); - gtk_entry_set_width_chars(GTK_ENTRY(clock_tmz_tooltip), 16); - gtk_table_attach(GTK_TABLE(table), clock_tmz_tooltip, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, clock_tmz_tooltip, _("Specifies the timezone used to display the clock tooltip. If empty, the current timezone is used. " - "Otherwise, it must be set to a valid value of the TZ environment variable."), NULL); + clock_tmz_tooltip = gtk_entry_new(); + gtk_widget_show(clock_tmz_tooltip); + gtk_entry_set_width_chars(GTK_ENTRY(clock_tmz_tooltip), 16); + gtk_table_attach(GTK_TABLE(table), clock_tmz_tooltip, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + clock_tmz_tooltip, + _("Specifies the timezone used to display the clock tooltip. If empty, the current timezone " + "is used. " + "Otherwise, it must be set to a valid value of the TZ environment variable."), + NULL); - change_paragraph(parent); + change_paragraph(parent); } void create_separator(GtkWidget *notebook, int i) { - GtkWidget *label; - GtkWidget *table; - int row, col; - Separator *separator = &g_array_index(separators, Separator, i); + GtkWidget *label; + GtkWidget *table; + int row, col; + Separator *separator = &g_array_index(separators, Separator, i); - separator->name[0] = 0; - sprintf(separator->name, "%s %d", _("Separator"), i + 1); - separator->page_label = gtk_label_new(separator->name); - gtk_widget_show(separator->page_label); - separator->page_separator = gtk_vbox_new(FALSE, DEFAULT_HOR_SPACING); - separator->container = addScrollBarToWidget(separator->page_separator); - gtk_container_set_border_width(GTK_CONTAINER(separator->page_separator), 10); - gtk_widget_show(separator->page_separator); - gtk_notebook_append_page(GTK_NOTEBOOK(notebook), separator->container, separator->page_label); + separator->name[0] = 0; + sprintf(separator->name, "%s %d", _("Separator"), i + 1); + separator->page_label = gtk_label_new(separator->name); + gtk_widget_show(separator->page_label); + separator->page_separator = gtk_vbox_new(FALSE, DEFAULT_HOR_SPACING); + separator->container = addScrollBarToWidget(separator->page_separator); + gtk_container_set_border_width(GTK_CONTAINER(separator->page_separator), 10); + gtk_widget_show(separator->page_separator); + gtk_notebook_append_page(GTK_NOTEBOOK(notebook), separator->container, separator->page_label); - GtkWidget *parent = separator->page_separator; + GtkWidget *parent = separator->page_separator; - table = gtk_table_new(1, 2, FALSE); - gtk_widget_show(table); - gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); - gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); - gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); - row = 0, col = 2; + table = gtk_table_new(1, 2, FALSE); + gtk_widget_show(table); + gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); + gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); + gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); + row = 0, col = 2; - label = gtk_label_new(_("<b>Appearance</b>")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_label_set_use_markup(GTK_LABEL(label), TRUE); - gtk_widget_show(label); - gtk_box_pack_start(GTK_BOX(parent), label, FALSE, FALSE, 0); + label = gtk_label_new(_("<b>Appearance</b>")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_label_set_use_markup(GTK_LABEL(label), TRUE); + gtk_widget_show(label); + gtk_box_pack_start(GTK_BOX(parent), label, FALSE, FALSE, 0); - table = gtk_table_new(3, 10, FALSE); - gtk_widget_show(table); - gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); - gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); - gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); - row = 0, col = 2; + table = gtk_table_new(3, 10, FALSE); + gtk_widget_show(table); + gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); + gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); + gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); + row = 0, col = 2; - label = gtk_label_new(_("Background")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + label = gtk_label_new(_("Background")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - separator->separator_background = create_background_combo(_("Separator")); - gtk_widget_show(separator->separator_background); - gtk_table_attach(GTK_TABLE(table), separator->separator_background, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + separator->separator_background = create_background_combo(_("Separator")); + gtk_widget_show(separator->separator_background); + gtk_table_attach(GTK_TABLE(table), separator->separator_background, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - row++, col = 2; - label = gtk_label_new(_("Foreground color")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Foreground color")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - separator->separator_color = gtk_color_button_new(); - gtk_color_button_set_use_alpha(GTK_COLOR_BUTTON(separator->separator_color), TRUE); - gtk_widget_show(separator->separator_color); - GdkColor color; - hex2gdk("#777777", &color); - gtk_color_button_set_color(GTK_COLOR_BUTTON(separator->separator_color), &color); - gtk_color_button_set_alpha(GTK_COLOR_BUTTON(separator_get_last()->separator_color), (90*65535)/100); - gtk_table_attach(GTK_TABLE(table), separator->separator_color, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + separator->separator_color = gtk_color_button_new(); + gtk_color_button_set_use_alpha(GTK_COLOR_BUTTON(separator->separator_color), TRUE); + gtk_widget_show(separator->separator_color); + GdkColor color; + hex2gdk("#777777", &color); + gtk_color_button_set_color(GTK_COLOR_BUTTON(separator->separator_color), &color); + gtk_color_button_set_alpha(GTK_COLOR_BUTTON(separator_get_last()->separator_color), (90 * 65535) / 100); + gtk_table_attach(GTK_TABLE(table), separator->separator_color, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - row++, col = 2; - label = gtk_label_new(_("Style")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Style")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - separator->separator_style = gtk_combo_box_new_text(); - gtk_widget_show(separator->separator_style); - gtk_table_attach(GTK_TABLE(table), separator->separator_style, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_combo_box_append_text(GTK_COMBO_BOX(separator->separator_style), _("Empty")); - gtk_combo_box_append_text(GTK_COMBO_BOX(separator->separator_style), _("Line")); - gtk_combo_box_append_text(GTK_COMBO_BOX(separator->separator_style), _("Dots")); - gtk_combo_box_set_active(GTK_COMBO_BOX(separator->separator_style), 2); + separator->separator_style = gtk_combo_box_new_text(); + gtk_widget_show(separator->separator_style); + gtk_table_attach(GTK_TABLE(table), separator->separator_style, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_combo_box_append_text(GTK_COMBO_BOX(separator->separator_style), _("Empty")); + gtk_combo_box_append_text(GTK_COMBO_BOX(separator->separator_style), _("Line")); + gtk_combo_box_append_text(GTK_COMBO_BOX(separator->separator_style), _("Dots")); + gtk_combo_box_set_active(GTK_COMBO_BOX(separator->separator_style), 2); - row++, col = 2; - label = gtk_label_new(_("Size")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Size")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - separator->separator_size = gtk_spin_button_new_with_range(0, 10000, 1); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(separator->separator_size), 3); - gtk_widget_show(separator->separator_size); - gtk_table_attach(GTK_TABLE(table), separator->separator_size, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + separator->separator_size = gtk_spin_button_new_with_range(0, 10000, 1); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(separator->separator_size), 3); + gtk_widget_show(separator->separator_size); + gtk_table_attach(GTK_TABLE(table), separator->separator_size, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - row++, col = 2; - label = gtk_label_new(_("Horizontal padding")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Horizontal padding")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - separator->separator_padding_x = gtk_spin_button_new_with_range(0, 500, 1); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(separator->separator_padding_x), 1); - gtk_widget_show(separator->separator_padding_x); - gtk_table_attach(GTK_TABLE(table), separator->separator_padding_x, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + separator->separator_padding_x = gtk_spin_button_new_with_range(0, 500, 1); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(separator->separator_padding_x), 1); + gtk_widget_show(separator->separator_padding_x); + gtk_table_attach(GTK_TABLE(table), separator->separator_padding_x, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - row++, col = 2; - label = gtk_label_new(_("Vertical padding")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Vertical padding")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - separator->separator_padding_y = gtk_spin_button_new_with_range(0, 500, 1); - gtk_widget_show(separator->separator_padding_y); - gtk_table_attach(GTK_TABLE(table), separator->separator_padding_y, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + separator->separator_padding_y = gtk_spin_button_new_with_range(0, 500, 1); + gtk_widget_show(separator->separator_padding_y); + gtk_table_attach(GTK_TABLE(table), separator->separator_padding_y, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - change_paragraph(parent); + change_paragraph(parent); } void create_execp(GtkWidget *notebook, int i) { - GtkWidget *label; - GtkWidget *table; - int row, col; - GtkTooltips *tooltips = gtk_tooltips_new(); + GtkWidget *label; + GtkWidget *table; + int row, col; + GtkTooltips *tooltips = gtk_tooltips_new(); - Executor *executor = &g_array_index(executors, Executor, i); + Executor *executor = &g_array_index(executors, Executor, i); - executor->name[0] = 0; - sprintf(executor->name, "%s %d", _("Executor"), i + 1); - executor->page_label = gtk_label_new(executor->name); - gtk_widget_show(executor->page_label); - executor->page_execp = gtk_vbox_new(FALSE, DEFAULT_HOR_SPACING); - executor->container = addScrollBarToWidget(executor->page_execp); - gtk_container_set_border_width(GTK_CONTAINER(executor->page_execp), 10); - gtk_widget_show(executor->page_execp); - gtk_notebook_append_page(GTK_NOTEBOOK(notebook), executor->container, executor->page_label); + executor->name[0] = 0; + sprintf(executor->name, "%s %d", _("Executor"), i + 1); + executor->page_label = gtk_label_new(executor->name); + gtk_widget_show(executor->page_label); + executor->page_execp = gtk_vbox_new(FALSE, DEFAULT_HOR_SPACING); + executor->container = addScrollBarToWidget(executor->page_execp); + gtk_container_set_border_width(GTK_CONTAINER(executor->page_execp), 10); + gtk_widget_show(executor->page_execp); + gtk_notebook_append_page(GTK_NOTEBOOK(notebook), executor->container, executor->page_label); - GtkWidget *parent = executor->page_execp; + GtkWidget *parent = executor->page_execp; - table = gtk_table_new(1, 2, FALSE); - gtk_widget_show(table); - gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); - gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); - gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); - row = 0, col = 2; + table = gtk_table_new(1, 2, FALSE); + gtk_widget_show(table); + gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); + gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); + gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); + row = 0, col = 2; - label = gtk_label_new(_("<b>Format</b>")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_label_set_use_markup(GTK_LABEL(label), TRUE); gtk_widget_show(label); - gtk_box_pack_start(GTK_BOX(parent), label, FALSE, FALSE, 0); + label = gtk_label_new(_("<b>Format</b>")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_label_set_use_markup(GTK_LABEL(label), TRUE); + gtk_widget_show(label); + gtk_box_pack_start(GTK_BOX(parent), label, FALSE, FALSE, 0); - table = gtk_table_new(3, 10, FALSE); - gtk_widget_show(table); - gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); - gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); - gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); - row = 0, col = 2; + table = gtk_table_new(3, 10, FALSE); + gtk_widget_show(table); + gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); + gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); + gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); + row = 0, col = 2; - label = gtk_label_new(_("Command")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + label = gtk_label_new(_("Command")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - executor->execp_command = gtk_entry_new(); - gtk_widget_show(executor->execp_command); - gtk_entry_set_width_chars(GTK_ENTRY(executor->execp_command), 50); - gtk_table_attach(GTK_TABLE(table), executor->execp_command, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, executor->execp_command, - _("Specifies the command to execute."), NULL); + executor->execp_command = gtk_entry_new(); + gtk_widget_show(executor->execp_command); + gtk_entry_set_width_chars(GTK_ENTRY(executor->execp_command), 50); + gtk_table_attach(GTK_TABLE(table), executor->execp_command, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, executor->execp_command, _("Specifies the command to execute."), NULL); - row++, col = 2; - label = gtk_label_new(_("Interval")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Interval")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - executor->execp_interval = gtk_spin_button_new_with_range(0, 1000000, 1); - gtk_widget_show(executor->execp_interval); - gtk_table_attach(GTK_TABLE(table), executor->execp_interval, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, executor->execp_interval, _("Specifies the interval at which the command is executed, in seconds. " - "If zero, the command is executed only once."), NULL); + executor->execp_interval = gtk_spin_button_new_with_range(0, 1000000, 1); + gtk_widget_show(executor->execp_interval); + gtk_table_attach(GTK_TABLE(table), executor->execp_interval, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + executor->execp_interval, + _("Specifies the interval at which the command is executed, in seconds. " + "If zero, the command is executed only once."), + NULL); - row++, col = 2; - label = gtk_label_new(_("Show icon")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Show icon")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - executor->execp_has_icon = gtk_check_button_new(); - gtk_widget_show(executor->execp_has_icon); - gtk_table_attach(GTK_TABLE(table), executor->execp_has_icon, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, executor->execp_has_icon, _("If enabled, the first line printed by the command is interpreted " - "as a path to an image file."), NULL); + executor->execp_has_icon = gtk_check_button_new(); + gtk_widget_show(executor->execp_has_icon); + gtk_table_attach(GTK_TABLE(table), executor->execp_has_icon, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + executor->execp_has_icon, + _("If enabled, the first line printed by the command is interpreted " + "as a path to an image file."), + NULL); - row++, col = 2; - label = gtk_label_new(_("Cache icon")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Cache icon")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - executor->execp_cache_icon = gtk_check_button_new(); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(executor->execp_cache_icon), 1); - gtk_widget_show(executor->execp_cache_icon); - gtk_table_attach(GTK_TABLE(table), executor->execp_cache_icon, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, executor->execp_cache_icon, _("If enabled, the image is not reloaded from disk every time the command is executed if the path remains unchanged. Enabling this is recommended."), NULL); + executor->execp_cache_icon = gtk_check_button_new(); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(executor->execp_cache_icon), 1); + gtk_widget_show(executor->execp_cache_icon); + gtk_table_attach(GTK_TABLE(table), executor->execp_cache_icon, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + executor->execp_cache_icon, + _("If enabled, the image is not reloaded from disk every time the command is executed if the " + "path remains unchanged. Enabling this is recommended."), + NULL); - row++, col = 2; - label = gtk_label_new(_("Continuous output")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Continuous output")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - executor->execp_continuous = gtk_spin_button_new_with_range(0, 1000000, 1); - gtk_widget_show(executor->execp_continuous); - gtk_table_attach(GTK_TABLE(table), executor->execp_continuous, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, executor->execp_continuous, _("If non-zero, the last execp_continuous lines from the output of " - "the command are displayed, every execp_continuous lines; this is " - "useful for showing the output of commands that run indefinitely, " - "such as 'ping 127.0.0.1'. If zero, the output of the command is " - "displayed after it finishes executing."), NULL); - row++, col = 2; - label = gtk_label_new(_("Display markup")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + executor->execp_continuous = gtk_spin_button_new_with_range(0, 1000000, 1); + gtk_widget_show(executor->execp_continuous); + gtk_table_attach(GTK_TABLE(table), executor->execp_continuous, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + executor->execp_continuous, + _("If non-zero, the last execp_continuous lines from the output of " + "the command are displayed, every execp_continuous lines; this is " + "useful for showing the output of commands that run indefinitely, " + "such as 'ping 127.0.0.1'. If zero, the output of the command is " + "displayed after it finishes executing."), + NULL); + row++, col = 2; + label = gtk_label_new(_("Display markup")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - executor->execp_markup = gtk_check_button_new(); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(executor->execp_markup), 1); - gtk_widget_show(executor->execp_markup); - gtk_table_attach(GTK_TABLE(table), executor->execp_markup, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, executor->execp_markup, _("If enabled, the output of the command is treated as Pango markup, " - "which allows rich text formatting. Note that using this with commands " - "that print data downloaded from the Internet is a potential security risk."), NULL); + executor->execp_markup = gtk_check_button_new(); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(executor->execp_markup), 1); + gtk_widget_show(executor->execp_markup); + gtk_table_attach(GTK_TABLE(table), executor->execp_markup, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + executor->execp_markup, + _("If enabled, the output of the command is treated as Pango markup, " + "which allows rich text formatting. Note that using this with commands " + "that print data downloaded from the Internet is a potential security risk."), + NULL); - change_paragraph(parent); + change_paragraph(parent); - label = gtk_label_new(_("<b>Mouse events</b>")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_label_set_use_markup(GTK_LABEL(label), TRUE); - gtk_widget_show(label); - gtk_box_pack_start(GTK_BOX(parent), label, FALSE, FALSE, 0); + label = gtk_label_new(_("<b>Mouse events</b>")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_label_set_use_markup(GTK_LABEL(label), TRUE); + gtk_widget_show(label); + gtk_box_pack_start(GTK_BOX(parent), label, FALSE, FALSE, 0); - table = gtk_table_new(5, 10, FALSE); - gtk_widget_show(table); - gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); - gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); - gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); - row = 0, col = 2; + table = gtk_table_new(5, 10, FALSE); + gtk_widget_show(table); + gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); + gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); + gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); + row = 0, col = 2; - label = gtk_label_new(_("Left click command")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + label = gtk_label_new(_("Left click command")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - executor->execp_left_command = gtk_entry_new(); - gtk_widget_show(executor->execp_left_command); - gtk_entry_set_width_chars(GTK_ENTRY(executor->execp_left_command), 50); - gtk_table_attach(GTK_TABLE(table), executor->execp_left_command, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, executor->execp_left_command, - _("Specifies a command that will be executed when the executor receives a left click."), NULL); + executor->execp_left_command = gtk_entry_new(); + gtk_widget_show(executor->execp_left_command); + gtk_entry_set_width_chars(GTK_ENTRY(executor->execp_left_command), 50); + gtk_table_attach(GTK_TABLE(table), executor->execp_left_command, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + executor->execp_left_command, + _("Specifies a command that will be executed when the executor receives a left click."), + NULL); - row++, col = 2; - label = gtk_label_new(_("Right click command")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Right click command")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - executor->execp_right_command = gtk_entry_new(); - gtk_widget_show(executor->execp_right_command); - gtk_entry_set_width_chars(GTK_ENTRY(executor->execp_right_command), 50); - gtk_table_attach(GTK_TABLE(table), executor->execp_right_command, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, executor->execp_right_command, - _("Specifies a command that will be executed when the executor receives a right click."), NULL); + executor->execp_right_command = gtk_entry_new(); + gtk_widget_show(executor->execp_right_command); + gtk_entry_set_width_chars(GTK_ENTRY(executor->execp_right_command), 50); + gtk_table_attach(GTK_TABLE(table), executor->execp_right_command, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + executor->execp_right_command, + _("Specifies a command that will be executed when the executor receives a right click."), + NULL); - row++, col = 2; - label = gtk_label_new(_("Middle click command")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Middle click command")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - executor->execp_mclick_command = gtk_entry_new(); - gtk_widget_show(executor->execp_mclick_command); - gtk_entry_set_width_chars(GTK_ENTRY(executor->execp_mclick_command), 50); - gtk_table_attach(GTK_TABLE(table), executor->execp_mclick_command, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, executor->execp_mclick_command, - _("Specifies a command that will be executed when the executor receives a middle click."), NULL); + executor->execp_mclick_command = gtk_entry_new(); + gtk_widget_show(executor->execp_mclick_command); + gtk_entry_set_width_chars(GTK_ENTRY(executor->execp_mclick_command), 50); + gtk_table_attach(GTK_TABLE(table), executor->execp_mclick_command, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + executor->execp_mclick_command, + _("Specifies a command that will be executed when the executor receives a middle click."), + NULL); - row++, col = 2; - label = gtk_label_new(_("Wheel scroll up command")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Wheel scroll up command")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - executor->execp_uwheel_command = gtk_entry_new(); - gtk_widget_show(executor->execp_uwheel_command); - gtk_entry_set_width_chars(GTK_ENTRY(executor->execp_uwheel_command), 50); - gtk_table_attach(GTK_TABLE(table), executor->execp_uwheel_command, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, executor->execp_uwheel_command, - _("Specifies a command that will be executed when the executor receives a mouse scroll up."), NULL); + executor->execp_uwheel_command = gtk_entry_new(); + gtk_widget_show(executor->execp_uwheel_command); + gtk_entry_set_width_chars(GTK_ENTRY(executor->execp_uwheel_command), 50); + gtk_table_attach(GTK_TABLE(table), executor->execp_uwheel_command, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + executor->execp_uwheel_command, + _("Specifies a command that will be executed when the executor receives a mouse scroll up."), + NULL); - row++, col = 2; - label = gtk_label_new(_("Wheel scroll down command")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Wheel scroll down command")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - executor->execp_dwheel_command = gtk_entry_new(); - gtk_widget_show(executor->execp_dwheel_command); - gtk_entry_set_width_chars(GTK_ENTRY(executor->execp_dwheel_command), 50); - gtk_table_attach(GTK_TABLE(table), executor->execp_dwheel_command, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, executor->execp_dwheel_command, - _("Specifies a command that will be executed when the executor receives a mouse scroll down."), NULL); + executor->execp_dwheel_command = gtk_entry_new(); + gtk_widget_show(executor->execp_dwheel_command); + gtk_entry_set_width_chars(GTK_ENTRY(executor->execp_dwheel_command), 50); + gtk_table_attach(GTK_TABLE(table), executor->execp_dwheel_command, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + executor->execp_dwheel_command, + _("Specifies a command that will be executed when the executor receives a mouse scroll down."), + NULL); - change_paragraph(parent); + change_paragraph(parent); - label = gtk_label_new(_("<b>Appearance</b>")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_label_set_use_markup(GTK_LABEL(label), TRUE); - gtk_widget_show(label); - gtk_box_pack_start(GTK_BOX(parent), label, FALSE, FALSE, 0); + label = gtk_label_new(_("<b>Appearance</b>")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_label_set_use_markup(GTK_LABEL(label), TRUE); + gtk_widget_show(label); + gtk_box_pack_start(GTK_BOX(parent), label, FALSE, FALSE, 0); - table = gtk_table_new(3, 22, FALSE); - gtk_widget_show(table); - gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); - gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); - gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); - row = 0, col = 2; + table = gtk_table_new(3, 22, FALSE); + gtk_widget_show(table); + gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); + gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); + gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); + row = 0, col = 2; - label = gtk_label_new(_("Background")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + label = gtk_label_new(_("Background")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - executor->execp_background = create_background_combo(_("Executor")); - gtk_widget_show(executor->execp_background); - gtk_table_attach(GTK_TABLE(table), executor->execp_background, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, executor->execp_background, _("Selects the background used to display the executor. " - "Backgrounds can be edited in the Backgrounds tab."), NULL); + executor->execp_background = create_background_combo(_("Executor")); + gtk_widget_show(executor->execp_background); + gtk_table_attach(GTK_TABLE(table), executor->execp_background, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + executor->execp_background, + _("Selects the background used to display the executor. " + "Backgrounds can be edited in the Backgrounds tab."), + NULL); - row++, col = 2; - label = gtk_label_new(_("Horizontal padding")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Horizontal padding")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - executor->execp_padding_x = gtk_spin_button_new_with_range(0, 500, 1); - gtk_widget_show(executor->execp_padding_x); - gtk_table_attach(GTK_TABLE(table), executor->execp_padding_x, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, executor->execp_padding_x, _("Specifies the horizontal padding of the executor. " - "This is the space between the border and the content inside."), NULL); + executor->execp_padding_x = gtk_spin_button_new_with_range(0, 500, 1); + gtk_widget_show(executor->execp_padding_x); + gtk_table_attach(GTK_TABLE(table), executor->execp_padding_x, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + executor->execp_padding_x, + _("Specifies the horizontal padding of the executor. " + "This is the space between the border and the content inside."), + NULL); - row++, col = 2; - label = gtk_label_new(_("Vertical padding")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Vertical padding")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - executor->execp_padding_y = gtk_spin_button_new_with_range(0, 500, 1); - gtk_widget_show(executor->execp_padding_y); - gtk_table_attach(GTK_TABLE(table), executor->execp_padding_y, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, executor->execp_padding_y, _("Specifies the vertical padding of the executor. " - "This is the space between the border and the content inside."), NULL); + executor->execp_padding_y = gtk_spin_button_new_with_range(0, 500, 1); + gtk_widget_show(executor->execp_padding_y); + gtk_table_attach(GTK_TABLE(table), executor->execp_padding_y, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + executor->execp_padding_y, + _("Specifies the vertical padding of the executor. " + "This is the space between the border and the content inside."), + NULL); - row++, col = 1; - executor->execp_font_set = gtk_check_button_new(); - gtk_widget_show(executor->execp_font_set); - gtk_table_attach(GTK_TABLE(table), executor->execp_font_set, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - gtk_tooltips_set_tip(tooltips, executor->execp_font_set, _("If not checked, the desktop theme font is used. If checked, the custom font specified here is used."), NULL); - col++; + row++, col = 1; + executor->execp_font_set = gtk_check_button_new(); + gtk_widget_show(executor->execp_font_set); + gtk_table_attach(GTK_TABLE(table), executor->execp_font_set, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + gtk_tooltips_set_tip(tooltips, + executor->execp_font_set, + _("If not checked, the desktop theme font is used. If checked, the custom font specified here " + "is used."), + NULL); + col++; - label = gtk_label_new(_("Font")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + label = gtk_label_new(_("Font")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - executor->execp_font = gtk_font_button_new_with_font(get_default_font()); - gtk_widget_show(executor->execp_font); - gtk_table_attach(GTK_TABLE(table), executor->execp_font, col, col+3, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_font_button_set_show_style(GTK_FONT_BUTTON(executor->execp_font), TRUE); - gtk_signal_connect(GTK_OBJECT(executor->execp_font_set), "toggled", GTK_SIGNAL_FUNC(font_set_callback), executor->execp_font); - font_set_callback(executor->execp_font_set, executor->execp_font); + executor->execp_font = gtk_font_button_new_with_font(get_default_font()); + gtk_widget_show(executor->execp_font); + gtk_table_attach(GTK_TABLE(table), executor->execp_font, col, col + 3, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_font_button_set_show_style(GTK_FONT_BUTTON(executor->execp_font), TRUE); + gtk_signal_connect(GTK_OBJECT(executor->execp_font_set), + "toggled", + GTK_SIGNAL_FUNC(font_set_callback), + executor->execp_font); + font_set_callback(executor->execp_font_set, executor->execp_font); - row++, col = 2; - label = gtk_label_new(_("Font color")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Font color")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - executor->execp_font_color = gtk_color_button_new(); - gtk_color_button_set_use_alpha(GTK_COLOR_BUTTON(executor->execp_font_color), TRUE); - gtk_widget_show(executor->execp_font_color); - gtk_table_attach(GTK_TABLE(table), executor->execp_font_color, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + executor->execp_font_color = gtk_color_button_new(); + gtk_color_button_set_use_alpha(GTK_COLOR_BUTTON(executor->execp_font_color), TRUE); + gtk_widget_show(executor->execp_font_color); + gtk_table_attach(GTK_TABLE(table), executor->execp_font_color, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - row++, col = 2; - label = gtk_label_new(_("Centered")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Centered")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - executor->execp_centered = gtk_check_button_new(); - gtk_widget_show(executor->execp_centered); - gtk_table_attach(GTK_TABLE(table), executor->execp_centered, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + executor->execp_centered = gtk_check_button_new(); + gtk_widget_show(executor->execp_centered); + gtk_table_attach(GTK_TABLE(table), executor->execp_centered, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - row++, col = 2; - label = gtk_label_new(_("Icon width")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Icon width")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - executor->execp_icon_w = gtk_spin_button_new_with_range(0, 1000000, 1); - gtk_widget_show(executor->execp_icon_w); - gtk_table_attach(GTK_TABLE(table), executor->execp_icon_w, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, executor->execp_icon_w, _("If non-zero, the image is resized to this width."), NULL); + executor->execp_icon_w = gtk_spin_button_new_with_range(0, 1000000, 1); + gtk_widget_show(executor->execp_icon_w); + gtk_table_attach(GTK_TABLE(table), executor->execp_icon_w, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, executor->execp_icon_w, _("If non-zero, the image is resized to this width."), NULL); - row++, col = 2; - label = gtk_label_new(_("Icon height")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Icon height")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - executor->execp_icon_h = gtk_spin_button_new_with_range(0, 1000000, 1); - gtk_widget_show(executor->execp_icon_h); - gtk_table_attach(GTK_TABLE(table), executor->execp_icon_h, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, executor->execp_icon_h, _("If non-zero, the image is resized to this height."), NULL); + executor->execp_icon_h = gtk_spin_button_new_with_range(0, 1000000, 1); + gtk_widget_show(executor->execp_icon_h); + gtk_table_attach(GTK_TABLE(table), executor->execp_icon_h, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, executor->execp_icon_h, _("If non-zero, the image is resized to this height."), NULL); - row++, col = 2; - label = gtk_label_new(_("Tooltip")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Tooltip")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - executor->execp_show_tooltip = gtk_check_button_new(); - gtk_widget_show(executor->execp_show_tooltip); - gtk_table_attach(GTK_TABLE(table), executor->execp_show_tooltip, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(executor->execp_show_tooltip), 1); - col++; + executor->execp_show_tooltip = gtk_check_button_new(); + gtk_widget_show(executor->execp_show_tooltip); + gtk_table_attach(GTK_TABLE(table), executor->execp_show_tooltip, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(executor->execp_show_tooltip), 1); + col++; - row++, col = 2; - label = gtk_label_new(_("Tooltip text")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Tooltip text")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - executor->execp_tooltip = gtk_entry_new(); - gtk_widget_show(executor->execp_tooltip); - gtk_entry_set_width_chars(GTK_ENTRY(executor->execp_tooltip), 50); - gtk_table_attach(GTK_TABLE(table), executor->execp_tooltip, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, executor->execp_tooltip, - _("The tooltip text to display. Leave this empty to display an automatically generated tooltip with information about when the command was last executed."), NULL); + executor->execp_tooltip = gtk_entry_new(); + gtk_widget_show(executor->execp_tooltip); + gtk_entry_set_width_chars(GTK_ENTRY(executor->execp_tooltip), 50); + gtk_table_attach(GTK_TABLE(table), executor->execp_tooltip, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + executor->execp_tooltip, + _("The tooltip text to display. Leave this empty to display an automatically generated " + "tooltip with information about when the command was last executed."), + NULL); - change_paragraph(parent); + change_paragraph(parent); } void create_button(GtkWidget *notebook, int i) { - GtkWidget *label; - GtkWidget *table; - int row, col; - GtkTooltips *tooltips = gtk_tooltips_new(); + GtkWidget *label; + GtkWidget *table; + int row, col; + GtkTooltips *tooltips = gtk_tooltips_new(); - Button *button = &g_array_index(buttons, Button, i); + Button *button = &g_array_index(buttons, Button, i); - button->name[0] = 0; - sprintf(button->name, "%s %d", _("Button"), i + 1); - button->page_label = gtk_label_new(button->name); - gtk_widget_show(button->page_label); - button->page_button = gtk_vbox_new(FALSE, DEFAULT_HOR_SPACING); - button->container = addScrollBarToWidget(button->page_button); - gtk_container_set_border_width(GTK_CONTAINER(button->page_button), 10); - gtk_widget_show(button->page_button); - gtk_notebook_append_page(GTK_NOTEBOOK(notebook), button->container, button->page_label); + button->name[0] = 0; + sprintf(button->name, "%s %d", _("Button"), i + 1); + button->page_label = gtk_label_new(button->name); + gtk_widget_show(button->page_label); + button->page_button = gtk_vbox_new(FALSE, DEFAULT_HOR_SPACING); + button->container = addScrollBarToWidget(button->page_button); + gtk_container_set_border_width(GTK_CONTAINER(button->page_button), 10); + gtk_widget_show(button->page_button); + gtk_notebook_append_page(GTK_NOTEBOOK(notebook), button->container, button->page_label); - GtkWidget *parent = button->page_button; + GtkWidget *parent = button->page_button; - table = gtk_table_new(1, 2, FALSE); - gtk_widget_show(table); - gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); - gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); - gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); - row = 0, col = 2; + table = gtk_table_new(1, 2, FALSE); + gtk_widget_show(table); + gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); + gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); + gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); + row = 0, col = 2; - label = gtk_label_new(_("<b>Format</b>")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_label_set_use_markup(GTK_LABEL(label), TRUE); gtk_widget_show(label); - gtk_box_pack_start(GTK_BOX(parent), label, FALSE, FALSE, 0); + label = gtk_label_new(_("<b>Format</b>")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_label_set_use_markup(GTK_LABEL(label), TRUE); + gtk_widget_show(label); + gtk_box_pack_start(GTK_BOX(parent), label, FALSE, FALSE, 0); - table = gtk_table_new(3, 10, FALSE); - gtk_widget_show(table); - gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); - gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); - gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); - row = 0, col = 2; + table = gtk_table_new(3, 10, FALSE); + gtk_widget_show(table); + gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); + gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); + gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); + row = 0, col = 2; - label = gtk_label_new(_("Icon")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + label = gtk_label_new(_("Icon")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - button->button_icon = gtk_entry_new(); - gtk_widget_show(button->button_icon); - gtk_entry_set_width_chars(GTK_ENTRY(button->button_icon), 50); - gtk_table_attach(GTK_TABLE(table), button->button_icon, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + button->button_icon = gtk_entry_new(); + gtk_widget_show(button->button_icon); + gtk_entry_set_width_chars(GTK_ENTRY(button->button_icon), 50); + gtk_table_attach(GTK_TABLE(table), button->button_icon, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - row++, col = 2; - label = gtk_label_new(_("Text")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Text")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - button->button_text = gtk_entry_new(); - gtk_widget_show(button->button_text); - gtk_entry_set_width_chars(GTK_ENTRY(button->button_text), 50); - gtk_table_attach(GTK_TABLE(table), button->button_text, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + button->button_text = gtk_entry_new(); + gtk_widget_show(button->button_text); + gtk_entry_set_width_chars(GTK_ENTRY(button->button_text), 50); + gtk_table_attach(GTK_TABLE(table), button->button_text, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - row++, col = 2; - label = gtk_label_new(_("Tooltip")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Tooltip")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - button->button_tooltip = gtk_entry_new(); - gtk_widget_show(button->button_tooltip); - gtk_entry_set_width_chars(GTK_ENTRY(button->button_tooltip), 50); - gtk_table_attach(GTK_TABLE(table), button->button_tooltip, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + button->button_tooltip = gtk_entry_new(); + gtk_widget_show(button->button_tooltip); + gtk_entry_set_width_chars(GTK_ENTRY(button->button_tooltip), 50); + gtk_table_attach(GTK_TABLE(table), button->button_tooltip, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - change_paragraph(parent); + change_paragraph(parent); - label = gtk_label_new(_("<b>Mouse events</b>")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_label_set_use_markup(GTK_LABEL(label), TRUE); - gtk_widget_show(label); - gtk_box_pack_start(GTK_BOX(parent), label, FALSE, FALSE, 0); + label = gtk_label_new(_("<b>Mouse events</b>")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_label_set_use_markup(GTK_LABEL(label), TRUE); + gtk_widget_show(label); + gtk_box_pack_start(GTK_BOX(parent), label, FALSE, FALSE, 0); - table = gtk_table_new(5, 10, FALSE); - gtk_widget_show(table); - gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); - gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); - gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); - row = 0, col = 2; + table = gtk_table_new(5, 10, FALSE); + gtk_widget_show(table); + gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); + gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); + gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); + row = 0, col = 2; - label = gtk_label_new(_("Left click command")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + label = gtk_label_new(_("Left click command")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - button->button_left_command = gtk_entry_new(); - gtk_widget_show(button->button_left_command); - gtk_entry_set_width_chars(GTK_ENTRY(button->button_left_command), 50); - gtk_table_attach(GTK_TABLE(table), button->button_left_command, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, button->button_left_command, - _("Specifies a command that will be executed when the button receives a left click."), NULL); + button->button_left_command = gtk_entry_new(); + gtk_widget_show(button->button_left_command); + gtk_entry_set_width_chars(GTK_ENTRY(button->button_left_command), 50); + gtk_table_attach(GTK_TABLE(table), button->button_left_command, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + button->button_left_command, + _("Specifies a command that will be executed when the button receives a left click."), + NULL); - row++, col = 2; - label = gtk_label_new(_("Right click command")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Right click command")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - button->button_right_command = gtk_entry_new(); - gtk_widget_show(button->button_right_command); - gtk_entry_set_width_chars(GTK_ENTRY(button->button_right_command), 50); - gtk_table_attach(GTK_TABLE(table), button->button_right_command, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, button->button_right_command, - _("Specifies a command that will be executed when the button receives a right click."), NULL); + button->button_right_command = gtk_entry_new(); + gtk_widget_show(button->button_right_command); + gtk_entry_set_width_chars(GTK_ENTRY(button->button_right_command), 50); + gtk_table_attach(GTK_TABLE(table), button->button_right_command, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + button->button_right_command, + _("Specifies a command that will be executed when the button receives a right click."), + NULL); - row++, col = 2; - label = gtk_label_new(_("Middle click command")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Middle click command")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - button->button_mclick_command = gtk_entry_new(); - gtk_widget_show(button->button_mclick_command); - gtk_entry_set_width_chars(GTK_ENTRY(button->button_mclick_command), 50); - gtk_table_attach(GTK_TABLE(table), button->button_mclick_command, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, button->button_mclick_command, - _("Specifies a command that will be executed when the button receives a middle click."), NULL); + button->button_mclick_command = gtk_entry_new(); + gtk_widget_show(button->button_mclick_command); + gtk_entry_set_width_chars(GTK_ENTRY(button->button_mclick_command), 50); + gtk_table_attach(GTK_TABLE(table), button->button_mclick_command, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + button->button_mclick_command, + _("Specifies a command that will be executed when the button receives a middle click."), + NULL); - row++, col = 2; - label = gtk_label_new(_("Wheel scroll up command")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Wheel scroll up command")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - button->button_uwheel_command = gtk_entry_new(); - gtk_widget_show(button->button_uwheel_command); - gtk_entry_set_width_chars(GTK_ENTRY(button->button_uwheel_command), 50); - gtk_table_attach(GTK_TABLE(table), button->button_uwheel_command, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, button->button_uwheel_command, - _("Specifies a command that will be executed when the button receives a mouse scroll up."), NULL); + button->button_uwheel_command = gtk_entry_new(); + gtk_widget_show(button->button_uwheel_command); + gtk_entry_set_width_chars(GTK_ENTRY(button->button_uwheel_command), 50); + gtk_table_attach(GTK_TABLE(table), button->button_uwheel_command, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + button->button_uwheel_command, + _("Specifies a command that will be executed when the button receives a mouse scroll up."), + NULL); - row++, col = 2; - label = gtk_label_new(_("Wheel scroll down command")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Wheel scroll down command")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - button->button_dwheel_command = gtk_entry_new(); - gtk_widget_show(button->button_dwheel_command); - gtk_entry_set_width_chars(GTK_ENTRY(button->button_dwheel_command), 50); - gtk_table_attach(GTK_TABLE(table), button->button_dwheel_command, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, button->button_dwheel_command, - _("Specifies a command that will be executed when the button receives a mouse scroll down."), NULL); + button->button_dwheel_command = gtk_entry_new(); + gtk_widget_show(button->button_dwheel_command); + gtk_entry_set_width_chars(GTK_ENTRY(button->button_dwheel_command), 50); + gtk_table_attach(GTK_TABLE(table), button->button_dwheel_command, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + button->button_dwheel_command, + _("Specifies a command that will be executed when the button receives a mouse scroll down."), + NULL); - change_paragraph(parent); + change_paragraph(parent); - label = gtk_label_new(_("<b>Appearance</b>")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_label_set_use_markup(GTK_LABEL(label), TRUE); - gtk_widget_show(label); - gtk_box_pack_start(GTK_BOX(parent), label, FALSE, FALSE, 0); + label = gtk_label_new(_("<b>Appearance</b>")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_label_set_use_markup(GTK_LABEL(label), TRUE); + gtk_widget_show(label); + gtk_box_pack_start(GTK_BOX(parent), label, FALSE, FALSE, 0); - table = gtk_table_new(3, 22, FALSE); - gtk_widget_show(table); - gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); - gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); - gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); - row = 0, col = 2; + table = gtk_table_new(3, 22, FALSE); + gtk_widget_show(table); + gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); + gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); + gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); + row = 0, col = 2; - label = gtk_label_new(_("Background")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + label = gtk_label_new(_("Background")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - button->button_background = create_background_combo(_("Button")); - gtk_widget_show(button->button_background); - gtk_table_attach(GTK_TABLE(table), button->button_background, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, button->button_background, _("Selects the background used to display the button. " - "Backgrounds can be edited in the Backgrounds tab."), NULL); + button->button_background = create_background_combo(_("Button")); + gtk_widget_show(button->button_background); + gtk_table_attach(GTK_TABLE(table), button->button_background, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + button->button_background, + _("Selects the background used to display the button. " + "Backgrounds can be edited in the Backgrounds tab."), + NULL); - row++, col = 2; - label = gtk_label_new(_("Horizontal padding")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Horizontal padding")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - button->button_padding_x = gtk_spin_button_new_with_range(0, 500, 1); - gtk_widget_show(button->button_padding_x); - gtk_table_attach(GTK_TABLE(table), button->button_padding_x, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, button->button_padding_x, _("Specifies the horizontal padding of the button. " - "This is the space between the border and the content inside."), NULL); + button->button_padding_x = gtk_spin_button_new_with_range(0, 500, 1); + gtk_widget_show(button->button_padding_x); + gtk_table_attach(GTK_TABLE(table), button->button_padding_x, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + button->button_padding_x, + _("Specifies the horizontal padding of the button. " + "This is the space between the border and the content inside."), + NULL); - row++, col = 2; - label = gtk_label_new(_("Vertical padding")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Vertical padding")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - button->button_padding_y = gtk_spin_button_new_with_range(0, 500, 1); - gtk_widget_show(button->button_padding_y); - gtk_table_attach(GTK_TABLE(table), button->button_padding_y, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, button->button_padding_y, _("Specifies the vertical padding of the button. " - "This is the space between the border and the content inside."), NULL); + button->button_padding_y = gtk_spin_button_new_with_range(0, 500, 1); + gtk_widget_show(button->button_padding_y); + gtk_table_attach(GTK_TABLE(table), button->button_padding_y, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + button->button_padding_y, + _("Specifies the vertical padding of the button. " + "This is the space between the border and the content inside."), + NULL); - row++, col = 1; - button->button_font_set = gtk_check_button_new(); - gtk_widget_show(button->button_font_set); - gtk_table_attach(GTK_TABLE(table), button->button_font_set, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - gtk_tooltips_set_tip(tooltips, button->button_font_set, _("If not checked, the desktop theme font is used. If checked, the custom font specified here is used."), NULL); - col++; + row++, col = 1; + button->button_font_set = gtk_check_button_new(); + gtk_widget_show(button->button_font_set); + gtk_table_attach(GTK_TABLE(table), button->button_font_set, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + gtk_tooltips_set_tip(tooltips, + button->button_font_set, + _("If not checked, the desktop theme font is used. If checked, the custom font specified here " + "is used."), + NULL); + col++; - label = gtk_label_new(_("Font")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + label = gtk_label_new(_("Font")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - button->button_font = gtk_font_button_new_with_font(get_default_font()); - gtk_widget_show(button->button_font); - gtk_table_attach(GTK_TABLE(table), button->button_font, col, col+3, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_font_button_set_show_style(GTK_FONT_BUTTON(button->button_font), TRUE); - gtk_signal_connect(GTK_OBJECT(button->button_font_set), "toggled", GTK_SIGNAL_FUNC(font_set_callback), button->button_font); - font_set_callback(button->button_font_set, button->button_font); + button->button_font = gtk_font_button_new_with_font(get_default_font()); + gtk_widget_show(button->button_font); + gtk_table_attach(GTK_TABLE(table), button->button_font, col, col + 3, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_font_button_set_show_style(GTK_FONT_BUTTON(button->button_font), TRUE); + gtk_signal_connect(GTK_OBJECT(button->button_font_set), + "toggled", + GTK_SIGNAL_FUNC(font_set_callback), + button->button_font); + font_set_callback(button->button_font_set, button->button_font); - row++, col = 2; - label = gtk_label_new(_("Font color")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Font color")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - button->button_font_color = gtk_color_button_new(); - gtk_color_button_set_use_alpha(GTK_COLOR_BUTTON(button->button_font_color), TRUE); - gtk_widget_show(button->button_font_color); - gtk_table_attach(GTK_TABLE(table), button->button_font_color, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + button->button_font_color = gtk_color_button_new(); + gtk_color_button_set_use_alpha(GTK_COLOR_BUTTON(button->button_font_color), TRUE); + gtk_widget_show(button->button_font_color); + gtk_table_attach(GTK_TABLE(table), button->button_font_color, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - row++, col = 2; - label = gtk_label_new(_("Centered")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Centered")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - button->button_centered = gtk_check_button_new(); - gtk_widget_show(button->button_centered); - gtk_table_attach(GTK_TABLE(table), button->button_centered, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + button->button_centered = gtk_check_button_new(); + gtk_widget_show(button->button_centered); + gtk_table_attach(GTK_TABLE(table), button->button_centered, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - row++, col = 2; - label = gtk_label_new(_("Maximum icon size")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Maximum icon size")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - button->button_max_icon_size = gtk_spin_button_new_with_range(0, 500, 1); - gtk_widget_show(button->button_max_icon_size); - gtk_table_attach(GTK_TABLE(table), button->button_max_icon_size, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + button->button_max_icon_size = gtk_spin_button_new_with_range(0, 500, 1); + gtk_widget_show(button->button_max_icon_size); + gtk_table_attach(GTK_TABLE(table), button->button_max_icon_size, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - change_paragraph(parent); + change_paragraph(parent); } void separator_create_new() { - g_array_set_size(separators, separators->len + 1); - create_separator(notebook, separators->len - 1); + g_array_set_size(separators, separators->len + 1); + create_separator(notebook, separators->len - 1); } void execp_create_new() { - g_array_set_size(executors, executors->len + 1); - create_execp(notebook, executors->len - 1); + g_array_set_size(executors, executors->len + 1); + create_execp(notebook, executors->len - 1); } void button_create_new() { - g_array_set_size(buttons, buttons->len + 1); - create_button(notebook, buttons->len - 1); + g_array_set_size(buttons, buttons->len + 1); + create_button(notebook, buttons->len - 1); } Separator *separator_get_last() { - if (separators->len <= 0) - separator_create_new(); - return &g_array_index(separators, Separator, separators->len - 1); + if (separators->len <= 0) + separator_create_new(); + return &g_array_index(separators, Separator, separators->len - 1); } Executor *execp_get_last() { - if (executors->len <= 0) - execp_create_new(); - return &g_array_index(executors, Executor, executors->len - 1); + if (executors->len <= 0) + execp_create_new(); + return &g_array_index(executors, Executor, executors->len - 1); } Button *button_get_last() { - if (buttons->len <= 0) - button_create_new(); - return &g_array_index(buttons, Button, buttons->len - 1); + if (buttons->len <= 0) + button_create_new(); + return &g_array_index(buttons, Button, buttons->len - 1); } void separator_remove(int i) { - Separator *separator = &g_array_index(separators, Separator, i); + Separator *separator = &g_array_index(separators, Separator, i); - for (int i_page = 0; i_page < gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook)); i_page++) { - GtkWidget *page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), i_page); - if (page == separator->container) { - gtk_widget_hide(page); - gtk_notebook_remove_page(GTK_NOTEBOOK(notebook), i_page); - } - } + for (int i_page = 0; i_page < gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook)); i_page++) { + GtkWidget *page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), i_page); + if (page == separator->container) { + gtk_widget_hide(page); + gtk_notebook_remove_page(GTK_NOTEBOOK(notebook), i_page); + } + } - separators = g_array_remove_index(separators, i); + separators = g_array_remove_index(separators, i); } void execp_remove(int i) { - Executor *executor = &g_array_index(executors, Executor, i); + Executor *executor = &g_array_index(executors, Executor, i); - for (int i_page = 0; i_page < gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook)); i_page++) { - GtkWidget *page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), i_page); - if (page == executor->container) { - gtk_widget_hide(page); - gtk_notebook_remove_page(GTK_NOTEBOOK(notebook), i_page); - } - } + for (int i_page = 0; i_page < gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook)); i_page++) { + GtkWidget *page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), i_page); + if (page == executor->container) { + gtk_widget_hide(page); + gtk_notebook_remove_page(GTK_NOTEBOOK(notebook), i_page); + } + } - executors = g_array_remove_index(executors, i); + executors = g_array_remove_index(executors, i); } void button_remove(int i) { - Button *button = &g_array_index(buttons, Button, i); + Button *button = &g_array_index(buttons, Button, i); - for (int i_page = 0; i_page < gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook)); i_page++) { - GtkWidget *page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), i_page); - if (page == button->container) { - gtk_widget_hide(page); - gtk_notebook_remove_page(GTK_NOTEBOOK(notebook), i_page); - } - } + for (int i_page = 0; i_page < gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook)); i_page++) { + GtkWidget *page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), i_page); + if (page == button->container) { + gtk_widget_hide(page); + gtk_notebook_remove_page(GTK_NOTEBOOK(notebook), i_page); + } + } - buttons = g_array_remove_index(buttons, i); + buttons = g_array_remove_index(buttons, i); } void separator_update_indices() { - for (int i = 0; i < separators->len; i++) { - Separator *separator = &g_array_index(separators, Separator, i); - sprintf(separator->name, "%s %d", _("Separator"), i + 1); - gtk_label_set_text(GTK_LABEL(separator->page_label), separator->name); - } + for (int i = 0; i < separators->len; i++) { + Separator *separator = &g_array_index(separators, Separator, i); + sprintf(separator->name, "%s %d", _("Separator"), i + 1); + gtk_label_set_text(GTK_LABEL(separator->page_label), separator->name); + } - GtkTreeModel *model = GTK_TREE_MODEL(panel_items); - GtkTreeIter iter; - if (!gtk_tree_model_get_iter_first(model, &iter)) - return; - int separator_index = -1; - while (1) { - gchar *name; - gchar *value; - gtk_tree_model_get(model, &iter, - itemsColName, &name, - itemsColValue, &value, - -1); + GtkTreeModel *model = GTK_TREE_MODEL(panel_items); + GtkTreeIter iter; + if (!gtk_tree_model_get_iter_first(model, &iter)) + return; + int separator_index = -1; + while (1) { + gchar *name; + gchar *value; + gtk_tree_model_get(model, &iter, itemsColName, &name, itemsColValue, &value, -1); - if (g_str_equal(value, ":")) { - separator_index++; - char buffer[256]; - buffer[0] = 0; - sprintf(buffer, "%s %d", _("Separator"), separator_index + 1); + if (g_str_equal(value, ":")) { + separator_index++; + char buffer[256]; + buffer[0] = 0; + sprintf(buffer, "%s %d", _("Separator"), separator_index + 1); - gtk_list_store_set(panel_items, &iter, - itemsColName, buffer, - -1); - } + gtk_list_store_set(panel_items, &iter, itemsColName, buffer, -1); + } - if (!gtk_tree_model_iter_next(model, &iter)) - break; - } + if (!gtk_tree_model_iter_next(model, &iter)) + break; + } } void execp_update_indices() { - for (int i = 0; i < executors->len; i++) { - Executor *executor = &g_array_index(executors, Executor, i); - sprintf(executor->name, "%s %d", _("Executor"), i + 1); - gtk_label_set_text(GTK_LABEL(executor->page_label), executor->name); - } + for (int i = 0; i < executors->len; i++) { + Executor *executor = &g_array_index(executors, Executor, i); + sprintf(executor->name, "%s %d", _("Executor"), i + 1); + gtk_label_set_text(GTK_LABEL(executor->page_label), executor->name); + } - GtkTreeModel *model = GTK_TREE_MODEL(panel_items); - GtkTreeIter iter; - if (!gtk_tree_model_get_iter_first(model, &iter)) - return; - int execp_index = -1; - while (1) { - gchar *name; - gchar *value; - gtk_tree_model_get(model, &iter, - itemsColName, &name, - itemsColValue, &value, - -1); + GtkTreeModel *model = GTK_TREE_MODEL(panel_items); + GtkTreeIter iter; + if (!gtk_tree_model_get_iter_first(model, &iter)) + return; + int execp_index = -1; + while (1) { + gchar *name; + gchar *value; + gtk_tree_model_get(model, &iter, itemsColName, &name, itemsColValue, &value, -1); - if (g_str_equal(value, "E")) { - execp_index++; - char buffer[256]; - buffer[0] = 0; - sprintf(buffer, "%s %d", _("Executor"), execp_index + 1); + if (g_str_equal(value, "E")) { + execp_index++; + char buffer[256]; + buffer[0] = 0; + sprintf(buffer, "%s %d", _("Executor"), execp_index + 1); - gtk_list_store_set(panel_items, &iter, - itemsColName, buffer, - -1); - } + gtk_list_store_set(panel_items, &iter, itemsColName, buffer, -1); + } - if (!gtk_tree_model_iter_next(model, &iter)) - break; - } + if (!gtk_tree_model_iter_next(model, &iter)) + break; + } } void button_update_indices() { - for (int i = 0; i < buttons->len; i++) { - Button *button = &g_array_index(buttons, Button, i); - sprintf(button->name, "%s %d", _("Button"), i + 1); - gtk_label_set_text(GTK_LABEL(button->page_label), button->name); - } + for (int i = 0; i < buttons->len; i++) { + Button *button = &g_array_index(buttons, Button, i); + sprintf(button->name, "%s %d", _("Button"), i + 1); + gtk_label_set_text(GTK_LABEL(button->page_label), button->name); + } - GtkTreeModel *model = GTK_TREE_MODEL(panel_items); - GtkTreeIter iter; - if (!gtk_tree_model_get_iter_first(model, &iter)) - return; - int button_index = -1; - while (1) { - gchar *name; - gchar *value; - gtk_tree_model_get(model, &iter, - itemsColName, &name, - itemsColValue, &value, - -1); + GtkTreeModel *model = GTK_TREE_MODEL(panel_items); + GtkTreeIter iter; + if (!gtk_tree_model_get_iter_first(model, &iter)) + return; + int button_index = -1; + while (1) { + gchar *name; + gchar *value; + gtk_tree_model_get(model, &iter, itemsColName, &name, itemsColValue, &value, -1); - if (g_str_equal(value, "P")) { - button_index++; - char buffer[256]; - buffer[0] = 0; - sprintf(buffer, "%s %d", _("Button"), button_index + 1); + if (g_str_equal(value, "P")) { + button_index++; + char buffer[256]; + buffer[0] = 0; + sprintf(buffer, "%s %d", _("Button"), button_index + 1); - gtk_list_store_set(panel_items, &iter, - itemsColName, buffer, - -1); - } + gtk_list_store_set(panel_items, &iter, itemsColName, buffer, -1); + } - if (!gtk_tree_model_iter_next(model, &iter)) - break; - } + if (!gtk_tree_model_iter_next(model, &iter)) + break; + } } void create_systemtray(GtkWidget *parent) { - GtkWidget *table; - GtkWidget *label; - int row, col; - GtkTooltips *tooltips = gtk_tooltips_new(); + GtkWidget *table; + GtkWidget *label; + int row, col; + GtkTooltips *tooltips = gtk_tooltips_new(); - label = gtk_label_new(_("<b>Options</b>")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_label_set_use_markup(GTK_LABEL(label), TRUE); - gtk_widget_show(label); - gtk_box_pack_start(GTK_BOX(parent), label, FALSE, FALSE, 0); + label = gtk_label_new(_("<b>Options</b>")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_label_set_use_markup(GTK_LABEL(label), TRUE); + gtk_widget_show(label); + gtk_box_pack_start(GTK_BOX(parent), label, FALSE, FALSE, 0); - table = gtk_table_new(2, 2, FALSE); - gtk_widget_show(table); - gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); - gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); - gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); - row = 0; - col = 2; + table = gtk_table_new(2, 2, FALSE); + gtk_widget_show(table); + gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); + gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); + gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); + row = 0; + col = 2; - label = gtk_label_new(_("Icon ordering")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + label = gtk_label_new(_("Icon ordering")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - systray_icon_order = gtk_combo_box_new_text(); - gtk_widget_show(systray_icon_order); - gtk_table_attach(GTK_TABLE(table), systray_icon_order, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_combo_box_append_text(GTK_COMBO_BOX(systray_icon_order), _("Ascending")); - gtk_combo_box_append_text(GTK_COMBO_BOX(systray_icon_order), _("Descending")); - gtk_combo_box_append_text(GTK_COMBO_BOX(systray_icon_order), _("Left to right")); - gtk_combo_box_append_text(GTK_COMBO_BOX(systray_icon_order), _("Right to left")); - gtk_combo_box_set_active(GTK_COMBO_BOX(systray_icon_order), 0); - gtk_tooltips_set_tip(tooltips, systray_icon_order, _("Specifies the order used to arrange the system tray icons. \n" - "'Ascending' means that icons are sorted in ascending order of their window names. \n" - "'Descending' means that icons are sorted in descending order of their window names. \n" - "'Left to right' means that icons are always added to the left. \n" - "'Right to left' means that icons are always added to the right."), NULL); + systray_icon_order = gtk_combo_box_new_text(); + gtk_widget_show(systray_icon_order); + gtk_table_attach(GTK_TABLE(table), systray_icon_order, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_combo_box_append_text(GTK_COMBO_BOX(systray_icon_order), _("Ascending")); + gtk_combo_box_append_text(GTK_COMBO_BOX(systray_icon_order), _("Descending")); + gtk_combo_box_append_text(GTK_COMBO_BOX(systray_icon_order), _("Left to right")); + gtk_combo_box_append_text(GTK_COMBO_BOX(systray_icon_order), _("Right to left")); + gtk_combo_box_set_active(GTK_COMBO_BOX(systray_icon_order), 0); + gtk_tooltips_set_tip(tooltips, + systray_icon_order, + _("Specifies the order used to arrange the system tray icons. \n" + "'Ascending' means that icons are sorted in ascending order of their window names. \n" + "'Descending' means that icons are sorted in descending order of their window names. \n" + "'Left to right' means that icons are always added to the left. \n" + "'Right to left' means that icons are always added to the right."), + NULL); - row++; - col = 2; - label = gtk_label_new(_("Monitor")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++; + col = 2; + label = gtk_label_new(_("Monitor")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - systray_monitor = gtk_combo_box_new_text(); - gtk_widget_show(systray_monitor); - gtk_table_attach(GTK_TABLE(table), systray_monitor, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_combo_box_append_text(GTK_COMBO_BOX(systray_monitor), _("1")); - gtk_combo_box_append_text(GTK_COMBO_BOX(systray_monitor), _("2")); - gtk_combo_box_append_text(GTK_COMBO_BOX(systray_monitor), _("3")); - gtk_combo_box_append_text(GTK_COMBO_BOX(systray_monitor), _("4")); - gtk_combo_box_append_text(GTK_COMBO_BOX(systray_monitor), _("5")); - gtk_combo_box_append_text(GTK_COMBO_BOX(systray_monitor), _("6")); - gtk_combo_box_set_active(GTK_COMBO_BOX(systray_monitor), 0); - gtk_tooltips_set_tip(tooltips, systray_monitor, _("Specifies the monitor on which to place the system tray. " - "Due to technical limitations, the system tray cannot be displayed on multiple monitors."), NULL); + systray_monitor = gtk_combo_box_new_text(); + gtk_widget_show(systray_monitor); + gtk_table_attach(GTK_TABLE(table), systray_monitor, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_combo_box_append_text(GTK_COMBO_BOX(systray_monitor), _("1")); + gtk_combo_box_append_text(GTK_COMBO_BOX(systray_monitor), _("2")); + gtk_combo_box_append_text(GTK_COMBO_BOX(systray_monitor), _("3")); + gtk_combo_box_append_text(GTK_COMBO_BOX(systray_monitor), _("4")); + gtk_combo_box_append_text(GTK_COMBO_BOX(systray_monitor), _("5")); + gtk_combo_box_append_text(GTK_COMBO_BOX(systray_monitor), _("6")); + gtk_combo_box_set_active(GTK_COMBO_BOX(systray_monitor), 0); + gtk_tooltips_set_tip(tooltips, + systray_monitor, + _("Specifies the monitor on which to place the system tray. " + "Due to technical limitations, the system tray cannot be displayed on multiple monitors."), + NULL); - change_paragraph(parent); + change_paragraph(parent); - label = gtk_label_new(_("<b>Appearance</b>")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_label_set_use_markup(GTK_LABEL(label), TRUE); - gtk_widget_show(label); - gtk_box_pack_start(GTK_BOX(parent), label, FALSE, FALSE, 0); + label = gtk_label_new(_("<b>Appearance</b>")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_label_set_use_markup(GTK_LABEL(label), TRUE); + gtk_widget_show(label); + gtk_box_pack_start(GTK_BOX(parent), label, FALSE, FALSE, 0); - table = gtk_table_new(6, 10, FALSE); - gtk_widget_show(table); - gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); - gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); - gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); - row = 0, col = 2; + table = gtk_table_new(6, 10, FALSE); + gtk_widget_show(table); + gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); + gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); + gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); + row = 0, col = 2; - label = gtk_label_new(_("Background")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + label = gtk_label_new(_("Background")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - systray_background = create_background_combo(_("Systray")); - gtk_widget_show(systray_background); - gtk_table_attach(GTK_TABLE(table), systray_background, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, systray_background, _("Selects the background used to display the system tray. " - "Backgrounds can be edited in the Backgrounds tab."), NULL); + systray_background = create_background_combo(_("Systray")); + gtk_widget_show(systray_background); + gtk_table_attach(GTK_TABLE(table), systray_background, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + systray_background, + _("Selects the background used to display the system tray. " + "Backgrounds can be edited in the Backgrounds tab."), + NULL); - row++; - col = 2; - label = gtk_label_new(_("Horizontal padding")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++; + col = 2; + label = gtk_label_new(_("Horizontal padding")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - systray_padding_x = gtk_spin_button_new_with_range(0, 500, 1); - gtk_widget_show(systray_padding_x); - gtk_table_attach(GTK_TABLE(table), systray_padding_x, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, systray_padding_x, _("Specifies the horizontal padding of the system tray. " - "This is the space between the border and the content inside."), NULL); + systray_padding_x = gtk_spin_button_new_with_range(0, 500, 1); + gtk_widget_show(systray_padding_x); + gtk_table_attach(GTK_TABLE(table), systray_padding_x, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + systray_padding_x, + _("Specifies the horizontal padding of the system tray. " + "This is the space between the border and the content inside."), + NULL); - row++; - col = 2; - label = gtk_label_new(_("Vertical padding")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++; + col = 2; + label = gtk_label_new(_("Vertical padding")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - systray_padding_y = gtk_spin_button_new_with_range(0, 500, 1); - gtk_widget_show(systray_padding_y); - gtk_table_attach(GTK_TABLE(table), systray_padding_y, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, systray_padding_y, _("Specifies the vertical padding of the system tray. " - "This is the space between the border and the content inside."), NULL); + systray_padding_y = gtk_spin_button_new_with_range(0, 500, 1); + gtk_widget_show(systray_padding_y); + gtk_table_attach(GTK_TABLE(table), systray_padding_y, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + systray_padding_y, + _("Specifies the vertical padding of the system tray. " + "This is the space between the border and the content inside."), + NULL); - row++; - col = 2; - label = gtk_label_new(_("Spacing")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++; + col = 2; + label = gtk_label_new(_("Spacing")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - systray_spacing = gtk_spin_button_new_with_range(0, 500, 1); - gtk_widget_show(systray_spacing); - gtk_table_attach(GTK_TABLE(table), systray_spacing, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, systray_spacing, _("Specifies the spacing between system tray icons."), NULL); + systray_spacing = gtk_spin_button_new_with_range(0, 500, 1); + gtk_widget_show(systray_spacing); + gtk_table_attach(GTK_TABLE(table), systray_spacing, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, systray_spacing, _("Specifies the spacing between system tray icons."), NULL); - row++; - col = 2; - label = gtk_label_new(_("Icon size")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++; + col = 2; + label = gtk_label_new(_("Icon size")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - systray_icon_size = gtk_spin_button_new_with_range(0, 500, 1); - gtk_widget_show(systray_icon_size); - gtk_table_attach(GTK_TABLE(table), systray_icon_size, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, systray_icon_size, _("Specifies the size of the system tray icons, in pixels."), NULL); + systray_icon_size = gtk_spin_button_new_with_range(0, 500, 1); + gtk_widget_show(systray_icon_size); + gtk_table_attach(GTK_TABLE(table), systray_icon_size, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + systray_icon_size, + _("Specifies the size of the system tray icons, in pixels."), + NULL); - row++; - col = 2; - label = gtk_label_new(_("Icon opacity")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++; + col = 2; + label = gtk_label_new(_("Icon opacity")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - systray_icon_opacity = gtk_spin_button_new_with_range(0, 100, 1); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(systray_icon_opacity), 100); - gtk_widget_show(systray_icon_opacity); - gtk_table_attach(GTK_TABLE(table), systray_icon_opacity, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, systray_icon_opacity, _("Specifies the opacity of the system tray icons, in percent."), NULL); + systray_icon_opacity = gtk_spin_button_new_with_range(0, 100, 1); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(systray_icon_opacity), 100); + gtk_widget_show(systray_icon_opacity); + gtk_table_attach(GTK_TABLE(table), systray_icon_opacity, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + systray_icon_opacity, + _("Specifies the opacity of the system tray icons, in percent."), + NULL); - row++; - col = 2; - label = gtk_label_new(_("Icon saturation")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++; + col = 2; + label = gtk_label_new(_("Icon saturation")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - systray_icon_saturation = gtk_spin_button_new_with_range(-100, 100, 1); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(systray_icon_saturation), 0); - gtk_widget_show(systray_icon_saturation); - gtk_table_attach(GTK_TABLE(table), systray_icon_saturation, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, systray_icon_saturation, _("Specifies the saturation adjustment of the system tray icons, in percent."), NULL); + systray_icon_saturation = gtk_spin_button_new_with_range(-100, 100, 1); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(systray_icon_saturation), 0); + gtk_widget_show(systray_icon_saturation); + gtk_table_attach(GTK_TABLE(table), systray_icon_saturation, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + systray_icon_saturation, + _("Specifies the saturation adjustment of the system tray icons, in percent."), + NULL); - row++; - col = 2; - label = gtk_label_new(_("Icon brightness")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++; + col = 2; + label = gtk_label_new(_("Icon brightness")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - systray_icon_brightness = gtk_spin_button_new_with_range(-100, 100, 1); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(systray_icon_brightness), 0); - gtk_widget_show(systray_icon_brightness); - gtk_table_attach(GTK_TABLE(table), systray_icon_brightness, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, systray_icon_brightness, _("Specifies the brightness adjustment of the system tray icons, in percent."), NULL); + systray_icon_brightness = gtk_spin_button_new_with_range(-100, 100, 1); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(systray_icon_brightness), 0); + gtk_widget_show(systray_icon_brightness); + gtk_table_attach(GTK_TABLE(table), systray_icon_brightness, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + systray_icon_brightness, + _("Specifies the brightness adjustment of the system tray icons, in percent."), + NULL); - row++, col = 2; - label = gtk_label_new(_("Name filter")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Name filter")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - systray_name_filter = gtk_entry_new(); - gtk_widget_show(systray_name_filter); - gtk_entry_set_width_chars(GTK_ENTRY(systray_name_filter), 50); - gtk_table_attach(GTK_TABLE(table), systray_name_filter, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + systray_name_filter = gtk_entry_new(); + gtk_widget_show(systray_name_filter); + gtk_entry_set_width_chars(GTK_ENTRY(systray_name_filter), 50); + gtk_table_attach(GTK_TABLE(table), systray_name_filter, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; } void create_battery(GtkWidget *parent) { - GtkWidget *table, *label; - int row, col; - GtkTooltips *tooltips = gtk_tooltips_new(); + GtkWidget *table, *label; + int row, col; + GtkTooltips *tooltips = gtk_tooltips_new(); - table = gtk_table_new(1, 2, FALSE); - gtk_widget_show(table); - gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); - gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); - gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); - row = 0, col = 2; + table = gtk_table_new(1, 2, FALSE); + gtk_widget_show(table); + gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); + gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); + gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); + row = 0, col = 2; - label = gtk_label_new(_("<b>Thresholds</b>")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_label_set_use_markup(GTK_LABEL(label), TRUE); - gtk_widget_show(label); - gtk_box_pack_start(GTK_BOX(parent), label, FALSE, FALSE, 0); + label = gtk_label_new(_("<b>Thresholds</b>")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_label_set_use_markup(GTK_LABEL(label), TRUE); + gtk_widget_show(label); + gtk_box_pack_start(GTK_BOX(parent), label, FALSE, FALSE, 0); - table = gtk_table_new(2, 10, FALSE); - gtk_widget_show(table); - gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); - gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); - gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); - row = 0, col = 2; + table = gtk_table_new(2, 10, FALSE); + gtk_widget_show(table); + gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); + gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); + gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); + row = 0, col = 2; - label = gtk_label_new(_("Hide if charge higher than")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + label = gtk_label_new(_("Hide if charge higher than")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - battery_hide_if_higher = gtk_spin_button_new_with_range(0, 101, 1); - gtk_widget_show(battery_hide_if_higher); - gtk_table_attach(GTK_TABLE(table), battery_hide_if_higher, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, battery_hide_if_higher, _("Minimum battery level for which to hide the batter applet. Use 101 to always show the batter applet."), NULL); + battery_hide_if_higher = gtk_spin_button_new_with_range(0, 101, 1); + gtk_widget_show(battery_hide_if_higher); + gtk_table_attach(GTK_TABLE(table), battery_hide_if_higher, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + battery_hide_if_higher, + _("Minimum battery level for which to hide the batter applet. Use 101 to always show the " + "batter applet."), + NULL); - label = gtk_label_new(_("%")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + label = gtk_label_new(_("%")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - row++, col = 2; - label = gtk_label_new(_("Alert if charge lower than")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Alert if charge lower than")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - battery_alert_if_lower = gtk_spin_button_new_with_range(0, 100, 1); - gtk_widget_show(battery_alert_if_lower); - gtk_table_attach(GTK_TABLE(table), battery_alert_if_lower, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, battery_alert_if_lower, _("Battery level for which to display an alert."), NULL); + battery_alert_if_lower = gtk_spin_button_new_with_range(0, 100, 1); + gtk_widget_show(battery_alert_if_lower); + gtk_table_attach(GTK_TABLE(table), battery_alert_if_lower, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, battery_alert_if_lower, _("Battery level for which to display an alert."), NULL); - label = gtk_label_new(_("%")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + label = gtk_label_new(_("%")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - row++, col = 2; - label = gtk_label_new(_("Alert command")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Alert command")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - battery_alert_cmd = gtk_entry_new(); - gtk_widget_show(battery_alert_cmd); - gtk_entry_set_width_chars(GTK_ENTRY(battery_alert_cmd), 50); - gtk_table_attach(GTK_TABLE(table), battery_alert_cmd, col, col+3, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, battery_alert_cmd, _("Command to be executed when the alert threshold is reached."), NULL); + battery_alert_cmd = gtk_entry_new(); + gtk_widget_show(battery_alert_cmd); + gtk_entry_set_width_chars(GTK_ENTRY(battery_alert_cmd), 50); + gtk_table_attach(GTK_TABLE(table), battery_alert_cmd, col, col + 3, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + battery_alert_cmd, + _("Command to be executed when the alert threshold is reached."), + NULL); - change_paragraph(parent); + change_paragraph(parent); - label = gtk_label_new(_("<b>AC connection events</b>")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_label_set_use_markup(GTK_LABEL(label), TRUE); - gtk_widget_show(label); - gtk_box_pack_start(GTK_BOX(parent), label, FALSE, FALSE, 0); + label = gtk_label_new(_("<b>AC connection events</b>")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_label_set_use_markup(GTK_LABEL(label), TRUE); + gtk_widget_show(label); + gtk_box_pack_start(GTK_BOX(parent), label, FALSE, FALSE, 0); - table = gtk_table_new(2, 10, FALSE); - gtk_widget_show(table); - gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); - gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); - gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); + table = gtk_table_new(2, 10, FALSE); + gtk_widget_show(table); + gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); + gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); + gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); - row = 0, col = 2; - label = gtk_label_new(_("AC connected command")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row = 0, col = 2; + label = gtk_label_new(_("AC connected command")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - ac_connected_cmd = gtk_entry_new(); - gtk_widget_show(ac_connected_cmd); - gtk_entry_set_width_chars(GTK_ENTRY(ac_connected_cmd), 50); - gtk_table_attach(GTK_TABLE(table), ac_connected_cmd, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, ac_connected_cmd, - _("Specifies a command that will be executed when AC is connected to the system."), NULL); + ac_connected_cmd = gtk_entry_new(); + gtk_widget_show(ac_connected_cmd); + gtk_entry_set_width_chars(GTK_ENTRY(ac_connected_cmd), 50); + gtk_table_attach(GTK_TABLE(table), ac_connected_cmd, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + ac_connected_cmd, + _("Specifies a command that will be executed when AC is connected to the system."), + NULL); - row++, col = 2; - label = gtk_label_new(_("AC disconnected command")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("AC disconnected command")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - ac_disconnected_cmd = gtk_entry_new(); - gtk_widget_show(ac_disconnected_cmd); - gtk_entry_set_width_chars(GTK_ENTRY(ac_disconnected_cmd), 50); - gtk_table_attach(GTK_TABLE(table), ac_disconnected_cmd, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, ac_disconnected_cmd, - _("Specifies a command that will be executed when AC is disconnected to the system."), NULL); + ac_disconnected_cmd = gtk_entry_new(); + gtk_widget_show(ac_disconnected_cmd); + gtk_entry_set_width_chars(GTK_ENTRY(ac_disconnected_cmd), 50); + gtk_table_attach(GTK_TABLE(table), ac_disconnected_cmd, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + ac_disconnected_cmd, + _("Specifies a command that will be executed when AC is disconnected to the system."), + NULL); - change_paragraph(parent); + change_paragraph(parent); - label = gtk_label_new(_("<b>Mouse events</b>")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_label_set_use_markup(GTK_LABEL(label), TRUE); - gtk_widget_show(label); - gtk_box_pack_start(GTK_BOX(parent), label, FALSE, FALSE, 0); + label = gtk_label_new(_("<b>Mouse events</b>")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_label_set_use_markup(GTK_LABEL(label), TRUE); + gtk_widget_show(label); + gtk_box_pack_start(GTK_BOX(parent), label, FALSE, FALSE, 0); - table = gtk_table_new(5, 10, FALSE); - gtk_widget_show(table); - gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); - gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); - gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); - row = 0, col = 2; + table = gtk_table_new(5, 10, FALSE); + gtk_widget_show(table); + gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); + gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); + gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); + row = 0, col = 2; - label = gtk_label_new(_("Tooltips")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + label = gtk_label_new(_("Tooltips")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - battery_tooltip = gtk_check_button_new(); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(battery_tooltip), 1); - gtk_widget_show(battery_tooltip); - gtk_table_attach(GTK_TABLE(table), battery_tooltip, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, battery_tooltip, _("If enabled, shows a tooltip with detailed battery information when the mouse is moved over the battery widget."), NULL); + battery_tooltip = gtk_check_button_new(); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(battery_tooltip), 1); + gtk_widget_show(battery_tooltip); + gtk_table_attach(GTK_TABLE(table), battery_tooltip, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + battery_tooltip, + _("If enabled, shows a tooltip with detailed battery information when the mouse is moved over " + "the battery widget."), + NULL); - row++, col = 2; - label = gtk_label_new(_("Left click command")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Left click command")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - battery_left_command = gtk_entry_new(); - gtk_widget_show(battery_left_command); - gtk_entry_set_width_chars(GTK_ENTRY(battery_left_command), 50); - gtk_table_attach(GTK_TABLE(table), battery_left_command, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, battery_left_command, - _("Specifies a command that will be executed when the battery receives a left click."), NULL); + battery_left_command = gtk_entry_new(); + gtk_widget_show(battery_left_command); + gtk_entry_set_width_chars(GTK_ENTRY(battery_left_command), 50); + gtk_table_attach(GTK_TABLE(table), battery_left_command, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + battery_left_command, + _("Specifies a command that will be executed when the battery receives a left click."), + NULL); - row++, col = 2; - label = gtk_label_new(_("Right click command")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Right click command")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - battery_right_command = gtk_entry_new(); - gtk_widget_show(battery_right_command); - gtk_entry_set_width_chars(GTK_ENTRY(battery_right_command), 50); - gtk_table_attach(GTK_TABLE(table), battery_right_command, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, battery_right_command, - _("Specifies a command that will be executed when the battery receives a right click."), NULL); + battery_right_command = gtk_entry_new(); + gtk_widget_show(battery_right_command); + gtk_entry_set_width_chars(GTK_ENTRY(battery_right_command), 50); + gtk_table_attach(GTK_TABLE(table), battery_right_command, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + battery_right_command, + _("Specifies a command that will be executed when the battery receives a right click."), + NULL); - row++, col = 2; - label = gtk_label_new(_("Middle click command")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Middle click command")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - battery_mclick_command = gtk_entry_new(); - gtk_widget_show(battery_mclick_command); - gtk_entry_set_width_chars(GTK_ENTRY(battery_mclick_command), 50); - gtk_table_attach(GTK_TABLE(table), battery_mclick_command, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, battery_mclick_command, - _("Specifies a command that will be executed when the battery receives a middle click."), NULL); + battery_mclick_command = gtk_entry_new(); + gtk_widget_show(battery_mclick_command); + gtk_entry_set_width_chars(GTK_ENTRY(battery_mclick_command), 50); + gtk_table_attach(GTK_TABLE(table), battery_mclick_command, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + battery_mclick_command, + _("Specifies a command that will be executed when the battery receives a middle click."), + NULL); - row++, col = 2; - label = gtk_label_new(_("Wheel scroll up command")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Wheel scroll up command")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - battery_uwheel_command = gtk_entry_new(); - gtk_widget_show(battery_uwheel_command); - gtk_entry_set_width_chars(GTK_ENTRY(battery_uwheel_command), 50); - gtk_table_attach(GTK_TABLE(table), battery_uwheel_command, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, battery_uwheel_command, - _("Specifies a command that will be executed when the battery receives a mouse scroll up."), NULL); + battery_uwheel_command = gtk_entry_new(); + gtk_widget_show(battery_uwheel_command); + gtk_entry_set_width_chars(GTK_ENTRY(battery_uwheel_command), 50); + gtk_table_attach(GTK_TABLE(table), battery_uwheel_command, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + battery_uwheel_command, + _("Specifies a command that will be executed when the battery receives a mouse scroll up."), + NULL); - row++, col = 2; - label = gtk_label_new(_("Wheel scroll down command")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Wheel scroll down command")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - battery_dwheel_command = gtk_entry_new(); - gtk_widget_show(battery_dwheel_command); - gtk_entry_set_width_chars(GTK_ENTRY(battery_dwheel_command), 50); - gtk_table_attach(GTK_TABLE(table), battery_dwheel_command, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, battery_dwheel_command, - _("Specifies a command that will be executed when the battery receives a mouse scroll down."), NULL); + battery_dwheel_command = gtk_entry_new(); + gtk_widget_show(battery_dwheel_command); + gtk_entry_set_width_chars(GTK_ENTRY(battery_dwheel_command), 50); + gtk_table_attach(GTK_TABLE(table), battery_dwheel_command, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + battery_dwheel_command, + _("Specifies a command that will be executed when the battery receives a mouse scroll down."), + NULL); - change_paragraph(parent); + change_paragraph(parent); - label = gtk_label_new(_("<b>Appearance</b>")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_label_set_use_markup(GTK_LABEL(label), TRUE); - gtk_widget_show(label); - gtk_box_pack_start(GTK_BOX(parent), label, FALSE, FALSE, 0); + label = gtk_label_new(_("<b>Appearance</b>")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_label_set_use_markup(GTK_LABEL(label), TRUE); + gtk_widget_show(label); + gtk_box_pack_start(GTK_BOX(parent), label, FALSE, FALSE, 0); - table = gtk_table_new(4, 22, FALSE); - gtk_widget_show(table); - gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); - gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); - gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); - row = 0, col = 2; + table = gtk_table_new(4, 22, FALSE); + gtk_widget_show(table); + gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); + gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); + gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); + row = 0, col = 2; - label = gtk_label_new(_("Background")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + label = gtk_label_new(_("Background")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - battery_background = create_background_combo(_("Battery")); - gtk_widget_show(battery_background); - gtk_table_attach(GTK_TABLE(table), battery_background, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, battery_background, _("Selects the background used to display the battery. " - "Backgrounds can be edited in the Backgrounds tab."), NULL); + battery_background = create_background_combo(_("Battery")); + gtk_widget_show(battery_background); + gtk_table_attach(GTK_TABLE(table), battery_background, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + battery_background, + _("Selects the background used to display the battery. " + "Backgrounds can be edited in the Backgrounds tab."), + NULL); - row++, col = 2; - label = gtk_label_new(_("Horizontal padding")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Horizontal padding")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - battery_padding_x = gtk_spin_button_new_with_range(0, 500, 1); - gtk_widget_show(battery_padding_x); - gtk_table_attach(GTK_TABLE(table), battery_padding_x, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, battery_padding_x, _("Specifies the horizontal padding of the battery. " - "This is the space between the border and the content inside."), NULL); + battery_padding_x = gtk_spin_button_new_with_range(0, 500, 1); + gtk_widget_show(battery_padding_x); + gtk_table_attach(GTK_TABLE(table), battery_padding_x, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + battery_padding_x, + _("Specifies the horizontal padding of the battery. " + "This is the space between the border and the content inside."), + NULL); - row++, col = 2; - label = gtk_label_new(_("Vertical padding")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Vertical padding")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - battery_padding_y = gtk_spin_button_new_with_range(0, 500, 1); - gtk_widget_show(battery_padding_y); - gtk_table_attach(GTK_TABLE(table), battery_padding_y, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, battery_padding_y, _("Specifies the vertical padding of the battery. " - "This is the space between the border and the content inside."), NULL); + battery_padding_y = gtk_spin_button_new_with_range(0, 500, 1); + gtk_widget_show(battery_padding_y); + gtk_table_attach(GTK_TABLE(table), battery_padding_y, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + battery_padding_y, + _("Specifies the vertical padding of the battery. " + "This is the space between the border and the content inside."), + NULL); - row++, col = 1; - battery_font_line1_set = gtk_check_button_new(); - gtk_widget_show(battery_font_line1_set); - gtk_table_attach(GTK_TABLE(table), battery_font_line1_set, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - gtk_tooltips_set_tip(tooltips, battery_font_line1_set, _("If not checked, the desktop theme font is used. If checked, the custom font specified here is used."), NULL); - col++; + row++, col = 1; + battery_font_line1_set = gtk_check_button_new(); + gtk_widget_show(battery_font_line1_set); + gtk_table_attach(GTK_TABLE(table), battery_font_line1_set, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + gtk_tooltips_set_tip(tooltips, + battery_font_line1_set, + _("If not checked, the desktop theme font is used. If checked, the custom font specified here " + "is used."), + NULL); + col++; - label = gtk_label_new(_("Font first line")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + label = gtk_label_new(_("Font first line")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - PangoFontDescription *bat1_font_desc = pango_font_description_from_string(get_default_font()); - pango_font_description_set_size(bat1_font_desc, pango_font_description_get_size(bat1_font_desc) - PANGO_SCALE); - battery_font_line1 = gtk_font_button_new_with_font(pango_font_description_to_string(bat1_font_desc)); - gtk_widget_show(battery_font_line1); - pango_font_description_free(bat1_font_desc); - gtk_table_attach(GTK_TABLE(table), battery_font_line1, col, col+3, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_font_button_set_show_style(GTK_FONT_BUTTON(battery_font_line1), TRUE); - gtk_tooltips_set_tip(tooltips, battery_font_line1, _("Specifies the font used to display the first line of the battery text."), NULL); - gtk_signal_connect(GTK_OBJECT(battery_font_line1_set), "toggled", GTK_SIGNAL_FUNC(font_set_callback), battery_font_line1); - font_set_callback(battery_font_line1_set, battery_font_line1); + PangoFontDescription *bat1_font_desc = pango_font_description_from_string(get_default_font()); + pango_font_description_set_size(bat1_font_desc, pango_font_description_get_size(bat1_font_desc) - PANGO_SCALE); + battery_font_line1 = gtk_font_button_new_with_font(pango_font_description_to_string(bat1_font_desc)); + gtk_widget_show(battery_font_line1); + pango_font_description_free(bat1_font_desc); + gtk_table_attach(GTK_TABLE(table), battery_font_line1, col, col + 3, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_font_button_set_show_style(GTK_FONT_BUTTON(battery_font_line1), TRUE); + gtk_tooltips_set_tip(tooltips, + battery_font_line1, + _("Specifies the font used to display the first line of the battery text."), + NULL); + gtk_signal_connect(GTK_OBJECT(battery_font_line1_set), + "toggled", + GTK_SIGNAL_FUNC(font_set_callback), + battery_font_line1); + font_set_callback(battery_font_line1_set, battery_font_line1); - row++, col = 1; - battery_font_line2_set = gtk_check_button_new(); - gtk_widget_show(battery_font_line2_set); - gtk_table_attach(GTK_TABLE(table), battery_font_line2_set, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - gtk_tooltips_set_tip(tooltips, battery_font_line2_set, _("If not checked, the desktop theme font is used. If checked, the custom font specified here is used."), NULL); - col++; + row++, col = 1; + battery_font_line2_set = gtk_check_button_new(); + gtk_widget_show(battery_font_line2_set); + gtk_table_attach(GTK_TABLE(table), battery_font_line2_set, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + gtk_tooltips_set_tip(tooltips, + battery_font_line2_set, + _("If not checked, the desktop theme font is used. If checked, the custom font specified here " + "is used."), + NULL); + col++; - label = gtk_label_new(_("Font second line")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + label = gtk_label_new(_("Font second line")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - PangoFontDescription *bat2_font_desc = pango_font_description_from_string(get_default_font()); - pango_font_description_set_size(bat2_font_desc, pango_font_description_get_size(bat2_font_desc) - PANGO_SCALE); - battery_font_line2 = gtk_font_button_new_with_font(pango_font_description_to_string(bat2_font_desc)); - pango_font_description_free(bat2_font_desc); - gtk_widget_show(battery_font_line2); - gtk_table_attach(GTK_TABLE(table), battery_font_line2, col, col+3, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_font_button_set_show_style(GTK_FONT_BUTTON(battery_font_line2), TRUE); - gtk_tooltips_set_tip(tooltips, battery_font_line2, _("Specifies the font used to display the second line of the battery text."), NULL); - gtk_signal_connect(GTK_OBJECT(battery_font_line2_set), "toggled", GTK_SIGNAL_FUNC(font_set_callback), battery_font_line2); - font_set_callback(battery_font_line2_set, battery_font_line2); + PangoFontDescription *bat2_font_desc = pango_font_description_from_string(get_default_font()); + pango_font_description_set_size(bat2_font_desc, pango_font_description_get_size(bat2_font_desc) - PANGO_SCALE); + battery_font_line2 = gtk_font_button_new_with_font(pango_font_description_to_string(bat2_font_desc)); + pango_font_description_free(bat2_font_desc); + gtk_widget_show(battery_font_line2); + gtk_table_attach(GTK_TABLE(table), battery_font_line2, col, col + 3, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_font_button_set_show_style(GTK_FONT_BUTTON(battery_font_line2), TRUE); + gtk_tooltips_set_tip(tooltips, + battery_font_line2, + _("Specifies the font used to display the second line of the battery text."), + NULL); + gtk_signal_connect(GTK_OBJECT(battery_font_line2_set), + "toggled", + GTK_SIGNAL_FUNC(font_set_callback), + battery_font_line2); + font_set_callback(battery_font_line2_set, battery_font_line2); - row++, col = 2; - label = gtk_label_new(_("Font color")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Font color")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - battery_font_color = gtk_color_button_new(); - gtk_color_button_set_use_alpha(GTK_COLOR_BUTTON(battery_font_color), TRUE); - gtk_widget_show(battery_font_color); - gtk_table_attach(GTK_TABLE(table), battery_font_color, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, battery_font_color, _("Specifies the font clor used to display the battery text."), NULL); + battery_font_color = gtk_color_button_new(); + gtk_color_button_set_use_alpha(GTK_COLOR_BUTTON(battery_font_color), TRUE); + gtk_widget_show(battery_font_color); + gtk_table_attach(GTK_TABLE(table), battery_font_color, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + battery_font_color, + _("Specifies the font clor used to display the battery text."), + NULL); - change_paragraph(parent); + change_paragraph(parent); } void create_tooltip(GtkWidget *parent) { - GtkWidget *table; - GtkWidget *label; - int row, col; - GtkTooltips *tooltips = gtk_tooltips_new(); + GtkWidget *table; + GtkWidget *label; + int row, col; + GtkTooltips *tooltips = gtk_tooltips_new(); - label = gtk_label_new(_("<b>Timing</b>")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_label_set_use_markup(GTK_LABEL(label), TRUE); - gtk_widget_show(label); - gtk_box_pack_start(GTK_BOX(parent), label, FALSE, FALSE, 0); + label = gtk_label_new(_("<b>Timing</b>")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_label_set_use_markup(GTK_LABEL(label), TRUE); + gtk_widget_show(label); + gtk_box_pack_start(GTK_BOX(parent), label, FALSE, FALSE, 0); - table = gtk_table_new(2, 22, FALSE); - gtk_widget_show(table); - gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); - gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); - gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); - row = 0, col = 2; + table = gtk_table_new(2, 22, FALSE); + gtk_widget_show(table); + gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); + gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); + gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); + row = 0, col = 2; - label = gtk_label_new(_("Show delay")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + label = gtk_label_new(_("Show delay")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - tooltip_show_after = gtk_spin_button_new_with_range(0, 10000, 0.1); - gtk_widget_show(tooltip_show_after); - gtk_table_attach(GTK_TABLE(table), tooltip_show_after, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, tooltip_show_after, _("Specifies a delay after which to show the tooltip when moving the mouse over an element."), NULL); + tooltip_show_after = gtk_spin_button_new_with_range(0, 10000, 0.1); + gtk_widget_show(tooltip_show_after); + gtk_table_attach(GTK_TABLE(table), tooltip_show_after, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + tooltip_show_after, + _("Specifies a delay after which to show the tooltip when moving the mouse over an element."), + NULL); - label = gtk_label_new(_("seconds")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + label = gtk_label_new(_("seconds")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - row++, col = 2; - label = gtk_label_new(_("Hide delay")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Hide delay")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - tooltip_hide_after = gtk_spin_button_new_with_range(0, 10000, 0.1); - gtk_widget_show(tooltip_hide_after); - gtk_table_attach(GTK_TABLE(table), tooltip_hide_after, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - gtk_tooltips_set_tip(tooltips, tooltip_hide_after, _("Specifies a delay after which to hide the tooltip when moving the mouse outside an element."), NULL); - col++; + tooltip_hide_after = gtk_spin_button_new_with_range(0, 10000, 0.1); + gtk_widget_show(tooltip_hide_after); + gtk_table_attach(GTK_TABLE(table), tooltip_hide_after, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + gtk_tooltips_set_tip(tooltips, + tooltip_hide_after, + _("Specifies a delay after which to hide the tooltip when moving the mouse outside an " + "element."), + NULL); + col++; - label = gtk_label_new(_("seconds")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + label = gtk_label_new(_("seconds")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - change_paragraph(parent); + change_paragraph(parent); - label = gtk_label_new(_("<b>Appearance</b>")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_label_set_use_markup(GTK_LABEL(label), TRUE); - gtk_widget_show(label); - gtk_box_pack_start(GTK_BOX(parent), label, FALSE, FALSE, 0); + label = gtk_label_new(_("<b>Appearance</b>")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_label_set_use_markup(GTK_LABEL(label), TRUE); + gtk_widget_show(label); + gtk_box_pack_start(GTK_BOX(parent), label, FALSE, FALSE, 0); - table = gtk_table_new(3, 10, FALSE); - gtk_widget_show(table); - gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); - gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); - gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); - row = 0, col = 2; + table = gtk_table_new(3, 10, FALSE); + gtk_widget_show(table); + gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); + gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); + gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); + row = 0, col = 2; - label = gtk_label_new(_("Background")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + label = gtk_label_new(_("Background")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - tooltip_background = create_background_combo(_("Tooltip")); - gtk_widget_show(tooltip_background); - gtk_table_attach(GTK_TABLE(table), tooltip_background, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, tooltip_background, _("Selects the background used to display the tooltip. " - "Backgrounds can be edited in the Backgrounds tab."), NULL); + tooltip_background = create_background_combo(_("Tooltip")); + gtk_widget_show(tooltip_background); + gtk_table_attach(GTK_TABLE(table), tooltip_background, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + tooltip_background, + _("Selects the background used to display the tooltip. " + "Backgrounds can be edited in the Backgrounds tab."), + NULL); - row++, col = 2; - label = gtk_label_new(_("Horizontal padding")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Horizontal padding")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - tooltip_padding_x = gtk_spin_button_new_with_range(0, 500, 1); - gtk_widget_show(tooltip_padding_x); - gtk_table_attach(GTK_TABLE(table), tooltip_padding_x, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, tooltip_padding_x, _("Specifies the horizontal padding of the tooltip. " - "This is the space between the border and the content inside."), NULL); + tooltip_padding_x = gtk_spin_button_new_with_range(0, 500, 1); + gtk_widget_show(tooltip_padding_x); + gtk_table_attach(GTK_TABLE(table), tooltip_padding_x, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + tooltip_padding_x, + _("Specifies the horizontal padding of the tooltip. " + "This is the space between the border and the content inside."), + NULL); - row++, col = 2; - label = gtk_label_new(_("Vertical padding")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Vertical padding")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - tooltip_padding_y = gtk_spin_button_new_with_range(0, 500, 1); - gtk_widget_show(tooltip_padding_y); - gtk_table_attach(GTK_TABLE(table), tooltip_padding_y, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, tooltip_padding_y, _("Specifies the vertical padding of the tooltip. " - "This is the space between the border and the content inside."), NULL); + tooltip_padding_y = gtk_spin_button_new_with_range(0, 500, 1); + gtk_widget_show(tooltip_padding_y); + gtk_table_attach(GTK_TABLE(table), tooltip_padding_y, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + tooltip_padding_y, + _("Specifies the vertical padding of the tooltip. " + "This is the space between the border and the content inside."), + NULL); - row++, col = 1; - tooltip_font_set = gtk_check_button_new(); - gtk_widget_show(tooltip_font_set); - gtk_table_attach(GTK_TABLE(table), tooltip_font_set, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - gtk_tooltips_set_tip(tooltips, tooltip_font_set, _("If not checked, the desktop theme font is used. If checked, the custom font specified here is used."), NULL); - col++; + row++, col = 1; + tooltip_font_set = gtk_check_button_new(); + gtk_widget_show(tooltip_font_set); + gtk_table_attach(GTK_TABLE(table), tooltip_font_set, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + gtk_tooltips_set_tip(tooltips, + tooltip_font_set, + _("If not checked, the desktop theme font is used. If checked, the custom font specified here " + "is used."), + NULL); + col++; - label = gtk_label_new(_("Font")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + label = gtk_label_new(_("Font")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - tooltip_font = gtk_font_button_new_with_font(get_default_font()); - gtk_widget_show(tooltip_font); - gtk_table_attach(GTK_TABLE(table), tooltip_font, col, col+3, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_font_button_set_show_style(GTK_FONT_BUTTON(tooltip_font), TRUE); - gtk_tooltips_set_tip(tooltips, tooltip_font, _("Specifies the font used to display the text of the tooltip."), NULL); - gtk_signal_connect(GTK_OBJECT(tooltip_font_set), "toggled", GTK_SIGNAL_FUNC(font_set_callback), tooltip_font); - font_set_callback(tooltip_font_set, tooltip_font); + tooltip_font = gtk_font_button_new_with_font(get_default_font()); + gtk_widget_show(tooltip_font); + gtk_table_attach(GTK_TABLE(table), tooltip_font, col, col + 3, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_font_button_set_show_style(GTK_FONT_BUTTON(tooltip_font), TRUE); + gtk_tooltips_set_tip(tooltips, tooltip_font, _("Specifies the font used to display the text of the tooltip."), NULL); + gtk_signal_connect(GTK_OBJECT(tooltip_font_set), "toggled", GTK_SIGNAL_FUNC(font_set_callback), tooltip_font); + font_set_callback(tooltip_font_set, tooltip_font); - row++, col = 2; - label = gtk_label_new(_("Font color")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - gtk_widget_show(label); - gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; + row++, col = 2; + label = gtk_label_new(_("Font color")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; - tooltip_font_color = gtk_color_button_new(); - gtk_color_button_set_use_alpha(GTK_COLOR_BUTTON(tooltip_font_color), TRUE); - gtk_widget_show(tooltip_font_color); - gtk_table_attach(GTK_TABLE(table), tooltip_font_color, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, tooltip_font_color, _("Specifies the font color used to display the text of the tooltip."), NULL); + tooltip_font_color = gtk_color_button_new(); + gtk_color_button_set_use_alpha(GTK_COLOR_BUTTON(tooltip_font_color), TRUE); + gtk_widget_show(tooltip_font_color); + gtk_table_attach(GTK_TABLE(table), tooltip_font_color, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, + tooltip_font_color, + _("Specifies the font color used to display the text of the tooltip."), + NULL); - change_paragraph(parent); + change_paragraph(parent); } static GtkWidget *please_wait_dialog = NULL; void create_please_wait(GtkWindow *parent) { - if (please_wait_dialog) - return; + if (please_wait_dialog) + return; - please_wait_dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL); - gtk_window_set_title(GTK_WINDOW(please_wait_dialog), "Center"); - gtk_window_set_default_size(GTK_WINDOW(please_wait_dialog), 300, 150); - gtk_window_set_position(GTK_WINDOW(please_wait_dialog), GTK_WIN_POS_CENTER); - gtk_container_set_border_width(GTK_CONTAINER(please_wait_dialog), 15); - gtk_window_set_title(GTK_WINDOW(please_wait_dialog), _("Please wait...")); - gtk_window_set_deletable(GTK_WINDOW(please_wait_dialog), FALSE); + please_wait_dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL); + gtk_window_set_title(GTK_WINDOW(please_wait_dialog), "Center"); + gtk_window_set_default_size(GTK_WINDOW(please_wait_dialog), 300, 150); + gtk_window_set_position(GTK_WINDOW(please_wait_dialog), GTK_WIN_POS_CENTER); + gtk_container_set_border_width(GTK_CONTAINER(please_wait_dialog), 15); + gtk_window_set_title(GTK_WINDOW(please_wait_dialog), _("Please wait...")); + gtk_window_set_deletable(GTK_WINDOW(please_wait_dialog), FALSE); - GtkWidget *label = gtk_label_new(_("Loading...")); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + GtkWidget *label = gtk_label_new(_("Loading...")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - GtkWidget *halign = gtk_alignment_new(0.5, 0.5, 0, 0); - gtk_container_add(GTK_CONTAINER(halign), label); + GtkWidget *halign = gtk_alignment_new(0.5, 0.5, 0, 0); + gtk_container_add(GTK_CONTAINER(halign), label); gtk_container_add(GTK_CONTAINER(please_wait_dialog), halign); - gtk_widget_show_all(please_wait_dialog); - gtk_window_set_modal(GTK_WINDOW(please_wait_dialog), TRUE); - // gtk_window_set_keep_above(GTK_WINDOW(please_wait_dialog), TRUE); - gtk_window_set_transient_for(GTK_WINDOW(please_wait_dialog), parent); + gtk_widget_show_all(please_wait_dialog); + gtk_window_set_modal(GTK_WINDOW(please_wait_dialog), TRUE); + // gtk_window_set_keep_above(GTK_WINDOW(please_wait_dialog), TRUE); + gtk_window_set_transient_for(GTK_WINDOW(please_wait_dialog), parent); } void process_events() { - while (gtk_events_pending()) - gtk_main_iteration_do(FALSE); + while (gtk_events_pending()) + gtk_main_iteration_do(FALSE); } void destroy_please_wait() { - if (!please_wait_dialog) - return; - gtk_widget_destroy(please_wait_dialog); - please_wait_dialog = NULL; + if (!please_wait_dialog) + return; + gtk_widget_destroy(please_wait_dialog); + please_wait_dialog = NULL; }
M src/tint2conf/properties.hsrc/tint2conf/properties.h

@@ -8,22 +8,20 @@ #include <gdk-pixbuf/gdk-pixbuf.h>

#include "../launcher/icon-theme-common.h" - // panel -extern GtkWidget *panel_width, *panel_height, *panel_margin_x, *panel_margin_y, *panel_padding_x, *panel_padding_y, *panel_spacing; -extern GtkWidget *panel_wm_menu, *panel_dock, *panel_autohide, *panel_autohide_show_time, *panel_autohide_hide_time, *panel_autohide_size; -extern GtkWidget *panel_combo_strut_policy, *panel_combo_layer, *panel_combo_width_type, *panel_combo_height_type, *panel_combo_monitor; +extern GtkWidget *panel_width, *panel_height, *panel_margin_x, *panel_margin_y, *panel_padding_x, *panel_padding_y, + *panel_spacing; +extern GtkWidget *panel_wm_menu, *panel_dock, *panel_autohide, *panel_autohide_show_time, *panel_autohide_hide_time, + *panel_autohide_size; +extern GtkWidget *panel_combo_strut_policy, *panel_combo_layer, *panel_combo_width_type, *panel_combo_height_type, + *panel_combo_monitor; extern GtkWidget *panel_window_name, *disable_transparency; extern GtkWidget *panel_mouse_effects; extern GtkWidget *mouse_hover_icon_opacity, *mouse_hover_icon_saturation, *mouse_hover_icon_brightness; extern GtkWidget *mouse_pressed_icon_opacity, *mouse_pressed_icon_saturation, *mouse_pressed_icon_brightness; extern GtkWidget *panel_primary_monitor_first, *panel_shrink; -enum { - itemsColName = 0, - itemsColValue, - itemsNumCols -}; +enum { itemsColName = 0, itemsColValue, itemsNumCols }; extern GtkListStore *panel_items, *all_items; extern GtkWidget *panel_items_view, *all_items_view; char *get_panel_items();

@@ -52,44 +50,34 @@

// taskbar extern GtkWidget *taskbar_show_desktop, *taskbar_show_name, *taskbar_padding_x, *taskbar_padding_y, *taskbar_spacing; extern GtkWidget *taskbar_hide_inactive_tasks, *taskbar_hide_diff_monitor; -extern GtkWidget *taskbar_name_padding_x, *taskbar_name_padding_y, *taskbar_name_inactive_color, *taskbar_name_active_color; +extern GtkWidget *taskbar_name_padding_x, *taskbar_name_padding_y, *taskbar_name_inactive_color, + *taskbar_name_active_color; extern GtkWidget *taskbar_name_font, *taskbar_name_font_set; extern GtkWidget *taskbar_active_background, *taskbar_inactive_background; extern GtkWidget *taskbar_name_active_background, *taskbar_name_inactive_background; -extern GtkWidget *taskbar_distribute_size, *taskbar_sort_order, *taskbar_alignment, *taskbar_always_show_all_desktop_tasks; +extern GtkWidget *taskbar_distribute_size, *taskbar_sort_order, *taskbar_alignment, + *taskbar_always_show_all_desktop_tasks; extern GtkWidget *taskbar_hide_empty; // task -extern GtkWidget *task_mouse_left, *task_mouse_middle, *task_mouse_right, *task_mouse_scroll_up, *task_mouse_scroll_down; +extern GtkWidget *task_mouse_left, *task_mouse_middle, *task_mouse_right, *task_mouse_scroll_up, + *task_mouse_scroll_down; extern GtkWidget *task_show_icon, *task_show_text, *task_align_center, *font_shadow; extern GtkWidget *task_maximum_width, *task_maximum_height, *task_padding_x, *task_padding_y, *task_spacing; extern GtkWidget *task_font, *task_font_set; -extern GtkWidget *task_default_color, *task_default_color_set, - *task_default_icon_opacity, *task_default_icon_osb_set, - *task_default_icon_saturation, - *task_default_icon_brightness, - *task_default_background, *task_default_background_set; -extern GtkWidget *task_normal_color, *task_normal_color_set, - *task_normal_icon_opacity, *task_normal_icon_osb_set, - *task_normal_icon_saturation, - *task_normal_icon_brightness, - *task_normal_background, *task_normal_background_set; -extern GtkWidget *task_active_color, *task_active_color_set, - *task_active_icon_opacity, *task_active_icon_osb_set, - *task_active_icon_saturation, - *task_active_icon_brightness, - *task_active_background, *task_active_background_set; -extern GtkWidget *task_urgent_color, *task_urgent_color_set, - *task_urgent_icon_opacity, *task_urgent_icon_osb_set, - *task_urgent_icon_saturation, - *task_urgent_icon_brightness, - *task_urgent_background, *task_urgent_background_set; +extern GtkWidget *task_default_color, *task_default_color_set, *task_default_icon_opacity, *task_default_icon_osb_set, + *task_default_icon_saturation, *task_default_icon_brightness, *task_default_background, + *task_default_background_set; +extern GtkWidget *task_normal_color, *task_normal_color_set, *task_normal_icon_opacity, *task_normal_icon_osb_set, + *task_normal_icon_saturation, *task_normal_icon_brightness, *task_normal_background, *task_normal_background_set; +extern GtkWidget *task_active_color, *task_active_color_set, *task_active_icon_opacity, *task_active_icon_osb_set, + *task_active_icon_saturation, *task_active_icon_brightness, *task_active_background, *task_active_background_set; +extern GtkWidget *task_urgent_color, *task_urgent_color_set, *task_urgent_icon_opacity, *task_urgent_icon_osb_set, + *task_urgent_icon_saturation, *task_urgent_icon_brightness, *task_urgent_background, *task_urgent_background_set; extern GtkWidget *task_urgent_blinks; -extern GtkWidget *task_iconified_color, *task_iconified_color_set, - *task_iconified_icon_opacity, *task_iconified_icon_osb_set, - *task_iconified_icon_saturation, - *task_iconified_icon_brightness, - *task_iconified_background, *task_iconified_background_set; +extern GtkWidget *task_iconified_color, *task_iconified_color_set, *task_iconified_icon_opacity, + *task_iconified_icon_osb_set, *task_iconified_icon_saturation, *task_iconified_icon_brightness, + *task_iconified_background, *task_iconified_background_set; // clock extern GtkWidget *clock_format_line1, *clock_format_line2, *clock_tmz_line1, *clock_tmz_line2;

@@ -102,10 +90,12 @@

// battery extern GtkWidget *battery_hide_if_higher, *battery_alert_if_lower, *battery_alert_cmd; extern GtkWidget *battery_padding_x, *battery_padding_y; -extern GtkWidget *battery_font_line1, *battery_font_line1_set, *battery_font_line2, *battery_font_line2_set, *battery_font_color; +extern GtkWidget *battery_font_line1, *battery_font_line1_set, *battery_font_line2, *battery_font_line2_set, + *battery_font_color; extern GtkWidget *battery_background; extern GtkWidget *battery_tooltip; -extern GtkWidget *battery_left_command, *battery_mclick_command, *battery_right_command, *battery_uwheel_command, *battery_dwheel_command; +extern GtkWidget *battery_left_command, *battery_mclick_command, *battery_right_command, *battery_uwheel_command, + *battery_dwheel_command; extern GtkWidget *ac_connected_cmd, *ac_disconnected_cmd; // systray

@@ -121,60 +111,55 @@ extern GtkWidget *tooltip_background;

// Separator typedef struct Separator { - char name[256]; - GtkWidget *container; - GtkWidget *page_separator; - GtkWidget *page_label; - GtkWidget *separator_background; - GtkWidget *separator_color; - GtkWidget *separator_style; - GtkWidget *separator_size; - GtkWidget *separator_padding_x; - GtkWidget *separator_padding_y; + char name[256]; + GtkWidget *container; + GtkWidget *page_separator; + GtkWidget *page_label; + GtkWidget *separator_background; + GtkWidget *separator_color; + GtkWidget *separator_style; + GtkWidget *separator_size; + GtkWidget *separator_padding_x; + GtkWidget *separator_padding_y; } Separator; extern GArray *separators; // Executor typedef struct Executor { - char name[256]; - GtkWidget *container; - GtkWidget *page_execp; - GtkWidget *page_label; - GtkWidget *execp_command, *execp_interval, *execp_has_icon, *execp_cache_icon, *execp_show_tooltip; - GtkWidget *execp_continuous, *execp_markup, *execp_tooltip; - GtkWidget *execp_left_command, *execp_right_command; - GtkWidget *execp_mclick_command, *execp_rclick_command, *execp_uwheel_command, *execp_dwheel_command; - GtkWidget *execp_font, *execp_font_set, *execp_font_color, *execp_padding_x, *execp_padding_y, *execp_centered; - GtkWidget *execp_background, *execp_icon_w, *execp_icon_h; + char name[256]; + GtkWidget *container; + GtkWidget *page_execp; + GtkWidget *page_label; + GtkWidget *execp_command, *execp_interval, *execp_has_icon, *execp_cache_icon, *execp_show_tooltip; + GtkWidget *execp_continuous, *execp_markup, *execp_tooltip; + GtkWidget *execp_left_command, *execp_right_command; + GtkWidget *execp_mclick_command, *execp_rclick_command, *execp_uwheel_command, *execp_dwheel_command; + GtkWidget *execp_font, *execp_font_set, *execp_font_color, *execp_padding_x, *execp_padding_y, *execp_centered; + GtkWidget *execp_background, *execp_icon_w, *execp_icon_h; } Executor; extern GArray *executors; // Button typedef struct Button { - char name[256]; - GtkWidget *container; - GtkWidget *page_button; - GtkWidget *page_label; - GtkWidget *button_icon, *button_text, *button_tooltip; - GtkWidget *button_left_command, *button_right_command; - GtkWidget *button_mclick_command, *button_rclick_command, *button_uwheel_command, *button_dwheel_command; - GtkWidget *button_font, *button_font_set, *button_font_color, *button_padding_x, *button_padding_y, *button_centered; - GtkWidget *button_background, *button_max_icon_size; + char name[256]; + GtkWidget *container; + GtkWidget *page_button; + GtkWidget *page_label; + GtkWidget *button_icon, *button_text, *button_tooltip; + GtkWidget *button_left_command, *button_right_command; + GtkWidget *button_mclick_command, *button_rclick_command, *button_uwheel_command, *button_dwheel_command; + GtkWidget *button_font, *button_font_set, *button_font_color, *button_padding_x, *button_padding_y, + *button_centered; + GtkWidget *button_background, *button_max_icon_size; } Button; extern GArray *buttons; // launcher -enum { - appsColIcon = 0, - appsColIconName, - appsColText, - appsColPath, - appsNumCols -}; +enum { appsColIcon = 0, appsColIconName, appsColText, appsColPath, appsNumCols }; extern GtkListStore *launcher_apps, *all_apps; extern GtkWidget *launcher_apps_view, *all_apps_view;

@@ -195,73 +180,49 @@ gchar *get_current_icon_theme();

// background enum { - bgColPixbuf = 0, - bgColFillColor, - bgColFillOpacity, - bgColBorderColor, - bgColBorderOpacity, - bgColGradientId, - bgColBorderWidth, - bgColCornerRadius, - bgColText, - bgColFillColorOver, - bgColFillOpacityOver, - bgColBorderColorOver, - bgColBorderOpacityOver, - bgColGradientIdOver, - bgColFillColorPress, - bgColFillOpacityPress, - bgColBorderColorPress, - bgColBorderOpacityPress, - bgColGradientIdPress, + bgColPixbuf = 0, + bgColFillColor, + bgColFillOpacity, + bgColBorderColor, + bgColBorderOpacity, + bgColGradientId, + bgColBorderWidth, + bgColCornerRadius, + bgColText, + bgColFillColorOver, + bgColFillOpacityOver, + bgColBorderColorOver, + bgColBorderOpacityOver, + bgColGradientIdOver, + bgColFillColorPress, + bgColFillOpacityPress, + bgColBorderColorPress, + bgColBorderOpacityPress, + bgColGradientIdPress, bgColBorderSidesTop, bgColBorderSidesBottom, bgColBorderSidesLeft, bgColBorderSidesRight, - bgNumCols + bgNumCols }; extern GtkListStore *backgrounds; -extern GtkWidget *current_background, - *background_fill_color, - *background_border_color, - *background_gradient, - *background_fill_color_over, - *background_border_color_over, - *background_gradient_over, - *background_fill_color_press, - *background_border_color_press, - *background_gradient_press, - *background_border_width, - *background_border_sides_top, - *background_border_sides_bottom, - *background_border_sides_left, - *background_border_sides_right, - *background_corner_radius; +extern GtkWidget *current_background, *background_fill_color, *background_border_color, *background_gradient, + *background_fill_color_over, *background_border_color_over, *background_gradient_over, *background_fill_color_press, + *background_border_color_press, *background_gradient_press, *background_border_width, *background_border_sides_top, + *background_border_sides_bottom, *background_border_sides_left, *background_border_sides_right, + *background_corner_radius; // gradients -enum { - grColPixbuf = 0, - grColId, - grColText, - grNumCols -}; +enum { grColPixbuf = 0, grColId, grColText, grNumCols }; // gradient color stops -enum { - grStopColPixbuf = 0, - grStopNumCols -}; +enum { grStopColPixbuf = 0, grStopNumCols }; extern GtkListStore *gradient_ids, *gradient_stop_ids; extern GList *gradients; -extern GtkWidget *current_gradient, - *gradient_combo_type, - *gradient_start_color, - *gradient_end_color, - *current_gradient_stop, - *gradient_stop_color, - *gradient_stop_offset; +extern GtkWidget *current_gradient, *gradient_combo_type, *gradient_start_color, *gradient_end_color, + *current_gradient_stop, *gradient_stop_color, *gradient_stop_offset; void background_create_new(); void background_force_update();
M src/tint2conf/properties_rw.csrc/tint2conf/properties_rw.c

@@ -34,432 +34,442 @@ static int num_gr;

void config_read_file(const char *path) { - num_bg = 0; - background_create_new(); - gradient_create_new(GRADIENT_CONFIG_VERTICAL); + num_bg = 0; + background_create_new(); + gradient_create_new(GRADIENT_CONFIG_VERTICAL); - config_has_panel_items = 0; - config_has_battery = 0; - config_battery_enabled = 0; - config_has_systray = 0; - config_systray_enabled = 0; - no_items_clock_enabled = 0; - no_items_systray_enabled = 0; - no_items_battery_enabled = 0; + config_has_panel_items = 0; + config_has_battery = 0; + config_battery_enabled = 0; + config_has_systray = 0; + config_systray_enabled = 0; + no_items_clock_enabled = 0; + no_items_systray_enabled = 0; + no_items_battery_enabled = 0; - FILE *fp = fopen(path, "r"); - if (fp) { - char* line = NULL; - size_t line_size = 0; - while (getline(&line, &line_size, fp) >= 0) { - char *key, *value; - if (parse_line(line, &key, &value)) { - add_entry(key, value); - free(key); - free(value); - } - } - free(line); - fclose(fp); - } + FILE *fp = fopen(path, "r"); + if (fp) { + char *line = NULL; + size_t line_size = 0; + while (getline(&line, &line_size, fp) >= 0) { + char *key, *value; + if (parse_line(line, &key, &value)) { + add_entry(key, value); + free(key); + free(value); + } + } + free(line); + fclose(fp); + } - finalize_gradient(); - finalize_bg(); + finalize_gradient(); + finalize_bg(); - if (!config_has_panel_items) { - char panel_items[256]; - panel_items[0] = 0; - strcat(panel_items, "T"); - if (config_has_battery) { - if (config_battery_enabled) - strcat(panel_items, "B"); - } else { - if (no_items_battery_enabled) - strcat(panel_items, "B"); - } - if (config_has_systray) { - if (config_systray_enabled) - strcat(panel_items, "S"); - } else { - if (no_items_systray_enabled) - strcat(panel_items, "S"); - } - if (no_items_clock_enabled) - strcat(panel_items, "C"); - set_panel_items(panel_items); - } + if (!config_has_panel_items) { + char panel_items[256]; + panel_items[0] = 0; + strcat(panel_items, "T"); + if (config_has_battery) { + if (config_battery_enabled) + strcat(panel_items, "B"); + } else { + if (no_items_battery_enabled) + strcat(panel_items, "B"); + } + if (config_has_systray) { + if (config_systray_enabled) + strcat(panel_items, "S"); + } else { + if (no_items_systray_enabled) + strcat(panel_items, "S"); + } + if (no_items_clock_enabled) + strcat(panel_items, "C"); + set_panel_items(panel_items); + } } void config_write_color(FILE *fp, const char *name, GdkColor color, int opacity) { - fprintf(fp, "%s = #%02x%02x%02x %d\n", name, color.red >> 8, color.green >> 8, color.blue >> 8, opacity); + fprintf(fp, "%s = #%02x%02x%02x %d\n", name, color.red >> 8, color.green >> 8, color.blue >> 8, opacity); } void config_write_gradients(FILE *fp) { - fprintf(fp, "#-------------------------------------\n"); - fprintf(fp, "# Gradients\n"); + fprintf(fp, "#-------------------------------------\n"); + fprintf(fp, "# Gradients\n"); - int index = 1; + int index = 1; - for (GList *gl = gradients ? gradients->next : NULL; gl; gl = gl->next, index++) { - GradientConfig *g = (GradientConfig *)gl->data; - GdkColor color; - int opacity; + for (GList *gl = gradients ? gradients->next : NULL; gl; gl = gl->next, index++) { + GradientConfig *g = (GradientConfig *)gl->data; + GdkColor color; + int opacity; - fprintf(fp, "# Gradient %d\n", index); - fprintf(fp, "gradient = %s\n", g->type == GRADIENT_CONFIG_HORIZONTAL ? "horizontal" : g->type == GRADIENT_CONFIG_VERTICAL ? "vertical" : "radial"); + fprintf(fp, "# Gradient %d\n", index); + fprintf(fp, + "gradient = %s\n", + g->type == GRADIENT_CONFIG_HORIZONTAL ? "horizontal" : g->type == GRADIENT_CONFIG_VERTICAL ? "vertical" + : "radial"); - cairoColor2GdkColor(g->start_color.color.rgb[0], g->start_color.color.rgb[1], g->start_color.color.rgb[2], &color); - opacity = g->start_color.color.alpha * 100; - config_write_color(fp, "start_color", color, opacity); + cairoColor2GdkColor(g->start_color.color.rgb[0], + g->start_color.color.rgb[1], + g->start_color.color.rgb[2], + &color); + opacity = g->start_color.color.alpha * 100; + config_write_color(fp, "start_color", color, opacity); - cairoColor2GdkColor(g->end_color.color.rgb[0], g->end_color.color.rgb[1], g->end_color.color.rgb[2], &color); - opacity = g->end_color.color.alpha * 100; - config_write_color(fp, "end_color", color, opacity); + cairoColor2GdkColor(g->end_color.color.rgb[0], g->end_color.color.rgb[1], g->end_color.color.rgb[2], &color); + opacity = g->end_color.color.alpha * 100; + config_write_color(fp, "end_color", color, opacity); - for (GList *l = g->extra_color_stops; l; l = l->next) { - GradientConfigColorStop *stop = (GradientConfigColorStop *)l->data; - // color_stop = percentage #rrggbb opacity - cairoColor2GdkColor(stop->color.rgb[0], stop->color.rgb[1], stop->color.rgb[2], &color); - opacity = stop->color.alpha * 100; - fprintf(fp, "color_stop = %f #%02x%02x%02x %d\n", stop->offset * 100, color.red >> 8, color.green >> 8, color.blue >> 8, opacity); - } - fprintf(fp, "\n"); - } + for (GList *l = g->extra_color_stops; l; l = l->next) { + GradientConfigColorStop *stop = (GradientConfigColorStop *)l->data; + // color_stop = percentage #rrggbb opacity + cairoColor2GdkColor(stop->color.rgb[0], stop->color.rgb[1], stop->color.rgb[2], &color); + opacity = stop->color.alpha * 100; + fprintf(fp, + "color_stop = %f #%02x%02x%02x %d\n", + stop->offset * 100, + color.red >> 8, + color.green >> 8, + color.blue >> 8, + opacity); + } + fprintf(fp, "\n"); + } } void config_write_backgrounds(FILE *fp) { - fprintf(fp, "#-------------------------------------\n"); - fprintf(fp, "# Backgrounds\n"); + fprintf(fp, "#-------------------------------------\n"); + fprintf(fp, "# Backgrounds\n"); - int index; - for (index = 1;; index++) { - GtkTreePath *path; - GtkTreeIter iter; + int index; + for (index = 1;; index++) { + GtkTreePath *path; + GtkTreeIter iter; - path = gtk_tree_path_new_from_indices(index, -1); - gboolean found = gtk_tree_model_get_iter(GTK_TREE_MODEL(backgrounds), &iter, path); - gtk_tree_path_free(path); + path = gtk_tree_path_new_from_indices(index, -1); + gboolean found = gtk_tree_model_get_iter(GTK_TREE_MODEL(backgrounds), &iter, path); + gtk_tree_path_free(path); - if (!found) { - break; - } + if (!found) { + break; + } - int r; - int b; - gboolean sideTop; - gboolean sideBottom; - gboolean sideLeft; - gboolean sideRight; - GdkColor *fillColor; - int fillOpacity; - GdkColor *borderColor; - int borderOpacity; - int gradient_id; - GdkColor *fillColorOver; - int fillOpacityOver; - GdkColor *borderColorOver; - int borderOpacityOver; - int gradient_id_over; - GdkColor *fillColorPress; - int fillOpacityPress; - GdkColor *borderColorPress; - int borderOpacityPress; - int gradient_id_press; - gchar *text; + int r; + int b; + gboolean sideTop; + gboolean sideBottom; + gboolean sideLeft; + gboolean sideRight; + GdkColor *fillColor; + int fillOpacity; + GdkColor *borderColor; + int borderOpacity; + int gradient_id; + GdkColor *fillColorOver; + int fillOpacityOver; + GdkColor *borderColorOver; + int borderOpacityOver; + int gradient_id_over; + GdkColor *fillColorPress; + int fillOpacityPress; + GdkColor *borderColorPress; + int borderOpacityPress; + int gradient_id_press; + gchar *text; - gtk_tree_model_get(GTK_TREE_MODEL(backgrounds), - &iter, - bgColFillColor, - &fillColor, - bgColFillOpacity, - &fillOpacity, - bgColBorderColor, - &borderColor, - bgColBorderOpacity, - &borderOpacity, - bgColGradientId, - &gradient_id, - bgColFillColorOver, - &fillColorOver, - bgColFillOpacityOver, - &fillOpacityOver, - bgColBorderColorOver, - &borderColorOver, - bgColBorderOpacityOver, - &borderOpacityOver, - bgColGradientIdOver, - &gradient_id_over, - bgColFillColorPress, - &fillColorPress, - bgColFillOpacityPress, - &fillOpacityPress, - bgColBorderColorPress, - &borderColorPress, - bgColBorderOpacityPress, - &borderOpacityPress, - bgColGradientIdPress, - &gradient_id_press, - bgColBorderWidth, - &b, - bgColCornerRadius, - &r, - bgColText, - &text, - bgColBorderSidesTop, - &sideTop, - bgColBorderSidesBottom, - &sideBottom, - bgColBorderSidesLeft, - &sideLeft, - bgColBorderSidesRight, - &sideRight, - -1); - fprintf(fp, "# Background %d: %s\n", index, text ? text : ""); - fprintf(fp, "rounded = %d\n", r); - fprintf(fp, "border_width = %d\n", b); + gtk_tree_model_get(GTK_TREE_MODEL(backgrounds), + &iter, + bgColFillColor, + &fillColor, + bgColFillOpacity, + &fillOpacity, + bgColBorderColor, + &borderColor, + bgColBorderOpacity, + &borderOpacity, + bgColGradientId, + &gradient_id, + bgColFillColorOver, + &fillColorOver, + bgColFillOpacityOver, + &fillOpacityOver, + bgColBorderColorOver, + &borderColorOver, + bgColBorderOpacityOver, + &borderOpacityOver, + bgColGradientIdOver, + &gradient_id_over, + bgColFillColorPress, + &fillColorPress, + bgColFillOpacityPress, + &fillOpacityPress, + bgColBorderColorPress, + &borderColorPress, + bgColBorderOpacityPress, + &borderOpacityPress, + bgColGradientIdPress, + &gradient_id_press, + bgColBorderWidth, + &b, + bgColCornerRadius, + &r, + bgColText, + &text, + bgColBorderSidesTop, + &sideTop, + bgColBorderSidesBottom, + &sideBottom, + bgColBorderSidesLeft, + &sideLeft, + bgColBorderSidesRight, + &sideRight, + -1); + fprintf(fp, "# Background %d: %s\n", index, text ? text : ""); + fprintf(fp, "rounded = %d\n", r); + fprintf(fp, "border_width = %d\n", b); - char sides[10]; - sides[0] = '\0'; - if (sideTop) - strcat(sides, "T"); - if (sideBottom) - strcat(sides, "B"); - if (sideLeft) - strcat(sides, "L"); - if (sideRight) - strcat(sides, "R"); - fprintf(fp, "border_sides = %s\n", sides); + char sides[10]; + sides[0] = '\0'; + if (sideTop) + strcat(sides, "T"); + if (sideBottom) + strcat(sides, "B"); + if (sideLeft) + strcat(sides, "L"); + if (sideRight) + strcat(sides, "R"); + fprintf(fp, "border_sides = %s\n", sides); - config_write_color(fp, "background_color", *fillColor, fillOpacity); - config_write_color(fp, "border_color", *borderColor, borderOpacity); - if (gradient_id >= 0) - fprintf(fp, "gradient_id = %d\n", gradient_id); - config_write_color(fp, "background_color_hover", *fillColorOver, fillOpacityOver); - config_write_color(fp, "border_color_hover", *borderColorOver, borderOpacityOver); - if (gradient_id_over >= 0) - fprintf(fp, "gradient_id_hover = %d\n", gradient_id_over); - config_write_color(fp, "background_color_pressed", *fillColorPress, fillOpacityPress); - config_write_color(fp, "border_color_pressed", *borderColorPress, borderOpacityPress); - if (gradient_id_press >= 0) - fprintf(fp, "gradient_id_pressed = %d\n", gradient_id_press); - fprintf(fp, "\n"); - } + config_write_color(fp, "background_color", *fillColor, fillOpacity); + config_write_color(fp, "border_color", *borderColor, borderOpacity); + if (gradient_id >= 0) + fprintf(fp, "gradient_id = %d\n", gradient_id); + config_write_color(fp, "background_color_hover", *fillColorOver, fillOpacityOver); + config_write_color(fp, "border_color_hover", *borderColorOver, borderOpacityOver); + if (gradient_id_over >= 0) + fprintf(fp, "gradient_id_hover = %d\n", gradient_id_over); + config_write_color(fp, "background_color_pressed", *fillColorPress, fillOpacityPress); + config_write_color(fp, "border_color_pressed", *borderColorPress, borderOpacityPress); + if (gradient_id_press >= 0) + fprintf(fp, "gradient_id_pressed = %d\n", gradient_id_press); + fprintf(fp, "\n"); + } } void config_write_panel(FILE *fp) { - fprintf(fp, "#-------------------------------------\n"); - fprintf(fp, "# Panel\n"); - char *items = get_panel_items(); - fprintf(fp, "panel_items = %s\n", items); - free(items); - fprintf(fp, - "panel_size = %d%s %d%s\n", - (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(panel_width)), - gtk_combo_box_get_active(GTK_COMBO_BOX(panel_combo_width_type)) == 0 ? "%" : "", - (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(panel_height)), - gtk_combo_box_get_active(GTK_COMBO_BOX(panel_combo_height_type)) == 0 ? "%" : ""); - fprintf(fp, - "panel_margin = %d %d\n", - (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(panel_margin_x)), - (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(panel_margin_y))); - fprintf(fp, - "panel_padding = %d %d %d\n", - (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(panel_padding_x)), - (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(panel_padding_y)), - (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(panel_spacing))); - fprintf(fp, "panel_background_id = %d\n", gtk_combo_box_get_active(GTK_COMBO_BOX(panel_background))); - fprintf(fp, "wm_menu = %d\n", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(panel_wm_menu)) ? 1 : 0); - fprintf(fp, "panel_dock = %d\n", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(panel_dock)) ? 1 : 0); + fprintf(fp, "#-------------------------------------\n"); + fprintf(fp, "# Panel\n"); + char *items = get_panel_items(); + fprintf(fp, "panel_items = %s\n", items); + free(items); + fprintf(fp, + "panel_size = %d%s %d%s\n", + (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(panel_width)), + gtk_combo_box_get_active(GTK_COMBO_BOX(panel_combo_width_type)) == 0 ? "%" : "", + (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(panel_height)), + gtk_combo_box_get_active(GTK_COMBO_BOX(panel_combo_height_type)) == 0 ? "%" : ""); + fprintf(fp, + "panel_margin = %d %d\n", + (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(panel_margin_x)), + (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(panel_margin_y))); + fprintf(fp, + "panel_padding = %d %d %d\n", + (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(panel_padding_x)), + (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(panel_padding_y)), + (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(panel_spacing))); + fprintf(fp, "panel_background_id = %d\n", gtk_combo_box_get_active(GTK_COMBO_BOX(panel_background))); + fprintf(fp, "wm_menu = %d\n", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(panel_wm_menu)) ? 1 : 0); + fprintf(fp, "panel_dock = %d\n", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(panel_dock)) ? 1 : 0); - fprintf(fp, "panel_position = "); - if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(screen_position[POS_BLH]))) { - fprintf(fp, "bottom left horizontal"); - } else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(screen_position[POS_BCH]))) { - fprintf(fp, "bottom center horizontal"); - } else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(screen_position[POS_BRH]))) { - fprintf(fp, "bottom right horizontal"); - } else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(screen_position[POS_TLH]))) { - fprintf(fp, "top left horizontal"); - } else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(screen_position[POS_TCH]))) { - fprintf(fp, "top center horizontal"); - } else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(screen_position[POS_TRH]))) { - fprintf(fp, "top right horizontal"); - } else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(screen_position[POS_TLV]))) { - fprintf(fp, "top left vertical"); - } else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(screen_position[POS_CLV]))) { - fprintf(fp, "center left vertical"); - } else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(screen_position[POS_BLV]))) { - fprintf(fp, "bottom left vertical"); - } else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(screen_position[POS_TRV]))) { - fprintf(fp, "top right vertical"); - } else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(screen_position[POS_CRV]))) { - fprintf(fp, "center right vertical"); - } else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(screen_position[POS_BRV]))) { - fprintf(fp, "bottom right vertical"); - } - fprintf(fp, "\n"); + fprintf(fp, "panel_position = "); + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(screen_position[POS_BLH]))) { + fprintf(fp, "bottom left horizontal"); + } else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(screen_position[POS_BCH]))) { + fprintf(fp, "bottom center horizontal"); + } else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(screen_position[POS_BRH]))) { + fprintf(fp, "bottom right horizontal"); + } else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(screen_position[POS_TLH]))) { + fprintf(fp, "top left horizontal"); + } else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(screen_position[POS_TCH]))) { + fprintf(fp, "top center horizontal"); + } else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(screen_position[POS_TRH]))) { + fprintf(fp, "top right horizontal"); + } else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(screen_position[POS_TLV]))) { + fprintf(fp, "top left vertical"); + } else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(screen_position[POS_CLV]))) { + fprintf(fp, "center left vertical"); + } else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(screen_position[POS_BLV]))) { + fprintf(fp, "bottom left vertical"); + } else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(screen_position[POS_TRV]))) { + fprintf(fp, "top right vertical"); + } else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(screen_position[POS_CRV]))) { + fprintf(fp, "center right vertical"); + } else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(screen_position[POS_BRV]))) { + fprintf(fp, "bottom right vertical"); + } + fprintf(fp, "\n"); - fprintf(fp, "panel_layer = "); - if (gtk_combo_box_get_active(GTK_COMBO_BOX(panel_combo_layer)) == 0) { - fprintf(fp, "top"); - } else if (gtk_combo_box_get_active(GTK_COMBO_BOX(panel_combo_layer)) == 1) { - fprintf(fp, "normal"); - } else { - fprintf(fp, "bottom"); - } - fprintf(fp, "\n"); + fprintf(fp, "panel_layer = "); + if (gtk_combo_box_get_active(GTK_COMBO_BOX(panel_combo_layer)) == 0) { + fprintf(fp, "top"); + } else if (gtk_combo_box_get_active(GTK_COMBO_BOX(panel_combo_layer)) == 1) { + fprintf(fp, "normal"); + } else { + fprintf(fp, "bottom"); + } + fprintf(fp, "\n"); - fprintf(fp, "panel_monitor = "); - if (gtk_combo_box_get_active(GTK_COMBO_BOX(panel_combo_monitor)) == 0) { - fprintf(fp, "all"); - } else { - fprintf(fp, "%d", gtk_combo_box_get_active(GTK_COMBO_BOX(panel_combo_monitor))); - } - fprintf(fp, "\n"); + fprintf(fp, "panel_monitor = "); + if (gtk_combo_box_get_active(GTK_COMBO_BOX(panel_combo_monitor)) == 0) { + fprintf(fp, "all"); + } else { + fprintf(fp, "%d", gtk_combo_box_get_active(GTK_COMBO_BOX(panel_combo_monitor))); + } + fprintf(fp, "\n"); - fprintf(fp, - "primary_monitor_first = %d\n", - gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(panel_primary_monitor_first)) ? 1 : 0); + fprintf(fp, + "primary_monitor_first = %d\n", + gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(panel_primary_monitor_first)) ? 1 : 0); - fprintf(fp, - "panel_shrink = %d\n", - gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(panel_shrink)) ? 1 : 0); + fprintf(fp, "panel_shrink = %d\n", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(panel_shrink)) ? 1 : 0); - fprintf(fp, "autohide = %d\n", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(panel_autohide)) ? 1 : 0); - fprintf(fp, "autohide_show_timeout = %g\n", gtk_spin_button_get_value(GTK_SPIN_BUTTON(panel_autohide_show_time))); - fprintf(fp, "autohide_hide_timeout = %g\n", gtk_spin_button_get_value(GTK_SPIN_BUTTON(panel_autohide_hide_time))); - fprintf(fp, "autohide_height = %d\n", (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(panel_autohide_size))); + fprintf(fp, "autohide = %d\n", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(panel_autohide)) ? 1 : 0); + fprintf(fp, "autohide_show_timeout = %g\n", gtk_spin_button_get_value(GTK_SPIN_BUTTON(panel_autohide_show_time))); + fprintf(fp, "autohide_hide_timeout = %g\n", gtk_spin_button_get_value(GTK_SPIN_BUTTON(panel_autohide_hide_time))); + fprintf(fp, "autohide_height = %d\n", (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(panel_autohide_size))); - fprintf(fp, "strut_policy = "); - if (gtk_combo_box_get_active(GTK_COMBO_BOX(panel_combo_strut_policy)) == 0) { - fprintf(fp, "follow_size"); - } else if (gtk_combo_box_get_active(GTK_COMBO_BOX(panel_combo_strut_policy)) == 1) { - fprintf(fp, "minimum"); - } else if (gtk_combo_box_get_active(GTK_COMBO_BOX(panel_combo_strut_policy)) == 2) { - fprintf(fp, "none"); - } - fprintf(fp, "\n"); + fprintf(fp, "strut_policy = "); + if (gtk_combo_box_get_active(GTK_COMBO_BOX(panel_combo_strut_policy)) == 0) { + fprintf(fp, "follow_size"); + } else if (gtk_combo_box_get_active(GTK_COMBO_BOX(panel_combo_strut_policy)) == 1) { + fprintf(fp, "minimum"); + } else if (gtk_combo_box_get_active(GTK_COMBO_BOX(panel_combo_strut_policy)) == 2) { + fprintf(fp, "none"); + } + fprintf(fp, "\n"); - fprintf(fp, "panel_window_name = %s\n", gtk_entry_get_text(GTK_ENTRY(panel_window_name))); - fprintf(fp, - "disable_transparency = %d\n", - gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(disable_transparency)) ? 1 : 0); - fprintf(fp, "mouse_effects = %d\n", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(panel_mouse_effects)) ? 1 : 0); - fprintf(fp, "font_shadow = %d\n", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(font_shadow)) ? 1 : 0); - fprintf(fp, - "mouse_hover_icon_asb = %d %d %d\n", - (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(mouse_hover_icon_opacity)), - (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(mouse_hover_icon_saturation)), - (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(mouse_hover_icon_brightness))); - fprintf(fp, - "mouse_pressed_icon_asb = %d %d %d\n", - (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(mouse_pressed_icon_opacity)), - (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(mouse_pressed_icon_saturation)), - (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(mouse_pressed_icon_brightness))); + fprintf(fp, "panel_window_name = %s\n", gtk_entry_get_text(GTK_ENTRY(panel_window_name))); + fprintf(fp, + "disable_transparency = %d\n", + gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(disable_transparency)) ? 1 : 0); + fprintf(fp, "mouse_effects = %d\n", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(panel_mouse_effects)) ? 1 : 0); + fprintf(fp, "font_shadow = %d\n", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(font_shadow)) ? 1 : 0); + fprintf(fp, + "mouse_hover_icon_asb = %d %d %d\n", + (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(mouse_hover_icon_opacity)), + (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(mouse_hover_icon_saturation)), + (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(mouse_hover_icon_brightness))); + fprintf(fp, + "mouse_pressed_icon_asb = %d %d %d\n", + (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(mouse_pressed_icon_opacity)), + (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(mouse_pressed_icon_saturation)), + (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(mouse_pressed_icon_brightness))); - fprintf(fp, "\n"); + fprintf(fp, "\n"); } void config_write_taskbar(FILE *fp) { - fprintf(fp, "#-------------------------------------\n"); - fprintf(fp, "# Taskbar\n"); + fprintf(fp, "#-------------------------------------\n"); + fprintf(fp, "# Taskbar\n"); - fprintf(fp, - "taskbar_mode = %s\n", - gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(taskbar_show_desktop)) ? "multi_desktop" : "single_desktop"); - fprintf(fp, - "taskbar_hide_if_empty = %d\n", - gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(taskbar_hide_empty)) ? 1 : 0); - fprintf(fp, - "taskbar_padding = %d %d %d\n", - (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(taskbar_padding_x)), - (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(taskbar_padding_y)), - (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(taskbar_spacing))); - fprintf(fp, "taskbar_background_id = %d\n", gtk_combo_box_get_active(GTK_COMBO_BOX(taskbar_inactive_background))); - fprintf(fp, - "taskbar_active_background_id = %d\n", - gtk_combo_box_get_active(GTK_COMBO_BOX(taskbar_active_background))); - fprintf(fp, "taskbar_name = %d\n", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(taskbar_show_name)) ? 1 : 0); - fprintf(fp, - "taskbar_hide_inactive_tasks = %d\n", - gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(taskbar_hide_inactive_tasks)) ? 1 : 0); - fprintf(fp, - "taskbar_hide_different_monitor = %d\n", - gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(taskbar_hide_diff_monitor)) ? 1 : 0); - fprintf(fp, - "taskbar_always_show_all_desktop_tasks = %d\n", - gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(taskbar_always_show_all_desktop_tasks)) ? 1 : 0); - fprintf(fp, - "taskbar_name_padding = %d %d\n", - (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(taskbar_name_padding_x)), - (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(taskbar_name_padding_y))); - fprintf(fp, - "taskbar_name_background_id = %d\n", - gtk_combo_box_get_active(GTK_COMBO_BOX(taskbar_name_inactive_background))); - fprintf(fp, - "taskbar_name_active_background_id = %d\n", - gtk_combo_box_get_active(GTK_COMBO_BOX(taskbar_name_active_background))); - if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(taskbar_name_font_set))) - fprintf(fp, "taskbar_name_font = %s\n", gtk_font_button_get_font_name(GTK_FONT_BUTTON(taskbar_name_font))); + fprintf(fp, + "taskbar_mode = %s\n", + gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(taskbar_show_desktop)) ? "multi_desktop" : "single_desktop"); + fprintf(fp, + "taskbar_hide_if_empty = %d\n", + gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(taskbar_hide_empty)) ? 1 : 0); + fprintf(fp, + "taskbar_padding = %d %d %d\n", + (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(taskbar_padding_x)), + (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(taskbar_padding_y)), + (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(taskbar_spacing))); + fprintf(fp, "taskbar_background_id = %d\n", gtk_combo_box_get_active(GTK_COMBO_BOX(taskbar_inactive_background))); + fprintf(fp, + "taskbar_active_background_id = %d\n", + gtk_combo_box_get_active(GTK_COMBO_BOX(taskbar_active_background))); + fprintf(fp, "taskbar_name = %d\n", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(taskbar_show_name)) ? 1 : 0); + fprintf(fp, + "taskbar_hide_inactive_tasks = %d\n", + gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(taskbar_hide_inactive_tasks)) ? 1 : 0); + fprintf(fp, + "taskbar_hide_different_monitor = %d\n", + gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(taskbar_hide_diff_monitor)) ? 1 : 0); + fprintf(fp, + "taskbar_always_show_all_desktop_tasks = %d\n", + gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(taskbar_always_show_all_desktop_tasks)) ? 1 : 0); + fprintf(fp, + "taskbar_name_padding = %d %d\n", + (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(taskbar_name_padding_x)), + (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(taskbar_name_padding_y))); + fprintf(fp, + "taskbar_name_background_id = %d\n", + gtk_combo_box_get_active(GTK_COMBO_BOX(taskbar_name_inactive_background))); + fprintf(fp, + "taskbar_name_active_background_id = %d\n", + gtk_combo_box_get_active(GTK_COMBO_BOX(taskbar_name_active_background))); + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(taskbar_name_font_set))) + fprintf(fp, "taskbar_name_font = %s\n", gtk_font_button_get_font_name(GTK_FONT_BUTTON(taskbar_name_font))); - GdkColor color; - gtk_color_button_get_color(GTK_COLOR_BUTTON(taskbar_name_inactive_color), &color); - config_write_color(fp, - "taskbar_name_font_color", - color, - gtk_color_button_get_alpha(GTK_COLOR_BUTTON(taskbar_name_inactive_color)) * 100 / 0xffff); + GdkColor color; + gtk_color_button_get_color(GTK_COLOR_BUTTON(taskbar_name_inactive_color), &color); + config_write_color(fp, + "taskbar_name_font_color", + color, + gtk_color_button_get_alpha(GTK_COLOR_BUTTON(taskbar_name_inactive_color)) * 100 / 0xffff); - gtk_color_button_get_color(GTK_COLOR_BUTTON(taskbar_name_active_color), &color); - config_write_color(fp, - "taskbar_name_active_font_color", - color, - gtk_color_button_get_alpha(GTK_COLOR_BUTTON(taskbar_name_active_color)) * 100 / 0xffff); + gtk_color_button_get_color(GTK_COLOR_BUTTON(taskbar_name_active_color), &color); + config_write_color(fp, + "taskbar_name_active_font_color", + color, + gtk_color_button_get_alpha(GTK_COLOR_BUTTON(taskbar_name_active_color)) * 100 / 0xffff); - fprintf(fp, - "taskbar_distribute_size = %d\n", - gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(taskbar_distribute_size)) ? 1 : 0); + fprintf(fp, + "taskbar_distribute_size = %d\n", + gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(taskbar_distribute_size)) ? 1 : 0); - fprintf(fp, "taskbar_sort_order = "); - if (gtk_combo_box_get_active(GTK_COMBO_BOX(taskbar_sort_order)) <= 0) { - fprintf(fp, "none"); - } else if (gtk_combo_box_get_active(GTK_COMBO_BOX(taskbar_sort_order)) == 1) { - fprintf(fp, "title"); - } else if (gtk_combo_box_get_active(GTK_COMBO_BOX(taskbar_sort_order)) == 2) { - fprintf(fp, "center"); - } else if (gtk_combo_box_get_active(GTK_COMBO_BOX(taskbar_sort_order)) == 3) { - fprintf(fp, "mru"); - } else if (gtk_combo_box_get_active(GTK_COMBO_BOX(taskbar_sort_order)) == 4) { - fprintf(fp, "lru"); - } else { - fprintf(fp, "none"); - } - fprintf(fp, "\n"); + fprintf(fp, "taskbar_sort_order = "); + if (gtk_combo_box_get_active(GTK_COMBO_BOX(taskbar_sort_order)) <= 0) { + fprintf(fp, "none"); + } else if (gtk_combo_box_get_active(GTK_COMBO_BOX(taskbar_sort_order)) == 1) { + fprintf(fp, "title"); + } else if (gtk_combo_box_get_active(GTK_COMBO_BOX(taskbar_sort_order)) == 2) { + fprintf(fp, "center"); + } else if (gtk_combo_box_get_active(GTK_COMBO_BOX(taskbar_sort_order)) == 3) { + fprintf(fp, "mru"); + } else if (gtk_combo_box_get_active(GTK_COMBO_BOX(taskbar_sort_order)) == 4) { + fprintf(fp, "lru"); + } else { + fprintf(fp, "none"); + } + fprintf(fp, "\n"); - fprintf(fp, "task_align = "); - if (gtk_combo_box_get_active(GTK_COMBO_BOX(taskbar_alignment)) <= 0) { - fprintf(fp, "left"); - } else if (gtk_combo_box_get_active(GTK_COMBO_BOX(taskbar_alignment)) == 1) { - fprintf(fp, "center"); - } else { - fprintf(fp, "right"); - } - fprintf(fp, "\n"); + fprintf(fp, "task_align = "); + if (gtk_combo_box_get_active(GTK_COMBO_BOX(taskbar_alignment)) <= 0) { + fprintf(fp, "left"); + } else if (gtk_combo_box_get_active(GTK_COMBO_BOX(taskbar_alignment)) == 1) { + fprintf(fp, "center"); + } else { + fprintf(fp, "right"); + } + fprintf(fp, "\n"); - fprintf(fp, "\n"); + fprintf(fp, "\n"); } void config_write_task_font_color(FILE *fp, char *name, GtkWidget *task_color) { - GdkColor color; - gtk_color_button_get_color(GTK_COLOR_BUTTON(task_color), &color); - char full_name[128]; - sprintf(full_name, "task%s_font_color", name); - config_write_color(fp, full_name, color, gtk_color_button_get_alpha(GTK_COLOR_BUTTON(task_color)) * 100 / 0xffff); + GdkColor color; + gtk_color_button_get_color(GTK_COLOR_BUTTON(task_color), &color); + char full_name[128]; + sprintf(full_name, "task%s_font_color", name); + config_write_color(fp, full_name, color, gtk_color_button_get_alpha(GTK_COLOR_BUTTON(task_color)) * 100 / 0xffff); } void config_write_task_icon_osb(FILE *fp,

@@ -468,1587 +478,1586 @@ GtkWidget *widget_opacity,

GtkWidget *widget_saturation, GtkWidget *widget_brightness) { - char full_name[128]; - sprintf(full_name, "task%s_icon_asb", name); - fprintf(fp, - "%s = %d %d %d\n", - full_name, - (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(widget_opacity)), - (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(widget_saturation)), - (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(widget_brightness))); + char full_name[128]; + sprintf(full_name, "task%s_icon_asb", name); + fprintf(fp, + "%s = %d %d %d\n", + full_name, + (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(widget_opacity)), + (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(widget_saturation)), + (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(widget_brightness))); } void config_write_task_background(FILE *fp, char *name, GtkWidget *task_background) { - char full_name[128]; - sprintf(full_name, "task%s_background_id", name); - fprintf(fp, "%s = %d\n", full_name, gtk_combo_box_get_active(GTK_COMBO_BOX(task_background))); + char full_name[128]; + sprintf(full_name, "task%s_background_id", name); + fprintf(fp, "%s = %d\n", full_name, gtk_combo_box_get_active(GTK_COMBO_BOX(task_background))); } void config_write_task(FILE *fp) { - fprintf(fp, "#-------------------------------------\n"); - fprintf(fp, "# Task\n"); + fprintf(fp, "#-------------------------------------\n"); + fprintf(fp, "# Task\n"); - fprintf(fp, "task_text = %d\n", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(task_show_text)) ? 1 : 0); - fprintf(fp, "task_icon = %d\n", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(task_show_icon)) ? 1 : 0); - fprintf(fp, "task_centered = %d\n", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(task_align_center)) ? 1 : 0); - fprintf(fp, "urgent_nb_of_blink = %d\n", (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(task_urgent_blinks))); - fprintf(fp, - "task_maximum_size = %d %d\n", - (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(task_maximum_width)), - (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(task_maximum_height))); - fprintf(fp, - "task_padding = %d %d %d\n", - (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(task_padding_x)), - (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(task_padding_y)), - (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(task_spacing))); - if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(task_font_set))) - fprintf(fp, "task_font = %s\n", gtk_font_button_get_font_name(GTK_FONT_BUTTON(task_font))); - fprintf(fp, "task_tooltip = %d\n", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(tooltip_task_show)) ? 1 : 0); + fprintf(fp, "task_text = %d\n", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(task_show_text)) ? 1 : 0); + fprintf(fp, "task_icon = %d\n", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(task_show_icon)) ? 1 : 0); + fprintf(fp, "task_centered = %d\n", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(task_align_center)) ? 1 : 0); + fprintf(fp, "urgent_nb_of_blink = %d\n", (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(task_urgent_blinks))); + fprintf(fp, + "task_maximum_size = %d %d\n", + (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(task_maximum_width)), + (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(task_maximum_height))); + fprintf(fp, + "task_padding = %d %d %d\n", + (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(task_padding_x)), + (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(task_padding_y)), + (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(task_spacing))); + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(task_font_set))) + fprintf(fp, "task_font = %s\n", gtk_font_button_get_font_name(GTK_FONT_BUTTON(task_font))); + fprintf(fp, "task_tooltip = %d\n", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(tooltip_task_show)) ? 1 : 0); - // same for: "" _normal _active _urgent _iconified - if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(task_default_color_set))) { - config_write_task_font_color(fp, "", task_default_color); - } - if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(task_normal_color_set))) { - config_write_task_font_color(fp, "_normal", task_normal_color); - } - if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(task_active_color_set))) { - config_write_task_font_color(fp, "_active", task_active_color); - } - if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(task_urgent_color_set))) { - config_write_task_font_color(fp, "_urgent", task_urgent_color); - } - if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(task_iconified_color_set))) { - config_write_task_font_color(fp, "_iconified", task_iconified_color); - } + // same for: "" _normal _active _urgent _iconified + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(task_default_color_set))) { + config_write_task_font_color(fp, "", task_default_color); + } + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(task_normal_color_set))) { + config_write_task_font_color(fp, "_normal", task_normal_color); + } + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(task_active_color_set))) { + config_write_task_font_color(fp, "_active", task_active_color); + } + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(task_urgent_color_set))) { + config_write_task_font_color(fp, "_urgent", task_urgent_color); + } + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(task_iconified_color_set))) { + config_write_task_font_color(fp, "_iconified", task_iconified_color); + } - // same for: "" _normal _active _urgent _iconified - if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(task_default_icon_osb_set))) { - config_write_task_icon_osb(fp, - "", - task_default_icon_opacity, - task_default_icon_saturation, - task_default_icon_brightness); - } - if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(task_normal_icon_osb_set))) { - config_write_task_icon_osb(fp, - "_normal", - task_normal_icon_opacity, - task_normal_icon_saturation, - task_normal_icon_brightness); - } - if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(task_active_icon_osb_set))) { - config_write_task_icon_osb(fp, - "_active", - task_active_icon_opacity, - task_active_icon_saturation, - task_active_icon_brightness); - } - if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(task_urgent_icon_osb_set))) { - config_write_task_icon_osb(fp, - "_urgent", - task_urgent_icon_opacity, - task_urgent_icon_saturation, - task_urgent_icon_brightness); - } - if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(task_iconified_icon_osb_set))) { - config_write_task_icon_osb(fp, - "_iconified", - task_iconified_icon_opacity, - task_iconified_icon_saturation, - task_iconified_icon_brightness); - } + // same for: "" _normal _active _urgent _iconified + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(task_default_icon_osb_set))) { + config_write_task_icon_osb(fp, + "", + task_default_icon_opacity, + task_default_icon_saturation, + task_default_icon_brightness); + } + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(task_normal_icon_osb_set))) { + config_write_task_icon_osb(fp, + "_normal", + task_normal_icon_opacity, + task_normal_icon_saturation, + task_normal_icon_brightness); + } + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(task_active_icon_osb_set))) { + config_write_task_icon_osb(fp, + "_active", + task_active_icon_opacity, + task_active_icon_saturation, + task_active_icon_brightness); + } + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(task_urgent_icon_osb_set))) { + config_write_task_icon_osb(fp, + "_urgent", + task_urgent_icon_opacity, + task_urgent_icon_saturation, + task_urgent_icon_brightness); + } + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(task_iconified_icon_osb_set))) { + config_write_task_icon_osb(fp, + "_iconified", + task_iconified_icon_opacity, + task_iconified_icon_saturation, + task_iconified_icon_brightness); + } - // same for: "" _normal _active _urgent _iconified - if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(task_default_background_set))) { - config_write_task_background(fp, "", task_default_background); - } - if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(task_normal_background_set))) { - config_write_task_background(fp, "_normal", task_normal_background); - } - if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(task_active_background_set))) { - config_write_task_background(fp, "_active", task_active_background); - } - if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(task_urgent_background_set))) { - config_write_task_background(fp, "_urgent", task_urgent_background); - } - if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(task_iconified_background_set))) { - config_write_task_background(fp, "_iconified", task_iconified_background); - } + // same for: "" _normal _active _urgent _iconified + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(task_default_background_set))) { + config_write_task_background(fp, "", task_default_background); + } + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(task_normal_background_set))) { + config_write_task_background(fp, "_normal", task_normal_background); + } + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(task_active_background_set))) { + config_write_task_background(fp, "_active", task_active_background); + } + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(task_urgent_background_set))) { + config_write_task_background(fp, "_urgent", task_urgent_background); + } + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(task_iconified_background_set))) { + config_write_task_background(fp, "_iconified", task_iconified_background); + } - fprintf(fp, "mouse_left = %s\n", get_action(task_mouse_left)); - fprintf(fp, "mouse_middle = %s\n", get_action(task_mouse_middle)); - fprintf(fp, "mouse_right = %s\n", get_action(task_mouse_right)); - fprintf(fp, "mouse_scroll_up = %s\n", get_action(task_mouse_scroll_up)); - fprintf(fp, "mouse_scroll_down = %s\n", get_action(task_mouse_scroll_down)); + fprintf(fp, "mouse_left = %s\n", get_action(task_mouse_left)); + fprintf(fp, "mouse_middle = %s\n", get_action(task_mouse_middle)); + fprintf(fp, "mouse_right = %s\n", get_action(task_mouse_right)); + fprintf(fp, "mouse_scroll_up = %s\n", get_action(task_mouse_scroll_up)); + fprintf(fp, "mouse_scroll_down = %s\n", get_action(task_mouse_scroll_down)); - fprintf(fp, "\n"); + fprintf(fp, "\n"); } void config_write_systray(FILE *fp) { - fprintf(fp, "#-------------------------------------\n"); - fprintf(fp, "# System tray (notification area)\n"); + fprintf(fp, "#-------------------------------------\n"); + fprintf(fp, "# System tray (notification area)\n"); - fprintf(fp, - "systray_padding = %d %d %d\n", - (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(systray_padding_x)), - (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(systray_padding_y)), - (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(systray_spacing))); - fprintf(fp, "systray_background_id = %d\n", gtk_combo_box_get_active(GTK_COMBO_BOX(systray_background))); + fprintf(fp, + "systray_padding = %d %d %d\n", + (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(systray_padding_x)), + (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(systray_padding_y)), + (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(systray_spacing))); + fprintf(fp, "systray_background_id = %d\n", gtk_combo_box_get_active(GTK_COMBO_BOX(systray_background))); - fprintf(fp, "systray_sort = "); - if (gtk_combo_box_get_active(GTK_COMBO_BOX(systray_icon_order)) == 0) { - fprintf(fp, "ascending"); - } else if (gtk_combo_box_get_active(GTK_COMBO_BOX(systray_icon_order)) == 1) { - fprintf(fp, "descending"); - } else if (gtk_combo_box_get_active(GTK_COMBO_BOX(systray_icon_order)) == 2) { - fprintf(fp, "left2right"); - } else if (gtk_combo_box_get_active(GTK_COMBO_BOX(systray_icon_order)) == 3) { - fprintf(fp, "right2left"); - } - fprintf(fp, "\n"); + fprintf(fp, "systray_sort = "); + if (gtk_combo_box_get_active(GTK_COMBO_BOX(systray_icon_order)) == 0) { + fprintf(fp, "ascending"); + } else if (gtk_combo_box_get_active(GTK_COMBO_BOX(systray_icon_order)) == 1) { + fprintf(fp, "descending"); + } else if (gtk_combo_box_get_active(GTK_COMBO_BOX(systray_icon_order)) == 2) { + fprintf(fp, "left2right"); + } else if (gtk_combo_box_get_active(GTK_COMBO_BOX(systray_icon_order)) == 3) { + fprintf(fp, "right2left"); + } + fprintf(fp, "\n"); - fprintf(fp, "systray_icon_size = %d\n", (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(systray_icon_size))); - fprintf(fp, - "systray_icon_asb = %d %d %d\n", - (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(systray_icon_opacity)), - (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(systray_icon_saturation)), - (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(systray_icon_brightness))); + fprintf(fp, "systray_icon_size = %d\n", (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(systray_icon_size))); + fprintf(fp, + "systray_icon_asb = %d %d %d\n", + (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(systray_icon_opacity)), + (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(systray_icon_saturation)), + (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(systray_icon_brightness))); - fprintf(fp, "systray_monitor = "); - fprintf(fp, "%d", MAX(1, 1 + gtk_combo_box_get_active(GTK_COMBO_BOX(systray_monitor)))); - fprintf(fp, "\n"); + fprintf(fp, "systray_monitor = "); + fprintf(fp, "%d", MAX(1, 1 + gtk_combo_box_get_active(GTK_COMBO_BOX(systray_monitor)))); + fprintf(fp, "\n"); - fprintf(fp, "systray_name_filter = %s\n", gtk_entry_get_text(GTK_ENTRY(systray_name_filter))); + fprintf(fp, "systray_name_filter = %s\n", gtk_entry_get_text(GTK_ENTRY(systray_name_filter))); - fprintf(fp, "\n"); + fprintf(fp, "\n"); } void config_write_launcher(FILE *fp) { - fprintf(fp, "#-------------------------------------\n"); - fprintf(fp, "# Launcher\n"); + fprintf(fp, "#-------------------------------------\n"); + fprintf(fp, "# Launcher\n"); - fprintf(fp, - "launcher_padding = %d %d %d\n", - (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(launcher_padding_x)), - (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(launcher_padding_y)), - (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(launcher_spacing))); - fprintf(fp, "launcher_background_id = %d\n", gtk_combo_box_get_active(GTK_COMBO_BOX(launcher_background))); - fprintf(fp, - "launcher_icon_background_id = %d\n", - gtk_combo_box_get_active(GTK_COMBO_BOX(launcher_icon_background))); - fprintf(fp, "launcher_icon_size = %d\n", (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(launcher_icon_size))); - fprintf(fp, - "launcher_icon_asb = %d %d %d\n", - (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(launcher_icon_opacity)), - (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(launcher_icon_saturation)), - (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(launcher_icon_brightness))); - gchar *icon_theme = get_current_icon_theme(); - if (icon_theme && !g_str_equal(icon_theme, "")) { - fprintf(fp, "launcher_icon_theme = %s\n", icon_theme); - g_free(icon_theme); - icon_theme = NULL; - } - fprintf(fp, - "launcher_icon_theme_override = %d\n", - gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(launcher_icon_theme_override)) ? 1 : 0); - fprintf(fp, - "startup_notifications = %d\n", - gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(startup_notifications)) ? 1 : 0); - fprintf(fp, "launcher_tooltip = %d\n", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(launcher_tooltip)) ? 1 : 0); + fprintf(fp, + "launcher_padding = %d %d %d\n", + (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(launcher_padding_x)), + (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(launcher_padding_y)), + (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(launcher_spacing))); + fprintf(fp, "launcher_background_id = %d\n", gtk_combo_box_get_active(GTK_COMBO_BOX(launcher_background))); + fprintf(fp, + "launcher_icon_background_id = %d\n", + gtk_combo_box_get_active(GTK_COMBO_BOX(launcher_icon_background))); + fprintf(fp, "launcher_icon_size = %d\n", (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(launcher_icon_size))); + fprintf(fp, + "launcher_icon_asb = %d %d %d\n", + (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(launcher_icon_opacity)), + (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(launcher_icon_saturation)), + (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(launcher_icon_brightness))); + gchar *icon_theme = get_current_icon_theme(); + if (icon_theme && !g_str_equal(icon_theme, "")) { + fprintf(fp, "launcher_icon_theme = %s\n", icon_theme); + g_free(icon_theme); + icon_theme = NULL; + } + fprintf(fp, + "launcher_icon_theme_override = %d\n", + gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(launcher_icon_theme_override)) ? 1 : 0); + fprintf(fp, + "startup_notifications = %d\n", + gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(startup_notifications)) ? 1 : 0); + fprintf(fp, "launcher_tooltip = %d\n", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(launcher_tooltip)) ? 1 : 0); - int index; - for (index = 0;; index++) { - GtkTreePath *path; - GtkTreeIter iter; + int index; + for (index = 0;; index++) { + GtkTreePath *path; + GtkTreeIter iter; - path = gtk_tree_path_new_from_indices(index, -1); - gboolean found = gtk_tree_model_get_iter(GTK_TREE_MODEL(launcher_apps), &iter, path); - gtk_tree_path_free(path); + path = gtk_tree_path_new_from_indices(index, -1); + gboolean found = gtk_tree_model_get_iter(GTK_TREE_MODEL(launcher_apps), &iter, path); + gtk_tree_path_free(path); - if (!found) { - break; - } + if (!found) { + break; + } - gchar *app_path; - gtk_tree_model_get(GTK_TREE_MODEL(launcher_apps), &iter, appsColPath, &app_path, -1); - char *contracted = contract_tilde(app_path); - fprintf(fp, "launcher_item_app = %s\n", contracted); - free(contracted); - g_free(app_path); - } + gchar *app_path; + gtk_tree_model_get(GTK_TREE_MODEL(launcher_apps), &iter, appsColPath, &app_path, -1); + char *contracted = contract_tilde(app_path); + fprintf(fp, "launcher_item_app = %s\n", contracted); + free(contracted); + g_free(app_path); + } - gchar **app_dirs = g_strsplit(gtk_entry_get_text(GTK_ENTRY(launcher_apps_dirs)), ",", 0); - for (index = 0; app_dirs[index]; index++) { - gchar *dir = app_dirs[index]; - g_strstrip(dir); - if (strlen(dir) > 0) { - char *contracted = contract_tilde(dir); - fprintf(fp, "launcher_apps_dir = %s\n", contracted); - free(contracted); - } - } - g_strfreev(app_dirs); + gchar **app_dirs = g_strsplit(gtk_entry_get_text(GTK_ENTRY(launcher_apps_dirs)), ",", 0); + for (index = 0; app_dirs[index]; index++) { + gchar *dir = app_dirs[index]; + g_strstrip(dir); + if (strlen(dir) > 0) { + char *contracted = contract_tilde(dir); + fprintf(fp, "launcher_apps_dir = %s\n", contracted); + free(contracted); + } + } + g_strfreev(app_dirs); - fprintf(fp, "\n"); + fprintf(fp, "\n"); } void config_write_clock(FILE *fp) { - fprintf(fp, "#-------------------------------------\n"); - fprintf(fp, "# Clock\n"); + fprintf(fp, "#-------------------------------------\n"); + fprintf(fp, "# Clock\n"); - fprintf(fp, "time1_format = %s\n", gtk_entry_get_text(GTK_ENTRY(clock_format_line1))); - fprintf(fp, "time2_format = %s\n", gtk_entry_get_text(GTK_ENTRY(clock_format_line2))); - if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(clock_font_line1_set))) - fprintf(fp, "time1_font = %s\n", gtk_font_button_get_font_name(GTK_FONT_BUTTON(clock_font_line1))); - fprintf(fp, "time1_timezone = %s\n", gtk_entry_get_text(GTK_ENTRY(clock_tmz_line1))); - fprintf(fp, "time2_timezone = %s\n", gtk_entry_get_text(GTK_ENTRY(clock_tmz_line2))); - if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(clock_font_line2_set))) - fprintf(fp, "time2_font = %s\n", gtk_font_button_get_font_name(GTK_FONT_BUTTON(clock_font_line2))); + fprintf(fp, "time1_format = %s\n", gtk_entry_get_text(GTK_ENTRY(clock_format_line1))); + fprintf(fp, "time2_format = %s\n", gtk_entry_get_text(GTK_ENTRY(clock_format_line2))); + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(clock_font_line1_set))) + fprintf(fp, "time1_font = %s\n", gtk_font_button_get_font_name(GTK_FONT_BUTTON(clock_font_line1))); + fprintf(fp, "time1_timezone = %s\n", gtk_entry_get_text(GTK_ENTRY(clock_tmz_line1))); + fprintf(fp, "time2_timezone = %s\n", gtk_entry_get_text(GTK_ENTRY(clock_tmz_line2))); + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(clock_font_line2_set))) + fprintf(fp, "time2_font = %s\n", gtk_font_button_get_font_name(GTK_FONT_BUTTON(clock_font_line2))); - GdkColor color; - gtk_color_button_get_color(GTK_COLOR_BUTTON(clock_font_color), &color); - config_write_color(fp, - "clock_font_color", - color, - gtk_color_button_get_alpha(GTK_COLOR_BUTTON(clock_font_color)) * 100 / 0xffff); + GdkColor color; + gtk_color_button_get_color(GTK_COLOR_BUTTON(clock_font_color), &color); + config_write_color(fp, + "clock_font_color", + color, + gtk_color_button_get_alpha(GTK_COLOR_BUTTON(clock_font_color)) * 100 / 0xffff); - fprintf(fp, - "clock_padding = %d %d\n", - (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(clock_padding_x)), - (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(clock_padding_y))); - fprintf(fp, "clock_background_id = %d\n", gtk_combo_box_get_active(GTK_COMBO_BOX(clock_background))); - fprintf(fp, "clock_tooltip = %s\n", gtk_entry_get_text(GTK_ENTRY(clock_format_tooltip))); - fprintf(fp, "clock_tooltip_timezone = %s\n", gtk_entry_get_text(GTK_ENTRY(clock_tmz_tooltip))); - fprintf(fp, "clock_lclick_command = %s\n", gtk_entry_get_text(GTK_ENTRY(clock_left_command))); - fprintf(fp, "clock_rclick_command = %s\n", gtk_entry_get_text(GTK_ENTRY(clock_right_command))); - fprintf(fp, "clock_mclick_command = %s\n", gtk_entry_get_text(GTK_ENTRY(clock_mclick_command))); - fprintf(fp, "clock_uwheel_command = %s\n", gtk_entry_get_text(GTK_ENTRY(clock_uwheel_command))); - fprintf(fp, "clock_dwheel_command = %s\n", gtk_entry_get_text(GTK_ENTRY(clock_dwheel_command))); + fprintf(fp, + "clock_padding = %d %d\n", + (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(clock_padding_x)), + (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(clock_padding_y))); + fprintf(fp, "clock_background_id = %d\n", gtk_combo_box_get_active(GTK_COMBO_BOX(clock_background))); + fprintf(fp, "clock_tooltip = %s\n", gtk_entry_get_text(GTK_ENTRY(clock_format_tooltip))); + fprintf(fp, "clock_tooltip_timezone = %s\n", gtk_entry_get_text(GTK_ENTRY(clock_tmz_tooltip))); + fprintf(fp, "clock_lclick_command = %s\n", gtk_entry_get_text(GTK_ENTRY(clock_left_command))); + fprintf(fp, "clock_rclick_command = %s\n", gtk_entry_get_text(GTK_ENTRY(clock_right_command))); + fprintf(fp, "clock_mclick_command = %s\n", gtk_entry_get_text(GTK_ENTRY(clock_mclick_command))); + fprintf(fp, "clock_uwheel_command = %s\n", gtk_entry_get_text(GTK_ENTRY(clock_uwheel_command))); + fprintf(fp, "clock_dwheel_command = %s\n", gtk_entry_get_text(GTK_ENTRY(clock_dwheel_command))); - fprintf(fp, "\n"); + fprintf(fp, "\n"); } void config_write_battery(FILE *fp) { - fprintf(fp, "#-------------------------------------\n"); - fprintf(fp, "# Battery\n"); + fprintf(fp, "#-------------------------------------\n"); + fprintf(fp, "# Battery\n"); - fprintf(fp, "battery_tooltip = %d\n", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(battery_tooltip)) ? 1 : 0); - fprintf(fp, "battery_low_status = %g\n", gtk_spin_button_get_value(GTK_SPIN_BUTTON(battery_alert_if_lower))); - fprintf(fp, "battery_low_cmd = %s\n", gtk_entry_get_text(GTK_ENTRY(battery_alert_cmd))); - if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(battery_font_line1_set))) - fprintf(fp, "bat1_font = %s\n", gtk_font_button_get_font_name(GTK_FONT_BUTTON(battery_font_line1))); - if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(battery_font_line2_set))) - fprintf(fp, "bat2_font = %s\n", gtk_font_button_get_font_name(GTK_FONT_BUTTON(battery_font_line2))); - GdkColor color; - gtk_color_button_get_color(GTK_COLOR_BUTTON(battery_font_color), &color); - config_write_color(fp, - "battery_font_color", - color, - gtk_color_button_get_alpha(GTK_COLOR_BUTTON(battery_font_color)) * 100 / 0xffff); - fprintf(fp, - "battery_padding = %d %d\n", - (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(battery_padding_x)), - (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(battery_padding_y))); - fprintf(fp, "battery_background_id = %d\n", gtk_combo_box_get_active(GTK_COMBO_BOX(battery_background))); - fprintf(fp, "battery_hide = %d\n", (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(battery_hide_if_higher))); - fprintf(fp, "battery_lclick_command = %s\n", gtk_entry_get_text(GTK_ENTRY(battery_left_command))); - fprintf(fp, "battery_rclick_command = %s\n", gtk_entry_get_text(GTK_ENTRY(battery_right_command))); - fprintf(fp, "battery_mclick_command = %s\n", gtk_entry_get_text(GTK_ENTRY(battery_mclick_command))); - fprintf(fp, "battery_uwheel_command = %s\n", gtk_entry_get_text(GTK_ENTRY(battery_uwheel_command))); - fprintf(fp, "battery_dwheel_command = %s\n", gtk_entry_get_text(GTK_ENTRY(battery_dwheel_command))); + fprintf(fp, "battery_tooltip = %d\n", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(battery_tooltip)) ? 1 : 0); + fprintf(fp, "battery_low_status = %g\n", gtk_spin_button_get_value(GTK_SPIN_BUTTON(battery_alert_if_lower))); + fprintf(fp, "battery_low_cmd = %s\n", gtk_entry_get_text(GTK_ENTRY(battery_alert_cmd))); + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(battery_font_line1_set))) + fprintf(fp, "bat1_font = %s\n", gtk_font_button_get_font_name(GTK_FONT_BUTTON(battery_font_line1))); + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(battery_font_line2_set))) + fprintf(fp, "bat2_font = %s\n", gtk_font_button_get_font_name(GTK_FONT_BUTTON(battery_font_line2))); + GdkColor color; + gtk_color_button_get_color(GTK_COLOR_BUTTON(battery_font_color), &color); + config_write_color(fp, + "battery_font_color", + color, + gtk_color_button_get_alpha(GTK_COLOR_BUTTON(battery_font_color)) * 100 / 0xffff); + fprintf(fp, + "battery_padding = %d %d\n", + (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(battery_padding_x)), + (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(battery_padding_y))); + fprintf(fp, "battery_background_id = %d\n", gtk_combo_box_get_active(GTK_COMBO_BOX(battery_background))); + fprintf(fp, "battery_hide = %d\n", (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(battery_hide_if_higher))); + fprintf(fp, "battery_lclick_command = %s\n", gtk_entry_get_text(GTK_ENTRY(battery_left_command))); + fprintf(fp, "battery_rclick_command = %s\n", gtk_entry_get_text(GTK_ENTRY(battery_right_command))); + fprintf(fp, "battery_mclick_command = %s\n", gtk_entry_get_text(GTK_ENTRY(battery_mclick_command))); + fprintf(fp, "battery_uwheel_command = %s\n", gtk_entry_get_text(GTK_ENTRY(battery_uwheel_command))); + fprintf(fp, "battery_dwheel_command = %s\n", gtk_entry_get_text(GTK_ENTRY(battery_dwheel_command))); - fprintf(fp, "ac_connected_cmd = %s\n", gtk_entry_get_text(GTK_ENTRY(ac_connected_cmd))); - fprintf(fp, "ac_disconnected_cmd = %s\n", gtk_entry_get_text(GTK_ENTRY(ac_disconnected_cmd))); + fprintf(fp, "ac_connected_cmd = %s\n", gtk_entry_get_text(GTK_ENTRY(ac_connected_cmd))); + fprintf(fp, "ac_disconnected_cmd = %s\n", gtk_entry_get_text(GTK_ENTRY(ac_disconnected_cmd))); - fprintf(fp, "\n"); + fprintf(fp, "\n"); } void config_write_separator(FILE *fp) { - for (int i = 0; i < separators->len; i++) { - fprintf(fp, "#-------------------------------------\n"); - fprintf(fp, "# Separator %d\n", i + 1); + for (int i = 0; i < separators->len; i++) { + fprintf(fp, "#-------------------------------------\n"); + fprintf(fp, "# Separator %d\n", i + 1); - Separator *separator = &g_array_index(separators, Separator, i); + Separator *separator = &g_array_index(separators, Separator, i); - fprintf(fp, "separator = new\n"); - fprintf(fp, - "separator_background_id = %d\n", - gtk_combo_box_get_active(GTK_COMBO_BOX(separator->separator_background))); - GdkColor color; - gtk_color_button_get_color(GTK_COLOR_BUTTON(separator->separator_color), &color); - config_write_color(fp, - "separator_color", - color, - gtk_color_button_get_alpha(GTK_COLOR_BUTTON(separator->separator_color)) * 100 / 0xffff); - // fprintf(fp, "separator_style = %d\n", - // (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(separator->separator_style))); - fprintf(fp, - "separator_style = %s\n", - gtk_combo_box_get_active(GTK_COMBO_BOX(separator->separator_style)) == 0 - ? "empty" - : gtk_combo_box_get_active(GTK_COMBO_BOX(separator->separator_style)) == 1 ? "line" : "dots"); - fprintf(fp, - "separator_size = %d\n", - (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(separator->separator_size))); - fprintf(fp, - "separator_padding = %d %d\n", - (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(separator->separator_padding_x)), - (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(separator->separator_padding_y))); - fprintf(fp, "\n"); - } + fprintf(fp, "separator = new\n"); + fprintf(fp, + "separator_background_id = %d\n", + gtk_combo_box_get_active(GTK_COMBO_BOX(separator->separator_background))); + GdkColor color; + gtk_color_button_get_color(GTK_COLOR_BUTTON(separator->separator_color), &color); + config_write_color(fp, + "separator_color", + color, + gtk_color_button_get_alpha(GTK_COLOR_BUTTON(separator->separator_color)) * 100 / 0xffff); + // fprintf(fp, "separator_style = %d\n", + // (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(separator->separator_style))); + fprintf(fp, + "separator_style = %s\n", + gtk_combo_box_get_active(GTK_COMBO_BOX(separator->separator_style)) == 0 + ? "empty" + : gtk_combo_box_get_active(GTK_COMBO_BOX(separator->separator_style)) == 1 ? "line" : "dots"); + fprintf(fp, + "separator_size = %d\n", + (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(separator->separator_size))); + fprintf(fp, + "separator_padding = %d %d\n", + (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(separator->separator_padding_x)), + (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(separator->separator_padding_y))); + fprintf(fp, "\n"); + } } void config_write_execp(FILE *fp) { - for (int i = 0; i < executors->len; i++) { - fprintf(fp, "#-------------------------------------\n"); - fprintf(fp, "# Executor %d\n", i + 1); + for (int i = 0; i < executors->len; i++) { + fprintf(fp, "#-------------------------------------\n"); + fprintf(fp, "# Executor %d\n", i + 1); - Executor *executor = &g_array_index(executors, Executor, i); + Executor *executor = &g_array_index(executors, Executor, i); - fprintf(fp, "execp = new\n"); - fprintf(fp, "execp_command = %s\n", gtk_entry_get_text(GTK_ENTRY(executor->execp_command))); - fprintf(fp, "execp_interval = %d\n", (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(executor->execp_interval))); - fprintf(fp, - "execp_has_icon = %d\n", - gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(executor->execp_has_icon)) ? 1 : 0); - fprintf(fp, - "execp_cache_icon = %d\n", - gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(executor->execp_cache_icon)) ? 1 : 0); - fprintf(fp, - "execp_continuous = %d\n", - (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(executor->execp_continuous))); - fprintf(fp, - "execp_markup = %d\n", - gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(executor->execp_markup)) ? 1 : 0); - if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(executor->execp_show_tooltip))) { - fprintf(fp, "execp_tooltip = \n"); - } else { - const gchar *text = gtk_entry_get_text(GTK_ENTRY(executor->execp_tooltip)); - if (strlen(text) > 0) - fprintf(fp, "execp_tooltip = %s\n", text); - } + fprintf(fp, "execp = new\n"); + fprintf(fp, "execp_command = %s\n", gtk_entry_get_text(GTK_ENTRY(executor->execp_command))); + fprintf(fp, "execp_interval = %d\n", (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(executor->execp_interval))); + fprintf(fp, + "execp_has_icon = %d\n", + gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(executor->execp_has_icon)) ? 1 : 0); + fprintf(fp, + "execp_cache_icon = %d\n", + gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(executor->execp_cache_icon)) ? 1 : 0); + fprintf(fp, + "execp_continuous = %d\n", + (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(executor->execp_continuous))); + fprintf(fp, + "execp_markup = %d\n", + gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(executor->execp_markup)) ? 1 : 0); + if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(executor->execp_show_tooltip))) { + fprintf(fp, "execp_tooltip = \n"); + } else { + const gchar *text = gtk_entry_get_text(GTK_ENTRY(executor->execp_tooltip)); + if (strlen(text) > 0) + fprintf(fp, "execp_tooltip = %s\n", text); + } - fprintf(fp, "execp_lclick_command = %s\n", gtk_entry_get_text(GTK_ENTRY(executor->execp_left_command))); - fprintf(fp, "execp_rclick_command = %s\n", gtk_entry_get_text(GTK_ENTRY(executor->execp_right_command))); - fprintf(fp, "execp_mclick_command = %s\n", gtk_entry_get_text(GTK_ENTRY(executor->execp_mclick_command))); - fprintf(fp, "execp_uwheel_command = %s\n", gtk_entry_get_text(GTK_ENTRY(executor->execp_uwheel_command))); - fprintf(fp, "execp_dwheel_command = %s\n", gtk_entry_get_text(GTK_ENTRY(executor->execp_dwheel_command))); + fprintf(fp, "execp_lclick_command = %s\n", gtk_entry_get_text(GTK_ENTRY(executor->execp_left_command))); + fprintf(fp, "execp_rclick_command = %s\n", gtk_entry_get_text(GTK_ENTRY(executor->execp_right_command))); + fprintf(fp, "execp_mclick_command = %s\n", gtk_entry_get_text(GTK_ENTRY(executor->execp_mclick_command))); + fprintf(fp, "execp_uwheel_command = %s\n", gtk_entry_get_text(GTK_ENTRY(executor->execp_uwheel_command))); + fprintf(fp, "execp_dwheel_command = %s\n", gtk_entry_get_text(GTK_ENTRY(executor->execp_dwheel_command))); - if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(executor->execp_font_set))) - fprintf(fp, "execp_font = %s\n", gtk_font_button_get_font_name(GTK_FONT_BUTTON(executor->execp_font))); - GdkColor color; - gtk_color_button_get_color(GTK_COLOR_BUTTON(executor->execp_font_color), &color); - config_write_color(fp, - "execp_font_color", - color, - gtk_color_button_get_alpha(GTK_COLOR_BUTTON(executor->execp_font_color)) * 100 / 0xffff); - fprintf(fp, - "execp_padding = %d %d\n", - (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(executor->execp_padding_x)), - (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(executor->execp_padding_y))); - fprintf(fp, "execp_background_id = %d\n", gtk_combo_box_get_active(GTK_COMBO_BOX(executor->execp_background))); - fprintf(fp, - "execp_centered = %d\n", - gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(executor->execp_centered)) ? 1 : 0); - fprintf(fp, "execp_icon_w = %d\n", (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(executor->execp_icon_w))); - fprintf(fp, "execp_icon_h = %d\n", (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(executor->execp_icon_h))); + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(executor->execp_font_set))) + fprintf(fp, "execp_font = %s\n", gtk_font_button_get_font_name(GTK_FONT_BUTTON(executor->execp_font))); + GdkColor color; + gtk_color_button_get_color(GTK_COLOR_BUTTON(executor->execp_font_color), &color); + config_write_color(fp, + "execp_font_color", + color, + gtk_color_button_get_alpha(GTK_COLOR_BUTTON(executor->execp_font_color)) * 100 / 0xffff); + fprintf(fp, + "execp_padding = %d %d\n", + (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(executor->execp_padding_x)), + (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(executor->execp_padding_y))); + fprintf(fp, "execp_background_id = %d\n", gtk_combo_box_get_active(GTK_COMBO_BOX(executor->execp_background))); + fprintf(fp, + "execp_centered = %d\n", + gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(executor->execp_centered)) ? 1 : 0); + fprintf(fp, "execp_icon_w = %d\n", (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(executor->execp_icon_w))); + fprintf(fp, "execp_icon_h = %d\n", (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(executor->execp_icon_h))); - fprintf(fp, "\n"); - } + fprintf(fp, "\n"); + } } void config_write_button(FILE *fp) { - for (int i = 0; i < buttons->len; i++) { - fprintf(fp, "#-------------------------------------\n"); - fprintf(fp, "# Button %d\n", i + 1); + for (int i = 0; i < buttons->len; i++) { + fprintf(fp, "#-------------------------------------\n"); + fprintf(fp, "# Button %d\n", i + 1); - Button *button = &g_array_index(buttons, Button, i); + Button *button = &g_array_index(buttons, Button, i); - fprintf(fp, "button = new\n"); - if (strlen(gtk_entry_get_text(GTK_ENTRY(button->button_icon)))) - fprintf(fp, "button_icon = %s\n", gtk_entry_get_text(GTK_ENTRY(button->button_icon))); - if (gtk_entry_get_text(GTK_ENTRY(button->button_text))) - fprintf(fp, "button_text = %s\n", gtk_entry_get_text(GTK_ENTRY(button->button_text))); - if (strlen(gtk_entry_get_text(GTK_ENTRY(button->button_tooltip)))) - fprintf(fp, "button_tooltip = %s\n", gtk_entry_get_text(GTK_ENTRY(button->button_tooltip))); + fprintf(fp, "button = new\n"); + if (strlen(gtk_entry_get_text(GTK_ENTRY(button->button_icon)))) + fprintf(fp, "button_icon = %s\n", gtk_entry_get_text(GTK_ENTRY(button->button_icon))); + if (gtk_entry_get_text(GTK_ENTRY(button->button_text))) + fprintf(fp, "button_text = %s\n", gtk_entry_get_text(GTK_ENTRY(button->button_text))); + if (strlen(gtk_entry_get_text(GTK_ENTRY(button->button_tooltip)))) + fprintf(fp, "button_tooltip = %s\n", gtk_entry_get_text(GTK_ENTRY(button->button_tooltip))); - fprintf(fp, "button_lclick_command = %s\n", gtk_entry_get_text(GTK_ENTRY(button->button_left_command))); - fprintf(fp, "button_rclick_command = %s\n", gtk_entry_get_text(GTK_ENTRY(button->button_right_command))); - fprintf(fp, "button_mclick_command = %s\n", gtk_entry_get_text(GTK_ENTRY(button->button_mclick_command))); - fprintf(fp, "button_uwheel_command = %s\n", gtk_entry_get_text(GTK_ENTRY(button->button_uwheel_command))); - fprintf(fp, "button_dwheel_command = %s\n", gtk_entry_get_text(GTK_ENTRY(button->button_dwheel_command))); + fprintf(fp, "button_lclick_command = %s\n", gtk_entry_get_text(GTK_ENTRY(button->button_left_command))); + fprintf(fp, "button_rclick_command = %s\n", gtk_entry_get_text(GTK_ENTRY(button->button_right_command))); + fprintf(fp, "button_mclick_command = %s\n", gtk_entry_get_text(GTK_ENTRY(button->button_mclick_command))); + fprintf(fp, "button_uwheel_command = %s\n", gtk_entry_get_text(GTK_ENTRY(button->button_uwheel_command))); + fprintf(fp, "button_dwheel_command = %s\n", gtk_entry_get_text(GTK_ENTRY(button->button_dwheel_command))); - if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button->button_font_set))) - fprintf(fp, "button_font = %s\n", gtk_font_button_get_font_name(GTK_FONT_BUTTON(button->button_font))); - GdkColor color; - gtk_color_button_get_color(GTK_COLOR_BUTTON(button->button_font_color), &color); - config_write_color(fp, - "button_font_color", - color, - gtk_color_button_get_alpha(GTK_COLOR_BUTTON(button->button_font_color)) * 100 / 0xffff); - fprintf(fp, - "button_padding = %d %d\n", - (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(button->button_padding_x)), - (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(button->button_padding_y))); - fprintf(fp, "button_background_id = %d\n", gtk_combo_box_get_active(GTK_COMBO_BOX(button->button_background))); - fprintf(fp, - "button_centered = %d\n", - gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button->button_centered)) ? 1 : 0); - fprintf(fp, - "button_max_icon_size = %d\n", - (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(button->button_max_icon_size))); + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button->button_font_set))) + fprintf(fp, "button_font = %s\n", gtk_font_button_get_font_name(GTK_FONT_BUTTON(button->button_font))); + GdkColor color; + gtk_color_button_get_color(GTK_COLOR_BUTTON(button->button_font_color), &color); + config_write_color(fp, + "button_font_color", + color, + gtk_color_button_get_alpha(GTK_COLOR_BUTTON(button->button_font_color)) * 100 / 0xffff); + fprintf(fp, + "button_padding = %d %d\n", + (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(button->button_padding_x)), + (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(button->button_padding_y))); + fprintf(fp, "button_background_id = %d\n", gtk_combo_box_get_active(GTK_COMBO_BOX(button->button_background))); + fprintf(fp, + "button_centered = %d\n", + gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button->button_centered)) ? 1 : 0); + fprintf(fp, + "button_max_icon_size = %d\n", + (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(button->button_max_icon_size))); - - fprintf(fp, "\n"); - } + fprintf(fp, "\n"); + } } void config_write_tooltip(FILE *fp) { - fprintf(fp, "#-------------------------------------\n"); - fprintf(fp, "# Tooltip\n"); + fprintf(fp, "#-------------------------------------\n"); + fprintf(fp, "# Tooltip\n"); - fprintf(fp, "tooltip_show_timeout = %g\n", gtk_spin_button_get_value(GTK_SPIN_BUTTON(tooltip_show_after))); - fprintf(fp, "tooltip_hide_timeout = %g\n", gtk_spin_button_get_value(GTK_SPIN_BUTTON(tooltip_hide_after))); - fprintf(fp, - "tooltip_padding = %d %d\n", - (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(tooltip_padding_x)), - (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(tooltip_padding_y))); - fprintf(fp, "tooltip_background_id = %d\n", gtk_combo_box_get_active(GTK_COMBO_BOX(tooltip_background))); + fprintf(fp, "tooltip_show_timeout = %g\n", gtk_spin_button_get_value(GTK_SPIN_BUTTON(tooltip_show_after))); + fprintf(fp, "tooltip_hide_timeout = %g\n", gtk_spin_button_get_value(GTK_SPIN_BUTTON(tooltip_hide_after))); + fprintf(fp, + "tooltip_padding = %d %d\n", + (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(tooltip_padding_x)), + (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(tooltip_padding_y))); + fprintf(fp, "tooltip_background_id = %d\n", gtk_combo_box_get_active(GTK_COMBO_BOX(tooltip_background))); - GdkColor color; - gtk_color_button_get_color(GTK_COLOR_BUTTON(tooltip_font_color), &color); - config_write_color(fp, - "tooltip_font_color", - color, - gtk_color_button_get_alpha(GTK_COLOR_BUTTON(tooltip_font_color)) * 100 / 0xffff); + GdkColor color; + gtk_color_button_get_color(GTK_COLOR_BUTTON(tooltip_font_color), &color); + config_write_color(fp, + "tooltip_font_color", + color, + gtk_color_button_get_alpha(GTK_COLOR_BUTTON(tooltip_font_color)) * 100 / 0xffff); - if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(tooltip_font_set))) - fprintf(fp, "tooltip_font = %s\n", gtk_font_button_get_font_name(GTK_FONT_BUTTON(tooltip_font))); + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(tooltip_font_set))) + fprintf(fp, "tooltip_font = %s\n", gtk_font_button_get_font_name(GTK_FONT_BUTTON(tooltip_font))); - fprintf(fp, "\n"); + fprintf(fp, "\n"); } // Similar to BSD checksum, except we skip the first line (metadata) unsigned short checksum_txt(FILE *f) { - unsigned int checksum = 0; - fseek(f, 0, SEEK_SET); + unsigned int checksum = 0; + fseek(f, 0, SEEK_SET); - // Skip the first line - int c; - do { - c = getc(f); - } while (c != EOF && c != '\n'); + // Skip the first line + int c; + do { + c = getc(f); + } while (c != EOF && c != '\n'); - while ((c = getc(f)) != EOF) { - // Rotate right - checksum = (checksum >> 1) + ((checksum & 1) << 15); - // Update checksum - checksum += c; - // Truncate to 16 bits - checksum &= 0xffff; - } - return checksum; + while ((c = getc(f)) != EOF) { + // Rotate right + checksum = (checksum >> 1) + ((checksum & 1) << 15); + // Update checksum + checksum += c; + // Truncate to 16 bits + checksum &= 0xffff; + } + return checksum; } void config_save_file(const char *path) { - printf("config_save_file : %s\n", path); + printf("config_save_file : %s\n", path); - FILE *fp; - if ((fp = fopen(path, "w+t")) == NULL) - return; + FILE *fp; + if ((fp = fopen(path, "w+t")) == NULL) + return; - unsigned short checksum = 0; - fprintf(fp, "#---- Generated by tint2conf %04x ----\n", checksum); - fprintf(fp, "# See https://gitlab.com/o9000/tint2/wikis/Configure for \n"); - fprintf(fp, "# full documentation of the configuration options.\n"); + unsigned short checksum = 0; + fprintf(fp, "#---- Generated by tint2conf %04x ----\n", checksum); + fprintf(fp, "# See https://gitlab.com/o9000/tint2/wikis/Configure for \n"); + fprintf(fp, "# full documentation of the configuration options.\n"); - config_write_gradients(fp); - config_write_backgrounds(fp); - config_write_panel(fp); - config_write_taskbar(fp); - config_write_task(fp); - config_write_systray(fp); - config_write_launcher(fp); - config_write_clock(fp); - config_write_battery(fp); - config_write_separator(fp); - config_write_execp(fp); - config_write_button(fp); - config_write_tooltip(fp); + config_write_gradients(fp); + config_write_backgrounds(fp); + config_write_panel(fp); + config_write_taskbar(fp); + config_write_task(fp); + config_write_systray(fp); + config_write_launcher(fp); + config_write_clock(fp); + config_write_battery(fp); + config_write_separator(fp); + config_write_execp(fp); + config_write_button(fp); + config_write_tooltip(fp); - checksum = checksum_txt(fp); - fseek(fp, 0, SEEK_SET); - fflush(fp); - fprintf(fp, "#---- Generated by tint2conf %04x ----\n", checksum); + checksum = checksum_txt(fp); + fseek(fp, 0, SEEK_SET); + fflush(fp); + fprintf(fp, "#---- Generated by tint2conf %04x ----\n", checksum); - fclose(fp); + fclose(fp); } gboolean config_is_manual(const char *path) { - FILE *fp; - char line[512]; - gboolean result; + FILE *fp; + char line[512]; + gboolean result; - if ((fp = fopen(path, "r")) == NULL) - return FALSE; + if ((fp = fopen(path, "r")) == NULL) + return FALSE; - result = TRUE; - if (fgets(line, sizeof(line), fp) != NULL) { - if (!g_regex_match_simple("^#---- Generated by tint2conf [0-9a-f][0-9a-f][0-9a-f][0-9a-f] ----\n$", - line, - 0, - 0)) { - result = TRUE; - } else { - unsigned short checksum1 = checksum_txt(fp); - unsigned short checksum2 = 0; - if (sscanf(line, "#---- Generated by tint2conf %hxu", &checksum2) == 1) { - result = checksum1 != checksum2; - } else { - result = TRUE; - } - } - } - fclose(fp); - return result; + result = TRUE; + if (fgets(line, sizeof(line), fp) != NULL) { + if (!g_regex_match_simple("^#---- Generated by tint2conf [0-9a-f][0-9a-f][0-9a-f][0-9a-f] ----\n$", + line, + 0, + 0)) { + result = TRUE; + } else { + unsigned short checksum1 = checksum_txt(fp); + unsigned short checksum2 = 0; + if (sscanf(line, "#---- Generated by tint2conf %hxu", &checksum2) == 1) { + result = checksum1 != checksum2; + } else { + result = TRUE; + } + } + } + fclose(fp); + return result; } void finalize_bg() { - if (num_bg > 0) { - if (!read_bg_color_hover) { - GdkColor fillColor; - gtk_color_button_get_color(GTK_COLOR_BUTTON(background_fill_color), &fillColor); - gtk_color_button_set_color(GTK_COLOR_BUTTON(background_fill_color_over), &fillColor); - int fillOpacity = gtk_color_button_get_alpha(GTK_COLOR_BUTTON(background_fill_color)); - gtk_color_button_set_alpha(GTK_COLOR_BUTTON(background_fill_color_over), fillOpacity); - background_force_update(); - } - if (!read_border_color_hover) { - GdkColor fillColor; - gtk_color_button_get_color(GTK_COLOR_BUTTON(background_border_color), &fillColor); - gtk_color_button_set_color(GTK_COLOR_BUTTON(background_border_color_over), &fillColor); - int fillOpacity = gtk_color_button_get_alpha(GTK_COLOR_BUTTON(background_border_color)); - gtk_color_button_set_alpha(GTK_COLOR_BUTTON(background_border_color_over), fillOpacity); - background_force_update(); - } - if (!read_bg_color_press) { - GdkColor fillColor; - gtk_color_button_get_color(GTK_COLOR_BUTTON(background_fill_color), &fillColor); - gtk_color_button_set_color(GTK_COLOR_BUTTON(background_fill_color_press), &fillColor); - int fillOpacity = gtk_color_button_get_alpha(GTK_COLOR_BUTTON(background_fill_color)); - gtk_color_button_set_alpha(GTK_COLOR_BUTTON(background_fill_color_press), fillOpacity); - background_force_update(); - } - if (!read_border_color_press) { - GdkColor fillColor; - gtk_color_button_get_color(GTK_COLOR_BUTTON(background_border_color_over), &fillColor); - gtk_color_button_set_color(GTK_COLOR_BUTTON(background_border_color_press), &fillColor); - int fillOpacity = gtk_color_button_get_alpha(GTK_COLOR_BUTTON(background_border_color_over)); - gtk_color_button_set_alpha(GTK_COLOR_BUTTON(background_border_color_press), fillOpacity); - background_force_update(); - } - } + if (num_bg > 0) { + if (!read_bg_color_hover) { + GdkColor fillColor; + gtk_color_button_get_color(GTK_COLOR_BUTTON(background_fill_color), &fillColor); + gtk_color_button_set_color(GTK_COLOR_BUTTON(background_fill_color_over), &fillColor); + int fillOpacity = gtk_color_button_get_alpha(GTK_COLOR_BUTTON(background_fill_color)); + gtk_color_button_set_alpha(GTK_COLOR_BUTTON(background_fill_color_over), fillOpacity); + background_force_update(); + } + if (!read_border_color_hover) { + GdkColor fillColor; + gtk_color_button_get_color(GTK_COLOR_BUTTON(background_border_color), &fillColor); + gtk_color_button_set_color(GTK_COLOR_BUTTON(background_border_color_over), &fillColor); + int fillOpacity = gtk_color_button_get_alpha(GTK_COLOR_BUTTON(background_border_color)); + gtk_color_button_set_alpha(GTK_COLOR_BUTTON(background_border_color_over), fillOpacity); + background_force_update(); + } + if (!read_bg_color_press) { + GdkColor fillColor; + gtk_color_button_get_color(GTK_COLOR_BUTTON(background_fill_color), &fillColor); + gtk_color_button_set_color(GTK_COLOR_BUTTON(background_fill_color_press), &fillColor); + int fillOpacity = gtk_color_button_get_alpha(GTK_COLOR_BUTTON(background_fill_color)); + gtk_color_button_set_alpha(GTK_COLOR_BUTTON(background_fill_color_press), fillOpacity); + background_force_update(); + } + if (!read_border_color_press) { + GdkColor fillColor; + gtk_color_button_get_color(GTK_COLOR_BUTTON(background_border_color_over), &fillColor); + gtk_color_button_set_color(GTK_COLOR_BUTTON(background_border_color_press), &fillColor); + int fillOpacity = gtk_color_button_get_alpha(GTK_COLOR_BUTTON(background_border_color_over)); + gtk_color_button_set_alpha(GTK_COLOR_BUTTON(background_border_color_press), fillOpacity); + background_force_update(); + } + } } void finalize_gradient() { - if (num_gr > 0) { - gradient_force_update(); - } + if (num_gr > 0) { + gradient_force_update(); + } } void add_entry(char *key, char *value) { - char *value1 = 0, *value2 = 0, *value3 = 0; + char *value1 = 0, *value2 = 0, *value3 = 0; - /* Gradients */ - if (strcmp(key, "gradient") == 0) { - finalize_gradient(); - GradientConfigType t; - if (g_str_equal(value, "horizontal")) - t = GRADIENT_CONFIG_HORIZONTAL; - else if (g_str_equal(value, "vertical")) - t = GRADIENT_CONFIG_VERTICAL; - else - t = GRADIENT_CONFIG_RADIAL; - gradient_create_new(t); - num_gr++; - gradient_force_update(); - } else if (strcmp(key, "start_color") == 0) { - extract_values(value, &value1, &value2, &value3); - GdkColor col; - hex2gdk(value1, &col); - gtk_color_button_set_color(GTK_COLOR_BUTTON(gradient_start_color), &col); - int alpha = value2 ? atoi(value2) : 50; - gtk_color_button_set_alpha(GTK_COLOR_BUTTON(gradient_start_color), (alpha * 65535) / 100); - gradient_force_update(); - } else if (strcmp(key, "end_color") == 0) { - extract_values(value, &value1, &value2, &value3); - GdkColor col; - hex2gdk(value1, &col); - gtk_color_button_set_color(GTK_COLOR_BUTTON(gradient_end_color), &col); - int alpha = value2 ? atoi(value2) : 50; - gtk_color_button_set_alpha(GTK_COLOR_BUTTON(gradient_end_color), (alpha * 65535) / 100); - gradient_force_update(); - } else if (strcmp(key, "color_stop") == 0) { - GradientConfig *g = (GradientConfig *)g_list_last(gradients)->data; - extract_values(value, &value1, &value2, &value3); - GradientConfigColorStop *color_stop = (GradientConfigColorStop *) calloc(1, sizeof(GradientConfigColorStop)); - color_stop->offset = atof(value1) / 100.0; - get_color(value2, color_stop->color.rgb); - if (value3) - color_stop->color.alpha = (atoi(value3) / 100.0); - else - color_stop->color.alpha = 0.5; - g->extra_color_stops = g_list_append(g->extra_color_stops, color_stop); - current_gradient_changed(NULL, NULL); - } else + /* Gradients */ + if (strcmp(key, "gradient") == 0) { + finalize_gradient(); + GradientConfigType t; + if (g_str_equal(value, "horizontal")) + t = GRADIENT_CONFIG_HORIZONTAL; + else if (g_str_equal(value, "vertical")) + t = GRADIENT_CONFIG_VERTICAL; + else + t = GRADIENT_CONFIG_RADIAL; + gradient_create_new(t); + num_gr++; + gradient_force_update(); + } else if (strcmp(key, "start_color") == 0) { + extract_values(value, &value1, &value2, &value3); + GdkColor col; + hex2gdk(value1, &col); + gtk_color_button_set_color(GTK_COLOR_BUTTON(gradient_start_color), &col); + int alpha = value2 ? atoi(value2) : 50; + gtk_color_button_set_alpha(GTK_COLOR_BUTTON(gradient_start_color), (alpha * 65535) / 100); + gradient_force_update(); + } else if (strcmp(key, "end_color") == 0) { + extract_values(value, &value1, &value2, &value3); + GdkColor col; + hex2gdk(value1, &col); + gtk_color_button_set_color(GTK_COLOR_BUTTON(gradient_end_color), &col); + int alpha = value2 ? atoi(value2) : 50; + gtk_color_button_set_alpha(GTK_COLOR_BUTTON(gradient_end_color), (alpha * 65535) / 100); + gradient_force_update(); + } else if (strcmp(key, "color_stop") == 0) { + GradientConfig *g = (GradientConfig *)g_list_last(gradients)->data; + extract_values(value, &value1, &value2, &value3); + GradientConfigColorStop *color_stop = (GradientConfigColorStop *)calloc(1, sizeof(GradientConfigColorStop)); + color_stop->offset = atof(value1) / 100.0; + get_color(value2, color_stop->color.rgb); + if (value3) + color_stop->color.alpha = (atoi(value3) / 100.0); + else + color_stop->color.alpha = 0.5; + g->extra_color_stops = g_list_append(g->extra_color_stops, color_stop); + current_gradient_changed(NULL, NULL); + } else - /* Background and border */ - if (strcmp(key, "rounded") == 0) { - // 'rounded' is the first parameter => alloc a new background - finalize_bg(); - background_create_new(); - num_bg++; - read_bg_color_hover = 0; - read_border_color_hover = 0; - read_bg_color_press = 0; - read_border_color_press = 0; - gtk_spin_button_set_value(GTK_SPIN_BUTTON(background_corner_radius), atoi(value)); - background_force_update(); - } else if (strcmp(key, "border_width") == 0) { - gtk_spin_button_set_value(GTK_SPIN_BUTTON(background_border_width), atoi(value)); - background_force_update(); - } else if (strcmp(key, "background_color") == 0) { - extract_values(value, &value1, &value2, &value3); - GdkColor col; - hex2gdk(value1, &col); - gtk_color_button_set_color(GTK_COLOR_BUTTON(background_fill_color), &col); - int alpha = value2 ? atoi(value2) : 50; - gtk_color_button_set_alpha(GTK_COLOR_BUTTON(background_fill_color), (alpha * 65535) / 100); - background_force_update(); - } else if (strcmp(key, "border_color") == 0) { - extract_values(value, &value1, &value2, &value3); - GdkColor col; - hex2gdk(value1, &col); - gtk_color_button_set_color(GTK_COLOR_BUTTON(background_border_color), &col); - int alpha = value2 ? atoi(value2) : 50; - gtk_color_button_set_alpha(GTK_COLOR_BUTTON(background_border_color), (alpha * 65535) / 100); - background_force_update(); - } else if (strcmp(key, "background_color_hover") == 0) { - extract_values(value, &value1, &value2, &value3); - GdkColor col; - hex2gdk(value1, &col); - gtk_color_button_set_color(GTK_COLOR_BUTTON(background_fill_color_over), &col); - int alpha = value2 ? atoi(value2) : 50; - gtk_color_button_set_alpha(GTK_COLOR_BUTTON(background_fill_color_over), (alpha * 65535) / 100); - background_force_update(); - read_bg_color_hover = 1; - } else if (strcmp(key, "border_color_hover") == 0) { - extract_values(value, &value1, &value2, &value3); - GdkColor col; - hex2gdk(value1, &col); - gtk_color_button_set_color(GTK_COLOR_BUTTON(background_border_color_over), &col); - int alpha = value2 ? atoi(value2) : 50; - gtk_color_button_set_alpha(GTK_COLOR_BUTTON(background_border_color_over), (alpha * 65535) / 100); - background_force_update(); - read_border_color_hover = 1; - } else if (strcmp(key, "background_color_pressed") == 0) { - extract_values(value, &value1, &value2, &value3); - GdkColor col; - hex2gdk(value1, &col); - gtk_color_button_set_color(GTK_COLOR_BUTTON(background_fill_color_press), &col); - int alpha = value2 ? atoi(value2) : 50; - gtk_color_button_set_alpha(GTK_COLOR_BUTTON(background_fill_color_press), (alpha * 65535) / 100); - background_force_update(); - read_bg_color_press = 1; - } else if (strcmp(key, "border_color_pressed") == 0) { - extract_values(value, &value1, &value2, &value3); - GdkColor col; - hex2gdk(value1, &col); - gtk_color_button_set_color(GTK_COLOR_BUTTON(background_border_color_press), &col); - int alpha = value2 ? atoi(value2) : 50; - gtk_color_button_set_alpha(GTK_COLOR_BUTTON(background_border_color_press), (alpha * 65535) / 100); - background_force_update(); - read_border_color_press = 1; - } else if (strcmp(key, "border_sides") == 0) { - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(background_border_sides_top), - strchr(value, 't') || strchr(value, 'T')); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(background_border_sides_bottom), - strchr(value, 'b') || strchr(value, 'B')); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(background_border_sides_left), - strchr(value, 'l') || strchr(value, 'L')); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(background_border_sides_right), - strchr(value, 'r') || strchr(value, 'R')); - background_force_update(); - } else if (strcmp(key, "gradient_id") == 0) { - int id = gradient_index_safe(atoi(value)); - gtk_combo_box_set_active(GTK_COMBO_BOX(background_gradient), id); - background_force_update(); - } else if (strcmp(key, "gradient_id_hover") == 0 || strcmp(key, "hover_gradient_id") == 0) { - int id = gradient_index_safe(atoi(value)); - gtk_combo_box_set_active(GTK_COMBO_BOX(background_gradient_over), id); - background_force_update(); - } else if (strcmp(key, "gradient_id_pressed") == 0 || strcmp(key, "pressed_gradient_id") == 0) { - int id = gradient_index_safe(atoi(value)); - gtk_combo_box_set_active(GTK_COMBO_BOX(background_gradient_press), id); - background_force_update(); - } + /* Background and border */ + if (strcmp(key, "rounded") == 0) { + // 'rounded' is the first parameter => alloc a new background + finalize_bg(); + background_create_new(); + num_bg++; + read_bg_color_hover = 0; + read_border_color_hover = 0; + read_bg_color_press = 0; + read_border_color_press = 0; + gtk_spin_button_set_value(GTK_SPIN_BUTTON(background_corner_radius), atoi(value)); + background_force_update(); + } else if (strcmp(key, "border_width") == 0) { + gtk_spin_button_set_value(GTK_SPIN_BUTTON(background_border_width), atoi(value)); + background_force_update(); + } else if (strcmp(key, "background_color") == 0) { + extract_values(value, &value1, &value2, &value3); + GdkColor col; + hex2gdk(value1, &col); + gtk_color_button_set_color(GTK_COLOR_BUTTON(background_fill_color), &col); + int alpha = value2 ? atoi(value2) : 50; + gtk_color_button_set_alpha(GTK_COLOR_BUTTON(background_fill_color), (alpha * 65535) / 100); + background_force_update(); + } else if (strcmp(key, "border_color") == 0) { + extract_values(value, &value1, &value2, &value3); + GdkColor col; + hex2gdk(value1, &col); + gtk_color_button_set_color(GTK_COLOR_BUTTON(background_border_color), &col); + int alpha = value2 ? atoi(value2) : 50; + gtk_color_button_set_alpha(GTK_COLOR_BUTTON(background_border_color), (alpha * 65535) / 100); + background_force_update(); + } else if (strcmp(key, "background_color_hover") == 0) { + extract_values(value, &value1, &value2, &value3); + GdkColor col; + hex2gdk(value1, &col); + gtk_color_button_set_color(GTK_COLOR_BUTTON(background_fill_color_over), &col); + int alpha = value2 ? atoi(value2) : 50; + gtk_color_button_set_alpha(GTK_COLOR_BUTTON(background_fill_color_over), (alpha * 65535) / 100); + background_force_update(); + read_bg_color_hover = 1; + } else if (strcmp(key, "border_color_hover") == 0) { + extract_values(value, &value1, &value2, &value3); + GdkColor col; + hex2gdk(value1, &col); + gtk_color_button_set_color(GTK_COLOR_BUTTON(background_border_color_over), &col); + int alpha = value2 ? atoi(value2) : 50; + gtk_color_button_set_alpha(GTK_COLOR_BUTTON(background_border_color_over), (alpha * 65535) / 100); + background_force_update(); + read_border_color_hover = 1; + } else if (strcmp(key, "background_color_pressed") == 0) { + extract_values(value, &value1, &value2, &value3); + GdkColor col; + hex2gdk(value1, &col); + gtk_color_button_set_color(GTK_COLOR_BUTTON(background_fill_color_press), &col); + int alpha = value2 ? atoi(value2) : 50; + gtk_color_button_set_alpha(GTK_COLOR_BUTTON(background_fill_color_press), (alpha * 65535) / 100); + background_force_update(); + read_bg_color_press = 1; + } else if (strcmp(key, "border_color_pressed") == 0) { + extract_values(value, &value1, &value2, &value3); + GdkColor col; + hex2gdk(value1, &col); + gtk_color_button_set_color(GTK_COLOR_BUTTON(background_border_color_press), &col); + int alpha = value2 ? atoi(value2) : 50; + gtk_color_button_set_alpha(GTK_COLOR_BUTTON(background_border_color_press), (alpha * 65535) / 100); + background_force_update(); + read_border_color_press = 1; + } else if (strcmp(key, "border_sides") == 0) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(background_border_sides_top), + strchr(value, 't') || strchr(value, 'T')); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(background_border_sides_bottom), + strchr(value, 'b') || strchr(value, 'B')); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(background_border_sides_left), + strchr(value, 'l') || strchr(value, 'L')); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(background_border_sides_right), + strchr(value, 'r') || strchr(value, 'R')); + background_force_update(); + } else if (strcmp(key, "gradient_id") == 0) { + int id = gradient_index_safe(atoi(value)); + gtk_combo_box_set_active(GTK_COMBO_BOX(background_gradient), id); + background_force_update(); + } else if (strcmp(key, "gradient_id_hover") == 0 || strcmp(key, "hover_gradient_id") == 0) { + int id = gradient_index_safe(atoi(value)); + gtk_combo_box_set_active(GTK_COMBO_BOX(background_gradient_over), id); + background_force_update(); + } else if (strcmp(key, "gradient_id_pressed") == 0 || strcmp(key, "pressed_gradient_id") == 0) { + int id = gradient_index_safe(atoi(value)); + gtk_combo_box_set_active(GTK_COMBO_BOX(background_gradient_press), id); + background_force_update(); + } - /* Panel */ - else if (strcmp(key, "panel_size") == 0) { - extract_values(value, &value1, &value2, &value3); - char *b; - if ((b = strchr(value1, '%'))) { - b[0] = '\0'; - gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_width_type), 0); - } else - gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_width_type), 1); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(panel_width), atoi(value1)); - if (atoi(value1) == 0) { - // full width mode - gtk_spin_button_set_value(GTK_SPIN_BUTTON(panel_width), 100); - gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_width_type), 0); - } - if ((b = strchr(value2, '%'))) { - b[0] = '\0'; - gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_height_type), 0); - } else - gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_height_type), 1); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(panel_height), atoi(value2)); - } else if (strcmp(key, "panel_items") == 0) { - config_has_panel_items = 1; - set_panel_items(value); - } else if (strcmp(key, "panel_margin") == 0) { - extract_values(value, &value1, &value2, &value3); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(panel_margin_x), atoi(value1)); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(panel_margin_y), atoi(value2)); - } else if (strcmp(key, "panel_padding") == 0) { - extract_values(value, &value1, &value2, &value3); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(panel_padding_x), atoi(value1)); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(panel_spacing), atoi(value1)); - if (value2) - gtk_spin_button_set_value(GTK_SPIN_BUTTON(panel_padding_y), atoi(value2)); - if (value3) - gtk_spin_button_set_value(GTK_SPIN_BUTTON(panel_spacing), atoi(value3)); - } else if (strcmp(key, "panel_position") == 0) { - extract_values(value, &value1, &value2, &value3); + /* Panel */ + else if (strcmp(key, "panel_size") == 0) { + extract_values(value, &value1, &value2, &value3); + char *b; + if ((b = strchr(value1, '%'))) { + b[0] = '\0'; + gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_width_type), 0); + } else + gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_width_type), 1); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(panel_width), atoi(value1)); + if (atoi(value1) == 0) { + // full width mode + gtk_spin_button_set_value(GTK_SPIN_BUTTON(panel_width), 100); + gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_width_type), 0); + } + if ((b = strchr(value2, '%'))) { + b[0] = '\0'; + gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_height_type), 0); + } else + gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_height_type), 1); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(panel_height), atoi(value2)); + } else if (strcmp(key, "panel_items") == 0) { + config_has_panel_items = 1; + set_panel_items(value); + } else if (strcmp(key, "panel_margin") == 0) { + extract_values(value, &value1, &value2, &value3); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(panel_margin_x), atoi(value1)); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(panel_margin_y), atoi(value2)); + } else if (strcmp(key, "panel_padding") == 0) { + extract_values(value, &value1, &value2, &value3); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(panel_padding_x), atoi(value1)); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(panel_spacing), atoi(value1)); + if (value2) + gtk_spin_button_set_value(GTK_SPIN_BUTTON(panel_padding_y), atoi(value2)); + if (value3) + gtk_spin_button_set_value(GTK_SPIN_BUTTON(panel_spacing), atoi(value3)); + } else if (strcmp(key, "panel_position") == 0) { + extract_values(value, &value1, &value2, &value3); - char vpos, hpos, orientation; + char vpos, hpos, orientation; - vpos = 'B'; - hpos = 'C'; - orientation = 'H'; + vpos = 'B'; + hpos = 'C'; + orientation = 'H'; - if (value1) { - if (strcmp(value1, "top") == 0) - vpos = 'T'; - if (strcmp(value1, "bottom") == 0) - vpos = 'B'; - if (strcmp(value1, "center") == 0) - vpos = 'C'; - } + if (value1) { + if (strcmp(value1, "top") == 0) + vpos = 'T'; + if (strcmp(value1, "bottom") == 0) + vpos = 'B'; + if (strcmp(value1, "center") == 0) + vpos = 'C'; + } - if (value2) { - if (strcmp(value2, "left") == 0) - hpos = 'L'; - if (strcmp(value2, "right") == 0) - hpos = 'R'; - if (strcmp(value2, "center") == 0) - hpos = 'C'; - } + if (value2) { + if (strcmp(value2, "left") == 0) + hpos = 'L'; + if (strcmp(value2, "right") == 0) + hpos = 'R'; + if (strcmp(value2, "center") == 0) + hpos = 'C'; + } - if (value3) { - if (strcmp(value3, "horizontal") == 0) - orientation = 'H'; - if (strcmp(value3, "vertical") == 0) - orientation = 'V'; - } + if (value3) { + if (strcmp(value3, "horizontal") == 0) + orientation = 'H'; + if (strcmp(value3, "vertical") == 0) + orientation = 'V'; + } - if (vpos == 'T' && hpos == 'L' && orientation == 'H') - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(screen_position[POS_TLH]), 1); - if (vpos == 'T' && hpos == 'C' && orientation == 'H') - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(screen_position[POS_TCH]), 1); - if (vpos == 'T' && hpos == 'R' && orientation == 'H') - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(screen_position[POS_TRH]), 1); + if (vpos == 'T' && hpos == 'L' && orientation == 'H') + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(screen_position[POS_TLH]), 1); + if (vpos == 'T' && hpos == 'C' && orientation == 'H') + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(screen_position[POS_TCH]), 1); + if (vpos == 'T' && hpos == 'R' && orientation == 'H') + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(screen_position[POS_TRH]), 1); - if (vpos == 'B' && hpos == 'L' && orientation == 'H') - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(screen_position[POS_BLH]), 1); - if (vpos == 'B' && hpos == 'C' && orientation == 'H') - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(screen_position[POS_BCH]), 1); - if (vpos == 'B' && hpos == 'R' && orientation == 'H') - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(screen_position[POS_BRH]), 1); + if (vpos == 'B' && hpos == 'L' && orientation == 'H') + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(screen_position[POS_BLH]), 1); + if (vpos == 'B' && hpos == 'C' && orientation == 'H') + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(screen_position[POS_BCH]), 1); + if (vpos == 'B' && hpos == 'R' && orientation == 'H') + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(screen_position[POS_BRH]), 1); - if (vpos == 'T' && hpos == 'L' && orientation == 'V') - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(screen_position[POS_TLV]), 1); - if (vpos == 'C' && hpos == 'L' && orientation == 'V') - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(screen_position[POS_CLV]), 1); - if (vpos == 'B' && hpos == 'L' && orientation == 'V') - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(screen_position[POS_BLV]), 1); + if (vpos == 'T' && hpos == 'L' && orientation == 'V') + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(screen_position[POS_TLV]), 1); + if (vpos == 'C' && hpos == 'L' && orientation == 'V') + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(screen_position[POS_CLV]), 1); + if (vpos == 'B' && hpos == 'L' && orientation == 'V') + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(screen_position[POS_BLV]), 1); - if (vpos == 'T' && hpos == 'R' && orientation == 'V') - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(screen_position[POS_TRV]), 1); - if (vpos == 'C' && hpos == 'R' && orientation == 'V') - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(screen_position[POS_CRV]), 1); - if (vpos == 'B' && hpos == 'R' && orientation == 'V') - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(screen_position[POS_BRV]), 1); - } else if (strcmp(key, "panel_background_id") == 0) { - int id = background_index_safe(atoi(value)); - gtk_combo_box_set_active(GTK_COMBO_BOX(panel_background), id); - } else if (strcmp(key, "panel_window_name") == 0) { - gtk_entry_set_text(GTK_ENTRY(panel_window_name), value); - } else if (strcmp(key, "disable_transparency") == 0) { - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(disable_transparency), atoi(value)); - } else if (strcmp(key, "mouse_effects") == 0) { - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(panel_mouse_effects), atoi(value)); - } else if (strcmp(key, "mouse_hover_icon_asb") == 0) { - extract_values(value, &value1, &value2, &value3); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(mouse_hover_icon_opacity), atoi(value1)); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(mouse_hover_icon_saturation), atoi(value2)); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(mouse_hover_icon_brightness), atoi(value3)); - } else if (strcmp(key, "mouse_pressed_icon_asb") == 0) { - extract_values(value, &value1, &value2, &value3); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(mouse_pressed_icon_opacity), atoi(value1)); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(mouse_pressed_icon_saturation), atoi(value2)); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(mouse_pressed_icon_brightness), atoi(value3)); - } else if (strcmp(key, "font_shadow") == 0) { - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(font_shadow), atoi(value)); - } else if (strcmp(key, "wm_menu") == 0) { - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(panel_wm_menu), atoi(value)); - } else if (strcmp(key, "panel_dock") == 0) { - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(panel_dock), atoi(value)); - } else if (strcmp(key, "panel_layer") == 0) { - if (strcmp(value, "bottom") == 0) - gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_layer), 2); - else if (strcmp(value, "top") == 0) - gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_layer), 0); - else - gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_layer), 1); - } else if (strcmp(key, "panel_monitor") == 0) { - if (strcmp(value, "all") == 0) - gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_monitor), 0); - else if (strcmp(value, "1") == 0) - gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_monitor), 1); - else if (strcmp(value, "2") == 0) - gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_monitor), 2); - else if (strcmp(value, "3") == 0) - gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_monitor), 3); - else if (strcmp(value, "4") == 0) - gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_monitor), 4); - else if (strcmp(value, "5") == 0) - gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_monitor), 5); - else if (strcmp(value, "6") == 0) - gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_monitor), 6); - } else if (strcmp(key, "primary_monitor_first") == 0) { - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(panel_primary_monitor_first), atoi(value)); - } else if (strcmp(key, "panel_shrink") == 0) { - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(panel_shrink), atoi(value)); - } + if (vpos == 'T' && hpos == 'R' && orientation == 'V') + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(screen_position[POS_TRV]), 1); + if (vpos == 'C' && hpos == 'R' && orientation == 'V') + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(screen_position[POS_CRV]), 1); + if (vpos == 'B' && hpos == 'R' && orientation == 'V') + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(screen_position[POS_BRV]), 1); + } else if (strcmp(key, "panel_background_id") == 0) { + int id = background_index_safe(atoi(value)); + gtk_combo_box_set_active(GTK_COMBO_BOX(panel_background), id); + } else if (strcmp(key, "panel_window_name") == 0) { + gtk_entry_set_text(GTK_ENTRY(panel_window_name), value); + } else if (strcmp(key, "disable_transparency") == 0) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(disable_transparency), atoi(value)); + } else if (strcmp(key, "mouse_effects") == 0) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(panel_mouse_effects), atoi(value)); + } else if (strcmp(key, "mouse_hover_icon_asb") == 0) { + extract_values(value, &value1, &value2, &value3); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(mouse_hover_icon_opacity), atoi(value1)); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(mouse_hover_icon_saturation), atoi(value2)); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(mouse_hover_icon_brightness), atoi(value3)); + } else if (strcmp(key, "mouse_pressed_icon_asb") == 0) { + extract_values(value, &value1, &value2, &value3); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(mouse_pressed_icon_opacity), atoi(value1)); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(mouse_pressed_icon_saturation), atoi(value2)); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(mouse_pressed_icon_brightness), atoi(value3)); + } else if (strcmp(key, "font_shadow") == 0) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(font_shadow), atoi(value)); + } else if (strcmp(key, "wm_menu") == 0) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(panel_wm_menu), atoi(value)); + } else if (strcmp(key, "panel_dock") == 0) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(panel_dock), atoi(value)); + } else if (strcmp(key, "panel_layer") == 0) { + if (strcmp(value, "bottom") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_layer), 2); + else if (strcmp(value, "top") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_layer), 0); + else + gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_layer), 1); + } else if (strcmp(key, "panel_monitor") == 0) { + if (strcmp(value, "all") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_monitor), 0); + else if (strcmp(value, "1") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_monitor), 1); + else if (strcmp(value, "2") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_monitor), 2); + else if (strcmp(value, "3") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_monitor), 3); + else if (strcmp(value, "4") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_monitor), 4); + else if (strcmp(value, "5") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_monitor), 5); + else if (strcmp(value, "6") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_monitor), 6); + } else if (strcmp(key, "primary_monitor_first") == 0) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(panel_primary_monitor_first), atoi(value)); + } else if (strcmp(key, "panel_shrink") == 0) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(panel_shrink), atoi(value)); + } - /* autohide options */ - else if (strcmp(key, "autohide") == 0) { - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(panel_autohide), atoi(value)); - } else if (strcmp(key, "autohide_show_timeout") == 0) { - gtk_spin_button_set_value(GTK_SPIN_BUTTON(panel_autohide_show_time), atof(value)); - } else if (strcmp(key, "autohide_hide_timeout") == 0) { - gtk_spin_button_set_value(GTK_SPIN_BUTTON(panel_autohide_hide_time), atof(value)); - } else if (strcmp(key, "strut_policy") == 0) { - if (strcmp(value, "follow_size") == 0) - gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_strut_policy), 0); - else if (strcmp(value, "none") == 0) - gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_strut_policy), 2); - else - gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_strut_policy), 1); - } else if (strcmp(key, "autohide_height") == 0) { - if (atoi(value) <= 0) { - // autohide need height > 0 - gtk_spin_button_set_value(GTK_SPIN_BUTTON(panel_autohide_size), 1); - } else { - gtk_spin_button_set_value(GTK_SPIN_BUTTON(panel_autohide_size), atoi(value)); - } - } + /* autohide options */ + else if (strcmp(key, "autohide") == 0) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(panel_autohide), atoi(value)); + } else if (strcmp(key, "autohide_show_timeout") == 0) { + gtk_spin_button_set_value(GTK_SPIN_BUTTON(panel_autohide_show_time), atof(value)); + } else if (strcmp(key, "autohide_hide_timeout") == 0) { + gtk_spin_button_set_value(GTK_SPIN_BUTTON(panel_autohide_hide_time), atof(value)); + } else if (strcmp(key, "strut_policy") == 0) { + if (strcmp(value, "follow_size") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_strut_policy), 0); + else if (strcmp(value, "none") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_strut_policy), 2); + else + gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_strut_policy), 1); + } else if (strcmp(key, "autohide_height") == 0) { + if (atoi(value) <= 0) { + // autohide need height > 0 + gtk_spin_button_set_value(GTK_SPIN_BUTTON(panel_autohide_size), 1); + } else { + gtk_spin_button_set_value(GTK_SPIN_BUTTON(panel_autohide_size), atoi(value)); + } + } - /* Battery */ - else if (strcmp(key, "battery") == 0) { - // Obsolete option - config_has_battery = 1; - config_battery_enabled = atoi(value); - } else if (strcmp(key, "battery_tooltip") == 0) { - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(battery_tooltip), atoi(value)); - } else if (strcmp(key, "battery_low_status") == 0) { - gtk_spin_button_set_value(GTK_SPIN_BUTTON(battery_alert_if_lower), atof(value)); - } else if (strcmp(key, "battery_low_cmd") == 0) { - gtk_entry_set_text(GTK_ENTRY(battery_alert_cmd), value); - } else if (strcmp(key, "bat1_font") == 0) { - gtk_font_button_set_font_name(GTK_FONT_BUTTON(battery_font_line1), value); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(battery_font_line1_set), TRUE); - } else if (strcmp(key, "bat2_font") == 0) { - gtk_font_button_set_font_name(GTK_FONT_BUTTON(battery_font_line2), value); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(battery_font_line2_set), TRUE); - } else if (strcmp(key, "battery_font_color") == 0) { - extract_values(value, &value1, &value2, &value3); - GdkColor col; - hex2gdk(value1, &col); - gtk_color_button_set_color(GTK_COLOR_BUTTON(battery_font_color), &col); - if (value2) { - int alpha = atoi(value2); - gtk_color_button_set_alpha(GTK_COLOR_BUTTON(battery_font_color), (alpha * 65535) / 100); - } - } else if (strcmp(key, "battery_padding") == 0) { - extract_values(value, &value1, &value2, &value3); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(battery_padding_x), atoi(value1)); - if (value2) - gtk_spin_button_set_value(GTK_SPIN_BUTTON(battery_padding_y), atoi(value2)); - } else if (strcmp(key, "battery_background_id") == 0) { - int id = background_index_safe(atoi(value)); - gtk_combo_box_set_active(GTK_COMBO_BOX(battery_background), id); - } else if (strcmp(key, "battery_hide") == 0) { - int percentage_hide = atoi(value); - if (percentage_hide == 0) - gtk_spin_button_set_value(GTK_SPIN_BUTTON(battery_hide_if_higher), 101.0); - else - gtk_spin_button_set_value(GTK_SPIN_BUTTON(battery_hide_if_higher), atoi(value)); - } else if (strcmp(key, "battery_lclick_command") == 0) { - gtk_entry_set_text(GTK_ENTRY(battery_left_command), value); - } else if (strcmp(key, "battery_rclick_command") == 0) { - gtk_entry_set_text(GTK_ENTRY(battery_right_command), value); - } else if (strcmp(key, "battery_mclick_command") == 0) { - gtk_entry_set_text(GTK_ENTRY(battery_mclick_command), value); - } else if (strcmp(key, "battery_uwheel_command") == 0) { - gtk_entry_set_text(GTK_ENTRY(battery_uwheel_command), value); - } else if (strcmp(key, "battery_dwheel_command") == 0) { - gtk_entry_set_text(GTK_ENTRY(battery_dwheel_command), value); - } else if (strcmp(key, "ac_connected_cmd") == 0) { - gtk_entry_set_text(GTK_ENTRY(ac_connected_cmd), value); - } else if (strcmp(key, "ac_disconnected_cmd") == 0) { - gtk_entry_set_text(GTK_ENTRY(ac_disconnected_cmd), value); - } + /* Battery */ + else if (strcmp(key, "battery") == 0) { + // Obsolete option + config_has_battery = 1; + config_battery_enabled = atoi(value); + } else if (strcmp(key, "battery_tooltip") == 0) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(battery_tooltip), atoi(value)); + } else if (strcmp(key, "battery_low_status") == 0) { + gtk_spin_button_set_value(GTK_SPIN_BUTTON(battery_alert_if_lower), atof(value)); + } else if (strcmp(key, "battery_low_cmd") == 0) { + gtk_entry_set_text(GTK_ENTRY(battery_alert_cmd), value); + } else if (strcmp(key, "bat1_font") == 0) { + gtk_font_button_set_font_name(GTK_FONT_BUTTON(battery_font_line1), value); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(battery_font_line1_set), TRUE); + } else if (strcmp(key, "bat2_font") == 0) { + gtk_font_button_set_font_name(GTK_FONT_BUTTON(battery_font_line2), value); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(battery_font_line2_set), TRUE); + } else if (strcmp(key, "battery_font_color") == 0) { + extract_values(value, &value1, &value2, &value3); + GdkColor col; + hex2gdk(value1, &col); + gtk_color_button_set_color(GTK_COLOR_BUTTON(battery_font_color), &col); + if (value2) { + int alpha = atoi(value2); + gtk_color_button_set_alpha(GTK_COLOR_BUTTON(battery_font_color), (alpha * 65535) / 100); + } + } else if (strcmp(key, "battery_padding") == 0) { + extract_values(value, &value1, &value2, &value3); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(battery_padding_x), atoi(value1)); + if (value2) + gtk_spin_button_set_value(GTK_SPIN_BUTTON(battery_padding_y), atoi(value2)); + } else if (strcmp(key, "battery_background_id") == 0) { + int id = background_index_safe(atoi(value)); + gtk_combo_box_set_active(GTK_COMBO_BOX(battery_background), id); + } else if (strcmp(key, "battery_hide") == 0) { + int percentage_hide = atoi(value); + if (percentage_hide == 0) + gtk_spin_button_set_value(GTK_SPIN_BUTTON(battery_hide_if_higher), 101.0); + else + gtk_spin_button_set_value(GTK_SPIN_BUTTON(battery_hide_if_higher), atoi(value)); + } else if (strcmp(key, "battery_lclick_command") == 0) { + gtk_entry_set_text(GTK_ENTRY(battery_left_command), value); + } else if (strcmp(key, "battery_rclick_command") == 0) { + gtk_entry_set_text(GTK_ENTRY(battery_right_command), value); + } else if (strcmp(key, "battery_mclick_command") == 0) { + gtk_entry_set_text(GTK_ENTRY(battery_mclick_command), value); + } else if (strcmp(key, "battery_uwheel_command") == 0) { + gtk_entry_set_text(GTK_ENTRY(battery_uwheel_command), value); + } else if (strcmp(key, "battery_dwheel_command") == 0) { + gtk_entry_set_text(GTK_ENTRY(battery_dwheel_command), value); + } else if (strcmp(key, "ac_connected_cmd") == 0) { + gtk_entry_set_text(GTK_ENTRY(ac_connected_cmd), value); + } else if (strcmp(key, "ac_disconnected_cmd") == 0) { + gtk_entry_set_text(GTK_ENTRY(ac_disconnected_cmd), value); + } - /* Clock */ - else if (strcmp(key, "time1_format") == 0) { - gtk_entry_set_text(GTK_ENTRY(clock_format_line1), value); - no_items_clock_enabled = strlen(value) > 0; - } else if (strcmp(key, "time2_format") == 0) { - gtk_entry_set_text(GTK_ENTRY(clock_format_line2), value); - } else if (strcmp(key, "time1_font") == 0) { - gtk_font_button_set_font_name(GTK_FONT_BUTTON(clock_font_line1), value); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(clock_font_line1_set), TRUE); - } else if (strcmp(key, "time1_timezone") == 0) { - gtk_entry_set_text(GTK_ENTRY(clock_tmz_line1), value); - } else if (strcmp(key, "time2_timezone") == 0) { - gtk_entry_set_text(GTK_ENTRY(clock_tmz_line2), value); - } else if (strcmp(key, "time2_font") == 0) { - gtk_font_button_set_font_name(GTK_FONT_BUTTON(clock_font_line2), value); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(clock_font_line2_set), TRUE); - } else if (strcmp(key, "clock_font_color") == 0) { - extract_values(value, &value1, &value2, &value3); - GdkColor col; - hex2gdk(value1, &col); - gtk_color_button_set_color(GTK_COLOR_BUTTON(clock_font_color), &col); - if (value2) { - int alpha = atoi(value2); - gtk_color_button_set_alpha(GTK_COLOR_BUTTON(clock_font_color), (alpha * 65535) / 100); - } - } else if (strcmp(key, "clock_padding") == 0) { - extract_values(value, &value1, &value2, &value3); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(clock_padding_x), atoi(value1)); - if (value2) - gtk_spin_button_set_value(GTK_SPIN_BUTTON(clock_padding_y), atoi(value2)); - } else if (strcmp(key, "clock_background_id") == 0) { - int id = background_index_safe(atoi(value)); - gtk_combo_box_set_active(GTK_COMBO_BOX(clock_background), id); - } else if (strcmp(key, "clock_tooltip") == 0) { - gtk_entry_set_text(GTK_ENTRY(clock_format_tooltip), value); - } else if (strcmp(key, "clock_tooltip_timezone") == 0) { - gtk_entry_set_text(GTK_ENTRY(clock_tmz_tooltip), value); - } else if (strcmp(key, "clock_lclick_command") == 0) { - gtk_entry_set_text(GTK_ENTRY(clock_left_command), value); - } else if (strcmp(key, "clock_rclick_command") == 0) { - gtk_entry_set_text(GTK_ENTRY(clock_right_command), value); - } else if (strcmp(key, "clock_mclick_command") == 0) { - gtk_entry_set_text(GTK_ENTRY(clock_mclick_command), value); - } else if (strcmp(key, "clock_uwheel_command") == 0) { - gtk_entry_set_text(GTK_ENTRY(clock_uwheel_command), value); - } else if (strcmp(key, "clock_dwheel_command") == 0) { - gtk_entry_set_text(GTK_ENTRY(clock_dwheel_command), value); - } + /* Clock */ + else if (strcmp(key, "time1_format") == 0) { + gtk_entry_set_text(GTK_ENTRY(clock_format_line1), value); + no_items_clock_enabled = strlen(value) > 0; + } else if (strcmp(key, "time2_format") == 0) { + gtk_entry_set_text(GTK_ENTRY(clock_format_line2), value); + } else if (strcmp(key, "time1_font") == 0) { + gtk_font_button_set_font_name(GTK_FONT_BUTTON(clock_font_line1), value); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(clock_font_line1_set), TRUE); + } else if (strcmp(key, "time1_timezone") == 0) { + gtk_entry_set_text(GTK_ENTRY(clock_tmz_line1), value); + } else if (strcmp(key, "time2_timezone") == 0) { + gtk_entry_set_text(GTK_ENTRY(clock_tmz_line2), value); + } else if (strcmp(key, "time2_font") == 0) { + gtk_font_button_set_font_name(GTK_FONT_BUTTON(clock_font_line2), value); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(clock_font_line2_set), TRUE); + } else if (strcmp(key, "clock_font_color") == 0) { + extract_values(value, &value1, &value2, &value3); + GdkColor col; + hex2gdk(value1, &col); + gtk_color_button_set_color(GTK_COLOR_BUTTON(clock_font_color), &col); + if (value2) { + int alpha = atoi(value2); + gtk_color_button_set_alpha(GTK_COLOR_BUTTON(clock_font_color), (alpha * 65535) / 100); + } + } else if (strcmp(key, "clock_padding") == 0) { + extract_values(value, &value1, &value2, &value3); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(clock_padding_x), atoi(value1)); + if (value2) + gtk_spin_button_set_value(GTK_SPIN_BUTTON(clock_padding_y), atoi(value2)); + } else if (strcmp(key, "clock_background_id") == 0) { + int id = background_index_safe(atoi(value)); + gtk_combo_box_set_active(GTK_COMBO_BOX(clock_background), id); + } else if (strcmp(key, "clock_tooltip") == 0) { + gtk_entry_set_text(GTK_ENTRY(clock_format_tooltip), value); + } else if (strcmp(key, "clock_tooltip_timezone") == 0) { + gtk_entry_set_text(GTK_ENTRY(clock_tmz_tooltip), value); + } else if (strcmp(key, "clock_lclick_command") == 0) { + gtk_entry_set_text(GTK_ENTRY(clock_left_command), value); + } else if (strcmp(key, "clock_rclick_command") == 0) { + gtk_entry_set_text(GTK_ENTRY(clock_right_command), value); + } else if (strcmp(key, "clock_mclick_command") == 0) { + gtk_entry_set_text(GTK_ENTRY(clock_mclick_command), value); + } else if (strcmp(key, "clock_uwheel_command") == 0) { + gtk_entry_set_text(GTK_ENTRY(clock_uwheel_command), value); + } else if (strcmp(key, "clock_dwheel_command") == 0) { + gtk_entry_set_text(GTK_ENTRY(clock_dwheel_command), value); + } - /* Taskbar */ - else if (strcmp(key, "taskbar_mode") == 0) { - if (strcmp(value, "multi_desktop") == 0) - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(taskbar_show_desktop), 1); - else - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(taskbar_show_desktop), 0); - } else if (strcmp(key, "taskbar_hide_if_empty") == 0) { - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(taskbar_hide_empty), atoi(value)); - } else if (strcmp(key, "taskbar_distribute_size") == 0) { - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(taskbar_distribute_size), atoi(value)); - } else if (strcmp(key, "taskbar_sort_order") == 0) { - if (strcmp(value, "none") == 0) - gtk_combo_box_set_active(GTK_COMBO_BOX(taskbar_sort_order), 0); - else if (strcmp(value, "title") == 0) - gtk_combo_box_set_active(GTK_COMBO_BOX(taskbar_sort_order), 1); - else if (strcmp(value, "center") == 0) - gtk_combo_box_set_active(GTK_COMBO_BOX(taskbar_sort_order), 2); - else if (strcmp(value, "mru") == 0) - gtk_combo_box_set_active(GTK_COMBO_BOX(taskbar_sort_order), 3); - else if (strcmp(value, "lru") == 0) - gtk_combo_box_set_active(GTK_COMBO_BOX(taskbar_sort_order), 4); - else - gtk_combo_box_set_active(GTK_COMBO_BOX(taskbar_sort_order), 0); - } else if (strcmp(key, "task_align") == 0) { - if (strcmp(value, "left") == 0) - gtk_combo_box_set_active(GTK_COMBO_BOX(taskbar_alignment), 0); - else if (strcmp(value, "center") == 0) - gtk_combo_box_set_active(GTK_COMBO_BOX(taskbar_alignment), 1); - else if (strcmp(value, "right") == 0) - gtk_combo_box_set_active(GTK_COMBO_BOX(taskbar_alignment), 2); - else - gtk_combo_box_set_active(GTK_COMBO_BOX(taskbar_alignment), 0); - } else if (strcmp(key, "taskbar_padding") == 0) { - extract_values(value, &value1, &value2, &value3); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(taskbar_padding_x), atoi(value1)); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(taskbar_spacing), atoi(value1)); - if (value2) - gtk_spin_button_set_value(GTK_SPIN_BUTTON(taskbar_padding_y), atoi(value2)); - if (value3) - gtk_spin_button_set_value(GTK_SPIN_BUTTON(taskbar_spacing), atoi(value3)); - } else if (strcmp(key, "taskbar_background_id") == 0) { - int id = background_index_safe(atoi(value)); - gtk_combo_box_set_active(GTK_COMBO_BOX(taskbar_inactive_background), id); - if (gtk_combo_box_get_active(GTK_COMBO_BOX(taskbar_active_background)) < 0) - gtk_combo_box_set_active(GTK_COMBO_BOX(taskbar_active_background), id); - } else if (strcmp(key, "taskbar_active_background_id") == 0) { - int id = background_index_safe(atoi(value)); - gtk_combo_box_set_active(GTK_COMBO_BOX(taskbar_active_background), id); - } else if (strcmp(key, "taskbar_name") == 0) { - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(taskbar_show_name), atoi(value)); - } else if (strcmp(key, "taskbar_hide_inactive_tasks") == 0) { - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(taskbar_hide_inactive_tasks), atoi(value)); - } else if (strcmp(key, "taskbar_hide_different_monitor") == 0) { - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(taskbar_hide_diff_monitor), atoi(value)); - } else if (strcmp(key, "taskbar_always_show_all_desktop_tasks") == 0) { - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(taskbar_always_show_all_desktop_tasks), atoi(value)); - } else if (strcmp(key, "taskbar_name_padding") == 0) { - extract_values(value, &value1, &value2, &value3); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(taskbar_name_padding_x), atoi(value1)); - if (value2) - gtk_spin_button_set_value(GTK_SPIN_BUTTON(taskbar_name_padding_y), atoi(value2)); - } else if (strcmp(key, "taskbar_name_background_id") == 0) { - int id = background_index_safe(atoi(value)); - gtk_combo_box_set_active(GTK_COMBO_BOX(taskbar_name_inactive_background), id); - if (gtk_combo_box_get_active(GTK_COMBO_BOX(taskbar_name_active_background)) < 0) - gtk_combo_box_set_active(GTK_COMBO_BOX(taskbar_name_active_background), id); - } else if (strcmp(key, "taskbar_name_active_background_id") == 0) { - int id = background_index_safe(atoi(value)); - gtk_combo_box_set_active(GTK_COMBO_BOX(taskbar_name_active_background), id); - } else if (strcmp(key, "taskbar_name_font") == 0) { - gtk_font_button_set_font_name(GTK_FONT_BUTTON(taskbar_name_font), value); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(taskbar_name_font_set), TRUE); - } else if (strcmp(key, "taskbar_name_font_color") == 0) { - extract_values(value, &value1, &value2, &value3); - GdkColor col; - hex2gdk(value1, &col); - gtk_color_button_set_color(GTK_COLOR_BUTTON(taskbar_name_inactive_color), &col); - if (value2) { - int alpha = atoi(value2); - gtk_color_button_set_alpha(GTK_COLOR_BUTTON(taskbar_name_inactive_color), (alpha * 65535) / 100); - } - } else if (strcmp(key, "taskbar_name_active_font_color") == 0) { - extract_values(value, &value1, &value2, &value3); - GdkColor col; - hex2gdk(value1, &col); - gtk_color_button_set_color(GTK_COLOR_BUTTON(taskbar_name_active_color), &col); - if (value2) { - int alpha = atoi(value2); - gtk_color_button_set_alpha(GTK_COLOR_BUTTON(taskbar_name_active_color), (alpha * 65535) / 100); - } - } + /* Taskbar */ + else if (strcmp(key, "taskbar_mode") == 0) { + if (strcmp(value, "multi_desktop") == 0) + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(taskbar_show_desktop), 1); + else + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(taskbar_show_desktop), 0); + } else if (strcmp(key, "taskbar_hide_if_empty") == 0) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(taskbar_hide_empty), atoi(value)); + } else if (strcmp(key, "taskbar_distribute_size") == 0) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(taskbar_distribute_size), atoi(value)); + } else if (strcmp(key, "taskbar_sort_order") == 0) { + if (strcmp(value, "none") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(taskbar_sort_order), 0); + else if (strcmp(value, "title") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(taskbar_sort_order), 1); + else if (strcmp(value, "center") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(taskbar_sort_order), 2); + else if (strcmp(value, "mru") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(taskbar_sort_order), 3); + else if (strcmp(value, "lru") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(taskbar_sort_order), 4); + else + gtk_combo_box_set_active(GTK_COMBO_BOX(taskbar_sort_order), 0); + } else if (strcmp(key, "task_align") == 0) { + if (strcmp(value, "left") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(taskbar_alignment), 0); + else if (strcmp(value, "center") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(taskbar_alignment), 1); + else if (strcmp(value, "right") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(taskbar_alignment), 2); + else + gtk_combo_box_set_active(GTK_COMBO_BOX(taskbar_alignment), 0); + } else if (strcmp(key, "taskbar_padding") == 0) { + extract_values(value, &value1, &value2, &value3); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(taskbar_padding_x), atoi(value1)); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(taskbar_spacing), atoi(value1)); + if (value2) + gtk_spin_button_set_value(GTK_SPIN_BUTTON(taskbar_padding_y), atoi(value2)); + if (value3) + gtk_spin_button_set_value(GTK_SPIN_BUTTON(taskbar_spacing), atoi(value3)); + } else if (strcmp(key, "taskbar_background_id") == 0) { + int id = background_index_safe(atoi(value)); + gtk_combo_box_set_active(GTK_COMBO_BOX(taskbar_inactive_background), id); + if (gtk_combo_box_get_active(GTK_COMBO_BOX(taskbar_active_background)) < 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(taskbar_active_background), id); + } else if (strcmp(key, "taskbar_active_background_id") == 0) { + int id = background_index_safe(atoi(value)); + gtk_combo_box_set_active(GTK_COMBO_BOX(taskbar_active_background), id); + } else if (strcmp(key, "taskbar_name") == 0) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(taskbar_show_name), atoi(value)); + } else if (strcmp(key, "taskbar_hide_inactive_tasks") == 0) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(taskbar_hide_inactive_tasks), atoi(value)); + } else if (strcmp(key, "taskbar_hide_different_monitor") == 0) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(taskbar_hide_diff_monitor), atoi(value)); + } else if (strcmp(key, "taskbar_always_show_all_desktop_tasks") == 0) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(taskbar_always_show_all_desktop_tasks), atoi(value)); + } else if (strcmp(key, "taskbar_name_padding") == 0) { + extract_values(value, &value1, &value2, &value3); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(taskbar_name_padding_x), atoi(value1)); + if (value2) + gtk_spin_button_set_value(GTK_SPIN_BUTTON(taskbar_name_padding_y), atoi(value2)); + } else if (strcmp(key, "taskbar_name_background_id") == 0) { + int id = background_index_safe(atoi(value)); + gtk_combo_box_set_active(GTK_COMBO_BOX(taskbar_name_inactive_background), id); + if (gtk_combo_box_get_active(GTK_COMBO_BOX(taskbar_name_active_background)) < 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(taskbar_name_active_background), id); + } else if (strcmp(key, "taskbar_name_active_background_id") == 0) { + int id = background_index_safe(atoi(value)); + gtk_combo_box_set_active(GTK_COMBO_BOX(taskbar_name_active_background), id); + } else if (strcmp(key, "taskbar_name_font") == 0) { + gtk_font_button_set_font_name(GTK_FONT_BUTTON(taskbar_name_font), value); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(taskbar_name_font_set), TRUE); + } else if (strcmp(key, "taskbar_name_font_color") == 0) { + extract_values(value, &value1, &value2, &value3); + GdkColor col; + hex2gdk(value1, &col); + gtk_color_button_set_color(GTK_COLOR_BUTTON(taskbar_name_inactive_color), &col); + if (value2) { + int alpha = atoi(value2); + gtk_color_button_set_alpha(GTK_COLOR_BUTTON(taskbar_name_inactive_color), (alpha * 65535) / 100); + } + } else if (strcmp(key, "taskbar_name_active_font_color") == 0) { + extract_values(value, &value1, &value2, &value3); + GdkColor col; + hex2gdk(value1, &col); + gtk_color_button_set_color(GTK_COLOR_BUTTON(taskbar_name_active_color), &col); + if (value2) { + int alpha = atoi(value2); + gtk_color_button_set_alpha(GTK_COLOR_BUTTON(taskbar_name_active_color), (alpha * 65535) / 100); + } + } - /* Task */ - else if (strcmp(key, "task_text") == 0) { - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(task_show_text), atoi(value)); - } else if (strcmp(key, "task_icon") == 0) { - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(task_show_icon), atoi(value)); - } else if (strcmp(key, "task_centered") == 0) { - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(task_align_center), atoi(value)); - } else if (strcmp(key, "urgent_nb_of_blink") == 0) { - gtk_spin_button_set_value(GTK_SPIN_BUTTON(task_urgent_blinks), atoi(value)); - } else if (strcmp(key, "task_width") == 0) { - // old parameter : just for backward compatibility - gtk_spin_button_set_value(GTK_SPIN_BUTTON(task_maximum_width), atoi(value)); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(task_maximum_height), 30.0); - } else if (strcmp(key, "task_maximum_size") == 0) { - extract_values(value, &value1, &value2, &value3); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(task_maximum_width), atoi(value1)); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(task_maximum_height), 30.0); - if (value2) - gtk_spin_button_set_value(GTK_SPIN_BUTTON(task_maximum_height), atoi(value2)); - } else if (strcmp(key, "task_padding") == 0) { - extract_values(value, &value1, &value2, &value3); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(task_padding_x), atoi(value1)); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(task_spacing), atoi(value1)); - if (value2) - gtk_spin_button_set_value(GTK_SPIN_BUTTON(task_padding_y), atoi(value2)); - if (value3) - gtk_spin_button_set_value(GTK_SPIN_BUTTON(task_spacing), atoi(value3)); - } else if (strcmp(key, "task_font") == 0) { - gtk_font_button_set_font_name(GTK_FONT_BUTTON(task_font), value); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(task_font_set), TRUE); - } else if (g_regex_match_simple("task.*_font_color", key, 0, 0)) { - gchar **split = g_regex_split_simple("_", key, 0, 0); - GtkWidget *widget = NULL; - if (strcmp(split[1], "normal") == 0) { - widget = task_normal_color; - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(task_normal_color_set), 1); - } else if (strcmp(split[1], "active") == 0) { - widget = task_active_color; - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(task_active_color_set), 1); - } else if (strcmp(split[1], "urgent") == 0) { - widget = task_urgent_color; - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(task_urgent_color_set), 1); - } else if (strcmp(split[1], "iconified") == 0) { - widget = task_iconified_color; - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(task_iconified_color_set), 1); - } else if (strcmp(split[1], "font") == 0) { - widget = task_default_color; - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(task_default_color_set), 1); - } - g_strfreev(split); - if (widget) { - extract_values(value, &value1, &value2, &value3); - GdkColor col; - hex2gdk(value1, &col); - gtk_color_button_set_color(GTK_COLOR_BUTTON(widget), &col); - if (value2) { - int alpha = atoi(value2); - gtk_color_button_set_alpha(GTK_COLOR_BUTTON(widget), (alpha * 65535) / 100); - } - } - } else if (g_regex_match_simple("task.*_icon_asb", key, 0, 0)) { - gchar **split = g_regex_split_simple("_", key, 0, 0); - GtkWidget *widget_opacity = NULL; - GtkWidget *widget_saturation = NULL; - GtkWidget *widget_brightness = NULL; - if (strcmp(split[1], "normal") == 0) { - widget_opacity = task_normal_icon_opacity; - widget_saturation = task_normal_icon_saturation; - widget_brightness = task_normal_icon_brightness; - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(task_normal_icon_osb_set), 1); - } else if (strcmp(split[1], "active") == 0) { - widget_opacity = task_active_icon_opacity; - widget_saturation = task_active_icon_saturation; - widget_brightness = task_active_icon_brightness; - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(task_active_icon_osb_set), 1); - } else if (strcmp(split[1], "urgent") == 0) { - widget_opacity = task_urgent_icon_opacity; - widget_saturation = task_urgent_icon_saturation; - widget_brightness = task_urgent_icon_brightness; - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(task_urgent_icon_osb_set), 1); - } else if (strcmp(split[1], "iconified") == 0) { - widget_opacity = task_iconified_icon_opacity; - widget_saturation = task_iconified_icon_saturation; - widget_brightness = task_iconified_icon_brightness; - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(task_iconified_icon_osb_set), 1); - } else if (strcmp(split[1], "icon") == 0) { - widget_opacity = task_default_icon_opacity; - widget_saturation = task_default_icon_saturation; - widget_brightness = task_default_icon_brightness; - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(task_default_icon_osb_set), 1); - } - g_strfreev(split); - if (widget_opacity && widget_saturation && widget_brightness) { - extract_values(value, &value1, &value2, &value3); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(widget_opacity), atoi(value1)); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(widget_saturation), atoi(value2)); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(widget_brightness), atoi(value3)); - } - } else if (g_regex_match_simple("task.*_background_id", key, 0, 0)) { - gchar **split = g_regex_split_simple("_", key, 0, 0); - GtkWidget *widget = NULL; - if (strcmp(split[1], "normal") == 0) { - widget = task_normal_background; - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(task_normal_background_set), 1); - } else if (strcmp(split[1], "active") == 0) { - widget = task_active_background; - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(task_active_background_set), 1); - } else if (strcmp(split[1], "urgent") == 0) { - widget = task_urgent_background; - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(task_urgent_background_set), 1); - } else if (strcmp(split[1], "iconified") == 0) { - widget = task_iconified_background; - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(task_iconified_background_set), 1); - } else if (strcmp(split[1], "background") == 0) { - widget = task_default_background; - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(task_default_background_set), 1); - } - g_strfreev(split); - if (widget) { - int id = background_index_safe(atoi(value)); - gtk_combo_box_set_active(GTK_COMBO_BOX(widget), id); - } - } - // "tooltip" is deprecated but here for backwards compatibility - else if (strcmp(key, "task_tooltip") == 0 || strcmp(key, "tooltip") == 0) { - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(tooltip_task_show), atoi(value)); - } + /* Task */ + else if (strcmp(key, "task_text") == 0) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(task_show_text), atoi(value)); + } else if (strcmp(key, "task_icon") == 0) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(task_show_icon), atoi(value)); + } else if (strcmp(key, "task_centered") == 0) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(task_align_center), atoi(value)); + } else if (strcmp(key, "urgent_nb_of_blink") == 0) { + gtk_spin_button_set_value(GTK_SPIN_BUTTON(task_urgent_blinks), atoi(value)); + } else if (strcmp(key, "task_width") == 0) { + // old parameter : just for backward compatibility + gtk_spin_button_set_value(GTK_SPIN_BUTTON(task_maximum_width), atoi(value)); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(task_maximum_height), 30.0); + } else if (strcmp(key, "task_maximum_size") == 0) { + extract_values(value, &value1, &value2, &value3); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(task_maximum_width), atoi(value1)); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(task_maximum_height), 30.0); + if (value2) + gtk_spin_button_set_value(GTK_SPIN_BUTTON(task_maximum_height), atoi(value2)); + } else if (strcmp(key, "task_padding") == 0) { + extract_values(value, &value1, &value2, &value3); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(task_padding_x), atoi(value1)); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(task_spacing), atoi(value1)); + if (value2) + gtk_spin_button_set_value(GTK_SPIN_BUTTON(task_padding_y), atoi(value2)); + if (value3) + gtk_spin_button_set_value(GTK_SPIN_BUTTON(task_spacing), atoi(value3)); + } else if (strcmp(key, "task_font") == 0) { + gtk_font_button_set_font_name(GTK_FONT_BUTTON(task_font), value); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(task_font_set), TRUE); + } else if (g_regex_match_simple("task.*_font_color", key, 0, 0)) { + gchar **split = g_regex_split_simple("_", key, 0, 0); + GtkWidget *widget = NULL; + if (strcmp(split[1], "normal") == 0) { + widget = task_normal_color; + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(task_normal_color_set), 1); + } else if (strcmp(split[1], "active") == 0) { + widget = task_active_color; + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(task_active_color_set), 1); + } else if (strcmp(split[1], "urgent") == 0) { + widget = task_urgent_color; + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(task_urgent_color_set), 1); + } else if (strcmp(split[1], "iconified") == 0) { + widget = task_iconified_color; + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(task_iconified_color_set), 1); + } else if (strcmp(split[1], "font") == 0) { + widget = task_default_color; + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(task_default_color_set), 1); + } + g_strfreev(split); + if (widget) { + extract_values(value, &value1, &value2, &value3); + GdkColor col; + hex2gdk(value1, &col); + gtk_color_button_set_color(GTK_COLOR_BUTTON(widget), &col); + if (value2) { + int alpha = atoi(value2); + gtk_color_button_set_alpha(GTK_COLOR_BUTTON(widget), (alpha * 65535) / 100); + } + } + } else if (g_regex_match_simple("task.*_icon_asb", key, 0, 0)) { + gchar **split = g_regex_split_simple("_", key, 0, 0); + GtkWidget *widget_opacity = NULL; + GtkWidget *widget_saturation = NULL; + GtkWidget *widget_brightness = NULL; + if (strcmp(split[1], "normal") == 0) { + widget_opacity = task_normal_icon_opacity; + widget_saturation = task_normal_icon_saturation; + widget_brightness = task_normal_icon_brightness; + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(task_normal_icon_osb_set), 1); + } else if (strcmp(split[1], "active") == 0) { + widget_opacity = task_active_icon_opacity; + widget_saturation = task_active_icon_saturation; + widget_brightness = task_active_icon_brightness; + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(task_active_icon_osb_set), 1); + } else if (strcmp(split[1], "urgent") == 0) { + widget_opacity = task_urgent_icon_opacity; + widget_saturation = task_urgent_icon_saturation; + widget_brightness = task_urgent_icon_brightness; + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(task_urgent_icon_osb_set), 1); + } else if (strcmp(split[1], "iconified") == 0) { + widget_opacity = task_iconified_icon_opacity; + widget_saturation = task_iconified_icon_saturation; + widget_brightness = task_iconified_icon_brightness; + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(task_iconified_icon_osb_set), 1); + } else if (strcmp(split[1], "icon") == 0) { + widget_opacity = task_default_icon_opacity; + widget_saturation = task_default_icon_saturation; + widget_brightness = task_default_icon_brightness; + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(task_default_icon_osb_set), 1); + } + g_strfreev(split); + if (widget_opacity && widget_saturation && widget_brightness) { + extract_values(value, &value1, &value2, &value3); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(widget_opacity), atoi(value1)); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(widget_saturation), atoi(value2)); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(widget_brightness), atoi(value3)); + } + } else if (g_regex_match_simple("task.*_background_id", key, 0, 0)) { + gchar **split = g_regex_split_simple("_", key, 0, 0); + GtkWidget *widget = NULL; + if (strcmp(split[1], "normal") == 0) { + widget = task_normal_background; + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(task_normal_background_set), 1); + } else if (strcmp(split[1], "active") == 0) { + widget = task_active_background; + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(task_active_background_set), 1); + } else if (strcmp(split[1], "urgent") == 0) { + widget = task_urgent_background; + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(task_urgent_background_set), 1); + } else if (strcmp(split[1], "iconified") == 0) { + widget = task_iconified_background; + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(task_iconified_background_set), 1); + } else if (strcmp(split[1], "background") == 0) { + widget = task_default_background; + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(task_default_background_set), 1); + } + g_strfreev(split); + if (widget) { + int id = background_index_safe(atoi(value)); + gtk_combo_box_set_active(GTK_COMBO_BOX(widget), id); + } + } + // "tooltip" is deprecated but here for backwards compatibility + else if (strcmp(key, "task_tooltip") == 0 || strcmp(key, "tooltip") == 0) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(tooltip_task_show), atoi(value)); + } - /* Systray */ - else if (strcmp(key, "systray") == 0) { - // Obsolete option - config_has_systray = 1; - config_systray_enabled = atoi(value); - } else if (strcmp(key, "systray_padding") == 0) { - no_items_systray_enabled = 1; + /* Systray */ + else if (strcmp(key, "systray") == 0) { + // Obsolete option + config_has_systray = 1; + config_systray_enabled = atoi(value); + } else if (strcmp(key, "systray_padding") == 0) { + no_items_systray_enabled = 1; - extract_values(value, &value1, &value2, &value3); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(systray_padding_x), atoi(value1)); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(systray_spacing), atoi(value1)); - if (value2) - gtk_spin_button_set_value(GTK_SPIN_BUTTON(systray_padding_y), atoi(value2)); - if (value3) - gtk_spin_button_set_value(GTK_SPIN_BUTTON(systray_spacing), atoi(value3)); - } else if (strcmp(key, "systray_background_id") == 0) { - int id = background_index_safe(atoi(value)); - gtk_combo_box_set_active(GTK_COMBO_BOX(systray_background), id); - } else if (strcmp(key, "systray_sort") == 0) { - if (strcmp(value, "descending") == 0) - gtk_combo_box_set_active(GTK_COMBO_BOX(systray_icon_order), 1); - else if (strcmp(value, "ascending") == 0) - gtk_combo_box_set_active(GTK_COMBO_BOX(systray_icon_order), 0); - else if (strcmp(value, "right2left") == 0) - gtk_combo_box_set_active(GTK_COMBO_BOX(systray_icon_order), 3); - else // default to left2right - gtk_combo_box_set_active(GTK_COMBO_BOX(systray_icon_order), 2); - } else if (strcmp(key, "systray_icon_size") == 0) { - gtk_spin_button_set_value(GTK_SPIN_BUTTON(systray_icon_size), atoi(value)); - } else if (strcmp(key, "systray_monitor") == 0) { - if (strcmp(value, "1") == 0) - gtk_combo_box_set_active(GTK_COMBO_BOX(systray_monitor), 0); - else if (strcmp(value, "2") == 0) - gtk_combo_box_set_active(GTK_COMBO_BOX(systray_monitor), 1); - else if (strcmp(value, "3") == 0) - gtk_combo_box_set_active(GTK_COMBO_BOX(systray_monitor), 2); - else if (strcmp(value, "4") == 0) - gtk_combo_box_set_active(GTK_COMBO_BOX(systray_monitor), 3); - else if (strcmp(value, "5") == 0) - gtk_combo_box_set_active(GTK_COMBO_BOX(systray_monitor), 4); - else if (strcmp(value, "6") == 0) - gtk_combo_box_set_active(GTK_COMBO_BOX(systray_monitor), 5); - } else if (strcmp(key, "systray_icon_asb") == 0) { - extract_values(value, &value1, &value2, &value3); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(systray_icon_opacity), atoi(value1)); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(systray_icon_saturation), atoi(value2)); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(systray_icon_brightness), atoi(value3)); - } else if (strcmp(key, "systray_name_filter") == 0) { - gtk_entry_set_text(GTK_ENTRY(systray_name_filter), value); - } + extract_values(value, &value1, &value2, &value3); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(systray_padding_x), atoi(value1)); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(systray_spacing), atoi(value1)); + if (value2) + gtk_spin_button_set_value(GTK_SPIN_BUTTON(systray_padding_y), atoi(value2)); + if (value3) + gtk_spin_button_set_value(GTK_SPIN_BUTTON(systray_spacing), atoi(value3)); + } else if (strcmp(key, "systray_background_id") == 0) { + int id = background_index_safe(atoi(value)); + gtk_combo_box_set_active(GTK_COMBO_BOX(systray_background), id); + } else if (strcmp(key, "systray_sort") == 0) { + if (strcmp(value, "descending") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(systray_icon_order), 1); + else if (strcmp(value, "ascending") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(systray_icon_order), 0); + else if (strcmp(value, "right2left") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(systray_icon_order), 3); + else // default to left2right + gtk_combo_box_set_active(GTK_COMBO_BOX(systray_icon_order), 2); + } else if (strcmp(key, "systray_icon_size") == 0) { + gtk_spin_button_set_value(GTK_SPIN_BUTTON(systray_icon_size), atoi(value)); + } else if (strcmp(key, "systray_monitor") == 0) { + if (strcmp(value, "1") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(systray_monitor), 0); + else if (strcmp(value, "2") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(systray_monitor), 1); + else if (strcmp(value, "3") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(systray_monitor), 2); + else if (strcmp(value, "4") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(systray_monitor), 3); + else if (strcmp(value, "5") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(systray_monitor), 4); + else if (strcmp(value, "6") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(systray_monitor), 5); + } else if (strcmp(key, "systray_icon_asb") == 0) { + extract_values(value, &value1, &value2, &value3); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(systray_icon_opacity), atoi(value1)); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(systray_icon_saturation), atoi(value2)); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(systray_icon_brightness), atoi(value3)); + } else if (strcmp(key, "systray_name_filter") == 0) { + gtk_entry_set_text(GTK_ENTRY(systray_name_filter), value); + } - /* Launcher */ - else if (strcmp(key, "launcher_padding") == 0) { - extract_values(value, &value1, &value2, &value3); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(launcher_padding_x), atoi(value1)); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(launcher_spacing), atoi(value1)); - if (value2) - gtk_spin_button_set_value(GTK_SPIN_BUTTON(launcher_padding_y), atoi(value2)); - if (value3) - gtk_spin_button_set_value(GTK_SPIN_BUTTON(launcher_spacing), atoi(value3)); - } else if (strcmp(key, "launcher_background_id") == 0) { - int id = background_index_safe(atoi(value)); - gtk_combo_box_set_active(GTK_COMBO_BOX(launcher_background), id); - } else if (strcmp(key, "launcher_icon_background_id") == 0) { - int id = background_index_safe(atoi(value)); - gtk_combo_box_set_active(GTK_COMBO_BOX(launcher_icon_background), id); - } else if (strcmp(key, "launcher_icon_size") == 0) { - gtk_spin_button_set_value(GTK_SPIN_BUTTON(launcher_icon_size), atoi(value)); - } else if (strcmp(key, "launcher_item_app") == 0) { - char *path = expand_tilde(value); - load_desktop_file(path, TRUE); - load_desktop_file(path, FALSE); - free(path); - } else if (strcmp(key, "launcher_apps_dir") == 0) { - char *path = expand_tilde(value); + /* Launcher */ + else if (strcmp(key, "launcher_padding") == 0) { + extract_values(value, &value1, &value2, &value3); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(launcher_padding_x), atoi(value1)); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(launcher_spacing), atoi(value1)); + if (value2) + gtk_spin_button_set_value(GTK_SPIN_BUTTON(launcher_padding_y), atoi(value2)); + if (value3) + gtk_spin_button_set_value(GTK_SPIN_BUTTON(launcher_spacing), atoi(value3)); + } else if (strcmp(key, "launcher_background_id") == 0) { + int id = background_index_safe(atoi(value)); + gtk_combo_box_set_active(GTK_COMBO_BOX(launcher_background), id); + } else if (strcmp(key, "launcher_icon_background_id") == 0) { + int id = background_index_safe(atoi(value)); + gtk_combo_box_set_active(GTK_COMBO_BOX(launcher_icon_background), id); + } else if (strcmp(key, "launcher_icon_size") == 0) { + gtk_spin_button_set_value(GTK_SPIN_BUTTON(launcher_icon_size), atoi(value)); + } else if (strcmp(key, "launcher_item_app") == 0) { + char *path = expand_tilde(value); + load_desktop_file(path, TRUE); + load_desktop_file(path, FALSE); + free(path); + } else if (strcmp(key, "launcher_apps_dir") == 0) { + char *path = expand_tilde(value); - if (gtk_entry_get_text_length(GTK_ENTRY(launcher_apps_dirs)) > 0) { - gtk_entry_append_text(GTK_ENTRY(launcher_apps_dirs), ","); - } - gtk_entry_append_text(GTK_ENTRY(launcher_apps_dirs), path); + if (gtk_entry_get_text_length(GTK_ENTRY(launcher_apps_dirs)) > 0) { + gtk_entry_append_text(GTK_ENTRY(launcher_apps_dirs), ","); + } + gtk_entry_append_text(GTK_ENTRY(launcher_apps_dirs), path); - free(path); - } else if (strcmp(key, "launcher_icon_theme") == 0) { - set_current_icon_theme(value); - } else if (strcmp(key, "launcher_icon_theme_override") == 0) { - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(launcher_icon_theme_override), atoi(value)); - } else if (strcmp(key, "launcher_tooltip") == 0) { - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(launcher_tooltip), atoi(value)); - } else if (strcmp(key, "startup_notifications") == 0) { - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(startup_notifications), atoi(value)); - } else if (strcmp(key, "launcher_icon_asb") == 0) { - extract_values(value, &value1, &value2, &value3); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(launcher_icon_opacity), atoi(value1)); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(launcher_icon_saturation), atoi(value2)); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(launcher_icon_brightness), atoi(value3)); - } + free(path); + } else if (strcmp(key, "launcher_icon_theme") == 0) { + set_current_icon_theme(value); + } else if (strcmp(key, "launcher_icon_theme_override") == 0) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(launcher_icon_theme_override), atoi(value)); + } else if (strcmp(key, "launcher_tooltip") == 0) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(launcher_tooltip), atoi(value)); + } else if (strcmp(key, "startup_notifications") == 0) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(startup_notifications), atoi(value)); + } else if (strcmp(key, "launcher_icon_asb") == 0) { + extract_values(value, &value1, &value2, &value3); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(launcher_icon_opacity), atoi(value1)); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(launcher_icon_saturation), atoi(value2)); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(launcher_icon_brightness), atoi(value3)); + } - /* Tooltip */ - else if (strcmp(key, "tooltip_show_timeout") == 0) { - gtk_spin_button_set_value(GTK_SPIN_BUTTON(tooltip_show_after), atof(value)); - } else if (strcmp(key, "tooltip_hide_timeout") == 0) { - gtk_spin_button_set_value(GTK_SPIN_BUTTON(tooltip_hide_after), atof(value)); - } else if (strcmp(key, "tooltip_padding") == 0) { - extract_values(value, &value1, &value2, &value3); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(tooltip_padding_x), atoi(value1)); - if (value2) - gtk_spin_button_set_value(GTK_SPIN_BUTTON(tooltip_padding_y), atoi(value2)); - } else if (strcmp(key, "tooltip_background_id") == 0) { - int id = background_index_safe(atoi(value)); - gtk_combo_box_set_active(GTK_COMBO_BOX(tooltip_background), id); - } else if (strcmp(key, "tooltip_font_color") == 0) { - extract_values(value, &value1, &value2, &value3); - GdkColor col; - hex2gdk(value1, &col); - gtk_color_button_set_color(GTK_COLOR_BUTTON(tooltip_font_color), &col); - if (value2) { - int alpha = atoi(value2); - gtk_color_button_set_alpha(GTK_COLOR_BUTTON(tooltip_font_color), (alpha * 65535) / 100); - } - } else if (strcmp(key, "tooltip_font") == 0) { - gtk_font_button_set_font_name(GTK_FONT_BUTTON(tooltip_font), value); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(tooltip_font_set), TRUE); - } + /* Tooltip */ + else if (strcmp(key, "tooltip_show_timeout") == 0) { + gtk_spin_button_set_value(GTK_SPIN_BUTTON(tooltip_show_after), atof(value)); + } else if (strcmp(key, "tooltip_hide_timeout") == 0) { + gtk_spin_button_set_value(GTK_SPIN_BUTTON(tooltip_hide_after), atof(value)); + } else if (strcmp(key, "tooltip_padding") == 0) { + extract_values(value, &value1, &value2, &value3); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(tooltip_padding_x), atoi(value1)); + if (value2) + gtk_spin_button_set_value(GTK_SPIN_BUTTON(tooltip_padding_y), atoi(value2)); + } else if (strcmp(key, "tooltip_background_id") == 0) { + int id = background_index_safe(atoi(value)); + gtk_combo_box_set_active(GTK_COMBO_BOX(tooltip_background), id); + } else if (strcmp(key, "tooltip_font_color") == 0) { + extract_values(value, &value1, &value2, &value3); + GdkColor col; + hex2gdk(value1, &col); + gtk_color_button_set_color(GTK_COLOR_BUTTON(tooltip_font_color), &col); + if (value2) { + int alpha = atoi(value2); + gtk_color_button_set_alpha(GTK_COLOR_BUTTON(tooltip_font_color), (alpha * 65535) / 100); + } + } else if (strcmp(key, "tooltip_font") == 0) { + gtk_font_button_set_font_name(GTK_FONT_BUTTON(tooltip_font), value); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(tooltip_font_set), TRUE); + } - /* Mouse actions */ - else if (strcmp(key, "mouse_left") == 0) { - set_action(value, task_mouse_left); - } else if (strcmp(key, "mouse_middle") == 0) { - set_action(value, task_mouse_middle); - } else if (strcmp(key, "mouse_right") == 0) { - set_action(value, task_mouse_right); - } else if (strcmp(key, "mouse_scroll_up") == 0) { - set_action(value, task_mouse_scroll_up); - } else if (strcmp(key, "mouse_scroll_down") == 0) { - set_action(value, task_mouse_scroll_down); - } + /* Mouse actions */ + else if (strcmp(key, "mouse_left") == 0) { + set_action(value, task_mouse_left); + } else if (strcmp(key, "mouse_middle") == 0) { + set_action(value, task_mouse_middle); + } else if (strcmp(key, "mouse_right") == 0) { + set_action(value, task_mouse_right); + } else if (strcmp(key, "mouse_scroll_up") == 0) { + set_action(value, task_mouse_scroll_up); + } else if (strcmp(key, "mouse_scroll_down") == 0) { + set_action(value, task_mouse_scroll_down); + } - /* Separator */ - else if (strcmp(key, "separator") == 0) { - separator_create_new(); - } else if (strcmp(key, "separator_background_id") == 0) { - int id = background_index_safe(atoi(value)); - gtk_combo_box_set_active(GTK_COMBO_BOX(separator_get_last()->separator_background), id); - } else if (strcmp(key, "separator_color") == 0) { - extract_values(value, &value1, &value2, &value3); - GdkColor col; - hex2gdk(value1, &col); - gtk_color_button_set_color(GTK_COLOR_BUTTON(separator_get_last()->separator_color), &col); - if (value2) { - int alpha = atoi(value2); - gtk_color_button_set_alpha(GTK_COLOR_BUTTON(separator_get_last()->separator_color), (alpha * 65535) / 100); - } - } else if (strcmp(key, "separator_style") == 0) { - if (g_str_equal(value, "empty")) - gtk_combo_box_set_active(GTK_COMBO_BOX(separator_get_last()->separator_style), 0); - else if (g_str_equal(value, "line")) - gtk_combo_box_set_active(GTK_COMBO_BOX(separator_get_last()->separator_style), 1); - else if (g_str_equal(value, "dots")) - gtk_combo_box_set_active(GTK_COMBO_BOX(separator_get_last()->separator_style), 2); - } else if (strcmp(key, "separator_size") == 0) { - gtk_spin_button_set_value(GTK_SPIN_BUTTON(separator_get_last()->separator_size), atoi(value)); - } else if (strcmp(key, "separator_padding") == 0) { - extract_values(value, &value1, &value2, &value3); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(separator_get_last()->separator_padding_x), atoi(value1)); - if (value2) - gtk_spin_button_set_value(GTK_SPIN_BUTTON(separator_get_last()->separator_padding_y), atoi(value2)); - } + /* Separator */ + else if (strcmp(key, "separator") == 0) { + separator_create_new(); + } else if (strcmp(key, "separator_background_id") == 0) { + int id = background_index_safe(atoi(value)); + gtk_combo_box_set_active(GTK_COMBO_BOX(separator_get_last()->separator_background), id); + } else if (strcmp(key, "separator_color") == 0) { + extract_values(value, &value1, &value2, &value3); + GdkColor col; + hex2gdk(value1, &col); + gtk_color_button_set_color(GTK_COLOR_BUTTON(separator_get_last()->separator_color), &col); + if (value2) { + int alpha = atoi(value2); + gtk_color_button_set_alpha(GTK_COLOR_BUTTON(separator_get_last()->separator_color), (alpha * 65535) / 100); + } + } else if (strcmp(key, "separator_style") == 0) { + if (g_str_equal(value, "empty")) + gtk_combo_box_set_active(GTK_COMBO_BOX(separator_get_last()->separator_style), 0); + else if (g_str_equal(value, "line")) + gtk_combo_box_set_active(GTK_COMBO_BOX(separator_get_last()->separator_style), 1); + else if (g_str_equal(value, "dots")) + gtk_combo_box_set_active(GTK_COMBO_BOX(separator_get_last()->separator_style), 2); + } else if (strcmp(key, "separator_size") == 0) { + gtk_spin_button_set_value(GTK_SPIN_BUTTON(separator_get_last()->separator_size), atoi(value)); + } else if (strcmp(key, "separator_padding") == 0) { + extract_values(value, &value1, &value2, &value3); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(separator_get_last()->separator_padding_x), atoi(value1)); + if (value2) + gtk_spin_button_set_value(GTK_SPIN_BUTTON(separator_get_last()->separator_padding_y), atoi(value2)); + } - /* Executor */ - else if (strcmp(key, "execp") == 0) { - execp_create_new(); - } else if (strcmp(key, "execp_command") == 0) { - gtk_entry_set_text(GTK_ENTRY(execp_get_last()->execp_command), value); - } else if (strcmp(key, "execp_interval") == 0) { - gtk_spin_button_set_value(GTK_SPIN_BUTTON(execp_get_last()->execp_interval), atoi(value)); - } else if (strcmp(key, "execp_has_icon") == 0) { - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(execp_get_last()->execp_has_icon), atoi(value)); - } else if (strcmp(key, "execp_cache_icon") == 0) { - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(execp_get_last()->execp_cache_icon), atoi(value)); - } else if (strcmp(key, "execp_continuous") == 0) { - gtk_spin_button_set_value(GTK_SPIN_BUTTON(execp_get_last()->execp_continuous), atoi(value)); - } else if (strcmp(key, "execp_markup") == 0) { - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(execp_get_last()->execp_markup), atoi(value)); - } else if (strcmp(key, "execp_tooltip") == 0) { - if (strlen(value) > 0) { - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(execp_get_last()->execp_show_tooltip), 1); - } else { - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(execp_get_last()->execp_show_tooltip), 0); - } - gtk_entry_set_text(GTK_ENTRY(execp_get_last()->execp_tooltip), value); - } else if (strcmp(key, "execp_lclick_command") == 0) { - gtk_entry_set_text(GTK_ENTRY(execp_get_last()->execp_left_command), value); - } else if (strcmp(key, "execp_rclick_command") == 0) { - gtk_entry_set_text(GTK_ENTRY(execp_get_last()->execp_right_command), value); - } else if (strcmp(key, "execp_mclick_command") == 0) { - gtk_entry_set_text(GTK_ENTRY(execp_get_last()->execp_mclick_command), value); - } else if (strcmp(key, "execp_uwheel_command") == 0) { - gtk_entry_set_text(GTK_ENTRY(execp_get_last()->execp_uwheel_command), value); - } else if (strcmp(key, "execp_dwheel_command") == 0) { - gtk_entry_set_text(GTK_ENTRY(execp_get_last()->execp_dwheel_command), value); - } else if (strcmp(key, "execp_font") == 0) { - gtk_font_button_set_font_name(GTK_FONT_BUTTON(execp_get_last()->execp_font), value); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(execp_get_last()->execp_font_set), TRUE); - } else if (strcmp(key, "execp_font_color") == 0) { - extract_values(value, &value1, &value2, &value3); - GdkColor col; - hex2gdk(value1, &col); - gtk_color_button_set_color(GTK_COLOR_BUTTON(execp_get_last()->execp_font_color), &col); - if (value2) { - int alpha = atoi(value2); - gtk_color_button_set_alpha(GTK_COLOR_BUTTON(execp_get_last()->execp_font_color), (alpha * 65535) / 100); - } - } else if (strcmp(key, "execp_padding") == 0) { - extract_values(value, &value1, &value2, &value3); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(execp_get_last()->execp_padding_x), atoi(value1)); - if (value2) - gtk_spin_button_set_value(GTK_SPIN_BUTTON(execp_get_last()->execp_padding_y), atoi(value2)); - } else if (strcmp(key, "execp_background_id") == 0) { - int id = background_index_safe(atoi(value)); - gtk_combo_box_set_active(GTK_COMBO_BOX(execp_get_last()->execp_background), id); - } else if (strcmp(key, "execp_icon_w") == 0) { - gtk_spin_button_set_value(GTK_SPIN_BUTTON(execp_get_last()->execp_icon_w), atoi(value)); - } else if (strcmp(key, "execp_icon_h") == 0) { - gtk_spin_button_set_value(GTK_SPIN_BUTTON(execp_get_last()->execp_icon_h), atoi(value)); - } else if (strcmp(key, "execp_centered") == 0) { - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(execp_get_last()->execp_centered), atoi(value)); - } + /* Executor */ + else if (strcmp(key, "execp") == 0) { + execp_create_new(); + } else if (strcmp(key, "execp_command") == 0) { + gtk_entry_set_text(GTK_ENTRY(execp_get_last()->execp_command), value); + } else if (strcmp(key, "execp_interval") == 0) { + gtk_spin_button_set_value(GTK_SPIN_BUTTON(execp_get_last()->execp_interval), atoi(value)); + } else if (strcmp(key, "execp_has_icon") == 0) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(execp_get_last()->execp_has_icon), atoi(value)); + } else if (strcmp(key, "execp_cache_icon") == 0) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(execp_get_last()->execp_cache_icon), atoi(value)); + } else if (strcmp(key, "execp_continuous") == 0) { + gtk_spin_button_set_value(GTK_SPIN_BUTTON(execp_get_last()->execp_continuous), atoi(value)); + } else if (strcmp(key, "execp_markup") == 0) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(execp_get_last()->execp_markup), atoi(value)); + } else if (strcmp(key, "execp_tooltip") == 0) { + if (strlen(value) > 0) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(execp_get_last()->execp_show_tooltip), 1); + } else { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(execp_get_last()->execp_show_tooltip), 0); + } + gtk_entry_set_text(GTK_ENTRY(execp_get_last()->execp_tooltip), value); + } else if (strcmp(key, "execp_lclick_command") == 0) { + gtk_entry_set_text(GTK_ENTRY(execp_get_last()->execp_left_command), value); + } else if (strcmp(key, "execp_rclick_command") == 0) { + gtk_entry_set_text(GTK_ENTRY(execp_get_last()->execp_right_command), value); + } else if (strcmp(key, "execp_mclick_command") == 0) { + gtk_entry_set_text(GTK_ENTRY(execp_get_last()->execp_mclick_command), value); + } else if (strcmp(key, "execp_uwheel_command") == 0) { + gtk_entry_set_text(GTK_ENTRY(execp_get_last()->execp_uwheel_command), value); + } else if (strcmp(key, "execp_dwheel_command") == 0) { + gtk_entry_set_text(GTK_ENTRY(execp_get_last()->execp_dwheel_command), value); + } else if (strcmp(key, "execp_font") == 0) { + gtk_font_button_set_font_name(GTK_FONT_BUTTON(execp_get_last()->execp_font), value); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(execp_get_last()->execp_font_set), TRUE); + } else if (strcmp(key, "execp_font_color") == 0) { + extract_values(value, &value1, &value2, &value3); + GdkColor col; + hex2gdk(value1, &col); + gtk_color_button_set_color(GTK_COLOR_BUTTON(execp_get_last()->execp_font_color), &col); + if (value2) { + int alpha = atoi(value2); + gtk_color_button_set_alpha(GTK_COLOR_BUTTON(execp_get_last()->execp_font_color), (alpha * 65535) / 100); + } + } else if (strcmp(key, "execp_padding") == 0) { + extract_values(value, &value1, &value2, &value3); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(execp_get_last()->execp_padding_x), atoi(value1)); + if (value2) + gtk_spin_button_set_value(GTK_SPIN_BUTTON(execp_get_last()->execp_padding_y), atoi(value2)); + } else if (strcmp(key, "execp_background_id") == 0) { + int id = background_index_safe(atoi(value)); + gtk_combo_box_set_active(GTK_COMBO_BOX(execp_get_last()->execp_background), id); + } else if (strcmp(key, "execp_icon_w") == 0) { + gtk_spin_button_set_value(GTK_SPIN_BUTTON(execp_get_last()->execp_icon_w), atoi(value)); + } else if (strcmp(key, "execp_icon_h") == 0) { + gtk_spin_button_set_value(GTK_SPIN_BUTTON(execp_get_last()->execp_icon_h), atoi(value)); + } else if (strcmp(key, "execp_centered") == 0) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(execp_get_last()->execp_centered), atoi(value)); + } - /* Button */ - else if (strcmp(key, "button") == 0) { - button_create_new(); - } else if (strcmp(key, "button_icon") == 0) { - gtk_entry_set_text(GTK_ENTRY(button_get_last()->button_icon), value); - } else if (strcmp(key, "button_text") == 0) { - gtk_entry_set_text(GTK_ENTRY(button_get_last()->button_text), value); - } else if (strcmp(key, "button_tooltip") == 0) { - gtk_entry_set_text(GTK_ENTRY(button_get_last()->button_tooltip), value); - } else if (strcmp(key, "button_lclick_command") == 0) { - gtk_entry_set_text(GTK_ENTRY(button_get_last()->button_left_command), value); - } else if (strcmp(key, "button_rclick_command") == 0) { - gtk_entry_set_text(GTK_ENTRY(button_get_last()->button_right_command), value); - } else if (strcmp(key, "button_mclick_command") == 0) { - gtk_entry_set_text(GTK_ENTRY(button_get_last()->button_mclick_command), value); - } else if (strcmp(key, "button_uwheel_command") == 0) { - gtk_entry_set_text(GTK_ENTRY(button_get_last()->button_uwheel_command), value); - } else if (strcmp(key, "button_dwheel_command") == 0) { - gtk_entry_set_text(GTK_ENTRY(button_get_last()->button_dwheel_command), value); - } else if (strcmp(key, "button_font") == 0) { - gtk_font_button_set_font_name(GTK_FONT_BUTTON(button_get_last()->button_font), value); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button_get_last()->button_font_set), TRUE); - } else if (strcmp(key, "button_font_color") == 0) { - extract_values(value, &value1, &value2, &value3); - GdkColor col; - hex2gdk(value1, &col); - gtk_color_button_set_color(GTK_COLOR_BUTTON(button_get_last()->button_font_color), &col); - if (value2) { - int alpha = atoi(value2); - gtk_color_button_set_alpha(GTK_COLOR_BUTTON(button_get_last()->button_font_color), (alpha * 65535) / 100); - } - } else if (strcmp(key, "button_padding") == 0) { - extract_values(value, &value1, &value2, &value3); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(button_get_last()->button_padding_x), atoi(value1)); - if (value2) - gtk_spin_button_set_value(GTK_SPIN_BUTTON(button_get_last()->button_padding_y), atoi(value2)); - } else if (strcmp(key, "button_background_id") == 0) { - int id = background_index_safe(atoi(value)); - gtk_combo_box_set_active(GTK_COMBO_BOX(button_get_last()->button_background), id); - } else if (strcmp(key, "button_centered") == 0) { - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button_get_last()->button_centered), atoi(value)); - } else if (strcmp(key, "button_max_icon_size") == 0) { - gtk_spin_button_set_value(GTK_SPIN_BUTTON(button_get_last()->button_max_icon_size), atoi(value)); - } + /* Button */ + else if (strcmp(key, "button") == 0) { + button_create_new(); + } else if (strcmp(key, "button_icon") == 0) { + gtk_entry_set_text(GTK_ENTRY(button_get_last()->button_icon), value); + } else if (strcmp(key, "button_text") == 0) { + gtk_entry_set_text(GTK_ENTRY(button_get_last()->button_text), value); + } else if (strcmp(key, "button_tooltip") == 0) { + gtk_entry_set_text(GTK_ENTRY(button_get_last()->button_tooltip), value); + } else if (strcmp(key, "button_lclick_command") == 0) { + gtk_entry_set_text(GTK_ENTRY(button_get_last()->button_left_command), value); + } else if (strcmp(key, "button_rclick_command") == 0) { + gtk_entry_set_text(GTK_ENTRY(button_get_last()->button_right_command), value); + } else if (strcmp(key, "button_mclick_command") == 0) { + gtk_entry_set_text(GTK_ENTRY(button_get_last()->button_mclick_command), value); + } else if (strcmp(key, "button_uwheel_command") == 0) { + gtk_entry_set_text(GTK_ENTRY(button_get_last()->button_uwheel_command), value); + } else if (strcmp(key, "button_dwheel_command") == 0) { + gtk_entry_set_text(GTK_ENTRY(button_get_last()->button_dwheel_command), value); + } else if (strcmp(key, "button_font") == 0) { + gtk_font_button_set_font_name(GTK_FONT_BUTTON(button_get_last()->button_font), value); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button_get_last()->button_font_set), TRUE); + } else if (strcmp(key, "button_font_color") == 0) { + extract_values(value, &value1, &value2, &value3); + GdkColor col; + hex2gdk(value1, &col); + gtk_color_button_set_color(GTK_COLOR_BUTTON(button_get_last()->button_font_color), &col); + if (value2) { + int alpha = atoi(value2); + gtk_color_button_set_alpha(GTK_COLOR_BUTTON(button_get_last()->button_font_color), (alpha * 65535) / 100); + } + } else if (strcmp(key, "button_padding") == 0) { + extract_values(value, &value1, &value2, &value3); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(button_get_last()->button_padding_x), atoi(value1)); + if (value2) + gtk_spin_button_set_value(GTK_SPIN_BUTTON(button_get_last()->button_padding_y), atoi(value2)); + } else if (strcmp(key, "button_background_id") == 0) { + int id = background_index_safe(atoi(value)); + gtk_combo_box_set_active(GTK_COMBO_BOX(button_get_last()->button_background), id); + } else if (strcmp(key, "button_centered") == 0) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button_get_last()->button_centered), atoi(value)); + } else if (strcmp(key, "button_max_icon_size") == 0) { + gtk_spin_button_set_value(GTK_SPIN_BUTTON(button_get_last()->button_max_icon_size), atoi(value)); + } - if (value1) - free(value1); - if (value2) - free(value2); - if (value3) - free(value3); + if (value1) + free(value1); + if (value2) + free(value2); + if (value3) + free(value3); } void hex2gdk(char *hex, GdkColor *color) { - if (hex == NULL || hex[0] != '#') - return; + if (hex == NULL || hex[0] != '#') + return; - color->red = 257 * (hex_char_to_int(hex[1]) * 16 + hex_char_to_int(hex[2])); - color->green = 257 * (hex_char_to_int(hex[3]) * 16 + hex_char_to_int(hex[4])); - color->blue = 257 * (hex_char_to_int(hex[5]) * 16 + hex_char_to_int(hex[6])); - color->pixel = 0; + color->red = 257 * (hex_char_to_int(hex[1]) * 16 + hex_char_to_int(hex[2])); + color->green = 257 * (hex_char_to_int(hex[3]) * 16 + hex_char_to_int(hex[4])); + color->blue = 257 * (hex_char_to_int(hex[5]) * 16 + hex_char_to_int(hex[6])); + color->pixel = 0; } void set_action(char *event, GtkWidget *combo) { - if (strcmp(event, "none") == 0) - gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0); - else if (strcmp(event, "close") == 0) - gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 1); - else if (strcmp(event, "toggle") == 0) - gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 2); - else if (strcmp(event, "iconify") == 0) - gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 3); - else if (strcmp(event, "shade") == 0) - gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 4); - else if (strcmp(event, "toggle_iconify") == 0) - gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 5); - else if (strcmp(event, "maximize_restore") == 0) - gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 6); - else if (strcmp(event, "desktop_left") == 0) - gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 7); - else if (strcmp(event, "desktop_right") == 0) - gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 8); - else if (strcmp(event, "next_task") == 0) - gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 9); - else if (strcmp(event, "prev_task") == 0) - gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 10); + if (strcmp(event, "none") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0); + else if (strcmp(event, "close") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 1); + else if (strcmp(event, "toggle") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 2); + else if (strcmp(event, "iconify") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 3); + else if (strcmp(event, "shade") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 4); + else if (strcmp(event, "toggle_iconify") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 5); + else if (strcmp(event, "maximize_restore") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 6); + else if (strcmp(event, "desktop_left") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 7); + else if (strcmp(event, "desktop_right") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 8); + else if (strcmp(event, "next_task") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 9); + else if (strcmp(event, "prev_task") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 10); } char *get_action(GtkWidget *combo) { - if (gtk_combo_box_get_active(GTK_COMBO_BOX(combo)) == 0) - return "none"; - if (gtk_combo_box_get_active(GTK_COMBO_BOX(combo)) == 1) - return "close"; - if (gtk_combo_box_get_active(GTK_COMBO_BOX(combo)) == 2) - return "toggle"; - if (gtk_combo_box_get_active(GTK_COMBO_BOX(combo)) == 3) - return "iconify"; - if (gtk_combo_box_get_active(GTK_COMBO_BOX(combo)) == 4) - return "shade"; - if (gtk_combo_box_get_active(GTK_COMBO_BOX(combo)) == 5) - return "toggle_iconify"; - if (gtk_combo_box_get_active(GTK_COMBO_BOX(combo)) == 6) - return "maximize_restore"; - if (gtk_combo_box_get_active(GTK_COMBO_BOX(combo)) == 7) - return "desktop_left"; - if (gtk_combo_box_get_active(GTK_COMBO_BOX(combo)) == 8) - return "desktop_right"; - if (gtk_combo_box_get_active(GTK_COMBO_BOX(combo)) == 9) - return "next_task"; - if (gtk_combo_box_get_active(GTK_COMBO_BOX(combo)) == 10) - return "prev_task"; - return "none"; + if (gtk_combo_box_get_active(GTK_COMBO_BOX(combo)) == 0) + return "none"; + if (gtk_combo_box_get_active(GTK_COMBO_BOX(combo)) == 1) + return "close"; + if (gtk_combo_box_get_active(GTK_COMBO_BOX(combo)) == 2) + return "toggle"; + if (gtk_combo_box_get_active(GTK_COMBO_BOX(combo)) == 3) + return "iconify"; + if (gtk_combo_box_get_active(GTK_COMBO_BOX(combo)) == 4) + return "shade"; + if (gtk_combo_box_get_active(GTK_COMBO_BOX(combo)) == 5) + return "toggle_iconify"; + if (gtk_combo_box_get_active(GTK_COMBO_BOX(combo)) == 6) + return "maximize_restore"; + if (gtk_combo_box_get_active(GTK_COMBO_BOX(combo)) == 7) + return "desktop_left"; + if (gtk_combo_box_get_active(GTK_COMBO_BOX(combo)) == 8) + return "desktop_right"; + if (gtk_combo_box_get_active(GTK_COMBO_BOX(combo)) == 9) + return "next_task"; + if (gtk_combo_box_get_active(GTK_COMBO_BOX(combo)) == 10) + return "prev_task"; + return "none"; }
M src/tint2conf/properties_rw.hsrc/tint2conf/properties_rw.h

@@ -5,7 +5,7 @@ #include <gtk/gtk.h>

char *get_current_theme_path(); gboolean config_is_manual(const char *path); -void config_read_file (const char *path); +void config_read_file(const char *path); void config_save_file(const char *path); #endif
M src/tint2conf/theme_view.csrc/tint2conf/theme_view.c

@@ -34,203 +34,216 @@ gint theme_name_compare(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer user_data);

GtkWidget *create_view() { - GtkTreeViewColumn *col; - GtkCellRenderer *renderer; + GtkTreeViewColumn *col; + GtkCellRenderer *renderer; - theme_list_store = - gtk_list_store_new(NB_COL, G_TYPE_STRING, G_TYPE_STRING, GDK_TYPE_PIXBUF, G_TYPE_INT, G_TYPE_INT, G_TYPE_BOOLEAN); + theme_list_store = gtk_list_store_new(NB_COL, + G_TYPE_STRING, + G_TYPE_STRING, + GDK_TYPE_PIXBUF, + G_TYPE_INT, + G_TYPE_INT, + G_TYPE_BOOLEAN); - GtkWidget *view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(theme_list_store)); - gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(view), TRUE); - gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(view), FALSE); + GtkWidget *view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(theme_list_store)); + gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(view), TRUE); + gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(view), FALSE); - g_object_unref(theme_list_store); // destroy store automatically with view + g_object_unref(theme_list_store); // destroy store automatically with view - renderer = gtk_cell_renderer_text_new(); - col = gtk_tree_view_column_new(); - gtk_tree_view_column_pack_start(col, renderer, TRUE); - gtk_tree_view_column_add_attribute(col, renderer, "text", COL_THEME_FILE); - gtk_tree_view_column_set_visible(col, FALSE); - gtk_tree_view_append_column(GTK_TREE_VIEW(view), col); + renderer = gtk_cell_renderer_text_new(); + col = gtk_tree_view_column_new(); + gtk_tree_view_column_pack_start(col, renderer, TRUE); + gtk_tree_view_column_add_attribute(col, renderer, "text", COL_THEME_FILE); + gtk_tree_view_column_set_visible(col, FALSE); + gtk_tree_view_append_column(GTK_TREE_VIEW(view), col); - renderer = gtk_cell_renderer_text_new(); - col = gtk_tree_view_column_new(); - gtk_tree_view_column_pack_start(col, renderer, TRUE); - gtk_tree_view_column_add_attribute(col, renderer, "text", COL_THEME_NAME); - gtk_tree_view_append_column(GTK_TREE_VIEW(view), col); + renderer = gtk_cell_renderer_text_new(); + col = gtk_tree_view_column_new(); + gtk_tree_view_column_pack_start(col, renderer, TRUE); + gtk_tree_view_column_add_attribute(col, renderer, "text", COL_THEME_NAME); + gtk_tree_view_append_column(GTK_TREE_VIEW(view), col); - g_renderer = gtk_cell_renderer_pixbuf_new(); - g_object_set(g_renderer, "xalign", 0.0, NULL); - gtk_cell_renderer_set_fixed_size(g_renderer, 200, 30); - col = gtk_tree_view_column_new(); - gtk_tree_view_column_pack_start(col, g_renderer, TRUE); - gtk_tree_view_column_add_attribute(col, g_renderer, "pixbuf", COL_SNAPSHOT); - gtk_tree_view_column_add_attribute(col, g_renderer, "width", COL_WIDTH); - gtk_tree_view_column_add_attribute(col, g_renderer, "height", COL_HEIGHT); - gtk_tree_view_append_column(GTK_TREE_VIEW(view), col); + g_renderer = gtk_cell_renderer_pixbuf_new(); + g_object_set(g_renderer, "xalign", 0.0, NULL); + gtk_cell_renderer_set_fixed_size(g_renderer, 200, 30); + col = gtk_tree_view_column_new(); + gtk_tree_view_column_pack_start(col, g_renderer, TRUE); + gtk_tree_view_column_add_attribute(col, g_renderer, "pixbuf", COL_SNAPSHOT); + gtk_tree_view_column_add_attribute(col, g_renderer, "width", COL_WIDTH); + gtk_tree_view_column_add_attribute(col, g_renderer, "height", COL_HEIGHT); + gtk_tree_view_append_column(GTK_TREE_VIEW(view), col); - GtkTreeSortable *sortable = GTK_TREE_SORTABLE(theme_list_store); - gtk_tree_sortable_set_sort_column_id(sortable, COL_THEME_FILE, GTK_SORT_ASCENDING); - gtk_tree_sortable_set_sort_func(sortable, COL_THEME_FILE, theme_name_compare, NULL, NULL); - return view; + GtkTreeSortable *sortable = GTK_TREE_SORTABLE(theme_list_store); + gtk_tree_sortable_set_sort_column_id(sortable, COL_THEME_FILE, GTK_SORT_ASCENDING); + gtk_tree_sortable_set_sort_func(sortable, COL_THEME_FILE, theme_name_compare, NULL, NULL); + return view; } gint theme_name_compare(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer user_data) { - gchar *path_a, *path_b; - gtk_tree_model_get(model, a, COL_THEME_FILE, &path_a, -1); - gtk_tree_model_get(model, b, COL_THEME_FILE, &path_b, -1); + gchar *path_a, *path_b; + gtk_tree_model_get(model, a, COL_THEME_FILE, &path_a, -1); + gtk_tree_model_get(model, b, COL_THEME_FILE, &path_b, -1); - gboolean home_a = strstr(path_a, g_get_user_config_dir()) == path_a; - gboolean home_b = strstr(path_b, g_get_user_config_dir()) == path_b; + gboolean home_a = strstr(path_a, g_get_user_config_dir()) == path_a; + gboolean home_b = strstr(path_b, g_get_user_config_dir()) == path_b; - if (home_a && !home_b) - return -1; - if (!home_a && home_b) - return 1; + if (home_a && !home_b) + return -1; + if (!home_a && home_b) + return 1; - gchar *name_a = path_a; - gchar *p; - for (p = name_a; *p; p++) { - if (*p == '/') - name_a = p + 1; - } - gchar *name_b = path_b; - for (p = name_b; *p; p++) { - if (*p == '/') - name_b = p + 1; - } - if (g_str_equal(name_a, name_b)) - return 0; - if (g_str_equal(name_a, "tint2rc")) - return -1; - if (g_str_equal(name_b, "tint2rc")) - return 1; - gint result = strnatcasecmp(name_a, name_b); - g_free(path_a); - g_free(path_b); - return result; + gchar *name_a = path_a; + gchar *p; + for (p = name_a; *p; p++) { + if (*p == '/') + name_a = p + 1; + } + gchar *name_b = path_b; + for (p = name_b; *p; p++) { + if (*p == '/') + name_b = p + 1; + } + if (g_str_equal(name_a, name_b)) + return 0; + if (g_str_equal(name_a, "tint2rc")) + return -1; + if (g_str_equal(name_b, "tint2rc")) + return 1; + gint result = strnatcasecmp(name_a, name_b); + g_free(path_a); + g_free(path_b); + return result; } gboolean theme_list_contains(const char *given_path) { - GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(g_theme_view)); - GtkTreeIter iter; + GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(g_theme_view)); + GtkTreeIter iter; - gboolean have_iter = gtk_tree_model_get_iter_first(model, &iter); - while (have_iter) { - gchar *filepath; - gtk_tree_model_get(model, &iter, COL_THEME_FILE, &filepath, -1); - if (g_str_equal(filepath, given_path)) { - gtk_list_store_set(theme_list_store, &iter, COL_SNAPSHOT, NULL, -1); - g_free(filepath); - return TRUE; - } - g_free(filepath); - have_iter = gtk_tree_model_iter_next(model, &iter); - } - return FALSE; + gboolean have_iter = gtk_tree_model_get_iter_first(model, &iter); + while (have_iter) { + gchar *filepath; + gtk_tree_model_get(model, &iter, COL_THEME_FILE, &filepath, -1); + if (g_str_equal(filepath, given_path)) { + gtk_list_store_set(theme_list_store, &iter, COL_SNAPSHOT, NULL, -1); + g_free(filepath); + return TRUE; + } + g_free(filepath); + have_iter = gtk_tree_model_iter_next(model, &iter); + } + return FALSE; } void theme_list_append(const gchar *path) { - if (theme_list_contains(path)) - return; + if (theme_list_contains(path)) + return; - GtkTreeIter iter; - gtk_list_store_append(theme_list_store, &iter); + GtkTreeIter iter; + gtk_list_store_append(theme_list_store, &iter); - gchar *name = strrchr(path, '/') + 1; + gchar *name = strrchr(path, '/') + 1; - gchar *dir = g_strdup(path); - strrchr(dir, '/')[0] = 0; - char *suffix = contract_tilde(dir); - g_free(dir); + gchar *dir = g_strdup(path); + strrchr(dir, '/')[0] = 0; + char *suffix = contract_tilde(dir); + g_free(dir); - gchar *display_name = g_strdup_printf("%s\n(%s)", name, suffix); - gtk_list_store_set(theme_list_store, &iter, COL_THEME_FILE, path, COL_THEME_NAME, display_name, COL_FORCE_REFRESH, FALSE, -1); - g_free(display_name); - g_free(suffix); + gchar *display_name = g_strdup_printf("%s\n(%s)", name, suffix); + gtk_list_store_set(theme_list_store, + &iter, + COL_THEME_FILE, + path, + COL_THEME_NAME, + display_name, + COL_FORCE_REFRESH, + FALSE, + -1); + g_free(display_name); + g_free(suffix); } gboolean update_snapshot(gpointer ignored) { - { - gchar *tint2_cache_dir = g_build_filename(g_get_user_cache_dir(), "tint2", NULL); - if (!g_file_test(tint2_cache_dir, G_FILE_TEST_IS_DIR)) - g_mkdir(tint2_cache_dir, 0700); - g_free(tint2_cache_dir); - } + { + gchar *tint2_cache_dir = g_build_filename(g_get_user_cache_dir(), "tint2", NULL); + if (!g_file_test(tint2_cache_dir, G_FILE_TEST_IS_DIR)) + g_mkdir(tint2_cache_dir, 0700); + g_free(tint2_cache_dir); + } - const gint PADDING = 20; + const gint PADDING = 20; - GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(g_theme_view)); + GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(g_theme_view)); - GtkTreeIter iter; - gboolean have_iter; + GtkTreeIter iter; + gboolean have_iter; - int num_updates = 0; - gboolean need_pls_wait = FALSE; + int num_updates = 0; + gboolean need_pls_wait = FALSE; - have_iter = gtk_tree_model_get_iter_first(model, &iter); - while (have_iter) { - GdkPixbuf *pixbuf; - gtk_tree_model_get(model, &iter, COL_SNAPSHOT, &pixbuf, -1); - if (pixbuf) { - g_object_unref(pixbuf); - have_iter = gtk_tree_model_iter_next(model, &iter); - continue; - } + have_iter = gtk_tree_model_get_iter_first(model, &iter); + while (have_iter) { + GdkPixbuf *pixbuf; + gtk_tree_model_get(model, &iter, COL_SNAPSHOT, &pixbuf, -1); + if (pixbuf) { + g_object_unref(pixbuf); + have_iter = gtk_tree_model_iter_next(model, &iter); + continue; + } - gchar *path; - gboolean force_refresh; - gtk_tree_model_get(model, &iter, COL_THEME_FILE, &path, COL_FORCE_REFRESH, &force_refresh, -1); + gchar *path; + gboolean force_refresh; + gtk_tree_model_get(model, &iter, COL_THEME_FILE, &path, COL_FORCE_REFRESH, &force_refresh, -1); - char hash[MD4_HEX_SIZE + 4]; - md4hexf(path, hash); - strcat(hash, ".png"); + char hash[MD4_HEX_SIZE + 4]; + md4hexf(path, hash); + strcat(hash, ".png"); - gchar *snap = g_build_filename(g_get_user_cache_dir(), "tint2", hash, NULL); - pixbuf = force_refresh ? NULL : gdk_pixbuf_new_from_file(snap, NULL); - if (!pixbuf) { - gchar *cmd = g_strdup_printf("tint2 -c \'%s\' -s \'%s\' 1>/dev/null 2>/dev/null", path, snap); - num_updates++; - if (num_updates > 3 && !need_pls_wait) { - need_pls_wait = TRUE; - create_please_wait(GTK_WINDOW(g_window)); - } - if (system(cmd) == 0) { - // load - pixbuf = gdk_pixbuf_new_from_file(snap, NULL); - } - g_free(cmd); - } + gchar *snap = g_build_filename(g_get_user_cache_dir(), "tint2", hash, NULL); + pixbuf = force_refresh ? NULL : gdk_pixbuf_new_from_file(snap, NULL); + if (!pixbuf) { + gchar *cmd = g_strdup_printf("tint2 -c \'%s\' -s \'%s\' 1>/dev/null 2>/dev/null", path, snap); + num_updates++; + if (num_updates > 3 && !need_pls_wait) { + need_pls_wait = TRUE; + create_please_wait(GTK_WINDOW(g_window)); + } + if (system(cmd) == 0) { + // load + pixbuf = gdk_pixbuf_new_from_file(snap, NULL); + } + g_free(cmd); + } - g_free(snap); - g_free(path); + g_free(snap); + g_free(path); - gtk_list_store_set(theme_list_store, - &iter, - COL_SNAPSHOT, - pixbuf, - COL_WIDTH, - gdk_pixbuf_get_width(pixbuf) + PADDING, - COL_HEIGHT, - gdk_pixbuf_get_height(pixbuf) + PADDING, - COL_FORCE_REFRESH, - FALSE, - -1); - if (pixbuf) - g_object_unref(pixbuf); + gtk_list_store_set(theme_list_store, + &iter, + COL_SNAPSHOT, + pixbuf, + COL_WIDTH, + gdk_pixbuf_get_width(pixbuf) + PADDING, + COL_HEIGHT, + gdk_pixbuf_get_height(pixbuf) + PADDING, + COL_FORCE_REFRESH, + FALSE, + -1); + if (pixbuf) + g_object_unref(pixbuf); - if (need_pls_wait) - process_events(); + if (need_pls_wait) + process_events(); - have_iter = gtk_tree_model_iter_next(model, &iter); - } + have_iter = gtk_tree_model_iter_next(model, &iter); + } - if (need_pls_wait) - destroy_please_wait(); + if (need_pls_wait) + destroy_please_wait(); - return FALSE; + return FALSE; }
M src/tint2conf/theme_view.hsrc/tint2conf/theme_view.h

@@ -5,13 +5,15 @@ #include <gtk/gtk.h>

extern GtkWidget *g_theme_view; extern GtkListStore *theme_list_store; -enum { COL_THEME_FILE = 0, - COL_THEME_NAME, - COL_SNAPSHOT, - COL_WIDTH, - COL_HEIGHT, - COL_FORCE_REFRESH, - NB_COL, }; +enum { + COL_THEME_FILE = 0, + COL_THEME_NAME, + COL_SNAPSHOT, + COL_WIDTH, + COL_HEIGHT, + COL_FORCE_REFRESH, + NB_COL, +}; GtkWidget *create_view();
M src/tint2rc.csrc/tint2rc.c

@@ -1,411 +1,261 @@

#include "tint2rc.h" -unsigned char themes_tint2rc[] = { - 0x23, 0x2d, 0x2d, 0x2d, 0x2d, 0x20, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, - 0x74, 0x65, 0x64, 0x20, 0x62, 0x79, 0x20, 0x74, 0x69, 0x6e, 0x74, 0x32, - 0x63, 0x6f, 0x6e, 0x66, 0x20, 0x32, 0x36, 0x34, 0x31, 0x20, 0x2d, 0x2d, - 0x2d, 0x2d, 0x0a, 0x23, 0x20, 0x53, 0x65, 0x65, 0x20, 0x68, 0x74, 0x74, - 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x67, 0x69, 0x74, 0x6c, 0x61, 0x62, 0x2e, - 0x63, 0x6f, 0x6d, 0x2f, 0x6f, 0x39, 0x30, 0x30, 0x30, 0x2f, 0x74, 0x69, - 0x6e, 0x74, 0x32, 0x2f, 0x77, 0x69, 0x6b, 0x69, 0x73, 0x2f, 0x43, 0x6f, - 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x65, 0x20, 0x66, 0x6f, 0x72, 0x20, - 0x0a, 0x23, 0x20, 0x66, 0x75, 0x6c, 0x6c, 0x20, 0x64, 0x6f, 0x63, 0x75, - 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x6f, 0x66, - 0x20, 0x74, 0x68, 0x65, 0x20, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, - 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x6f, 0x70, 0x74, 0x69, 0x6f, - 0x6e, 0x73, 0x2e, 0x0a, 0x23, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, - 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, - 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, - 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, 0x23, 0x20, 0x42, 0x61, 0x63, - 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x73, 0x0a, 0x23, 0x20, 0x42, - 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x20, 0x31, 0x3a, - 0x20, 0x50, 0x61, 0x6e, 0x65, 0x6c, 0x0a, 0x72, 0x6f, 0x75, 0x6e, 0x64, - 0x65, 0x64, 0x20, 0x3d, 0x20, 0x30, 0x0a, 0x62, 0x6f, 0x72, 0x64, 0x65, - 0x72, 0x5f, 0x77, 0x69, 0x64, 0x74, 0x68, 0x20, 0x3d, 0x20, 0x30, 0x0a, - 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x63, - 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x23, 0x30, 0x30, 0x30, 0x30, - 0x30, 0x30, 0x20, 0x36, 0x30, 0x0a, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, - 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x23, 0x30, 0x30, - 0x30, 0x30, 0x30, 0x30, 0x20, 0x33, 0x30, 0x0a, 0x62, 0x61, 0x63, 0x6b, - 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, - 0x5f, 0x68, 0x6f, 0x76, 0x65, 0x72, 0x20, 0x3d, 0x20, 0x23, 0x30, 0x30, - 0x30, 0x30, 0x30, 0x30, 0x20, 0x36, 0x30, 0x0a, 0x62, 0x6f, 0x72, 0x64, - 0x65, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x68, 0x6f, 0x76, - 0x65, 0x72, 0x20, 0x3d, 0x20, 0x23, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, - 0x20, 0x33, 0x30, 0x0a, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, - 0x6e, 0x64, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x70, 0x72, 0x65, - 0x73, 0x73, 0x65, 0x64, 0x20, 0x3d, 0x20, 0x23, 0x30, 0x30, 0x30, 0x30, - 0x30, 0x30, 0x20, 0x36, 0x30, 0x0a, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, - 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x70, 0x72, 0x65, 0x73, 0x73, - 0x65, 0x64, 0x20, 0x3d, 0x20, 0x23, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, - 0x20, 0x33, 0x30, 0x0a, 0x0a, 0x23, 0x20, 0x42, 0x61, 0x63, 0x6b, 0x67, - 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x20, 0x32, 0x3a, 0x20, 0x44, 0x65, 0x66, - 0x61, 0x75, 0x6c, 0x74, 0x20, 0x74, 0x61, 0x73, 0x6b, 0x2c, 0x20, 0x49, - 0x63, 0x6f, 0x6e, 0x69, 0x66, 0x69, 0x65, 0x64, 0x20, 0x74, 0x61, 0x73, - 0x6b, 0x0a, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x65, 0x64, 0x20, 0x3d, 0x20, - 0x34, 0x0a, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x5f, 0x77, 0x69, 0x64, - 0x74, 0x68, 0x20, 0x3d, 0x20, 0x31, 0x0a, 0x62, 0x61, 0x63, 0x6b, 0x67, - 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x20, - 0x3d, 0x20, 0x23, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x20, 0x32, 0x30, - 0x0a, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, - 0x72, 0x20, 0x3d, 0x20, 0x23, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x20, - 0x33, 0x30, 0x0a, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, - 0x64, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x68, 0x6f, 0x76, 0x65, - 0x72, 0x20, 0x3d, 0x20, 0x23, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x20, - 0x32, 0x32, 0x0a, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x5f, 0x63, 0x6f, - 0x6c, 0x6f, 0x72, 0x5f, 0x68, 0x6f, 0x76, 0x65, 0x72, 0x20, 0x3d, 0x20, - 0x23, 0x65, 0x61, 0x65, 0x61, 0x65, 0x61, 0x20, 0x34, 0x34, 0x0a, 0x62, - 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x63, 0x6f, - 0x6c, 0x6f, 0x72, 0x5f, 0x70, 0x72, 0x65, 0x73, 0x73, 0x65, 0x64, 0x20, - 0x3d, 0x20, 0x23, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x20, 0x34, 0x0a, - 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, - 0x5f, 0x70, 0x72, 0x65, 0x73, 0x73, 0x65, 0x64, 0x20, 0x3d, 0x20, 0x23, - 0x65, 0x61, 0x65, 0x61, 0x65, 0x61, 0x20, 0x34, 0x34, 0x0a, 0x0a, 0x23, - 0x20, 0x42, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x20, - 0x33, 0x3a, 0x20, 0x41, 0x63, 0x74, 0x69, 0x76, 0x65, 0x20, 0x74, 0x61, - 0x73, 0x6b, 0x0a, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x65, 0x64, 0x20, 0x3d, - 0x20, 0x34, 0x0a, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x5f, 0x77, 0x69, - 0x64, 0x74, 0x68, 0x20, 0x3d, 0x20, 0x31, 0x0a, 0x62, 0x61, 0x63, 0x6b, - 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, - 0x20, 0x3d, 0x20, 0x23, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x20, 0x32, - 0x30, 0x0a, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x5f, 0x63, 0x6f, 0x6c, - 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x23, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, - 0x20, 0x34, 0x30, 0x0a, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, - 0x6e, 0x64, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x68, 0x6f, 0x76, - 0x65, 0x72, 0x20, 0x3d, 0x20, 0x23, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, - 0x20, 0x32, 0x32, 0x0a, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x5f, 0x63, - 0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x68, 0x6f, 0x76, 0x65, 0x72, 0x20, 0x3d, - 0x20, 0x23, 0x65, 0x61, 0x65, 0x61, 0x65, 0x61, 0x20, 0x34, 0x34, 0x0a, - 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x63, - 0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x70, 0x72, 0x65, 0x73, 0x73, 0x65, 0x64, - 0x20, 0x3d, 0x20, 0x23, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x20, 0x34, - 0x0a, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, - 0x72, 0x5f, 0x70, 0x72, 0x65, 0x73, 0x73, 0x65, 0x64, 0x20, 0x3d, 0x20, - 0x23, 0x65, 0x61, 0x65, 0x61, 0x65, 0x61, 0x20, 0x34, 0x34, 0x0a, 0x0a, - 0x23, 0x20, 0x42, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, - 0x20, 0x34, 0x3a, 0x20, 0x55, 0x72, 0x67, 0x65, 0x6e, 0x74, 0x20, 0x74, - 0x61, 0x73, 0x6b, 0x0a, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x65, 0x64, 0x20, - 0x3d, 0x20, 0x34, 0x0a, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x5f, 0x77, - 0x69, 0x64, 0x74, 0x68, 0x20, 0x3d, 0x20, 0x31, 0x0a, 0x62, 0x61, 0x63, - 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, - 0x72, 0x20, 0x3d, 0x20, 0x23, 0x61, 0x61, 0x34, 0x34, 0x30, 0x30, 0x20, - 0x31, 0x30, 0x30, 0x0a, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x5f, 0x63, - 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x23, 0x61, 0x61, 0x37, 0x37, - 0x33, 0x33, 0x20, 0x31, 0x30, 0x30, 0x0a, 0x62, 0x61, 0x63, 0x6b, 0x67, - 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, - 0x68, 0x6f, 0x76, 0x65, 0x72, 0x20, 0x3d, 0x20, 0x23, 0x63, 0x63, 0x37, - 0x37, 0x30, 0x30, 0x20, 0x31, 0x30, 0x30, 0x0a, 0x62, 0x6f, 0x72, 0x64, - 0x65, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x68, 0x6f, 0x76, - 0x65, 0x72, 0x20, 0x3d, 0x20, 0x23, 0x61, 0x61, 0x37, 0x37, 0x33, 0x33, - 0x20, 0x31, 0x30, 0x30, 0x0a, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, - 0x75, 0x6e, 0x64, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x70, 0x72, - 0x65, 0x73, 0x73, 0x65, 0x64, 0x20, 0x3d, 0x20, 0x23, 0x35, 0x35, 0x35, - 0x35, 0x35, 0x35, 0x20, 0x34, 0x0a, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, - 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x70, 0x72, 0x65, 0x73, 0x73, - 0x65, 0x64, 0x20, 0x3d, 0x20, 0x23, 0x61, 0x61, 0x37, 0x37, 0x33, 0x33, - 0x20, 0x31, 0x30, 0x30, 0x0a, 0x0a, 0x23, 0x20, 0x42, 0x61, 0x63, 0x6b, - 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x20, 0x35, 0x3a, 0x20, 0x54, 0x6f, - 0x6f, 0x6c, 0x74, 0x69, 0x70, 0x0a, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x65, - 0x64, 0x20, 0x3d, 0x20, 0x31, 0x0a, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, - 0x5f, 0x77, 0x69, 0x64, 0x74, 0x68, 0x20, 0x3d, 0x20, 0x31, 0x0a, 0x62, - 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x63, 0x6f, - 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x23, 0x66, 0x66, 0x66, 0x66, 0x61, - 0x61, 0x20, 0x31, 0x30, 0x30, 0x0a, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, - 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x23, 0x30, 0x30, - 0x30, 0x30, 0x30, 0x30, 0x20, 0x31, 0x30, 0x30, 0x0a, 0x62, 0x61, 0x63, - 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, - 0x72, 0x5f, 0x68, 0x6f, 0x76, 0x65, 0x72, 0x20, 0x3d, 0x20, 0x23, 0x66, - 0x66, 0x66, 0x66, 0x61, 0x61, 0x20, 0x31, 0x30, 0x30, 0x0a, 0x62, 0x6f, - 0x72, 0x64, 0x65, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x68, - 0x6f, 0x76, 0x65, 0x72, 0x20, 0x3d, 0x20, 0x23, 0x30, 0x30, 0x30, 0x30, - 0x30, 0x30, 0x20, 0x31, 0x30, 0x30, 0x0a, 0x62, 0x61, 0x63, 0x6b, 0x67, - 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, - 0x70, 0x72, 0x65, 0x73, 0x73, 0x65, 0x64, 0x20, 0x3d, 0x20, 0x23, 0x66, - 0x66, 0x66, 0x66, 0x61, 0x61, 0x20, 0x31, 0x30, 0x30, 0x0a, 0x62, 0x6f, - 0x72, 0x64, 0x65, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x70, - 0x72, 0x65, 0x73, 0x73, 0x65, 0x64, 0x20, 0x3d, 0x20, 0x23, 0x30, 0x30, - 0x30, 0x30, 0x30, 0x30, 0x20, 0x31, 0x30, 0x30, 0x0a, 0x0a, 0x23, 0x2d, - 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, - 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, - 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, - 0x0a, 0x23, 0x20, 0x50, 0x61, 0x6e, 0x65, 0x6c, 0x0a, 0x70, 0x61, 0x6e, - 0x65, 0x6c, 0x5f, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x20, 0x3d, 0x20, 0x4c, - 0x54, 0x53, 0x43, 0x0a, 0x70, 0x61, 0x6e, 0x65, 0x6c, 0x5f, 0x73, 0x69, - 0x7a, 0x65, 0x20, 0x3d, 0x20, 0x31, 0x30, 0x30, 0x25, 0x20, 0x33, 0x30, - 0x0a, 0x70, 0x61, 0x6e, 0x65, 0x6c, 0x5f, 0x6d, 0x61, 0x72, 0x67, 0x69, - 0x6e, 0x20, 0x3d, 0x20, 0x30, 0x20, 0x30, 0x0a, 0x70, 0x61, 0x6e, 0x65, - 0x6c, 0x5f, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x20, 0x3d, 0x20, - 0x32, 0x20, 0x30, 0x20, 0x32, 0x0a, 0x70, 0x61, 0x6e, 0x65, 0x6c, 0x5f, - 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x69, - 0x64, 0x20, 0x3d, 0x20, 0x31, 0x0a, 0x77, 0x6d, 0x5f, 0x6d, 0x65, 0x6e, - 0x75, 0x20, 0x3d, 0x20, 0x31, 0x0a, 0x70, 0x61, 0x6e, 0x65, 0x6c, 0x5f, - 0x64, 0x6f, 0x63, 0x6b, 0x20, 0x3d, 0x20, 0x30, 0x0a, 0x70, 0x61, 0x6e, - 0x65, 0x6c, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, - 0x3d, 0x20, 0x62, 0x6f, 0x74, 0x74, 0x6f, 0x6d, 0x20, 0x63, 0x65, 0x6e, - 0x74, 0x65, 0x72, 0x20, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x6f, 0x6e, 0x74, - 0x61, 0x6c, 0x0a, 0x70, 0x61, 0x6e, 0x65, 0x6c, 0x5f, 0x6c, 0x61, 0x79, - 0x65, 0x72, 0x20, 0x3d, 0x20, 0x74, 0x6f, 0x70, 0x0a, 0x70, 0x61, 0x6e, - 0x65, 0x6c, 0x5f, 0x6d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x20, 0x3d, - 0x20, 0x61, 0x6c, 0x6c, 0x0a, 0x70, 0x72, 0x69, 0x6d, 0x61, 0x72, 0x79, - 0x5f, 0x6d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x5f, 0x66, 0x69, 0x72, - 0x73, 0x74, 0x20, 0x3d, 0x20, 0x30, 0x0a, 0x61, 0x75, 0x74, 0x6f, 0x68, - 0x69, 0x64, 0x65, 0x20, 0x3d, 0x20, 0x30, 0x0a, 0x61, 0x75, 0x74, 0x6f, - 0x68, 0x69, 0x64, 0x65, 0x5f, 0x73, 0x68, 0x6f, 0x77, 0x5f, 0x74, 0x69, - 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x20, 0x3d, 0x20, 0x30, 0x0a, 0x61, 0x75, - 0x74, 0x6f, 0x68, 0x69, 0x64, 0x65, 0x5f, 0x68, 0x69, 0x64, 0x65, 0x5f, - 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x20, 0x3d, 0x20, 0x30, 0x2e, - 0x35, 0x0a, 0x61, 0x75, 0x74, 0x6f, 0x68, 0x69, 0x64, 0x65, 0x5f, 0x68, - 0x65, 0x69, 0x67, 0x68, 0x74, 0x20, 0x3d, 0x20, 0x32, 0x0a, 0x73, 0x74, - 0x72, 0x75, 0x74, 0x5f, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x20, 0x3d, - 0x20, 0x66, 0x6f, 0x6c, 0x6c, 0x6f, 0x77, 0x5f, 0x73, 0x69, 0x7a, 0x65, - 0x0a, 0x70, 0x61, 0x6e, 0x65, 0x6c, 0x5f, 0x77, 0x69, 0x6e, 0x64, 0x6f, - 0x77, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x20, 0x3d, 0x20, 0x74, 0x69, 0x6e, - 0x74, 0x32, 0x0a, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x74, - 0x72, 0x61, 0x6e, 0x73, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x20, - 0x3d, 0x20, 0x31, 0x0a, 0x6d, 0x6f, 0x75, 0x73, 0x65, 0x5f, 0x65, 0x66, - 0x66, 0x65, 0x63, 0x74, 0x73, 0x20, 0x3d, 0x20, 0x31, 0x0a, 0x66, 0x6f, - 0x6e, 0x74, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x20, 0x3d, 0x20, - 0x30, 0x0a, 0x6d, 0x6f, 0x75, 0x73, 0x65, 0x5f, 0x68, 0x6f, 0x76, 0x65, - 0x72, 0x5f, 0x69, 0x63, 0x6f, 0x6e, 0x5f, 0x61, 0x73, 0x62, 0x20, 0x3d, - 0x20, 0x31, 0x30, 0x30, 0x20, 0x30, 0x20, 0x31, 0x30, 0x0a, 0x6d, 0x6f, - 0x75, 0x73, 0x65, 0x5f, 0x70, 0x72, 0x65, 0x73, 0x73, 0x65, 0x64, 0x5f, - 0x69, 0x63, 0x6f, 0x6e, 0x5f, 0x61, 0x73, 0x62, 0x20, 0x3d, 0x20, 0x31, - 0x30, 0x30, 0x20, 0x30, 0x20, 0x30, 0x0a, 0x0a, 0x23, 0x2d, 0x2d, 0x2d, - 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, - 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, - 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, 0x23, - 0x20, 0x54, 0x61, 0x73, 0x6b, 0x62, 0x61, 0x72, 0x0a, 0x74, 0x61, 0x73, - 0x6b, 0x62, 0x61, 0x72, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x20, 0x3d, 0x20, - 0x73, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x5f, 0x64, 0x65, 0x73, 0x6b, 0x74, - 0x6f, 0x70, 0x0a, 0x74, 0x61, 0x73, 0x6b, 0x62, 0x61, 0x72, 0x5f, 0x70, - 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x20, 0x3d, 0x20, 0x30, 0x20, 0x30, - 0x20, 0x32, 0x0a, 0x74, 0x61, 0x73, 0x6b, 0x62, 0x61, 0x72, 0x5f, 0x62, - 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x69, 0x64, - 0x20, 0x3d, 0x20, 0x30, 0x0a, 0x74, 0x61, 0x73, 0x6b, 0x62, 0x61, 0x72, - 0x5f, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x5f, 0x62, 0x61, 0x63, 0x6b, - 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x69, 0x64, 0x20, 0x3d, 0x20, - 0x30, 0x0a, 0x74, 0x61, 0x73, 0x6b, 0x62, 0x61, 0x72, 0x5f, 0x6e, 0x61, - 0x6d, 0x65, 0x20, 0x3d, 0x20, 0x31, 0x0a, 0x74, 0x61, 0x73, 0x6b, 0x62, - 0x61, 0x72, 0x5f, 0x68, 0x69, 0x64, 0x65, 0x5f, 0x69, 0x6e, 0x61, 0x63, - 0x74, 0x69, 0x76, 0x65, 0x5f, 0x74, 0x61, 0x73, 0x6b, 0x73, 0x20, 0x3d, - 0x20, 0x30, 0x0a, 0x74, 0x61, 0x73, 0x6b, 0x62, 0x61, 0x72, 0x5f, 0x68, - 0x69, 0x64, 0x65, 0x5f, 0x64, 0x69, 0x66, 0x66, 0x65, 0x72, 0x65, 0x6e, - 0x74, 0x5f, 0x6d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x20, 0x3d, 0x20, - 0x30, 0x0a, 0x74, 0x61, 0x73, 0x6b, 0x62, 0x61, 0x72, 0x5f, 0x61, 0x6c, - 0x77, 0x61, 0x79, 0x73, 0x5f, 0x73, 0x68, 0x6f, 0x77, 0x5f, 0x61, 0x6c, - 0x6c, 0x5f, 0x64, 0x65, 0x73, 0x6b, 0x74, 0x6f, 0x70, 0x5f, 0x74, 0x61, - 0x73, 0x6b, 0x73, 0x20, 0x3d, 0x20, 0x30, 0x0a, 0x74, 0x61, 0x73, 0x6b, - 0x62, 0x61, 0x72, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x5f, 0x70, 0x61, 0x64, - 0x64, 0x69, 0x6e, 0x67, 0x20, 0x3d, 0x20, 0x34, 0x20, 0x32, 0x0a, 0x74, - 0x61, 0x73, 0x6b, 0x62, 0x61, 0x72, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x5f, - 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x69, - 0x64, 0x20, 0x3d, 0x20, 0x30, 0x0a, 0x74, 0x61, 0x73, 0x6b, 0x62, 0x61, - 0x72, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x5f, 0x61, 0x63, 0x74, 0x69, 0x76, - 0x65, 0x5f, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, - 0x5f, 0x69, 0x64, 0x20, 0x3d, 0x20, 0x30, 0x0a, 0x74, 0x61, 0x73, 0x6b, - 0x62, 0x61, 0x72, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x5f, 0x66, 0x6f, 0x6e, - 0x74, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x23, 0x65, - 0x33, 0x65, 0x33, 0x65, 0x33, 0x20, 0x31, 0x30, 0x30, 0x0a, 0x74, 0x61, - 0x73, 0x6b, 0x62, 0x61, 0x72, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x5f, 0x61, - 0x63, 0x74, 0x69, 0x76, 0x65, 0x5f, 0x66, 0x6f, 0x6e, 0x74, 0x5f, 0x63, - 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x23, 0x66, 0x66, 0x66, 0x66, - 0x66, 0x66, 0x20, 0x31, 0x30, 0x30, 0x0a, 0x74, 0x61, 0x73, 0x6b, 0x62, - 0x61, 0x72, 0x5f, 0x64, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, - 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x20, 0x3d, 0x20, 0x30, 0x0a, 0x74, - 0x61, 0x73, 0x6b, 0x62, 0x61, 0x72, 0x5f, 0x73, 0x6f, 0x72, 0x74, 0x5f, - 0x6f, 0x72, 0x64, 0x65, 0x72, 0x20, 0x3d, 0x20, 0x6e, 0x6f, 0x6e, 0x65, - 0x0a, 0x74, 0x61, 0x73, 0x6b, 0x5f, 0x61, 0x6c, 0x69, 0x67, 0x6e, 0x20, - 0x3d, 0x20, 0x6c, 0x65, 0x66, 0x74, 0x0a, 0x0a, 0x23, 0x2d, 0x2d, 0x2d, - 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, - 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, - 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, 0x23, - 0x20, 0x54, 0x61, 0x73, 0x6b, 0x0a, 0x74, 0x61, 0x73, 0x6b, 0x5f, 0x74, - 0x65, 0x78, 0x74, 0x20, 0x3d, 0x20, 0x31, 0x0a, 0x74, 0x61, 0x73, 0x6b, - 0x5f, 0x69, 0x63, 0x6f, 0x6e, 0x20, 0x3d, 0x20, 0x31, 0x0a, 0x74, 0x61, - 0x73, 0x6b, 0x5f, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x65, 0x64, 0x20, - 0x3d, 0x20, 0x31, 0x0a, 0x75, 0x72, 0x67, 0x65, 0x6e, 0x74, 0x5f, 0x6e, - 0x62, 0x5f, 0x6f, 0x66, 0x5f, 0x62, 0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x3d, - 0x20, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x0a, 0x74, 0x61, 0x73, 0x6b, - 0x5f, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x5f, 0x73, 0x69, 0x7a, - 0x65, 0x20, 0x3d, 0x20, 0x31, 0x35, 0x30, 0x20, 0x33, 0x35, 0x0a, 0x74, - 0x61, 0x73, 0x6b, 0x5f, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x20, - 0x3d, 0x20, 0x32, 0x20, 0x32, 0x20, 0x34, 0x0a, 0x74, 0x61, 0x73, 0x6b, - 0x5f, 0x74, 0x6f, 0x6f, 0x6c, 0x74, 0x69, 0x70, 0x20, 0x3d, 0x20, 0x31, - 0x0a, 0x74, 0x61, 0x73, 0x6b, 0x5f, 0x66, 0x6f, 0x6e, 0x74, 0x5f, 0x63, - 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x23, 0x66, 0x66, 0x66, 0x66, - 0x66, 0x66, 0x20, 0x31, 0x30, 0x30, 0x0a, 0x74, 0x61, 0x73, 0x6b, 0x5f, - 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x69, - 0x64, 0x20, 0x3d, 0x20, 0x32, 0x0a, 0x74, 0x61, 0x73, 0x6b, 0x5f, 0x61, - 0x63, 0x74, 0x69, 0x76, 0x65, 0x5f, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, - 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x69, 0x64, 0x20, 0x3d, 0x20, 0x33, 0x0a, - 0x74, 0x61, 0x73, 0x6b, 0x5f, 0x75, 0x72, 0x67, 0x65, 0x6e, 0x74, 0x5f, - 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x69, - 0x64, 0x20, 0x3d, 0x20, 0x34, 0x0a, 0x74, 0x61, 0x73, 0x6b, 0x5f, 0x69, - 0x63, 0x6f, 0x6e, 0x69, 0x66, 0x69, 0x65, 0x64, 0x5f, 0x62, 0x61, 0x63, - 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x69, 0x64, 0x20, 0x3d, - 0x20, 0x32, 0x0a, 0x6d, 0x6f, 0x75, 0x73, 0x65, 0x5f, 0x6c, 0x65, 0x66, - 0x74, 0x20, 0x3d, 0x20, 0x74, 0x6f, 0x67, 0x67, 0x6c, 0x65, 0x5f, 0x69, - 0x63, 0x6f, 0x6e, 0x69, 0x66, 0x79, 0x0a, 0x6d, 0x6f, 0x75, 0x73, 0x65, - 0x5f, 0x6d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x20, 0x3d, 0x20, 0x6e, 0x6f, - 0x6e, 0x65, 0x0a, 0x6d, 0x6f, 0x75, 0x73, 0x65, 0x5f, 0x72, 0x69, 0x67, - 0x68, 0x74, 0x20, 0x3d, 0x20, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0x0a, 0x6d, - 0x6f, 0x75, 0x73, 0x65, 0x5f, 0x73, 0x63, 0x72, 0x6f, 0x6c, 0x6c, 0x5f, - 0x75, 0x70, 0x20, 0x3d, 0x20, 0x74, 0x6f, 0x67, 0x67, 0x6c, 0x65, 0x0a, - 0x6d, 0x6f, 0x75, 0x73, 0x65, 0x5f, 0x73, 0x63, 0x72, 0x6f, 0x6c, 0x6c, - 0x5f, 0x64, 0x6f, 0x77, 0x6e, 0x20, 0x3d, 0x20, 0x69, 0x63, 0x6f, 0x6e, - 0x69, 0x66, 0x79, 0x0a, 0x0a, 0x23, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, - 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, - 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, - 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, 0x23, 0x20, 0x53, 0x79, - 0x73, 0x74, 0x65, 0x6d, 0x20, 0x74, 0x72, 0x61, 0x79, 0x20, 0x28, 0x6e, - 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, - 0x61, 0x72, 0x65, 0x61, 0x29, 0x0a, 0x73, 0x79, 0x73, 0x74, 0x72, 0x61, - 0x79, 0x5f, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x20, 0x3d, 0x20, - 0x30, 0x20, 0x34, 0x20, 0x32, 0x0a, 0x73, 0x79, 0x73, 0x74, 0x72, 0x61, - 0x79, 0x5f, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, - 0x5f, 0x69, 0x64, 0x20, 0x3d, 0x20, 0x30, 0x0a, 0x73, 0x79, 0x73, 0x74, - 0x72, 0x61, 0x79, 0x5f, 0x73, 0x6f, 0x72, 0x74, 0x20, 0x3d, 0x20, 0x61, - 0x73, 0x63, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x0a, 0x73, 0x79, 0x73, - 0x74, 0x72, 0x61, 0x79, 0x5f, 0x69, 0x63, 0x6f, 0x6e, 0x5f, 0x73, 0x69, - 0x7a, 0x65, 0x20, 0x3d, 0x20, 0x32, 0x34, 0x0a, 0x73, 0x79, 0x73, 0x74, - 0x72, 0x61, 0x79, 0x5f, 0x69, 0x63, 0x6f, 0x6e, 0x5f, 0x61, 0x73, 0x62, - 0x20, 0x3d, 0x20, 0x31, 0x30, 0x30, 0x20, 0x30, 0x20, 0x30, 0x0a, 0x73, - 0x79, 0x73, 0x74, 0x72, 0x61, 0x79, 0x5f, 0x6d, 0x6f, 0x6e, 0x69, 0x74, - 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x31, 0x0a, 0x0a, 0x23, 0x2d, 0x2d, 0x2d, - 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, - 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, - 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, 0x23, - 0x20, 0x4c, 0x61, 0x75, 0x6e, 0x63, 0x68, 0x65, 0x72, 0x0a, 0x6c, 0x61, - 0x75, 0x6e, 0x63, 0x68, 0x65, 0x72, 0x5f, 0x70, 0x61, 0x64, 0x64, 0x69, - 0x6e, 0x67, 0x20, 0x3d, 0x20, 0x32, 0x20, 0x34, 0x20, 0x32, 0x0a, 0x6c, - 0x61, 0x75, 0x6e, 0x63, 0x68, 0x65, 0x72, 0x5f, 0x62, 0x61, 0x63, 0x6b, - 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x69, 0x64, 0x20, 0x3d, 0x20, - 0x30, 0x0a, 0x6c, 0x61, 0x75, 0x6e, 0x63, 0x68, 0x65, 0x72, 0x5f, 0x69, - 0x63, 0x6f, 0x6e, 0x5f, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, - 0x6e, 0x64, 0x5f, 0x69, 0x64, 0x20, 0x3d, 0x20, 0x30, 0x0a, 0x6c, 0x61, - 0x75, 0x6e, 0x63, 0x68, 0x65, 0x72, 0x5f, 0x69, 0x63, 0x6f, 0x6e, 0x5f, - 0x73, 0x69, 0x7a, 0x65, 0x20, 0x3d, 0x20, 0x32, 0x34, 0x0a, 0x6c, 0x61, - 0x75, 0x6e, 0x63, 0x68, 0x65, 0x72, 0x5f, 0x69, 0x63, 0x6f, 0x6e, 0x5f, - 0x61, 0x73, 0x62, 0x20, 0x3d, 0x20, 0x31, 0x30, 0x30, 0x20, 0x30, 0x20, - 0x30, 0x0a, 0x6c, 0x61, 0x75, 0x6e, 0x63, 0x68, 0x65, 0x72, 0x5f, 0x69, - 0x63, 0x6f, 0x6e, 0x5f, 0x74, 0x68, 0x65, 0x6d, 0x65, 0x5f, 0x6f, 0x76, - 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x20, 0x3d, 0x20, 0x30, 0x0a, 0x73, - 0x74, 0x61, 0x72, 0x74, 0x75, 0x70, 0x5f, 0x6e, 0x6f, 0x74, 0x69, 0x66, - 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x20, 0x3d, 0x20, 0x31, - 0x0a, 0x6c, 0x61, 0x75, 0x6e, 0x63, 0x68, 0x65, 0x72, 0x5f, 0x74, 0x6f, - 0x6f, 0x6c, 0x74, 0x69, 0x70, 0x20, 0x3d, 0x20, 0x31, 0x0a, 0x6c, 0x61, - 0x75, 0x6e, 0x63, 0x68, 0x65, 0x72, 0x5f, 0x69, 0x74, 0x65, 0x6d, 0x5f, - 0x61, 0x70, 0x70, 0x20, 0x3d, 0x20, 0x2f, 0x75, 0x73, 0x72, 0x2f, 0x73, - 0x68, 0x61, 0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x74, 0x69, 0x6e, 0x74, 0x32, 0x63, - 0x6f, 0x6e, 0x66, 0x2e, 0x64, 0x65, 0x73, 0x6b, 0x74, 0x6f, 0x70, 0x0a, - 0x6c, 0x61, 0x75, 0x6e, 0x63, 0x68, 0x65, 0x72, 0x5f, 0x69, 0x74, 0x65, - 0x6d, 0x5f, 0x61, 0x70, 0x70, 0x20, 0x3d, 0x20, 0x2f, 0x75, 0x73, 0x72, - 0x2f, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x2f, 0x73, 0x68, 0x61, 0x72, 0x65, - 0x2f, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x73, 0x2f, 0x74, 0x69, 0x6e, 0x74, 0x32, 0x63, 0x6f, 0x6e, 0x66, 0x2e, - 0x64, 0x65, 0x73, 0x6b, 0x74, 0x6f, 0x70, 0x0a, 0x6c, 0x61, 0x75, 0x6e, - 0x63, 0x68, 0x65, 0x72, 0x5f, 0x69, 0x74, 0x65, 0x6d, 0x5f, 0x61, 0x70, - 0x70, 0x20, 0x3d, 0x20, 0x2f, 0x75, 0x73, 0x72, 0x2f, 0x73, 0x68, 0x61, - 0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x73, 0x2f, 0x66, 0x69, 0x72, 0x65, 0x66, 0x6f, 0x78, 0x2e, - 0x64, 0x65, 0x73, 0x6b, 0x74, 0x6f, 0x70, 0x0a, 0x6c, 0x61, 0x75, 0x6e, - 0x63, 0x68, 0x65, 0x72, 0x5f, 0x69, 0x74, 0x65, 0x6d, 0x5f, 0x61, 0x70, - 0x70, 0x20, 0x3d, 0x20, 0x2f, 0x75, 0x73, 0x72, 0x2f, 0x73, 0x68, 0x61, - 0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x73, 0x2f, 0x69, 0x63, 0x65, 0x77, 0x65, 0x61, 0x73, 0x65, - 0x6c, 0x2e, 0x64, 0x65, 0x73, 0x6b, 0x74, 0x6f, 0x70, 0x0a, 0x6c, 0x61, - 0x75, 0x6e, 0x63, 0x68, 0x65, 0x72, 0x5f, 0x69, 0x74, 0x65, 0x6d, 0x5f, - 0x61, 0x70, 0x70, 0x20, 0x3d, 0x20, 0x2f, 0x75, 0x73, 0x72, 0x2f, 0x73, - 0x68, 0x61, 0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x63, 0x68, 0x72, 0x6f, 0x6d, 0x69, - 0x75, 0x6d, 0x2d, 0x62, 0x72, 0x6f, 0x77, 0x73, 0x65, 0x72, 0x2e, 0x64, - 0x65, 0x73, 0x6b, 0x74, 0x6f, 0x70, 0x0a, 0x6c, 0x61, 0x75, 0x6e, 0x63, - 0x68, 0x65, 0x72, 0x5f, 0x69, 0x74, 0x65, 0x6d, 0x5f, 0x61, 0x70, 0x70, - 0x20, 0x3d, 0x20, 0x2f, 0x75, 0x73, 0x72, 0x2f, 0x73, 0x68, 0x61, 0x72, - 0x65, 0x2f, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x73, 0x2f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2d, 0x63, 0x68, - 0x72, 0x6f, 0x6d, 0x65, 0x2e, 0x64, 0x65, 0x73, 0x6b, 0x74, 0x6f, 0x70, - 0x0a, 0x0a, 0x23, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, - 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, - 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, - 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, 0x23, 0x20, 0x43, 0x6c, 0x6f, 0x63, 0x6b, - 0x0a, 0x74, 0x69, 0x6d, 0x65, 0x31, 0x5f, 0x66, 0x6f, 0x72, 0x6d, 0x61, - 0x74, 0x20, 0x3d, 0x20, 0x25, 0x48, 0x3a, 0x25, 0x4d, 0x0a, 0x74, 0x69, - 0x6d, 0x65, 0x32, 0x5f, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x20, 0x3d, - 0x20, 0x25, 0x41, 0x20, 0x25, 0x64, 0x20, 0x25, 0x42, 0x0a, 0x74, 0x69, - 0x6d, 0x65, 0x31, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x7a, 0x6f, 0x6e, 0x65, - 0x20, 0x3d, 0x20, 0x0a, 0x74, 0x69, 0x6d, 0x65, 0x32, 0x5f, 0x74, 0x69, - 0x6d, 0x65, 0x7a, 0x6f, 0x6e, 0x65, 0x20, 0x3d, 0x20, 0x0a, 0x63, 0x6c, - 0x6f, 0x63, 0x6b, 0x5f, 0x66, 0x6f, 0x6e, 0x74, 0x5f, 0x63, 0x6f, 0x6c, - 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x23, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, - 0x20, 0x31, 0x30, 0x30, 0x0a, 0x63, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x70, - 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x20, 0x3d, 0x20, 0x32, 0x20, 0x30, - 0x0a, 0x63, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x62, 0x61, 0x63, 0x6b, 0x67, - 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x69, 0x64, 0x20, 0x3d, 0x20, 0x30, - 0x0a, 0x63, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x74, 0x6f, 0x6f, 0x6c, 0x74, - 0x69, 0x70, 0x20, 0x3d, 0x20, 0x0a, 0x63, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, - 0x74, 0x6f, 0x6f, 0x6c, 0x74, 0x69, 0x70, 0x5f, 0x74, 0x69, 0x6d, 0x65, - 0x7a, 0x6f, 0x6e, 0x65, 0x20, 0x3d, 0x20, 0x0a, 0x63, 0x6c, 0x6f, 0x63, - 0x6b, 0x5f, 0x6c, 0x63, 0x6c, 0x69, 0x63, 0x6b, 0x5f, 0x63, 0x6f, 0x6d, - 0x6d, 0x61, 0x6e, 0x64, 0x20, 0x3d, 0x20, 0x0a, 0x63, 0x6c, 0x6f, 0x63, - 0x6b, 0x5f, 0x72, 0x63, 0x6c, 0x69, 0x63, 0x6b, 0x5f, 0x63, 0x6f, 0x6d, - 0x6d, 0x61, 0x6e, 0x64, 0x20, 0x3d, 0x20, 0x6f, 0x72, 0x61, 0x67, 0x65, - 0x0a, 0x63, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x6d, 0x63, 0x6c, 0x69, 0x63, - 0x6b, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x20, 0x3d, 0x20, - 0x0a, 0x63, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x75, 0x77, 0x68, 0x65, 0x65, - 0x6c, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x20, 0x3d, 0x20, - 0x0a, 0x63, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x64, 0x77, 0x68, 0x65, 0x65, - 0x6c, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x20, 0x3d, 0x20, - 0x0a, 0x0a, 0x23, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, - 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, - 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, - 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, 0x23, 0x20, 0x42, 0x61, 0x74, 0x74, 0x65, - 0x72, 0x79, 0x0a, 0x62, 0x61, 0x74, 0x74, 0x65, 0x72, 0x79, 0x5f, 0x74, - 0x6f, 0x6f, 0x6c, 0x74, 0x69, 0x70, 0x20, 0x3d, 0x20, 0x31, 0x0a, 0x62, - 0x61, 0x74, 0x74, 0x65, 0x72, 0x79, 0x5f, 0x6c, 0x6f, 0x77, 0x5f, 0x73, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x20, 0x3d, 0x20, 0x31, 0x30, 0x0a, 0x62, - 0x61, 0x74, 0x74, 0x65, 0x72, 0x79, 0x5f, 0x6c, 0x6f, 0x77, 0x5f, 0x63, - 0x6d, 0x64, 0x20, 0x3d, 0x20, 0x6e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x2d, - 0x73, 0x65, 0x6e, 0x64, 0x20, 0x22, 0x62, 0x61, 0x74, 0x74, 0x65, 0x72, - 0x79, 0x20, 0x6c, 0x6f, 0x77, 0x22, 0x0a, 0x62, 0x61, 0x74, 0x74, 0x65, - 0x72, 0x79, 0x5f, 0x66, 0x6f, 0x6e, 0x74, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, - 0x72, 0x20, 0x3d, 0x20, 0x23, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x20, - 0x31, 0x30, 0x30, 0x0a, 0x62, 0x61, 0x74, 0x74, 0x65, 0x72, 0x79, 0x5f, - 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x20, 0x3d, 0x20, 0x31, 0x20, - 0x30, 0x0a, 0x62, 0x61, 0x74, 0x74, 0x65, 0x72, 0x79, 0x5f, 0x62, 0x61, - 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x69, 0x64, 0x20, - 0x3d, 0x20, 0x30, 0x0a, 0x62, 0x61, 0x74, 0x74, 0x65, 0x72, 0x79, 0x5f, - 0x68, 0x69, 0x64, 0x65, 0x20, 0x3d, 0x20, 0x31, 0x30, 0x31, 0x0a, 0x62, - 0x61, 0x74, 0x74, 0x65, 0x72, 0x79, 0x5f, 0x6c, 0x63, 0x6c, 0x69, 0x63, - 0x6b, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x20, 0x3d, 0x20, - 0x0a, 0x62, 0x61, 0x74, 0x74, 0x65, 0x72, 0x79, 0x5f, 0x72, 0x63, 0x6c, - 0x69, 0x63, 0x6b, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x20, - 0x3d, 0x20, 0x0a, 0x62, 0x61, 0x74, 0x74, 0x65, 0x72, 0x79, 0x5f, 0x6d, - 0x63, 0x6c, 0x69, 0x63, 0x6b, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, - 0x64, 0x20, 0x3d, 0x20, 0x0a, 0x62, 0x61, 0x74, 0x74, 0x65, 0x72, 0x79, - 0x5f, 0x75, 0x77, 0x68, 0x65, 0x65, 0x6c, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, - 0x61, 0x6e, 0x64, 0x20, 0x3d, 0x20, 0x0a, 0x62, 0x61, 0x74, 0x74, 0x65, - 0x72, 0x79, 0x5f, 0x64, 0x77, 0x68, 0x65, 0x65, 0x6c, 0x5f, 0x63, 0x6f, - 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x20, 0x3d, 0x20, 0x0a, 0x61, 0x63, 0x5f, - 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x65, 0x64, 0x5f, 0x63, 0x6d, - 0x64, 0x20, 0x3d, 0x20, 0x0a, 0x61, 0x63, 0x5f, 0x64, 0x69, 0x73, 0x63, - 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x65, 0x64, 0x5f, 0x63, 0x6d, 0x64, - 0x20, 0x3d, 0x20, 0x0a, 0x0a, 0x23, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, - 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, - 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, - 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, 0x23, 0x20, 0x54, 0x6f, - 0x6f, 0x6c, 0x74, 0x69, 0x70, 0x0a, 0x74, 0x6f, 0x6f, 0x6c, 0x74, 0x69, - 0x70, 0x5f, 0x73, 0x68, 0x6f, 0x77, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x6f, - 0x75, 0x74, 0x20, 0x3d, 0x20, 0x30, 0x2e, 0x35, 0x0a, 0x74, 0x6f, 0x6f, - 0x6c, 0x74, 0x69, 0x70, 0x5f, 0x68, 0x69, 0x64, 0x65, 0x5f, 0x74, 0x69, - 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x20, 0x3d, 0x20, 0x30, 0x2e, 0x31, 0x0a, - 0x74, 0x6f, 0x6f, 0x6c, 0x74, 0x69, 0x70, 0x5f, 0x70, 0x61, 0x64, 0x64, - 0x69, 0x6e, 0x67, 0x20, 0x3d, 0x20, 0x32, 0x20, 0x32, 0x0a, 0x74, 0x6f, - 0x6f, 0x6c, 0x74, 0x69, 0x70, 0x5f, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, - 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x69, 0x64, 0x20, 0x3d, 0x20, 0x35, 0x0a, - 0x74, 0x6f, 0x6f, 0x6c, 0x74, 0x69, 0x70, 0x5f, 0x66, 0x6f, 0x6e, 0x74, - 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x23, 0x32, 0x32, - 0x32, 0x32, 0x32, 0x32, 0x20, 0x31, 0x30, 0x30, 0x0a, 0x0a -}; +unsigned char themes_tint2rc[] = + {0x23, 0x2d, 0x2d, 0x2d, 0x2d, 0x20, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x64, 0x20, 0x62, 0x79, 0x20, + 0x74, 0x69, 0x6e, 0x74, 0x32, 0x63, 0x6f, 0x6e, 0x66, 0x20, 0x32, 0x36, 0x34, 0x31, 0x20, 0x2d, 0x2d, 0x2d, 0x2d, + 0x0a, 0x23, 0x20, 0x53, 0x65, 0x65, 0x20, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x67, 0x69, 0x74, 0x6c, + 0x61, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6f, 0x39, 0x30, 0x30, 0x30, 0x2f, 0x74, 0x69, 0x6e, 0x74, 0x32, 0x2f, + 0x77, 0x69, 0x6b, 0x69, 0x73, 0x2f, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x65, 0x20, 0x66, 0x6f, 0x72, + 0x20, 0x0a, 0x23, 0x20, 0x66, 0x75, 0x6c, 0x6c, 0x20, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x20, 0x6f, 0x66, 0x20, 0x74, 0x68, 0x65, 0x20, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x0a, 0x23, 0x2d, 0x2d, 0x2d, + 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, + 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, 0x23, 0x20, 0x42, + 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x73, 0x0a, 0x23, 0x20, 0x42, 0x61, 0x63, 0x6b, 0x67, 0x72, + 0x6f, 0x75, 0x6e, 0x64, 0x20, 0x31, 0x3a, 0x20, 0x50, 0x61, 0x6e, 0x65, 0x6c, 0x0a, 0x72, 0x6f, 0x75, 0x6e, 0x64, + 0x65, 0x64, 0x20, 0x3d, 0x20, 0x30, 0x0a, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x5f, 0x77, 0x69, 0x64, 0x74, 0x68, + 0x20, 0x3d, 0x20, 0x30, 0x0a, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x63, 0x6f, 0x6c, + 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x23, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x20, 0x36, 0x30, 0x0a, 0x62, 0x6f, 0x72, + 0x64, 0x65, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x23, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x20, 0x33, 0x30, 0x0a, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, + 0x72, 0x5f, 0x68, 0x6f, 0x76, 0x65, 0x72, 0x20, 0x3d, 0x20, 0x23, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x20, 0x36, + 0x30, 0x0a, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x68, 0x6f, 0x76, 0x65, + 0x72, 0x20, 0x3d, 0x20, 0x23, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x20, 0x33, 0x30, 0x0a, 0x62, 0x61, 0x63, 0x6b, + 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x70, 0x72, 0x65, 0x73, 0x73, 0x65, + 0x64, 0x20, 0x3d, 0x20, 0x23, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x20, 0x36, 0x30, 0x0a, 0x62, 0x6f, 0x72, 0x64, + 0x65, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x70, 0x72, 0x65, 0x73, 0x73, 0x65, 0x64, 0x20, 0x3d, 0x20, + 0x23, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x20, 0x33, 0x30, 0x0a, 0x0a, 0x23, 0x20, 0x42, 0x61, 0x63, 0x6b, 0x67, + 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x20, 0x32, 0x3a, 0x20, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x20, 0x74, 0x61, + 0x73, 0x6b, 0x2c, 0x20, 0x49, 0x63, 0x6f, 0x6e, 0x69, 0x66, 0x69, 0x65, 0x64, 0x20, 0x74, 0x61, 0x73, 0x6b, 0x0a, + 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x65, 0x64, 0x20, 0x3d, 0x20, 0x34, 0x0a, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x5f, + 0x77, 0x69, 0x64, 0x74, 0x68, 0x20, 0x3d, 0x20, 0x31, 0x0a, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, + 0x64, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x23, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x20, 0x32, + 0x30, 0x0a, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x23, 0x37, + 0x37, 0x37, 0x37, 0x37, 0x37, 0x20, 0x33, 0x30, 0x0a, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, + 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x68, 0x6f, 0x76, 0x65, 0x72, 0x20, 0x3d, 0x20, 0x23, 0x61, 0x61, 0x61, + 0x61, 0x61, 0x61, 0x20, 0x32, 0x32, 0x0a, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, + 0x5f, 0x68, 0x6f, 0x76, 0x65, 0x72, 0x20, 0x3d, 0x20, 0x23, 0x65, 0x61, 0x65, 0x61, 0x65, 0x61, 0x20, 0x34, 0x34, + 0x0a, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x70, + 0x72, 0x65, 0x73, 0x73, 0x65, 0x64, 0x20, 0x3d, 0x20, 0x23, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x20, 0x34, 0x0a, + 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x70, 0x72, 0x65, 0x73, 0x73, 0x65, + 0x64, 0x20, 0x3d, 0x20, 0x23, 0x65, 0x61, 0x65, 0x61, 0x65, 0x61, 0x20, 0x34, 0x34, 0x0a, 0x0a, 0x23, 0x20, 0x42, + 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x20, 0x33, 0x3a, 0x20, 0x41, 0x63, 0x74, 0x69, 0x76, 0x65, + 0x20, 0x74, 0x61, 0x73, 0x6b, 0x0a, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x65, 0x64, 0x20, 0x3d, 0x20, 0x34, 0x0a, 0x62, + 0x6f, 0x72, 0x64, 0x65, 0x72, 0x5f, 0x77, 0x69, 0x64, 0x74, 0x68, 0x20, 0x3d, 0x20, 0x31, 0x0a, 0x62, 0x61, 0x63, + 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x23, 0x37, 0x37, + 0x37, 0x37, 0x37, 0x37, 0x20, 0x32, 0x30, 0x0a, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, + 0x72, 0x20, 0x3d, 0x20, 0x23, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x20, 0x34, 0x30, 0x0a, 0x62, 0x61, 0x63, 0x6b, + 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x68, 0x6f, 0x76, 0x65, 0x72, 0x20, + 0x3d, 0x20, 0x23, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x20, 0x32, 0x32, 0x0a, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, + 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x68, 0x6f, 0x76, 0x65, 0x72, 0x20, 0x3d, 0x20, 0x23, 0x65, 0x61, 0x65, + 0x61, 0x65, 0x61, 0x20, 0x34, 0x34, 0x0a, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x63, + 0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x70, 0x72, 0x65, 0x73, 0x73, 0x65, 0x64, 0x20, 0x3d, 0x20, 0x23, 0x35, 0x35, 0x35, + 0x35, 0x35, 0x35, 0x20, 0x34, 0x0a, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, + 0x70, 0x72, 0x65, 0x73, 0x73, 0x65, 0x64, 0x20, 0x3d, 0x20, 0x23, 0x65, 0x61, 0x65, 0x61, 0x65, 0x61, 0x20, 0x34, + 0x34, 0x0a, 0x0a, 0x23, 0x20, 0x42, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x20, 0x34, 0x3a, 0x20, + 0x55, 0x72, 0x67, 0x65, 0x6e, 0x74, 0x20, 0x74, 0x61, 0x73, 0x6b, 0x0a, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x65, 0x64, + 0x20, 0x3d, 0x20, 0x34, 0x0a, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x5f, 0x77, 0x69, 0x64, 0x74, 0x68, 0x20, 0x3d, + 0x20, 0x31, 0x0a, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, + 0x20, 0x3d, 0x20, 0x23, 0x61, 0x61, 0x34, 0x34, 0x30, 0x30, 0x20, 0x31, 0x30, 0x30, 0x0a, 0x62, 0x6f, 0x72, 0x64, + 0x65, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x23, 0x61, 0x61, 0x37, 0x37, 0x33, 0x33, 0x20, + 0x31, 0x30, 0x30, 0x0a, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, + 0x72, 0x5f, 0x68, 0x6f, 0x76, 0x65, 0x72, 0x20, 0x3d, 0x20, 0x23, 0x63, 0x63, 0x37, 0x37, 0x30, 0x30, 0x20, 0x31, + 0x30, 0x30, 0x0a, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x68, 0x6f, 0x76, + 0x65, 0x72, 0x20, 0x3d, 0x20, 0x23, 0x61, 0x61, 0x37, 0x37, 0x33, 0x33, 0x20, 0x31, 0x30, 0x30, 0x0a, 0x62, 0x61, + 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x70, 0x72, 0x65, 0x73, + 0x73, 0x65, 0x64, 0x20, 0x3d, 0x20, 0x23, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x20, 0x34, 0x0a, 0x62, 0x6f, 0x72, + 0x64, 0x65, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x70, 0x72, 0x65, 0x73, 0x73, 0x65, 0x64, 0x20, 0x3d, + 0x20, 0x23, 0x61, 0x61, 0x37, 0x37, 0x33, 0x33, 0x20, 0x31, 0x30, 0x30, 0x0a, 0x0a, 0x23, 0x20, 0x42, 0x61, 0x63, + 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x20, 0x35, 0x3a, 0x20, 0x54, 0x6f, 0x6f, 0x6c, 0x74, 0x69, 0x70, 0x0a, + 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x65, 0x64, 0x20, 0x3d, 0x20, 0x31, 0x0a, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x5f, + 0x77, 0x69, 0x64, 0x74, 0x68, 0x20, 0x3d, 0x20, 0x31, 0x0a, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, + 0x64, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x23, 0x66, 0x66, 0x66, 0x66, 0x61, 0x61, 0x20, 0x31, + 0x30, 0x30, 0x0a, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x23, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x20, 0x31, 0x30, 0x30, 0x0a, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, + 0x6e, 0x64, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x68, 0x6f, 0x76, 0x65, 0x72, 0x20, 0x3d, 0x20, 0x23, 0x66, + 0x66, 0x66, 0x66, 0x61, 0x61, 0x20, 0x31, 0x30, 0x30, 0x0a, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x5f, 0x63, 0x6f, + 0x6c, 0x6f, 0x72, 0x5f, 0x68, 0x6f, 0x76, 0x65, 0x72, 0x20, 0x3d, 0x20, 0x23, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x20, 0x31, 0x30, 0x30, 0x0a, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x63, 0x6f, 0x6c, + 0x6f, 0x72, 0x5f, 0x70, 0x72, 0x65, 0x73, 0x73, 0x65, 0x64, 0x20, 0x3d, 0x20, 0x23, 0x66, 0x66, 0x66, 0x66, 0x61, + 0x61, 0x20, 0x31, 0x30, 0x30, 0x0a, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, + 0x70, 0x72, 0x65, 0x73, 0x73, 0x65, 0x64, 0x20, 0x3d, 0x20, 0x23, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x20, 0x31, + 0x30, 0x30, 0x0a, 0x0a, 0x23, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, + 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, + 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, 0x23, 0x20, 0x50, 0x61, 0x6e, 0x65, 0x6c, 0x0a, 0x70, 0x61, 0x6e, 0x65, 0x6c, 0x5f, + 0x69, 0x74, 0x65, 0x6d, 0x73, 0x20, 0x3d, 0x20, 0x4c, 0x54, 0x53, 0x43, 0x0a, 0x70, 0x61, 0x6e, 0x65, 0x6c, 0x5f, + 0x73, 0x69, 0x7a, 0x65, 0x20, 0x3d, 0x20, 0x31, 0x30, 0x30, 0x25, 0x20, 0x33, 0x30, 0x0a, 0x70, 0x61, 0x6e, 0x65, + 0x6c, 0x5f, 0x6d, 0x61, 0x72, 0x67, 0x69, 0x6e, 0x20, 0x3d, 0x20, 0x30, 0x20, 0x30, 0x0a, 0x70, 0x61, 0x6e, 0x65, + 0x6c, 0x5f, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x20, 0x3d, 0x20, 0x32, 0x20, 0x30, 0x20, 0x32, 0x0a, 0x70, + 0x61, 0x6e, 0x65, 0x6c, 0x5f, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x69, 0x64, 0x20, + 0x3d, 0x20, 0x31, 0x0a, 0x77, 0x6d, 0x5f, 0x6d, 0x65, 0x6e, 0x75, 0x20, 0x3d, 0x20, 0x31, 0x0a, 0x70, 0x61, 0x6e, + 0x65, 0x6c, 0x5f, 0x64, 0x6f, 0x63, 0x6b, 0x20, 0x3d, 0x20, 0x30, 0x0a, 0x70, 0x61, 0x6e, 0x65, 0x6c, 0x5f, 0x70, + 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x3d, 0x20, 0x62, 0x6f, 0x74, 0x74, 0x6f, 0x6d, 0x20, 0x63, 0x65, + 0x6e, 0x74, 0x65, 0x72, 0x20, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x6f, 0x6e, 0x74, 0x61, 0x6c, 0x0a, 0x70, 0x61, 0x6e, + 0x65, 0x6c, 0x5f, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x20, 0x3d, 0x20, 0x74, 0x6f, 0x70, 0x0a, 0x70, 0x61, 0x6e, 0x65, + 0x6c, 0x5f, 0x6d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x61, 0x6c, 0x6c, 0x0a, 0x70, 0x72, 0x69, + 0x6d, 0x61, 0x72, 0x79, 0x5f, 0x6d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x5f, 0x66, 0x69, 0x72, 0x73, 0x74, 0x20, + 0x3d, 0x20, 0x30, 0x0a, 0x61, 0x75, 0x74, 0x6f, 0x68, 0x69, 0x64, 0x65, 0x20, 0x3d, 0x20, 0x30, 0x0a, 0x61, 0x75, + 0x74, 0x6f, 0x68, 0x69, 0x64, 0x65, 0x5f, 0x73, 0x68, 0x6f, 0x77, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, + 0x20, 0x3d, 0x20, 0x30, 0x0a, 0x61, 0x75, 0x74, 0x6f, 0x68, 0x69, 0x64, 0x65, 0x5f, 0x68, 0x69, 0x64, 0x65, 0x5f, + 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x20, 0x3d, 0x20, 0x30, 0x2e, 0x35, 0x0a, 0x61, 0x75, 0x74, 0x6f, 0x68, + 0x69, 0x64, 0x65, 0x5f, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x20, 0x3d, 0x20, 0x32, 0x0a, 0x73, 0x74, 0x72, 0x75, + 0x74, 0x5f, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x20, 0x3d, 0x20, 0x66, 0x6f, 0x6c, 0x6c, 0x6f, 0x77, 0x5f, 0x73, + 0x69, 0x7a, 0x65, 0x0a, 0x70, 0x61, 0x6e, 0x65, 0x6c, 0x5f, 0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x5f, 0x6e, 0x61, + 0x6d, 0x65, 0x20, 0x3d, 0x20, 0x74, 0x69, 0x6e, 0x74, 0x32, 0x0a, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x5f, + 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x20, 0x3d, 0x20, 0x31, 0x0a, 0x6d, 0x6f, + 0x75, 0x73, 0x65, 0x5f, 0x65, 0x66, 0x66, 0x65, 0x63, 0x74, 0x73, 0x20, 0x3d, 0x20, 0x31, 0x0a, 0x66, 0x6f, 0x6e, + 0x74, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x20, 0x3d, 0x20, 0x30, 0x0a, 0x6d, 0x6f, 0x75, 0x73, 0x65, 0x5f, + 0x68, 0x6f, 0x76, 0x65, 0x72, 0x5f, 0x69, 0x63, 0x6f, 0x6e, 0x5f, 0x61, 0x73, 0x62, 0x20, 0x3d, 0x20, 0x31, 0x30, + 0x30, 0x20, 0x30, 0x20, 0x31, 0x30, 0x0a, 0x6d, 0x6f, 0x75, 0x73, 0x65, 0x5f, 0x70, 0x72, 0x65, 0x73, 0x73, 0x65, + 0x64, 0x5f, 0x69, 0x63, 0x6f, 0x6e, 0x5f, 0x61, 0x73, 0x62, 0x20, 0x3d, 0x20, 0x31, 0x30, 0x30, 0x20, 0x30, 0x20, + 0x30, 0x0a, 0x0a, 0x23, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, + 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, + 0x2d, 0x2d, 0x2d, 0x0a, 0x23, 0x20, 0x54, 0x61, 0x73, 0x6b, 0x62, 0x61, 0x72, 0x0a, 0x74, 0x61, 0x73, 0x6b, 0x62, + 0x61, 0x72, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x20, 0x3d, 0x20, 0x73, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x5f, 0x64, 0x65, + 0x73, 0x6b, 0x74, 0x6f, 0x70, 0x0a, 0x74, 0x61, 0x73, 0x6b, 0x62, 0x61, 0x72, 0x5f, 0x70, 0x61, 0x64, 0x64, 0x69, + 0x6e, 0x67, 0x20, 0x3d, 0x20, 0x30, 0x20, 0x30, 0x20, 0x32, 0x0a, 0x74, 0x61, 0x73, 0x6b, 0x62, 0x61, 0x72, 0x5f, + 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x69, 0x64, 0x20, 0x3d, 0x20, 0x30, 0x0a, 0x74, + 0x61, 0x73, 0x6b, 0x62, 0x61, 0x72, 0x5f, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x5f, 0x62, 0x61, 0x63, 0x6b, 0x67, + 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x69, 0x64, 0x20, 0x3d, 0x20, 0x30, 0x0a, 0x74, 0x61, 0x73, 0x6b, 0x62, 0x61, + 0x72, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x20, 0x3d, 0x20, 0x31, 0x0a, 0x74, 0x61, 0x73, 0x6b, 0x62, 0x61, 0x72, 0x5f, + 0x68, 0x69, 0x64, 0x65, 0x5f, 0x69, 0x6e, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x5f, 0x74, 0x61, 0x73, 0x6b, 0x73, + 0x20, 0x3d, 0x20, 0x30, 0x0a, 0x74, 0x61, 0x73, 0x6b, 0x62, 0x61, 0x72, 0x5f, 0x68, 0x69, 0x64, 0x65, 0x5f, 0x64, + 0x69, 0x66, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x6d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x20, 0x3d, 0x20, + 0x30, 0x0a, 0x74, 0x61, 0x73, 0x6b, 0x62, 0x61, 0x72, 0x5f, 0x61, 0x6c, 0x77, 0x61, 0x79, 0x73, 0x5f, 0x73, 0x68, + 0x6f, 0x77, 0x5f, 0x61, 0x6c, 0x6c, 0x5f, 0x64, 0x65, 0x73, 0x6b, 0x74, 0x6f, 0x70, 0x5f, 0x74, 0x61, 0x73, 0x6b, + 0x73, 0x20, 0x3d, 0x20, 0x30, 0x0a, 0x74, 0x61, 0x73, 0x6b, 0x62, 0x61, 0x72, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x5f, + 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x20, 0x3d, 0x20, 0x34, 0x20, 0x32, 0x0a, 0x74, 0x61, 0x73, 0x6b, 0x62, + 0x61, 0x72, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x5f, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, + 0x69, 0x64, 0x20, 0x3d, 0x20, 0x30, 0x0a, 0x74, 0x61, 0x73, 0x6b, 0x62, 0x61, 0x72, 0x5f, 0x6e, 0x61, 0x6d, 0x65, + 0x5f, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x5f, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, + 0x69, 0x64, 0x20, 0x3d, 0x20, 0x30, 0x0a, 0x74, 0x61, 0x73, 0x6b, 0x62, 0x61, 0x72, 0x5f, 0x6e, 0x61, 0x6d, 0x65, + 0x5f, 0x66, 0x6f, 0x6e, 0x74, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x23, 0x65, 0x33, 0x65, 0x33, + 0x65, 0x33, 0x20, 0x31, 0x30, 0x30, 0x0a, 0x74, 0x61, 0x73, 0x6b, 0x62, 0x61, 0x72, 0x5f, 0x6e, 0x61, 0x6d, 0x65, + 0x5f, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x5f, 0x66, 0x6f, 0x6e, 0x74, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x20, + 0x3d, 0x20, 0x23, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x20, 0x31, 0x30, 0x30, 0x0a, 0x74, 0x61, 0x73, 0x6b, 0x62, + 0x61, 0x72, 0x5f, 0x64, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x20, + 0x3d, 0x20, 0x30, 0x0a, 0x74, 0x61, 0x73, 0x6b, 0x62, 0x61, 0x72, 0x5f, 0x73, 0x6f, 0x72, 0x74, 0x5f, 0x6f, 0x72, + 0x64, 0x65, 0x72, 0x20, 0x3d, 0x20, 0x6e, 0x6f, 0x6e, 0x65, 0x0a, 0x74, 0x61, 0x73, 0x6b, 0x5f, 0x61, 0x6c, 0x69, + 0x67, 0x6e, 0x20, 0x3d, 0x20, 0x6c, 0x65, 0x66, 0x74, 0x0a, 0x0a, 0x23, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, + 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, + 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, 0x23, 0x20, 0x54, 0x61, 0x73, 0x6b, 0x0a, + 0x74, 0x61, 0x73, 0x6b, 0x5f, 0x74, 0x65, 0x78, 0x74, 0x20, 0x3d, 0x20, 0x31, 0x0a, 0x74, 0x61, 0x73, 0x6b, 0x5f, + 0x69, 0x63, 0x6f, 0x6e, 0x20, 0x3d, 0x20, 0x31, 0x0a, 0x74, 0x61, 0x73, 0x6b, 0x5f, 0x63, 0x65, 0x6e, 0x74, 0x65, + 0x72, 0x65, 0x64, 0x20, 0x3d, 0x20, 0x31, 0x0a, 0x75, 0x72, 0x67, 0x65, 0x6e, 0x74, 0x5f, 0x6e, 0x62, 0x5f, 0x6f, + 0x66, 0x5f, 0x62, 0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x3d, 0x20, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x0a, 0x74, 0x61, + 0x73, 0x6b, 0x5f, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x20, 0x3d, 0x20, 0x31, + 0x35, 0x30, 0x20, 0x33, 0x35, 0x0a, 0x74, 0x61, 0x73, 0x6b, 0x5f, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x20, + 0x3d, 0x20, 0x32, 0x20, 0x32, 0x20, 0x34, 0x0a, 0x74, 0x61, 0x73, 0x6b, 0x5f, 0x74, 0x6f, 0x6f, 0x6c, 0x74, 0x69, + 0x70, 0x20, 0x3d, 0x20, 0x31, 0x0a, 0x74, 0x61, 0x73, 0x6b, 0x5f, 0x66, 0x6f, 0x6e, 0x74, 0x5f, 0x63, 0x6f, 0x6c, + 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x23, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x20, 0x31, 0x30, 0x30, 0x0a, 0x74, 0x61, + 0x73, 0x6b, 0x5f, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x69, 0x64, 0x20, 0x3d, 0x20, + 0x32, 0x0a, 0x74, 0x61, 0x73, 0x6b, 0x5f, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x5f, 0x62, 0x61, 0x63, 0x6b, 0x67, + 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x69, 0x64, 0x20, 0x3d, 0x20, 0x33, 0x0a, 0x74, 0x61, 0x73, 0x6b, 0x5f, 0x75, + 0x72, 0x67, 0x65, 0x6e, 0x74, 0x5f, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x69, 0x64, + 0x20, 0x3d, 0x20, 0x34, 0x0a, 0x74, 0x61, 0x73, 0x6b, 0x5f, 0x69, 0x63, 0x6f, 0x6e, 0x69, 0x66, 0x69, 0x65, 0x64, + 0x5f, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x69, 0x64, 0x20, 0x3d, 0x20, 0x32, 0x0a, + 0x6d, 0x6f, 0x75, 0x73, 0x65, 0x5f, 0x6c, 0x65, 0x66, 0x74, 0x20, 0x3d, 0x20, 0x74, 0x6f, 0x67, 0x67, 0x6c, 0x65, + 0x5f, 0x69, 0x63, 0x6f, 0x6e, 0x69, 0x66, 0x79, 0x0a, 0x6d, 0x6f, 0x75, 0x73, 0x65, 0x5f, 0x6d, 0x69, 0x64, 0x64, + 0x6c, 0x65, 0x20, 0x3d, 0x20, 0x6e, 0x6f, 0x6e, 0x65, 0x0a, 0x6d, 0x6f, 0x75, 0x73, 0x65, 0x5f, 0x72, 0x69, 0x67, + 0x68, 0x74, 0x20, 0x3d, 0x20, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0x0a, 0x6d, 0x6f, 0x75, 0x73, 0x65, 0x5f, 0x73, 0x63, + 0x72, 0x6f, 0x6c, 0x6c, 0x5f, 0x75, 0x70, 0x20, 0x3d, 0x20, 0x74, 0x6f, 0x67, 0x67, 0x6c, 0x65, 0x0a, 0x6d, 0x6f, + 0x75, 0x73, 0x65, 0x5f, 0x73, 0x63, 0x72, 0x6f, 0x6c, 0x6c, 0x5f, 0x64, 0x6f, 0x77, 0x6e, 0x20, 0x3d, 0x20, 0x69, + 0x63, 0x6f, 0x6e, 0x69, 0x66, 0x79, 0x0a, 0x0a, 0x23, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, + 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, + 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, 0x23, 0x20, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x20, 0x74, + 0x72, 0x61, 0x79, 0x20, 0x28, 0x6e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x61, + 0x72, 0x65, 0x61, 0x29, 0x0a, 0x73, 0x79, 0x73, 0x74, 0x72, 0x61, 0x79, 0x5f, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, + 0x67, 0x20, 0x3d, 0x20, 0x30, 0x20, 0x34, 0x20, 0x32, 0x0a, 0x73, 0x79, 0x73, 0x74, 0x72, 0x61, 0x79, 0x5f, 0x62, + 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x69, 0x64, 0x20, 0x3d, 0x20, 0x30, 0x0a, 0x73, 0x79, + 0x73, 0x74, 0x72, 0x61, 0x79, 0x5f, 0x73, 0x6f, 0x72, 0x74, 0x20, 0x3d, 0x20, 0x61, 0x73, 0x63, 0x65, 0x6e, 0x64, + 0x69, 0x6e, 0x67, 0x0a, 0x73, 0x79, 0x73, 0x74, 0x72, 0x61, 0x79, 0x5f, 0x69, 0x63, 0x6f, 0x6e, 0x5f, 0x73, 0x69, + 0x7a, 0x65, 0x20, 0x3d, 0x20, 0x32, 0x34, 0x0a, 0x73, 0x79, 0x73, 0x74, 0x72, 0x61, 0x79, 0x5f, 0x69, 0x63, 0x6f, + 0x6e, 0x5f, 0x61, 0x73, 0x62, 0x20, 0x3d, 0x20, 0x31, 0x30, 0x30, 0x20, 0x30, 0x20, 0x30, 0x0a, 0x73, 0x79, 0x73, + 0x74, 0x72, 0x61, 0x79, 0x5f, 0x6d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x31, 0x0a, 0x0a, 0x23, + 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, + 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, + 0x23, 0x20, 0x4c, 0x61, 0x75, 0x6e, 0x63, 0x68, 0x65, 0x72, 0x0a, 0x6c, 0x61, 0x75, 0x6e, 0x63, 0x68, 0x65, 0x72, + 0x5f, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x20, 0x3d, 0x20, 0x32, 0x20, 0x34, 0x20, 0x32, 0x0a, 0x6c, 0x61, + 0x75, 0x6e, 0x63, 0x68, 0x65, 0x72, 0x5f, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x69, + 0x64, 0x20, 0x3d, 0x20, 0x30, 0x0a, 0x6c, 0x61, 0x75, 0x6e, 0x63, 0x68, 0x65, 0x72, 0x5f, 0x69, 0x63, 0x6f, 0x6e, + 0x5f, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x69, 0x64, 0x20, 0x3d, 0x20, 0x30, 0x0a, + 0x6c, 0x61, 0x75, 0x6e, 0x63, 0x68, 0x65, 0x72, 0x5f, 0x69, 0x63, 0x6f, 0x6e, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x20, + 0x3d, 0x20, 0x32, 0x34, 0x0a, 0x6c, 0x61, 0x75, 0x6e, 0x63, 0x68, 0x65, 0x72, 0x5f, 0x69, 0x63, 0x6f, 0x6e, 0x5f, + 0x61, 0x73, 0x62, 0x20, 0x3d, 0x20, 0x31, 0x30, 0x30, 0x20, 0x30, 0x20, 0x30, 0x0a, 0x6c, 0x61, 0x75, 0x6e, 0x63, + 0x68, 0x65, 0x72, 0x5f, 0x69, 0x63, 0x6f, 0x6e, 0x5f, 0x74, 0x68, 0x65, 0x6d, 0x65, 0x5f, 0x6f, 0x76, 0x65, 0x72, + 0x72, 0x69, 0x64, 0x65, 0x20, 0x3d, 0x20, 0x30, 0x0a, 0x73, 0x74, 0x61, 0x72, 0x74, 0x75, 0x70, 0x5f, 0x6e, 0x6f, + 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x20, 0x3d, 0x20, 0x31, 0x0a, 0x6c, 0x61, 0x75, + 0x6e, 0x63, 0x68, 0x65, 0x72, 0x5f, 0x74, 0x6f, 0x6f, 0x6c, 0x74, 0x69, 0x70, 0x20, 0x3d, 0x20, 0x31, 0x0a, 0x6c, + 0x61, 0x75, 0x6e, 0x63, 0x68, 0x65, 0x72, 0x5f, 0x69, 0x74, 0x65, 0x6d, 0x5f, 0x61, 0x70, 0x70, 0x20, 0x3d, 0x20, + 0x2f, 0x75, 0x73, 0x72, 0x2f, 0x73, 0x68, 0x61, 0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x74, 0x69, 0x6e, 0x74, 0x32, 0x63, 0x6f, 0x6e, 0x66, 0x2e, 0x64, 0x65, 0x73, 0x6b, + 0x74, 0x6f, 0x70, 0x0a, 0x6c, 0x61, 0x75, 0x6e, 0x63, 0x68, 0x65, 0x72, 0x5f, 0x69, 0x74, 0x65, 0x6d, 0x5f, 0x61, + 0x70, 0x70, 0x20, 0x3d, 0x20, 0x2f, 0x75, 0x73, 0x72, 0x2f, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x2f, 0x73, 0x68, 0x61, + 0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x74, 0x69, 0x6e, + 0x74, 0x32, 0x63, 0x6f, 0x6e, 0x66, 0x2e, 0x64, 0x65, 0x73, 0x6b, 0x74, 0x6f, 0x70, 0x0a, 0x6c, 0x61, 0x75, 0x6e, + 0x63, 0x68, 0x65, 0x72, 0x5f, 0x69, 0x74, 0x65, 0x6d, 0x5f, 0x61, 0x70, 0x70, 0x20, 0x3d, 0x20, 0x2f, 0x75, 0x73, + 0x72, 0x2f, 0x73, 0x68, 0x61, 0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x73, 0x2f, 0x66, 0x69, 0x72, 0x65, 0x66, 0x6f, 0x78, 0x2e, 0x64, 0x65, 0x73, 0x6b, 0x74, 0x6f, 0x70, 0x0a, 0x6c, + 0x61, 0x75, 0x6e, 0x63, 0x68, 0x65, 0x72, 0x5f, 0x69, 0x74, 0x65, 0x6d, 0x5f, 0x61, 0x70, 0x70, 0x20, 0x3d, 0x20, + 0x2f, 0x75, 0x73, 0x72, 0x2f, 0x73, 0x68, 0x61, 0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x69, 0x63, 0x65, 0x77, 0x65, 0x61, 0x73, 0x65, 0x6c, 0x2e, 0x64, 0x65, 0x73, 0x6b, + 0x74, 0x6f, 0x70, 0x0a, 0x6c, 0x61, 0x75, 0x6e, 0x63, 0x68, 0x65, 0x72, 0x5f, 0x69, 0x74, 0x65, 0x6d, 0x5f, 0x61, + 0x70, 0x70, 0x20, 0x3d, 0x20, 0x2f, 0x75, 0x73, 0x72, 0x2f, 0x73, 0x68, 0x61, 0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, + 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x63, 0x68, 0x72, 0x6f, 0x6d, 0x69, 0x75, 0x6d, 0x2d, + 0x62, 0x72, 0x6f, 0x77, 0x73, 0x65, 0x72, 0x2e, 0x64, 0x65, 0x73, 0x6b, 0x74, 0x6f, 0x70, 0x0a, 0x6c, 0x61, 0x75, + 0x6e, 0x63, 0x68, 0x65, 0x72, 0x5f, 0x69, 0x74, 0x65, 0x6d, 0x5f, 0x61, 0x70, 0x70, 0x20, 0x3d, 0x20, 0x2f, 0x75, + 0x73, 0x72, 0x2f, 0x73, 0x68, 0x61, 0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x73, 0x2f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2d, 0x63, 0x68, 0x72, 0x6f, 0x6d, 0x65, 0x2e, 0x64, 0x65, + 0x73, 0x6b, 0x74, 0x6f, 0x70, 0x0a, 0x0a, 0x23, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, + 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, + 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, 0x23, 0x20, 0x43, 0x6c, 0x6f, 0x63, 0x6b, 0x0a, 0x74, 0x69, 0x6d, + 0x65, 0x31, 0x5f, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x20, 0x3d, 0x20, 0x25, 0x48, 0x3a, 0x25, 0x4d, 0x0a, 0x74, + 0x69, 0x6d, 0x65, 0x32, 0x5f, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x20, 0x3d, 0x20, 0x25, 0x41, 0x20, 0x25, 0x64, + 0x20, 0x25, 0x42, 0x0a, 0x74, 0x69, 0x6d, 0x65, 0x31, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x7a, 0x6f, 0x6e, 0x65, 0x20, + 0x3d, 0x20, 0x0a, 0x74, 0x69, 0x6d, 0x65, 0x32, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x7a, 0x6f, 0x6e, 0x65, 0x20, 0x3d, + 0x20, 0x0a, 0x63, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x66, 0x6f, 0x6e, 0x74, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x20, + 0x3d, 0x20, 0x23, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x20, 0x31, 0x30, 0x30, 0x0a, 0x63, 0x6c, 0x6f, 0x63, 0x6b, + 0x5f, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x20, 0x3d, 0x20, 0x32, 0x20, 0x30, 0x0a, 0x63, 0x6c, 0x6f, 0x63, + 0x6b, 0x5f, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x69, 0x64, 0x20, 0x3d, 0x20, 0x30, + 0x0a, 0x63, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x74, 0x6f, 0x6f, 0x6c, 0x74, 0x69, 0x70, 0x20, 0x3d, 0x20, 0x0a, 0x63, + 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x74, 0x6f, 0x6f, 0x6c, 0x74, 0x69, 0x70, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x7a, 0x6f, + 0x6e, 0x65, 0x20, 0x3d, 0x20, 0x0a, 0x63, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x6c, 0x63, 0x6c, 0x69, 0x63, 0x6b, 0x5f, + 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x20, 0x3d, 0x20, 0x0a, 0x63, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x72, 0x63, + 0x6c, 0x69, 0x63, 0x6b, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x20, 0x3d, 0x20, 0x6f, 0x72, 0x61, 0x67, + 0x65, 0x0a, 0x63, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x6d, 0x63, 0x6c, 0x69, 0x63, 0x6b, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, + 0x61, 0x6e, 0x64, 0x20, 0x3d, 0x20, 0x0a, 0x63, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x75, 0x77, 0x68, 0x65, 0x65, 0x6c, + 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x20, 0x3d, 0x20, 0x0a, 0x63, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x64, + 0x77, 0x68, 0x65, 0x65, 0x6c, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x20, 0x3d, 0x20, 0x0a, 0x0a, 0x23, + 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, + 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, + 0x23, 0x20, 0x42, 0x61, 0x74, 0x74, 0x65, 0x72, 0x79, 0x0a, 0x62, 0x61, 0x74, 0x74, 0x65, 0x72, 0x79, 0x5f, 0x74, + 0x6f, 0x6f, 0x6c, 0x74, 0x69, 0x70, 0x20, 0x3d, 0x20, 0x31, 0x0a, 0x62, 0x61, 0x74, 0x74, 0x65, 0x72, 0x79, 0x5f, + 0x6c, 0x6f, 0x77, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x20, 0x3d, 0x20, 0x31, 0x30, 0x0a, 0x62, 0x61, 0x74, + 0x74, 0x65, 0x72, 0x79, 0x5f, 0x6c, 0x6f, 0x77, 0x5f, 0x63, 0x6d, 0x64, 0x20, 0x3d, 0x20, 0x6e, 0x6f, 0x74, 0x69, + 0x66, 0x79, 0x2d, 0x73, 0x65, 0x6e, 0x64, 0x20, 0x22, 0x62, 0x61, 0x74, 0x74, 0x65, 0x72, 0x79, 0x20, 0x6c, 0x6f, + 0x77, 0x22, 0x0a, 0x62, 0x61, 0x74, 0x74, 0x65, 0x72, 0x79, 0x5f, 0x66, 0x6f, 0x6e, 0x74, 0x5f, 0x63, 0x6f, 0x6c, + 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x23, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x20, 0x31, 0x30, 0x30, 0x0a, 0x62, 0x61, + 0x74, 0x74, 0x65, 0x72, 0x79, 0x5f, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x20, 0x3d, 0x20, 0x31, 0x20, 0x30, + 0x0a, 0x62, 0x61, 0x74, 0x74, 0x65, 0x72, 0x79, 0x5f, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, + 0x5f, 0x69, 0x64, 0x20, 0x3d, 0x20, 0x30, 0x0a, 0x62, 0x61, 0x74, 0x74, 0x65, 0x72, 0x79, 0x5f, 0x68, 0x69, 0x64, + 0x65, 0x20, 0x3d, 0x20, 0x31, 0x30, 0x31, 0x0a, 0x62, 0x61, 0x74, 0x74, 0x65, 0x72, 0x79, 0x5f, 0x6c, 0x63, 0x6c, + 0x69, 0x63, 0x6b, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x20, 0x3d, 0x20, 0x0a, 0x62, 0x61, 0x74, 0x74, + 0x65, 0x72, 0x79, 0x5f, 0x72, 0x63, 0x6c, 0x69, 0x63, 0x6b, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x20, + 0x3d, 0x20, 0x0a, 0x62, 0x61, 0x74, 0x74, 0x65, 0x72, 0x79, 0x5f, 0x6d, 0x63, 0x6c, 0x69, 0x63, 0x6b, 0x5f, 0x63, + 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x20, 0x3d, 0x20, 0x0a, 0x62, 0x61, 0x74, 0x74, 0x65, 0x72, 0x79, 0x5f, 0x75, + 0x77, 0x68, 0x65, 0x65, 0x6c, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x20, 0x3d, 0x20, 0x0a, 0x62, 0x61, + 0x74, 0x74, 0x65, 0x72, 0x79, 0x5f, 0x64, 0x77, 0x68, 0x65, 0x65, 0x6c, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, + 0x64, 0x20, 0x3d, 0x20, 0x0a, 0x61, 0x63, 0x5f, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x65, 0x64, 0x5f, 0x63, + 0x6d, 0x64, 0x20, 0x3d, 0x20, 0x0a, 0x61, 0x63, 0x5f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, + 0x65, 0x64, 0x5f, 0x63, 0x6d, 0x64, 0x20, 0x3d, 0x20, 0x0a, 0x0a, 0x23, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, + 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, + 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, 0x23, 0x20, 0x54, 0x6f, 0x6f, 0x6c, 0x74, + 0x69, 0x70, 0x0a, 0x74, 0x6f, 0x6f, 0x6c, 0x74, 0x69, 0x70, 0x5f, 0x73, 0x68, 0x6f, 0x77, 0x5f, 0x74, 0x69, 0x6d, + 0x65, 0x6f, 0x75, 0x74, 0x20, 0x3d, 0x20, 0x30, 0x2e, 0x35, 0x0a, 0x74, 0x6f, 0x6f, 0x6c, 0x74, 0x69, 0x70, 0x5f, + 0x68, 0x69, 0x64, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x20, 0x3d, 0x20, 0x30, 0x2e, 0x31, 0x0a, + 0x74, 0x6f, 0x6f, 0x6c, 0x74, 0x69, 0x70, 0x5f, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x20, 0x3d, 0x20, 0x32, + 0x20, 0x32, 0x0a, 0x74, 0x6f, 0x6f, 0x6c, 0x74, 0x69, 0x70, 0x5f, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, + 0x6e, 0x64, 0x5f, 0x69, 0x64, 0x20, 0x3d, 0x20, 0x35, 0x0a, 0x74, 0x6f, 0x6f, 0x6c, 0x74, 0x69, 0x70, 0x5f, 0x66, + 0x6f, 0x6e, 0x74, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x23, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, + 0x20, 0x31, 0x30, 0x30, 0x0a, 0x0a}; unsigned int themes_tint2rc_len = 4870;
M src/tooltip/tooltip.csrc/tooltip/tooltip.c

@@ -41,290 +41,290 @@ Tooltip g_tooltip;

void default_tooltip() { - // give the tooltip some reasonable default values - memset(&g_tooltip, 0, sizeof(Tooltip)); + // give the tooltip some reasonable default values + memset(&g_tooltip, 0, sizeof(Tooltip)); - g_tooltip.font_color.rgb[0] = 1; - g_tooltip.font_color.rgb[1] = 1; - g_tooltip.font_color.rgb[2] = 1; - g_tooltip.font_color.alpha = 1; - just_shown = FALSE; + g_tooltip.font_color.rgb[0] = 1; + g_tooltip.font_color.rgb[1] = 1; + g_tooltip.font_color.rgb[2] = 1; + g_tooltip.font_color.alpha = 1; + just_shown = FALSE; } void cleanup_tooltip() { - stop_tooltip_timeout(); - tooltip_hide(NULL); - tooltip_copy_text(NULL); - if (g_tooltip.window) - XDestroyWindow(server.display, g_tooltip.window); - g_tooltip.window = 0; - pango_font_description_free(g_tooltip.font_desc); - g_tooltip.font_desc = NULL; + stop_tooltip_timeout(); + tooltip_hide(NULL); + tooltip_copy_text(NULL); + if (g_tooltip.window) + XDestroyWindow(server.display, g_tooltip.window); + g_tooltip.window = 0; + pango_font_description_free(g_tooltip.font_desc); + g_tooltip.font_desc = NULL; } void init_tooltip() { - if (!g_tooltip.bg) - g_tooltip.bg = &g_array_index(backgrounds, Background, 0); - tooltip_init_fonts(); + if (!g_tooltip.bg) + g_tooltip.bg = &g_array_index(backgrounds, Background, 0); + tooltip_init_fonts(); - XSetWindowAttributes attr; - attr.override_redirect = True; - attr.event_mask = StructureNotifyMask; - attr.colormap = server.colormap; - attr.background_pixel = 0; - attr.border_pixel = 0; - unsigned long mask = CWEventMask | CWColormap | CWBorderPixel | CWBackPixel | CWOverrideRedirect; - if (g_tooltip.window) - XDestroyWindow(server.display, g_tooltip.window); - g_tooltip.window = XCreateWindow(server.display, - server.root_win, - 0, - 0, - 100, - 20, - 0, - server.depth, - InputOutput, - server.visual, - mask, - &attr); + XSetWindowAttributes attr; + attr.override_redirect = True; + attr.event_mask = StructureNotifyMask; + attr.colormap = server.colormap; + attr.background_pixel = 0; + attr.border_pixel = 0; + unsigned long mask = CWEventMask | CWColormap | CWBorderPixel | CWBackPixel | CWOverrideRedirect; + if (g_tooltip.window) + XDestroyWindow(server.display, g_tooltip.window); + g_tooltip.window = XCreateWindow(server.display, + server.root_win, + 0, + 0, + 100, + 20, + 0, + server.depth, + InputOutput, + server.visual, + mask, + &attr); } void tooltip_init_fonts() { - if (!g_tooltip.font_desc) - g_tooltip.font_desc = pango_font_description_from_string(get_default_font()); + if (!g_tooltip.font_desc) + g_tooltip.font_desc = pango_font_description_from_string(get_default_font()); } void tooltip_default_font_changed() { - if (g_tooltip.has_font) - return; - if (!g_tooltip.has_font) { - pango_font_description_free(g_tooltip.font_desc); - g_tooltip.font_desc = NULL; - } - tooltip_init_fonts(); - tooltip_update(); + if (g_tooltip.has_font) + return; + if (!g_tooltip.has_font) { + pango_font_description_free(g_tooltip.font_desc); + g_tooltip.font_desc = NULL; + } + tooltip_init_fonts(); + tooltip_update(); } void tooltip_trigger_show(Area *area, Panel *p, XEvent *e) { - // Position the tooltip in the center of the area - x = area->posx + MIN(area->width / 3, 22) + e->xmotion.x_root - e->xmotion.x; - y = area->posy + area->height / 2 + e->xmotion.y_root - e->xmotion.y; - just_shown = TRUE; - g_tooltip.panel = p; - if (g_tooltip.mapped && g_tooltip.area != area) { - tooltip_copy_text(area); - tooltip_update(); - stop_tooltip_timeout(); - } else if (!g_tooltip.mapped) { - start_show_timeout(); - } + // Position the tooltip in the center of the area + x = area->posx + MIN(area->width / 3, 22) + e->xmotion.x_root - e->xmotion.x; + y = area->posy + area->height / 2 + e->xmotion.y_root - e->xmotion.y; + just_shown = TRUE; + g_tooltip.panel = p; + if (g_tooltip.mapped && g_tooltip.area != area) { + tooltip_copy_text(area); + tooltip_update(); + stop_tooltip_timeout(); + } else if (!g_tooltip.mapped) { + start_show_timeout(); + } } void tooltip_show(void *arg) { - int mx, my; - Window w; - XTranslateCoordinates(server.display, server.root_win, g_tooltip.panel->main_win, x, y, &mx, &my, &w); - Area *area = find_area_under_mouse(g_tooltip.panel, mx, my); - if (!g_tooltip.mapped && area->_get_tooltip_text) { - tooltip_copy_text(area); - g_tooltip.mapped = True; - XMapWindow(server.display, g_tooltip.window); - tooltip_update(); - XFlush(server.display); - } + int mx, my; + Window w; + XTranslateCoordinates(server.display, server.root_win, g_tooltip.panel->main_win, x, y, &mx, &my, &w); + Area *area = find_area_under_mouse(g_tooltip.panel, mx, my); + if (!g_tooltip.mapped && area->_get_tooltip_text) { + tooltip_copy_text(area); + g_tooltip.mapped = True; + XMapWindow(server.display, g_tooltip.window); + tooltip_update(); + XFlush(server.display); + } } void tooltip_update_geometry() { - Panel *panel = g_tooltip.panel; - int screen_width = server.monitors[panel->monitor].x + server.monitors[panel->monitor].width; + Panel *panel = g_tooltip.panel; + int screen_width = server.monitors[panel->monitor].x + server.monitors[panel->monitor].width; - cairo_surface_t *cs = cairo_xlib_surface_create(server.display, g_tooltip.window, server.visual, width, height); - cairo_t *c = cairo_create(cs); - PangoLayout *layout = pango_cairo_create_layout(c); + cairo_surface_t *cs = cairo_xlib_surface_create(server.display, g_tooltip.window, server.visual, width, height); + cairo_t *c = cairo_create(cs); + PangoLayout *layout = pango_cairo_create_layout(c); - pango_layout_set_font_description(layout, g_tooltip.font_desc); - PangoRectangle r1, r2; - pango_layout_set_text(layout, "1234567890", -1); - pango_layout_get_pixel_extents(layout, &r1, &r2); - int max_width = MIN(r2.width * 7, screen_width * 2 / 3); - pango_layout_set_width(layout, max_width * PANGO_SCALE); + pango_layout_set_font_description(layout, g_tooltip.font_desc); + PangoRectangle r1, r2; + pango_layout_set_text(layout, "1234567890", -1); + pango_layout_get_pixel_extents(layout, &r1, &r2); + int max_width = MIN(r2.width * 7, screen_width * 2 / 3); + pango_layout_set_width(layout, max_width * PANGO_SCALE); - pango_layout_set_text(layout, g_tooltip.tooltip_text, -1); - pango_layout_set_wrap(layout, PANGO_WRAP_WORD); - pango_layout_get_pixel_extents(layout, &r1, &r2); - width = left_right_bg_border_width(g_tooltip.bg) + 2 * g_tooltip.paddingx + r2.width; - height = top_bottom_bg_border_width(g_tooltip.bg) + 2 * g_tooltip.paddingy + r2.height; + pango_layout_set_text(layout, g_tooltip.tooltip_text, -1); + pango_layout_set_wrap(layout, PANGO_WRAP_WORD); + pango_layout_get_pixel_extents(layout, &r1, &r2); + width = left_right_bg_border_width(g_tooltip.bg) + 2 * g_tooltip.paddingx + r2.width; + height = top_bottom_bg_border_width(g_tooltip.bg) + 2 * g_tooltip.paddingy + r2.height; - if (panel_horizontal && panel_position & BOTTOM) - y = panel->posy - height; - else if (panel_horizontal && panel_position & TOP) - y = panel->posy + panel->area.height; - else if (panel_position & LEFT) - x = panel->posx + panel->area.width; - else - x = panel->posx - width; + if (panel_horizontal && panel_position & BOTTOM) + y = panel->posy - height; + else if (panel_horizontal && panel_position & TOP) + y = panel->posy + panel->area.height; + else if (panel_position & LEFT) + x = panel->posx + panel->area.width; + else + x = panel->posx - width; - g_object_unref(layout); - cairo_destroy(c); - cairo_surface_destroy(cs); + g_object_unref(layout); + cairo_destroy(c); + cairo_surface_destroy(cs); } void tooltip_adjust_geometry() { - // adjust coordinates and size to not go offscreen - // it seems quite impossible that the height needs to be adjusted, but we do it anyway. + // adjust coordinates and size to not go offscreen + // it seems quite impossible that the height needs to be adjusted, but we do it anyway. - Panel *panel = g_tooltip.panel; - int screen_width = server.monitors[panel->monitor].x + server.monitors[panel->monitor].width; - int screen_height = server.monitors[panel->monitor].y + server.monitors[panel->monitor].height; - if (x + width <= screen_width && y + height <= screen_height && x >= server.monitors[panel->monitor].x && - y >= server.monitors[panel->monitor].y) - return; // no adjustment needed + Panel *panel = g_tooltip.panel; + int screen_width = server.monitors[panel->monitor].x + server.monitors[panel->monitor].width; + int screen_height = server.monitors[panel->monitor].y + server.monitors[panel->monitor].height; + if (x + width <= screen_width && y + height <= screen_height && x >= server.monitors[panel->monitor].x && + y >= server.monitors[panel->monitor].y) + return; // no adjustment needed - int min_x, min_y, max_width, max_height; - if (panel_horizontal) { - min_x = 0; - max_width = server.monitors[panel->monitor].width; - max_height = server.monitors[panel->monitor].height - panel->area.height; - if (panel_position & BOTTOM) - min_y = 0; - else - min_y = panel->area.height; - } else { - max_width = server.monitors[panel->monitor].width - panel->area.width; - min_y = 0; - max_height = server.monitors[panel->monitor].height; - if (panel_position & LEFT) - min_x = panel->area.width; - else - min_x = 0; - } + int min_x, min_y, max_width, max_height; + if (panel_horizontal) { + min_x = 0; + max_width = server.monitors[panel->monitor].width; + max_height = server.monitors[panel->monitor].height - panel->area.height; + if (panel_position & BOTTOM) + min_y = 0; + else + min_y = panel->area.height; + } else { + max_width = server.monitors[panel->monitor].width - panel->area.width; + min_y = 0; + max_height = server.monitors[panel->monitor].height; + if (panel_position & LEFT) + min_x = panel->area.width; + else + min_x = 0; + } - if (x + width > server.monitors[panel->monitor].x + server.monitors[panel->monitor].width) - x = server.monitors[panel->monitor].x + server.monitors[panel->monitor].width - width; - if (y + height > server.monitors[panel->monitor].y + server.monitors[panel->monitor].height) - y = server.monitors[panel->monitor].y + server.monitors[panel->monitor].height - height; + if (x + width > server.monitors[panel->monitor].x + server.monitors[panel->monitor].width) + x = server.monitors[panel->monitor].x + server.monitors[panel->monitor].width - width; + if (y + height > server.monitors[panel->monitor].y + server.monitors[panel->monitor].height) + y = server.monitors[panel->monitor].y + server.monitors[panel->monitor].height - height; - if (x < min_x) - x = min_x; - if (width > max_width) - width = max_width; - if (y < min_y) - y = min_y; - if (height > max_height) - height = max_height; + if (x < min_x) + x = min_x; + if (width > max_width) + width = max_width; + if (y < min_y) + y = min_y; + if (height > max_height) + height = max_height; } void tooltip_update() { - if (!g_tooltip.tooltip_text) { - tooltip_hide(0); - return; - } + if (!g_tooltip.tooltip_text) { + tooltip_hide(0); + return; + } - tooltip_update_geometry(); - if (just_shown) { - if (!panel_horizontal) - y -= height / 2; // center vertically - just_shown = FALSE; - } - tooltip_adjust_geometry(); - XMoveResizeWindow(server.display, g_tooltip.window, x, y, width, height); + tooltip_update_geometry(); + if (just_shown) { + if (!panel_horizontal) + y -= height / 2; // center vertically + just_shown = FALSE; + } + tooltip_adjust_geometry(); + XMoveResizeWindow(server.display, g_tooltip.window, x, y, width, height); - // Stuff for drawing the tooltip - cairo_surface_t *cs = cairo_xlib_surface_create(server.display, g_tooltip.window, server.visual, width, height); - cairo_t *c = cairo_create(cs); - Color bc = g_tooltip.bg->fill_color; - Border b = g_tooltip.bg->border; - if (server.real_transparency) { - clear_pixmap(g_tooltip.window, 0, 0, width, height); - draw_rect(c, b.width, b.width, width - 2 * b.width, height - 2 * b.width, b.radius - b.width / 1.571); - cairo_set_source_rgba(c, bc.rgb[0], bc.rgb[1], bc.rgb[2], bc.alpha); - } else { - cairo_rectangle(c, 0., 0, width, height); - cairo_set_source_rgb(c, bc.rgb[0], bc.rgb[1], bc.rgb[2]); - } - cairo_fill(c); - cairo_set_line_width(c, b.width); - if (server.real_transparency) - draw_rect(c, b.width / 2.0, b.width / 2.0, width - b.width, height - b.width, b.radius); - else - cairo_rectangle(c, b.width / 2.0, b.width / 2.0, width - b.width, height - b.width); - cairo_set_source_rgba(c, b.color.rgb[0], b.color.rgb[1], b.color.rgb[2], b.color.alpha); - cairo_stroke(c); + // Stuff for drawing the tooltip + cairo_surface_t *cs = cairo_xlib_surface_create(server.display, g_tooltip.window, server.visual, width, height); + cairo_t *c = cairo_create(cs); + Color bc = g_tooltip.bg->fill_color; + Border b = g_tooltip.bg->border; + if (server.real_transparency) { + clear_pixmap(g_tooltip.window, 0, 0, width, height); + draw_rect(c, b.width, b.width, width - 2 * b.width, height - 2 * b.width, b.radius - b.width / 1.571); + cairo_set_source_rgba(c, bc.rgb[0], bc.rgb[1], bc.rgb[2], bc.alpha); + } else { + cairo_rectangle(c, 0., 0, width, height); + cairo_set_source_rgb(c, bc.rgb[0], bc.rgb[1], bc.rgb[2]); + } + cairo_fill(c); + cairo_set_line_width(c, b.width); + if (server.real_transparency) + draw_rect(c, b.width / 2.0, b.width / 2.0, width - b.width, height - b.width, b.radius); + else + cairo_rectangle(c, b.width / 2.0, b.width / 2.0, width - b.width, height - b.width); + cairo_set_source_rgba(c, b.color.rgb[0], b.color.rgb[1], b.color.rgb[2], b.color.alpha); + cairo_stroke(c); - Color fc = g_tooltip.font_color; - cairo_set_source_rgba(c, fc.rgb[0], fc.rgb[1], fc.rgb[2], fc.alpha); - PangoLayout *layout = pango_cairo_create_layout(c); - pango_layout_set_font_description(layout, g_tooltip.font_desc); - pango_layout_set_wrap(layout, PANGO_WRAP_WORD); - pango_layout_set_text(layout, g_tooltip.tooltip_text, -1); - PangoRectangle r1, r2; - pango_layout_get_pixel_extents(layout, &r1, &r2); - pango_layout_set_width(layout, width * PANGO_SCALE); - pango_layout_set_height(layout, height * PANGO_SCALE); - pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END); - // I do not know why this is the right way, but with the below cairo_move_to it seems to be centered (horiz. and - // vert.) - cairo_move_to(c, - -r1.x / 2 + left_bg_border_width(g_tooltip.bg) + g_tooltip.paddingx, - -r1.y / 2 + 1 + top_bg_border_width(g_tooltip.bg) + g_tooltip.paddingy); - pango_cairo_show_layout(c, layout); + Color fc = g_tooltip.font_color; + cairo_set_source_rgba(c, fc.rgb[0], fc.rgb[1], fc.rgb[2], fc.alpha); + PangoLayout *layout = pango_cairo_create_layout(c); + pango_layout_set_font_description(layout, g_tooltip.font_desc); + pango_layout_set_wrap(layout, PANGO_WRAP_WORD); + pango_layout_set_text(layout, g_tooltip.tooltip_text, -1); + PangoRectangle r1, r2; + pango_layout_get_pixel_extents(layout, &r1, &r2); + pango_layout_set_width(layout, width * PANGO_SCALE); + pango_layout_set_height(layout, height * PANGO_SCALE); + pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END); + // I do not know why this is the right way, but with the below cairo_move_to it seems to be centered (horiz. and + // vert.) + cairo_move_to(c, + -r1.x / 2 + left_bg_border_width(g_tooltip.bg) + g_tooltip.paddingx, + -r1.y / 2 + 1 + top_bg_border_width(g_tooltip.bg) + g_tooltip.paddingy); + pango_cairo_show_layout(c, layout); - g_object_unref(layout); - cairo_destroy(c); - cairo_surface_destroy(cs); + g_object_unref(layout); + cairo_destroy(c); + cairo_surface_destroy(cs); } void tooltip_trigger_hide() { - if (g_tooltip.mapped) { - tooltip_copy_text(0); - start_hide_timeout(); - } else { - // tooltip not visible yet, but maybe a timeout is still pending - stop_tooltip_timeout(); - } + if (g_tooltip.mapped) { + tooltip_copy_text(0); + start_hide_timeout(); + } else { + // tooltip not visible yet, but maybe a timeout is still pending + stop_tooltip_timeout(); + } } void tooltip_hide(void *arg) { - if (g_tooltip.mapped) { - g_tooltip.mapped = False; - XUnmapWindow(server.display, g_tooltip.window); - XFlush(server.display); - } + if (g_tooltip.mapped) { + g_tooltip.mapped = False; + XUnmapWindow(server.display, g_tooltip.window); + XFlush(server.display); + } } void start_show_timeout() { - change_timeout(&g_tooltip.timeout, g_tooltip.show_timeout_msec, 0, tooltip_show, 0); + change_timeout(&g_tooltip.timeout, g_tooltip.show_timeout_msec, 0, tooltip_show, 0); } void start_hide_timeout() { - change_timeout(&g_tooltip.timeout, g_tooltip.hide_timeout_msec, 0, tooltip_hide, 0); + change_timeout(&g_tooltip.timeout, g_tooltip.hide_timeout_msec, 0, tooltip_hide, 0); } void stop_tooltip_timeout() { - stop_timeout(g_tooltip.timeout); + stop_timeout(g_tooltip.timeout); } void tooltip_copy_text(Area *area) { - free(g_tooltip.tooltip_text); - if (area && area->_get_tooltip_text) - g_tooltip.tooltip_text = area->_get_tooltip_text(area); - else - g_tooltip.tooltip_text = NULL; - g_tooltip.area = area; + free(g_tooltip.tooltip_text); + if (area && area->_get_tooltip_text) + g_tooltip.tooltip_text = area->_get_tooltip_text(area); + else + g_tooltip.tooltip_text = NULL; + g_tooltip.area = area; }
M src/tooltip/tooltip.hsrc/tooltip/tooltip.h

@@ -23,20 +23,20 @@ #include "panel.h"

#include "timer.h" typedef struct { - Area *area; // never ever use the area attribut if you are not 100% sure that this area was not freed - char *tooltip_text; - Panel *panel; - Window window; - int show_timeout_msec; - int hide_timeout_msec; - Bool mapped; - int paddingx; - int paddingy; - gboolean has_font; - PangoFontDescription *font_desc; - Color font_color; - Background *bg; - timeout *timeout; + Area *area; // never ever use the area attribut if you are not 100% sure that this area was not freed + char *tooltip_text; + Panel *panel; + Window window; + int show_timeout_msec; + int hide_timeout_msec; + Bool mapped; + int paddingx; + int paddingy; + gboolean has_font; + PangoFontDescription *font_desc; + Color font_color; + Background *bg; + timeout *timeout; } Tooltip; extern Tooltip g_tooltip;
M src/util/area.csrc/util/area.c

@@ -37,1101 +37,1101 @@ Area *mouse_over_area = NULL;

void init_background(Background *bg) { - memset(bg, 0, sizeof(Background)); - bg->border.mask = BORDER_TOP | BORDER_BOTTOM | BORDER_LEFT | BORDER_RIGHT; + memset(bg, 0, sizeof(Background)); + bg->border.mask = BORDER_TOP | BORDER_BOTTOM | BORDER_LEFT | BORDER_RIGHT; } void initialize_positions(void *obj, int offset) { - Area *a = (Area *)obj; - for (GList *l = a->children; l; l = l->next) { - Area *child = ((Area *)l->data); - if (panel_horizontal) { - child->posy = offset + top_border_width(a) + a->paddingy; - child->height = a->height - 2 * a->paddingy - top_bottom_border_width(a); - if (child->_on_change_layout) - child->_on_change_layout(child); - initialize_positions(child, child->posy); - } else { - child->posx = offset + left_border_width(a) + a->paddingy; - child->width = a->width - 2 * a->paddingy - left_right_border_width(a); - if (child->_on_change_layout) - child->_on_change_layout(child); - initialize_positions(child, child->posx); - } - } + Area *a = (Area *)obj; + for (GList *l = a->children; l; l = l->next) { + Area *child = ((Area *)l->data); + if (panel_horizontal) { + child->posy = offset + top_border_width(a) + a->paddingy; + child->height = a->height - 2 * a->paddingy - top_bottom_border_width(a); + if (child->_on_change_layout) + child->_on_change_layout(child); + initialize_positions(child, child->posy); + } else { + child->posx = offset + left_border_width(a) + a->paddingy; + child->width = a->width - 2 * a->paddingy - left_right_border_width(a); + if (child->_on_change_layout) + child->_on_change_layout(child); + initialize_positions(child, child->posx); + } + } } void relayout_fixed(Area *a) { - if (!a->on_screen) - return; + if (!a->on_screen) + return; - // Children are resized before the parent - GList *l; - for (l = a->children; l; l = l->next) - relayout_fixed(l->data); + // Children are resized before the parent + GList *l; + for (l = a->children; l; l = l->next) + relayout_fixed(l->data); - // Recalculate size - a->_changed = FALSE; - if (a->resize_needed && a->size_mode == LAYOUT_FIXED) { - a->resize_needed = FALSE; + // Recalculate size + a->_changed = FALSE; + if (a->resize_needed && a->size_mode == LAYOUT_FIXED) { + a->resize_needed = FALSE; - if (a->_resize && a->_resize(a)) { - // The size has changed => resize needed for the parent - if (a->parent) - ((Area *)a->parent)->resize_needed = TRUE; - a->_changed = TRUE; - } - } + if (a->_resize && a->_resize(a)) { + // The size has changed => resize needed for the parent + if (a->parent) + ((Area *)a->parent)->resize_needed = TRUE; + a->_changed = TRUE; + } + } } void relayout_dynamic(Area *a, int level) { - if (!a->on_screen) - return; + if (!a->on_screen) + return; - // Area is resized before its children - if (a->resize_needed && a->size_mode == LAYOUT_DYNAMIC) { - a->resize_needed = FALSE; + // Area is resized before its children + if (a->resize_needed && a->size_mode == LAYOUT_DYNAMIC) { + a->resize_needed = FALSE; - if (a->_resize) { - if (a->_resize(a)) - a->_changed = TRUE; - // resize children with LAYOUT_DYNAMIC - for (GList *l = a->children; l; l = l->next) { - Area *child = ((Area *)l->data); - if (child->size_mode == LAYOUT_DYNAMIC && child->children) - child->resize_needed = 1; - } - } - } + if (a->_resize) { + if (a->_resize(a)) + a->_changed = TRUE; + // resize children with LAYOUT_DYNAMIC + for (GList *l = a->children; l; l = l->next) { + Area *child = ((Area *)l->data); + if (child->size_mode == LAYOUT_DYNAMIC && child->children) + child->resize_needed = 1; + } + } + } - // Layout children - if (a->children) { - if (a->alignment == ALIGN_LEFT) { - int pos = - (panel_horizontal ? a->posx + left_border_width(a) : a->posy + top_border_width(a)) + a->paddingxlr; + // Layout children + if (a->children) { + if (a->alignment == ALIGN_LEFT) { + int pos = + (panel_horizontal ? a->posx + left_border_width(a) : a->posy + top_border_width(a)) + a->paddingxlr; - for (GList *l = a->children; l; l = l->next) { - Area *child = ((Area *)l->data); - if (!child->on_screen) - continue; + for (GList *l = a->children; l; l = l->next) { + Area *child = ((Area *)l->data); + if (!child->on_screen) + continue; - if (panel_horizontal) { - if (pos != child->posx) { - // pos changed => redraw - child->posx = pos; - child->_changed = TRUE; - } - } else { - if (pos != child->posy) { - // pos changed => redraw - child->posy = pos; - child->_changed = TRUE; - } - } + if (panel_horizontal) { + if (pos != child->posx) { + // pos changed => redraw + child->posx = pos; + child->_changed = TRUE; + } + } else { + if (pos != child->posy) { + // pos changed => redraw + child->posy = pos; + child->_changed = TRUE; + } + } - relayout_dynamic(child, level + 1); + relayout_dynamic(child, level + 1); - pos += panel_horizontal ? child->width + a->paddingx : child->height + a->paddingx; - } - } else if (a->alignment == ALIGN_RIGHT) { - int pos = (panel_horizontal ? a->posx + a->width - right_border_width(a) - : a->posy + a->height - bottom_border_width(a)) - - a->paddingxlr; + pos += panel_horizontal ? child->width + a->paddingx : child->height + a->paddingx; + } + } else if (a->alignment == ALIGN_RIGHT) { + int pos = (panel_horizontal ? a->posx + a->width - right_border_width(a) + : a->posy + a->height - bottom_border_width(a)) - + a->paddingxlr; - for (GList *l = g_list_last(a->children); l; l = l->prev) { - Area *child = ((Area *)l->data); - if (!child->on_screen) - continue; + for (GList *l = g_list_last(a->children); l; l = l->prev) { + Area *child = ((Area *)l->data); + if (!child->on_screen) + continue; - pos -= panel_horizontal ? child->width : child->height; + pos -= panel_horizontal ? child->width : child->height; - if (panel_horizontal) { - if (pos != child->posx) { - // pos changed => redraw - child->posx = pos; - child->_changed = TRUE; - } - } else { - if (pos != child->posy) { - // pos changed => redraw - child->posy = pos; - child->_changed = TRUE; - } - } + if (panel_horizontal) { + if (pos != child->posx) { + // pos changed => redraw + child->posx = pos; + child->_changed = TRUE; + } + } else { + if (pos != child->posy) { + // pos changed => redraw + child->posy = pos; + child->_changed = TRUE; + } + } - relayout_dynamic(child, level + 1); + relayout_dynamic(child, level + 1); - pos -= a->paddingx; - } - } else if (a->alignment == ALIGN_CENTER) { + pos -= a->paddingx; + } + } else if (a->alignment == ALIGN_CENTER) { - int children_size = 0; + int children_size = 0; - for (GList *l = a->children; l; l = l->next) { - Area *child = ((Area *)l->data); - if (!child->on_screen) - continue; + for (GList *l = a->children; l; l = l->next) { + Area *child = ((Area *)l->data); + if (!child->on_screen) + continue; - children_size += panel_horizontal ? child->width : child->height; - children_size += (l == a->children) ? 0 : a->paddingx; - } + children_size += panel_horizontal ? child->width : child->height; + children_size += (l == a->children) ? 0 : a->paddingx; + } - int pos = - (panel_horizontal ? a->posx + left_border_width(a) : a->posy + top_border_width(a)) + a->paddingxlr; - pos += ((panel_horizontal ? a->width : a->height) - children_size) / 2; + int pos = + (panel_horizontal ? a->posx + left_border_width(a) : a->posy + top_border_width(a)) + a->paddingxlr; + pos += ((panel_horizontal ? a->width : a->height) - children_size) / 2; - for (GList *l = a->children; l; l = l->next) { - Area *child = ((Area *)l->data); - if (!child->on_screen) - continue; + for (GList *l = a->children; l; l = l->next) { + Area *child = ((Area *)l->data); + if (!child->on_screen) + continue; - if (panel_horizontal) { - if (pos != child->posx) { - // pos changed => redraw - child->posx = pos; - child->_changed = TRUE; - } - } else { - if (pos != child->posy) { - // pos changed => redraw - child->posy = pos; - child->_changed = TRUE; - } - } + if (panel_horizontal) { + if (pos != child->posx) { + // pos changed => redraw + child->posx = pos; + child->_changed = TRUE; + } + } else { + if (pos != child->posy) { + // pos changed => redraw + child->posy = pos; + child->_changed = TRUE; + } + } - relayout_dynamic(child, level + 1); + relayout_dynamic(child, level + 1); - pos += panel_horizontal ? child->width + a->paddingx : child->height + a->paddingx; - } - } - } + pos += panel_horizontal ? child->width + a->paddingx : child->height + a->paddingx; + } + } + } - if (a->_changed) { - // pos/size changed - a->_redraw_needed = TRUE; - if (a->_on_change_layout) - a->_on_change_layout(a); - } + if (a->_changed) { + // pos/size changed + a->_redraw_needed = TRUE; + if (a->_on_change_layout) + a->_on_change_layout(a); + } } int compute_desired_size(Area *a) { - if (!a->on_screen) - return 0; - if (a->_compute_desired_size) - return a->_compute_desired_size(a); - if (a->size_mode == LAYOUT_FIXED) - fprintf(stderr, YELLOW "Area %s does not set desired size!" RESET "\n", a->name); - return container_compute_desired_size(a); + if (!a->on_screen) + return 0; + if (a->_compute_desired_size) + return a->_compute_desired_size(a); + if (a->size_mode == LAYOUT_FIXED) + fprintf(stderr, YELLOW "Area %s does not set desired size!" RESET "\n", a->name); + return container_compute_desired_size(a); } int container_compute_desired_size(Area *a) { - if (!a->on_screen) - return 0; - int result = 2 * a->paddingxlr + (panel_horizontal ? left_right_border_width(a) : top_bottom_border_width(a)); - int children_count = 0; - for (GList *l = a->children; l != NULL; l = l->next) { - Area *child = (Area *)l->data; - if (child->on_screen) { - result += compute_desired_size(child); - children_count++; - } - } - if (children_count > 0) - result += (children_count - 1) * a->paddingx; - return result; + if (!a->on_screen) + return 0; + int result = 2 * a->paddingxlr + (panel_horizontal ? left_right_border_width(a) : top_bottom_border_width(a)); + int children_count = 0; + for (GList *l = a->children; l != NULL; l = l->next) { + Area *child = (Area *)l->data; + if (child->on_screen) { + result += compute_desired_size(child); + children_count++; + } + } + if (children_count > 0) + result += (children_count - 1) * a->paddingx; + return result; } void relayout(Area *a) { - relayout_fixed(a); - relayout_dynamic(a, 1); + relayout_fixed(a); + relayout_dynamic(a, 1); } int relayout_with_constraint(Area *a, int maximum_size) { - int fixed_children_count = 0; - int dynamic_children_count = 0; + int fixed_children_count = 0; + int dynamic_children_count = 0; - if (panel_horizontal) { - // detect free size for LAYOUT_DYNAMIC Areas - int size = a->width - 2 * a->paddingxlr - left_right_border_width(a); - for (GList *l = a->children; l; l = l->next) { - Area *child = (Area *)l->data; - if (child->on_screen && child->size_mode == LAYOUT_FIXED) { - size -= child->width; - fixed_children_count++; - } - if (child->on_screen && child->size_mode == LAYOUT_DYNAMIC) - dynamic_children_count++; - } - if (fixed_children_count + dynamic_children_count > 0) - size -= (fixed_children_count + dynamic_children_count - 1) * a->paddingx; + if (panel_horizontal) { + // detect free size for LAYOUT_DYNAMIC Areas + int size = a->width - 2 * a->paddingxlr - left_right_border_width(a); + for (GList *l = a->children; l; l = l->next) { + Area *child = (Area *)l->data; + if (child->on_screen && child->size_mode == LAYOUT_FIXED) { + size -= child->width; + fixed_children_count++; + } + if (child->on_screen && child->size_mode == LAYOUT_DYNAMIC) + dynamic_children_count++; + } + if (fixed_children_count + dynamic_children_count > 0) + size -= (fixed_children_count + dynamic_children_count - 1) * a->paddingx; - int width = 0; - int modulo = 0; - if (dynamic_children_count > 0) { - width = size / dynamic_children_count; - modulo = size % dynamic_children_count; - if (width > maximum_size && maximum_size > 0) { - width = maximum_size; - modulo = 0; - } - } + int width = 0; + int modulo = 0; + if (dynamic_children_count > 0) { + width = size / dynamic_children_count; + modulo = size % dynamic_children_count; + if (width > maximum_size && maximum_size > 0) { + width = maximum_size; + modulo = 0; + } + } - // Resize LAYOUT_DYNAMIC objects - for (GList *l = a->children; l; l = l->next) { - Area *child = (Area *)l->data; - if (child->on_screen && child->size_mode == LAYOUT_DYNAMIC) { - int old_width = child->width; - child->width = width; - if (modulo) { - child->width++; - modulo--; - } - if (child->width != old_width) - child->_changed = TRUE; - } - } - } else { - // detect free size for LAYOUT_DYNAMIC's Area - int size = a->height - 2 * a->paddingxlr - top_bottom_border_width(a); - for (GList *l = a->children; l; l = l->next) { - Area *child = (Area *)l->data; - if (child->on_screen && child->size_mode == LAYOUT_FIXED) { - size -= child->height; - fixed_children_count++; - } - if (child->on_screen && child->size_mode == LAYOUT_DYNAMIC) - dynamic_children_count++; - } - if (fixed_children_count + dynamic_children_count > 0) - size -= (fixed_children_count + dynamic_children_count - 1) * a->paddingx; + // Resize LAYOUT_DYNAMIC objects + for (GList *l = a->children; l; l = l->next) { + Area *child = (Area *)l->data; + if (child->on_screen && child->size_mode == LAYOUT_DYNAMIC) { + int old_width = child->width; + child->width = width; + if (modulo) { + child->width++; + modulo--; + } + if (child->width != old_width) + child->_changed = TRUE; + } + } + } else { + // detect free size for LAYOUT_DYNAMIC's Area + int size = a->height - 2 * a->paddingxlr - top_bottom_border_width(a); + for (GList *l = a->children; l; l = l->next) { + Area *child = (Area *)l->data; + if (child->on_screen && child->size_mode == LAYOUT_FIXED) { + size -= child->height; + fixed_children_count++; + } + if (child->on_screen && child->size_mode == LAYOUT_DYNAMIC) + dynamic_children_count++; + } + if (fixed_children_count + dynamic_children_count > 0) + size -= (fixed_children_count + dynamic_children_count - 1) * a->paddingx; - int height = 0; - int modulo = 0; - if (dynamic_children_count) { - height = size / dynamic_children_count; - modulo = size % dynamic_children_count; - if (height > maximum_size && maximum_size != 0) { - height = maximum_size; - modulo = 0; - } - } + int height = 0; + int modulo = 0; + if (dynamic_children_count) { + height = size / dynamic_children_count; + modulo = size % dynamic_children_count; + if (height > maximum_size && maximum_size != 0) { + height = maximum_size; + modulo = 0; + } + } - // Resize LAYOUT_DYNAMIC objects - for (GList *l = a->children; l; l = l->next) { - Area *child = (Area *)l->data; - if (child->on_screen && child->size_mode == LAYOUT_DYNAMIC) { - int old_height = child->height; - child->height = height; - if (modulo) { - child->height++; - modulo--; - } - if (child->height != old_height) - child->_changed = TRUE; - } - } - } - return 0; + // Resize LAYOUT_DYNAMIC objects + for (GList *l = a->children; l; l = l->next) { + Area *child = (Area *)l->data; + if (child->on_screen && child->size_mode == LAYOUT_DYNAMIC) { + int old_height = child->height; + child->height = height; + if (modulo) { + child->height++; + modulo--; + } + if (child->height != old_height) + child->_changed = TRUE; + } + } + } + return 0; } void schedule_redraw(Area *a) { - a->_redraw_needed = TRUE; + a->_redraw_needed = TRUE; - if (a->has_mouse_over_effect) { - for (int i = 0; i < MOUSE_STATE_COUNT; i++) { - XFreePixmap(server.display, a->pix_by_state[i]); - if (a->pix == a->pix_by_state[i]) - a->pix = None; - a->pix_by_state[i] = None; - } - if (a->pix) { - XFreePixmap(server.display, a->pix); - a->pix = None; - } - } + if (a->has_mouse_over_effect) { + for (int i = 0; i < MOUSE_STATE_COUNT; i++) { + XFreePixmap(server.display, a->pix_by_state[i]); + if (a->pix == a->pix_by_state[i]) + a->pix = None; + a->pix_by_state[i] = None; + } + if (a->pix) { + XFreePixmap(server.display, a->pix); + a->pix = None; + } + } - for (GList *l = a->children; l; l = l->next) - schedule_redraw((Area *)l->data); - schedule_panel_redraw(); + for (GList *l = a->children; l; l = l->next) + schedule_redraw((Area *)l->data); + schedule_panel_redraw(); } void draw_tree(Area *a) { - if (!a->on_screen) - return; + if (!a->on_screen) + return; - if (a->_redraw_needed) { - a->_redraw_needed = FALSE; - draw(a); - } + if (a->_redraw_needed) { + a->_redraw_needed = FALSE; + draw(a); + } - if (a->pix) - XCopyArea(server.display, - a->pix, - ((Panel *)a->panel)->temp_pmap, - server.gc, - 0, - 0, - a->width, - a->height, - a->posx, - a->posy); - else - fprintf(stderr, RED "%s %d: area %s has no pixmap!!!" RESET "\n", __FILE__, __LINE__, a->name); + if (a->pix) + XCopyArea(server.display, + a->pix, + ((Panel *)a->panel)->temp_pmap, + server.gc, + 0, + 0, + a->width, + a->height, + a->posx, + a->posy); + else + fprintf(stderr, RED "%s %d: area %s has no pixmap!!!" RESET "\n", __FILE__, __LINE__, a->name); - for (GList *l = a->children; l; l = l->next) - draw_tree((Area *)l->data); + for (GList *l = a->children; l; l = l->next) + draw_tree((Area *)l->data); } void hide(Area *a) { - Area *parent = (Area *)a->parent; + Area *parent = (Area *)a->parent; - if (!a->on_screen) - return; - a->on_screen = FALSE; - if (parent) - parent->resize_needed = TRUE; - if (panel_horizontal) - a->width = 0; - else - a->height = 0; + if (!a->on_screen) + return; + a->on_screen = FALSE; + if (parent) + parent->resize_needed = TRUE; + if (panel_horizontal) + a->width = 0; + else + a->height = 0; } void show(Area *a) { - Area *parent = (Area *)a->parent; + Area *parent = (Area *)a->parent; - if (a->on_screen) - return; - a->on_screen = TRUE; - if (parent) - parent->resize_needed = TRUE; - a->resize_needed = TRUE; - schedule_panel_redraw(); + if (a->on_screen) + return; + a->on_screen = TRUE; + if (parent) + parent->resize_needed = TRUE; + a->resize_needed = TRUE; + schedule_panel_redraw(); } void update_dependent_gradients(Area *a) { - if (!a->on_screen) - return; - if (a->_changed) { - for (GList *l = a->dependent_gradients; l; l = l->next) { - GradientInstance *gi = (GradientInstance *)l->data; - update_gradient(gi); - if (gi->area != a) - schedule_redraw(gi->area); - } - } - for (GList *l = a->children; l; l = l->next) - update_dependent_gradients((Area *)l->data); + if (!a->on_screen) + return; + if (a->_changed) { + for (GList *l = a->dependent_gradients; l; l = l->next) { + GradientInstance *gi = (GradientInstance *)l->data; + update_gradient(gi); + if (gi->area != a) + schedule_redraw(gi->area); + } + } + for (GList *l = a->children; l; l = l->next) + update_dependent_gradients((Area *)l->data); } void draw(Area *a) { - if (a->_changed) { - // On resize/move, invalidate cached pixmaps - for (int i = 0; i < MOUSE_STATE_COUNT; i++) { - XFreePixmap(server.display, a->pix_by_state[i]); - if (a->pix == a->pix_by_state[i]) { - a->pix = None; - } - a->pix_by_state[i] = None; - } - if (a->pix) { - XFreePixmap(server.display, a->pix); - a->pix = None; - } - } + if (a->_changed) { + // On resize/move, invalidate cached pixmaps + for (int i = 0; i < MOUSE_STATE_COUNT; i++) { + XFreePixmap(server.display, a->pix_by_state[i]); + if (a->pix == a->pix_by_state[i]) { + a->pix = None; + } + a->pix_by_state[i] = None; + } + if (a->pix) { + XFreePixmap(server.display, a->pix); + a->pix = None; + } + } - if (a->pix) { - XFreePixmap(server.display, a->pix); - if (a->pix_by_state[a->has_mouse_over_effect ? a->mouse_state : 0] != a->pix) - XFreePixmap(server.display, a->pix_by_state[a->has_mouse_over_effect ? a->mouse_state : 0]); - } - a->pix = XCreatePixmap(server.display, server.root_win, a->width, a->height, server.depth); - a->pix_by_state[a->has_mouse_over_effect ? a->mouse_state : 0] = a->pix; + if (a->pix) { + XFreePixmap(server.display, a->pix); + if (a->pix_by_state[a->has_mouse_over_effect ? a->mouse_state : 0] != a->pix) + XFreePixmap(server.display, a->pix_by_state[a->has_mouse_over_effect ? a->mouse_state : 0]); + } + a->pix = XCreatePixmap(server.display, server.root_win, a->width, a->height, server.depth); + a->pix_by_state[a->has_mouse_over_effect ? a->mouse_state : 0] = a->pix; - if (!a->_clear) { - // Add layer of root pixmap (or clear pixmap if real_transparency==true) - if (server.real_transparency) - clear_pixmap(a->pix, 0, 0, a->width, a->height); - XCopyArea(server.display, - ((Panel *)a->panel)->temp_pmap, - a->pix, - server.gc, - a->posx, - a->posy, - a->width, - a->height, - 0, - 0); - } else { - a->_clear(a); - } + if (!a->_clear) { + // Add layer of root pixmap (or clear pixmap if real_transparency==true) + if (server.real_transparency) + clear_pixmap(a->pix, 0, 0, a->width, a->height); + XCopyArea(server.display, + ((Panel *)a->panel)->temp_pmap, + a->pix, + server.gc, + a->posx, + a->posy, + a->width, + a->height, + 0, + 0); + } else { + a->_clear(a); + } - cairo_surface_t *cs = cairo_xlib_surface_create(server.display, a->pix, server.visual, a->width, a->height); - cairo_t *c = cairo_create(cs); + cairo_surface_t *cs = cairo_xlib_surface_create(server.display, a->pix, server.visual, a->width, a->height); + cairo_t *c = cairo_create(cs); - draw_background(a, c); + draw_background(a, c); - if (a->_draw_foreground) - a->_draw_foreground(a, c); + if (a->_draw_foreground) + a->_draw_foreground(a, c); - cairo_destroy(c); - cairo_surface_destroy(cs); + cairo_destroy(c); + cairo_surface_destroy(cs); } void draw_background(Area *a, cairo_t *c) { - if ((a->bg->fill_color.alpha > 0.0) || - (panel_config.mouse_effects && (a->has_mouse_over_effect || a->has_mouse_press_effect))) { - if (a->mouse_state == MOUSE_OVER) - cairo_set_source_rgba(c, - a->bg->fill_color_hover.rgb[0], - a->bg->fill_color_hover.rgb[1], - a->bg->fill_color_hover.rgb[2], - a->bg->fill_color_hover.alpha); - else if (a->mouse_state == MOUSE_DOWN) - cairo_set_source_rgba(c, - a->bg->fill_color_pressed.rgb[0], - a->bg->fill_color_pressed.rgb[1], - a->bg->fill_color_pressed.rgb[2], - a->bg->fill_color_pressed.alpha); - else - cairo_set_source_rgba(c, - a->bg->fill_color.rgb[0], - a->bg->fill_color.rgb[1], - a->bg->fill_color.rgb[2], - a->bg->fill_color.alpha); - // Not sure about this - draw_rect(c, - left_border_width(a), - top_border_width(a), - a->width - left_right_border_width(a), - a->height - top_bottom_border_width(a), - a->bg->border.radius - a->bg->border.width / 1.571); + if ((a->bg->fill_color.alpha > 0.0) || + (panel_config.mouse_effects && (a->has_mouse_over_effect || a->has_mouse_press_effect))) { + if (a->mouse_state == MOUSE_OVER) + cairo_set_source_rgba(c, + a->bg->fill_color_hover.rgb[0], + a->bg->fill_color_hover.rgb[1], + a->bg->fill_color_hover.rgb[2], + a->bg->fill_color_hover.alpha); + else if (a->mouse_state == MOUSE_DOWN) + cairo_set_source_rgba(c, + a->bg->fill_color_pressed.rgb[0], + a->bg->fill_color_pressed.rgb[1], + a->bg->fill_color_pressed.rgb[2], + a->bg->fill_color_pressed.alpha); + else + cairo_set_source_rgba(c, + a->bg->fill_color.rgb[0], + a->bg->fill_color.rgb[1], + a->bg->fill_color.rgb[2], + a->bg->fill_color.alpha); + // Not sure about this + draw_rect(c, + left_border_width(a), + top_border_width(a), + a->width - left_right_border_width(a), + a->height - top_bottom_border_width(a), + a->bg->border.radius - a->bg->border.width / 1.571); - cairo_fill(c); - } - for (GList *l = a->gradient_instances_by_state[a->mouse_state]; l; l = l->next) { - GradientInstance *gi = (GradientInstance *)l->data; - if (!gi->pattern) - update_gradient(gi); - cairo_set_source(c, gi->pattern); - draw_rect(c, - left_border_width(a), - top_border_width(a), - a->width - left_right_border_width(a), - a->height - top_bottom_border_width(a), - a->bg->border.radius - a->bg->border.width / 1.571); - cairo_fill(c); - } + cairo_fill(c); + } + for (GList *l = a->gradient_instances_by_state[a->mouse_state]; l; l = l->next) { + GradientInstance *gi = (GradientInstance *)l->data; + if (!gi->pattern) + update_gradient(gi); + cairo_set_source(c, gi->pattern); + draw_rect(c, + left_border_width(a), + top_border_width(a), + a->width - left_right_border_width(a), + a->height - top_bottom_border_width(a), + a->bg->border.radius - a->bg->border.width / 1.571); + cairo_fill(c); + } - if (a->bg->border.width > 0) { - cairo_set_line_width(c, a->bg->border.width); + if (a->bg->border.width > 0) { + cairo_set_line_width(c, a->bg->border.width); - // draw border inside (x, y, width, height) - if (a->mouse_state == MOUSE_OVER) - cairo_set_source_rgba(c, - a->bg->border_color_hover.rgb[0], - a->bg->border_color_hover.rgb[1], - a->bg->border_color_hover.rgb[2], - a->bg->border_color_hover.alpha); - else if (a->mouse_state == MOUSE_DOWN) - cairo_set_source_rgba(c, - a->bg->border_color_pressed.rgb[0], - a->bg->border_color_pressed.rgb[1], - a->bg->border_color_pressed.rgb[2], - a->bg->border_color_pressed.alpha); - else - cairo_set_source_rgba(c, - a->bg->border.color.rgb[0], - a->bg->border.color.rgb[1], - a->bg->border.color.rgb[2], - a->bg->border.color.alpha); - draw_rect_on_sides(c, - left_border_width(a) / 2., - top_border_width(a) / 2., - a->width - left_right_border_width(a) / 2., - a->height - top_bottom_border_width(a) / 2., - a->bg->border.radius, - a->bg->border.mask); + // draw border inside (x, y, width, height) + if (a->mouse_state == MOUSE_OVER) + cairo_set_source_rgba(c, + a->bg->border_color_hover.rgb[0], + a->bg->border_color_hover.rgb[1], + a->bg->border_color_hover.rgb[2], + a->bg->border_color_hover.alpha); + else if (a->mouse_state == MOUSE_DOWN) + cairo_set_source_rgba(c, + a->bg->border_color_pressed.rgb[0], + a->bg->border_color_pressed.rgb[1], + a->bg->border_color_pressed.rgb[2], + a->bg->border_color_pressed.alpha); + else + cairo_set_source_rgba(c, + a->bg->border.color.rgb[0], + a->bg->border.color.rgb[1], + a->bg->border.color.rgb[2], + a->bg->border.color.alpha); + draw_rect_on_sides(c, + left_border_width(a) / 2., + top_border_width(a) / 2., + a->width - left_right_border_width(a) / 2., + a->height - top_bottom_border_width(a) / 2., + a->bg->border.radius, + a->bg->border.mask); - cairo_stroke(c); - } + cairo_stroke(c); + } } void remove_area(Area *a) { - Area *area = (Area *)a; - Area *parent = (Area *)area->parent; + Area *area = (Area *)a; + Area *parent = (Area *)area->parent; - free_area_gradient_instances(a); + free_area_gradient_instances(a); - if (parent) { - parent->children = g_list_remove(parent->children, area); - parent->resize_needed = TRUE; - schedule_panel_redraw(); - schedule_redraw(parent); - } + if (parent) { + parent->children = g_list_remove(parent->children, area); + parent->resize_needed = TRUE; + schedule_panel_redraw(); + schedule_redraw(parent); + } - if (mouse_over_area == a) { - mouse_out(); - } + if (mouse_over_area == a) { + mouse_out(); + } } void add_area(Area *a, Area *parent) { - g_assert_null(a->parent); + g_assert_null(a->parent); - a->parent = parent; - if (parent) { - parent->children = g_list_append(parent->children, a); - parent->resize_needed = TRUE; - schedule_redraw(parent); - } + a->parent = parent; + if (parent) { + parent->children = g_list_append(parent->children, a); + parent->resize_needed = TRUE; + schedule_redraw(parent); + } } void free_area(Area *a) { - if (!a) - return; + if (!a) + return; - for (GList *l = a->children; l; l = l->next) - free_area(l->data); + for (GList *l = a->children; l; l = l->next) + free_area(l->data); - if (a->children) { - g_list_free(a->children); - a->children = NULL; - } - for (int i = 0; i < MOUSE_STATE_COUNT; i++) { - XFreePixmap(server.display, a->pix_by_state[i]); - if (a->pix == a->pix_by_state[i]) { - a->pix = None; - } - a->pix_by_state[i] = None; - } - if (a->pix) { - XFreePixmap(server.display, a->pix); - a->pix = None; - } - if (mouse_over_area == a) { - mouse_over_area = NULL; - } - free_area_gradient_instances(a); + if (a->children) { + g_list_free(a->children); + a->children = NULL; + } + for (int i = 0; i < MOUSE_STATE_COUNT; i++) { + XFreePixmap(server.display, a->pix_by_state[i]); + if (a->pix == a->pix_by_state[i]) { + a->pix = None; + } + a->pix_by_state[i] = None; + } + if (a->pix) { + XFreePixmap(server.display, a->pix); + a->pix = None; + } + if (mouse_over_area == a) { + mouse_over_area = NULL; + } + free_area_gradient_instances(a); } void mouse_over(Area *area, int pressed) { - if (mouse_over_area == area && !area) - return; + if (mouse_over_area == area && !area) + return; - MouseState new_state = MOUSE_NORMAL; - if (area) { - if (!pressed) { - new_state = area->has_mouse_over_effect ? MOUSE_OVER : MOUSE_NORMAL; - } else { - new_state = - area->has_mouse_press_effect ? MOUSE_DOWN : area->has_mouse_over_effect ? MOUSE_OVER : MOUSE_NORMAL; - } - } + MouseState new_state = MOUSE_NORMAL; + if (area) { + if (!pressed) { + new_state = area->has_mouse_over_effect ? MOUSE_OVER : MOUSE_NORMAL; + } else { + new_state = + area->has_mouse_press_effect ? MOUSE_DOWN : area->has_mouse_over_effect ? MOUSE_OVER : MOUSE_NORMAL; + } + } - if (mouse_over_area == area && mouse_over_area->mouse_state == new_state) - return; - mouse_out(); - if (new_state == MOUSE_NORMAL) - return; - mouse_over_area = area; + if (mouse_over_area == area && mouse_over_area->mouse_state == new_state) + return; + mouse_out(); + if (new_state == MOUSE_NORMAL) + return; + mouse_over_area = area; - mouse_over_area->mouse_state = new_state; - mouse_over_area->pix = mouse_over_area->pix_by_state[mouse_over_area->mouse_state]; - if (!mouse_over_area->pix) - mouse_over_area->_redraw_needed = TRUE; - schedule_panel_redraw(); + mouse_over_area->mouse_state = new_state; + mouse_over_area->pix = mouse_over_area->pix_by_state[mouse_over_area->mouse_state]; + if (!mouse_over_area->pix) + mouse_over_area->_redraw_needed = TRUE; + schedule_panel_redraw(); } void mouse_out() { - if (!mouse_over_area) - return; - mouse_over_area->mouse_state = MOUSE_NORMAL; - mouse_over_area->pix = mouse_over_area->pix_by_state[mouse_over_area->mouse_state]; - if (!mouse_over_area->pix) - mouse_over_area->_redraw_needed = TRUE; - schedule_panel_redraw(); - mouse_over_area = NULL; + if (!mouse_over_area) + return; + mouse_over_area->mouse_state = MOUSE_NORMAL; + mouse_over_area->pix = mouse_over_area->pix_by_state[mouse_over_area->mouse_state]; + if (!mouse_over_area->pix) + mouse_over_area->_redraw_needed = TRUE; + schedule_panel_redraw(); + mouse_over_area = NULL; } gboolean area_is_first(void *obj) { - Area *a = obj; - if (!a->on_screen) - return FALSE; + Area *a = obj; + if (!a->on_screen) + return FALSE; - Panel *panel = a->panel; + Panel *panel = a->panel; - Area *node = &panel->area; + Area *node = &panel->area; - while (node) { - if (!node->on_screen || node->width == 0 || node->height == 0) - return FALSE; - if (node == a) - return TRUE; + while (node) { + if (!node->on_screen || node->width == 0 || node->height == 0) + return FALSE; + if (node == a) + return TRUE; - GList *l = node->children; - node = NULL; - for (; l; l = l->next) { - Area *child = l->data; - if (!child->on_screen || child->width == 0 || child->height == 0) - continue; - node = child; - break; - } - } + GList *l = node->children; + node = NULL; + for (; l; l = l->next) { + Area *child = l->data; + if (!child->on_screen || child->width == 0 || child->height == 0) + continue; + node = child; + break; + } + } - return FALSE; + return FALSE; } gboolean area_is_last(void *obj) { - Area *a = obj; - if (!a->on_screen) - return FALSE; + Area *a = obj; + if (!a->on_screen) + return FALSE; - Panel *panel = a->panel; + Panel *panel = a->panel; - Area *node = &panel->area; + Area *node = &panel->area; - while (node) { - if (!node->on_screen || node->width == 0 || node->height == 0) - return FALSE; - if (node == a) - return TRUE; + while (node) { + if (!node->on_screen || node->width == 0 || node->height == 0) + return FALSE; + if (node == a) + return TRUE; - GList *l = node->children; - node = NULL; - for (; l; l = l->next) { - Area *child = l->data; - if (!child->on_screen || child->width == 0 || child->height == 0) - continue; - node = child; - } - } + GList *l = node->children; + node = NULL; + for (; l; l = l->next) { + Area *child = l->data; + if (!child->on_screen || child->width == 0 || child->height == 0) + continue; + node = child; + } + } - return FALSE; + return FALSE; } gboolean area_is_under_mouse(void *obj, int x, int y) { - Area *a = obj; - if (!a->on_screen || a->width == 0 || a->height == 0) - return FALSE; + Area *a = obj; + if (!a->on_screen || a->width == 0 || a->height == 0) + return FALSE; - if (a->_is_under_mouse) - return a->_is_under_mouse(a, x, y); + if (a->_is_under_mouse) + return a->_is_under_mouse(a, x, y); - return x >= a->posx && x <= (a->posx + a->width) && y >= a->posy && y <= (a->posy + a->height); + return x >= a->posx && x <= (a->posx + a->width) && y >= a->posy && y <= (a->posy + a->height); } gboolean full_width_area_is_under_mouse(void *obj, int x, int y) { - Area *a = obj; - if (!a->on_screen) - return FALSE; + Area *a = obj; + if (!a->on_screen) + return FALSE; - if (a->_is_under_mouse && a->_is_under_mouse != full_width_area_is_under_mouse) - return a->_is_under_mouse(a, x, y); + if (a->_is_under_mouse && a->_is_under_mouse != full_width_area_is_under_mouse) + return a->_is_under_mouse(a, x, y); - if (panel_horizontal) - return (x >= a->posx) && (x <= a->posx + a->width); - else - return (y >= a->posy) && (y <= a->posy + a->height); + if (panel_horizontal) + return (x >= a->posx) && (x <= a->posx + a->width); + else + return (y >= a->posy) && (y <= a->posy + a->height); } Area *find_area_under_mouse(void *root, int x, int y) { - Area *result = root; - Area *new_result = result; - do { - result = new_result; - GList *it = result->children; - while (it) { - Area *a = (Area *)it->data; - if (area_is_under_mouse(a, x, y)) { - new_result = a; - break; - } - it = it->next; - } - } while (new_result != result); - return result; + Area *result = root; + Area *new_result = result; + do { + result = new_result; + GList *it = result->children; + while (it) { + Area *a = (Area *)it->data; + if (area_is_under_mouse(a, x, y)) { + new_result = a; + break; + } + it = it->next; + } + } while (new_result != result); + return result; } int left_border_width(Area *a) { - return left_bg_border_width(a->bg); + return left_bg_border_width(a->bg); } int right_border_width(Area *a) { - return right_bg_border_width(a->bg); + return right_bg_border_width(a->bg); } int top_border_width(Area *a) { - return top_bg_border_width(a->bg); + return top_bg_border_width(a->bg); } int bottom_border_width(Area *a) { - return bottom_bg_border_width(a->bg); + return bottom_bg_border_width(a->bg); } int left_right_border_width(Area *a) { - return left_right_bg_border_width(a->bg); + return left_right_bg_border_width(a->bg); } int top_bottom_border_width(Area *a) { - return top_bottom_bg_border_width(a->bg); + return top_bottom_bg_border_width(a->bg); } int bg_border_width(Background *bg, int mask) { - return bg->border.mask & mask ? bg->border.width : 0; + return bg->border.mask & mask ? bg->border.width : 0; } int left_bg_border_width(Background *bg) { - return bg_border_width(bg, BORDER_LEFT); + return bg_border_width(bg, BORDER_LEFT); } int top_bg_border_width(Background *bg) { - return bg_border_width(bg, BORDER_TOP); + return bg_border_width(bg, BORDER_TOP); } int right_bg_border_width(Background *bg) { - return bg_border_width(bg, BORDER_RIGHT); + return bg_border_width(bg, BORDER_RIGHT); } int bottom_bg_border_width(Background *bg) { - return bg_border_width(bg, BORDER_BOTTOM); + return bg_border_width(bg, BORDER_BOTTOM); } int left_right_bg_border_width(Background *bg) { - return left_bg_border_width(bg) + right_bg_border_width(bg); + return left_bg_border_width(bg) + right_bg_border_width(bg); } int top_bottom_bg_border_width(Background *bg) { - return top_bg_border_width(bg) + bottom_bg_border_width(bg); + return top_bg_border_width(bg) + bottom_bg_border_width(bg); } void area_dump_geometry(Area *area, int indent) { - fprintf(stderr, "%*s%s:\n", indent, "", area->name); - indent += 2; - if (!area->on_screen) { - fprintf(stderr, "%*shidden\n", indent, ""); - return; - } - fprintf(stderr, - "%*sBox: x = %d, y = %d, w = %d, h = %d, desired size = %d\n", - indent, - "", - area->posx, - area->posy, - area->width, - area->height, - compute_desired_size(area)); - fprintf(stderr, - "%*sBorder: left = %d, right = %d, top = %d, bottom = %d\n", - indent, - "", - left_border_width(area), - right_border_width(area), - top_border_width(area), - bottom_border_width(area)); - fprintf(stderr, - "%*sPadding: left = right = %d, top = bottom = %d, spacing = %d\n", - indent, - "", - area->paddingxlr, - area->paddingy, - area->paddingx); - if (area->_dump_geometry) - area->_dump_geometry(area, indent); - if (area->children) { - fprintf(stderr, "%*sChildren:\n", indent, ""); - indent += 2; - for (GList *l = area->children; l; l = l->next) - area_dump_geometry((Area *)l->data, indent); - } + fprintf(stderr, "%*s%s:\n", indent, "", area->name); + indent += 2; + if (!area->on_screen) { + fprintf(stderr, "%*shidden\n", indent, ""); + return; + } + fprintf(stderr, + "%*sBox: x = %d, y = %d, w = %d, h = %d, desired size = %d\n", + indent, + "", + area->posx, + area->posy, + area->width, + area->height, + compute_desired_size(area)); + fprintf(stderr, + "%*sBorder: left = %d, right = %d, top = %d, bottom = %d\n", + indent, + "", + left_border_width(area), + right_border_width(area), + top_border_width(area), + bottom_border_width(area)); + fprintf(stderr, + "%*sPadding: left = right = %d, top = bottom = %d, spacing = %d\n", + indent, + "", + area->paddingxlr, + area->paddingy, + area->paddingx); + if (area->_dump_geometry) + area->_dump_geometry(area, indent); + if (area->children) { + fprintf(stderr, "%*sChildren:\n", indent, ""); + indent += 2; + for (GList *l = area->children; l; l = l->next) + area_dump_geometry((Area *)l->data, indent); + } } Area *compute_element_area(Area *area, Element element) { - if (element == ELEMENT_SELF) - return area; - if (element == ELEMENT_PARENT) - return (Area *)area->parent; - if (element == ELEMENT_PANEL) - return (Area *)area->panel; - g_assert_not_reached(); - return area; + if (element == ELEMENT_SELF) + return area; + if (element == ELEMENT_PARENT) + return (Area *)area->parent; + if (element == ELEMENT_PANEL) + return (Area *)area->panel; + g_assert_not_reached(); + return area; } void instantiate_gradient_offsets(GradientInstance *gi, GList *offsets) { - for (GList *l = offsets; l; l = l->next) { - Offset *offset = (Offset *)l->data; - if (!offset->constant) { - Area *element_area = compute_element_area(gi->area, offset->element); - element_area->dependent_gradients = g_list_append(element_area->dependent_gradients, gi); - } - } + for (GList *l = offsets; l; l = l->next) { + Offset *offset = (Offset *)l->data; + if (!offset->constant) { + Area *element_area = compute_element_area(gi->area, offset->element); + element_area->dependent_gradients = g_list_append(element_area->dependent_gradients, gi); + } + } } void free_gradient_offsets(GradientInstance *gi, GList **offsets) { - for (GList *l = *offsets; l; l = l->next) { - Offset *offset = (Offset *)l->data; - if (!offset->constant) { - Area *element_area = compute_element_area(gi->area, offset->element); - element_area->dependent_gradients = g_list_remove_all(element_area->dependent_gradients, gi); - } - } + for (GList *l = *offsets; l; l = l->next) { + Offset *offset = (Offset *)l->data; + if (!offset->constant) { + Area *element_area = compute_element_area(gi->area, offset->element); + element_area->dependent_gradients = g_list_remove_all(element_area->dependent_gradients, gi); + } + } } void instantiate_gradient_point(GradientInstance *gi, ControlPoint *control) { - instantiate_gradient_offsets(gi, control->offsets_x); - instantiate_gradient_offsets(gi, control->offsets_y); - instantiate_gradient_offsets(gi, control->offsets_r); + instantiate_gradient_offsets(gi, control->offsets_x); + instantiate_gradient_offsets(gi, control->offsets_y); + instantiate_gradient_offsets(gi, control->offsets_r); } void free_gradient_instance_point(GradientInstance *gi, ControlPoint *control) { - free_gradient_offsets(gi, &control->offsets_x); - free_gradient_offsets(gi, &control->offsets_y); - free_gradient_offsets(gi, &control->offsets_r); + free_gradient_offsets(gi, &control->offsets_x); + free_gradient_offsets(gi, &control->offsets_y); + free_gradient_offsets(gi, &control->offsets_r); } void instantiate_gradient(Area *area, GradientClass *g, GradientInstance *gi) { - g_assert_nonnull(area); - g_assert_nonnull(g); - gi->area = area; - gi->gradient_class = g; - instantiate_gradient_point(gi, &g->from); - instantiate_gradient_point(gi, &g->to); + g_assert_nonnull(area); + g_assert_nonnull(g); + gi->area = area; + gi->gradient_class = g; + instantiate_gradient_point(gi, &g->from); + instantiate_gradient_point(gi, &g->to); } void free_gradient_instance(GradientInstance *gi) { - if (gi->pattern) { - cairo_pattern_destroy(gi->pattern); - gi->pattern = NULL; - } - free_gradient_instance_point(gi, &gi->gradient_class->from); - free_gradient_instance_point(gi, &gi->gradient_class->to); - gi->gradient_class = NULL; + if (gi->pattern) { + cairo_pattern_destroy(gi->pattern); + gi->pattern = NULL; + } + free_gradient_instance_point(gi, &gi->gradient_class->from); + free_gradient_instance_point(gi, &gi->gradient_class->to); + gi->gradient_class = NULL; } void instantiate_area_gradients(Area *area) { - if (debug_gradients) - fprintf(stderr, "Initializing gradients for area %s\n", area->name); - for (int i = 0; i < MOUSE_STATE_COUNT; i++) { - g_assert_null(area->gradient_instances_by_state[i]); - GradientClass *g = area->bg->gradients[i]; - if (!g) - continue; - GradientInstance *gi = (GradientInstance *)calloc(1, sizeof(GradientInstance)); - instantiate_gradient(area, g, gi); - area->gradient_instances_by_state[i] = g_list_append(area->gradient_instances_by_state[i], gi); - } + if (debug_gradients) + fprintf(stderr, "Initializing gradients for area %s\n", area->name); + for (int i = 0; i < MOUSE_STATE_COUNT; i++) { + g_assert_null(area->gradient_instances_by_state[i]); + GradientClass *g = area->bg->gradients[i]; + if (!g) + continue; + GradientInstance *gi = (GradientInstance *)calloc(1, sizeof(GradientInstance)); + instantiate_gradient(area, g, gi); + area->gradient_instances_by_state[i] = g_list_append(area->gradient_instances_by_state[i], gi); + } } void free_area_gradient_instances(Area *area) { - if (debug_gradients) - fprintf(stderr, "Freeing gradients for area %s\n", area->name); - for (int i = 0; i < MOUSE_STATE_COUNT; i++) { - for (GList *l = area->gradient_instances_by_state[i]; l; l = l->next) { - GradientInstance *gi = (GradientInstance *)l->data; - free_gradient_instance(gi); - } - g_list_free_full(area->gradient_instances_by_state[i], free); - area->gradient_instances_by_state[i] = NULL; - } - g_assert_null(area->dependent_gradients); + if (debug_gradients) + fprintf(stderr, "Freeing gradients for area %s\n", area->name); + for (int i = 0; i < MOUSE_STATE_COUNT; i++) { + for (GList *l = area->gradient_instances_by_state[i]; l; l = l->next) { + GradientInstance *gi = (GradientInstance *)l->data; + free_gradient_instance(gi); + } + g_list_free_full(area->gradient_instances_by_state[i], free); + area->gradient_instances_by_state[i] = NULL; + } + g_assert_null(area->dependent_gradients); } double compute_control_point_offset(Area *area, Offset *offset) { - if (offset->constant) - return offset->constant_value; + if (offset->constant) + return offset->constant_value; - Area *element_area = compute_element_area(area, offset->element); - Area *parent_area = ((Area *)area->parent); - g_assert_nonnull(element_area); - g_assert_nonnull(parent_area); + Area *element_area = compute_element_area(area, offset->element); + Area *parent_area = ((Area *)area->parent); + g_assert_nonnull(element_area); + g_assert_nonnull(parent_area); - double width = element_area->width; - double height = element_area->height; - double radius = sqrt(element_area->width * element_area->width + element_area->height * element_area->height) / 2.0; + double width = element_area->width; + double height = element_area->height; + double radius = sqrt(element_area->width * element_area->width + element_area->height * element_area->height) / 2.0; - double left, top; - if (offset->element == ELEMENT_SELF) { - left = 0; - top = 0; - } else if (offset->element == ELEMENT_PARENT) { - left = parent_area->posx - area->posx; - top = parent_area->posy - area->posy; - } else if (offset->element == ELEMENT_PANEL) { - left = 0 - area->posx; - top = 0 - area->posy; - } + double left, top; + if (offset->element == ELEMENT_SELF) { + left = 0; + top = 0; + } else if (offset->element == ELEMENT_PARENT) { + left = parent_area->posx - area->posx; + top = parent_area->posy - area->posy; + } else if (offset->element == ELEMENT_PANEL) { + left = 0 - area->posx; + top = 0 - area->posy; + } - double right = left + width; - double bottom = top + height; - double center_x = left + 0.5 * width; - double center_y = top + 0.5 * height; + double right = left + width; + double bottom = top + height; + double center_x = left + 0.5 * width; + double center_y = top + 0.5 * height; - if (offset->variable == SIZE_WIDTH) - return width * offset->multiplier; - if (offset->variable == SIZE_HEIGHT) - return height * offset->multiplier; - if (offset->variable == SIZE_RADIUS) - return radius * offset->multiplier; - if (offset->variable == SIZE_LEFT) - return left * offset->multiplier; - if (offset->variable == SIZE_RIGHT) - return right * offset->multiplier; - if (offset->variable == SIZE_TOP) - return top * offset->multiplier; - if (offset->variable == SIZE_BOTTOM) - return bottom * offset->multiplier; - if (offset->variable == SIZE_CENTERX) - return center_x * offset->multiplier; - if (offset->variable == SIZE_CENTERY) - return center_y * offset->multiplier; + if (offset->variable == SIZE_WIDTH) + return width * offset->multiplier; + if (offset->variable == SIZE_HEIGHT) + return height * offset->multiplier; + if (offset->variable == SIZE_RADIUS) + return radius * offset->multiplier; + if (offset->variable == SIZE_LEFT) + return left * offset->multiplier; + if (offset->variable == SIZE_RIGHT) + return right * offset->multiplier; + if (offset->variable == SIZE_TOP) + return top * offset->multiplier; + if (offset->variable == SIZE_BOTTOM) + return bottom * offset->multiplier; + if (offset->variable == SIZE_CENTERX) + return center_x * offset->multiplier; + if (offset->variable == SIZE_CENTERY) + return center_y * offset->multiplier; - g_assert_not_reached(); - return 0; + g_assert_not_reached(); + return 0; } double compute_control_point_offsets(GradientInstance *gi, GList *offsets) { - double result = 0; - for (GList *l = offsets; l; l = l->next) { - Offset *offset = (Offset *)l->data; - result += compute_control_point_offset(gi->area, offset); - } - return result; + double result = 0; + for (GList *l = offsets; l; l = l->next) { + Offset *offset = (Offset *)l->data; + result += compute_control_point_offset(gi->area, offset); + } + return result; } void compute_control_point(GradientInstance *gi, ControlPoint *control, double *x, double *y, double *r) { - *x = compute_control_point_offsets(gi, control->offsets_x); - *y = compute_control_point_offsets(gi, control->offsets_y); - *r = compute_control_point_offsets(gi, control->offsets_r); + *x = compute_control_point_offsets(gi, control->offsets_x); + *y = compute_control_point_offsets(gi, control->offsets_y); + *r = compute_control_point_offsets(gi, control->offsets_r); } void update_gradient(GradientInstance *gi) { - if (gi->pattern) { - return; - cairo_pattern_destroy(gi->pattern); - gi->pattern = NULL; - } - double from_x, from_y, from_r; - compute_control_point(gi, &gi->gradient_class->from, &from_x, &from_y, &from_r); - double to_x, to_y, to_r; - compute_control_point(gi, &gi->gradient_class->to, &to_x, &to_y, &to_r); - if (gi->gradient_class->type == GRADIENT_VERTICAL || gi->gradient_class->type == GRADIENT_HORIZONTAL) { - gi->pattern = cairo_pattern_create_linear(from_x, from_y, to_x, to_y); - if (debug_gradients) - fprintf(stderr, - "Creating linear gradient for area %s: %f %f, %f %f\n", - gi->area->name, - from_x, - from_y, - to_x, - to_y); - } else if (gi->gradient_class->type == GRADIENT_CENTERED) { - gi->pattern = cairo_pattern_create_radial(from_x, from_y, from_r, to_x, to_y, to_r); - if (debug_gradients) - fprintf(stderr, - "Creating radial gradient for area %s: %f %f %f, %f %f %f\n", - gi->area->name, - from_x, - from_y, - from_r, - to_x, - to_y, - to_r); - } else { - g_assert_not_reached(); - } - if (debug_gradients) - fprintf(stderr, - "Adding color stop at offset %f: %f %f %f %f\n", - 0.0, - gi->gradient_class->start_color.rgb[0], - gi->gradient_class->start_color.rgb[1], - gi->gradient_class->start_color.rgb[2], - gi->gradient_class->start_color.alpha); - cairo_pattern_add_color_stop_rgba(gi->pattern, - 0, - gi->gradient_class->start_color.rgb[0], - gi->gradient_class->start_color.rgb[1], - gi->gradient_class->start_color.rgb[2], - gi->gradient_class->start_color.alpha); - for (GList *l = gi->gradient_class->extra_color_stops; l; l = l->next) { - ColorStop *color_stop = (ColorStop *)l->data; - if (debug_gradients) - fprintf(stderr, - "Adding color stop at offset %f: %f %f %f %f\n", - color_stop->offset, - color_stop->color.rgb[0], - color_stop->color.rgb[1], - color_stop->color.rgb[2], - color_stop->color.alpha); - cairo_pattern_add_color_stop_rgba(gi->pattern, - color_stop->offset, - color_stop->color.rgb[0], - color_stop->color.rgb[1], - color_stop->color.rgb[2], - color_stop->color.alpha); - } - if (debug_gradients) - fprintf(stderr, - "Adding color stop at offset %f: %f %f %f %f\n", - 1.0, - gi->gradient_class->end_color.rgb[0], - gi->gradient_class->end_color.rgb[1], - gi->gradient_class->end_color.rgb[2], - gi->gradient_class->end_color.alpha); - cairo_pattern_add_color_stop_rgba(gi->pattern, - 1.0, - gi->gradient_class->end_color.rgb[0], - gi->gradient_class->end_color.rgb[1], - gi->gradient_class->end_color.rgb[2], - gi->gradient_class->end_color.alpha); + if (gi->pattern) { + return; + cairo_pattern_destroy(gi->pattern); + gi->pattern = NULL; + } + double from_x, from_y, from_r; + compute_control_point(gi, &gi->gradient_class->from, &from_x, &from_y, &from_r); + double to_x, to_y, to_r; + compute_control_point(gi, &gi->gradient_class->to, &to_x, &to_y, &to_r); + if (gi->gradient_class->type == GRADIENT_VERTICAL || gi->gradient_class->type == GRADIENT_HORIZONTAL) { + gi->pattern = cairo_pattern_create_linear(from_x, from_y, to_x, to_y); + if (debug_gradients) + fprintf(stderr, + "Creating linear gradient for area %s: %f %f, %f %f\n", + gi->area->name, + from_x, + from_y, + to_x, + to_y); + } else if (gi->gradient_class->type == GRADIENT_CENTERED) { + gi->pattern = cairo_pattern_create_radial(from_x, from_y, from_r, to_x, to_y, to_r); + if (debug_gradients) + fprintf(stderr, + "Creating radial gradient for area %s: %f %f %f, %f %f %f\n", + gi->area->name, + from_x, + from_y, + from_r, + to_x, + to_y, + to_r); + } else { + g_assert_not_reached(); + } + if (debug_gradients) + fprintf(stderr, + "Adding color stop at offset %f: %f %f %f %f\n", + 0.0, + gi->gradient_class->start_color.rgb[0], + gi->gradient_class->start_color.rgb[1], + gi->gradient_class->start_color.rgb[2], + gi->gradient_class->start_color.alpha); + cairo_pattern_add_color_stop_rgba(gi->pattern, + 0, + gi->gradient_class->start_color.rgb[0], + gi->gradient_class->start_color.rgb[1], + gi->gradient_class->start_color.rgb[2], + gi->gradient_class->start_color.alpha); + for (GList *l = gi->gradient_class->extra_color_stops; l; l = l->next) { + ColorStop *color_stop = (ColorStop *)l->data; + if (debug_gradients) + fprintf(stderr, + "Adding color stop at offset %f: %f %f %f %f\n", + color_stop->offset, + color_stop->color.rgb[0], + color_stop->color.rgb[1], + color_stop->color.rgb[2], + color_stop->color.alpha); + cairo_pattern_add_color_stop_rgba(gi->pattern, + color_stop->offset, + color_stop->color.rgb[0], + color_stop->color.rgb[1], + color_stop->color.rgb[2], + color_stop->color.alpha); + } + if (debug_gradients) + fprintf(stderr, + "Adding color stop at offset %f: %f %f %f %f\n", + 1.0, + gi->gradient_class->end_color.rgb[0], + gi->gradient_class->end_color.rgb[1], + gi->gradient_class->end_color.rgb[2], + gi->gradient_class->end_color.alpha); + cairo_pattern_add_color_stop_rgba(gi->pattern, + 1.0, + gi->gradient_class->end_color.rgb[0], + gi->gradient_class->end_color.rgb[1], + gi->gradient_class->end_color.rgb[2], + gi->gradient_class->end_color.alpha); }
M src/util/area.hsrc/util/area.h

@@ -121,125 +121,125 @@ // The caller takes ownership of the pointer.

// The Area's _get_tooltip_text member must point to this function. typedef enum BorderMask { - BORDER_TOP = 1 << 0, - BORDER_BOTTOM = 1 << 1, - BORDER_LEFT = 1 << 2, - BORDER_RIGHT = 1 << 3 + BORDER_TOP = 1 << 0, + BORDER_BOTTOM = 1 << 1, + BORDER_LEFT = 1 << 2, + BORDER_RIGHT = 1 << 3 } BorderMask; #define BORDER_ALL (BORDER_TOP | BORDER_BOTTOM | BORDER_LEFT | BORDER_RIGHT) typedef struct Border { - // It's essential that the first member is color - Color color; - // Width in pixels - int width; - // Corner radius - int radius; - // Mask: bitwise OR of BorderMask - int mask; + // It's essential that the first member is color + Color color; + // Width in pixels + int width; + // Corner radius + int radius; + // Mask: bitwise OR of BorderMask + int mask; } Border; typedef enum MouseState { MOUSE_NORMAL = 0, MOUSE_OVER = 1, MOUSE_DOWN = 2, MOUSE_STATE_COUNT } MouseState; typedef struct Background { - // Normal state - Color fill_color; - Border border; - // On mouse hover - Color fill_color_hover; - Color border_color_hover; - // On mouse press - Color fill_color_pressed; - Color border_color_pressed; - // Pointer to a GradientClass or NULL, no ownership - GradientClass *gradients[MOUSE_STATE_COUNT]; + // Normal state + Color fill_color; + Border border; + // On mouse hover + Color fill_color_hover; + Color border_color_hover; + // On mouse press + Color fill_color_pressed; + Color border_color_pressed; + // Pointer to a GradientClass or NULL, no ownership + GradientClass *gradients[MOUSE_STATE_COUNT]; } Background; typedef enum Layout { - LAYOUT_DYNAMIC, - LAYOUT_FIXED, + LAYOUT_DYNAMIC, + LAYOUT_FIXED, } Layout; typedef enum Alignment { - ALIGN_LEFT = 0, - ALIGN_CENTER = 1, - ALIGN_RIGHT = 2, + ALIGN_LEFT = 0, + ALIGN_CENTER = 1, + ALIGN_RIGHT = 2, } Alignment; struct Panel; typedef struct Area { - // Position relative to the panel window - int posx, posy; - // Size, including borders - int width, height; - int old_width, old_height; - Background *bg; - // Each element is a GradientInstance attached to this Area (list can be empty) - GList *gradient_instances_by_state[MOUSE_STATE_COUNT]; - // Each element is a GradientInstance that depends on this Area's geometry (position or size) - GList *dependent_gradients; - // List of children, each one a pointer to Area - GList *children; - // Pointer to the parent Area or NULL - void *parent; - // Pointer to the Panel that contains this Area - void *panel; - Layout size_mode; - Alignment alignment; - gboolean has_mouse_over_effect; - gboolean has_mouse_press_effect; - // TODO padding/spacing is a clusterfuck - // paddingxlr = padding - // paddingy = vertical padding, sometimes - // paddingx = spacing - int paddingxlr, paddingx, paddingy; - MouseState mouse_state; - // Set to non-zero if the Area is visible. An object may exist but stay hidden. - gboolean on_screen; - // Set to non-zero if the size of the Area has to be recalculated. - gboolean resize_needed; - // Set to non-zero if the Area has to be redrawn. - // Do not set this directly; use schedule_redraw() instead. - gboolean _redraw_needed; - // Set to non-zero if the position/size has changed, thus _on_change_layout needs to be called - gboolean _changed; - // This is the pixmap on which the Area is rendered. Render to it directly if needed. - Pixmap pix; - Pixmap pix_by_state[MOUSE_STATE_COUNT]; - char name[32]; + // Position relative to the panel window + int posx, posy; + // Size, including borders + int width, height; + int old_width, old_height; + Background *bg; + // Each element is a GradientInstance attached to this Area (list can be empty) + GList *gradient_instances_by_state[MOUSE_STATE_COUNT]; + // Each element is a GradientInstance that depends on this Area's geometry (position or size) + GList *dependent_gradients; + // List of children, each one a pointer to Area + GList *children; + // Pointer to the parent Area or NULL + void *parent; + // Pointer to the Panel that contains this Area + void *panel; + Layout size_mode; + Alignment alignment; + gboolean has_mouse_over_effect; + gboolean has_mouse_press_effect; + // TODO padding/spacing is a clusterfuck + // paddingxlr = padding + // paddingy = vertical padding, sometimes + // paddingx = spacing + int paddingxlr, paddingx, paddingy; + MouseState mouse_state; + // Set to non-zero if the Area is visible. An object may exist but stay hidden. + gboolean on_screen; + // Set to non-zero if the size of the Area has to be recalculated. + gboolean resize_needed; + // Set to non-zero if the Area has to be redrawn. + // Do not set this directly; use schedule_redraw() instead. + gboolean _redraw_needed; + // Set to non-zero if the position/size has changed, thus _on_change_layout needs to be called + gboolean _changed; + // This is the pixmap on which the Area is rendered. Render to it directly if needed. + Pixmap pix; + Pixmap pix_by_state[MOUSE_STATE_COUNT]; + char name[32]; - // Callbacks + // Callbacks - // Called on draw before any drawing takes place, obj = pointer to the Area - void (*_clear)(void *obj); + // Called on draw before any drawing takes place, obj = pointer to the Area + void (*_clear)(void *obj); - // Called on draw, obj = pointer to the Area - void (*_draw_foreground)(void *obj, cairo_t *c); + // Called on draw, obj = pointer to the Area + void (*_draw_foreground)(void *obj, cairo_t *c); - // Called on resize, obj = pointer to the Area - // Returns 1 if the new size is different than the previous size. - gboolean (*_resize)(void *obj); + // Called on resize, obj = pointer to the Area + // Returns 1 if the new size is different than the previous size. + gboolean (*_resize)(void *obj); - // Called before resize, obj = pointer to the Area - // Returns the desired size of the Area - int (*_compute_desired_size)(void *obj); + // Called before resize, obj = pointer to the Area + // Returns the desired size of the Area + int (*_compute_desired_size)(void *obj); - // Implemented only to override the default layout algorithm for this widget. - // For example, if this widget is a cell in a table, its position and size should be computed here. - void (*_on_change_layout)(void *obj); + // Implemented only to override the default layout algorithm for this widget. + // For example, if this widget is a cell in a table, its position and size should be computed here. + void (*_on_change_layout)(void *obj); - // Returns a copy of the tooltip to be displayed for this widget. - // The caller takes ownership of the pointer. - char *(*_get_tooltip_text)(void *obj); + // Returns a copy of the tooltip to be displayed for this widget. + // The caller takes ownership of the pointer. + char *(*_get_tooltip_text)(void *obj); - // Returns true if the Area handles a mouse event at the given x, y coordinates relative to the window. - // Leave this to NULL to use a default implementation. - gboolean (*_is_under_mouse)(void *obj, int x, int y); + // Returns true if the Area handles a mouse event at the given x, y coordinates relative to the window. + // Leave this to NULL to use a default implementation. + gboolean (*_is_under_mouse)(void *obj, int x, int y); - // Prints the geometry of the object on stderr, with left indentation of indent spaces. - void (*_dump_geometry)(void *obj, int indent); + // Prints the geometry of the object on stderr, with left indentation of indent spaces. + void (*_dump_geometry)(void *obj, int indent); } Area; // Initializes the Background member to default values.
M src/util/cache.csrc/util/cache.c

@@ -32,129 +32,129 @@ #include "common.h"

void init_cache(Cache *cache) { - if (cache->_table) - free_cache(cache); - cache->_table = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); - cache->dirty = FALSE; - cache->loaded = FALSE; + if (cache->_table) + free_cache(cache); + cache->_table = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); + cache->dirty = FALSE; + cache->loaded = FALSE; } void free_cache(Cache *cache) { - if (cache->_table) - g_hash_table_destroy(cache->_table); - cache->_table = NULL; - cache->dirty = FALSE; - cache->loaded = FALSE; + if (cache->_table) + g_hash_table_destroy(cache->_table); + cache->_table = NULL; + cache->dirty = FALSE; + cache->loaded = FALSE; } void load_cache(Cache *cache, const gchar *cache_path) { - init_cache(cache); + init_cache(cache); - cache->loaded = TRUE; + cache->loaded = TRUE; - int fd = open(cache_path, O_RDONLY); - if (fd == -1) - return; - flock(fd, LOCK_SH); + int fd = open(cache_path, O_RDONLY); + if (fd == -1) + return; + flock(fd, LOCK_SH); - FILE *f = fopen(cache_path, "rt"); - if (!f) - goto unlock; + FILE *f = fopen(cache_path, "rt"); + if (!f) + goto unlock; - char *line = NULL; - size_t line_size; + char *line = NULL; + size_t line_size; - while (getline(&line, &line_size, f) >= 0) { - char *key, *value; + while (getline(&line, &line_size, f) >= 0) { + char *key, *value; - size_t line_len = strlen(line); - gboolean has_newline = FALSE; - if (line_len >= 1) { - if (line[line_len - 1] == '\n') { - line[line_len - 1] = '\0'; - line_len--; - has_newline = TRUE; - } - } - if (!has_newline) - break; + size_t line_len = strlen(line); + gboolean has_newline = FALSE; + if (line_len >= 1) { + if (line[line_len - 1] == '\n') { + line[line_len - 1] = '\0'; + line_len--; + has_newline = TRUE; + } + } + if (!has_newline) + break; - if (line_len == 0) - continue; + if (line_len == 0) + continue; - if (parse_line(line, &key, &value)) { - g_hash_table_insert(cache->_table, g_strdup(key), g_strdup(value)); - free(key); - free(value); - } - } - free(line); - fclose(f); + if (parse_line(line, &key, &value)) { + g_hash_table_insert(cache->_table, g_strdup(key), g_strdup(value)); + free(key); + free(value); + } + } + free(line); + fclose(f); unlock: - flock(fd, LOCK_UN); - close(fd); + flock(fd, LOCK_UN); + close(fd); } void write_cache_line(gpointer key, gpointer value, gpointer user_data) { - gchar *k = key; - gchar *v = value; - FILE *f = user_data; + gchar *k = key; + gchar *v = value; + FILE *f = user_data; - fprintf(f, "%s=%s\n", k, v); + fprintf(f, "%s=%s\n", k, v); } void save_cache(Cache *cache, const gchar *cache_path) { - int fd = open(cache_path, O_RDONLY | O_CREAT, 0600); - if (fd == -1) { - gchar *dir_path = g_path_get_dirname(cache_path); - g_mkdir_with_parents(dir_path, 0700); - g_free(dir_path); - fd = open(cache_path, O_RDONLY | O_CREAT, 0600); - } - if (fd == -1) { - fprintf(stderr, RED "Could not save icon theme cache!" RESET "\n"); - return; - } - flock(fd, LOCK_EX); + int fd = open(cache_path, O_RDONLY | O_CREAT, 0600); + if (fd == -1) { + gchar *dir_path = g_path_get_dirname(cache_path); + g_mkdir_with_parents(dir_path, 0700); + g_free(dir_path); + fd = open(cache_path, O_RDONLY | O_CREAT, 0600); + } + if (fd == -1) { + fprintf(stderr, RED "Could not save icon theme cache!" RESET "\n"); + return; + } + flock(fd, LOCK_EX); - FILE *f = fopen(cache_path, "w"); - if (!f) { - fprintf(stderr, RED "Could not save icon theme cache!" RESET "\n"); - goto unlock; - } - g_hash_table_foreach(cache->_table, write_cache_line, f); - fclose(f); - cache->dirty = FALSE; + FILE *f = fopen(cache_path, "w"); + if (!f) { + fprintf(stderr, RED "Could not save icon theme cache!" RESET "\n"); + goto unlock; + } + g_hash_table_foreach(cache->_table, write_cache_line, f); + fclose(f); + cache->dirty = FALSE; unlock: - flock(fd, LOCK_UN); - close(fd); + flock(fd, LOCK_UN); + close(fd); } const gchar *get_from_cache(Cache *cache, const gchar *key) { - if (!cache->_table) - return NULL; - return g_hash_table_lookup(cache->_table, key); + if (!cache->_table) + return NULL; + return g_hash_table_lookup(cache->_table, key); } void add_to_cache(Cache *cache, const gchar *key, const gchar *value) { - if (!cache->_table) - init_cache(cache); + if (!cache->_table) + init_cache(cache); - if (!key || !value) - return; + if (!key || !value) + return; - gchar *old_value = g_hash_table_lookup(cache->_table, key); - if (old_value && g_str_equal(old_value, value)) - return; + gchar *old_value = g_hash_table_lookup(cache->_table, key); + if (old_value && g_str_equal(old_value, value)) + return; - g_hash_table_insert(cache->_table, g_strdup(key), g_strdup(value)); - cache->dirty = TRUE; + g_hash_table_insert(cache->_table, g_strdup(key), g_strdup(value)); + cache->dirty = TRUE; }
M src/util/cache.hsrc/util/cache.h

@@ -6,9 +6,9 @@

// A cache with string keys and values, backed by a file. // The strings must not be NULL and are stripped of any whitespace at start and end. typedef struct Cache { - gboolean dirty; - gboolean loaded; - GHashTable *_table; + gboolean dirty; + gboolean loaded; + GHashTable *_table; } Cache; // Initializes the cache. You can also call load_cache directly if you set the memory contents to zero first.
M src/util/color.csrc/util/color.c

@@ -1,2 +1,1 @@

#include "color.h" -
M src/util/color.hsrc/util/color.h

@@ -2,10 +2,10 @@ #ifndef COLOR_H

#define COLOR_H typedef struct Color { - // Values are in [0, 1], with 0 meaning no intensity. - double rgb[3]; - // Values are in [0, 1], with 0 meaning fully transparent, 1 meaning fully opaque. - double alpha; + // Values are in [0, 1], with 0 meaning no intensity. + double rgb[3]; + // Values are in [0, 1], with 0 meaning fully transparent, 1 meaning fully opaque. + double alpha; } Color; #endif // COLOR_H
M src/util/common.csrc/util/common.c

@@ -46,643 +46,643 @@ #endif

void copy_file(const char *path_src, const char *path_dest) { - if (g_str_equal(path_src, path_dest)) - return; + if (g_str_equal(path_src, path_dest)) + return; - FILE *file_src, *file_dest; - char buffer[4096]; - int nb; + FILE *file_src, *file_dest; + char buffer[4096]; + int nb; - file_src = fopen(path_src, "rb"); - if (file_src == NULL) - return; + file_src = fopen(path_src, "rb"); + if (file_src == NULL) + return; - file_dest = fopen(path_dest, "wb"); - if (file_dest == NULL) { - fclose(file_src); - return; - } + file_dest = fopen(path_dest, "wb"); + if (file_dest == NULL) { + fclose(file_src); + return; + } - while ((nb = fread(buffer, 1, sizeof(buffer), file_src)) > 0) { - if (nb != fwrite(buffer, 1, nb, file_dest)) { - printf("Error while copying file %s to %s\n", path_src, path_dest); - } - } + while ((nb = fread(buffer, 1, sizeof(buffer), file_src)) > 0) { + if (nb != fwrite(buffer, 1, nb, file_dest)) { + printf("Error while copying file %s to %s\n", path_src, path_dest); + } + } - fclose(file_dest); - fclose(file_src); + fclose(file_dest); + fclose(file_src); } gboolean parse_line(const char *line, char **key, char **value) { - char *a, *b; + char *a, *b; - /* Skip useless lines */ - if ((line[0] == '#') || (line[0] == '\n')) - return FALSE; - if (!(a = strchr(line, '='))) - return FALSE; + /* Skip useless lines */ + if ((line[0] == '#') || (line[0] == '\n')) + return FALSE; + if (!(a = strchr(line, '='))) + return FALSE; - /* overwrite '=' with '\0' */ - a[0] = '\0'; - *key = strdup(line); - a++; + /* overwrite '=' with '\0' */ + a[0] = '\0'; + *key = strdup(line); + a++; - /* overwrite '\n' with '\0' if '\n' present */ - if ((b = strchr(a, '\n'))) - b[0] = '\0'; + /* overwrite '\n' with '\0' if '\n' present */ + if ((b = strchr(a, '\n'))) + b[0] = '\0'; - *value = strdup(a); + *value = strdup(a); - g_strstrip(*key); - g_strstrip(*value); - return TRUE; + g_strstrip(*key); + g_strstrip(*value); + return TRUE; } void tint_exec(const char *command) { - if (command) { - if (fork() == 0) { - // change for the fork the signal mask - // sigset_t sigset; - // sigprocmask(SIG_SETMASK, &sigset, 0); - // sigprocmask(SIG_UNBLOCK, &sigset, 0); - execl("/bin/sh", "/bin/sh", "-c", command, NULL); - _exit(0); - } - } + if (command) { + if (fork() == 0) { + // change for the fork the signal mask + // sigset_t sigset; + // sigprocmask(SIG_SETMASK, &sigset, 0); + // sigprocmask(SIG_UNBLOCK, &sigset, 0); + execl("/bin/sh", "/bin/sh", "-c", command, NULL); + _exit(0); + } + } } char *expand_tilde(const char *s) { - const gchar *home = g_get_home_dir(); - if (home && (strcmp(s, "~") == 0 || strstr(s, "~/") == s)) { - char *result = calloc(strlen(home) + strlen(s), 1); - strcat(result, home); - strcat(result, s + 1); - return result; - } else { - return strdup(s); - } + const gchar *home = g_get_home_dir(); + if (home && (strcmp(s, "~") == 0 || strstr(s, "~/") == s)) { + char *result = calloc(strlen(home) + strlen(s), 1); + strcat(result, home); + strcat(result, s + 1); + return result; + } else { + return strdup(s); + } } char *contract_tilde(const char *s) { - const gchar *home = g_get_home_dir(); - if (!home) - return strdup(s); + const gchar *home = g_get_home_dir(); + if (!home) + return strdup(s); - char *home_slash = calloc(strlen(home) + 2, 1); - strcat(home_slash, home); - strcat(home_slash, "/"); + char *home_slash = calloc(strlen(home) + 2, 1); + strcat(home_slash, home); + strcat(home_slash, "/"); - if ((strcmp(s, home) == 0 || strstr(s, home_slash) == s)) { - char *result = calloc(strlen(s) - strlen(home) + 2, 1); - strcat(result, "~"); - strcat(result, s + strlen(home)); - free(home_slash); - return result; - } else { - free(home_slash); - return strdup(s); - } + if ((strcmp(s, home) == 0 || strstr(s, home_slash) == s)) { + char *result = calloc(strlen(s) - strlen(home) + 2, 1); + strcat(result, "~"); + strcat(result, s + strlen(home)); + free(home_slash); + return result; + } else { + free(home_slash); + return strdup(s); + } } int hex_char_to_int(char c) { - int r; + int r; - if (c >= '0' && c <= '9') - r = c - '0'; - else if (c >= 'a' && c <= 'f') - r = c - 'a' + 10; - else if (c >= 'A' && c <= 'F') - r = c - 'A' + 10; - else - r = 0; + if (c >= '0' && c <= '9') + r = c - '0'; + else if (c >= 'a' && c <= 'f') + r = c - 'a' + 10; + else if (c >= 'A' && c <= 'F') + r = c - 'A' + 10; + else + r = 0; - return r; + return r; } int hex_to_rgb(char *hex, int *r, int *g, int *b) { - if (hex == NULL || hex[0] != '#') - return (0); + if (hex == NULL || hex[0] != '#') + return (0); - int len = strlen(hex); - if (len == 3 + 1) { - *r = hex_char_to_int(hex[1]); - *g = hex_char_to_int(hex[2]); - *b = hex_char_to_int(hex[3]); - } else if (len == 6 + 1) { - *r = hex_char_to_int(hex[1]) * 16 + hex_char_to_int(hex[2]); - *g = hex_char_to_int(hex[3]) * 16 + hex_char_to_int(hex[4]); - *b = hex_char_to_int(hex[5]) * 16 + hex_char_to_int(hex[6]); - } else if (len == 12 + 1) { - *r = hex_char_to_int(hex[1]) * 16 + hex_char_to_int(hex[2]); - *g = hex_char_to_int(hex[5]) * 16 + hex_char_to_int(hex[6]); - *b = hex_char_to_int(hex[9]) * 16 + hex_char_to_int(hex[10]); - } else - return 0; + int len = strlen(hex); + if (len == 3 + 1) { + *r = hex_char_to_int(hex[1]); + *g = hex_char_to_int(hex[2]); + *b = hex_char_to_int(hex[3]); + } else if (len == 6 + 1) { + *r = hex_char_to_int(hex[1]) * 16 + hex_char_to_int(hex[2]); + *g = hex_char_to_int(hex[3]) * 16 + hex_char_to_int(hex[4]); + *b = hex_char_to_int(hex[5]) * 16 + hex_char_to_int(hex[6]); + } else if (len == 12 + 1) { + *r = hex_char_to_int(hex[1]) * 16 + hex_char_to_int(hex[2]); + *g = hex_char_to_int(hex[5]) * 16 + hex_char_to_int(hex[6]); + *b = hex_char_to_int(hex[9]) * 16 + hex_char_to_int(hex[10]); + } else + return 0; - return 1; + return 1; } void get_color(char *hex, double *rgb) { - int r, g, b; - r = g = b = 0; - hex_to_rgb(hex, &r, &g, &b); + int r, g, b; + r = g = b = 0; + hex_to_rgb(hex, &r, &g, &b); - rgb[0] = (r / 255.0); - rgb[1] = (g / 255.0); - rgb[2] = (b / 255.0); + rgb[0] = (r / 255.0); + rgb[1] = (g / 255.0); + rgb[2] = (b / 255.0); } void extract_values(const char *str, char **value1, char **value2, char **value3) { - *value1 = NULL; - *value2 = NULL; - *value3 = NULL; - char **tokens = g_strsplit(str, " ", 3); - if (tokens[0]) { - *value1 = strdup(tokens[0]); - if (tokens[1]) { - *value2 = strdup(tokens[1]); - if (tokens[2]) { - *value3 = strdup(tokens[2]); - } - } - } - g_strfreev(tokens); + *value1 = NULL; + *value2 = NULL; + *value3 = NULL; + char **tokens = g_strsplit(str, " ", 3); + if (tokens[0]) { + *value1 = strdup(tokens[0]); + if (tokens[1]) { + *value2 = strdup(tokens[1]); + if (tokens[2]) { + *value3 = strdup(tokens[2]); + } + } + } + g_strfreev(tokens); } void extract_values_4(const char *str, char **value1, char **value2, char **value3, char **value4) { - *value1 = NULL; - *value2 = NULL; - *value3 = NULL; - *value4 = NULL; - char **tokens = g_strsplit(str, " ", 4); - if (tokens[0]) { - *value1 = strdup(tokens[0]); - if (tokens[1]) { - *value2 = strdup(tokens[1]); - if (tokens[2]) { - *value3 = strdup(tokens[2]); - if (tokens[3]) { - *value4 = strdup(tokens[3]); - } - } - } - } - g_strfreev(tokens); + *value1 = NULL; + *value2 = NULL; + *value3 = NULL; + *value4 = NULL; + char **tokens = g_strsplit(str, " ", 4); + if (tokens[0]) { + *value1 = strdup(tokens[0]); + if (tokens[1]) { + *value2 = strdup(tokens[1]); + if (tokens[2]) { + *value3 = strdup(tokens[2]); + if (tokens[3]) { + *value4 = strdup(tokens[3]); + } + } + } + } + g_strfreev(tokens); } void adjust_asb(DATA32 *data, int w, int h, float alpha_adjust, float satur_adjust, float bright_adjust) { - for (int id = 0; id < w * h; id++) { - unsigned int argb = data[id]; - int a = (argb >> 24) & 0xff; - // transparent => nothing to do. - if (a == 0) - continue; - int r = (argb >> 16) & 0xff; - int g = (argb >> 8) & 0xff; - int b = (argb)&0xff; + for (int id = 0; id < w * h; id++) { + unsigned int argb = data[id]; + int a = (argb >> 24) & 0xff; + // transparent => nothing to do. + if (a == 0) + continue; + int r = (argb >> 16) & 0xff; + int g = (argb >> 8) & 0xff; + int b = (argb)&0xff; - // Convert RGB to HSV - int cmax = MAX3(r, g, b); - int cmin = MIN3(r, g, b); - int delta = cmax - cmin; - float brightness = cmax / 255.0f; - float saturation; - if (cmax != 0) - saturation = delta / (float)cmax; - else - saturation = 0; - float hue; - if (saturation == 0) { - hue = 0; - } else { - float redc = (cmax - r) / (float)delta; - float greenc = (cmax - g) / (float)delta; - float bluec = (cmax - b) / (float)delta; - if (r == cmax) - hue = bluec - greenc; - else if (g == cmax) - hue = 2.0f + redc - bluec; - else - hue = 4.0f + greenc - redc; - hue = hue / 6.0f; - if (hue < 0) - hue = hue + 1.0f; - } + // Convert RGB to HSV + int cmax = MAX3(r, g, b); + int cmin = MIN3(r, g, b); + int delta = cmax - cmin; + float brightness = cmax / 255.0f; + float saturation; + if (cmax != 0) + saturation = delta / (float)cmax; + else + saturation = 0; + float hue; + if (saturation == 0) { + hue = 0; + } else { + float redc = (cmax - r) / (float)delta; + float greenc = (cmax - g) / (float)delta; + float bluec = (cmax - b) / (float)delta; + if (r == cmax) + hue = bluec - greenc; + else if (g == cmax) + hue = 2.0f + redc - bluec; + else + hue = 4.0f + greenc - redc; + hue = hue / 6.0f; + if (hue < 0) + hue = hue + 1.0f; + } - // Adjust H, S - saturation += satur_adjust; - saturation = CLAMP(saturation, 0.0, 1.0); + // Adjust H, S + saturation += satur_adjust; + saturation = CLAMP(saturation, 0.0, 1.0); - a *= alpha_adjust; - a = CLAMP(a, 0, 255); + a *= alpha_adjust; + a = CLAMP(a, 0, 255); - // Convert HSV to RGB - if (saturation == 0) { - r = g = b = (int)(brightness * 255.0f + 0.5f); - } else { - float h2 = (hue - (int)hue) * 6.0f; - float f = h2 - (int)(h2); - float p = brightness * (1.0f - saturation); - float q = brightness * (1.0f - saturation * f); - float t = brightness * (1.0f - (saturation * (1.0f - f))); + // Convert HSV to RGB + if (saturation == 0) { + r = g = b = (int)(brightness * 255.0f + 0.5f); + } else { + float h2 = (hue - (int)hue) * 6.0f; + float f = h2 - (int)(h2); + float p = brightness * (1.0f - saturation); + float q = brightness * (1.0f - saturation * f); + float t = brightness * (1.0f - (saturation * (1.0f - f))); - switch ((int)h2) { - case 0: - r = (int)(brightness * 255.0f + 0.5f); - g = (int)(t * 255.0f + 0.5f); - b = (int)(p * 255.0f + 0.5f); - break; - case 1: - r = (int)(q * 255.0f + 0.5f); - g = (int)(brightness * 255.0f + 0.5f); - b = (int)(p * 255.0f + 0.5f); - break; - case 2: - r = (int)(p * 255.0f + 0.5f); - g = (int)(brightness * 255.0f + 0.5f); - b = (int)(t * 255.0f + 0.5f); - break; - case 3: - r = (int)(p * 255.0f + 0.5f); - g = (int)(q * 255.0f + 0.5f); - b = (int)(brightness * 255.0f + 0.5f); - break; - case 4: - r = (int)(t * 255.0f + 0.5f); - g = (int)(p * 255.0f + 0.5f); - b = (int)(brightness * 255.0f + 0.5f); - break; - case 5: - r = (int)(brightness * 255.0f + 0.5f); - g = (int)(p * 255.0f + 0.5f); - b = (int)(q * 255.0f + 0.5f); - break; - } - } + switch ((int)h2) { + case 0: + r = (int)(brightness * 255.0f + 0.5f); + g = (int)(t * 255.0f + 0.5f); + b = (int)(p * 255.0f + 0.5f); + break; + case 1: + r = (int)(q * 255.0f + 0.5f); + g = (int)(brightness * 255.0f + 0.5f); + b = (int)(p * 255.0f + 0.5f); + break; + case 2: + r = (int)(p * 255.0f + 0.5f); + g = (int)(brightness * 255.0f + 0.5f); + b = (int)(t * 255.0f + 0.5f); + break; + case 3: + r = (int)(p * 255.0f + 0.5f); + g = (int)(q * 255.0f + 0.5f); + b = (int)(brightness * 255.0f + 0.5f); + break; + case 4: + r = (int)(t * 255.0f + 0.5f); + g = (int)(p * 255.0f + 0.5f); + b = (int)(brightness * 255.0f + 0.5f); + break; + case 5: + r = (int)(brightness * 255.0f + 0.5f); + g = (int)(p * 255.0f + 0.5f); + b = (int)(q * 255.0f + 0.5f); + break; + } + } - r += bright_adjust * 255; - g += bright_adjust * 255; - b += bright_adjust * 255; + r += bright_adjust * 255; + g += bright_adjust * 255; + b += bright_adjust * 255; - r = CLAMP(r, 0, 255); - g = CLAMP(g, 0, 255); - b = CLAMP(b, 0, 255); + r = CLAMP(r, 0, 255); + g = CLAMP(g, 0, 255); + b = CLAMP(b, 0, 255); - argb = a; - argb = (argb << 8) + r; - argb = (argb << 8) + g; - argb = (argb << 8) + b; - data[id] = argb; - } + argb = a; + argb = (argb << 8) + r; + argb = (argb << 8) + g; + argb = (argb << 8) + b; + data[id] = argb; + } } void create_heuristic_mask(DATA32 *data, int w, int h) { - // first we need to find the mask color, therefore we check all 4 edge pixel and take the color which - // appears most often (we only need to check three edges, the 4th is implicitly clear) - unsigned int topLeft = data[0], topRight = data[w - 1], bottomLeft = data[w * h - w], bottomRight = data[w * h - 1]; - int max = (topLeft == topRight) + (topLeft == bottomLeft) + (topLeft == bottomRight); - int maskPos = 0; - if (max < (topRight == topLeft) + (topRight == bottomLeft) + (topRight == bottomRight)) { - max = (topRight == topLeft) + (topRight == bottomLeft) + (topRight == bottomRight); - maskPos = w - 1; - } - if (max < (bottomLeft == topRight) + (bottomLeft == topLeft) + (bottomLeft == bottomRight)) - maskPos = w * h - w; + // first we need to find the mask color, therefore we check all 4 edge pixel and take the color which + // appears most often (we only need to check three edges, the 4th is implicitly clear) + unsigned int topLeft = data[0], topRight = data[w - 1], bottomLeft = data[w * h - w], bottomRight = data[w * h - 1]; + int max = (topLeft == topRight) + (topLeft == bottomLeft) + (topLeft == bottomRight); + int maskPos = 0; + if (max < (topRight == topLeft) + (topRight == bottomLeft) + (topRight == bottomRight)) { + max = (topRight == topLeft) + (topRight == bottomLeft) + (topRight == bottomRight); + maskPos = w - 1; + } + if (max < (bottomLeft == topRight) + (bottomLeft == topLeft) + (bottomLeft == bottomRight)) + maskPos = w * h - w; - // now mask out every pixel which has the same color as the edge pixels - unsigned char *udata = (unsigned char *)data; - unsigned char b = udata[4 * maskPos]; - unsigned char g = udata[4 * maskPos + 1]; - unsigned char r = udata[4 * maskPos + 1]; - for (int i = 0; i < h * w; ++i) { - if (b - udata[0] == 0 && g - udata[1] == 0 && r - udata[2] == 0) - udata[3] = 0; - udata += 4; - } + // now mask out every pixel which has the same color as the edge pixels + unsigned char *udata = (unsigned char *)data; + unsigned char b = udata[4 * maskPos]; + unsigned char g = udata[4 * maskPos + 1]; + unsigned char r = udata[4 * maskPos + 1]; + for (int i = 0; i < h * w; ++i) { + if (b - udata[0] == 0 && g - udata[1] == 0 && r - udata[2] == 0) + udata[3] = 0; + udata += 4; + } } void render_image(Drawable d, int x, int y) { - if (!server.real_transparency) { - imlib_context_set_blend(1); - imlib_context_set_drawable(d); - imlib_render_image_on_drawable(x, y); - return; - } + if (!server.real_transparency) { + imlib_context_set_blend(1); + imlib_context_set_drawable(d); + imlib_render_image_on_drawable(x, y); + return; + } - int w = imlib_image_get_width(), h = imlib_image_get_height(); + int w = imlib_image_get_width(), h = imlib_image_get_height(); - Pixmap pixmap = XCreatePixmap(server.display, server.root_win, w, h, 32); - imlib_context_set_drawable(pixmap); - imlib_context_set_blend(0); - imlib_render_image_on_drawable(0, 0); + Pixmap pixmap = XCreatePixmap(server.display, server.root_win, w, h, 32); + imlib_context_set_drawable(pixmap); + imlib_context_set_blend(0); + imlib_render_image_on_drawable(0, 0); - Pixmap mask = XCreatePixmap(server.display, server.root_win, w, h, 32); - imlib_context_set_drawable(mask); - imlib_context_set_blend(0); - imlib_render_image_on_drawable(0, 0); + Pixmap mask = XCreatePixmap(server.display, server.root_win, w, h, 32); + imlib_context_set_drawable(mask); + imlib_context_set_blend(0); + imlib_render_image_on_drawable(0, 0); - Picture pict = XRenderCreatePicture(server.display, - pixmap, - XRenderFindStandardFormat(server.display, PictStandardARGB32), - 0, - 0); - Picture pict_drawable = - XRenderCreatePicture(server.display, d, XRenderFindVisualFormat(server.display, server.visual), 0, 0); - Picture pict_mask = - XRenderCreatePicture(server.display, mask, XRenderFindStandardFormat(server.display, PictStandardARGB32), 0, 0); - XRenderComposite(server.display, PictOpOver, pict, pict_mask, pict_drawable, 0, 0, 0, 0, x, y, w, h); + Picture pict = XRenderCreatePicture(server.display, + pixmap, + XRenderFindStandardFormat(server.display, PictStandardARGB32), + 0, + 0); + Picture pict_drawable = + XRenderCreatePicture(server.display, d, XRenderFindVisualFormat(server.display, server.visual), 0, 0); + Picture pict_mask = + XRenderCreatePicture(server.display, mask, XRenderFindStandardFormat(server.display, PictStandardARGB32), 0, 0); + XRenderComposite(server.display, PictOpOver, pict, pict_mask, pict_drawable, 0, 0, 0, 0, x, y, w, h); - XRenderFreePicture(server.display, pict_mask); - XRenderFreePicture(server.display, pict_drawable); - XRenderFreePicture(server.display, pict); - XFreePixmap(server.display, mask); - XFreePixmap(server.display, pixmap); + XRenderFreePicture(server.display, pict_mask); + XRenderFreePicture(server.display, pict_drawable); + XRenderFreePicture(server.display, pict); + XFreePixmap(server.display, mask); + XFreePixmap(server.display, pixmap); } void draw_text(PangoLayout *layout, cairo_t *c, int posx, int posy, Color *color, int font_shadow) { - if (font_shadow) { - const int shadow_size = 3; - const double shadow_edge_alpha = 0.0; - int i, j; - for (i = -shadow_size; i <= shadow_size; i++) { - for (j = -shadow_size; j <= shadow_size; j++) { - cairo_set_source_rgba(c, - 0.0, - 0.0, - 0.0, - 1.0 - - (1.0 - shadow_edge_alpha) * - sqrt((i * i + j * j) / (double)(shadow_size * shadow_size))); - pango_cairo_update_layout(c, layout); - cairo_move_to(c, posx + i, posy + j); - pango_cairo_show_layout(c, layout); - } - } - } - cairo_set_source_rgba(c, color->rgb[0], color->rgb[1], color->rgb[2], color->alpha); - pango_cairo_update_layout(c, layout); - cairo_move_to(c, posx, posy); - pango_cairo_show_layout(c, layout); + if (font_shadow) { + const int shadow_size = 3; + const double shadow_edge_alpha = 0.0; + int i, j; + for (i = -shadow_size; i <= shadow_size; i++) { + for (j = -shadow_size; j <= shadow_size; j++) { + cairo_set_source_rgba(c, + 0.0, + 0.0, + 0.0, + 1.0 - + (1.0 - shadow_edge_alpha) * + sqrt((i * i + j * j) / (double)(shadow_size * shadow_size))); + pango_cairo_update_layout(c, layout); + cairo_move_to(c, posx + i, posy + j); + pango_cairo_show_layout(c, layout); + } + } + } + cairo_set_source_rgba(c, color->rgb[0], color->rgb[1], color->rgb[2], color->alpha); + pango_cairo_update_layout(c, layout); + cairo_move_to(c, posx, posy); + pango_cairo_show_layout(c, layout); } Imlib_Image load_image(const char *path, int cached) { - Imlib_Image image; + Imlib_Image image; #ifdef HAVE_RSVG - if (cached) { - image = imlib_load_image_immediately(path); - } else { - image = imlib_load_image_immediately_without_cache(path); - } - if (!image && g_str_has_suffix(path, ".svg")) { - char tmp_filename[128]; - sprintf(tmp_filename, "/tmp/tint2-%d.png", (int)getpid()); - int fd = open(tmp_filename, O_CREAT | O_EXCL, 0600); - if (fd >= 0) { - // 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(path, &err); + if (cached) { + image = imlib_load_image_immediately(path); + } else { + image = imlib_load_image_immediately_without_cache(path); + } + if (!image && g_str_has_suffix(path, ".svg")) { + char tmp_filename[128]; + sprintf(tmp_filename, "/tmp/tint2-%d.png", (int)getpid()); + int fd = open(tmp_filename, O_CREAT | O_EXCL, 0600); + if (fd >= 0) { + // 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(path, &err); - if (err != NULL) { - fprintf(stderr, "Could not load svg image!: %s", err->message); - g_error_free(err); - } else { - GdkPixbuf *pixbuf = rsvg_handle_get_pixbuf(svg); - gdk_pixbuf_save(pixbuf, tmp_filename, "png", NULL, NULL); - } - exit(0); - } else { - // Parent - close(fd); - waitpid(pid, 0, 0); - image = imlib_load_image_immediately_without_cache(tmp_filename); - unlink(tmp_filename); - } - } - } else + if (err != NULL) { + fprintf(stderr, "Could not load svg image!: %s", err->message); + g_error_free(err); + } else { + GdkPixbuf *pixbuf = rsvg_handle_get_pixbuf(svg); + gdk_pixbuf_save(pixbuf, tmp_filename, "png", NULL, NULL); + } + exit(0); + } else { + // Parent + close(fd); + waitpid(pid, 0, 0); + image = imlib_load_image_immediately_without_cache(tmp_filename); + unlink(tmp_filename); + } + } + } else #endif - { - if (cached) { - image = imlib_load_image_immediately(path); - } else { - image = imlib_load_image_immediately_without_cache(path); - } - } - return image; + { + if (cached) { + image = imlib_load_image_immediately(path); + } else { + image = imlib_load_image_immediately_without_cache(path); + } + } + return image; } Imlib_Image adjust_icon(Imlib_Image original, int alpha, int saturation, int brightness) { - if (!original) - return NULL; + if (!original) + return NULL; - imlib_context_set_image(original); - Imlib_Image copy = imlib_clone_image(); + imlib_context_set_image(original); + Imlib_Image copy = imlib_clone_image(); - imlib_context_set_image(copy); - imlib_image_set_has_alpha(1); - DATA32 *data = imlib_image_get_data(); - adjust_asb(data, - imlib_image_get_width(), - imlib_image_get_height(), - alpha / 100.0, - saturation / 100.0, - brightness / 100.0); - imlib_image_put_back_data(data); - return copy; + imlib_context_set_image(copy); + imlib_image_set_has_alpha(1); + DATA32 *data = imlib_image_get_data(); + adjust_asb(data, + imlib_image_get_width(), + imlib_image_get_height(), + alpha / 100.0, + saturation / 100.0, + brightness / 100.0); + imlib_image_put_back_data(data); + return copy; } void draw_rect(cairo_t *c, double x, double y, double w, double h, double r) { - draw_rect_on_sides(c, x, y, w, h, r, BORDER_ALL); + draw_rect_on_sides(c, x, y, w, h, r, BORDER_ALL); } void draw_rect_on_sides(cairo_t *c, double x, double y, double w, double h, double r, int border_mask) { - double c1 = 0.55228475 * r; - cairo_move_to(c, x + r, y); - // Top line - if (border_mask & BORDER_TOP) - cairo_rel_line_to(c, w - 2 * r, 0); - else - cairo_rel_move_to(c, w - 2 * r, y); - // Top right corner - if (r > 0) { - if ((border_mask & BORDER_TOP) && (border_mask & BORDER_RIGHT)) - cairo_rel_curve_to(c, c1, 0.0, r, c1, r, r); - else - cairo_rel_move_to(c, r, r); - } - // Right line - if (border_mask & BORDER_RIGHT) - cairo_rel_line_to(c, 0, h - 2 * r); - else - cairo_rel_move_to(c, 0, h - 2 * r); - // Bottom right corner - if (r > 0) { - if ((border_mask & BORDER_RIGHT) && (border_mask & BORDER_BOTTOM)) - cairo_rel_curve_to(c, 0.0, c1, c1 - r, r, -r, r); - else - cairo_rel_move_to(c, -r, r); - } - // Bottom line - if (border_mask & BORDER_BOTTOM) - cairo_rel_line_to(c, -w + 2 * r, 0); - else - cairo_rel_move_to(c, -w + 2 * r, 0); - // Bottom left corner - if (r > 0) { - if ((border_mask & BORDER_LEFT) && (border_mask & BORDER_BOTTOM)) - cairo_rel_curve_to(c, -c1, 0, -r, -c1, -r, -r); - else - cairo_rel_move_to(c, -r, -r); - } - // Left line - if (border_mask & BORDER_LEFT) - cairo_rel_line_to(c, 0, -h + 2 * r); - else - cairo_rel_move_to(c, 0, -h + 2 * r); - // Top left corner - if (r > 0) { - if ((border_mask & BORDER_LEFT) && (border_mask & BORDER_TOP)) - cairo_rel_curve_to(c, 0, -c1, r - c1, -r, r, -r); - else - cairo_rel_move_to(c, r, -r); - } + double c1 = 0.55228475 * r; + cairo_move_to(c, x + r, y); + // Top line + if (border_mask & BORDER_TOP) + cairo_rel_line_to(c, w - 2 * r, 0); + else + cairo_rel_move_to(c, w - 2 * r, y); + // Top right corner + if (r > 0) { + if ((border_mask & BORDER_TOP) && (border_mask & BORDER_RIGHT)) + cairo_rel_curve_to(c, c1, 0.0, r, c1, r, r); + else + cairo_rel_move_to(c, r, r); + } + // Right line + if (border_mask & BORDER_RIGHT) + cairo_rel_line_to(c, 0, h - 2 * r); + else + cairo_rel_move_to(c, 0, h - 2 * r); + // Bottom right corner + if (r > 0) { + if ((border_mask & BORDER_RIGHT) && (border_mask & BORDER_BOTTOM)) + cairo_rel_curve_to(c, 0.0, c1, c1 - r, r, -r, r); + else + cairo_rel_move_to(c, -r, r); + } + // Bottom line + if (border_mask & BORDER_BOTTOM) + cairo_rel_line_to(c, -w + 2 * r, 0); + else + cairo_rel_move_to(c, -w + 2 * r, 0); + // Bottom left corner + if (r > 0) { + if ((border_mask & BORDER_LEFT) && (border_mask & BORDER_BOTTOM)) + cairo_rel_curve_to(c, -c1, 0, -r, -c1, -r, -r); + else + cairo_rel_move_to(c, -r, -r); + } + // Left line + if (border_mask & BORDER_LEFT) + cairo_rel_line_to(c, 0, -h + 2 * r); + else + cairo_rel_move_to(c, 0, -h + 2 * r); + // Top left corner + if (r > 0) { + if ((border_mask & BORDER_LEFT) && (border_mask & BORDER_TOP)) + cairo_rel_curve_to(c, 0, -c1, r - c1, -r, r, -r); + else + cairo_rel_move_to(c, r, -r); + } } void clear_pixmap(Pixmap p, int x, int y, int w, int h) { - Picture pict = - XRenderCreatePicture(server.display, p, XRenderFindVisualFormat(server.display, server.visual), 0, 0); - XRenderColor col; - col.red = col.green = col.blue = col.alpha = 0; - XRenderFillRectangle(server.display, PictOpSrc, pict, &col, x, y, w, h); - XRenderFreePicture(server.display, pict); + Picture pict = + XRenderCreatePicture(server.display, p, XRenderFindVisualFormat(server.display, server.visual), 0, 0); + XRenderColor col; + col.red = col.green = col.blue = col.alpha = 0; + XRenderFillRectangle(server.display, PictOpSrc, pict, &col, x, y, w, h); + XRenderFreePicture(server.display, pict); } void get_text_size2(PangoFontDescription *font, - int *height_ink, - int *height, - int *width, - int panel_height, - int panel_width, - char *text, - int len, - PangoWrapMode wrap, - PangoEllipsizeMode ellipsis, - gboolean markup) + int *height_ink, + int *height, + int *width, + int panel_height, + int panel_width, + char *text, + int len, + PangoWrapMode wrap, + PangoEllipsizeMode ellipsis, + gboolean markup) { - PangoRectangle rect_ink, rect; + PangoRectangle rect_ink, rect; - Pixmap pmap = XCreatePixmap(server.display, server.root_win, panel_height, panel_width, server.depth); + Pixmap pmap = XCreatePixmap(server.display, server.root_win, panel_height, panel_width, server.depth); - cairo_surface_t *cs = cairo_xlib_surface_create(server.display, pmap, server.visual, panel_height, panel_width); - cairo_t *c = cairo_create(cs); + cairo_surface_t *cs = cairo_xlib_surface_create(server.display, pmap, server.visual, panel_height, panel_width); + cairo_t *c = cairo_create(cs); - PangoLayout *layout = pango_cairo_create_layout(c); - pango_layout_set_width(layout, panel_width * PANGO_SCALE); - pango_layout_set_height(layout, panel_height * PANGO_SCALE); - pango_layout_set_wrap(layout, wrap); - pango_layout_set_ellipsize(layout, ellipsis); - pango_layout_set_font_description(layout, font); - if (!markup) - pango_layout_set_text(layout, text, len); - else - pango_layout_set_markup(layout, text, len); + PangoLayout *layout = pango_cairo_create_layout(c); + pango_layout_set_width(layout, panel_width * PANGO_SCALE); + pango_layout_set_height(layout, panel_height * PANGO_SCALE); + pango_layout_set_wrap(layout, wrap); + pango_layout_set_ellipsize(layout, ellipsis); + pango_layout_set_font_description(layout, font); + if (!markup) + pango_layout_set_text(layout, text, len); + else + pango_layout_set_markup(layout, text, len); - pango_layout_get_pixel_extents(layout, &rect_ink, &rect); - *height_ink = rect_ink.height; - *height = rect.height; - *width = rect.width; - // printf("dimension : %d - %d\n", rect_ink.height, rect.height); + pango_layout_get_pixel_extents(layout, &rect_ink, &rect); + *height_ink = rect_ink.height; + *height = rect.height; + *width = rect.width; + // printf("dimension : %d - %d\n", rect_ink.height, rect.height); - g_object_unref(layout); - cairo_destroy(c); - cairo_surface_destroy(cs); - XFreePixmap(server.display, pmap); + g_object_unref(layout); + cairo_destroy(c); + cairo_surface_destroy(cs); + XFreePixmap(server.display, pmap); } #if !GLIB_CHECK_VERSION(2, 34, 0) GList *g_list_copy_deep(GList *list, GCopyFunc func, gpointer user_data) { - list = g_list_copy(list); + list = g_list_copy(list); - if (func) { - for (GList *l = list; l; l = l->next) { - l->data = func(l->data, user_data); - } - } + if (func) { + for (GList *l = list; l; l = l->next) { + l->data = func(l->data, user_data); + } + } - return list; + return list; } #endif GSList *load_locations_from_env(GSList *locations, const char *var, ...) { - char *value = getenv(var); - if (value) { - value = strdup(value); - char *p = value; - char *t; - for (char *token = strtok_r(value, ":", &t); token; token = strtok_r(NULL, ":", &t)) { - va_list ap; - va_start(ap, var); - for (const char *suffix = va_arg(ap, const char *); suffix; suffix = va_arg(ap, const char *)) { - locations = g_slist_append(locations, g_build_filename(token, suffix, NULL)); - } - va_end(ap); - } - free(p); - } - return locations; + char *value = getenv(var); + if (value) { + value = strdup(value); + char *p = value; + char *t; + for (char *token = strtok_r(value, ":", &t); token; token = strtok_r(NULL, ":", &t)) { + va_list ap; + va_start(ap, var); + for (const char *suffix = va_arg(ap, const char *); suffix; suffix = va_arg(ap, const char *)) { + locations = g_slist_append(locations, g_build_filename(token, suffix, NULL)); + } + va_end(ap); + } + free(p); + } + return locations; } GSList *slist_remove_duplicates(GSList *list, GCompareFunc eq, GDestroyNotify fr) { - GSList *new_list = NULL; + GSList *new_list = NULL; - for (GSList *l1 = list; l1; l1 = g_slist_next(l1)) { - gboolean duplicate = FALSE; - for (GSList *l2 = new_list; l2; l2 = g_slist_next(l2)) { - if (eq(l1->data, l2->data)) { - duplicate = TRUE; - break; - } - } - if (!duplicate) { - new_list = g_slist_append(new_list, l1->data); - l1->data = NULL; - } - } + for (GSList *l1 = list; l1; l1 = g_slist_next(l1)) { + gboolean duplicate = FALSE; + for (GSList *l2 = new_list; l2; l2 = g_slist_next(l2)) { + if (eq(l1->data, l2->data)) { + duplicate = TRUE; + break; + } + } + if (!duplicate) { + new_list = g_slist_append(new_list, l1->data); + l1->data = NULL; + } + } - g_slist_free_full(list, fr); + g_slist_free_full(list, fr); - return new_list; + return new_list; } gint cmp_ptr(gconstpointer a, gconstpointer b) { - if (a < b) - return -1; - else if (a == b) - return 0; - else - return 1; + if (a < b) + return -1; + else if (a == b) + return 0; + else + return 1; }
M src/util/common.hsrc/util/common.h

@@ -24,19 +24,19 @@ #define MIN3(a, b, c) MIN(MIN(a, b), c)

// mouse actions typedef enum MouseAction { - NONE = 0, - CLOSE, - TOGGLE, - ICONIFY, - SHADE, - TOGGLE_ICONIFY, - MAXIMIZE_RESTORE, - MAXIMIZE, - RESTORE, - DESKTOP_LEFT, - DESKTOP_RIGHT, - NEXT_TASK, - PREV_TASK + NONE = 0, + CLOSE, + TOGGLE, + ICONIFY, + SHADE, + TOGGLE_ICONIFY, + MAXIMIZE_RESTORE, + MAXIMIZE, + RESTORE, + DESKTOP_LEFT, + DESKTOP_RIGHT, + NEXT_TASK, + PREV_TASK } MouseAction; #define ALL_DESKTOPS 0xFFFFFFFF

@@ -94,16 +94,16 @@ // Renders the current Imlib image to a drawable. Wrapper around imlib_render_image_on_drawable.

void render_image(Drawable d, int x, int y); void get_text_size2(PangoFontDescription *font, - int *height_ink, - int *height, - int *width, - int panel_height, - int panel_with, - char *text, - int len, - PangoWrapMode wrap, - PangoEllipsizeMode ellipsis, - gboolean markup); + int *height_ink, + int *height, + int *width, + int panel_height, + int panel_with, + char *text, + int len, + PangoWrapMode wrap, + PangoEllipsizeMode ellipsis, + gboolean markup); void draw_text(PangoLayout *layout, cairo_t *c, int posx, int posy, Color *color, int font_shadow);

@@ -125,10 +125,10 @@ // A trivial pointer comparator.

gint cmp_ptr(gconstpointer a, gconstpointer b); #define free_and_null(p) \ - { \ - free(p); \ - p = NULL; \ - } + { \ + free(p); \ + p = NULL; \ + } #if !GLIB_CHECK_VERSION(2, 33, 4) GList *g_list_copy_deep(GList *list, GCopyFunc func, gpointer user_data);
M src/util/gradient.csrc/util/gradient.c

@@ -8,116 +8,116 @@ #include "common.h"

gboolean read_double(const char *str, double *value) { - if (!str[0]) - return FALSE; - char *end; - *value = strtod(str, &end); - if (end[0]) - return FALSE; - return TRUE; + if (!str[0]) + return FALSE; + char *end; + *value = strtod(str, &end); + if (end[0]) + return FALSE; + return TRUE; } gboolean read_double_with_percent(const char *str, double *value) { - if (!str[0]) - return FALSE; - char *end; - *value = strtod(str, &end); - if (end[0] == '%' && !end[1]) { - *value *= 0.01; - return TRUE; - } - if (end[0]) - return FALSE; - return TRUE; + if (!str[0]) + return FALSE; + char *end; + *value = strtod(str, &end); + if (end[0] == '%' && !end[1]) { + *value *= 0.01; + return TRUE; + } + if (end[0]) + return FALSE; + return TRUE; } GradientType gradient_type_from_string(const char *str) { - if (g_str_equal(str, "horizontal")) - return GRADIENT_HORIZONTAL; - if (g_str_equal(str, "vertical")) - return GRADIENT_VERTICAL; - if (g_str_equal(str, "radial")) - return GRADIENT_CENTERED; - fprintf(stderr, RED "Invalid gradient type: %s" RESET "\n", str); - return GRADIENT_VERTICAL; + if (g_str_equal(str, "horizontal")) + return GRADIENT_HORIZONTAL; + if (g_str_equal(str, "vertical")) + return GRADIENT_VERTICAL; + if (g_str_equal(str, "radial")) + return GRADIENT_CENTERED; + fprintf(stderr, RED "Invalid gradient type: %s" RESET "\n", str); + return GRADIENT_VERTICAL; } void init_gradient(GradientClass *g, GradientType type) { - memset(g, 0, sizeof(*g)); - g->type = type; - if (g->type == GRADIENT_VERTICAL) { - Offset *offset_top = (Offset *)calloc(1, sizeof(Offset)); - offset_top->constant = TRUE; - offset_top->constant_value = 0; - g->from.offsets_y = g_list_append(g->from.offsets_y, offset_top); - Offset *offset_bottom = (Offset *)calloc(1, sizeof(Offset)); - offset_bottom->constant = FALSE; - offset_bottom->element = ELEMENT_SELF; - offset_bottom->variable = SIZE_HEIGHT; - offset_bottom->multiplier = 1.0; - g->to.offsets_y = g_list_append(g->to.offsets_y, offset_bottom); - } else if (g->type == GRADIENT_HORIZONTAL) { - Offset *offset_left = (Offset *)calloc(1, sizeof(Offset)); - offset_left->constant = TRUE; - offset_left->constant_value = 0; - g->from.offsets_x = g_list_append(g->from.offsets_x, offset_left); - Offset *offset_right = (Offset *)calloc(1, sizeof(Offset)); - offset_right->constant = FALSE; - offset_right->element = ELEMENT_SELF; - offset_right->variable = SIZE_WIDTH; - offset_right->multiplier = 1.0; - g->to.offsets_x = g_list_append(g->to.offsets_x, offset_right); - } else if (g->type == GRADIENT_CENTERED) { - // from - Offset *offset_center_x = (Offset *)calloc(1, sizeof(Offset)); - offset_center_x->constant = FALSE; - offset_center_x->element = ELEMENT_SELF; - offset_center_x->variable = SIZE_CENTERX; - offset_center_x->multiplier = 1.0; - g->from.offsets_x = g_list_append(g->from.offsets_x, offset_center_x); - Offset *offset_center_y = (Offset *)calloc(1, sizeof(Offset)); - offset_center_y->constant = FALSE; - offset_center_y->element = ELEMENT_SELF; - offset_center_y->variable = SIZE_CENTERY; - offset_center_y->multiplier = 1.0; - g->from.offsets_y = g_list_append(g->from.offsets_y, offset_center_y); - Offset *offset_center_r = (Offset *)calloc(1, sizeof(Offset)); - offset_center_r->constant = TRUE; - offset_center_r->constant_value = 0; - g->from.offsets_r = g_list_append(g->from.offsets_r, offset_center_r); - // to - offset_center_x = (Offset *)calloc(1, sizeof(Offset)); - offset_center_x->constant = FALSE; - offset_center_x->element = ELEMENT_SELF; - offset_center_x->variable = SIZE_CENTERX; - offset_center_x->multiplier = 1.0; - g->to.offsets_x = g_list_append(g->to.offsets_x, offset_center_x); - offset_center_y = (Offset *)calloc(1, sizeof(Offset)); - offset_center_y->constant = FALSE; - offset_center_y->element = ELEMENT_SELF; - offset_center_y->variable = SIZE_CENTERY; - offset_center_y->multiplier = 1.0; - g->to.offsets_y = g_list_append(g->to.offsets_y, offset_center_y); - offset_center_r = (Offset *)calloc(1, sizeof(Offset)); - offset_center_r->constant = FALSE; - offset_center_r->element = ELEMENT_SELF; - offset_center_r->variable = SIZE_RADIUS; - offset_center_r->multiplier = 1.0; - g->to.offsets_r = g_list_append(g->to.offsets_r, offset_center_r); - } + memset(g, 0, sizeof(*g)); + g->type = type; + if (g->type == GRADIENT_VERTICAL) { + Offset *offset_top = (Offset *)calloc(1, sizeof(Offset)); + offset_top->constant = TRUE; + offset_top->constant_value = 0; + g->from.offsets_y = g_list_append(g->from.offsets_y, offset_top); + Offset *offset_bottom = (Offset *)calloc(1, sizeof(Offset)); + offset_bottom->constant = FALSE; + offset_bottom->element = ELEMENT_SELF; + offset_bottom->variable = SIZE_HEIGHT; + offset_bottom->multiplier = 1.0; + g->to.offsets_y = g_list_append(g->to.offsets_y, offset_bottom); + } else if (g->type == GRADIENT_HORIZONTAL) { + Offset *offset_left = (Offset *)calloc(1, sizeof(Offset)); + offset_left->constant = TRUE; + offset_left->constant_value = 0; + g->from.offsets_x = g_list_append(g->from.offsets_x, offset_left); + Offset *offset_right = (Offset *)calloc(1, sizeof(Offset)); + offset_right->constant = FALSE; + offset_right->element = ELEMENT_SELF; + offset_right->variable = SIZE_WIDTH; + offset_right->multiplier = 1.0; + g->to.offsets_x = g_list_append(g->to.offsets_x, offset_right); + } else if (g->type == GRADIENT_CENTERED) { + // from + Offset *offset_center_x = (Offset *)calloc(1, sizeof(Offset)); + offset_center_x->constant = FALSE; + offset_center_x->element = ELEMENT_SELF; + offset_center_x->variable = SIZE_CENTERX; + offset_center_x->multiplier = 1.0; + g->from.offsets_x = g_list_append(g->from.offsets_x, offset_center_x); + Offset *offset_center_y = (Offset *)calloc(1, sizeof(Offset)); + offset_center_y->constant = FALSE; + offset_center_y->element = ELEMENT_SELF; + offset_center_y->variable = SIZE_CENTERY; + offset_center_y->multiplier = 1.0; + g->from.offsets_y = g_list_append(g->from.offsets_y, offset_center_y); + Offset *offset_center_r = (Offset *)calloc(1, sizeof(Offset)); + offset_center_r->constant = TRUE; + offset_center_r->constant_value = 0; + g->from.offsets_r = g_list_append(g->from.offsets_r, offset_center_r); + // to + offset_center_x = (Offset *)calloc(1, sizeof(Offset)); + offset_center_x->constant = FALSE; + offset_center_x->element = ELEMENT_SELF; + offset_center_x->variable = SIZE_CENTERX; + offset_center_x->multiplier = 1.0; + g->to.offsets_x = g_list_append(g->to.offsets_x, offset_center_x); + offset_center_y = (Offset *)calloc(1, sizeof(Offset)); + offset_center_y->constant = FALSE; + offset_center_y->element = ELEMENT_SELF; + offset_center_y->variable = SIZE_CENTERY; + offset_center_y->multiplier = 1.0; + g->to.offsets_y = g_list_append(g->to.offsets_y, offset_center_y); + offset_center_r = (Offset *)calloc(1, sizeof(Offset)); + offset_center_r->constant = FALSE; + offset_center_r->element = ELEMENT_SELF; + offset_center_r->variable = SIZE_RADIUS; + offset_center_r->multiplier = 1.0; + g->to.offsets_r = g_list_append(g->to.offsets_r, offset_center_r); + } } void cleanup_gradient(GradientClass *g) { - g_list_free_full(g->extra_color_stops, free); - g_list_free_full(g->from.offsets_x, free); - g_list_free_full(g->from.offsets_y, free); - g_list_free_full(g->from.offsets_r, free); - g_list_free_full(g->to.offsets_x, free); - g_list_free_full(g->to.offsets_y, free); - g_list_free_full(g->to.offsets_r, free); - bzero(g, sizeof(*g)); + g_list_free_full(g->extra_color_stops, free); + g_list_free_full(g->from.offsets_x, free); + g_list_free_full(g->from.offsets_y, free); + g_list_free_full(g->from.offsets_r, free); + g_list_free_full(g->to.offsets_x, free); + g_list_free_full(g->to.offsets_y, free); + g_list_free_full(g->to.offsets_r, free); + bzero(g, sizeof(*g)); }
M src/util/gradient.hsrc/util/gradient.h

@@ -9,62 +9,54 @@

////////////////////////////////////////////////////////////////////// // Gradient types read from config options, not associated to any area -typedef enum GradientType { - GRADIENT_VERTICAL = 0, - GRADIENT_HORIZONTAL, - GRADIENT_CENTERED -} GradientType; +typedef enum GradientType { GRADIENT_VERTICAL = 0, GRADIENT_HORIZONTAL, GRADIENT_CENTERED } GradientType; typedef struct ColorStop { - Color color; - // offset in 0-1 - double offset; + Color color; + // offset in 0-1 + double offset; } ColorStop; -typedef enum Element { - ELEMENT_SELF = 0, - ELEMENT_PARENT, - ELEMENT_PANEL -} Element; +typedef enum Element { ELEMENT_SELF = 0, ELEMENT_PARENT, ELEMENT_PANEL } Element; typedef enum SizeVariable { - SIZE_WIDTH = 0, - SIZE_HEIGHT, - SIZE_RADIUS, - SIZE_LEFT, - SIZE_RIGHT, - SIZE_TOP, - SIZE_BOTTOM, - SIZE_CENTERX, - SIZE_CENTERY + SIZE_WIDTH = 0, + SIZE_HEIGHT, + SIZE_RADIUS, + SIZE_LEFT, + SIZE_RIGHT, + SIZE_TOP, + SIZE_BOTTOM, + SIZE_CENTERX, + SIZE_CENTERY } SizeVariable; typedef struct Offset { - gboolean constant; - // if constant == true - double constant_value; - // else - Element element; - SizeVariable variable; - double multiplier; + gboolean constant; + // if constant == true + double constant_value; + // else + Element element; + SizeVariable variable; + double multiplier; } Offset; typedef struct ControlPoint { - // Each element is an Offset - GList *offsets_x; - GList *offsets_y; - // Defined only for radial gradients - GList *offsets_r; + // Each element is an Offset + GList *offsets_x; + GList *offsets_y; + // Defined only for radial gradients + GList *offsets_r; } ControlPoint; typedef struct GradientClass { - GradientType type; - Color start_color; - Color end_color; - // Each element is a ColorStop - GList *extra_color_stops; - ControlPoint from; - ControlPoint to; + GradientType type; + Color start_color; + Color end_color; + // Each element is a ColorStop + GList *extra_color_stops; + ControlPoint from; + ControlPoint to; } GradientClass; GradientType gradient_type_from_string(const char *str);

@@ -78,9 +70,9 @@ struct Area;

typedef struct Area Area; typedef struct GradientInstance { - GradientClass *gradient_class; - Area *area; - cairo_pattern_t *pattern; + GradientClass *gradient_class; + Area *area; + cairo_pattern_t *pattern; } GradientInstance; extern gboolean debug_gradients;
M src/util/strnatcmp.csrc/util/strnatcmp.c

@@ -43,110 +43,110 @@ // both numbers to know that they have the same magnitude, so we

// remember it in BIAS. static int compare_right(char const *a, char const *b) { - int bias = 0; + int bias = 0; - for (;; a++, b++) { - if (!isdigit(*a) && !isdigit(*b)) - return bias; - else if (!isdigit(*a)) - return -1; - else if (!isdigit(*b)) - return +1; - else if (*a < *b) { - if (!bias) - bias = -1; - } else if (*a > *b) { - if (!bias) - bias = +1; - } else if (!*a && !*b) - return bias; - } + for (;; a++, b++) { + if (!isdigit(*a) && !isdigit(*b)) + return bias; + else if (!isdigit(*a)) + return -1; + else if (!isdigit(*b)) + return +1; + else if (*a < *b) { + if (!bias) + bias = -1; + } else if (*a > *b) { + if (!bias) + bias = +1; + } else if (!*a && !*b) + return bias; + } - return 0; + return 0; } // Compare two left-aligned numbers: // The first to have a different value wins. static int compare_left(char const *a, char const *b) { - for (;; a++, b++) { - if (!isdigit(*a) && !isdigit(*b)) - return 0; - else if (!isdigit(*a)) - return -1; - else if (!isdigit(*b)) - return +1; - else if (*a < *b) - return -1; - else if (*a > *b) - return +1; - } + for (;; a++, b++) { + if (!isdigit(*a) && !isdigit(*b)) + return 0; + else if (!isdigit(*a)) + return -1; + else if (!isdigit(*b)) + return +1; + else if (*a < *b) + return -1; + else if (*a > *b) + return +1; + } - return 0; + return 0; } static int strnatcmp0(char const *a, char const *b, int ignore_case) { - assert(a && b); + assert(a && b); - int ai, bi; - ai = bi = 0; - while (1) { - char ca = a[ai]; - char cb = b[bi]; + int ai, bi; + ai = bi = 0; + while (1) { + char ca = a[ai]; + char cb = b[bi]; - // Skip over leading spaces - while (isspace(ca)) { - ai++; - ca = a[ai]; - } + // Skip over leading spaces + while (isspace(ca)) { + ai++; + ca = a[ai]; + } - while (isspace(cb)) { - bi++; - cb = b[bi]; - } + while (isspace(cb)) { + bi++; + cb = b[bi]; + } - // Process run of digits - if (isdigit(ca) && isdigit(cb)) { - int fractional = (ca == '0' || cb == '0'); + // Process run of digits + if (isdigit(ca) && isdigit(cb)) { + int fractional = (ca == '0' || cb == '0'); - if (fractional) { - int result = compare_left(a + ai, b + bi); - if (result) - return result; - } else { - int result = compare_right(a + ai, b + bi); - if (result) - return result; - } - } + if (fractional) { + int result = compare_left(a + ai, b + bi); + if (result) + return result; + } else { + int result = compare_right(a + ai, b + bi); + if (result) + return result; + } + } - if (!ca && !cb) { - // The strings compare the same. Perhaps the caller will want to call strcmp to break the tie. - return 0; - } + if (!ca && !cb) { + // The strings compare the same. Perhaps the caller will want to call strcmp to break the tie. + return 0; + } - if (ignore_case) { - ca = toupper(ca); - cb = toupper(cb); - } + if (ignore_case) { + ca = toupper(ca); + cb = toupper(cb); + } - if (ca < cb) - return -1; - else if (ca > cb) - return +1; + if (ca < cb) + return -1; + else if (ca > cb) + return +1; - ai++; - bi++; - } + ai++; + bi++; + } } int strnatcmp(char const *a, char const *b) { - return strnatcmp0(a, b, 0); + return strnatcmp0(a, b, 0); } int strnatcasecmp(char const *a, char const *b) { - return strnatcmp0(a, b, 1); + return strnatcmp0(a, b, 1); }
M src/util/timer.csrc/util/timer.c

@@ -28,22 +28,22 @@ GHashTable *multi_timeouts;

// functions and structs for multi timeouts typedef struct { - int current_count; - int count_to_expiration; + int current_count; + int count_to_expiration; } multi_timeout; typedef struct { - GSList *timeout_list; - timeout *parent_timeout; + GSList *timeout_list; + timeout *parent_timeout; } multi_timeout_handler; struct _timeout { - int interval_msec; - struct timespec timeout_expires; - void (*_callback)(void *); - void *arg; - multi_timeout *multi_timeout; - timeout **self; + int interval_msec; + struct timespec timeout_expires; + void (*_callback)(void *); + void *arg; + multi_timeout *multi_timeout; + timeout **self; }; void add_timeout_intern(int value_msec, int interval_msec, void (*_callback)(void *), void *arg, timeout *t);

@@ -61,25 +61,25 @@ void stop_multi_timeout(timeout *t);

void default_timeout() { - timeout_list = NULL; - multi_timeouts = NULL; + timeout_list = NULL; + multi_timeouts = NULL; } void cleanup_timeout() { - while (timeout_list) { - timeout *t = timeout_list->data; - if (t->multi_timeout) - stop_multi_timeout(t); - if (t->self) - *t->self = NULL; - free(t); - timeout_list = g_slist_remove(timeout_list, t); - } - if (multi_timeouts) { - g_hash_table_destroy(multi_timeouts); - multi_timeouts = NULL; - } + while (timeout_list) { + timeout *t = timeout_list->data; + if (t->multi_timeout) + stop_multi_timeout(t); + if (t->self) + *t->self = NULL; + free(t); + timeout_list = g_slist_remove(timeout_list, t); + } + if (multi_timeouts) { + g_hash_table_destroy(multi_timeouts); + multi_timeouts = NULL; + } } // Implementation notes for timeouts

@@ -96,358 +96,358 @@ // however it's save to call it.

timeout *add_timeout(int value_msec, int interval_msec, void (*_callback)(void *), void *arg, timeout **self) { - if (self && *self) - return *self; - timeout *t = calloc(1, sizeof(timeout)); - t->self = self; - add_timeout_intern(value_msec, interval_msec, _callback, arg, t); - return t; + if (self && *self) + return *self; + timeout *t = calloc(1, sizeof(timeout)); + t->self = self; + add_timeout_intern(value_msec, interval_msec, _callback, arg, t); + return t; } void change_timeout(timeout **t, int value_msec, int interval_msec, void (*_callback)(), void *arg) { - if (!((timeout_list && g_slist_find(timeout_list, *t)) || - (multi_timeouts && g_hash_table_lookup(multi_timeouts, *t)))) - *t = add_timeout(value_msec, interval_msec, _callback, arg, t); - else { - if ((*t)->multi_timeout) - remove_from_multi_timeout(*t); - else - timeout_list = g_slist_remove(timeout_list, *t); - add_timeout_intern(value_msec, interval_msec, _callback, arg, *t); - } + if (!((timeout_list && g_slist_find(timeout_list, *t)) || + (multi_timeouts && g_hash_table_lookup(multi_timeouts, *t)))) + *t = add_timeout(value_msec, interval_msec, _callback, arg, t); + else { + if ((*t)->multi_timeout) + remove_from_multi_timeout(*t); + else + timeout_list = g_slist_remove(timeout_list, *t); + add_timeout_intern(value_msec, interval_msec, _callback, arg, *t); + } } void update_next_timeout() { - if (timeout_list) { - timeout *t = timeout_list->data; - struct timespec cur_time; - struct timespec next_timeout2 = {.tv_sec = next_timeout.tv_sec, .tv_nsec = next_timeout.tv_usec * 1000}; - clock_gettime(CLOCK_MONOTONIC, &cur_time); - if (timespec_subtract(&next_timeout2, &t->timeout_expires, &cur_time)) { - next_timeout.tv_sec = 0; - next_timeout.tv_usec = 0; - } else { - next_timeout.tv_sec = next_timeout2.tv_sec; - next_timeout.tv_usec = next_timeout2.tv_nsec / 1000; - } - } else - next_timeout.tv_sec = -1; + if (timeout_list) { + timeout *t = timeout_list->data; + struct timespec cur_time; + struct timespec next_timeout2 = {.tv_sec = next_timeout.tv_sec, .tv_nsec = next_timeout.tv_usec * 1000}; + clock_gettime(CLOCK_MONOTONIC, &cur_time); + if (timespec_subtract(&next_timeout2, &t->timeout_expires, &cur_time)) { + next_timeout.tv_sec = 0; + next_timeout.tv_usec = 0; + } else { + next_timeout.tv_sec = next_timeout2.tv_sec; + next_timeout.tv_usec = next_timeout2.tv_nsec / 1000; + } + } else + next_timeout.tv_sec = -1; } void callback_timeout_expired() { - struct timespec cur_time; - timeout *t; - while (timeout_list) { - clock_gettime(CLOCK_MONOTONIC, &cur_time); - t = timeout_list->data; - if (compare_timespecs(&t->timeout_expires, &cur_time) <= 0) { - // it's time for the callback function - t->_callback(t->arg); - // If _callback() calls stop_timeout(t) the timer 't' was freed and is not in the timeout_list - if (g_slist_find(timeout_list, t)) { - // Timer still exists - timeout_list = g_slist_remove(timeout_list, t); - if (t->interval_msec > 0) { - add_timeout_intern(t->interval_msec, t->interval_msec, t->_callback, t->arg, t); - } else { - // Destroy single-shot timer - if (t->self) - *t->self = NULL; - free(t); - } - } - } else { - return; - } - } + struct timespec cur_time; + timeout *t; + while (timeout_list) { + clock_gettime(CLOCK_MONOTONIC, &cur_time); + t = timeout_list->data; + if (compare_timespecs(&t->timeout_expires, &cur_time) <= 0) { + // it's time for the callback function + t->_callback(t->arg); + // If _callback() calls stop_timeout(t) the timer 't' was freed and is not in the timeout_list + if (g_slist_find(timeout_list, t)) { + // Timer still exists + timeout_list = g_slist_remove(timeout_list, t); + if (t->interval_msec > 0) { + add_timeout_intern(t->interval_msec, t->interval_msec, t->_callback, t->arg, t); + } else { + // Destroy single-shot timer + if (t->self) + *t->self = NULL; + free(t); + } + } + } else { + return; + } + } } void stop_timeout(timeout *t) { - if (!t) - return; - // if not in the list, it was deleted in callback_timeout_expired - if ((timeout_list && g_slist_find(timeout_list, t)) || (multi_timeouts && g_hash_table_lookup(multi_timeouts, t))) { - if (multi_timeouts && t->multi_timeout) - remove_from_multi_timeout(t); - if (timeout_list) - timeout_list = g_slist_remove(timeout_list, t); - if (t->self) - *t->self = NULL; - free(t); - } + if (!t) + return; + // if not in the list, it was deleted in callback_timeout_expired + if ((timeout_list && g_slist_find(timeout_list, t)) || (multi_timeouts && g_hash_table_lookup(multi_timeouts, t))) { + if (multi_timeouts && t->multi_timeout) + remove_from_multi_timeout(t); + if (timeout_list) + timeout_list = g_slist_remove(timeout_list, t); + if (t->self) + *t->self = NULL; + free(t); + } } void add_timeout_intern(int value_msec, int interval_msec, void (*_callback)(), void *arg, timeout *t) { - t->interval_msec = interval_msec; - t->_callback = _callback; - t->arg = arg; - struct timespec cur_time; - clock_gettime(CLOCK_MONOTONIC, &cur_time); - t->timeout_expires = add_msec_to_timespec(cur_time, value_msec); + t->interval_msec = interval_msec; + t->_callback = _callback; + t->arg = arg; + struct timespec cur_time; + clock_gettime(CLOCK_MONOTONIC, &cur_time); + t->timeout_expires = add_msec_to_timespec(cur_time, value_msec); - int can_align = 0; - if (interval_msec > 0 && !t->multi_timeout) - can_align = align_with_existing_timeouts(t); - if (!can_align) - timeout_list = g_slist_insert_sorted(timeout_list, t, compare_timeouts); + int can_align = 0; + if (interval_msec > 0 && !t->multi_timeout) + can_align = align_with_existing_timeouts(t); + if (!can_align) + timeout_list = g_slist_insert_sorted(timeout_list, t, compare_timeouts); } gint compare_timeouts(gconstpointer t1, gconstpointer t2) { - return compare_timespecs(&((const timeout *)t1)->timeout_expires, &((const timeout *)t2)->timeout_expires); + return compare_timespecs(&((const timeout *)t1)->timeout_expires, &((const timeout *)t2)->timeout_expires); } gint compare_timespecs(const struct timespec *t1, const struct timespec *t2) { - if (t1->tv_sec < t2->tv_sec) - return -1; - else if (t1->tv_sec == t2->tv_sec) { - if (t1->tv_nsec < t2->tv_nsec) - return -1; - else if (t1->tv_nsec == t2->tv_nsec) - return 0; - else - return 1; - } else - return 1; + if (t1->tv_sec < t2->tv_sec) + return -1; + else if (t1->tv_sec == t2->tv_sec) { + if (t1->tv_nsec < t2->tv_nsec) + return -1; + else if (t1->tv_nsec == t2->tv_nsec) + return 0; + else + return 1; + } else + return 1; } int timespec_subtract(struct timespec *result, struct timespec *x, struct timespec *y) { - /* Perform the carry for the later subtraction by updating y. */ - if (x->tv_nsec < y->tv_nsec) { - int nsec = (y->tv_nsec - x->tv_nsec) / 1000000000 + 1; - y->tv_nsec -= 1000000000 * nsec; - y->tv_sec += nsec; - } - if (x->tv_nsec - y->tv_nsec > 1000000000) { - int nsec = (x->tv_nsec - y->tv_nsec) / 1000000000; - y->tv_nsec += 1000000000 * nsec; - y->tv_sec -= nsec; - } + /* Perform the carry for the later subtraction by updating y. */ + if (x->tv_nsec < y->tv_nsec) { + int nsec = (y->tv_nsec - x->tv_nsec) / 1000000000 + 1; + y->tv_nsec -= 1000000000 * nsec; + y->tv_sec += nsec; + } + if (x->tv_nsec - y->tv_nsec > 1000000000) { + int nsec = (x->tv_nsec - y->tv_nsec) / 1000000000; + y->tv_nsec += 1000000000 * nsec; + y->tv_sec -= nsec; + } - /* Compute the time remaining to wait. tv_nsec is certainly positive. */ - result->tv_sec = x->tv_sec - y->tv_sec; - result->tv_nsec = x->tv_nsec - y->tv_nsec; + /* Compute the time remaining to wait. tv_nsec is certainly positive. */ + result->tv_sec = x->tv_sec - y->tv_sec; + result->tv_nsec = x->tv_nsec - y->tv_nsec; - /* Return 1 if result is negative. */ - return x->tv_sec < y->tv_sec; + /* Return 1 if result is negative. */ + return x->tv_sec < y->tv_sec; } struct timespec add_msec_to_timespec(struct timespec ts, int msec) { - ts.tv_sec += msec / 1000; - ts.tv_nsec += (msec % 1000) * 1000000; - if (ts.tv_nsec >= 1000000000) { // 10^9 - ts.tv_sec++; - ts.tv_nsec -= 1000000000; - } - return ts; + ts.tv_sec += msec / 1000; + ts.tv_nsec += (msec % 1000) * 1000000; + if (ts.tv_nsec >= 1000000000) { // 10^9 + ts.tv_sec++; + ts.tv_nsec -= 1000000000; + } + return ts; } int align_with_existing_timeouts(timeout *t) { - GSList *it = timeout_list; - while (it) { - timeout *t2 = it->data; - if (t2->interval_msec > 0) { - if (t->interval_msec % t2->interval_msec == 0 || t2->interval_msec % t->interval_msec == 0) { - if (!multi_timeouts) - multi_timeouts = g_hash_table_new(0, 0); - if (!t->multi_timeout && !t2->multi_timeout) { - // both timeouts can be aligned, but there is no multi timeout for them - create_multi_timeout(t, t2); - } else { - // there is already a multi timeout, so we append the new timeout to the multi timeout - append_multi_timeout(t, t2); - } - return 1; - } - } - it = it->next; - } - return 0; + GSList *it = timeout_list; + while (it) { + timeout *t2 = it->data; + if (t2->interval_msec > 0) { + if (t->interval_msec % t2->interval_msec == 0 || t2->interval_msec % t->interval_msec == 0) { + if (!multi_timeouts) + multi_timeouts = g_hash_table_new(0, 0); + if (!t->multi_timeout && !t2->multi_timeout) { + // both timeouts can be aligned, but there is no multi timeout for them + create_multi_timeout(t, t2); + } else { + // there is already a multi timeout, so we append the new timeout to the multi timeout + append_multi_timeout(t, t2); + } + return 1; + } + } + it = it->next; + } + return 0; } int calc_multi_timeout_interval(multi_timeout_handler *mth) { - GSList *it = mth->timeout_list; - timeout *t = it->data; - int min_interval = t->interval_msec; - it = it->next; - while (it) { - t = it->data; - if (t->interval_msec < min_interval) - min_interval = t->interval_msec; - it = it->next; - } - return min_interval; + GSList *it = mth->timeout_list; + timeout *t = it->data; + int min_interval = t->interval_msec; + it = it->next; + while (it) { + t = it->data; + if (t->interval_msec < min_interval) + min_interval = t->interval_msec; + it = it->next; + } + return min_interval; } void create_multi_timeout(timeout *t1, timeout *t2) { - multi_timeout *mt1 = calloc(1, sizeof(multi_timeout)); - multi_timeout *mt2 = calloc(1, sizeof(multi_timeout)); - multi_timeout_handler *mth = calloc(1, sizeof(multi_timeout_handler)); - timeout *real_timeout = calloc(1, sizeof(timeout)); + multi_timeout *mt1 = calloc(1, sizeof(multi_timeout)); + multi_timeout *mt2 = calloc(1, sizeof(multi_timeout)); + multi_timeout_handler *mth = calloc(1, sizeof(multi_timeout_handler)); + timeout *real_timeout = calloc(1, sizeof(timeout)); - mth->timeout_list = 0; - mth->timeout_list = g_slist_prepend(mth->timeout_list, t1); - mth->timeout_list = g_slist_prepend(mth->timeout_list, t2); - mth->parent_timeout = real_timeout; + mth->timeout_list = 0; + mth->timeout_list = g_slist_prepend(mth->timeout_list, t1); + mth->timeout_list = g_slist_prepend(mth->timeout_list, t2); + mth->parent_timeout = real_timeout; - g_hash_table_insert(multi_timeouts, t1, mth); - g_hash_table_insert(multi_timeouts, t2, mth); - g_hash_table_insert(multi_timeouts, real_timeout, mth); + g_hash_table_insert(multi_timeouts, t1, mth); + g_hash_table_insert(multi_timeouts, t2, mth); + g_hash_table_insert(multi_timeouts, real_timeout, mth); - t1->multi_timeout = mt1; - t2->multi_timeout = mt2; - // set real_timeout->multi_timeout to something, such that we see in add_timeout_intern that - // it is already a multi_timeout (we never use it, except of checking for 0 ptr) - real_timeout->multi_timeout = (void *)real_timeout; + t1->multi_timeout = mt1; + t2->multi_timeout = mt2; + // set real_timeout->multi_timeout to something, such that we see in add_timeout_intern that + // it is already a multi_timeout (we never use it, except of checking for 0 ptr) + real_timeout->multi_timeout = (void *)real_timeout; - timeout_list = g_slist_remove(timeout_list, t1); - timeout_list = g_slist_remove(timeout_list, t2); + timeout_list = g_slist_remove(timeout_list, t1); + timeout_list = g_slist_remove(timeout_list, t2); - update_multi_timeout_values(mth); + update_multi_timeout_values(mth); } void append_multi_timeout(timeout *t1, timeout *t2) { - if (t2->multi_timeout) { - // swap t1 and t2 such that t1 is the multi timeout - timeout *tmp = t2; - t2 = t1; - t1 = tmp; - } + if (t2->multi_timeout) { + // swap t1 and t2 such that t1 is the multi timeout + timeout *tmp = t2; + t2 = t1; + t1 = tmp; + } - multi_timeout *mt = calloc(1, sizeof(multi_timeout)); - multi_timeout_handler *mth = g_hash_table_lookup(multi_timeouts, t1); + multi_timeout *mt = calloc(1, sizeof(multi_timeout)); + multi_timeout_handler *mth = g_hash_table_lookup(multi_timeouts, t1); - mth->timeout_list = g_slist_prepend(mth->timeout_list, t2); - g_hash_table_insert(multi_timeouts, t2, mth); + mth->timeout_list = g_slist_prepend(mth->timeout_list, t2); + g_hash_table_insert(multi_timeouts, t2, mth); - t2->multi_timeout = mt; + t2->multi_timeout = mt; - update_multi_timeout_values(mth); + update_multi_timeout_values(mth); } void update_multi_timeout_values(multi_timeout_handler *mth) { - int interval = calc_multi_timeout_interval(mth); - int next_timeout_msec = interval; + int interval = calc_multi_timeout_interval(mth); + int next_timeout_msec = interval; - struct timespec cur_time; - clock_gettime(CLOCK_MONOTONIC, &cur_time); + struct timespec cur_time; + clock_gettime(CLOCK_MONOTONIC, &cur_time); - GSList *it = mth->timeout_list; - struct timespec diff_time; - while (it) { - timeout *t = it->data; - t->multi_timeout->count_to_expiration = t->interval_msec / interval; - timespec_subtract(&diff_time, &t->timeout_expires, &cur_time); - int msec_to_expiration = diff_time.tv_sec * 1000 + diff_time.tv_nsec / 1000000; - int count_left = msec_to_expiration / interval + (msec_to_expiration % interval != 0); - t->multi_timeout->current_count = t->multi_timeout->count_to_expiration - count_left; - if (msec_to_expiration < next_timeout_msec) - next_timeout_msec = msec_to_expiration; - it = it->next; - } + GSList *it = mth->timeout_list; + struct timespec diff_time; + while (it) { + timeout *t = it->data; + t->multi_timeout->count_to_expiration = t->interval_msec / interval; + timespec_subtract(&diff_time, &t->timeout_expires, &cur_time); + int msec_to_expiration = diff_time.tv_sec * 1000 + diff_time.tv_nsec / 1000000; + int count_left = msec_to_expiration / interval + (msec_to_expiration % interval != 0); + t->multi_timeout->current_count = t->multi_timeout->count_to_expiration - count_left; + if (msec_to_expiration < next_timeout_msec) + next_timeout_msec = msec_to_expiration; + it = it->next; + } - mth->parent_timeout->interval_msec = interval; - timeout_list = g_slist_remove(timeout_list, mth->parent_timeout); - add_timeout_intern(next_timeout_msec, interval, callback_multi_timeout, mth, mth->parent_timeout); + mth->parent_timeout->interval_msec = interval; + timeout_list = g_slist_remove(timeout_list, mth->parent_timeout); + add_timeout_intern(next_timeout_msec, interval, callback_multi_timeout, mth, mth->parent_timeout); } void callback_multi_timeout(void *arg) { - multi_timeout_handler *mth = arg; - struct timespec cur_time; - clock_gettime(CLOCK_MONOTONIC, &cur_time); - GSList *it = mth->timeout_list; - while (it) { - timeout *t = it->data; - if (++t->multi_timeout->current_count >= t->multi_timeout->count_to_expiration) { - t->_callback(t->arg); - if (multi_timeouts && g_hash_table_lookup(multi_timeouts, t)) { - // Timer still exists - t->multi_timeout->current_count = 0; - t->timeout_expires = add_msec_to_timespec(cur_time, t->interval_msec); - } else { - return; - } - } - it = it->next; - } + multi_timeout_handler *mth = arg; + struct timespec cur_time; + clock_gettime(CLOCK_MONOTONIC, &cur_time); + GSList *it = mth->timeout_list; + while (it) { + timeout *t = it->data; + if (++t->multi_timeout->current_count >= t->multi_timeout->count_to_expiration) { + t->_callback(t->arg); + if (multi_timeouts && g_hash_table_lookup(multi_timeouts, t)) { + // Timer still exists + t->multi_timeout->current_count = 0; + t->timeout_expires = add_msec_to_timespec(cur_time, t->interval_msec); + } else { + return; + } + } + it = it->next; + } } void remove_from_multi_timeout(timeout *t) { - multi_timeout_handler *mth = g_hash_table_lookup(multi_timeouts, t); - g_hash_table_remove(multi_timeouts, t); + multi_timeout_handler *mth = g_hash_table_lookup(multi_timeouts, t); + g_hash_table_remove(multi_timeouts, t); - mth->timeout_list = g_slist_remove(mth->timeout_list, t); - free(t->multi_timeout); - t->multi_timeout = 0; + mth->timeout_list = g_slist_remove(mth->timeout_list, t); + free(t->multi_timeout); + t->multi_timeout = 0; - if (g_slist_length(mth->timeout_list) == 1) { - timeout *last_timeout = mth->timeout_list->data; - mth->timeout_list = g_slist_remove(mth->timeout_list, last_timeout); - free(last_timeout->multi_timeout); - last_timeout->multi_timeout = 0; - g_hash_table_remove(multi_timeouts, last_timeout); - g_hash_table_remove(multi_timeouts, mth->parent_timeout); - mth->parent_timeout->multi_timeout = 0; - stop_timeout(mth->parent_timeout); - free(mth); + if (g_slist_length(mth->timeout_list) == 1) { + timeout *last_timeout = mth->timeout_list->data; + mth->timeout_list = g_slist_remove(mth->timeout_list, last_timeout); + free(last_timeout->multi_timeout); + last_timeout->multi_timeout = 0; + g_hash_table_remove(multi_timeouts, last_timeout); + g_hash_table_remove(multi_timeouts, mth->parent_timeout); + mth->parent_timeout->multi_timeout = 0; + stop_timeout(mth->parent_timeout); + free(mth); - struct timespec cur_time, diff_time; - clock_gettime(CLOCK_MONOTONIC, &cur_time); - timespec_subtract(&diff_time, &t->timeout_expires, &cur_time); - int msec_to_expiration = diff_time.tv_sec * 1000 + diff_time.tv_nsec / 1000000; - add_timeout_intern(msec_to_expiration, - last_timeout->interval_msec, - last_timeout->_callback, - last_timeout->arg, - last_timeout); - } else - update_multi_timeout_values(mth); + struct timespec cur_time, diff_time; + clock_gettime(CLOCK_MONOTONIC, &cur_time); + timespec_subtract(&diff_time, &t->timeout_expires, &cur_time); + int msec_to_expiration = diff_time.tv_sec * 1000 + diff_time.tv_nsec / 1000000; + add_timeout_intern(msec_to_expiration, + last_timeout->interval_msec, + last_timeout->_callback, + last_timeout->arg, + last_timeout); + } else + update_multi_timeout_values(mth); } void stop_multi_timeout(timeout *t) { - multi_timeout_handler *mth = g_hash_table_lookup(multi_timeouts, t); - g_hash_table_remove(multi_timeouts, mth->parent_timeout); - while (mth->timeout_list) { - timeout *t1 = mth->timeout_list->data; - mth->timeout_list = g_slist_remove(mth->timeout_list, t1); - g_hash_table_remove(multi_timeouts, t1); - free(t1->multi_timeout); - free(t1); - } - free(mth); + multi_timeout_handler *mth = g_hash_table_lookup(multi_timeouts, t); + g_hash_table_remove(multi_timeouts, mth->parent_timeout); + while (mth->timeout_list) { + timeout *t1 = mth->timeout_list->data; + mth->timeout_list = g_slist_remove(mth->timeout_list, t1); + g_hash_table_remove(multi_timeouts, t1); + free(t1->multi_timeout); + free(t1); + } + free(mth); } double profiling_get_time_old_time = 0; double get_time() { - struct timespec cur_time; - clock_gettime(CLOCK_MONOTONIC, &cur_time); - return cur_time.tv_sec + cur_time.tv_nsec * 1.0e-9; + struct timespec cur_time; + clock_gettime(CLOCK_MONOTONIC, &cur_time); + return cur_time.tv_sec + cur_time.tv_nsec * 1.0e-9; } double profiling_get_time() { - double t = get_time(); - if (profiling_get_time_old_time == 0) - profiling_get_time_old_time = t; - double delta = t - profiling_get_time_old_time; - profiling_get_time_old_time = t; - return delta; + double t = get_time(); + if (profiling_get_time_old_time == 0) + profiling_get_time_old_time = t; + double delta = t - profiling_get_time_old_time; + profiling_get_time_old_time = t; + return delta; }
M src/util/uevent.csrc/util/uevent.c

@@ -38,170 +38,170 @@ static GList *notifiers = NULL;

static const char *has_prefix(const char *str, const char *end, const char *prefix, size_t prefixlen) { - if ((end - str) < prefixlen) - return NULL; + if ((end - str) < prefixlen) + return NULL; - if (!memcmp(str, prefix, prefixlen)) - return str + prefixlen; + if (!memcmp(str, prefix, prefixlen)) + return str + prefixlen; - return NULL; + return NULL; } #define HAS_CONST_PREFIX(str, end, prefix) has_prefix((str), end, prefix, sizeof(prefix) - 1) static void uevent_param_free(gpointer data) { - struct uevent_parameter *param = data; - free(param->key); - free(param->val); - free(param); + struct uevent_parameter *param = data; + free(param->key); + free(param->val); + free(param); } static void uevent_free(struct uevent *ev) { - free(ev->path); - free(ev->subsystem); - g_list_free_full(ev->params, uevent_param_free); - free(ev); + free(ev->path); + free(ev->subsystem); + g_list_free_full(ev->params, uevent_param_free); + free(ev); } static struct uevent *uevent_new(char *buffer, int size) { - gboolean first = TRUE; + gboolean first = TRUE; - if (size == 0) - return NULL; + if (size == 0) + return NULL; - struct uevent *ev = calloc(1, sizeof(*ev)); - if (!ev) - return NULL; + struct uevent *ev = calloc(1, sizeof(*ev)); + if (!ev) + return NULL; - /* ensure nul termination required by strlen() */ - buffer[size - 1] = '\0'; + /* ensure nul termination required by strlen() */ + buffer[size - 1] = '\0'; - const char *s = buffer; - const char *end = s + size; - for (; s < end; s += strlen(s) + 1) { - if (first) { - const char *p = strchr(s, '@'); - if (!p) { - /* error: kernel events contain @ */ - /* triggered by udev events, though */ - free(ev); - return NULL; - } - ev->path = strdup(p + 1); - first = FALSE; - } else { - const char *val; - if ((val = HAS_CONST_PREFIX(s, end, "ACTION=")) != NULL) { - if (!strcmp(val, "add")) - ev->action = UEVENT_ADD; - else if (!strcmp(val, "remove")) - ev->action = UEVENT_REMOVE; - else if (!strcmp(val, "change")) - ev->action = UEVENT_CHANGE; - else - ev->action = UEVENT_UNKNOWN; - } else if ((val = HAS_CONST_PREFIX(s, end, "SEQNUM=")) != NULL) { - ev->sequence = atoi(val); - } else if ((val = HAS_CONST_PREFIX(s, end, "SUBSYSTEM=")) != NULL) { - ev->subsystem = strdup(val); - } else { - val = strchr(s, '='); - if (val) { - struct uevent_parameter *param = malloc(sizeof(*param)); - if (param) { - param->key = strndup(s, val - s); - param->val = strdup(val + 1); - ev->params = g_list_append(ev->params, param); - } - } - } - } - } + const char *s = buffer; + const char *end = s + size; + for (; s < end; s += strlen(s) + 1) { + if (first) { + const char *p = strchr(s, '@'); + if (!p) { + /* error: kernel events contain @ */ + /* triggered by udev events, though */ + free(ev); + return NULL; + } + ev->path = strdup(p + 1); + first = FALSE; + } else { + const char *val; + if ((val = HAS_CONST_PREFIX(s, end, "ACTION=")) != NULL) { + if (!strcmp(val, "add")) + ev->action = UEVENT_ADD; + else if (!strcmp(val, "remove")) + ev->action = UEVENT_REMOVE; + else if (!strcmp(val, "change")) + ev->action = UEVENT_CHANGE; + else + ev->action = UEVENT_UNKNOWN; + } else if ((val = HAS_CONST_PREFIX(s, end, "SEQNUM=")) != NULL) { + ev->sequence = atoi(val); + } else if ((val = HAS_CONST_PREFIX(s, end, "SUBSYSTEM=")) != NULL) { + ev->subsystem = strdup(val); + } else { + val = strchr(s, '='); + if (val) { + struct uevent_parameter *param = malloc(sizeof(*param)); + if (param) { + param->key = strndup(s, val - s); + param->val = strdup(val + 1); + ev->params = g_list_append(ev->params, param); + } + } + } + } + } - return ev; + return ev; } void uevent_register_notifier(struct uevent_notify *nb) { - notifiers = g_list_append(notifiers, nb); + notifiers = g_list_append(notifiers, nb); } void uevent_unregister_notifier(struct uevent_notify *nb) { - GList *l = notifiers; + GList *l = notifiers; - while (l != NULL) { - GList *next = l->next; - struct uevent_notify *lnb = l->data; + while (l != NULL) { + GList *next = l->next; + struct uevent_notify *lnb = l->data; - if (memcmp(nb, lnb, sizeof(struct uevent_notify)) == 0) - notifiers = g_list_delete_link(notifiers, l); + if (memcmp(nb, lnb, sizeof(struct uevent_notify)) == 0) + notifiers = g_list_delete_link(notifiers, l); - l = next; - } + l = next; + } } void uevent_handler() { - if (ueventfd < 0) - return; + if (ueventfd < 0) + return; - char buf[512]; - int len = recv(ueventfd, buf, sizeof(buf), MSG_DONTWAIT); - if (len < 0) - return; + char buf[512]; + int len = recv(ueventfd, buf, sizeof(buf), MSG_DONTWAIT); + if (len < 0) + return; - struct uevent *ev = uevent_new(buf, len); - if (ev) { - for (GList *l = notifiers; l; l = l->next) { - struct uevent_notify *nb = l->data; + struct uevent *ev = uevent_new(buf, len); + if (ev) { + for (GList *l = notifiers; l; l = l->next) { + struct uevent_notify *nb = l->data; - if (!(ev->action & nb->action)) - continue; + if (!(ev->action & nb->action)) + continue; - if (nb->subsystem && strcmp(ev->subsystem, nb->subsystem)) - continue; + if (nb->subsystem && strcmp(ev->subsystem, nb->subsystem)) + continue; - nb->cb(ev, nb->userdata); - } + nb->cb(ev, nb->userdata); + } - uevent_free(ev); - } + uevent_free(ev); + } } int uevent_init() { - /* Open hotplug event netlink socket */ - memset(&nls, 0, sizeof(struct sockaddr_nl)); - nls.nl_family = AF_NETLINK; - nls.nl_pid = getpid(); - nls.nl_groups = -1; + /* Open hotplug event netlink socket */ + memset(&nls, 0, sizeof(struct sockaddr_nl)); + nls.nl_family = AF_NETLINK; + nls.nl_pid = getpid(); + nls.nl_groups = -1; - /* open socket */ - ueventfd = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_KOBJECT_UEVENT); - if (ueventfd < 0) { - fprintf(stderr, "Error: socket open failed\n"); - return -1; - } + /* open socket */ + ueventfd = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_KOBJECT_UEVENT); + if (ueventfd < 0) { + fprintf(stderr, "Error: socket open failed\n"); + return -1; + } - /* Listen to netlink socket */ - if (bind(ueventfd, (void *)&nls, sizeof(struct sockaddr_nl))) { - fprintf(stderr, "Bind failed\n"); - return -1; - } + /* Listen to netlink socket */ + if (bind(ueventfd, (void *)&nls, sizeof(struct sockaddr_nl))) { + fprintf(stderr, "Bind failed\n"); + return -1; + } - printf("Kernel uevent interface initialized...\n"); + printf("Kernel uevent interface initialized...\n"); - return ueventfd; + return ueventfd; } void uevent_cleanup() { - if (ueventfd >= 0) - close(ueventfd); + if (ueventfd >= 0) + close(ueventfd); } #endif
M src/util/uevent.hsrc/util/uevent.h

@@ -21,31 +21,31 @@ #ifndef UEVENT_H

#define UEVENT_H enum uevent_action { - UEVENT_UNKNOWN = 0x01, - UEVENT_ADD = 0x02, - UEVENT_REMOVE = 0x04, - UEVENT_CHANGE = 0x08, + UEVENT_UNKNOWN = 0x01, + UEVENT_ADD = 0x02, + UEVENT_REMOVE = 0x04, + UEVENT_CHANGE = 0x08, }; struct uevent_parameter { - char *key; - char *val; + char *key; + char *val; }; struct uevent { - char *path; - enum uevent_action action; - int sequence; - char *subsystem; - GList *params; + char *path; + enum uevent_action action; + int sequence; + char *subsystem; + GList *params; }; struct uevent_notify { - int action; /* bitfield */ - char *subsystem; /* NULL => any */ - void *userdata; + int action; /* bitfield */ + char *subsystem; /* NULL => any */ + void *userdata; - void (*cb)(struct uevent *e, void *userdata); + void (*cb)(struct uevent *e, void *userdata); }; #if ENABLE_UEVENT

@@ -58,7 +58,7 @@ void uevent_unregister_notifier(struct uevent_notify *nb);

#else static inline int uevent_init() { - return -1; + return -1; } static inline void uevent_cleanup()
M src/util/window.csrc/util/window.c

@@ -37,288 +37,288 @@ #include "taskbar.h"

void activate_window(Window win) { - send_event32(win, server.atom._NET_ACTIVE_WINDOW, 2, CurrentTime, 0); + send_event32(win, server.atom._NET_ACTIVE_WINDOW, 2, CurrentTime, 0); } void change_window_desktop(Window win, int desktop) { - send_event32(win, server.atom._NET_WM_DESKTOP, desktop, 2, 0); + send_event32(win, server.atom._NET_WM_DESKTOP, desktop, 2, 0); } void close_window(Window win) { - send_event32(win, server.atom._NET_CLOSE_WINDOW, 0, 2, 0); + send_event32(win, server.atom._NET_CLOSE_WINDOW, 0, 2, 0); } void toggle_window_shade(Window win) { - send_event32(win, server.atom._NET_WM_STATE, 2, server.atom._NET_WM_STATE_SHADED, 0); + send_event32(win, server.atom._NET_WM_STATE, 2, server.atom._NET_WM_STATE_SHADED, 0); } void toggle_window_maximized(Window win) { - send_event32(win, server.atom._NET_WM_STATE, 2, server.atom._NET_WM_STATE_MAXIMIZED_VERT, 0); - send_event32(win, server.atom._NET_WM_STATE, 2, server.atom._NET_WM_STATE_MAXIMIZED_HORZ, 0); + send_event32(win, server.atom._NET_WM_STATE, 2, server.atom._NET_WM_STATE_MAXIMIZED_VERT, 0); + send_event32(win, server.atom._NET_WM_STATE, 2, server.atom._NET_WM_STATE_MAXIMIZED_HORZ, 0); } gboolean window_is_hidden(Window win) { - Window window; - int count; + Window window; + int count; - Atom *at = server_get_property(win, server.atom._NET_WM_STATE, XA_ATOM, &count); - for (int i = 0; i < count; i++) { - if (at[i] == server.atom._NET_WM_STATE_SKIP_TASKBAR) { - XFree(at); - return TRUE; - } - // do not add transient_for windows if the transient window is already in the taskbar - window = win; - while (XGetTransientForHint(server.display, window, &window)) { - if (get_task_buttons(window)) { - XFree(at); - return TRUE; - } - } - } - XFree(at); + Atom *at = server_get_property(win, server.atom._NET_WM_STATE, XA_ATOM, &count); + for (int i = 0; i < count; i++) { + if (at[i] == server.atom._NET_WM_STATE_SKIP_TASKBAR) { + XFree(at); + return TRUE; + } + // do not add transient_for windows if the transient window is already in the taskbar + window = win; + while (XGetTransientForHint(server.display, window, &window)) { + if (get_task_buttons(window)) { + XFree(at); + return TRUE; + } + } + } + XFree(at); - at = server_get_property(win, server.atom._NET_WM_WINDOW_TYPE, XA_ATOM, &count); - for (int i = 0; i < count; i++) { - if (at[i] == server.atom._NET_WM_WINDOW_TYPE_DOCK || at[i] == server.atom._NET_WM_WINDOW_TYPE_DESKTOP || - at[i] == server.atom._NET_WM_WINDOW_TYPE_TOOLBAR || at[i] == server.atom._NET_WM_WINDOW_TYPE_MENU || - at[i] == server.atom._NET_WM_WINDOW_TYPE_SPLASH) { - XFree(at); - return TRUE; - } - } - XFree(at); + at = server_get_property(win, server.atom._NET_WM_WINDOW_TYPE, XA_ATOM, &count); + for (int i = 0; i < count; i++) { + if (at[i] == server.atom._NET_WM_WINDOW_TYPE_DOCK || at[i] == server.atom._NET_WM_WINDOW_TYPE_DESKTOP || + at[i] == server.atom._NET_WM_WINDOW_TYPE_TOOLBAR || at[i] == server.atom._NET_WM_WINDOW_TYPE_MENU || + at[i] == server.atom._NET_WM_WINDOW_TYPE_SPLASH) { + XFree(at); + return TRUE; + } + } + XFree(at); - for (int i = 0; i < num_panels; i++) { - if (panels[i].main_win == win) { - return TRUE; - } - } + for (int i = 0; i < num_panels; i++) { + if (panels[i].main_win == win) { + return TRUE; + } + } - // specification - // Windows with neither _NET_WM_WINDOW_TYPE nor WM_TRANSIENT_FOR set - // MUST be taken as top-level window. - return FALSE; + // specification + // Windows with neither _NET_WM_WINDOW_TYPE nor WM_TRANSIENT_FOR set + // MUST be taken as top-level window. + return FALSE; } int get_window_desktop(Window win) { - int desktop = get_property32(win, server.atom._NET_WM_DESKTOP, XA_CARDINAL); - if (desktop == ALL_DESKTOPS) - return desktop; - if (!server.viewports) - return CLAMP(desktop, 0, server.num_desktops - 1); + int desktop = get_property32(win, server.atom._NET_WM_DESKTOP, XA_CARDINAL); + if (desktop == ALL_DESKTOPS) + return desktop; + if (!server.viewports) + return CLAMP(desktop, 0, server.num_desktops - 1); - int x, y, w, h; - get_window_coordinates(win, &x, &y, &w, &h); + int x, y, w, h; + get_window_coordinates(win, &x, &y, &w, &h); - desktop = get_current_desktop(); - // Window coordinates are relative to the current viewport, make them absolute - x += server.viewports[desktop].x; - y += server.viewports[desktop].y; + desktop = get_current_desktop(); + // Window coordinates are relative to the current viewport, make them absolute + x += server.viewports[desktop].x; + y += server.viewports[desktop].y; - if (x < 0 || y < 0) { - int num_results; - long *x_screen_size = - server_get_property(server.root_win, server.atom._NET_DESKTOP_GEOMETRY, XA_CARDINAL, &num_results); - if (!x_screen_size) - return 0; - int x_screen_width = x_screen_size[0]; - int x_screen_height = x_screen_size[1]; - XFree(x_screen_size); + if (x < 0 || y < 0) { + int num_results; + long *x_screen_size = + server_get_property(server.root_win, server.atom._NET_DESKTOP_GEOMETRY, XA_CARDINAL, &num_results); + if (!x_screen_size) + return 0; + int x_screen_width = x_screen_size[0]; + int x_screen_height = x_screen_size[1]; + XFree(x_screen_size); - // Wrap - if (x < 0) - x += x_screen_width; - if (y < 0) - y += x_screen_height; - } + // Wrap + if (x < 0) + x += x_screen_width; + if (y < 0) + y += x_screen_height; + } - int best_match = -1; - int match_right = 0; - int match_bottom = 0; - // There is an ambiguity when a window is right on the edge between viewports. - // In that case, prefer the viewports which is on the right and bottom of the window's top-left corner. - for (int i = 0; i < server.num_desktops; i++) { - if (x >= server.viewports[i].x && x <= (server.viewports[i].x + server.viewports[i].width) && - y >= server.viewports[i].y && y <= (server.viewports[i].y + server.viewports[i].height)) { - int current_right = x < (server.viewports[i].x + server.viewports[i].width); - int current_bottom = y < (server.viewports[i].y + server.viewports[i].height); - if (best_match < 0 || (!match_right && current_right) || (!match_bottom && current_bottom)) { - best_match = i; - } - } - } + int best_match = -1; + int match_right = 0; + int match_bottom = 0; + // There is an ambiguity when a window is right on the edge between viewports. + // In that case, prefer the viewports which is on the right and bottom of the window's top-left corner. + for (int i = 0; i < server.num_desktops; i++) { + if (x >= server.viewports[i].x && x <= (server.viewports[i].x + server.viewports[i].width) && + y >= server.viewports[i].y && y <= (server.viewports[i].y + server.viewports[i].height)) { + int current_right = x < (server.viewports[i].x + server.viewports[i].width); + int current_bottom = y < (server.viewports[i].y + server.viewports[i].height); + if (best_match < 0 || (!match_right && current_right) || (!match_bottom && current_bottom)) { + best_match = i; + } + } + } - if (best_match < 0) - best_match = 0; - // fprintf(stderr, "window %lx %s : viewport %d, (%d, %d)\n", win, get_task(win) ? get_task(win)->title : "??", - // best_match+1, x, y); - return best_match; + if (best_match < 0) + best_match = 0; + // fprintf(stderr, "window %lx %s : viewport %d, (%d, %d)\n", win, get_task(win) ? get_task(win)->title : "??", + // best_match+1, x, y); + return best_match; } int get_window_monitor(Window win) { - int x, y, w, h; - get_window_coordinates(win, &x, &y, &w, &h); + int x, y, w, h; + get_window_coordinates(win, &x, &y, &w, &h); - int best_match = -1; - int match_right = 0; - int match_bottom = 0; - // There is an ambiguity when a window is right on the edge between screens. - // In that case, prefer the monitor which is on the right and bottom of the window's top-left corner. - for (int i = 0; i < server.num_monitors; i++) { - if (x >= server.monitors[i].x && x <= (server.monitors[i].x + server.monitors[i].width) && - y >= server.monitors[i].y && y <= (server.monitors[i].y + server.monitors[i].height)) { - int current_right = x < (server.monitors[i].x + server.monitors[i].width); - int current_bottom = y < (server.monitors[i].y + server.monitors[i].height); - if (best_match < 0 || (!match_right && current_right) || (!match_bottom && current_bottom)) { - best_match = i; - } - } - } + int best_match = -1; + int match_right = 0; + int match_bottom = 0; + // There is an ambiguity when a window is right on the edge between screens. + // In that case, prefer the monitor which is on the right and bottom of the window's top-left corner. + for (int i = 0; i < server.num_monitors; i++) { + if (x >= server.monitors[i].x && x <= (server.monitors[i].x + server.monitors[i].width) && + y >= server.monitors[i].y && y <= (server.monitors[i].y + server.monitors[i].height)) { + int current_right = x < (server.monitors[i].x + server.monitors[i].width); + int current_bottom = y < (server.monitors[i].y + server.monitors[i].height); + if (best_match < 0 || (!match_right && current_right) || (!match_bottom && current_bottom)) { + best_match = i; + } + } + } - if (best_match < 0) - best_match = 0; - // fprintf(stderr, "desktop %d, window %lx %s : monitor %d, (%d, %d)\n", 1 + get_current_desktop(), win, - // get_task(win) ? get_task(win)->title : "??", best_match+1, x, y); - return best_match; + if (best_match < 0) + best_match = 0; + // fprintf(stderr, "desktop %d, window %lx %s : monitor %d, (%d, %d)\n", 1 + get_current_desktop(), win, + // get_task(win) ? get_task(win)->title : "??", best_match+1, x, y); + return best_match; } void get_window_coordinates(Window win, int *x, int *y, int *w, int *h) { - int dummy_int; - unsigned ww, wh, bw, bh; - Window src; - XTranslateCoordinates(server.display, win, server.root_win, 0, 0, x, y, &src); - XGetGeometry(server.display, win, &src, &dummy_int, &dummy_int, &ww, &wh, &bw, &bh); - *w = ww + bw; - *h = wh + bh; + int dummy_int; + unsigned ww, wh, bw, bh; + Window src; + XTranslateCoordinates(server.display, win, server.root_win, 0, 0, x, y, &src); + XGetGeometry(server.display, win, &src, &dummy_int, &dummy_int, &ww, &wh, &bw, &bh); + *w = ww + bw; + *h = wh + bh; } gboolean window_is_iconified(Window win) { - // EWMH specification : minimization of windows use _NET_WM_STATE_HIDDEN. - // WM_STATE is not accurate for shaded window and in multi_desktop mode. - int count; - Atom *at = server_get_property(win, server.atom._NET_WM_STATE, XA_ATOM, &count); - for (int i = 0; i < count; i++) { - if (at[i] == server.atom._NET_WM_STATE_HIDDEN) { - XFree(at); - return TRUE; - } - } - XFree(at); - return FALSE; + // EWMH specification : minimization of windows use _NET_WM_STATE_HIDDEN. + // WM_STATE is not accurate for shaded window and in multi_desktop mode. + int count; + Atom *at = server_get_property(win, server.atom._NET_WM_STATE, XA_ATOM, &count); + for (int i = 0; i < count; i++) { + if (at[i] == server.atom._NET_WM_STATE_HIDDEN) { + XFree(at); + return TRUE; + } + } + XFree(at); + return FALSE; } gboolean window_is_urgent(Window win) { - int count; + int count; - Atom *at = server_get_property(win, server.atom._NET_WM_STATE, XA_ATOM, &count); - for (int i = 0; i < count; i++) { - if (at[i] == server.atom._NET_WM_STATE_DEMANDS_ATTENTION) { - XFree(at); - return TRUE; - } - } - XFree(at); - return FALSE; + Atom *at = server_get_property(win, server.atom._NET_WM_STATE, XA_ATOM, &count); + for (int i = 0; i < count; i++) { + if (at[i] == server.atom._NET_WM_STATE_DEMANDS_ATTENTION) { + XFree(at); + return TRUE; + } + } + XFree(at); + return FALSE; } gboolean window_is_skip_taskbar(Window win) { - int count; + int count; - Atom *at = server_get_property(win, server.atom._NET_WM_STATE, XA_ATOM, &count); - for (int i = 0; i < count; i++) { - if (at[i] == server.atom._NET_WM_STATE_SKIP_TASKBAR) { - XFree(at); - return 1; - } - } - XFree(at); - return FALSE; + Atom *at = server_get_property(win, server.atom._NET_WM_STATE, XA_ATOM, &count); + for (int i = 0; i < count; i++) { + if (at[i] == server.atom._NET_WM_STATE_SKIP_TASKBAR) { + XFree(at); + return 1; + } + } + XFree(at); + return FALSE; } Window get_active_window() { - return get_property32(server.root_win, server.atom._NET_ACTIVE_WINDOW, XA_WINDOW); + return get_property32(server.root_win, server.atom._NET_ACTIVE_WINDOW, XA_WINDOW); } gboolean window_is_active(Window win) { - return (win == get_property32(server.root_win, server.atom._NET_ACTIVE_WINDOW, XA_WINDOW)); + return (win == get_property32(server.root_win, server.atom._NET_ACTIVE_WINDOW, XA_WINDOW)); } int get_icon_count(gulong *data, int num) { - int count, pos, w, h; + int count, pos, w, h; - count = 0; - pos = 0; - while (pos + 2 < num) { - w = data[pos++]; - h = data[pos++]; - pos += w * h; - if (pos > num || w <= 0 || h <= 0) - break; - count++; - } + count = 0; + pos = 0; + while (pos + 2 < num) { + w = data[pos++]; + h = data[pos++]; + pos += w * h; + if (pos > num || w <= 0 || h <= 0) + break; + count++; + } - return count; + return count; } gulong *get_best_icon(gulong *data, int icon_count, int num, int *iw, int *ih, int best_icon_size) { - int width[icon_count], height[icon_count], pos, i, w, h; - gulong *icon_data[icon_count]; + int width[icon_count], height[icon_count], pos, i, w, h; + gulong *icon_data[icon_count]; - /* List up icons */ - pos = 0; - i = icon_count; - while (i--) { - w = data[pos++]; - h = data[pos++]; - if (pos + w * h > num) - break; + /* List up icons */ + pos = 0; + i = icon_count; + while (i--) { + w = data[pos++]; + h = data[pos++]; + if (pos + w * h > num) + break; - width[i] = w; - height[i] = h; - icon_data[i] = &data[pos]; + width[i] = w; + height[i] = h; + icon_data[i] = &data[pos]; - pos += w * h; - } + pos += w * h; + } - /* Try to find exact size */ - int icon_num = -1; - for (i = 0; i < icon_count; i++) { - if (width[i] == best_icon_size) { - icon_num = i; - break; - } - } + /* Try to find exact size */ + int icon_num = -1; + for (i = 0; i < icon_count; i++) { + if (width[i] == best_icon_size) { + icon_num = i; + break; + } + } - /* Take the biggest or whatever */ - if (icon_num < 0) { - int highest = 0; - for (i = 0; i < icon_count; i++) { - if (width[i] > highest) { - icon_num = i; - highest = width[i]; - } - } - } + /* Take the biggest or whatever */ + if (icon_num < 0) { + int highest = 0; + for (i = 0; i < icon_count; i++) { + if (width[i] > highest) { + icon_num = i; + highest = width[i]; + } + } + } - *iw = width[icon_num]; - *ih = height[icon_num]; - return icon_data[icon_num]; + *iw = width[icon_num]; + *ih = height[icon_num]; + return icon_data[icon_num]; } // Thanks zcodes!