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, *edgeresist;
48 GtkWidget *winresist_l, *edgeresist_l;
49 GtkSizeGroup *group1, *group2;
51 winresist = glade_xml_get_widget(glade, "resist_window");
52 edgeresist = glade_xml_get_widget(glade, "resist_edge");
53 group1 = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
55 gtk_size_group_add_widget(group1, winresist);
56 gtk_size_group_add_widget(group1, edgeresist);
58 winresist_l = glade_xml_get_widget(glade, "resist_window_label");
59 edgeresist_l = glade_xml_get_widget(glade, "resist_edge_label");
60 group2 = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
62 gtk_size_group_add_widget(group2, winresist_l);
63 gtk_size_group_add_widget(group2, edgeresist_l);
68 GtkWidget *posi, *dir;
69 GtkWidget *posi_l, *dir_l;
70 GtkSizeGroup *group1, *group2;
72 posi = glade_xml_get_widget(glade, "dock_position");
73 dir = glade_xml_get_widget(glade, "dock_direction");
74 group1 = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
76 gtk_size_group_add_widget(group1, posi);
77 gtk_size_group_add_widget(group1, dir);
79 posi_l = glade_xml_get_widget(glade, "dock_position_label");
80 dir_l = glade_xml_get_widget(glade, "dock_direction_label");
81 group2 = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
83 gtk_size_group_add_widget(group2, posi_l);
84 gtk_size_group_add_widget(group2, dir_l);
89 gboolean on_main_window_delete_event(GtkWidget *w, GdkEvent *e, gpointer d)
95 void on_close_clicked()
100 void on_about_clicked()
105 parent = glade_xml_get_widget(glade, "main_window");
106 about = glade_xml_get_widget(glade, "about_window");
108 gtk_window_set_transient_for(GTK_WINDOW(about), GTK_WINDOW(parent));
109 gtk_widget_show(about);
112 void on_about_close_clicked()
116 about = glade_xml_get_widget(glade, "about_window");
118 gtk_widget_hide(about);
121 void on_about_window_delete_event()
125 about = glade_xml_get_widget(glade, "about_window");
127 gtk_widget_hide(about);
130 void setup_focus_mouse(GtkWidget *w)
136 b = tree_get_bool("focus/followMouse", FALSE);
137 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), b);
140 GtkWidget *delay = glade_xml_get_widget(glade, "focus_delay");
141 GtkWidget *delay_l = glade_xml_get_widget(glade, "focus_delay_label");
142 GtkWidget *delay_u = glade_xml_get_widget(glade,
143 "focus_delay_label_units");
144 GtkWidget *raise = glade_xml_get_widget(glade, "focus_raise");
145 GtkWidget *last = glade_xml_get_widget(glade, "focus_last");
146 gtk_widget_set_sensitive(delay, b);
147 gtk_widget_set_sensitive(delay_l, b);
148 gtk_widget_set_sensitive(delay_u, b);
149 gtk_widget_set_sensitive(raise, b);
150 gtk_widget_set_sensitive(last, b);
156 void setup_focus_delay(GtkWidget *w)
159 gtk_spin_button_set_value(GTK_SPIN_BUTTON(w),
160 tree_get_int("focus/focusDelay", 0));
164 void setup_focus_raise(GtkWidget *w)
167 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w),
168 tree_get_bool("focus/raiseOnFocus", FALSE));
172 void setup_focus_last(GtkWidget *w)
175 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w),
176 tree_get_bool("focus/focusLast", FALSE));
180 void setup_focus_new(GtkWidget *w)
183 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w),
184 tree_get_bool("focus/focusNew", TRUE));
188 void setup_place_mouse(GtkWidget *w)
193 s = tree_get_string("placement/policy", "Smart");
194 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w),
195 !g_ascii_strcasecmp(s, "UnderMouse"));
200 void setup_resist_window(GtkWidget *w)
203 gtk_spin_button_set_value(GTK_SPIN_BUTTON(w),
204 tree_get_int("resistance/strength", 10));
208 void setup_resist_edge(GtkWidget *w)
211 gtk_spin_button_set_value(GTK_SPIN_BUTTON(w),
212 tree_get_int("resistance/screen_edge_strength",
217 void setup_resize_contents(GtkWidget *w)
220 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w),
221 tree_get_bool("resize/drawContents", TRUE));
225 void setup_dock_position(GtkWidget *w)
232 s = tree_get_string("dock/position", "TopLeft");
235 if (!strcasecmp(s, "Top"))
236 gtk_option_menu_set_history(GTK_OPTION_MENU(w), 1);
237 else if (!strcasecmp(s, "TopRight"))
238 gtk_option_menu_set_history(GTK_OPTION_MENU(w), 2);
239 else if (!strcasecmp(s, "Left"))
240 gtk_option_menu_set_history(GTK_OPTION_MENU(w), 3);
241 else if (!strcasecmp(s, "Right"))
242 gtk_option_menu_set_history(GTK_OPTION_MENU(w), 4);
243 else if (!strcasecmp(s, "BottomLeft"))
244 gtk_option_menu_set_history(GTK_OPTION_MENU(w), 5);
245 else if (!strcasecmp(s, "Bottom"))
246 gtk_option_menu_set_history(GTK_OPTION_MENU(w), 6);
247 else if (!strcasecmp(s, "BottomRight"))
248 gtk_option_menu_set_history(GTK_OPTION_MENU(w), 7);
249 else if (!strcasecmp(s, "Floating")) {
250 gtk_option_menu_set_history(GTK_OPTION_MENU(w), 8);
253 gtk_option_menu_set_history(GTK_OPTION_MENU(w), 0);
258 s = glade_xml_get_widget(glade, "dock_float_x");
259 gtk_widget_set_sensitive(s, f);
260 s = glade_xml_get_widget(glade, "dock_float_y");
261 gtk_widget_set_sensitive(s, f);
262 s = glade_xml_get_widget(glade, "dock_float_label");
263 gtk_widget_set_sensitive(s, f);
264 s = glade_xml_get_widget(glade, "dock_float_label_x");
265 gtk_widget_set_sensitive(s, f);
271 void setup_dock_float_x(GtkWidget *w)
275 gtk_spin_button_set_value(GTK_SPIN_BUTTON(w),
276 tree_get_int("dock/floatingX", 0));
281 void setup_dock_float_y(GtkWidget *w)
285 gtk_spin_button_set_value(GTK_SPIN_BUTTON(w),
286 tree_get_int("dock/floatingY", 0));
291 void setup_dock_stacking(GtkWidget *top, GtkWidget *normal, GtkWidget *bottom)
297 s = tree_get_string("dock/stacking", "Top");
299 if(!strcasecmp(s, "Normal"))
300 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(normal), TRUE);
301 else if(!strcasecmp(s, "Bottom"))
302 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(bottom), TRUE);
304 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(top), TRUE);
310 void setup_dock_direction(GtkWidget *w)
316 s = tree_get_string("dock/direction", "Vertical");
318 if (!strcasecmp(s, "Horizontal"))
319 gtk_option_menu_set_history(GTK_OPTION_MENU(w), 1);
321 gtk_option_menu_set_history(GTK_OPTION_MENU(w), 0);
327 void setup_dock_hide(GtkWidget *w)
333 b = tree_get_bool("dock/autoHide", FALSE);
334 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), b);
337 GtkWidget *delay = glade_xml_get_widget(glade, "dock_hide_delay");
338 GtkWidget *delay_l = glade_xml_get_widget(glade, "dock_hide_label");
339 GtkWidget *delay_u = glade_xml_get_widget(glade,
340 "dock_hide_label_units");
341 gtk_widget_set_sensitive(delay, b);
342 gtk_widget_set_sensitive(delay_l, b);
343 gtk_widget_set_sensitive(delay_u, b);
349 void setup_dock_hide_delay(GtkWidget *w)
353 gtk_spin_button_set_value(GTK_SPIN_BUTTON(w),
354 tree_get_int("dock/hideDelay", 300));
359 static void add_theme_dir(const gchar *dirname)
364 if ((dir = g_dir_open(dirname, 0, NULL))) {
365 while ((n = g_dir_read_name(dir))) {
368 full = g_build_filename(dirname, n, "openbox-3",
370 if (!g_file_test(full,
371 G_FILE_TEST_IS_REGULAR |
372 G_FILE_TEST_IS_SYMLINK))
378 themes = g_list_append(themes, g_strdup(n));
385 void setup_theme_names(GtkWidget *w)
387 GtkCellRenderer *render;
388 GtkTreeViewColumn *column;
393 GtkTreeSelection *select;
397 name = tree_get_string("theme/name", "TheBear");
399 for (it = themes; it; it = g_list_next(it))
400 g_list_free(it->data);
404 p = g_build_filename(g_get_home_dir(), ".themes", NULL);
410 for (it = parse_xdg_data_dir_paths(); it; it = g_slist_next(it)) {
411 p = g_build_filename(it->data, "themes", NULL);
417 add_theme_dir(THEMEDIR);
419 themes = g_list_sort(themes, (GCompareFunc) strcasecmp);
422 theme_store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_BOOLEAN);
423 gtk_tree_view_set_model(GTK_TREE_VIEW(w), GTK_TREE_MODEL(theme_store));
424 g_object_unref (theme_store);
426 gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(w)),
427 GTK_SELECTION_SINGLE);
429 render = gtk_cell_renderer_text_new();
430 column = gtk_tree_view_column_new_with_attributes
431 ("Name", render, "text", 0, NULL);
432 gtk_tree_view_append_column(GTK_TREE_VIEW(w), column);
434 /* return to regular scheduled programming */
436 for (it = themes; it; it = next) {
439 next = g_list_next(it);
441 /* remove duplicates */
442 if (next && !strcmp(it->data, next->data)) {
444 themes = g_list_delete_link(themes, it);
448 gtk_list_store_append(theme_store, &iter);
449 gtk_list_store_set(theme_store, &iter,
454 if(!strcmp(name, it->data)) {
456 path = gtk_tree_path_new_from_indices(i, -1);
457 gtk_tree_view_set_cursor(GTK_TREE_VIEW(w), path, NULL, FALSE);
464 /* setup the selection handler */
465 select = gtk_tree_view_get_selection(GTK_TREE_VIEW (w));
466 gtk_tree_selection_set_mode(select, GTK_SELECTION_SINGLE);
467 g_signal_connect (G_OBJECT(select), "changed",
468 G_CALLBACK(on_theme_names_selection_changed),
476 void setup_title_layout(GtkWidget *w)
482 layout = tree_get_string("theme/titleLayout", "NLIMC");
483 gtk_entry_set_text(GTK_ENTRY(w), layout);
489 void setup_desktop_num(GtkWidget *w)
493 num_desktops = tree_get_int("desktops/number", 4);
494 gtk_spin_button_set_value(GTK_SPIN_BUTTON(w), num_desktops);
499 void setup_window_border(GtkWidget *w)
505 border = tree_get_bool("theme/keepBorder", TRUE);
506 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), border);
511 static void setup_font(GtkWidget *w, const gchar *place)
513 gchar *fontstring, *node;
514 gchar *name, **names;
521 node = g_strdup_printf("theme/font:place=%s/name", place);
522 name = tree_get_string(node, "Sans");
525 node = g_strdup_printf("theme/font:place=%s/size", place);
526 size = tree_get_string(node, "8");
529 node = g_strdup_printf("theme/font:place=%s/weight", place);
530 weight = tree_get_string(node, "");
533 node = g_strdup_printf("theme/font:place=%s/slant", place);
534 slant = tree_get_string(node, "");
537 /* get only the first font in the string */
538 names = g_strsplit(name, ",", 0);
540 name = g_strdup(names[0]);
543 /* don't use "normal" in the gtk string */
544 if (!g_ascii_strcasecmp(weight, "normal")) {
545 g_free(weight); weight = g_strdup("");
547 if (!g_ascii_strcasecmp(slant, "normal")) {
548 g_free(slant); slant = g_strdup("");
551 fontstring = g_strdup_printf("%s %s %s %s", name, weight, slant, size);
552 gtk_font_button_set_font_name(GTK_FONT_BUTTON(w), fontstring);
562 void setup_font_active(GtkWidget *w)
564 setup_font(w, "ActiveWindow");
567 void setup_font_inactive(GtkWidget *w)
569 setup_font(w, "InactiveWindow");
572 void setup_font_menu_header(GtkWidget *w)
574 setup_font(w, "MenuHeader");
577 void setup_font_menu_item(GtkWidget *w)
579 setup_font(w, "MenuItem");
582 void setup_font_display(GtkWidget *w)
584 setup_font(w, "OnScreenDisplay");
588 static void reset_desktop_names()
595 gtk_list_store_clear(desktop_store);
597 for (lit = desktop_names; lit; lit = g_list_next(lit))
599 g_list_free(desktop_names);
600 desktop_names = NULL;
603 n = tree_get_node("desktops/names", NULL)->children;
607 if (!xmlStrcmp(n->name, (const xmlChar*)"name")) {
608 name = parse_string(doc, n);
610 desktop_names = g_list_append(desktop_names, name);
612 gtk_list_store_append(desktop_store, &it);
613 gtk_list_store_set(desktop_store, &it,
614 0, (name[0] ? name : _("(Unnamed desktop)")),
623 while (i < num_desktops) {
624 gchar *name = g_strdup("");
626 desktop_names = g_list_append(desktop_names, name);
628 gtk_list_store_append(desktop_store, &it);
629 gtk_list_store_set(desktop_store, &it,
630 0, _("(Unnamed desktop)"),
637 void setup_desktop_names(GtkWidget *w)
639 GtkCellRenderer *render;
640 GtkTreeViewColumn *column;
644 desktop_store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_BOOLEAN);
645 gtk_tree_view_set_model(GTK_TREE_VIEW(w), GTK_TREE_MODEL(desktop_store));
646 g_object_unref (desktop_store);
648 gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(w)),
649 GTK_SELECTION_SINGLE);
651 render = gtk_cell_renderer_text_new();
652 g_signal_connect(render, "edited",
653 G_CALLBACK (on_desktop_names_cell_edited),
656 column = gtk_tree_view_column_new_with_attributes
657 ("Name", render, "text", 0, "editable", 1, NULL);
658 gtk_tree_view_append_column(GTK_TREE_VIEW(w), column);
660 reset_desktop_names();
666 /***********************************************************************/
668 void on_window_border_toggled(GtkToggleButton *w, gpointer data)
674 b = gtk_toggle_button_get_active(w);
675 tree_set_bool("theme/keepBorder", b);
678 static void on_font_set(GtkFontButton *w, const gchar *place)
682 const gchar *size = NULL;
683 const gchar *bold = NULL;
684 const gchar *italic = NULL;
688 font = g_strdup(gtk_font_button_get_font_name(w));
689 while ((c = strrchr(font, ' '))) {
690 if (!bold && !italic && !size && atoi(c+1))
692 else if (!bold && !italic && !g_ascii_strcasecmp(c+1, "italic"))
694 else if (!bold && !g_ascii_strcasecmp(c+1, "bold"))
700 if (!bold) bold = "Normal";
701 if (!italic) italic = "Normal";
703 node = g_strdup_printf("theme/font:place=%s/name", place);
704 tree_set_string(node, font);
707 node = g_strdup_printf("theme/font:place=%s/size", place);
708 tree_set_string(node, size);
711 node = g_strdup_printf("theme/font:place=%s/weight", place);
712 tree_set_string(node, bold);
715 node = g_strdup_printf("theme/font:place=%s/slant", place);
716 tree_set_string(node, italic);
722 void on_font_active_font_set(GtkFontButton *w, gpointer data)
724 on_font_set(w, "ActiveWindow");
727 void on_font_inactive_font_set(GtkFontButton *w, gpointer data)
729 on_font_set(w, "InactiveWindow");
732 void on_font_menu_header_font_set(GtkFontButton *w, gpointer data)
734 on_font_set(w, "MenuHeader");
737 void on_font_menu_item_font_set(GtkFontButton *w, gpointer data)
739 on_font_set(w, "MenuItem");
742 void on_font_display_font_set(GtkFontButton *w, gpointer data)
744 on_font_set(w, "OnScreenDisplay");
747 void on_focus_mouse_toggled(GtkToggleButton *w, gpointer data)
753 b = gtk_toggle_button_get_active(w);
754 tree_set_bool("focus/followMouse", b);
757 GtkWidget *delay = glade_xml_get_widget(glade, "focus_delay");
758 GtkWidget *delay_l = glade_xml_get_widget(glade, "focus_delay_label");
759 GtkWidget *delay_u = glade_xml_get_widget(glade,
760 "focus_delay_label_units");
761 GtkWidget *raise = glade_xml_get_widget(glade, "focus_raise");
762 GtkWidget *last = glade_xml_get_widget(glade, "focus_last");
763 gtk_widget_set_sensitive(delay, b);
764 gtk_widget_set_sensitive(delay_l, b);
765 gtk_widget_set_sensitive(delay_u, b);
766 gtk_widget_set_sensitive(raise, b);
767 gtk_widget_set_sensitive(last, b);
771 void on_focus_delay_value_changed(GtkSpinButton *w, gpointer data)
775 tree_set_int("focus/focusDelay",
776 gtk_spin_button_get_value_as_int(w));
779 void on_focus_raise_toggled(GtkToggleButton *w, gpointer data)
783 tree_set_bool("focus/raiseOnFocus", gtk_toggle_button_get_active(w));
786 void on_focus_last_toggled(GtkToggleButton *w, gpointer data)
790 tree_set_bool("focus/focusLast", gtk_toggle_button_get_active(w));
793 void on_focus_new_toggled(GtkToggleButton *w, gpointer data)
797 tree_set_bool("focus/focusNew", gtk_toggle_button_get_active(w));
800 void on_place_mouse_toggled(GtkToggleButton *w, gpointer data)
804 tree_set_string("placement/policy",
805 (gtk_toggle_button_get_active(w) ?
806 "UnderMouse" : "Smart"));
809 void on_resist_window_value_changed(GtkSpinButton *w, gpointer data)
813 tree_set_int("resistance/strength", gtk_spin_button_get_value_as_int(w));
816 void on_resist_edge_value_changed(GtkSpinButton *w, gpointer data)
820 tree_set_int("resistance/screen_edge_strength",
821 gtk_spin_button_get_value_as_int(w));
824 void on_resize_contents_toggled(GtkToggleButton *w, gpointer data)
828 tree_set_bool("resize/drawContents", gtk_toggle_button_get_active(w));
831 void on_dock_top_left_activate(GtkMenuItem *w, gpointer data)
835 tree_set_string("dock/position", "TopLeft");
839 s = glade_xml_get_widget(glade, "dock_float_x");
840 gtk_widget_set_sensitive(s, FALSE);
841 s = glade_xml_get_widget(glade, "dock_float_y");
842 gtk_widget_set_sensitive(s, FALSE);
843 s = glade_xml_get_widget(glade, "dock_float_label");
844 gtk_widget_set_sensitive(s, FALSE);
845 s = glade_xml_get_widget(glade, "dock_float_label_x");
846 gtk_widget_set_sensitive(s, FALSE);
850 void on_dock_top_activate(GtkMenuItem *w, gpointer data)
854 tree_set_string("dock/position", "Top");
858 s = glade_xml_get_widget(glade, "dock_float_x");
859 gtk_widget_set_sensitive(s, FALSE);
860 s = glade_xml_get_widget(glade, "dock_float_y");
861 gtk_widget_set_sensitive(s, FALSE);
862 s = glade_xml_get_widget(glade, "dock_float_label");
863 gtk_widget_set_sensitive(s, FALSE);
864 s = glade_xml_get_widget(glade, "dock_float_label_x");
865 gtk_widget_set_sensitive(s, FALSE);
869 void on_dock_top_right_activate(GtkMenuItem *w, gpointer data)
873 tree_set_string("dock/position", "TopRight");
877 s = glade_xml_get_widget(glade, "dock_float_x");
878 gtk_widget_set_sensitive(s, FALSE);
879 s = glade_xml_get_widget(glade, "dock_float_y");
880 gtk_widget_set_sensitive(s, FALSE);
881 s = glade_xml_get_widget(glade, "dock_float_label");
882 gtk_widget_set_sensitive(s, FALSE);
883 s = glade_xml_get_widget(glade, "dock_float_label_x");
884 gtk_widget_set_sensitive(s, FALSE);
888 void on_dock_left_activate(GtkMenuItem *w, gpointer data)
892 tree_set_string("dock/position", "Left");
896 s = glade_xml_get_widget(glade, "dock_float_x");
897 gtk_widget_set_sensitive(s, FALSE);
898 s = glade_xml_get_widget(glade, "dock_float_y");
899 gtk_widget_set_sensitive(s, FALSE);
900 s = glade_xml_get_widget(glade, "dock_float_label");
901 gtk_widget_set_sensitive(s, FALSE);
902 s = glade_xml_get_widget(glade, "dock_float_label_x");
903 gtk_widget_set_sensitive(s, FALSE);
907 void on_dock_right_activate(GtkMenuItem *w, gpointer data)
911 tree_set_string("dock/position", "Right");
915 s = glade_xml_get_widget(glade, "dock_float_x");
916 gtk_widget_set_sensitive(s, FALSE);
917 s = glade_xml_get_widget(glade, "dock_float_y");
918 gtk_widget_set_sensitive(s, FALSE);
919 s = glade_xml_get_widget(glade, "dock_float_label");
920 gtk_widget_set_sensitive(s, FALSE);
921 s = glade_xml_get_widget(glade, "dock_float_label_x");
922 gtk_widget_set_sensitive(s, FALSE);
927 void on_dock_bottom_left_activate(GtkMenuItem *w, gpointer data)
931 tree_set_string("dock/position", "BottomLeft");
935 s = glade_xml_get_widget(glade, "dock_float_x");
936 gtk_widget_set_sensitive(s, FALSE);
937 s = glade_xml_get_widget(glade, "dock_float_y");
938 gtk_widget_set_sensitive(s, FALSE);
939 s = glade_xml_get_widget(glade, "dock_float_label");
940 gtk_widget_set_sensitive(s, FALSE);
941 s = glade_xml_get_widget(glade, "dock_float_label_x");
942 gtk_widget_set_sensitive(s, FALSE);
946 void on_dock_bottom_activate(GtkMenuItem *w, gpointer data)
950 tree_set_string("dock/position", "Bottom");
954 s = glade_xml_get_widget(glade, "dock_float_x");
955 gtk_widget_set_sensitive(s, FALSE);
956 s = glade_xml_get_widget(glade, "dock_float_y");
957 gtk_widget_set_sensitive(s, FALSE);
958 s = glade_xml_get_widget(glade, "dock_float_label");
959 gtk_widget_set_sensitive(s, FALSE);
960 s = glade_xml_get_widget(glade, "dock_float_label_x");
961 gtk_widget_set_sensitive(s, FALSE);
965 void on_dock_bottom_right_activate(GtkMenuItem *w, gpointer data)
969 tree_set_string("dock/position", "BottomRight");
973 s = glade_xml_get_widget(glade, "dock_float_x");
974 gtk_widget_set_sensitive(s, FALSE);
975 s = glade_xml_get_widget(glade, "dock_float_y");
976 gtk_widget_set_sensitive(s, FALSE);
977 s = glade_xml_get_widget(glade, "dock_float_label");
978 gtk_widget_set_sensitive(s, FALSE);
979 s = glade_xml_get_widget(glade, "dock_float_label_x");
980 gtk_widget_set_sensitive(s, FALSE);
984 void on_dock_floating_activate(GtkMenuItem *w, gpointer data)
988 tree_set_string("dock/position", "Floating");
992 s = glade_xml_get_widget(glade, "dock_float_x");
993 gtk_widget_set_sensitive(s, TRUE);
994 s = glade_xml_get_widget(glade, "dock_float_y");
995 gtk_widget_set_sensitive(s, TRUE);
996 s = glade_xml_get_widget(glade, "dock_float_label");
997 gtk_widget_set_sensitive(s, TRUE);
998 s = glade_xml_get_widget(glade, "dock_float_label_x");
999 gtk_widget_set_sensitive(s, TRUE);
1003 void on_dock_float_x_value_changed(GtkSpinButton *w, gpointer data)
1005 if (mapping) return;
1007 tree_set_int("dock/floatingX", gtk_spin_button_get_value_as_int(w));
1010 void on_dock_float_y_value_changed(GtkSpinButton *w, gpointer data)
1012 if (mapping) return;
1014 tree_set_int("dock/floatingY", gtk_spin_button_get_value_as_int(w));
1017 void on_dock_stacking_top_toggled(GtkToggleButton *w, gpointer data)
1019 if (mapping) return;
1021 if(gtk_toggle_button_get_active(w))
1022 tree_set_string("dock/stacking", "Top");
1025 void on_dock_stacking_normal_toggled(GtkToggleButton *w, gpointer data)
1027 if (mapping) return;
1029 if(gtk_toggle_button_get_active(w))
1030 tree_set_string("dock/stacking", "Normal");
1033 void on_dock_stacking_bottom_toggled(GtkToggleButton *w, gpointer data)
1035 if (mapping) return;
1037 if(gtk_toggle_button_get_active(w))
1038 tree_set_string("dock/stacking", "Bottom");
1041 void on_dock_horizontal_activate(GtkMenuItem *w, gpointer data)
1043 if (mapping) return;
1045 tree_set_string("dock/direction", "Horizontal");
1048 void on_dock_vertical_activate(GtkMenuItem *w, gpointer data)
1050 if (mapping) return;
1052 tree_set_string("dock/direction", "Vertical");
1055 void on_dock_hide_toggled(GtkToggleButton *w, gpointer data)
1057 if (mapping) return;
1059 tree_set_bool("dock/autoHide", gtk_toggle_button_get_active(w));
1061 GtkWidget *delay = glade_xml_get_widget(glade, "dock_hide_delay");
1062 GtkWidget *delay_l = glade_xml_get_widget(glade, "dock_hide_label");
1063 GtkWidget *delay_u = glade_xml_get_widget(glade,
1064 "dock_hide_label_units");
1065 gtk_widget_set_sensitive(delay, gtk_toggle_button_get_active(w));
1066 gtk_widget_set_sensitive(delay_l, gtk_toggle_button_get_active(w));
1067 gtk_widget_set_sensitive(delay_u, gtk_toggle_button_get_active(w));
1071 void on_dock_hide_delay_value_changed(GtkSpinButton *w, gpointer data)
1073 if (mapping) return;
1075 tree_set_int("dock/hideDelay",
1076 gtk_spin_button_get_value_as_int(w));
1079 void on_theme_name_changed(GtkOptionMenu *w, gpointer data)
1083 if (mapping) return;
1085 name = g_list_nth_data(themes, gtk_option_menu_get_history(w));
1088 tree_set_string("theme/name", name);
1091 void on_theme_names_selection_changed(GtkTreeSelection *sel, gpointer data)
1094 GtkTreeModel *model;
1097 if (mapping) return;
1099 if(gtk_tree_selection_get_selected(sel, &model, &iter)) {
1100 gtk_tree_model_get(model, &iter, 0, &name, -1);
1104 tree_set_string("theme/name", name);
1107 void on_title_layout_changed(GtkEntry *w, gpointer data)
1111 gboolean n, d, s, l, i, m, c;
1113 if (mapping) return;
1115 layout = g_strdup(gtk_entry_get_text(w));
1117 n = d = s = l = i = m = c = FALSE;
1119 for (it = layout; *it; ++it) {
1157 /* drop the letter */
1158 for (it2 = it; *it2; ++it2)
1166 gtk_entry_set_text(w, layout);
1167 tree_set_string("theme/titleLayout", layout);
1171 static void set_desktop_names()
1176 gint num = 0, last = -1;
1178 n = tree_get_node("desktops/names", NULL);
1179 while ((c = n->children)) {
1184 for (lit = desktop_names; lit; lit = g_list_next(lit)) {
1185 if (((gchar*)lit->data)[0]) /* not empty */
1191 for (lit = desktop_names; lit && num <= last; lit = g_list_next(lit)) {
1192 xmlNewTextChild(n, NULL, "name", lit->data);
1197 /* make openbox re-set the property */
1198 XDeleteProperty(GDK_DISPLAY(), GDK_ROOT_WINDOW(),
1199 XInternAtom(GDK_DISPLAY(), "_NET_DESKTOP_NAMES", FALSE));
1202 static void set_desktop_number()
1206 tree_set_int("desktops/number", num_desktops);
1208 ce.xclient.type = ClientMessage;
1209 ce.xclient.message_type = XInternAtom(GDK_DISPLAY(),
1210 "_NET_NUMBER_OF_DESKTOPS",
1212 ce.xclient.display = GDK_DISPLAY();
1213 ce.xclient.window = GDK_ROOT_WINDOW();
1214 ce.xclient.format = 32;
1215 ce.xclient.data.l[0] = num_desktops;
1216 ce.xclient.data.l[1] = 0;
1217 ce.xclient.data.l[2] = 0;
1218 ce.xclient.data.l[3] = 0;
1219 ce.xclient.data.l[4] = 0;
1220 XSendEvent(GDK_DISPLAY(), GDK_ROOT_WINDOW(), FALSE,
1221 SubstructureNotifyMask | SubstructureRedirectMask,
1225 void on_desktop_num_value_changed(GtkSpinButton *w, gpointer data)
1227 if (mapping) return;
1229 num_desktops = gtk_spin_button_get_value(w);
1231 set_desktop_number();
1233 reset_desktop_names();
1236 static void on_desktop_names_cell_edited(GtkCellRendererText *cell,
1237 const gchar *path_string,
1238 const gchar *new_text,
1247 if (mapping) return;
1249 path = gtk_tree_path_new_from_string (path_string);
1250 gtk_tree_model_get_iter(GTK_TREE_MODEL(desktop_store), &it, path);
1252 gtk_tree_model_get(GTK_TREE_MODEL(desktop_store), &it, 0, &old_text, -1);
1255 i = gtk_tree_path_get_indices(path)[0];
1256 lit = g_list_nth(desktop_names, i);
1259 lit->data = g_strdup(new_text);
1260 if (new_text[0]) /* not empty */
1261 gtk_list_store_set(desktop_store, &it, 0, lit->data, -1);
1263 gtk_list_store_set(desktop_store, &it, 0, _("(Unnamed desktop)"), -1);
1265 set_desktop_names();