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>
26 #include "empathy-dialpad-button.h"
28 G_DEFINE_TYPE (EmpathyDialpadButton, empathy_dialpad_button, GTK_TYPE_BUTTON)
44 static guint signals[LAST_SIGNAL];
47 struct _EmpathyDialpadButtonPriv
55 empathy_dialpad_button_get_property (GObject *object,
60 EmpathyDialpadButton *self = EMPATHY_DIALPAD_BUTTON (object);
65 g_value_set_string (value, self->priv->label);
68 g_value_set_string (value, self->priv->sub_label);
71 g_value_set_uint (value, self->priv->event);
74 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
80 empathy_dialpad_button_set_property (GObject *object,
85 EmpathyDialpadButton *self = EMPATHY_DIALPAD_BUTTON (object);
90 g_assert (self->priv->label == NULL); /* construct-only */
91 self->priv->label = g_value_dup_string (value);
94 g_assert (self->priv->sub_label == NULL); /* construct-only */
95 self->priv->sub_label = g_value_dup_string (value);
98 self->priv->event = g_value_get_uint (value);
101 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
107 empathy_dialpad_button_constructed (GObject *object)
109 EmpathyDialpadButton *self = EMPATHY_DIALPAD_BUTTON (object);
110 void (*chain_up) (GObject *) =
111 ((GObjectClass *) empathy_dialpad_button_parent_class)->constructed;
116 g_assert (self->priv->label != NULL);
117 g_assert (self->priv->sub_label != NULL);
119 vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
121 gtk_container_add (GTK_CONTAINER (self), vbox);
124 label = gtk_label_new ("");
125 str = g_strdup_printf ("<span size='x-large'>%s</span>",
127 gtk_label_set_markup (GTK_LABEL (label), str);
130 gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 3);
133 label = gtk_label_new ("");
134 str = g_strdup_printf (
135 "<span foreground='#555555'>%s</span>",
136 self->priv->sub_label);
137 gtk_label_set_markup (GTK_LABEL (label), str);
140 gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, TRUE, 0);
142 if (chain_up != NULL)
147 empathy_dialpad_button_finalize (GObject *object)
149 EmpathyDialpadButton *self = EMPATHY_DIALPAD_BUTTON (object);
150 void (*chain_up) (GObject *) =
151 ((GObjectClass *) empathy_dialpad_button_parent_class)->finalize;
153 g_free (self->priv->label);
154 g_free (self->priv->sub_label);
156 if (chain_up != NULL)
161 empathy_dialpad_button_class_init (
162 EmpathyDialpadButtonClass *klass)
164 GObjectClass *oclass = G_OBJECT_CLASS (klass);
167 oclass->get_property = empathy_dialpad_button_get_property;
168 oclass->set_property = empathy_dialpad_button_set_property;
169 oclass->constructed = empathy_dialpad_button_constructed;
170 oclass->finalize = empathy_dialpad_button_finalize;
172 spec = g_param_spec_string ("label", "label",
175 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
176 g_object_class_install_property (oclass, PROP_LABEL, spec);
178 spec = g_param_spec_string ("sub-label", "sub-label",
181 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
182 g_object_class_install_property (oclass, PROP_SUB_LABEL, spec);
184 spec = g_param_spec_uint ("event", "event",
186 0, TP_NUM_DTMF_EVENTS, 0,
187 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
188 g_object_class_install_property (oclass, PROP_EVENT, spec);
190 g_type_class_add_private (klass, sizeof (EmpathyDialpadButtonPriv));
194 empathy_dialpad_button_init (EmpathyDialpadButton *self)
196 self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
197 EMPATHY_TYPE_DIALPAD_BUTTON, EmpathyDialpadButtonPriv);
201 empathy_dialpad_button_new (const gchar *label,
202 const gchar *sub_label,
205 return g_object_new (EMPATHY_TYPE_DIALPAD_BUTTON,
207 "sub-label", sub_label,
213 empathy_dialpad_button_get_label (EmpathyDialpadButton *self)
215 return self->priv->label;
219 empathy_dialpad_button_get_sub_label (EmpathyDialpadButton *self)
221 return self->priv->sub_label;
225 empathy_dialpad_button_get_event (EmpathyDialpadButton *self)
227 return self->priv->event;