[gnome-applets] geyes: port to GSettings



commit 83868d043b3cb55d244eb84b9cb31544ef27b7b4
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Sat Jul 5 22:21:50 2014 +0300

    geyes: port to GSettings

 configure.ac                                       |    6 ++--
 geyes/Makefile.am                                  |   25 ++++++++++++-------
 geyes/geyes.c                                      |   10 ++++----
 geyes/geyes.h                                      |    5 ++++
 geyes/geyes.schemas.in                             |   17 -------------
 ...org.gnome.gnome-applets.geyes.gschema.xml.in.in |    8 ++++++
 geyes/themes.c                                     |   26 +------------------
 po/POTFILES.in                                     |    2 +-
 po/POTFILES.skip                                   |    1 +
 9 files changed, 41 insertions(+), 59 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index ab49a7d..5999cd5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -12,9 +12,9 @@ m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
 dnl ***************************************************************************
 dnl *** Minimum library versions for GNOME-APPLETS                          ***
 dnl ***************************************************************************
-GTK_REQUIRED=3.0
-GLIB_REQUIRED=2.22.0
-GIO_REQUIRED=2.15.3
+GTK_REQUIRED=3.2
+GLIB_REQUIRED=2.26.0
+GIO_REQUIRED=2.26.0
 GCONF_REQUIRED=2.8.0
 LIBPANEL_REQUIRED=2.91.90
 LIBGTOP_REQUIRED=2.11.92
diff --git a/geyes/Makefile.am b/geyes/Makefile.am
index f0b59c4..faa4b0b 100644
--- a/geyes/Makefile.am
+++ b/geyes/Makefile.am
@@ -40,16 +40,26 @@ org.gnome.panel.applet.GeyesAppletFactory.service: $(service_in_files)
             -e "s|\ LIBEXECDIR\@|$(libexecdir)|" \
             $< > $@
 
-CLEANFILES = $(applet_DATA) $(applet_DATA).in $(service_DATA) $(schemas_DATA)
+CLEANFILES = $(applet_DATA) $(applet_DATA).in $(service_DATA) \
+       $(gsettings_SCHEMAS_in) \
+       $(gsettings_SCHEMAS) \
+       *.gschema.valid
 
 uidir = $(pkgdatadir)/ui
 ui_DATA = geyes-applet-menu.xml
 
-schemasdir   = @GCONF_SCHEMA_FILE_DIR@
-schemas_in_files = geyes.schemas.in
-schemas_DATA = $(schemas_in_files:.schemas.in=.schemas)
+gsettings_schemas_in_in = \
+       org.gnome.gnome-applets.geyes.gschema.xml.in.in
 
- INTLTOOL_SCHEMAS_RULE@
+ INTLTOOL_XML_NOMERGE_RULE@
+
+gsettings_schemas_in = $(gsettings_schemas_in_in:.xml.in.in=.xml.in)
+gsettings_SCHEMAS = $(gsettings_schemas_in:.xml.in=.xml)
+
+%.gschema.xml.in: %.gschema.xml.in.in Makefile
+       $(AM_V_GEN) $(SED) -e 's^\ GETTEXT_PACKAGE\@^$(GETTEXT_PACKAGE)^g' < $< > $@
+
+ GSETTINGS_RULES@
 
 themesdir = $(pkgdatadir)/geyes
 
@@ -61,10 +71,10 @@ icons =     \
        gnome-eyes-applet.16.png
 
 EXTRA_DIST = \
+       $(gsettings_schemas_in_in)      \
             README.themes                                      \
             org.gnome.applets.GeyesApplet.panel-applet.in.in   \
              $(service_in_files)                               \
-            $(schemas_in_files)                                \
             $(ui_DATA)                                         \
             $(icons)
 
@@ -110,8 +120,5 @@ install-data-local:
                echo "*** Icon cache not updated. After install, run this:"; \
                echo "***   $(gtk_update_icon_cache)"; \
        fi
-if GCONF_SCHEMAS_INSTALL
-       GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) $(GCONFTOOL) --makefile-install-rule 
$(schemas_DATA) ;
-endif
 
 -include $(top_srcdir)/git.mk
diff --git a/geyes/geyes.c b/geyes/geyes.c
index 8197b33..acb4dd1 100644
--- a/geyes/geyes.c
+++ b/geyes/geyes.c
@@ -21,7 +21,6 @@
 #include <math.h>
 #include <stdlib.h>
 #include <panel-applet.h>
-#include <panel-applet-gconf.h>
 #include "geyes.h"
 
 #define UPDATE_TIMEOUT 100
@@ -166,9 +165,7 @@ properties_load (EyesApplet *eyes_applet)
 {
         gchar *theme_path = NULL;
 
-       theme_path = panel_applet_gconf_get_string (
-               eyes_applet->applet, "theme_path", NULL);
-
+       theme_path = g_settings_get_string (eyes_applet->settings, KEY_THEME_PATH);
        if (theme_path == NULL)
                theme_path = g_strdup (GEYES_THEMES_DIR "Default-tiny");
        
@@ -290,6 +287,9 @@ destroy_cb (GtkWidget *object, EyesApplet *eyes_applet)
        if (eyes_applet->prop_box.pbox)
                gtk_widget_destroy (eyes_applet->prop_box.pbox);
 
+       if (eyes_applet->settings)
+               g_object_unref (eyes_applet->settings);
+
        g_free (eyes_applet);
 }
 
