60
60
#define UNITY_GSETTINGS_PATH "/org/compiz/profiles/unity/plugins/unityshell/"
61
61
#define UNITY_LAUNCHER_ALL_MONITORS_KEY "num-launchers"
62
62
#define UNITY_STICKY_EDGE_KEY "launcher-capture-mouse"
63
#define UNITY_UI_GSETTINGS_SCHEMA "com.canonical.Unity.Interface"
64
#define UNITY_UI_SCALE_FACTOR_MONITOR "app-scale-factor-monitor"
65
#define UNITY_UI_SCALE_FALLBACK_TO_MAX "app-fallback-to-maximum-scale-factor"
63
66
#define UNITY2D_GSETTINGS_MAIN "com.canonical.Unity2d"
64
67
#define UNITY2D_GSETTINGS_LAUNCHER "com.canonical.Unity2d.Launcher"
90
93
GSettings *clock_settings;
91
94
GSettings *unity_settings;
95
GSettings *unity_ui_settings;
92
96
GSettings *unity2d_settings_main;
93
97
GSettings *unity2d_settings_launcher;
94
98
GSettings *desktop_settings;
142
146
GObjectConstructParam *properties);
143
147
static void on_screen_changed (GnomeRRScreen *scr, gpointer data);
144
148
static void refresh_unity_launcher_placement (CcDisplayPanel *self);
149
static void refresh_unity_monitor_scale (CcDisplayPanel *self);
145
150
static gboolean unity_launcher_on_all_monitors (GSettings *settings);
198
203
g_object_unref (self->priv->unity2d_settings_launcher);
199
204
if (self->priv->unity_settings != NULL)
200
205
g_object_unref (self->priv->unity_settings);
206
if (self->priv->unity_ui_settings != NULL)
207
g_object_unref (self->priv->unity_ui_settings);
201
208
if (self->priv->desktop_settings != NULL)
202
209
g_object_unref (self->priv->desktop_settings);
712
722
/* set inactive the launcher placement choice */
713
723
gtk_widget_set_sensitive (WID ("launcher_placement_combo"), !mirror_is_active);
714
724
gtk_widget_set_sensitive (WID ("stickyedge_switch"), !mirror_is_active);
725
gtk_widget_set_sensitive (WID ("ui_scale_monitor_combo"), !mirror_is_active);
716
727
g_signal_handlers_unblock_by_func (self->priv->clone_checkbox, G_CALLBACK (on_clone_changed), self);
733
744
rebuild_current_monitor_label (CcDisplayPanel *self)
737
748
gboolean use_color;
739
750
if (self->priv->current_output)
741
752
if (gnome_rr_config_get_clone (self->priv->current_configuration))
742
tmp = mirror_monitor_name ();
754
gchar *str = mirror_monitor_name ();
755
gtk_label_set_text (GTK_LABEL (self->priv->current_monitor_label), str);
744
tmp = g_strdup (gnome_rr_output_info_get_display_name (self->priv->current_output));
760
str = gnome_rr_output_info_get_display_name (self->priv->current_output);
761
gtk_label_set_text (GTK_LABEL (self->priv->current_monitor_label), str);
746
str = g_strdup_printf ("<b>%s</b>", tmp);
747
764
cc_rr_labeler_get_rgba_for_output (self->priv->labeler, self->priv->current_output, &color);
748
765
use_color = TRUE;
753
str = g_strdup_printf ("<b>%s</b>", _("Monitor"));
769
gtk_label_set_text (GTK_LABEL (self->priv->current_monitor_label), _("Monitor"));
754
770
use_color = FALSE;
757
gtk_label_set_markup (GTK_LABEL (self->priv->current_monitor_label), str);
762
775
GdkRGBA black = { 0, 0, 0, 1.0 };
2859
2873
gtk_combo_box_set_active (GTK_COMBO_BOX (launcher_placement_combo), index_of_primary_screen);
2877
refresh_unity_monitor_scale (CcDisplayPanel *self)
2879
GtkWidget *ui_scale_monitor_combo = WID ("ui_scale_monitor_combo");
2880
GtkListStore *liststore;
2882
GList *connected_outputs = NULL;
2884
gchar *target_monitor = g_settings_get_string (self->priv->unity_ui_settings, UNITY_UI_SCALE_FACTOR_MONITOR);
2885
gint target_monitor_idx = -1;
2888
liststore = (GtkListStore *) gtk_builder_get_object (self->priv->builder, "available_ui_scale_monitor_store");
2889
gtk_list_store_clear (liststore);
2891
connected_outputs = list_connected_outputs (self, NULL, NULL);
2892
for (list = connected_outputs, i = 0; list != NULL; list = list->next)
2894
gchar *monitor_name;
2895
GdkPixbuf *monitor_pixbuf;
2896
GnomeRROutputInfo *output = list->data;
2898
if (!gnome_rr_output_info_is_active (output))
2901
gtk_list_store_append (liststore, &iter);
2902
monitor_name = g_strdup (gnome_rr_output_info_get_display_name (output));
2903
monitor_pixbuf = get_monitor_pixbuf (self, output);
2905
gtk_list_store_set (liststore, &iter, 0, monitor_pixbuf, 1, monitor_name, -1);
2907
/* select it if primary and only one launcher */
2908
if (g_strcmp0 (gnome_rr_output_info_get_name (output), target_monitor) == 0)
2909
target_monitor_idx = i;
2912
g_object_unref (monitor_pixbuf);
2913
g_free (monitor_name);
2916
gtk_list_store_append (liststore, &iter);
2917
gtk_list_store_set (liststore, &iter, 0, NULL, 1, _("Display with largest controls"), -1);
2920
gtk_list_store_append (liststore, &iter);
2921
gtk_list_store_set (liststore, &iter, 0, NULL, 1, _("Display with smallest controls"), -1);
2924
if (target_monitor_idx < 0)
2926
gboolean fallback_max_scale = g_settings_get_boolean (self->priv->unity_ui_settings, UNITY_UI_SCALE_FALLBACK_TO_MAX);
2927
target_monitor_idx = fallback_max_scale ? max_idx : min_idx;
2930
gtk_combo_box_set_active (GTK_COMBO_BOX (ui_scale_monitor_combo), target_monitor_idx);
2932
g_free (target_monitor);
2862
2935
static gboolean
2863
2936
switcher_set_to_launcher_on_all_monitors (CcDisplayPanel *self)
3003
on_ui_scale_monitor_combo_setting_changed (GSettings* settings,
3005
CcDisplayPanel *self)
3007
refresh_unity_monitor_scale (self);
3011
on_ui_scale_monitor_combo_changed (GtkComboBox *combo, CcDisplayPanel *self)
3013
gint active = gtk_combo_box_get_active (combo);
3015
gint index_on_combo = 0;
3016
gchar *scale_monitor = NULL;
3021
GnomeRROutputInfo **outputs = gnome_rr_config_get_outputs (self->priv->current_configuration);
3023
for (i = 0; outputs[i] != NULL; ++i)
3025
GnomeRROutputInfo *output = outputs[i];
3026
if (!gnome_rr_output_info_is_active (output))
3029
if (active == index_on_combo)
3031
scale_monitor = g_strdup (gnome_rr_output_info_get_name (output));
3039
scale_monitor = g_strdup("");
3041
if (active >= index_on_combo)
3043
gboolean use_max_scaled_monitor = (active == index_on_combo);
3044
gboolean fallback_setting = g_settings_get_boolean (self->priv->unity_ui_settings, UNITY_UI_SCALE_FALLBACK_TO_MAX);
3046
if (fallback_setting != use_max_scaled_monitor)
3047
g_settings_set_boolean (self->priv->unity_ui_settings, UNITY_UI_SCALE_FALLBACK_TO_MAX, use_max_scaled_monitor);
3051
gchar *current_setting = g_settings_get_string (self->priv->unity_ui_settings, UNITY_UI_SCALE_FACTOR_MONITOR);
3053
if (g_strcmp0 (current_setting, scale_monitor) != 0)
3054
g_settings_set_string (self->priv->unity_ui_settings, UNITY_UI_SCALE_FACTOR_MONITOR, scale_monitor);
3056
g_free (current_setting);
3057
g_free (scale_monitor);
2930
3061
setup_unity_settings (CcDisplayPanel *self)
2932
3063
GSettingsSchema *schema;
2946
3077
g_settings_schema_unref (schema);
2949
if (!self->priv->unity_settings)
3080
schema = g_settings_schema_source_lookup (g_settings_schema_source_get_default (), UNITY_UI_GSETTINGS_SCHEMA, TRUE);
3083
self->priv->unity_ui_settings = g_settings_new (UNITY_UI_GSETTINGS_SCHEMA);
3084
g_settings_schema_unref (schema);
3087
if (!self->priv->unity_settings || !self->priv->unity_ui_settings)
2952
3090
GtkWidget *sticky_edge_switch = WID ("stickyedge_switch");
2957
3095
stickyedge_widget_refresh (GTK_SWITCH (sticky_edge_switch), self->priv->unity_settings);
2959
3097
g_signal_connect (G_OBJECT (WID ("launcher_placement_combo")), "changed",
2960
G_CALLBACK (on_launcher_placement_combo_changed), self);
3098
G_CALLBACK (on_launcher_placement_combo_changed), self);
2961
3099
g_signal_connect (self->priv->unity_settings, "changed::" UNITY_LAUNCHER_ALL_MONITORS_KEY,
2962
3100
G_CALLBACK (ext_launcher_placement_changed_callback), self);
3102
g_signal_connect (G_OBJECT (WID ("ui_scale_monitor_combo")), "changed",
3103
G_CALLBACK (on_ui_scale_monitor_combo_changed), self);
3104
g_signal_connect (self->priv->unity_ui_settings, "changed::" UNITY_UI_SCALE_FACTOR_MONITOR,
3105
G_CALLBACK (on_ui_scale_monitor_combo_setting_changed), self);
3106
g_signal_connect (self->priv->unity_ui_settings, "changed::" UNITY_UI_SCALE_FALLBACK_TO_MAX,
3107
G_CALLBACK (on_ui_scale_monitor_combo_setting_changed), self);
2979
3124
CcDisplayPanel *self;
2980
3125
CcShell *shell;
2981
3126
GtkWidget *toplevel;
2982
gchar *objects[] = {"display-panel", "available_launcher_placement_store", NULL};
3127
gchar *objects[] = {"display-panel", "available_launcher_placement_store",
3128
"available_ui_scale_monitor_store", NULL};
2984
3130
obj = G_OBJECT_CLASS (cc_display_panel_parent_class)->constructor (gtype, n_properties, properties);
2985
3131
self = CC_DISPLAY_PANEL (obj);
3073
3219
gtk_container_add (GTK_CONTAINER (align), self->priv->area);
3075
on_screen_changed (self->priv->screen, self);
3077
3221
g_signal_connect_swapped (WID ("apply_button"),
3078
3222
"clicked", G_CALLBACK (apply), self);
3087
3231
gtk_widget_hide (WID ("sticky_edge_label"));
3088
3232
gtk_widget_hide (WID ("launcher_placement_combo"));
3089
3233
gtk_widget_hide (WID ("stickyedge_switch"));
3234
gtk_widget_hide (WID ("ui_scale_separator"));
3235
gtk_widget_hide (WID ("ui_scale_label"));
3236
gtk_widget_hide (WID ("ui_scale"));
3237
gtk_widget_hide (WID ("ui_scale_monitor_label"));
3238
gtk_widget_hide (WID ("ui_scale_monitor_combo"));
3092
3241
gtk_widget_show (self->priv->panel);
3093
3242
gtk_container_add (GTK_CONTAINER (self), self->priv->panel);
3244
on_screen_changed (self->priv->screen, self);