aboutsummaryrefslogtreecommitdiff
path: root/libindicator/indicator-object.c
diff options
context:
space:
mode:
authorTed Gould <ted@canonical.com>2009-10-08 18:36:06 -0400
committerTed Gould <ted@canonical.com>2009-10-08 18:36:06 -0400
commitf4b307cda5b10c41dd733d6189fd5a1ce7fe3111 (patch)
treedbf2f604a5f179b8a3405e111ebfa81ddbffe71c /libindicator/indicator-object.c
parentbce9f5143bfbe49972aebe3fa3e0a4566e2502b7 (diff)
downloadlibayatana-indicator-f4b307cda5b10c41dd733d6189fd5a1ce7fe3111.tar.gz
libayatana-indicator-f4b307cda5b10c41dd733d6189fd5a1ce7fe3111.tar.bz2
libayatana-indicator-f4b307cda5b10c41dd733d6189fd5a1ce7fe3111.zip
Fleshing out the load from file function. Still fails.
Diffstat (limited to 'libindicator/indicator-object.c')
-rw-r--r--libindicator/indicator-object.c68
1 files changed, 66 insertions, 2 deletions
diff --git a/libindicator/indicator-object.c b/libindicator/indicator-object.c
index 00ede90..afeaf19 100644
--- a/libindicator/indicator-object.c
+++ b/libindicator/indicator-object.c
@@ -1,12 +1,16 @@
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
+#include "indicator.h"
#include "indicator-object.h"
typedef struct _IndicatorObjectPrivate IndicatorObjectPrivate;
struct _IndicatorObjectPrivate {
- guint data;
+ GtkLabel * label;
+ GtkImage * icon;
+ GtkMenu * menu;
};
#define INDICATOR_OBJECT_GET_PRIVATE(o) \
@@ -35,6 +39,11 @@ indicator_object_class_init (IndicatorObjectClass *klass)
static void
indicator_object_init (IndicatorObject *self)
{
+ IndicatorObjectPrivate * priv = INDICATOR_OBJECT_GET_PRIVATE(self);
+
+ priv->label = NULL;
+ priv->icon = NULL;
+ priv->menu = NULL;
return;
}
@@ -42,6 +51,22 @@ indicator_object_init (IndicatorObject *self)
static void
indicator_object_dispose (GObject *object)
{
+ IndicatorObjectPrivate * priv = INDICATOR_OBJECT_GET_PRIVATE(object);
+
+ if (priv->label != NULL) {
+ g_object_unref(priv->label);
+ priv->label = NULL;
+ }
+
+ if (priv->icon != NULL) {
+ g_object_unref(priv->icon);
+ priv->icon = NULL;
+ }
+
+ if (priv->menu != NULL) {
+ g_object_unref(priv->menu);
+ priv->menu = NULL;
+ }
G_OBJECT_CLASS (indicator_object_parent_class)->dispose (object);
return;
@@ -58,5 +83,44 @@ indicator_object_finalize (GObject *object)
IndicatorObject *
indicator_object_new_from_file (const gchar * file)
{
- return NULL;
+ g_return_val_if_fail(file != NULL, NULL);
+
+ GModule * module = g_module_open(file,
+ G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL);
+ g_return_val_if_fail(module != NULL, NULL);
+
+ get_version_t lget_version = NULL;
+ g_return_val_if_fail(g_module_symbol(module, INDICATOR_GET_VERSION_S, (gpointer *)(&lget_version)), FALSE);
+ if (!INDICATOR_VERSION_CHECK(lget_version())) {
+ g_warning("Indicator using API version '%s' we're expecting '%s'", lget_version(), INDICATOR_VERSION);
+ return NULL;
+ }
+
+ GObject * object = g_object_new(INDICATOR_OBJECT_TYPE, NULL);
+ IndicatorObjectPrivate * priv = INDICATOR_OBJECT_GET_PRIVATE(object);
+
+ get_label_t lget_label = NULL;
+ g_return_val_if_fail(g_module_symbol(module, INDICATOR_GET_LABEL_S, (gpointer *)(&lget_label)), FALSE);
+ g_return_val_if_fail(lget_label != NULL, FALSE);
+ priv->label = lget_label();
+
+ get_icon_t lget_icon = NULL;
+ g_return_val_if_fail(g_module_symbol(module, INDICATOR_GET_ICON_S, (gpointer *)(&lget_icon)), FALSE);
+ g_return_val_if_fail(lget_icon != NULL, FALSE);
+ priv->icon = lget_icon();
+
+ get_menu_t lget_menu = NULL;
+ g_return_val_if_fail(g_module_symbol(module, INDICATOR_GET_MENU_S, (gpointer *)(&lget_menu)), FALSE);
+ g_return_val_if_fail(lget_menu != NULL, FALSE);
+ priv->menu = lget_menu();
+
+ if (priv->label == NULL && priv->icon == NULL) {
+ /* This is the case where there is nothing to display,
+ kinda odd that we'd have a module with nothing. */
+ g_warning("No label or icon. Odd.");
+ g_object_unref(object);
+ return NULL;
+ }
+
+ return INDICATOR_OBJECT(object);
}