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 GtkWidget *last = glade_xml_get_widget(glade, "focus_last");
138 gtk_widget_set_sensitive(delay, b);
139 gtk_widget_set_sensitive(delay_l, b);
140 gtk_widget_set_sensitive(delay_u, b);
141 gtk_widget_set_sensitive(raise, b);
142 gtk_widget_set_sensitive(last, b);
148 void setup_focus_delay(GtkWidget *w)
151 gtk_spin_button_set_value(GTK_SPIN_BUTTON(w),
152 tree_get_int("focus/focusDelay", 0));
156 void setup_focus_raise(GtkWidget *w)
159 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w),
160 tree_get_bool("focus/raiseOnFocus", FALSE));
164 void setup_focus_last(GtkWidget *w)
167 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w),
168 tree_get_bool("focus/focusLast", FALSE));
172 void setup_focus_new(GtkWidget *w)
175 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w),
176 tree_get_bool("focus/focusNew", TRUE));
180 void setup_place_mouse(GtkWidget *w)
185 s = tree_get_string("placement/policy", "Smart");
186 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w),
187 !g_ascii_strcasecmp(s, "UnderMouse"));
192 void setup_resist_window(GtkWidget *w)
195 gtk_spin_button_set_value(GTK_SPIN_BUTTON(w),
196 tree_get_int("resistance/strength", 10));
200 void setup_resist_edge(GtkWidget *w)
203 gtk_spin_button_set_value(GTK_SPIN_BUTTON(w),
204 tree_get_int("resistance/screen_edge_strength",
209 void setup_resize_contents(GtkWidget *w)
212 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w),
213 tree_get_bool("resize/drawContents", TRUE));
217 void setup_dock_position(GtkWidget *w)
224 s = tree_get_string("dock/position", "TopLeft");
227 if (!strcasecmp(s, "Top"))
228 gtk_option_menu_set_history(GTK_OPTION_MENU(w), 1);
229 else if (!strcasecmp(s, "TopRight"))
230 gtk_option_menu_set_history(GTK_OPTION_MENU(w), 2);
231 else if (!strcasecmp(s, "Left"))
232 gtk_option_menu_set_history(GTK_OPTION_MENU(w), 3);
233 else if (!strcasecmp(s, "Right"))
234 gtk_option_menu_set_history(GTK_OPTION_MENU(w), 4);
235 else if (!strcasecmp(s, "BottomLeft"))
236 gtk_option_menu_set_history(GTK_OPTION_MENU(w), 5);
237 else if (!strcasecmp(s, "Bottom"))
238 gtk_option_menu_set_history(GTK_OPTION_MENU(w), 6);
239 else if (!strcasecmp(s, "BottomRight"))
240 gtk_option_menu_set_history(GTK_OPTION_MENU(w), 7);
241 else if (!strcasecmp(s, "Floating")) {
242 gtk_option_menu_set_history(GTK_OPTION_MENU(w), 8);
245 gtk_option_menu_set_history(GTK_OPTION_MENU(w), 0);
250 s = glade_xml_get_widget(glade, "dock_float_x");
251 gtk_widget_set_sensitive(s, f);
252 s = glade_xml_get_widget(glade, "dock_float_y");
253 gtk_widget_set_sensitive(s, f);
254 s = glade_xml_get_widget(glade, "dock_float_label");
255 gtk_widget_set_sensitive(s, f);
256 s = glade_xml_get_widget(glade, "dock_float_label_x");
257 gtk_widget_set_sensitive(s, f);
263 void setup_dock_float_x(GtkWidget *w)
267 gtk_spin_button_set_value(GTK_SPIN_BUTTON(w),
268 tree_get_int("dock/floatingX", 0));
273 void setup_dock_float_y(GtkWidget *w)
277 gtk_spin_button_set_value(GTK_SPIN_BUTTON(w),
278 tree_get_int("dock/floatingY", 0));
283 void setup_dock_stacking(GtkWidget *top, GtkWidget *normal, GtkWidget *bottom)
289 s = tree_get_string("dock/stacking", "Top");
291 if(!strcasecmp(s, "Normal"))
292 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(normal), TRUE);
293 else if(!strcasecmp(s, "Bottom"))
294 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(bottom), TRUE);
296 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(top), TRUE);
302 void setup_dock_direction(GtkWidget *w)
308 s = tree_get_string("dock/direction", "Vertical");
310 if (!strcasecmp(s, "Horizontal"))
311 gtk_option_menu_set_history(GTK_OPTION_MENU(w), 1);
313 gtk_option_menu_set_history(GTK_OPTION_MENU(w), 0);
319 void setup_dock_hide(GtkWidget *w)
325 b = tree_get_bool("dock/autoHide", FALSE);
326 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), b);
329 GtkWidget *delay = glade_xml_get_widget(glade, "dock_hide_delay");
330 GtkWidget *delay_l = glade_xml_get_widget(glade, "dock_hide_label");
331 GtkWidget *delay_u = glade_xml_get_widget(glade,
332 "dock_hide_label_units");
333 gtk_widget_set_sensitive(delay, b);
334 gtk_widget_set_sensitive(delay_l, b);
335 gtk_widget_set_sensitive(delay_u, b);
341 void setup_dock_hide_delay(GtkWidget *w)
345 gtk_spin_button_set_value(GTK_SPIN_BUTTON(w),
346 tree_get_int("dock/hideDelay", 300));
351 static void add_theme_dir(const gchar *dirname)
356 if ((dir = g_dir_open(dirname, 0, NULL))) {
357 while ((n = g_dir_read_name(dir))) {
360 full = g_build_filename(dirname, n, "openbox-3",
362 if (!g_file_test(full,
363 G_FILE_TEST_IS_REGULAR |
364 G_FILE_TEST_IS_SYMLINK))
370 themes = g_list_append(themes, g_strdup(n));
377 void setup_theme_names(GtkWidget *w)
379 GtkCellRenderer *render;
380 GtkTreeViewColumn *column;
385 GtkTreeSelection *select;
389 name = tree_get_string("theme/name", "TheBear");
391 for (it = themes; it; it = g_list_next(it))
392 g_list_free(it->data);
396 p = g_build_filename(g_get_home_dir(), ".themes", NULL);
402 for (it = parse_xdg_data_dir_paths(); it; it = g_slist_next(it)) {
403 p = g_build_filename(it->data, "themes", NULL);
409 add_theme_dir(THEMEDIR);
411 themes = g_list_sort(themes, (GCompareFunc) strcasecmp);
414 theme_store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_BOOLEAN);
415 gtk_tree_view_set_model(GTK_TREE_VIEW(w), GTK_TREE_MODEL(theme_store));
416 g_object_unref (theme_store);
418 gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(w)),
419 GTK_SELECTION_SINGLE);
421 render = gtk_cell_renderer_text_new();
422 column = gtk_tree_view_column_new_with_attributes
423 ("Name", render, "text", 0, NULL);
424 gtk_tree_view_append_column(GTK_TREE_VIEW(w), column);
426 /* return to regular scheduled programming */
428 for (it = themes; it; it = next) {
431 next = g_list_next(it);
433 /* remove duplicates */
434 if (next && !strcmp(it->data, next->data)) {
436 themes = g_list_delete_link(themes, it);
440 gtk_list_store_append(theme_store, &iter);
441 gtk_list_store_set(theme_store, &iter,
446 if(!strcmp(name, it->data)) {
448 path = gtk_tree_path_new_from_indices(i, -1);
449 gtk_tree_view_set_cursor(GTK_TREE_VIEW(w), path, NULL, FALSE);
456 /* setup the selection handler */
457 select = gtk_tree_view_get_selection(GTK_TREE_VIEW (w));
458 gtk_tree_selection_set_mode(select, GTK_SELECTION_SINGLE);
459 g_signal_connect (G_OBJECT(select), "changed",
460 G_CALLBACK(on_theme_names_selection_changed),
468 void setup_title_layout(GtkWidget *w)
474 layout = tree_get_string("theme/titleLayout", "NLIMC");
475 gtk_entry_set_text(GTK_ENTRY(w), layout);
481 void setup_desktop_num(GtkWidget *w)
485 num_desktops = tree_get_int("desktops/number", 4);
486 gtk_spin_button_set_value(GTK_SPIN_BUTTON(w), num_desktops);
491 void setup_window_border(GtkWidget *w)
497 border = tree_get_bool("theme/keepBorder", TRUE);
498 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), border);
503 static void setup_font(GtkWidget *w, const gchar *place)
505 gchar *fontstring, *node;
506 gchar *name, **names;
513 node = g_strdup_printf("theme/font:place=%s/name", place);
514 name = tree_get_string(node, "Sans");
517 node = g_strdup_printf("theme/font:place=%s/size", place);
518 size = tree_get_string(node, "8");
521 node = g_strdup_printf("theme/font:place=%s/weight", place);
522 weight = tree_get_string(node, "");
525 node = g_strdup_printf("theme/font:place=%s/slant", place);
526 slant = tree_get_string(node, "");
529 /* get only the first font in the string */
530 names = g_strsplit(name, ",", 0);
532 name = g_strdup(names[0]);
535 /* don't use "normal" in the gtk string */
536 if (!g_ascii_strcasecmp(weight, "normal")) {
537 g_free(weight); weight = g_strdup("");
539 if (!g_ascii_strcasecmp(slant, "normal")) {
540 g_free(slant); slant = g_strdup("");
543 fontstring = g_strdup_printf("%s %s %s %s", name, weight, slant, size);
544 gtk_font_button_set_font_name(GTK_FONT_BUTTON(w), fontstring);
554 void setup_font_active(GtkWidget *w)
556 setup_font(w, "ActiveWindow");
559 void setup_font_inactive(GtkWidget *w)
561 setup_font(w, "InactiveWindow");
564 void setup_font_menu_header(GtkWidget *w)
566 setup_font(w, "MenuHeader");
569 void setup_font_menu_item(GtkWidget *w)
571 setup_font(w, "MenuItem");
574 void setup_font_display(GtkWidget *w)
576 setup_font(w, "OnScreenDisplay");
580 static void reset_desktop_names()
587 gtk_list_store_clear(desktop_store);
589 for (lit = desktop_names; lit; lit = g_list_next(lit))
591 g_list_free(desktop_names);
592 desktop_names = NULL;
595 n = tree_get_node("desktops/names", NULL)->children;
599 if (!xmlStrcmp(n->name, (const xmlChar*)"name")) {
600 name = parse_string(doc, n);
602 desktop_names = g_list_append(desktop_names, name);
604 gtk_list_store_append(desktop_store, &it);
605 gtk_list_store_set(desktop_store, &it,
606 0, (name[0] ? name : _("(Unnamed desktop)")),
615 while (i < num_desktops) {
616 gchar *name = g_strdup("");
618 desktop_names = g_list_append(desktop_names, name);
620 gtk_list_store_append(desktop_store, &it);
621 gtk_list_store_set(desktop_store, &it,
622 0, _("(Unnamed desktop)"),
629 void setup_desktop_names(GtkWidget *w)
631 GtkCellRenderer *render;
632 GtkTreeViewColumn *column;
636 desktop_store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_BOOLEAN);
637 gtk_tree_view_set_model(GTK_TREE_VIEW(w), GTK_TREE_MODEL(desktop_store));
638 g_object_unref (desktop_store);
640 gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(w)),
641 GTK_SELECTION_SINGLE);
643 render = gtk_cell_renderer_text_new();
644 g_signal_connect(render, "edited",
645 G_CALLBACK (on_desktop_names_cell_edited),
648 column = gtk_tree_view_column_new_with_attributes
649 ("Name", render, "text", 0, "editable", 1, NULL);
650 gtk_tree_view_append_column(GTK_TREE_VIEW(w), column);
652 reset_desktop_names();
658 /***********************************************************************/
660 void on_window_border_toggled(GtkToggleButton *w, gpointer data)
666 b = gtk_toggle_button_get_active(w);
667 tree_set_bool("theme/keepBorder", b);
670 static void on_font_set(GtkFontButton *w, const gchar *place)
674 const gchar *size = NULL;
675 const gchar *bold = NULL;
676 const gchar *italic = NULL;
680 font = g_strdup(gtk_font_button_get_font_name(w));
681 while ((c = strrchr(font, ' '))) {
682 if (!bold && !italic && !size && atoi(c+1))
684 else if (!bold && !italic && !g_ascii_strcasecmp(c+1, "italic"))
686 else if (!bold && !g_ascii_strcasecmp(c+1, "bold"))
692 if (!bold) bold = "Normal";
693 if (!italic) italic = "Normal";
695 node = g_strdup_printf("theme/font:place=%s/name", place);
696 tree_set_string(node, font);
699 node = g_strdup_printf("theme/font:place=%s/size", place);
700 tree_set_string(node, size);
703 node = g_strdup_printf("theme/font:place=%s/weight", place);
704 tree_set_string(node, bold);
707 node = g_strdup_printf("theme/font:place=%s/slant", place);
708 tree_set_string(node, italic);
714 void on_font_active_font_set(GtkFontButton *w, gpointer data)
716 on_font_set(w, "ActiveWindow");
719 void on_font_inactive_font_set(GtkFontButton *w, gpointer data)
721 on_font_set(w, "InactiveWindow");
724 void on_font_menu_header_font_set(GtkFontButton *w, gpointer data)
726 on_font_set(w, "MenuHeader");
729 void on_font_menu_item_font_set(GtkFontButton *w, gpointer data)
731 on_font_set(w, "MenuItem");
734 void on_font_display_font_set(GtkFontButton *w, gpointer data)
736 on_font_set(w, "OnScreenDisplay");
739 void on_focus_mouse_toggled(GtkToggleButton *w, gpointer data)
745 b = gtk_toggle_button_get_active(w);
746 tree_set_bool("focus/followMouse", b);
749 GtkWidget *delay = glade_xml_get_widget(glade, "focus_delay");
750 GtkWidget *delay_l = glade_xml_get_widget(glade, "focus_delay_label");
751 GtkWidget *delay_u = glade_xml_get_widget(glade,
752 "focus_delay_label_units");
753 GtkWidget *raise = glade_xml_get_widget(glade, "focus_raise");
754 GtkWidget *last = glade_xml_get_widget(glade, "focus_last");
755 gtk_widget_set_sensitive(delay, b);
756 gtk_widget_set_sensitive(delay_l, b);
757 gtk_widget_set_sensitive(delay_u, b);
758 gtk_widget_set_sensitive(raise, b);
759 gtk_widget_set_sensitive(last, b);
763 void on_focus_delay_value_changed(GtkSpinButton *w, gpointer data)
767 tree_set_int("focus/focusDelay",
768 gtk_spin_button_get_value_as_int(w));
771 void on_focus_raise_toggled(GtkToggleButton *w, gpointer data)
775 tree_set_bool("focus/raiseOnFocus", gtk_toggle_button_get_active(w));
778 void on_focus_last_toggled(GtkToggleButton *w, gpointer data)
782 tree_set_bool("focus/focusLast", gtk_toggle_button_get_active(w));
785 void on_focus_new_toggled(GtkToggleButton *w, gpointer data)
789 tree_set_bool("focus/focusNew", gtk_toggle_button_get_active(w));
792 void on_place_mouse_toggled(GtkToggleButton *w, gpointer data)
796 tree_set_string("placement/policy",
797 (gtk_toggle_button_get_active(w) ?
798 "UnderMouse" : "Smart"));
801 void on_resist_window_value_changed(GtkSpinButton *w, gpointer data)
805 tree_set_int("resistance/strength", gtk_spin_button_get_value_as_int(w));
808 void on_resist_edge_value_changed(GtkSpinButton *w, gpointer data)
812 tree_set_int("resistance/screen_edge_strength",
813 gtk_spin_button_get_value_as_int(w));
816 void on_resize_contents_toggled(GtkToggleButton *w, gpointer data)
820 tree_set_bool("resize/drawContents", gtk_toggle_button_get_active(w));
823 void on_dock_top_left_activate(GtkMenuItem *w, gpointer data)
827 tree_set_string("dock/position", "TopLeft");
831 s = glade_xml_get_widget(glade, "dock_float_x");
832 gtk_widget_set_sensitive(s, FALSE);
833 s = glade_xml_get_widget(glade, "dock_float_y");
834 gtk_widget_set_sensitive(s, FALSE);
835 s = glade_xml_get_widget(glade, "dock_float_label");
836 gtk_widget_set_sensitive(s, FALSE);
837 s = glade_xml_get_widget(glade, "dock_float_label_x");
838 gtk_widget_set_sensitive(s, FALSE);
842 void on_dock_top_activate(GtkMenuItem *w, gpointer data)
846 tree_set_string("dock/position", "Top");
850 s = glade_xml_get_widget(glade, "dock_float_x");
851 gtk_widget_set_sensitive(s, FALSE);
852 s = glade_xml_get_widget(glade, "dock_float_y");
853 gtk_widget_set_sensitive(s, FALSE);
854 s = glade_xml_get_widget(glade, "dock_float_label");
855 gtk_widget_set_sensitive(s, FALSE);
856 s = glade_xml_get_widget(glade, "dock_float_label_x");
857 gtk_widget_set_sensitive(s, FALSE);
861 void on_dock_top_right_activate(GtkMenuItem *w, gpointer data)
865 tree_set_string("dock/position", "TopRight");
869 s = glade_xml_get_widget(glade, "dock_float_x");
870 gtk_widget_set_sensitive(s, FALSE);
871 s = glade_xml_get_widget(glade, "dock_float_y");
872 gtk_widget_set_sensitive(s, FALSE);
873 s = glade_xml_get_widget(glade, "dock_float_label");
874 gtk_widget_set_sensitive(s, FALSE);
875 s = glade_xml_get_widget(glade, "dock_float_label_x");
876 gtk_widget_set_sensitive(s, FALSE);
880 void on_dock_left_activate(GtkMenuItem *w, gpointer data)
884 tree_set_string("dock/position", "Left");
888 s = glade_xml_get_widget(glade, "dock_float_x");
889 gtk_widget_set_sensitive(s, FALSE);
890 s = glade_xml_get_widget(glade, "dock_float_y");
891 gtk_widget_set_sensitive(s, FALSE);
892 s = glade_xml_get_widget(glade, "dock_float_label");
893 gtk_widget_set_sensitive(s, FALSE);
894 s = glade_xml_get_widget(glade, "dock_float_label_x");
895 gtk_widget_set_sensitive(s, FALSE);
899 void on_dock_right_activate(GtkMenuItem *w, gpointer data)
903 tree_set_string("dock/position", "Right");
907 s = glade_xml_get_widget(glade, "dock_float_x");
908 gtk_widget_set_sensitive(s, FALSE);
909 s = glade_xml_get_widget(glade, "dock_float_y");
910 gtk_widget_set_sensitive(s, FALSE);
911 s = glade_xml_get_widget(glade, "dock_float_label");
912 gtk_widget_set_sensitive(s, FALSE);
913 s = glade_xml_get_widget(glade, "dock_float_label_x");
914 gtk_widget_set_sensitive(s, FALSE);
919 void on_dock_bottom_left_activate(GtkMenuItem *w, gpointer data)
923 tree_set_string("dock/position", "BottomLeft");
927 s = glade_xml_get_widget(glade, "dock_float_x");
928 gtk_widget_set_sensitive(s, FALSE);
929 s = glade_xml_get_widget(glade, "dock_float_y");
930 gtk_widget_set_sensitive(s, FALSE);
931 s = glade_xml_get_widget(glade, "dock_float_label");
932 gtk_widget_set_sensitive(s, FALSE);
933 s = glade_xml_get_widget(glade, "dock_float_label_x");
934 gtk_widget_set_sensitive(s, FALSE);
938 void on_dock_bottom_activate(GtkMenuItem *w, gpointer data)
942 tree_set_string("dock/position", "Bottom");
946 s = glade_xml_get_widget(glade, "dock_float_x");
947 gtk_widget_set_sensitive(s, FALSE);
948 s = glade_xml_get_widget(glade, "dock_float_y");
949 gtk_widget_set_sensitive(s, FALSE);
950 s = glade_xml_get_widget(glade, "dock_float_label");
951 gtk_widget_set_sensitive(s, FALSE);
952 s = glade_xml_get_widget(glade, "dock_float_label_x");
953 gtk_widget_set_sensitive(s, FALSE);
957 void on_dock_bottom_right_activate(GtkMenuItem *w, gpointer data)
961 tree_set_string("dock/position", "BottomRight");
965 s = glade_xml_get_widget(glade, "dock_float_x");
966 gtk_widget_set_sensitive(s, FALSE);
967 s = glade_xml_get_widget(glade, "dock_float_y");
968 gtk_widget_set_sensitive(s, FALSE);
969 s = glade_xml_get_widget(glade, "dock_float_label");
970 gtk_widget_set_sensitive(s, FALSE);
971 s = glade_xml_get_widget(glade, "dock_float_label_x");
972 gtk_widget_set_sensitive(s, FALSE);
976 void on_dock_floating_activate(GtkMenuItem *w, gpointer data)
980 tree_set_string("dock/position", "Floating");
984 s = glade_xml_get_widget(glade, "dock_float_x");
985 gtk_widget_set_sensitive(s, TRUE);
986 s = glade_xml_get_widget(glade, "dock_float_y");
987 gtk_widget_set_sensitive(s, TRUE);
988 s = glade_xml_get_widget(glade, "dock_float_label");
989 gtk_widget_set_sensitive(s, TRUE);
990 s = glade_xml_get_widget(glade, "dock_float_label_x");
991 gtk_widget_set_sensitive(s, TRUE);
995 void on_dock_float_x_value_changed(GtkSpinButton *w, gpointer data)
999 tree_set_int("dock/floatingX", gtk_spin_button_get_value_as_int(w));
1002 void on_dock_float_y_value_changed(GtkSpinButton *w, gpointer data)
1004 if (mapping) return;
1006 tree_set_int("dock/floatingY", gtk_spin_button_get_value_as_int(w));
1009 void on_dock_stacking_top_toggled(GtkToggleButton *w, gpointer data)
1011 if (mapping) return;
1013 if(gtk_toggle_button_get_active(w))
1014 tree_set_string("dock/stacking", "Top");
1017 void on_dock_stacking_normal_toggled(GtkToggleButton *w, gpointer data)
1019 if (mapping) return;
1021 if(gtk_toggle_button_get_active(w))
1022 tree_set_string("dock/stacking", "Normal");
1025 void on_dock_stacking_bottom_toggled(GtkToggleButton *w, gpointer data)
1027 if (mapping) return;
1029 if(gtk_toggle_button_get_active(w))
1030 tree_set_string("dock/stacking", "Bottom");
1033 void on_dock_horizontal_activate(GtkMenuItem *w, gpointer data)
1035 if (mapping) return;
1037 tree_set_string("dock/direction", "Horizontal");
1040 void on_dock_vertical_activate(GtkMenuItem *w, gpointer data)
1042 if (mapping) return;
1044 tree_set_string("dock/direction", "Vertical");
1047 void on_dock_hide_toggled(GtkToggleButton *w, gpointer data)
1049 if (mapping) return;
1051 tree_set_bool("dock/autoHide", gtk_toggle_button_get_active(w));
1053 GtkWidget *delay = glade_xml_get_widget(glade, "dock_hide_delay");
1054 GtkWidget *delay_l = glade_xml_get_widget(glade, "dock_hide_label");
1055 GtkWidget *delay_u = glade_xml_get_widget(glade,
1056 "dock_hide_label_units");
1057 gtk_widget_set_sensitive(delay, gtk_toggle_button_get_active(w));
1058 gtk_widget_set_sensitive(delay_l, gtk_toggle_button_get_active(w));
1059 gtk_widget_set_sensitive(delay_u, gtk_toggle_button_get_active(w));
1063 void on_dock_hide_delay_value_changed(GtkSpinButton *w, gpointer data)
1065 if (mapping) return;
1067 tree_set_int("dock/hideDelay",
1068 gtk_spin_button_get_value_as_int(w));
1071 void on_theme_name_changed(GtkOptionMenu *w, gpointer data)
1075 if (mapping) return;
1077 name = g_list_nth_data(themes, gtk_option_menu_get_history(w));
1080 tree_set_string("theme/name", name);
1083 void on_theme_names_selection_changed(GtkTreeSelection *sel, gpointer data)
1086 GtkTreeModel *model;
1089 if (mapping) return;
1091 if(gtk_tree_selection_get_selected(sel, &model, &iter)) {
1092 gtk_tree_model_get(model, &iter, 0, &name, -1);
1096 tree_set_string("theme/name", name);
1099 void on_title_layout_changed(GtkEntry *w, gpointer data)
1103 gboolean n, d, s, l, i, m, c;
1105 if (mapping) return;
1107 layout = g_strdup(gtk_entry_get_text(w));
1109 n = d = s = l = i = m = c = FALSE;
1111 for (it = layout; *it; ++it) {
1149 /* drop the letter */
1150 for (it2 = it; *it2; ++it2)
1158 gtk_entry_set_text(w, layout);
1159 tree_set_string("theme/titleLayout", layout);
1163 static void set_desktop_names()
1168 gint num = 0, last = -1;
1170 n = tree_get_node("desktops/names", NULL);
1171 while ((c = n->children)) {
1176 for (lit = desktop_names; lit; lit = g_list_next(lit)) {
1177 if (((gchar*)lit->data)[0]) /* not empty */
1183 for (lit = desktop_names; lit && num <= last; lit = g_list_next(lit)) {
1184 xmlNewTextChild(n, NULL, "name", lit->data);
1189 /* make openbox re-set the property */
1190 XDeleteProperty(GDK_DISPLAY(), GDK_ROOT_WINDOW(),
1191 XInternAtom(GDK_DISPLAY(), "_NET_DESKTOP_NAMES", FALSE));
1194 static void set_desktop_number()
1198 tree_set_int("desktops/number", num_desktops);
1200 ce.xclient.type = ClientMessage;
1201 ce.xclient.message_type = XInternAtom(GDK_DISPLAY(),
1202 "_NET_NUMBER_OF_DESKTOPS",
1204 ce.xclient.display = GDK_DISPLAY();
1205 ce.xclient.window = GDK_ROOT_WINDOW();
1206 ce.xclient.format = 32;
1207 ce.xclient.data.l[0] = num_desktops;
1208 ce.xclient.data.l[1] = 0;
1209 ce.xclient.data.l[2] = 0;
1210 ce.xclient.data.l[3] = 0;
1211 ce.xclient.data.l[4] = 0;
1212 XSendEvent(GDK_DISPLAY(), GDK_ROOT_WINDOW(), FALSE,
1213 SubstructureNotifyMask | SubstructureRedirectMask,
1217 void on_desktop_num_value_changed(GtkSpinButton *w, gpointer data)
1219 if (mapping) return;
1221 num_desktops = gtk_spin_button_get_value(w);
1223 set_desktop_number();
1225 reset_desktop_names();
1228 static void on_desktop_names_cell_edited(GtkCellRendererText *cell,
1229 const gchar *path_string,
1230 const gchar *new_text,
1233 if (mapping) return;
1235 GtkTreePath *path = gtk_tree_path_new_from_string (path_string);
1241 gtk_tree_model_get_iter(GTK_TREE_MODEL(desktop_store), &it, path);
1243 gtk_tree_model_get(GTK_TREE_MODEL(desktop_store), &it, 0, &old_text, -1);
1246 i = gtk_tree_path_get_indices(path)[0];
1247 lit = g_list_nth(desktop_names, i);
1250 lit->data = g_strdup(new_text);
1251 if (new_text[0]) /* not empty */
1252 gtk_list_store_set(desktop_store, &it, 0, lit->data, -1);
1254 gtk_list_store_set(desktop_store, &it, 0, _("(Unnamed desktop)"), -1);
1256 set_desktop_names();