~ubuntu-branches/ubuntu/vivid/ekiga/vivid-proposed

« back to all changes in this revision

Viewing changes to src/gui/main.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Kilian Krause
  • Date: 2011-07-17 00:24:50 UTC
  • mfrom: (5.1.5 upstream) (7.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20110717002450-ytg3wsrc1ptd3153
Tags: 3.3.1-1
* New upstream release.
 - Required libpt-dev 2.10 and libopal-dev 3.10
* Fix debian/watch to catch new version
* Remove libnotify0.7.patch - included upstream
* Add libboost-dev and libboost-signals-dev to Build-Depends
* debian/rules: Don't install *.la files for new internal shared libs
* Fix Vcs URIs to point to correct desktop/experimental/ekiga tree

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-2006 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
 
 *                         main_window.cpp  -  description
31
 
 *                         -------------------------------
32
 
 *   begin                : Mon Mar 26 2001
33
 
 *   copyright            : (C) 2000-2006 by Damien Sandras
34
 
 *   description          : This file contains all the functions needed to
35
 
 *                          build the main window.
36
 
 */
37
 
 
38
 
#include "revision.h"
39
 
 
40
 
#include "config.h"
41
 
 
42
 
#include "main.h"
43
 
 
44
 
#include "ekiga.h"
45
 
#include "conf.h"
46
 
#include "misc.h"
47
 
#include "callbacks.h"
48
 
#include "statusicon.h"
49
 
#include "dialpad.h"
50
 
#include "statusmenu.h"
51
 
 
52
 
#include "gmdialog.h"
53
 
#include "gmentrydialog.h"
54
 
#include "gmstatusbar.h"
55
 
#include "gmconnectbutton.h"
56
 
#include "gmstockicons.h"
57
 
#include "gmconf.h"
58
 
#include "gmwindow.h"
59
 
#include "gmmenuaddon.h"
60
 
#include "gmlevelmeter.h"
61
 
#include "gmpowermeter.h"
62
 
#include "gmconfwidgets.h"
63
 
#include "trigger.h"
64
 
#include "menu-builder-gtk.h"
65
 
 
66
 
#include "platform/gm-platform.h"
67
 
 
68
 
#include <gdk/gdkkeysyms.h>
69
 
 
70
 
#ifdef HAVE_DBUS
71
 
#include "components/dbus.h"
72
 
#endif
73
 
 
74
 
#ifndef WIN32
75
 
#include <signal.h>
76
 
#include <gdk/gdkx.h>
77
 
#else
78
 
#include "platform/winpaths.h"
79
 
#include <gdk/gdkwin32.h>
80
 
#endif
81
 
 
82
 
#ifdef HAVE_GNOME
83
 
#undef _
84
 
#undef N_
85
 
#include <gnome.h>
86
 
#endif
87
 
 
88
 
#ifdef HAVE_NOTIFY
89
 
#include <libnotify/notify.h>
90
 
#endif
91
 
 
92
 
#if defined(P_FREEBSD) || defined (P_MACOSX)
93
 
#include <libintl.h>
94
 
#endif
95
 
 
96
 
#include <libxml/parser.h>
97
 
 
98
 
#include "videoinput-core.h"
99
 
#include "audioinput-core.h"
100
 
#include "audiooutput-core.h"
101
 
 
102
 
#include "call-core.h"
103
 
#include "account.h"
104
 
#include "gtk-frontend.h"
105
 
#include "services.h"
106
 
#include "form-dialog-gtk.h"
107
 
 
108
 
#include "../devices/videooutput.h"
109
 
 
110
 
enum CallingState {Standby, Calling, Connected, Called};
111
 
 
112
 
enum DeviceType { AudioInput, AudioOutput, VideoInput} ;
113
 
struct deviceStruct {
114
 
  char name[256];
115
 
  DeviceType deviceType;
116
 
};
117
 
 
118
 
/* Declarations */
119
 
struct _GmMainWindow
120
 
{
121
 
  _GmMainWindow (Ekiga::ServiceCore & _core) : core (_core) { }
122
 
 
123
 
  GtkWidget *input_signal;
124
 
  GtkWidget *output_signal;
125
 
  GtkObject *adj_input_volume;
126
 
  GtkObject *adj_output_volume;
127
 
  GtkWidget *audio_input_volume_frame;
128
 
  GtkWidget *audio_output_volume_frame;
129
 
  GtkWidget *audio_settings_window;
130
 
  GtkWidget *audio_settings_button;
131
 
 
132
 
  GtkObject *adj_whiteness;
133
 
  GtkObject *adj_brightness;
134
 
  GtkObject *adj_colour;
135
 
  GtkObject *adj_contrast;
136
 
  GtkWidget *video_settings_button;
137
 
  GtkWidget *video_settings_frame;
138
 
  GtkWidget *video_settings_window;
139
 
 
140
 
  GtkListStore *completion;
141
 
 
142
 
  GtkAccelGroup *accel;
143
 
 
144
 
  GtkWidget *main_menu;
145
 
  GtkWidget *main_toolbar;
146
 
 
147
 
  GtkWidget *window_vbox;
148
 
 
149
 
  GtkWidget *status_label_ebox;
150
 
  GtkWidget *info_text;
151
 
  GtkWidget *info_label;
152
 
 
153
 
  GtkWidget *statusbar;
154
 
  GtkWidget *statusbar_ebox;
155
 
  GtkWidget *qualitymeter;
156
 
  GtkWidget *entry;
157
 
  GtkWidget *main_notebook;
158
 
  GtkWidget *hpaned;
159
 
  GtkWidget *roster;
160
 
  GtkWidget *main_video_image;
161
 
  GtkWidget *local_video_image;
162
 
  GtkWidget *remote_video_image;
163
 
  GtkWidget *video_frame;
164
 
  GtkWidget *preview_button;
165
 
  GtkWidget *connect_button;
166
 
  GtkWidget *hold_button;
167
 
  GtkWidget *transfer_call_popup;
168
 
  GtkWidget *status_option_menu;
169
 
  Ekiga::Presentity* presentity;
170
 
 
171
 
#ifndef WIN32
172
 
  GdkGC* video_widget_gc;
173
 
#endif
174
 
 
175
 
  unsigned int calling_state;
176
 
  bool audio_transmission_active;
177
 
  bool audio_reception_active;
178
 
  bool video_transmission_active;
179
 
  bool video_reception_active;
180
 
  std::string transmitted_video_codec;
181
 
  std::string transmitted_audio_codec;
182
 
  std::string received_video_codec;
183
 
  std::string received_audio_codec;
184
 
  unsigned int timeout_id;
185
 
  unsigned int levelmeter_timeout_id;
186
 
  Ekiga::Call *current_call;
187
 
  Ekiga::ServiceCore & core;
188
 
  std::vector<sigc::connection> connections;
189
 
  std::list<std::string> accounts;
190
 
};
191
 
 
192
 
typedef struct _GmMainWindow GmMainWindow;
193
 
 
194
 
 
195
 
#define GM_MAIN_WINDOW(x) (GmMainWindow *) (x)
196
 
 
197
 
/* channel types */
198
 
enum {
199
 
  CHANNEL_FIRST,
200
 
  CHANNEL_AUDIO,
201
 
  CHANNEL_VIDEO,
202
 
  CHANNEL_LAST
203
 
};
204
 
 
205
 
 
206
 
/* GUI Functions */
207
 
 
208
 
 
209
 
/* DESCRIPTION  : / 
210
 
 * BEHAVIOR     : Frees a GmMainWindow and its content.
211
 
 * PRE          : A non-NULL pointer to a GmMainWindow.
212
 
 */
213
 
static void gm_mw_destroy (gpointer);
214
 
 
215
 
 
216
 
/* DESCRIPTION  : / 
217
 
 * BEHAVIOR     : Returns a pointer to the private GmMainWindow
218
 
 *                used by the main book GMObject.
219
 
 * PRE          : The given GtkWidget pointer must be the main window GMObject. 
220
 
 */
221
 
static GmMainWindow *gm_mw_get_mw (GtkWidget *);
222
 
 
223
 
 
224
 
/* DESCRIPTION  :  /
225
 
 * BEHAVIOR     :  Create the URI toolbar of the main window.
226
 
 *                 The toolbar is created in its initial state, with
227
 
 *                 required items being unsensitive.
228
 
 * PRE          :  The main window GMObject.
229
 
 */
230
 
static GtkWidget *gm_mw_init_uri_toolbar (GtkWidget *);
231
 
 
232
 
 
233
 
/* DESCRIPTION  :  /
234
 
 * BEHAVIOR     :  Create the status menu toolbar of the main window.
235
 
 * PRE          :  The main window GMObject.
236
 
 */
237
 
static GtkWidget *gm_mw_init_status_toolbar (GtkWidget *);
238
 
 
239
 
 
240
 
/* DESCRIPTION  :  /
241
 
 * BEHAVIOR     :  Create the menu of the main window.
242
 
 *                 The menu is created in its initial state, with
243
 
 *                 required items being unsensitive.
244
 
 * PRE          :  The main window GMObject. The statusbar must have been
245
 
 *                 created.
246
 
 */
247
 
static void gm_mw_init_menu (GtkWidget *);
248
 
 
249
 
 
250
 
/* description  : /
251
 
 * behavior     : Builds the contacts list part of the main window.
252
 
 * pre          : The given GtkWidget pointer must be the main window GMObject. 
253
 
 */
254
 
static void gm_mw_init_contacts_list (GtkWidget *);
255
 
 
256
 
 
257
 
/* description  : /
258
 
 * behavior     : builds the dialpad part of the main window.
259
 
 * pre          : the given GtkWidget pointer must be the main window GMObject. 
260
 
 */
261
 
static void gm_mw_init_dialpad (GtkWidget *);
262
 
 
263
 
/* DESCRIPTION  : /
264
 
 * BEHAVIOR     : Builds the video settings popup of the main window.
265
 
 * PRE          : The given GtkWidget pointer must be the main window GMObject. 
266
 
 */
267
 
static GtkWidget *gm_mw_video_settings_window_new (GtkWidget *);
268
 
 
269
 
 
270
 
/* DESCRIPTION  : /
271
 
 * BEHAVIOR     : Builds the audio settings popup for the main window.
272
 
 * PRE          : The given GtkWidget pointer must be the main window GMObject. 
273
 
 */
274
 
static GtkWidget *gm_mw_audio_settings_window_new (GtkWidget *);
275
 
 
276
 
 
277
 
/* DESCRIPTION  : /
278
 
 * BEHAVIOR     : Builds the call part of the main window.
279
 
 * PRE          : The given GtkWidget pointer must be the main window GMObject. 
280
 
 */
281
 
static void gm_mw_init_call (GtkWidget *);
282
 
 
283
 
 
284
 
/* DESCRIPTION  : /
285
 
 * BEHAVIOR     : Builds the call history part of the main window.
286
 
 * PRE          : The given GtkWidget pointer must be the main window GMObject. 
287
 
 */
288
 
static void gm_mw_init_history (GtkWidget *);
289
 
 
290
 
 
291
 
/* DESCRIPTION  :  /
292
 
 * BEHAVIOR     :  enables/disables the zoom related menuitems according
293
 
 *                 to zoom factor
294
 
 * PRE          :  The main window GMObject.
295
 
 */
296
 
static void gm_mw_zooms_menu_update_sensitivity (GtkWidget *,
297
 
                                                 unsigned int);
298
 
static void gm_main_window_toggle_fullscreen (Ekiga::VideoOutputFSToggle toggle,
299
 
                                              GtkWidget   *main_window);
300
 
 
301
 
static void gm_main_window_show_call_panel (GtkWidget *self);
302
 
 
303
 
static void gm_main_window_hide_call_panel (GtkWidget *self);
304
 
 
305
 
void gm_main_window_clear_signal_levels (GtkWidget *main_window);
306
 
 
307
 
void gm_main_window_selected_presentity_build_menu (GtkWidget *main_window);
308
 
 
309
 
void gm_main_window_incoming_call_dialog_show (GtkWidget *main_window,
310
 
                                               Ekiga::Call & call);
311
 
 
312
 
#ifdef HAVE_NOTIFY
313
 
void gm_main_window_incoming_call_notify (GtkWidget *main_window, 
314
 
                                          Ekiga::Call & call);
315
 
#endif
316
 
 
317
 
 
318
 
/* Callbacks */
319
 
/* DESCRIPTION  :  This callback is called when the user selects a presentity
320
 
 *                 in the roster
321
 
 * BEHAVIOR     :  Populates the Chat->Contact submenu
322
 
 * PRE          :  /
323
 
 */
324
 
static void on_presentity_selected (GtkWidget* view,
325
 
                                    Ekiga::Presentity* presentity,
326
 
                                    gpointer data);
327
 
 
328
 
/* DESCRIPTION  :  This callback is called when the chat window alerts about
329
 
 *                 unread messages
330
 
 * BEHAVIOR     :  Plays a sound (if enabled)
331
 
 * PRE          :  /
332
 
 */
333
 
static void on_chat_unread_alert (GtkWidget*,
334
 
                                  gpointer);
335
 
 
336
 
/* DESCRIPTION  :  This callback is called when the control panel 
337
 
 *                 section key changes.
338
 
 * BEHAVIOR     :  Sets the right page, and also sets 
339
 
 *                 the good value for the radio menu. 
340
 
 * PRE          :  /
341
 
 */
342
 
static void panel_section_changed_nt (gpointer id,
343
 
                                      GmConfEntry *entry,
344
 
                                      gpointer data);
345
 
 
346
 
 
347
 
/* DESCRIPTION  :  This callback is called when the call panel 
348
 
 *                 section key changes.
349
 
 * BEHAVIOR     :  Show it or hide it, resize the window appropriately.
350
 
 * PRE          :  /
351
 
 */
352
 
static void show_call_panel_changed_nt (G_GNUC_UNUSED gpointer id, 
353
 
                                        GmConfEntry *entry, 
354
 
                                        gpointer data);
355
 
 
356
 
 
357
 
/** Pull a trigger from a Ekiga::Service
358
 
 *
359
 
 * @param data is a pointer to the Ekiga::Trigger
360
 
 */
361
 
static void pull_trigger_cb (GtkWidget * /*widget*/,
362
 
                             gpointer data);
363
 
 
364
 
 
365
 
/** Show the widget passed as parameter
366
 
 *
367
 
 * @param data is a pointer to the widget to show
368
 
 */
369
 
static void  show_widget_cb (GtkWidget * /*widget*/,
370
 
                             gpointer data);
371
 
 
372
 
 
373
 
/* DESCRIPTION  :  /
374
 
 * BEHAVIOR     :  Set the current active call on hold.
375
 
 * PRE          :  /
376
 
 */
377
 
static void hold_current_call_cb (GtkWidget *,
378
 
                                  gpointer);
379
 
 
380
 
 
381
 
/* DESCRIPTION  :  /
382
 
 * BEHAVIOR     :  Set the current active call audio channel on pause or not
383
 
 * PRE          :  a pointer to the main window 
384
 
 */
385
 
static void toggle_audio_stream_pause_cb (GtkWidget *, 
386
 
                                          gpointer);
387
 
 
388
 
 
389
 
/* DESCRIPTION  :  /
390
 
 * BEHAVIOR     :  Set the current active call video channel on pause or not
391
 
 * PRE          :  a pointer to the main window 
392
 
 */
393
 
static void toggle_video_stream_pause_cb (GtkWidget *, 
394
 
                                          gpointer);
395
 
 
396
 
 
397
 
/* DESCRIPTION  :  /
398
 
 * BEHAVIOR     :  Creates a dialog to transfer the current call and transfer
399
 
 *                 it if required.
400
 
 * PRE          :  The parent window.
401
 
 */
402
 
static void transfer_current_call_cb (GtkWidget *,
403
 
                                      gpointer);
404
 
 
405
 
 
406
 
/* DESCRIPTION  :  This callback is called when a video window is shown.
407
 
 * BEHAVIOR     :  Set the WM HINTS to stay-on-top if the config key is set
408
 
 *                 to true.
409
 
 * PRE          :  /
410
 
 */
411
 
static void video_window_shown_cb (GtkWidget *,
412
 
                                   gpointer);
413
 
 
414
 
/* DESCRIPTION  :  This callback is called when the user changes the
415
 
 *                 audio settings sliders in the main notebook.
416
 
 * BEHAVIOR     :  Update the volume of the choosen mixers. If the update
417
 
 *                 fails, the sliders are put back to 0.
418
 
 * PRE          :  The main window GMObject.
419
 
 */
420
 
static void audio_volume_changed_cb (GtkAdjustment *, 
421
 
                                     gpointer);
422
 
 
423
 
 
424
 
/* DESCRIPTION  :  This callback is called when the user changes one of the 
425
 
 *                 video settings sliders in the main notebook.
426
 
 * BEHAVIOR     :  Updates the value in real time, if it fails, reset 
427
 
 *                 all sliders to 0.
428
 
 * PRE          :  gpointer is a valid pointer to the main window GmObject.
429
 
 */
430
 
static void video_settings_changed_cb (GtkAdjustment *, 
431
 
                                       gpointer);
432
 
 
433
 
 
434
 
/* DESCRIPTION  :  This callback is called when the user changes the
435
 
 *                 page in the main notebook.
436
 
 * BEHAVIOR     :  Update the config key accordingly.
437
 
 * PRE          :  A valid pointer to the main window GmObject.
438
 
 */
439
 
static void panel_section_changed_cb (GtkNotebook *, 
440
 
                                      GtkNotebookPage *,
441
 
                                      gint, 
442
 
                                      gpointer);
443
 
 
444
 
 
445
 
/* DESCRIPTION  :  This callback is called when the user 
446
 
 *                 clicks on the dialpad button.
447
 
 * BEHAVIOR     :  Generates a dialpad event.
448
 
 * PRE          :  A valid pointer to the main window GMObject.
449
 
 */
450
 
static void dialpad_button_clicked_cb (EkigaDialpad  *dialpad,
451
 
                                       const gchar *button_text,
452
 
                                       GtkWidget   *main_window);
453
 
 
454
 
 
455
 
/* DESCRIPTION  :  This callback is called when the user tries to close
456
 
 *                 the application using the window manager.
457
 
 * BEHAVIOR     :  Calls the real callback if the notification icon is 
458
 
 *                 not shown else hide GM.
459
 
 * PRE          :  A valid pointer to the main window GMObject.
460
 
 */
461
 
static gint window_closed_cb (GtkWidget *, 
462
 
                              GdkEvent *, 
463
 
                              gpointer);
464
 
 
465
 
 
466
 
/* DESCRIPTION  :  This callback is called when the user tries to close
467
 
 *                 the main window using the FILE-menu
468
 
 * BEHAVIOUR    :  Directly calls window_closed_cb (i.e. it's just a wrapper)
469
 
 * PRE          :  ---
470
 
 */
471
 
 
472
 
static void window_closed_from_menu_cb (GtkWidget *,
473
 
                                       gpointer);
474
 
 
475
 
 
476
 
/* DESCRIPTION  :  This callback is called when the user changes the zoom
477
 
 *                 factor in the menu, and chooses to zoom in.
478
 
 * BEHAVIOR     :  zoom *= 2.
479
 
 * PRE          :  The GConf key to update with the new zoom.
480
 
 */
481
 
static void zoom_in_changed_cb (GtkWidget *,
482
 
                                gpointer);
483
 
 
484
 
 
485
 
/* DESCRIPTION  :  This callback is called when the user changes the zoom
486
 
 *                 factor in the menu, and chooses to zoom in.
487
 
 * BEHAVIOR     :  zoom /= 2.
488
 
 * PRE          :  The GConf key to update with the new zoom.
489
 
 */
490
 
static void zoom_out_changed_cb (GtkWidget *,
491
 
                                 gpointer);
492
 
 
493
 
 
494
 
/* DESCRIPTION  :  This callback is called when the user changes the zoom
495
 
 *                 factor in the menu, and chooses to zoom in.
496
 
 * BEHAVIOR     :  zoom = 1.
497
 
 * PRE          :  The GConf key to update with the new zoom.
498
 
 */
499
 
static void zoom_normal_changed_cb (GtkWidget *,
500
 
                                    gpointer);
501
 
 
502
 
void 
503
 
display_changed_cb (GtkWidget *widget,
504
 
                    gpointer data);
505
 
 
506
 
/* DESCRIPTION  :  This callback is called when the user toggles fullscreen
507
 
 *                 factor in the popup menu.
508
 
 * BEHAVIOR     :  Toggles the fullscreen configuration key. 
509
 
 * PRE          :  / 
510
 
 */
511
 
static void fullscreen_changed_cb (GtkWidget *,
512
 
                                   gpointer);
513
 
 
514
 
/* DESCRIPTION  :  This callback is called when the user changes the URL
515
 
 *                 in the URL bar.
516
 
 * BEHAVIOR     :  It udpates the tooltip with the new URL
517
 
 *                 and the completion cache.
518
 
 * PRE          :  A valid pointer to the main window GMObject. 
519
 
 */
520
 
static void url_changed_cb (GtkEditable *, 
521
 
                            gpointer);
522
 
 
523
 
/* DESCRIPTION  :  This callback is called when the user presses a
524
 
 *                 button in the toolbar. 
525
 
 *                 (See menu_toggle_changed)
526
 
 * BEHAVIOR     :  Updates the config cache.
527
 
 * PRE          :  data is the key.
528
 
 */
529
 
static void toolbar_toggle_button_changed_cb (GtkWidget *, 
530
 
                                              gpointer);
531
 
 
532
 
 
533
 
/* DESCRIPTION  :  This callback is called when the status bar is clicked.
534
 
 * BEHAVIOR     :  Clear all info message, not normal messages.
535
 
 * PRE          :  The main window GMObject.
536
 
 */
537
 
static gboolean statusbar_clicked_cb (GtkWidget *,
538
 
                                      GdkEventButton *,
539
 
                                      gpointer);
540
 
 
541
 
 
542
 
/* DESCRIPTION  :  This callback is called if main window is focussed
543
 
 * BEHAVIOR     :  currently only: unset urgency hint
544
 
 * PRE          : /
545
 
 */
546
 
static gboolean main_window_focus_event_cb (GtkWidget *,
547
 
                                            GdkEventFocus *,
548
 
                                            gpointer);
549
 
 
550
 
static void audio_volume_window_shown_cb (GtkWidget *widget,
551
 
                                          gpointer data);
552
 
 
553
 
static void audio_volume_window_hidden_cb (GtkWidget *widget,
554
 
                                           gpointer data);
555
 
 
556
 
 
557
 
 
558
 
/* 
559
 
 * Engine Callbacks 
560
 
 */
561
 
static void on_ready_cb (gpointer self)
562
 
{
563
 
  gm_main_window_set_busy (GTK_WIDGET (self), false);
564
 
}
565
 
 
566
 
 
567
 
static void on_registration_event (const Ekiga::Account & account,
568
 
                                   Ekiga::AccountCore::RegistrationState state,
569
 
                                   std::string /*info*/,
570
 
                                   gpointer self)
571
 
{
572
 
  GmMainWindow *mw = NULL;
573
 
 
574
 
  gchar *msg = NULL;
575
 
  std::string aor = account.get_aor ();
576
 
 
577
 
  g_return_if_fail (GTK_WIDGET (self) != NULL);
578
 
  mw = gm_mw_get_mw (GTK_WIDGET (self));
579
 
 
580
 
  switch (state) {
581
 
  case Ekiga::AccountCore::Registered:
582
 
    /* Translators: Is displayed once an account "%s" is registered. */
583
 
    msg = g_strdup_printf (_("Registered %s"), aor.c_str ()); 
584
 
    mw->accounts.push_back (account.get_host ());
585
 
    break;
586
 
 
587
 
  case Ekiga::AccountCore::Unregistered:
588
 
    /* Translators: Is displayed once an account "%s" is unregistered. */
589
 
    msg = g_strdup_printf (_("Unregistered %s"), aor.c_str ());
590
 
    mw->accounts.remove (account.get_host ());
591
 
    break;
592
 
 
593
 
  case Ekiga::AccountCore::UnregistrationFailed:
594
 
    msg = g_strdup_printf (_("Could not unregister %s"), aor.c_str ());
595
 
    break;
596
 
 
597
 
  case Ekiga::AccountCore::RegistrationFailed:
598
 
    msg = g_strdup_printf (_("Could not register %s"), aor.c_str ());
599
 
    break;
600
 
 
601
 
  case Ekiga::AccountCore::Processing:
602
 
  default:
603
 
    break;
604
 
  }
605
 
 
606
 
  if (msg)
607
 
    gm_main_window_flash_message (GTK_WIDGET (self), "%s", msg);
608
 
 
609
 
  g_free (msg);
610
 
}
611
 
 
612
 
 
613
 
static void on_setup_call_cb (Ekiga::CallManager & /*manager*/,
614
 
                              Ekiga::Call & call,
615
 
                              gpointer self)
616
 
{
617
 
  GmMainWindow *mw = gm_mw_get_mw (GTK_WIDGET (self));
618
 
  Ekiga::AudioOutputCore *audiooutput_core = dynamic_cast<Ekiga::AudioOutputCore *> (mw->core.get ("audiooutput-core"));
619
 
 
620
 
  if (!call.is_outgoing ()) {
621
 
    gm_main_window_update_calling_state (GTK_WIDGET (self), Called);
622
 
    audiooutput_core->start_play_event("incoming_call_sound", 4000, 256);
623
 
#ifdef HAVE_NOTIFY
624
 
    gm_main_window_incoming_call_notify (GTK_WIDGET (self), call);
625
 
#else
626
 
    gm_main_window_incoming_call_dialog_show (GTK_WIDGET (self), call);
627
 
#endif
628
 
  }
629
 
  else {
630
 
    gm_main_window_update_calling_state (GTK_WIDGET (self), Calling);
631
 
    if (!call.get_remote_uri ().empty ())
632
 
      gm_main_window_set_call_url (GTK_WIDGET (self), call.get_remote_uri ().c_str());
633
 
    mw->current_call = &call;
634
 
  }
635
 
}
636
 
 
637
 
 
638
 
static void on_ringing_call_cb (Ekiga::CallManager & /*manager*/,
639
 
                                Ekiga::Call & call,
640
 
                                gpointer self)
641
 
{
642
 
  GmMainWindow *mw = gm_mw_get_mw (GTK_WIDGET (self));
643
 
  Ekiga::AudioOutputCore *audiooutput_core = dynamic_cast<Ekiga::AudioOutputCore *> (mw->core.get ("audiooutput-core"));
644
 
 
645
 
  if (call.is_outgoing ()) {
646
 
    audiooutput_core->start_play_event("ring_tone_sound", 3000, 256);
647
 
  }
648
 
}
649
 
 
650
 
 
651
 
 
652
 
static gboolean on_stats_refresh_cb (gpointer self) 
653
 
{
654
 
  gchar *msg = NULL;
655
 
 
656
 
  GmMainWindow *mw = gm_mw_get_mw (GTK_WIDGET (self));
657
 
  
658
 
  if (mw->calling_state == Connected && mw->current_call) {
659
 
 
660
 
    Ekiga::VideoOutputStats videooutput_stats;
661
 
    Ekiga::VideoOutputCore *videooutput_core = dynamic_cast<Ekiga::VideoOutputCore *> (mw->core.get ("videooutput-core"));
662
 
    videooutput_core->get_videooutput_stats(videooutput_stats);
663
 
  
664
 
    msg = g_strdup_printf (_("A:%.1f/%.1f   V:%.1f/%.1f   FPS:%d/%d"), 
665
 
                           mw->current_call->get_transmitted_audio_bandwidth (),
666
 
                           mw->current_call->get_received_audio_bandwidth (),
667
 
                           mw->current_call->get_transmitted_video_bandwidth (),
668
 
                           mw->current_call->get_received_video_bandwidth (),
669
 
                           videooutput_stats.tx_fps,
670
 
                           videooutput_stats.rx_fps);
671
 
    gm_main_window_flash_message (GTK_WIDGET (self), msg);
672
 
    gm_main_window_set_call_duration (GTK_WIDGET (self), mw->current_call->get_duration ().c_str ());
673
 
    g_free (msg);
674
 
 
675
 
    unsigned int jitter = mw->current_call->get_jitter_size ();
676
 
    double lost = mw->current_call->get_lost_packets ();
677
 
    double late = mw->current_call->get_late_packets ();
678
 
    double out_of_order = mw->current_call->get_out_of_order_packets ();
679
 
 
680
 
    gm_main_window_update_stats (GTK_WIDGET (self), lost, late, out_of_order, jitter, 
681
 
                                 0, 0, 0, 0,
682
 
                                 videooutput_stats.rx_width,
683
 
                                 videooutput_stats.rx_height,
684
 
                                 videooutput_stats.tx_width,
685
 
                                 videooutput_stats.tx_height);
686
 
  }
687
 
  return true;
688
 
}
689
 
 
690
 
static gboolean on_signal_level_refresh_cb (gpointer self) 
691
 
{
692
 
  GmMainWindow *mw = gm_mw_get_mw (GTK_WIDGET (self));
693
 
 
694
 
  Ekiga::AudioInputCore *audioinput_core = dynamic_cast<Ekiga::AudioInputCore *> (mw->core.get ("audioinput-core"));
695
 
  Ekiga::AudioOutputCore *audiooutput_core = dynamic_cast<Ekiga::AudioOutputCore *> (mw->core.get ("audiooutput-core"));
696
 
 
697
 
  gtk_levelmeter_set_level (GTK_LEVELMETER (mw->output_signal), audiooutput_core->get_average_level());
698
 
  gtk_levelmeter_set_level (GTK_LEVELMETER (mw->input_signal), audioinput_core->get_average_level());
699
 
  return true;
700
 
}
701
 
 
702
 
static void on_established_call_cb (Ekiga::CallManager & /*manager*/,
703
 
                                    Ekiga::Call & call,
704
 
                                    gpointer self)
705
 
{
706
 
  GmMainWindow *mw = gm_mw_get_mw (GTK_WIDGET (self));
707
 
  gchar* info = NULL;
708
 
 
709
 
  info = g_strdup_printf (_("Connected with %s"),
710
 
                          call.get_remote_party_name ().c_str ());
711
 
 
712
 
  if (!call.get_remote_uri ().empty ())
713
 
    gm_main_window_set_call_url (GTK_WIDGET (self), call.get_remote_uri ().c_str());
714
 
  if (gm_conf_get_bool (VIDEO_DISPLAY_KEY "stay_on_top"))
715
 
    gm_main_window_set_stay_on_top (GTK_WIDGET (self), TRUE);
716
 
  gm_main_window_set_status (GTK_WIDGET (self), info);
717
 
  gm_main_window_flash_message (GTK_WIDGET (self), "%s", info);
718
 
  if (!gm_conf_get_bool (USER_INTERFACE_KEY "main_window/show_call_panel"))
719
 
    gm_main_window_show_call_panel (GTK_WIDGET (self));
720
 
  gm_main_window_update_calling_state (GTK_WIDGET (self), Connected);
721
 
 
722
 
  mw->current_call = &call;
723
 
 
724
 
  mw->timeout_id = g_timeout_add (1000, on_stats_refresh_cb, self);
725
 
 
726
 
  Ekiga::AudioOutputCore *audiooutput_core = dynamic_cast<Ekiga::AudioOutputCore *> (mw->core.get ("audiooutput-core"));
727
 
 
728
 
  audiooutput_core->stop_play_event("incoming_call_sound");
729
 
  audiooutput_core->stop_play_event("ring_tone_sound");
730
 
 
731
 
  g_free (info);
732
 
}
733
 
 
734
 
 
735
 
static void on_cleared_call_cb (Ekiga::CallManager & /*manager*/,
736
 
                                Ekiga::Call & call,
737
 
                                std::string reason, 
738
 
                                gpointer self)
739
 
{
740
 
  GmMainWindow *mw = gm_mw_get_mw (GTK_WIDGET (self));
741
 
 
742
 
  if (gm_conf_get_bool (VIDEO_DISPLAY_KEY "stay_on_top"))
743
 
    gm_main_window_set_stay_on_top (GTK_WIDGET (self), FALSE);
744
 
  gm_main_window_update_calling_state (GTK_WIDGET (self), Standby);
745
 
  gm_main_window_set_status (GTK_WIDGET (self), _("Standby"));
746
 
  gm_main_window_set_call_duration (GTK_WIDGET (self), NULL);
747
 
  gm_main_window_set_call_info (GTK_WIDGET (self), NULL, NULL, NULL, NULL);
748
 
  if (!gm_conf_get_bool (USER_INTERFACE_KEY "main_window/show_call_panel"))
749
 
    gm_main_window_hide_call_panel (GTK_WIDGET (self));
750
 
  gm_main_window_clear_stats (GTK_WIDGET (self));
751
 
  gm_main_window_update_logo_have_window (GTK_WIDGET (self));
752
 
  gm_main_window_push_message (GTK_WIDGET (self), "%s", reason.c_str ());
753
 
 
754
 
  if (mw->current_call && mw->current_call->get_id () == call.get_id ()) {
755
 
 
756
 
    mw->current_call = NULL;
757
 
    g_source_remove (mw->timeout_id);
758
 
    mw->timeout_id = -1;
759
 
  }
760
 
  Ekiga::AudioOutputCore *audiooutput_core = dynamic_cast<Ekiga::AudioOutputCore *> (mw->core.get ("audiooutput-core"));
761
 
 
762
 
  audiooutput_core->stop_play_event("incoming_call_sound");
763
 
  audiooutput_core->stop_play_event("ring_tone_sound");
764
 
 
765
 
  gm_main_window_clear_signal_levels(GTK_WIDGET (self));
766
 
}
767
 
 
768
 
 
769
 
static void on_cleared_incoming_call_cb (std::string /*reason*/,
770
 
                                         gpointer self)
771
 
{
772
 
  GmMainWindow *mw = NULL;
773
 
 
774
 
  GtkWidget *main_window = NULL;
775
 
  
776
 
  main_window = GnomeMeeting::Process ()->GetMainWindow ();
777
 
  mw = gm_mw_get_mw (main_window);
778
 
  Ekiga::AudioOutputCore *audiooutput_core = dynamic_cast<Ekiga::AudioOutputCore *> (mw->core.get ("audiooutput-core"));
779
 
  audiooutput_core->stop_play_event("incoming_call_sound");
780
 
  audiooutput_core->stop_play_event("ring_tone_sound");
781
 
 
782
 
#ifdef HAVE_NOTIFY
783
 
  notify_notification_close (NOTIFY_NOTIFICATION (self), NULL);
784
 
#else
785
 
  gtk_widget_destroy (GTK_WIDGET (self));
786
 
#endif
787
 
}
788
 
 
789
 
 
790
 
static void on_missed_incoming_call_cb (gpointer self)
791
 
{
792
 
#ifdef HAVE_NOTIFY
793
 
  notify_notification_close (NOTIFY_NOTIFICATION (self), NULL);
794
 
#else
795
 
  gtk_widget_destroy (GTK_WIDGET (self));
796
 
#endif
797
 
}
798
 
 
799
 
 
800
 
void gm_main_window_add_device_dialog_show (GtkWidget *main_window,
801
 
                                            const Ekiga::Device & device,
802
 
                                            DeviceType deviceType);
803
 
 
804
 
static void on_held_call_cb (Ekiga::CallManager & /*manager*/,
805
 
                             Ekiga::Call & /*call*/,
806
 
                             gpointer self)
807
 
{
808
 
  gchar *info_string = NULL;
809
 
 
810
 
  gm_main_window_set_call_hold (GTK_WIDGET (self), true);
811
 
  info_string = g_strdup (_("Call on hold"));
812
 
  gm_main_window_flash_message (GTK_WIDGET (self), "%s", info_string);
813
 
  g_free (info_string);
814
 
}
815
 
 
816
 
 
817
 
static void on_retrieved_call_cb (Ekiga::CallManager & /*manager*/,
818
 
                                  Ekiga::Call & /*call*/,
819
 
                                  gpointer self)
820
 
{
821
 
  gchar *info_string = NULL;
822
 
 
823
 
  gm_main_window_set_call_hold (GTK_WIDGET (self), false);
824
 
  info_string = g_strdup (_("Call retrieved"));
825
 
  gm_main_window_flash_message (GTK_WIDGET (self), "%s", info_string);
826
 
  g_free (info_string);
827
 
}
828
 
 
829
 
 
830
 
static void on_missed_call_cb (Ekiga::CallManager & /*manager*/,
831
 
                               Ekiga::Call & call,
832
 
                               gpointer self)
833
 
{
834
 
  GmMainWindow *mw = gm_mw_get_mw (GTK_WIDGET (self));
835
 
  Ekiga::AudioOutputCore *audiooutput_core = dynamic_cast<Ekiga::AudioOutputCore *> (mw->core.get ("audiooutput-core"));
836
 
 
837
 
  audiooutput_core->stop_play_event("incoming_call_sound");
838
 
  audiooutput_core->stop_play_event("ring_tone_sound");
839
 
 
840
 
  gchar* info = NULL;
841
 
  info = g_strdup_printf (_("Missed call from %s"),
842
 
                          call.get_remote_party_name ().c_str ());
843
 
  gm_main_window_push_message (GTK_WIDGET (self), "%s", info);
844
 
  g_free (info);
845
 
}
846
 
 
847
 
 
848
 
static void on_stream_opened_cb (Ekiga::CallManager & /*manager*/,
849
 
                                 Ekiga::Call & /* call */,
850
 
                                 std::string name,
851
 
                                 Ekiga::Call::StreamType type,
852
 
                                 bool is_transmitting,
853
 
                                 gpointer self)
854
 
{
855
 
  GmMainWindow *mw = NULL;
856
 
 
857
 
  g_return_if_fail (GTK_WIDGET (self) != NULL);
858
 
  mw = gm_mw_get_mw (GTK_WIDGET (self));
859
 
  g_return_if_fail (mw != NULL);
860
 
 
861
 
  bool is_closing = false;
862
 
  bool is_encoding = is_transmitting;
863
 
  bool is_video = (type == Ekiga::Call::Video);
864
 
 
865
 
  /* FIXME: This should not be needed anymore */
866
 
  if (type == Ekiga::Call::Video) {
867
 
    
868
 
    is_closing ?
869
 
      (is_encoding ? mw->video_transmission_active = false : mw->video_reception_active = false)
870
 
      :(is_encoding ? mw->video_transmission_active = true : mw->video_reception_active = true);
871
 
 
872
 
    if (is_encoding)
873
 
      is_closing ? mw->transmitted_video_codec = "" : mw->transmitted_video_codec = name;
874
 
    else
875
 
      is_closing ? mw->received_video_codec = "" : mw->received_video_codec = name;
876
 
  }
877
 
  else {
878
 
    
879
 
    is_closing ?
880
 
      (is_encoding ? mw->audio_transmission_active = false : mw->audio_reception_active = false)
881
 
      :(is_encoding ? mw->audio_transmission_active = true : mw->audio_reception_active = true);
882
 
 
883
 
    if (is_encoding)
884
 
      is_closing ? mw->transmitted_audio_codec = "" : mw->transmitted_audio_codec = name;
885
 
    else
886
 
      is_closing ? mw->received_audio_codec = "" : mw->received_audio_codec = name;
887
 
  }
888
 
 
889
 
  gm_main_window_update_sensitivity (GTK_WIDGET (self),
890
 
                                     is_video,
891
 
                                     is_video ? mw->video_reception_active : mw->audio_reception_active,
892
 
                                     is_video ? mw->video_transmission_active : mw->audio_transmission_active);
893
 
  gm_main_window_set_call_info (GTK_WIDGET (self), 
894
 
                                mw->transmitted_audio_codec.c_str (), 
895
 
                                mw->received_audio_codec.c_str (),
896
 
                                mw->transmitted_video_codec.c_str (), 
897
 
                                mw->received_audio_codec.c_str ());
898
 
}
899
 
 
900
 
 
901
 
static void on_stream_closed_cb (Ekiga::CallManager & /*manager*/,
902
 
                                 Ekiga::Call & /* call */,
903
 
                                 std::string name,
904
 
                                 Ekiga::Call::StreamType type,
905
 
                                 bool is_transmitting,
906
 
                                 gpointer self)
907
 
{
908
 
  GmMainWindow *mw = NULL;
909
 
 
910
 
  g_return_if_fail (GTK_WIDGET (self) != NULL);
911
 
  mw = gm_mw_get_mw (GTK_WIDGET (self));
912
 
  g_return_if_fail (mw != NULL);
913
 
 
914
 
  bool is_closing = true;
915
 
  bool is_encoding = is_transmitting;
916
 
  bool is_video = (type == Ekiga::Call::Video);
917
 
 
918
 
  /* FIXME: This should not be needed anymore */
919
 
  if (type == Ekiga::Call::Video) {
920
 
    
921
 
    is_closing ?
922
 
      (is_encoding ? mw->video_transmission_active = false : mw->video_reception_active = false)
923
 
      :(is_encoding ? mw->video_transmission_active = true : mw->video_reception_active = true);
924
 
 
925
 
    if (is_encoding)
926
 
      is_closing ? mw->transmitted_video_codec = "" : mw->transmitted_video_codec = name;
927
 
    else
928
 
      is_closing ? mw->received_video_codec = "" : mw->received_video_codec = name;
929
 
  }
930
 
  else {
931
 
    
932
 
    is_closing ?
933
 
      (is_encoding ? mw->audio_transmission_active = false : mw->audio_reception_active = false)
934
 
      :(is_encoding ? mw->audio_transmission_active = true : mw->audio_reception_active = true);
935
 
 
936
 
    if (is_encoding)
937
 
      is_closing ? mw->transmitted_audio_codec = "" : mw->transmitted_audio_codec = name;
938
 
    else
939
 
      is_closing ? mw->received_audio_codec = "" : mw->received_audio_codec = name;
940
 
  }
941
 
 
942
 
  gm_main_window_update_sensitivity (GTK_WIDGET (self),
943
 
                                     is_video,
944
 
                                     is_video ? mw->video_reception_active : mw->audio_reception_active,
945
 
                                     is_video ? mw->video_transmission_active : mw->audio_transmission_active);
946
 
  gm_main_window_set_call_info (GTK_WIDGET (self), 
947
 
                                mw->transmitted_audio_codec.c_str (), 
948
 
                                mw->received_audio_codec.c_str (),
949
 
                                mw->transmitted_video_codec.c_str (), 
950
 
                                mw->received_audio_codec.c_str ());
951
 
}
952
 
 
953
 
 
954
 
static void on_stream_paused_cb (Ekiga::CallManager & /*manager*/,
955
 
                                 Ekiga::Call & /*call*/,
956
 
                                 std::string /*name*/,
957
 
                                 Ekiga::Call::StreamType type,
958
 
                                 gpointer self)
959
 
{
960
 
  gm_main_window_set_channel_pause (GTK_WIDGET (self), true, (type == Ekiga::Call::Video));
961
 
}
962
 
 
963
 
 
964
 
static void on_stream_resumed_cb (Ekiga::CallManager & /*manager*/,
965
 
                                  Ekiga::Call & /*call*/,
966
 
                                  std::string /*name*/,
967
 
                                  Ekiga::Call::StreamType type,
968
 
                                  gpointer self)
969
 
{
970
 
  gm_main_window_set_channel_pause (GTK_WIDGET (self), false, (type == Ekiga::Call::Video));
971
 
}
972
 
 
973
 
 
974
 
static bool on_handle_errors (std::string error,
975
 
                              gpointer data)
976
 
{
977
 
  g_return_val_if_fail (data != NULL, false);
978
 
 
979
 
  GtkWidget *dialog = gtk_message_dialog_new (GTK_WINDOW (data), 
980
 
                                              GTK_DIALOG_MODAL, 
981
 
                                              GTK_MESSAGE_ERROR,
982
 
                                              GTK_BUTTONS_OK, NULL);
983
 
 
984
 
  gtk_window_set_title (GTK_WINDOW (dialog), _("Error"));
985
 
  gtk_label_set_markup (GTK_LABEL (GTK_MESSAGE_DIALOG (dialog)->label), error.c_str ());
986
 
  
987
 
  g_signal_connect_swapped (GTK_OBJECT (dialog), "response",
988
 
                            G_CALLBACK (gtk_widget_destroy),
989
 
                            GTK_OBJECT (dialog));
990
 
  
991
 
  gtk_widget_show_all (dialog);
992
 
 
993
 
  return true;
994
 
}
995
 
 
996
 
 
997
 
 
998
 
/* 
999
 
 * Display Engine Callbacks 
1000
 
 */
1001
 
 
1002
 
void 
1003
 
on_videooutput_device_opened_cb (Ekiga::VideoOutputManager & /* manager */, 
1004
 
                                 Ekiga::VideoOutputAccel /* accel */, 
1005
 
                                 Ekiga::VideoOutputMode mode, 
1006
 
                                 unsigned zoom, 
1007
 
                                 bool both_streams,
1008
 
                                 gpointer self)
1009
 
{
1010
 
  GmMainWindow *mw = gm_mw_get_mw (GTK_WIDGET (self));
1011
 
 
1012
 
  if (both_streams) {
1013
 
       gtk_menu_section_set_sensitive (mw->main_menu, "local_video", TRUE);
1014
 
       gtk_menu_section_set_sensitive (mw->main_menu, "fullscreen", TRUE);
1015
 
  } 
1016
 
  else {
1017
 
 
1018
 
    if (mode == Ekiga::VO_MODE_LOCAL)
1019
 
      gtk_menu_set_sensitive (mw->main_menu, "local_video", TRUE);
1020
 
 
1021
 
    if (mode == Ekiga::VO_MODE_REMOTE)
1022
 
       gtk_menu_set_sensitive (mw->main_menu, "remote_video", TRUE);
1023
 
  }
1024
 
 
1025
 
  gtk_radio_menu_select_with_id (mw->main_menu, "local_video", mode);
1026
 
 
1027
 
  gtk_menu_set_sensitive (mw->main_menu, "zoom_in", (zoom == 200) ? FALSE : TRUE);
1028
 
  gtk_menu_set_sensitive (mw->main_menu, "zoom_out", (zoom == 50) ? FALSE : TRUE);
1029
 
  gtk_menu_set_sensitive (mw->main_menu, "normal_size", (zoom == 100) ? FALSE : TRUE);
1030
 
}
1031
 
 
1032
 
void 
1033
 
on_videooutput_device_closed_cb (Ekiga::VideoOutputManager & /* manager */, gpointer self)
1034
 
{
1035
 
  GmMainWindow *mw = gm_mw_get_mw (GTK_WIDGET (self));
1036
 
 
1037
 
  gtk_menu_section_set_sensitive (mw->main_menu, "local_video", FALSE);
1038
 
 
1039
 
  gtk_menu_section_set_sensitive (mw->main_menu, "fullscreen", TRUE);
1040
 
 
1041
 
  gtk_menu_section_set_sensitive (mw->main_menu, "zoom_in", FALSE);
1042
 
}
1043
 
 
1044
 
void 
1045
 
on_videooutput_device_error_cb (Ekiga::VideoOutputManager & /* manager */, 
1046
 
                                Ekiga::VideoOutputErrorCodes error_code, 
1047
 
                                gpointer self)
1048
 
{
1049
 
  PTRACE(1, "Error opening the output device");
1050
 
}
1051
 
 
1052
 
void 
1053
 
on_fullscreen_mode_changed_cb (Ekiga::VideoOutputManager & /* manager */, Ekiga::VideoOutputFSToggle toggle,  gpointer self)
1054
 
{
1055
 
  gm_main_window_toggle_fullscreen (toggle, GTK_WIDGET (self));
1056
 
}
1057
 
 
1058
 
void 
1059
 
on_size_changed_cb (Ekiga::VideoOutputManager & /* manager */, unsigned width, unsigned height,  gpointer self)
1060
 
{
1061
 
  GmMainWindow *mw = gm_mw_get_mw (GTK_WIDGET (self));
1062
 
  GtkRequisition req;
1063
 
  int x, y;
1064
 
 
1065
 
  gtk_widget_size_request (GTK_WIDGET (mw->main_video_image), &req);
1066
 
  gtk_window_get_size (GTK_WINDOW (self), &x, &y);
1067
 
  gtk_widget_set_size_request (GTK_WIDGET (mw->main_video_image), width, height);
1068
 
  gtk_window_resize (GTK_WINDOW (self), width, height);
1069
 
  
1070
 
  GdkRectangle rect;
1071
 
  rect.x = mw->main_video_image->allocation.x;
1072
 
  rect.y = mw->main_video_image->allocation.y;
1073
 
  rect.width = mw->main_video_image->allocation.width;
1074
 
  rect.height = mw->main_video_image->allocation.height;
1075
 
 
1076
 
  gdk_window_invalidate_rect (GDK_WINDOW (GTK_WIDGET (self)->window), &rect , TRUE);
1077
 
}
1078
 
 
1079
 
void
1080
 
on_videoinput_device_opened_cb (Ekiga::VideoInputManager & /* manager */,
1081
 
                                Ekiga::VideoInputDevice & /* device */,
1082
 
                                Ekiga::VideoInputSettings & settings,
1083
 
                                gpointer self)
1084
 
{
1085
 
  GmMainWindow *mw = NULL;
1086
 
  g_return_if_fail (self != NULL);
1087
 
  mw = gm_mw_get_mw (GTK_WIDGET (self));
1088
 
  g_return_if_fail (mw != NULL);
1089
 
 
1090
 
  gtk_widget_set_sensitive (GTK_WIDGET (mw->video_settings_frame),  settings.modifyable ? TRUE : FALSE);
1091
 
  gtk_widget_set_sensitive (GTK_WIDGET (mw->video_settings_button),  settings.modifyable ? TRUE : FALSE);
1092
 
  GTK_ADJUSTMENT (mw->adj_whiteness)->value = settings.whiteness;
1093
 
  GTK_ADJUSTMENT (mw->adj_brightness)->value = settings.brightness;
1094
 
  GTK_ADJUSTMENT (mw->adj_colour)->value = settings.colour;
1095
 
  GTK_ADJUSTMENT (mw->adj_contrast)->value = settings.contrast;
1096
 
 
1097
 
  gtk_widget_queue_draw (GTK_WIDGET (mw->video_settings_frame));
1098
 
}
1099
 
 
1100
 
 
1101
 
 
1102
 
void 
1103
 
on_videoinput_device_closed_cb (Ekiga::VideoInputManager & /* manager */, Ekiga::VideoInputDevice & /*device*/, gpointer self)
1104
 
{
1105
 
  GmMainWindow *mw = NULL;
1106
 
  g_return_if_fail (self != NULL);
1107
 
  mw = gm_mw_get_mw (GTK_WIDGET (self));
1108
 
  g_return_if_fail (mw != NULL);
1109
 
 
1110
 
  gm_main_window_update_sensitivity (GTK_WIDGET (self), TRUE, FALSE, FALSE);
1111
 
  gm_main_window_update_logo_have_window (GTK_WIDGET (self));
1112
 
 
1113
 
  gtk_widget_set_sensitive (GTK_WIDGET (mw->video_settings_button),  FALSE);
1114
 
}
1115
 
 
1116
 
void 
1117
 
on_videoinput_device_added_cb (const Ekiga::VideoInputDevice & device, bool isDesired, gpointer self)
1118
 
{
1119
 
  GmMainWindow *mw = NULL;
1120
 
  g_return_if_fail (self != NULL);
1121
 
  mw = gm_mw_get_mw (GTK_WIDGET (self));
1122
 
  g_return_if_fail (mw != NULL);
1123
 
  gchar* message = NULL;
1124
 
 
1125
 
  /* Translators: This is a hotplug status */
1126
 
  message = g_strdup_printf (_("Added video input device %s"),
1127
 
                               device.GetString().c_str ());
1128
 
  gm_main_window_flash_message (GTK_WIDGET (self), "%s", message);
1129
 
  g_free (message);
1130
 
  if (!isDesired && mw->calling_state == Standby && !mw->current_call) 
1131
 
    gm_main_window_add_device_dialog_show (GTK_WIDGET (self), device, VideoInput);
1132
 
}
1133
 
 
1134
 
void 
1135
 
on_videoinput_device_removed_cb (const Ekiga::VideoInputDevice & device, bool, gpointer self)
1136
 
{
1137
 
  GmMainWindow *mw = NULL;
1138
 
  g_return_if_fail (self != NULL);
1139
 
  mw = gm_mw_get_mw (GTK_WIDGET (self));
1140
 
  g_return_if_fail (mw != NULL);
1141
 
  gchar* message = NULL;
1142
 
 
1143
 
  /* Translators: This is a hotplug status */
1144
 
  message = g_strdup_printf (_("Removed video input device %s"),
1145
 
                             device.GetString().c_str ());
1146
 
  gm_main_window_flash_message (GTK_WIDGET (self), "%s", message);
1147
 
  g_free (message);
1148
 
}
1149
 
 
1150
 
void 
1151
 
on_videoinput_device_error_cb (Ekiga::VideoInputManager & /* manager */, 
1152
 
                               Ekiga::VideoInputDevice & device, 
1153
 
                               Ekiga::VideoInputErrorCodes error_code, 
1154
 
                               gpointer self)
1155
 
{
1156
 
  gchar *dialog_title = NULL;
1157
 
  gchar *dialog_msg = NULL;
1158
 
  gchar *tmp_msg = NULL;
1159
 
 
1160
 
  dialog_title =
1161
 
  g_strdup_printf (_("Error while accessing video device %s"),
1162
 
                   (const char *) device.name.c_str());
1163
 
 
1164
 
  tmp_msg = g_strdup (_("A moving logo will be transmitted during calls. Notice that you can always transmit a given image or the moving logo by choosing \"Picture\" as video plugin and \"Moving logo\" or \"Static picture\" as device."));
1165
 
  switch (error_code) {
1166
 
 
1167
 
    case Ekiga::VI_ERROR_DEVICE:
1168
 
      dialog_msg = g_strconcat (_("There was an error while opening the device. In case it is a pluggable device it may be sufficient to reconnect it. If not, or if it still is not accessible, please check your permissions and make sure that the appropriate driver is loaded."), "\n\n", tmp_msg, NULL);
1169
 
      break;
1170
 
 
1171
 
    case Ekiga::VI_ERROR_FORMAT:
1172
 
      dialog_msg = g_strconcat (_("Your video driver doesn't support the requested video format."), "\n\n", tmp_msg, NULL);
1173
 
      break;
1174
 
 
1175
 
    case Ekiga::VI_ERROR_CHANNEL:
1176
 
      dialog_msg = g_strconcat (_("Could not open the chosen channel."), "\n\n", tmp_msg, NULL);
1177
 
      break;
1178
 
 
1179
 
    case Ekiga::VI_ERROR_COLOUR:
1180
 
      dialog_msg = g_strconcat (_("Your driver doesn't seem to support any of the color formats supported by Ekiga.\n Please check your kernel driver documentation in order to determine which Palette is supported."), "\n\n", tmp_msg, NULL);
1181
 
      break;
1182
 
 
1183
 
    case Ekiga::VI_ERROR_FPS:
1184
 
      dialog_msg = g_strconcat (_("Error while setting the frame rate."), "\n\n", tmp_msg, NULL);
1185
 
      break;
1186
 
 
1187
 
    case Ekiga::VI_ERROR_SCALE:
1188
 
      dialog_msg = g_strconcat (_("Error while setting the frame size."), "\n\n", tmp_msg, NULL);
1189
 
      break;
1190
 
 
1191
 
    case Ekiga::VI_ERROR_NONE:
1192
 
    default:
1193
 
      dialog_msg = g_strconcat (_("Unknown error."), "\n\n", tmp_msg, NULL);
1194
 
      break;
1195
 
  }
1196
 
 
1197
 
  gnomemeeting_warning_dialog_on_widget (GTK_WINDOW (GTK_WIDGET (self)),
1198
 
                                         "show_device_warnings",
1199
 
                                         dialog_title,
1200
 
                                         "%s", dialog_msg);
1201
 
  g_free (dialog_msg);
1202
 
  g_free (dialog_title);
1203
 
  g_free (tmp_msg);
1204
 
}
1205
 
 
1206
 
void
1207
 
on_audioinput_device_opened_cb (Ekiga::AudioInputManager & /* manager */,
1208
 
                                Ekiga::AudioInputDevice & /* device */,
1209
 
                                Ekiga::AudioInputSettings & settings,
1210
 
                                gpointer self)
1211
 
{
1212
 
  GmMainWindow *mw = NULL;
1213
 
  g_return_if_fail (self != NULL);
1214
 
  mw = gm_mw_get_mw (GTK_WIDGET (self));
1215
 
  g_return_if_fail (mw != NULL);
1216
 
 
1217
 
  gtk_widget_set_sensitive (GTK_WIDGET (mw->audio_input_volume_frame), settings.modifyable ? TRUE : FALSE);
1218
 
  gtk_widget_set_sensitive (GTK_WIDGET (mw->audio_settings_button), settings.modifyable ? TRUE : FALSE);
1219
 
  GTK_ADJUSTMENT (mw->adj_input_volume)->value = settings.volume;
1220
 
  
1221
 
  gtk_widget_queue_draw (GTK_WIDGET (mw->audio_input_volume_frame));
1222
 
}
1223
 
 
1224
 
 
1225
 
 
1226
 
void 
1227
 
on_audioinput_device_closed_cb (Ekiga::AudioInputManager & /* manager */, 
1228
 
                                Ekiga::AudioInputDevice & /*device*/, 
1229
 
                                gpointer self)
1230
 
{
1231
 
  GmMainWindow *mw = NULL;
1232
 
  g_return_if_fail (self != NULL);
1233
 
  mw = gm_mw_get_mw (GTK_WIDGET (self));
1234
 
  g_return_if_fail (mw != NULL);
1235
 
 
1236
 
  gtk_widget_set_sensitive (GTK_WIDGET (mw->audio_settings_button), FALSE);
1237
 
  gtk_widget_set_sensitive (GTK_WIDGET (mw->audio_input_volume_frame), FALSE);
1238
 
}
1239
 
 
1240
 
void 
1241
 
on_audioinput_device_added_cb (const Ekiga::AudioInputDevice & device, 
1242
 
                               bool isDesired,
1243
 
                               gpointer self)
1244
 
{
1245
 
  GmMainWindow *mw = NULL;
1246
 
  g_return_if_fail (self != NULL);
1247
 
  mw = gm_mw_get_mw (GTK_WIDGET (self));
1248
 
  g_return_if_fail (mw != NULL);
1249
 
  gchar* message = NULL;
1250
 
 
1251
 
  /* Translators: This is a hotplug status */
1252
 
  message = g_strdup_printf (_("Added audio input device %s"),
1253
 
                             device.GetString().c_str ());
1254
 
  gm_main_window_flash_message (GTK_WIDGET (self), "%s", message);
1255
 
  g_free (message);
1256
 
  if (!isDesired  && mw->calling_state == Standby && !mw->current_call)
1257
 
    gm_main_window_add_device_dialog_show (GTK_WIDGET (self), device,  AudioInput);
1258
 
    
1259
 
}
1260
 
 
1261
 
void 
1262
 
on_audioinput_device_removed_cb (const Ekiga::AudioInputDevice & device, 
1263
 
                                 bool,
1264
 
                                 gpointer self)
1265
 
{
1266
 
  GmMainWindow *mw = NULL;
1267
 
  g_return_if_fail (self != NULL);
1268
 
  mw = gm_mw_get_mw (GTK_WIDGET (self));
1269
 
  g_return_if_fail (mw != NULL);
1270
 
  gchar* message = NULL;
1271
 
 
1272
 
  /* Translators: This is a hotplug status */
1273
 
  message = g_strdup_printf (_("Removed audio input device %s"),
1274
 
                             device.GetString().c_str ());
1275
 
  gm_main_window_flash_message (GTK_WIDGET (self), "%s", message);
1276
 
  g_free (message);
1277
 
}
1278
 
 
1279
 
void 
1280
 
on_audioinput_device_error_cb (Ekiga::AudioInputManager & /* manager */, 
1281
 
                               Ekiga::AudioInputDevice & device, 
1282
 
                               Ekiga::AudioInputErrorCodes error_code, 
1283
 
                               gpointer self)
1284
 
{
1285
 
  gchar *dialog_title = NULL;
1286
 
  gchar *dialog_msg = NULL;
1287
 
  gchar *tmp_msg = NULL;
1288
 
 
1289
 
  dialog_title =
1290
 
  g_strdup_printf (_("Error while opening audio input device %s"),
1291
 
                   (const char *) device.name.c_str());
1292
 
 
1293
 
  /* Translators: This happens when there is an error with audio input:
1294
 
   * Nothing ("silence") will be transmitted */
1295
 
  tmp_msg = g_strdup (_("Only silence will be transmitted."));
1296
 
  switch (error_code) {
1297
 
 
1298
 
    case Ekiga::AI_ERROR_DEVICE:
1299
 
      dialog_msg = g_strconcat (tmp_msg, "\n\n", _("Unable to open the selected audio device for recording. In case it is a pluggable device it may be sufficient to reconnect it. If not, or if it still is not accessible, please check your audio setup, the permissions and that the device is not busy."), NULL);
1300
 
      break;
1301
 
 
1302
 
    case Ekiga::AI_ERROR_READ:
1303
 
      dialog_msg = g_strconcat (tmp_msg, "\n\n", _("The selected audio device was successfully opened but it is impossible to read data from this device. In case it is a pluggable device it may be sufficient to reconnect it. If not, or if it still is not accessible, please check your audio setup."), NULL);
1304
 
      break;
1305
 
 
1306
 
    case Ekiga::AI_ERROR_NONE:
1307
 
    default:
1308
 
      dialog_msg = g_strconcat (tmp_msg, "\n\n", _("Unknown error."), NULL);
1309
 
      break;
1310
 
  }
1311
 
 
1312
 
  gnomemeeting_warning_dialog_on_widget (GTK_WINDOW (GTK_WIDGET (self)),
1313
 
                                         "show_device_warnings",
1314
 
                                         dialog_title,
1315
 
                                         "%s", dialog_msg);
1316
 
  g_free (dialog_msg);
1317
 
  g_free (dialog_title);
1318
 
  g_free (tmp_msg);
1319
 
 
1320
 
}
1321
 
 
1322
 
void
1323
 
on_audiooutput_device_opened_cb (Ekiga::AudioOutputManager & /*manager*/,
1324
 
                                 Ekiga::AudioOutputPS ps,
1325
 
                                 Ekiga::AudioOutputDevice & /*device*/,
1326
 
                                 Ekiga::AudioOutputSettings & settings,
1327
 
                                 gpointer self)
1328
 
{
1329
 
  if (ps == Ekiga::secondary)
1330
 
    return;
1331
 
 
1332
 
  GmMainWindow *mw = NULL;
1333
 
  g_return_if_fail (self != NULL);
1334
 
  mw = gm_mw_get_mw (GTK_WIDGET (self));
1335
 
  g_return_if_fail (mw != NULL);
1336
 
 
1337
 
  gtk_widget_set_sensitive (GTK_WIDGET (mw->audio_settings_button), settings.modifyable ? TRUE : FALSE);
1338
 
  gtk_widget_set_sensitive (GTK_WIDGET (mw->audio_output_volume_frame), settings.modifyable ? TRUE : FALSE);
1339
 
  GTK_ADJUSTMENT (mw->adj_output_volume)->value = settings.volume;
1340
 
 
1341
 
  gtk_widget_queue_draw (GTK_WIDGET (mw->audio_output_volume_frame));
1342
 
}
1343
 
 
1344
 
 
1345
 
 
1346
 
void 
1347
 
on_audiooutput_device_closed_cb (Ekiga::AudioOutputManager & /*manager*/, 
1348
 
                                 Ekiga::AudioOutputPS ps, 
1349
 
                                 Ekiga::AudioOutputDevice & /*device*/, 
1350
 
                                 gpointer self)
1351
 
{
1352
 
  if (ps == Ekiga::secondary)
1353
 
    return;
1354
 
 
1355
 
  GmMainWindow *mw = NULL;
1356
 
  g_return_if_fail (self != NULL);
1357
 
  mw = gm_mw_get_mw (GTK_WIDGET (self));
1358
 
  g_return_if_fail (mw != NULL);
1359
 
 
1360
 
  gtk_widget_set_sensitive (GTK_WIDGET (mw->audio_settings_button), FALSE);
1361
 
  gtk_widget_set_sensitive (GTK_WIDGET (mw->audio_output_volume_frame), FALSE);
1362
 
}
1363
 
 
1364
 
void 
1365
 
on_audiooutput_device_added_cb (const Ekiga::AudioOutputDevice & device, 
1366
 
                                bool isDesired,
1367
 
                                gpointer self)
1368
 
{
1369
 
  GmMainWindow *mw = NULL;
1370
 
  g_return_if_fail (self != NULL);
1371
 
  mw = gm_mw_get_mw (GTK_WIDGET (self));
1372
 
  g_return_if_fail (mw != NULL);
1373
 
  gchar* message = NULL;
1374
 
 
1375
 
  message = g_strdup_printf (_("Added audio output device %s"), device.GetString().c_str ());
1376
 
  gm_main_window_flash_message (GTK_WIDGET (self), "%s", message);
1377
 
  g_free (message);
1378
 
  if (!isDesired && mw->calling_state == Standby && !mw->current_call)
1379
 
    gm_main_window_add_device_dialog_show (GTK_WIDGET (self), device, AudioOutput);
1380
 
}
1381
 
 
1382
 
void 
1383
 
on_audiooutput_device_removed_cb (const Ekiga::AudioOutputDevice & device, 
1384
 
                                  bool,
1385
 
                                  gpointer self)
1386
 
{
1387
 
  GmMainWindow *mw = NULL;
1388
 
  g_return_if_fail (self != NULL);
1389
 
  mw = gm_mw_get_mw (GTK_WIDGET (self));
1390
 
  g_return_if_fail (mw != NULL);
1391
 
  gchar* message = NULL;
1392
 
 
1393
 
  message = g_strdup_printf (_("Removed audio output device %s"),
1394
 
                             device.GetString().c_str ());
1395
 
  gm_main_window_flash_message (GTK_WIDGET (self), "%s", message);
1396
 
  g_free (message);
1397
 
}
1398
 
 
1399
 
void 
1400
 
on_audiooutput_device_error_cb (Ekiga::AudioOutputManager & /*manager */, 
1401
 
                                Ekiga::AudioOutputPS ps,
1402
 
                                Ekiga::AudioOutputDevice & device, 
1403
 
                                Ekiga::AudioOutputErrorCodes error_code, 
1404
 
                                gpointer self)
1405
 
{
1406
 
  if (ps == Ekiga::secondary)
1407
 
    return;
1408
 
 
1409
 
  gchar *dialog_title = NULL;
1410
 
  gchar *dialog_msg = NULL;
1411
 
  gchar *tmp_msg = NULL;
1412
 
 
1413
 
  dialog_title =
1414
 
  g_strdup_printf (_("Error while opening audio output device %s"),
1415
 
                   (const char *) device.name.c_str());
1416
 
 
1417
 
  tmp_msg = g_strdup (_("No incoming sound will be played."));
1418
 
  switch (error_code) {
1419
 
 
1420
 
    case Ekiga::AO_ERROR_DEVICE:
1421
 
      dialog_msg = g_strconcat (tmp_msg, "\n\n", _("Unable to open the selected audio device for playing. In case it is a pluggable device it may be sufficient to reconnect it. If not, or if it still is not accessible, please check your audio setup, the permissions and that the device is not busy."), NULL);
1422
 
      break;
1423
 
 
1424
 
    case Ekiga::AO_ERROR_WRITE:
1425
 
      dialog_msg = g_strconcat (tmp_msg, "\n\n", _("The selected audio device was successfully opened but it is impossible to write data from this device. In case it is a pluggable device it may be sufficient to reconnect it. If not, or if it still is not accessible, please check your audio setup."), NULL);
1426
 
      break;
1427
 
 
1428
 
    case Ekiga::AO_ERROR_NONE:
1429
 
    default:
1430
 
      dialog_msg = g_strconcat (tmp_msg, "\n\n", _("Unknown error."), NULL);
1431
 
      break;
1432
 
  }
1433
 
 
1434
 
  gnomemeeting_warning_dialog_on_widget (GTK_WINDOW (GTK_WIDGET (self)),
1435
 
                                         "show_device_warnings",
1436
 
                                         dialog_title,
1437
 
                                         "%s", dialog_msg);
1438
 
  g_free (dialog_msg);
1439
 
  g_free (dialog_title);
1440
 
  g_free (tmp_msg);
1441
 
}
1442
 
 
1443
 
 
1444
 
/* Implementation */
1445
 
static void
1446
 
gm_mw_destroy (gpointer m)
1447
 
{
1448
 
  GmMainWindow *mw = GM_MAIN_WINDOW (m);
1449
 
 
1450
 
  g_return_if_fail (mw != NULL);
1451
 
 
1452
 
  gtk_widget_destroy (mw->audio_settings_window);
1453
 
  gtk_widget_destroy (mw->video_settings_window);
1454
 
 
1455
 
  delete ((GmMainWindow *) mw);
1456
 
}
1457
 
 
1458
 
 
1459
 
static GmMainWindow *
1460
 
gm_mw_get_mw (GtkWidget *main_window)
1461
 
{
1462
 
  g_return_val_if_fail (main_window != NULL, NULL);
1463
 
 
1464
 
  return GM_MAIN_WINDOW (g_object_get_data (G_OBJECT (main_window), 
1465
 
                                            "GMObject"));
1466
 
}
1467
 
 
1468
 
 
1469
 
static void
1470
 
incoming_call_response_cb (GtkDialog *incoming_call_popup,
1471
 
                           gint response,
1472
 
                           gpointer data)
1473
 
{
1474
 
  Ekiga::Call *call = (Ekiga::Call *) data;
1475
 
 
1476
 
  gtk_widget_hide (GTK_WIDGET (incoming_call_popup));
1477
 
 
1478
 
  if (call) {
1479
 
 
1480
 
    switch (response) {
1481
 
    case 2:
1482
 
      call->answer ();
1483
 
      break;
1484
 
 
1485
 
    default:
1486
 
    case 0:
1487
 
      call->hangup ();
1488
 
      break;
1489
 
    }
1490
 
  }
1491
 
}
1492
 
 
1493
 
static void
1494
 
add_device_response_cb (GtkDialog *add_device_popup,
1495
 
                           gint response,
1496
 
                           gpointer data)
1497
 
{
1498
 
  deviceStruct *device_struct = (deviceStruct*) data;
1499
 
 
1500
 
  gtk_widget_hide (GTK_WIDGET (add_device_popup));
1501
 
 
1502
 
  if (response == 2) {
1503
 
 
1504
 
    switch (device_struct->deviceType)
1505
 
    {
1506
 
     case AudioInput:
1507
 
       gm_conf_set_string (AUDIO_DEVICES_KEY "input_device", device_struct->name);
1508
 
       break;
1509
 
     case AudioOutput:
1510
 
       gm_conf_set_string (AUDIO_DEVICES_KEY "output_device", device_struct->name);
1511
 
       break;
1512
 
     case VideoInput:
1513
 
       gm_conf_set_string (VIDEO_DEVICES_KEY "input_device", device_struct->name);
1514
 
       break;                   
1515
 
     default:;
1516
 
    }
1517
 
  }
1518
 
}
1519
 
 
1520
 
static void
1521
 
place_call_cb (GtkWidget * /*widget*/,
1522
 
               gpointer data)
1523
 
{
1524
 
  std::string uri;
1525
 
 
1526
 
  Ekiga::CallCore *call_core = NULL;
1527
 
  GmMainWindow *mw = NULL;
1528
 
 
1529
 
  mw = gm_mw_get_mw (GTK_WIDGET (data));
1530
 
 
1531
 
  if (mw->calling_state == Standby && !mw->current_call) {
1532
 
 
1533
 
    size_t pos;
1534
 
 
1535
 
    gm_main_window_update_calling_state (GTK_WIDGET (data), Calling);
1536
 
    call_core = dynamic_cast<Ekiga::CallCore*> (mw->core.get ("call-core"));
1537
 
    uri = gm_main_window_get_call_url (GTK_WIDGET (data));
1538
 
    if (call_core->dial (uri)) {
1539
 
 
1540
 
      pos = uri.find ("@");
1541
 
      if (pos != std::string::npos) {
1542
 
 
1543
 
        std::string host = uri.substr (pos + 1);
1544
 
        mw->accounts.remove (host);
1545
 
        mw->accounts.push_front (host);
1546
 
      }
1547
 
 
1548
 
    }
1549
 
    else {
1550
 
      gm_main_window_flash_message (GTK_WIDGET (data), _("Could not connect to remote host"));
1551
 
      gm_main_window_update_calling_state (GTK_WIDGET (data), Standby);
1552
 
    }
1553
 
  }
1554
 
}
1555
 
 
1556
 
 
1557
 
static void
1558
 
hangup_call_cb (GtkWidget * /*widget*/,
1559
 
                gpointer data)
1560
 
{
1561
 
  GmMainWindow *mw = NULL;
1562
 
 
1563
 
  mw = gm_mw_get_mw (GTK_WIDGET (data));
1564
 
 
1565
 
  if (mw->current_call) {
1566
 
 
1567
 
    mw->current_call->hangup ();
1568
 
    mw->current_call = NULL;
1569
 
  }
1570
 
}
1571
 
 
1572
 
 
1573
 
static void 
1574
 
toggle_call_cb (GtkWidget *widget,
1575
 
                gpointer data)
1576
 
{
1577
 
  GmMainWindow *mw = NULL;
1578
 
 
1579
 
  mw = gm_mw_get_mw (GTK_WIDGET (data));
1580
 
 
1581
 
  if (mw->current_call && gm_connect_button_get_connected (GM_CONNECT_BUTTON (mw->connect_button)))
1582
 
    hangup_call_cb (widget, data);
1583
 
  else if (!mw->current_call && !gm_connect_button_get_connected (GM_CONNECT_BUTTON (mw->connect_button)))
1584
 
    place_call_cb (widget, data);
1585
 
}
1586
 
 
1587
 
 
1588
 
static void
1589
 
on_status_icon_embedding_change (G_GNUC_UNUSED GObject obj,
1590
 
                                 G_GNUC_UNUSED GParamSpec param,
1591
 
                                 G_GNUC_UNUSED gpointer data)
1592
 
{
1593
 
  GtkWidget *main_window = NULL;
1594
 
  GtkStatusIcon *status_icon = NULL;
1595
 
 
1596
 
  status_icon = GTK_STATUS_ICON (GnomeMeeting::Process ()->GetStatusicon ());
1597
 
  main_window = GnomeMeeting::Process ()->GetMainWindow ();
1598
 
 
1599
 
  /* force the main window to show if no status icon for the user */
1600
 
  if (!gtk_status_icon_is_embedded (GTK_STATUS_ICON (status_icon)))
1601
 
    gtk_widget_show (main_window);
1602
 
}
1603
 
 
1604
 
static GtkWidget *
1605
 
gm_mw_init_uri_toolbar (GtkWidget *main_window)
1606
 
{
1607
 
  GmMainWindow *mw = NULL;
1608
 
 
1609
 
  GtkToolItem *item = NULL;
1610
 
 
1611
 
  GtkWidget *toolbar = NULL;
1612
 
  GtkEntryCompletion *completion = NULL;
1613
 
  
1614
 
  g_return_val_if_fail (main_window != NULL, NULL);
1615
 
  mw = gm_mw_get_mw (main_window);
1616
 
  g_return_val_if_fail (mw != NULL, NULL);
1617
 
 
1618
 
  
1619
 
  /* The main horizontal toolbar */
1620
 
  toolbar = gtk_toolbar_new ();
1621
 
  gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_ICONS);
1622
 
  gtk_toolbar_set_show_arrow (GTK_TOOLBAR (toolbar), FALSE);
1623
 
 
1624
 
 
1625
 
  /* URL bar */
1626
 
  /* Entry */
1627
 
  item = gtk_tool_item_new ();
1628
 
  mw->entry = gtk_entry_new ();
1629
 
  mw->completion = gtk_list_store_new (1, G_TYPE_STRING);
1630
 
  completion = gtk_entry_completion_new ();
1631
 
  gtk_entry_completion_set_model (GTK_ENTRY_COMPLETION (completion), GTK_TREE_MODEL (mw->completion));
1632
 
  gtk_entry_set_completion (GTK_ENTRY (mw->entry), completion);
1633
 
  gtk_entry_completion_set_inline_completion (GTK_ENTRY_COMPLETION (completion), false);
1634
 
  gtk_entry_completion_set_popup_completion (GTK_ENTRY_COMPLETION (completion), true);
1635
 
  gtk_entry_completion_set_text_column (GTK_ENTRY_COMPLETION (completion), 0);
1636
 
 
1637
 
  gtk_container_add (GTK_CONTAINER (item), mw->entry);
1638
 
  gtk_container_set_border_width (GTK_CONTAINER (item), 0);
1639
 
  gtk_tool_item_set_expand (GTK_TOOL_ITEM (item), true);
1640
 
  
1641
 
  gtk_entry_set_text (GTK_ENTRY (mw->entry), "sip:");
1642
 
 
1643
 
  // activate Ctrl-L to get the entry focus
1644
 
  gtk_widget_add_accelerator (mw->entry, "grab-focus",
1645
 
                              mw->accel, GDK_L,
1646
 
                              (GdkModifierType) GDK_CONTROL_MASK,
1647
 
                              (GtkAccelFlags) 0);
1648
 
 
1649
 
  gtk_editable_set_position (GTK_EDITABLE (GTK_WIDGET (mw->entry)), -1);
1650
 
 
1651
 
  g_signal_connect (G_OBJECT (mw->entry), "changed", 
1652
 
                    GTK_SIGNAL_FUNC (url_changed_cb), main_window);
1653
 
  g_signal_connect (G_OBJECT (mw->entry), "activate", 
1654
 
                    GTK_SIGNAL_FUNC (place_call_cb), main_window);
1655
 
 
1656
 
  gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, 0);
