~ci-train-bot/unity/unity-ubuntu-disco-3336

« back to all changes in this revision

Viewing changes to unity-shared/UnitySettings.cpp

UnitySettings: use the ubuntu-schemas path for scaling settings

Also remove unused parts of EMConverter (LP: #1721082)

Approved by: Andrea Azzarone

Show diffs side-by-side

added added

removed removed

Lines of Context:
62
62
const std::string COMPIZ_PROFILE = "current-profile";
63
63
 
64
64
const std::string UBUNTU_UI_SETTINGS = "com.ubuntu.user-interface";
 
65
const std::string UBUNTU_DESKTOP_UI_SETTINGS = "com.ubuntu.user-interface.desktop";
65
66
const std::string SCALE_FACTOR = "scale-factor";
66
67
 
67
 
const std::string GNOME_UI_SETTINGS = "org.gnome.desktop.interface";
68
 
const std::string GNOME_FONT_NAME = "font-name";
69
 
const std::string GNOME_CURSOR_SIZE = "cursor-size";
70
 
const std::string GNOME_SCALE_FACTOR = "scaling-factor";
71
 
const std::string GNOME_TEXT_SCALE_FACTOR = "text-scaling-factor";
 
68
const std::string DESKTOP_CURSOR_SIZE = "cursor-size";
 
69
const std::string DESKTOP_SCALE_FACTOR = "scaling-factor";
 
70
const std::string DESKTOP_TEXT_SCALE_FACTOR = "text-scaling-factor";
72
71
 
73
72
const std::string REMOTE_CONTENT_SETTINGS = "com.canonical.Unity.Lenses";
74
73
const std::string REMOTE_CONTENT_KEY = "remote-content-search";
84
83
 
85
84
const int DEFAULT_LAUNCHER_SIZE = 64;
86
85
const int MINIMUM_DESKTOP_HEIGHT = 800;
87
 
const int GNOME_SETTINGS_CHANGED_WAIT_SECONDS = 1;
 
86
const int DESKTOP_SETTINGS_CHANGED_WAIT_SECONDS = 1;
88
87
const double DEFAULT_DPI = 96.0f;
89
88
const double DPI_SCALING_LIMIT = 140.0f;
90
89
const int DPI_SCALING_STEP = 8;
105
104
    , gestures_settings_(g_settings_new(GESTURES_SETTINGS.c_str()))
106
105
    , ui_settings_(g_settings_new(UI_SETTINGS.c_str()))
107
106
    , ubuntu_ui_settings_(g_settings_new(UBUNTU_UI_SETTINGS.c_str()))
108
 
    , gnome_ui_settings_(g_settings_new(GNOME_UI_SETTINGS.c_str()))
 
107
    , desktop_ui_settings_(g_settings_new(UBUNTU_DESKTOP_UI_SETTINGS.c_str()))
109
108
    , remote_content_settings_(g_settings_new(REMOTE_CONTENT_SETTINGS.c_str()))
110
109
    , launcher_sizes_(monitors::MAX, DEFAULT_LAUNCHER_SIZE)
111
110
    , cached_launcher_position_(LauncherPosition::LEFT)
174
173
      UpdateDPI();
175
174
    });
176
175
 
177
 
    signals_.Add<void, GSettings*, const gchar*>(gnome_ui_settings_, "changed::" + GNOME_FONT_NAME, [this] (GSettings*, const gchar* t) {
178
 
      UpdateFontSize();
179
 
      UpdateDPI();
180
 
    });
