~ubuntu-branches/ubuntu/jaunty/ekiga/jaunty

« back to all changes in this revision

Viewing changes to lib/engine/gui/gtk-frontend/presentity-view.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2008-12-07 10:30:45 UTC
  • mfrom: (1.2.3 experimental)
  • Revision ID: james.westby@ubuntu.com-20081207103045-iaurrjo4p7d1nngo
Tags: 3.0.1-1ubuntu1
* Merge to Debian experimental, to get Ekiga 3. (LP: #274085) Remaining
  Ubuntu changes:
  - Launchpad Integration: (Ubuntu specific)
    + debian/control.in: Add liblaunchpad-integration-dev build dependency.
    + Add ubuntu_lpi.patch: Call launchpad_integration_add_items() in main() and
      check for the launchpad-integration pkg-config module.
    + Add autoconf.patch: autoconf changes from above patch.
  - Add ubuntu_desktop-file-onlyshowin.patch: Show ekiga in Mobile, too.
    (Ubuntu specific).
  - debian/control.in: Add missing fdupes build dependency for identical
    GNOME help file symlinking. (Debian #505536)
* Drop 42_change_pixmaps.dpatch: Many of the old icons do not exist any
  more, some have been replaced, and keeping the remaining three would make
  them look very inconsistent.
* Convert our dpatches to quilt patches and rewrite them for new upstream
  version.
* Add migrate_2.0_settings.patch: Properly migrate settings from
  2.0. Taken from upstream SVN, thanks to Damien Sandras!

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
/* Ekiga -- A VoIP and Video-Conferencing application
 
3
 * Copyright (C) 2000-2008 Damien Sandras
 
4
 *
 
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.
 
9
 *
 
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.
 
14
 *
 
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.
 
18
 *
 
19
 *
 
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.
 
26
 */
 
27
 
 
28
 
 
29
/*
 
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)
 
35
 *
 
36
 */
 
37
 
 
38
#include "presentity-view.h"
 
39
 
 
40
class PresentityViewHelper;
 
41
 
 
42
struct _PresentityViewPrivate
 
43
{
 
44
  Ekiga::Presentity* presentity;
 
45
  sigc::connection updated_conn;
 
46
  sigc::connection removed_conn;
 
47
 
 
48
  /* we contain those, so no need to unref them */
 
49
  GtkWidget* presence_image;
 
50
  GtkWidget* name_status;
 
51
  GtkWidget* avatar_image;
 
52
};
 
53
 
 
54
enum {
 
55
  PRESENTITY_VIEW_PROP_PRESENTITY = 1
 
56
};
 
57
 
 
58
static GObjectClass* parent_class = NULL;
 
59
 
 
60
/* declaration of callbacks */
 
61
 
 
62
static void on_presentity_updated (PresentityView* self);
 
63
 
 
64
static void on_presentity_removed (PresentityView* self);
 
65
 
 
66
/* declaration of internal api */
 
67
 
 
68
static void presentity_view_set_presentity (PresentityView* self,
 
69
                                            Ekiga::Presentity* presentity);
 
70
 
 
71
static void presentity_view_unset_presentity (PresentityView* self);
 
72
 
 
73
/* implementation of callbacks */
 
74
 
 
75
static void
 
76
on_presentity_updated (PresentityView* self)
 
77
{
 
78
  gchar *txt = NULL;
 
79
 
 
80
  gtk_image_set_from_stock (GTK_IMAGE (self->priv->presence_image),
 
81
                            self->priv->presentity->get_presence ().c_str (),
 
82
                            GTK_ICON_SIZE_MENU);
 
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 ());
 
87
  else
 
88
    txt = g_markup_printf_escaped ("<span weight=\"bold\">%s</span>",
 
89
                                   self->priv->presentity->get_name ().c_str ());
 
90
 
 
91
  gtk_label_set_markup (GTK_LABEL (self->priv->name_status), txt);
 
92
  g_free (txt);
 
93
  gtk_image_set_from_stock (GTK_IMAGE (self->priv->avatar_image),
 
94
                            self->priv->presentity->get_avatar ().c_str (),
 
95
                            GTK_ICON_SIZE_MENU);
 
96
}
 
97
 
 
98
static void
 
99
on_presentity_removed (PresentityView* self)
 
100
{
 
101
  presentity_view_unset_presentity (self);
 
102
}
 
103
 
 
104
/* implementation of internal api */
 
105
 
 
106
static void
 
107
presentity_view_set_presentity (PresentityView* self,
 
108
                                Ekiga::Presentity* presentity)
 
109
{
 
110
  g_return_if_fail (self->priv->presentity == NULL);
 
111
 
 
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));
 
115
 
 
116
  on_presentity_updated (self);
 
117
}
 
118
 
 
119
static void
 
