diff --git a/src/tint2conf/CMakeLists.txt b/src/tint2conf/CMakeLists.txt index 5526c7d..d944dd1 100644 --- a/src/tint2conf/CMakeLists.txt +++ b/src/tint2conf/CMakeLists.txt @@ -8,6 +8,7 @@ pkg_check_modules( GOBJECT2 REQUIRED gobject-2.0 ) pkg_check_modules( IMLIB2 REQUIRED imlib2 ) pkg_check_modules( GTHREAD2 REQUIRED gthread-2.0 ) pkg_check_modules( GTK2 REQUIRED gtk+-x11-2.0 ) +pkg_check_modules( RSVG librsvg-2.0>=2.36.0 ) include_directories( ../util ${X11_T2C_INCLUDE_DIRS} @@ -15,26 +16,44 @@ include_directories( ../util ${GOBJECT2_INCLUDE_DIRS} ${IMLIB2_INCLUDE_DIRS} ${GTHREAD2_INCLUDE_DIRS} - ${GTK2_INCLUDE_DIRS} ) + ${GTK2_INCLUDE_DIRS} + ${RSVG_INCLUDE_DIRS} ) set(SOURCES ../util/common.c + ../config.c + ../server.c + ../launcher/apps-common.c + ../launcher/icon-theme-common.c main.c properties.c properties_rw.c theme_view.c ) + +add_definitions( -DTINT2CONF ) + +option( ENABLE_RSVG "Rsvg support (launcher only)" ON ) + +if( ENABLE_RSVG ) + if( RSVG_FOUND ) + add_definitions( -DHAVE_RSVG ) + endif( RSVG_FOUND ) +endif( ENABLE_RSVG ) + link_directories( ${X11_T2C_LIBRARY_DIRS} ${GLIB2_LIBRARY_DIRS} ${GOBJECT2_LIBRARY_DIRS} ${IMLIB2_LIBRARY_DIRS} ${GTHREAD2_LIBRARY_DIRS} - ${GTK2_LIBRARY_DIRS} ) + ${GTK2_LIBRARY_DIRS} + ${RSVG_LIBRARY_DIRS} ) add_executable( tint2conf ${SOURCES} ) target_link_libraries( tint2conf ${X11_T2C_LIBRARIES} ${GLIB2_LIBRARIES} ${GOBJECT2_LIBRARIES} ${IMLIB2_LIBRARIES} ${GTHREAD2_LIBRARIES} - ${GTK2_LIBRARIES} ) + ${GTK2_LIBRARIES} + ${RSVG_LIBRARIES} ) if ( NOT DATADIR ) set( DATADIR share ) diff --git a/src/tint2conf/main.c b/src/tint2conf/main.c index 2339f11..dde8eff 100644 --- a/src/tint2conf/main.c +++ b/src/tint2conf/main.c @@ -17,23 +17,22 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. **************************************************************************/ +#include #ifdef HAVE_VERSION_H #include "version.h" #endif + #include "main.h" #include "common.h" #include "theme_view.h" #include "properties.h" #include "properties_rw.h" -#define SNAPSHOT_TICK 190 - - -// default config file and directory +// Default path to the tint2 config file char *g_path_config = NULL; +// Default path to the tint2 config directory char *g_path_dir = NULL; char *g_default_theme = NULL; -char *g_cmd_property = NULL; int g_width, g_height; GtkWidget *g_window; @@ -50,7 +49,7 @@ static void menuProperties(); static void menuQuit(); static void menuRefresh(); static void menuRefreshAll(); -static void menuApply(); +void menuApply(); static void menuAbout(); static gboolean view_onPopupMenu (GtkWidget *treeview, gpointer userdata); @@ -86,7 +85,6 @@ static const char *global_ui = " " " " " " - " " " " " " " " @@ -209,12 +207,15 @@ static void menuAdd() dialog = gtk_file_chooser_dialog_new(_("Add a theme"), GTK_WINDOW(g_window), GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_ADD, GTK_RESPONSE_ACCEPT, NULL); chooser = GTK_FILE_CHOOSER(dialog); - gtk_file_chooser_set_current_folder(chooser, g_get_home_dir()); + gchar *config_dir; + 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); gtk_file_chooser_set_select_multiple(chooser, TRUE); filter = gtk_file_filter_new(); gtk_file_filter_set_name(filter, _("Tint2 theme files")); - gtk_file_filter_add_pattern(filter, "*.tint2rc"); + gtk_file_filter_add_pattern(filter, "*tint2rc"); gtk_file_chooser_add_filter(chooser, filter); if (gtk_dialog_run (GTK_DIALOG(dialog)) != GTK_RESPONSE_ACCEPT) { @@ -291,7 +292,10 @@ static void menuSaveAs () chooser = GTK_FILE_CHOOSER(dialog); gtk_file_chooser_set_do_overwrite_confirmation(chooser, TRUE); - gtk_file_chooser_set_current_folder(chooser, g_get_home_dir()); + gchar *config_dir; + 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); gtk_file_chooser_set_current_name(chooser, pt1); if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) { @@ -325,6 +329,20 @@ static void menuDelete() } } +char *get_current_theme_file_name() +{ + GtkTreeSelection *sel; + GtkTreeIter iter; + GtkTreeModel *model; + char *file; + + sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(g_theme_view)); + if (gtk_tree_selection_get_selected(GTK_TREE_SELECTION(sel), &model, &iter)) { + gtk_tree_model_get(model, &iter, COL_THEME_FILE, &file, -1); + return file; + } + return NULL; +} static void menuProperties() { @@ -336,21 +354,11 @@ static void menuProperties() sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(g_theme_view)); if (gtk_tree_selection_get_selected(GTK_TREE_SELECTION(sel), &model, &iter)) { gtk_tree_model_get(model, &iter, COL_THEME_FILE, &file, -1); -//* GtkWidget *prop; prop = create_properties(); config_read_file(file); gtk_window_present(GTK_WINDOW(prop)); - //printf("menuProperties : fin\n"); -//*/ -/* - char *cmd = g_strdup_printf("%s \'%s\' &", g_cmd_property, file); - printf("cmd %s\n", cmd); - system(cmd); - g_free(cmd); - //*/ g_free(file); - } } @@ -365,8 +373,6 @@ static void menuQuit() g_free(g_path_dir); if (g_default_theme) g_free(g_default_theme); - if (g_cmd_property) - g_free(g_cmd_property); gtk_main_quit (); } @@ -404,7 +410,7 @@ static void menuRefreshAll() } -static void menuApply() +void menuApply() { GtkTreeSelection *sel; GtkTreeIter iter; @@ -417,15 +423,24 @@ static void menuApply() sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(g_theme_view)); if (gtk_tree_selection_get_selected(GTK_TREE_SELECTION(sel), &model, &iter)) { gtk_tree_model_get(model, &iter, COL_THEME_FILE, &g_default_theme, -1); - // overwrite tint2rc + // Create backup if the config file has been edited manually + if (config_is_manual(g_path_config)) { + char timestamp[64]; + sprintf(timestamp, "%ld", time(NULL)); + gchar *backup_path = g_build_filename(g_get_user_config_dir(), "tint2", "tint2rc.backup.", timestamp, NULL); + copy_file(g_path_config, backup_path); + g_free(backup_path); + } + // Write config file + printf("Writing %s to %s\n", g_default_theme, g_path_config); + fflush(stdout); copy_file(g_default_theme, g_path_config); - - // restart panel - system("killall -SIGUSR1 tint2"); + // Restart panel + int unused = system("killall -SIGUSR1 tint2"); + (void)unused; } } - static void view_popup_menu(GtkWidget *treeview, GdkEventButton *event, gpointer userdata) { GtkWidget *w = gtk_ui_manager_get_widget(globalUIManager, "/ThemePopup"); @@ -433,7 +448,6 @@ static void view_popup_menu(GtkWidget *treeview, GdkEventButton *event, gpointer gtk_menu_popup(GTK_MENU(w), 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? @@ -459,41 +473,38 @@ static gboolean view_onButtonPressed (GtkWidget *treeview, GdkEventButton *event return FALSE; } - static gboolean view_onPopupMenu (GtkWidget *treeview, gpointer userdata) { view_popup_menu(treeview, NULL, userdata); return TRUE; } - static void viewRowActivated(GtkTreeView *tree_view, GtkTreePath *path, GtkTreeViewColumn *column, gpointer user_data) { menuApply(); } - static void windowSizeAllocated() { - const gboolean isMaximized = g_window->window && (gdk_window_get_state(g_window->window) & GDK_WINDOW_STATE_MAXIMIZED); + const gboolean isMaximized = g_window->window && + (gdk_window_get_state(g_window->window) & GDK_WINDOW_STATE_MAXIMIZED); if(!isMaximized) gtk_window_get_size(GTK_WINDOW(g_window), &g_width, &g_height); } - static void load_theme(GtkWidget *list) { GDir *dir; - gchar *pt1, *name; + gchar *name; const gchar *file; gboolean found_theme = FALSE; dir = g_dir_open(g_path_dir, 0, NULL); - if (dir == NULL) return; + if (dir == NULL) + return; while ((file = g_dir_read_name(dir))) { - pt1 = strstr(file, ".tint2rc"); - if (pt1) { + if (g_str_has_suffix(file, ".tint2rc")) { found_theme = TRUE; name = g_build_filename (g_path_dir, file, NULL); custom_list_append(name); @@ -507,7 +518,8 @@ static void load_theme(GtkWidget *list) name = g_build_filename(g_get_user_config_dir(), "tint2", "default.tint2rc", NULL); copy_file(g_path_config, name); custom_list_append(name); - if (g_default_theme) g_free(g_default_theme); + if (g_default_theme) + g_free(g_default_theme); g_default_theme = strdup(name); g_free(name); } @@ -517,22 +529,22 @@ static void load_theme(GtkWidget *list) g_timeout_add(SNAPSHOT_TICK, (GSourceFunc)update_snapshot, NULL); } - void selectTheme(const gchar *name_theme) { gboolean have_iter, found_theme; GtkTreeIter iter; GtkTreeModel *model; - if (!name_theme) return; + if (!name_theme) + return; model = gtk_tree_view_get_model(GTK_TREE_VIEW(g_theme_view)); found_theme = searchTheme(name_theme, model, &iter); GtkTreePath *path = NULL; - if (found_theme) + if (found_theme) { path = gtk_tree_model_get_path(model, &iter); - else { + } else { have_iter = gtk_tree_model_get_iter_first(model, &iter); if (have_iter) path = gtk_tree_model_get_path(model, &iter); @@ -544,7 +556,6 @@ void selectTheme(const gchar *name_theme) } } - gboolean searchTheme(const gchar *name_theme, GtkTreeModel *model, GtkTreeIter *iter) { gchar *name; @@ -562,7 +573,7 @@ gboolean searchTheme(const gchar *name_theme, GtkTreeModel *model, GtkTreeIter * return found; } - +// Initializes the paths to the tint2 config locations. void initTheme() { g_path_dir = g_build_filename (g_get_user_config_dir(), "tint2", NULL); @@ -572,7 +583,7 @@ void initTheme() g_path_config = g_build_filename (g_get_user_config_dir(), "tint2", "tint2rc", NULL); } - +// Reads the tint2conf config file. void read_config() { char *path; @@ -584,7 +595,6 @@ void read_config() } g_width = 500; g_height = 350; - g_cmd_property = g_strconcat( "/usr/bin/env python ", INSTALL_PREFIX, "/bin/tintwizard.py", (void*)0 ); // load config path = g_build_filename (g_get_user_config_dir(), "tint2", "tint2confrc", NULL); @@ -597,10 +607,6 @@ void read_config() if (parse_line(line, &key, &value)) { if (strcmp (key, "default_theme") == 0) g_default_theme = strdup(value); - else if (strcmp (key, "cmd_property") == 0) { - g_free(g_cmd_property); - g_cmd_property = strdup(value); - } else if (strcmp (key, "width") == 0) g_width = atoi(value); else if (strcmp (key, "height") == 0) @@ -615,7 +621,7 @@ void read_config() g_free(path); } - +// Writes the tint2conf config file. void write_config() { char *path; @@ -629,9 +635,6 @@ void write_config() if (g_default_theme != NULL) { fprintf(fp, "default_theme = %s\n", g_default_theme); } - if (g_cmd_property != NULL) { - fprintf(fp, "cmd_property = %s\n", g_cmd_property); - } fprintf(fp, "width = %d\n", g_width); fprintf(fp, "height = %d\n", g_height); fputs("\n", fp); @@ -639,6 +642,3 @@ void write_config() } g_free(path); } - - - diff --git a/src/tint2conf/main.h b/src/tint2conf/main.h index f463aaf..6c538d9 100644 --- a/src/tint2conf/main.h +++ b/src/tint2conf/main.h @@ -1,4 +1,3 @@ - #include #include #include @@ -14,3 +13,6 @@ #define _(String) String #endif +#define SNAPSHOT_TICK 190 +gboolean update_snapshot(); +void menuApply(); \ No newline at end of file diff --git a/src/tint2conf/properties.c b/src/tint2conf/properties.c index 5b2cf0b..1a09ce5 100644 --- a/src/tint2conf/properties.c +++ b/src/tint2conf/properties.c @@ -19,1611 +19,2982 @@ #include "main.h" #include "properties.h" +#include "properties_rw.h" +#include "../launcher/apps-common.h" +#include "../launcher/icon-theme-common.h" -#define ROW_SPACING 10 -#define COL_SPACING 8 -#define DEFAULT_HOR_SPACING 5 +#define ROW_SPACING 10 +#define COL_SPACING 8 +#define DEFAULT_HOR_SPACING 5 -void change_paragraph(GtkWidget *widget); -void create_general(GtkWidget *parent); -void create_panel(GtkWidget *parent); -void create_panel_items(GtkWidget *parent); -void create_launcher(GtkWidget *parent); -void create_taskbar(GtkWidget *parent); -void create_task(GtkWidget *parent); -void create_clock(GtkWidget *parent); -void create_systemtray(GtkWidget *parent); -void create_battery(GtkWidget *parent); -void create_tooltip(GtkWidget *parent); -void create_background(GtkWidget *parent); +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; + +GtkListStore *panel_items, *all_items; +GtkWidget *panel_items_view, *all_items_view; + +GtkWidget *screen_position[12]; +GSList *screen_position_group; +GtkWidget *panel_background; + +// taskbar +GtkWidget *taskbar_show_desktop, *taskbar_show_name, *taskbar_padding_x, *taskbar_padding_y, *taskbar_spacing; +GtkWidget *taskbar_name_padding_x, *taskbar_name_inactive_color, *taskbar_name_active_color, *taskbar_name_font; +GtkWidget *taskbar_active_background, *taskbar_inactive_background; +GtkWidget *taskbar_name_active_background, *taskbar_name_inactive_background; + +// task +GtkWidget *task_mouse_middle, *task_mouse_right, *task_mouse_scroll_up, *task_mouse_scroll_down; +GtkWidget *task_show_icon, *task_show_text, *task_align_center, *task_font_shadow; +GtkWidget *task_maximum_width, *task_maximum_height, *task_padding_x, *task_padding_y, *task_font; +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; + +// clock +GtkWidget *clock_format_line1, *clock_format_line2, *clock_tmz_line1, *clock_tmz_line2; +GtkWidget *clock_left_command, *clock_right_command; +GtkWidget *clock_padding_x, *clock_padding_y, *clock_font_line1, *clock_font_line2, *clock_font_color; +GtkWidget *clock_background; + +// battery +GtkWidget *battery_hide_if_higher, *battery_alert_if_lower, *battery_alert_cmd; +GtkWidget *battery_padding_x, *battery_padding_y, *battery_font_line1, *battery_font_line2, *battery_font_color; +GtkWidget *battery_background; + +// systray +GtkWidget *systray_icon_order, *systray_padding_x, *systray_padding_y, *systray_spacing; +GtkWidget *systray_icon_size, *systray_icon_opacity, *systray_icon_saturation, *systray_icon_brightness; +GtkWidget *systray_background; + +// tooltip +GtkWidget *tooltip_padding_x, *tooltip_padding_y, *tooltip_font, *tooltip_font_color; +GtkWidget *tooltip_task_show, *tooltip_show_after, *tooltip_hide_after; +GtkWidget *clock_format_tooltip, *clock_tmz_tooltip; +GtkWidget *tooltip_background; + +// launcher + +GtkListStore *launcher_apps, *all_apps; +GtkWidget *launcher_apps_view, *all_apps_view; + +GtkWidget *launcher_icon_size, *launcher_icon_theme, *launcher_padding_x, *launcher_padding_y, *launcher_spacing; +GtkWidget *margin_x, *margin_y; +GtkWidget *launcher_background; + +IconThemeWrapper *icon_theme; + +GtkListStore *backgrounds; +GtkWidget *current_background, + *background_fill_color, + *background_border_color, + *background_border_width, + *background_corner_radius; + + +GtkWidget *addScrollBarToWidget(GtkWidget *widget); +gboolean gtk_tree_model_iter_prev_tint2(GtkTreeModel *model, GtkTreeIter *iter); + +void change_paragraph(GtkWidget *widget); +void create_general(GtkWidget *parent); +void create_background(GtkWidget *parent); +void background_duplicate(GtkWidget *widget, gpointer data); +void background_delete(GtkWidget *widget, gpointer data); +void background_update_image(int index); +void background_update(GtkWidget *widget, gpointer data); +void current_background_changed(GtkWidget *widget, gpointer data); +void create_panel(GtkWidget *parent); +void create_panel_items(GtkWidget *parent); +void create_launcher(GtkWidget *parent); +gchar *get_default_theme_name(); +void icon_theme_changed(); +void load_icons(GtkListStore *apps); +void create_taskbar(GtkWidget *parent); +void create_task(GtkWidget *parent); +void create_task_status(GtkWidget *notebook, + char *name, + 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_clock(GtkWidget *parent); +void create_systemtray(GtkWidget *parent); +void create_battery(GtkWidget *parent); +void create_tooltip(GtkWidget *parent); +void panel_add_item(GtkWidget *widget, gpointer data); +void panel_remove_item(GtkWidget *widget, gpointer data); +void panel_move_item_down(GtkWidget *widget, gpointer data); +void panel_move_item_up(GtkWidget *widget, gpointer data); + +void applyClicked(GtkWidget *widget, gpointer data) +{ + char *file = get_current_theme_file_name(); + if (file) + config_save_file(file); + g_free(file); + g_timeout_add(SNAPSHOT_TICK, (GSourceFunc)update_snapshot, NULL); + // TODO if this is not the current theme, don't do anything + menuApply(); +} + +void cancelClicked(GtkWidget *widget, gpointer data) +{ + GtkWidget *view = (GtkWidget *)data; + gtk_widget_destroy(view); +} + +void okClicked(GtkWidget *widget, gpointer data) +{ + applyClicked(widget, data); + cancelClicked(widget, data); +} GtkWidget *create_properties() { - GtkWidget *view, *dialog_vbox3, *button, *notebook; + GtkWidget *view, *dialog_vbox3, *button, *notebook; GtkTooltips *tooltips; - GtkWidget *page_panel, *page_panel_items, *page_launcher, *page_taskbar, *page_battery, *page_clock, *page_tooltip, *page_systemtray, *page_task, *page_background; + GtkWidget *page_panel, *page_panel_items, *page_launcher, *page_taskbar, *page_battery, *page_clock, + *page_tooltip, *page_systemtray, *page_task, *page_background; GtkWidget *label; - tooltips = gtk_tooltips_new (); + tooltips = gtk_tooltips_new(); + (void) tooltips; // 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_skip_pager_hint (GTK_WINDOW (view), TRUE); - gtk_window_set_type_hint (GTK_WINDOW (view), GDK_WINDOW_TYPE_HINT_DIALOG); + view = gtk_dialog_new(); + gtk_window_set_title(GTK_WINDOW(view), _("Properties")); + gtk_window_set_modal(GTK_WINDOW(view), TRUE); + 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); + 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); + 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_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_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_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 (_("Panel")); - gtk_widget_show (label); - page_panel = gtk_vbox_new (FALSE, DEFAULT_HOR_SPACING); + 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), 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), page_panel, label); + gtk_widget_show(page_panel); + gtk_notebook_append_page(GTK_NOTEBOOK(notebook), 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); + 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), page_panel_items, label); + gtk_widget_show(page_panel_items); + gtk_notebook_append_page(GTK_NOTEBOOK(notebook), page_panel_items, label); create_panel_items(page_panel_items); - label = gtk_label_new (_("Launcher")); - gtk_widget_show (label); - page_launcher = gtk_vbox_new (FALSE, DEFAULT_HOR_SPACING); + 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), page_launcher, label); + gtk_widget_show(page_launcher); + gtk_notebook_append_page(GTK_NOTEBOOK(notebook), page_launcher, label); create_launcher(page_launcher); - label = gtk_label_new (_("Taskbar")); - gtk_widget_show (label); - page_taskbar = gtk_vbox_new (FALSE, DEFAULT_HOR_SPACING); + 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), page_taskbar, label); + gtk_widget_show(page_taskbar); + gtk_notebook_append_page(GTK_NOTEBOOK(notebook), page_taskbar, label); create_taskbar(page_taskbar); - label = gtk_label_new (_("Task")); - gtk_widget_show (label); - page_task = gtk_vbox_new (FALSE, DEFAULT_HOR_SPACING); + label = gtk_label_new(_("Task")); + 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), page_task, label); + gtk_widget_show(page_task); + gtk_notebook_append_page(GTK_NOTEBOOK(notebook), page_task, label); create_task(page_task); - label = gtk_label_new (_("Clock")); - gtk_widget_show (label); - page_clock = gtk_vbox_new (FALSE, DEFAULT_HOR_SPACING); + 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), page_clock, label); + gtk_widget_show(page_clock); + gtk_notebook_append_page(GTK_NOTEBOOK(notebook), page_clock, label); create_clock(page_clock); - label = gtk_label_new (_("Notification")); - gtk_widget_show (label); - page_systemtray = gtk_vbox_new (FALSE, DEFAULT_HOR_SPACING); + label = gtk_label_new(_("Notification")); + 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), page_systemtray, label); + gtk_widget_show(page_systemtray); + gtk_notebook_append_page(GTK_NOTEBOOK(notebook), 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); + 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), page_battery, label); + gtk_widget_show(page_battery); + gtk_notebook_append_page(GTK_NOTEBOOK(notebook), 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); + 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), page_tooltip, label); + gtk_widget_show(page_tooltip); + gtk_notebook_append_page(GTK_NOTEBOOK(notebook), page_tooltip, label); create_tooltip(page_tooltip); - label = gtk_label_new (_("Background")); - 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), page_background, label); - create_background(page_background); - return view; } - -void change_paragraph(GtkWidget *widget) +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); } +GtkWidget *create_background_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", 0, NULL); + return combo; +} -void create_panel(GtkWidget *parent) +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; +} + +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; +} + +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); + + GtkWidget *table, *label, *button; + + 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); + + 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, 0, 1, 0, 1, GTK_FILL, 0, 0, 0); + + current_background = create_background_combo(); + gtk_widget_show(current_background); + gtk_table_attach(GTK_TABLE(table), current_background, 1, 2, 0, 1, GTK_FILL, 0, 0, 0); + + 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, 2, 3, 0, 1, GTK_FILL, 0, 0, 0); + + 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, 3, 4, 0, 1, GTK_FILL, 0, 0, 0); + + change_paragraph(parent); + + 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); + + label = gtk_label_new(_(" ")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, GTK_FILL, 0, 0, 0); + + 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, 1, 2, 0, 1, GTK_FILL, 0, 0, 0); + + 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, 2, 3, 0, 1, GTK_FILL, 0, 0, 0); + + 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, 1, 2, 1, 2, GTK_FILL, 0, 0, 0); + + 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, 2, 3, 1, 2, GTK_FILL, 0, 0, 0); + + 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, 1, 2, 2, 3, GTK_FILL, 0, 0, 0); + + 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, 2, 3, 2, 3, GTK_FILL, 0, 0, 0); + + 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, 1, 2, 3, 4, GTK_FILL, 0, 0, 0); + + 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, 2, 3, 3, 4, GTK_FILL, 0, 0, 0); + + 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_border_width), "value-changed", G_CALLBACK(background_update), NULL); + g_signal_connect(G_OBJECT(background_corner_radius), "value-changed", G_CALLBACK(background_update), NULL); + + change_paragraph(parent); +} + +int get_model_length(GtkTreeModel *model) { int i; - GtkWidget *screen_position[12]; - GtkWidget *table, *hbox, *frame; - GtkWidget *label; + for (i = 0; ; i++) { + GtkTreePath *path; + GtkTreeIter iter; - label = gtk_label_new (_("Position and size")); - 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); + 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; + } + } +} + +int background_index_safe(int index) +{ + 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 = 12; + int b = 1; + GdkColor fillColor; + cairoColor2GdkColor(0, 0, 0.3, &fillColor); + int fillOpacity = 100; + GdkColor borderColor; + cairoColor2GdkColor(0, 0, 0.7, &borderColor); + int borderOpacity = 100; + + 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, + bgColBorderWidth, b, + bgColCornerRadius, r, + -1); + + background_update_image(index); + gtk_combo_box_set_active(GTK_COMBO_BOX(current_background), get_model_length(GTK_TREE_MODEL(backgrounds)) - 1); +} + +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; + } + + 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); + + int r; + int b; + GdkColor *fillColor; + int fillOpacity; + GdkColor *borderColor; + int borderOpacity; + + gtk_tree_model_get(GTK_TREE_MODEL(backgrounds), &iter, + bgColFillColor, &fillColor, + bgColFillOpacity, &fillOpacity, + bgColBorderColor, &borderColor, + bgColBorderOpacity, &borderOpacity, + bgColBorderWidth, &b, + bgColCornerRadius, &r, + -1); + + gtk_list_store_append(backgrounds, &iter); + gtk_list_store_set(backgrounds, &iter, + bgColPixbuf, NULL, + bgColFillColor, fillColor, + bgColFillOpacity, fillOpacity, + bgColBorderColor, borderColor, + bgColBorderOpacity, borderOpacity, + bgColBorderWidth, b, + bgColCornerRadius, r, + -1); + g_boxed_free(GDK_TYPE_COLOR, fillColor); + g_boxed_free(GDK_TYPE_COLOR, borderColor); + 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; + + if (get_model_length(GTK_TREE_MODEL(backgrounds)) <= 1) + return; + + 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); + + 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); +} + +void background_update_image(int index) +{ + 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); + + int w = 70; + int h = 30; + int r; + int b; + GdkPixbuf *pixbuf; + GdkColor *fillColor; + int fillOpacity = 50; + GdkColor *borderColor; + int borderOpacity = 100; + + gtk_tree_model_get(GTK_TREE_MODEL(backgrounds), &iter, + bgColFillColor, &fillColor, + bgColFillOpacity, &fillOpacity, + bgColBorderColor, &borderColor, + bgColBorderOpacity, &borderOpacity, + bgColBorderWidth, &b, + bgColCornerRadius, &r, + -1); + + 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; + + g_boxed_free(GDK_TYPE_COLOR, fillColor); + g_boxed_free(GDK_TYPE_COLOR, borderColor); + + GdkPixmap *pixmap = gdk_pixmap_new(NULL, w, h, 24); + + 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); + + 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_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; + + 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); +} + +void background_force_update() +{ + background_update(NULL, NULL); +} + +void background_update(GtkWidget *widget, gpointer data) +{ + int index = gtk_combo_box_get_active(GTK_COMBO_BOX(current_background)); + if (index < 0) + return; + + 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); + + int r; + int b; + GdkColor fillColor; + int fillOpacity; + GdkColor borderColor; + int borderOpacity; + + r = gtk_spin_button_get_value(GTK_SPIN_BUTTON(background_corner_radius)); + b = gtk_spin_button_get_value(GTK_SPIN_BUTTON(background_border_width)); + gtk_color_button_get_color(GTK_COLOR_BUTTON(background_fill_color), &fillColor); + fillOpacity = gtk_color_button_get_alpha(GTK_COLOR_BUTTON(background_fill_color)) * 100 / 0xffff; + gtk_color_button_get_color(GTK_COLOR_BUTTON(background_border_color), &borderColor); + borderOpacity = gtk_color_button_get_alpha(GTK_COLOR_BUTTON(background_border_color)) * 100 / 0xffff; + + gtk_list_store_set(backgrounds, &iter, + bgColPixbuf, NULL, + bgColFillColor, &fillColor, + bgColFillOpacity, fillOpacity, + bgColBorderColor, &borderColor, + bgColBorderOpacity, borderOpacity, + bgColBorderWidth, b, + bgColCornerRadius, r, + -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; + + 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); + + int r; + int b; + GdkColor *fillColor; + int fillOpacity; + GdkColor *borderColor; + int borderOpacity; + + gtk_tree_model_get(GTK_TREE_MODEL(backgrounds), &iter, + bgColFillColor, &fillColor, + bgColFillOpacity, &fillOpacity, + bgColBorderColor, &borderColor, + bgColBorderOpacity, &borderOpacity, + bgColBorderWidth, &b, + bgColCornerRadius, &r, + -1); + + 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_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); +} + +void create_panel(GtkWidget *parent) +{ + int i; + GtkWidget *table, *hbox, *frame; + GtkWidget *label; + + label = gtk_label_new(_("Position and size")); + 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); // left marging - table = gtk_table_new (2, 1, FALSE); - gtk_widget_show (table); - gtk_box_pack_start (GTK_BOX (hbox), 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, 1, FALSE); + gtk_widget_show(table); + gtk_box_pack_start(GTK_BOX(hbox), 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, 8, FALSE); - gtk_widget_show (table); - gtk_box_pack_start (GTK_BOX (hbox), 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, 8, FALSE); + gtk_widget_show(table); + gtk_box_pack_start(GTK_BOX(hbox), 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 (_("Width")); - 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(_("Width")); + 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); - panel_width = gtk_spin_button_new_with_range (0, 9000, 1); - gtk_widget_show (panel_width); - gtk_table_attach (GTK_TABLE (table), panel_width, 2, 3, 0, 1, GTK_FILL, 0, 0, 0); + panel_width = gtk_spin_button_new_with_range(0, 9000, 1); + gtk_widget_show(panel_width); + gtk_table_attach(GTK_TABLE(table), panel_width, 2, 3, 0, 1, GTK_FILL, 0, 0, 0); - 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, 3, 4, 0, 1, GTK_FILL, 0, 0, 0); - 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")); + 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, 3, 4, 0, 1, GTK_FILL, 0, 0, 0); + 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")); - label = gtk_label_new (_("Marging x")); - gtk_misc_set_alignment (GTK_MISC (label), 0, 0); - gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, 6, 7, 0, 1, GTK_FILL, 0, 0, 0); + label = gtk_label_new(_("Margin x")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, 6, 7, 0, 1, GTK_FILL, 0, 0, 0); - panel_margin_x = gtk_spin_button_new_with_range (0, 500, 1); - gtk_widget_show (panel_margin_x); - gtk_entry_set_max_length (GTK_ENTRY (panel_margin_x), 3); - gtk_table_attach (GTK_TABLE (table), panel_margin_x, 7, 8, 0, 1, GTK_FILL, 0, 0, 0); + 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, 7, 8, 0, 1, GTK_FILL, 0, 0, 0); - label = gtk_label_new (_("Height")); - 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(_("Height")); + 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); - panel_height = gtk_spin_button_new_with_range (0, 9000, 1); - gtk_widget_show (panel_height); - gtk_table_attach (GTK_TABLE (table), panel_height, 2, 3, 1, 2, GTK_FILL, 0, 0, 0); + panel_height = gtk_spin_button_new_with_range(0, 9000, 1); + gtk_widget_show(panel_height); + gtk_table_attach(GTK_TABLE(table), panel_height, 2, 3, 1, 2, GTK_FILL, 0, 0, 0); change_paragraph(parent); - 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, 3, 4, 1, 2, GTK_FILL, 0, 0, 0); - 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")); + 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, 3, 4, 1, 2, GTK_FILL, 0, 0, 0); + 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")); - label = gtk_label_new (_("Marging y")); - gtk_misc_set_alignment (GTK_MISC (label), 0, 0); - gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, 6, 7, 1, 2, GTK_FILL, 0, 0, 0); + label = gtk_label_new(_("Margin y")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, 6, 7, 1, 2, GTK_FILL, 0, 0, 0); - panel_margin_y = gtk_spin_button_new_with_range (0, 500, 1); - gtk_widget_show (panel_margin_y); - gtk_entry_set_max_length (GTK_ENTRY (panel_margin_y), 3); - gtk_table_attach (GTK_TABLE (table), panel_margin_y, 7, 8, 1, 2, GTK_FILL, 0, 0, 0); + 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, 7, 8, 1, 2, GTK_FILL, 0, 0, 0); - frame = gtk_frame_new (NULL); - gtk_widget_show (frame); - gtk_box_pack_start (GTK_BOX (hbox), frame, FALSE, TRUE, 0); - gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE); + frame = gtk_frame_new(NULL); + gtk_widget_show(frame); + gtk_box_pack_start(GTK_BOX(hbox), frame, FALSE, TRUE, 0); + gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_NONE); - table = gtk_table_new (5, 5, FALSE); - gtk_widget_show (table); - gtk_box_pack_start (GTK_BOX (hbox), table, FALSE, FALSE, 0); + table = gtk_table_new(5, 5, FALSE); + gtk_widget_show(table); + gtk_box_pack_start(GTK_BOX(hbox), table, FALSE, FALSE, 0); for (i = 0; i < 12; ++i) { - screen_position[i] = gtk_toggle_button_new (); - gtk_widget_show (screen_position[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); - -// g_signal_connect (G_OBJECT (screen_position[i]), "button-press-event", G_CALLBACK (screen_position_pressed)); -// g_signal_connect (G_OBJECT (screen_position[i]), "key-press-event", G_CALLBACK (screen_position_pressed)); + 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 (table), screen_position[0], 1, 2, 0, 1); - gtk_table_attach_defaults (GTK_TABLE (table), screen_position[1], 2, 3, 0, 1); - gtk_table_attach_defaults (GTK_TABLE (table), screen_position[2], 3, 4, 0, 1); - gtk_table_attach_defaults (GTK_TABLE (table), screen_position[3], 0, 1, 1, 2); - gtk_table_attach_defaults (GTK_TABLE (table), screen_position[4], 0, 1, 2, 3); - gtk_table_attach_defaults (GTK_TABLE (table), screen_position[5], 0, 1, 3, 4); - gtk_table_attach_defaults (GTK_TABLE (table), screen_position[6], 4, 5, 1, 2); - gtk_table_attach_defaults (GTK_TABLE (table), screen_position[7], 4, 5, 2, 3); - gtk_table_attach_defaults (GTK_TABLE (table), screen_position[8], 4, 5, 3, 4); - gtk_table_attach_defaults (GTK_TABLE (table), screen_position[9], 1, 2, 4, 5); - gtk_table_attach_defaults (GTK_TABLE (table), screen_position[10], 2, 3, 4, 5); - gtk_table_attach_defaults (GTK_TABLE (table), screen_position[11], 3, 4, 4, 5); + gtk_table_attach_defaults(GTK_TABLE(table), screen_position[0], 1, 2, 0, 1); + gtk_table_attach_defaults(GTK_TABLE(table), screen_position[1], 2, 3, 0, 1); + gtk_table_attach_defaults(GTK_TABLE(table), screen_position[2], 3, 4, 0, 1); + gtk_table_attach_defaults(GTK_TABLE(table), screen_position[3], 0, 1, 1, 2); + gtk_table_attach_defaults(GTK_TABLE(table), screen_position[4], 0, 1, 2, 3); + gtk_table_attach_defaults(GTK_TABLE(table), screen_position[5], 0, 1, 3, 4); + gtk_table_attach_defaults(GTK_TABLE(table), screen_position[6], 4, 5, 1, 2); + gtk_table_attach_defaults(GTK_TABLE(table), screen_position[7], 4, 5, 2, 3); + gtk_table_attach_defaults(GTK_TABLE(table), screen_position[8], 4, 5, 3, 4); + gtk_table_attach_defaults(GTK_TABLE(table), screen_position[9], 1, 2, 4, 5); + gtk_table_attach_defaults(GTK_TABLE(table), screen_position[10], 2, 3, 4, 5); + gtk_table_attach_defaults(GTK_TABLE(table), screen_position[11], 3, 4, 4, 5); - label = gtk_label_new (_("Autohide")); - 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(_("Autohide")); + 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); - 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, 2, 3, 0, 1, GTK_FILL, 0, 0, 0); + 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, 2, 3, 0, 1, GTK_FILL, 0, 0, 0); - panel_autohide = gtk_check_button_new (); - gtk_widget_show (panel_autohide); - gtk_table_attach (GTK_TABLE (table), panel_autohide, 3, 4, 0, 1, GTK_FILL, 0, 0, 0); + panel_autohide = gtk_check_button_new(); + gtk_widget_show(panel_autohide); + gtk_table_attach(GTK_TABLE(table), panel_autohide, 3, 4, 0, 1, GTK_FILL, 0, 0, 0); - 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, 6, 7, 0, 1, GTK_FILL, 0, 0, 0); + 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, 6, 7, 0, 1, GTK_FILL, 0, 0, 0); - 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, 7, 8, 0, 1, GTK_FILL, 0, 0, 0); + 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, 7, 8, 0, 1, GTK_FILL, 0, 0, 0); - 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, 8, 9, 0, 1, GTK_FILL, 0, 0, 0); + 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, 8, 9, 0, 1, GTK_FILL, 0, 0, 0); - 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, 2, 3, 1, 2, GTK_FILL, 0, 0, 0); + 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, 2, 3, 1, 2, GTK_FILL, 0, 0, 0); - panel_autohide_size = gtk_spin_button_new_with_range (0, 500, 1); - gtk_widget_show (panel_autohide_size); - gtk_entry_set_max_length (GTK_ENTRY (panel_autohide_size), 3); - gtk_table_attach (GTK_TABLE (table), panel_autohide_size, 3, 4, 1, 2, GTK_FILL, 0, 0, 0); + 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, 3, 4, 1, 2, GTK_FILL, 0, 0, 0); - 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, 6, 7, 1, 2, GTK_FILL, 0, 0, 0); + 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, 6, 7, 1, 2, GTK_FILL, 0, 0, 0); - 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, 7, 8, 1, 2, GTK_FILL, 0, 0, 0); + 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, 7, 8, 1, 2, GTK_FILL, 0, 0, 0); - 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, 8, 9, 1, 2, GTK_FILL, 0, 0, 0); + 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, 8, 9, 1, 2, GTK_FILL, 0, 0, 0); change_paragraph(parent); - label = gtk_label_new (_("Appearance")); - 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(_("Appearance")); + 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); - 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, 2, 3, 0, 1, GTK_FILL, 0, 0, 0); + 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, 2, 3, 0, 1, GTK_FILL, 0, 0, 0); - panel_padding_x = gtk_spin_button_new_with_range (0, 500, 1); - gtk_widget_show (panel_padding_x); - gtk_entry_set_max_length (GTK_ENTRY (panel_padding_x), 3); - gtk_table_attach (GTK_TABLE (table), panel_padding_x, 3, 4, 0, 1, GTK_FILL, 0, 0, 0); + 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, 3, 4, 0, 1, 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, 6, 7, 0, 1, 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, 6, 7, 0, 1, GTK_FILL, 0, 0, 0); - combo_background = gtk_combo_box_new_text (); - gtk_widget_show (combo_background); - gtk_table_attach (GTK_TABLE (table), combo_background, 7, 8, 0, 1, GTK_FILL, 0, 0, 0); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Id 1")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Id 2")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Id 3")); + panel_background = create_background_combo(); + gtk_widget_show(panel_background); + gtk_table_attach(GTK_TABLE(table), panel_background, 7, 8, 0, 1, GTK_FILL, 0, 0, 0); - 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, 2, 3, 1, 2, GTK_FILL, 0, 0, 0); + 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, 2, 3, 1, 2, GTK_FILL, 0, 0, 0); - panel_padding_y = gtk_spin_button_new_with_range (0, 500, 1); - gtk_widget_show (panel_padding_y); - gtk_entry_set_max_length (GTK_ENTRY (panel_padding_y), 3); - gtk_table_attach (GTK_TABLE (table), panel_padding_y, 3, 4, 1, 2, GTK_FILL, 0, 0, 0); + 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, 3, 4, 1, 2, GTK_FILL, 0, 0, 0); - 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, 6, 7, 1, 2, GTK_FILL, 0, 0, 0); + 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, 6, 7, 1, 2, GTK_FILL, 0, 0, 0); - panel_spacing = gtk_spin_button_new_with_range (0, 500, 1); - gtk_widget_show (panel_spacing); - gtk_entry_set_max_length (GTK_ENTRY (panel_spacing), 3); - gtk_table_attach (GTK_TABLE (table), panel_spacing, 7, 8, 1, 2, GTK_FILL, 0, 0, 0); + panel_spacing = gtk_spin_button_new_with_range(0, 500, 1); + gtk_widget_show(panel_spacing); + gtk_table_attach(GTK_TABLE(table), panel_spacing, 7, 8, 1, 2, GTK_FILL, 0, 0, 0); change_paragraph(parent); - label = gtk_label_new (_("Window manager")); - 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(_("Window manager")); + 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); - label = gtk_label_new (_("Show WM menu")); - gtk_misc_set_alignment (GTK_MISC (label), 0, 0); - gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, 2, 3, 0, 1, GTK_FILL, 0, 0, 0); + label = gtk_label_new(_("Show WM menu")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, 2, 3, 0, 1, GTK_FILL, 0, 0, 0); - panel_wm_menu = gtk_check_button_new (); - gtk_widget_show (panel_wm_menu); - gtk_entry_set_max_length (GTK_ENTRY (panel_wm_menu), 3); - gtk_table_attach (GTK_TABLE (table), panel_wm_menu, 3, 4, 0, 1, GTK_FILL, 0, 0, 0); + panel_wm_menu = gtk_check_button_new(); + gtk_widget_show(panel_wm_menu); + gtk_table_attach(GTK_TABLE(table), panel_wm_menu, 3, 4, 0, 1, GTK_FILL, 0, 0, 0); - label = gtk_label_new (_("Place in dock")); - gtk_misc_set_alignment (GTK_MISC (label), 0, 0); - gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, 2, 3, 1, 2, GTK_FILL, 0, 0, 0); + label = gtk_label_new(_("Place in dock")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, 2, 3, 1, 2, GTK_FILL, 0, 0, 0); - panel_dock = gtk_check_button_new (); - gtk_widget_show (panel_dock); - gtk_entry_set_max_length (GTK_ENTRY (panel_dock), 3); - gtk_table_attach (GTK_TABLE (table), panel_dock, 3, 4, 1, 2, GTK_FILL, 0, 0, 0); + panel_dock = gtk_check_button_new(); + gtk_widget_show(panel_dock); + gtk_table_attach(GTK_TABLE(table), panel_dock, 3, 4, 1, 2, GTK_FILL, 0, 0, 0); - label = gtk_label_new (_("Panel's layer")); - gtk_misc_set_alignment (GTK_MISC (label), 0, 0); - gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, 6, 7, 0, 1, GTK_FILL, 0, 0, 0); + label = gtk_label_new(_("Panel's layer")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, 6, 7, 0, 1, GTK_FILL, 0, 0, 0); - panel_combo_layer = gtk_combo_box_new_text (); - gtk_widget_show (panel_combo_layer); - gtk_entry_set_max_length (GTK_ENTRY (panel_combo_layer), 3); - gtk_table_attach (GTK_TABLE (table), panel_combo_layer, 7, 8, 0, 1, GTK_FILL, 0, 0, 0); - 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")); + panel_combo_layer = gtk_combo_box_new_text(); + gtk_widget_show(panel_combo_layer); + gtk_table_attach(GTK_TABLE(table), panel_combo_layer, 7, 8, 0, 1, GTK_FILL, 0, 0, 0); + 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")); - label = gtk_label_new (_("Maximized window")); - gtk_misc_set_alignment (GTK_MISC (label), 0, 0); - gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, 6, 7, 1, 2, GTK_FILL, 0, 0, 0); + label = gtk_label_new(_("Maximized window")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, 6, 7, 1, 2, GTK_FILL, 0, 0, 0); - panel_combo_strut_policy = gtk_combo_box_new_text (); - gtk_widget_show (panel_combo_strut_policy); - gtk_entry_set_max_length (GTK_ENTRY (panel_combo_strut_policy), 3); - gtk_table_attach (GTK_TABLE (table), panel_combo_strut_policy, 7, 8, 1, 2, GTK_FILL, 0, 0, 0); - gtk_combo_box_append_text (GTK_COMBO_BOX (panel_combo_strut_policy), _("Follow panel size")); - gtk_combo_box_append_text (GTK_COMBO_BOX (panel_combo_strut_policy), _("Follow hidden size")); - gtk_combo_box_append_text (GTK_COMBO_BOX (panel_combo_strut_policy), _("Full screen")); + 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, 7, 8, 1, 2, GTK_FILL, 0, 0, 0); + gtk_combo_box_append_text(GTK_COMBO_BOX(panel_combo_strut_policy), _("Follow panel size")); + gtk_combo_box_append_text(GTK_COMBO_BOX(panel_combo_strut_policy), _("Follow hidden size")); + gtk_combo_box_append_text(GTK_COMBO_BOX(panel_combo_strut_policy), _("Full screen")); - 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, 10, 11, 0, 1, GTK_FILL, 0, 0, 0); + 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, 10, 11, 0, 1, GTK_FILL, 0, 0, 0); - panel_combo_monitor = gtk_combo_box_new_text (); - gtk_widget_show (panel_combo_monitor); - gtk_table_attach (GTK_TABLE (table), panel_combo_monitor, 11, 12, 0, 1, GTK_FILL, 0, 0, 0); - 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")); + panel_combo_monitor = gtk_combo_box_new_text(); + gtk_widget_show(panel_combo_monitor); + gtk_table_attach(GTK_TABLE(table), panel_combo_monitor, 11, 12, 0, 1, GTK_FILL, 0, 0, 0); + 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")); change_paragraph(parent); } - -void create_panel_items(GtkWidget *parent) +void create_panel_items(GtkWidget *parent) { - GtkWidget *table, *label; + GtkWidget *table, *label, *button, *image; - 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); + 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); - label = gtk_label_new (_("Items order")); - gtk_misc_set_alignment (GTK_MISC (label), 0, 0); - gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, GTK_FILL, 0, 0, 0); + 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, "Notification area (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); - items_order = gtk_entry_new (); - gtk_widget_show (items_order); - gtk_entry_set_width_chars (GTK_ENTRY (items_order), 15); - gtk_table_attach (GTK_TABLE (table), items_order, 1, 2, 0, 1, GTK_FILL, 0, 0, 0); + 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); + + + 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); + + 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(_("Items selected")); + 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(_("Items available")); + 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); + + 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); + + 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); + + 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); + + 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_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(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); } - -void create_launcher(GtkWidget *parent) +gboolean panel_contains(const char *value) { - GtkWidget *table, *label; + GtkTreeModel *model = GTK_TREE_MODEL(panel_items); - label = gtk_label_new (_("Applications")); - 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); + 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; + } + + if (!gtk_tree_model_iter_next(model, &i)) { + break; + } + } + + return FALSE; +} + +char *get_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; + } + + 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; + } + } + + return result; +} + +void set_panel_items(const char *items) +{ + gtk_list_store_clear(panel_items); + + for (; items && *items; items++) { + const char *value = NULL; + const char *name = NULL; + + 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 = "Notification area (system tray)"; + } else if (v == 'T') { + value = "T"; + name = "Taskbar"; + } else if (v == 'L') { + value = "L"; + name = "Launcher"; + } else { + continue; + } + + 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; + + 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); + + if (!panel_contains(value)) { + 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); + } + } +} + +void panel_remove_item(GtkWidget *widget, gpointer data) +{ + GtkTreeIter iter; + GtkTreeModel *model; + + if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(panel_items_view)), &model, &iter)) { + gtk_list_store_remove(panel_items, &iter); + } +} + +void panel_move_item_down(GtkWidget *widget, gpointer data) +{ + 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)) { + gtk_list_store_swap(panel_items, &iter, &next); + } + } +} + +void panel_move_item_up(GtkWidget *widget, gpointer data) +{ + { + 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)) { + gtk_list_store_swap(panel_items, &iter, &prev); + } + } + } +} + +enum { + iconsColName = 0, + iconsColDescr, + iconsNumCols +}; +GtkListStore *icon_themes; + +void launcher_add_app(GtkWidget *widget, gpointer data) +{ + 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; + + 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, + appsColText, g_strdup(name), + appsColPath, g_strdup(path), + appsColIconName, g_strdup(iconName), + -1); + if (pixbuf) + g_object_unref(pixbuf); + } +} + +void launcher_remove_app(GtkWidget *widget, gpointer data) +{ + 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); + } +} + +void launcher_move_app_down(GtkWidget *widget, gpointer data) +{ + 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); + } + } +} + +void launcher_move_app_up(GtkWidget *widget, gpointer data) +{ + 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); + } + } +} + +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; + + 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; + } + + 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); + + 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; + + 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; + } + + 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() +{ + 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); + + load_icons(launcher_apps); + load_icons(all_apps); +} + +void launcher_icon_theme_changed(GtkWidget *widget, gpointer data) +{ + icon_theme_changed(); +} + +GdkPixbuf *load_icon(const gchar *name) +{ + int size = 22; + char *path = get_icon_path(icon_theme, name, size); + 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; + + 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; + + 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) +{ + DesktopEntry entry; + if (read_desktop_file(file, &entry)) { + 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, + appsColText, g_strdup(entry.name), + appsColPath, g_strdup(file), + appsColIconName, g_strdup(entry.icon), + -1); + if (pixbuf) + g_object_unref(pixbuf); + } else { + printf("Could not load %s\n", file); + } + free_desktop_entry(&entry); +} + +void load_desktop_files(const gchar *path) +{ + 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 (g_file_test(file, G_FILE_TEST_IS_REGULAR) && + g_str_has_suffix(file, ".desktop")) { + load_desktop_file(file, FALSE); + } else if (g_file_test(file, G_FILE_TEST_IS_DIR)) { + load_desktop_files(file); + } + g_free(file); + } + g_dir_close(d); +} + +void load_theme_file(const char *file_name, const char *theme) +{ + if (!file_name || !theme) { + return; + } + + FILE *f; + if ((f = fopen(file_name, "rt")) == NULL) { + return; + } + + char *line = NULL; + size_t line_size; + + 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--; + } + } + + if (line_len == 0) + continue; + + if (parse_theme_line(line, &key, &value)) { + if (strcmp(key, "Name") == 0) { + // value is like Tango + GtkTreeIter iter; + gtk_list_store_append(icon_themes, &iter); + gtk_list_store_set(icon_themes, &iter, + iconsColName, g_strdup(theme), + iconsColDescr, g_strdup(value), + -1); + } + } + + 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) +{ + 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); + } else if (g_file_test(file, G_FILE_TEST_IS_DIR)) { + load_icon_themes(file, name); + } + 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; +} + +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); + + gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window), widget); + + gtk_widget_set_size_request(scrolled_window, 100, 300); + + gtk_widget_show(widget); + gtk_widget_show(scrolled_window); + + return scrolled_window; +} + +void create_launcher(GtkWidget *parent) +{ + GtkWidget *image; + + 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); + 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); + + + 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); + + GtkWidget *table, *label, *button; + + 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(_("Applications selected")); + 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(_("Applications available")); + 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); + + 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); + + 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); + + 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); + + 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_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(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); - label = gtk_label_new (_("Appearance")); - 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(_("Appearance")); + 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); + 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); - 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, 2, 3, 0, 1, GTK_FILL, 0, 0, 0); + 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, 2, 3, 0, 1, GTK_FILL, 0, 0, 0); - launcher_padding_x = gtk_spin_button_new_with_range (0, 500, 1); - gtk_widget_show (launcher_padding_x); - gtk_entry_set_max_length (GTK_ENTRY (launcher_padding_x), 3); - gtk_table_attach (GTK_TABLE (table), launcher_padding_x, 3, 4, 0, 1, GTK_FILL, 0, 0, 0); + 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, 3, 4, 0, 1, GTK_FILL, 0, 0, 0); - 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, 2, 3, 1, 2, GTK_FILL, 0, 0, 0); + 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, 2, 3, 1, 2, GTK_FILL, 0, 0, 0); - launcher_padding_y = gtk_spin_button_new_with_range (0, 500, 1); - gtk_widget_show (launcher_padding_y); - gtk_entry_set_max_length (GTK_ENTRY (launcher_padding_y), 3); - gtk_table_attach (GTK_TABLE (table), launcher_padding_y, 3, 4, 1, 2, GTK_FILL, 0, 0, 0); + 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, 3, 4, 1, 2, GTK_FILL, 0, 0, 0); - 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, 2, 3, 2, 3, GTK_FILL, 0, 0, 0); + 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, 2, 3, 2, 3, GTK_FILL, 0, 0, 0); - launcher_spacing = gtk_spin_button_new_with_range (0, 500, 1); - gtk_widget_show (launcher_spacing); - gtk_entry_set_max_length (GTK_ENTRY (launcher_spacing), 3); - gtk_table_attach (GTK_TABLE (table), launcher_spacing, 3, 4, 2, 3, GTK_FILL, 0, 0, 0); + launcher_spacing = gtk_spin_button_new_with_range(0, 500, 1); + gtk_widget_show(launcher_spacing); + gtk_table_attach(GTK_TABLE(table), launcher_spacing, 3, 4, 2, 3, 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, 6, 7, 0, 1, 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, 6, 7, 0, 1, GTK_FILL, 0, 0, 0); - combo_background = gtk_combo_box_new_text (); - gtk_widget_show (combo_background); - gtk_table_attach (GTK_TABLE (table), combo_background, 7, 8, 0, 1, GTK_FILL, 0, 0, 0); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Id 1")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Id 2")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Id 3")); + launcher_background = create_background_combo(); + gtk_widget_show(launcher_background); + gtk_table_attach(GTK_TABLE(table), launcher_background, 7, 8, 0, 1, GTK_FILL, 0, 0, 0); - 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, 6, 7, 1, 2, GTK_FILL, 0, 0, 0); + 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, 6, 7, 1, 2, GTK_FILL, 0, 0, 0); - launcher_icon_size = gtk_spin_button_new_with_range (0, 500, 1); - gtk_widget_show (launcher_icon_size); - gtk_entry_set_max_length (GTK_ENTRY (launcher_icon_size), 3); - gtk_table_attach (GTK_TABLE (table), launcher_icon_size, 7, 8, 1, 2, GTK_FILL, 0, 0, 0); + 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, 7, 8, 1, 2, GTK_FILL, 0, 0, 0); - 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, 6, 7, 2, 3, GTK_FILL, 0, 0, 0); + 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, 6, 7, 2, 3, GTK_FILL, 0, 0, 0); - launcher_icon_theme = gtk_combo_box_new_text (); - gtk_widget_show (launcher_icon_theme); - gtk_table_attach (GTK_TABLE (table), launcher_icon_theme, 7, 8, 2, 3, GTK_FILL, 0, 0, 0); - gtk_combo_box_append_text (GTK_COMBO_BOX (launcher_icon_theme), _("Theme 1")); - gtk_combo_box_append_text (GTK_COMBO_BOX (launcher_icon_theme), _("Theme 2")); - gtk_combo_box_append_text (GTK_COMBO_BOX (launcher_icon_theme), _("Theme 3")); + + 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), NULL); + gtk_widget_show(launcher_icon_theme); + gtk_table_attach(GTK_TABLE(table), launcher_icon_theme, 7, 8, 2, 3, GTK_FILL, 0, 0, 0); change_paragraph(parent); + + GtkTreeIter iter; + gtk_list_store_append(icon_themes, &iter); + gtk_list_store_set(icon_themes, &iter, + 0, "", + -1); + + fprintf(stderr, "Loading icon themes\n"); fflush(stderr); + 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); + } + fprintf(stderr, "Icon themes loaded\n"); fflush(stderr); + + fprintf(stderr, "Loading .desktop files\n"); fflush(stderr); + load_desktop_files("/usr/share/applications"); + load_icons(launcher_apps); + load_icons(all_apps); + fprintf(stderr, "Desktop files loaded\n"); fflush(stderr); } - -void create_taskbar(GtkWidget *parent) +void create_taskbar(GtkWidget *parent) { - GtkWidget *table, *label; + GtkWidget *table, *label; - 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); + 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); - label = gtk_label_new (_("Show all desktop")); - gtk_misc_set_alignment (GTK_MISC (label), 0, 0); - gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, GTK_FILL, 0, 0, 0); + label = gtk_label_new(_("Show all desktop")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, GTK_FILL, 0, 0, 0); - taskbar_show_desktop = gtk_check_button_new (); - gtk_widget_show (taskbar_show_desktop); - gtk_entry_set_max_length (GTK_ENTRY (taskbar_show_desktop), 3); - gtk_table_attach (GTK_TABLE (table), taskbar_show_desktop, 1, 2, 0, 1, GTK_FILL, 0, 0, 0); + taskbar_show_desktop = gtk_check_button_new(); + gtk_widget_show(taskbar_show_desktop); + gtk_table_attach(GTK_TABLE(table), taskbar_show_desktop, 1, 2, 0, 1, GTK_FILL, 0, 0, 0); - label = gtk_label_new (_("Show taskbar name")); - gtk_misc_set_alignment (GTK_MISC (label), 0, 0); - gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2, GTK_FILL, 0, 0, 0); + label = gtk_label_new(_("Show taskbar name")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, 0, 1, 1, 2, GTK_FILL, 0, 0, 0); - taskbar_show_name = gtk_check_button_new (); - gtk_widget_show (taskbar_show_name); - gtk_entry_set_max_length (GTK_ENTRY (taskbar_show_name), 3); - gtk_table_attach (GTK_TABLE (table), taskbar_show_name, 1, 2, 1, 2, GTK_FILL, 0, 0, 0); + taskbar_show_name = gtk_check_button_new(); + gtk_widget_show(taskbar_show_name); + gtk_table_attach(GTK_TABLE(table), taskbar_show_name, 1, 2, 1, 2, GTK_FILL, 0, 0, 0); change_paragraph(parent); - label = gtk_label_new (_("Taskbar Appearance")); - 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(_("Taskbar Appearance")); + 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); + 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); - 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, 2, 3, 0, 1, GTK_FILL, 0, 0, 0); + 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, 2, 3, 0, 1, GTK_FILL, 0, 0, 0); - taskbar_padding_x = gtk_spin_button_new_with_range (0, 500, 1); - gtk_widget_show (taskbar_padding_x); - gtk_entry_set_max_length (GTK_ENTRY (taskbar_padding_x), 3); - gtk_table_attach (GTK_TABLE (table), taskbar_padding_x, 3, 4, 0, 1, GTK_FILL, 0, 0, 0); + 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, 3, 4, 0, 1, GTK_FILL, 0, 0, 0); - 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, 2, 3, 1, 2, GTK_FILL, 0, 0, 0); + 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, 2, 3, 1, 2, GTK_FILL, 0, 0, 0); - taskbar_padding_y = gtk_spin_button_new_with_range (0, 500, 1); - gtk_widget_show (taskbar_padding_y); - gtk_entry_set_max_length (GTK_ENTRY (taskbar_padding_y), 3); - gtk_table_attach (GTK_TABLE (table), taskbar_padding_y, 3, 4, 1, 2, GTK_FILL, 0, 0, 0); + 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, 3, 4, 1, 2, GTK_FILL, 0, 0, 0); - 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, 2, 3, 2, 3, GTK_FILL, 0, 0, 0); + 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, 2, 3, 2, 3, GTK_FILL, 0, 0, 0); - taskbar_spacing = gtk_spin_button_new_with_range (0, 500, 1); - gtk_widget_show (taskbar_spacing); - gtk_entry_set_max_length (GTK_ENTRY (taskbar_spacing), 3); - gtk_table_attach (GTK_TABLE (table), taskbar_spacing, 3, 4, 2, 3, GTK_FILL, 0, 0, 0); + taskbar_spacing = gtk_spin_button_new_with_range(0, 500, 1); + gtk_widget_show(taskbar_spacing); + gtk_table_attach(GTK_TABLE(table), taskbar_spacing, 3, 4, 2, 3, GTK_FILL, 0, 0, 0); - 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, 6, 7, 0, 1, GTK_FILL, 0, 0, 0); + 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, 6, 7, 0, 1, GTK_FILL, 0, 0, 0); - combo_background = gtk_combo_box_new_text (); - gtk_widget_show (combo_background); - gtk_table_attach (GTK_TABLE (table), combo_background, 7, 8, 0, 1, GTK_FILL, 0, 0, 0); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Id 1")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Id 2")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Id 3")); + taskbar_inactive_background = create_background_combo(); + gtk_widget_show(taskbar_inactive_background); + gtk_table_attach(GTK_TABLE(table), taskbar_inactive_background, 7, 8, 0, 1, GTK_FILL, 0, 0, 0); - 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, 6, 7, 1, 2, GTK_FILL, 0, 0, 0); + 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, 6, 7, 1, 2, GTK_FILL, 0, 0, 0); - combo_background = gtk_combo_box_new_text (); - gtk_widget_show (combo_background); - gtk_table_attach (GTK_TABLE (table), combo_background, 7, 8, 1, 2, GTK_FILL, 0, 0, 0); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Id 1")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Id 2")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Id 3")); + taskbar_active_background = create_background_combo(); + gtk_widget_show(taskbar_active_background); + gtk_table_attach(GTK_TABLE(table), taskbar_active_background, 7, 8, 1, 2, GTK_FILL, 0, 0, 0); change_paragraph(parent); - label = gtk_label_new (_("Name appearance")); - 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(_("Name appearance")); + 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); + 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); - 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, 2, 3, 0, 1, GTK_FILL, 0, 0, 0); + 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, 2, 3, 0, 1, GTK_FILL, 0, 0, 0); - taskbar_name_padding_x = gtk_spin_button_new_with_range (0, 500, 1); - gtk_widget_show (taskbar_name_padding_x); - gtk_entry_set_max_length (GTK_ENTRY (taskbar_name_padding_x), 3); - gtk_table_attach (GTK_TABLE (table), taskbar_name_padding_x, 3, 4, 0, 1, GTK_FILL, 0, 0, 0); + 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, 3, 4, 0, 1, GTK_FILL, 0, 0, 0); - 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, 2, 3, 1, 2, GTK_FILL, 0, 0, 0); + 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, 2, 3, 1, 2, GTK_FILL, 0, 0, 0); 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, 3, 4, 1, 2, GTK_FILL, 0, 0, 0); + gtk_widget_show(taskbar_name_inactive_color); + gtk_table_attach(GTK_TABLE(table), taskbar_name_inactive_color, 3, 4, 1, 2, GTK_FILL, 0, 0, 0); - 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, 2, 3, 2, 3, GTK_FILL, 0, 0, 0); + 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, 2, 3, 2, 3, GTK_FILL, 0, 0, 0); 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, 3, 4, 2, 3, GTK_FILL, 0, 0, 0); + gtk_widget_show(taskbar_name_active_color); + gtk_table_attach(GTK_TABLE(table), taskbar_name_active_color, 3, 4, 2, 3, GTK_FILL, 0, 0, 0); - 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, 6, 7, 0, 1, GTK_FILL, 0, 0, 0); + 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, 6, 7, 0, 1, GTK_FILL, 0, 0, 0); - taskbar_name_font = gtk_font_button_new (); - gtk_widget_show (taskbar_name_font); - gtk_table_attach (GTK_TABLE (table), taskbar_name_font, 7, 22, 0, 1, GTK_FILL, 0, 0, 0); - //gtk_font_button_set_show_style (GTK_FONT_BUTTON (taskbar_name_font), FALSE); + taskbar_name_font = gtk_font_button_new(); + gtk_widget_show(taskbar_name_font); + gtk_table_attach(GTK_TABLE(table), taskbar_name_font, 7, 22, 0, 1, GTK_FILL, 0, 0, 0); + //gtk_font_button_set_show_style(GTK_FONT_BUTTON(taskbar_name_font), FALSE); - 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, 6, 7, 1, 2, GTK_FILL, 0, 0, 0); + 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, 6, 7, 1, 2, GTK_FILL, 0, 0, 0); - combo_background = gtk_combo_box_new_text (); - gtk_widget_show (combo_background); - gtk_table_attach (GTK_TABLE (table), combo_background, 7, 8, 1, 2, GTK_FILL, 0, 0, 0); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Id 1")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Id 2")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Id 3")); + taskbar_name_inactive_background = create_background_combo(); + gtk_widget_show(taskbar_name_inactive_background); + gtk_table_attach(GTK_TABLE(table), taskbar_name_inactive_background, 7, 8, 1, 2, GTK_FILL, 0, 0, 0); - 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, 6, 7, 2, 3, GTK_FILL, 0, 0, 0); + 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, 6, 7, 2, 3, GTK_FILL, 0, 0, 0); - combo_background = gtk_combo_box_new_text (); - gtk_widget_show (combo_background); - gtk_table_attach (GTK_TABLE (table), combo_background, 7, 8, 2, 3, GTK_FILL, 0, 0, 0); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Id 1")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Id 2")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Id 3")); + taskbar_name_active_background = create_background_combo(); + gtk_widget_show(taskbar_name_active_background); + gtk_table_attach(GTK_TABLE(table), taskbar_name_active_background, 7, 8, 2, 3, GTK_FILL, 0, 0, 0); change_paragraph(parent); } - -void create_task(GtkWidget *parent) +void create_task(GtkWidget *parent) { - GtkWidget *table, *label, *notebook, *page_task; + GtkWidget *table, *label, *notebook; - label = gtk_label_new (_("Mouse action")); - 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(_("Mouse action")); + 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(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); - 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, 2, 3, 0, 1, GTK_FILL, 0, 0, 0); + 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, 2, 3, 0, 1, GTK_FILL, 0, 0, 0); - task_mouse_middle = gtk_combo_box_new_text (); - gtk_widget_show (task_mouse_middle); - gtk_table_attach (GTK_TABLE (table), task_mouse_middle, 3, 4, 0, 1, GTK_FILL, 0, 0, 0); - 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), _("sShade")); - 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")); + task_mouse_middle = gtk_combo_box_new_text(); + gtk_widget_show(task_mouse_middle); + gtk_table_attach(GTK_TABLE(table), task_mouse_middle, 3, 4, 0, 1, GTK_FILL, 0, 0, 0); + 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), _("sShade")); + 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")); - 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, 6, 7, 0, 1, GTK_FILL, 0, 0, 0); + 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, 6, 7, 0, 1, GTK_FILL, 0, 0, 0); - 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, 7, 8, 0, 1, GTK_FILL, 0, 0, 0); - 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")); + 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, 7, 8, 0, 1, GTK_FILL, 0, 0, 0); + 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")); - 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, 2, 3, 1, 2, GTK_FILL, 0, 0, 0); + 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, 2, 3, 1, 2, GTK_FILL, 0, 0, 0); - task_mouse_right = gtk_combo_box_new_text (); - gtk_widget_show (task_mouse_right); - gtk_table_attach (GTK_TABLE (table), task_mouse_right, 3, 4, 1, 2, GTK_FILL, 0, 0, 0); - 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")); + task_mouse_right = gtk_combo_box_new_text(); + gtk_widget_show(task_mouse_right); + gtk_table_attach(GTK_TABLE(table), task_mouse_right, 3, 4, 1, 2, GTK_FILL, 0, 0, 0); + 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")); - 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, 6, 7, 1, 2, GTK_FILL, 0, 0, 0); + 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, 6, 7, 1, 2, GTK_FILL, 0, 0, 0); - 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, 7, 8, 1, 2, GTK_FILL, 0, 0, 0); - 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")); + 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, 7, 8, 1, 2, GTK_FILL, 0, 0, 0); + 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")); + + 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, 2, 3, 2, 3, GTK_FILL, 0, 0, 0); + + tooltip_task_show = gtk_check_button_new(); + gtk_widget_show(tooltip_task_show); + gtk_table_attach(GTK_TABLE(table), tooltip_task_show, 3, 4, 2, 3, GTK_FILL, 0, 0, 0); change_paragraph(parent); - label = gtk_label_new (_("Appearance")); - 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(_("Appearance")); + 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); + 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); - 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, 2, 3, 0, 1, GTK_FILL, 0, 0, 0); + 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, 2, 3, 0, 1, GTK_FILL, 0, 0, 0); - task_show_icon = gtk_check_button_new (); - gtk_widget_show (task_show_icon); - gtk_entry_set_max_length (GTK_ENTRY (task_show_icon), 3); - gtk_table_attach (GTK_TABLE (table), task_show_icon, 3, 4, 0, 1, GTK_FILL, 0, 0, 0); + task_show_icon = gtk_check_button_new(); + gtk_widget_show(task_show_icon); + gtk_table_attach(GTK_TABLE(table), task_show_icon, 3, 4, 0, 1, GTK_FILL, 0, 0, 0); - 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, 2, 3, 1, 2, GTK_FILL, 0, 0, 0); + 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, 2, 3, 1, 2, GTK_FILL, 0, 0, 0); - task_show_text = gtk_check_button_new (); - gtk_widget_show (task_show_text); - gtk_entry_set_max_length (GTK_ENTRY (task_show_text), 3); - gtk_table_attach (GTK_TABLE (table), task_show_text, 3, 4, 1, 2, GTK_FILL, 0, 0, 0); + task_show_text = gtk_check_button_new(); + gtk_widget_show(task_show_text); + gtk_table_attach(GTK_TABLE(table), task_show_text, 3, 4, 1, 2, GTK_FILL, 0, 0, 0); - label = gtk_label_new (_("Align center")); - gtk_misc_set_alignment (GTK_MISC (label), 0, 0); - gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, 2, 3, 2, 3, GTK_FILL, 0, 0, 0); + label = gtk_label_new(_("Align center")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, 2, 3, 2, 3, GTK_FILL, 0, 0, 0); - task_align_center = gtk_check_button_new (); - gtk_widget_show (task_align_center); - gtk_entry_set_max_length (GTK_ENTRY (task_align_center), 3); - gtk_table_attach (GTK_TABLE (table), task_align_center, 3, 4, 2, 3, GTK_FILL, 0, 0, 0); + task_align_center = gtk_check_button_new(); + gtk_widget_show(task_align_center); + gtk_table_attach(GTK_TABLE(table), task_align_center, 3, 4, 2, 3, GTK_FILL, 0, 0, 0); - label = gtk_label_new (_("Font shadow")); - gtk_misc_set_alignment (GTK_MISC (label), 0, 0); - gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, 2, 3, 3, 4, GTK_FILL, 0, 0, 0); + label = gtk_label_new(_("Font shadow")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, 2, 3, 3, 4, GTK_FILL, 0, 0, 0); - task_font_shadow = gtk_check_button_new (); - gtk_widget_show (task_font_shadow); - gtk_entry_set_max_length (GTK_ENTRY (task_font_shadow), 3); - gtk_table_attach (GTK_TABLE (table), task_font_shadow, 3, 4, 3, 4, GTK_FILL, 0, 0, 0); + task_font_shadow = gtk_check_button_new(); + gtk_widget_show(task_font_shadow); + gtk_table_attach(GTK_TABLE(table), task_font_shadow, 3, 4, 3, 4, GTK_FILL, 0, 0, 0); - 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, 6, 7, 0, 1, GTK_FILL, 0, 0, 0); + 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, 6, 7, 0, 1, GTK_FILL, 0, 0, 0); - 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, 7, 8, 0, 1, GTK_FILL, 0, 0, 0); + 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, 7, 8, 0, 1, GTK_FILL, 0, 0, 0); - 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, 6, 7, 1, 2, GTK_FILL, 0, 0, 0); + 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, 6, 7, 1, 2, GTK_FILL, 0, 0, 0); - 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, 7, 8, 1, 2, GTK_FILL, 0, 0, 0); + 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, 7, 8, 1, 2, GTK_FILL, 0, 0, 0); - 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, 6, 7, 2, 3, GTK_FILL, 0, 0, 0); + 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, 6, 7, 2, 3, GTK_FILL, 0, 0, 0); - 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, 7, 8, 2, 3, GTK_FILL, 0, 0, 0); + 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, 7, 8, 2, 3, GTK_FILL, 0, 0, 0); - 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, 6, 7, 3, 4, GTK_FILL, 0, 0, 0); + 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, 6, 7, 3, 4, GTK_FILL, 0, 0, 0); - 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, 7, 8, 3, 4, GTK_FILL, 0, 0, 0); + 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, 7, 8, 3, 4, GTK_FILL, 0, 0, 0); - 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, 10, 11, 0, 1, GTK_FILL, 0, 0, 0); + 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, 10, 11, 0, 1, GTK_FILL, 0, 0, 0); - task_font = gtk_font_button_new (); - gtk_widget_show (task_font); - gtk_table_attach (GTK_TABLE (table), task_font, 11, 12, 0, 1, GTK_FILL, 0, 0, 0); -// gtk_font_button_set_show_style (GTK_FONT_BUTTON (task_font), FALSE); - - // tasks - 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); + task_font = gtk_font_button_new(); + gtk_widget_show(task_font); + gtk_table_attach(GTK_TABLE(table), task_font, 11, 12, 0, 1, GTK_FILL, 0, 0, 0); +// gtk_font_button_set_show_style(GTK_FONT_BUTTON(task_font), FALSE); // notebook - label = gtk_label_new (_("Normal task")); - 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), page_task, label); + 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); - label = gtk_label_new (_("Active task")); - 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), page_task, label); - - label = gtk_label_new (_("Urgent task")); - 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), page_task, label); - - label = gtk_label_new (_("Iconified task")); - 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), page_task, label); + create_task_status(notebook, + "Default style", + &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", + &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", + &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", + &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", + &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 create_clock(GtkWidget *parent) +void task_status_toggle_button_callback(GtkWidget *widget, gpointer data) { - GtkWidget *table; - GtkWidget *label; + GtkWidget *child1, *child2, *child3; + child1 = child2 = child3 = NULL; - 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); + 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; + } -// change_paragraph(parent); + 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); +} - label = gtk_label_new (_("Format and timezone")); - 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); +void create_task_status(GtkWidget *notebook, + char *name, + 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) +{ + 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); - 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); + 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); - 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, 2, 3, 0, 1, GTK_FILL, 0, 0, 0); + *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); - 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, 3, 4, 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); - 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, 2, 3, 1, 2, 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); - 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, 3, 4, 1, 2, GTK_FILL, 0, 0, 0); + *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); - 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, 6, 7, 0, 1, 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); - 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, 7, 8, 0, 1, GTK_FILL, 0, 0, 0); + *task_status_icon_opacity = gtk_spin_button_new_with_range(0, 100, 1); + 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); - 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, 6, 7, 1, 2, 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); - 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, 7, 8, 1, 2, GTK_FILL, 0, 0, 0); + *task_status_icon_saturation = gtk_spin_button_new_with_range(-100, 100, 1); + 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); + + 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_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); + + *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); + + 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(); + gtk_widget_show(*task_status_background); + gtk_table_attach(GTK_TABLE(table), *task_status_background, 2, 3, 4, 5, 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); + } + + 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; + + 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); + + label = gtk_label_new(_("Format and timezone")); + 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); + + 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, 2, 3, 0, 1, GTK_FILL, 0, 0, 0); + + 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, 3, 4, 0, 1, GTK_FILL, 0, 0, 0); + + 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, 2, 3, 1, 2, GTK_FILL, 0, 0, 0); + + 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, 3, 4, 1, 2, GTK_FILL, 0, 0, 0); + + 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, 6, 7, 0, 1, GTK_FILL, 0, 0, 0); + + 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, 7, 8, 0, 1, GTK_FILL, 0, 0, 0); + + 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, 6, 7, 1, 2, GTK_FILL, 0, 0, 0); + + 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, 7, 8, 1, 2, GTK_FILL, 0, 0, 0); change_paragraph(parent); - label = gtk_label_new (_("Mouse action")); - 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(_("Mouse action")); + 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); - 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, 2, 3, 0, 1, GTK_FILL, 0, 0, 0); + 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, 2, 3, 0, 1, GTK_FILL, 0, 0, 0); - clock_left_command = gtk_entry_new (); - gtk_widget_show (clock_left_command); - gtk_entry_set_width_chars (GTK_ENTRY (clock_left_command), 16); - gtk_table_attach (GTK_TABLE (table), clock_left_command, 3, 4, 0, 1, GTK_FILL, 0, 0, 0); + clock_left_command = gtk_entry_new(); + gtk_widget_show(clock_left_command); + gtk_entry_set_width_chars(GTK_ENTRY(clock_left_command), 16); + gtk_table_attach(GTK_TABLE(table), clock_left_command, 3, 4, 0, 1, GTK_FILL, 0, 0, 0); - 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, 6, 7, 0, 1, GTK_FILL, 0, 0, 0); + 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, 6, 7, 0, 1, GTK_FILL, 0, 0, 0); - clock_right_command = gtk_entry_new (); - gtk_widget_show (clock_right_command); - gtk_entry_set_width_chars (GTK_ENTRY (clock_right_command), 16); - gtk_table_attach (GTK_TABLE (table), clock_right_command, 7, 8, 0, 1, GTK_FILL, 0, 0, 0); + clock_right_command = gtk_entry_new(); + gtk_widget_show(clock_right_command); + gtk_entry_set_width_chars(GTK_ENTRY(clock_right_command), 16); + gtk_table_attach(GTK_TABLE(table), clock_right_command, 7, 8, 0, 1, GTK_FILL, 0, 0, 0); change_paragraph(parent); - label = gtk_label_new (_("Appearance")); - 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(_("Appearance")); + 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); + 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); - 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, 2, 3, 0, 1, GTK_FILL, 0, 0, 0); + 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, 2, 3, 0, 1, GTK_FILL, 0, 0, 0); - clock_padding_x = gtk_spin_button_new_with_range (0, 500, 1); - gtk_widget_show (clock_padding_x); - gtk_entry_set_max_length (GTK_ENTRY (clock_padding_x), 3); - gtk_table_attach (GTK_TABLE (table), clock_padding_x, 3, 4, 0, 1, GTK_FILL, 0, 0, 0); + 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, 3, 4, 0, 1, GTK_FILL, 0, 0, 0); - 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, 2, 3, 1, 2, GTK_FILL, 0, 0, 0); + 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, 2, 3, 1, 2, GTK_FILL, 0, 0, 0); - clock_padding_y = gtk_spin_button_new_with_range (0, 500, 1); - gtk_widget_show (clock_padding_y); - gtk_entry_set_max_length (GTK_ENTRY (clock_padding_y), 3); - gtk_table_attach (GTK_TABLE (table), clock_padding_y, 3, 4, 1, 2, GTK_FILL, 0, 0, 0); + 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, 3, 4, 1, 2, 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, 2, 3, 2, 3, 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, 2, 3, 2, 3, GTK_FILL, 0, 0, 0); - combo_background = gtk_combo_box_new_text (); - gtk_widget_show (combo_background); - gtk_table_attach (GTK_TABLE (table), combo_background, 3, 4, 2, 3, GTK_FILL, 0, 0, 0); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Id 1")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Id 2")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Id 3")); + clock_background = create_background_combo(); + gtk_widget_show(clock_background); + gtk_table_attach(GTK_TABLE(table), clock_background, 3, 4, 2, 3, GTK_FILL, 0, 0, 0); - 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, 6, 7, 0, 1, GTK_FILL, 0, 0, 0); + 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, 6, 7, 0, 1, GTK_FILL, 0, 0, 0); - clock_font_line1 = gtk_font_button_new (); - gtk_widget_show (clock_font_line1); - gtk_table_attach (GTK_TABLE (table), clock_font_line1, 7, 22, 0, 1, GTK_FILL, 0, 0, 0); -// gtk_font_button_set_show_style (GTK_FONT_BUTTON (clock_font_line1), FALSE); + clock_font_line1 = gtk_font_button_new(); + gtk_widget_show(clock_font_line1); + gtk_table_attach(GTK_TABLE(table), clock_font_line1, 7, 22, 0, 1, GTK_FILL, 0, 0, 0); +// gtk_font_button_set_show_style(GTK_FONT_BUTTON(clock_font_line1), FALSE); - 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, 6, 7, 1, 2, GTK_FILL, 0, 0, 0); + 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, 6, 7, 1, 2, GTK_FILL, 0, 0, 0); - clock_font_line2 = gtk_font_button_new (); - gtk_widget_show (clock_font_line2); - gtk_table_attach (GTK_TABLE (table), clock_font_line2, 7, 22, 1, 2, GTK_FILL, 0, 0, 0); -// gtk_font_button_set_show_style (GTK_FONT_BUTTON (clock_font_line2), FALSE); + clock_font_line2 = gtk_font_button_new(); + gtk_widget_show(clock_font_line2); + gtk_table_attach(GTK_TABLE(table), clock_font_line2, 7, 22, 1, 2, GTK_FILL, 0, 0, 0); +// gtk_font_button_set_show_style(GTK_FONT_BUTTON(clock_font_line2), FALSE); - 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, 6, 7, 2, 3, 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, 6, 7, 2, 3, GTK_FILL, 0, 0, 0); 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, 7, 8, 2, 3, GTK_FILL, 0, 0, 0); + gtk_widget_show(clock_font_color); + gtk_table_attach(GTK_TABLE(table), clock_font_color, 7, 8, 2, 3, GTK_FILL, 0, 0, 0); + + change_paragraph(parent); + + label = gtk_label_new(_("Tooltip")); + 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); + + label = gtk_label_new(_("Clock tooltip format")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, 2, 3, 0, 1, GTK_FILL, 0, 0, 0); + + clock_format_tooltip = gtk_entry_new(); + gtk_widget_show(clock_format_tooltip); + gtk_entry_set_width_chars(GTK_ENTRY(clock_format_tooltip), 16); + gtk_table_attach(GTK_TABLE(table), clock_format_tooltip, 3, 4, 0, 1, GTK_FILL, 0, 0, 0); + + label = gtk_label_new(_("Clock tooltip timezone")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, 2, 3, 1, 2, GTK_FILL, 0, 0, 0); + + 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, 3, 4, 1, 2, GTK_FILL, 0, 0, 0); change_paragraph(parent); } - -void create_systemtray(GtkWidget *parent) +void create_systemtray(GtkWidget *parent) { - GtkWidget *table; - GtkWidget *label; + GtkWidget *table; + GtkWidget *label; - 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); + 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); - 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, 0, 1, 1, 2, GTK_FILL, 0, 0, 0); + 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, 0, 1, 1, 2, GTK_FILL, 0, 0, 0); - systray_icon_order = gtk_combo_box_new_text (); - gtk_widget_show (systray_icon_order); - gtk_table_attach (GTK_TABLE (table), systray_icon_order, 1, 2, 1, 2, GTK_FILL, 0, 0, 0); - 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")); + systray_icon_order = gtk_combo_box_new_text(); + gtk_widget_show(systray_icon_order); + gtk_table_attach(GTK_TABLE(table), systray_icon_order, 1, 2, 1, 2, GTK_FILL, 0, 0, 0); + 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")); change_paragraph(parent); - label = gtk_label_new (_("Appearance")); - 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(_("Appearance")); + 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); + 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); - 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, 2, 3, 0, 1, GTK_FILL, 0, 0, 0); + 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, 2, 3, 0, 1, GTK_FILL, 0, 0, 0); - systray_padding_x = gtk_spin_button_new_with_range (0, 500, 1); - gtk_widget_show (systray_padding_x); - gtk_entry_set_max_length (GTK_ENTRY (systray_padding_x), 3); - gtk_table_attach (GTK_TABLE (table), systray_padding_x, 3, 4, 0, 1, GTK_FILL, 0, 0, 0); + 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, 3, 4, 0, 1, GTK_FILL, 0, 0, 0); - 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, 2, 3, 1, 2, GTK_FILL, 0, 0, 0); + 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, 2, 3, 1, 2, GTK_FILL, 0, 0, 0); - systray_padding_y = gtk_spin_button_new_with_range (0, 500, 1); - gtk_widget_show (systray_padding_y); - gtk_entry_set_max_length (GTK_ENTRY (systray_padding_y), 3); - gtk_table_attach (GTK_TABLE (table), systray_padding_y, 3, 4, 1, 2, GTK_FILL, 0, 0, 0); + 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, 3, 4, 1, 2, GTK_FILL, 0, 0, 0); - 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, 2, 3, 2, 3, GTK_FILL, 0, 0, 0); + 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, 2, 3, 2, 3, GTK_FILL, 0, 0, 0); - systray_spacing = gtk_spin_button_new_with_range (0, 500, 1); - gtk_widget_show (systray_spacing); - gtk_entry_set_max_length (GTK_ENTRY (systray_spacing), 3); - gtk_table_attach (GTK_TABLE (table), systray_spacing, 3, 4, 2, 3, GTK_FILL, 0, 0, 0); + systray_spacing = gtk_spin_button_new_with_range(0, 500, 1); + gtk_widget_show(systray_spacing); + gtk_table_attach(GTK_TABLE(table), systray_spacing, 3, 4, 2, 3, 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, 2, 3, 3, 4, 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, 2, 3, 3, 4, GTK_FILL, 0, 0, 0); - combo_background = gtk_combo_box_new_text (); - gtk_widget_show (combo_background); - gtk_table_attach (GTK_TABLE (table), combo_background, 3, 4, 3, 4, GTK_FILL, 0, 0, 0); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Id 1")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Id 2")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Id 3")); + systray_background = create_background_combo(); + gtk_widget_show(systray_background); + gtk_table_attach(GTK_TABLE(table), systray_background, 3, 4, 3, 4, GTK_FILL, 0, 0, 0); - 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, 6, 7, 0, 1, GTK_FILL, 0, 0, 0); + 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, 6, 7, 0, 1, GTK_FILL, 0, 0, 0); - systray_icon_size = gtk_spin_button_new_with_range (0, 500, 1); - gtk_widget_show (systray_icon_size); - gtk_entry_set_max_length (GTK_ENTRY (systray_icon_size), 3); - gtk_table_attach (GTK_TABLE (table), systray_icon_size, 7, 8, 0, 1, GTK_FILL, 0, 0, 0); + 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, 7, 8, 0, 1, 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, 6, 7, 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, 6, 7, 1, 2, GTK_FILL, 0, 0, 0); - systray_icon_opacity = gtk_spin_button_new_with_range (0, 100, 1); - gtk_widget_show (systray_icon_opacity); - gtk_entry_set_max_length (GTK_ENTRY (systray_icon_opacity), 3); - gtk_table_attach (GTK_TABLE (table), systray_icon_opacity, 7, 8, 1, 2, GTK_FILL, 0, 0, 0); + systray_icon_opacity = gtk_spin_button_new_with_range(0, 100, 1); + gtk_widget_show(systray_icon_opacity); + gtk_table_attach(GTK_TABLE(table), systray_icon_opacity, 7, 8, 1, 2, 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, 6, 7, 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, 6, 7, 2, 3, GTK_FILL, 0, 0, 0); - systray_icon_saturation = gtk_spin_button_new_with_range (-100, 100, 1); - gtk_widget_show (systray_icon_saturation); - gtk_entry_set_max_length (GTK_ENTRY (systray_icon_saturation), 4); - gtk_table_attach (GTK_TABLE (table), systray_icon_saturation, 7, 8, 2, 3, GTK_FILL, 0, 0, 0); + systray_icon_saturation = gtk_spin_button_new_with_range(-100, 100, 1); + gtk_widget_show(systray_icon_saturation); + gtk_table_attach(GTK_TABLE(table), systray_icon_saturation, 7, 8, 2, 3, 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, 6, 7, 3, 4, GTK_FILL, 0, 0, 0); - - systray_icon_brightness = gtk_spin_button_new_with_range (-100, 100, 1); - gtk_widget_show (systray_icon_brightness); - gtk_entry_set_max_length (GTK_ENTRY (systray_icon_brightness), 4); - gtk_table_attach (GTK_TABLE (table), systray_icon_brightness, 7, 8, 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, 6, 7, 3, 4, GTK_FILL, 0, 0, 0); + systray_icon_brightness = gtk_spin_button_new_with_range(-100, 100, 1); + gtk_widget_show(systray_icon_brightness); + gtk_table_attach(GTK_TABLE(table), systray_icon_brightness, 7, 8, 3, 4, GTK_FILL, 0, 0, 0); } - -void create_battery(GtkWidget *parent) +void create_battery(GtkWidget *parent) { - GtkWidget *table, *label; + GtkWidget *table, *label; - 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); + 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); - label = gtk_label_new (_("Event")); - 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(_("Event")); + 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); - 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, 2, 3, 0, 1, GTK_FILL, 0, 0, 0); + 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, 2, 3, 0, 1, GTK_FILL, 0, 0, 0); - battery_hide_if_higher = gtk_spin_button_new_with_range (0, 101, 1); - gtk_widget_show (battery_hide_if_higher); - gtk_entry_set_max_length (GTK_ENTRY (battery_hide_if_higher), 3); - gtk_table_attach (GTK_TABLE (table), battery_hide_if_higher, 3, 4, 0, 1, GTK_FILL, 0, 0, 0); + 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, 3, 4, 0, 1, GTK_FILL, 0, 0, 0); - label = gtk_label_new (_("%")); - gtk_misc_set_alignment (GTK_MISC (label), 0, 0); - gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, 4, 5, 0, 1, GTK_FILL, 0, 0, 0); + label = gtk_label_new(_("%")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, 4, 5, 0, 1, GTK_FILL, 0, 0, 0); - 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, 2, 3, 1, 2, GTK_FILL, 0, 0, 0); + 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, 2, 3, 1, 2, GTK_FILL, 0, 0, 0); - battery_alert_if_lower = gtk_spin_button_new_with_range (0, 100, 1); - gtk_widget_show (battery_alert_if_lower); - gtk_entry_set_max_length (GTK_ENTRY (battery_alert_if_lower), 3); - gtk_table_attach (GTK_TABLE (table), battery_alert_if_lower, 3, 4, 1, 2, GTK_FILL, 0, 0, 0); + 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, 3, 4, 1, 2, GTK_FILL, 0, 0, 0); - label = gtk_label_new (_("%")); - gtk_misc_set_alignment (GTK_MISC (label), 0, 0); - gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, 4, 5, 1, 2, GTK_FILL, 0, 0, 0); + label = gtk_label_new(_("%")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, 4, 5, 1, 2, GTK_FILL, 0, 0, 0); - 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, 7, 8, 1, 2, GTK_FILL, 0, 0, 0); + 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, 7, 8, 1, 2, GTK_FILL, 0, 0, 0); - battery_alert_cmd = gtk_entry_new (); - gtk_widget_show (battery_alert_cmd); - gtk_entry_set_width_chars (GTK_ENTRY (battery_alert_cmd), 28); - gtk_table_attach (GTK_TABLE (table), battery_alert_cmd, 8, 9, 1, 2, GTK_FILL, 0, 0, 0); + battery_alert_cmd = gtk_entry_new(); + gtk_widget_show(battery_alert_cmd); + gtk_entry_set_width_chars(GTK_ENTRY(battery_alert_cmd), 28); + gtk_table_attach(GTK_TABLE(table), battery_alert_cmd, 8, 9, 1, 2, GTK_FILL, 0, 0, 0); change_paragraph(parent); - label = gtk_label_new (_("Appearance")); - 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(_("Appearance")); + 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); + 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); - 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, 2, 3, 0, 1, GTK_FILL, 0, 0, 0); + 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, 2, 3, 0, 1, GTK_FILL, 0, 0, 0); - battery_padding_x = gtk_spin_button_new_with_range (0, 500, 1); - gtk_widget_show (battery_padding_x); - gtk_entry_set_max_length (GTK_ENTRY (battery_padding_x), 3); - gtk_table_attach (GTK_TABLE (table), battery_padding_x, 3, 4, 0, 1, GTK_FILL, 0, 0, 0); + 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, 3, 4, 0, 1, GTK_FILL, 0, 0, 0); - 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, 2, 3, 1, 2, GTK_FILL, 0, 0, 0); + 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, 2, 3, 1, 2, GTK_FILL, 0, 0, 0); - battery_padding_y = gtk_spin_button_new_with_range (0, 500, 1); - gtk_widget_show (battery_padding_y); - gtk_entry_set_max_length (GTK_ENTRY (battery_padding_y), 3); - gtk_table_attach (GTK_TABLE (table), battery_padding_y, 3, 4, 1, 2, GTK_FILL, 0, 0, 0); + 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, 3, 4, 1, 2, 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, 2, 3, 2, 3, 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, 2, 3, 2, 3, GTK_FILL, 0, 0, 0); - combo_background = gtk_combo_box_new_text (); - gtk_widget_show (combo_background); - gtk_table_attach (GTK_TABLE (table), combo_background, 3, 4, 2, 3, GTK_FILL, 0, 0, 0); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Id 1")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Id 2")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Id 3")); + battery_background = create_background_combo(); + gtk_widget_show(battery_background); + gtk_table_attach(GTK_TABLE(table), battery_background, 3, 4, 2, 3, GTK_FILL, 0, 0, 0); - 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, 6, 7, 0, 1, GTK_FILL, 0, 0, 0); + 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, 6, 7, 0, 1, GTK_FILL, 0, 0, 0); - battery_font_line1 = gtk_font_button_new (); - gtk_widget_show (battery_font_line1); - gtk_table_attach (GTK_TABLE (table), battery_font_line1, 7, 22, 0, 1, GTK_FILL, 0, 0, 0); -// gtk_font_button_set_show_style (GTK_FONT_BUTTON (battery_font_line1), FALSE); + battery_font_line1 = gtk_font_button_new(); + gtk_widget_show(battery_font_line1); + gtk_table_attach(GTK_TABLE(table), battery_font_line1, 7, 22, 0, 1, GTK_FILL, 0, 0, 0); +// gtk_font_button_set_show_style(GTK_FONT_BUTTON(battery_font_line1), FALSE); - 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, 6, 7, 1, 2, GTK_FILL, 0, 0, 0); + 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, 6, 7, 1, 2, GTK_FILL, 0, 0, 0); - battery_font_line2 = gtk_font_button_new (); - gtk_widget_show (battery_font_line2); - gtk_table_attach (GTK_TABLE (table), battery_font_line2, 7, 22, 1, 2, GTK_FILL, 0, 0, 0); -// gtk_font_button_set_show_style (GTK_FONT_BUTTON (battery_font_line2), FALSE); + battery_font_line2 = gtk_font_button_new(); + gtk_widget_show(battery_font_line2); + gtk_table_attach(GTK_TABLE(table), battery_font_line2, 7, 22, 1, 2, GTK_FILL, 0, 0, 0); +// gtk_font_button_set_show_style(GTK_FONT_BUTTON(battery_font_line2), FALSE); - 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, 6, 7, 2, 3, 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, 6, 7, 2, 3, GTK_FILL, 0, 0, 0); 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, 7, 8, 2, 3, GTK_FILL, 0, 0, 0); + gtk_widget_show(battery_font_color); + gtk_table_attach(GTK_TABLE(table), battery_font_color, 7, 8, 2, 3, GTK_FILL, 0, 0, 0); change_paragraph(parent); } - -void create_tooltip(GtkWidget *parent) +void create_tooltip(GtkWidget *parent) { - GtkWidget *table; - GtkWidget *label; + GtkWidget *table; + GtkWidget *label; - 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); + label = gtk_label_new(_("Timing")); + 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 (_("Show tooltip")); - gtk_misc_set_alignment (GTK_MISC (label), 0, 0); - gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, GTK_FILL, 0, 0, 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); - tooltip_task_show = gtk_check_button_new (); - gtk_widget_show (tooltip_task_show); - gtk_table_attach (GTK_TABLE (table), tooltip_task_show, 1, 2, 0, 1, GTK_FILL, 0, 0, 0); + label = gtk_label_new(_("Show tooltip after")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, 2, 3, 0, 1, GTK_FILL, 0, 0, 0); + + 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, 3, 4, 0, 1, GTK_FILL, 0, 0, 0); + + 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, 4, 5, 0, 1, GTK_FILL, 0, 0, 0); + + label = gtk_label_new(_("Hide tooltip after")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, 2, 3, 1, 2, GTK_FILL, 0, 0, 0); + + 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, 3, 4, 1, 2, GTK_FILL, 0, 0, 0); + + 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, 4, 5, 1, 2, GTK_FILL, 0, 0, 0); change_paragraph(parent); - label = gtk_label_new (_("Timing")); - 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(_("Appearance")); + 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); + 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); - label = gtk_label_new (_("Show tooltip after")); - gtk_misc_set_alignment (GTK_MISC (label), 0, 0); - gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, 2, 3, 0, 1, GTK_FILL, 0, 0, 0); + 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, 2, 3, 0, 1, GTK_FILL, 0, 0, 0); - 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, 3, 4, 0, 1, GTK_FILL, 0, 0, 0); + 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, 3, 4, 0, 1, GTK_FILL, 0, 0, 0); - 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, 4, 5, 0, 1, GTK_FILL, 0, 0, 0); + 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, 2, 3, 1, 2, GTK_FILL, 0, 0, 0); - label = gtk_label_new (_("Hide tooltip after")); - gtk_misc_set_alignment (GTK_MISC (label), 0, 0); - gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, 2, 3, 1, 2, GTK_FILL, 0, 0, 0); + 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, 3, 4, 1, 2, GTK_FILL, 0, 0, 0); - 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, 3, 4, 1, 2, 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, 2, 3, 2, 3, GTK_FILL, 0, 0, 0); - 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, 4, 5, 1, 2, GTK_FILL, 0, 0, 0); + tooltip_background = create_background_combo(); + gtk_widget_show(tooltip_background); + gtk_table_attach(GTK_TABLE(table), tooltip_background, 3, 4, 2, 3, GTK_FILL, 0, 0, 0); - change_paragraph(parent); - - label = gtk_label_new (_("Appearance")); - 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(_("Font")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, 6, 7, 0, 1, GTK_FILL, 0, 0, 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); + tooltip_font = gtk_font_button_new(); + gtk_widget_show(tooltip_font); + gtk_table_attach(GTK_TABLE(table), tooltip_font, 7, 22, 0, 1, GTK_FILL, 0, 0, 0); +// gtk_font_button_set_show_style(GTK_FONT_BUTTON(tooltip_font), FALSE); - 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, 2, 3, 0, 1, GTK_FILL, 0, 0, 0); - - tooltip_padding_x = gtk_spin_button_new_with_range (0, 500, 1); - gtk_widget_show (tooltip_padding_x); - gtk_entry_set_max_length (GTK_ENTRY (tooltip_padding_x), 3); - gtk_table_attach (GTK_TABLE (table), tooltip_padding_x, 3, 4, 0, 1, GTK_FILL, 0, 0, 0); - - 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, 2, 3, 1, 2, GTK_FILL, 0, 0, 0); - - tooltip_padding_y = gtk_spin_button_new_with_range (0, 500, 1); - gtk_widget_show (tooltip_padding_y); - gtk_entry_set_max_length (GTK_ENTRY (tooltip_padding_y), 3); - gtk_table_attach (GTK_TABLE (table), tooltip_padding_y, 3, 4, 1, 2, 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, 2, 3, 2, 3, GTK_FILL, 0, 0, 0); - - combo_background = gtk_combo_box_new_text (); - gtk_widget_show (combo_background); - gtk_table_attach (GTK_TABLE (table), combo_background, 3, 4, 2, 3, GTK_FILL, 0, 0, 0); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Id 1")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Id 2")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Id 3")); - - 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, 6, 7, 0, 1, GTK_FILL, 0, 0, 0); - - tooltip_font = gtk_font_button_new (); - gtk_widget_show (tooltip_font); - gtk_table_attach (GTK_TABLE (table), tooltip_font, 7, 22, 0, 1, GTK_FILL, 0, 0, 0); -// gtk_font_button_set_show_style (GTK_FONT_BUTTON (tooltip_font), FALSE); - - 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, 6, 7, 1, 2, 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, 6, 7, 1, 2, GTK_FILL, 0, 0, 0); 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, 7, 8, 1, 2, GTK_FILL, 0, 0, 0); - - change_paragraph(parent); - - label = gtk_label_new (_("Clock tooltip")); - 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); - - label = gtk_label_new (_("Clock tooltip format")); - gtk_misc_set_alignment (GTK_MISC (label), 0, 0); - gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, 2, 3, 0, 1, GTK_FILL, 0, 0, 0); - - clock_format_tooltip = gtk_entry_new (); - gtk_widget_show (clock_format_tooltip); - gtk_entry_set_width_chars (GTK_ENTRY (clock_format_tooltip), 16); - gtk_table_attach (GTK_TABLE (table), clock_format_tooltip, 3, 4, 0, 1, GTK_FILL, 0, 0, 0); - - label = gtk_label_new (_("Clock tooltip timezone")); - gtk_misc_set_alignment (GTK_MISC (label), 0, 0); - gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, 2, 3, 1, 2, GTK_FILL, 0, 0, 0); - - 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, 3, 4, 1, 2, GTK_FILL, 0, 0, 0); + gtk_widget_show(tooltip_font_color); + gtk_table_attach(GTK_TABLE(table), tooltip_font_color, 7, 8, 1, 2, GTK_FILL, 0, 0, 0); change_paragraph(parent); } - - -void create_background(GtkWidget *parent) -{ - - change_paragraph(parent); -} - diff --git a/src/tint2conf/properties.h b/src/tint2conf/properties.h index e9bec9c..9238441 100644 --- a/src/tint2conf/properties.h +++ b/src/tint2conf/properties.h @@ -3,49 +3,152 @@ #define PROPERTIES #include +#include +#include + +#include "../launcher/icon-theme-common.h" + // panel -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 *items_order; +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; + +enum { + itemsColName = 0, + itemsColValue, + itemsNumCols +}; +extern GtkListStore *panel_items, *all_items; +extern GtkWidget *panel_items_view, *all_items_view; +char *get_panel_items(); +void set_panel_items(const char *items); + +extern GtkWidget *screen_position[12]; +extern GSList *screen_position_group; +extern GtkWidget *panel_background; + +#define POS_TLH 0 +#define POS_TCH 1 +#define POS_TRH 2 + +#define POS_TLV 3 +#define POS_CLV 4 +#define POS_BLV 5 + +#define POS_TRV 6 +#define POS_CRV 7 +#define POS_BRV 8 + +#define POS_BLH 9 +#define POS_BCH 10 +#define POS_BRH 11 // taskbar -GtkWidget *taskbar_show_desktop, *taskbar_show_name, *taskbar_padding_x, *taskbar_padding_y, *taskbar_spacing; -GtkWidget *taskbar_name_padding_x, *taskbar_name_inactive_color, *taskbar_name_active_color, *taskbar_name_font; +extern GtkWidget *taskbar_show_desktop, *taskbar_show_name, *taskbar_padding_x, *taskbar_padding_y, *taskbar_spacing; +extern GtkWidget *taskbar_name_padding_x, *taskbar_name_inactive_color, *taskbar_name_active_color, *taskbar_name_font; +extern GtkWidget *taskbar_active_background, *taskbar_inactive_background; +extern GtkWidget *taskbar_name_active_background, *taskbar_name_inactive_background; // task -GtkWidget *task_mouse_middle, *task_mouse_right, *task_mouse_scroll_up, *task_mouse_scroll_down; -GtkWidget *task_show_icon, *task_show_text, *task_align_center, *task_font_shadow; -GtkWidget *task_maximum_width, *task_maximum_height, *task_padding_x, *task_padding_y, *task_font; +extern GtkWidget *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, *task_font_shadow; +extern GtkWidget *task_maximum_width, *task_maximum_height, *task_padding_x, *task_padding_y, *task_font; +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; // clock -GtkWidget *clock_format_line1, *clock_format_line2, *clock_tmz_line1, *clock_tmz_line2; -GtkWidget *clock_left_command, *clock_right_command; -GtkWidget *clock_padding_x, *clock_padding_y, *clock_font_line1, *clock_font_line2, *clock_font_color; +extern GtkWidget *clock_format_line1, *clock_format_line2, *clock_tmz_line1, *clock_tmz_line2; +extern GtkWidget *clock_left_command, *clock_right_command; +extern GtkWidget *clock_padding_x, *clock_padding_y, *clock_font_line1, *clock_font_line2, *clock_font_color; +extern GtkWidget *clock_background; // battery -GtkWidget *battery_hide_if_higher, *battery_alert_if_lower, *battery_alert_cmd; -GtkWidget *battery_padding_x, *battery_padding_y, *battery_font_line1, *battery_font_line2, *battery_font_color; +extern GtkWidget *battery_hide_if_higher, *battery_alert_if_lower, *battery_alert_cmd; +extern GtkWidget *battery_padding_x, *battery_padding_y, *battery_font_line1, *battery_font_line2, *battery_font_color; +extern GtkWidget *battery_background; // systray -GtkWidget *systray_icon_order, *systray_padding_x, *systray_padding_y, *systray_spacing; -GtkWidget *systray_icon_size, *systray_icon_opacity, *systray_icon_saturation, *systray_icon_brightness; +extern GtkWidget *systray_icon_order, *systray_padding_x, *systray_padding_y, *systray_spacing; +extern GtkWidget *systray_icon_size, *systray_icon_opacity, *systray_icon_saturation, *systray_icon_brightness; +extern GtkWidget *systray_background; // tooltip -GtkWidget *tooltip_padding_x, *tooltip_padding_y, *tooltip_font, *tooltip_font_color; -GtkWidget *tooltip_task_show, *tooltip_show_after, *tooltip_hide_after; -GtkWidget *clock_format_tooltip, *clock_tmz_tooltip; +extern GtkWidget *tooltip_padding_x, *tooltip_padding_y, *tooltip_font, *tooltip_font_color; +extern GtkWidget *tooltip_task_show, *tooltip_show_after, *tooltip_hide_after; +extern GtkWidget *clock_format_tooltip, *clock_tmz_tooltip; +extern GtkWidget *tooltip_background; // launcher -GtkWidget *launcher_icon_size, *launcher_icon_theme, *launcher_padding_x, *launcher_padding_y, *launcher_spacing; + +enum { + appsColIcon = 0, + appsColIconName, + appsColText, + appsColPath, + appsNumCols +}; + +extern GtkListStore *launcher_apps, *all_apps; +extern GtkWidget *launcher_apps_view, *all_apps_view; + +extern GtkWidget *launcher_icon_size, *launcher_icon_theme, *launcher_padding_x, *launcher_padding_y, *launcher_spacing; +extern GtkWidget *margin_x, *margin_y; +extern GtkWidget *launcher_background; + +extern IconThemeWrapper *icon_theme; + +void load_desktop_file(const char *file, gboolean selected); +void set_current_icon_theme(const char *theme); +gchar *get_current_icon_theme(); // background -GtkWidget *combo_background; -GtkWidget *margin_x, *margin_y; +enum { + bgColPixbuf = 0, + bgColFillColor, + bgColFillOpacity, + bgColBorderColor, + bgColBorderOpacity, + bgColBorderWidth, + bgColCornerRadius, + bgNumCols +}; + +extern GtkListStore *backgrounds; +extern GtkWidget *current_background, + *background_fill_color, + *background_border_color, + *background_border_width, + *background_corner_radius; + +void background_create_new(); +void background_force_update(); +int background_index_safe(int index); GtkWidget *create_properties(); - #endif - diff --git a/src/tint2conf/properties_rw.c b/src/tint2conf/properties_rw.c index a82a9fa..f45c08b 100644 --- a/src/tint2conf/properties_rw.c +++ b/src/tint2conf/properties_rw.c @@ -9,140 +9,683 @@ #include "properties_rw.h" -void add_entry (char *key, char *value); +void add_entry(char *key, char *value); void hex2gdk(char *hex, GdkColor *color); void get_action(char *event, GtkWidget *combo); - -void config_read_file (const char *path) +void config_read_file(const char *path) { FILE *fp; char line[512]; char *key, *value; - if ((fp = fopen(path, "r")) == NULL) return; + if ((fp = fopen(path, "r")) == NULL) + return; while (fgets(line, sizeof(line), fp) != NULL) { if (parse_line(line, &key, &value)) { - add_entry (key, value); - free (key); - free (value); + add_entry(key, value); + free(key); + free(value); } } - fclose (fp); + fclose(fp); } +void config_write_color(FILE *fp, 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); +} + +void config_write_backgrounds(FILE *fp) +{ + fprintf(fp, "#--------------------------------\n"); + fprintf(fp, "# Backgrounds\n"); + + 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); + + if (!found) { + break; + } + + int r; + int b; + GdkColor *fillColor; + int fillOpacity; + GdkColor *borderColor; + int borderOpacity; + + gtk_tree_model_get(GTK_TREE_MODEL(backgrounds), &iter, + bgColFillColor, &fillColor, + bgColFillOpacity, &fillOpacity, + bgColBorderColor, &borderColor, + bgColBorderOpacity, &borderOpacity, + bgColBorderWidth, &b, + bgColCornerRadius, &r, + -1); + fprintf(fp, "#%d\n", index + 1); + fprintf(fp, "rounded = %d\n", r); + fprintf(fp, "border_width = %d\n", b); + config_write_color(fp, "background_color", *fillColor, fillOpacity); + config_write_color(fp, "border_color", *borderColor, borderOpacity); + 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", 1 + 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_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, "center"); + } 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, "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, "\n"); +} + +void config_write_taskbar(FILE *fp) +{ + 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_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", 1 + gtk_combo_box_get_active(GTK_COMBO_BOX(taskbar_inactive_background))); + fprintf(fp, "taskbar_active_background_id = %d\n", 1 + 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_name_padding = %d\n", + (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(taskbar_name_padding_x))); + fprintf(fp, "taskbar_name_background_id = %d\n", 1 + gtk_combo_box_get_active(GTK_COMBO_BOX(taskbar_name_inactive_background))); + fprintf(fp, "taskbar_name_active_background_id = %d\n", 1 + gtk_combo_box_get_active(GTK_COMBO_BOX(taskbar_name_active_background))); + 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); + + 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, "\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); +} + +void config_write_task_icon_osb(FILE *fp, + char *name, + 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))); +} + +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, 1 + 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, "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, "font_shadow = %d\n", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(task_font_shadow)) ? 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\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))); + 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_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); + } + + fprintf(fp, "\n"); +} + +void config_write_systray(FILE *fp) +{ + 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", 1 + 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_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, "\n"); +} + +void config_write_launcher(FILE *fp) +{ + 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", 1 + gtk_combo_box_get_active(GTK_COMBO_BOX(launcher_background))); + fprintf(fp, "launcher_icon_size = %d\n", (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(launcher_icon_size))); + gchar *icon_theme = get_current_icon_theme(); + if (icon_theme) { + fprintf(fp, "launcher_icon_theme = %s\n", icon_theme); + g_free(icon_theme); + icon_theme = NULL; + } + + 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); + + if (!found) { + break; + } + + gchar *app_path; + gtk_tree_model_get(GTK_TREE_MODEL(launcher_apps), &iter, + appsColPath, &app_path, + -1); + fprintf(fp, "launcher_item_app = %s\n", app_path); + g_free(app_path); + } + + fprintf(fp, "\n"); +} + +void config_write_clock(FILE *fp) +{ + 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))); + 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))); + 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); + + 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_x))); + fprintf(fp, "clock_background_id = %d\n", 1 + 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, "\n"); +} + +void config_write_battery(FILE *fp) +{ + fprintf(fp, "#--------------------------------\n"); + fprintf(fp, "# Battery\n"); + + 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))); + fprintf(fp, "bat1_font = %s\n", gtk_font_button_get_font_name(GTK_FONT_BUTTON(battery_font_line1))); + 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", 1 + 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, "\n"); +} + +void config_write_tooltip(FILE *fp) +{ + 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", 1 + 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); + + fprintf(fp, "tooltip_font = %s\n", gtk_font_button_get_font_name(GTK_FONT_BUTTON(tooltip_font))); + + fprintf(fp, "\n"); +} void config_save_file(const char *path) { - //printf("config_save_file : %s\n", path); + printf("config_save_file : %s\n", path); + fflush(stdout); + + FILE *fp; + if ((fp = fopen(path, "wt")) == NULL) + return; + + fprintf(fp, "#---- Generated by tint2conf ----\n"); + + 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_tooltip(fp); + + fclose(fp); } +gboolean config_is_manual(const char *path) +{ + FILE *fp; + char line[512]; + gboolean result; -void add_entry (char *key, char *value) + if ((fp = fopen(path, "r")) == NULL) + return FALSE; + + result = TRUE; + if (fgets(line, sizeof(line), fp) != NULL) { + if (g_str_equal(line, "#---- Generated by tint2conf ----\n")) { + result = FALSE; + } + } + fclose(fp); + return result; +} + +void add_entry(char *key, char *value) { char *value1=0, *value2=0, *value3=0; /* Background and border */ - if (strcmp (key, "rounded") == 0) { + if (strcmp(key, "rounded") == 0) { // 'rounded' is the first parameter => alloc a new background - //Background bg; - //bg.border.rounded = atoi(value); - //g_array_append_val(backgrounds, bg); + background_create_new(); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(background_corner_radius), atoi(value)); + background_force_update(); } - else if (strcmp (key, "border_width") == 0) { - //g_array_index(backgrounds, Background, backgrounds->len-1).border.width = atoi(value); + 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) { + else if (strcmp(key, "background_color") == 0) { extract_values(value, &value1, &value2, &value3); - //Background* bg = &g_array_index(backgrounds, Background, backgrounds->len-1); - //get_color (value1, bg->back.color); - //if (value2) bg->back.alpha = (atoi (value2) / 100.0); - //else bg->back.alpha = 0.5; + 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) { + else if (strcmp(key, "border_color") == 0) { extract_values(value, &value1, &value2, &value3); - //Background* bg = &g_array_index(backgrounds, Background, backgrounds->len-1); - //get_color (value1, bg->border.color); - //if (value2) bg->border.alpha = (atoi (value2) / 100.0); - //else bg->border.alpha = 0.5; + 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(); } /* Panel */ - else if (strcmp (key, "panel_size") == 0) { + else if (strcmp(key, "panel_size") == 0) { extract_values(value, &value1, &value2, &value3); char *b; - if ((b = strchr (value1, '%'))) { + 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), atof(value1)); + 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, '%'))) { + 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), atof(value2)); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(panel_height), atoi(value2)); } - else if (strcmp (key, "panel_items") == 0) { - gtk_entry_set_text(GTK_ENTRY(items_order), value); + else if (strcmp(key, "panel_items") == 0) { + set_panel_items(value); } - else if (strcmp (key, "panel_margin") == 0) { + else if (strcmp(key, "panel_margin") == 0) { extract_values(value, &value1, &value2, &value3); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(panel_margin_x), atof(value1)); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(panel_margin_y), atof(value1)); + 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(value1)); } - else if (strcmp (key, "panel_padding") == 0) { + else if (strcmp(key, "panel_padding") == 0) { extract_values(value, &value1, &value2, &value3); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(panel_padding_x), atof(value1)); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(panel_spacing), atof(value1)); - if (value2) gtk_spin_button_set_value(GTK_SPIN_BUTTON(panel_padding_y), atof(value2)); - if (value3) gtk_spin_button_set_value(GTK_SPIN_BUTTON(panel_spacing), atof(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) { + else if (strcmp(key, "panel_position") == 0) { 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; + + char vpos, hpos, orientation; + + 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 (!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 (value2) { + if (strcmp(value2, "left") == 0) + hpos = 'L'; + if (strcmp(value2, "right") == 0) + hpos = 'R'; + if (strcmp(value2, "center") == 0) + hpos = 'C'; } - if (!value3) panel_horizontal = 1; - else { - if (strcmp (value3, "vertical") == 0) panel_horizontal = 0; - else panel_horizontal = 1; + + 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 == '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 == '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 = atoi (value); - //id = (id < backgrounds->len && id >= 0) ? id : 0; - //panel_config.area.bg = &g_array_index(backgrounds, Background, id); + 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, "wm_menu") == 0) { + 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) { + 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) { + 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) @@ -150,8 +693,23 @@ void add_entry (char *key, char *value) else gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_layer), 1); } - else if (strcmp (key, "panel_monitor") == 0) { - //panel_config.monitor = config_get_monitor(value); + 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, "0") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_monitor), 1); + else if (strcmp(value, "1") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_monitor), 2); + else if (strcmp(value, "2") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_monitor), 3); + else if (strcmp(value, "3") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_monitor), 4); + else if (strcmp(value, "4") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_monitor), 5); + else if (strcmp(value, "5") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_monitor), 6); + else if (strcmp(value, "6") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_monitor), 7); } /* autohide options */ @@ -173,28 +731,28 @@ void add_entry (char *key, char *value) gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_strut_policy), 1); } else if (strcmp(key, "autohide_height") == 0) { - if (atoi(value) == 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)); } - else - gtk_spin_button_set_value(GTK_SPIN_BUTTON(panel_autohide_size), atof(value)); } /* Battery */ - else if (strcmp (key, "battery_low_status") == 0) { + 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) { + 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) { + else if (strcmp(key, "bat1_font") == 0) { gtk_font_button_set_font_name(GTK_FONT_BUTTON(battery_font_line1), value); } - else if (strcmp (key, "bat2_font") == 0) { + else if (strcmp(key, "bat2_font") == 0) { gtk_font_button_set_font_name(GTK_FONT_BUTTON(battery_font_line2), value); } - else if (strcmp (key, "battery_font_color") == 0) { + else if (strcmp(key, "battery_font_color") == 0) { extract_values(value, &value1, &value2, &value3); GdkColor col; hex2gdk(value1, &col); @@ -204,32 +762,31 @@ void add_entry (char *key, char *value) gtk_color_button_set_alpha(GTK_COLOR_BUTTON(battery_font_color), (alpha*65535)/100); } } - else if (strcmp (key, "battery_padding") == 0) { + else if (strcmp(key, "battery_padding") == 0) { extract_values(value, &value1, &value2, &value3); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(battery_padding_x), atof(value1)); - if (value2) gtk_spin_button_set_value(GTK_SPIN_BUTTON(battery_padding_y), atof(value2)); + 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 = atoi (value); - //id = (id < backgrounds->len && id >= 0) ? id : 0; - //panel_config.battery.area.bg = &g_array_index(backgrounds, Background, id); + 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); + 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), atof(value)); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(battery_hide_if_higher), atoi(value)); } /* Clock */ - else if (strcmp (key, "time1_format") == 0) { + else if (strcmp(key, "time1_format") == 0) { gtk_entry_set_text(GTK_ENTRY(clock_format_line1), value); } - else if (strcmp (key, "time2_format") == 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) { + else if (strcmp(key, "time1_font") == 0) { gtk_font_button_set_font_name(GTK_FONT_BUTTON(clock_font_line1), value); } else if (strcmp(key, "time1_timezone") == 0) { @@ -238,10 +795,10 @@ void add_entry (char *key, char *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) { + else if (strcmp(key, "time2_font") == 0) { gtk_font_button_set_font_name(GTK_FONT_BUTTON(clock_font_line2), value); } - else if (strcmp (key, "clock_font_color") == 0) { + else if (strcmp(key, "clock_font_color") == 0) { extract_values(value, &value1, &value2, &value3); GdkColor col; hex2gdk(value1, &col); @@ -251,15 +808,14 @@ void add_entry (char *key, char *value) gtk_color_button_set_alpha(GTK_COLOR_BUTTON(clock_font_color), (alpha*65535)/100); } } - else if (strcmp (key, "clock_padding") == 0) { + else if (strcmp(key, "clock_padding") == 0) { extract_values(value, &value1, &value2, &value3); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(clock_padding_x), atof(value1)); - if (value2) gtk_spin_button_set_value(GTK_SPIN_BUTTON(clock_padding_y), atof(value2)); + 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 = 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_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); @@ -275,54 +831,50 @@ void add_entry (char *key, char *value) } /* Taskbar */ - else if (strcmp (key, "taskbar_mode") == 0) { - if (strcmp (value, "multi_desktop") == 0) + 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_padding") == 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), atof(value1)); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(taskbar_spacing), atof(value1)); - if (value2) gtk_spin_button_set_value(GTK_SPIN_BUTTON(taskbar_padding_y), atof(value2)); - if (value3) gtk_spin_button_set_value(GTK_SPIN_BUTTON(taskbar_spacing), atof(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 = 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_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 = 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_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) { + 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_name_padding") == 0) { + 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), atof(value1)); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(taskbar_name_padding_x), atoi(value1)); } - 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_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 = 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_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) { + else if (strcmp(key, "taskbar_name_font") == 0) { gtk_font_button_set_font_name(GTK_FONT_BUTTON(taskbar_name_font), value); } - else if (strcmp (key, "taskbar_name_font_color") == 0) { + else if (strcmp(key, "taskbar_name_font_color") == 0) { extract_values(value, &value1, &value2, &value3); GdkColor col; hex2gdk(value1, &col); @@ -332,7 +884,7 @@ void add_entry (char *key, char *value) 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) { + else if (strcmp(key, "taskbar_name_active_font_color") == 0) { extract_values(value, &value1, &value2, &value3); GdkColor col; hex2gdk(value1, &col); @@ -344,92 +896,152 @@ void add_entry (char *key, char *value) } /* Task */ - else if (strcmp (key, "task_text") == 0) { + 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) { + 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) { + else if (strcmp(key, "task_centered") == 0) { gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(task_align_center), atoi(value)); } - else if (strcmp (key, "font_shadow") == 0) { + else if (strcmp(key, "font_shadow") == 0) { gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(task_font_shadow), atoi(value)); } - else if (strcmp (key, "urgent_nb_of_blink") == 0) { - //max_tick_urgent = 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) { + else if (strcmp(key, "task_width") == 0) { // old parameter : just for backward compatibility - gtk_spin_button_set_value(GTK_SPIN_BUTTON(task_maximum_width), atof(value)); + 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) { + 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), atof(value1)); + 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), atof(value2)); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(task_maximum_height), atoi(value2)); } - else if (strcmp (key, "task_padding") == 0) { + else if (strcmp(key, "task_padding") == 0) { extract_values(value, &value1, &value2, &value3); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(task_padding_x), atof(value1)); - if (value2) gtk_spin_button_set_value(GTK_SPIN_BUTTON(task_padding_y), atof(value2)); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(task_padding_x), atoi(value1)); + if (value2) gtk_spin_button_set_value(GTK_SPIN_BUTTON(task_padding_y), atoi(value2)); } - else if (strcmp (key, "task_font") == 0) { + else if (strcmp(key, "task_font") == 0) { gtk_font_button_set_font_name(GTK_FONT_BUTTON(task_font), value); } else if (g_regex_match_simple("task.*_font_color", key, 0, 0)) { - /*gchar** split = g_regex_split_simple("_", key, 0, 0); - int status = get_task_status(split[1]); + 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); - 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].color); - panel_config.g_task.font[status].alpha = alpha; - panel_config.g_task.config_font_mask |= (1<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<len && id >= 0) ? id : 0; - //systray.area.bg = &g_array_index(backgrounds, Background, id); + 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) @@ -442,58 +1054,55 @@ void add_entry (char *key, char *value) 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), atof(value)); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(systray_icon_size), atoi(value)); } 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), atof(value1)); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(systray_icon_saturation), atof(value2)); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(systray_icon_brightness), atof(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)); } /* Launcher */ - else if (strcmp (key, "launcher_padding") == 0) { + else if (strcmp(key, "launcher_padding") == 0) { extract_values(value, &value1, &value2, &value3); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(launcher_padding_x), atof(value1)); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(launcher_spacing), atof(value1)); - if (value2) gtk_spin_button_set_value(GTK_SPIN_BUTTON(launcher_padding_y), atof(value2)); - if (value3) gtk_spin_button_set_value(GTK_SPIN_BUTTON(launcher_spacing), atof(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 = 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_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_size") == 0) { - gtk_spin_button_set_value(GTK_SPIN_BUTTON(launcher_icon_size), atof(value)); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(launcher_icon_size), atoi(value)); } else if (strcmp(key, "launcher_item_app") == 0) { - //char *app = strdup(value); - //panel_config.launcher.list_apps = g_slist_append(panel_config.launcher.list_apps, app); + load_desktop_file(value, TRUE); + load_desktop_file(value, FALSE); } else if (strcmp(key, "launcher_icon_theme") == 0) { - // if XSETTINGS manager running, tint2 use it. - //icon_theme_name = strdup(value); + set_current_icon_theme(value); } /* Tooltip */ - else if (strcmp (key, "tooltip_show_timeout") == 0) { + 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) { + 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) { + else if (strcmp(key, "tooltip_padding") == 0) { extract_values(value, &value1, &value2, &value3); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(tooltip_padding_x), atof(value1)); - if (value2) gtk_spin_button_set_value(GTK_SPIN_BUTTON(tooltip_padding_y), atof(value2)); + 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 = atoi (value); - //id = (id < backgrounds->len && id >= 0) ? id : 0; - //g_tooltip.bg = &g_array_index(backgrounds, Background, id); + 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) { + else if (strcmp(key, "tooltip_font_color") == 0) { extract_values(value, &value1, &value2, &value3); GdkColor col; hex2gdk(value1, &col); @@ -503,63 +1112,61 @@ void add_entry (char *key, char *value) gtk_color_button_set_alpha(GTK_COLOR_BUTTON(tooltip_font_color), (alpha*65535)/100); } } - else if (strcmp (key, "tooltip_font") == 0) { + else if (strcmp(key, "tooltip_font") == 0) { gtk_font_button_set_font_name(GTK_FONT_BUTTON(tooltip_font), value); } /* Mouse actions */ - else if (strcmp (key, "mouse_middle") == 0) { + else if (strcmp(key, "mouse_middle") == 0) { get_action(value, task_mouse_middle); } - else if (strcmp (key, "mouse_right") == 0) { + else if (strcmp(key, "mouse_right") == 0) { get_action(value, task_mouse_right); } - else if (strcmp (key, "mouse_scroll_up") == 0) { + else if (strcmp(key, "mouse_scroll_up") == 0) { get_action(value, task_mouse_scroll_up); } - else if (strcmp (key, "mouse_scroll_down") == 0) { + else if (strcmp(key, "mouse_scroll_down") == 0) { get_action(value, task_mouse_scroll_down); } - 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; - 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->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 get_action(char *event, GtkWidget *combo) { - if (strcmp (event, "none") == 0) + if (strcmp(event, "none") == 0) gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0); - else if (strcmp (event, "close") == 0) + else if (strcmp(event, "close") == 0) gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 1); - else if (strcmp (event, "toggle") == 0) + else if (strcmp(event, "toggle") == 0) gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 2); - else if (strcmp (event, "iconify") == 0) + else if (strcmp(event, "iconify") == 0) gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 3); - else if (strcmp (event, "shade") == 0) + else if (strcmp(event, "shade") == 0) gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 4); - else if (strcmp (event, "toggle_iconify") == 0) + else if (strcmp(event, "toggle_iconify") == 0) gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 5); - else if (strcmp (event, "maximize_restore") == 0) + else if (strcmp(event, "maximize_restore") == 0) gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 6); - else if (strcmp (event, "desktop_left") == 0) + else if (strcmp(event, "desktop_left") == 0) gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 7); - else if (strcmp (event, "desktop_right") == 0) + else if (strcmp(event, "desktop_right") == 0) gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 8); - else if (strcmp (event, "next_task") == 0) + else if (strcmp(event, "next_task") == 0) gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 9); - else if (strcmp (event, "prev_task") == 0) + else if (strcmp(event, "prev_task") == 0) gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 10); } - diff --git a/src/tint2conf/properties_rw.h b/src/tint2conf/properties_rw.h index 77f86e8..c62c4fe 100644 --- a/src/tint2conf/properties_rw.h +++ b/src/tint2conf/properties_rw.h @@ -1,11 +1,11 @@ - #ifndef PROPERTIES_RW #define PROPERTIES_RW +#include +char *get_current_theme_file_name(); +gboolean config_is_manual(const char *path); void config_read_file (const char *path); void config_save_file(const char *path); - #endif - diff --git a/src/tint2conf/theme_view.c b/src/tint2conf/theme_view.c index 05fad6b..d47ddc9 100644 --- a/src/tint2conf/theme_view.c +++ b/src/tint2conf/theme_view.c @@ -27,8 +27,6 @@ GtkListStore *g_store; int g_width_list, g_height_list; GtkCellRenderer *g_renderer; - - GtkWidget *create_view() { GtkTreeViewColumn *col; @@ -85,8 +83,6 @@ void custom_list_append(const gchar *name) gchar *b, *n; b = strrchr(name, '/'); n = g_strdup(b+1); - b = strrchr(n, '.'); - *b = '\0'; gtk_list_store_set(g_store, &iter, COL_THEME_NAME, n, -1); } @@ -96,7 +92,9 @@ gboolean update_snapshot() GtkTreeModel *model; GtkTreeIter iter; GdkPixbuf *icon; - gboolean have_iter, found = FALSE; + gboolean have_iter; + + gint pixWidth = 200, pixHeight = 30; model = gtk_tree_view_get_model(GTK_TREE_VIEW(g_theme_view)); have_iter = gtk_tree_model_get_iter_first(model, &iter); @@ -104,54 +102,42 @@ gboolean update_snapshot() gtk_tree_model_get(model, &iter, COL_SNAPSHOT, &icon, -1); if (icon != NULL) { g_object_unref(icon); - have_iter = gtk_tree_model_iter_next(model, &iter); } - else { - found = TRUE; - break; - } - } - if (found) { // build panel's snapshot - GdkPixbuf *pixbuf; + GdkPixbuf *pixbuf = NULL; gchar *name, *snap, *cmd; - gint pixWidth, pixHeight; - gboolean changeSize = FALSE; - snap = g_build_filename (g_get_user_config_dir(), "tint2", "snap.jpg", NULL); + snap = g_build_filename(g_get_user_config_dir(), "tint2", "snap.jpg", NULL); g_remove(snap); gtk_tree_model_get(model, &iter, COL_THEME_FILE, &name, -1); cmd = g_strdup_printf("tint2 -c \'%s\' -s \'%s\'", name, snap); - system(cmd); - - // load - pixbuf = gdk_pixbuf_new_from_file(snap, NULL); - if (pixbuf == NULL) { - printf("snapshot NULL : %s\n", cmd); - found = FALSE; + if (system(cmd) == 0) { + // load + pixbuf = gdk_pixbuf_new_from_file(snap, NULL); + if (pixbuf == NULL) { + printf("snapshot NULL : %s\n", cmd); + } } g_free(snap); g_free(cmd); g_free(name); - pixWidth = gdk_pixbuf_get_width(pixbuf); - pixHeight = gdk_pixbuf_get_height(pixbuf); - if (g_width_list != pixWidth) { - g_width_list = pixWidth; - changeSize = TRUE; - } - if (g_height_list != (pixHeight+30)) { - g_height_list = pixHeight+30; - changeSize = TRUE; - } - if (changeSize) - gtk_cell_renderer_set_fixed_size(g_renderer, g_width_list, g_height_list); + gint w, h; + w = gdk_pixbuf_get_width(pixbuf); + h = gdk_pixbuf_get_height(pixbuf); + pixWidth = w > pixWidth ? w : pixWidth; + pixHeight = h > pixHeight ? h : pixHeight; gtk_list_store_set(g_store, &iter, COL_SNAPSHOT, pixbuf, -1); + + have_iter = gtk_tree_model_iter_next(model, &iter); } - return found; + + gtk_cell_renderer_set_fixed_size(g_renderer, pixWidth + 30, pixHeight + 30); + + return FALSE; } diff --git a/src/tint2conf/theme_view.h b/src/tint2conf/theme_view.h index dc1c71d..023915e 100644 --- a/src/tint2conf/theme_view.h +++ b/src/tint2conf/theme_view.h @@ -12,8 +12,6 @@ GtkWidget *create_view(); void custom_list_append(const gchar *name); -gboolean update_snapshot(); - #endif diff --git a/src/tint2conf/tint2conf.desktop b/src/tint2conf/tint2conf.desktop index 16c49a5..6bfbde4 100644 --- a/src/tint2conf/tint2conf.desktop +++ b/src/tint2conf/tint2conf.desktop @@ -1,6 +1,5 @@ [Desktop Entry] Type=Application -Encoding=UTF-8 Name=Panel tint2 Name[am]=ፓነል tint2 Name[ar]=الشريط tint2