1657
 
 
1658
 
  /* The connect button */
1659
 
  item = gtk_tool_item_new ();
1660
 
  mw->connect_button = gm_connect_button_new (GM_STOCK_PHONE_PICK_UP_24,
1661
 
                                              GM_STOCK_PHONE_HANG_UP_24,
1662
 
                                              GTK_ICON_SIZE_LARGE_TOOLBAR);
1663
 
  gtk_container_add (GTK_CONTAINER (item), mw->connect_button);
1664
 
  gtk_container_set_border_width (GTK_CONTAINER (mw->connect_button), 0);
1665
 
  gtk_tool_item_set_expand (GTK_TOOL_ITEM (item), FALSE);
1666
 
 
1667
 
  gtk_widget_set_tooltip_text (GTK_WIDGET (mw->connect_button),
1668
 
                               _("Enter a URI on the left, and click this button to place a call"));
1669
 
  
1670
 
  gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
1671
 
 
1672
 
  g_signal_connect (G_OBJECT (mw->connect_button), "clicked",
1673
 
                    G_CALLBACK (toggle_call_cb), 
1674
 
                    main_window);
1675
 
 
1676
 
  gtk_widget_show_all (GTK_WIDGET (toolbar));
1677
 
  
1678
 
  return toolbar;
1679
 
}
1680
 
 
1681
 
 
1682
 
