[empathy] add empathy-dialpad-button



commit 086cd424968bc5c4ef97f3b715bd26fd2a46e9ec
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date:   Fri Jul 6 14:39:20 2012 +0200

    add empathy-dialpad-button
    
    https://bugzilla.gnome.org/show_bug.cgi?id=679396

 libempathy-gtk/Makefile.am              |    2 +
 libempathy-gtk/empathy-dialpad-button.c |  202 +++++++++++++++++++++++++++++++
 libempathy-gtk/empathy-dialpad-button.h |   85 +++++++++++++
 3 files changed, 289 insertions(+), 0 deletions(-)
---
diff --git a/libempathy-gtk/Makefile.am b/libempathy-gtk/Makefile.am
index a86358f..f059022 100644
--- a/libempathy-gtk/Makefile.am
+++ b/libempathy-gtk/Makefile.am
@@ -52,6 +52,7 @@ libempathy_gtk_handwritten_source =            	\
 	empathy-contact-search-dialog.c		\
 	empathy-contact-widget.c		\
 	empathy-dialpad-widget.c		\
+	empathy-dialpad-button.c		\
 	empathy-geometry.c			\
 	empathy-groups-widget.c			\
 	empathy-individual-dialogs.c		\
@@ -119,6 +120,7 @@ libempathy_gtk_headers =			\
 	empathy-contact-widget.h		\
 	empathy-contactinfo-utils.h		\
 	empathy-dialpad-widget.h		\
+	empathy-dialpad-button.h		\
 	empathy-geometry.h			\
 	empathy-groups-widget.h			\
 	empathy-images.h			\
