2 * Copyright (C) 2011-2012 Collabora Ltd.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public
15 * License along with this program; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17 * Boston, MA 02110-1301 USA
19 * Authors: Danielle Madeley <danielle.madeley@collabora.co.uk>
20 * Guillaume Desmottes <guillaume.desmottes@collabora.co.uk>
24 #include "empathy-dialpad-button.h"
26 G_DEFINE_TYPE (EmpathyDialpadButton, empathy_dialpad_button, GTK_TYPE_BUTTON)
42 static guint signals[LAST_SIGNAL];
45 struct _EmpathyDialpadButtonPriv
53 empathy_dialpad_button_get_property (GObject *object,
58 EmpathyDialpadButton *self = EMPATHY_DIALPAD_BUTTON (object);
63 g_value_set_string (value, self->priv->label);
66 g_value_set_string (value, self->priv->sub_label);
69 g_value_set_uint (value, self->priv->event);
72 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
78 empathy_dialpad_button_set_property (GObject *object,
83 EmpathyDialpadButton *self = EMPATHY_DIALPAD_BUTTON (object);
88 g_assert (self->priv->label == NULL); /* construct-only */
89 self->priv->label = g_value_dup_string (value);
92 g_assert (self->priv->sub_label == NULL); /* construct-only */
93 self->priv->sub_label = g_value_dup_string (value);
96 self->priv->event = g_value_get_uint (value);
99 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
105 empathy_dialpad_button_constructed (GObject *object)
107 EmpathyDialpadButton *self = EMPATHY_DIALPAD_BUTTON (object);
108 void (*chain_up) (GObject *) =
109 ((GObjectClass *) empathy_dialpad_button_parent_class)->constructed;
114 g_assert (self->priv->label != NULL);
115 g_assert (self->priv->sub_label != NULL);
117 vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
119 gtk_container_add (GTK_CONTAINER (self), vbox);
122 label = gtk_label_new ("");
123 str = g_strdup_printf ("<span size='x-large'>%s</span>",
125 gtk_label_set_markup (GTK_LABEL (label), str);
128 gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 3);
131 label = gtk_label_new ("");
132 str = g_strdup_printf (
133 "<span foreground='#555555'>%s</span>",
134 self->priv->sub_label);
135 gtk_label_set_markup (GTK_LABEL (label), str);
138 gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, TRUE, 0);
140 if (chain_up != NULL)
145 empathy_dialpad_button_finalize (GObject *object)
147 EmpathyDialpadButton *self = EMPATHY_DIALPAD_BUTTON (object);
148 void (*chain_up) (GObject *) =
149 ((GObjectClass *) empathy_dialpad_button_parent_class)->finalize;
151 g_free (self->priv->label);
152 g_free (self->priv->sub_label);
154 if (chain_up != NULL)
159 empathy_dialpad_button_class_init (
160 EmpathyDialpadButtonClass *klass)
162 GObjectClass *oclass = G_OBJECT_CLASS (klass);
165 oclass->get_property = empathy_dialpad_button_get_property;
166 oclass->set_property = empathy_dialpad_button_set_property;
167 oclass->constructed = empathy_dialpad_button_constructed;
168 oclass->finalize = empathy_dialpad_button_finalize;
170 spec = g_param_spec_string ("label", "label",
173 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
174 g_object_class_install_property (oclass, PROP_LABEL, spec);
176 spec = g_param_spec_string ("sub-label", "sub-label",
179 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
180 g_object_class_install_property (oclass, PROP_SUB_LABEL, spec);
182 spec = g_param_spec_uint ("event", "event",
184 0, TP_NUM_DTMF_EVENTS, 0,
185 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
186 g_object_class_install_property (oclass, PROP_EVENT, spec);
188 g_type_class_add_private (klass, sizeof (EmpathyDialpadButtonPriv));
192 empathy_dialpad_button_init (EmpathyDialpadButton *self)
194 self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
195 EMPATHY_TYPE_DIALPAD_BUTTON, EmpathyDialpadButtonPriv);
199 empathy_dialpad_button_new (const gchar *label,
200 const gchar *sub_label,
203 return g_object_new (EMPATHY_TYPE_DIALPAD_BUTTON,
205 "sub-label", sub_label,
211 empathy_dialpad_button_get_label (EmpathyDialpadButton *self)
213 return self->priv->label;
217 empathy_dialpad_button_get_sub_label (EmpathyDialpadButton *self)
219 return self->priv->sub_label;
223 empathy_dialpad_button_get_event (EmpathyDialpadButton *self)
225 return self->priv->event;