@@ -358,7 +358,7 @@ geyes_applet_fill (PanelApplet *applet)
        
         eyes_applet = create_eyes (applet);
 
-       panel_applet_add_preferences (applet, "/schemas/apps/geyes/prefs", NULL);
+       eyes_applet->settings = panel_applet_settings_new (applet, GEYES_PREFS_SCHEMA);
 
         eyes_applet->timeout_id = g_timeout_add (
                UPDATE_TIMEOUT, (GSourceFunc) timer_cb, eyes_applet);
diff --git a/geyes/geyes.h b/geyes/geyes.h
index 8f12d9d..d8266a0 100644
--- a/geyes/geyes.h
+++ b/geyes/geyes.h
@@ -26,6 +26,9 @@
 #include <gtk/gtk.h>
 #include <panel-applet.h>
 
+#define GEYES_PREFS_SCHEMA "org.gnome.gnome-applets.geyes"
+#define KEY_THEME_PATH     "theme-path"
+
 #define MAX_EYES 1000
 typedef struct
 {
@@ -61,6 +64,8 @@ typedef struct
 
        /* Properties */
        EyesPropertyBox prop_box;
+
+       GSettings *settings;
 } EyesApplet;
 
 /* eyes.c */
diff --git a/geyes/org.gnome.gnome-applets.geyes.gschema.xml.in.in 
b/geyes/org.gnome.gnome-applets.geyes.gschema.xml.in.in
new file mode 100644
index 0000000..6c4a5ad
--- /dev/null
+++ b/geyes/org.gnome.gnome-applets.geyes.gschema.xml.in.in
@@ -0,0 +1,8 @@
+<schemalist gettext-domain="@GETTEXT_PACKAGE@">
+       <schema id="org.gnome.gnome-applets.geyes">
+               <key name="theme-path" type="s">
+                       <default>''</default>
+                       <_summary>Directory in which the theme is located</_summary>
+               </key>
+       </schema>
+</schemalist>
diff --git a/geyes/themes.c b/geyes/themes.c
index d1f9965..30fdd54 100644
--- a/geyes/themes.c
+++ b/geyes/themes.c
@@ -23,8 +23,6 @@
 #include <limits.h>
 #include <ctype.h>
 #include <gtk/gtk.h>
-#include <gconf/gconf-client.h>
-#include <panel-applet-gconf.h>
 #include "geyes.h"
 
 #define NUM_THEME_DIRECTORIES 2
@@ -174,25 +172,6 @@ destroy_theme (EyesApplet *eyes_applet)
         g_free (eyes_applet->theme_name);
 }
 
-static gboolean
-key_writable (PanelApplet *applet, const char *key)
-{
-       gboolean writable;
-       char *fullkey;
-       static GConfClient *client = NULL;
-
-       if (client == NULL)
-               client = gconf_client_get_default ();
-
-       fullkey = panel_applet_gconf_get_full_key (applet, key);
-
-       writable = gconf_client_key_is_writable (client, fullkey, NULL);
-
-       g_free (fullkey);
-
-       return writable;
-}
-
 static void
 theme_selected_cb (GtkTreeSelection *selection, gpointer data)
 {
@@ -221,8 +200,7 @@ theme_selected_cb (GtkTreeSelection *selection, gpointer data)
         load_theme (eyes_applet, theme);
         setup_eyes (eyes_applet);
        
-       panel_applet_gconf_set_string (
-               eyes_applet->applet, "theme_path", theme, NULL);
+       g_settings_set_string (eyes_applet->settings, KEY_THEME_PATH, theme);
        
        g_free (theme);
 }
@@ -380,7 +358,7 @@ properties_cb (GtkAction  *action,
                          G_CALLBACK (theme_selected_cb),
                          eyes_applet);
 
-       if ( ! key_writable (eyes_applet->applet, "theme_path")) {
+       if (!g_settings_is_writable (eyes_applet->settings, KEY_THEME_PATH)) {
                gtk_widget_set_sensitive (tree, FALSE);
                gtk_widget_set_sensitive (label, FALSE);
        }
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 97e29a6..faf07ba 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -29,8 +29,8 @@ drivemount/drivemount.c
 drivemount/drivemount.schemas.in
 [type: gettext/ini]drivemount/org.gnome.applets.DriveMountApplet.panel-applet.in.in
 geyes/geyes.c
-geyes/geyes.schemas.in
 [type: gettext/ini]geyes/org.gnome.applets.GeyesApplet.panel-applet.in.in
+geyes/org.gnome.gnome-applets.geyes.gschema.xml.in.in
 geyes/themes.c
 gweather/gweather-about.c
 gweather/gweather-applet.c
diff --git a/po/POTFILES.skip b/po/POTFILES.skip
index 4d4a0e6..0c57bba 100644
--- a/po/POTFILES.skip
+++ b/po/POTFILES.skip
@@ -9,6 +9,7 @@ charpick/org.gnome.applets.CharpickerApplet.panel-applet.in
 cpufreq/org.gnome.applets.CPUFreqApplet.panel-applet.in
 drivemount/drivemount/org.gnome.applets.DriveMountApplet.panel-applet.in
 geyes/org.gnome.applets.GeyesApplet.panel-applet.in
+geyes/org.gnome.gnome-applets.geyes.gschema.xml.in
 gweather/org.gnome.applets.GWeatherApplet.panel-applet.in
 gweather/org.gnome.gnome-applets.gweather.gschema.xml.in
 gweather/Locations.xml.in


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]