static GtkWidget *
1683
 
gm_mw_init_status_toolbar (GtkWidget *main_window)
1684
 
{
1685
 
  GmMainWindow *mw = NULL;
1686
 
 
1687
 
  GtkWidget *toolbar = NULL;
1688
 
  GtkToolItem *item = NULL;
1689
 
 
1690
 
  g_return_val_if_fail (main_window != NULL, NULL);
1691
 
  mw = gm_mw_get_mw (main_window);
1692
 
  g_return_val_if_fail (mw != NULL, NULL);
1693
 
 
1694
 
  
1695
 
  /* The main horizontal toolbar */
1696
 
  toolbar = gtk_toolbar_new ();
1697
 
  gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_ICONS);
1698
 
  gtk_toolbar_set_show_arrow (GTK_TOOLBAR (toolbar), FALSE);
1699
 
 
1700
 
  item = gtk_tool_item_new ();
1701
 
  mw->status_option_menu = status_menu_new (); 
1702
 
  status_menu_set_parent_window (STATUS_MENU (mw->status_option_menu), 
1703
 
                                 GTK_WINDOW (main_window));
1704
 
  gtk_container_add (GTK_CONTAINER (item), mw->status_option_menu);
1705
 
  gtk_container_set_border_width (GTK_CONTAINER (item), 0);
1706
 
  gtk_tool_item_set_expand (GTK_TOOL_ITEM (item), TRUE);
1707
 
  
1708
 
  gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, 0);
1709
 
 
1710
 
  gtk_widget_show_all (toolbar);
1711
 
  
1712
 
  return toolbar;
1713
 
}
1714
 
 
1715
 
        
1716
 
static void
1717
 
gm_mw_init_menu (GtkWidget *main_window)
1718
 
{
1719
 
  GmMainWindow *mw = NULL;
1720
 
 
1721
 
  Ekiga::ServiceCore *services = NULL;
1722
 
  Ekiga::Trigger *local_cluster_trigger = NULL;
1723
 
  GtkFrontend *gtk_frontend = NULL;
1724
 
  
1725
 
  GtkWidget *addressbook_window = NULL;
1726
 
  GtkWidget *accounts_window = NULL;
1727
 
 
1728
 
  bool show_call_panel = false;
1729
 
  
1730
 
  PanelSection cps = DIALPAD;
1731
 
 
1732
 
  g_return_if_fail (main_window != NULL);
1733
 
  mw = gm_mw_get_mw (main_window);
1734
 
 
1735
 
  services = GnomeMeeting::Process ()->GetServiceCore ();
1736
 
  local_cluster_trigger = dynamic_cast<Ekiga::Trigger *>(services->get ("local-cluster"));
1737
 
  gtk_frontend = dynamic_cast<GtkFrontend *>(services->get ("gtk-frontend"));
1738
 
  addressbook_window = GTK_WIDGET (gtk_frontend->get_addressbook_window ()); 
1739
 
  accounts_window = GnomeMeeting::Process ()->GetAccountsWindow ();
1740
 
 
1741
 
  mw->main_menu = gtk_menu_bar_new ();
1742
 
 
1743
 
  /* Default values */
1744
 
  show_call_panel = gm_conf_get_bool (USER_INTERFACE_KEY "main_window/show_call_panel");
1745
 
  cps = (PanelSection) gm_conf_get_int (USER_INTERFACE_KEY "main_window/panel_section"); 
1746
 
  
1747
 
  static MenuEntry gnomemeeting_menu [] =
1748
 
    {
1749
 
      GTK_MENU_NEW (_("_Chat")),
1750
 
 
1751
 
      GTK_MENU_ENTRY("connect", _("Ca_ll"), _("Place a new call"), 
1752
 
                     GM_STOCK_PHONE_PICK_UP_16, 'o',
1753
 
                     GTK_SIGNAL_FUNC (place_call_cb), main_window, TRUE),
1754
 
      GTK_MENU_ENTRY("disconnect", _("_Hang up"),
1755
 
                     _("Terminate the current call"), 
1756
 
                     GM_STOCK_PHONE_HANG_UP_16, GDK_Escape,
1757
 
                     GTK_SIGNAL_FUNC (hangup_call_cb), main_window, FALSE),
1758
 
 
1759
 
      GTK_MENU_SEPARATOR,
1760
 
 
1761
 
      GTK_MENU_ENTRY("add_contact", _("A_dd Contact"), _("Add a contact to the roster"),
1762
 
                     GTK_STOCK_ADD, 'n', 
1763
 
                     GTK_SIGNAL_FUNC (pull_trigger_cb), local_cluster_trigger, true),
1764
 
 
1765
 
      GTK_MENU_THEME_ENTRY("address_book", _("Address _Book"),
1766
 
                           _("Find contacts"),
1767
 
                           GM_ICON_ADDRESSBOOK, 'b',
1768
 
                           GTK_SIGNAL_FUNC (show_widget_cb),
1769
 
                           (gpointer) addressbook_window, TRUE),
1770
 
 
1771
 
      GTK_MENU_SEPARATOR,
1772
 
 
1773
 
      GTK_MENU_ENTRY("contact", _("_Contact"),
1774
 
                     _("Act on selected contact"),
1775
 
                     GTK_STOCK_EXECUTE, 0,
1776
 
                     NULL, NULL, FALSE),
1777
 
 
1778
 
      GTK_MENU_SEPARATOR,
1779
 
 
1780
 
      GTK_MENU_ENTRY("hold_call", _("H_old Call"), _("Hold the current call"),
1781
 
                     NULL, GDK_h, 
1782
 
                     GTK_SIGNAL_FUNC (hold_current_call_cb), main_window,
1783
 
                     FALSE),
1784
 
      GTK_MENU_ENTRY("transfer_call", _("_Transfer Call"),
1785
 
                     _("Transfer the current call"),
1786
 
                     NULL, GDK_t, 
1787
 
                     GTK_SIGNAL_FUNC (transfer_current_call_cb), main_window, 
1788
 
                     FALSE),
1789
 
 
1790
 
      GTK_MENU_SEPARATOR,
1791
 
 
1792
 
      GTK_MENU_ENTRY("suspend_audio", _("Suspend _Audio"),
1793
 
                     _("Suspend or resume the audio transmission"),
1794
 
                     NULL, GDK_m,
1795
 
                     GTK_SIGNAL_FUNC (toggle_audio_stream_pause_cb),
1796
 
                     main_window, FALSE),
1797
 
      GTK_MENU_ENTRY("suspend_video", _("Suspend _Video"),
1798
 
                     _("Suspend or resume the video transmission"),
1799
 
                     NULL, GDK_p, 
1800
 
                     GTK_SIGNAL_FUNC (toggle_video_stream_pause_cb),
1801
 
                     main_window, FALSE),
1802
 
 
1803
 
      GTK_MENU_SEPARATOR,
1804
 
 
1805
 
      GTK_MENU_ENTRY("close", NULL, _("Close the Ekiga window"),
1806
 
                     GTK_STOCK_CLOSE, 'W', 
1807
 
                     GTK_SIGNAL_FUNC (window_closed_from_menu_cb),
1808
 
                     (gpointer) main_window, TRUE),
1809
 
 
1810
 
      GTK_MENU_SEPARATOR,
1811
 
      
1812
 
      GTK_MENU_ENTRY("quit", NULL, _("Quit"),
1813
 
                     GTK_STOCK_QUIT, 'Q', 
1814
 
                     GTK_SIGNAL_FUNC (quit_callback), NULL, TRUE),
1815
 
 
1816
 
      GTK_MENU_NEW (_("_Edit")),
1817
 
 
1818
 
      GTK_MENU_ENTRY("configuration_assistant", _("_Configuration Assistant"),
1819
 
                     _("Run the configuration assistant"),
1820
 
                     NULL, 0, 
1821
 
                     G_CALLBACK (show_assistant_window_cb),
1822
 
                     NULL, TRUE),
1823
 
 
1824
 
      GTK_MENU_SEPARATOR,
1825
 
      
1826
 
      GTK_MENU_ENTRY("accounts", _("_Accounts"),
1827
 
                     _("Edit your accounts"), 
1828
 
                     NULL, 'E',
1829
 
                     GTK_SIGNAL_FUNC (show_window_cb),
1830
 
                     (gpointer) accounts_window, TRUE),
1831
 
 
1832
 
      GTK_MENU_ENTRY("preferences", NULL,
1833
 
                     _("Change your preferences"), 
1834
 
                     GTK_STOCK_PREFERENCES, 0,
1835
 
                     G_CALLBACK (show_prefs_window_cb),
1836
 
                     NULL, TRUE),
1837
 
 
1838
 
      GTK_MENU_NEW(_("_View")),
1839
 
 
1840
 
      GTK_MENU_RADIO_ENTRY("contacts", _("Con_tacts"), _("View the contacts list"),
1841
 
                           NULL, 0,
1842
 
                           GTK_SIGNAL_FUNC (radio_menu_changed_cb),
1843
 
                           (gpointer) USER_INTERFACE_KEY "main_window/panel_section",
1844
 
                           (cps == CONTACTS), TRUE),
1845
 
      GTK_MENU_RADIO_ENTRY("dialpad", _("_Dialpad"), _("View the dialpad"),
1846
 
                           NULL, 0,
1847
 
                           GTK_SIGNAL_FUNC (radio_menu_changed_cb), 
1848
 
                           (gpointer) USER_INTERFACE_KEY "main_window/panel_section",
1849
 
                           (cps == DIALPAD), TRUE),
1850
 
      GTK_MENU_RADIO_ENTRY("callhistory", _("_Call History"), _("View the call history"),
1851
 
                           NULL, 0,
1852
 
                           GTK_SIGNAL_FUNC (radio_menu_changed_cb),
1853
 
                           (gpointer) USER_INTERFACE_KEY "main_window/panel_section",
1854
 
                           (cps == CALL), TRUE),
1855
 
 
1856
 
      GTK_MENU_SEPARATOR,
1857
 
 
1858
 
      GTK_MENU_TOGGLE_ENTRY("callpanel", _("_Show Call Panel"), _("Show the call panel"),
1859
 
                            NULL, 'J', 
1860
 
                            GTK_SIGNAL_FUNC (toggle_menu_changed_cb),
1861
 
                            (gpointer) USER_INTERFACE_KEY "main_window/show_call_panel", 
1862
 
                            show_call_panel, TRUE),
1863
 
 
1864
 
      GTK_MENU_SEPARATOR,
1865
 
 
1866
 
      GTK_MENU_RADIO_ENTRY("local_video", _("_Local Video"),
1867
 
                           _("Local video image"),
1868
 
                           NULL, '1', 
1869
 
                           GTK_SIGNAL_FUNC (display_changed_cb),
1870
 
                           (gpointer) VIDEO_DISPLAY_KEY "video_view",
1871
 
                           TRUE, FALSE),
1872
 
      GTK_MENU_RADIO_ENTRY("remote_video", _("_Remote Video"),
1873
 
                           _("Remote video image"),
1874
 
                           NULL, '2', 
1875
 
                           GTK_SIGNAL_FUNC (display_changed_cb), 
1876
 
                           (gpointer) VIDEO_DISPLAY_KEY "video_view",
1877
 
                           FALSE, FALSE),
1878
 
      GTK_MENU_RADIO_ENTRY("both_incrusted", _("_Picture-in-Picture"),
1879
 
                           _("Both video images"),
1880
 
                           NULL, '3', 
1881
 
                           GTK_SIGNAL_FUNC (display_changed_cb), 
1882
 
                           (gpointer) VIDEO_DISPLAY_KEY "video_view",
1883
 
                           FALSE, FALSE),
1884
 
      GTK_MENU_RADIO_ENTRY("both_incrusted_window", _("Picture-in-Picture in Separate _Window"),
1885
 
                           _("Both video images"),
1886
 
                           NULL, '4', 
1887
 
                           GTK_SIGNAL_FUNC (display_changed_cb), 
1888
 
                           (gpointer) VIDEO_DISPLAY_KEY "video_view",
1889
 
                           FALSE, FALSE),
1890
 
      GTK_MENU_SEPARATOR,
1891
 
 
1892
 
      GTK_MENU_ENTRY("zoom_in", NULL, _("Zoom in"), 
1893
 
                     GTK_STOCK_ZOOM_IN, '+', 
1894
 
                     GTK_SIGNAL_FUNC (zoom_in_changed_cb),
1895
 
                     (gpointer) VIDEO_DISPLAY_KEY "zoom", FALSE),
1896
 
      GTK_MENU_ENTRY("zoom_out", NULL, _("Zoom out"), 
1897
 
                     GTK_STOCK_ZOOM_OUT, '-', 
1898
 
                     GTK_SIGNAL_FUNC (zoom_out_changed_cb),
1899
 
                     (gpointer) VIDEO_DISPLAY_KEY "zoom", FALSE),
1900
 
      GTK_MENU_ENTRY("normal_size", NULL, _("Normal size"), 
1901
 
                     GTK_STOCK_ZOOM_100, '0',
1902
 
                     GTK_SIGNAL_FUNC (zoom_normal_changed_cb),
1903
 
                     (gpointer) VIDEO_DISPLAY_KEY "zoom", FALSE),
1904
 
      GTK_MENU_ENTRY("fullscreen", _("_Fullscreen"), _("Switch to fullscreen"), 
1905
 
                     GTK_STOCK_ZOOM_IN, GDK_F11, 
1906
 
                     GTK_SIGNAL_FUNC (fullscreen_changed_cb),
1907
 
                     (gpointer) main_window, FALSE),
1908
 
 
1909
 
      GTK_MENU_NEW(_("_Help")),
1910
 
 
1911
 
      GTK_MENU_ENTRY("help", NULL, 
1912
 
                     _("Get help by reading the Ekiga manual"),
1913
 
                     GTK_STOCK_HELP, GDK_F1, 
1914
 
                     GTK_SIGNAL_FUNC (help_cb), NULL, TRUE),
1915
 
 
1916
 
      GTK_MENU_ENTRY("about", NULL,
1917
 
                     _("View information about Ekiga"),
1918
 
                     GTK_STOCK_ABOUT, 0, 
1919
 
                     GTK_SIGNAL_FUNC (about_callback), (gpointer) main_window,
1920
 
                     TRUE),
1921
 
       
1922
 
      GTK_MENU_END
1923
 
    };
1924
 
 
1925
 
 
1926
 
  gtk_build_menu (mw->main_menu, 
1927
 
                  gnomemeeting_menu, 
1928
 
                  mw->accel, 
1929
 
                  mw->statusbar);
1930
 
 
1931
 
  gtk_widget_show_all (GTK_WIDGET (mw->main_menu));
1932
 
}
1933
 
 
1934
 
 
1935
 
