From 5afb6c09ed3770753eaf068f1a6f998c8d0b9b07 Mon Sep 17 00:00:00 2001 From: Clement Lefebvre Date: Fri, 4 Sep 2015 16:00:03 +0100 Subject: Display settings: Added support to set the primary monitor. --- capplets/display/display-capplet.ui | 258 ++++++++++++++++++++++-------------- capplets/display/xrandr-capplet.c | 25 ++++ 2 files changed, 181 insertions(+), 102 deletions(-) diff --git a/capplets/display/display-capplet.ui b/capplets/display/display-capplet.ui index fec38817..9887a410 100644 --- a/capplets/display/display-capplet.ui +++ b/capplets/display/display-capplet.ui @@ -1,19 +1,99 @@ - + + False 5 Monitor Preferences dialog True - vertical + False 2 + + + True + False + end + + + gtk-help + True + True + True + False + False + True + + + False + False + 0 + True + + + + + Apply system-wide + True + True + True + Applies the current configuration for other MATE users on the computer. Note that this doesn't affect login screens or other desktop environments. + False + True + + + False + False + 1 + + + + + gtk-apply + True + True + True + False + False + True + + + False + False + 2 + + + + + gtk-close + True + True + True + False + False + True + + + False + False + 3 + + + + + False + True + end + 0 + + True + False 2 2 12 @@ -21,22 +101,26 @@ True - vertical + False 12 True + False + True + True 0 True + False 12 @@ -44,6 +128,7 @@ True True False + False True True @@ -59,6 +144,7 @@ True True True + False True @@ -80,10 +166,11 @@ True - vertical + False True + False 0 Panel icon @@ -99,6 +186,7 @@ True + False 12 @@ -106,6 +194,7 @@ True True False + False True True @@ -127,72 +216,79 @@ True + False 0 0 True - 6 + False + 7 2 12 6 True + False 0 _Resolution: True resolution_combo - 2 - 3 + 3 + 4 GTK_FILL - + True + False 0 Re_fresh rate: True refresh_combo - 3 - 4 + 4 + 5 GTK_FILL - + True + False 1 2 - 2 - 3 - + 3 + 4 + True + False 1 2 - 3 - 4 - + 4 + 5 + True + False 12 @@ -200,6 +296,7 @@ True True False + False True True True @@ -216,6 +313,7 @@ True True False + False True True monitor_on_radio @@ -231,15 +329,17 @@ 2 1 2 - + True + False True + False 0 Monitor @@ -250,27 +350,29 @@ 2 - + True + False 0 R_otation: True rotation_combo - 4 - 5 + 5 + 6 GTK_FILL - + True + False liststore1 @@ -282,9 +384,9 @@ 1 2 - 4 - 5 - + 5 + 6 + @@ -292,19 +394,22 @@ Include _panel True False + False True True - 5 - 6 + 2 + 6 + 7 GTK_FILL - + True + False @@ -314,8 +419,26 @@ 2 5 6 - - + + + + + + + Set as primary + True + False + True + True + Sets the selected monitor as primary. + False + + + 2 + 2 + 3 + GTK_FILL + GTK_FILL @@ -324,86 +447,17 @@ 1 2 - + GTK_FILL + True + True 1 - - - True - end - - - gtk-help - True - True - True - False - True - - - False - False - 0 - True - - - - - Make Default - True - True - True - True - - - False - False - 1 - - - - - gtk-apply - True - True - True - False - True - - - False - False - 2 - - - - - gtk-close - True - True - True - False - True - - - False - False - 3 - - - - - False - end - 0 - - diff --git a/capplets/display/xrandr-capplet.c b/capplets/display/xrandr-capplet.c index 6b09de84..bc91fd32 100644 --- a/capplets/display/xrandr-capplet.c +++ b/capplets/display/xrandr-capplet.c @@ -63,6 +63,7 @@ struct App GtkWidget *panel_checkbox; GtkWidget *clone_checkbox; GtkWidget *show_icon_checkbox; + GtkWidget *primary_button; /* We store the event timestamp when the Apply button is clicked */ GtkWidget *apply_button; @@ -690,6 +691,8 @@ rebuild_gui (App *app) #endif gtk_widget_set_sensitive (app->panel_checkbox, sensitive); + gtk_widget_set_sensitive (app->primary_button, app->current_output && !mate_rr_output_info_get_primary(app->current_output)); + app->ignore_gui_changes = FALSE; } @@ -2178,6 +2181,24 @@ on_detect_displays (GtkWidget *widget, gpointer data) } } +static void +set_primary (GtkWidget *widget, gpointer data) +{ + App *app = data; + int i; + MateRROutputInfo **outputs; + + if (!app->current_output) + return; + + outputs = mate_rr_config_get_outputs (app->current_configuration); + for (i=0; outputs[i]!=NULL; i++) { + mate_rr_output_info_set_primary (outputs[i], outputs[i] == app->current_output); + } + + gtk_widget_set_sensitive (app->primary_button, !mate_rr_output_info_get_primary(app->current_output)); +} + #define MSD_XRANDR_SCHEMA "org.mate.SettingsDaemon.plugins.xrandr" #define SHOW_ICON_KEY "show-notification-icon" #define DEFAULT_CONFIGURATION_FILE_KEY "default-configuration-file" @@ -2511,6 +2532,10 @@ run_application (App *app) g_signal_connect (_gtk_builder_get_widget (builder, "detect_displays_button"), "clicked", G_CALLBACK (on_detect_displays), app); + app->primary_button = _gtk_builder_get_widget (builder, "primary_button"); + + g_signal_connect (app->primary_button, "clicked", G_CALLBACK (set_primary), app); + app->show_icon_checkbox = _gtk_builder_get_widget (builder, "show_notification_icon"); -- cgit v1.2.1