- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / libgtk2ui / gconf_titlebar_listener.h
1 // Copyright (c) 2011 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
5 #ifndef CHROME_BROWSER_UI_LIBGTK2UI_GCONF_TITLEBAR_LISTENER_H_
6 #define CHROME_BROWSER_UI_LIBGTK2UI_GCONF_TITLEBAR_LISTENER_H_
7
8 #include <gconf/gconf-client.h>
9 #include <gtk/gtk.h>
10
11 #include <set>
12 #include <string>
13
14 #include "base/basictypes.h"
15 #include "chrome/browser/ui/libgtk2ui/gtk2_signal.h"
16
17 namespace libgtk2ui {
18 class Gtk2UI;
19
20 // On GNOME desktops, subscribes to the gconf key which controlls button order.
21 // Everywhere else, SetTiltebarButtons() just calls back into BrowserTitlebar
22 // with the default ordering.
23 class GConfTitlebarListener {
24  public:
25   // Sends data to the Gtk2UI when available.
26   explicit GConfTitlebarListener(Gtk2UI* delegate);
27   ~GConfTitlebarListener();
28
29  private:
30   // Called whenever the metacity key changes.
31   CHROMEG_CALLBACK_2(GConfTitlebarListener, void, OnChangeNotification,
32                      GConfClient*, guint, GConfEntry*);
33
34   // Checks |error|. On error, prints out a message and closes the connection
35   // to GConf and reverts to default mode.
36   bool HandleGError(GError* error, const char* key);
37
38   // Parses the return data structure from GConf, falling back to the default
39   // value on any error.
40   void ParseAndStoreValue(GConfValue* gconf_value);
41
42   Gtk2UI* delegate_;
43
44   // Pointer to our gconf context. NULL if we aren't on a desktop that uses
45   // gconf.
46   GConfClient* client_;
47
48   DISALLOW_COPY_AND_ASSIGN(GConfTitlebarListener);
49 };
50
51 }  // namespace libgtk2ui
52
53 #endif  // CHROME_BROWSER_UI_LIBGTK2UI_GCONF_TITLEBAR_LISTENER_H_