static void 
1936
 
gm_mw_init_contacts_list (GtkWidget *main_window)
1937
 
{
1938
 
  GmMainWindow *mw = NULL;
1939
 
 
1940
 
  GtkWidget *label = NULL;
1941
 
 
1942
 
  GtkFrontend *gtk_frontend = NULL;
1943
 
  Ekiga::ServiceCore *services = NULL;
1944
 
  GtkWidget* roster_view = NULL;
1945
 
 
1946
 
  g_return_if_fail (main_window != NULL);
1947
 
  mw = gm_mw_get_mw (main_window);
1948
 
  
1949
 
  services = GnomeMeeting::Process ()->GetServiceCore ();
1950
 
  g_return_if_fail (services != NULL);
1951
 
 
1952
 
  gtk_frontend = dynamic_cast<GtkFrontend *>(services->get ("gtk-frontend"));
1953
 
 
1954
 
  label = gtk_label_new (_("Contacts"));
1955
 
  roster_view = GTK_WIDGET (gtk_frontend->get_roster_view ());
1956
 
  gtk_notebook_append_page (GTK_NOTEBOOK (mw->main_notebook),
1957
 
                            roster_view, label);
1958
 
  g_signal_connect (G_OBJECT (roster_view), "presentity-selected",
1959
 
                    G_CALLBACK (on_presentity_selected), main_window);
1960
 
}
1961
 
 
1962
 
 
1963
 
static void 
1964
 
gm_mw_init_dialpad (GtkWidget *main_window)
1965
 
{
1966
 
  GmMainWindow *mw = NULL;
1967
 
 
1968
 
  GtkWidget *dialpad = NULL;
1969
 
  GtkWidget *alignment = NULL;
1970
 
  GtkWidget *label = NULL;
1971
 
 
1972
 
  g_return_if_fail (main_window != NULL);
1973
 
  mw = gm_mw_get_mw (main_window);
1974
 
 
1975
 
  dialpad = ekiga_dialpad_new (mw->accel);
1976
 
  g_signal_connect (dialpad, "button-clicked",
1977
 
                    G_CALLBACK (dialpad_button_clicked_cb), main_window);
1978
 
 
1979
 
  alignment = gtk_alignment_new (0.5, 0.5, 0.2, 0.2);
1980
 
  gtk_container_add (GTK_CONTAINER (alignment), dialpad);
1981
 
 
1982
 
  label = gtk_label_new (_("Dialpad"));
1983
 
  gtk_notebook_append_page (GTK_NOTEBOOK (mw->main_notebook),
1984
 
                            alignment, label);
1985
 
}
1986
 
 
1987
 
 
1988
 
static GtkWidget * 
1989
 
gm_mw_video_settings_window_new (GtkWidget *main_window)
1990
 
{
1991
 
  GmMainWindow *mw = NULL;
1992
 
  
1993
 
  GtkWidget *hbox = NULL;
1994
 
  GtkWidget *vbox = NULL;
1995
 
  GtkWidget *image = NULL;
1996
 
  GtkWidget *window = NULL;
1997
 
 
1998
 
  GtkWidget *hscale_brightness = NULL;
1999
 
  GtkWidget *hscale_colour = NULL;
2000
 
  GtkWidget *hscale_contrast = NULL;
2001
 
  GtkWidget *hscale_whiteness = NULL;
2002
 
 
2003
 
  int brightness = 0, colour = 0, contrast = 0, whiteness = 0;
2004
 
 
2005
 
  g_return_val_if_fail (main_window != NULL, NULL);
2006
 
  mw = gm_mw_get_mw (main_window);
2007
 
 
2008
 
  
2009
 
  /* Build the window */
2010
 
  window = gtk_dialog_new ();
2011
 
  g_object_set_data_full (G_OBJECT (window), "window_name",
2012
 
                          g_strdup ("video_settings_window"), g_free); 
2013
 
  gtk_dialog_add_button (GTK_DIALOG (window), 
2014
 
                         GTK_STOCK_CLOSE, 
2015
 
                         GTK_RESPONSE_CANCEL);
2016
 
 
2017
 
  gtk_window_set_title (GTK_WINDOW (window), 
2018
 
                        _("Video Settings"));
2019
 
 
2020
 
  /* Webcam Control Frame, we need it to disable controls */            
2021
 
  mw->video_settings_frame = gtk_frame_new (NULL);
2022
 
  gtk_frame_set_shadow_type (GTK_FRAME (mw->video_settings_frame), 
2023
 
                             GTK_SHADOW_NONE);
2024
 
  gtk_container_set_border_width (GTK_CONTAINER (mw->video_settings_frame), 5);
2025
 
  
2026
 
  /* Category */
2027
 
  vbox = gtk_vbox_new (0, FALSE);
2028
 
  gtk_container_add (GTK_CONTAINER (mw->video_settings_frame), vbox);
2029
 
  
2030
 
  /* Brightness */
2031
 
  hbox = gtk_hbox_new (0, FALSE);
2032
 
  image = gtk_image_new_from_icon_name (GM_ICON_BRIGHTNESS, GTK_ICON_SIZE_MENU);
2033
 
  gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
2034
 
 
2035
 
  mw->adj_brightness = gtk_adjustment_new (brightness, 0.0, 
2036
 
                                           255.0, 1.0, 5.0, 1.0);
2037
 
  hscale_brightness = gtk_hscale_new (GTK_ADJUSTMENT (mw->adj_brightness));
2038
 
  gtk_range_set_update_policy (GTK_RANGE (hscale_brightness),
2039
 
                               GTK_UPDATE_DELAYED);
2040
 
  gtk_scale_set_draw_value (GTK_SCALE (hscale_brightness), FALSE);
2041
 
  gtk_scale_set_value_pos (GTK_SCALE (hscale_brightness), GTK_POS_RIGHT);
2042
 
  gtk_box_pack_start (GTK_BOX (hbox), hscale_brightness, TRUE, TRUE, 2);
2043
 
  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 3);
2044
 
 
2045
 
  gtk_widget_set_tooltip_text (hscale_brightness, _("Adjust brightness"));
2046
 
 
2047
 
  g_signal_connect (G_OBJECT (mw->adj_brightness), "value-changed",
2048
 
                    G_CALLBACK (video_settings_changed_cb), 
2049
 
                    (gpointer) main_window);
2050
 
 
2051
 
  /* Whiteness */
2052
 
  hbox = gtk_hbox_new (0, FALSE);
2053
 
  image = gtk_image_new_from_icon_name (GM_ICON_WHITENESS, GTK_ICON_SIZE_MENU);
2054
 
  gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
2055
 
 
2056
 
  mw->adj_whiteness = gtk_adjustment_new (whiteness, 0.0, 
2057
 
                                          255.0, 1.0, 5.0, 1.0);
2058
 
  hscale_whiteness = gtk_hscale_new (GTK_ADJUSTMENT (mw->adj_whiteness));
2059
 
  gtk_range_set_update_policy (GTK_RANGE (hscale_whiteness),
2060
 
                               GTK_UPDATE_DELAYED);
2061
 
  gtk_scale_set_draw_value (GTK_SCALE (hscale_whiteness), FALSE);
2062
 
  gtk_scale_set_value_pos (GTK_SCALE (hscale_whiteness), GTK_POS_RIGHT);
2063
 
  gtk_box_pack_start (GTK_BOX (hbox), hscale_whiteness, TRUE, TRUE, 2);
2064
 
  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 3);
2065
 
 
2066
 
  gtk_widget_set_tooltip_text (hscale_whiteness, _("Adjust whiteness"));
2067
 
 
2068
 
  g_signal_connect (G_OBJECT (mw->adj_whiteness), "value-changed",
2069
 
                    G_CALLBACK (video_settings_changed_cb), 
2070
 
                    (gpointer) main_window);
2071
 
 
2072
 
  /* Colour */
2073
 
  hbox = gtk_hbox_new (0, FALSE);
2074
 
  image = gtk_image_new_from_icon_name (GM_ICON_COLOURNESS, GTK_ICON_SIZE_MENU);
2075
 
  gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
2076
 
 
2077
 
  mw->adj_colour = gtk_adjustment_new (colour, 0.0, 
2078
 
                                       255.0, 1.0, 5.0, 1.0);
2079
 
  hscale_colour = gtk_hscale_new (GTK_ADJUSTMENT (mw->adj_colour));
2080
 
  gtk_range_set_update_policy (GTK_RANGE (hscale_colour),
2081
 
                               GTK_UPDATE_DELAYED);
2082
 
  gtk_scale_set_draw_value (GTK_SCALE (hscale_colour), FALSE);
2083
 
  gtk_scale_set_value_pos (GTK_SCALE (hscale_colour), GTK_POS_RIGHT);
2084
 
  gtk_box_pack_start (GTK_BOX (hbox), hscale_colour, TRUE, TRUE, 2);
2085
 
  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 3);
2086
 
 
2087
 
  gtk_widget_set_tooltip_text (hscale_colour, _("Adjust color"));
2088
 
 
2089
 
  g_signal_connect (G_OBJECT (mw->adj_colour), "value-changed",
2090
 
                    G_CALLBACK (video_settings_changed_cb), 
2091
 
                    (gpointer) main_window);
2092
 
 
2093
 
  /* Contrast */
2094
 
  hbox = gtk_hbox_new (0, FALSE);
2095
 
  image = gtk_image_new_from_icon_name (GM_ICON_CONTRAST, GTK_ICON_SIZE_MENU);
2096
 
  gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
2097
 
  
2098
 
  mw->adj_contrast = gtk_adjustment_new (contrast, 0.0, 
2099
 
                                         255.0, 1.0, 5.0, 1.0);
2100
 
  hscale_contrast = gtk_hscale_new (GTK_ADJUSTMENT (mw->adj_contrast));
2101
 
  gtk_range_set_update_policy (GTK_RANGE (hscale_contrast),
2102
 
                               GTK_UPDATE_DELAYED);
2103
 
  gtk_scale_set_draw_value (GTK_SCALE (hscale_contrast), FALSE);
2104
 
  gtk_scale_set_value_pos (GTK_SCALE (hscale_contrast), GTK_POS_RIGHT);
2105
 
  gtk_box_pack_start (GTK_BOX (hbox), hscale_contrast, TRUE, TRUE, 2);
2106
 
  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 3);
2107
 
 
2108
 
  gtk_widget_set_tooltip_text (hscale_contrast, _("Adjust contrast"));
2109
 
 
2110
 
  g_signal_connect (G_OBJECT (mw->adj_contrast), "value-changed",
2111
 
                    G_CALLBACK (video_settings_changed_cb), 
2112
 
                    (gpointer) main_window);
2113
 
  
2114
 
  gtk_container_add (GTK_CONTAINER (GTK_DIALOG (window)->vbox), 
2115
 
                     mw->video_settings_frame);
2116
 
  gtk_widget_show_all (mw->video_settings_frame);
2117
 
 
2118
 
  gtk_widget_set_sensitive (GTK_WIDGET (mw->video_settings_frame), FALSE);
2119
 
  
2120
 
  /* That's an usual GtkWindow, connect it to the signals */
2121
 
  g_signal_connect_swapped (GTK_OBJECT (window), 
2122
 
                            "response", 
2123
 
                            G_CALLBACK (gnomemeeting_window_hide),
2124
 
                            (gpointer) window);
2125
 
 
2126
 
  g_signal_connect (GTK_OBJECT (window), 
2127
 
                    "delete-event", 
2128
 
                    G_CALLBACK (delete_window_cb), NULL);
2129
 
 
2130
 
  return window;
2131
 
}
2132
 
 
2133
 
 
2134
 
 
2135
 
static GtkWidget * 
2136
 
gm_mw_audio_settings_window_new (GtkWidget *main_window)
2137
 
{
2138
 
  GmMainWindow *mw = NULL;
2139
 
  
2140
 
  GtkWidget *hscale_play = NULL; 
2141
 
  GtkWidget *hscale_rec = NULL;
2142
 
  GtkWidget *hbox = NULL;
2143
 
  GtkWidget *vbox = NULL;
2144
 
  GtkWidget *small_vbox = NULL;
2145
 
  GtkWidget *window = NULL;
2146
 
  
2147
 
 
2148
 
  /* Get the data from the GMObject */
2149
 
  g_return_val_if_fail (main_window != NULL, NULL);
2150
 
  mw = gm_mw_get_mw (main_window);
2151
 
  
2152
 
 
2153
 
  /* Build the window */
2154
 
  window = gtk_dialog_new ();
2155
 
  g_object_set_data_full (G_OBJECT (window), "window_name",
2156
 
                          g_strdup ("audio_settings_window"), g_free); 
2157
 
  gtk_dialog_add_button (GTK_DIALOG (window), 
2158
 
                         GTK_STOCK_CLOSE, 
2159
 
                         GTK_RESPONSE_CANCEL);
2160
 
 
2161
 
  gtk_window_set_title (GTK_WINDOW (window), 
2162
 
                        _("Audio Settings"));
2163
 
 
2164
 
  /* Audio control frame, we need it to disable controls */             
2165
 
  mw->audio_output_volume_frame = gtk_frame_new (NULL);
2166
 
  gtk_frame_set_shadow_type (GTK_FRAME (mw->audio_output_volume_frame), 
2167
 
                             GTK_SHADOW_NONE);
2168
 
  gtk_container_set_border_width (GTK_CONTAINER (mw->audio_output_volume_frame), 5);
2169
 
 
2170
 
 
2171
 
  /* The vbox */
2172
 
  vbox = gtk_vbox_new (0, FALSE);
2173
 
  gtk_container_add (GTK_CONTAINER (mw->audio_output_volume_frame), vbox);
2174
 
 
2175
 
  /* Output volume */
2176
 
  hbox = gtk_hbox_new (0, FALSE);
2177
 
  gtk_box_pack_start (GTK_BOX (hbox), 
2178
 
                      gtk_image_new_from_icon_name (GM_ICON_AUDIO_VOLUME_HIGH, 
2179
 
                                                    GTK_ICON_SIZE_SMALL_TOOLBAR),
2180
 
                      FALSE, FALSE, 0);
2181
 
  
2182
 
  small_vbox = gtk_vbox_new (0, FALSE);
2183
 
  mw->adj_output_volume = gtk_adjustment_new (0, 0.0, 101.0, 1.0, 5.0, 1.0);
2184
 
  hscale_play = gtk_hscale_new (GTK_ADJUSTMENT (mw->adj_output_volume));
2185
 
  gtk_range_set_update_policy (GTK_RANGE (hscale_play),
2186
 
                               GTK_UPDATE_DELAYED);
2187
 
  gtk_scale_set_value_pos (GTK_SCALE (hscale_play), GTK_POS_RIGHT); 
2188
 
  gtk_scale_set_draw_value (GTK_SCALE (hscale_play), FALSE);
2189
 
  gtk_box_pack_start (GTK_BOX (small_vbox), hscale_play, TRUE, TRUE, 0);
2190
 
 
2191
 
  mw->output_signal = gtk_levelmeter_new ();
2192
 
  gtk_box_pack_start (GTK_BOX (small_vbox), mw->output_signal, TRUE, TRUE, 0);
2193
 
  gtk_box_pack_start (GTK_BOX (hbox), small_vbox, TRUE, TRUE, 2);
2194
 
  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 3);
2195
 
 
2196
 
  gtk_container_add (GTK_CONTAINER (GTK_DIALOG (window)->vbox), 
2197
 
                     mw->audio_output_volume_frame);
2198
 
  gtk_widget_show_all (mw->audio_output_volume_frame);
2199
 
  gtk_widget_set_sensitive (GTK_WIDGET (mw->audio_output_volume_frame),  FALSE);
2200
 
 
2201
 
  /* Audio control frame, we need it to disable controls */             
2202
 
  mw->audio_input_volume_frame = gtk_frame_new (NULL);
2203
 
  gtk_frame_set_shadow_type (GTK_FRAME (mw->audio_input_volume_frame), 
2204
 
                             GTK_SHADOW_NONE);
2205
 
  gtk_container_set_border_width (GTK_CONTAINER (mw->audio_input_volume_frame), 5);
2206
 
 
2207
 
  /* The vbox */
2208
 
  vbox = gtk_vbox_new (0, FALSE);
2209
 
  gtk_container_add (GTK_CONTAINER (mw->audio_input_volume_frame), vbox);
2210
 
 
2211
 
  /* Input volume */
2212
 
  hbox = gtk_hbox_new (0, FALSE);
2213
 
  gtk_box_pack_start (GTK_BOX (hbox),
2214
 
                      gtk_image_new_from_icon_name (GM_ICON_MICROPHONE, 
2215
 
                                                    GTK_ICON_SIZE_SMALL_TOOLBAR),
2216
 
                      FALSE, FALSE, 0);
2217
 
 
2218
 
  small_vbox = gtk_vbox_new (0, FALSE);
2219
 
  mw->adj_input_volume = gtk_adjustment_new (0, 0.0, 101.0, 1.0, 5.0, 1.0);
2220
 
  hscale_rec = gtk_hscale_new (GTK_ADJUSTMENT (mw->adj_input_volume));
2221
 
  gtk_range_set_update_policy (GTK_RANGE (hscale_rec),
2222
 
                               GTK_UPDATE_DELAYED);
2223
 
  gtk_scale_set_value_pos (GTK_SCALE (hscale_rec), GTK_POS_RIGHT); 
2224
 
  gtk_scale_set_draw_value (GTK_SCALE (hscale_rec), FALSE);
2225
 
  gtk_box_pack_start (GTK_BOX (small_vbox), hscale_rec, TRUE, TRUE, 0);
2226
 
 
2227
 
  mw->input_signal = gtk_levelmeter_new ();
2228
 
  gtk_box_pack_start (GTK_BOX (small_vbox), mw->input_signal, TRUE, TRUE, 0);
2229
 
  gtk_box_pack_start (GTK_BOX (hbox), small_vbox, TRUE, TRUE, 2);
2230
 
  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 3);
2231
 
 
2232
 
  gtk_container_add (GTK_CONTAINER (GTK_DIALOG (window)->vbox), 
2233
 
                     mw->audio_input_volume_frame);
2234
 
  gtk_widget_show_all (mw->audio_input_volume_frame);
2235
 
  gtk_widget_set_sensitive (GTK_WIDGET (mw->audio_input_volume_frame),  FALSE);
2236
 
 
2237
 
  g_signal_connect (G_OBJECT (mw->adj_output_volume), "value-changed",
2238
 
                    G_CALLBACK (audio_volume_changed_cb), main_window);
2239
 
 
2240
 
  g_signal_connect (G_OBJECT (mw->adj_input_volume), "value-changed",
2241
 
                    G_CALLBACK (audio_volume_changed_cb), main_window);
2242
 
 
2243
 
 
2244
 
 
2245
 
  
2246
 
  /* That's an usual GtkWindow, connect it to the signals */
2247
 
  g_signal_connect_swapped (GTK_OBJECT (window), 
2248
 
                            "response", 
2249
 
                            G_CALLBACK (gnomemeeting_window_hide),
2250
 
                            (gpointer) window);
2251
 
 
2252
 
  g_signal_connect (GTK_OBJECT (window), 
2253
 
                    "delete-event", 
2254
 
                    G_CALLBACK (delete_window_cb), NULL);
2255
 
 
2256
 
  g_signal_connect (G_OBJECT (window), "show", 
2257
 
                    GTK_SIGNAL_FUNC (audio_volume_window_shown_cb), main_window);
2258
 
 
2259
 
  g_signal_connect (G_OBJECT (window), "hide", 
2260
 
                    GTK_SIGNAL_FUNC (audio_volume_window_hidden_cb), main_window);
2261
 
 
2262
 
  return window;
2263
 
}
2264
 
 
2265
 
 
2266
 
static void 
2267
 
gm_mw_init_call (GtkWidget *main_window)
2268
 
{
2269
 
  GmMainWindow *mw = NULL;
2270
 
 
2271
 
  GtkWidget *frame = NULL;
2272
 
  GtkWidget *event_box = NULL;
2273
 
  GtkWidget *table = NULL;
2274
 
 
2275
 
  GtkWidget *toolbar = NULL;
2276
 
  GtkToolItem *item = NULL;
2277
 
 
2278
 
  GtkWidget *image = NULL;
2279
 
  GtkWidget *alignment = NULL;
2280
 
 
2281
 
  GdkColor white;
2282
 
  gdk_color_parse ("white", &white);
2283
 
 
2284
 
  /* Get the data from the GMObject */
2285
 
  mw = gm_mw_get_mw (main_window);
2286
 
 
2287
 
  /* The main table */
2288
 
  frame = gtk_frame_new (NULL);
2289
 
  event_box = gtk_event_box_new ();
2290
 
  gtk_widget_modify_bg (event_box, GTK_STATE_PRELIGHT, &white);
2291
 
  gtk_widget_modify_bg (event_box, GTK_STATE_NORMAL, &white);
2292
 
  table = gtk_table_new (3, 4, FALSE);
2293
 
  gtk_container_add (GTK_CONTAINER (event_box), table);
2294
 
  gtk_container_add (GTK_CONTAINER (frame), event_box);
2295
 
 
2296
 
  /* The frame that contains the video */
2297
 
  mw->video_frame = gtk_frame_new (NULL);
2298
 
  gtk_frame_set_shadow_type (GTK_FRAME (mw->video_frame), 
2299
 
                             GTK_SHADOW_NONE);
2300
 
  
2301
 
  mw->main_video_image = gtk_image_new ();
2302
 
  gtk_container_set_border_width (GTK_CONTAINER (mw->video_frame), 0);
2303
 
  gtk_container_add (GTK_CONTAINER (mw->video_frame), mw->main_video_image);
2304
 
  gtk_table_attach (GTK_TABLE (table), GTK_WIDGET (mw->video_frame),       
2305
 
                    0, 4, 0, 1,         
2306
 
                    (GtkAttachOptions) GTK_EXPAND,      
2307
 
                    (GtkAttachOptions) GTK_EXPAND,      
2308
 
                    24, 24);
2309
 
 
2310
 
  /* The frame that contains information about the call */
2311
 
  /* Text buffer */
2312
 
  GtkTextBuffer *buffer = NULL;
2313
 
  
2314
 
  mw->info_text = gtk_text_view_new ();
2315
 
  gtk_widget_modify_bg (mw->info_text, GTK_STATE_PRELIGHT, &white);
2316
 
  gtk_widget_modify_bg (mw->info_text, GTK_STATE_NORMAL, &white);
2317
 
  gtk_widget_modify_bg (mw->info_text, GTK_STATE_INSENSITIVE, &white);
2318
 
 
2319
 
  gtk_text_view_set_editable (GTK_TEXT_VIEW (mw->info_text), FALSE);
2320
 
  gtk_widget_set_sensitive (GTK_WIDGET (mw->info_text), FALSE);
2321
 
  gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (mw->info_text),
2322
 
                               GTK_WRAP_WORD);
2323
 
 
2324
 
  buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (mw->info_text));
2325
 
  gtk_text_view_set_cursor_visible  (GTK_TEXT_VIEW (mw->info_text), FALSE);
2326
 
 
2327
 
  gtk_text_buffer_create_tag (buffer, "status",
2328
 
                              "foreground", "black", 
2329
 
                              "paragraph-background", "white",
2330
 
                              "justification", GTK_JUSTIFY_CENTER,
2331
 
                              "weight", PANGO_WEIGHT_BOLD,
2332
 
                              "scale", 1.2,
2333
 
                              NULL);
2334
 
  gtk_text_buffer_create_tag (buffer, "codecs",
2335
 
                              "justification", GTK_JUSTIFY_RIGHT,
2336
 
                              "stretch", PANGO_STRETCH_CONDENSED,
2337
 
                              "foreground", "darkgray", 
2338
 
                              "paragraph-background", "white",
2339
 
                              NULL);
2340
 
  gtk_text_buffer_create_tag (buffer, "call-duration",
2341
 
                              "foreground", "black", 
2342
 
                              "paragraph-background", "white",
2343
 
                              "justification", GTK_JUSTIFY_CENTER,
2344
 
                              "weight", PANGO_WEIGHT_BOLD,
2345
 
                              NULL);
2346
 
 
2347
 
  gm_main_window_set_status (main_window, _("Standby"));
2348
 
  gm_main_window_set_call_duration (main_window, NULL);
2349
 
  gm_main_window_set_call_info (main_window, NULL, NULL, NULL, NULL);
2350
 
 
2351
 
  alignment = gtk_alignment_new (0.0, 0.0, 1.0, 0.0);
2352
 
  gtk_container_add (GTK_CONTAINER (alignment), mw->info_text);
2353
 
  gtk_table_attach (GTK_TABLE (table), alignment,
2354
 
                    0, 4, 1, 2,         
2355
 
                    (GtkAttachOptions) (GTK_FILL | GTK_EXPAND),
2356
 
                    (GtkAttachOptions) (GTK_FILL | GTK_EXPAND),
2357
 
                    0, 0);
2358
 
  
2359
 
  /* The toolbar */
2360
 
  toolbar = gtk_toolbar_new ();
2361
 
  gtk_widget_modify_bg (toolbar, GTK_STATE_PRELIGHT, &white);
2362
 
  gtk_widget_modify_bg (toolbar, GTK_STATE_NORMAL, &white);
2363
 
  gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_ICONS);
2364
 
  gtk_toolbar_set_show_arrow (GTK_TOOLBAR (toolbar), FALSE);
2365
 
 
2366
 
  /* Audio Volume */
2367
 
  item = gtk_tool_item_new ();
2368
 
  mw->audio_settings_button = gtk_button_new ();
2369
 
  gtk_button_set_relief (GTK_BUTTON (mw->audio_settings_button), GTK_RELIEF_NONE);
2370
 
  image = gtk_image_new_from_icon_name (GM_ICON_AUDIO_VOLUME_HIGH,
2371
 
                                        GTK_ICON_SIZE_MENU);
2372
 
  gtk_container_add (GTK_CONTAINER (mw->audio_settings_button), image);
2373
 
  gtk_container_add (GTK_CONTAINER (item), mw->audio_settings_button);
2374
 
  gtk_tool_item_set_expand (GTK_TOOL_ITEM (item), FALSE);
2375
 
  
2376
 
  gtk_widget_show (mw->audio_settings_button);
2377
 
  gtk_widget_set_sensitive (mw->audio_settings_button, FALSE);
2378
 
  gtk_toolbar_insert (GTK_TOOLBAR (toolbar), 
2379
 
                      GTK_TOOL_ITEM (item), -1);
2380
 
  gtk_tool_item_set_tooltip_text (GTK_TOOL_ITEM (item),
2381
 
                                  _("Change the volume of your soundcard"));
