diff options
author | zhuyaliang <[email protected]> | 2021-03-04 10:29:23 +0800 |
---|---|---|
committer | Robert Antoni Buj Gelonch <[email protected]> | 2021-03-08 12:00:27 +0100 |
commit | 1cca4936a347ad4c7c81e18fcf913e6b393a2994 (patch) | |
tree | f5586ffbf9809f3535f6b37ee7d9747f9fdacd85 | |
parent | b6ba059d3334364c7237751f9af05bc8593406ee (diff) | |
download | mate-control-center-1cca4936a347ad4c7c81e18fcf913e6b393a2994.tar.bz2 mate-control-center-1cca4936a347ad4c7c81e18fcf913e6b393a2994.tar.xz |
Add adjust window scaling function for display preference and update display-capplet.ui file
-rw-r--r-- | capplets/display/display-capplet.ui | 351 | ||||
-rw-r--r-- | capplets/display/ui-a11y.suppr | 1 | ||||
-rw-r--r-- | capplets/display/xrandr-capplet.c | 63 |
3 files changed, 256 insertions, 159 deletions
diff --git a/capplets/display/display-capplet.ui b/capplets/display/display-capplet.ui index 95f51ba8..be905a8b 100644 --- a/capplets/display/display-capplet.ui +++ b/capplets/display/display-capplet.ui @@ -1,16 +1,16 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.22.0 --> +<!-- Generated with glade 3.38.2 --> <interface> <requires lib="gtk+" version="3.22"/> <object class="GtkImage" id="apply_button_img"> <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="icon_name">gtk-apply</property> + <property name="can-focus">False</property> + <property name="icon-name">gtk-apply</property> </object> <object class="GtkImage" id="help_button_img"> <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="icon_name">help-browser</property> + <property name="can-focus">False</property> + <property name="icon-name">help-browser</property> </object> <object class="GtkListStore" id="liststore1"> <columns> @@ -34,34 +34,34 @@ </object> <object class="GtkImage" id="window_close_button_img"> <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="icon_name">window-close</property> + <property name="can-focus">False</property> + <property name="icon-name">window-close</property> </object> <object class="GtkDialog" id="dialog"> - <property name="can_focus">False</property> - <property name="border_width">5</property> + <property name="can-focus">False</property> + <property name="border-width">5</property> <property name="title" translatable="yes">Monitor Preferences</property> - <property name="type_hint">dialog</property> + <property name="type-hint">dialog</property> <child internal-child="vbox"> <object class="GtkBox" id="dialog-vbox1"> <property name="visible">True</property> - <property name="can_focus">False</property> + <property name="can-focus">False</property> <property name="orientation">vertical</property> <property name="spacing">2</property> <child internal-child="action_area"> <object class="GtkButtonBox" id="dialog-action_area1"> <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="layout_style">end</property> + <property name="can-focus">False</property> + <property name="layout-style">end</property> <child> <object class="GtkButton" id="helpbutton1"> <property name="label" translatable="yes">_Help</property> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="can_default">True</property> - <property name="receives_default">False</property> + <property name="can-focus">True</property> + <property name="can-default">True</property> + <property name="receives-default">False</property> <property name="image">help_button_img</property> - <property name="use_underline">True</property> + <property name="use-underline">True</property> </object> <packing> <property name="expand">False</property> @@ -74,10 +74,10 @@ <object class="GtkButton" id="make_default_button"> <property name="label" translatable="yes">Apply system-wide</property> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - <property name="tooltip_text" translatable="yes">Applies the current configuration for other MATE users on the computer. Note that this doesn't affect login screens or other desktop environments.</property> - <property name="use_underline">True</property> + <property name="can-focus">True</property> + <property name="receives-default">True</property> + <property name="tooltip-text" translatable="yes">Applies the current configuration for other MATE users on the computer. Note that this doesn't affect login screens or other desktop environments.</property> + <property name="use-underline">True</property> </object> <packing> <property name="expand">False</property> @@ -89,11 +89,11 @@ <object class="GtkButton" id="apply_button"> <property name="label" translatable="yes">_Apply</property> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="can_default">True</property> - <property name="receives_default">False</property> + <property name="can-focus">True</property> + <property name="can-default">True</property> + <property name="receives-default">False</property> <property name="image">apply_button_img</property> - <property name="use_underline">True</property> + <property name="use-underline">True</property> </object> <packing> <property name="expand">False</property> @@ -105,11 +105,11 @@ <object class="GtkButton" id="button2"> <property name="label" translatable="yes">_Close</property> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="can_default">True</property> - <property name="receives_default">False</property> + <property name="can-focus">True</property> + <property name="can-default">True</property> + <property name="receives-default">False</property> <property name="image">window_close_button_img</property> - <property name="use_underline">True</property> + <property name="use-underline">True</property> </object> <packing> <property name="expand">False</property> @@ -121,26 +121,27 @@ <packing> <property name="expand">False</property> <property name="fill">True</property> - <property name="pack_type">end</property> + <property name="pack-type">end</property> <property name="position">0</property> </packing> </child> <child> + <!-- n-columns=2 n-rows=3 --> <object class="GtkGrid" id="table2"> <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="row_spacing">12</property> - <property name="column_spacing">12</property> + <property name="can-focus">False</property> + <property name="row-spacing">12</property> + <property name="column-spacing">12</property> <child> <object class="GtkBox" id="vbox3"> <property name="visible">True</property> - <property name="can_focus">False</property> + <property name="can-focus">False</property> <property name="orientation">vertical</property> <property name="spacing">12</property> <child> <object class="GtkAlignment" id="align"> <property name="visible">True</property> - <property name="can_focus">False</property> + <property name="can-focus">False</property> <child> <placeholder/> </child> @@ -154,16 +155,16 @@ <child> <object class="GtkBox" id="hbox1"> <property name="visible">True</property> - <property name="can_focus">False</property> + <property name="can-focus">False</property> <property name="spacing">12</property> <child> <object class="GtkCheckButton" id="clone_checkbox"> <property name="label" translatable="yes">Sa_me image in all monitors</property> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="use_underline">True</property> - <property name="draw_indicator">True</property> + <property name="can-focus">True</property> + <property name="receives-default">False</property> + <property name="use-underline">True</property> + <property name="draw-indicator">True</property> </object> <packing> <property name="expand">False</property> @@ -175,14 +176,14 @@ <object class="GtkButton" id="detect_displays_button"> <property name="label" translatable="yes">_Detect monitors</property> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - <property name="use_underline">True</property> + <property name="can-focus">True</property> + <property name="receives-default">True</property> + <property name="use-underline">True</property> </object> <packing> <property name="expand">False</property> <property name="fill">False</property> - <property name="pack_type">end</property> + <property name="pack-type">end</property> <property name="position">1</property> </packing> </child> @@ -195,134 +196,85 @@ </child> </object> <packing> - <property name="left_attach">0</property> - <property name="top_attach">0</property> - </packing> - </child> - <child> - <object class="GtkBox" id="vbox4"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="orientation">vertical</property> - <child> - <object class="GtkLabel" id="label8"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes">Panel icon</property> - <property name="xalign">0</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="GtkAlignment" id="alignment2"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="left_padding">12</property> - <child> - <object class="GtkCheckButton" id="show_notification_icon"> - <property name="label" translatable="yes">_Show monitors in panel</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="halign">start</property> - <property name="use_underline">True</property> - <property name="draw_indicator">True</property> - </object> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">1</property> - </packing> - </child> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">1</property> + <property name="left-attach">0</property> + <property name="top-attach">0</property> </packing> </child> <child> <object class="GtkAlignment" id="alignment1"> <property name="visible">True</property> - <property name="can_focus">False</property> + <property name="can-focus">False</property> <property name="xalign">0</property> <property name="yalign">0</property> <child> + <!-- n-columns=2 n-rows=7 --> <object class="GtkGrid" id="table1"> <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="row_spacing">6</property> - <property name="column_spacing">12</property> + <property name="can-focus">False</property> + <property name="row-spacing">6</property> + <property name="column-spacing">12</property> <child> <object class="GtkLabel" id="label2"> <property name="visible">True</property> - <property name="can_focus">False</property> + <property name="can-focus">False</property> <property name="label" translatable="yes">_Resolution:</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">resolution_combo</property> + <property name="use-underline">True</property> + <property name="mnemonic-widget">resolution_combo</property> <property name="xalign">0</property> </object> <packing> - <property name="left_attach">0</property> - <property name="top_attach">3</property> + <property name="left-attach">0</property> + <property name="top-attach">3</property> </packing> </child> <child> <object class="GtkLabel" id="label3"> <property name="visible">True</property> - <property name="can_focus">False</property> + <property name="can-focus">False</property> <property name="label" translatable="yes">Re_fresh rate:</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">refresh_combo</property> + <property name="use-underline">True</property> + <property name="mnemonic-widget">refresh_combo</property> <property name="xalign">0</property> </object> <packing> - <property name="left_attach">0</property> - <property name="top_attach">4</property> + <property name="left-attach">0</property> + <property name="top-attach">4</property> </packing> </child> <child> <object class="GtkComboBox" id="resolution_combo"> <property name="visible">True</property> - <property name="can_focus">False</property> + <property name="can-focus">False</property> </object> <packing> - <property name="left_attach">1</property> - <property name="top_attach">3</property> + <property name="left-attach">1</property> + <property name="top-attach">3</property> </packing> </child> <child> <object class="GtkComboBox" id="refresh_combo"> <property name="visible">True</property> - <property name="can_focus">False</property> + <property name="can-focus">False</property> </object> <packing> - <property name="left_attach">1</property> - <property name="top_attach">4</property> + <property name="left-attach">1</property> + <property name="top-attach">4</property> </packing> </child> <child> <object class="GtkBox" id="hbox2"> <property name="visible">True</property> - <property name="can_focus">False</property> + <property name="can-focus">False</property> <property name="spacing">12</property> <child> <object class="GtkRadioButton" id="monitor_on_radio"> <property name="label" translatable="yes">On</property> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="use_underline">True</property> + <property name="can-focus">True</property> + <property name="receives-default">False</property> + <property name="use-underline">True</property> <property name="active">True</property> - <property name="draw_indicator">True</property> + <property name="draw-indicator">True</property> </object> <packing> <property name="expand">False</property> @@ -334,10 +286,10 @@ <object class="GtkRadioButton" id="monitor_off_radio"> <property name="label" translatable="yes">Off</property> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="use_underline">True</property> - <property name="draw_indicator">True</property> + <property name="can-focus">True</property> + <property name="receives-default">False</property> + <property name="use-underline">True</property> + <property name="draw-indicator">True</property> <property name="group">monitor_on_radio</property> </object> <packing> @@ -348,14 +300,14 @@ </child> </object> <packing> - <property name="left_attach">0</property> - <property name="top_attach">1</property> + <property name="left-attach">0</property> + <property name="top-attach">1</property> </packing> </child> <child> <object class="GtkComboBox" id="rotation_combo"> <property name="visible">True</property> - <property name="can_focus">False</property> + <property name="can-focus">False</property> <property name="model">liststore1</property> <child> <object class="GtkCellRendererText" id="cellrenderertext1"/> @@ -365,34 +317,34 @@ </child> </object> <packing> - <property name="left_attach">1</property> - <property name="top_attach">5</property> + <property name="left-attach">1</property> + <property name="top-attach">5</property> </packing> </child> <child> <object class="GtkCheckButton" id="panel_checkbox"> <property name="label" translatable="yes">Include _panel</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="use_underline">True</property> - <property name="draw_indicator">True</property> + <property name="can-focus">True</property> + <property name="receives-default">False</property> + <property name="use-underline">True</property> + <property name="draw-indicator">True</property> </object> <packing> - <property name="left_attach">0</property> - <property name="top_attach">6</property> + <property name="left-attach">0</property> + <property name="top-attach">6</property> </packing> </child> <child> <object class="GtkAlignment" id="alignment4"> <property name="visible">True</property> - <property name="can_focus">False</property> + <property name="can-focus">False</property> <child> <placeholder/> </child> </object> <packing> - <property name="left_attach">1</property> - <property name="top_attach">5</property> + <property name="left-attach">1</property> + <property name="top-attach">5</property> </packing> </child> <child> @@ -400,39 +352,39 @@ <property name="label" translatable="yes">Set as primary</property> <property name="visible">True</property> <property name="sensitive">False</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - <property name="tooltip_text" translatable="yes">Sets the selected monitor as primary.</property> + <property name="can-focus">True</property> + <property name="receives-default">True</property> + <property name="tooltip-text" translatable="yes">Sets the selected monitor as primary.</property> </object> <packing> - <property name="left_attach">0</property> - <property name="top_attach">2</property> + <property name="left-attach">0</property> + <property name="top-attach">2</property> <property name="width">2</property> </packing> </child> <child> <object class="GtkLabel" id="label5"> <property name="visible">True</property> - <property name="can_focus">False</property> + <property name="can-focus">False</property> <property name="label" translatable="yes">R_otation:</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">rotation_combo</property> + <property name="use-underline">True</property> + <property name="mnemonic-widget">rotation_combo</property> <property name="xalign">0</property> </object> <packing> - <property name="left_attach">0</property> - <property name="top_attach">5</property> + <property name="left-attach">0</property> + <property name="top-attach">5</property> </packing> </child> <child> <object class="GtkEventBox" id="current_monitor_event_box"> <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="visible_window">False</property> + <property name="can-focus">False</property> + <property name="visible-window">False</property> <child> <object class="GtkLabel" id="current_monitor_label"> <property name="visible">True</property> - <property name="can_focus">False</property> + <property name="can-focus">False</property> <property name="label" translatable="yes">Monitor</property> <property name="xalign">0</property> <attributes> @@ -442,8 +394,8 @@ </child> </object> <packing> - <property name="left_attach">0</property> - <property name="top_attach">0</property> + <property name="left-attach">0</property> + <property name="top-attach">0</property> <property name="width">2</property> </packing> </child> @@ -457,11 +409,95 @@ </child> </object> <packing> - <property name="left_attach">1</property> - <property name="top_attach">0</property> + <property name="left-attach">1</property> + <property name="top-attach">0</property> </packing> </child> <child> + <object class="GtkBox" id="vbox4"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="orientation">vertical</property> + <child> + <object class="GtkLabel" id="label8"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="label" translatable="yes">Panel icon</property> + <property name="xalign">0</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="GtkAlignment" id="alignment2"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="left-padding">12</property> + <child> + <object class="GtkCheckButton" id="show_notification_icon"> + <property name="label" translatable="yes">_Show monitors in panel</property> + <property name="visible">True</property> + <property name="can-focus">True</property> + <property name="receives-default">False</property> + <property name="halign">start</property> + <property name="use-underline">True</property> + <property name="draw-indicator">True</property> + </object> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="left-attach">0</property> + <property name="top-attach">2</property> + </packing> + </child> + <child> + <object class="GtkBox" id="scale_vbox"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="orientation">vertical</property> + <property name="spacing">12</property> + <child> + <object class="GtkLabel" id="label9"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="label" translatable="yes">Scaling</property> + <property name="xalign">0</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> + <placeholder/> + </child> + </object> + <packing> + <property name="left-attach">0</property> + <property name="top-attach">1</property> + </packing> + </child> + <child> + <placeholder/> + </child> + <child> <placeholder/> </child> </object> @@ -479,8 +515,5 @@ <action-widget response="-10">apply_button</action-widget> <action-widget response="-7">button2</action-widget> </action-widgets> - <child type="titlebar"> - <placeholder/> - </child> </object> </interface> diff --git a/capplets/display/ui-a11y.suppr b/capplets/display/ui-a11y.suppr index 318cde7c..f75c8d3b 100644 --- a/capplets/display/ui-a11y.suppr +++ b/capplets/display/ui-a11y.suppr @@ -1,2 +1,3 @@ display-capplet.ui://GtkLabel[@id='label8'] orphan-label +display-capplet.ui://GtkLabel[@id='label9'] orphan-label display-capplet.ui://GtkLabel[@id='current_monitor_label'] orphan-label diff --git a/capplets/display/xrandr-capplet.c b/capplets/display/xrandr-capplet.c index dea2614a..012d8936 100644 --- a/capplets/display/xrandr-capplet.c +++ b/capplets/display/xrandr-capplet.c @@ -38,6 +38,9 @@ #include "capplet-util.h" +#define MATE_INTERFACE_SCHEMA "org.mate.interface" +#define WINDOW_SCALE_KEY "window-scaling-factor" + typedef struct App App; typedef struct GrabInfo GrabInfo; @@ -58,6 +61,8 @@ struct App GtkWidget *refresh_combo; GtkWidget *rotation_combo; GtkWidget *panel_checkbox; + GtkWidget *scale_vbox; + GtkWidget *scale_bbox; GtkWidget *clone_checkbox; GtkWidget *show_icon_checkbox; GtkWidget *primary_button; @@ -69,6 +74,7 @@ struct App GtkWidget *area; gboolean ignore_gui_changes; GSettings *settings; + GSettings *scale_settings; /* These are used while we are waiting for the ApplyConfiguration method to be executed over D-bus */ GDBusConnection *connection; @@ -453,6 +459,58 @@ mirror_screens_is_supported (App *app) } static void +on_scale_btn_active_changed_cb (GtkWidget *widget, + App *app) +{ + gint scale; + + if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) + return; + + scale = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "scale")); + g_settings_set_int (app->scale_settings, WINDOW_SCALE_KEY, scale); +} + +static void +rebuild_scale_window (App *app) +{ + GtkRadioButton *group = NULL; + gint32 scale; + int i; + const char *button_label[] = {_("auto detect"), _("100%"), _("200%"), NULL}; + + if (app->scale_bbox != NULL) + return; + + app->scale_bbox = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL); + gtk_container_set_border_width (GTK_CONTAINER (app->scale_bbox), 6); + gtk_container_add (GTK_CONTAINER (app->scale_vbox), app->scale_bbox); + + scale = g_settings_get_int (app->scale_settings, WINDOW_SCALE_KEY); + + for (i = 0; button_label[i] != NULL; i++) + { + GtkWidget *scale_btn; + scale_btn = gtk_radio_button_new_with_label_from_widget (group, button_label[i]); + if (!group) + group = GTK_RADIO_BUTTON (scale_btn); + if (i == scale) + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (scale_btn), TRUE); + + g_object_set_data (G_OBJECT (scale_btn), + "scale", + GINT_TO_POINTER (i)); + + g_signal_connect (scale_btn, + "toggled", + G_CALLBACK (on_scale_btn_active_changed_cb), + app); + gtk_container_add (GTK_CONTAINER (app->scale_bbox), scale_btn); + } + gtk_widget_show_all (app->scale_bbox); +} + +static void rebuild_mirror_screens (App *app) { gboolean mirror_is_active; @@ -646,6 +704,7 @@ rebuild_gui (App *app) #endif rebuild_mirror_screens (app); + rebuild_scale_window (app); rebuild_current_monitor_label (app); rebuild_on_off_radios (app); rebuild_resolution_combo (app); @@ -2397,6 +2456,7 @@ run_application (App *app) } app->settings = g_settings_new (MSD_XRANDR_SCHEMA); + app->scale_settings = g_settings_new (MATE_INTERFACE_SCHEMA); app->dialog = _gtk_builder_get_widget (builder, "dialog"); g_signal_connect_after (app->dialog, "map-event", @@ -2433,6 +2493,8 @@ run_application (App *app) g_signal_connect (app->rotation_combo, "changed", G_CALLBACK (on_rotation_changed), app); + app->scale_vbox = _gtk_builder_get_widget (builder, "scale_vbox"); + app->clone_checkbox = _gtk_builder_get_widget (builder, "clone_checkbox"); g_signal_connect (app->clone_checkbox, "toggled", G_CALLBACK (on_clone_changed), app); @@ -2526,6 +2588,7 @@ restart: gtk_widget_destroy (app->dialog); g_object_unref (app->screen); g_object_unref (app->settings); + g_object_unref (app->scale_settings); } int |