~attente/unity-control-center/iso-next-group

« back to all changes in this revision

Viewing changes to panels/display/cc-display-panel.c

  • Committer: CI bot
  • Author(s): Marco Trevisan (Treviño)
  • Date: 2014-03-28 12:57:57 UTC
  • mfrom: (12761.3.21 unity-control-center)
  • Revision ID: ps-jenkins@lists.canonical.com-20140328125757-ny93p9x1f7xsq76b
Display: Use 2-columns style (Monitor/General options), add more UI scaling options Fixes: 1297053

Show diffs side-by-side

added added

removed removed

Lines of Context:
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"
65
68
 
89
92
 
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);
146
151
 
147
152
static void
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);
203
210
 
314
321
  select_current_output_from_dialog_position (self);
315
322
 
316
323
  if (is_unity_session ())
317
 
    refresh_unity_launcher_placement (self);
 
324
    {
 
325
      refresh_unity_launcher_placement (self);
 
326
      refresh_unity_monitor_scale (self);
 
327
    }
318
328
}
319
329
 
320
330
static void
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);
715
726
 
716
727
  g_signal_handlers_unblock_by_func (self->priv->clone_checkbox, G_CALLBACK (on_clone_changed), self);
717
728
}
732
743
static void
733
744
rebuild_current_monitor_label (CcDisplayPanel *self)
734
745
{
735
 
  char *str, *tmp;
 
746
  gchar *str;
736
747
  GdkRGBA color;
737
748
  gboolean use_color;
738
749
 
739
750
  if (self->priv->current_output)
740
751
    {
741
752
      if (gnome_rr_config_get_clone (self->priv->current_configuration))
742
 
        tmp = mirror_monitor_name ();
 
753
        {
 
754
          gchar *str = mirror_monitor_name ();
 
755
          gtk_label_set_text (GTK_LABEL (self->priv->current_monitor_label), str);
 
756
          g_free (str);
 
757
        }
743
758
      else
744
 
        tmp = g_strdup (gnome_rr_output_info_get_display_name (self->priv->current_output));
 
759
        {
 
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);
 
762
        }
745
763
 
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;
749
 
      g_free (tmp);
750
766
    }
751
767
  else
752
768
    {
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;
755
771
    }
756
772
 
757
 
  gtk_label_set_markup (GTK_LABEL (self->priv->current_monitor_label), str);
758
 
  g_free (str);
759
 
 
760
773
  if (use_color)
761
774
    {
762
775
      GdkRGBA black = { 0, 0, 0, 1.0 };
956
969
  rebuild_rotation_combo (self);
957
970
  rebuild_ui_scale (self);
958
971
  refresh_unity_launcher_placement (self);
 
972
  refresh_unity_monitor_scale (self);
959
973
 
960
974
  self->priv->ignore_gui_changes = FALSE;
961
975
}
2859
2873
   gtk_combo_box_set_active (GTK_COMBO_BOX (launcher_placement_combo), index_of_primary_screen);
2860
2874
}
2861
2875
 
 
2876
static void
 
2877
refresh_unity_monitor_scale (CcDisplayPanel *self)
 
2878
{
 
2879
  GtkWidget *ui_scale_monitor_combo = WID ("ui_scale_monitor_combo");
 
2880
  GtkListStore *liststore;
 
2881
  GtkTreeIter iter;
 
2882
  GList *connected_outputs = NULL;
 
2883
  GList *list;
 
2884
  gchar *target_monitor = g_settings_get_string (self->priv->unity_ui_settings, UNITY_UI_SCALE_FACTOR_MONITOR);
 
2885
  gint target_monitor_idx = -1;
 
2886
  gint i;
 
2887
 
 
2888
  liststore = (GtkListStore *) gtk_builder_get_object (self->priv->builder, "available_ui_scale_monitor_store");
 
2889
  gtk_list_store_clear (liststore);
 
2890
 
 
2891
  connected_outputs = list_connected_outputs (self, NULL, NULL);
 
2892
  for (list = connected_outputs, i = 0; list != NULL; list = list->next)
 
2893
    {
 
2894
      gchar *monitor_name;
 
2895
      GdkPixbuf *monitor_pixbuf;
 
2896
      GnomeRROutputInfo *output = list->data;
 
2897
 
 
2898
      if (!gnome_rr_output_info_is_active (output))
 
2899
        continue;
 
2900
 
 
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);
 
2904
 
 
2905
      gtk_list_store_set (liststore, &iter, 0, monitor_pixbuf, 1, monitor_name, -1);
 
2906
 
 
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;
 
2910
      i++;
 
2911
 
 
2912
      g_object_unref (monitor_pixbuf);
 
2913
      g_free (monitor_name);
 
2914
    }
 
2915
 
 
2916
   gtk_list_store_append (liststore, &iter);
 
2917
   gtk_list_store_set (liststore, &iter, 0, NULL, 1, _("Display with largest controls"), -1);
 
2918
   gint max_idx = i++;
 
2919
 
 
2920
   gtk_list_store_append (liststore, &iter);
 