2382
 
  g_signal_connect (G_OBJECT (mw->audio_settings_button), "clicked",
2383
 
                    G_CALLBACK (show_window_cb),
2384
 
                    (gpointer) mw->audio_settings_window);
2385
 
  
2386
 
  /* Video Settings */
2387
 
  item = gtk_tool_item_new ();
2388
 
  mw->video_settings_button = gtk_button_new ();
2389
 
  gtk_button_set_relief (GTK_BUTTON (mw->video_settings_button), GTK_RELIEF_NONE);
2390
 
  image = gtk_image_new_from_stock (GM_STOCK_COLOR_BRIGHTNESS_CONTRAST,
2391
 
                                    GTK_ICON_SIZE_MENU);
2392
 
  gtk_container_add (GTK_CONTAINER (mw->video_settings_button), image);
2393
 
  gtk_container_add (GTK_CONTAINER (item), mw->video_settings_button);
2394
 
  gtk_tool_item_set_expand (GTK_TOOL_ITEM (item), FALSE);
2395
 
  
2396
 
  gtk_widget_show (mw->video_settings_button);
2397
 
  gtk_widget_set_sensitive (mw->video_settings_button, FALSE);
2398
 
  gtk_toolbar_insert (GTK_TOOLBAR (toolbar), 
2399
 
                      GTK_TOOL_ITEM (item), -1);
2400
 
  gtk_tool_item_set_tooltip_text (GTK_TOOL_ITEM (item),
2401
 
                                   _("Change the color settings of your video device"));
2402
 
 
2403
 
  g_signal_connect (G_OBJECT (mw->video_settings_button), "clicked",
2404
 
                    G_CALLBACK (show_window_cb),
2405
 
                    (gpointer) mw->video_settings_window);
2406
 
 
2407
 
  /* Video Preview Button */
2408
 
  item = gtk_tool_item_new ();
2409
 
  mw->preview_button = gtk_toggle_button_new ();
2410
 
  gtk_button_set_relief (GTK_BUTTON (mw->preview_button), GTK_RELIEF_NONE);
2411
 
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (mw->preview_button),
2412
 
                                gm_conf_get_bool (VIDEO_DEVICES_KEY "enable_preview"));
2413
 
  image = gtk_image_new_from_icon_name (GM_ICON_CAMERA_VIDEO, 
2414
 
                                        GTK_ICON_SIZE_MENU);
2415
 
  gtk_container_add (GTK_CONTAINER (mw->preview_button), image);
2416
 
  gtk_container_add (GTK_CONTAINER (item), mw->preview_button);
2417
 
  gtk_tool_item_set_expand (GTK_TOOL_ITEM (item), FALSE);
2418
 
  
2419
 
  gtk_widget_show (mw->preview_button);
2420
 
  gtk_toolbar_insert (GTK_TOOLBAR (toolbar), 
2421
 
                      GTK_TOOL_ITEM (item), -1);
2422
 
  gtk_tool_item_set_tooltip_text (GTK_TOOL_ITEM (item),
2423
 
                                  _("Display images from your camera device"));
2424
 
 
2425
 
  g_signal_connect (G_OBJECT (mw->preview_button), "toggled",
2426
 
                    G_CALLBACK (toolbar_toggle_button_changed_cb),
2427
 
                    (gpointer) VIDEO_DEVICES_KEY "enable_preview");
2428
 
 
2429
 
  /* Call Pause */
2430
 
  item = gtk_tool_item_new ();
2431
 
  mw->hold_button = gtk_toggle_button_new ();
2432
 
  image = gtk_image_new_from_icon_name (GM_ICON_MEDIA_PLAYBACK_PAUSE,
2433
 
                                        GTK_ICON_SIZE_MENU);
2434
 
  gtk_button_set_relief (GTK_BUTTON (mw->hold_button), GTK_RELIEF_NONE);
2435
 
  gtk_container_add (GTK_CONTAINER (mw->hold_button), image);
2436
 
  gtk_container_add (GTK_CONTAINER (item), mw->hold_button);
2437
 
  gtk_tool_item_set_expand (GTK_TOOL_ITEM (item), FALSE);
2438
 
  
2439
 
  gtk_widget_show (mw->hold_button);
2440
 
  gtk_toolbar_insert (GTK_TOOLBAR (toolbar), 
2441
 
                      GTK_TOOL_ITEM (item), -1);
2442
 
  gtk_tool_item_set_tooltip_text (GTK_TOOL_ITEM (item),
2443
 
                                  _("Hold the current call"));
2444
 
  gtk_widget_set_sensitive (GTK_WIDGET (mw->hold_button), FALSE);
2445
 
 
2446
 
  g_signal_connect (G_OBJECT (mw->hold_button), "clicked",
2447
 
                    G_CALLBACK (hold_current_call_cb), main_window); 
2448
 
 
2449
 
  alignment = gtk_alignment_new (0.0, 0.0, 1.0, 0.0);
2450
 
  gtk_container_add (GTK_CONTAINER (alignment), toolbar);
2451
 
  gtk_table_attach (GTK_TABLE (table), alignment,
2452
 
                    1, 3, 2, 3,         
2453
 
                    (GtkAttachOptions) (GTK_FILL | GTK_EXPAND),
2454
 
                    (GtkAttachOptions) (GTK_FILL | GTK_EXPAND),
2455
 
                    0, 0);
2456
 
 
2457
 
  gtk_paned_pack2 (GTK_PANED (mw->hpaned), frame, true, false);
2458
 
}  
2459
 
 
2460
 
static void
2461
 
gm_mw_init_history (GtkWidget *main_window)
2462
 
{
2463
 
  GmMainWindow *mw = NULL;
2464
 
  Ekiga::ServiceCore *services = NULL;
2465
 
  GtkWidget *label = NULL;
2466
 
  GtkFrontend *gtk_frontend = NULL;
2467
 
 
2468
 
  g_return_if_fail (main_window != NULL);
2469
 
  mw = gm_mw_get_mw (main_window);
2470
 
 
2471
 
  services = GnomeMeeting::Process ()->GetServiceCore ();
2472
 
  g_return_if_fail (services != NULL);
2473
 
 
2474
 
  gtk_frontend = dynamic_cast<GtkFrontend *>(services->get ("gtk-frontend"));
2475
 
 
2476
 
  label = gtk_label_new (_("Call history"));
2477
 
  gtk_notebook_append_page (GTK_NOTEBOOK (mw->main_notebook),
2478
 
                            GTK_WIDGET (gtk_frontend->get_call_history_view ()),
2479
 
                            label);
2480
 
}
2481
 
 
2482
 
void
2483
 
gm_mw_zooms_menu_update_sensitivity (GtkWidget *main_window,
2484
 
                                     unsigned int zoom)
2485
 
{
2486
 
  GmMainWindow *mw = NULL;
2487
 
 
2488
 
  mw = gm_mw_get_mw (main_window);
2489
 
 
2490
 
  g_return_if_fail (mw != NULL);
2491
 
 
2492
 
  /* between 0.5 and 2.0 zoom */
2493
 
  /* like above, also update the popup menus of the separate video windows */
2494
 
  gtk_menu_set_sensitive (mw->main_menu, "zoom_in",
2495
 
                          (zoom == 200) ? FALSE : TRUE);
2496
 
 
2497
 
  gtk_menu_set_sensitive (mw->main_menu, "zoom_out",
2498
 
                          (zoom == 50) ? FALSE : TRUE);
2499
 
 
2500
 
  gtk_menu_set_sensitive (mw->main_menu, "normal_size",
2501
 
                          (zoom == 100) ? FALSE : TRUE);
2502
 
}
2503
 
 
2504
 
 
2505
 
/* GTK callbacks */
2506
 
static gint
2507
 
gnomemeeting_tray_hack_cb (G_GNUC_UNUSED gpointer data)
2508
 
{
2509
 
  GtkWidget *main_window = NULL;
2510
 
  GtkStatusIcon *statusicon = NULL;
2511
 
 
2512
 
  statusicon = GTK_STATUS_ICON (GnomeMeeting::Process ()->GetStatusicon ());
2513
 
  main_window = GnomeMeeting::Process ()->GetMainWindow ();
2514
 
  
2515
 
  //gdk_threads_enter ();
2516
 
 
2517
 
  if (!gtk_status_icon_is_embedded (GTK_STATUS_ICON (statusicon))) 
2518
 
    gtk_widget_show (main_window);
2519
 
  
2520
 
  //gdk_threads_leave ();
2521
 
 
2522
 
  return FALSE;
2523
 
}
2524
 
 
2525
 
 
2526
 
static void
2527
 
on_presentity_selected (G_GNUC_UNUSED GtkWidget* view,
2528
 
                        Ekiga::Presentity* presentity,
2529
 
                        gpointer self)
2530
 
{
2531
 
  GmMainWindow *mw = gm_mw_get_mw (GTK_WIDGET (self));
2532
 
 
2533
 
  g_return_if_fail (mw != NULL);
2534
 
 
2535
 
  mw->presentity = presentity;
2536
 
 
2537
 
  gm_main_window_selected_presentity_build_menu (GTK_WIDGET (self));
2538
 
}
2539
 
 
2540
 
 
2541
 
static void
2542
 
on_chat_unread_alert (G_GNUC_UNUSED GtkWidget* widget,
2543
 
                      G_GNUC_UNUSED gpointer data)
2544
 
{
2545
 
  if (!gm_conf_get_bool (SOUND_EVENTS_KEY "enable_new_message_sound"))
2546
 
    return;
2547
 
 
2548
 
  Ekiga::ServiceCore *core = GnomeMeeting::Process ()->GetServiceCore ();
2549
 
  Ekiga::AudioOutputCore *audiooutput_core = dynamic_cast<Ekiga::AudioOutputCore *> (core->get ("audiooutput-core"));
2550
 
 
2551
 
  std::string file_name_string = gm_conf_get_string (SOUND_EVENTS_KEY "new_message_sound");
2552
 
 
2553
 
  if (!file_name_string.empty ())
2554
 
    audiooutput_core->play_file(file_name_string);
2555
 
}
2556
 
 
2557
 
 
2558
 
static void 
2559
 
panel_section_changed_nt (G_GNUC_UNUSED gpointer id, 
2560
 
                          GmConfEntry *entry, 
2561
 
                          gpointer data)
2562
 
{
2563
 
  gint section = 0;
2564
 
 
2565
 
  g_return_if_fail (data != NULL);
2566
 
  
2567
 
  if (gm_conf_entry_get_type (entry) == GM_CONF_INT) {
2568
 
 
2569
 
    //gdk_threads_enter ();
2570
 
    section = gm_conf_entry_get_int (entry);
2571
 
    gm_main_window_set_panel_section (GTK_WIDGET (data), 
2572
 
                                      section);
2573
 
    //gdk_threads_leave ();
2574
 
  }
2575
 
}
2576
 
 
2577
 
 
2578
 
static void 
2579
 
show_call_panel_changed_nt (G_GNUC_UNUSED gpointer id, 
2580
 
                            GmConfEntry *entry, 
2581
 
                            gpointer data)
2582
 
{
2583
 
  g_return_if_fail (data != NULL);
2584
 
 
2585
 
  if (gm_conf_entry_get_type (entry) == GM_CONF_BOOL) {
2586
 
 
2587
 
    //gdk_threads_enter ();
2588
 
    if (gm_conf_entry_get_bool (entry)) 
2589
 
      gm_main_window_show_call_panel (GTK_WIDGET (data));
2590
 
    else 
2591
 
      gm_main_window_hide_call_panel (GTK_WIDGET (data));
2592
 
 
2593
 
    //gdk_threads_leave ();
2594
 
  }
2595
 
}
2596
 
 
2597
 
 
2598
 
static void 
2599
 
pull_trigger_cb (GtkWidget * /*widget*/,
2600
 
                 gpointer data)
2601
 
{
2602
 
  Ekiga::Trigger *trigger = (Ekiga::Trigger *) data;
2603
 
 
2604
 
  g_return_if_fail (trigger != NULL);
2605
 
 
2606
 
  trigger->pull ();
2607
 
}
2608
 
 
2609
 
 
2610
 
static void 
2611
 
show_widget_cb (GtkWidget * /*widget*/,
2612
 
                gpointer data)
2613
 
{
2614
 
  g_return_if_fail (data != NULL);
2615
 
 
2616
 
  gtk_widget_show_all (GTK_WIDGET (data));
2617
 
}
2618
 
 
2619
 
 
2620
 
static void 
2621
 
hold_current_call_cb (G_GNUC_UNUSED GtkWidget *widget,
2622
 
                      gpointer data)
2623
 
{
2624
 
  GmMainWindow *mw = NULL;
2625
 
 
2626
 
  mw = gm_mw_get_mw (GTK_WIDGET (data));
2627
 
 
2628
 
  if (mw->current_call) {
2629
 
    mw->current_call->toggle_hold ();
2630
 
  }
2631
 
}
2632
 
 
2633
 
 
2634
 
static void
2635
 
toggle_audio_stream_pause_cb (GtkWidget * /*widget*/,
2636
 
                              gpointer data)
2637
 
{
2638
 
  GmMainWindow *mw = NULL;
2639
 
 
2640
 
  mw = gm_mw_get_mw (GTK_WIDGET (data));
2641
 
 
2642
 
  if (mw->current_call)
2643
 
    mw->current_call->toggle_stream_pause (Ekiga::Call::Audio);
2644
 
}
2645
 
 
2646
 
 
2647
 
static void
2648
 
toggle_video_stream_pause_cb (GtkWidget * /*widget*/,
2649
 
                              gpointer data)
2650
 
{
2651
 
  GmMainWindow *mw = NULL;
2652
 
 
2653
 
  mw = gm_mw_get_mw (GTK_WIDGET (data));
2654
 
 
2655
 
  if (mw->current_call)
2656
 
    mw->current_call->toggle_stream_pause (Ekiga::Call::Video);
2657
 
}
2658
 
 
2659
 
 
2660
 
 
2661
 
static void 
2662
 
transfer_current_call_cb (G_GNUC_UNUSED GtkWidget *widget,
2663
 
                          gpointer data)
2664
 
{
2665
 
  GtkWidget *main_window = NULL;
2666
 
  
2667
 
  g_return_if_fail (data != NULL);
2668
 
  
2669
 
  main_window = GnomeMeeting::Process ()->GetMainWindow ();
2670
 
 
2671
 
  gm_main_window_transfer_dialog_run (main_window, GTK_WIDGET (data), NULL);  
2672
 
}
2673
 
 
2674
 
 
2675
 
static gboolean 
2676
 
video_window_expose_cb (GtkWidget *main_window,
2677
 
                        G_GNUC_UNUSED GdkEventExpose *event,
2678
 
                        G_GNUC_UNUSED gpointer data)
2679
 
{
2680
 
  GmMainWindow *mw = NULL;
2681
 
 
2682
 
  if (!main_window) 
2683
 
    return FALSE;
2684
 
 
2685
 
  mw = gm_mw_get_mw (main_window);
2686
 
  if (!mw)
2687
 
    return FALSE;
2688
 
 
2689
 
  GtkWidget* videoWidget = mw->main_video_image;
2690
 
  if (!GTK_WIDGET_REALIZED(videoWidget))
2691
 
    return FALSE;
2692
 
 
2693
 
  if (!GDK_IS_WINDOW(mw->main_video_image->window))
2694
 
    return FALSE;
2695
 
 
2696
 
  Ekiga::DisplayInfo display_info;
2697
 
  display_info.x = mw->main_video_image->allocation.x;
2698
 
  display_info.y = mw->main_video_image->allocation.y;
2699
 
#ifdef WIN32  
2700
 
  display_info.hwnd = ((HWND)GDK_WINDOW_HWND (mw->main_video_image->window));
2701
 
#else 
2702
 
  if (!mw->video_widget_gc) { 
2703
 
    mw->video_widget_gc = gdk_gc_new(mw->main_video_image->window);
2704
 
    if ( mw->video_widget_gc == NULL)
2705
 
      return FALSE;
2706
 
 
2707
 
  }
2708
 
 
2709
 
  if (GDK_GC_XGC(mw->video_widget_gc) == NULL)
2710
 
    return FALSE;
2711
 
 
2712
 
  display_info.gc = GDK_GC_XGC(mw->video_widget_gc);
2713
 
  display_info.xdisplay = GDK_GC_XDISPLAY (mw->video_widget_gc);
2714
 
 
2715
 
  display_info.window = GDK_WINDOW_XWINDOW (mw->main_video_image->window);
2716
 
  if (display_info.window == 0)  //FIXME: Should be None
2717
 
    return FALSE;
2718
 
 
2719
 
  gdk_flush();
2720
 
#endif
2721
 
  display_info.widget_info_set = TRUE;
2722
 
 
2723
 
  Ekiga::VideoOutputCore *videooutput_core = dynamic_cast<Ekiga::VideoOutputCore *> (mw->core.get ("videooutput-core"));
2724
 
  videooutput_core->set_display_info(display_info);
2725
 
 
2726
 
  return FALSE;
2727
 
}
2728
 
 
2729
 
static void
2730
 
video_window_shown_cb (GtkWidget *w,
2731
 
                       gpointer data)
2732
 
{
2733
 
  GmMainWindow *mw = NULL;
2734
 
 
2735
 
  mw = gm_mw_get_mw (GTK_WIDGET (data));
2736
 
 
2737
 
  if (gm_conf_get_bool (VIDEO_DISPLAY_KEY "stay_on_top")
2738
 
      && mw->current_call)
2739
 
    gdk_window_set_always_on_top (GDK_WINDOW (w->window), TRUE);
2740
 
}
2741
 
 
2742
 
 
2743
 
static void 
2744
 
audio_volume_changed_cb (GtkAdjustment * /*adjustment*/,
2745
 
                         gpointer data)
2746
 
{
2747
 
  GmMainWindow *mw = NULL;
2748
 
  g_return_if_fail (data != NULL);
2749
 
  mw = gm_mw_get_mw (GTK_WIDGET (data));
2750
 
 
2751
 
  Ekiga::AudioInputCore *audioinput_core = dynamic_cast<Ekiga::AudioInputCore *> (mw->core.get ("audioinput-core"));
2752
 
  Ekiga::AudioOutputCore *audiooutput_core = dynamic_cast<Ekiga::AudioOutputCore *> (mw->core.get ("audiooutput-core"));
2753
 
 
2754
 
  audiooutput_core->set_volume(Ekiga::primary, (unsigned)GTK_ADJUSTMENT (mw->adj_output_volume)->value);
2755
 
  audioinput_core->set_volume((unsigned)GTK_ADJUSTMENT (mw->adj_input_volume)->value);
2756
 
}
2757
 
 
2758
 
static void 
2759
 
audio_volume_window_shown_cb (GtkWidget * /*widget*/,
2760
 
                              gpointer data)
2761
 
{
2762
 
  GmMainWindow *mw = NULL;
2763
 
  g_return_if_fail (data != NULL);
2764
 
  mw = gm_mw_get_mw (GTK_WIDGET (data));
2765
 
 
2766
 
  Ekiga::AudioInputCore *audioinput_core = dynamic_cast<Ekiga::AudioInputCore *> (mw->core.get ("audioinput-core"));
2767
 
  Ekiga::AudioOutputCore *audiooutput_core = dynamic_cast<Ekiga::AudioOutputCore *> (mw->core.get ("audiooutput-core"));
2768
 
 
2769
 
  audioinput_core->set_average_collection(true);
2770
 
  audiooutput_core->set_average_collection(true);
2771
 
  mw->levelmeter_timeout_id = g_timeout_add_full (G_PRIORITY_DEFAULT_IDLE, 50, on_signal_level_refresh_cb, data, NULL);
2772
 
}
2773
 
 
2774
 
 
2775
 
static void 
2776
 
audio_volume_window_hidden_cb (GtkWidget * /*widget*/,
2777
 
                               gpointer data)
2778
 
{
2779
 
  GmMainWindow *mw = NULL;
2780
 
  g_return_if_fail (data != NULL);
2781
 
  mw = gm_mw_get_mw (GTK_WIDGET (data));
2782
 
 
2783
 
  Ekiga::AudioInputCore *audioinput_core = dynamic_cast<Ekiga::AudioInputCore *> (mw->core.get ("audioinput-core"));
2784
 
  Ekiga::AudioOutputCore *audiooutput_core = dynamic_cast<Ekiga::AudioOutputCore *> (mw->core.get ("audiooutput-core"));
2785
 
 
2786
 
  g_source_remove (mw->levelmeter_timeout_id);
2787
 
  audioinput_core->set_average_collection(false);
2788
 
  audiooutput_core->set_average_collection(false);
2789
 
}
2790
 
 
2791
 
static void 
2792
 
video_settings_changed_cb (GtkAdjustment * /*adjustment*/,
2793
 
                           gpointer data)
2794
 
2795
 
  GmMainWindow *mw = NULL;
2796
 
  g_return_if_fail (data != NULL);
2797
 
  mw = gm_mw_get_mw (GTK_WIDGET (data));
2798
 
  g_return_if_fail (mw != NULL);
2799
 
 
2800
 
  Ekiga::VideoInputCore *videoinput_core = dynamic_cast<Ekiga::VideoInputCore *> (mw->core.get ("videoinput-core"));
2801
 
 
2802
 
  videoinput_core->set_whiteness ((unsigned) GTK_ADJUSTMENT (mw->adj_whiteness)->value);
2803
 
  videoinput_core->set_brightness ((unsigned) GTK_ADJUSTMENT (mw->adj_brightness)->value);
2804
 
  videoinput_core->set_colour ((unsigned) GTK_ADJUSTMENT (mw->adj_colour)->value);
2805
 
  videoinput_core->set_contrast ((unsigned) GTK_ADJUSTMENT (mw->adj_contrast)->value);
2806
 
}
2807
 
 
2808
 
 
2809
 
static void 
2810
 
panel_section_changed_cb (G_GNUC_UNUSED GtkNotebook *notebook,
2811
 
                          G_GNUC_UNUSED GtkNotebookPage *page,
2812
 
                          G_GNUC_UNUSED gint page_num,
2813
 
                          gpointer data) 
2814
 
{
2815
 
  GmMainWindow *mw = NULL;
2816
 
 
2817
 
  gint current_page = 0;
2818
 
 
2819
 
  g_return_if_fail (data != NULL);
2820
 
  mw = gm_mw_get_mw (GTK_WIDGET (data));
2821
 
 
2822
 
  current_page = 
2823
 
    gtk_notebook_get_current_page (GTK_NOTEBOOK (mw->main_notebook));
2824
 
  gm_conf_set_int (USER_INTERFACE_KEY "main_window/panel_section",
2825
 
                   current_page);
2826
 
}
2827
 
 
2828
 
 
2829
 
static void
2830
 
dialpad_button_clicked_cb (EkigaDialpad  * /* dialpad */,
2831
 
                           const gchar *button_text,
2832
 
                           GtkWidget   *main_window)
2833
 
{
2834
 
  GmMainWindow *mw = NULL;
2835
 
 
2836
 
  mw = gm_mw_get_mw (main_window);
2837
 
 
2838
 
  if (mw->current_call)
2839
 
    mw->current_call->send_dtmf (button_text[0]);
2840
 
  else
2841
 
    gm_main_window_append_call_url (main_window, button_text);
2842
 
}
2843
 
 
2844
 
 
2845
 
static gint 
2846
 
window_closed_cb (G_GNUC_UNUSED GtkWidget *widget,
2847
 
                  G_GNUC_UNUSED GdkEvent *event,
2848
 
                  gpointer data)
2849
 
{
2850
 
  GtkStatusIcon *statusicon = NULL;
2851
 
  GtkWidget *main_window = NULL;
2852
 
 
2853
 
  GmMainWindow *mw = NULL;
2854
 
 
2855
 
  main_window = GnomeMeeting::Process ()->GetMainWindow ();
2856
 
  statusicon = GTK_STATUS_ICON (GnomeMeeting::Process ()->GetStatusicon ());
2857
 
  mw = gm_mw_get_mw (GTK_WIDGET (main_window));
2858
 
 
2859
 
  /* Hide in any case, but quit program when we don't have a status menu */
2860
 
  gtk_widget_hide (GTK_WIDGET (data));
2861
 
  if (!gtk_status_icon_is_embedded (GTK_STATUS_ICON (statusicon)))
2862
 
    quit_callback (NULL, data);
2863
 
 
2864
 
  return (TRUE);
2865
 
}
2866
 
 
2867
 
 
2868
 
static void
2869
 
window_closed_from_menu_cb (GtkWidget *widget,
2870
 
                           gpointer data)
2871
 
{
2872
 
window_closed_cb (widget, NULL, data);
2873
 
}
2874
 
 
2875
 
 
2876
 
static void 
2877
 
zoom_in_changed_cb (G_GNUC_UNUSED GtkWidget *widget,
2878
 
                    gpointer data)
2879
 
{
2880
 
  GtkWidget *main_window = GnomeMeeting::Process ()->GetMainWindow ();
2881
 
  g_return_if_fail (main_window != NULL);
2882
 
 
2883
 
  GmMainWindow *mw = gm_mw_get_mw (main_window);
2884
 
  g_return_if_fail (mw != NULL);
2885
 
 
2886
 
  g_return_if_fail (data != NULL);
2887
 
 
2888
 
  Ekiga::DisplayInfo display_info;
2889
 
 
2890
 
  display_info.zoom = gm_conf_get_int ((char *) data);
2891
 
 
2892
 
  if (display_info.zoom < 200)
2893
 
    display_info.zoom = display_info.zoom * 2;
2894
 
 
2895
 
  gm_conf_set_int ((char *) data, display_info.zoom);
2896
 
  gm_mw_zooms_menu_update_sensitivity (main_window, display_info.zoom);
2897
 
}
2898
 
 
2899
 
 
2900
 
static void 
2901
 
zoom_out_changed_cb (G_GNUC_UNUSED GtkWidget *widget,
2902
 
                     gpointer data)
2903
 
{
2904
 
  GtkWidget *main_window = GnomeMeeting::Process ()->GetMainWindow ();
2905
 
  g_return_if_fail (main_window != NULL);
2906
 
 
2907
 
  GmMainWindow *mw = gm_mw_get_mw (main_window);
2908
 
  g_return_if_fail (mw != NULL);
2909
 
 
2910
 
  g_return_if_fail (data != NULL);
2911
 
 
2912
 
  Ekiga::DisplayInfo display_info;
2913
 
 
2914
 
  display_info.zoom = gm_conf_get_int ((char *) data);
2915
 
 
2916
 
  if (display_info.zoom  > 50)
2917
 
    display_info.zoom  = (unsigned int) (display_info.zoom  / 2);
2918
 
 
2919
 
  gm_conf_set_int ((char *) data, display_info.zoom);
2920
 
  gm_mw_zooms_menu_update_sensitivity (main_window, display_info.zoom);
2921
 
}
2922
 
 
2923
 
 
2924
 
static void 
2925
 
zoom_normal_changed_cb (G_GNUC_UNUSED GtkWidget *widget,
2926
 
                        gpointer data)
2927
 
{
2928
 
  GtkWidget *main_window = GnomeMeeting::Process ()->GetMainWindow ();
2929
 
  g_return_if_fail (main_window != NULL);
2930
 
 
2931
 
  GmMainWindow *mw = gm_mw_get_mw (main_window);
2932
 
  g_return_if_fail (mw != NULL);
2933
 
 
2934
 
  g_return_if_fail (data != NULL);
2935
 
 
2936
 
  Ekiga::DisplayInfo display_info;
2937
 
 
2938
 
  display_info.zoom  = 100;
2939
 
 
2940
 
  gm_conf_set_int ((char *) data, display_info.zoom);
2941
 
  gm_mw_zooms_menu_update_sensitivity (main_window, display_info.zoom);
2942
 
}
2943
 
 
2944
 
 
2945
 
void 
2946
 
display_changed_cb (GtkWidget *widget,
2947
 
                       gpointer data)
2948
 
{
2949
 
  GtkWidget *main_window = GnomeMeeting::Process ()->GetMainWindow ();
2950
 
  g_return_if_fail (main_window != NULL);
2951
 
 
2952
 
  GmMainWindow *mw = gm_mw_get_mw (main_window);
2953
 
  g_return_if_fail (mw != NULL);
2954
 
 
2955
 
  g_return_if_fail (data != NULL);
2956
 
 
2957
 
  GSList *group = NULL;
2958
 
  int group_last_pos = 0;
2959
 
  int active = 0;
2960
 
  Ekiga::DisplayInfo display_info;
2961
 
 
2962
 
  group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (widget));
2963
 
  group_last_pos = g_slist_length (group) - 1; /* If length 1, last pos is 0 */
2964
 
 
2965
 
  /* Only do something when a new CHECK_MENU_ITEM becomes active,
2966
 
     not when it becomes inactive */
2967
 
  if (GTK_CHECK_MENU_ITEM (widget)->active) {
2968
 
 
2969
 
    while (group) {
2970
 
 
2971
 
      if (group->data == widget) 
2972
 
        break;
2973
 
      
2974
 
      active++;
2975
 
      group = g_slist_next (group);
2976
 
    }
2977
 
 
2978
 
    gm_conf_set_int ((gchar *) data, group_last_pos - active);
2979
 
  }
2980
 
}
2981
 
 
2982
 
 
2983
 
static void 
2984
 
fullscreen_changed_cb (G_GNUC_UNUSED GtkWidget *widget,
2985
 
                       G_GNUC_UNUSED gpointer data)
2986
 
{
2987
 
  GtkWidget* main_window = GnomeMeeting::Process()->GetMainWindow ();
2988
 
  g_return_if_fail (main_window != NULL);
2989
 
  gm_main_window_toggle_fullscreen (Ekiga::VO_FS_TOGGLE, main_window);
2990
 
}
2991
 
 
2992
 
 
2993
 
static void
2994
 
url_changed_cb (GtkEditable  *e,
2995
 
                gpointer data)
2996
 
