]> git.0d.be Git - empathy.git/commitdiff
add account-plugin-widget
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Fri, 13 Jul 2012 10:21:00 +0000 (12:21 +0200)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Tue, 24 Jul 2012 14:20:03 +0000 (16:20 +0200)
https://bugzilla.gnome.org/show_bug.cgi?id=680448

ubuntu-online-accounts/cc-plugins/empathy-accounts-plugin-widget.c [new file with mode: 0644]
ubuntu-online-accounts/cc-plugins/empathy-accounts-plugin-widget.h [new file with mode: 0644]

diff --git a/ubuntu-online-accounts/cc-plugins/empathy-accounts-plugin-widget.c b/ubuntu-online-accounts/cc-plugins/empathy-accounts-plugin-widget.c
new file mode 100644 (file)
index 0000000..c19207a
--- /dev/null
@@ -0,0 +1,145 @@
+/*
+ * empathy-accounts-plugin-widget.c
+ *
+ * Copyright (C) 2012 Collabora Ltd. <http://www.collabora.co.uk/>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+
+#include "config.h"
+
+#include "empathy-accounts-plugin-widget.h"
+
+G_DEFINE_TYPE (EmpathyAccountsPluginWidget, empathy_accounts_plugin_widget, GTK_TYPE_BOX)
+
+enum
+{
+  PROP_ACCOUNT = 1,
+  N_PROPS
+};
+
+/*
+enum
+{
+  LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL];
+*/
+
+struct _EmpathyAccountsPluginWidgetPriv
+{
+  AgAccount *account;
+};
+
+static void
+empathy_accounts_plugin_widget_get_property (GObject *object,
+    guint property_id,
+    GValue *value,
+    GParamSpec *pspec)
+{
+  EmpathyAccountsPluginWidget *self = EMPATHY_ACCOUNTS_PLUGIN_WIDGET (object);
+
+  switch (property_id)
+    {
+      case PROP_ACCOUNT:
+        g_value_set_object (value, self->priv->account);
+        break;
+      default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+        break;
+    }
+}
+
+static void
+empathy_accounts_plugin_widget_set_property (GObject *object,
+    guint property_id,
+    const GValue *value,
+    GParamSpec *pspec)
+{
+  EmpathyAccountsPluginWidget *self = EMPATHY_ACCOUNTS_PLUGIN_WIDGET (object);
+
+  switch (property_id)
+    {
+      case PROP_ACCOUNT:
+        self->priv->account = g_value_dup_object (value);
+        break;
+      default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+        break;
+    }
+}
+
+static void
+empathy_accounts_plugin_widget_constructed (GObject *object)
+{
+  //EmpathyAccountsPluginWidget *self = EMPATHY_ACCOUNTS_PLUGIN_WIDGET (object);
+  void (*chain_up) (GObject *) =
+      ((GObjectClass *) empathy_accounts_plugin_widget_parent_class)->constructed;
+
+  if (chain_up != NULL)
+    chain_up (object);
+}
+
+static void
+empathy_accounts_plugin_widget_dispose (GObject *object)
+{
+  EmpathyAccountsPluginWidget *self = EMPATHY_ACCOUNTS_PLUGIN_WIDGET (object);
+  void (*chain_up) (GObject *) =
+      ((GObjectClass *) empathy_accounts_plugin_widget_parent_class)->dispose;
+
+  g_clear_object (&self->priv->account);
+
+  if (chain_up != NULL)
+    chain_up (object);
+}
+
+static void
+empathy_accounts_plugin_widget_class_init (
+    EmpathyAccountsPluginWidgetClass *klass)
+{
+  GObjectClass *oclass = G_OBJECT_CLASS (klass);
+  GParamSpec *spec;
+
+  oclass->get_property = empathy_accounts_plugin_widget_get_property;
+  oclass->set_property = empathy_accounts_plugin_widget_set_property;
+  oclass->constructed = empathy_accounts_plugin_widget_constructed;
+  oclass->dispose = empathy_accounts_plugin_widget_dispose;
+
+  spec = g_param_spec_object ("account", "account",
+      "AgAccount",
+      AG_TYPE_ACCOUNT,
+      G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
+  g_object_class_install_property (oclass, PROP_ACCOUNT, spec);
+
+  g_type_class_add_private (klass, sizeof (EmpathyAccountsPluginWidgetPriv));
+}
+
+static void
+empathy_accounts_plugin_widget_init (EmpathyAccountsPluginWidget *self)
+{
+  self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
+      EMPATHY_TYPE_ACCOUNTS_PLUGIN_WIDGET, EmpathyAccountsPluginWidgetPriv);
+}
+
+GtkWidget *
+empathy_accounts_plugin_widget_new (AgAccount *account)
+{
+  return g_object_new (EMPATHY_TYPE_ACCOUNTS_PLUGIN_WIDGET,
+      "account", account,
+      "orientation", GTK_ORIENTATION_VERTICAL,
+      NULL);
+}
diff --git a/ubuntu-online-accounts/cc-plugins/empathy-accounts-plugin-widget.h b/ubuntu-online-accounts/cc-plugins/empathy-accounts-plugin-widget.h
new file mode 100644 (file)
index 0000000..17963e6
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * empathy-accounts-plugin-widget.h
+ *
+ * Copyright (C) 2012 Collabora Ltd. <http://www.collabora.co.uk/>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+
+#ifndef __EMPATHY_ACCOUNTS_PLUGIN_WIDGET_H__
+#define __EMPATHY_ACCOUNTS_PLUGIN_WIDGET_H__
+
+#include <gtk/gtk.h>
+
+#include <libaccounts-glib/ag-account.h>
+
+G_BEGIN_DECLS
+
+typedef struct _EmpathyAccountsPluginWidget EmpathyAccountsPluginWidget;
+typedef struct _EmpathyAccountsPluginWidgetClass EmpathyAccountsPluginWidgetClass;
+typedef struct _EmpathyAccountsPluginWidgetPriv EmpathyAccountsPluginWidgetPriv;
+
+struct _EmpathyAccountsPluginWidgetClass
+{
+  /*<private>*/
+  GtkBoxClass parent_class;
+};
+
+struct _EmpathyAccountsPluginWidget
+{
+  /*<private>*/
+  GtkBox parent;
+  EmpathyAccountsPluginWidgetPriv *priv;
+};
+
+GType empathy_accounts_plugin_widget_get_type (void);
+
+/* TYPE MACROS */
+#define EMPATHY_TYPE_ACCOUNTS_PLUGIN_WIDGET \
+  (empathy_accounts_plugin_widget_get_type ())
+#define EMPATHY_ACCOUNTS_PLUGIN_WIDGET(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST((obj), \
+    EMPATHY_TYPE_ACCOUNTS_PLUGIN_WIDGET, \
+    EmpathyAccountsPluginWidget))
+#define EMPATHY_ACCOUNTS_PLUGIN_WIDGET_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_CAST((klass), \
+    EMPATHY_TYPE_ACCOUNTS_PLUGIN_WIDGET, \
+    EmpathyAccountsPluginWidgetClass))
+#define EMPATHY_IS_ACCOUNTS_PLUGIN_WIDGET(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE((obj), \
+    EMPATHY_TYPE_ACCOUNTS_PLUGIN_WIDGET))
+#define EMPATHY_IS_ACCOUNTS_PLUGIN_WIDGET_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_TYPE((klass), \
+    EMPATHY_TYPE_ACCOUNTS_PLUGIN_WIDGET))
+#define EMPATHY_ACCOUNTS_PLUGIN_WIDGET_GET_CLASS(obj) \
+  (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+    EMPATHY_TYPE_ACCOUNTS_PLUGIN_WIDGET, \
+    EmpathyAccountsPluginWidgetClass))
+
+GtkWidget * empathy_accounts_plugin_widget_new (AgAccount *account);
+
+G_END_DECLS
+
+#endif /* #ifndef __EMPATHY_ACCOUNTS_PLUGIN_WIDGET_H__*/