summaryrefslogtreecommitdiff
path: root/capplets
diff options
context:
space:
mode:
authorVictor Kareh <[email protected]>2018-03-15 14:53:50 -0400
committerlukefromdc <[email protected]>2018-03-16 13:55:05 -0400
commit48b4fc3407816ddcab6e2bd20b063b6de9746e25 (patch)
tree09bd8464301c05e3b239eb50140e3b7260377705 /capplets
parent9888c14a69484aecdb48bfea6bcd562b178e9ff1 (diff)
downloadmate-control-center-48b4fc3407816ddcab6e2bd20b063b6de9746e25.tar.bz2
mate-control-center-48b4fc3407816ddcab6e2bd20b063b6de9746e25.tar.xz
Add auto-detect toggle switch
Currently if a user changes the DPI, there is no way to reset it back to the auto-detected value from Xserver (which we store as 0 in gsettings). Adding this toggle solves that issue. I also removed a deprecated [GtkHandleBox](https://developer.gnome.org/gtk3/stable/GtkHandleBox.html) and all its associated code.
Diffstat (limited to 'capplets')
-rw-r--r--capplets/appearance/appearance-font.c74
-rw-r--r--capplets/appearance/appearance-ui.c48
-rw-r--r--capplets/appearance/appearance.h1
-rw-r--r--capplets/appearance/data/appearance.ui221
4 files changed, 202 insertions, 142 deletions
diff --git a/capplets/appearance/appearance-font.c b/capplets/appearance/appearance-font.c
index 998bfa28..f4dd0d4d 100644
--- a/capplets/appearance/appearance-font.c
+++ b/capplets/appearance/appearance-font.c
@@ -473,11 +473,22 @@ dpi_load (GSettings *settings,
}
static void
-dpi_changed (GSettings *settings,
- gchar *key,
- gpointer user_data)
+dpi_changed (GSettings *settings,
+ gchar *key,
+ AppearanceData *data)
{
- dpi_load (settings, user_data);
+ GtkWidget *spinner;
+ GtkWidget *toggle;
+ gdouble dpi;
+
+ dpi = g_settings_get_double (data->font_settings, FONT_DPI_KEY);
+ spinner = appearance_capplet_get_widget (data, "dpi_spinner");
+ toggle = appearance_capplet_get_widget (data, "dpi_reset_switch");
+
+ dpi_load (settings, GTK_SPIN_BUTTON (spinner));
+
+ gtk_switch_set_state (GTK_SWITCH (toggle), dpi == 0);
+ gtk_widget_set_sensitive (spinner, dpi != 0);
}
static void
@@ -490,8 +501,8 @@ monitors_changed (GdkScreen *screen,
}
static void
-dpi_value_changed (GtkSpinButton *spinner,
- GSettings *settings)
+dpi_value_changed (GtkSpinButton *spinner,
+ AppearanceData *data)
{
/* Like any time when using a spin button with GSettings, there is
* a race condition here. When we change, we send the new
@@ -503,6 +514,7 @@ dpi_value_changed (GtkSpinButton *spinner,
*/
if (!in_change) {
GdkScreen *screen;
+ GtkWidget *toggle;
gint scale;
gdouble new_dpi;
@@ -510,12 +522,34 @@ dpi_value_changed (GtkSpinButton *spinner,
scale = gdk_window_get_scale_factor (gdk_screen_get_root_window (screen));
new_dpi = gtk_spin_button_get_value (spinner) / (double)scale;
- g_settings_set_double (settings, FONT_DPI_KEY, new_dpi);
+ g_settings_set_double (data->font_settings, FONT_DPI_KEY, new_dpi);
- dpi_load (settings, spinner);
+ dpi_load (data->font_settings, spinner);
+
+ toggle = appearance_capplet_get_widget (data, "dpi_reset_switch");
+ gtk_switch_set_active (GTK_SWITCH (toggle), FALSE);
}
}
+static gboolean
+dpi_value_reset (GtkSwitch *toggle,
+ gboolean state,
+ AppearanceData *data)
+{
+ GtkWidget *spinner;
+ spinner = appearance_capplet_get_widget (data, "dpi_spinner");
+
+ if (state)
+ g_settings_set_double (data->font_settings, FONT_DPI_KEY, 0);
+ else
+ dpi_value_changed (GTK_SPIN_BUTTON (spinner), data);
+
+ gtk_switch_set_state(toggle, state);
+ gtk_widget_set_sensitive (spinner, !state);
+
+ return TRUE;
+}
+
static void
cb_details_response (GtkDialog *dialog, gint response_id)
{
@@ -532,27 +566,37 @@ cb_show_details (GtkWidget *button,
{
if (!data->font_details) {
GtkAdjustment *adjustment;
- GtkWidget *widget;
+ GtkWidget *spinner;
+ GtkWidget *toggle;
EnumGroup *group;
+ gdouble dpi;
data->font_details = appearance_capplet_get_widget (data, "render_details");
gtk_window_set_transient_for (GTK_WINDOW (data->font_details),
GTK_WINDOW (appearance_capplet_get_widget (data, "appearance_window")));
- widget = appearance_capplet_get_widget (data, "dpi_spinner");
+ spinner = appearance_capplet_get_widget (data, "dpi_spinner");
+ toggle = appearance_capplet_get_widget (data, "dpi_reset_switch");
+
+ /* Set initial state for widgets */
+ dpi = g_settings_get_double (data->font_settings, FONT_DPI_KEY);
+ gtk_switch_set_active (GTK_SWITCH (toggle), dpi == 0);
+ gtk_widget_set_sensitive (GTK_WIDGET (spinner), dpi != 0);
/* pick a sensible maximum dpi */
- adjustment = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (widget));
+ adjustment = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spinner));
gtk_adjustment_set_lower (adjustment, DPI_LOW_REASONABLE_VALUE);
gtk_adjustment_set_upper (adjustment, DPI_HIGH_REASONABLE_VALUE);
gtk_adjustment_set_step_increment (adjustment, 1);
- dpi_load (data->font_settings, GTK_SPIN_BUTTON (widget));
- g_signal_connect (widget, "value_changed",
- G_CALLBACK (dpi_value_changed), data->font_settings);
+ dpi_load (data->font_settings, GTK_SPIN_BUTTON (spinner));
+ g_signal_connect (spinner, "value-changed",
+ G_CALLBACK (dpi_value_changed), data);
+ g_signal_connect (toggle, "state-set",
+ G_CALLBACK (dpi_value_reset), data);
- g_signal_connect (data->font_settings, "changed::" FONT_DPI_KEY, G_CALLBACK (dpi_changed), widget);
+ g_signal_connect (data->font_settings, "changed::" FONT_DPI_KEY, G_CALLBACK (dpi_changed), data);
/* Update font DPI when window scaling factor is changed */
g_signal_connect (gdk_screen_get_default (), "monitors-changed", G_CALLBACK (monitors_changed), data);
diff --git a/capplets/appearance/appearance-ui.c b/capplets/appearance/appearance-ui.c
index 00427e96..86c61fdb 100644
--- a/capplets/appearance/appearance-ui.c
+++ b/capplets/appearance/appearance-ui.c
@@ -22,34 +22,6 @@
#include "appearance.h"
#include "stdio.h"
-
-static void
-show_handlebar (AppearanceData *data, gboolean show)
-{
- GtkWidget *handlebox = appearance_capplet_get_widget (data, "toolbar_handlebox");
- GtkWidget *toolbar = appearance_capplet_get_widget (data, "toolbar_toolbar");
- GtkWidget *align = appearance_capplet_get_widget (data, "toolbar_align");
-
- g_object_ref (handlebox);
- g_object_ref (toolbar);
-
- if (gtk_bin_get_child (GTK_BIN (align)))
- gtk_container_remove (GTK_CONTAINER (align), gtk_bin_get_child (GTK_BIN (align)));
-
- if (gtk_bin_get_child (GTK_BIN (handlebox)))
- gtk_container_remove (GTK_CONTAINER (handlebox), gtk_bin_get_child (GTK_BIN (handlebox)));
-
- if (show) {
- gtk_container_add (GTK_CONTAINER (align), handlebox);
- gtk_container_add (GTK_CONTAINER (handlebox), toolbar);
- g_object_unref (handlebox);
- } else {
- gtk_container_add (GTK_CONTAINER (align), toolbar);
- }
-
- g_object_unref (toolbar);
-}
-
static void
set_have_icons (AppearanceData *data, gboolean value)
{
@@ -94,14 +66,6 @@ menus_have_icons_cb (GSettings *settings,
set_have_icons (data, g_settings_get_boolean (settings, key));
}
-static void
-toolbar_detachable_cb (GSettings *settings,
- gchar *key,
- AppearanceData *data)
-{
- show_handlebar (data, g_settings_get_boolean (settings, key));
-}
-
/** GUI Callbacks **/
static gint
@@ -140,16 +104,4 @@ ui_init (AppearanceData *data)
set_have_icons (data,
g_settings_get_boolean (data->interface_settings,
MENU_ICONS_KEY));
-
- g_signal_connect (appearance_capplet_get_widget (data, "toolbar_handlebox"),
- "button_press_event",
- (GCallback) button_press_block_cb, NULL);
-
- show_handlebar (data,
- g_settings_get_boolean (data->interface_settings,
- TOOLBAR_DETACHABLE_KEY));
-
- /* no ui for detachable toolbars */
- g_signal_connect (data->interface_settings,
- "changed::" TOOLBAR_DETACHABLE_KEY, (GCallback) toolbar_detachable_cb, data);
}
diff --git a/capplets/appearance/appearance.h b/capplets/appearance/appearance.h
index 37f58291..36963125 100644
--- a/capplets/appearance/appearance.h
+++ b/capplets/appearance/appearance.h
@@ -47,7 +47,6 @@
#define COLOR_SCHEME_KEY "gtk-color-scheme"
#define ACCEL_CHANGE_KEY "can-change-accels"
#define MENU_ICONS_KEY "menus-have-icons"
-#define TOOLBAR_DETACHABLE_KEY "toolbar-detachable"
#define TOOLBAR_STYLE_KEY "toolbar-style"
#define GTK_FONT_DEFAULT_VALUE "Sans 10"
diff --git a/capplets/appearance/data/appearance.ui b/capplets/appearance/data/appearance.ui
index d8667193..ba20160f 100644
--- a/capplets/appearance/data/appearance.ui
+++ b/capplets/appearance/data/appearance.ui
@@ -1,5 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.20.0 -->
+<!-- Generated with glade 3.22.0
+
+mate-appearance-properties - appearance properties dialog window
+Copyright (C) MATE Developers
+
+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 the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+Author: Wolfgang Ulbrich
+
+-->
<interface>
<requires lib="gtk+" version="3.14"/>
<!-- interface-license-type gplv2 -->
@@ -56,23 +77,40 @@
<property name="orientation">vertical</property>
<property name="spacing">18</property>
<child>
- <object class="GtkAlignment" id="alignment5">
+ <object class="GtkBox" id="vbox_resolution">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">0</property>
- <property name="xscale">0</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">8</property>
<child>
- <object class="GtkBox" id="hbox_resolution">
+ <object class="GtkLabel" id="label11">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="spacing">12</property>
+ <property name="halign">start</property>
+ <property name="label" translatable="yes">R_esolution</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">dpi_spinner</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox" id="hbox20">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="valign">center</property>
+ <property name="spacing">8</property>
<child>
- <object class="GtkLabel" id="label11">
+ <object class="GtkLabel" id="label16">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="label" translatable="yes">R_esolution:</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">dpi_spinner</property>
+ <property name="label" translatable="yes">Dots per inch (DPI):</property>
</object>
<packing>
<property name="expand">False</property>
@@ -81,34 +119,10 @@
</packing>
</child>
<child>
- <object class="GtkBox" id="hbox20">
+ <object class="GtkSpinButton" id="dpi_spinner">
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkSpinButton" id="dpi_spinner">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="climb_rate">1</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label16">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">dots per inch</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">2</property>
- </packing>
- </child>
+ <property name="can_focus">True</property>
+ <property name="climb_rate">1</property>
</object>
<packing>
<property name="expand">False</property>
@@ -117,11 +131,53 @@
</packing>
</child>
</object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox" id="hbox21">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">8</property>
+ <child>
+ <object class="GtkLabel" id="label51">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="tooltip_text" translatable="yes">This resets the font DPI to the auto-detected value from Xserver.</property>
+ <property name="label" translatable="yes">Automatic detection:</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSwitch" id="dpi_reset_switch">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="active">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
</child>
</object>
<packing>
<property name="expand">False</property>
- <property name="fill">False</property>
+ <property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
@@ -757,6 +813,9 @@
<property name="position">3</property>
</packing>
</child>
+ <child>
+ <placeholder/>
+ </child>
</object>
<packing>
<property name="expand">False</property>
@@ -769,6 +828,9 @@
<action-widgets>
<action-widget response="-7">button3</action-widget>
</action-widgets>
+ <child>
+ <placeholder/>
+ </child>
</object>
<object class="GtkDialog" id="theme_details">
<property name="can_focus">False</property>
@@ -1553,6 +1615,9 @@
<action-widget response="-11">theme_help_button</action-widget>
<action-widget response="-7">theme_close_button</action-widget>
</action-widgets>
+ <child>
+ <placeholder/>
+ </child>
</object>
<object class="GtkDialog" id="theme_save_dialog">
<property name="can_focus">False</property>
@@ -1724,6 +1789,9 @@
<action-widget response="-6">save_dialog_cancel_button</action-widget>
<action-widget response="-5">save_dialog_save_button</action-widget>
</action-widgets>
+ <child>
+ <placeholder/>
+ </child>
</object>
<object class="GtkListStore" id="toolbar_style_liststore">
<columns>
@@ -3085,53 +3153,47 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
- <object class="GtkHandleBox" id="toolbar_handlebox">
+ <object class="GtkToolbar" id="toolbar_toolbar">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="toolbar_style">both-horiz</property>
<child>
- <object class="GtkToolbar" id="toolbar_toolbar">
+ <object class="GtkToolButton" id="button2">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="toolbar_style">both-horiz</property>
- <child>
- <object class="GtkToolButton" id="button2">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="is_important">True</property>
- <property name="stock_id">gtk-new</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">True</property>
- </packing>
- </child>
- <child>
- <object class="GtkToolButton" id="button4">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="stock_id">gtk-open</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">True</property>
- </packing>
- </child>
- <child>
- <object class="GtkToolButton" id="save_button">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="stock_id">gtk-save</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">True</property>
- </packing>
- </child>
- <style>
- <class name="primary-toolbar"/>
- </style>
+ <property name="is_important">True</property>
+ <property name="stock_id">gtk-new</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="homogeneous">True</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkToolButton" id="button4">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="stock_id">gtk-open</property>
</object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="homogeneous">True</property>
+ </packing>
</child>
+ <child>
+ <object class="GtkToolButton" id="save_button">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="stock_id">gtk-save</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="homogeneous">True</property>
+ </packing>
+ </child>
+ <style>
+ <class name="primary-toolbar"/>
+ </style>
</object>
</child>
</object>
@@ -3192,5 +3254,8 @@
<action-widget response="-11">help_button</action-widget>
<action-widget response="-7">close_button</action-widget>
</action-widgets>
+ <child>
+ <placeholder/>
+ </child>
</object>
</interface>