{
2997
 
  GmMainWindow *mw = NULL;
2998
 
 
2999
 
  GtkTreeIter iter;
3000
 
  const char *tip_text = NULL;
3001
 
  gchar *entry = NULL;
3002
 
 
3003
 
  g_return_if_fail (data != NULL);
3004
 
  mw = gm_mw_get_mw (GTK_WIDGET (data));
3005
 
 
3006
 
  tip_text = gtk_entry_get_text (GTK_ENTRY (e));
3007
 
 
3008
 
  if (g_strrstr (tip_text, "@") == NULL) {
3009
 
 
3010
 
    gtk_list_store_clear (mw->completion);
3011
 
 
3012
 
    for (std::list<std::string>::iterator it = mw->accounts.begin ();
3013
 
         it != mw->accounts.end ();
3014
 
         it++) {
3015
 
 
3016
 
      entry = g_strdup_printf ("%s@%s", tip_text, it->c_str ());
3017
 
      gtk_list_store_append (mw->completion, &iter);
3018
 
      gtk_list_store_set (mw->completion, &iter, 0, entry, -1);
3019
 
      g_free (entry);
3020
 
    }
3021
 
  }
3022
 
 
3023
 
  gtk_widget_set_tooltip_text (GTK_WIDGET (e), tip_text);
3024
 
}
3025
 
 
3026
 
 
3027
 
static void 
3028
 
toolbar_toggle_button_changed_cb (G_GNUC_UNUSED GtkWidget *widget,
3029
 
                                  gpointer data)
3030
 
{
3031
 
  bool shown = gm_conf_get_bool ((gchar *) data);
3032
 
 
3033
 
  gm_conf_set_bool ((gchar *) data, !shown);
3034
 
}
3035
 
 
3036
 
 
3037
 
static gboolean 
3038
 
statusbar_clicked_cb (G_GNUC_UNUSED GtkWidget *widget,
3039
 
                      G_GNUC_UNUSED GdkEventButton *event,
3040
 
                      gpointer data)
3041
 
{
3042
 
  GmMainWindow *mw = NULL;
3043
 
 
3044
 
  g_return_val_if_fail (data != NULL, TRUE);
3045
 
 
3046
 
  mw = gm_mw_get_mw (GTK_WIDGET (data));
3047
 
 
3048
 
  g_return_val_if_fail (GTK_WIDGET (data), TRUE);
3049
 
 
3050
 
  gm_main_window_push_message (GTK_WIDGET (data), NULL);
3051
 
 
3052
 
  return FALSE;
3053
 
}
3054
 
 
3055
 
 
3056
 
static gboolean
3057
 
main_window_focus_event_cb (GtkWidget *main_window,
3058
 
                            G_GNUC_UNUSED GdkEventFocus *event,
3059
 
                            G_GNUC_UNUSED gpointer user_data)
3060
 
{
3061
 
  if (gtk_window_get_urgency_hint (GTK_WINDOW (main_window)))
3062
 
      gtk_window_set_urgency_hint (GTK_WINDOW (main_window), FALSE);
3063
 
 
3064
 
  return FALSE;
3065
 
}
3066
 
 
3067
 
 
3068
 
/* Public functions */
3069
 
void 
3070
 
gm_main_window_press_dialpad (GtkWidget *main_window,
3071
 
                              const char c)
3072
 
{
3073
 
  guint key = 0;
3074
 
 
3075
 
  if (c == '*')
3076
 
    key = GDK_KP_Multiply;
3077
 
  else if (c == '#')
3078
 
    key = GDK_numbersign;
3079
 
  else
3080
 
    key = GDK_KP_0 + atoi (&c);
3081
 
 
3082
 
  gtk_accel_groups_activate (G_OBJECT (main_window), key, (GdkModifierType) 0);
3083
 
}
3084
 
 
3085
 
 
3086
 
GtkWidget*
3087
 
gm_main_window_get_video_widget (GtkWidget *main_window)
3088
 
{
3089
 
  GmMainWindow *mw = NULL;
3090
 
  
3091
 
  g_return_val_if_fail (main_window != NULL, NULL);
3092
 
  mw = gm_mw_get_mw (main_window);
3093
 
  g_return_val_if_fail (mw != NULL, NULL);
3094
 
 
3095
 
  return mw->main_video_image;
3096
 
}
3097
 
 
3098
 
 
3099
 
void 
3100
 
gm_main_window_update_logo_have_window (GtkWidget *main_window)
3101
 
{
3102
 
  GmMainWindow *mw = NULL;
3103
 
 
3104
 
  g_return_if_fail (main_window != NULL);
3105
 
 
3106
 
  mw = gm_mw_get_mw (main_window);
3107
 
  g_return_if_fail (mw != NULL);
3108
 
 
3109
 
  g_object_set (G_OBJECT (mw->main_video_image),
3110
 
                "icon-name", GM_ICON_LOGO,
3111
 
                "pixel-size", 72,
3112
 
                NULL);
3113
 
  
3114
 
  gtk_widget_set_size_request (GTK_WIDGET (mw->main_video_image),
3115
 
                               GM_QCIF_WIDTH, GM_QCIF_HEIGHT);
3116
 
 
3117
 
  GdkRectangle rect;
3118
 
  rect.x = mw->main_video_image->allocation.x;
3119
 
  rect.y = mw->main_video_image->allocation.y;
3120
 
  rect.width = mw->main_video_image->allocation.width;
3121
 
  rect.height = mw->main_video_image->allocation.height;
3122
 
 
3123
 
  gdk_window_invalidate_rect (GDK_WINDOW (main_window->window), &rect , TRUE);
3124
 
}
3125
 
 
3126
 
 
3127
 
void 
3128
 
gm_main_window_set_call_hold (GtkWidget *main_window,
3129
 
                              bool is_on_hold)
3130
 
{
3131
 
  GmMainWindow *mw = NULL;
3132
 
  
3133
 
  GtkWidget *child = NULL;
3134
 
  
3135
 
  
3136
 
  g_return_if_fail (main_window != NULL);
3137
 
  
3138
 
  mw = gm_mw_get_mw (main_window);
3139
 
  
3140
 
  g_return_if_fail (mw != NULL);
3141
 
  
3142
 
  
3143
 
  child = GTK_BIN (gtk_menu_get_widget (mw->main_menu, "hold_call"))->child;
3144
 
 
3145
 
  if (is_on_hold) {
3146
 
 
3147
 
    if (GTK_IS_LABEL (child))
3148
 
      gtk_label_set_text_with_mnemonic (GTK_LABEL (child),
3149
 
                                        _("_Retrieve Call"));
3150
 
 
3151
 
    /* Set the audio and video menu to unsensitive */
3152
 
    gtk_menu_set_sensitive (mw->main_menu, "suspend_audio", FALSE);
3153
 
    gtk_menu_set_sensitive (mw->main_menu, "suspend_video", FALSE);
3154
 
    
3155
 
    gm_main_window_set_channel_pause (main_window, TRUE, FALSE);
3156
 
    gm_main_window_set_channel_pause (main_window, TRUE, TRUE);
3157
 
  }
3158
 
  else {
3159
 
 
3160
 
    if (GTK_IS_LABEL (child))
3161
 
      gtk_label_set_text_with_mnemonic (GTK_LABEL (child),
3162
 
                                        _("_Hold Call"));
3163
 
 
3164
 
    gtk_menu_set_sensitive (mw->main_menu, "suspend_audio", TRUE);
3165
 
    gtk_menu_set_sensitive (mw->main_menu, "suspend_video", TRUE);
3166
 
 
3167
 
    gm_main_window_set_channel_pause (main_window, FALSE, FALSE);
3168
 
    gm_main_window_set_channel_pause (main_window, FALSE, TRUE);
3169
 
  }
3170
 
  
3171
 
  g_signal_handlers_block_by_func (G_OBJECT (mw->hold_button),
3172
 
                                   (gpointer) hold_current_call_cb,
3173
 
                                   main_window);
3174
 
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (mw->hold_button), 
3175
 
                                is_on_hold);
3176
 
  g_signal_handlers_unblock_by_func (G_OBJECT (mw->hold_button),
3177
 
                                     (gpointer) hold_current_call_cb,
3178
 
                                     main_window);
3179
 
}
3180
 
 
3181
 
 
3182
 
void 
3183
 
gm_main_window_set_channel_pause (GtkWidget *main_window,
3184
 
                                  gboolean pause,
3185
 
                                  gboolean is_video)
3186
 
{
3187
 
  GmMainWindow *mw = NULL;
3188
 
  
3189
 
  GtkWidget *child = NULL;
3190
 
 
3191
 
  gchar *msg = NULL;
3192
 
  
3193
 
  g_return_if_fail (main_window != NULL);
3194
 
  
3195
 
  mw = gm_mw_get_mw (main_window);
3196
 
  
3197
 
  g_return_if_fail (mw != NULL);
3198
 
  
3199
 
 
3200
 
  if (!pause && !is_video)
3201
 
    msg = g_strdup (_("Suspend _Audio"));
3202
 
  else if (!pause && is_video)
3203
 
    msg = g_strdup (_("Suspend _Video"));
3204
 
  else if (pause && !is_video)
3205
 
    msg = g_strdup (_("Resume _Audio"));
3206
 
  else if (pause && is_video)
3207
 
    msg = g_strdup (_("Resume _Video"));
3208
 
 
3209
 
  
3210
 
  if (is_video) {
3211
 
    
3212
 
    child =
3213
 
      GTK_BIN (gtk_menu_get_widget (mw->main_menu, "suspend_video"))->child;
3214
 
  }
3215
 
  else {
3216
 
    
3217
 
    child =
3218
 
      GTK_BIN (gtk_menu_get_widget (mw->main_menu, "suspend_audio"))->child;
3219
 
  }
3220
 
        
3221
 
 
3222
 
  if (GTK_IS_LABEL (child)) 
3223
 
    gtk_label_set_text_with_mnemonic (GTK_LABEL (child),
3224
 
                                      msg);
3225
 
 
3226
 
  g_free (msg);
3227
 
}
3228
 
 
3229
 
 
3230
 
void
3231
 
gm_main_window_update_calling_state (GtkWidget *main_window,
3232
 
                                     unsigned calling_state)
3233
 
{
3234
 
  GmMainWindow *mw = NULL;
3235
 
  
3236
 
  g_return_if_fail (main_window != NULL);
3237
 
 
3238
 
  mw = gm_mw_get_mw (main_window);
3239
 
 
3240
 
  g_return_if_fail (mw!= NULL);
3241
 
 
3242
 
  gm_main_window_selected_presentity_build_menu (main_window);
3243
 
  switch (calling_state)
3244
 
    {
3245
 
    case Standby:
3246
 
      
3247
 
      /* Update the hold state */
3248
 
      gm_main_window_set_call_hold (main_window, FALSE);
3249
 
 
3250
 
      /* Update the sensitivity, all channels are closed */
3251
 
      gm_main_window_update_sensitivity (main_window, TRUE, FALSE, FALSE);
3252
 
      gm_main_window_update_sensitivity (main_window, FALSE, FALSE, FALSE);
3253
 
      
3254
 
      /* Update the menus and toolbar items */
3255
 
      gtk_menu_set_sensitive (mw->main_menu, "connect", TRUE);
3256
 
      gtk_menu_set_sensitive (mw->main_menu, "disconnect", FALSE);
3257
 
      gtk_menu_section_set_sensitive (mw->main_menu, "hold_call", FALSE);
3258
 
      gtk_widget_set_sensitive (GTK_WIDGET (mw->hold_button), FALSE);
3259
 
      gtk_widget_set_sensitive (GTK_WIDGET (mw->preview_button), TRUE);
3260
 
      
3261
 
      /* Update the connect button */
3262
 
      gm_connect_button_set_connected (GM_CONNECT_BUTTON (mw->connect_button),
3263
 
                                       FALSE);
3264
 
        
3265
 
      /* Destroy the transfer call popup */
3266
 
      if (mw->transfer_call_popup) 
3267
 
        gtk_dialog_response (GTK_DIALOG (mw->transfer_call_popup),
3268
 
                             GTK_RESPONSE_REJECT);
3269
 
 
3270
 
      break;
3271
 
 
3272
 
 
3273
 
    case Calling:
3274
 
 
3275
 
      /* Update the menus and toolbar items */
3276
 
      gtk_menu_set_sensitive (mw->main_menu, "connect", FALSE);
3277
 
      gtk_menu_set_sensitive (mw->main_menu, "disconnect", TRUE);
3278
 
      gtk_widget_set_sensitive (GTK_WIDGET (mw->preview_button), FALSE);
3279
 
 
3280
 
      /* Update the connect button */
3281
 
      gm_connect_button_set_connected (GM_CONNECT_BUTTON (mw->connect_button),
3282
 
                                       TRUE);
3283
 
 
3284
 
      break;
3285
 
 
3286
 
 
3287
 
    case Connected:
3288
 
 
3289
 
      /* Update the menus and toolbar items */
3290
 
      gtk_menu_set_sensitive (mw->main_menu, "connect", FALSE);
3291
 
      gtk_menu_set_sensitive (mw->main_menu, "disconnect", TRUE);
3292
 
      gtk_menu_section_set_sensitive (mw->main_menu, "hold_call", TRUE);
3293
 
      gtk_widget_set_sensitive (GTK_WIDGET (mw->hold_button), TRUE);
3294
 
      gtk_widget_set_sensitive (GTK_WIDGET (mw->preview_button), FALSE);
3295
 
 
3296
 
      /* Update the connect button */
3297
 
      gm_connect_button_set_connected (GM_CONNECT_BUTTON (mw->connect_button),
3298
 
                                       TRUE);
3299
 
 
3300
 
      break;
3301
 
 
3302
 
 
3303
 
    case Called:
3304
 
 
3305
 
      /* Update the menus and toolbar items */
3306
 
      gtk_menu_set_sensitive (mw->main_menu, "disconnect", TRUE);
3307
 
 
3308
 
      /* Update the connect button */
3309
 
      gm_connect_button_set_connected (GM_CONNECT_BUTTON (mw->connect_button),
3310
 
                                       FALSE);
3311
 
 
3312
 
      break;
3313
 
 
3314
 
    default:
3315
 
      break;
3316
 
    }
3317
 
 
3318
 
  mw->calling_state = calling_state;
3319
 
}
3320
 
 
3321
 
 
3322
 
void
3323
 
gm_main_window_update_sensitivity (GtkWidget *main_window,
3324
 
                                   bool is_video,
3325
 
                                   bool /*is_receiving*/,
3326
 
                                   bool is_transmitting)
3327
 
{
3328
 
  GmMainWindow *mw = NULL;
3329
 
  
3330
 
  mw = gm_mw_get_mw (main_window);
3331
 
 
3332
 
  g_return_if_fail (mw != NULL);
3333
 
 
3334
 
  if (is_transmitting) {
3335
 
 
3336
 
    if (!is_video) 
3337
 
      gtk_menu_set_sensitive (mw->main_menu, "suspend_audio", TRUE);
3338
 
    else 
3339
 
      gtk_menu_set_sensitive (mw->main_menu, "suspend_video", TRUE);
3340
 
  }     
3341
 
  else {
3342
 
 
3343
 
    if (!is_video)
3344
 
      gtk_menu_set_sensitive (mw->main_menu, "suspend_audio", FALSE);
3345
 
    else
3346
 
      gtk_menu_set_sensitive (mw->main_menu, "suspend_video", FALSE);
3347
 
 
3348
 
  }
3349
 
}
3350
 
 
3351
 
 
3352
 
void
3353
 
gm_main_window_toggle_fullscreen (Ekiga::VideoOutputFSToggle toggle,
3354
 
                                  GtkWidget   *main_window)
3355
 
{
3356
 
  GmMainWindow *mw = gm_mw_get_mw (main_window);
3357
 
  g_return_if_fail (mw != NULL);
3358
 
 
3359
 
  Ekiga::VideoOutputMode videooutput_mode;
3360
 
 
3361
 
  switch (toggle) {
3362
 
    case Ekiga::VO_FS_OFF:
3363
 
      if (gm_conf_get_int (VIDEO_DISPLAY_KEY "video_view") == Ekiga::VO_MODE_FULLSCREEN) {
3364
 
 
3365
 
        videooutput_mode = (Ekiga::VideoOutputMode) gm_conf_get_int (VIDEO_DISPLAY_KEY "video_view_before_fullscreen");
3366
 
        gm_conf_set_int (VIDEO_DISPLAY_KEY "video_view", videooutput_mode);
3367
 
      }
3368
 
      break;
3369
 
    case Ekiga::VO_FS_ON:
3370
 
      if (gm_conf_get_int (VIDEO_DISPLAY_KEY "video_view") != Ekiga::VO_MODE_FULLSCREEN) {
3371
 
 
3372
 
        videooutput_mode = (Ekiga::VideoOutputMode) gm_conf_get_int (VIDEO_DISPLAY_KEY "video_view");
3373
 
        gm_conf_set_int (VIDEO_DISPLAY_KEY "video_view_before_fullscreen", videooutput_mode);
3374
 
        gm_conf_set_int (VIDEO_DISPLAY_KEY "video_view", Ekiga::VO_MODE_FULLSCREEN);
3375
 
      }
3376
 
      break;
3377
 
 
3378
 
    case Ekiga::VO_FS_TOGGLE:
3379
 
    default:
3380
 
      if (gm_conf_get_int (VIDEO_DISPLAY_KEY "video_view") == Ekiga::VO_MODE_FULLSCREEN) {
3381
 
 
3382
 
        videooutput_mode = (Ekiga::VideoOutputMode) gm_conf_get_int (VIDEO_DISPLAY_KEY "video_view_before_fullscreen");
3383
 
        gm_conf_set_int (VIDEO_DISPLAY_KEY "video_view", videooutput_mode);
3384
 
      }
3385
 
      else {
3386
 
 
3387
 
        videooutput_mode =  (Ekiga::VideoOutputMode) gm_conf_get_int (VIDEO_DISPLAY_KEY "video_view");
3388
 
        gm_conf_set_int (VIDEO_DISPLAY_KEY "video_view_before_fullscreen", videooutput_mode);
3389
 
        gm_conf_set_int (VIDEO_DISPLAY_KEY "video_view", Ekiga::VO_MODE_FULLSCREEN);
3390
 
      }
3391
 
      break;
3392
 
  }
3393
 
}
3394
 
 
3395
 
 
3396
 
static void 
3397
 
gm_main_window_show_call_panel (GtkWidget *self)
3398
 
{
3399
 
  GmMainWindow *mw = NULL;
3400
 
 
3401
 
  mw = gm_mw_get_mw (GTK_WIDGET (self));
3402
 
 
3403
 
  if (!GTK_WIDGET_VISIBLE (gtk_paned_get_child2 (GTK_PANED (mw->hpaned)))) {
3404
 
    gtk_widget_show_all (gtk_paned_get_child2 (GTK_PANED (mw->hpaned)));
3405
 
  }
3406
 
}
3407
 
 
3408
 
 
3409
 
static void 
3410
 
gm_main_window_hide_call_panel (GtkWidget *self)
3411
 
{
3412
 
  GmMainWindow *mw = NULL;
3413
 
  GtkRequisition req;
3414
 
  int x, y = 0;
3415
 
 
3416
 
  mw = gm_mw_get_mw (GTK_WIDGET (self));
3417
 
 
3418
 
  if (GTK_WIDGET_VISIBLE (gtk_paned_get_child2 (GTK_PANED (mw->hpaned)))) {
3419
 
 
3420
 
    gtk_widget_size_request (gtk_paned_get_child2 (GTK_PANED (mw->hpaned)), &req);
3421
 
    gtk_window_get_size (GTK_WINDOW (self), &x, &y);
3422
 
    gtk_widget_hide (gtk_paned_get_child2 (GTK_PANED (mw->hpaned)));
3423
 
    x = x - req.width;
3424
 
    gtk_window_resize (GTK_WINDOW (self), x, y);
3425
 
  }
3426
 
}
3427
 
 
3428
 
 
3429
 
void
3430
 
gm_main_window_set_busy (GtkWidget *main_window,
3431
 
                         bool busy)
3432
 
{
3433
 
  GmMainWindow *mw = NULL;
3434
 
  
3435
 
  GdkCursor *cursor = NULL;
3436
 
 
3437
 
  mw = gm_mw_get_mw (main_window);
3438
 
 
3439
 
  g_return_if_fail (mw != NULL);
3440
 
 
3441
 
  gtk_widget_set_sensitive (mw->main_toolbar, !busy);
3442
 
  gtk_widget_set_sensitive (mw->main_menu, !busy);
3443
 
 
3444
 
  if (busy) {
3445
 
 
3446
 
    cursor = gdk_cursor_new (GDK_WATCH);
3447
 
    gdk_window_set_cursor (GTK_WIDGET (main_window)->window, cursor);
3448
 
    gdk_cursor_unref (cursor);
3449
 
  }
3450
 
  else
3451
 
    gdk_window_set_cursor (GTK_WIDGET (main_window)->window, NULL);
3452
 
}
3453
 
 
3454
 
void
3455
 
gm_main_window_clear_signal_levels (GtkWidget *main_window)
3456
 
{
3457
 
  GmMainWindow *mw = NULL;
3458
 
 
3459
 
  g_return_if_fail (main_window != NULL);
3460
 
 
3461
 
  mw = gm_mw_get_mw (main_window);
3462
 
 
3463
 
  g_return_if_fail (mw != NULL);
3464
 
 
3465
 
  gtk_levelmeter_clear (GTK_LEVELMETER (mw->output_signal));
3466
 
  gtk_levelmeter_clear (GTK_LEVELMETER (mw->input_signal));
3467
 
}
3468
 
 
3469
 
void 
3470
 
gm_main_window_selected_presentity_build_menu (GtkWidget *main_window)
3471
 
{
3472
 
  GmMainWindow *mw = NULL;
3473
 
  GtkWidget* menu = NULL;
3474
 
 
3475
 
  g_return_if_fail (main_window != NULL);
3476
 
 
3477
 
  mw = gm_mw_get_mw (main_window);
3478
 
 
3479
 
  g_return_if_fail (mw != NULL);
3480
 
 
3481
 
  menu = gtk_menu_get_widget (mw->main_menu, "contact");
3482
 
  if (mw->presentity != NULL) {
3483
 
 
3484
 
    MenuBuilderGtk builder;
3485
 
    gtk_widget_set_sensitive (menu, TRUE);
3486
 
    if (mw->presentity->populate_menu (builder)) {
3487
 
 
3488
 
      gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu), builder.menu);
3489
 
      gtk_widget_show_all (builder.menu);
3490
 
    } 
3491
 
    else {
3492
 
 
3493
 
      gtk_widget_set_sensitive (menu, FALSE);
3494
 
      g_object_unref (builder.menu);
3495
 
    }
3496
 
  } 
3497
 
  else {
3498
 
 
3499
 
    gtk_widget_set_sensitive (menu, FALSE);
3500
 
    gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu), NULL);
3501
 
  }
3502
 
}
3503
 
 
3504
 
 
3505
 
void gm_main_window_incoming_call_dialog_show (GtkWidget *main_window,
3506
 
                                               Ekiga::Call & call)
3507
 
{
3508
 
  GmMainWindow *mw = NULL;
3509
 
  
3510
 
  GdkPixbuf *pixbuf = NULL;
3511
 
 
3512
 
  GtkWidget *label = NULL;
3513
 
  GtkWidget *vbox = NULL;
3514
 
  GtkWidget *b1 = NULL;
3515
 
  GtkWidget *b2 = NULL;
3516
 
  GtkWidget *incoming_call_popup = NULL;
3517
 
 
3518
 
  gchar *msg = NULL;
3519
 
 
3520
 
  // FIXME could the call become invalid ?
3521
 
  const char *utf8_name = call.get_remote_party_name ().c_str ();
3522
 
  const char *utf8_app = call.get_remote_application ().c_str ();
3523
 
  const char *utf8_url = call.get_remote_uri ().c_str ();
3524
 
  const char *utf8_local = call.get_local_party_name ().c_str ();
3525
 
 
3526
 
  g_return_if_fail (main_window);
3527
 
  
3528
 
  mw = gm_mw_get_mw (main_window);
3529
 
  
3530
 
  g_return_if_fail (mw != NULL);
3531
 
 
3532
 
  incoming_call_popup = gtk_dialog_new ();
3533
 
  b2 = gtk_dialog_add_button (GTK_DIALOG (incoming_call_popup),
3534
 
                              _("Reject"), 0);
3535
 
  b1 = gtk_dialog_add_button (GTK_DIALOG (incoming_call_popup),
3536
 
                              _("Accept"), 2);
3537
 
 
3538
 
  gtk_dialog_set_default_response (GTK_DIALOG (incoming_call_popup), 2);
3539
 
 
3540
 
  vbox = GTK_DIALOG (incoming_call_popup)->vbox;
3541
 
 
3542
 
  msg = g_strdup_printf ("%s <i>%s</i>", _("Incoming call from"), (const char*) utf8_name);
3543
 
  label = gtk_label_new (NULL);
3544
 
  gtk_label_set_markup (GTK_LABEL (label), msg);
3545
 
  gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 10);
3546
 
  gtk_misc_set_alignment (GTK_MISC (label), 0.5, 0.0);
3547
 
  gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
3548
 
  g_free (msg);
3549
 
 
3550
 
  pixbuf = gtk_widget_render_icon (GTK_WIDGET (incoming_call_popup),
3551
 
                                   GM_STOCK_PHONE_PICK_UP_16,
3552
 
                                   GTK_ICON_SIZE_MENU, NULL);
3553
 
  gtk_window_set_icon (GTK_WINDOW (incoming_call_popup), pixbuf);
3554
 
  g_object_unref (pixbuf);
3555
 
 
3556
 
  if (utf8_url) {
3557
 
    
3558
 
    label = gtk_label_new (NULL);
3559
 
    msg = g_strdup_printf ("<b>%s</b> <span foreground=\"blue\"><u>%s</u></span>",
3560
 
                           _("Remote URI:"), utf8_url);
3561
 
    gtk_label_set_markup (GTK_LABEL (label), msg);
3562
 
    gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
3563
 
    gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 2);
3564
 
    gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0);
3565
 
    g_free (msg);
3566
 
  }
3567
 
 
3568
 
  if (utf8_app) {
3569
 
 
3570
 
    label = gtk_label_new (NULL);
3571
 
    msg = g_strdup_printf ("<b>%s</b> %s",
3572
 
                           _("Remote Application:"), utf8_app);
3573
 
    gtk_label_set_markup (GTK_LABEL (label), msg);
3574
 
    gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
3575
 
    gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 2);
3576
 
    gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0);
3577
 
    g_free (msg);
3578
 
  }
3579
 
 
3580
 
  if (utf8_local) {
3581
 
    
3582
 
    label = gtk_label_new (NULL);
3583
 
    msg =
3584
 
      g_strdup_printf ("<b>%s</b> %s",
3585
 
                       _("Account ID:"), utf8_local);
3586
 
    gtk_label_set_markup (GTK_LABEL (label), msg);
3587
 
    gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
3588
 
    gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 2);
3589
 
    gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0);
3590
 
    g_free (msg);
3591
 
  }
3592
 
 
3593
 
  msg = g_strdup_printf (_("Call from %s"), (const char*) utf8_name);
3594
 
  gtk_window_set_title (GTK_WINDOW (incoming_call_popup), msg);
3595
 
  g_free (msg);
3596
 
  gtk_window_set_modal (GTK_WINDOW (incoming_call_popup), TRUE);
3597
 
  gtk_window_set_keep_above (GTK_WINDOW (incoming_call_popup), TRUE);
3598
 
  gtk_window_set_urgency_hint (GTK_WINDOW (main_window), TRUE);
3599
 
  gtk_window_set_transient_for (GTK_WINDOW (incoming_call_popup),
3600
 
                                GTK_WINDOW (main_window));
3601
 
 
3602
 
  gtk_widget_show_all (incoming_call_popup);
3603
 
 
3604
 
  g_signal_connect (G_OBJECT (incoming_call_popup), "delete_event",
3605
 
                    G_CALLBACK (gtk_widget_hide_on_delete), NULL);
3606
 
  g_signal_connect (G_OBJECT (incoming_call_popup), "response",
3607
 
                    GTK_SIGNAL_FUNC (incoming_call_response_cb), &call);
3608
 
 
3609
 
  call.cleared.connect (sigc::bind (sigc::ptr_fun (on_cleared_incoming_call_cb),
3610
 
                                    (gpointer) incoming_call_popup));
3611
 
  call.missed.connect (sigc::bind (sigc::ptr_fun (on_missed_incoming_call_cb), 
3612
 
                                   (gpointer) incoming_call_popup));
3613
 
}
3614
 
 
3615
 
 
3616
 
#ifdef HAVE_NOTIFY
3617
 
static void
3618
 
notify_action_cb (NotifyNotification *notification,
3619
 
                  gchar *action,
3620
 
                  gpointer data)
3621
 
{
3622
 
  Ekiga::Call *call = (Ekiga::Call *) data;
3623
 
 
3624
 
  notify_notification_close (notification, NULL);
3625
 
 
3626
 
  if (call) {
3627
 
 
3628
 
    if (!strcmp (action, "accept"))
3629
 
      call->answer ();
3630
 
    else
3631
 
      call->hangup ();
3632
 
  }
3633
 
}
3634
 
 
3635
 
 
3636
 
static void
3637
 
closed_cb (NotifyNotification* /*notify*/, 
3638
 
           gpointer main_window)
3639
 
{
3640
 
  GmMainWindow *mw = NULL;
3641
 
 
3642
 
  g_return_if_fail (main_window != NULL);
3643
 
 
3644
 
  mw = gm_mw_get_mw (GTK_WIDGET (main_window));
3645
 
 
3646
 
  g_return_if_fail (mw != NULL);
3647
 
 
3648
 
  Ekiga::AudioOutputCore *audiooutput_core = dynamic_cast<Ekiga::AudioOutputCore *> (mw->core.get ("audiooutput-core"));
3649
 
  if (audiooutput_core) 
3650
 
    audiooutput_core->stop_play_event ("incoming_call_sound");
3651
 
}
3652
 
 
3653
 
 
3654
 
void gm_main_window_incoming_call_notify (GtkWidget *main_window,
3655
 
                                          Ekiga::Call & call)
3656
 
