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 /* don't use "normal" in the gtk string */
515 if (!g_ascii_strcasecmp(weight, "normal")) {
516 g_free(weight); weight = g_strdup("");
518 if (!g_ascii_strcasecmp(slant, "normal")) {
519 g_free(slant); slant = g_strdup("");
522 fontstring = g_strdup_printf("%s %s %s %s", name, weight, slant, size);
523 gtk_font_button_set_font_name(GTK_FONT_BUTTON(w), fontstring);
533 void setup_font_inactive(GtkWidget *w)
536 gchar *name, **names;
543 name = tree_get_string("theme/font:place=InactiveWindow/name", "Sans");
544 size = tree_get_string("theme/font:place=InactiveWindow/size", "8");
545 weight = tree_get_string("theme/font:place=InactiveWindow/weight", "");
546 slant = tree_get_string("theme/font:place=InactiveWindow/slant", "");
548 /* get only the first font in the string */
549 names = g_strsplit(name, ",", 0);
551 name = g_strdup(names[0]);
554 fontstring = g_strdup_printf("%s %s %s %s", name, weight, slant, size);
555 gtk_font_button_set_font_name(GTK_FONT_BUTTON(w), fontstring);
565 void setup_font_menu_header(GtkWidget *w)
568 gchar *name, **names;
575 name = tree_get_string("theme/font:place=MenuHeader/name", "Sans");
576 size = tree_get_string("theme/font:place=MenuHeader/size", "8");
577 weight = tree_get_string("theme/font:place=MenuHeader/weight", "");
578 slant = tree_get_string("theme/font:place=MenuHeader/slant", "");
580 /* get only the first font in the string */
581 names = g_strsplit(name, ",", 0);
583 name = g_strdup(names[0]);
586 fontstring = g_strdup_printf("%s %s %s %s", name, weight, slant, size);
587 gtk_font_button_set_font_name(GTK_FONT_BUTTON(w), fontstring);
597 void setup_font_menu_item(GtkWidget *w)
600 gchar *name, **names;
607 name = tree_get_string("theme/font:place=MenuItem/name", "Sans");
608 size = tree_get_string("theme/font:place=MenuItem/size", "8");
609 weight = tree_get_string("theme/font:place=MenuItem/weight", "");
610 slant = tree_get_string("theme/font:place=MenuItem/slant", "");
612 /* get only the first font in the string */
613 names = g_strsplit(name, ",", 0);
615 name = g_strdup(names[0]);
618 fontstring = g_strdup_printf("%s %s %s %s", name, weight, slant, size);
619 gtk_font_button_set_font_name(GTK_FONT_BUTTON(w), fontstring);
629 void setup_font_display(GtkWidget *w)
632 gchar *name, **names;
639 name = tree_get_string("theme/font:place=OnScreenDisplay/name", "Sans");
640 size = tree_get_string("theme/font:place=OnScreenDisplay/size", "8");
641 weight = tree_get_string("theme/font:place=OnScreenDisplay/weight", "");
642 slant = tree_get_string("theme/font:place=OnScreenDisplay/slant", "");
644 /* get only the first font in the string */
645 names = g_strsplit(name, ",", 0);
647 name = g_strdup(names[0]);
650 fontstring = g_strdup_printf("%s %s %s %s", name, weight, slant, size);
651 gtk_font_button_set_font_name(GTK_FONT_BUTTON(w), fontstring);
661 static void reset_desktop_names()
668 gtk_list_store_clear(desktop_store);
670 for (lit = desktop_names; lit; lit = g_list_next(lit))
672 g_list_free(desktop_names);
673 desktop_names = NULL;
676 n = tree_get_node("desktops/names", NULL)->children;
680 if (!xmlStrcmp(n->name, (const xmlChar*)"name")) {
681 name = parse_string(doc, n);
683 desktop_names = g_list_append(desktop_names, name);
685 gtk_list_store_append(desktop_store, &it);
686 gtk_list_store_set(desktop_store, &it,
687 0, (name[0] ? name : _("(Unnamed desktop)")),
696 while (i < num_desktops) {
697 gchar *name = g_strdup("");
699 desktop_names = g_list_append(desktop_names, name);
701 gtk_list_store_append(desktop_store, &it);
702 gtk_list_store_set(desktop_store, &it,
703 0, _("(Unnamed desktop)"),
710 void setup_desktop_names(GtkWidget *w)
712 GtkCellRenderer *render;
713 GtkTreeViewColumn *column;
717 desktop_store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_BOOLEAN);
718 gtk_tree_view_set_model(GTK_TREE_VIEW(w), GTK_TREE_MODEL(desktop_store));
719 g_object_unref (desktop_store);
721 gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(w)),
722 GTK_SELECTION_SINGLE);
724 render = gtk_cell_renderer_text_new();
725 g_signal_connect(render, "edited",
726 G_CALLBACK (on_desktop_names_cell_edited),
729 column = gtk_tree_view_column_new_with_attributes
730 ("Name", render, "text", 0, "editable", 1, NULL);
731 gtk_tree_view_append_column(GTK_TREE_VIEW(w), column);
733 reset_desktop_names();
739 /***********************************************************************/
741 void on_window_border_toggled(GtkToggleButton *w, gpointer data)
747 b = gtk_toggle_button_get_active(w);
748 tree_set_bool("theme/keepBorder", b);
751 static void on_font_set(GtkFontButton *w, const gchar *place)
755 const gchar *size = NULL;
756 const gchar *bold = NULL;
757 const gchar *italic = NULL;
761 font = g_strdup(gtk_font_button_get_font_name(w));
762 while ((c = strrchr(font, ' '))) {
763 if (!bold && !italic && !size && atoi(c+1))
765 else if (!bold && !italic && !g_ascii_strcasecmp(c+1, "italic"))
767 else if (!bold && !g_ascii_strcasecmp(c+1, "bold"))
773 if (!bold) bold = "Normal";
774 if (!italic) italic = "Normal";
776 node = g_strdup_printf("theme/font:place=%s/name", place);
777 tree_set_string(node, font);
780 node = g_strdup_printf("theme/font:place=%s/size", place);
781 tree_set_string(node, size);
784 node = g_strdup_printf("theme/font:place=%s/weight", place);
785 tree_set_string(node, bold);
788 node = g_strdup_printf("theme/font:place=%s/slant", place);
789 tree_set_string(node, italic);
795 void on_font_active_font_set(GtkFontButton *w, gpointer data)
797 on_font_set(w, "ActiveWindow");
800 void on_font_inactive_font_set(GtkFontButton *w, gpointer data)
802 on_font_set(w, "InactiveWindow");
805 void on_font_menu_header_font_set(GtkFontButton *w, gpointer data)
807 on_font_set(w, "MenuHeader");
810 void on_font_menu_item_font_set(GtkFontButton *w, gpointer data)
812 on_font_set(w, "MenuItem");
815 void on_font_display_font_set(GtkFontButton *w, gpointer data)
817 on_font_set(w, "OnScreenDisplay");
820 void on_focus_mouse_toggled(GtkToggleButton *w, gpointer data)
826 b = gtk_toggle_button_get_active(w);
827 tree_set_bool("focus/followMouse", b);
830 GtkWidget *delay = glade_xml_get_widget(glade, "focus_delay");
831 GtkWidget *delay_l = glade_xml_get_widget(glade, "focus_delay_label");
832 GtkWidget *delay_u = glade_xml_get_widget(glade,
833 "focus_delay_label_units");
834 GtkWidget *raise = glade_xml_get_widget(glade, "focus_raise");
835 gtk_widget_set_sensitive(delay, b);
836 gtk_widget_set_sensitive(delay_l, b);
837 gtk_widget_set_sensitive(delay_u, b);
838 gtk_widget_set_sensitive(raise, b);
842 void on_focus_delay_value_changed(GtkSpinButton *w, gpointer data)
846 tree_set_int("focus/focusDelay",
847 gtk_spin_button_get_value_as_int(w));
850 void on_focus_raise_toggled(GtkToggleButton *w, gpointer data)
854 tree_set_bool("focus/raiseOnFocus", gtk_toggle_button_get_active(w));
857 void on_focus_new_toggled(GtkToggleButton *w, gpointer data)
861 tree_set_bool("focus/focusNew", gtk_toggle_button_get_active(w));
864 void on_place_mouse_toggled(GtkToggleButton *w, gpointer data)
868 tree_set_string("placement/policy",
869 (gtk_toggle_button_get_active(w) ?
870 "UnderMouse" : "Smart"));
873 void on_resist_window_value_changed(GtkSpinButton *w, gpointer data)
877 tree_set_int("resistance/strength", gtk_spin_button_get_value_as_int(w));
880 void on_resist_edge_value_changed(GtkSpinButton *w, gpointer data)
884 tree_set_int("resistance/screen_edge_strength",
885 gtk_spin_button_get_value_as_int(w));
888 void on_resize_contents_toggled(GtkToggleButton *w, gpointer data)
892 tree_set_bool("resize/drawContents", gtk_toggle_button_get_active(w));
895 void on_dock_top_left_activate(GtkMenuItem *w, gpointer data)
899 tree_set_string("dock/position", "TopLeft");
903 s = glade_xml_get_widget(glade, "dock_float_x");
904 gtk_widget_set_sensitive(s, FALSE);
905 s = glade_xml_get_widget(glade, "dock_float_y");
906 gtk_widget_set_sensitive(s, FALSE);
907 s = glade_xml_get_widget(glade, "dock_float_label");
908 gtk_widget_set_sensitive(s, FALSE);
909 s = glade_xml_get_widget(glade, "dock_float_label_x");
910 gtk_widget_set_sensitive(s, FALSE);
914 void on_dock_top_activate(GtkMenuItem *w, gpointer data)
918 tree_set_string("dock/position", "Top");
922 s = glade_xml_get_widget(glade, "dock_float_x");
923 gtk_widget_set_sensitive(s, FALSE);
924 s = glade_xml_get_widget(glade, "dock_float_y");
925 gtk_widget_set_sensitive(s, FALSE);
926 s = glade_xml_get_widget(glade, "dock_float_label");
927 gtk_widget_set_sensitive(s, FALSE);
928 s = glade_xml_get_widget(glade, "dock_float_label_x");
929 gtk_widget_set_sensitive(s, FALSE);
933 void on_dock_top_right_activate(GtkMenuItem *w, gpointer data)
937 tree_set_string("dock/position", "TopRight");
941 s = glade_xml_get_widget(glade, "dock_float_x");
942 gtk_widget_set_sensitive(s, FALSE);
943 s = glade_xml_get_widget(glade, "dock_float_y");
944 gtk_widget_set_sensitive(s, FALSE);
945 s = glade_xml_get_widget(glade, "dock_float_label");
946 gtk_widget_set_sensitive(s, FALSE);
947 s = glade_xml_get_widget(glade, "dock_float_label_x");
948 gtk_widget_set_sensitive(s, FALSE);
952 void on_dock_left_activate(GtkMenuItem *w, gpointer data)
956 tree_set_string("dock/position", "Left");
960 s = glade_xml_get_widget(glade, "dock_float_x");
961 gtk_widget_set_sensitive(s, FALSE);
962 s = glade_xml_get_widget(glade, "dock_float_y");
963 gtk_widget_set_sensitive(s, FALSE);
964 s = glade_xml_get_widget(glade, "dock_float_label");
965 gtk_widget_set_sensitive(s, FALSE);
966 s = glade_xml_get_widget(glade, "dock_float_label_x");
967 gtk_widget_set_sensitive(s, FALSE);
971 void on_dock_right_activate(GtkMenuItem *w, gpointer data)
975 tree_set_string("dock/position", "Right");
979 s = glade_xml_get_widget(glade, "dock_float_x");
980 gtk_widget_set_sensitive(s, FALSE);
981 s = glade_xml_get_widget(glade, "dock_float_y");
982 gtk_widget_set_sensitive(s, FALSE);
983 s = glade_xml_get_widget(glade, "dock_float_label");
984 gtk_widget_set_sensitive(s, FALSE);
985 s = glade_xml_get_widget(glade, "dock_float_label_x");
986 gtk_widget_set_sensitive(s, FALSE);
991 void on_dock_bottom_left_activate(GtkMenuItem *w, gpointer data)
995 tree_set_string("dock/position", "BottomLeft");
999 s = glade_xml_get_widget(glade, "dock_float_x");
1000 gtk_widget_set_sensitive(s, FALSE);
1001 s = glade_xml_get_widget(glade, "dock_float_y");
1002 gtk_widget_set_sensitive(s, FALSE);
1003 s = glade_xml_get_widget(glade, "dock_float_label");
1004 gtk_widget_set_sensitive(s, FALSE);
1005 s = glade_xml_get_widget(glade, "dock_float_label_x");
1006 gtk_widget_set_sensitive(s, FALSE);
1010 void on_dock_bottom_activate(GtkMenuItem *w, gpointer data)
1012 if (mapping) return;
1014 tree_set_string("dock/position", "Bottom");
1018 s = glade_xml_get_widget(glade, "dock_float_x");
1019 gtk_widget_set_sensitive(s, FALSE);
1020 s = glade_xml_get_widget(glade, "dock_float_y");
1021 gtk_widget_set_sensitive(s, FALSE);
1022 s = glade_xml_get_widget(glade, "dock_float_label");
1023 gtk_widget_set_sensitive(s, FALSE);
1024 s = glade_xml_get_widget(glade, "dock_float_label_x");
1025 gtk_widget_set_sensitive(s, FALSE);
1029 void on_dock_bottom_right_activate(GtkMenuItem *w, gpointer data)
1031 if (mapping) return;
1033 tree_set_string("dock/position", "BottomRight");
1037 s = glade_xml_get_widget(glade, "dock_float_x");
1038 gtk_widget_set_sensitive(s, FALSE);
1039 s = glade_xml_get_widget(glade, "dock_float_y");
1040 gtk_widget_set_sensitive(s, FALSE);
1041 s = glade_xml_get_widget(glade, "dock_float_label");
1042 gtk_widget_set_sensitive(s, FALSE);
1043 s = glade_xml_get_widget(glade, "dock_float_label_x");
1044 gtk_widget_set_sensitive(s, FALSE);
1048 void on_dock_floating_activate(GtkMenuItem *w, gpointer data)
1050 if (mapping) return;
1052 tree_set_string("dock/position", "Floating");
1056 s = glade_xml_get_widget(glade, "dock_float_x");
1057 gtk_widget_set_sensitive(s, TRUE);
1058 s = glade_xml_get_widget(glade, "dock_float_y");
1059 gtk_widget_set_sensitive(s, TRUE);
1060 s = glade_xml_get_widget(glade, "dock_float_label");
1061 gtk_widget_set_sensitive(s, TRUE);
1062 s = glade_xml_get_widget(glade, "dock_float_label_x");
1063 gtk_widget_set_sensitive(s, TRUE);
1067 void on_dock_float_x_value_changed(GtkSpinButton *w, gpointer data)
1069 if (mapping) return;
1071 tree_set_int("dock/floatingX", gtk_spin_button_get_value_as_int(w));
1074 void on_dock_float_y_value_changed(GtkSpinButton *w, gpointer data)
1076 if (mapping) return;
1078 tree_set_int("dock/floatingY", gtk_spin_button_get_value_as_int(w));
1081 void on_dock_stacking_top_toggled(GtkToggleButton *w, gpointer data)
1083 if (mapping) return;
1085 if(gtk_toggle_button_get_active(w))
1086 tree_set_string("dock/stacking", "Top");
1089 void on_dock_stacking_normal_toggled(GtkToggleButton *w, gpointer data)
1091 if (mapping) return;
1093 if(gtk_toggle_button_get_active(w))
1094 tree_set_string("dock/stacking", "Normal");
1097 void on_dock_stacking_bottom_toggled(GtkToggleButton *w, gpointer data)
1099 if (mapping) return;
1101 if(gtk_toggle_button_get_active(w))
1102 tree_set_string("dock/stacking", "Bottom");
1105 void on_dock_horizontal_activate(GtkMenuItem *w, gpointer data)
1107 if (mapping) return;
1109 tree_set_string("dock/direction", "Horizontal");
1112 void on_dock_vertical_activate(GtkMenuItem *w, gpointer data)
1114 if (mapping) return;
1116 tree_set_string("dock/direction", "Vertical");
1119 void on_dock_hide_toggled(GtkToggleButton *w, gpointer data)
1121 if (mapping) return;
1123 tree_set_bool("dock/autoHide", gtk_toggle_button_get_active(w));
1125 GtkWidget *delay = glade_xml_get_widget(glade, "dock_hide_delay");
1126 GtkWidget *delay_l = glade_xml_get_widget(glade, "dock_hide_label");
1127 GtkWidget *delay_u = glade_xml_get_widget(glade,
1128 "dock_hide_label_units");
1129 gtk_widget_set_sensitive(delay, gtk_toggle_button_get_active(w));
1130 gtk_widget_set_sensitive(delay_l, gtk_toggle_button_get_active(w));
1131 gtk_widget_set_sensitive(delay_u, gtk_toggle_button_get_active(w));
1135 void on_dock_hide_delay_value_changed(GtkSpinButton *w, gpointer data)
1137 if (mapping) return;
1139 tree_set_int("dock/hideDelay",
1140 gtk_spin_button_get_value_as_int(w));
1143 void on_theme_name_changed(GtkOptionMenu *w, gpointer data)
1147 if (mapping) return;
1149 name = g_list_nth_data(themes, gtk_option_menu_get_history(w));
1152 tree_set_string("theme/name", name);
1155 void on_theme_names_selection_changed(GtkTreeSelection *sel, gpointer data)
1158 GtkTreeModel *model;
1161 if (mapping) return;
1163 if(gtk_tree_selection_get_selected(sel, &model, &iter)) {
1164 gtk_tree_model_get(model, &iter, 0, &name, -1);
1168 tree_set_string("theme/name", name);
1171 void on_title_layout_changed(GtkEntry *w, gpointer data)
1175 gboolean n, d, s, l, i, m, c;
1177 if (mapping) return;
1179 layout = g_strdup(gtk_entry_get_text(w));
1181 n = d = s = l = i = m = c = FALSE;
1183 for (it = layout; *it; ++it) {
1221 /* drop the letter */
1222 for (it2 = it; *it2; ++it2)
1230 gtk_entry_set_text(w, layout);
1231 tree_set_string("theme/titleLayout", layout);
1235 static void set_desktop_names()
1240 gint num = 0, last = -1;
1242 n = tree_get_node("desktops/names", NULL);
1243 while ((c = n->children)) {
1248 for (lit = desktop_names; lit; lit = g_list_next(lit)) {
1249 if (((gchar*)lit->data)[0]) /* not empty */
1255 for (lit = desktop_names; lit && num <= last; lit = g_list_next(lit)) {
1256 xmlNewTextChild(n, NULL, "name", lit->data);
1261 /* make openbox re-set the property */
1262 XDeleteProperty(GDK_DISPLAY(), GDK_ROOT_WINDOW(),
1263 XInternAtom(GDK_DISPLAY(), "_NET_DESKTOP_NAMES", FALSE));
1266 static void set_desktop_number()
1270 tree_set_int("desktops/number", num_desktops);
1272 ce.xclient.type = ClientMessage;
1273 ce.xclient.message_type = XInternAtom(GDK_DISPLAY(),
1274 "_NET_NUMBER_OF_DESKTOPS",
1276 ce.xclient.display = GDK_DISPLAY();
1277 ce.xclient.window = GDK_ROOT_WINDOW();
1278 ce.xclient.format = 32;
1279 ce.xclient.data.l[0] = num_desktops;
1280 ce.xclient.data.l[1] = 0;
1281 ce.xclient.data.l[2] = 0;
1282 ce.xclient.data.l[3] = 0;
1283 ce.xclient.data.l[4] = 0;
1284 XSendEvent(GDK_DISPLAY(), GDK_ROOT_WINDOW(), FALSE,
1285 SubstructureNotifyMask | SubstructureRedirectMask,
1289 void on_desktop_num_value_changed(GtkSpinButton *w, gpointer data)
1291 if (mapping) return;
1293 num_desktops = gtk_spin_button_get_value(w);
1295 set_desktop_number();
1297 reset_desktop_names();
1300 static void on_desktop_names_cell_edited(GtkCellRendererText *cell,
1301 const gchar *path_string,
1302 const gchar *new_text,
1305 if (mapping) return;
1307 GtkTreePath *path = gtk_tree_path_new_from_string (path_string);
1313 gtk_tree_model_get_iter(GTK_TREE_MODEL(desktop_store), &it, path);
1315 gtk_tree_model_get(GTK_TREE_MODEL(desktop_store), &it, 0, &old_text, -1);
1318 i = gtk_tree_path_get_indices(path)[0];
1319 lit = g_list_nth(desktop_names, i);
1322 lit->data = g_strdup(new_text);
1323 if (new_text[0]) /* not empty */
1324 gtk_list_store_set(desktop_store, &it, 0, lit->data, -1);
1326 gtk_list_store_set(desktop_store, &it, 0, _("(Unnamed desktop)"), -1);
1328 set_desktop_names();