OLD | NEW |
| (Empty) |
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_GTK_GCONF_TITLEBAR_LISTENER_H_ | |
6 #define CHROME_BROWSER_UI_GTK_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 "ui/base/gtk/gtk_signal.h" | |
16 | |
17 class BrowserTitlebar; | |
18 template <typename T> struct DefaultSingletonTraits; | |
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 // | |
24 // Meant to be used as a Singleton through base/memory/singleton.h's interface. | |
25 class GConfTitlebarListener { | |
26 public: | |
27 // Returns the singleton instance. | |
28 static GConfTitlebarListener* GetInstance(); | |
29 | |
30 // Sets the current titlebar button order. On GNOME desktops, also subscribes | |
31 // to further notifications when this changes. | |
32 void SetTitlebarButtons(BrowserTitlebar* titlebar); | |
33 | |
34 // Removes |titlebar| from the list of objects observing button order change | |
35 // notifications. | |
36 void RemoveObserver(BrowserTitlebar* titlebar); | |
37 | |
38 protected: | |
39 ~GConfTitlebarListener(); | |
40 | |
41 private: | |
42 // Private constructor to enforce singleton access. | |
43 GConfTitlebarListener(); | |
44 | |
45 // Called whenever the metacity key changes. | |
46 CHROMEG_CALLBACK_2(GConfTitlebarListener, void, OnChangeNotification, | |
47 GConfClient*, guint, GConfEntry*); | |
48 | |
49 // Checks |error|. On error, prints out a message and closes the connection | |
50 // to GConf and reverts to default mode. | |
51 bool HandleGError(GError* error, const char* key); | |
52 | |
53 // Parses the return data structure from GConf, falling back to the default | |
54 // value on any error. | |
55 void ParseAndStoreValue(GConfValue* gconf_value); | |
56 | |
57 // Pointer to our gconf context. NULL if we aren't on a desktop that uses | |
58 // gconf. | |
59 GConfClient* client_; | |
60 | |
61 // The current button ordering as heard from gconf. | |
62 std::string current_value_; | |
63 | |
64 // BrowserTitlebar objects which have subscribed to updates. | |
65 std::set<BrowserTitlebar*> titlebars_; | |
66 | |
67 friend struct DefaultSingletonTraits<GConfTitlebarListener>; | |
68 DISALLOW_COPY_AND_ASSIGN(GConfTitlebarListener); | |
69 }; | |
70 | |
71 #endif // CHROME_BROWSER_UI_GTK_GCONF_TITLEBAR_LISTENER_H_ | |
OLD | NEW |