{
3657
 
  NotifyNotification *notify = NULL;
3658
 
  
3659
 
  GtkStatusIcon *statusicon = NULL;
3660
 
 
3661
 
  gchar *uri = NULL;
3662
 
  gchar *app = NULL;
3663
 
  gchar *account = NULL;
3664
 
  gchar *body = NULL;
3665
 
  gchar *title = NULL;
3666
 
 
3667
 
  statusicon = GTK_STATUS_ICON (GnomeMeeting::Process ()->GetStatusicon ());
3668
 
 
3669
 
  // FIXME could the call become invalid ?
3670
 
  const char *utf8_name = call.get_remote_party_name ().c_str ();
3671
 
  const char *utf8_app = call.get_remote_application ().c_str ();
3672
 
  const char *utf8_url = call.get_remote_uri ().c_str ();
3673
 
  const char *utf8_local = call.get_local_party_name ().c_str ();
3674
 
 
3675
 
  title = g_strdup_printf ("%s %s", _("Incoming call from"), (const char*) utf8_name);
3676
 
 
3677
 
  if (utf8_url)
3678
 
    uri = g_strdup_printf ("<b>%s</b> %s", _("Remote URI:"), utf8_url);
3679
 
  if (utf8_app)
3680
 
    app = g_strdup_printf ("<b>%s</b> %s", _("Remote Application:"), utf8_app);
3681
 
  if (utf8_local)
3682
 
    account = g_strdup_printf ("<b>%s</b> %s", _("Account ID:"), utf8_local);
3683
 
 
3684
 
  body = g_strdup_printf ("%s\n%s\n%s", uri, app, account);
3685
 
  
3686
 
  notify = notify_notification_new (title, body, GM_ICON_LOGO, NULL);
3687
 
  notify_notification_add_action (notify, "accept", _("Accept"), notify_action_cb, &call, NULL);
3688
 
  notify_notification_add_action (notify, "reject", _("Reject"), notify_action_cb, &call, NULL);
3689
 
  notify_notification_set_timeout (notify, NOTIFY_EXPIRES_NEVER);
3690
 
  notify_notification_set_urgency (notify, NOTIFY_URGENCY_CRITICAL);
3691
 
  notify_notification_attach_to_status_icon (notify, statusicon);
3692
 
  if (!notify_notification_show (notify, NULL))
3693
 
    gm_main_window_incoming_call_dialog_show (main_window, call);
3694
 
  else {
3695
 
    call.cleared.connect (sigc::bind (sigc::ptr_fun (on_cleared_incoming_call_cb),
3696
 
                                      (gpointer) notify));
3697
 
    call.missed.connect (sigc::bind (sigc::ptr_fun (on_missed_incoming_call_cb), 
3698
 
                                     (gpointer) notify));
3699
 
  }
3700
 
 
3701
 
  g_signal_connect (notify, "closed", G_CALLBACK (closed_cb), main_window);
3702
 
 
3703
 
  g_free (uri);
3704
 
  g_free (app);
3705
 
  g_free (account);
3706
 
  g_free (title);
3707
 
  g_free (body);
3708
 
}
3709
 
#endif
3710
 
 
3711
 
void 
3712
 
gm_main_window_set_panel_section (GtkWidget *main_window,
3713
 
                                  int section)
3714
 
{
3715
 
  GmMainWindow *mw = NULL;
3716
 
  
3717
 
  GtkWidget *menu = NULL;
3718
 
  
3719
 
  g_return_if_fail (main_window != NULL);
3720
 
  
3721
 
  mw = gm_mw_get_mw (main_window);
3722
 
 
3723
 
  g_return_if_fail (mw != NULL);
3724
 
 
3725
 
  gtk_notebook_set_current_page (GTK_NOTEBOOK (mw->main_notebook), section);
3726
 
  
3727
 
  menu = gtk_menu_get_widget (mw->main_menu, "dialpad");
3728
 
  
3729
 
  gtk_radio_menu_select_with_widget (GTK_WIDGET (menu), section);
3730
 
}
3731
 
 
3732
 
 
3733
 
void 
3734
 
gm_main_window_set_status (GtkWidget *main_window,
3735
 
                           std::string /*short_status*/,
3736
 
                           std::string /*long_status*/)
3737
 
{
3738
 
  GmMainWindow *mw = NULL;
3739
 
  
3740
 
  /*
3741
 
  const char * status [] = 
3742
 
    { 
3743
 
      _("Online"), 
3744
 
      _("Away"), 
3745
 
      _("Do Not Disturb"), 
3746
 
      _("Invisible"),
3747
 
      NULL, 
3748
 
      NULL 
3749
 
    };
3750
 
*/
3751
 
  g_return_if_fail (main_window != NULL);
3752
 
 
3753
 
  mw = gm_mw_get_mw (main_window);
3754
 
  g_return_if_fail (mw != NULL);
3755
 
}
3756
 
 
3757
 
 
3758
 
void 
3759
 
gm_main_window_set_call_info (GtkWidget *main_window,
3760
 
                              const char *tr_audio_codec,
3761
 
                              G_GNUC_UNUSED const char *re_audio_codec,
3762
 
                              const char *tr_video_codec,
3763
 
                              G_GNUC_UNUSED const char *re_video_codec)
3764
 
{
3765
 
  GmMainWindow *mw = NULL;
3766
 
 
3767
 
  GtkTextIter iter;
3768
 
  GtkTextIter *end_iter = NULL;
3769
 
  GtkTextBuffer *buffer = NULL;
3770
 
  
3771
 
  gchar *info = NULL;
3772
 
  
3773
 
  g_return_if_fail (main_window != NULL);
3774
 
  
3775
 
  mw = gm_mw_get_mw (main_window);
3776
 
 
3777
 
  g_return_if_fail (mw != NULL);
3778
 
 
3779
 
  if (!tr_audio_codec && !tr_video_codec)
3780
 
    info = g_strdup (" ");
3781
 
  else
3782
 
    info = g_strdup_printf ("%s - %s",
3783
 
                            tr_audio_codec?tr_audio_codec:"", 
3784
 
                            tr_video_codec?tr_video_codec:"");
3785
 
  
3786
 
  buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (mw->info_text));
3787
 
  gtk_text_buffer_get_start_iter (buffer, &iter);
3788
 
  gtk_text_iter_forward_lines (&iter, 2);
3789
 
  end_iter = gtk_text_iter_copy (&iter);
3790
 
  gtk_text_iter_forward_line (end_iter);
3791
 
  gtk_text_buffer_delete (buffer, &iter, end_iter);
3792
 
  gtk_text_iter_free (end_iter);
3793
 
  gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, info, 
3794
 
                                            -1, "codecs", NULL);
3795
 
  g_free (info);
3796
 
}
3797
 
 
3798
 
 
3799
 
void 
3800
 
gm_main_window_set_status (GtkWidget *main_window,
3801
 
                           const char *status)
3802
 
{
3803
 
  GmMainWindow *mw = NULL;
3804
 
 
3805
 
  GtkTextIter iter;
3806
 
  GtkTextIter* end_iter = NULL;
3807
 
  GtkTextBuffer *buffer = NULL;
3808
 
 
3809
 
  gchar *info = NULL;
3810
 
  
3811
 
  g_return_if_fail (main_window != NULL);
3812
 
  
3813
 
  mw = gm_mw_get_mw (main_window);
3814
 
 
3815
 
  g_return_if_fail (mw != NULL);
3816
 
  
3817
 
  info = g_strdup_printf ("%s\n", status);
3818
 
  
3819
 
  buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (mw->info_text));
3820
 
  gtk_text_buffer_get_start_iter (buffer, &iter);
3821
 
  end_iter = gtk_text_iter_copy (&iter);
3822
 
  gtk_text_iter_forward_line (end_iter);
3823
 
  gtk_text_buffer_delete (buffer, &iter, end_iter);
3824
 
  gtk_text_iter_free (end_iter);
3825
 
  gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, info, 
3826
 
                                            -1, "status", NULL);
3827
 
  g_free (info);
3828
 
}
3829
 
 
3830
 
 
3831
 
void 
3832
 
gm_main_window_set_call_duration (GtkWidget *main_window,
3833
 
                                  const char *duration)
3834
 
{
3835
 
  GmMainWindow *mw = NULL;
3836
 
 
3837
 
  GtkTextIter iter;
3838
 
  GtkTextIter* end_iter = NULL;
3839
 
  GtkTextBuffer *buffer = NULL;
3840
 
 
3841
 
  gchar *info = NULL;
3842
 
 
3843
 
  g_return_if_fail (main_window != NULL);
3844
 
  
3845
 
  mw = gm_mw_get_mw (main_window);
3846
 
 
3847
 
  g_return_if_fail (mw != NULL);
3848
 
  
3849
 
  if (duration)
3850
 
    info = g_strdup_printf (_("Call Duration: %s\n"), duration);
3851
 
  else
3852
 
    info = g_strdup ("\n");
3853
 
  
3854
 
  buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (mw->info_text));
3855
 
  gtk_text_buffer_get_start_iter (buffer, &iter);
3856
 
  gtk_text_iter_forward_line (&iter);
3857
 
  end_iter = gtk_text_iter_copy (&iter);
3858
 
  gtk_text_iter_forward_line (end_iter);
3859
 
  gtk_text_buffer_delete (buffer, &iter, end_iter);
3860
 
  gtk_text_iter_free (end_iter);
3861
 
  gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, info, 
3862
 
                                            -1, "call-duration", NULL);
3863
 
 
3864
 
  g_free (info);
3865
 
}
3866
 
 
3867
 
 
3868
 
gboolean 
3869
 
gm_main_window_transfer_dialog_run (GtkWidget *main_window,
3870
 
                                    GtkWidget *parent_window,
3871
 
                                    const char *u)
3872
 
{
3873
 
  GmMainWindow *mw = NULL;
3874
 
  
3875
 
  gint answer = 0;
3876
 
  
3877
 
  const char *forward_url = NULL;
3878
 
 
3879
 
  g_return_val_if_fail (main_window != NULL, FALSE);
3880
 
  g_return_val_if_fail (parent_window != NULL, FALSE);
3881
 
  
3882
 
  mw = gm_mw_get_mw (main_window);
3883
 
 
3884
 
  g_return_val_if_fail (mw != NULL, FALSE);
3885
 
  
3886
 
  mw->transfer_call_popup = 
3887
 
    gm_entry_dialog_new (_("Transfer call to:"),
3888
 
                         _("Transfer"));
3889
 
  
3890
 
  gtk_window_set_transient_for (GTK_WINDOW (mw->transfer_call_popup),
3891
 
                                GTK_WINDOW (parent_window));
3892
 
  
3893
 
  gtk_dialog_set_default_response (GTK_DIALOG (mw->transfer_call_popup),
3894
 
                                   GTK_RESPONSE_ACCEPT);
3895
 
  
3896
 
  if (u && !strcmp (u, ""))
3897
 
    gm_entry_dialog_set_text (GM_ENTRY_DIALOG (mw->transfer_call_popup), u);
3898
 
  else
3899
 
    gm_entry_dialog_set_text (GM_ENTRY_DIALOG (mw->transfer_call_popup), "sip:");
3900
 
 
3901
 
  gnomemeeting_threads_dialog_show (mw->transfer_call_popup);
3902
 
 
3903
 
  answer = gtk_dialog_run (GTK_DIALOG (mw->transfer_call_popup));
3904
 
  switch (answer) {
3905
 
 
3906
 
  case GTK_RESPONSE_ACCEPT:
3907
 
 
3908
 
    forward_url = gm_entry_dialog_get_text (GM_ENTRY_DIALOG (mw->transfer_call_popup));
3909
 
    if (strcmp (forward_url, "") && mw->current_call)
3910
 
      mw->current_call->transfer (forward_url);
3911
 
    break;
3912
 
 
3913
 
  default:
3914
 
    break;
3915
 
  }
3916
 
 
3917
 
  gtk_widget_destroy (mw->transfer_call_popup);
3918
 
  mw->transfer_call_popup = NULL;
3919
 
 
3920
 
  return (answer == GTK_RESPONSE_ACCEPT);
3921
 
}
3922
 
 
3923
 
 
3924
 
void 
3925
 
gm_main_window_add_device_dialog_show (GtkWidget *main_window,
3926
 
                                       const Ekiga::Device & device,
3927
 
                                       DeviceType deviceType)
3928
 
{
3929
 
  GmMainWindow *mw = NULL;
3930
 
  
3931
 
  GtkWidget *label = NULL;
3932
 
  GtkWidget *vbox = NULL;
3933
 
  GtkWidget *b1 = NULL;
3934
 
  GtkWidget *b2 = NULL;
3935
 
  GtkWidget *add_device_popup = NULL;
3936
 
 
3937
 
  g_return_if_fail (main_window);
3938
 
  mw = gm_mw_get_mw (main_window);
3939
 
  g_return_if_fail (mw != NULL);
3940
 
 
3941
 
 
3942
 
  add_device_popup = gtk_dialog_new ();
3943
 
  b2 = gtk_dialog_add_button (GTK_DIALOG (add_device_popup),
3944
 
                              _("No"), 0);
3945
 
  b1 = gtk_dialog_add_button (GTK_DIALOG (add_device_popup),
3946
 
                              _("Yes"), 2);
3947
 
 
3948
 
  gtk_dialog_set_default_response (GTK_DIALOG (add_device_popup), 2);
3949
 
 
3950
 
  vbox = GTK_DIALOG (add_device_popup)->vbox;
3951
 
 
3952
 
  std::string msg;
3953
 
  std::string title;
3954
 
 
3955
 
  switch (deviceType) {
3956
 
    case AudioInput:
3957
 
      msg = _("Detected new audio input device:");
3958
 
      title = _("Audio Devices");
3959
 
      break;
3960
 
    case AudioOutput:
3961
 
      msg = _("Detected new audio output device:");
3962
 
      title = _("Audio Devices");
3963
 
      break;
3964
 
    case VideoInput:
3965
 
      msg = _("Detected new video input device:");
3966
 
      title = _("Video Devices");
3967
 
      break;
3968
 
    default:
3969
 
      break;
3970
 
  }
3971
 
  label = gtk_label_new (NULL);
3972
 
  gtk_label_set_markup (GTK_LABEL (label), msg.c_str());
3973
 
  gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 2);
3974
 
  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0);
3975
 
  gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
3976
 
  
3977
 
  msg  = "<b>" + device.GetString() + "</b>";
3978
 
  label = gtk_label_new (NULL);
3979
 
  gtk_label_set_markup (GTK_LABEL (label), msg.c_str());
3980
 
  gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 2);
3981
 
  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0);
3982
 
  gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
3983
 
 
3984
 
  msg  = _("Do you want to use it as default device?");
3985
 
  label = gtk_label_new (NULL);
3986
 
  gtk_label_set_markup (GTK_LABEL (label), msg.c_str());
3987
 
  gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 2);
3988
 
  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0);
3989
 
  gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
3990
 
 
3991
 
  gtk_window_set_title (GTK_WINDOW (add_device_popup), title.c_str ());
3992
 
  gtk_window_set_modal (GTK_WINDOW (add_device_popup), TRUE);
3993
 
  gtk_window_set_keep_above (GTK_WINDOW (add_device_popup), TRUE);
3994
 
  gtk_window_set_urgency_hint (GTK_WINDOW (main_window), TRUE);
3995
 
  gtk_window_set_transient_for (GTK_WINDOW (add_device_popup),
3996
 
                                GTK_WINDOW (main_window));
3997
 
 
3998
 
  gtk_widget_show_all (add_device_popup);
3999
 
 
4000
 
 
4001
 
//  g_signal_connect (G_OBJECT (add_device_popup), "delete_event",
4002
 
//                    G_CALLBACK (gtk_widget_hide_on_delete), NULL);
4003
 
//  g_signal_connect (G_OBJECT (add_device_popup), "response",
4004
 
//                    GTK_SIGNAL_FUNC (add_device_response_cb), &device);
4005
 
 
4006
 
  deviceStruct* device_struct = g_new(deviceStruct, 1);
4007
 
  snprintf (device_struct->name, sizeof (device_struct->name), "%s", (device.GetString()).c_str());
4008
 
  device_struct->deviceType = deviceType;
4009
 
 
4010
 
  g_signal_connect_data (G_OBJECT (add_device_popup), "delete_event",
4011
 
                         G_CALLBACK (gtk_widget_hide_on_delete), 
4012
 
                         (gpointer) device_struct,
4013
 
                         (GClosureNotify) g_free,
4014
 
                         (GConnectFlags) 0);
4015
 
 
4016
 
  g_signal_connect_data (G_OBJECT (add_device_popup), "response",
4017
 
                         G_CALLBACK (add_device_response_cb), 
4018
 
                         (gpointer) device_struct,
4019
 
                         (GClosureNotify) g_free,
4020
 
                         (GConnectFlags) 0);
4021
 
}
4022
 
 
4023
 
GtkWidget *
4024
 
gm_main_window_new (Ekiga::ServiceCore & core)
4025
 
{
4026
 
  GmMainWindow *mw = NULL;
4027
 
 
4028
 
  GtkWidget *window = NULL;
4029
 
  
4030
 
  GtkWidget *status_toolbar = NULL;
4031
 
 
4032
 
  GtkStatusIcon *status_icon = NULL;
4033
 
 
4034
 
  PanelSection section = DIALPAD;
4035
 
 
4036
 
  sigc::connection conn;
4037
 
 
4038
 
  Ekiga::ServiceCore *services = NULL;
4039
 
  GtkFrontend *gtk_frontend = NULL;
4040
 
  GtkWidget *chat_window = NULL;
4041
 
 
4042
 
  /* initialize the callback to play IM message sound */
4043
 
  services = GnomeMeeting::Process ()->GetServiceCore ();
4044
 
  gtk_frontend = dynamic_cast<GtkFrontend *>(services->get ("gtk-frontend"));
4045
 
  chat_window = GTK_WIDGET (gtk_frontend->get_chat_window ());
4046
 
 
4047
 
  g_signal_connect (chat_window, "unread-alert",
4048
 
                    G_CALLBACK (on_chat_unread_alert), NULL);
4049
 
 
4050
 
  /* The Top-level window */
4051
 
  window = gm_window_new_with_key (USER_INTERFACE_KEY "main_window");
4052
 
  gm_window_set_hide_on_delete (GM_WINDOW (window), FALSE);
4053
 
  gtk_window_set_title (GTK_WINDOW (window), 
4054
 
                        _("Ekiga"));
4055
 
 
4056
 
  g_signal_connect (G_OBJECT (window), "focus-in-event",
4057
 
                    GTK_SIGNAL_FUNC (main_window_focus_event_cb), NULL);
4058
 
 
4059
 
 
4060
 
  /* The GMObject data */
4061
 
  mw = new GmMainWindow (core);
4062
 
  mw->presentity = NULL;
4063
 
  mw->transfer_call_popup = NULL;
4064
 
  mw->current_call = NULL;
4065
 
  mw->timeout_id = -1;
4066
 
  mw->levelmeter_timeout_id = -1;
4067
 
  mw->audio_transmission_active = mw->audio_reception_active 
4068
 
    = mw->video_transmission_active = mw->video_reception_active = false;
4069
 
  g_object_set_data_full (G_OBJECT (window), "GMObject", 
4070
 
                          mw, (GDestroyNotify) gm_mw_destroy);
4071
 
 
4072
 
#ifndef WIN32
4073
 
  mw->video_widget_gc = NULL;
4074
 
#endif
4075
 
 
4076
 
  /* Accelerators */
4077
 
  mw->accel = gtk_accel_group_new ();
4078
 
  gtk_window_add_accel_group (GTK_WINDOW (window), mw->accel);
4079
 
  g_object_unref (mw->accel);
4080
 
 
4081
 
  mw->window_vbox = gtk_vbox_new (0, FALSE);
4082
 
  gtk_container_add (GTK_CONTAINER (window), mw->window_vbox);
4083
 
  gtk_widget_show_all (mw->window_vbox);
4084
 
 
4085
 
  /* The main menu */
4086
 
  mw->statusbar = gm_statusbar_new ();
4087
 
  gm_mw_init_menu (window); 
4088
 
  gtk_box_pack_start (GTK_BOX (mw->window_vbox), mw->main_menu,
4089
 
                      FALSE, FALSE, 0);
4090
 
 
4091
 
  /* The toolbars */
4092
 
  mw->main_toolbar = gm_mw_init_uri_toolbar (window);
4093
 
  gtk_box_pack_start (GTK_BOX (mw->window_vbox), mw->main_toolbar, false, false, 0); 
4094
 
 
4095
 
  /* The Audio & Video Settings windows */
4096
 
  mw->audio_settings_window = gm_mw_audio_settings_window_new (window);
4097
 
  mw->video_settings_window = gm_mw_video_settings_window_new (window);
4098
 
 
4099
 
  /* The 2 parts of the gui */
4100
 
  mw->hpaned = gtk_hpaned_new ();
4101
 
  gtk_box_pack_start (GTK_BOX (mw->window_vbox), mw->hpaned,
4102
 
                      true, true, 0);
4103
 
 
4104
 
  mw->main_notebook = gtk_notebook_new ();
4105
 
 
4106
 
  gtk_notebook_popup_enable (GTK_NOTEBOOK (mw->main_notebook));
4107
 
  gtk_notebook_set_show_tabs (GTK_NOTEBOOK (mw->main_notebook), true);
4108
 
  gtk_notebook_set_scrollable (GTK_NOTEBOOK (mw->main_notebook), true);
4109
 
 
4110
 
  gm_mw_init_contacts_list (window);
4111
 
  gm_mw_init_dialpad (window);
4112
 
  gtk_paned_pack1 (GTK_PANED (mw->hpaned), mw->main_notebook, true, false);
4113
 
 
4114
 
  gm_mw_init_call (window);
4115
 
  gm_mw_init_history (window);
4116
 
 
4117
 
  section = (PanelSection) 
4118
 
    gm_conf_get_int (USER_INTERFACE_KEY "main_window/panel_section");
4119
 
  gtk_widget_show (mw->hpaned);
4120
 
  gtk_widget_show_all (GTK_WIDGET (gtk_paned_get_child1 (GTK_PANED (mw->hpaned))));
4121
 
  if (gm_conf_get_bool (USER_INTERFACE_KEY "main_window/show_call_panel"))
4122
 
    gtk_widget_show_all (GTK_WIDGET (gtk_paned_get_child2 (GTK_PANED (mw->hpaned))));
4123
 
  gm_main_window_set_panel_section (window, section);
4124
 
 
4125
 
  /* Status toolbar */
4126
 
  status_toolbar = gm_mw_init_status_toolbar (window);
4127
 
  gtk_box_pack_start (GTK_BOX (mw->window_vbox), status_toolbar, false, false, 0);
4128
 
 
4129
 
  /* The statusbar with qualitymeter */
4130
 
  gtk_statusbar_set_has_resize_grip (GTK_STATUSBAR (mw->statusbar), TRUE);
4131
 
  GtkShadowType shadow_type;
4132
 
  gtk_widget_style_get (mw->statusbar, "shadow-type", &shadow_type, NULL);
4133
 
 
4134
 
  GtkWidget *frame = gtk_frame_new (NULL);
4135
 
  gtk_frame_set_shadow_type (GTK_FRAME (frame), shadow_type);
4136
 
  gtk_box_pack_start (GTK_BOX (mw->statusbar), frame, FALSE, TRUE, 0);
4137
 
 
4138
 
  gtk_box_reorder_child (GTK_BOX (mw->statusbar), frame, 0);
4139
 
 
4140
 
  mw->qualitymeter = gm_powermeter_new ();
4141
 
  gtk_container_add (GTK_CONTAINER (frame), mw->qualitymeter);
4142
 
 
4143
 
  mw->statusbar_ebox = gtk_event_box_new ();
4144
 
  gtk_container_add (GTK_CONTAINER (mw->statusbar_ebox), mw->statusbar);
4145
 
 
4146
 
  gtk_box_pack_start (GTK_BOX (mw->window_vbox), mw->statusbar_ebox,
4147
 
                      FALSE, FALSE, 0);
4148
 
  gtk_widget_show_all (mw->statusbar_ebox);
4149
 
 
4150
 
  g_signal_connect (G_OBJECT (mw->statusbar_ebox), "button-press-event",
4151
 
                    GTK_SIGNAL_FUNC (statusbar_clicked_cb), window);
4152
 
 
4153
 
  gtk_widget_realize (window);
4154
 
  gm_main_window_update_logo_have_window (window);
4155
 
  g_signal_connect_after (G_OBJECT (mw->main_notebook), "switch-page",
4156
 
                          G_CALLBACK (panel_section_changed_cb), 
4157
 
                          window);
4158
 
 
4159
 
  /* if the user tries to close the window : delete_event */
4160
 
  g_signal_connect (G_OBJECT (window), "delete_event",
4161
 
                    G_CALLBACK (window_closed_cb), 
4162
 
                    (gpointer) window);
4163
 
  g_signal_connect (G_OBJECT (window), "show", 
4164
 
                    GTK_SIGNAL_FUNC (video_window_shown_cb), window);
4165
 
  g_signal_connect (G_OBJECT (window), "expose-event", 
4166
 
                    GTK_SIGNAL_FUNC (video_window_expose_cb), NULL);
4167
 
  
4168
 
  /* New Display Engine signals */
4169
 
  Ekiga::VideoOutputCore *videooutput_core = dynamic_cast<Ekiga::VideoOutputCore *> (mw->core.get ("videooutput-core"));
4170
 
 
4171
 
  conn = videooutput_core->device_opened.connect (sigc::bind (sigc::ptr_fun (on_videooutput_device_opened_cb), (gpointer) window));
4172
 
  mw->connections.push_back (conn);
4173
 
 
4174
 
  conn = videooutput_core->device_closed.connect (sigc::bind (sigc::ptr_fun (on_videooutput_device_closed_cb), (gpointer) window));
4175
 
  mw->connections.push_back (conn);
4176
 
 
4177
 
  conn = videooutput_core->device_error.connect (sigc::bind (sigc::ptr_fun (on_videooutput_device_error_cb), (gpointer) window));
4178
 
  mw->connections.push_back (conn);
4179
 
 
4180
 
  conn = videooutput_core->size_changed.connect (sigc::bind (sigc::ptr_fun (on_size_changed_cb), (gpointer) window));
4181
 
  mw->connections.push_back (conn);
4182
 
 
4183
 
  conn = videooutput_core->fullscreen_mode_changed.connect (sigc::bind (sigc::ptr_fun (on_fullscreen_mode_changed_cb), (gpointer) window));
4184
 
  mw->connections.push_back (conn);
4185
 
 
4186
 
  /* New VideoInput Engine signals */
4187
 
  Ekiga::VideoInputCore *videoinput_core = dynamic_cast<Ekiga::VideoInputCore *> (mw->core.get ("videoinput-core"));
4188
 
 
4189
 
  conn = videoinput_core->device_opened.connect (sigc::bind (sigc::ptr_fun (on_videoinput_device_opened_cb), (gpointer) window));
4190
 
  mw->connections.push_back (conn);
4191
 
 
4192
 
  conn = videoinput_core->device_closed.connect (sigc::bind (sigc::ptr_fun (on_videoinput_device_closed_cb), (gpointer) window));
4193
 
  mw->connections.push_back (conn);
4194
 
 
4195
 
  conn = videoinput_core->device_added.connect (sigc::bind (sigc::ptr_fun (on_videoinput_device_added_cb), (gpointer) window));
4196
 
  mw->connections.push_back (conn);
4197
 
 
4198
 
  conn = videoinput_core->device_removed.connect (sigc::bind (sigc::ptr_fun (on_videoinput_device_removed_cb), (gpointer) window));
4199
 
  mw->connections.push_back (conn);
4200
 
 
4201
 
  conn = videoinput_core->device_error.connect (sigc::bind (sigc::ptr_fun (on_videoinput_device_error_cb), (gpointer) window));
4202
 
  mw->connections.push_back (conn);
4203
 
 
4204
 
  /* New AudioInput Engine signals */
4205
 
  Ekiga::AudioInputCore *audioinput_core = dynamic_cast<Ekiga::AudioInputCore *> (mw->core.get ("audioinput-core"));
4206
 
 
4207
 
  conn = audioinput_core->device_opened.connect (sigc::bind (sigc::ptr_fun (on_audioinput_device_opened_cb), (gpointer) window));
4208
 
  mw->connections.push_back (conn);
4209
 
 
4210
 
  conn = audioinput_core->device_closed.connect (sigc::bind (sigc::ptr_fun (on_audioinput_device_closed_cb), (gpointer) window));
4211
 
  mw->connections.push_back (conn);
4212
 
 
4213
 
  conn = audioinput_core->device_added.connect (sigc::bind (sigc::ptr_fun (on_audioinput_device_added_cb), (gpointer) window));
4214
 
  mw->connections.push_back (conn);
4215
 
 
4216
 
  conn = audioinput_core->device_removed.connect (sigc::bind (sigc::ptr_fun (on_audioinput_device_removed_cb), (gpointer) window));
4217
 
  mw->connections.push_back (conn);
4218
 
 
4219
 
  conn = audioinput_core->device_error.connect (sigc::bind (sigc::ptr_fun (on_audioinput_device_error_cb), (gpointer) window));
4220
 
  mw->connections.push_back (conn);
4221
 
 
4222
 
  /* New AudioOutput Engine signals */
4223
 
  Ekiga::AudioOutputCore *audiooutput_core = dynamic_cast<Ekiga::AudioOutputCore *> (mw->core.get ("audiooutput-core"));
4224
 
 
4225
 
  conn = audiooutput_core->device_opened.connect (sigc::bind (sigc::ptr_fun (on_audiooutput_device_opened_cb), (gpointer) window));
4226
 
  mw->connections.push_back (conn);
4227
 
 
4228
 
  conn = audiooutput_core->device_closed.connect (sigc::bind (sigc::ptr_fun (on_audiooutput_device_closed_cb), (gpointer) window));
4229
 
  mw->connections.push_back (conn);
4230
 
 
4231
 
  conn = audiooutput_core->device_added.connect (sigc::bind (sigc::ptr_fun (on_audiooutput_device_added_cb), (gpointer) window));
4232
 
  mw->connections.push_back (conn);
4233
 
 
4234
 
  conn = audiooutput_core->device_removed.connect (sigc::bind (sigc::ptr_fun (on_audiooutput_device_removed_cb), (gpointer) window));
4235
 
  mw->connections.push_back (conn);
4236
 
 
4237
 
  conn = audiooutput_core->device_error.connect (sigc::bind (sigc::ptr_fun (on_audiooutput_device_error_cb), (gpointer) window));
4238
 
  mw->connections.push_back (conn);
4239
 
    
4240
 
  /* New Call Engine signals */
4241
 
  Ekiga::CallCore *call_core = dynamic_cast<Ekiga::CallCore *> (mw->core.get ("call-core"));
4242
 
  Ekiga::AccountCore *account_core = dynamic_cast<Ekiga::AccountCore *> (mw->core.get ("account-core"));
4243
 
 
4244
 
  /* Engine Signals callbacks */
4245
 
  conn = account_core->registration_event.connect (sigc::bind (sigc::ptr_fun (on_registration_event), (gpointer) window));
4246
 
  mw->connections.push_back (conn);
4247
 
 
4248
 
  conn = call_core->ready.connect (sigc::bind (sigc::ptr_fun (on_ready_cb), (gpointer) window));
4249
 
  mw->connections.push_back (conn);
4250
 
 
4251
 
  conn = call_core->setup_call.connect (sigc::bind (sigc::ptr_fun (on_setup_call_cb), (gpointer) window));
4252
 
  mw->connections.push_back (conn);
4253
 
 
4254
 
  conn = call_core->ringing_call.connect (sigc::bind (sigc::ptr_fun (on_ringing_call_cb), (gpointer) window));
4255
 
  mw->connections.push_back (conn);
4256
 
  
4257
 
  conn = call_core->established_call.connect (sigc::bind (sigc::ptr_fun (on_established_call_cb), (gpointer) window));
4258
 
  mw->connections.push_back (conn);
4259
 
  
4260
 
  conn = call_core->cleared_call.connect (sigc::bind (sigc::ptr_fun (on_cleared_call_cb), (gpointer) window));
4261
 
  mw->connections.push_back (conn);
4262
 
  
4263
 
  conn = call_core->held_call.connect (sigc::bind (sigc::ptr_fun (on_held_call_cb), (gpointer) window));
4264
 
  mw->connections.push_back (conn);
4265
 
  
4266
 
  conn = call_core->retrieved_call.connect (sigc::bind (sigc::ptr_fun (on_retrieved_call_cb), (gpointer) window));
4267
 
  mw->connections.push_back (conn);
4268
 
  
4269
 
  conn = call_core->missed_call.connect (sigc::bind (sigc::ptr_fun (on_missed_call_cb), (gpointer) window));
4270
 
  mw->connections.push_back (conn);
4271
 
  
4272
 
  conn = call_core->stream_opened.connect (sigc::bind (sigc::ptr_fun (on_stream_opened_cb), (gpointer) window));
4273
 
  mw->connections.push_back (conn);
4274
 
  
4275
 
  conn = call_core->stream_closed.connect (sigc::bind (sigc::ptr_fun (on_stream_closed_cb), (gpointer) window));
4276
 
  mw->connections.push_back (conn);
4277
 
 
4278
 
  conn = call_core->stream_paused.connect (sigc::bind (sigc::ptr_fun (on_stream_paused_cb), (gpointer) window));
4279
 
  mw->connections.push_back (conn);
4280
 
 
4281
 
  conn = call_core->stream_resumed.connect (sigc::bind (sigc::ptr_fun (on_stream_resumed_cb), (gpointer) window));
4282
 
  mw->connections.push_back (conn);
4283
 
 
4284
 
  conn = call_core->errors.add_handler (sigc::bind (sigc::ptr_fun (on_handle_errors), (gpointer) window));
4285
 
  mw->connections.push_back (conn);
4286
 
 
4287
 
  /* Notifiers */
4288
 
  gm_conf_notifier_add (USER_INTERFACE_KEY "main_window/panel_section",
4289
 
                        panel_section_changed_nt, window);
4290
 
 
4291
 
  gm_conf_notifier_add (USER_INTERFACE_KEY "main_window/show_call_panel",
4292
 
                        show_call_panel_changed_nt, window);
4293
 
 
4294
 
  /* Track status icon embed changes */
4295
 
  status_icon = GTK_STATUS_ICON (GnomeMeeting::Process ()->GetStatusicon ());
4296
 
  g_signal_connect (G_OBJECT (status_icon), "notify::embedded",
4297
 
                    G_CALLBACK (on_status_icon_embedding_change), NULL);
4298
 
 
4299
 
  /* Until we are ready, nothing possible  */
4300
 
  gm_main_window_set_busy (window, true);
4301
 
 
4302
 
  return window;
4303
 
}
4304
 
 
4305
 
 
4306
 