181
 
 
182
 
    signals_.Add<void, GSettings*, const gchar*>(gnome_ui_settings_, "changed::" + GNOME_TEXT_SCALE_FACTOR, [this] (GSettings*, const gchar* t) {
183
 
      double new_scale_factor = g_settings_get_double(gnome_ui_settings_, GNOME_TEXT_SCALE_FACTOR.c_str());
 
176
    signals_.Add<void, GSettings*, const gchar*>(desktop_ui_settings_, "changed::" + DESKTOP_TEXT_SCALE_FACTOR, [this] (GSettings*, const gchar* t) {
 
177
      double new_scale_factor = g_settings_get_double(desktop_ui_settings_, DESKTOP_TEXT_SCALE_FACTOR.c_str());
184
178
      g_settings_set_double(ui_settings_, TEXT_SCALE_FACTOR.c_str(), new_scale_factor);
185
179
    });
186
180
 
203
197
    UpdateGesturesSetting();
204
198
    UpdateTextScaleFactor();
205
199
    UpdateCursorScaleFactor();
206
 
    UpdateFontSize();
207
200
    UpdateDPI();
208
201
 
209
202
    CacheFormFactor();
365
358
    return g_settings_get_boolean(usettings_, PAM_CHECK_ACCOUNT_TYPE.c_str());
366
359
  }
367
360
 
368
 
  int GetFontSize() const
369
 
  {
370
 
    gint font_size;
371
 
    PangoFontDescription* desc;
372
 
 
373
 
    glib::String font_name(g_settings_get_string(gnome_ui_settings_, GNOME_FONT_NAME.c_str()));
374
 
    desc = pango_font_description_from_string(font_name);
375
 
    font_size = pango_font_description_get_size(desc);
376
 
    pango_font_description_free(desc);
377
 
 
378
 
    return font_size / 1024;
379
 
  }
380
 
 
381
 
  void UpdateFontSize()
382
 
  {
383
 
    int font_size = GetFontSize();
384
 
 
385
 
    for (auto const& em : em_converters_)
386
 
      em->SetFontSize(font_size);
387
 
  }
388
 
 
389
361
  void UpdateTextScaleFactor()
390
362
  {
391
363
    parent_->font_scaling = g_settings_get_double(ui_settings_, TEXT_SCALE_FACTOR.c_str());
505
477
 
506
478
  void UpdateAppsScaling(double scale)
507
479
  {
508
 
    signals_.Block(gnome_ui_settings_);
 
480
    signals_.Block(desktop_ui_settings_);
509
481
    unsigned integer_scaling = std::max<unsigned>(1, std::lround(scale));
510
482
    double point_scaling = scale / static_cast<double>(integer_scaling);
511
483
    double text_scale_factor = parent_->font_scaling() * point_scaling;
512
 
    glib::Variant default_cursor_size(g_settings_get_default_value(gnome_ui_settings_, GNOME_CURSOR_SIZE.c_str()), glib::StealRef());
 
484
    glib::Variant default_cursor_size(g_settings_get_default_value(desktop_ui_settings_, DESKTOP_CURSOR_SIZE.c_str()), glib::StealRef());
513
485
    int cursor_size = std::round(default_cursor_size.GetInt32() * point_scaling * cursor_scale_);
514
 
    g_settings_set_int(gnome_ui_settings_, GNOME_CURSOR_SIZE.c_str(), cursor_size);
515
 
    g_settings_set_uint(gnome_ui_settings_, GNOME_SCALE_FACTOR.c_str(), integer_scaling);
516
 
    g_settings_set_double(gnome_ui_settings_, GNOME_TEXT_SCALE_FACTOR.c_str(), text_scale_factor);
 
486
    g_settings_set_int(desktop_ui_settings_, DESKTOP_CURSOR_SIZE.c_str(), cursor_size);
 
487
    g_settings_set_uint(desktop_ui_settings_, DESKTOP_SCALE_FACTOR.c_str(), integer_scaling);
 
488
    g_settings_set_double(desktop_ui_settings_, DESKTOP_TEXT_SCALE_FACTOR.c_str(), text_scale_factor);
517
489
 
518
 
    changing_gnome_settings_timeout_.reset(new glib::TimeoutSeconds(GNOME_SETTINGS_CHANGED_WAIT_SECONDS, [this] {
519
 
      signals_.Unblock(gnome_ui_settings_);
 
490
    changing_desktop_settings_timeout_.reset(new glib::TimeoutSeconds(DESKTOP_SETTINGS_CHANGED_WAIT_SECONDS, [this] {
 
491
      signals_.Unblock(desktop_ui_settings_);
520
492
      return false;
521
493
    }, glib::Source::Priority::LOW));
522
494
  }
546
518
  glib::Object<GSettings> gestures_settings_;
547
519
  glib::Object<GSettings> ui_settings_;
548
520
  glib::Object<GSettings> ubuntu_ui_settings_;
549
 
  glib::Object<GSettings> gnome_ui_settings_;
 
521
  glib::Object<GSettings> desktop_ui_settings_;
550
522
  glib::Object<GSettings> remote_content_settings_;
551
 
  glib::Source::UniquePtr changing_gnome_settings_timeout_;
 
523
  glib::Source::UniquePtr changing_desktop_settings_timeout_;
552
524
  glib::SignalManager signals_;
553
525
  std::vector<EMConverter::Ptr> em_converters_;
554
526
  std::vector<int> launcher_sizes_;