From 510db1d630afce59d26d92410acc0bfa6e1478b9 Mon Sep 17 00:00:00 2001 From: Stefano Karapetsas Date: Tue, 18 Feb 2014 12:31:31 +0100 Subject: windows: Use GSettings and drop libwindow-settings dependency --- capplets/windows/Makefile.am | 5 +- capplets/windows/mate-window-properties.c | 452 ++++++++++-------------------- 2 files changed, 146 insertions(+), 311 deletions(-) diff --git a/capplets/windows/Makefile.am b/capplets/windows/Makefile.am index 1327573e..6be448d3 100644 --- a/capplets/windows/Makefile.am +++ b/capplets/windows/Makefile.am @@ -3,8 +3,7 @@ cappletname = window bin_PROGRAMS = mate-window-properties -mate_window_properties_LDADD = $(MATECC_CAPPLETS_LIBS) \ - $(top_builddir)/libwindow-settings/libmate-window-settings.la +mate_window_properties_LDADD = $(MATECC_CAPPLETS_LIBS) mate_window_properties_SOURCES = \ mate-metacity-support.h \ @@ -21,8 +20,6 @@ Desktop_in_files = mate-window-properties.desktop.in desktop_DATA = $(Desktop_in_files:.desktop.in=.desktop) AM_CPPFLAGS = $(MATECC_CAPPLETS_CFLAGS) \ - -I$(top_srcdir)/libwindow-settings \ - -DMATE_WINDOW_MANAGER_MODULE_PATH=\""$(libdir)/window-manager-settings"\" \ -DUIDIR=\""$(uidir)"\" \ -DMATELOCALEDIR="\"$(datadir)/locale\"" \ -DPIXMAPDIR=\""$(pixmapdir)"\" diff --git a/capplets/windows/mate-window-properties.c b/capplets/windows/mate-window-properties.c index d51895b7..e663cd8f 100644 --- a/capplets/windows/mate-window-properties.c +++ b/capplets/windows/mate-window-properties.c @@ -30,7 +30,6 @@ #include #include #include -#include #include @@ -38,6 +37,37 @@ #include "wm-common.h" #include "capplet-util.h" +#define MARCO_SCHEMA "org.mate.Marco.general" +#define MARCO_THEME_KEY "theme" +#define MARCO_FONT_KEY "titlebar-font" +#define MARCO_FOCUS_KEY "focus-mode" +#define MARCO_USE_SYSTEM_FONT_KEY "titlebar-uses-system-font" +#define MARCO_AUTORAISE_KEY "auto-raise" +#define MARCO_AUTORAISE_DELAY_KEY "auto-raise-delay" +#define MARCO_MOUSE_MODIFIER_KEY "mouse-button-modifier" +#define MARCO_DOUBLE_CLICK_TITLEBAR_KEY "action-double-click-titlebar" +#define MARCO_COMPOSITING_MANAGER_KEY "compositing-manager" +#define MARCO_COMPOSITING_FAST_ALT_TAB_KEY "compositing-fast-alt-tab" + +/* keep following enums in sync with marco */ +enum +{ + ACTION_TITLEBAR_TOGGLE_SHADE, + ACTION_TITLEBAR_TOGGLE_MAXIMIZE, + ACTION_TITLEBAR_TOGGLE_MAXIMIZE_HORIZONTALLY, + ACTION_TITLEBAR_TOGGLE_MAXIMIZE_VERTICALLY, + ACTION_TITLEBAR_MINIMIZE, + ACTION_TITLEBAR_NONE, + ACTION_TITLEBAR_LOWER, + ACTION_TITLEBAR_MENU +}; +enum +{ + FOCUS_MODE_CLICK, + FOCUS_MODE_SLOPPY, + FOCUS_MODE_MOUSE +}; + typedef struct { int number; @@ -46,7 +76,6 @@ typedef struct GtkWidget *radio; } MouseClickModifier; -static MateWindowManager *current_wm; /* may be NULL */ static GtkWidget *dialog_win; static GObject *compositing_checkbutton; static GObject *compositing_fast_alt_tab_checkbutton; @@ -57,9 +86,7 @@ static GtkWidget *autoraise_delay_hbox; static GObject *double_click_titlebar_optionmenu; static GObject *alt_click_hbox; -static MateWMSettings *settings; -static const MateWMDoubleClickAction *double_click_actions = NULL; -static int n_double_click_actions = 0; +static GSettings *marco_settings; static MouseClickModifier *mouse_modifiers = NULL; static int n_mouse_modifiers = 0; @@ -67,177 +94,101 @@ static int n_mouse_modifiers = 0; static void reload_mouse_modifiers (void); static void -compositing_manager_toggled_callback (GtkWidget *button, - void *data) +update_sensitivity () { - MateWMSettings new_settings; - - new_settings.flags = MATE_WM_SETTING_COMPOSITING_MANAGER; - new_settings.compositing_manager = - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)); - - if (current_wm != NULL && new_settings.compositing_manager != settings->compositing_manager) - mate_window_manager_change_settings (current_wm, &new_settings); + gtk_widget_set_sensitive (GTK_WIDGET (compositing_fast_alt_tab_checkbutton), + g_settings_get_boolean (marco_settings, MARCO_COMPOSITING_MANAGER_KEY)); + gtk_widget_set_sensitive (GTK_WIDGET (autoraise_checkbutton), + g_settings_get_enum (marco_settings, MARCO_FOCUS_KEY) != FOCUS_MODE_CLICK); + gtk_widget_set_sensitive (GTK_WIDGET (autoraise_delay_hbox), + g_settings_get_enum (marco_settings, MARCO_FOCUS_KEY) != FOCUS_MODE_CLICK && + g_settings_get_boolean (marco_settings, MARCO_AUTORAISE_KEY)); } static void -compositing_fast_alt_tab_toggled_callback (GtkWidget *button, - void *data) +marco_settings_changed_callback (GSettings *settings, + const gchar *key, + gpointer user_data) { - MateWMSettings new_settings; - - new_settings.flags = MATE_WM_SETTING_COMPOSITING_ALTTAB; - new_settings.compositing_fast_alt_tab = - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)); - - if (current_wm != NULL && new_settings.compositing_fast_alt_tab != settings->compositing_fast_alt_tab) - mate_window_manager_change_settings (current_wm, &new_settings); + update_sensitivity (); } static void mouse_focus_toggled_callback (GtkWidget *button, void *data) { - MateWMSettings new_settings; - - new_settings.flags = MATE_WM_SETTING_MOUSE_FOCUS; - new_settings.focus_follows_mouse = - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)); - - if (current_wm != NULL && new_settings.focus_follows_mouse != settings->focus_follows_mouse) - mate_window_manager_change_settings (current_wm, &new_settings); + g_settings_set_enum (marco_settings, + MARCO_FOCUS_KEY, + gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)) ? + FOCUS_MODE_SLOPPY : FOCUS_MODE_CLICK); } static void -autoraise_toggled_callback (GtkWidget *button, - void *data) +mouse_focus_changed_callback (GSettings *settings, + const gchar *key, + gpointer user_data) { - MateWMSettings new_settings; - - new_settings.flags = MATE_WM_SETTING_AUTORAISE; - new_settings.autoraise = - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)); - - if (current_wm != NULL && new_settings.autoraise != settings->autoraise) - mate_window_manager_change_settings (current_wm, &new_settings); - + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (focus_mode_checkbutton), + g_settings_get_enum (settings, key) == FOCUS_MODE_SLOPPY); } static void autoraise_delay_value_changed_callback (GtkWidget *slider, void *data) { - MateWMSettings new_settings; - - new_settings.flags = MATE_WM_SETTING_AUTORAISE_DELAY; - new_settings.autoraise_delay = - gtk_range_get_value (GTK_RANGE (slider)) * 1000; - - if (current_wm != NULL && new_settings.autoraise_delay != settings->autoraise_delay) - mate_window_manager_change_settings (current_wm, &new_settings); + g_settings_set_int (marco_settings, + MARCO_AUTORAISE_DELAY_KEY, + gtk_range_get_value (GTK_RANGE (slider)) * 1000); } static void double_click_titlebar_changed_callback (GtkWidget *optionmenu, void *data) { - MateWMSettings new_settings; - - new_settings.flags = MATE_WM_SETTING_DOUBLE_CLICK_ACTION; - new_settings.double_click_action = - gtk_combo_box_get_active (GTK_COMBO_BOX (optionmenu)); - - if (current_wm != NULL && new_settings.double_click_action != settings->double_click_action) - mate_window_manager_change_settings (current_wm, &new_settings); + g_settings_set_enum (marco_settings, MARCO_DOUBLE_CLICK_TITLEBAR_KEY, + gtk_combo_box_get_active (GTK_COMBO_BOX (optionmenu))); } static void alt_click_radio_toggled_callback (GtkWidget *radio, void *data) { - MateWMSettings new_settings; - gboolean active; MouseClickModifier *modifier = data; + gboolean active; + gchar *value; - new_settings.flags = MATE_WM_SETTING_MOUSE_MOVE_MODIFIER; active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radio)); - if (active && current_wm != NULL) { - new_settings.mouse_move_modifier = modifier->value; - - if ((settings->mouse_move_modifier == NULL) || - (strcmp (new_settings.mouse_move_modifier, - settings->mouse_move_modifier) != 0)) - mate_window_manager_change_settings (current_wm, &new_settings); + if (active) { + value = g_strdup_printf ("<%s>", modifier->value); + g_settings_set_string (marco_settings, MARCO_MOUSE_MODIFIER_KEY, value); + g_free (value); } } static void -update_sensitivity (void) -{ - gtk_widget_set_sensitive (GTK_WIDGET (autoraise_checkbutton), - settings->focus_follows_mouse); - - gtk_widget_set_sensitive (autoraise_delay_hbox, - settings->focus_follows_mouse && settings->autoraise); - - gtk_widget_set_sensitive (GTK_WIDGET (double_click_titlebar_optionmenu), - n_double_click_actions > 1); - - gtk_widget_set_sensitive (GTK_WIDGET (compositing_fast_alt_tab_checkbutton), - settings->compositing_manager); - - /* disable the whole dialog while no WM is running, or - * a WM we don't understand is running. We should probably do - * something better. I don't want to just launch the config tool - * as we would on startup though, because then you'd get weirdness - * in the gap time between old and new WM. - */ - gtk_widget_set_sensitive (dialog_win, current_wm != NULL); -} - -static void -init_settings_struct (MateWMSettings *settings) -{ - /* Init fields that weren't initialized */ - if ((settings->flags & MATE_WM_SETTING_COMPOSITING_MANAGER) == 0) - settings->compositing_manager = FALSE; - - if ((settings->flags & MATE_WM_SETTING_COMPOSITING_ALTTAB) == 0) - settings->compositing_fast_alt_tab = FALSE; - - if ((settings->flags & MATE_WM_SETTING_MOUSE_FOCUS) == 0) - settings->focus_follows_mouse = FALSE; - - if ((settings->flags & MATE_WM_SETTING_AUTORAISE) == 0) - settings->autoraise = FALSE; - - if ((settings->flags & MATE_WM_SETTING_AUTORAISE_DELAY) == 0) - settings->autoraise_delay = 1000; - - if ((settings->flags & MATE_WM_SETTING_MOUSE_MOVE_MODIFIER) == 0) - settings->mouse_move_modifier = "Super"; - - if ((settings->flags & MATE_WM_SETTING_DOUBLE_CLICK_ACTION) == 0) - settings->double_click_action = 0; -} - -static void -set_alt_click_value (const MateWMSettings *settings) +set_alt_click_value () { gboolean match_found = FALSE; + gchar *mouse_move_modifier; + gchar *value; int i; + mouse_move_modifier = g_settings_get_string (marco_settings, MARCO_MOUSE_MODIFIER_KEY); + /* We look for a matching modifier and set it. */ - if (settings->mouse_move_modifier != NULL) { - for (i = 0; i < n_mouse_modifiers; i ++) - if (strcmp (mouse_modifiers[i].value, - settings->mouse_move_modifier) == 0) { + if (mouse_move_modifier != NULL) { + for (i = 0; i < n_mouse_modifiers; i ++) { + value = g_strdup_printf ("<%s>", mouse_modifiers[i].value); + if (strcmp (value, mouse_move_modifier) == 0) { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (mouse_modifiers[i].radio), TRUE); match_found = TRUE; break; } + g_free (value); + } + g_free (mouse_move_modifier); } /* No matching modifier was found; we set all the toggle buttons to be @@ -249,119 +200,38 @@ set_alt_click_value (const MateWMSettings *settings) } static void -reload_settings (void) +wm_unsupported () { - MateWMSettings new_settings; - - g_assert (n_mouse_modifiers > 0); - - if (current_wm != NULL) { - new_settings.flags = - MATE_WM_SETTING_COMPOSITING_MANAGER | - MATE_WM_SETTING_COMPOSITING_ALTTAB | - MATE_WM_SETTING_MOUSE_FOCUS | - MATE_WM_SETTING_AUTORAISE | - MATE_WM_SETTING_AUTORAISE_DELAY | - MATE_WM_SETTING_MOUSE_MOVE_MODIFIER | - MATE_WM_SETTING_DOUBLE_CLICK_ACTION; - - /* this will clear any flags that don't get filled in */ - mate_window_manager_get_settings (current_wm, &new_settings); - } else { - new_settings.flags = 0; - } - - init_settings_struct (&new_settings); - - if (new_settings.compositing_manager != settings->compositing_manager) - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (compositing_checkbutton), - new_settings.compositing_manager); - - if (new_settings.compositing_fast_alt_tab != settings->compositing_fast_alt_tab) - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (compositing_fast_alt_tab_checkbutton), - new_settings.compositing_fast_alt_tab); - - if (new_settings.focus_follows_mouse != settings->focus_follows_mouse) - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (focus_mode_checkbutton), - new_settings.focus_follows_mouse); - - if (new_settings.autoraise != settings->autoraise) - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (autoraise_checkbutton), - new_settings.autoraise); + GtkWidget *no_tool_dialog; - if (new_settings.autoraise_delay != settings->autoraise_delay) - gtk_range_set_value (GTK_RANGE (autoraise_delay_slider), - new_settings.autoraise_delay / 1000.0); + no_tool_dialog = + gtk_message_dialog_new (NULL, + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_ERROR, + GTK_BUTTONS_CLOSE, + " "); + gtk_window_set_title (GTK_WINDOW (no_tool_dialog), ""); + gtk_window_set_resizable (GTK_WINDOW (no_tool_dialog), FALSE); - if (n_double_click_actions > 0 && - new_settings.double_click_action != settings->double_click_action) { - gtk_combo_box_set_active (GTK_COMBO_BOX (double_click_titlebar_optionmenu), - new_settings.double_click_action); - } - - if (settings->mouse_move_modifier == NULL || - new_settings.mouse_move_modifier == NULL || - strcmp (settings->mouse_move_modifier, - new_settings.mouse_move_modifier) != 0) { - set_alt_click_value (&new_settings); - } + gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (no_tool_dialog), _("The current window manager is unsupported")); - mate_wm_settings_free (settings); - settings = mate_wm_settings_copy (&new_settings); + gtk_dialog_run (GTK_DIALOG (no_tool_dialog)); - update_sensitivity (); -} - -static void -wm_settings_changed_callback (MateWindowManager *wm, - void *data) -{ - reload_settings (); + gtk_widget_destroy (no_tool_dialog); } static void -update_wm (GdkScreen *screen, - gboolean load_settings) +wm_changed_callback (GdkScreen *screen, + void *data) { - int i; + const char *current_wm; - g_assert (n_mouse_modifiers > 0); + current_wm = gdk_x11_screen_get_window_manager_name (screen); - if (current_wm != NULL) { - g_signal_handlers_disconnect_by_func (G_OBJECT (current_wm), - G_CALLBACK (wm_settings_changed_callback), - NULL); - current_wm = NULL; - double_click_actions = NULL; - n_double_click_actions = 0; + if (g_strcmp0 (current_wm, WM_COMMON_MARCO) != 0) { + wm_unsupported (); + gtk_main_quit (); } - - current_wm = mate_wm_manager_get_current (screen); - - if (current_wm != NULL) { - g_signal_connect (G_OBJECT (current_wm), "settings_changed", - G_CALLBACK (wm_settings_changed_callback), NULL); - - mate_window_manager_get_double_click_actions (current_wm, - &double_click_actions, - &n_double_click_actions); - - } - - for (i = 0; i < n_double_click_actions; i++) { - gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (double_click_titlebar_optionmenu), - double_click_actions[i].human_readable_name); - } - - if (load_settings) - reload_settings (); -} - -static void -wm_changed_callback (GdkScreen *screen, - void *data) -{ - update_wm (screen, TRUE); } static void @@ -378,60 +248,13 @@ response_cb (GtkWidget *dialog_win, } } -static void -try_spawn_config_tool (GdkScreen *screen) -{ - GError *error; - - error = NULL; - mate_wm_manager_spawn_config_tool_for_current (screen, &error); - - if (error != NULL) { - GtkWidget *no_tool_dialog; - char *str; - char *escaped; - - escaped = g_markup_escape_text (error->message, -1); - - str = g_strdup_printf ("%s\n\n%s", - _("Cannot start the preferences application for your window manager"), - escaped); - g_free (escaped); - - no_tool_dialog = - gtk_message_dialog_new (NULL, - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_CLOSE, - " "); - gtk_window_set_title (GTK_WINDOW (no_tool_dialog), ""); - gtk_window_set_resizable (GTK_WINDOW (no_tool_dialog), FALSE); - - gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (no_tool_dialog), str); - - g_free (str); - - gtk_dialog_run (GTK_DIALOG (no_tool_dialog)); - - gtk_widget_destroy (no_tool_dialog); - g_error_free (error); - - exit (1); - } - - /* exit, let the config tool handle it */ - exit (0); -} - int main (int argc, char **argv) { GdkScreen *screen; - MateWMSettings new_settings; GtkBuilder *builder; GError *error = NULL; - const char *name; - int rc = 0; + const char *current_wm; int i; bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR); @@ -440,25 +263,21 @@ main (int argc, char **argv) gtk_init (&argc, &argv); - mate_wm_manager_init (); - screen = gdk_display_get_default_screen (gdk_display_get_default ()); + current_wm = gdk_x11_screen_get_window_manager_name (screen); - current_wm = mate_wm_manager_get_current (screen); - - if (current_wm == NULL) { - /* metacity support */ - name = gdk_x11_screen_get_window_manager_name (screen); - if (g_strcmp0 (name, WM_COMMON_METACITY) == 0) { - mate_metacity_config_tool (); - return 0; - } + if (g_strcmp0 (current_wm, WM_COMMON_METACITY) == 0) { + mate_metacity_config_tool (); + return 0; + } - /* other window managers */ - try_spawn_config_tool (screen); - goto out; + if (g_strcmp0 (current_wm, WM_COMMON_MARCO) != 0) { + wm_unsupported (); + return 1; } + marco_settings = g_settings_new (MARCO_SCHEMA); + builder = gtk_builder_new (); gtk_builder_set_translation_domain (builder, GETTEXT_PACKAGE); @@ -466,8 +285,7 @@ main (int argc, char **argv) g_warning ("Could not parse UI file: %s", error->message); g_error_free (error); g_object_unref (builder); - rc = 1; - goto out; + return 1; } dialog_win = GTK_WIDGET (gtk_builder_get_object (builder, @@ -494,20 +312,23 @@ main (int argc, char **argv) gtk_range_set_increments (GTK_RANGE (autoraise_delay_slider), 0.2, 1.0); - new_settings.flags = 0; - init_settings_struct (&new_settings); - settings = mate_wm_settings_copy (&new_settings); reload_mouse_modifiers (); - update_wm (screen, FALSE); - set_alt_click_value (&new_settings); - gtk_range_set_value (GTK_RANGE (autoraise_delay_slider), - new_settings.autoraise_delay / 1000.0); + gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (double_click_titlebar_optionmenu), _("Roll up")); + gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (double_click_titlebar_optionmenu), _("Maximize")); + gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (double_click_titlebar_optionmenu), _("Maximize Horizontally")); + gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (double_click_titlebar_optionmenu), _("Maximize Vertically")); + gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (double_click_titlebar_optionmenu), _("Minimize")); + gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (double_click_titlebar_optionmenu), _("None")); gtk_combo_box_set_active (GTK_COMBO_BOX (double_click_titlebar_optionmenu), - new_settings.double_click_action); + g_settings_get_enum (marco_settings, MARCO_DOUBLE_CLICK_TITLEBAR_KEY)); - reload_settings (); /* must come before below signal connections */ + set_alt_click_value (); + gtk_range_set_value (GTK_RANGE (autoraise_delay_slider), + g_settings_get_int (marco_settings, MARCO_AUTORAISE_DELAY_KEY) / 1000.0); + gtk_combo_box_set_active (GTK_COMBO_BOX (double_click_titlebar_optionmenu), + g_settings_get_enum (marco_settings, MARCO_DOUBLE_CLICK_TITLEBAR_KEY)); g_signal_connect (G_OBJECT (dialog_win), "response", G_CALLBACK (response_cb), NULL); @@ -515,17 +336,31 @@ main (int argc, char **argv) g_signal_connect (G_OBJECT (dialog_win), "destroy", G_CALLBACK (gtk_main_quit), NULL); - g_signal_connect (compositing_checkbutton, "toggled", - G_CALLBACK (compositing_manager_toggled_callback), NULL); + g_signal_connect (marco_settings, "changed", + G_CALLBACK (marco_settings_changed_callback), NULL); - g_signal_connect (compositing_fast_alt_tab_checkbutton, "toggled", - G_CALLBACK (compositing_fast_alt_tab_toggled_callback), NULL); + g_settings_bind (marco_settings, + MARCO_COMPOSITING_MANAGER_KEY, + compositing_checkbutton, + "active", + G_SETTINGS_BIND_DEFAULT); + + g_settings_bind (marco_settings, + MARCO_COMPOSITING_FAST_ALT_TAB_KEY, + compositing_fast_alt_tab_checkbutton, + "active", + G_SETTINGS_BIND_DEFAULT); g_signal_connect (focus_mode_checkbutton, "toggled", G_CALLBACK (mouse_focus_toggled_callback), NULL); + g_signal_connect (marco_settings, "changed::" MARCO_FOCUS_KEY, + G_CALLBACK (mouse_focus_changed_callback), NULL); - g_signal_connect (autoraise_checkbutton, "toggled", - G_CALLBACK (autoraise_toggled_callback), NULL); + g_settings_bind (marco_settings, + MARCO_AUTORAISE_KEY, + autoraise_checkbutton, + "active", + G_SETTINGS_BIND_DEFAULT); g_signal_connect (autoraise_delay_slider, "value_changed", G_CALLBACK (autoraise_delay_value_changed_callback), NULL); @@ -544,15 +379,18 @@ main (int argc, char **argv) ++i; } + /* update sensitivity */ + update_sensitivity (); + capplet_set_icon (dialog_win, "preferences-system-windows"); gtk_widget_show (dialog_win); gtk_main (); + g_object_unref (marco_settings); g_object_unref (builder); -out: - return rc; + return 0; } #include -- cgit v1.2.1 From 09005bb34140eb70e2763df12b1c58a1d1ae3023 Mon Sep 17 00:00:00 2001 From: Stefano Karapetsas Date: Tue, 18 Feb 2014 12:44:29 +0100 Subject: windows: Disable the dialog if window manager changed, without quit --- capplets/windows/mate-window-properties.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/capplets/windows/mate-window-properties.c b/capplets/windows/mate-window-properties.c index e663cd8f..65aa5a2a 100644 --- a/capplets/windows/mate-window-properties.c +++ b/capplets/windows/mate-window-properties.c @@ -228,10 +228,7 @@ wm_changed_callback (GdkScreen *screen, current_wm = gdk_x11_screen_get_window_manager_name (screen); - if (g_strcmp0 (current_wm, WM_COMMON_MARCO) != 0) { - wm_unsupported (); - gtk_main_quit (); - } + gtk_widget_set_sensitive (dialog_win, g_strcmp0 (current_wm, WM_COMMON_MARCO) == 0); } static void -- cgit v1.2.1 From ebc5e95401925ff2b727f40d00ca3bcb464ba652 Mon Sep 17 00:00:00 2001 From: Stefano Karapetsas Date: Tue, 18 Feb 2014 12:55:16 +0100 Subject: windows: Fix indentation --- capplets/windows/mate-window-properties.c | 655 ++++++++++++++---------------- 1 file changed, 315 insertions(+), 340 deletions(-) diff --git a/capplets/windows/mate-window-properties.c b/capplets/windows/mate-window-properties.c index 65aa5a2a..6e3bb77e 100644 --- a/capplets/windows/mate-window-properties.c +++ b/capplets/windows/mate-window-properties.c @@ -6,6 +6,7 @@ * * Written by: Seth Nickell * Havoc Pennington + * Stefano Karapetsas * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -52,28 +53,28 @@ /* keep following enums in sync with marco */ enum { - ACTION_TITLEBAR_TOGGLE_SHADE, - ACTION_TITLEBAR_TOGGLE_MAXIMIZE, - ACTION_TITLEBAR_TOGGLE_MAXIMIZE_HORIZONTALLY, - ACTION_TITLEBAR_TOGGLE_MAXIMIZE_VERTICALLY, - ACTION_TITLEBAR_MINIMIZE, - ACTION_TITLEBAR_NONE, - ACTION_TITLEBAR_LOWER, - ACTION_TITLEBAR_MENU + ACTION_TITLEBAR_TOGGLE_SHADE, + ACTION_TITLEBAR_TOGGLE_MAXIMIZE, + ACTION_TITLEBAR_TOGGLE_MAXIMIZE_HORIZONTALLY, + ACTION_TITLEBAR_TOGGLE_MAXIMIZE_VERTICALLY, + ACTION_TITLEBAR_MINIMIZE, + ACTION_TITLEBAR_NONE, + ACTION_TITLEBAR_LOWER, + ACTION_TITLEBAR_MENU }; enum { - FOCUS_MODE_CLICK, - FOCUS_MODE_SLOPPY, - FOCUS_MODE_MOUSE + FOCUS_MODE_CLICK, + FOCUS_MODE_SLOPPY, + FOCUS_MODE_MOUSE }; typedef struct { - int number; - char *name; - const char *value; /* machine-readable name for storing config */ - GtkWidget *radio; + int number; + char *name; + const char *value; /* machine-readable name for storing config */ + GtkWidget *radio; } MouseClickModifier; static GtkWidget *dialog_win; @@ -96,13 +97,13 @@ static void reload_mouse_modifiers (void); static void update_sensitivity () { - gtk_widget_set_sensitive (GTK_WIDGET (compositing_fast_alt_tab_checkbutton), - g_settings_get_boolean (marco_settings, MARCO_COMPOSITING_MANAGER_KEY)); - gtk_widget_set_sensitive (GTK_WIDGET (autoraise_checkbutton), - g_settings_get_enum (marco_settings, MARCO_FOCUS_KEY) != FOCUS_MODE_CLICK); - gtk_widget_set_sensitive (GTK_WIDGET (autoraise_delay_hbox), - g_settings_get_enum (marco_settings, MARCO_FOCUS_KEY) != FOCUS_MODE_CLICK && - g_settings_get_boolean (marco_settings, MARCO_AUTORAISE_KEY)); + gtk_widget_set_sensitive (GTK_WIDGET (compositing_fast_alt_tab_checkbutton), + g_settings_get_boolean (marco_settings, MARCO_COMPOSITING_MANAGER_KEY)); + gtk_widget_set_sensitive (GTK_WIDGET (autoraise_checkbutton), + g_settings_get_enum (marco_settings, MARCO_FOCUS_KEY) != FOCUS_MODE_CLICK); + gtk_widget_set_sensitive (GTK_WIDGET (autoraise_delay_hbox), + g_settings_get_enum (marco_settings, MARCO_FOCUS_KEY) != FOCUS_MODE_CLICK && + g_settings_get_boolean (marco_settings, MARCO_AUTORAISE_KEY)); } static void @@ -110,17 +111,17 @@ marco_settings_changed_callback (GSettings *settings, const gchar *key, gpointer user_data) { - update_sensitivity (); + update_sensitivity (); } static void mouse_focus_toggled_callback (GtkWidget *button, void *data) { - g_settings_set_enum (marco_settings, - MARCO_FOCUS_KEY, - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)) ? - FOCUS_MODE_SLOPPY : FOCUS_MODE_CLICK); + g_settings_set_enum (marco_settings, + MARCO_FOCUS_KEY, + gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)) ? + FOCUS_MODE_SLOPPY : FOCUS_MODE_CLICK); } static void @@ -136,258 +137,242 @@ static void autoraise_delay_value_changed_callback (GtkWidget *slider, void *data) { - g_settings_set_int (marco_settings, - MARCO_AUTORAISE_DELAY_KEY, - gtk_range_get_value (GTK_RANGE (slider)) * 1000); + g_settings_set_int (marco_settings, + MARCO_AUTORAISE_DELAY_KEY, + gtk_range_get_value (GTK_RANGE (slider)) * 1000); } static void double_click_titlebar_changed_callback (GtkWidget *optionmenu, void *data) { - g_settings_set_enum (marco_settings, MARCO_DOUBLE_CLICK_TITLEBAR_KEY, - gtk_combo_box_get_active (GTK_COMBO_BOX (optionmenu))); + g_settings_set_enum (marco_settings, MARCO_DOUBLE_CLICK_TITLEBAR_KEY, + gtk_combo_box_get_active (GTK_COMBO_BOX (optionmenu))); } static void alt_click_radio_toggled_callback (GtkWidget *radio, void *data) { - MouseClickModifier *modifier = data; - gboolean active; - gchar *value; + MouseClickModifier *modifier = data; + gboolean active; + gchar *value; - active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radio)); + active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radio)); - if (active) { - value = g_strdup_printf ("<%s>", modifier->value); - g_settings_set_string (marco_settings, MARCO_MOUSE_MODIFIER_KEY, value); - g_free (value); - } + if (active) { + value = g_strdup_printf ("<%s>", modifier->value); + g_settings_set_string (marco_settings, MARCO_MOUSE_MODIFIER_KEY, value); + g_free (value); + } } static void set_alt_click_value () { - gboolean match_found = FALSE; - gchar *mouse_move_modifier; - gchar *value; - int i; - - mouse_move_modifier = g_settings_get_string (marco_settings, MARCO_MOUSE_MODIFIER_KEY); - - /* We look for a matching modifier and set it. */ - if (mouse_move_modifier != NULL) { - for (i = 0; i < n_mouse_modifiers; i ++) { - value = g_strdup_printf ("<%s>", mouse_modifiers[i].value); - if (strcmp (value, mouse_move_modifier) == 0) { - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (mouse_modifiers[i].radio), - TRUE); - match_found = TRUE; - break; - } - g_free (value); - } - g_free (mouse_move_modifier); - } - - /* No matching modifier was found; we set all the toggle buttons to be - * insensitive. */ - for (i = 0; i < n_mouse_modifiers; i++) { - gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (mouse_modifiers[i].radio), - ! match_found); - } + gboolean match_found = FALSE; + gchar *mouse_move_modifier; + gchar *value; + int i; + + mouse_move_modifier = g_settings_get_string (marco_settings, MARCO_MOUSE_MODIFIER_KEY); + + /* We look for a matching modifier and set it. */ + if (mouse_move_modifier != NULL) { + for (i = 0; i < n_mouse_modifiers; i ++) { + value = g_strdup_printf ("<%s>", mouse_modifiers[i].value); + if (strcmp (value, mouse_move_modifier) == 0) { + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (mouse_modifiers[i].radio), TRUE); + match_found = TRUE; + break; + } + g_free (value); + } + g_free (mouse_move_modifier); + } + + /* No matching modifier was found; we set all the toggle buttons to be + * insensitive. */ + for (i = 0; i < n_mouse_modifiers; i++) { + gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (mouse_modifiers[i].radio), ! match_found); + } } static void wm_unsupported () { - GtkWidget *no_tool_dialog; + GtkWidget *no_tool_dialog; - no_tool_dialog = - gtk_message_dialog_new (NULL, - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_CLOSE, - " "); - gtk_window_set_title (GTK_WINDOW (no_tool_dialog), ""); - gtk_window_set_resizable (GTK_WINDOW (no_tool_dialog), FALSE); + no_tool_dialog = gtk_message_dialog_new (NULL, + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_ERROR, + GTK_BUTTONS_CLOSE, + " "); + gtk_window_set_title (GTK_WINDOW (no_tool_dialog), ""); + gtk_window_set_resizable (GTK_WINDOW (no_tool_dialog), FALSE); - gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (no_tool_dialog), _("The current window manager is unsupported")); + gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (no_tool_dialog), _("The current window manager is unsupported")); - gtk_dialog_run (GTK_DIALOG (no_tool_dialog)); + gtk_dialog_run (GTK_DIALOG (no_tool_dialog)); - gtk_widget_destroy (no_tool_dialog); + gtk_widget_destroy (no_tool_dialog); } static void wm_changed_callback (GdkScreen *screen, void *data) { - const char *current_wm; + const char *current_wm; - current_wm = gdk_x11_screen_get_window_manager_name (screen); + current_wm = gdk_x11_screen_get_window_manager_name (screen); - gtk_widget_set_sensitive (dialog_win, g_strcmp0 (current_wm, WM_COMMON_MARCO) == 0); + gtk_widget_set_sensitive (dialog_win, g_strcmp0 (current_wm, WM_COMMON_MARCO) == 0); } static void response_cb (GtkWidget *dialog_win, - int response_id, + int response_id, void *data) { - if (response_id == GTK_RESPONSE_HELP) { - capplet_help (GTK_WINDOW (dialog_win), - "goscustdesk-58"); - } else { - gtk_widget_destroy (dialog_win); - } + if (response_id == GTK_RESPONSE_HELP) { + capplet_help (GTK_WINDOW (dialog_win), "goscustdesk-58"); + } else { + gtk_widget_destroy (dialog_win); + } } int main (int argc, char **argv) { - GdkScreen *screen; - GtkBuilder *builder; - GError *error = NULL; - const char *current_wm; - int i; + GdkScreen *screen; + GtkBuilder *builder; + GError *error = NULL; + const char *current_wm; + int i; - bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR); - bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); - textdomain (GETTEXT_PACKAGE); + bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR); + bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); + textdomain (GETTEXT_PACKAGE); - gtk_init (&argc, &argv); + gtk_init (&argc, &argv); - screen = gdk_display_get_default_screen (gdk_display_get_default ()); - current_wm = gdk_x11_screen_get_window_manager_name (screen); + screen = gdk_display_get_default_screen (gdk_display_get_default ()); + current_wm = gdk_x11_screen_get_window_manager_name (screen); - if (g_strcmp0 (current_wm, WM_COMMON_METACITY) == 0) { - mate_metacity_config_tool (); - return 0; - } - - if (g_strcmp0 (current_wm, WM_COMMON_MARCO) != 0) { - wm_unsupported (); - return 1; - } + if (g_strcmp0 (current_wm, WM_COMMON_METACITY) == 0) { + mate_metacity_config_tool (); + return 0; + } - marco_settings = g_settings_new (MARCO_SCHEMA); + if (g_strcmp0 (current_wm, WM_COMMON_MARCO) != 0) { + wm_unsupported (); + return 1; + } - builder = gtk_builder_new (); - gtk_builder_set_translation_domain (builder, GETTEXT_PACKAGE); + marco_settings = g_settings_new (MARCO_SCHEMA); - if (gtk_builder_add_from_file (builder, UIDIR "/mate-window-properties.ui", &error) == 0) { - g_warning ("Could not parse UI file: %s", error->message); - g_error_free (error); - g_object_unref (builder); - return 1; - } + builder = gtk_builder_new (); + gtk_builder_set_translation_domain (builder, GETTEXT_PACKAGE); - dialog_win = GTK_WIDGET (gtk_builder_get_object (builder, - "main-dialog")); - compositing_checkbutton = gtk_builder_get_object (builder, - "compositing-manager-checkbutton"); - compositing_fast_alt_tab_checkbutton = gtk_builder_get_object (builder, - "compositing-fast-alt-tab-checkbutton"); - focus_mode_checkbutton = gtk_builder_get_object (builder, - "focus-mode-checkbutton"); - autoraise_checkbutton = gtk_builder_get_object (builder, - "autoraise-checkbutton"); - autoraise_delay_slider = gtk_builder_get_object (builder, - "autoraise-delay-slider"); - autoraise_delay_hbox = GTK_WIDGET (gtk_builder_get_object (builder, - "autoraise-delay-hbox")); - double_click_titlebar_optionmenu = gtk_builder_get_object (builder, - "double-click-titlebar-optionmenu"); - alt_click_hbox = gtk_builder_get_object (builder, "alt-click-box"); - - gtk_range_set_range (GTK_RANGE (autoraise_delay_slider), - 0, 10); - - gtk_range_set_increments (GTK_RANGE (autoraise_delay_slider), - 0.2, 1.0); - - - reload_mouse_modifiers (); - - gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (double_click_titlebar_optionmenu), _("Roll up")); - gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (double_click_titlebar_optionmenu), _("Maximize")); - gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (double_click_titlebar_optionmenu), _("Maximize Horizontally")); - gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (double_click_titlebar_optionmenu), _("Maximize Vertically")); - gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (double_click_titlebar_optionmenu), _("Minimize")); - gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (double_click_titlebar_optionmenu), _("None")); - gtk_combo_box_set_active (GTK_COMBO_BOX (double_click_titlebar_optionmenu), - g_settings_get_enum (marco_settings, MARCO_DOUBLE_CLICK_TITLEBAR_KEY)); - - set_alt_click_value (); - gtk_range_set_value (GTK_RANGE (autoraise_delay_slider), - g_settings_get_int (marco_settings, MARCO_AUTORAISE_DELAY_KEY) / 1000.0); - gtk_combo_box_set_active (GTK_COMBO_BOX (double_click_titlebar_optionmenu), - g_settings_get_enum (marco_settings, MARCO_DOUBLE_CLICK_TITLEBAR_KEY)); - - g_signal_connect (G_OBJECT (dialog_win), "response", - G_CALLBACK (response_cb), NULL); - - g_signal_connect (G_OBJECT (dialog_win), "destroy", - G_CALLBACK (gtk_main_quit), NULL); - - g_signal_connect (marco_settings, "changed", - G_CALLBACK (marco_settings_changed_callback), NULL); - - g_settings_bind (marco_settings, - MARCO_COMPOSITING_MANAGER_KEY, - compositing_checkbutton, - "active", - G_SETTINGS_BIND_DEFAULT); - - g_settings_bind (marco_settings, - MARCO_COMPOSITING_FAST_ALT_TAB_KEY, - compositing_fast_alt_tab_checkbutton, - "active", - G_SETTINGS_BIND_DEFAULT); - - g_signal_connect (focus_mode_checkbutton, "toggled", - G_CALLBACK (mouse_focus_toggled_callback), NULL); - g_signal_connect (marco_settings, "changed::" MARCO_FOCUS_KEY, - G_CALLBACK (mouse_focus_changed_callback), NULL); - - g_settings_bind (marco_settings, - MARCO_AUTORAISE_KEY, - autoraise_checkbutton, - "active", - G_SETTINGS_BIND_DEFAULT); - - g_signal_connect (autoraise_delay_slider, "value_changed", - G_CALLBACK (autoraise_delay_value_changed_callback), NULL); - - g_signal_connect (double_click_titlebar_optionmenu, "changed", - G_CALLBACK (double_click_titlebar_changed_callback), NULL); - - g_signal_connect (G_OBJECT (screen), "window_manager_changed", - G_CALLBACK (wm_changed_callback), NULL); - - i = 0; - while (i < n_mouse_modifiers) { - g_signal_connect (G_OBJECT (mouse_modifiers[i].radio), "toggled", - G_CALLBACK (alt_click_radio_toggled_callback), - &mouse_modifiers[i]); - ++i; - } + if (gtk_builder_add_from_file (builder, UIDIR "/mate-window-properties.ui", &error) == 0) { + g_warning ("Could not parse UI file: %s", error->message); + g_error_free (error); + g_object_unref (builder); + return 1; + } + + dialog_win = GTK_WIDGET (gtk_builder_get_object (builder, "main-dialog")); + compositing_checkbutton = gtk_builder_get_object (builder, "compositing-manager-checkbutton"); + compositing_fast_alt_tab_checkbutton = gtk_builder_get_object (builder, "compositing-fast-alt-tab-checkbutton"); + focus_mode_checkbutton = gtk_builder_get_object (builder, "focus-mode-checkbutton"); + autoraise_checkbutton = gtk_builder_get_object (builder, "autoraise-checkbutton"); + autoraise_delay_slider = gtk_builder_get_object (builder, "autoraise-delay-slider"); + autoraise_delay_hbox = GTK_WIDGET (gtk_builder_get_object (builder, "autoraise-delay-hbox")); + double_click_titlebar_optionmenu = gtk_builder_get_object (builder, "double-click-titlebar-optionmenu"); + alt_click_hbox = gtk_builder_get_object (builder, "alt-click-box"); + + gtk_range_set_range (GTK_RANGE (autoraise_delay_slider), 0, 10); + gtk_range_set_increments (GTK_RANGE (autoraise_delay_slider), 0.2, 1.0); + + reload_mouse_modifiers (); + + gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (double_click_titlebar_optionmenu), _("Roll up")); + gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (double_click_titlebar_optionmenu), _("Maximize")); + gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (double_click_titlebar_optionmenu), _("Maximize Horizontally")); + gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (double_click_titlebar_optionmenu), _("Maximize Vertically")); + gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (double_click_titlebar_optionmenu), _("Minimize")); + gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (double_click_titlebar_optionmenu), _("None")); + gtk_combo_box_set_active (GTK_COMBO_BOX (double_click_titlebar_optionmenu), + g_settings_get_enum (marco_settings, MARCO_DOUBLE_CLICK_TITLEBAR_KEY)); + + set_alt_click_value (); + gtk_range_set_value (GTK_RANGE (autoraise_delay_slider), + g_settings_get_int (marco_settings, MARCO_AUTORAISE_DELAY_KEY) / 1000.0); + gtk_combo_box_set_active (GTK_COMBO_BOX (double_click_titlebar_optionmenu), + g_settings_get_enum (marco_settings, MARCO_DOUBLE_CLICK_TITLEBAR_KEY)); + + g_signal_connect (G_OBJECT (dialog_win), "response", + G_CALLBACK (response_cb), NULL); + + g_signal_connect (G_OBJECT (dialog_win), "destroy", + G_CALLBACK (gtk_main_quit), NULL); + + g_signal_connect (marco_settings, "changed", + G_CALLBACK (marco_settings_changed_callback), NULL); + + g_settings_bind (marco_settings, + MARCO_COMPOSITING_MANAGER_KEY, + compositing_checkbutton, + "active", + G_SETTINGS_BIND_DEFAULT); + + g_settings_bind (marco_settings, + MARCO_COMPOSITING_FAST_ALT_TAB_KEY, + compositing_fast_alt_tab_checkbutton, + "active", + G_SETTINGS_BIND_DEFAULT); + + g_signal_connect (focus_mode_checkbutton, "toggled", + G_CALLBACK (mouse_focus_toggled_callback), NULL); + g_signal_connect (marco_settings, "changed::" MARCO_FOCUS_KEY, + G_CALLBACK (mouse_focus_changed_callback), NULL); + + g_settings_bind (marco_settings, + MARCO_AUTORAISE_KEY, + autoraise_checkbutton, + "active", + G_SETTINGS_BIND_DEFAULT); + + g_signal_connect (autoraise_delay_slider, "value_changed", + G_CALLBACK (autoraise_delay_value_changed_callback), NULL); + + g_signal_connect (double_click_titlebar_optionmenu, "changed", + G_CALLBACK (double_click_titlebar_changed_callback), NULL); + + g_signal_connect (G_OBJECT (screen), "window_manager_changed", + G_CALLBACK (wm_changed_callback), NULL); + + i = 0; + while (i < n_mouse_modifiers) { + g_signal_connect (G_OBJECT (mouse_modifiers[i].radio), "toggled", + G_CALLBACK (alt_click_radio_toggled_callback), + &mouse_modifiers[i]); + ++i; + } - /* update sensitivity */ - update_sensitivity (); + /* update sensitivity */ + update_sensitivity (); - capplet_set_icon (dialog_win, "preferences-system-windows"); - gtk_widget_show (dialog_win); + capplet_set_icon (dialog_win, "preferences-system-windows"); + gtk_widget_show (dialog_win); - gtk_main (); + gtk_main (); - g_object_unref (marco_settings); - g_object_unref (builder); + g_object_unref (marco_settings); + g_object_unref (builder); - return 0; + return 0; } #include @@ -396,159 +381,149 @@ main (int argc, char **argv) static void fill_radio (GtkRadioButton *group, - MouseClickModifier *modifier) + MouseClickModifier *modifier) { - modifier->radio = - gtk_radio_button_new_with_mnemonic_from_widget (group, - modifier->name); - gtk_box_pack_start (GTK_BOX (alt_click_hbox), - modifier->radio, FALSE, FALSE, 0); + modifier->radio = gtk_radio_button_new_with_mnemonic_from_widget (group, modifier->name); + gtk_box_pack_start (GTK_BOX (alt_click_hbox), modifier->radio, FALSE, FALSE, 0); - gtk_widget_show (modifier->radio); + gtk_widget_show (modifier->radio); } static void reload_mouse_modifiers (void) { - XModifierKeymap *modmap; - KeySym *keymap; - int keysyms_per_keycode; - int map_size; - int i; - gboolean have_meta; - gboolean have_hyper; - gboolean have_super; - int min_keycode, max_keycode; - int mod_meta, mod_super, mod_hyper; + XModifierKeymap *modmap; + KeySym *keymap; + int keysyms_per_keycode; + int map_size; + int i; + gboolean have_meta; + gboolean have_hyper; + gboolean have_super; + int min_keycode, max_keycode; + int mod_meta, mod_super, mod_hyper; #if GTK_CHECK_VERSION (3, 0, 0) - XDisplayKeycodes (gdk_x11_display_get_xdisplay(gdk_display_get_default()), + XDisplayKeycodes (gdk_x11_display_get_xdisplay(gdk_display_get_default()), #else - XDisplayKeycodes (gdk_display, + XDisplayKeycodes (gdk_display, #endif - &min_keycode, - &max_keycode); + &min_keycode, + &max_keycode); #if GTK_CHECK_VERSION (3, 0, 0) - keymap = XGetKeyboardMapping (gdk_x11_display_get_xdisplay(gdk_display_get_default()), + keymap = XGetKeyboardMapping (gdk_x11_display_get_xdisplay(gdk_display_get_default()), #else - keymap = XGetKeyboardMapping (gdk_display, + keymap = XGetKeyboardMapping (gdk_display, #endif - min_keycode, - max_keycode - min_keycode, - &keysyms_per_keycode); + min_keycode, + max_keycode - min_keycode, + &keysyms_per_keycode); #if GTK_CHECK_VERSION (3, 0, 0) - modmap = XGetModifierMapping (gdk_x11_display_get_xdisplay(gdk_display_get_default())); + modmap = XGetModifierMapping (gdk_x11_display_get_xdisplay(gdk_display_get_default())); #else - modmap = XGetModifierMapping (gdk_display); + modmap = XGetModifierMapping (gdk_display); #endif - have_super = FALSE; - have_meta = FALSE; - have_hyper = FALSE; - - /* there are 8 modifiers, and the first 3 are shift, shift lock, - * and control + have_super = FALSE; + have_meta = FALSE; + have_hyper = FALSE; + + /* there are 8 modifiers, and the first 3 are shift, shift lock, + * and control + */ + map_size = 8 * modmap->max_keypermod; + i = 3 * modmap->max_keypermod; + mod_meta = mod_super = mod_hyper = 0; + while (i < map_size) { + /* get the key code at this point in the map, + * see if its keysym is one we're interested in */ - map_size = 8 * modmap->max_keypermod; - i = 3 * modmap->max_keypermod; - mod_meta = mod_super = mod_hyper = 0; - while (i < map_size) { - /* get the key code at this point in the map, - * see if its keysym is one we're interested in - */ - int keycode = modmap->modifiermap[i]; - - if (keycode >= min_keycode && - keycode <= max_keycode) { - int j = 0; - KeySym *syms = keymap + (keycode - min_keycode) * keysyms_per_keycode; - - while (j < keysyms_per_keycode) { - if (syms[j] == XK_Super_L || - syms[j] == XK_Super_R) - mod_super = i / modmap->max_keypermod; - else if (syms[j] == XK_Hyper_L || - syms[j] == XK_Hyper_R) - mod_hyper = i / modmap->max_keypermod; - else if ((syms[j] == XK_Meta_L || - syms[j] == XK_Meta_R)) - mod_meta = i / modmap->max_keypermod; - ++j; - } - } - - ++i; + int keycode = modmap->modifiermap[i]; + + if (keycode >= min_keycode && + keycode <= max_keycode) { + int j = 0; + KeySym *syms = keymap + (keycode - min_keycode) * keysyms_per_keycode; + + while (j < keysyms_per_keycode) { + if (syms[j] == XK_Super_L || syms[j] == XK_Super_R) + mod_super = i / modmap->max_keypermod; + else if (syms[j] == XK_Hyper_L || syms[j] == XK_Hyper_R) + mod_hyper = i / modmap->max_keypermod; + else if ((syms[j] == XK_Meta_L || syms[j] == XK_Meta_R)) + mod_meta = i / modmap->max_keypermod; + ++j; + } } - if ((1 << mod_meta) != Mod1Mask) - have_meta = TRUE; - if (mod_super != 0 && - mod_super != mod_meta) - have_super = TRUE; - if (mod_hyper != 0 && - mod_hyper != mod_meta && - mod_hyper != mod_super) - have_hyper = TRUE; - - XFreeModifiermap (modmap); - XFree (keymap); - - i = 0; - while (i < n_mouse_modifiers) { - g_free (mouse_modifiers[i].name); - if (mouse_modifiers[i].radio) - gtk_widget_destroy (mouse_modifiers[i].radio); - ++i; - } - g_free (mouse_modifiers); - mouse_modifiers = NULL; + ++i; + } + + if ((1 << mod_meta) != Mod1Mask) + have_meta = TRUE; + if (mod_super != 0 && mod_super != mod_meta) + have_super = TRUE; + if (mod_hyper != 0 && mod_hyper != mod_meta && mod_hyper != mod_super) + have_hyper = TRUE; + + XFreeModifiermap (modmap); + XFree (keymap); + + i = 0; + while (i < n_mouse_modifiers) { + g_free (mouse_modifiers[i].name); + if (mouse_modifiers[i].radio) + gtk_widget_destroy (mouse_modifiers[i].radio); + ++i; + } + g_free (mouse_modifiers); + mouse_modifiers = NULL; + + n_mouse_modifiers = 1; /* alt */ + if (have_super) + ++n_mouse_modifiers; + if (have_hyper) + ++n_mouse_modifiers; + if (have_meta) + ++n_mouse_modifiers; - n_mouse_modifiers = 1; /* alt */ - if (have_super) - ++n_mouse_modifiers; - if (have_hyper) - ++n_mouse_modifiers; - if (have_meta) - ++n_mouse_modifiers; + mouse_modifiers = g_new0 (MouseClickModifier, n_mouse_modifiers); - mouse_modifiers = g_new0 (MouseClickModifier, n_mouse_modifiers); + i = 0; - i = 0; + mouse_modifiers[i].number = i; + mouse_modifiers[i].name = g_strdup (_("_Alt")); + mouse_modifiers[i].value = "Alt"; + ++i; + if (have_hyper) { mouse_modifiers[i].number = i; - mouse_modifiers[i].name = g_strdup (_("_Alt")); - mouse_modifiers[i].value = "Alt"; + mouse_modifiers[i].name = g_strdup (_("H_yper")); + mouse_modifiers[i].value = "Hyper"; ++i; + } - if (have_hyper) { - mouse_modifiers[i].number = i; - mouse_modifiers[i].name = g_strdup (_("H_yper")); - mouse_modifiers[i].value = "Hyper"; - ++i; - } - - if (have_super) { - mouse_modifiers[i].number = i; - mouse_modifiers[i].name = g_strdup (_("S_uper (or \"Windows logo\")")); - mouse_modifiers[i].value = "Super"; - ++i; - } + if (have_super) { + mouse_modifiers[i].number = i; + mouse_modifiers[i].name = g_strdup (_("S_uper (or \"Windows logo\")")); + mouse_modifiers[i].value = "Super"; + ++i; + } - if (have_meta) { - mouse_modifiers[i].number = i; - mouse_modifiers[i].name = g_strdup (_("_Meta")); - mouse_modifiers[i].value = "Meta"; - ++i; - } + if (have_meta) { + mouse_modifiers[i].number = i; + mouse_modifiers[i].name = g_strdup (_("_Meta")); + mouse_modifiers[i].value = "Meta"; + ++i; + } - g_assert (i == n_mouse_modifiers); + g_assert (i == n_mouse_modifiers); - i = 0; - while (i < n_mouse_modifiers) { - fill_radio (i == 0 ? NULL : GTK_RADIO_BUTTON (mouse_modifiers[i-1].radio), - &mouse_modifiers[i]); - ++i; - } + i = 0; + while (i < n_mouse_modifiers) { + fill_radio (i == 0 ? NULL : GTK_RADIO_BUTTON (mouse_modifiers[i-1].radio), &mouse_modifiers[i]); + ++i; + } } -- cgit v1.2.1 From b0ba7d51e7da6a775d0d61d830b87700e17fd196 Mon Sep 17 00:00:00 2001 From: Stefano Karapetsas Date: Tue, 18 Feb 2014 13:36:41 +0100 Subject: windows: Add option to enable side by side tiling --- capplets/windows/mate-window-properties.c | 9 ++++ capplets/windows/mate-window-properties.ui | 68 ++++++++++++++++++++++++++++-- 2 files changed, 74 insertions(+), 3 deletions(-) diff --git a/capplets/windows/mate-window-properties.c b/capplets/windows/mate-window-properties.c index 6e3bb77e..b2697bd6 100644 --- a/capplets/windows/mate-window-properties.c +++ b/capplets/windows/mate-window-properties.c @@ -49,6 +49,7 @@ #define MARCO_DOUBLE_CLICK_TITLEBAR_KEY "action-double-click-titlebar" #define MARCO_COMPOSITING_MANAGER_KEY "compositing-manager" #define MARCO_COMPOSITING_FAST_ALT_TAB_KEY "compositing-fast-alt-tab" +#define MARCO_SIDE_BY_SIDE_TILING_KEY "side-by-side-tiling" /* keep following enums in sync with marco */ enum @@ -80,6 +81,7 @@ typedef struct static GtkWidget *dialog_win; static GObject *compositing_checkbutton; static GObject *compositing_fast_alt_tab_checkbutton; +static GObject *side_by_side_tiling_checkbutton; static GObject *focus_mode_checkbutton; static GObject *autoraise_checkbutton; static GObject *autoraise_delay_slider; @@ -285,6 +287,7 @@ main (int argc, char **argv) dialog_win = GTK_WIDGET (gtk_builder_get_object (builder, "main-dialog")); compositing_checkbutton = gtk_builder_get_object (builder, "compositing-manager-checkbutton"); compositing_fast_alt_tab_checkbutton = gtk_builder_get_object (builder, "compositing-fast-alt-tab-checkbutton"); + side_by_side_tiling_checkbutton = gtk_builder_get_object (builder, "side-by-side-tiling"); focus_mode_checkbutton = gtk_builder_get_object (builder, "focus-mode-checkbutton"); autoraise_checkbutton = gtk_builder_get_object (builder, "autoraise-checkbutton"); autoraise_delay_slider = gtk_builder_get_object (builder, "autoraise-delay-slider"); @@ -333,6 +336,12 @@ main (int argc, char **argv) "active", G_SETTINGS_BIND_DEFAULT); + g_settings_bind (marco_settings, + MARCO_SIDE_BY_SIDE_TILING_KEY, + side_by_side_tiling_checkbutton, + "active", + G_SETTINGS_BIND_DEFAULT); + g_signal_connect (focus_mode_checkbutton, "toggled", G_CALLBACK (mouse_focus_toggled_callback), NULL); g_signal_connect (marco_settings, "changed::" MARCO_FOCUS_KEY, diff --git a/capplets/windows/mate-window-properties.ui b/capplets/windows/mate-window-properties.ui index 1029fed9..22d658d4 100644 --- a/capplets/windows/mate-window-properties.ui +++ b/capplets/windows/mate-window-properties.ui @@ -11,6 +11,7 @@ True 2 + True @@ -106,6 +107,66 @@ 0 + + + + True + 6 + + + True + 0 + Window Snapping + + + + + + False + False + 0 + + + + + True + 12 + + + True + 6 + + + Enable side by side tiling + True + True + False + True + True + + + False + False + 0 + + + + + + + False + False + 1 + + + + + False + False + 1 + + + True @@ -247,7 +308,7 @@ False False - 1 + 2 @@ -322,7 +383,7 @@ False False - 2 + 3 @@ -398,7 +459,7 @@ False False - 3 + 4 @@ -406,6 +467,7 @@ 1 + True -- cgit v1.2.1