summaryrefslogtreecommitdiff
path: root/capplets
diff options
context:
space:
mode:
authormbkma <[email protected]>2021-03-29 11:56:50 +0200
committerraveit65 <[email protected]>2021-04-29 22:10:33 +0200
commit6e0fc53c78d784aef2336a671a516e003f4ba359 (patch)
treed8304a74d51a5fbcc6f5a12dcb53a6a8cfde35a3 /capplets
parent5d200206e51b53b2d347b5d1a4b4a9ad07cc6ed1 (diff)
downloadmate-control-center-6e0fc53c78d784aef2336a671a516e003f4ba359.tar.bz2
mate-control-center-6e0fc53c78d784aef2336a671a516e003f4ba359.tar.xz
windows-applet: add right and left (with menu) titlebar button layout options, respect custom values
Diffstat (limited to 'capplets')
-rw-r--r--capplets/windows/mate-window-properties.c77
-rw-r--r--capplets/windows/window-properties.ui7
2 files changed, 60 insertions, 24 deletions
diff --git a/capplets/windows/mate-window-properties.c b/capplets/windows/mate-window-properties.c
index 8b7ed11c..501569d0 100644
--- a/capplets/windows/mate-window-properties.c
+++ b/capplets/windows/mate-window-properties.c
@@ -55,8 +55,21 @@
#define MARCO_COMPOSITING_MANAGER_KEY "compositing-manager"
#define MARCO_COMPOSITING_FAST_ALT_TAB_KEY "compositing-fast-alt-tab"
-#define MARCO_BUTTON_LAYOUT_RIGHT "menu:minimize,maximize,close"
-#define MARCO_BUTTON_LAYOUT_LEFT "close,minimize,maximize:"
+enum
+{
+ MARCO_BUTTON_LAYOUT_RIGHT_WITH_MENU = 0,
+ MARCO_BUTTON_LAYOUT_LEFT_WITH_MENU,
+ MARCO_BUTTON_LAYOUT_RIGHT,
+ MARCO_BUTTON_LAYOUT_LEFT,
+ MARCO_BUTTON_LAYOUT_COUNT
+};
+
+static const char *button_layout [MARCO_BUTTON_LAYOUT_COUNT] = {
+ [MARCO_BUTTON_LAYOUT_RIGHT_WITH_MENU] = "menu:minimize,maximize,close",
+ [MARCO_BUTTON_LAYOUT_LEFT_WITH_MENU] = "close,minimize,maximize:menu",
+ [MARCO_BUTTON_LAYOUT_RIGHT] = ":minimize,maximize,close",
+ [MARCO_BUTTON_LAYOUT_LEFT] = "close,minimize,maximize:"
+};
/* keep following enums in sync with marco */
enum
@@ -118,8 +131,6 @@ static void reload_mouse_modifiers (void);
static void
update_sensitivity (void)
{
- gchar *str;
-
gtk_widget_set_sensitive (compositing_fast_alt_tab_checkbutton,
g_settings_get_boolean (marco_settings, MARCO_COMPOSITING_MANAGER_KEY));
gtk_widget_set_sensitive (allow_top_tiling_checkbutton,
@@ -131,12 +142,6 @@ update_sensitivity (void)
gtk_widget_set_sensitive (autoraise_delay_spinbutton,
g_settings_get_enum (marco_settings, MARCO_FOCUS_KEY) != FOCUS_MODE_CLICK &&
g_settings_get_boolean (marco_settings, MARCO_AUTORAISE_KEY));
-
- str = g_settings_get_string (marco_settings, MARCO_BUTTON_LAYOUT_KEY);
- gtk_widget_set_sensitive (titlebar_layout_optionmenu,
- g_strcmp0 (str, MARCO_BUTTON_LAYOUT_LEFT) == 0 ||
- g_strcmp0 (str, MARCO_BUTTON_LAYOUT_RIGHT) == 0);
- g_free (str);
}
static void
@@ -198,18 +203,48 @@ double_click_titlebar_changed_callback (GtkWidget *optionmenu,
gtk_combo_box_get_active (GTK_COMBO_BOX (optionmenu)));
}
+static gchar *custom_titlebar_button_layout = NULL;
+
static void
-titlebar_layout_changed_callback (GtkWidget *optionmenu,
- void *data)
+titlebar_layout_changed_callback (GtkWidget *optionmenu)
{
gint value = gtk_combo_box_get_active (GTK_COMBO_BOX (optionmenu));
- if (value == 0) {
- g_settings_set_string (marco_settings, MARCO_BUTTON_LAYOUT_KEY, MARCO_BUTTON_LAYOUT_RIGHT);
+ if (value < MARCO_BUTTON_LAYOUT_COUNT) {
+ g_settings_set_string (marco_settings, MARCO_BUTTON_LAYOUT_KEY, button_layout[value]);
+ g_settings_set_string (interface_settings, GTK_BUTTON_LAYOUT_KEY, button_layout[value]);
+ }
+ /* Custom Layout */
+ else if ((value == MARCO_BUTTON_LAYOUT_COUNT) && custom_titlebar_button_layout) {
+ g_settings_set_string (marco_settings, MARCO_BUTTON_LAYOUT_KEY, custom_titlebar_button_layout);
+ g_settings_set_string (interface_settings, GTK_BUTTON_LAYOUT_KEY, custom_titlebar_button_layout);
+ }
+}
+
+static void
+set_titlebar_button_layout(void)
+{
+ gchar *str;
+ gboolean found = FALSE;
+
+ str = g_settings_get_string (marco_settings, MARCO_BUTTON_LAYOUT_KEY);
+ for (gint i = 0; i < MARCO_BUTTON_LAYOUT_COUNT; i++) {
+ if (g_strcmp0 (str, button_layout[i]) == 0) {
+ gtk_combo_box_set_active (GTK_COMBO_BOX (titlebar_layout_optionmenu), i);
+ found = TRUE;
+ break;
+ }
}
- else if (value == 1) {
- g_settings_set_string (marco_settings, MARCO_BUTTON_LAYOUT_KEY, MARCO_BUTTON_LAYOUT_LEFT);
+ /* A custom value is found in MARCO_BUTTON_LAYOUT_KEY
+ * (maybe the user changed the value in dconf-editor) */
+ if (!found) {
+ g_free (custom_titlebar_button_layout);
+ custom_titlebar_button_layout = g_strdup(str);
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (titlebar_layout_optionmenu), _("Custom"));
+ gtk_combo_box_set_active (GTK_COMBO_BOX (titlebar_layout_optionmenu), 4);
}
+
+ g_free(str);
}
static void
@@ -310,7 +345,6 @@ main (int argc, char **argv)
GtkBuilder *builder;
GdkScreen *screen;
GtkWidget *nb;
- gchar *str;
const char *current_wm;
int i;
@@ -384,14 +418,11 @@ main (int argc, char **argv)
reload_mouse_modifiers ();
- str = g_settings_get_string (marco_settings, MARCO_BUTTON_LAYOUT_KEY);
- gtk_combo_box_set_active (GTK_COMBO_BOX (titlebar_layout_optionmenu),
- g_strcmp0 (str, MARCO_BUTTON_LAYOUT_RIGHT) == 0 ? 0 : 1);
- g_free (str);
-
gtk_combo_box_set_active (GTK_COMBO_BOX (double_click_titlebar_optionmenu),
g_settings_get_enum (marco_settings, MARCO_DOUBLE_CLICK_TITLEBAR_KEY));
+ set_titlebar_button_layout ();
+
set_alt_click_value ();
gtk_combo_box_set_active (GTK_COMBO_BOX (double_click_titlebar_optionmenu),
@@ -474,6 +505,8 @@ main (int argc, char **argv)
g_object_unref (marco_settings);
+ g_free (custom_titlebar_button_layout);
+
return 0;
}
diff --git a/capplets/windows/window-properties.ui b/capplets/windows/window-properties.ui
index b66292fe..1426188b 100644
--- a/capplets/windows/window-properties.ui
+++ b/capplets/windows/window-properties.ui
@@ -671,6 +671,7 @@ Author: Robert Buj
<object class="GtkLabel" id="position_of_titlebar_buttons_label">
<property name="visible">True</property>
<property name="can-focus">False</property>
+ <property name="halign">start</property>
<property name="label" translatable="yes">_Position of titlebar buttons:</property>
<property name="use-underline">True</property>
<property name="mnemonic-widget">titlebar_layout_optionmenu</property>
@@ -686,6 +687,8 @@ Author: Robert Buj
<property name="visible">True</property>
<property name="can-focus">False</property>
<items>
+ <item translatable="yes">Right (with menu)</item>
+ <item translatable="yes">Left (with menu)</item>
<item translatable="yes">Right</item>
<item translatable="yes">Left</item>
</items>
@@ -707,14 +710,14 @@ Author: Robert Buj
</object>
<packing>
<property name="expand">False</property>
- <property name="fill">True</property>
+ <property name="fill">False</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
- <property name="fill">True</property>
+ <property name="fill">False</property>
<property name="position">2</property>
</packing>
</child>