1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
3 handlers.h for ObConf, the configuration tool for Openbox
4 Copyright (c) 2003-2007 Dana Jansens
5 Copyright (c) 2003 Tim Riley
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 See the COPYING file for a copy of the GNU General Public License.
23 #include "openbox/render.h"
29 static gboolean mapping;
31 static GtkListStore *desktop_store;
32 static int num_desktops;
33 static GList *desktop_names;
34 static GtkListStore *theme_store;
36 static void on_desktop_names_cell_edited(GtkCellRendererText *cell,
37 const gchar *path_string,
38 const gchar *new_text,
41 static void on_theme_names_selection_changed(GtkTreeSelection *sel,
45 void setup_behavior_tab()
47 GtkWidget *winresist = glade_xml_get_widget(glade, "resist_window");
48 GtkWidget *edgeresist = glade_xml_get_widget(glade, "resist_edge");
49 GtkSizeGroup *group1 = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
51 gtk_size_group_add_widget(group1, winresist);
52 gtk_size_group_add_widget(group1, edgeresist);
54 GtkWidget *winresist_l = glade_xml_get_widget(glade, "resist_window_label");
55 GtkWidget *edgeresist_l = glade_xml_get_widget(glade, "resist_edge_label");
56 GtkSizeGroup *group2 = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
58 gtk_size_group_add_widget(group2, winresist_l);
59 gtk_size_group_add_widget(group2, edgeresist_l);
64 GtkWidget *posi = glade_xml_get_widget(glade, "dock_position");
65 GtkWidget *dir = glade_xml_get_widget(glade, "dock_direction");
66 GtkSizeGroup *group1 = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
68 gtk_size_group_add_widget(group1, posi);
69 gtk_size_group_add_widget(group1, dir);
71 GtkWidget *posi_l = glade_xml_get_widget(glade, "dock_position_label");
72 GtkWidget *dir_l = glade_xml_get_widget(glade, "dock_direction_label");
73 GtkSizeGroup *group2 = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
75 gtk_size_group_add_widget(group2, posi_l);
76 gtk_size_group_add_widget(group2, dir_l);
81 gboolean on_main_window_delete_event(GtkWidget *w, GdkEvent *e, gpointer d)
87 void on_close_clicked()
92 void on_about_clicked()
97 parent = glade_xml_get_widget(glade, "main_window");
98 about = glade_xml_get_widget(glade, "about_window");
100 gtk_window_set_transient_for(GTK_WINDOW(about), GTK_WINDOW(parent));
101 gtk_widget_show(about);
104 void on_about_close_clicked()
108 about = glade_xml_get_widget(glade, "about_window");
110 gtk_widget_hide(about);
113 void on_about_window_delete_event()
117 about = glade_xml_get_widget(glade, "about_window");
119 gtk_widget_hide(about);
122 void setup_focus_mouse(GtkWidget *w)
128 b = tree_get_bool("focus/followMouse", FALSE);
129 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), b);
132 GtkWidget *delay = glade_xml_get_widget(glade, "focus_delay");
133 GtkWidget *delay_l = glade_xml_get_widget(glade, "focus_delay_label");
134 GtkWidget *delay_u = glade_xml_get_widget(glade,
135 "focus_delay_label_units");
136 GtkWidget *raise = glade_xml_get_widget(glade, "focus_raise");
137 gtk_widget_set_sensitive(delay, b);
138 gtk_widget_set_sensitive(delay_l, b);
139 gtk_widget_set_sensitive(delay_u, b);
140 gtk_widget_set_sensitive(raise, b);
146 void setup_focus_delay(GtkWidget *w)
149 gtk_spin_button_set_value(GTK_SPIN_BUTTON(w),
150 tree_get_int("focus/focusDelay", 0));
154 void setup_focus_raise(GtkWidget *w)
157 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w),
158 tree_get_bool("focus/raiseOnFocus", FALSE));
162 void setup_focus_new(GtkWidget *w)
165 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w),
166 tree_get_bool("focus/focusNew", TRUE));
170 void setup_place_mouse(GtkWidget *w)
175 s = tree_get_string("placement/policy", "Smart");
176 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w),
177 !g_ascii_strcasecmp(s, "UnderMouse"));
182 void setup_resist_window(GtkWidget *w)
185 gtk_spin_button_set_value(GTK_SPIN_BUTTON(w),
186 tree_get_int("resistance/strength", 10));
190 void setup_resist_edge(GtkWidget *w)
193 gtk_spin_button_set_value(GTK_SPIN_BUTTON(w),
194 tree_get_int("resistance/screen_edge_strength",
199 void setup_resize_contents(GtkWidget *w)
202 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w),
203 tree_get_bool("resize/drawContents", TRUE));
207 void setup_dock_position(GtkWidget *w)
214 s = tree_get_string("dock/position", "TopLeft");
217 if (!strcasecmp(s, "Top"))
218 gtk_option_menu_set_history(GTK_OPTION_MENU(w), 1);
219 else if (!strcasecmp(s, "TopRight"))
220 gtk_option_menu_set_history(GTK_OPTION_MENU(w), 2);
221 else if (!strcasecmp(s, "Left"))
222 gtk_option_menu_set_history(GTK_OPTION_MENU(w), 3);
223 else if (!strcasecmp(s, "Right"))
224 gtk_option_menu_set_history(GTK_OPTION_MENU(w), 4);
225 else if (!strcasecmp(s, "BottomLeft"))
226 gtk_option_menu_set_history(GTK_OPTION_MENU(w), 5);
227 else if (!strcasecmp(s, "Bottom"))
228 gtk_option_menu_set_history(GTK_OPTION_MENU(w), 6);
229 else if (!strcasecmp(s, "BottomRight"))
230 gtk_option_menu_set_history(GTK_OPTION_MENU(w), 7);
231 else if (!strcasecmp(s, "Floating")) {
232 gtk_option_menu_set_history(GTK_OPTION_MENU(w), 8);
235 gtk_option_menu_set_history(GTK_OPTION_MENU(w), 0);
240 s = glade_xml_get_widget(glade, "dock_float_x");
241 gtk_widget_set_sensitive(s, f);
242 s = glade_xml_get_widget(glade, "dock_float_y");
243 gtk_widget_set_sensitive(s, f);
244 s = glade_xml_get_widget(glade, "dock_float_label");
245 gtk_widget_set_sensitive(s, f);
246 s = glade_xml_get_widget(glade, "dock_float_label_x");
247 gtk_widget_set_sensitive(s, f);
253 void setup_dock_float_x(GtkWidget *w)
257 gtk_spin_button_set_value(GTK_SPIN_BUTTON(w),
258 tree_get_int("dock/floatingX", 0));
263 void setup_dock_float_y(GtkWidget *w)
267 gtk_spin_button_set_value(GTK_SPIN_BUTTON(w),
268 tree_get_int("dock/floatingY", 0));
273 void setup_dock_stacking(GtkWidget *top, GtkWidget *normal, GtkWidget *bottom)
279 s = tree_get_string("dock/stacking", "Top");
281 if(!strcasecmp(s, "Normal"))
282 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(normal), TRUE);
283 else if(!strcasecmp(s, "Bottom"))
284 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(bottom), TRUE);
286 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(top), TRUE);
292 void setup_dock_direction(GtkWidget *w)
298 s = tree_get_string("dock/direction", "Vertical");
300 if (!strcasecmp(s, "Horizontal"))
301 gtk_option_menu_set_history(GTK_OPTION_MENU(w), 1);
303 gtk_option_menu_set_history(GTK_OPTION_MENU(w), 0);
309 void setup_dock_hide(GtkWidget *w)
315 b = tree_get_bool("dock/autoHide", FALSE);
316 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), b);
319 GtkWidget *delay = glade_xml_get_widget(glade, "dock_hide_delay");
320 GtkWidget *delay_l = glade_xml_get_widget(glade, "dock_hide_label");
321 GtkWidget *delay_u = glade_xml_get_widget(glade,
322 "dock_hide_label_units");
323 gtk_widget_set_sensitive(delay, b);
324 gtk_widget_set_sensitive(delay_l, b);
325 gtk_widget_set_sensitive(delay_u, b);
331 void setup_dock_hide_delay(GtkWidget *w)
335 gtk_spin_button_set_value(GTK_SPIN_BUTTON(w),
336 tree_get_int("dock/hideDelay", 300));
341 static void add_theme_dir(const gchar *dirname)
346 if ((dir = g_dir_open(dirname, 0, NULL))) {
347 while ((n = g_dir_read_name(dir))) {
350 full = g_build_filename(dirname, n, "openbox-3",
352 if (!g_file_test(full,
353 G_FILE_TEST_IS_REGULAR |
354 G_FILE_TEST_IS_SYMLINK))
360 themes = g_list_append(themes, g_strdup(n));
367 void setup_theme_names(GtkWidget *w)
369 GtkCellRenderer *render;
370 GtkTreeViewColumn *column;
375 GtkTreeSelection *select;
379 name = tree_get_string("theme/name", "TheBear");
381 for (it = themes; it; it = g_list_next(it))
382 g_list_free(it->data);
386 p = g_build_filename(g_get_home_dir(), ".themes", NULL);
392 for (it = parse_xdg_data_dir_paths(); it; it = g_slist_next(it)) {
393 p = g_build_filename(it->data, "themes", NULL);
399 add_theme_dir(THEMEDIR);
401 themes = g_list_sort(themes, (GCompareFunc) strcasecmp);
404 theme_store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_BOOLEAN);
405 gtk_tree_view_set_model(GTK_TREE_VIEW(w), GTK_TREE_MODEL(theme_store));
406 g_object_unref (theme_store);
408 gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(w)),
409 GTK_SELECTION_SINGLE);
411 render = gtk_cell_renderer_text_new();
412 column = gtk_tree_view_column_new_with_attributes
413 ("Name", render, "text", 0, NULL);
414 gtk_tree_view_append_column(GTK_TREE_VIEW(w), column);
416 /* return to regular scheduled programming */
418 for (it = themes; it; it = next) {
421 next = g_list_next(it);
423 /* remove duplicates */
424 if (next && !strcmp(it->data, next->data)) {
426 themes = g_list_delete_link(themes, it);
430 gtk_list_store_append(theme_store, &iter);
431 gtk_list_store_set(theme_store, &iter,
436 if(!strcmp(name, it->data)) {
438 path = gtk_tree_path_new_from_indices(i, -1);
439 gtk_tree_view_set_cursor(GTK_TREE_VIEW(w), path, NULL, FALSE);
446 /* setup the selection handler */
447 select = gtk_tree_view_get_selection(GTK_TREE_VIEW (w));
448 gtk_tree_selection_set_mode(select, GTK_SELECTION_SINGLE);
449 g_signal_connect (G_OBJECT(select), "changed",
450 G_CALLBACK(on_theme_names_selection_changed),
458 void setup_title_layout(GtkWidget *w)
464 layout = tree_get_string("theme/titleLayout", "NLIMC");
465 gtk_entry_set_text(GTK_ENTRY(w), layout);
471 void setup_desktop_num(GtkWidget *w)
475 num_desktops = tree_get_int("desktops/number", 4);
476 gtk_spin_button_set_value(GTK_SPIN_BUTTON(w), num_desktops);
481 void setup_window_border(GtkWidget *w)
487 border = tree_get_bool("theme/keepBorder", TRUE);
488 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), border);
493 void setup_font_active(GtkWidget *w)
496 gchar *name, **names;
503 name = tree_get_string("theme/font:place=ActiveWindow/name", "Sans");
504 size = tree_get_string("theme/font:place=ActiveWindow/size", "8");
505 weight = tree_get_string("theme/font:place=ActiveWindow/weight", "");
506 slant = tree_get_string("theme/font:place=ActiveWindow/slant", "");
508 /* get only the first font in the string */
509 names = g_strsplit(name, ",", 0);
511 name = g_strdup(names[0]);
514 fontstring = g_strdup_printf("%s %s %s %s", name, weight, slant, size);
515 gtk_font_button_set_font_name(GTK_FONT_BUTTON(w), fontstring);
525 void setup_font_inactive(GtkWidget *w)
528 gchar *name, **names;
535 name = tree_get_string("theme/font:place=InactiveWindow/name", "Sans");
536 size = tree_get_string("theme/font:place=InactiveWindow/size", "8");
537 weight = tree_get_string("theme/font:place=InactiveWindow/weight", "");
538 slant = tree_get_string("theme/font:place=InactiveWindow/slant", "");
540 /* get only the first font in the string */
541 names = g_strsplit(name, ",", 0);
543 name = g_strdup(names[0]);
546 fontstring = g_strdup_printf("%s %s %s %s", name, weight, slant, size);
547 gtk_font_button_set_font_name(GTK_FONT_BUTTON(w), fontstring);
557 void setup_font_menu_header(GtkWidget *w)
560 gchar *name, **names;
567 name = tree_get_string("theme/font:place=MenuHeader/name", "Sans");
568 size = tree_get_string("theme/font:place=MenuHeader/size", "8");
569 weight = tree_get_string("theme/font:place=MenuHeader/weight", "");
570 slant = tree_get_string("theme/font:place=MenuHeader/slant", "");
572 /* get only the first font in the string */
573 names = g_strsplit(name, ",", 0);
575 name = g_strdup(names[0]);
578 fontstring = g_strdup_printf("%s %s %s %s", name, weight, slant, size);
579 gtk_font_button_set_font_name(GTK_FONT_BUTTON(w), fontstring);
589 void setup_font_menu_item(GtkWidget *w)
592 gchar *name, **names;
599 name = tree_get_string("theme/font:place=MenuItem/name", "Sans");
600 size = tree_get_string("theme/font:place=MenuItem/size", "8");
601 weight = tree_get_string("theme/font:place=MenuItem/weight", "");
602 slant = tree_get_string("theme/font:place=MenuItem/slant", "");
604 /* get only the first font in the string */
605 names = g_strsplit(name, ",", 0);
607 name = g_strdup(names[0]);
610 fontstring = g_strdup_printf("%s %s %s %s", name, weight, slant, size);
611 gtk_font_button_set_font_name(GTK_FONT_BUTTON(w), fontstring);
621 void setup_font_display(GtkWidget *w)
624 gchar *name, **names;
631 name = tree_get_string("theme/font:place=OnScreenDisplay/name", "Sans");
632 size = tree_get_string("theme/font:place=OnScreenDisplay/size", "8");
633 weight = tree_get_string("theme/font:place=OnScreenDisplay/weight", "");
634 slant = tree_get_string("theme/font:place=OnScreenDisplay/slant", "");
636 /* get only the first font in the string */
637 names = g_strsplit(name, ",", 0);
639 name = g_strdup(names[0]);
642 fontstring = g_strdup_printf("%s %s %s %s", name, weight, slant, size);
643 gtk_font_button_set_font_name(GTK_FONT_BUTTON(w), fontstring);
653 static void reset_desktop_names()
660 gtk_list_store_clear(desktop_store);
662 for (lit = desktop_names; lit; lit = g_list_next(lit))
664 g_list_free(desktop_names);
665 desktop_names = NULL;
668 n = tree_get_node("desktops/names", NULL)->children;
672 if (!xmlStrcmp(n->name, (const xmlChar*)"name")) {
673 name = parse_string(doc, n);
675 desktop_names = g_list_append(desktop_names, name);
677 gtk_list_store_append(desktop_store, &it);
678 gtk_list_store_set(desktop_store, &it,
679 0, (name[0] ? name : _("(Unnamed desktop)")),
688 while (i < num_desktops) {
689 gchar *name = g_strdup("");
691 desktop_names = g_list_append(desktop_names, name);
693 gtk_list_store_append(desktop_store, &it);
694 gtk_list_store_set(desktop_store, &it,
695 0, _("(Unnamed desktop)"),
702 void setup_desktop_names(GtkWidget *w)
704 GtkCellRenderer *render;
705 GtkTreeViewColumn *column;
709 desktop_store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_BOOLEAN);
710 gtk_tree_view_set_model(GTK_TREE_VIEW(w), GTK_TREE_MODEL(desktop_store));
711 g_object_unref (desktop_store);
713 gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(w)),
714 GTK_SELECTION_SINGLE);
716 render = gtk_cell_renderer_text_new();
717 g_signal_connect(render, "edited",
718 G_CALLBACK (on_desktop_names_cell_edited),
721 column = gtk_tree_view_column_new_with_attributes
722 ("Name", render, "text", 0, "editable", 1, NULL);
723 gtk_tree_view_append_column(GTK_TREE_VIEW(w), column);
725 reset_desktop_names();
731 /***********************************************************************/
733 void on_window_border_toggled(GtkToggleButton *w, gpointer data)
739 b = gtk_toggle_button_get_active(w);
740 tree_set_bool("theme/keepBorder", b);
743 static void on_font_set(GtkFontButton *w, const gchar *place)
747 const gchar *size = NULL;
748 const gchar *bold = NULL;
749 const gchar *italic = NULL;
753 font = g_strdup(gtk_font_button_get_font_name(w));
754 while ((c = strrchr(font, ' '))) {
755 if (!bold && !italic && !size && atoi(c+1))
757 else if (!bold && !italic && !g_ascii_strcasecmp(c+1, "italic"))
759 else if (!bold && !g_ascii_strcasecmp(c+1, "bold"))
765 if (!bold) bold = "Normal";
766 if (!italic) italic = "Normal";
768 node = g_strdup_printf("theme/font:place=%s/name", place);
769 tree_set_string(node, font);
772 node = g_strdup_printf("theme/font:place=%s/size", place);
773 tree_set_string(node, size);
776 node = g_strdup_printf("theme/font:place=%s/weight", place);
777 tree_set_string(node, bold);
780 node = g_strdup_printf("theme/font:place=%s/slant", place);
781 tree_set_string(node, italic);
787 void on_font_active_font_set(GtkFontButton *w, gpointer data)
789 on_font_set(w, "ActiveWindow");
792 void on_font_inactive_font_set(GtkFontButton *w, gpointer data)
794 on_font_set(w, "InactiveWindow");
797 void on_font_menu_header_font_set(GtkFontButton *w, gpointer data)
799 on_font_set(w, "MenuHeader");
802 void on_font_menu_item_font_set(GtkFontButton *w, gpointer data)
804 on_font_set(w, "MenuItem");
807 void on_font_display_font_set(GtkFontButton *w, gpointer data)
809 on_font_set(w, "OnScreenDisplay");
812 void on_focus_mouse_toggled(GtkToggleButton *w, gpointer data)
818 b = gtk_toggle_button_get_active(w);
819 tree_set_bool("focus/followMouse", b);
822 GtkWidget *delay = glade_xml_get_widget(glade, "focus_delay");
823 GtkWidget *delay_l = glade_xml_get_widget(glade, "focus_delay_label");
824 GtkWidget *delay_u = glade_xml_get_widget(glade,
825 "focus_delay_label_units");
826 GtkWidget *raise = glade_xml_get_widget(glade, "focus_raise");
827 gtk_widget_set_sensitive(delay, b);
828 gtk_widget_set_sensitive(delay_l, b);
829 gtk_widget_set_sensitive(delay_u, b);
830 gtk_widget_set_sensitive(raise, b);
834 void on_focus_delay_value_changed(GtkSpinButton *w, gpointer data)
838 tree_set_int("focus/focusDelay",
839 gtk_spin_button_get_value_as_int(w));
842 void on_focus_raise_toggled(GtkToggleButton *w, gpointer data)
846 tree_set_bool("focus/raiseOnFocus", gtk_toggle_button_get_active(w));
849 void on_focus_new_toggled(GtkToggleButton *w, gpointer data)
853 tree_set_bool("focus/focusNew", gtk_toggle_button_get_active(w));
856 void on_place_mouse_toggled(GtkToggleButton *w, gpointer data)
860 tree_set_string("placement/policy",
861 (gtk_toggle_button_get_active(w) ?
862 "UnderMouse" : "Smart"));
865 void on_resist_window_value_changed(GtkSpinButton *w, gpointer data)
869 tree_set_int("resistance/strength", gtk_spin_button_get_value_as_int(w));
872 void on_resist_edge_value_changed(GtkSpinButton *w, gpointer data)
876 tree_set_int("resistance/screen_edge_strength",
877 gtk_spin_button_get_value_as_int(w));
880 void on_resize_contents_toggled(GtkToggleButton *w, gpointer data)
884 tree_set_bool("resize/drawContents", gtk_toggle_button_get_active(w));
887 void on_dock_top_left_activate(GtkMenuItem *w, gpointer data)
891 tree_set_string("dock/position", "TopLeft");
895 s = glade_xml_get_widget(glade, "dock_float_x");
896 gtk_widget_set_sensitive(s, FALSE);
897 s = glade_xml_get_widget(glade, "dock_float_y");
898 gtk_widget_set_sensitive(s, FALSE);
899 s = glade_xml_get_widget(glade, "dock_float_label");
900 gtk_widget_set_sensitive(s, FALSE);
901 s = glade_xml_get_widget(glade, "dock_float_label_x");
902 gtk_widget_set_sensitive(s, FALSE);
906 void on_dock_top_activate(GtkMenuItem *w, gpointer data)
910 tree_set_string("dock/position", "Top");
914 s = glade_xml_get_widget(glade, "dock_float_x");
915 gtk_widget_set_sensitive(s, FALSE);
916 s = glade_xml_get_widget(glade, "dock_float_y");
917 gtk_widget_set_sensitive(s, FALSE);
918 s = glade_xml_get_widget(glade, "dock_float_label");
919 gtk_widget_set_sensitive(s, FALSE);
920 s = glade_xml_get_widget(glade, "dock_float_label_x");
921 gtk_widget_set_sensitive(s, FALSE);
925 void on_dock_top_right_activate(GtkMenuItem *w, gpointer data)
929 tree_set_string("dock/position", "TopRight");
933 s = glade_xml_get_widget(glade, "dock_float_x");
934 gtk_widget_set_sensitive(s, FALSE);
935 s = glade_xml_get_widget(glade, "dock_float_y");
936 gtk_widget_set_sensitive(s, FALSE);
937 s = glade_xml_get_widget(glade, "dock_float_label");
938 gtk_widget_set_sensitive(s, FALSE);
939 s = glade_xml_get_widget(glade, "dock_float_label_x");
940 gtk_widget_set_sensitive(s, FALSE);
944 void on_dock_left_activate(GtkMenuItem *w, gpointer data)
948 tree_set_string("dock/position", "Left");
952 s = glade_xml_get_widget(glade, "dock_float_x");
953 gtk_widget_set_sensitive(s, FALSE);
954 s = glade_xml_get_widget(glade, "dock_float_y");
955 gtk_widget_set_sensitive(s, FALSE);
956 s = glade_xml_get_widget(glade, "dock_float_label");
957 gtk_widget_set_sensitive(s, FALSE);
958 s = glade_xml_get_widget(glade, "dock_float_label_x");
959 gtk_widget_set_sensitive(s, FALSE);
963 void on_dock_right_activate(GtkMenuItem *w, gpointer data)
967 tree_set_string("dock/position", "Right");
971 s = glade_xml_get_widget(glade, "dock_float_x");
972 gtk_widget_set_sensitive(s, FALSE);
973 s = glade_xml_get_widget(glade, "dock_float_y");
974 gtk_widget_set_sensitive(s, FALSE);
975 s = glade_xml_get_widget(glade, "dock_float_label");
976 gtk_widget_set_sensitive(s, FALSE);
977 s = glade_xml_get_widget(glade, "dock_float_label_x");
978 gtk_widget_set_sensitive(s, FALSE);
983 void on_dock_bottom_left_activate(GtkMenuItem *w, gpointer data)
987 tree_set_string("dock/position", "BottomLeft");
991 s = glade_xml_get_widget(glade, "dock_float_x");
992 gtk_widget_set_sensitive(s, FALSE);
993 s = glade_xml_get_widget(glade, "dock_float_y");
994 gtk_widget_set_sensitive(s, FALSE);
995 s = glade_xml_get_widget(glade, "dock_float_label");
996 gtk_widget_set_sensitive(s, FALSE);
997 s = glade_xml_get_widget(glade, "dock_float_label_x");
998 gtk_widget_set_sensitive(s, FALSE);
1002 void on_dock_bottom_activate(GtkMenuItem *w, gpointer data)
1004 if (mapping) return;
1006 tree_set_string("dock/position", "Bottom");
1010 s = glade_xml_get_widget(glade, "dock_float_x");
1011 gtk_widget_set_sensitive(s, FALSE);
1012 s = glade_xml_get_widget(glade, "dock_float_y");
1013 gtk_widget_set_sensitive(s, FALSE);
1014 s = glade_xml_get_widget(glade, "dock_float_label");
1015 gtk_widget_set_sensitive(s, FALSE);
1016 s = glade_xml_get_widget(glade, "dock_float_label_x");
1017 gtk_widget_set_sensitive(s, FALSE);
1021 void on_dock_bottom_right_activate(GtkMenuItem *w, gpointer data)
1023 if (mapping) return;
1025 tree_set_string("dock/position", "BottomRight");
1029 s = glade_xml_get_widget(glade, "dock_float_x");
1030 gtk_widget_set_sensitive(s, FALSE);
1031 s = glade_xml_get_widget(glade, "dock_float_y");
1032 gtk_widget_set_sensitive(s, FALSE);
1033 s = glade_xml_get_widget(glade, "dock_float_label");
1034 gtk_widget_set_sensitive(s, FALSE);
1035 s = glade_xml_get_widget(glade, "dock_float_label_x");
1036 gtk_widget_set_sensitive(s, FALSE);
1040 void on_dock_floating_activate(GtkMenuItem *w, gpointer data)
1042 if (mapping) return;
1044 tree_set_string("dock/position", "Floating");
1048 s = glade_xml_get_widget(glade, "dock_float_x");
1049 gtk_widget_set_sensitive(s, TRUE);
1050 s = glade_xml_get_widget(glade, "dock_float_y");
1051 gtk_widget_set_sensitive(s, TRUE);
1052 s = glade_xml_get_widget(glade, "dock_float_label");
1053 gtk_widget_set_sensitive(s, TRUE);
1054 s = glade_xml_get_widget(glade, "dock_float_label_x");
1055 gtk_widget_set_sensitive(s, TRUE);
1059 void on_dock_float_x_value_changed(GtkSpinButton *w, gpointer data)
1061 if (mapping) return;
1063 tree_set_int("dock/floatingX", gtk_spin_button_get_value_as_int(w));
1066 void on_dock_float_y_value_changed(GtkSpinButton *w, gpointer data)
1068 if (mapping) return;
1070 tree_set_int("dock/floatingY", gtk_spin_button_get_value_as_int(w));
1073 void on_dock_stacking_top_toggled(GtkToggleButton *w, gpointer data)
1075 if (mapping) return;
1077 if(gtk_toggle_button_get_active(w))
1078 tree_set_string("dock/stacking", "Top");
1081 void on_dock_stacking_normal_toggled(GtkToggleButton *w, gpointer data)
1083 if (mapping) return;
1085 if(gtk_toggle_button_get_active(w))
1086 tree_set_string("dock/stacking", "Normal");
1089 void on_dock_stacking_bottom_toggled(GtkToggleButton *w, gpointer data)
1091 if (mapping) return;
1093 if(gtk_toggle_button_get_active(w))
1094 tree_set_string("dock/stacking", "Bottom");
1097 void on_dock_horizontal_activate(GtkMenuItem *w, gpointer data)
1099 if (mapping) return;
1101 tree_set_string("dock/direction", "Horizontal");
1104 void on_dock_vertical_activate(GtkMenuItem *w, gpointer data)
1106 if (mapping) return;
1108 tree_set_string("dock/direction", "Vertical");
1111 void on_dock_hide_toggled(GtkToggleButton *w, gpointer data)
1113 if (mapping) return;
1115 tree_set_bool("dock/autoHide", gtk_toggle_button_get_active(w));
1117 GtkWidget *delay = glade_xml_get_widget(glade, "dock_hide_delay");
1118 GtkWidget *delay_l = glade_xml_get_widget(glade, "dock_hide_label");
1119 GtkWidget *delay_u = glade_xml_get_widget(glade,
1120 "dock_hide_label_units");
1121 gtk_widget_set_sensitive(delay, gtk_toggle_button_get_active(w));
1122 gtk_widget_set_sensitive(delay_l, gtk_toggle_button_get_active(w));
1123 gtk_widget_set_sensitive(delay_u, gtk_toggle_button_get_active(w));
1127 void on_dock_hide_delay_value_changed(GtkSpinButton *w, gpointer data)
1129 if (mapping) return;
1131 tree_set_int("dock/hideDelay",
1132 gtk_spin_button_get_value_as_int(w));
1135 void on_theme_name_changed(GtkOptionMenu *w, gpointer data)
1139 if (mapping) return;
1141 name = g_list_nth_data(themes, gtk_option_menu_get_history(w));
1144 tree_set_string("theme/name", name);
1147 void on_theme_names_selection_changed(GtkTreeSelection *sel, gpointer data)
1150 GtkTreeModel *model;
1153 if (mapping) return;
1155 if(gtk_tree_selection_get_selected(sel, &model, &iter)) {
1156 gtk_tree_model_get(model, &iter, 0, &name, -1);
1160 tree_set_string("theme/name", name);
1163 void on_title_layout_changed(GtkEntry *w, gpointer data)
1167 gboolean n, d, s, l, i, m, c;
1169 if (mapping) return;
1171 layout = g_strdup(gtk_entry_get_text(w));
1173 n = d = s = l = i = m = c = FALSE;
1175 for (it = layout; *it; ++it) {
1213 /* drop the letter */
1214 for (it2 = it; *it2; ++it2)
1222 gtk_entry_set_text(w, layout);
1223 tree_set_string("theme/titleLayout", layout);
1227 static void set_desktop_names()
1232 gint num = 0, last = -1;
1234 n = tree_get_node("desktops/names", NULL);
1235 while ((c = n->children)) {
1240 for (lit = desktop_names; lit; lit = g_list_next(lit)) {
1241 if (((gchar*)lit->data)[0]) /* not empty */
1247 for (lit = desktop_names; lit && num <= last; lit = g_list_next(lit))
1248 xmlNewTextChild(n, NULL, "name", lit->data);
1251 /* make openbox re-set the property */
1252 XDeleteProperty(GDK_DISPLAY(), GDK_ROOT_WINDOW(),
1253 XInternAtom(GDK_DISPLAY(), "_NET_DESKTOP_NAMES", FALSE));
1256 static void set_desktop_number()
1260 tree_set_int("desktops/number", num_desktops);
1262 ce.xclient.type = ClientMessage;
1263 ce.xclient.message_type = XInternAtom(GDK_DISPLAY(),
1264 "_NET_NUMBER_OF_DESKTOPS",
1266 ce.xclient.display = GDK_DISPLAY();
1267 ce.xclient.window = GDK_ROOT_WINDOW();
1268 ce.xclient.format = 32;
1269 ce.xclient.data.l[0] = num_desktops;
1270 ce.xclient.data.l[1] = 0;
1271 ce.xclient.data.l[2] = 0;
1272 ce.xclient.data.l[3] = 0;
1273 ce.xclient.data.l[4] = 0;
1274 XSendEvent(GDK_DISPLAY(), GDK_ROOT_WINDOW(), FALSE,
1275 SubstructureNotifyMask | SubstructureRedirectMask,
1279 void on_desktop_num_value_changed(GtkSpinButton *w, gpointer data)
1281 if (mapping) return;
1283 num_desktops = gtk_spin_button_get_value(w);
1285 set_desktop_number();
1287 reset_desktop_names();
1290 static void on_desktop_names_cell_edited(GtkCellRendererText *cell,
1291 const gchar *path_string,
1292 const gchar *new_text,
1295 if (mapping) return;
1297 GtkTreePath *path = gtk_tree_path_new_from_string (path_string);
1303 gtk_tree_model_get_iter(GTK_TREE_MODEL(desktop_store), &it, path);
1305 gtk_tree_model_get(GTK_TREE_MODEL(desktop_store), &it, 0, &old_text, -1);
1308 i = gtk_tree_path_get_indices(path)[0];
1309 lit = g_list_nth(desktop_names, i);
1312 lit->data = g_strdup(new_text);
1313 if (new_text[0]) /* not empty */
1314 gtk_list_store_set(desktop_store, &it, 0, lit->data, -1);
1316 gtk_list_store_set(desktop_store, &it, 0, _("(Unnamed desktop)"), -1);
1318 set_desktop_names();