diff --git a/libempathy-gtk/empathy-dialpad-button.c b/libempathy-gtk/empathy-dialpad-button.c
new file mode 100644
index 0000000..0378401
--- /dev/null
+++ b/libempathy-gtk/empathy-dialpad-button.c
@@ -0,0 +1,202 @@
+/*
+ * Copyright (C) 2011-2012 Collabora Ltd.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA  02110-1301  USA
+ *
+ * Authors: Danielle Madeley <danielle madeley collabora co uk>
+ *          Guillaume Desmottes <guillaume desmottes collabora co uk>
+ */
+
+
+#include "config.h"
+
+#include "empathy-dialpad-button.h"
+
+G_DEFINE_TYPE (EmpathyDialpadButton, empathy_dialpad_button, GTK_TYPE_BUTTON)
+
+enum
+{
+  PROP_LABEL = 1,
+  PROP_SUB_LABEL,
+  PROP_EVENT,
+  N_PROPS
+};
+
+/*
+enum
+{
+  LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL];
+*/
+
+struct _EmpathyDialpadButtonPriv
+{
+  gchar *label;
+  gchar *sub_label;
+  TpDTMFEvent event;
+};
+
+static void
+empathy_dialpad_button_get_property (GObject *object,
+    guint property_id,
+    GValue *value,
+    GParamSpec *pspec)
+{
+  EmpathyDialpadButton *self = EMPATHY_DIALPAD_BUTTON (object);
+
+  switch (property_id)
+    {
+      case PROP_LABEL:
+        g_value_set_string (value, self->priv->label);
+        break;
+      case PROP_SUB_LABEL:
+        g_value_set_string (value, self->priv->sub_label);
+        break;
+      case PROP_EVENT:
+        g_value_set_uint (value, self->priv->event);
+        break;
+      default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+        break;
+    }
+}
+
+static void
+empathy_dialpad_button_set_property (GObject *object,
+    guint property_id,
+    const GValue *value,
+    GParamSpec *pspec)
+{
+  EmpathyDialpadButton *self = EMPATHY_DIALPAD_BUTTON (object);
+
+  switch (property_id)
+    {
+      case PROP_LABEL:
+        g_assert (self->priv->label == NULL); /* construct-only */
+        self->priv->label = g_value_dup_string (value);
+        break;
+      case PROP_SUB_LABEL:
+        g_assert (self->priv->sub_label == NULL); /* construct-only */
+        self->priv->sub_label = g_value_dup_string (value);
+        break;
+      case PROP_EVENT:
+        self->priv->event = g_value_get_uint (value);
+        break;
+      default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+        break;
+    }
+}
+
+static void
+empathy_dialpad_button_constructed (GObject *object)
+{
+  EmpathyDialpadButton *self = EMPATHY_DIALPAD_BUTTON (object);
+  void (*chain_up) (GObject *) =
+      ((GObjectClass *) empathy_dialpad_button_parent_class)->constructed;
+
+  g_assert (self->priv->label != NULL);
+  g_assert (self->priv->sub_label != NULL);
+
+  if (chain_up != NULL)
+    chain_up (object);
+}
+
+static void
+empathy_dialpad_button_finalize (GObject *object)
+{
+  EmpathyDialpadButton *self = EMPATHY_DIALPAD_BUTTON (object);
+  void (*chain_up) (GObject *) =
+      ((GObjectClass *) empathy_dialpad_button_parent_class)->finalize;
+
+  g_free (self->priv->label);
+  g_free (self->priv->sub_label);
+
+  if (chain_up != NULL)
+    chain_up (object);
+}
+
+static void
+empathy_dialpad_button_class_init (
+    EmpathyDialpadButtonClass *klass)
+{
+  GObjectClass *oclass = G_OBJECT_CLASS (klass);
+  GParamSpec *spec;
+
+  oclass->get_property = empathy_dialpad_button_get_property;
+  oclass->set_property = empathy_dialpad_button_set_property;
+  oclass->constructed = empathy_dialpad_button_constructed;
+  oclass->finalize = empathy_dialpad_button_finalize;
+
+  spec = g_param_spec_string ("label", "label",
+      "Label",
+      NULL,
+      G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
+  g_object_class_install_property (oclass, PROP_LABEL, spec);
+
+  spec = g_param_spec_string ("sub-label", "sub-label",
+      "Sub-label",
+      NULL,
+      G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
+  g_object_class_install_property (oclass, PROP_SUB_LABEL, spec);
+
+  spec = g_param_spec_uint ("event", "event",
+      "TpDTMFEvent",
+      0, TP_NUM_DTMF_EVENTS, 0,
+      G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
+  g_object_class_install_property (oclass, PROP_EVENT, spec);
+
+  g_type_class_add_private (klass, sizeof (EmpathyDialpadButtonPriv));
+}
+
+static void
+empathy_dialpad_button_init (EmpathyDialpadButton *self)
+{
+  self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
+      EMPATHY_TYPE_DIALPAD_BUTTON, EmpathyDialpadButtonPriv);
+}
+
+GtkWidget *
+empathy_dialpad_button_new (const gchar *label,
+    const gchar *sub_label,
+    TpDTMFEvent event)
+{
+  return g_object_new (EMPATHY_TYPE_DIALPAD_BUTTON,
+      "label", label,
+      "sub-label", sub_label,
+      "event", event,
+      NULL);
+}
+
+const gchar *
+empathy_dialpad_button_get_label (EmpathyDialpadButton *self)
+{
+  return self->priv->label;
+}
+
+const gchar *
+empathy_dialpad_button_get_sub_label (EmpathyDialpadButton *self)
+{
+  return self->priv->sub_label;
+}
+
+TpDTMFEvent
+empathy_dialpad_button_get_event (EmpathyDialpadButton *self)
+{
+  return self->priv->event;
+}
diff --git a/libempathy-gtk/empathy-dialpad-button.h b/libempathy-gtk/empathy-dialpad-button.h
new file mode 100644
index 0000000..cca96f3
--- /dev/null
+++ b/libempathy-gtk/empathy-dialpad-button.h
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2011-2012 Collabora Ltd.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA  02110-1301  USA
+ *
+ * Authors: Danielle Madeley <danielle madeley collabora co uk>
+ *          Guillaume Desmottes <guillaume desmottes collabora co uk>
+ */
+
+
+#ifndef __EMPATHY_DIALPAD_BUTTON_H__
+#define __EMPATHY_DIALPAD_BUTTON_H__
+
+#include <gtk/gtk.h>
+
+#include <telepathy-glib/telepathy-glib.h>
+
+G_BEGIN_DECLS
+
+typedef struct _EmpathyDialpadButton EmpathyDialpadButton;
+typedef struct _EmpathyDialpadButtonClass EmpathyDialpadButtonClass;
+typedef struct _EmpathyDialpadButtonPriv EmpathyDialpadButtonPriv;
+
+struct _EmpathyDialpadButtonClass
+{
+  /*<private>*/
+  GtkButtonClass parent_class;
+};
+
+struct _EmpathyDialpadButton
+{
+  /*<private>*/
+  GtkButton parent;
+  EmpathyDialpadButtonPriv *priv;
+};
+
+GType empathy_dialpad_button_get_type (void);
+
+/* TYPE MACROS */
+#define EMPATHY_TYPE_DIALPAD_BUTTON \
+  (empathy_dialpad_button_get_type ())
+#define EMPATHY_DIALPAD_BUTTON(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST((obj), \
+    EMPATHY_TYPE_DIALPAD_BUTTON, \
+    EmpathyDialpadButton))
+#define EMPATHY_DIALPAD_BUTTON_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_CAST((klass), \
+    EMPATHY_TYPE_DIALPAD_BUTTON, \
+    EmpathyDialpadButtonClass))
+#define EMPATHY_IS_DIALPAD_BUTTON(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE((obj), \
+    EMPATHY_TYPE_DIALPAD_BUTTON))
+#define EMPATHY_IS_DIALPAD_BUTTON_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_TYPE((klass), \
+    EMPATHY_TYPE_DIALPAD_BUTTON))
+#define EMPATHY_DIALPAD_BUTTON_GET_CLASS(obj) \
+  (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+    EMPATHY_TYPE_DIALPAD_BUTTON, \
+    EmpathyDialpadButtonClass))
+
+GtkWidget * empathy_dialpad_button_new (
+    const gchar *label,
+    const gchar *sub_label,
+    TpDTMFEvent event);
+
+const gchar * empathy_dialpad_button_get_label (EmpathyDialpadButton *self);
+const gchar * empathy_dialpad_button_get_sub_label (EmpathyDialpadButton *self);
+TpDTMFEvent empathy_dialpad_button_get_event (EmpathyDialpadButton *self);
+
+G_END_DECLS
+
+#endif /* #ifndef __EMPATHY_DIALPAD_BUTTON_H__*/



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