settings_provider_gsettings.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // Copyright 2017 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef UI_GTK_SETTINGS_PROVIDER_GSETTINGS_H_
  5. #define UI_GTK_SETTINGS_PROVIDER_GSETTINGS_H_
  6. #include <gio/gio.h>
  7. #include <string>
  8. #include "base/memory/raw_ptr.h"
  9. #include "ui/base/glib/glib_signal.h"
  10. #include "ui/base/glib/scoped_gobject.h"
  11. #include "ui/gtk/settings_provider.h"
  12. namespace gtk {
  13. class GtkUi;
  14. // On GNOME desktops, subscribes to the gsettings key which controlls button
  15. // order and the middle click action. Everywhere else, SetTiltebarButtons()
  16. // just calls back into BrowserTitlebar with the default ordering.
  17. class SettingsProviderGSettings : public SettingsProvider {
  18. public:
  19. // Sends data to the GtkUi when available.
  20. explicit SettingsProviderGSettings(GtkUi* delegate);
  21. SettingsProviderGSettings(const SettingsProviderGSettings&) = delete;
  22. SettingsProviderGSettings& operator=(const SettingsProviderGSettings&) =
  23. delete;
  24. ~SettingsProviderGSettings() override;
  25. private:
  26. CHROMEG_CALLBACK_1(SettingsProviderGSettings,
  27. void,
  28. OnDecorationButtonLayoutChanged,
  29. GSettings*,
  30. const gchar*);
  31. CHROMEG_CALLBACK_1(SettingsProviderGSettings,
  32. void,
  33. OnMiddleClickActionChanged,
  34. GSettings*,
  35. const gchar*);
  36. void ParseAndStoreButtonValue(const std::string&);
  37. void ParseAndStoreMiddleClickValue(const std::string&);
  38. raw_ptr<GtkUi> delegate_;
  39. ScopedGObject<GSettings> button_settings_;
  40. ScopedGObject<GSettings> click_settings_;
  41. gulong signal_button_id_;
  42. gulong signal_middle_click_id_;
  43. };
  44. } // namespace gtk
  45. #endif // UI_GTK_SETTINGS_PROVIDER_GSETTINGS_H_