2
/* Ekiga -- A VoIP and Video-Conferencing application
3
* Copyright (C) 2000-2008 Damien Sandras
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
20
* Ekiga is licensed under the GPL license and as a special exception,
21
* you have permission to link or otherwise combine this program with the
22
* programs OPAL, OpenH323 and PWLIB, and distribute the combination,
23
* without applying the requirements of the GNU GPL to the OPAL, OpenH323
24
* and PWLIB programs, as long as you do follow the requirements of the
25
* GNU GPL for all the rest of the software thus combined.
30
* presentity-view.cpp - description
31
* --------------------------------
32
* begin : written in july 2008 by Julien Puydt
33
* copyright : (C) 2008 by Julien Puydt
34
* description : Implementation of a Chat area (view and control)
38
#include "presentity-view.h"
40
class PresentityViewHelper;
42
struct _PresentityViewPrivate
44
Ekiga::Presentity* presentity;
45
sigc::connection updated_conn;
46
sigc::connection removed_conn;
48
/* we contain those, so no need to unref them */
49
GtkWidget* presence_image;
50
GtkWidget* name_status;
51
GtkWidget* avatar_image;
55
PRESENTITY_VIEW_PROP_PRESENTITY = 1
58
static GObjectClass* parent_class = NULL;
60
/* declaration of callbacks */
62
static void on_presentity_updated (PresentityView* self);
64
static void on_presentity_removed (PresentityView* self);
66
/* declaration of internal api */
68
static void presentity_view_set_presentity (PresentityView* self,
69
Ekiga::Presentity* presentity);
71
static void presentity_view_unset_presentity (PresentityView* self);
73
/* implementation of callbacks */
76
on_presentity_updated (PresentityView* self)
80
gtk_image_set_from_stock (GTK_IMAGE (self->priv->presence_image),
81
self->priv->presentity->get_presence ().c_str (),
83
if (!self->priv->presentity->get_status ().empty ())
84
txt = g_markup_printf_escaped ("<span weight=\"bold\">%s</span>\n<span size=\"small\">%s</span>",
85
self->priv->presentity->get_name ().c_str (),
86
self->priv->presentity->get_status ().c_str ());
88
txt = g_markup_printf_escaped ("<span weight=\"bold\">%s</span>",
89
self->priv->presentity->get_name ().c_str ());
91
gtk_label_set_markup (GTK_LABEL (self->priv->name_status), txt);
93
gtk_image_set_from_stock (GTK_IMAGE (self->priv->avatar_image),
94
self->priv->presentity->get_avatar ().c_str (),
99
on_presentity_removed (PresentityView* self)
101
presentity_view_unset_presentity (self);
104
/* implementation of internal api */
107
presentity_view_set_presentity (PresentityView* self,
108
Ekiga::Presentity* presentity)
110
g_return_if_fail (self->priv->presentity == NULL);
112
self->priv->presentity = presentity;
113
self->priv->updated_conn = self->priv->presentity->updated.connect (sigc::bind (sigc::ptr_fun (on_presentity_updated), self));
114
self->priv->removed_conn = self->priv->presentity->removed.connect (sigc::bind (sigc::ptr_fun (on_presentity_removed), self));
116
on_presentity_updated (self);
120
presentity_view_unset_presentity (PresentityView* self)
122
if (self->priv->presentity) {
124
self->priv->presentity = NULL;
125
self->priv->updated_conn.disconnect ();
126
self->priv->removed_conn.disconnect ();
133
presentity_view_finalize (GObject* obj)
135
PresentityView* self = NULL;
137
self = (PresentityView*)obj;
139
presentity_view_unset_presentity (self);
144
parent_class->finalize (obj);
148
presentity_view_set_property (GObject* obj,
153
PresentityView* self = NULL;
154
Ekiga::Presentity* presentity = NULL;
156
self = (PresentityView* )obj;
160
case PRESENTITY_VIEW_PROP_PRESENTITY:
161
presentity = (Ekiga::Presentity*)g_value_get_pointer (value);
162
presentity_view_set_presentity (self, presentity);
167
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, spec);
173
presentity_view_class_init (gpointer g_class,
174
G_GNUC_UNUSED gpointer class_data)
176
GObjectClass* gobject_class = NULL;
177
GParamSpec* spec = NULL;
179
parent_class = (GObjectClass*)g_type_class_peek_parent (g_class);
181
gobject_class = (GObjectClass*)g_class;
182
gobject_class->finalize = presentity_view_finalize;
183
gobject_class->set_property = presentity_view_set_property;
185
spec = g_param_spec_pointer ("presentity",
186
"displayed presentity",
187
"Displayed presentity",
188
(GParamFlags)(G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
189
g_object_class_install_property (gobject_class,
190
PRESENTITY_VIEW_PROP_PRESENTITY,
195
presentity_view_init (GTypeInstance* instance,
196
G_GNUC_UNUSED gpointer g_class)
198
PresentityView* self = NULL;
200
self = (PresentityView*)instance;
202
self->priv = new PresentityViewPrivate;
203
self->priv->presentity = NULL;
205
self->priv->presence_image = gtk_image_new ();
206
gtk_box_pack_start (GTK_BOX (self), self->priv->presence_image,
208
gtk_widget_show (self->priv->presence_image);
210
self->priv->name_status = gtk_label_new (NULL);
211
gtk_box_pack_start (GTK_BOX (self), self->priv->name_status,
213
gtk_widget_show (self->priv->name_status);
215
self->priv->avatar_image = gtk_image_new ();
216
gtk_box_pack_start (GTK_BOX (self), self->priv->avatar_image,
218
gtk_widget_show (self->priv->avatar_image);
223
presentity_view_get_type ()
225
static GType result = 0;
229
static const GTypeInfo info = {
230
sizeof (PresentityViewClass),
233
presentity_view_class_init,
236
sizeof (PresentityView),
238
presentity_view_init,
242
result = g_type_register_static (GTK_TYPE_HBOX,
244
&info, (GTypeFlags) 0);
253
presentity_view_new (Ekiga::Presentity& presentity)
255
return (GtkWidget*)g_object_new (TYPE_PRESENTITY_VIEW,
256
"presentity", &presentity,