120
presentity_view_unset_presentity (PresentityView* self)
 
121
{
 
122
  if (self->priv->presentity) {
 
123
 
 
124
    self->priv->presentity = NULL;
 
125
    self->priv->updated_conn.disconnect ();
 
126
    self->priv->removed_conn.disconnect ();
 
127
  }
 
128
}
 
129
 
 
130
/* GObject code */
 
131
 
 
132
static void
 
133
presentity_view_finalize (GObject* obj)
 
134
{
 
135
  PresentityView* self = NULL;
 
136
 
 
137
  self = (PresentityView*)obj;
 
138
 
 
139
  presentity_view_unset_presentity (self);
 
140
 
 
141
  delete self->priv;
 
142
  self->priv = NULL;
 
143
 
 
144
  parent_class->finalize (obj);
 
145
}
 
146
 
 
147
static void
 
148
presentity_view_set_property (GObject* obj,
 
149
                              guint prop_id,
 
150
                              const GValue* value,
 
151
                              GParamSpec* spec)
 
152
{
 
153
  PresentityView* self = NULL;
 
154
  Ekiga::Presentity* presentity = NULL;
 
155
 
 
156
  self = (PresentityView* )obj;
 
157
 
 
158
  switch (prop_id) {
 
159
 
 
160
  case PRESENTITY_VIEW_PROP_PRESENTITY:
 
161
    presentity = (Ekiga::Presentity*)g_value_get_pointer (value);
 
162
    presentity_view_set_presentity (self, presentity);
 
163
 
 
164
    break;
 
165
 
 
166
  default:
 
167
    G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, spec);
 
168
    break;
 
169
  }
 
170
}
 
171
 
 
172
static void
 
173
presentity_view_class_init (gpointer g_class,
 
174
                            G_GNUC_UNUSED gpointer class_data)
 
175
{
 
176
  GObjectClass* gobject_class = NULL;
 
177
  GParamSpec* spec = NULL;
 
178
 
 
179
  parent_class = (GObjectClass*)g_type_class_peek_parent (g_class);
 
180
 
 
181
  gobject_class = (GObjectClass*)g_class;
 
182
  gobject_class->finalize = presentity_view_finalize;
 
183
  gobject_class->set_property = presentity_view_set_property;
 
184
 
 
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,
 
191
                                   spec);
 
192
}
 
193
 
 
194
static void
 
195
presentity_view_init (GTypeInstance* instance,
 
196
                      G_GNUC_UNUSED gpointer g_class)
 
197
{
 
198
  PresentityView* self = NULL;
 
199
 
 
200
  self = (PresentityView*)instance;
 
201
 
 
202
  self->priv = new PresentityViewPrivate;
 
203
  self->priv->presentity = NULL;
 
204
 
 
205
  self->priv->presence_image = gtk_image_new ();
 
206
  gtk_box_pack_start (GTK_BOX (self), self->priv->presence_image,
 
207
                      FALSE, FALSE, 2);
 
208
  gtk_widget_show (self->priv->presence_image);
 
209
 
 
210
  self->priv->name_status = gtk_label_new (NULL);
 
211
  gtk_box_pack_start (GTK_BOX (self), self->priv->name_status,
 
212
                      FALSE, TRUE, 2);
 
213
  gtk_widget_show (self->priv->name_status);
 
214
 
 
215
  self->priv->avatar_image = gtk_image_new ();
 
216
  gtk_box_pack_start (GTK_BOX (self), self->priv->avatar_image,
 
217
                      FALSE, FALSE, 2);
 
218
  gtk_widget_show (self->priv->avatar_image);
 
219
}
 
220
 
 
221
 
 
222
GType
 
223
presentity_view_get_type ()
 
224
{
 
225
  static GType result = 0;
 
226
 
 
227
  if (result == 0) {
 
228
 
 
229
    static const GTypeInfo info = {
 
230
      sizeof (PresentityViewClass),
 
231
      NULL,
 
232
      NULL,
 
233
      presentity_view_class_init,
 
234
      NULL,
 
235
      NULL,
 
236
      sizeof (PresentityView),
 
237
      0,
 
238
      presentity_view_init,
 
239
      NULL
 
240
    };
 
241
 
 
242
    result = g_type_register_static (GTK_TYPE_HBOX,
 
243
                                     "PresentityView",
 
244
                                     &info, (GTypeFlags) 0);
 
245
  }
 
246
 
 
247
  return result;
 
248
}
 
249
 
 
250
/* public api */
 
251
 
 
252
GtkWidget*
 
253
presentity_view_new (Ekiga::Presentity& presentity)
 
254
{
 
255
  return (GtkWidget*)g_object_new (TYPE_PRESENTITY_VIEW,
 
256
                                   "presentity", &presentity,
 
257
                                   NULL);
 
258
}