From 8d773c5db915bc75cc450db2216dee54f71b92c2 Mon Sep 17 00:00:00 2001 From: Stefano Karapetsas Date: Thu, 11 Oct 2012 00:02:07 +0200 Subject: migrate libmate-panel-applet to gsettings --- libmate-panel-applet/Makefile.am | 46 +-- .../libmatepanelapplet-3.0-uninstalled.pc.in | 11 - libmate-panel-applet/libmatepanelapplet-3.0.pc.in | 11 - .../libmatepanelapplet-4.0-uninstalled.pc.in | 11 + libmate-panel-applet/libmatepanelapplet-4.0.pc.in | 11 + libmate-panel-applet/mate-panel-applet-gsettings.c | 108 +++++ libmate-panel-applet/mate-panel-applet-gsettings.h | 45 ++ libmate-panel-applet/mate-panel-applet-mateconf.c | 457 --------------------- libmate-panel-applet/mate-panel-applet-mateconf.h | 90 ---- libmate-panel-applet/mate-panel-applet.c | 211 ++-------- libmate-panel-applet/mate-panel-applet.h | 4 +- 11 files changed, 227 insertions(+), 778 deletions(-) delete mode 100644 libmate-panel-applet/libmatepanelapplet-3.0-uninstalled.pc.in delete mode 100644 libmate-panel-applet/libmatepanelapplet-3.0.pc.in create mode 100644 libmate-panel-applet/libmatepanelapplet-4.0-uninstalled.pc.in create mode 100644 libmate-panel-applet/libmatepanelapplet-4.0.pc.in create mode 100644 libmate-panel-applet/mate-panel-applet-gsettings.c create mode 100644 libmate-panel-applet/mate-panel-applet-gsettings.h delete mode 100644 libmate-panel-applet/mate-panel-applet-mateconf.c delete mode 100644 libmate-panel-applet/mate-panel-applet-mateconf.h (limited to 'libmate-panel-applet') diff --git a/libmate-panel-applet/Makefile.am b/libmate-panel-applet/Makefile.am index 3465e1a1..244d5d41 100644 --- a/libmate-panel-applet/Makefile.am +++ b/libmate-panel-applet/Makefile.am @@ -1,4 +1,4 @@ -lib_LTLIBRARIES = libmate-panel-applet-3.la +lib_LTLIBRARIES = libmate-panel-applet-4.la noinst_PROGRAMS = test-dbus-applet AM_CPPFLAGS = \ @@ -9,34 +9,34 @@ AM_CPPFLAGS = \ AM_CFLAGS = $(WARN_CFLAGS) -libmate_panel_appletincludedir = $(includedir)/mate-panel-3.0/libmate-panel-applet +libmate_panel_appletincludedir = $(includedir)/mate-panel-4.0/libmate-panel-applet libmate_panel_appletinclude_HEADERS = \ mate-panel-applet.h \ - mate-panel-applet-mateconf.h \ + mate-panel-applet-gsettings.h \ mate-panel-applet-enums.h -libmate_panel_applet_3_la_SOURCES = \ +libmate_panel_applet_4_la_SOURCES = \ $(BUILT_SOURCES) \ mate-panel-applet.h \ mate-panel-applet.c \ mate-panel-applet-factory.h \ mate-panel-applet-factory.c \ - mate-panel-applet-mateconf.c \ - mate-panel-applet-mateconf.h + mate-panel-applet-gsettings.c \ + mate-panel-applet-gsettings.h -libmate_panel_applet_3_la_LIBADD = \ +libmate_panel_applet_4_la_LIBADD = \ $(LIBMATE_PANEL_APPLET_LIBS) \ $(X_LIBS) -libmate_panel_applet_3_la_LDFLAGS = \ +libmate_panel_applet_4_la_LDFLAGS = \ -version-info $(LIB_MATE_PANEL_APPLET_LT_VERSION) \ -no-undefined test_dbus_applet_LDADD = \ $(LIBMATE_PANEL_APPLET_LIBS) \ - libmate-panel-applet-3.la + libmate-panel-applet-4.la -$(libmate_panel_applet_3_la_OBJECTS) $(test_dbus_applet_OBJECTS): $(BUILT_SOURCES) +$(libmate_panel_applet_4_la_OBJECTS) $(test_dbus_applet_OBJECTS): $(BUILT_SOURCES) mate-panel-applet-marshal.h: mate-panel-applet-marshal.list $(GLIB_GENMARSHAL) $(AM_V_GEN)$(GLIB_GENMARSHAL) $< --header --prefix=mate_panel_applet_marshal > $@ @@ -82,7 +82,7 @@ BUILT_SOURCES = \ mate-panel-applet-marshal.h pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = libmatepanelapplet-3.0.pc +pkgconfig_DATA = libmatepanelapplet-4.0.pc appletdir = $(datadir)/mate-panel/applets applet_in_files = org.mate.panel.TestApplet.mate-panel-applet.in @@ -93,8 +93,8 @@ noinst_DATA = $(applet_in_files:.mate-panel-applet.in=.mate-panel-applet) EXTRA_DIST = \ org.mate.panel.TestApplet.mate-panel-applet.in \ mate-panel-applet-marshal.list \ - libmatepanelapplet-3.0.pc.in \ - libmatepanelapplet-3.0-uninstalled.pc.in + libmatepanelapplet-4.0.pc.in \ + libmatepanelapplet-4.0-uninstalled.pc.in CLEANFILES = $(BUILT_SOURCES) $(noinst_DATA) @@ -110,21 +110,21 @@ if HAVE_INTROSPECTION introspection_sources = \ mate-panel-applet.c \ mate-panel-applet.h \ - mate-panel-applet-mateconf.c \ - mate-panel-applet-mateconf.h + mate-panel-applet-gsettings.c \ + mate-panel-applet-gsettings.h built_introspection_sources = \ mate-panel-applet-enums.c \ mate-panel-applet-enums.h -MatePanelApplet-3.0.gir: libmate-panel-applet-3.la -MatePanelApplet_3_0_gir_INCLUDES = GObject-2.0 Gtk-2.0 MateConf-2.0 -MatePanelApplet_3_0_gir_CFLAGS = $(AM_CPPFLAGS) -MatePanelApplet_3_0_gir_LIBS = libmate-panel-applet-3.la -MatePanelApplet_3_0_gir_FILES = $(addprefix $(srcdir)/,$(introspection_sources)) $(addprefix $(builddir)/,$(built_introspection_sources)) +MatePanelApplet-4.0.gir: libmate-panel-applet-4.la +MatePanelApplet_4_0_gir_INCLUDES = GObject-2.0 Gtk-2.0 Gio-2.0 +MatePanelApplet_4_0_gir_CFLAGS = $(AM_CPPFLAGS) +MatePanelApplet_4_0_gir_LIBS = libmate-panel-applet-4.la +MatePanelApplet_4_0_gir_FILES = $(addprefix $(srcdir)/,$(introspection_sources)) $(addprefix $(builddir)/,$(built_introspection_sources)) # When requiring gobject-introspection 0.9.5, use this: -#MatePanelApplet_3_0_gir_SCANNERFLAGS = --identifier-prefix=Panel --symbol-prefix=panel --pkg-export=libmatepanelapplet-3.0 -MatePanelApplet_3_0_gir_SCANNERFLAGS = --strip-prefix=MatePanel --pkg-export=libmatepanelapplet-3.0 -INTROSPECTION_GIRS += MatePanelApplet-3.0.gir +#MatePanelApplet_4_0_gir_SCANNERFLAGS = --identifier-prefix=Panel --symbol-prefix=panel --pkg-export=libmatepanelapplet-4.0 +MatePanelApplet_4_0_gir_SCANNERFLAGS = --strip-prefix=MatePanel --pkg-export=libmatepanelapplet-4.0 +INTROSPECTION_GIRS += MatePanelApplet-4.0.gir girdir = $(INTROSPECTION_GIRDIR) gir_DATA = $(INTROSPECTION_GIRS) diff --git a/libmate-panel-applet/libmatepanelapplet-3.0-uninstalled.pc.in b/libmate-panel-applet/libmatepanelapplet-3.0-uninstalled.pc.in deleted file mode 100644 index 40f02130..00000000 --- a/libmate-panel-applet/libmatepanelapplet-3.0-uninstalled.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: libmate-panel-applet-3 -Description: libmate-panel-applet-3 -Requires: glib-2.0 mateconf-2.0 gtk+-2.0 -Version: @VERSION@ -Libs: ${pc_top_builddir}/${pcfiledir}/libmate-panel-applet-3.la -Cflags: -I${pc_top_builddir}/${pcfiledir} diff --git a/libmate-panel-applet/libmatepanelapplet-3.0.pc.in b/libmate-panel-applet/libmatepanelapplet-3.0.pc.in deleted file mode 100644 index 97fee38a..00000000 --- a/libmate-panel-applet/libmatepanelapplet-3.0.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: libmate-panel-applet-3 -Description: libmate-panel-applet-3 -Requires: glib-2.0 mateconf-2.0 gtk+-2.0 -Version: @VERSION@ -Libs: -L${libdir} -lmate-panel-applet-3 -Cflags: -I${includedir}/mate-panel-3.0/libmate-panel-applet diff --git a/libmate-panel-applet/libmatepanelapplet-4.0-uninstalled.pc.in b/libmate-panel-applet/libmatepanelapplet-4.0-uninstalled.pc.in new file mode 100644 index 00000000..d693e648 --- /dev/null +++ b/libmate-panel-applet/libmatepanelapplet-4.0-uninstalled.pc.in @@ -0,0 +1,11 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: libmate-panel-applet-4 +Description: libmate-panel-applet-4 +Requires: glib-2.0 gio-2.0 gtk+-2.0 +Version: @VERSION@ +Libs: ${pc_top_builddir}/${pcfiledir}/libmate-panel-applet-4.la +Cflags: -I${pc_top_builddir}/${pcfiledir} diff --git a/libmate-panel-applet/libmatepanelapplet-4.0.pc.in b/libmate-panel-applet/libmatepanelapplet-4.0.pc.in new file mode 100644 index 00000000..5c3058c8 --- /dev/null +++ b/libmate-panel-applet/libmatepanelapplet-4.0.pc.in @@ -0,0 +1,11 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: libmate-panel-applet-4 +Description: libmate-panel-applet-4 +Requires: glib-2.0 gio-2.0 gtk+-2.0 +Version: @VERSION@ +Libs: -L${libdir} -lmate-panel-applet-4 +Cflags: -I${includedir}/mate-panel-4.0/libmate-panel-applet diff --git a/libmate-panel-applet/mate-panel-applet-gsettings.c b/libmate-panel-applet/mate-panel-applet-gsettings.c new file mode 100644 index 00000000..0acda0e8 --- /dev/null +++ b/libmate-panel-applet/mate-panel-applet-gsettings.c @@ -0,0 +1,108 @@ +/* + * mate-panel-applet-gsettings.c: panel applet preferences handling. + * + * Copyright (C) 2012 Stefano Karapetsas + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Authors: + * Stefano Karapetsas + */ + +#include +#include + +#include "mate-panel-applet.h" +#include "mate-panel-applet-gsettings.h" + +GSettings * +mate_panel_applet_settings_new (MatePanelApplet *applet, gchar *schema) +{ + GSettings *settings = NULL; + gchar *path; + + g_return_val_if_fail (PANEL_IS_APPLET (applet), NULL); + + path = mate_panel_applet_get_preferences_path (applet); + + if (path) + settings = g_settings_new_with_path (schema, path); + g_free (path); + + return settings; +} + +GList* +mate_panel_applet_settings_get_glist (GSettings *settings, gchar *key) +{ + gchar **array; + GList *list = NULL; + gint i; + array = g_settings_get_strv (settings, key); + if (array != NULL) { + for (i = 0; array[i]; i++) { + list = g_list_append (list, g_strdup (array[i])); + } + } + g_strfreev (array); + return list; +} + +void +mate_panel_applet_settings_set_glist (GSettings *settings, gchar *key, GList *list) +{ + gchar **array; + GList *l; + gint i; + for (l = list; l; l = l->next) { + array[i] = g_strdup (l->data); + i++; + } + array[i] = NULL; + g_settings_set_strv (settings, key, (const gchar **) array); + g_strfreev (array); +} + +GSList* +mate_panel_applet_settings_get_gslist (GSettings *settings, gchar *key) +{ + gchar **array; + GSList *list = NULL; + gint i; + array = g_settings_get_strv (settings, key); + if (array != NULL) { + for (i = 0; array[i]; i++) { + list = g_slist_append (list, g_strdup (array[i])); + } + } + g_strfreev (array); + return list; +} + +void +mate_panel_applet_settings_set_gslist (GSettings *settings, gchar *key, GSList *list) +{ + gchar **array; + GSList *l; + gint i; + for (l = list; l; l = l->next) { + array[i] = g_strdup (l->data); + i++; + } + array[i] = NULL; + g_settings_set_strv (settings, key, (const gchar **) array); + g_strfreev (array); +} diff --git a/libmate-panel-applet/mate-panel-applet-gsettings.h b/libmate-panel-applet/mate-panel-applet-gsettings.h new file mode 100644 index 00000000..a8426256 --- /dev/null +++ b/libmate-panel-applet/mate-panel-applet-gsettings.h @@ -0,0 +1,45 @@ +/* + * mate-panel-applet-gsettings.h: panel applet preferences handling. + * + * Copyright (C) 2012 Stefano Karapetsas + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Authors: + * Stefano Karapetsas + */ + +#ifndef __MATE_PANEL_APPLET_GSETTINGS_H__ +#define __MATE_PANEL_APPLET_GSETTINGS_H__ + +#include +#include + +#include + +#define PANEL_OBJECT_PREFS_PATH "/org/mate/panel/objects/%s/prefs" + +G_BEGIN_DECLS + +GSettings* mate_panel_applet_settings_new (MatePanelApplet *applet, gchar *schema); +GList* mate_panel_applet_settings_get_glist (GSettings *settings, gchar *key); +void mate_panel_applet_settings_set_glist (GSettings *settings, gchar *key, GList *list); +GSList* mate_panel_applet_settings_get_gslist (GSettings *settings, gchar *key); +void mate_panel_applet_settings_set_gslist (GSettings *settings, gchar *key, GSList *list); + +G_END_DECLS + +#endif /* __MATE_PANEL_APPLET_GSETTINGS_H__ */ diff --git a/libmate-panel-applet/mate-panel-applet-mateconf.c b/libmate-panel-applet/mate-panel-applet-mateconf.c deleted file mode 100644 index 0c7f4763..00000000 --- a/libmate-panel-applet/mate-panel-applet-mateconf.c +++ /dev/null @@ -1,457 +0,0 @@ -/* - * mate-panel-applet-mateconf.c: panel applet preferences handling. - * - * Copyright (C) 2001-2003 Sun Microsystems, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Authors: - * Mark McLoughlin - */ - -#include - -#include "mate-panel-applet-mateconf.h" - -static MateConfClient * -mate_panel_applet_mateconf_get_client (void) -{ - static MateConfClient *client = NULL; - - if (!client) - client = mateconf_client_get_default (); - - return client; -} - -gchar * -mate_panel_applet_mateconf_get_full_key (MatePanelApplet *applet, - const gchar *key) -{ - gchar *prefs_key; - gchar *full_key; - - g_return_val_if_fail (PANEL_IS_APPLET (applet), NULL); - - if (!key) - return NULL; - - prefs_key = mate_panel_applet_get_preferences_key (applet); - - full_key = g_strdup_printf ("%s/%s", prefs_key, key); - - g_free (prefs_key); - - return full_key; -} - -void -mate_panel_applet_mateconf_set_bool (MatePanelApplet *applet, - const gchar *key, - gboolean the_bool, - GError **opt_error) -{ - MateConfClient *client; - gchar *full_key; - GError **error = NULL; - GError *our_error = NULL; - - g_return_if_fail (PANEL_IS_APPLET (applet)); - - if (opt_error) - error = opt_error; - else - error = &our_error; - - full_key = mate_panel_applet_mateconf_get_full_key (applet, key); - - client = mate_panel_applet_mateconf_get_client (); - - mateconf_client_set_bool (client, full_key, the_bool, error); - - g_free (full_key); - - if (!opt_error && our_error) { - g_warning (G_STRLOC ": mateconf error : '%s'", our_error->message); - g_error_free (our_error); - } -} - -void -mate_panel_applet_mateconf_set_int (MatePanelApplet *applet, - const gchar *key, - gint the_int, - GError **opt_error) -{ - MateConfClient *client; - gchar *full_key; - GError **error = NULL; - GError *our_error = NULL; - - g_return_if_fail (PANEL_IS_APPLET (applet)); - - if (opt_error) - error = opt_error; - else - error = &our_error; - - full_key = mate_panel_applet_mateconf_get_full_key (applet, key); - - client = mate_panel_applet_mateconf_get_client (); - - mateconf_client_set_int (client, full_key, the_int, error); - - g_free (full_key); - - if (!opt_error && our_error) { - g_warning (G_STRLOC ": mateconf error : '%s'", our_error->message); - g_error_free (our_error); - } -} - -void -mate_panel_applet_mateconf_set_string (MatePanelApplet *applet, - const gchar *key, - const gchar *the_string, - GError **opt_error) -{ - MateConfClient *client; - gchar *full_key; - GError **error = NULL; - GError *our_error = NULL; - - g_return_if_fail (PANEL_IS_APPLET (applet)); - - if (opt_error) - error = opt_error; - else - error = &our_error; - - full_key = mate_panel_applet_mateconf_get_full_key (applet, key); - - client = mate_panel_applet_mateconf_get_client (); - - mateconf_client_set_string (client, full_key, the_string, error); - - g_free (full_key); - - if (!opt_error && our_error) { - g_warning (G_STRLOC ": mateconf error : '%s'", our_error->message); - g_error_free (our_error); - } -} - -void -mate_panel_applet_mateconf_set_float (MatePanelApplet *applet, - const gchar *key, - gdouble the_float, - GError **opt_error) -{ - MateConfClient *client; - gchar *full_key; - GError **error = NULL; - GError *our_error = NULL; - - g_return_if_fail (PANEL_IS_APPLET (applet)); - - if (opt_error) - error = opt_error; - else - error = &our_error; - - full_key = mate_panel_applet_mateconf_get_full_key (applet, key); - - client = mate_panel_applet_mateconf_get_client (); - - mateconf_client_set_float (client, full_key, the_float, error); - - g_free (full_key); - - if (!opt_error && our_error) { - g_warning (G_STRLOC ": mateconf error : '%s'", our_error->message); - g_error_free (our_error); - } -} - -void -mate_panel_applet_mateconf_set_list (MatePanelApplet *applet, - const gchar *key, - MateConfValueType list_type, - GSList *list, - GError **opt_error) -{ - MateConfClient *client; - gchar *full_key; - GError **error = NULL; - GError *our_error = NULL; - - g_return_if_fail (PANEL_IS_APPLET (applet)); - - if (opt_error) - error = opt_error; - else - error = &our_error; - - full_key = mate_panel_applet_mateconf_get_full_key (applet, key); - - client = mate_panel_applet_mateconf_get_client (); - - mateconf_client_set_list (client, full_key, list_type, list, error); - - g_free (full_key); - - if (!opt_error && our_error) { - g_warning (G_STRLOC ": mateconf error : '%s'", our_error->message); - g_error_free (our_error); - } -} - -void -mate_panel_applet_mateconf_set_value (MatePanelApplet *applet, - const gchar *key, - MateConfValue *value, - GError **opt_error) -{ - MateConfClient *client; - gchar *full_key; - GError **error = NULL; - GError *our_error = NULL; - - g_return_if_fail (PANEL_IS_APPLET (applet)); - - if (opt_error) - error = opt_error; - else - error = &our_error; - - full_key = mate_panel_applet_mateconf_get_full_key (applet, key); - - client = mate_panel_applet_mateconf_get_client (); - - mateconf_client_set (client, full_key, value, error); - - g_free (full_key); - - if (!opt_error && our_error) { - g_warning (G_STRLOC ": mateconf error : '%s'", our_error->message); - g_error_free (our_error); - } -} - -gboolean -mate_panel_applet_mateconf_get_bool (MatePanelApplet *applet, - const gchar *key, - GError **opt_error) -{ - MateConfClient *client; - gchar *full_key; - gboolean retval; - GError **error = NULL; - GError *our_error = NULL; - - g_return_val_if_fail (PANEL_IS_APPLET (applet), FALSE); - - if (opt_error) - error = opt_error; - else - error = &our_error; - - full_key = mate_panel_applet_mateconf_get_full_key (applet, key); - - client = mate_panel_applet_mateconf_get_client (); - - retval = mateconf_client_get_bool (client, full_key, error); - - g_free (full_key); - - if (!opt_error && our_error) { - g_warning (G_STRLOC ": mateconf error : '%s'", our_error->message); - g_error_free (our_error); - } - - return retval; -} - -gint -mate_panel_applet_mateconf_get_int (MatePanelApplet *applet, - const gchar *key, - GError **opt_error) -{ - MateConfClient *client; - gchar *full_key; - gint retval; - GError **error = NULL; - GError *our_error = NULL; - - g_return_val_if_fail (PANEL_IS_APPLET (applet), -1); - - if (opt_error) - error = opt_error; - else - error = &our_error; - - full_key = mate_panel_applet_mateconf_get_full_key (applet, key); - - client = mate_panel_applet_mateconf_get_client (); - - retval = mateconf_client_get_int (client, full_key, error); - - g_free (full_key); - - if (!opt_error && our_error) { - g_warning (G_STRLOC ": mateconf error : '%s'", our_error->message); - g_error_free (our_error); - } - - return retval; -} - -gchar * -mate_panel_applet_mateconf_get_string (MatePanelApplet *applet, - const gchar *key, - GError **opt_error) -{ - MateConfClient *client; - gchar *full_key; - gchar *retval; - GError **error = NULL; - GError *our_error = NULL; - - g_return_val_if_fail (PANEL_IS_APPLET (applet), NULL); - - if (opt_error) - error = opt_error; - else - error = &our_error; - - full_key = mate_panel_applet_mateconf_get_full_key (applet, key); - - client = mate_panel_applet_mateconf_get_client (); - - retval = mateconf_client_get_string (client, full_key, error); - - g_free (full_key); - - if (!opt_error && our_error) { - g_warning (G_STRLOC ": mateconf error : '%s'", our_error->message); - g_error_free (our_error); - } - - return retval; -} - -gdouble -mate_panel_applet_mateconf_get_float (MatePanelApplet *applet, - const gchar *key, - GError **opt_error) -{ - MateConfClient *client; - gchar *full_key; - gdouble retval; - GError **error = NULL; - GError *our_error = NULL; - - g_return_val_if_fail (PANEL_IS_APPLET (applet), 0.0); - - if (opt_error) - error = opt_error; - else - error = &our_error; - - full_key = mate_panel_applet_mateconf_get_full_key (applet, key); - - client = mate_panel_applet_mateconf_get_client (); - - retval = mateconf_client_get_float (client, full_key, error); - - g_free (full_key); - - if (!opt_error && our_error) { - g_warning (G_STRLOC ": mateconf error : '%s'", our_error->message); - g_error_free (our_error); - } - - return retval; -} - -MateConfValue * -mate_panel_applet_mateconf_get_value (MatePanelApplet *applet, - const gchar *key, - GError **opt_error) -{ - MateConfClient *client; - gchar *full_key; - MateConfValue *retval; - GError **error = NULL; - GError *our_error = NULL; - - g_return_val_if_fail (PANEL_IS_APPLET (applet), NULL); - - if (opt_error) - error = opt_error; - else - error = &our_error; - - full_key = mate_panel_applet_mateconf_get_full_key (applet, key); - - client = mate_panel_applet_mateconf_get_client (); - - retval = mateconf_client_get (client, full_key, error); - - g_free (full_key); - - if (!opt_error && our_error) { - g_warning (G_STRLOC ": mateconf error : '%s'", our_error->message); - g_error_free (our_error); - } - - return retval; -} - -GSList * -mate_panel_applet_mateconf_get_list (MatePanelApplet *applet, - const gchar *key, - MateConfValueType list_type, - GError **opt_error) -{ - MateConfClient *client; - gchar *full_key; - GSList *retval; - GError **error = NULL; - GError *our_error = NULL; - - g_return_val_if_fail (PANEL_IS_APPLET (applet), NULL); - - if (opt_error) - error = opt_error; - else - error = &our_error; - - full_key = mate_panel_applet_mateconf_get_full_key (applet, key); - - client = mate_panel_applet_mateconf_get_client (); - - retval = mateconf_client_get_list (client, full_key, list_type, error); - - g_free (full_key); - - if (!opt_error && our_error) { - g_warning (G_STRLOC ": mateconf error : '%s'", our_error->message); - g_error_free (our_error); - } - - return retval; -} diff --git a/libmate-panel-applet/mate-panel-applet-mateconf.h b/libmate-panel-applet/mate-panel-applet-mateconf.h deleted file mode 100644 index 2eb523a4..00000000 --- a/libmate-panel-applet/mate-panel-applet-mateconf.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * mate-panel-applet-mateconf.h: panel applet preferences handling. - * - * Copyright (C) 2001-2003 Sun Microsystems, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Authors: - * Mark McLoughlin - */ - -#ifndef __MATE_PANEL_APPLET_MATECONF_H__ -#define __MATE_PANEL_APPLET_MATECONF_H__ - -#include -#include - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -gchar *mate_panel_applet_mateconf_get_full_key (MatePanelApplet *applet, - const gchar *key); - -void mate_panel_applet_mateconf_set_bool (MatePanelApplet *applet, - const gchar *key, - gboolean the_bool, - GError **opt_error); -void mate_panel_applet_mateconf_set_int (MatePanelApplet *applet, - const gchar *key, - gint the_int, - GError **opt_error); -void mate_panel_applet_mateconf_set_string (MatePanelApplet *applet, - const gchar *key, - const gchar *the_string, - GError **opt_error); -void mate_panel_applet_mateconf_set_float (MatePanelApplet *applet, - const gchar *key, - gdouble the_float, - GError **opt_error); -void mate_panel_applet_mateconf_set_list (MatePanelApplet *applet, - const gchar *key, - MateConfValueType list_type, - GSList *list, - GError **opt_error); -void mate_panel_applet_mateconf_set_value (MatePanelApplet *applet, - const gchar *key, - MateConfValue *value, - GError **opt_error); - -gboolean mate_panel_applet_mateconf_get_bool (MatePanelApplet *applet, - const gchar *key, - GError **opt_error); -gint mate_panel_applet_mateconf_get_int (MatePanelApplet *applet, - const gchar *key, - GError **opt_error); -gchar *mate_panel_applet_mateconf_get_string (MatePanelApplet *applet, - const gchar *key, - GError **opt_error); -gdouble mate_panel_applet_mateconf_get_float (MatePanelApplet *applet, - const gchar *key, - GError **opt_error); -GSList *mate_panel_applet_mateconf_get_list (MatePanelApplet *applet, - const gchar *key, - MateConfValueType list_type, - GError **opt_error); -MateConfValue *mate_panel_applet_mateconf_get_value (MatePanelApplet *applet, - const gchar *key, - GError **opt_error); - -#ifdef __cplusplus -} -#endif - -#endif /* __MATE_PANEL_APPLET_MATECONF_H__ */ diff --git a/libmate-panel-applet/mate-panel-applet.c b/libmate-panel-applet/mate-panel-applet.c index 6993505e..e9e46e57 100644 --- a/libmate-panel-applet/mate-panel-applet.c +++ b/libmate-panel-applet/mate-panel-applet.c @@ -37,8 +37,6 @@ #include #include #include -#include -#include #include #include "mate-panel-applet.h" @@ -51,14 +49,13 @@ struct _MatePanelAppletPrivate { GtkWidget *plug; GtkWidget *applet; - MateConfClient *client; GDBusConnection *connection; char *id; GClosure *closure; char *object_path; guint object_id; - char *prefs_key; + char *prefs_path; GtkUIManager *ui_manager; GtkActionGroup *applet_action_group; @@ -98,7 +95,7 @@ enum { PROP_ID, PROP_CLOSURE, PROP_CONNECTION, - PROP_PREFS_KEY, + PROP_PREFS_PATH, PROP_ORIENT, PROP_SIZE, PROP_BACKGROUND, @@ -152,179 +149,33 @@ G_DEFINE_TYPE (MatePanelApplet, mate_panel_applet, GTK_TYPE_EVENT_BOX) #define MATE_PANEL_APPLET_INTERFACE "org.mate.panel.applet.Applet" #define MATE_PANEL_APPLET_OBJECT_PATH "/org/mate/panel/applet/%s/%d" -static void -mate_panel_applet_associate_schemas_in_dir (MateConfClient *client, - const gchar *prefs_key, - const gchar *schema_dir, - GError **error) -{ - GSList *list, *l; - - list = mateconf_client_all_entries (client, schema_dir, error); - - if (*error != NULL) - return; - - for (l = list; l; l = l->next) { - MateConfEntry *entry = l->data; - const gchar *schema_key; - MateConfEntry *applet_entry; - const gchar *applet_schema_key; - gchar *key; - gchar *tmp; - - schema_key = mateconf_entry_get_key (entry); - tmp = g_path_get_basename (schema_key); - - if (strchr (tmp, '-')) - g_warning ("Applet key '%s' contains a hyphen. Please " - "use underscores in mateconf keys\n", tmp); - - key = g_strdup_printf ("%s/%s", prefs_key, tmp); - g_free (tmp); - - /* Associating a schema is potentially expensive, so let's try - * to avoid this by doing it only when needed. So we check if - * the key is already correctly associated. */ - - applet_entry = mateconf_client_get_entry (client, key, - NULL, TRUE, NULL); - if (applet_entry) - applet_schema_key = mateconf_entry_get_schema_name (applet_entry); - else - applet_schema_key = NULL; - - if (g_strcmp0 (schema_key, applet_schema_key) != 0) { - mateconf_engine_associate_schema (client->engine, - key, schema_key, error); - - if (applet_entry == NULL || - mateconf_entry_get_value (applet_entry) == NULL || - mateconf_entry_get_is_default (applet_entry)) { - /* unset the key: mateconf_client_get_entry() - * brought an invalid entry in the client - * cache, and we want to fix this */ - mateconf_client_unset (client, key, NULL); - } - } - - g_free (key); - - if (applet_entry) - mateconf_entry_unref (applet_entry); - mateconf_entry_unref (entry); - - if (*error) { - g_slist_free (list); - return; - } - } - - g_slist_free (list); - - list = mateconf_client_all_dirs (client, schema_dir, error); - - for (l = list; l; l = l->next) { - gchar *subdir = l->data; - gchar *prefs_subdir; - gchar *schema_subdir; - gchar *tmp; - - tmp = g_path_get_basename (subdir); - - prefs_subdir = g_strdup_printf ("%s/%s", prefs_key, tmp); - schema_subdir = g_strdup_printf ("%s/%s", schema_dir, tmp); - - mate_panel_applet_associate_schemas_in_dir (client, - prefs_subdir, - schema_subdir, - error); - - g_free (prefs_subdir); - g_free (schema_subdir); - g_free (subdir); - g_free (tmp); - - if (*error) { - g_slist_free (list); - return; - } - } - - g_slist_free (list); -} - -void -mate_panel_applet_add_preferences (MatePanelApplet *applet, - const gchar *schema_dir, - GError **opt_error) -{ - GError **error = NULL; - GError *our_error = NULL; - - g_return_if_fail (PANEL_IS_APPLET (applet)); - g_return_if_fail (schema_dir != NULL); - - if (!applet->priv->prefs_key) - return; - - if (opt_error) - error = opt_error; - else - error = &our_error; - - mate_panel_applet_associate_schemas_in_dir (applet->priv->client, - applet->priv->prefs_key, - schema_dir, - error); - - if (!opt_error && our_error) { - g_warning (G_STRLOC ": failed to add preferences from '%s' : '%s'", - schema_dir, our_error->message); - g_error_free (our_error); - } -} - char * -mate_panel_applet_get_preferences_key (MatePanelApplet *applet) +mate_panel_applet_get_preferences_path (MatePanelApplet *applet) { g_return_val_if_fail (PANEL_IS_APPLET (applet), NULL); - if (!applet->priv->prefs_key) + if (!applet->priv->prefs_path) return NULL; - return g_strdup (applet->priv->prefs_key); + return g_strdup (applet->priv->prefs_path); } static void -mate_panel_applet_set_preferences_key (MatePanelApplet *applet, - const char *prefs_key) +mate_panel_applet_set_preferences_path (MatePanelApplet *applet, + const char *prefs_path) { - if (applet->priv->prefs_key == prefs_key) + if (applet->priv->prefs_path == prefs_path) return; - if (g_strcmp0 (applet->priv->prefs_key, prefs_key) == 0) + if (g_strcmp0 (applet->priv->prefs_path, prefs_path) == 0) return; - if (applet->priv->prefs_key) { - mateconf_client_remove_dir (applet->priv->client, - applet->priv->prefs_key, - NULL); + if (prefs_path) { + applet->priv->prefs_path = g_strdup (prefs_path); - g_free (applet->priv->prefs_key); - applet->priv->prefs_key = NULL; } - if (prefs_key) { - applet->priv->prefs_key = g_strdup (prefs_key); - - mateconf_client_add_dir (applet->priv->client, - applet->priv->prefs_key, - MATECONF_CLIENT_PRELOAD_RECURSIVE, - NULL); - } - - g_object_notify (G_OBJECT (applet), "prefs-key"); + g_object_notify (G_OBJECT (applet), "prefs-path"); } MatePanelAppletFlags @@ -878,11 +729,7 @@ mate_panel_applet_finalize (GObject *object) applet->priv->object_path = NULL; } - mate_panel_applet_set_preferences_key (applet, NULL); - - if (applet->priv->client) - g_object_unref (applet->priv->client); - applet->priv->client = NULL; + mate_panel_applet_set_preferences_path (applet, NULL); if (applet->priv->applet_action_group) { g_object_unref (applet->priv->applet_action_group); @@ -900,7 +747,7 @@ mate_panel_applet_finalize (GObject *object) } g_free (applet->priv->size_hints); - g_free (applet->priv->prefs_key); + g_free (applet->priv->prefs_path); g_free (applet->priv->background); g_free (applet->priv->id); @@ -1650,8 +1497,8 @@ mate_panel_applet_get_property (GObject *object, case PROP_CONNECTION: g_value_set_object (value, applet->priv->connection); break; - case PROP_PREFS_KEY: - g_value_set_string (value, applet->priv->prefs_key); + case PROP_PREFS_PATH: + g_value_set_string (value, applet->priv->prefs_path); break; case PROP_ORIENT: g_value_set_uint (value, applet->priv->orient); @@ -1710,8 +1557,8 @@ mate_panel_applet_set_property (GObject *object, case PROP_CONNECTION: applet->priv->connection = g_value_dup_object (value); break; - case PROP_PREFS_KEY: - mate_panel_applet_set_preferences_key (applet, g_value_get_string (value)); + case PROP_PREFS_PATH: + mate_panel_applet_set_preferences_path (applet, g_value_get_string (value)); break; case PROP_ORIENT: mate_panel_applet_set_orient (applet, g_value_get_uint (value)); @@ -1811,8 +1658,6 @@ mate_panel_applet_init (MatePanelApplet *applet) applet->priv->orient = MATE_PANEL_APPLET_ORIENT_UP; applet->priv->size = 24; - applet->priv->client = mateconf_client_get_default (); - applet->priv->panel_action_group = gtk_action_group_new ("PanelActions"); gtk_action_group_set_translation_domain (applet->priv->panel_action_group, GETTEXT_PACKAGE); gtk_action_group_add_actions (applet->priv->panel_action_group, @@ -1909,10 +1754,10 @@ mate_panel_applet_class_init (MatePanelAppletClass *klass) G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE)); g_object_class_install_property (gobject_class, - PROP_PREFS_KEY, - g_param_spec_string ("prefs-key", - "PrefsKey", - "MateConf Preferences Key", + PROP_PREFS_PATH, + g_param_spec_string ("prefs-path", + "PrefsPath", + "GSettings Preferences Path", NULL, G_PARAM_READWRITE)); g_object_class_install_property (gobject_class, @@ -2064,9 +1909,9 @@ get_property_cb (GDBusConnection *connection, MatePanelApplet *applet = MATE_PANEL_APPLET (user_data); GVariant *retval = NULL; - if (g_strcmp0 (property_name, "PrefsKey") == 0) { - retval = g_variant_new_string (applet->priv->prefs_key ? - applet->priv->prefs_key : ""); + if (g_strcmp0 (property_name, "PrefsPath") == 0) { + retval = g_variant_new_string (applet->priv->prefs_path ? + applet->priv->prefs_path : ""); } else if (g_strcmp0 (property_name, "Orient") == 0) { retval = g_variant_new_uint32 (applet->priv->orient); } else if (g_strcmp0 (property_name, "Size") == 0) { @@ -2107,8 +1952,8 @@ set_property_cb (GDBusConnection *connection, { MatePanelApplet *applet = MATE_PANEL_APPLET (user_data); - if (g_strcmp0 (property_name, "PrefsKey") == 0) { - mate_panel_applet_set_preferences_key (applet, g_variant_get_string (value, NULL)); + if (g_strcmp0 (property_name, "PrefsPath") == 0) { + mate_panel_applet_set_preferences_path (applet, g_variant_get_string (value, NULL)); } else if (g_strcmp0 (property_name, "Orient") == 0) { mate_panel_applet_set_orient (applet, g_variant_get_uint32 (value)); } else if (g_strcmp0 (property_name, "Size") == 0) { @@ -2139,7 +1984,7 @@ static const gchar introspection_xml[] = "" "" "" - "" + "" "" "" "" diff --git a/libmate-panel-applet/mate-panel-applet.h b/libmate-panel-applet/mate-panel-applet.h index 8c75e29f..dfc1c079 100644 --- a/libmate-panel-applet/mate-panel-applet.h +++ b/libmate-panel-applet/mate-panel-applet.h @@ -92,9 +92,7 @@ MatePanelAppletBackgroundType mate_panel_applet_get_background(MatePanelApplet* void mate_panel_applet_set_background_widget(MatePanelApplet* applet, GtkWidget* widget); -gchar* mate_panel_applet_get_preferences_key(MatePanelApplet* applet); - -void mate_panel_applet_add_preferences(MatePanelApplet* applet, const gchar* schema_dir, GError** opt_error); +gchar* mate_panel_applet_get_preferences_path(MatePanelApplet* applet); MatePanelAppletFlags mate_panel_applet_get_flags(MatePanelApplet* applet); void mate_panel_applet_set_flags(MatePanelApplet* applet, MatePanelAppletFlags flags); -- cgit v1.2.1