void 
4307
 
gm_main_window_flash_message (GtkWidget *main_window, 
4308
 
                              const char *msg, 
4309
 
                              ...)
4310
 
{
4311
 
  GmMainWindow *mw = NULL;
4312
 
 
4313
 
  char buffer [1025];
4314
 
 
4315
 
  g_return_if_fail (main_window != NULL);
4316
 
 
4317
 
  mw = gm_mw_get_mw (main_window);
4318
 
 
4319
 
  va_list args;
4320
 
 
4321
 
  va_start (args, msg);
4322
 
 
4323
 
  if (msg == NULL)
4324
 
    buffer[0] = 0;
4325
 
  else 
4326
 
    vsnprintf (buffer, 1024, msg, args);
4327
 
 
4328
 
  gm_statusbar_flash_message (GM_STATUSBAR (mw->statusbar), "%s", buffer);
4329
 
  va_end (args);
4330
 
}
4331
 
 
4332
 
 
4333
 
void 
4334
 
gm_main_window_push_message (GtkWidget *main_window, 
4335
 
                             const char *msg, 
4336
 
                             ...)
4337
 
{
4338
 
  GmMainWindow *mw = NULL;
4339
 
 
4340
 
  char buffer [1025];
4341
 
 
4342
 
  g_return_if_fail (main_window != NULL);
4343
 
 
4344
 
  mw = gm_mw_get_mw (main_window);
4345
 
 
4346
 
  va_list args;
4347
 
 
4348
 
  va_start (args, msg);
4349
 
 
4350
 
  if (msg == NULL)
4351
 
    buffer[0] = 0;
4352
 
  else 
4353
 
    vsnprintf (buffer, 1024, msg, args);
4354
 
 
4355
 
  gm_statusbar_push_message (GM_STATUSBAR (mw->statusbar), "%s", buffer);
4356
 
  va_end (args);
4357
 
}
4358
 
 
4359
 
 
4360
 
void 
4361
 
gm_main_window_push_info_message (GtkWidget *main_window, 
4362
 
                                  const char *msg, 
4363
 
                                  ...)
4364
 
{
4365
 
  GmMainWindow *mw = NULL;
4366
 
  char *buffer;
4367
 
  
4368
 
  g_return_if_fail (main_window != NULL);
4369
 
 
4370
 
  mw = gm_mw_get_mw (main_window);
4371
 
 
4372
 
  va_list args;
4373
 
 
4374
 
  va_start (args, msg);
4375
 
  buffer = g_strdup_vprintf (msg, args);
4376
 
  gm_statusbar_push_info_message (GM_STATUSBAR (mw->statusbar), "%s", buffer);
4377
 
  g_free (buffer);
4378
 
  va_end (args);
4379
 
}
4380
 
 
4381
 
 
4382
 
void 
4383
 
gm_main_window_set_call_url (GtkWidget *main_window, 
4384
 
                             const char *url)
4385
 
{
4386
 
  GmMainWindow *mw = NULL;
4387
 
 
4388
 
  g_return_if_fail (main_window != NULL && url != NULL);
4389
 
 
4390
 
  mw = gm_mw_get_mw (main_window);
4391
 
 
4392
 
  g_return_if_fail (mw != NULL);
4393
 
 
4394
 
  gtk_entry_set_text (GTK_ENTRY (mw->entry), url);
4395
 
  gtk_editable_set_position (GTK_EDITABLE (mw->entry), -1);
4396
 
  gtk_widget_grab_focus (GTK_WIDGET (mw->entry));
4397
 
  gtk_editable_select_region (GTK_EDITABLE (mw->entry), -1, -1);
4398
 
}
4399
 
 
4400
 
 
4401
 
void 
4402
 
gm_main_window_append_call_url (GtkWidget *main_window, 
4403
 
                                const char *url)
4404
 
{
4405
 
  GmMainWindow *mw = NULL;
4406
 
  
4407
 
  int pos = -1;
4408
 
 
4409
 
  g_return_if_fail (main_window != NULL && url != NULL);
4410
 
 
4411
 
  mw = gm_mw_get_mw (main_window);
4412
 
 
4413
 
  g_return_if_fail (mw != NULL && url != NULL);
4414
 
 
4415
 
  if (gtk_editable_get_selection_bounds (GTK_EDITABLE (mw->entry), NULL, NULL)) 
4416
 
    gtk_editable_delete_selection (GTK_EDITABLE (mw->entry));
4417
 
 
4418
 
  pos = gtk_editable_get_position (GTK_EDITABLE (mw->entry));
4419
 
  gtk_editable_insert_text (GTK_EDITABLE (mw->entry), url, strlen (url), &pos);
4420
 
  gtk_editable_select_region (GTK_EDITABLE (mw->entry), -1, -1);
4421
 
  gtk_editable_set_position (GTK_EDITABLE (mw->entry), pos);
4422
 
}
4423
 
 
4424
 
 
4425
 
const char *
4426
 
gm_main_window_get_call_url (GtkWidget *main_window)
4427
 
{
4428
 
  GmMainWindow *mw = NULL;
4429
 
 
4430
 
  g_return_val_if_fail (main_window != NULL, NULL);
4431
 
 
4432
 
  mw = gm_mw_get_mw (main_window);
4433
 
 
4434
 
  g_return_val_if_fail (mw != NULL, NULL);
4435
 
 
4436
 
  return gtk_entry_get_text (GTK_ENTRY (mw->entry));
4437
 
}
4438
 
 
4439
 
 
4440
 
void 
4441
 
gm_main_window_clear_stats (GtkWidget *main_window)
4442
 
{
4443
 
  GmMainWindow *mw = NULL;
4444
 
 
4445
 
  g_return_if_fail (main_window != NULL);
4446
 
 
4447
 
  mw = gm_mw_get_mw (main_window);
4448
 
 
4449
 
  g_return_if_fail (mw != NULL);
4450
 
 
4451
 
  gm_main_window_update_stats (main_window, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
4452
 
  if (mw->qualitymeter)
4453
 
    gm_powermeter_set_level (GM_POWERMETER (mw->qualitymeter), 0.0);
4454
 
}
4455
 
 
4456
 
 
4457
 
void 
4458
 
gm_main_window_update_stats (GtkWidget *main_window,
4459
 
                             float lost,
4460
 
                             float late,
4461
 
                             float out_of_order,
4462
 
                             int jitter,
4463
 
                             G_GNUC_UNUSED float new_video_octets_received,
4464
 
                             G_GNUC_UNUSED float new_video_octets_transmitted,
4465
 
                             G_GNUC_UNUSED float new_audio_octets_received,
4466
 
                             G_GNUC_UNUSED float new_audio_octets_transmitted,
4467
 
                             unsigned int re_width,
4468
 
                             unsigned int re_height,
4469
 
                             unsigned int tr_width,
4470
 
                             unsigned int tr_height)
4471
 
{
4472
 
  GmMainWindow *mw = NULL;
4473
 
  
4474
 
  gchar *stats_msg = NULL;
4475
 
  gchar *stats_msg_tr = NULL;
4476
 
  gchar *stats_msg_re = NULL;
4477
 
 
4478
 
  int jitter_quality = 0;
4479
 
  gfloat quality_level = 0.0;
4480
 
 
4481
 
  
4482
 
  g_return_if_fail (main_window != NULL);
4483
 
 
4484
 
  mw = gm_mw_get_mw (main_window);
4485
 
 
4486
 
  g_return_if_fail (mw != NULL);
4487
 
 
4488
 
  if ((tr_width > 0) && (tr_height > 0))
4489
 
    /* Translators:
4490
 
     * TX is a common abbreviation for "transmit" */
4491
 
    stats_msg_tr = g_strdup_printf (_("TX: %dx%d "), tr_width, tr_height);
4492
 
 
4493
 
  if ((re_width > 0) && (re_height > 0)) 
4494
 
    /* Translators:
4495
 
     * RX is a common abbreviation for "receive" */
4496
 
    stats_msg_re = g_strdup_printf (_("RX: %dx%d "), re_width, re_height);
4497
 
 
4498
 
  stats_msg = g_strdup_printf (_("Lost packets: %.1f %%\nLate packets: %.1f %%\nOut of order packets: %.1f %%\nJitter buffer: %d ms%s%s%s"), 
4499
 
                                  lost, 
4500
 
                                  late, 
4501
 
                                  out_of_order, 
4502
 
                                  jitter,
4503
 
                                  (stats_msg_tr || stats_msg_re) ? "\nResolution: " : "", 
4504
 
                                  (stats_msg_tr) ? stats_msg_tr : "", 
4505
 
                                  (stats_msg_re) ? stats_msg_re : "");
4506
 
 
4507
 
  g_free(stats_msg_tr);
4508
 
  g_free(stats_msg_re);
4509
 
 
4510
 
 
4511
 
  if (mw->statusbar_ebox) {
4512
 
    gtk_widget_set_tooltip_text (GTK_WIDGET (mw->statusbar_ebox), stats_msg);
4513
 
  }
4514
 
  g_free (stats_msg);
4515
 
 
4516
 
    /* "arithmetics" for the quality level */
4517
 
    /* Thanks Snark for the math hints */
4518
 
    if (jitter < 30)
4519
 
      jitter_quality = 100;
4520
 
    if (jitter >= 30 && jitter < 50)
4521
 
      jitter_quality = 100 - (jitter - 30);
4522
 
    if (jitter >= 50 && jitter < 100)
4523
 
      jitter_quality = 80 - (jitter - 50) * 20 / 50;
4524
 
    if (jitter >= 100 && jitter < 150)
4525
 
      jitter_quality = 60 - (jitter - 100) * 20 / 50;
4526
 
    if (jitter >= 150 && jitter < 200)
4527
 
      jitter_quality = 40 - (jitter - 150) * 20 / 50;
4528
 
    if (jitter >= 200 && jitter < 300)
4529
 
      jitter_quality = 20 - (jitter - 200) * 20 / 100;
4530
 
    if (jitter >= 300 || jitter_quality < 0)
4531
 
      jitter_quality = 0;
4532
 
 
4533
 
    quality_level = (float) jitter_quality / 100;
4534
 
 
4535
 
    if ( (lost > 0.0) ||
4536
 
         (late > 0.0) ||
4537
 
         ((out_of_order > 0.0) && quality_level > 0.2) ) {
4538
 
      quality_level = 0.2;
4539
 
    }
4540
 
 
4541
 
    if ( (lost > 0.02) ||
4542
 
         (late > 0.02) ||
4543
 
         (out_of_order > 0.02) ) {
4544
 
      quality_level = 0;
4545
 
    }
4546
 
 
4547
 
    if (mw->qualitymeter)
4548
 
      gm_powermeter_set_level (GM_POWERMETER (mw->qualitymeter),
4549
 
                               quality_level);
4550
 
}
4551
 
 
4552
 
 
4553
 
GdkPixbuf *
4554
 
gm_main_window_get_current_picture (GtkWidget *main_window)
4555
 
{
4556
 
  GmMainWindow *mw = NULL;
4557
 
  
4558
 
  g_return_val_if_fail (main_window != NULL, NULL);
4559
 
 
4560
 
  mw = gm_mw_get_mw (main_window);
4561
 
 
4562
 
  g_return_val_if_fail (mw != NULL, NULL);
4563
 
 
4564
 
  return gtk_image_get_pixbuf (GTK_IMAGE (mw->main_video_image));
4565
 
}
4566
 
 
4567
 
 
4568
 
void 
4569
 
gm_main_window_set_stay_on_top (GtkWidget *main_window,
4570
 
                                gboolean stay_on_top)
4571
 
{
4572
 
  GmMainWindow *mw = NULL;
4573
 
  
4574
 
  GdkWindow *gm_window = NULL;
4575
 
 
4576
 
  g_return_if_fail (main_window != NULL);
4577
 
  mw = gm_mw_get_mw (main_window);
4578
 
  g_return_if_fail (mw != NULL);
4579
 
  
4580
 
  gm_window = GDK_WINDOW (main_window->window);
4581
 
 
4582
 
  /* Update the stay-on-top attribute */
4583
 
  gdk_window_set_always_on_top (GDK_WINDOW (gm_window), stay_on_top);
4584
 
}
4585
 
 
4586
 
/* The main () */
4587
 
int 
4588
 
main (int argc, 
4589
 
      char ** argv, 
4590
 
      char ** envp)
4591
 
{
4592
 
  GOptionContext *context = NULL;
4593
 
 
4594
 
  GtkWidget *main_window = NULL;
4595
 
  GtkWidget *assistant_window = NULL;
4596
 
 
4597
 
  GtkWidget *dialog = NULL;
4598
 
  
4599
 
  gchar *path = NULL;
4600
 
  gchar *url = NULL;
4601
 
  gchar *msg = NULL;
4602
 
  gchar *title = NULL;
4603
 
 
4604
 
  int debug_level = 0;
4605
 
  int debug_level_up = 0;
4606
 
  int error = -1;
4607
 
#ifdef HAVE_GNOME
4608
 
  GnomeProgram *program;
4609
 
#endif
4610
 
 
4611
 
  /* Globals */
4612
 
#ifndef WIN32
4613
 
  if (!XInitThreads ())
4614
 
    exit (1);
4615
 
#endif
4616
 
 
4617
 
  /* PWLIB initialization */
4618
 
  PProcess::PreInitialise (argc, argv, envp);
4619
 
  
4620
 
  /* GTK+ initialization */
4621
 
  g_type_init ();
4622
 
  g_thread_init (NULL);
4623
 
//  gdk_threads_init ();
4624
 
#ifndef WIN32
4625
 
  signal (SIGPIPE, SIG_IGN);
4626
 
#endif
4627
 
 
4628
 
  /* initialize platform-specific code */
4629
 
  gm_platform_init ();
4630
 
 
4631
 
  /* Configuration backend initialization */
4632
 
  gm_conf_init ();
4633
 
 
4634
 
  /* Gettext initialization */
4635
 
  path = g_build_filename (DATA_DIR, "locale", NULL);
4636
 
  textdomain (GETTEXT_PACKAGE);
4637
 
  bindtextdomain (GETTEXT_PACKAGE, path);
4638
 
  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
4639
 
  g_free (path);
4640
 
 
4641
 
  /* Arguments initialization */
4642
 
  GOptionEntry arguments [] =
4643
 
    {
4644
 
      {
4645
 
        "debug", 'd', 0, G_OPTION_ARG_INT, &debug_level, 
4646
 
       N_("Prints debug messages in the console (level between 1 and 5)"), 
4647
 
       NULL
4648
 
      },
4649
 
      {
4650
 
        "debug_user_plane", 'u', 0, G_OPTION_ARG_INT, &debug_level_up, 
4651
 
       N_("Prints user plane debug messages in the console (level between 1 and 4)"), 
4652
 
       NULL
4653
 
      },
4654
 
      {
4655
 
        "call", 'c', 0, G_OPTION_ARG_STRING, &url,
4656
 
        N_("Makes Ekiga call the given URI"),
4657
 
        NULL
4658
 
      },
4659
 
      {
4660
 
        NULL, 0, 0, (GOptionArg)0, NULL,
4661
 
        NULL,
4662
 
        NULL
4663
 
      }
4664
 
    };
4665
 
  context = g_option_context_new (NULL);
4666
 
  g_option_context_add_main_entries (context, arguments, PACKAGE_NAME);
4667
 
  g_option_context_set_help_enabled (context, TRUE);
4668
 
  
4669
 
  /* GNOME Initialisation */
4670
 
#ifdef HAVE_GNOME
4671
 
  program = gnome_program_init (PACKAGE_NAME, VERSION,
4672
 
                                LIBGNOMEUI_MODULE, argc, argv,
4673
 
                                GNOME_PARAM_GOPTION_CONTEXT, context,
4674
 
                                GNOME_PARAM_HUMAN_READABLE_NAME, "ekiga",
4675
 
                                GNOME_PARAM_APP_DATADIR, DATA_DIR,
4676
 
                                (void *) NULL);
4677
 
#else
4678
 
  g_option_context_add_group (context, gtk_get_option_group (TRUE));
4679
 
  g_option_context_parse (context, &argc, &argv, NULL);
4680
 
  g_option_context_free (context);
4681
 
#endif
4682
 
 
4683
 
#ifdef HAVE_NOTIFY
4684
 
  notify_init (PACKAGE_NAME);
4685
 
#endif
4686
 
 
4687
 
#ifndef WIN32
4688
 
  char* text_label =  g_strdup_printf ("%d", debug_level);
4689
 
  setenv ("PTLIB_TRACE_CODECS", text_label, TRUE);
4690
 
  g_free (text_label);
4691
 
  text_label =  g_strdup_printf ("%d", debug_level_up);
4692
 
  setenv ("PTLIB_TRACE_CODECS_USER_PLANE", text_label, TRUE);
4693
 
  g_free (text_label);
4694
 
#else
4695
 
  char* text_label =  g_strdup_printf ("PTLIB_TRACE_CODECS=%d", debug_level);
4696
 
  _putenv (text_label);
4697
 
  g_free (text_label);
4698
 
  text_label =  g_strdup_printf ("PTLIB_TRACE_CODECS_USER_PLANE=%d", debug_level_up);
4699
 
  _putenv (text_label);
4700
 
  g_free (text_label);
4701
 
#endif
4702
 
 
4703
 
  /* Ekiga initialisation */
4704
 
  static GnomeMeeting instance;
4705
 
 
4706
 
  if (debug_level != 0)
4707
 
    PTrace::Initialise (PMAX (PMIN (5, debug_level), 0), NULL,
4708
 
                        PTrace::Timestamp | PTrace::Thread
4709
 
                        | PTrace::Blocks | PTrace::DateAndTime);
4710
 
#ifdef EKIGA_REVISION
4711
 
  PTRACE(1, "Ekiga SVN revision: " << EKIGA_REVISION);
4712
 
#endif
4713
 
 
4714
 
#ifdef HAVE_DBUS
4715
 
  if (!ekiga_dbus_claim_ownership ()) {
4716
 
    ekiga_dbus_client_show ();
4717
 
    if (url != NULL)
4718
 
      ekiga_dbus_client_connect (url);
4719
 
    exit (0);
4720
 
  }
4721
 
#endif
4722
 
 
4723
 
  /* Configuration database initialization */
4724
 
#ifdef HAVE_GCONF
4725
 
  if (!gnomemeeting_conf_check ()) 
4726
 
    error = 3;
4727
 
#endif
4728
 
 
4729
 
  /* Init gm_conf */
4730
 
  gm_conf_watch ();
4731
 
 
4732
 
  GnomeMeeting::Process ()->InitEngine ();
4733
 
  GnomeMeeting::Process ()->BuildGUI ();
4734
 
  GnomeMeeting::Process ()->DetectInterfaces ();
4735
 
  
4736
 
  /* Add depreciated notifiers */
4737
 
  gnomemeeting_conf_init ();
4738
 
 
4739
 
  /* Show the window if there is no error, exit with a popup if there
4740
 
   * is a fatal error.
4741
 
   */
4742
 
  main_window = GnomeMeeting::Process ()->GetMainWindow ();
4743
 
  GmMainWindow *mw = gm_mw_get_mw (main_window); //TODO no gm_mw_get_mw here
4744
 
  Ekiga::CallCore *call_core = dynamic_cast<Ekiga::CallCore *> (mw->core.get ("call-core"));
4745
 
  if (error == -1) {
4746
 
 
4747
 
    if (gm_conf_get_int (GENERAL_KEY "version") 
4748
 
        < 1000 * MAJOR_VERSION + 10 * MINOR_VERSION + BUILD_NUMBER) {
4749
 
 
4750
 
      gnomemeeting_conf_upgrade ();
4751
 
      assistant_window = GnomeMeeting::Process ()->GetAssistantWindow ();
4752
 
      gtk_widget_show_all (assistant_window);
4753
 
    }
4754
 
    else {
4755
 
 
4756
 
      /* Show the main window */
4757
 
      if (!gm_conf_get_bool (USER_INTERFACE_KEY "start_hidden")) 
4758
 
        gtk_widget_show (main_window);
4759
 
      else
4760
 
        g_timeout_add (15000, (GtkFunction) gnomemeeting_tray_hack_cb, NULL);
4761
 
    }
4762
 
 
4763
 
    /* Call the given host if needed */
4764
 
    if (url) 
4765
 
      call_core->dial (url);
4766
 
  }
4767
 
  else {
4768
 
 
4769
 
    switch (error) {
4770
 
 
4771
 
    case 1:
4772
 
      title = g_strdup (_("No usable audio plugin detected"));
4773
 
      msg = g_strdup (_("Ekiga didn't find any usable audio plugin. Make sure that your installation is correct."));
4774
 
      break;
4775
 
    case 2:
4776
 
      title = g_strdup (_("No usable audio codecs detected"));
4777
 
      msg = g_strdup (_("Ekiga didn't find any usable audio codec. Make sure that your installation is correct."));
4778
 
      break;
4779
 
#ifdef HAVE_GCONF
4780
 
    case 3:
4781
 
      {
4782
 
        gchar *key_name = g_strdup ("\"/apps/" PACKAGE_NAME "/general/gconf_test_age\"");
4783
 
        title = g_strdup (_("Configuration database corruption"));
4784
 
        msg = g_strdup_printf (_("Ekiga got an invalid value for the configuration key %s.\n\nIt probably means that your configuration schemas have not been correctly installed or that the permissions are not correct.\n\nPlease check the FAQ (http://www.ekiga.org/), the troubleshooting section of the GConf site (http://www.gnome.org/projects/gconf/) or the mailing list archives for more information (http://mail.gnome.org) about this problem."), key_name);
4785
 
        g_free (key_name);
4786
 
      }
4787
 
      break;
4788
 
#endif
4789
 
    default:
4790
 
      break;
4791
 
    }
4792
 
 
4793
 
    dialog = gtk_message_dialog_new (GTK_WINDOW (main_window), 
4794
 
                                     GTK_DIALOG_MODAL, 
4795
 
                                     GTK_MESSAGE_ERROR,
4796
 
                                     GTK_BUTTONS_OK, NULL);
4797
 
 
4798
 
    gtk_window_set_title (GTK_WINDOW (dialog), title);
4799
 
    gtk_label_set_markup (GTK_LABEL (GTK_MESSAGE_DIALOG (dialog)->label), msg);
4800
 
  
4801
 
    g_signal_connect (GTK_OBJECT (dialog), "response",
4802
 
                      G_CALLBACK (quit_callback),
4803
 
                      GTK_OBJECT (dialog));
4804
 
    g_signal_connect_swapped (GTK_OBJECT (dialog), "response",
4805
 
                              G_CALLBACK (gtk_widget_destroy),
4806
 
                              GTK_OBJECT (dialog));
4807
 
  
4808
 
    gtk_widget_show_all (dialog);
4809
 
 
4810
 
    g_free (title);
4811
 
    g_free (msg);
4812
 
  }
4813
 
 
4814
 
#ifdef HAVE_DBUS
4815
 
  /* Create the dbus server instance */
4816
 
  EkigaDBusComponent *dbus_component = ekiga_dbus_component_new (&mw->core);
4817
 
#endif
4818
 
 
4819
 
  /* The GTK loop */
4820
 
  //gdk_threads_enter ();
4821
 
  gtk_main ();
4822
 
  //gdk_threads_leave ();
4823
 
 
4824
 
#ifdef HAVE_DBUS
4825
 
  g_object_unref (dbus_component);
4826
 
#endif
4827
 
 
4828
 
  /* Exit Ekiga */
4829
 
  GnomeMeeting::Process ()->Exit ();
4830
 
 
4831
 
  /* Save and shutdown the configuration */
4832
 
  gm_conf_save ();
4833
 
  gm_conf_shutdown ();
4834
 
 
4835
 
#ifdef HAVE_GNOME
4836
 
  g_object_unref (program);
4837
 
#endif
4838
 
 
4839
 
  /* deinitialize platform-specific code */
4840
 
  gm_platform_shutdown ();
4841
 
 
4842
 
#ifdef HAVE_NOTIFY
4843
 
  notify_uninit ();
4844
 
#endif
4845
 
 
4846
 
  return 0;
4847
 
}
4848
 
 
4849
 
 
4850
 
#ifdef WIN32
4851
 
 
4852
 
typedef struct {
4853
 
  int newmode;
4854
 
} _startupinfo;
4855
 
 
4856
 
extern "C" void __getmainargs (int *argcp, char ***argvp, char ***envp, int glob, _startupinfo *sinfo);
4857
 
int 
4858
 
APIENTRY WinMain (HINSTANCE hInstance,
4859
 
                  HINSTANCE hPrevInstance,
4860
 
                  LPSTR     lpCmdLine,
4861
 
                  int       nCmdShow)
4862
 
{
4863
 
  HANDLE ekr_mutex;
4864
 
  int iresult;
4865
 
  char **env;
4866
 
  char **argv;
4867
 
  int argc;
4868
 
  _startupinfo info = {0};
4869
 
 
4870
 
  ekr_mutex = CreateMutex (NULL, FALSE, "EkigaIsRunning");
4871
 
  if (GetLastError () == ERROR_ALREADY_EXISTS)
4872
 
    MessageBox (NULL, "Ekiga is running already !", "Ekiga - 2nd instance", MB_ICONEXCLAMATION | MB_OK);
4873
 
  else {
4874
 
 
4875
 
    /* use msvcrt.dll to parse command line */
4876
 
    __getmainargs (&argc, &argv, &env, 0, &info);
4877
 
 
4878
 
    std::freopen("stdout.txt", "w", stdout);
4879
 
    std::freopen("stderr.txt", "w", stderr);
4880
 
 
4881
 
    iresult = main (argc, argv, env);
4882
 
  }
4883
 
  CloseHandle (ekr_mutex);
4884
 
  return iresult;
4885
 
}
4886
 
#endif
4887