summaryrefslogtreecommitdiff
path: root/chromium/ui/gtk/settings_provider_gsettings.h
blob: 9ef220a8511691c682f037114853bd945995b179 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef UI_GTK_SETTINGS_PROVIDER_GSETTINGS_H_
#define UI_GTK_SETTINGS_PROVIDER_GSETTINGS_H_

#include <gio/gio.h>

#include <string>

#include "base/macros.h"
#include "ui/base/glib/glib_signal.h"
#include "ui/gtk/settings_provider.h"

namespace gtk {
class GtkUi;

// On GNOME desktops, subscribes to the gsettings key which controlls button
// order and the middle click action. Everywhere else, SetTiltebarButtons()
// just calls back into BrowserTitlebar with the default ordering.
class SettingsProviderGSettings : public SettingsProvider {
 public:
  // Sends data to the GtkUi when available.
  explicit SettingsProviderGSettings(GtkUi* delegate);
  ~SettingsProviderGSettings() override;

 private:
  CHROMEG_CALLBACK_1(SettingsProviderGSettings,
                     void,
                     OnDecorationButtonLayoutChanged,
                     GSettings*,
                     const gchar*);

  CHROMEG_CALLBACK_1(SettingsProviderGSettings,
                     void,
                     OnMiddleClickActionChanged,
                     GSettings*,
                     const gchar*);

  void ParseAndStoreButtonValue(const std::string&);

  void ParseAndStoreMiddleClickValue(const std::string&);

  GtkUi* delegate_;

  GSettings* button_settings_ = nullptr;
  GSettings* click_settings_ = nullptr;
  gulong signal_button_id_;
  gulong signal_middle_click_id_;

  DISALLOW_COPY_AND_ASSIGN(SettingsProviderGSettings);
};

}  // namespace gtk

#endif  // UI_GTK_SETTINGS_PROVIDER_GSETTINGS_H_