2921
   gtk_list_store_set (liststore, &iter, 0, NULL, 1, _("Display with smallest controls"), -1);
 
2922
   gint min_idx = i++;
 
2923
 
 
2924
   if (target_monitor_idx < 0)
 
2925
    {
 
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;
 
2928
    }
 
2929
 
 
2930
   gtk_combo_box_set_active (GTK_COMBO_BOX (ui_scale_monitor_combo), target_monitor_idx);
 
2931
 
 
2932
   g_free (target_monitor);
 
2933
}
 
2934
 
2862
2935
static gboolean
2863
2936
switcher_set_to_launcher_on_all_monitors (CcDisplayPanel *self)
2864
2937
{
2927
3000
}
2928
3001
 
2929
3002
static void
 
3003
on_ui_scale_monitor_combo_setting_changed (GSettings* settings,
 
3004
                                           guint key,
 
3005
                                           CcDisplayPanel *self)
 
3006
{
 
3007
  refresh_unity_monitor_scale (self);
 
3008
}
 
3009
 
 
3010
static void
 
3011
on_ui_scale_monitor_combo_changed (GtkComboBox *combo, CcDisplayPanel *self)
 
3012
{
 
3013
  gint active = gtk_combo_box_get_active (combo);
 
3014
  gint i;
 
3015
  gint index_on_combo = 0;
 
3016
  gchar *scale_monitor = NULL;
 
3017
 
 
3018
  if (active < 0)
 
3019
    return;
 
3020
 
 
3021
  GnomeRROutputInfo **outputs = gnome_rr_config_get_outputs (self->priv->current_configuration);
 
3022
 
 
3023
  for (i = 0; outputs[i] != NULL; ++i)
 
3024
    {
 
3025
      GnomeRROutputInfo *output = outputs[i];
 
3026
      if (!gnome_rr_output_info_is_active (output))
 
3027
        continue;
 
3028
 
 
3029
      if (active == index_on_combo)
 
3030
        {
 
3031
          scale_monitor = g_strdup (gnome_rr_output_info_get_name (output));
 
3032
          break;
 
3033
        }
 
3034
      index_on_combo++;
 
3035
    }
 
3036
 
 
3037
    if (!scale_monitor)
 
3038
      {
 
3039
        scale_monitor = g_strdup("");
 
3040
 
 
3041
        if (active >= index_on_combo)
 
3042
          {
 
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);
 
3045
 
 
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);
 
3048
          }
 
3049
      }
 
3050
 
 
3051
  gchar *current_setting = g_settings_get_string (self->priv->unity_ui_settings, UNITY_UI_SCALE_FACTOR_MONITOR);
 
3052
 
 
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);
 
3055
 
 
3056
  g_free (current_setting);
 
3057
  g_free (scale_monitor);
 
3058
}
 
3059
 
 
3060
static void
2930
3061
setup_unity_settings (CcDisplayPanel *self)
2931
3062
{
2932
3063
  GSettingsSchema *schema;
2946
3077
      g_settings_schema_unref (schema);
2947
3078
    }
2948
3079
 
2949
 
  if (!self->priv->unity_settings)
 
3080
  schema = g_settings_schema_source_lookup (g_settings_schema_source_get_default (), UNITY_UI_GSETTINGS_SCHEMA, TRUE);
 
3081
  if (schema)
 
3082
    {
 
3083
      self->priv->unity_ui_settings = g_settings_new (UNITY_UI_GSETTINGS_SCHEMA);
 
3084
      g_settings_schema_unref (schema);
 
3085
    }
 
3086
 
 
3087
  if (!self->priv->unity_settings || !self->priv->unity_ui_settings)
2950
3088
    return;
2951
3089
 
2952
3090
  GtkWidget *sticky_edge_switch = WID ("stickyedge_switch");
2957
3095
  stickyedge_widget_refresh (GTK_SWITCH (sticky_edge_switch), self->priv->unity_settings);
2958
3096
 
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);
 
3101
 
 
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);
2963
3108
}
2964
3109
 
2965
3110
static void
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};
2983
3129
 
2984
3130
  obj = G_OBJECT_CLASS (cc_display_panel_parent_class)->constructor (gtype, n_properties, properties);
2985
3131
  self = CC_DISPLAY_PANEL (obj);
3072
3218
 
3073
3219
  gtk_container_add (GTK_CONTAINER (align), self->priv->area);
3074
3220
 
3075
 
  on_screen_changed (self->priv->screen, self);
3076
 
 
3077
3221
  g_signal_connect_swapped (WID ("apply_button"),
3078
3222
                            "clicked", G_CALLBACK (apply), self);
3079
3223
 
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"));
3090
3239
    }
3091
3240
 
3092
3241
  gtk_widget_show (self->priv->panel);
3093
3242
  gtk_container_add (GTK_CONTAINER (self), self->priv->panel);
3094
3243
 
 
3244
  on_screen_changed (self->priv->screen, self);
 
3245
 
3095
3246
  return obj;
3096
3247
}
3097
3248