[Xfce4-commits] <xfce4-places-plugin:master> Make the PlacesCfg a GObject.
Andrzej
noreply at xfce.org
Sat Sep 15 21:56:01 CEST 2012
Updating branch refs/heads/master
to 362dd6ee150a0140d7f328c8e361ad06e0b94655 (commit)
from 89bad7fa73fcd9c61a67735c00f0eb3bb9c864af (commit)
commit 362dd6ee150a0140d7f328c8e361ad06e0b94655
Author: Andrzej <ndrwrdck at gmail.com>
Date: Sun Sep 16 01:33:39 2012 +0900
Make the PlacesCfg a GObject.
Needed for binding to xfconf properties.
panel-plugin/cfg.c | 31 ++++++++++++++++++++++++++-----
panel-plugin/cfg.h | 28 +++++++++++++++++++++++-----
panel-plugin/view.c | 2 +-
3 files changed, 50 insertions(+), 11 deletions(-)
diff --git a/panel-plugin/cfg.c b/panel-plugin/cfg.c
index d8e151c..3cd5ed5 100644
--- a/panel-plugin/cfg.c
+++ b/panel-plugin/cfg.c
@@ -34,6 +34,26 @@
#include "cfg.h"
#include "view.h"
+static void places_cfg_finalize (GObject *object);
+
+
+G_DEFINE_TYPE (PlacesCfg, places_cfg, G_TYPE_OBJECT)
+
+static void
+places_cfg_class_init (PlacesCfgClass *klass)
+{
+ GObjectClass *gobject_class;
+
+ gobject_class = G_OBJECT_CLASS (klass);
+ gobject_class->finalize = places_cfg_finalize;
+}
+
+
+
+static void
+places_cfg_init (PlacesCfg *cfg)
+{
+}
/********** Configuration File **********/
@@ -550,10 +570,11 @@ places_cfg_open_dialog(PlacesCfg *cfg)
/********** Initialization & Finalization **********/
-void
-places_cfg_finalize(PlacesCfg *cfg)
+static void
+places_cfg_finalize (GObject *object)
{
- g_assert(cfg != NULL);
+ PlacesCfg *cfg = XFCE_PLACES_CFG (object);
+ DBG("PlacesCfg finalize called");
if(cfg->label != NULL)
g_free(cfg->label);
@@ -565,7 +586,7 @@ places_cfg_finalize(PlacesCfg *cfg)
if(cfg->write_path != NULL)
g_free(cfg->write_path);
- g_free(cfg);
+ G_OBJECT_CLASS (places_cfg_parent_class)->finalize (object);
}
PlacesCfg*
@@ -575,7 +596,7 @@ places_cfg_new(XfcePanelPlugin *plugin, PlacesViewCfgIface *view_iface)
g_assert(view_iface != NULL);
- cfg = g_new0(PlacesCfg, 1);
+ cfg = g_object_new (XFCE_TYPE_PLACES_CFG, NULL);
cfg->plugin = plugin;
cfg->view_iface = view_iface;
diff --git a/panel-plugin/cfg.h b/panel-plugin/cfg.h
index a0e5f9a..15afa51 100644
--- a/panel-plugin/cfg.h
+++ b/panel-plugin/cfg.h
@@ -26,8 +26,22 @@
#include <libxfce4panel/libxfce4panel.h>
#include "view.h"
-typedef struct
+typedef struct _PlacesCfgClass PlacesCfgClass;
+typedef struct _PlacesCfg PlacesCfg;
+
+#define XFCE_TYPE_PLACES_CFG (places_cfg_get_type ())
+#define XFCE_PLACES_CFG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFCE_TYPE_PLACES_CFG, PlacesCfg))
+#define XFCE_PLACES_CFG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFCE_TYPE_PLACES_CFG, PlacesCfgClass))
+#define XFCE_IS_PLACES_CFG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFCE_TYPE_PLACES_CFG))
+#define XFCE_IS_PLACES_CFG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XFCE_TYPE_PLACES_CFG))
+#define XFCE_PLACES_CFG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFCE_TYPE_PLACES_CFG, PlacesCfgClass))
+
+GType places_cfg_get_type (void) G_GNUC_CONST;
+
+struct _PlacesCfg
{
+ GObject __parent__;
+
/* "private" */
XfcePanelPlugin *plugin;
PlacesViewCfgIface *view_iface;
@@ -49,7 +63,12 @@ typedef struct
gchar *label;
gchar *search_cmd;
-} PlacesCfg;
+};
+
+struct _PlacesCfgClass
+{
+ GObjectClass __parent__;
+};
void
places_cfg_open_dialog(PlacesCfg*);
@@ -60,11 +79,10 @@ places_cfg_load(PlacesCfg*);
void
places_cfg_save(PlacesCfg*);
-void
-places_cfg_finalize(PlacesCfg*);
-
PlacesCfg*
places_cfg_new(XfcePanelPlugin*, PlacesViewCfgIface*);
+G_END_DECLS
+
#endif
/* vim: set ai et tabstop=4: */
diff --git a/panel-plugin/view.c b/panel-plugin/view.c
index 5378004..802ea36 100644
--- a/panel-plugin/view.c
+++ b/panel-plugin/view.c
@@ -1054,7 +1054,7 @@ places_view_finalize(PlacesView *view)
view->tooltips = NULL;
#endif
- places_cfg_finalize(view->cfg);
+ g_object_unref(view->cfg);
view->cfg = NULL;
g_free(view->view_cfg_iface);
More information about the Xfce4-commits
mailing list