Home | History | Annotate | Download | only in libgtk2ui
      1 // Copyright 2014 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_LISTENER_H_
      6 #define CHROME_BROWSER_UI_LIBGTK2UI_GCONF_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 "base/callback_forward.h"
     16 #include "chrome/browser/ui/libgtk2ui/gtk2_signal.h"
     17 
     18 namespace libgtk2ui {
     19 class Gtk2UI;
     20 
     21 // On GNOME desktops, subscribes to the gconf key which controlls button order.
     22 // Everywhere else, SetTiltebarButtons() just calls back into BrowserTitlebar
     23 // with the default ordering.
     24 class GConfListener {
     25  public:
     26   // Sends data to the Gtk2UI when available.
     27   explicit GConfListener(Gtk2UI* delegate);
     28   ~GConfListener();
     29 
     30  private:
     31   // Called whenever the metacity key changes.
     32   CHROMEG_CALLBACK_2(GConfListener, void, OnChangeNotification,
     33                      GConfClient*, guint, GConfEntry*);
     34 
     35   void GetAndRegister(const char* key_to_subscribe,
     36                       const base::Callback<void(GConfValue*)>& initial_setter);
     37 
     38   // Checks |error|. On error, prints out a message and closes the connection
     39   // to GConf and reverts to default mode.
     40   bool HandleGError(GError* error, const char* key);
     41 
     42   // Parses the return data structure from GConf, falling back to the default
     43   // value on any error.
     44   void ParseAndStoreButtonValue(GConfValue* gconf_value);
     45   void ParseAndStoreMiddleClickValue(GConfValue* gconf_value);
     46 
     47   Gtk2UI* delegate_;
     48 
     49   // Pointer to our gconf context. NULL if we aren't on a desktop that uses
     50   // gconf.
     51   GConfClient* client_;
     52 
     53   DISALLOW_COPY_AND_ASSIGN(GConfListener);
     54 };
     55 
     56 }  // namespace libgtk2ui
     57 
     58 #endif  // CHROME_BROWSER_UI_LIBGTK2UI_GCONF_LISTENER_H_
     59