~noskcaj/ubuntu/trusty/ekiga/ftbfs

« back to all changes in this revision

Viewing changes to src/gui/main.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2006-01-28 18:49:20 UTC
  • Revision ID: james.westby@ubuntu.com-20060128184920-v525ihmiv7id40xs
Tags: upstream-1.99.0
ImportĀ upstreamĀ versionĀ 1.99.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
/* GnomeMeeting -- A 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
 
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
18
 *
 
19
 *
 
20
 * GnomeMeeting 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 OpenH323 and Pwlib, and distribute the combination, without
 
23
 * applying the requirements of the GNU GPL to the OpenH323 program, as long
 
24
 * as you do follow the requirements of the GNU GPL for all the rest of the
 
25
 * 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
 
 
39
#include "../../config.h"
 
40
 
 
41
#include "main.h"
 
42
#include "callshistory.h"
 
43
 
 
44
#include "pcss.h"
 
45
#include "ekiga.h"
 
46
#include "chat.h"
 
47
#include "config.h"
 
48
#include "misc.h"
 
49
#include "callbacks.h"
 
50
#include "statusicon.h"
 
51
#include "audio.h"
 
52
#include "urlhandler.h"
 
53
 
 
54
#include "gmdialog.h"
 
55
#include "gmentrydialog.h"
 
56
#include "gmstatusbar.h"
 
57
#include "gmconnectbutton.h"
 
58
#include "gmstockicons.h"
 
59
#include "gmconf.h"
 
60
#include "gmcontacts.h"
 
61
#include "gmmenuaddon.h"
 
62
#include "gmstatsdrawingarea.h"
 
63
#include "gmlevelmeter.h"
 
64
 
 
65
 
 
66
#include "../pixmaps/text_logo.xpm"
 
67
#include "../pixmaps/gm_both_incrusted_frame.xpm"
 
68
 
 
69
#include <gdk/gdkkeysyms.h>
 
70
 
 
71
#ifndef DISABLE_GNOME
 
72
#include <libgnomeui/gnome-window-icon.h>
 
73
#include "bonobo.h"
 
74
#endif
 
75
 
 
76
#ifndef WIN32
 
77
#include <gdk/gdkx.h>
 
78
#endif
 
79
 
 
80
#if defined(P_FREEBSD) || defined (P_MACOSX)
 
81
#include <libintl.h>
 
82
#endif
 
83
 
 
84
#include <libxml/parser.h>
 
85
 
 
86
#ifdef HAS_SDL
 
87
#include <SDL.h>
 
88
#endif
 
89
 
 
90
#ifdef WIN32
 
91
#include "winpaths.h"
 
92
#endif
 
93
 
 
94
#define GM_MAIN_WINDOW(x) (GmWindow *) (x)
 
95
 
 
96
 
 
97
/* Declarations */
 
98
struct _GmWindow
 
99
{
 
100
  GtkWidget *input_signal;
 
101
  GtkWidget *output_signal;
 
102
  GtkObject *adj_input_volume;
 
103
  GtkObject *adj_output_volume;
 
104
  GtkWidget *audio_volume_frame;
 
105
 
 
106
  GtkObject *adj_whiteness;
 
107
  GtkObject *adj_brightness;
 
108
  GtkObject *adj_colour;
 
109
  GtkObject *adj_contrast;
 
110
  GtkWidget *video_settings_frame;
 
111
  
 
112
  GtkTooltips *tips;
 
113
  GtkAccelGroup *accel;
 
114
 
 
115
  GtkWidget *main_menu;
 
116
  
 
117
#ifdef DISABLE_GNOME
 
118
  GtkWidget *window_vbox;
 
119
  GtkWidget *window_hbox;
 
120
#endif
 
121
 
 
122
  GtkWidget *status_label;
 
123
  GtkWidget *info_label;
 
124
 
 
125
  GtkWidget *statusbar;
 
126
  GtkWidget *statusbar_ebox;
 
127
  GtkWidget *combo;
 
128
  GtkWidget *main_notebook;
 
129
  GtkWidget *main_video_image;
 
130
  GtkWidget *local_video_image;
 
131
  GtkWidget *local_video_window;
 
132
  GtkWidget *remote_video_image;
 
133
  GtkWidget *remote_video_window;
 
134
  GtkWidget *video_frame;
 
135
  GtkWidget *preview_button;
 
136
  GtkWidget *connect_button;
 
137
  GtkWidget *video_chan_button;
 
138
  GtkWidget *audio_chan_button;
 
139
  GtkWidget *incoming_call_popup;
 
140
  GtkWidget *transfer_call_popup;
 
141
  GtkWidget *stats_label;
 
142
  GtkWidget *stats_drawing_area;
 
143
 
 
144
#ifdef HAS_SDL
 
145
  SDL_Surface *screen;
 
146
#endif
 
147
};
 
148
 
 
149
 
 
150
typedef struct _GmWindow GmWindow;
 
151
 
 
152
 
 
153
#define GM_WINDOW(x) (GmWindow *) (x)
 
154
 
 
155
 
 
156
/* GUI Functions */
 
157
 
 
158
 
 
159
/* DESCRIPTION  : / 
 
160
 * BEHAVIOR     : Frees a GmMainWindow and its content.
 
161
 * PRE          : A non-NULL pointer to a GmMainWindow.
 
162
 */
 
163
static void gm_mw_destroy (gpointer);
 
164
 
 
165
 
 
166
/* DESCRIPTION  : / 
 
167
 * BEHAVIOR     : Returns a pointer to the private GmMainWindow
 
168
 *                used by the main book GMObject.
 
169
 * PRE          : The given GtkWidget pointer must be the main window GMObject. 
 
170
 */
 
171
static GmWindow *gm_mw_get_mw (GtkWidget *);
 
172
 
 
173
 
 
174
/* DESCRIPTION  :  /
 
175
 * BEHAVIOR     :  Create the toolbars of the main window.
 
176
 *                 The toolbars are created in their initial state, with
 
177
 *                 required items being unsensitive.
 
178
 * PRE          :  The main window GMObject.
 
179
 */
 
180
static void gm_mw_init_toolbars (GtkWidget *);
 
181
 
 
182
 
 
183
/* DESCRIPTION  :  /
 
184
 * BEHAVIOR     :  Create the menu of the main window.
 
185
 *                 The menu is created in its initial state, with
 
186
 *                 required items being unsensitive.
 
187
 * PRE          :  The main window GMObject. The statusbar must have been
 
188
 *                 created.
 
189
 */
 
190
static void gm_mw_init_menu (GtkWidget *);
 
191
 
 
192
 
 
193
/* DESCRIPTION  : /
 
194
 * BEHAVIOR     : Builds the stats part of the main window.
 
195
 * PRE          : The given GtkWidget pointer must be the main window GMObject. 
 
196
 */
 
197
static void gm_mw_init_stats (GtkWidget *);
 
198
 
 
199
 
 
200
/* DESCRIPTION  : /
 
201
 * BEHAVIOR     : Builds the dialpad part of the main window.
 
202
 * PRE          : The given GtkWidget pointer must be the main window GMObject. 
 
203
 */
 
204
static void gm_mw_init_dialpad (GtkWidget *);
 
205
 
 
206
 
 
207
/* DESCRIPTION  : /
 
208
 * BEHAVIOR     : Builds the video settings part of the main window.
 
209
 * PRE          : The given GtkWidget pointer must be the main window GMObject. 
 
210
 */
 
211
static void gm_mw_init_video_settings (GtkWidget *);
 
212
 
 
213
 
 
214
/* DESCRIPTION  : /
 
215
 * BEHAVIOR     : Builds the audio settings part of the main window.
 
216
 * PRE          : The given GtkWidget pointer must be the main window GMObject. 
 
217
 */
 
218
static void gm_mw_init_audio_settings (GtkWidget *);
 
219
 
 
220
 
 
221
/* DESCRIPTION   :  /
 
222
 * BEHAVIOR      : Creates a video window.
 
223
 * PRE           : The title of the window, the drawing area and the window
 
224
 *                 name that will be used by gnomemeeting_window_show/hide.
 
225
 */
 
226
GtkWidget *gm_mw_video_window_new (GtkWidget *,
 
227
                                   gboolean,
 
228
                                   gchar *,
 
229
                                   GtkWidget *&,
 
230
                                   gchar *);
 
231
 
 
232
 
 
233
#ifdef HAS_SDL
 
234
/* DESCRIPTION   : /
 
235
 * BEHAVIOR      : Creates a video window.
 
236
 * PRE           : /
 
237
 */
 
238
void gm_mw_init_fullscreen_video_window (GtkWidget *);
 
239
 
 
240
 
 
241
/* DESCRIPTION   : /
 
242
 * BEHAVIOR      : Toggle the fullscreen state of the main window.
 
243
 * PRE           : /
 
244
 */
 
245
void gm_mw_toggle_fullscreen (GtkWidget *);
 
246
        
 
247
 
 
248
/* DESCRIPTION   : /
 
249
 * BEHAVIOR      : Return TRUE if the Esc key is pressed.
 
250
 * PRE           : /
 
251
 */
 
252
gboolean gm_mw_poll_fullscreen_video_window (GtkWidget *);
 
253
        
 
254
 
 
255
/* DESCRIPTION   : /
 
256
 * BEHAVIOR      : Creates a video window.
 
257
 * PRE           : /
 
258
 */
 
259
void gm_mw_destroy_fullscreen_video_window (GtkWidget *);
 
260
#endif
 
261
 
 
262
 
 
263
/* DESCRIPTION  :  /
 
264
 * BEHAVIOR     :  Show / hide the video section.
 
265
 * PRE          :  The main window GMObject.
 
266
 */
 
267
void gm_mw_show_video_section (GtkWidget *,
 
268
                               gboolean);
 
269
 
 
270
 
 
271
/* DESCRIPTION  :  /
 
272
 * BEHAVIOR     :  Show / hide the video section.
 
273
 * PRE          :  The main window GMObject.
 
274
 */
 
275
void gm_mw_show_control_panel (GtkWidget *,
 
276
                               gboolean);
 
277
 
 
278
 
 
279
/* Callbacks */
 
280
 
 
281
/* DESCRIPTION  :  /
 
282
 * BEHAVIOR     :  Set the current active call on hold.
 
283
 * PRE          :  /
 
284
 */
 
285
static void hold_current_call_cb (GtkWidget *,
 
286
                                  gpointer);
 
287
 
 
288
 
 
289
/* DESCRIPTION  :  /
 
290
 * BEHAVIOR     :  Set the current active call audio or video channel on pause
 
291
 *                 or not and update the GUI accordingly.
 
292
 * PRE          :  GPOINTER_TO_INT (data) = 0 if audio, 1 if video.
 
293
 */
 
294
static void pause_current_call_channel_cb (GtkWidget *,
 
295
                                           gpointer);
 
296
 
 
297
 
 
298
/* DESCRIPTION  :  /
 
299
 * BEHAVIOR     :  Creates a dialog to transfer the current call and transfer
 
300
 *                 it if required.
 
301
 * PRE          :  The parent window.
 
302
 */
 
303
static void transfer_current_call_cb (GtkWidget *,
 
304
                                      gpointer);
 
305
 
 
306
 
 
307
/* DESCRIPTION  :  This callback is called when a video window is shown.
 
308
 * BEHAVIOR     :  Set the WM HINTS to stay-on-top if the config key is set
 
309
 *                 to true.
 
310
 * PRE          :  /
 
311
 */
 
312
static void video_window_shown_cb (GtkWidget *,
 
313
                                   gpointer);
 
314
 
 
315
 
 
316
/* DESCRIPTION  :  This callback is called when the user changes the
 
317
 *                 audio settings sliders in the main notebook.
 
318
 * BEHAVIOR     :  Update the volume of the choosen mixers. If the update
 
319
 *                 fails, the sliders are put back to 0.
 
320
 * PRE          :  The main window GMObject.
 
321
 */
 
322
static void audio_volume_changed_cb (GtkAdjustment *, 
 
323
                                     gpointer);
 
324
 
 
325
 
 
326
/* DESCRIPTION  :  This callback is called when the user changes one of the 
 
327
 *                 video settings sliders in the main notebook.
 
328
 * BEHAVIOR     :  Updates the value in real time, if it fails, reset 
 
329
 *                 all sliders to 0.
 
330
 * PRE          :  gpointer is a valid pointer to the main window GmObject.
 
331
 */
 
332
static void video_settings_changed_cb (GtkAdjustment *, 
 
333
                                       gpointer);
 
334
 
 
335
 
 
336
/* DESCRIPTION  :  This callback is called when the user drops a contact.
 
337
 * BEHAVIOR     :  Calls the user corresponding to the contact or transfer
 
338
 *                 the calls to the user.
 
339
 * PRE          :  Assumes data hides a GmWindow*
 
340
 */
 
341
static void dnd_call_contact_cb (GtkWidget *widget, 
 
342
                                 GmContact *contact,
 
343
                                 gint x, 
 
344
                                 gint y, 
 
345
                                 gpointer data);
 
346
 
 
347
 
 
348
/* DESCRIPTION  :  This callback is called when the user changes the
 
349
 *                 page in the main notebook.
 
350
 * BEHAVIOR     :  Update the config key accordingly.
 
351
 * PRE          :  A valid pointer to the main window GmObject.
 
352
 */
 
353
static void control_panel_section_changed_cb (GtkNotebook *, 
 
354
                                              GtkNotebookPage *,
 
355
                                              gint, 
 
356
                                              gpointer);
 
357
 
 
358
 
 
359
/* DESCRIPTION  :  This callback is called when the user 
 
360
 *                 clicks on the dialpad button.
 
361
 * BEHAVIOR     :  Generates a dialpad event.
 
362
 * PRE          :  A valid pointer to the main window GMObject.
 
363
 */
 
364
static void dialpad_button_clicked_cb (GtkButton *, 
 
365
                                       gpointer);
 
366
 
 
367
 
 
368
/* DESCRIPTION  :  This callback is called when the user tries to close
 
369
 *                 the application using the window manager.
 
370
 * BEHAVIOR     :  Calls the real callback if the notification icon is 
 
371
 *                 not shown else hide GM.
 
372
 * PRE          :  A valid pointer to the main window GMObject.
 
373
 */
 
374
static gint window_closed_cb (GtkWidget *, 
 
375
                              GdkEvent *, 
 
376
                              gpointer);
 
377
 
 
378
 
 
379
/* DESCRIPTION  :  This callback is called when the user changes the zoom
 
380
 *                 factor in the menu, and chooses to zoom in.
 
381
 * BEHAVIOR     :  zoom *= 2.
 
382
 * PRE          :  The GConf key to update with the new zoom.
 
383
 */
 
384
static void zoom_in_changed_cb (GtkWidget *,
 
385
                                gpointer);
 
386
 
 
387
 
 
388
/* DESCRIPTION  :  This callback is called when the user changes the zoom
 
389
 *                 factor in the menu, and chooses to zoom in.
 
390
 * BEHAVIOR     :  zoom /= 2.
 
391
 * PRE          :  The GConf key to update with the new zoom.
 
392
 */
 
393
static void zoom_out_changed_cb (GtkWidget *,
 
394
                                 gpointer);
 
395
 
 
396
 
 
397
/* DESCRIPTION  :  This callback is called when the user changes the zoom
 
398
 *                 factor in the menu, and chooses to zoom in.
 
399
 * BEHAVIOR     :  zoom = 1.
 
400
 * PRE          :  The GConf key to update with the new zoom.
 
401
 */
 
402
static void zoom_normal_changed_cb (GtkWidget *,
 
403
                                    gpointer);
 
404
 
 
405
 
 
406
#ifdef HAS_SDL
 
407
/* DESCRIPTION  :  This callback is called when the user toggles fullscreen
 
408
 *                 factor in the popup menu.
 
409
 * BEHAVIOR     :  Toggles the fullscreen configuration key. 
 
410
 * PRE          :  / 
 
411
 */
 
412
static void fullscreen_changed_cb (GtkWidget *,
 
413
                                   gpointer);
 
414
#endif
 
415
 
 
416
 
 
417
/* DESCRIPTION  :  This callback is called when the user toggles an 
 
418
 *                 item in the speed dials menu.
 
419
 * BEHAVIOR     :  Calls the given speed dial.
 
420
 * PRE          :  data is the speed dial as a gchar *
 
421
 */
 
422
static void speed_dial_menu_item_selected_cb (GtkWidget *,
 
423
                                              gpointer);
 
424
 
 
425
 
 
426
/* DESCRIPTION  :  This callback is called when the user changes the URL
 
427
 *                 in the URL bar.
 
428
 * BEHAVIOR     :  It udpates the tooltip with the new URL.
 
429
 * PRE          :  A valid pointer to the main window GMObject. 
 
430
 */
 
431
static void url_changed_cb (GtkEditable *, 
 
432
                            gpointer);
 
433
 
 
434
 
 
435
/* DESCRIPTION  :  This callback is called when the user selects a match in the
 
436
 *                 possible URLs list.
 
437
 * BEHAVIOR     :  It udpates the URL bar and calls it.
 
438
 * PRE          :  /
 
439
 */
 
440
static gboolean completion_url_selected_cb (GtkEntryCompletion *,
 
441
                                            GtkTreeModel *,
 
442
                                            GtkTreeIter *,
 
443
                                            gpointer);
 
444
 
 
445
 
 
446
/* DESCRIPTION  :  This callback is called when the user clicks on enter
 
447
 *                 with a non-empty URL bar.
 
448
 * BEHAVIOR     :  It calls the URL.
 
449
 * PRE          :  /
 
450
 */
 
451
static void url_activated_cb (GtkWidget *, 
 
452
                              gpointer);
 
453
 
 
454
 
 
455
/* DESCRIPTION  :  This callback is called when the user presses the view 
 
456
 *                 mode button in the toolbar. 
 
457
 * BEHAVIOR     :  Updates the config cache to switch the video view.
 
458
 * PRE          :  /
 
459
 */
 
460
static void view_mode_button_clicked_cb (GtkWidget *, 
 
461
                                         gpointer);
 
462
 
 
463
 
 
464
/* DESCRIPTION  :  This callback is called when the user presses a
 
465
 *                 button in the toolbar. 
 
466
 *                 (See menu_toggle_changed)
 
467
 * BEHAVIOR     :  Updates the config cache.
 
468
 * PRE          :  data is the key.
 
469
 */
 
470
static void toolbar_toggle_button_changed_cb (GtkWidget *, 
 
471
                                              gpointer);
 
472
 
 
473
 
 
474
/* DESCRIPTION  :  This callback is called when the status bar is clicked.
 
475
 * BEHAVIOR     :  Clear all info message, not normal messages. Reset the
 
476
 *                 endpoint missed calls number.
 
477
 * PRE          :  The main window GMObject.
 
478
 */
 
479
static gboolean statusbar_clicked_cb (GtkWidget *,
 
480
                                      GdkEventButton *,
 
481
                                      gpointer);
 
482
 
 
483
 
 
484
/* DESCRIPTION  :  This callback is called on delete event for the incoming
 
485
 *                 call dialog.
 
486
 * BEHAVIOR     :  Disconnects and set the pointer to NULL, the destroy signal
 
487
 *                 will destroy the dialog by itself.
 
488
 * PRE          :  A valid main window GMObject.
 
489
 */
 
490
static gboolean delete_incoming_call_dialog_cb (GtkWidget *,
 
491
                                                GdkEvent *,
 
492
                                                gpointer);
 
493
 
 
494
 
 
495
/* DESCRIPTION  :  Called when the chat icon is clicked.
 
496
 * BEHAVIOR     :  Show the chat window or hide it.
 
497
 *                 If the chat window is shown during a call, the corresponding
 
498
 *                 call tab is added.
 
499
 *                 Reset the tray flashing state when the window is shown.
 
500
 * PRE          :  The pointer must be a valid pointer to the chat window
 
501
 *                 GMObject.
 
502
 */
 
503
static void show_chat_window_cb (GtkWidget *w,
 
504
                                 gpointer data);
 
505
 
 
506
 
 
507
/* DESCRIPTION  :  This callback is called in an idle loop.
 
508
 * BEHAVIOR     :  Do the job of gm_main_window_urls_history_update, but 
 
509
 *                 async.
 
510
 * PRE          :  A valid main window GMObject.
 
511
 */
 
512
static gboolean gm_mw_urls_history_update_cb (gpointer data);
 
513
 
 
514
 
 
515
/* Implementation */
 
516
static void
 
517
gm_mw_destroy (gpointer m)
 
518
{
 
519
  GmWindow *mw = GM_WINDOW (m);
 
520
  
 
521
  g_return_if_fail (mw != NULL);
 
522
 
 
523
  delete ((GmWindow *) mw);
 
524
}
 
525
 
 
526
 
 
527
static GmWindow *
 
528
gm_mw_get_mw (GtkWidget *main_window)
 
529
{
 
530
  g_return_val_if_fail (main_window != NULL, NULL);
 
531
 
 
532
  return GM_MAIN_WINDOW (g_object_get_data (G_OBJECT (main_window), 
 
533
                                            "GMObject"));
 
534
}
 
535
 
 
536
 
 
537
static void
 
538
gm_mw_init_toolbars (GtkWidget *main_window)
 
539
{
 
540
  GmWindow *mw = NULL;
 
541
  
 
542
  GtkWidget *button = NULL;
 
543
  GtkToolItem *item = NULL;
 
544
 
 
545
  GtkListStore *list_store = NULL;
 
546
  GtkWidget *toolbar = NULL;
 
547
  
 
548
  GtkEntryCompletion *completion = NULL;
 
549
  
 
550
  GtkWidget *image = NULL;
 
551
 
 
552
  GtkWidget *addressbook_window = NULL;
 
553
  GtkWidget *chat_window = NULL;
 
554
  
 
555
#ifndef DISABLE_GNOME
 
556
  int behavior = 0;
 
557
  BOOL toolbar_detachable = TRUE;
 
558
#endif
 
559
 
 
560
  addressbook_window = GnomeMeeting::Process ()->GetAddressbookWindow ();
 
561
  chat_window = GnomeMeeting::Process ()->GetChatWindow ();
 
562
 
 
563
  
 
564
  g_return_if_fail (main_window != NULL);
 
565
 
 
566
  mw = gm_mw_get_mw (main_window);
 
567
 
 
568
  g_return_if_fail (mw != NULL);
 
569
 
 
570
 
 
571
#ifndef DISABLE_GNOME
 
572
  toolbar_detachable = 
 
573
    gm_conf_get_bool ("/desktop/gnome/interface/toolbar_detachable");
 
574
#endif
 
575
 
 
576
  
 
577
  /* The main horizontal toolbar */
 
578
  toolbar = gtk_toolbar_new ();
 
579
  gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_ICONS);
 
580
  gtk_toolbar_set_show_arrow (GTK_TOOLBAR (toolbar), FALSE);
 
581
 
 
582
 
 
583
  /* URL bar */
 
584
  /* Entry */
 
585
  item = gtk_tool_item_new ();
 
586
  mw->combo = gtk_combo_box_entry_new_text ();
 
587
 
 
588
  gtk_container_add (GTK_CONTAINER (item), mw->combo);
 
589
  gtk_container_set_border_width (GTK_CONTAINER (item), 4);
 
590
  gtk_tool_item_set_expand (GTK_TOOL_ITEM (item), TRUE);
 
591
  
 
592
  completion = gtk_entry_completion_new ();
 
593
  
 
594
  list_store = gtk_list_store_new (3, 
 
595
                                   G_TYPE_STRING,
 
596
                                   G_TYPE_STRING,
 
597
                                   G_TYPE_STRING);
 
598
  
 
599
  gtk_entry_completion_set_model (GTK_ENTRY_COMPLETION (completion),
 
600
                                  GTK_TREE_MODEL (list_store));
 
601
  gtk_entry_completion_set_text_column (GTK_ENTRY_COMPLETION (completion), 2);
 
602
  gtk_entry_set_completion (GTK_ENTRY (GTK_BIN (mw->combo)->child), completion);
 
603
  
 
604
  gtk_entry_set_text (GTK_ENTRY (GTK_BIN (mw->combo)->child),
 
605
                      GMURL ().GetDefaultURL ());
 
606
 
 
607
  gtk_entry_completion_set_match_func (GTK_ENTRY_COMPLETION (completion),
 
608
                                       entry_completion_url_match_cb,
 
609
                                       (gpointer) list_store,
 
610
                                       NULL);
 
611
  
 
612
  gm_main_window_urls_history_update (main_window);
 
613
 
 
614
  g_signal_connect (G_OBJECT (GTK_BIN (mw->combo)->child), "changed", 
 
615
                    GTK_SIGNAL_FUNC (url_changed_cb), (gpointer) main_window);
 
616
  g_signal_connect (G_OBJECT (GTK_BIN (mw->combo)->child), "activate", 
 
617
                    GTK_SIGNAL_FUNC (url_activated_cb), NULL);
 
618
  g_signal_connect (G_OBJECT (completion), "match-selected", 
 
619
                    GTK_SIGNAL_FUNC (completion_url_selected_cb), NULL);
 
620
 
 
621
  gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, 0);
 
622
 
 
623
  
 
624
  /* The connect button */
 
625
  item = gtk_tool_item_new ();
 
626
  mw->connect_button = gm_connect_button_new (GM_STOCK_CONNECT,
 
627
                                              GM_STOCK_DISCONNECT,
 
628
                                              GTK_ICON_SIZE_LARGE_TOOLBAR,
 
629
                                              NULL,
 
630
                                              NULL);
 
631
  gtk_container_add (GTK_CONTAINER (item), mw->connect_button);
 
632
  gtk_tool_item_set_expand (GTK_TOOL_ITEM (item), FALSE);
 
633
 
 
634
  gtk_tooltips_set_tip (mw->tips, GTK_WIDGET (mw->connect_button), 
 
635
                        _("Enter an URL to call on the left, and click on this button to connect to the given URL"), NULL);
 
636
  
 
637
  gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
 
638
 
 
639
  g_signal_connect (G_OBJECT (mw->connect_button), "clicked",
 
640
                    G_CALLBACK (connect_button_clicked_cb), 
 
641
                    GTK_ENTRY (GTK_BIN (mw->combo)->child));
 
642
 
 
643
  gtk_widget_show_all (GTK_WIDGET (toolbar));
 
644
  
 
645
#ifndef DISABLE_GNOME
 
646
  behavior = (BONOBO_DOCK_ITEM_BEH_EXCLUSIVE
 
647
              | BONOBO_DOCK_ITEM_BEH_NEVER_VERTICAL);
 
648
 
 
649
  if (!toolbar_detachable)
 
650
    behavior |= BONOBO_DOCK_ITEM_BEH_LOCKED;
 
651
 
 
652
  gnome_app_add_docked (GNOME_APP (main_window), toolbar, "main_toolbar",
 
653
                        BonoboDockItemBehavior (behavior),
 
654
                        BONOBO_DOCK_TOP, 1, 0, 0);
 
655
#else
 
656
  gtk_box_pack_start (GTK_BOX (mw->window_vbox), toolbar, 
 
657
                      FALSE, FALSE, 0);
 
658
#endif
 
659
 
 
660
 
 
661
  /* The left toolbar */
 
662
  toolbar = gtk_toolbar_new ();
 
663
  gtk_toolbar_set_orientation (GTK_TOOLBAR (toolbar), 
 
664
                               GTK_ORIENTATION_VERTICAL);
 
665
  gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_ICONS);
 
666
  gtk_toolbar_set_show_arrow (GTK_TOOLBAR (toolbar), FALSE);
 
667
  
 
668
 
 
669
  /* The text chat */
 
670
  item = gtk_tool_item_new ();
 
671
  button = gtk_button_new ();
 
672
  gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
 
673
  image = gtk_image_new_from_stock (GM_STOCK_TEXT_CHAT,
 
674
                                    GTK_ICON_SIZE_LARGE_TOOLBAR);
 
675
  gtk_container_add (GTK_CONTAINER (button), image);
 
676
  gtk_container_add (GTK_CONTAINER (item), button);
 
677
  gtk_tool_item_set_expand (GTK_TOOL_ITEM (item), FALSE);
 
678
  gtk_tool_item_set_tooltip (GTK_TOOL_ITEM (item), 
 
679
                             mw->tips, _("Open text chat"), NULL);
 
680
  
 
681
  gtk_widget_show (button);
 
682
  gtk_toolbar_insert (GTK_TOOLBAR (toolbar), 
 
683
                      GTK_TOOL_ITEM (item), -1);
 
684
 
 
685
  g_signal_connect (G_OBJECT (button), "clicked",
 
686
                    GTK_SIGNAL_FUNC (show_chat_window_cb),
 
687
                    (gpointer) chat_window);
 
688
  
 
689
 
 
690
  /* The control panel */
 
691
  item = gtk_tool_item_new ();
 
692
  button = gtk_button_new ();
 
693
  gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
 
694
  image = gtk_image_new_from_stock (GM_STOCK_CONTROL_PANEL,
 
695
                                    GTK_ICON_SIZE_LARGE_TOOLBAR);
 
696
  gtk_container_add (GTK_CONTAINER (button), image);
 
697
  gtk_container_add (GTK_CONTAINER (item), button);
 
698
  gtk_tool_item_set_expand (GTK_TOOL_ITEM (item), FALSE);
 
699
  
 
700
  gtk_widget_show (GTK_WIDGET (item));
 
701
  gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
 
702
  gtk_tool_item_set_tooltip (GTK_TOOL_ITEM (item), 
 
703
                             mw->tips, _("Change the view mode"), NULL);
 
704
 
 
705
  g_signal_connect (G_OBJECT (button), "clicked",
 
706
                    GTK_SIGNAL_FUNC (view_mode_button_clicked_cb), NULL);
 
707
  
 
708
 
 
709
  /* The address book */
 
710
  item = gtk_tool_item_new ();
 
711
  button = gtk_button_new ();
 
712
  gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
 
713
  image = gtk_image_new_from_stock (GM_STOCK_ADDRESSBOOK_24,
 
714
                                    GTK_ICON_SIZE_LARGE_TOOLBAR);
 
715
  gtk_container_add (GTK_CONTAINER (button), image);
 
716
  gtk_container_add (GTK_CONTAINER (item), button);
 
717
  gtk_tool_item_set_expand (GTK_TOOL_ITEM (item), FALSE);
 
718
  
 
719
  gtk_widget_show (GTK_WIDGET (item));
 
720
  gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
 
721
  gtk_tool_item_set_tooltip (GTK_TOOL_ITEM (item), 
 
722
                             mw->tips, _("Open address book"), NULL);
 
723
 
 
724
  g_signal_connect (G_OBJECT (button), "clicked",
 
725
                    GTK_SIGNAL_FUNC (show_window_cb), 
 
726
                    (gpointer) addressbook_window);
 
727
  
 
728
 
 
729
  
 
730
  /* Video Preview Button */
 
731
  item = gtk_tool_item_new ();
 
732
  mw->preview_button = gtk_toggle_button_new ();
 
733
  image = gtk_image_new_from_stock (GM_STOCK_VIDEO_PREVIEW,
 
734
                                    GTK_ICON_SIZE_SMALL_TOOLBAR);
 
735
  gtk_container_add (GTK_CONTAINER (mw->preview_button), image);
 
736
  gtk_container_add (GTK_CONTAINER (item), mw->preview_button);
 
737
  gtk_tool_item_set_expand (GTK_TOOL_ITEM (item), FALSE);
 
738
  
 
739
  gtk_widget_show (mw->preview_button);
 
740
  gtk_toolbar_insert (GTK_TOOLBAR (toolbar), 
 
741
                      GTK_TOOL_ITEM (item), -1);
 
742
  gtk_tool_item_set_tooltip (GTK_TOOL_ITEM (item), mw->tips,
 
743
                             _("Display images from your camera device"), 
 
744
                             NULL);
 
745
 
 
746
  gtk_widget_set_size_request (GTK_WIDGET (mw->preview_button), 28, 28);
 
747
 
 
748
  g_signal_connect (G_OBJECT (mw->preview_button), "toggled",
 
749
                    G_CALLBACK (toolbar_toggle_button_changed_cb),
 
750
                    (gpointer) VIDEO_DEVICES_KEY "enable_preview");
 
751
 
 
752
 
 
753
  /* Audio Channel Button */
 
754
  item = gtk_tool_item_new ();
 
755
  mw->audio_chan_button = gtk_toggle_button_new ();
 
756
  image = gtk_image_new_from_stock (GM_STOCK_AUDIO_MUTE,
 
757
                                    GTK_ICON_SIZE_SMALL_TOOLBAR);
 
758
  gtk_container_add (GTK_CONTAINER (mw->audio_chan_button), image);
 
759
  gtk_container_add (GTK_CONTAINER (item), mw->audio_chan_button);
 
760
  gtk_tool_item_set_expand (GTK_TOOL_ITEM (item), FALSE);
 
761
  
 
762
  gtk_widget_show (mw->audio_chan_button);
 
763
  gtk_toolbar_insert (GTK_TOOLBAR (toolbar), 
 
764
                      GTK_TOOL_ITEM (item), -1);
 
765
  gtk_tool_item_set_tooltip (GTK_TOOL_ITEM (item), mw->tips,
 
766
                             _("Audio transmission status. During a call, click here to suspend or resume the audio transmission."), NULL);
 
767
 
 
768
  gtk_widget_set_size_request (GTK_WIDGET (mw->audio_chan_button), 28, 28);
 
769
  gtk_widget_set_sensitive (GTK_WIDGET (mw->audio_chan_button), FALSE);
 
770
 
 
771
  g_signal_connect (G_OBJECT (mw->audio_chan_button), "clicked",
 
772
                    G_CALLBACK (pause_current_call_channel_cb), 
 
773
                    GINT_TO_POINTER (0));
 
774
 
 
775
 
 
776
  /* Video Channel Button */
 
777
  item = gtk_tool_item_new ();
 
778
  mw->video_chan_button = gtk_toggle_button_new ();
 
779
  image = gtk_image_new_from_stock (GM_STOCK_VIDEO_MUTE,
 
780
                                    GTK_ICON_SIZE_SMALL_TOOLBAR);
 
781
  gtk_container_add (GTK_CONTAINER (mw->video_chan_button), image);
 
782
  gtk_container_add (GTK_CONTAINER (item), mw->video_chan_button);
 
783
  gtk_tool_item_set_expand (GTK_TOOL_ITEM (item), FALSE);
 
784
  
 
785
  gtk_widget_show (mw->video_chan_button);
 
786
  gtk_toolbar_insert (GTK_TOOLBAR (toolbar), 
 
787
                      GTK_TOOL_ITEM (item), -1);
 
788
  gtk_tool_item_set_tooltip (GTK_TOOL_ITEM (item), mw->tips,
 
789
                             _("Video transmission status. During a call, click here to suspend or resume the video transmission."), NULL);
 
790
 
 
791
  gtk_widget_set_size_request (GTK_WIDGET (mw->video_chan_button), 28, 28);
 
792
  gtk_widget_set_sensitive (GTK_WIDGET (mw->video_chan_button), FALSE);
 
793
 
 
794
  g_signal_connect (G_OBJECT (mw->video_chan_button), "clicked",
 
795
                    G_CALLBACK (pause_current_call_channel_cb), 
 
796
                    GINT_TO_POINTER (1));
 
797
 
 
798
 
 
799
  /* Add the toolbar to the UI */
 
800
#ifndef DISABLE_GNOME
 
801
  behavior = BONOBO_DOCK_ITEM_BEH_EXCLUSIVE;
 
802
 
 
803
  if (!toolbar_detachable)
 
804
    behavior |= BONOBO_DOCK_ITEM_BEH_LOCKED;
 
805
 
 
806
  gnome_app_add_toolbar (GNOME_APP (main_window), GTK_TOOLBAR (toolbar),
 
807
                         "left_toolbar", 
 
808
                         BonoboDockItemBehavior (behavior),
 
809
                         BONOBO_DOCK_LEFT, 2, 0, 0);
 
810
#else
 
811
  gtk_box_pack_start (GTK_BOX (mw->window_hbox), toolbar, 
 
812
                      FALSE, FALSE, 0);
 
813
#endif
 
814
  
 
815
  gtk_widget_show_all (GTK_WIDGET (toolbar));
 
816
}
 
817
 
 
818
        
 
819
static void
 
820
gm_mw_init_menu (GtkWidget *main_window)
 
821
{
 
822
  GmWindow *mw = NULL;
 
823
  
 
824
  GtkWidget *addressbook_window = NULL;
 
825
  GtkWidget *chat_window = NULL;
 
826
  GtkWidget *druid_window = NULL;
 
827
  GtkWidget *calls_history_window = NULL;
 
828
  GtkWidget *history_window = NULL;
 
829
  GtkWidget *prefs_window = NULL;
 
830
  GtkWidget *accounts_window = NULL;
 
831
  GtkWidget *pc2phone_window = NULL;
 
832
  
 
833
  IncomingCallMode icm = AVAILABLE;
 
834
  ViewMode mode = SOFTPHONE;
 
835
  ControlPanelSection cps = DIALPAD;
 
836
  gboolean show_video_section = FALSE;
 
837
  int nbr = 0;
 
838
 
 
839
  GSList *glist = NULL;
 
840
 
 
841
  g_return_if_fail (main_window != NULL);
 
842
  mw = gm_mw_get_mw (main_window);
 
843
  
 
844
  addressbook_window = GnomeMeeting::Process ()->GetAddressbookWindow ();
 
845
  calls_history_window = GnomeMeeting::Process ()->GetCallsHistoryWindow ();
 
846
  history_window = GnomeMeeting::Process ()->GetHistoryWindow ();
 
847
  chat_window = GnomeMeeting::Process ()->GetChatWindow ();
 
848
  druid_window = GnomeMeeting::Process ()->GetDruidWindow ();
 
849
  prefs_window = GnomeMeeting::Process ()->GetPrefsWindow ();
 
850
  accounts_window = GnomeMeeting::Process ()->GetAccountsWindow ();
 
851
  pc2phone_window = GnomeMeeting::Process ()->GetPC2PhoneWindow ();
 
852
 
 
853
  mw->main_menu = gtk_menu_bar_new ();
 
854
 
 
855
 
 
856
  /* Default values */
 
857
  icm = (IncomingCallMode) 
 
858
    gm_conf_get_int (CALL_OPTIONS_KEY "incoming_call_mode"); 
 
859
  cps = (ControlPanelSection)
 
860
    gm_conf_get_int (USER_INTERFACE_KEY "main_window/control_panel_section"); 
 
861
  mode = (ViewMode)
 
862
    gm_conf_get_int (USER_INTERFACE_KEY "main_window/view_mode"); 
 
863
  show_video_section =
 
864
    gm_conf_get_bool (USER_INTERFACE_KEY "main_window/show_video_section");
 
865
 
 
866
  
 
867
  static MenuEntry gnomemeeting_menu [] =
 
868
    {
 
869
      GTK_MENU_NEW (_("C_all")),
 
870
 
 
871
      GTK_MENU_ENTRY("connect", _("C_onnect"), _("Create a new connection"), 
 
872
                     GM_STOCK_CONNECT_16, 'o',
 
873
                     GTK_SIGNAL_FUNC (connect_cb), main_window, TRUE),
 
874
      GTK_MENU_ENTRY("disconnect", _("_Disconnect"),
 
875
                     _("Close the current connection"), 
 
876
                     GM_STOCK_DISCONNECT_16, 'd',
 
877
                     GTK_SIGNAL_FUNC (disconnect_cb), NULL, FALSE),
 
878
 
 
879
      GTK_MENU_SEPARATOR,
 
880
 
 
881
      GTK_MENU_RADIO_ENTRY("available", _("_Available"),
 
882
                           _("Display a popup to accept the call"),
 
883
                           NULL, 0, 
 
884
                           GTK_SIGNAL_FUNC (radio_menu_changed_cb),
 
885
                           (gpointer) CALL_OPTIONS_KEY "incoming_call_mode",
 
886
                           (icm == AVAILABLE), TRUE),
 
887
      GTK_MENU_RADIO_ENTRY("auto_answer", _("Aut_o Answer"),
 
888
                           _("Auto answer calls"),
 
889
                           NULL, 0, 
 
890
                           GTK_SIGNAL_FUNC (radio_menu_changed_cb),
 
891
                           (gpointer) CALL_OPTIONS_KEY "incoming_call_mode",
 
892
                           (icm == AUTO_ANSWER), TRUE),
 
893
      GTK_MENU_RADIO_ENTRY("do_not_disturb", _("_Do Not Disturb"), 
 
894
                           _("Reject calls"),
 
895
                           NULL, 0, 
 
896
                           GTK_SIGNAL_FUNC (radio_menu_changed_cb),
 
897
                           (gpointer) CALL_OPTIONS_KEY "incoming_call_mode",
 
898
                           (icm == DO_NOT_DISTURB), TRUE),
 
899
      GTK_MENU_RADIO_ENTRY("forward", _("_Forward"), _("Forward calls"),
 
900
                           NULL, 0,
 
901
                           GTK_SIGNAL_FUNC (radio_menu_changed_cb),
 
902
                           (gpointer) CALL_OPTIONS_KEY "incoming_call_mode",
 
903
                           (icm == FORWARD), TRUE),
 
904
 
 
905
      GTK_MENU_SEPARATOR,
 
906
 
 
907
      GTK_SUBMENU_NEW("speed_dials", _("Speed dials")),
 
908
 
 
909
      GTK_MENU_SEPARATOR,
 
910
 
 
911
      GTK_MENU_ENTRY("hold_call", _("_Hold Call"), _("Hold the current call"),
 
912
                     NULL, 'g', 
 
913
                     GTK_SIGNAL_FUNC (hold_current_call_cb), NULL,
 
914
                     FALSE),
 
915
      GTK_MENU_ENTRY("transfer_call", _("_Transfer Call"),
 
916
                     _("Transfer the current call"),
 
917
                     NULL, 't', 
 
918
                     GTK_SIGNAL_FUNC (transfer_current_call_cb), main_window, 
 
919
                     FALSE),
 
920
 
 
921
      GTK_MENU_SEPARATOR,
 
922
 
 
923
      GTK_MENU_ENTRY("suspend_audio", _("Suspend _Audio"),
 
924
                     _("Suspend or resume the audio transmission"),
 
925
                     NULL, 0,
 
926
                     GTK_SIGNAL_FUNC (pause_current_call_channel_cb),
 
927
                     GINT_TO_POINTER (0), FALSE),
 
928
      GTK_MENU_ENTRY("suspend_video", _("Suspend _Video"),
 
929
                     _("Suspend or resume the video transmission"),
 
930
                     NULL, 0, 
 
931
                     GTK_SIGNAL_FUNC (pause_current_call_channel_cb),
 
932
                     GINT_TO_POINTER (1), FALSE),
 
933
 
 
934
      GTK_MENU_SEPARATOR,
 
935
 
 
936
      GTK_MENU_ENTRY("save_picture", _("_Save Current Picture"), 
 
937
                     _("Save a snapshot of the current video"),
 
938
                     GTK_STOCK_SAVE, 'S',
 
939
                     GTK_SIGNAL_FUNC (save_callback), NULL, FALSE),
 
940
 
 
941
      GTK_MENU_SEPARATOR,
 
942
      
 
943
      GTK_MENU_ENTRY("close", _("_Close"), _("Close the Ekiga window"),
 
944
                     GTK_STOCK_CLOSE, 'W', 
 
945
                     GTK_SIGNAL_FUNC (show_window_cb),
 
946
                     (gpointer) main_window, TRUE),
 
947
 
 
948
      GTK_MENU_SEPARATOR,
 
949
      
 
950
      GTK_MENU_ENTRY("quit", _("_Quit"), _("Quit Ekiga"),
 
951
                     GTK_STOCK_QUIT, 'Q', 
 
952
                     GTK_SIGNAL_FUNC (quit_callback), NULL, TRUE),
 
953
 
 
954
      GTK_MENU_NEW (_("_Edit")),
 
955
 
 
956
      GTK_MENU_ENTRY("configuration_druid", _("Configuration Druid"),
 
957
                     _("Run the configuration druid"),
 
958
                     NULL, 0, 
 
959
                     GTK_SIGNAL_FUNC (show_window_cb),
 
960
                     (gpointer) druid_window, TRUE),
 
961
 
 
962
      GTK_MENU_SEPARATOR,
 
963
      
 
964
      GTK_MENU_ENTRY("accounts", _("_Accounts"),
 
965
                     _("Edit your accounts"), 
 
966
                     NULL, 'E',
 
967
                     GTK_SIGNAL_FUNC (show_window_cb),
 
968
                     (gpointer) accounts_window, TRUE),
 
969
 
 
970
      GTK_MENU_ENTRY("preferences", _("_Preferences"),
 
971
                     _("Change your preferences"), 
 
972
                     GTK_STOCK_PREFERENCES, 'P',
 
973
                     GTK_SIGNAL_FUNC (show_window_cb),
 
974
                     (gpointer) prefs_window, TRUE),
 
975
 
 
976
      GTK_MENU_NEW(_("_View")),
 
977
 
 
978
      GTK_SUBMENU_NEW("view_mode", _("View _Mode")),
 
979
 
 
980
      GTK_MENU_RADIO_ENTRY("softphone", _("Softp_hone"), 
 
981
                           _("Show the softphone view"),
 
982
                           NULL, 0,
 
983
                           GTK_SIGNAL_FUNC (radio_menu_changed_cb), 
 
984
                           (gpointer)USER_INTERFACE_KEY "main_window/view_mode",
 
985
                           (mode == SOFTPHONE), TRUE),
 
986
      GTK_MENU_RADIO_ENTRY("videophone", _("_Videophone"), 
 
987
                           _("Show the videophone view"),
 
988
                           NULL, 0,
 
989
                           GTK_SIGNAL_FUNC (radio_menu_changed_cb), 
 
990
                           (gpointer)USER_INTERFACE_KEY "main_window/view_mode",
 
991
                           (mode == VIDEOPHONE), TRUE),
 
992
      GTK_MENU_RADIO_ENTRY("full_view", _("_Full View"),
 
993
                           _("View all components"),
 
994
                           NULL, 0, 
 
995
                           GTK_SIGNAL_FUNC (radio_menu_changed_cb), 
 
996
                           (gpointer)USER_INTERFACE_KEY "main_window/view_mode",
 
997
                           (mode == FULLVIEW), TRUE),
 
998
      
 
999
      GTK_MENU_SEPARATOR,
 
1000
      
 
1001
      GTK_SUBMENU_NEW("control_panel", _("Control Panel")),
 
1002
 
 
1003
      GTK_MENU_RADIO_ENTRY("dialpad", _("_Dialpad"), _("View the dialpad"),
 
1004
                           NULL, 0,
 
1005
                           GTK_SIGNAL_FUNC (radio_menu_changed_cb), 
 
1006
                           (gpointer) USER_INTERFACE_KEY "main_window/control_panel_section",
 
1007
                           (cps == DIALPAD), TRUE),
 
1008
      GTK_MENU_RADIO_ENTRY("audio_settings", _("_Audio Settings"),
 
1009
                           _("View audio settings"),
 
1010
                           NULL, 0, 
 
1011
                           GTK_SIGNAL_FUNC (radio_menu_changed_cb), 
 
1012
                           (gpointer) USER_INTERFACE_KEY "main_window/control_panel_section",
 
1013
                           (cps == AUDIO_SETTINGS), TRUE),
 
1014
      GTK_MENU_RADIO_ENTRY("video_settings", _("_Video Settings"),
 
1015
                           _("View video settings"),
 
1016
                           NULL, 0, 
 
1017
                           GTK_SIGNAL_FUNC (radio_menu_changed_cb), 
 
1018
                           (gpointer) USER_INTERFACE_KEY "main_window/control_panel_section",
 
1019
                           (cps == VIDEO_SETTINGS), TRUE),
 
1020
      GTK_MENU_RADIO_ENTRY("statistics", _("Statistics"), 
 
1021
                           _("View audio/video transmission and reception statistics"),
 
1022
                           NULL, 0,
 
1023
                           GTK_SIGNAL_FUNC (radio_menu_changed_cb), 
 
1024
                           (gpointer) USER_INTERFACE_KEY "main_window/control_panel_section",
 
1025
                           (cps == STATISTICS), TRUE),
 
1026
 
 
1027
      GTK_MENU_SEPARATOR,
 
1028
 
 
1029
      GTK_MENU_RADIO_ENTRY("local_video", _("Local Video"),
 
1030
                           _("Local video image"),
 
1031
                           NULL, 0, 
 
1032
                           GTK_SIGNAL_FUNC (radio_menu_changed_cb),
 
1033
                           (gpointer) VIDEO_DISPLAY_KEY "video_view",
 
1034
                           TRUE, FALSE),
 
1035
      GTK_MENU_RADIO_ENTRY("remote_video", _("Remote Video"),
 
1036
                           _("Remote video image"),
 
1037
                           NULL, 0, 
 
1038
                           GTK_SIGNAL_FUNC (radio_menu_changed_cb), 
 
1039
                           (gpointer) VIDEO_DISPLAY_KEY "video_view",
 
1040
                           FALSE, FALSE),
 
1041
      GTK_MENU_RADIO_ENTRY("both_incrusted", _("Both (Picture-in-Picture)"),
 
1042
                           _("Both video images"),
 
1043
                           NULL, 0, 
 
1044
                           GTK_SIGNAL_FUNC (radio_menu_changed_cb), 
 
1045
                           (gpointer) VIDEO_DISPLAY_KEY "video_view",
 
1046
                           FALSE, FALSE),
 
1047
      GTK_MENU_RADIO_ENTRY("both_side_by_side", _("Both (Side-by-Side)"),
 
1048
                           _("Both video images"),
 
1049
                           NULL, 0, 
 
1050
                           GTK_SIGNAL_FUNC (radio_menu_changed_cb), 
 
1051
                           (gpointer) VIDEO_DISPLAY_KEY "video_view",
 
1052
                           FALSE, FALSE),
 
1053
      GTK_MENU_RADIO_ENTRY("both_new_windows",
 
1054
                           _("Both (Both in New Windows)"), 
 
1055
                           _("Both video images"),
 
1056
                           NULL, 0, 
 
1057
                           GTK_SIGNAL_FUNC (radio_menu_changed_cb), 
 
1058
                           (gpointer) VIDEO_DISPLAY_KEY "video_view",
 
1059
                           FALSE, FALSE),
 
1060
 
 
1061
      GTK_MENU_SEPARATOR,
 
1062
 
 
1063
      GTK_MENU_ENTRY("zoom_in", _("Zoom In"), _("Zoom in"), 
 
1064
                     GTK_STOCK_ZOOM_IN, '+', 
 
1065
                     GTK_SIGNAL_FUNC (zoom_in_changed_cb),
 
1066
                     (gpointer) VIDEO_DISPLAY_KEY "zoom_factor", FALSE),
 
1067
      GTK_MENU_ENTRY("zoom_out", _("Zoom Out"), _("Zoom out"), 
 
1068
                     GTK_STOCK_ZOOM_OUT, '-', 
 
1069
                     GTK_SIGNAL_FUNC (zoom_out_changed_cb),
 
1070
                     (gpointer) VIDEO_DISPLAY_KEY "zoom_factor", FALSE),
 
1071
      GTK_MENU_ENTRY("normal_size", _("Normal Size"), _("Normal size"), 
 
1072
                     GTK_STOCK_ZOOM_100, '=',
 
1073
                     GTK_SIGNAL_FUNC (zoom_normal_changed_cb),
 
1074
                     (gpointer) VIDEO_DISPLAY_KEY "zoom_factor", FALSE),
 
1075
 
 
1076
#ifdef HAS_SDL
 
1077
      GTK_MENU_ENTRY("fullscreen", _("Fullscreen"), _("Switch to fullscreen"), 
 
1078
                     GTK_STOCK_ZOOM_IN, 'f', 
 
1079
                     GTK_SIGNAL_FUNC (fullscreen_changed_cb),
 
1080
                     (gpointer) main_window, FALSE),
 
1081
#endif
 
1082
 
 
1083
      GTK_MENU_NEW(_("_Tools")),
 
1084
      
 
1085
      GTK_MENU_ENTRY("address_book", _("Address _Book"),
 
1086
                     _("Open the address book"),
 
1087
                     GM_STOCK_ADDRESSBOOK_16, 0,
 
1088
                     GTK_SIGNAL_FUNC (show_window_cb),
 
1089
                     (gpointer) addressbook_window, TRUE),
 
1090
      
 
1091
      GTK_MENU_SEPARATOR,
 
1092
 
 
1093
      GTK_MENU_ENTRY("chat_window", _("C_hat Window"),
 
1094
                     _("Open the chat window"),
 
1095
                     NULL, 0,
 
1096
                     GTK_SIGNAL_FUNC (show_window_cb),
 
1097
                     (gpointer) chat_window, TRUE),
 
1098
 
 
1099
      GTK_MENU_ENTRY("log", _("General History"),
 
1100
                     _("View the operations history"),
 
1101
                     NULL, 0, 
 
1102
                     GTK_SIGNAL_FUNC (show_window_cb),
 
1103
                     (gpointer) history_window, TRUE),
 
1104
      GTK_MENU_ENTRY("calls_history", _("Calls History"),
 
1105
                     _("View the calls history"),
 
1106
                     GM_STOCK_CALLS_HISTORY, 'h',
 
1107
                     GTK_SIGNAL_FUNC (show_window_cb),
 
1108
                     (gpointer) calls_history_window, TRUE),
 
1109
 
 
1110
      GTK_MENU_SEPARATOR,
 
1111
 
 
1112
      GTK_MENU_ENTRY("pc-to-phone", _("PC-To-Phone Account"),
 
1113
                     _("Manage your PC-To-Phone account"),
 
1114
                     NULL, 0, 
 
1115
                     GTK_SIGNAL_FUNC (show_window_cb),
 
1116
                     (gpointer) pc2phone_window, TRUE),
 
1117
      
 
1118
      GTK_MENU_NEW(_("_Help")),
 
1119
 
 
1120
#ifndef DISABLE_GNOME
 
1121
       GTK_MENU_ENTRY("help", _("_Contents"),
 
1122
                     _("Get help by reading the Ekiga manual"),
 
1123
                     GTK_STOCK_HELP, GDK_F1, 
 
1124
                     GTK_SIGNAL_FUNC (help_cb), NULL, TRUE),
 
1125
       
 
1126
      GTK_MENU_ENTRY("about", _("_About"),
 
1127
                     _("View information about Ekiga"),
 
1128
                     GNOME_STOCK_ABOUT, 0, 
 
1129
                     GTK_SIGNAL_FUNC (about_callback), (gpointer) main_window,
 
1130
                     TRUE),
 
1131
#else
 
1132
      GTK_MENU_ENTRY("help", _("_Contents"),
 
1133
                     _("Get help by reading the Ekiga manual"),
 
1134
                     GTK_STOCK_HELP, GDK_F1, 
 
1135
                     NULL, NULL, FALSE),
 
1136
       
 
1137
      GTK_MENU_ENTRY("about", _("_About"),
 
1138
                     _("View information about Ekiga"),
 
1139
                     NULL, 'a', 
 
1140
                     GTK_SIGNAL_FUNC (about_callback), (gpointer) main_window,
 
1141
                     TRUE),
 
1142
#endif
 
1143
       
 
1144
      GTK_MENU_END
 
1145
    };
 
1146
 
 
1147
 
 
1148
  gtk_build_menu (mw->main_menu, 
 
1149
                  gnomemeeting_menu, 
 
1150
                  mw->accel, 
 
1151
                  mw->statusbar);
 
1152
 
 
1153
  glist = 
 
1154
    gnomemeeting_addressbook_get_contacts (NULL, nbr, 
 
1155
                                           FALSE, NULL, NULL, NULL, "*"); 
 
1156
  gm_main_window_speed_dials_menu_update (main_window, glist);
 
1157
  g_slist_foreach (glist, (GFunc) gmcontact_delete, NULL);
 
1158
  g_slist_free (glist);
 
1159
 
 
1160
  gtk_widget_show_all (GTK_WIDGET (mw->main_menu));
 
1161
}
 
1162
 
 
1163
 
 
1164
static void 
 
1165
gm_mw_init_stats (GtkWidget *main_window)
 
1166
{
 
1167
  GmWindow *mw = NULL;
 
1168
  
 
1169
  GtkWidget *frame = NULL;
 
1170
  GtkWidget *frame2 = NULL;
 
1171
  GtkWidget *label = NULL;
 
1172
  GtkWidget *vbox = NULL;
 
1173
 
 
1174
  
 
1175
  g_return_if_fail (main_window != NULL);
 
1176
  mw = gm_mw_get_mw (main_window);
 
1177
 
 
1178
  
 
1179
  /* The main frame */
 
1180
  frame = gtk_frame_new (NULL);
 
1181
  gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
 
1182
  gtk_container_set_border_width (GTK_CONTAINER (frame), 5);
 
1183
  
 
1184
  /* The first frame with statistics display */
 
1185
  frame2 = gtk_frame_new (NULL);
 
1186
  gtk_frame_set_shadow_type (GTK_FRAME (frame2), GTK_SHADOW_IN);
 
1187
 
 
1188
  vbox = gtk_vbox_new (FALSE, 0);
 
1189
  mw->stats_drawing_area = stats_drawing_area_new ();
 
1190
 
 
1191
  gtk_box_pack_start (GTK_BOX (vbox), frame2, FALSE, TRUE, 0);
 
1192
  gtk_container_add (GTK_CONTAINER (frame2), mw->stats_drawing_area);
 
1193
 
 
1194
  gtk_widget_set_size_request (GTK_WIDGET (frame2), GM_QCIF_WIDTH-10, 47);
 
1195
  gtk_widget_queue_draw (mw->stats_drawing_area);
 
1196
 
 
1197
  /* The second one with some labels */
 
1198
  mw->stats_label = gtk_label_new ("");
 
1199
  gtk_misc_set_alignment (GTK_MISC (mw->stats_label), 0, 0);
 
1200
  gtk_box_pack_start (GTK_BOX (vbox), mw->stats_label, FALSE, TRUE, 3);
 
1201
 
 
1202
  gtk_container_add (GTK_CONTAINER (frame), vbox);
 
1203
 
 
1204
  gm_main_window_clear_stats (main_window);
 
1205
  
 
1206
  label = gtk_label_new (_("Statistics"));
 
1207
 
 
1208
  gtk_notebook_append_page (GTK_NOTEBOOK (mw->main_notebook), frame, label);
 
1209
}
 
1210
 
 
1211
 
 
1212
static void 
 
1213
gm_mw_init_dialpad (GtkWidget *main_window)
 
1214
{
 
1215
  GmWindow *mw = NULL;
 
1216
  
 
1217
  GtkSizeGroup *size_group_alpha = NULL;
 
1218
 
 
1219
  GtkWidget *box = NULL;
 
1220
  GtkWidget *button = NULL;
 
1221
  GtkWidget *label = NULL;
 
1222
  GtkWidget *table = NULL;
 
1223
 
 
1224
  int i = 0;
 
1225
 
 
1226
  char *key_n [] = { "1", "2", "3", "4", "5", "6", "7", "8", "9",
 
1227
                     "*", "0", "#"};
 
1228
  guint key_kp [] = { GDK_KP_1, GDK_KP_2, GDK_KP_3, GDK_KP_4, GDK_KP_5, 
 
1229
                      GDK_KP_6, GDK_KP_7, GDK_KP_8, GDK_KP_9, GDK_KP_Multiply,
 
1230
                      GDK_KP_0, GDK_numbersign};
 
1231
 
 
1232
  char *key_a []= { "  ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv",
 
1233
                   "wxyz", "  ", "  ", "  "};
 
1234
 
 
1235
  gchar *text_label = NULL;
 
1236
  
 
1237
 
 
1238
  g_return_if_fail (main_window != NULL);
 
1239
  mw = gm_mw_get_mw (main_window);
 
1240
 
 
1241
  table = gtk_table_new (4, 3, TRUE);
 
1242
  gtk_container_set_border_width (GTK_CONTAINER (table), 5);
 
1243
  
 
1244
 
 
1245
  size_group_alpha = gtk_size_group_new (GTK_SIZE_GROUP_BOTH);
 
1246
 
 
1247
  for (i = 0 ; i < 12 ; i++) {
 
1248
 
 
1249
    box = gtk_hbox_new (FALSE, 0);
 
1250
 
 
1251
    label = gtk_label_new (NULL);
 
1252
    text_label =
 
1253
      g_strdup_printf (" %s ",
 
1254
                       key_n [i]);
 
1255
    g_object_set (label, "xalign", 1.0, NULL);
 
1256
    gtk_label_set_markup (GTK_LABEL (label), text_label); 
 
1257
    gtk_box_pack_start (GTK_BOX(box), label, TRUE, TRUE, 0);
 
1258
 
 
1259
    label = gtk_label_new (NULL);
 
1260
    text_label =
 
1261
      g_strdup_printf ("<sub><span size=\"small\">%s</span></sub> ",
 
1262
                       key_a [i]);
 
1263
    g_object_set (label, "xalign", 0.0, NULL);
 
1264
    gtk_label_set_markup (GTK_LABEL (label), text_label); 
 
1265
    gtk_size_group_add_widget (size_group_alpha, label);
 
1266
    gtk_box_pack_start (GTK_BOX(box), label, FALSE, TRUE, 0);
 
1267
 
 
1268
    button = gtk_button_new ();
 
1269
    gtk_container_set_border_width (GTK_CONTAINER (button), 0);
 
1270
    gtk_container_add (GTK_CONTAINER (button), box);
 
1271
   
 
1272
    gtk_widget_add_accelerator (button, "activate", 
 
1273
                                mw->accel, key_kp [i], 
 
1274
                                (GdkModifierType) 0, (GtkAccelFlags) 0);
 
1275
    
 
1276
    gtk_table_attach (GTK_TABLE (table), GTK_WIDGET (button), 
 
1277
                      i%3, i%3+1, i/3, i/3+1,
 
1278
                      (GtkAttachOptions) (GTK_FILL | GTK_EXPAND),
 
1279
                      (GtkAttachOptions) (GTK_FILL),
 
1280
                      0, 0);
 
1281
    
 
1282
    g_signal_connect (G_OBJECT (button), "clicked",
 
1283
                      GTK_SIGNAL_FUNC (dialpad_button_clicked_cb), 
 
1284
                      main_window);
 
1285
 
 
1286
    g_free (text_label);
 
1287
  }
 
1288
  
 
1289
  label = gtk_label_new (_("Dialpad"));
 
1290
 
 
1291
  gtk_notebook_append_page (GTK_NOTEBOOK (mw->main_notebook),
 
1292
                            table, label);
 
1293
}
 
1294
 
 
1295
 
 
1296
static void 
 
1297
gm_mw_init_video_settings (GtkWidget *main_window)
 
1298
{
 
1299
  GmWindow *mw = NULL;
 
1300
  
 
1301
  GtkWidget *label = NULL;
 
1302
  GtkWidget *hbox = NULL;
 
1303
  GtkWidget *vbox = NULL;
 
1304
  GtkWidget *image = NULL;
 
1305
 
 
1306
  GtkWidget *hscale_brightness = NULL;
 
1307
  GtkWidget *hscale_colour = NULL;
 
1308
  GtkWidget *hscale_contrast = NULL;
 
1309
  GtkWidget *hscale_whiteness = NULL;
 
1310
 
 
1311
  int brightness = 0, colour = 0, contrast = 0, whiteness = 0;
 
1312
 
 
1313
  g_return_if_fail (main_window != NULL);
 
1314
  mw = gm_mw_get_mw (main_window);
 
1315
 
 
1316
  /* Webcam Control Frame, we need it to disable controls */            
 
1317
  mw->video_settings_frame = gtk_frame_new (NULL);
 
1318
  gtk_frame_set_shadow_type (GTK_FRAME (mw->video_settings_frame), 
 
1319
                             GTK_SHADOW_NONE);
 
1320
  gtk_container_set_border_width (GTK_CONTAINER (mw->video_settings_frame), 5);
 
1321
  
 
1322
  /* Category */
 
1323
  vbox = gtk_vbox_new (0, FALSE);
 
1324
  gtk_container_add (GTK_CONTAINER (mw->video_settings_frame), vbox);
 
1325
  
 
1326
  /* Brightness */
 
1327
  hbox = gtk_hbox_new (0, FALSE);
 
1328
  image = gtk_image_new_from_stock (GM_STOCK_BRIGHTNESS, GTK_ICON_SIZE_MENU);
 
1329
  gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
 
1330
 
 
1331
  mw->adj_brightness = gtk_adjustment_new (brightness, 0.0, 
 
1332
                                           255.0, 1.0, 5.0, 1.0);
 
1333
  hscale_brightness = gtk_hscale_new (GTK_ADJUSTMENT (mw->adj_brightness));
 
1334
  gtk_range_set_update_policy (GTK_RANGE (hscale_brightness),
 
1335
                               GTK_UPDATE_DELAYED);
 
1336
  gtk_scale_set_draw_value (GTK_SCALE (hscale_brightness), FALSE);
 
1337
  gtk_scale_set_value_pos (GTK_SCALE (hscale_brightness), GTK_POS_RIGHT);
 
1338
  gtk_box_pack_start (GTK_BOX (hbox), hscale_brightness, TRUE, TRUE, 2);
 
1339
  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 3);
 
1340
 
 
1341
  gtk_tooltips_set_tip (mw->tips, hscale_brightness,
 
1342
                        _("Adjust brightness"), NULL);
 
1343
 
 
1344
  g_signal_connect (G_OBJECT (mw->adj_brightness), "value-changed",
 
1345
                    G_CALLBACK (video_settings_changed_cb), 
 
1346
                    (gpointer) main_window);
 
1347
 
 
1348
  /* Whiteness */
 
1349
  hbox = gtk_hbox_new (0, FALSE);
 
1350
  image = gtk_image_new_from_stock (GM_STOCK_WHITENESS, GTK_ICON_SIZE_MENU);
 
1351
  gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
 
1352
 
 
1353
  mw->adj_whiteness = gtk_adjustment_new (whiteness, 0.0, 
 
1354
                                          255.0, 1.0, 5.0, 1.0);
 
1355
  hscale_whiteness = gtk_hscale_new (GTK_ADJUSTMENT (mw->adj_whiteness));
 
1356
  gtk_range_set_update_policy (GTK_RANGE (hscale_whiteness),
 
1357
                               GTK_UPDATE_DELAYED);
 
1358
  gtk_scale_set_draw_value (GTK_SCALE (hscale_whiteness), FALSE);
 
1359
  gtk_scale_set_value_pos (GTK_SCALE (hscale_whiteness), GTK_POS_RIGHT);
 
1360
  gtk_box_pack_start (GTK_BOX (hbox), hscale_whiteness, TRUE, TRUE, 2);
 
1361
  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 3);
 
1362
 
 
1363
  gtk_tooltips_set_tip (mw->tips, hscale_whiteness,
 
1364
                        _("Adjust whiteness"), NULL);
 
1365
 
 
1366
  g_signal_connect (G_OBJECT (mw->adj_whiteness), "value-changed",
 
1367
                    G_CALLBACK (video_settings_changed_cb), 
 
1368
                    (gpointer) main_window);
 
1369
 
 
1370
  /* Colour */
 
1371
  hbox = gtk_hbox_new (0, FALSE);
 
1372
  image = gtk_image_new_from_stock (GM_STOCK_COLOURNESS, GTK_ICON_SIZE_MENU);
 
1373
  gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
 
1374
 
 
1375
  mw->adj_colour = gtk_adjustment_new (colour, 0.0, 
 
1376
                                       255.0, 1.0, 5.0, 1.0);
 
1377
  hscale_colour = gtk_hscale_new (GTK_ADJUSTMENT (mw->adj_colour));
 
1378
  gtk_range_set_update_policy (GTK_RANGE (hscale_colour),
 
1379
                               GTK_UPDATE_DELAYED);
 
1380
  gtk_scale_set_draw_value (GTK_SCALE (hscale_colour), FALSE);
 
1381
  gtk_scale_set_value_pos (GTK_SCALE (hscale_colour), GTK_POS_RIGHT);
 
1382
  gtk_box_pack_start (GTK_BOX (hbox), hscale_colour, TRUE, TRUE, 2);
 
1383
  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 3);
 
1384
 
 
1385
  gtk_tooltips_set_tip (mw->tips, hscale_colour,
 
1386
                        _("Adjust color"), NULL);
 
1387
 
 
1388
  g_signal_connect (G_OBJECT (mw->adj_colour), "value-changed",
 
1389
                    G_CALLBACK (video_settings_changed_cb), 
 
1390
                    (gpointer) main_window);
 
1391
 
 
1392
  /* Contrast */
 
1393
  hbox = gtk_hbox_new (0, FALSE);
 
1394
  image = gtk_image_new_from_stock (GM_STOCK_CONTRAST, GTK_ICON_SIZE_MENU);
 
1395
  gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
 
1396
  
 
1397
  mw->adj_contrast = gtk_adjustment_new (contrast, 0.0, 
 
1398
                                         255.0, 1.0, 5.0, 1.0);
 
1399
  hscale_contrast = gtk_hscale_new (GTK_ADJUSTMENT (mw->adj_contrast));
 
1400
  gtk_range_set_update_policy (GTK_RANGE (hscale_contrast),
 
1401
                               GTK_UPDATE_DELAYED);
 
1402
  gtk_scale_set_draw_value (GTK_SCALE (hscale_contrast), FALSE);
 
1403
  gtk_scale_set_value_pos (GTK_SCALE (hscale_contrast), GTK_POS_RIGHT);
 
1404
  gtk_box_pack_start (GTK_BOX (hbox), hscale_contrast, TRUE, TRUE, 2);
 
1405
  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 3);
 
1406
 
 
1407
  gtk_tooltips_set_tip (mw->tips, hscale_contrast,
 
1408
                        _("Adjust contrast"), NULL);
 
1409
 
 
1410
  g_signal_connect (G_OBJECT (mw->adj_contrast), "value-changed",
 
1411
                    G_CALLBACK (video_settings_changed_cb), 
 
1412
                    (gpointer) main_window);
 
1413
  
 
1414
  label = gtk_label_new (_("Video"));  
 
1415
 
 
1416
  gtk_notebook_append_page (GTK_NOTEBOOK(mw->main_notebook), 
 
1417
                            mw->video_settings_frame, label);
 
1418
}
 
1419
 
 
1420
 
 
1421
 
 
1422
static void 
 
1423
gm_mw_init_audio_settings (GtkWidget *main_window)
 
1424
{
 
1425
  GmWindow *mw = NULL;
 
1426
  
 
1427
  GtkWidget *hscale_play = NULL; 
 
1428
  GtkWidget *hscale_rec = NULL;
 
1429
  GtkWidget *label = NULL;
 
1430
  GtkWidget *hbox = NULL;
 
1431
  GtkWidget *vbox = NULL;
 
1432
  GtkWidget *small_vbox = NULL;
 
1433
  
 
1434
 
 
1435
  /* Get the data from the GMObject */
 
1436
  mw = gm_mw_get_mw (main_window);
 
1437
  
 
1438
 
 
1439
  /* Audio control frame, we need it to disable controls */             
 
1440
  mw->audio_volume_frame = gtk_frame_new (NULL);
 
1441
  gtk_frame_set_shadow_type (GTK_FRAME (mw->audio_volume_frame), 
 
1442
                             GTK_SHADOW_NONE);
 
1443
  gtk_container_set_border_width (GTK_CONTAINER (mw->audio_volume_frame), 5);
 
1444
 
 
1445
 
 
1446
  /* The vbox */
 
1447
  vbox = gtk_vbox_new (0, FALSE);
 
1448
  gtk_container_add (GTK_CONTAINER (mw->audio_volume_frame), vbox);
 
1449
 
 
1450
  /* Output volume */
 
1451
  hbox = gtk_hbox_new (0, FALSE);
 
1452
  gtk_box_pack_start (GTK_BOX (hbox), 
 
1453
                      gtk_image_new_from_stock (GM_STOCK_VOLUME, 
 
1454
                                                GTK_ICON_SIZE_SMALL_TOOLBAR),
 
1455
                      FALSE, FALSE, 0);
 
1456
  
 
1457
  small_vbox = gtk_vbox_new (0, FALSE);
 
1458
  mw->adj_output_volume = gtk_adjustment_new (0, 0.0, 100.0, 1.0, 5.0, 1.0);
 
1459
  hscale_play = gtk_hscale_new (GTK_ADJUSTMENT (mw->adj_output_volume));
 
1460
  gtk_range_set_update_policy (GTK_RANGE (hscale_play),
 
1461
                               GTK_UPDATE_DELAYED);
 
1462
  gtk_scale_set_value_pos (GTK_SCALE (hscale_play), GTK_POS_RIGHT); 
 
1463
  gtk_scale_set_draw_value (GTK_SCALE (hscale_play), FALSE);
 
1464
  gtk_box_pack_start (GTK_BOX (small_vbox), hscale_play, TRUE, TRUE, 0);
 
1465
 
 
1466
  mw->output_signal = gtk_levelmeter_new ();
 
1467
  gtk_box_pack_start (GTK_BOX (small_vbox), mw->output_signal, TRUE, TRUE, 0);
 
1468
  gtk_box_pack_start (GTK_BOX (hbox), small_vbox, TRUE, TRUE, 2);
 
1469
  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 3);
 
1470
 
 
1471
  /* Input volume */
 
1472
  hbox = gtk_hbox_new (0, FALSE);
 
1473
  gtk_box_pack_start (GTK_BOX (hbox),
 
1474
                      gtk_image_new_from_stock (GM_STOCK_MICROPHONE, 
 
1475
                                                GTK_ICON_SIZE_SMALL_TOOLBAR),
 
1476
                      FALSE, FALSE, 0);
 
1477
 
 
1478
  small_vbox = gtk_vbox_new (0, FALSE);
 
1479
  mw->adj_input_volume = gtk_adjustment_new (0, 0.0, 100.0, 1.0, 5.0, 1.0);
 
1480
  hscale_rec = gtk_hscale_new (GTK_ADJUSTMENT (mw->adj_input_volume));
 
1481
  gtk_range_set_update_policy (GTK_RANGE (hscale_rec),
 
1482
                               GTK_UPDATE_DELAYED);
 
1483
  gtk_scale_set_value_pos (GTK_SCALE (hscale_rec), GTK_POS_RIGHT); 
 
1484
  gtk_scale_set_draw_value (GTK_SCALE (hscale_rec), FALSE);
 
1485
  gtk_box_pack_start (GTK_BOX (small_vbox), hscale_rec, TRUE, TRUE, 0);
 
1486
 
 
1487
  mw->input_signal = gtk_levelmeter_new ();
 
1488
  gtk_box_pack_start (GTK_BOX (small_vbox), mw->input_signal, TRUE, TRUE, 0);
 
1489
  gtk_box_pack_start (GTK_BOX (hbox), small_vbox, TRUE, TRUE, 2);
 
1490
  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 3);
 
1491
 
 
1492
  g_signal_connect (G_OBJECT (mw->adj_output_volume), "value-changed",
 
1493
                    G_CALLBACK (audio_volume_changed_cb), main_window);
 
1494
 
 
1495
  g_signal_connect (G_OBJECT (mw->adj_input_volume), "value-changed",
 
1496
                    G_CALLBACK (audio_volume_changed_cb), main_window);
 
1497
 
 
1498
  label = gtk_label_new (_("Audio"));
 
1499
 
 
1500
  gtk_notebook_append_page (GTK_NOTEBOOK (mw->main_notebook),
 
1501
                            mw->audio_volume_frame, label);
 
1502
}
 
1503
 
 
1504
 
 
1505
GtkWidget *
 
1506
gm_mw_video_window_new (GtkWidget *main_window,
 
1507
                        gboolean is_local,
 
1508
                        gchar *title, 
 
1509
                        GtkWidget *&image,
 
1510
                        gchar *window_name)
 
1511
{
 
1512
  GmWindow *mw = NULL;
 
1513
  
 
1514
  GtkWidget *event_box = NULL;
 
1515
  GtkWidget *vbox = NULL;
 
1516
  GtkWidget *window = NULL;
 
1517
 
 
1518
 
 
1519
  g_return_val_if_fail (main_window != NULL, NULL);
 
1520
  mw = gm_mw_get_mw (main_window);
 
1521
  g_return_val_if_fail (mw != NULL, NULL);
 
1522
  
 
1523
 
 
1524
  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
 
1525
  gtk_window_set_title (GTK_WINDOW (window), title);
 
1526
  g_object_set_data_full (G_OBJECT (window), "window_name",
 
1527
                          g_strdup (window_name), g_free);
 
1528
  
 
1529
  event_box = gtk_event_box_new ();
 
1530
  vbox = gtk_vbox_new (0, FALSE);
 
1531
  image = gtk_image_new ();
 
1532
 
 
1533
  gtk_box_pack_start (GTK_BOX (vbox), image, TRUE, TRUE, 0);
 
1534
  gtk_container_set_border_width (GTK_CONTAINER (window), 0);
 
1535
 
 
1536
  gtk_container_add (GTK_CONTAINER (window), event_box);
 
1537
  gtk_container_add (GTK_CONTAINER (event_box), vbox);
 
1538
  gtk_widget_realize (image);
 
1539
 
 
1540
  gtk_widget_set_size_request (GTK_WIDGET (image), 176, 144);
 
1541
  gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
 
1542
 
 
1543
  gtk_widget_show_all (event_box);
 
1544
 
 
1545
  static MenuEntry local_popup_menu [] = {
 
1546
    
 
1547
      GTK_MENU_ENTRY("zoom_in", _("Zoom In"), _("Zoom in"), 
 
1548
                     GTK_STOCK_ZOOM_IN, '+', 
 
1549
                     GTK_SIGNAL_FUNC (zoom_in_changed_cb),
 
1550
                     (gpointer) VIDEO_DISPLAY_KEY "local_zoom_factor", TRUE),
 
1551
      GTK_MENU_ENTRY("zoom_out", _("Zoom Out"), _("Zoom out"), 
 
1552
                     GTK_STOCK_ZOOM_OUT, '-', 
 
1553
                     GTK_SIGNAL_FUNC (zoom_out_changed_cb),
 
1554
                     (gpointer) VIDEO_DISPLAY_KEY "local_zoom_factor", TRUE),
 
1555
      GTK_MENU_ENTRY("normal_size", _("Normal Size"), _("Normal size"), 
 
1556
                     GTK_STOCK_ZOOM_100, '=',
 
1557
                     GTK_SIGNAL_FUNC (zoom_normal_changed_cb),
 
1558
                     (gpointer) VIDEO_DISPLAY_KEY "local_zoom_factor", TRUE),
 
1559
 
 
1560
#ifdef HAS_SDL
 
1561
      GTK_MENU_ENTRY("fullscreen", _("Fullscreen"), _("Switch to fullscreen"), 
 
1562
                     GTK_STOCK_ZOOM_IN, 'f', 
 
1563
                     GTK_SIGNAL_FUNC (fullscreen_changed_cb),
 
1564
                     (gpointer) main_window, TRUE),
 
1565
#endif
 
1566
 
 
1567
      GTK_MENU_END
 
1568
  };
 
1569
  
 
1570
  static MenuEntry remote_popup_menu [] = {
 
1571
    
 
1572
      GTK_MENU_ENTRY("zoom_in", _("Zoom In"), _("Zoom in"), 
 
1573
                     GTK_STOCK_ZOOM_IN, '+', 
 
1574
                     GTK_SIGNAL_FUNC (zoom_in_changed_cb),
 
1575
                     (gpointer) VIDEO_DISPLAY_KEY "remote_zoom_factor", TRUE),
 
1576
      GTK_MENU_ENTRY("zoom_out", _("Zoom Out"), _("Zoom out"), 
 
1577
                     GTK_STOCK_ZOOM_OUT, '-', 
 
1578
                     GTK_SIGNAL_FUNC (zoom_out_changed_cb),
 
1579
                     (gpointer) VIDEO_DISPLAY_KEY "remote_zoom_factor", TRUE),
 
1580
      GTK_MENU_ENTRY("normal_size", _("Normal Size"), _("Normal size"), 
 
1581
                     GTK_STOCK_ZOOM_100, '=',
 
1582
                     GTK_SIGNAL_FUNC (zoom_normal_changed_cb),
 
1583
                     (gpointer) VIDEO_DISPLAY_KEY "remote_zoom_factor", TRUE),
 
1584
 
 
1585
#ifdef HAS_SDL
 
1586
      GTK_MENU_ENTRY("fullscreen", _("Fullscreen"), _("Switch to fullscreen"), 
 
1587
                     GTK_STOCK_ZOOM_IN, 'f', 
 
1588
                     GTK_SIGNAL_FUNC (fullscreen_changed_cb),
 
1589
                     (gpointer) main_window, TRUE),
 
1590
#endif
 
1591
 
 
1592
      GTK_MENU_END
 
1593
  };
 
1594
 
 
1595
  if (is_local)
 
1596
    gtk_build_popup_menu (event_box, local_popup_menu, mw->accel);
 
1597
  else
 
1598
    gtk_build_popup_menu (event_box, remote_popup_menu, mw->accel);
 
1599
  
 
1600
  g_signal_connect (G_OBJECT (window), "delete_event",
 
1601
                    G_CALLBACK (gtk_widget_hide_on_delete), 0);
 
1602
 
 
1603
  return window;
 
1604
}
 
1605
 
 
1606
 
 
1607
#ifdef HAS_SDL
 
1608
void
 
1609
gm_mw_init_fullscreen_video_window (GtkWidget *main_window)
 
1610
{
 
1611
  GmWindow *mw = NULL;
 
1612
 
 
1613
  g_return_if_fail (main_window != NULL);
 
1614
 
 
1615
  mw = gm_mw_get_mw (main_window);
 
1616
 
 
1617
  g_return_if_fail (mw != NULL);
 
1618
 
 
1619
  mw->screen = SDL_GetVideoSurface ();
 
1620
  if (!mw->screen) {
 
1621
 
 
1622
    SDL_Init (SDL_INIT_VIDEO);
 
1623
    mw->screen = SDL_SetVideoMode (640, 480, 0, 
 
1624
                                   SDL_SWSURFACE | SDL_HWSURFACE | 
 
1625
                                   SDL_ANYFORMAT);
 
1626
    SDL_WM_ToggleFullScreen (mw->screen);
 
1627
    SDL_ShowCursor (SDL_DISABLE);
 
1628
  }
 
1629
}
 
1630
 
 
1631
 
 
1632
gboolean
 
1633
gm_mw_poll_fullscreen_video_window (GtkWidget *main_window)
 
1634
{
 
1635
  SDL_Event event;
 
1636
 
 
1637
  
 
1638
  while (SDL_PollEvent (&event)) {
 
1639
 
 
1640
    if (event.type == SDL_KEYDOWN) {
 
1641
 
 
1642
      /* Exit Full Screen */
 
1643
      if ((event.key.keysym.sym == SDLK_ESCAPE) ||
 
1644
          (event.key.keysym.sym == SDLK_f)) {
 
1645
 
 
1646
        return TRUE;
 
1647
      }
 
1648
    }
 
1649
  }
 
1650
 
 
1651
  return FALSE;
 
1652
}
 
1653
 
 
1654
 
 
1655
void
 
1656
gm_mw_toggle_fullscreen (GtkWidget *main_window)
 
1657
{
 
1658
  if (gm_conf_get_float (VIDEO_DISPLAY_KEY "zoom_factor") == -1.0)
 
1659
    gm_conf_set_float (VIDEO_DISPLAY_KEY "zoom_factor", 1.0);
 
1660
  else
 
1661
    gm_conf_set_float (VIDEO_DISPLAY_KEY "zoom_factor", -1.0);
 
1662
}
 
1663
 
 
1664
 
 
1665
void
 
1666
gm_mw_destroy_fullscreen_video_window (GtkWidget *main_window)
 
1667
{
 
1668
  GmWindow *mw = NULL;
 
1669
 
 
1670
  g_return_if_fail (main_window != NULL);
 
1671
 
 
1672
  mw = gm_mw_get_mw (main_window);
 
1673
 
 
1674
  g_return_if_fail (mw != NULL);
 
1675
 
 
1676
  SDL_Quit ();
 
1677
  mw->screen = NULL;
 
1678
  
 
1679
}
 
1680
#endif
 
1681
 
 
1682
 
 
1683
void 
 
1684
gm_mw_show_video_section (GtkWidget *main_window,
 
1685
                          gboolean show)
 
1686
{
 
1687
  GmWindow *mw = NULL;
 
1688
 
 
1689
  g_return_if_fail (main_window != NULL);
 
1690
  
 
1691
  mw = gm_mw_get_mw (main_window);
 
1692
 
 
1693
  g_return_if_fail (mw != NULL);
 
1694
 
 
1695
  if (show)
 
1696
    gtk_widget_show_all (mw->video_frame);
 
1697
  else 
 
1698
    gtk_widget_hide (mw->video_frame);
 
1699
}
 
1700
 
 
1701
 
 
1702
void 
 
1703
gm_mw_show_control_panel (GtkWidget *main_window,
 
1704
                          gboolean show)
 
1705
{
 
1706
  GmWindow *mw = NULL;
 
1707
 
 
1708
  g_return_if_fail (main_window != NULL);
 
1709
  
 
1710
  mw = gm_mw_get_mw (main_window);
 
1711
 
 
1712
  g_return_if_fail (mw != NULL);
 
1713
 
 
1714
  if (show)
 
1715
    gtk_widget_show_all (mw->main_notebook);
 
1716
  else 
 
1717
    gtk_widget_hide (mw->main_notebook);
 
1718
}
 
1719
 
 
1720
 
 
1721
/* GTK callbacks */
 
1722
static gint
 
1723
gnomemeeting_tray_hack_cb (gpointer data)
 
1724
{
 
1725
  GtkWidget *main_window = NULL;
 
1726
  GtkWidget *statusicon = NULL;
 
1727
 
 
1728
  statusicon = GnomeMeeting::Process ()->GetStatusicon ();
 
1729
  main_window = GnomeMeeting::Process ()->GetMainWindow ();
 
1730
  
 
1731
  gdk_threads_enter ();
 
1732
 
 
1733
  if (!gm_statusicon_is_embedded (statusicon)) {
 
1734
 
 
1735
    gnomemeeting_error_dialog (GTK_WINDOW (main_window), _("Notification area not detected"), _("The notification area is not present in your panel, so Ekiga cannot start hidden."));
 
1736
    gtk_widget_show (main_window);
 
1737
  }
 
1738
  
 
1739
  gdk_threads_leave ();
 
1740
 
 
1741
  return FALSE;
 
1742
}
 
1743
 
 
1744
static void 
 
1745
hold_current_call_cb (GtkWidget *widget,
 
1746
                      gpointer data)
 
1747
{
 
1748
  PString call_token;
 
1749
  GMManager *endpoint = NULL;
 
1750
 
 
1751
  BOOL is_on_hold = FALSE;
 
1752
  
 
1753
  endpoint = GnomeMeeting::Process ()->GetManager ();
 
1754
 
 
1755
  /* Release the GDK thread to prevent deadlocks, change
 
1756
   * the hold state at the endpoint level.
 
1757
   */
 
1758
  gdk_threads_leave ();
 
1759
  call_token = endpoint->GetCurrentCallToken ();
 
1760
  is_on_hold = endpoint->IsCallOnHold (call_token);
 
1761
  if (endpoint->SetCallOnHold (call_token, !is_on_hold))
 
1762
    is_on_hold = !is_on_hold; /* It worked */
 
1763
  gdk_threads_enter ();
 
1764
}
 
1765
 
 
1766
 
 
1767
static void
 
1768
pause_current_call_channel_cb (GtkWidget *widget,
 
1769
                               gpointer data)
 
1770
{
 
1771
  GMManager *endpoint = NULL;
 
1772
  GMVideoGrabber *vg = NULL;
 
1773
 
 
1774
  GtkWidget *main_window = NULL;
 
1775
 
 
1776
  PString current_call_token;
 
1777
  BOOL is_paused = FALSE;
 
1778
  
 
1779
  endpoint = GnomeMeeting::Process ()->GetManager ();
 
1780
  current_call_token = endpoint->GetCurrentCallToken ();
 
1781
 
 
1782
  main_window = GnomeMeeting::Process ()->GetMainWindow (); 
 
1783
 
 
1784
  if (current_call_token.IsEmpty ()
 
1785
      && (GPOINTER_TO_INT (data) == 1)
 
1786
      && endpoint->GetCallingState () == GMManager::Standby) {
 
1787
 
 
1788
    gdk_threads_leave ();
 
1789
    vg = endpoint->GetVideoGrabber ();
 
1790
    if (vg) {
 
1791
      
 
1792
      if (vg->IsGrabbing ()) {
 
1793
 
 
1794
        vg->StopGrabbing ();
 
1795
        gm_main_window_set_channel_pause (main_window, TRUE, TRUE);
 
1796
      }
 
1797
      else {
 
1798
 
 
1799
        vg->StartGrabbing ();
 
1800
        gm_main_window_set_channel_pause (main_window, FALSE, TRUE);
 
1801
      }
 
1802
 
 
1803
      vg->Unlock ();
 
1804
    }
 
1805
    gdk_threads_enter ();
 
1806
  }
 
1807
  else {
 
1808
 
 
1809
    if (GPOINTER_TO_INT (data) == 0) {
 
1810
      
 
1811
      gdk_threads_leave ();
 
1812
      is_paused = endpoint->IsCallAudioPaused (current_call_token);
 
1813
      if (endpoint->SetCallAudioPause (current_call_token, !is_paused))
 
1814
        is_paused = !is_paused; /* It worked */
 
1815
      gdk_threads_enter ();
 
1816
 
 
1817
      gm_main_window_set_channel_pause (main_window, is_paused, FALSE);
 
1818
    }
 
1819
    else {
 
1820
 
 
1821
      gdk_threads_leave ();
 
1822
      is_paused = endpoint->IsCallVideoPaused (current_call_token);
 
1823
      if (endpoint->SetCallVideoPause (current_call_token, !is_paused))
 
1824
        is_paused = !is_paused; /* It worked */
 
1825
      gdk_threads_enter ();
 
1826
      
 
1827
      gm_main_window_set_channel_pause (main_window, is_paused, TRUE);
 
1828
    }
 
1829
  }
 
1830
}
 
1831
 
 
1832
 
 
1833
static void 
 
1834
transfer_current_call_cb (GtkWidget *widget,
 
1835
                          gpointer data)
 
1836
{
 
1837
  GtkWidget *main_window = NULL;
 
1838
  
 
1839
  g_return_if_fail (data != NULL);
 
1840
  
 
1841
  main_window = GnomeMeeting::Process ()->GetMainWindow ();
 
1842
 
 
1843
  gm_main_window_transfer_dialog_run (main_window, GTK_WIDGET (data), NULL);  
 
1844
}
 
1845
 
 
1846
 
 
1847
static void
 
1848
video_window_shown_cb (GtkWidget *w, 
 
1849
                       gpointer data)
 
1850
{
 
1851
  GMManager *endpoint = NULL;
 
1852
 
 
1853
  endpoint = GnomeMeeting::Process ()->GetManager ();
 
1854
 
 
1855
  if (endpoint 
 
1856
      && gm_conf_get_bool (VIDEO_DISPLAY_KEY "stay_on_top")
 
1857
      && endpoint->GetCallingState () == GMManager::Connected)
 
1858
    gdk_window_set_always_on_top (GDK_WINDOW (w->window), TRUE);
 
1859
}
 
1860
 
 
1861
 
 
1862
static void
 
1863
dnd_call_contact_cb (GtkWidget *widget, 
 
1864
                     GmContact *contact,
 
1865
                     gint x, 
 
1866
                     gint y, 
 
1867
                     gpointer data)
 
1868
{
 
1869
  GmWindow *mw = NULL;
 
1870
  GMManager *ep = NULL;
 
1871
  
 
1872
  GtkWidget *main_window = NULL;
 
1873
  
 
1874
  g_return_if_fail (data != NULL);
 
1875
  
 
1876
  ep = GnomeMeeting::Process ()->GetManager ();
 
1877
  main_window = GnomeMeeting::Process ()->GetMainWindow ();
 
1878
 
 
1879
  mw = GM_WINDOW (data);
 
1880
 
 
1881
  if (contact && contact->url) {
 
1882
    
 
1883
    if (ep->GetCallingState () == GMManager::Connected)
 
1884
      gm_main_window_transfer_dialog_run (main_window, 
 
1885
                                          main_window, 
 
1886
                                          contact->url);
 
1887
    else if (ep->GetCallingState () == GMManager::Standby) 
 
1888
      GnomeMeeting::Process ()->Connect (contact->url);
 
1889
 
 
1890
    gmcontact_delete (contact);
 
1891
  }
 
1892
}
 
1893
 
 
1894
 
 
1895
static void 
 
1896
audio_volume_changed_cb (GtkAdjustment *adjustment, 
 
1897
                         gpointer data)
 
1898
{
 
1899
  GMManager *ep = NULL;
 
1900
  GMPCSSEndpoint *pcssEP = NULL;
 
1901
  
 
1902
  BOOL success = FALSE;
 
1903
 
 
1904
  int play_vol = 0; 
 
1905
  int rec_vol = 0;
 
1906
 
 
1907
  g_return_if_fail (data != NULL);
 
1908
 
 
1909
  ep = GnomeMeeting::Process ()->GetManager ();
 
1910
  pcssEP = ep->GetPCSSEndpoint ();
 
1911
  
 
1912
  gm_main_window_get_volume_sliders_values (GTK_WIDGET (data), 
 
1913
                                            play_vol, rec_vol);
 
1914
 
 
1915
  gdk_threads_leave ();
 
1916
  success = pcssEP->SetDeviceVolume (play_vol, rec_vol);
 
1917
  gdk_threads_enter ();
 
1918
 
 
1919
  if (!success)
 
1920
    gm_main_window_set_volume_sliders_values (GTK_WIDGET (data), 0, 0);
 
1921
}
 
1922
 
 
1923
 
 
1924
static void 
 
1925
video_settings_changed_cb (GtkAdjustment *adjustment, 
 
1926
                           gpointer data)
 
1927
 
1928
  GMManager *ep = NULL;
 
1929
  GMVideoGrabber *video_grabber = NULL;
 
1930
 
 
1931
  BOOL success = FALSE;
 
1932
  
 
1933
  int brightness = -1;
 
1934
  int whiteness = -1;
 
1935
  int colour = -1;
 
1936
  int contrast = -1;
 
1937
 
 
1938
  g_return_if_fail (data != NULL);
 
1939
  
 
1940
  ep = GnomeMeeting::Process ()->GetManager ();
 
1941
  
 
1942
  gm_main_window_get_video_sliders_values (GTK_WIDGET (data),
 
1943
                                           whiteness,
 
1944
                                           brightness,
 
1945
                                           colour,
 
1946
                                           contrast);
 
1947
 
 
1948
  /* Notice about mutexes:
 
1949
     The GDK lock is taken in the callback. We need to release it, because
 
1950
     if CreateVideoGrabber is called in another thread, it will only
 
1951
     release its internal mutex (also used by GetVideoGrabber) after it 
 
1952
     returns, but it will return only if it is opened, and it can't open 
 
1953
     if the GDK lock is held as it will wait on the GDK lock before 
 
1954
     updating the GUI */
 
1955
  gdk_threads_leave ();
 
1956
  if ((video_grabber = ep->GetVideoGrabber ())) {
 
1957
    
 
1958
    if (whiteness > 0)
 
1959
      success = video_grabber->SetWhiteness (whiteness << 8);
 
1960
    if (brightness > 0)
 
1961
      success = video_grabber->SetBrightness (brightness << 8) || success;
 
1962
    if (colour > 0)
 
1963
      success = video_grabber->SetColour (colour << 8) || success;
 
1964
    if (contrast > 0)
 
1965
      success = video_grabber->SetContrast (contrast << 8) || success;
 
1966
    video_grabber->Unlock ();
 
1967
  }
 
1968
  gdk_threads_enter ();
 
1969
 
 
1970
  if (!success)
 
1971
    gm_main_window_set_video_sliders_values (GTK_WIDGET (data), 0, 0, 0, 0);
 
1972
}
 
1973
 
 
1974
 
 
1975
static void 
 
1976
control_panel_section_changed_cb (GtkNotebook *notebook, 
 
1977
                                  GtkNotebookPage *page,
 
1978
                                  gint page_num, 
 
1979
                                  gpointer data) 
 
1980
{
 
1981
  GmWindow *mw = NULL;
 
1982
  
 
1983
  gint current_page = 0;
 
1984
 
 
1985
  g_return_if_fail (data != NULL);
 
1986
  mw = gm_mw_get_mw (GTK_WIDGET (data));
 
1987
  
 
1988
  current_page = 
 
1989
    gtk_notebook_get_current_page (GTK_NOTEBOOK (mw->main_notebook));
 
1990
  gm_conf_set_int (USER_INTERFACE_KEY "main_window/control_panel_section",
 
1991
                   current_page);
 
1992
}
 
1993
 
 
1994
 
 
1995
static void 
 
1996
dialpad_button_clicked_cb (GtkButton *button, 
 
1997
                           gpointer data)
 
1998
{
 
1999
  GtkWidget *label = NULL;
 
2000
  const char *button_text = NULL;
 
2001
 
 
2002
  BOOL sent = FALSE;
 
2003
  PString call_token;
 
2004
  PString url;
 
2005
 
 
2006
  GMManager *endpoint = NULL;
 
2007
 
 
2008
  g_return_if_fail (data != NULL);
 
2009
 
 
2010
 
 
2011
  endpoint = GnomeMeeting::Process ()->GetManager ();
 
2012
 
 
2013
  label = ( (GtkBoxChild*) GTK_BOX (gtk_bin_get_child (GTK_BIN (button)) )->children->data )->widget;
 
2014
  button_text = gtk_label_get_text (GTK_LABEL (label));
 
2015
 
 
2016
  if (button_text
 
2017
      && strcmp (button_text, "")
 
2018
      && strlen (button_text) > 1
 
2019
      && button_text [0]) {
 
2020
 
 
2021
    /* Release the GDK thread to prevent deadlocks */
 
2022
    gdk_threads_leave ();
 
2023
    call_token = endpoint->GetCurrentCallToken ();
 
2024
 
 
2025
    /* Send the DTMF if there is a current call */
 
2026
    if (!call_token.IsEmpty ()) {
 
2027
      
 
2028
      endpoint->SendDTMF (call_token, button_text [1]);
 
2029
      sent = TRUE;
 
2030
    }
 
2031
    gdk_threads_enter ();
 
2032
 
 
2033
 
 
2034
    /* Update the GUI, ie the URL bar if we are not in a call,
 
2035
     * and a button press in all cases */
 
2036
    if (!sent) {
 
2037
 
 
2038
      if (button_text [1] == '*')
 
2039
        url += '.';
 
2040
      else
 
2041
        url += button_text [1];
 
2042
      
 
2043
      gm_main_window_append_call_url (GTK_WIDGET (data), url);
 
2044
    }
 
2045
    else
 
2046
      gm_main_window_flash_message (GTK_WIDGET (data),
 
2047
                                    _("Sent DTMF %c"), 
 
2048
                                    button_text [1]);
 
2049
  }
 
2050
}
 
2051
 
 
2052
 
 
2053
static gint 
 
2054
window_closed_cb (GtkWidget *widget, 
 
2055
                  GdkEvent *event,
 
2056
                  gpointer data)
 
2057
{
 
2058
  GtkWidget *statusicon = NULL;
 
2059
  
 
2060
  GmWindow *mw = NULL;
 
2061
  
 
2062
  gboolean b = FALSE;
 
2063
 
 
2064
  g_return_val_if_fail (data != NULL, FALSE);
 
2065
  mw = gm_mw_get_mw (GTK_WIDGET (data));
 
2066
  statusicon = GnomeMeeting::Process ()->GetStatusicon ();
 
2067
  
 
2068
 
 
2069
  b = gm_statusicon_is_embedded (statusicon);
 
2070
 
 
2071
  if (!b)
 
2072
    quit_callback (NULL, data);
 
2073
  else 
 
2074
    gnomemeeting_window_hide (GTK_WIDGET (data));
 
2075
 
 
2076
  return (TRUE);
 
2077
}  
 
2078
 
 
2079
 
 
2080
static void 
 
2081
zoom_in_changed_cb (GtkWidget *widget,
 
2082
                    gpointer data)
 
2083
{
 
2084
  double zoom = 0.0;
 
2085
 
 
2086
  g_return_if_fail (data != NULL);
 
2087
 
 
2088
  zoom = gm_conf_get_float ((char *) data);
 
2089
 
 
2090
  if (zoom < 2.00)
 
2091
    zoom = zoom * 2.0;
 
2092
 
 
2093
  gm_conf_set_float ((char *) data, zoom);
 
2094
}
 
2095
 
 
2096
 
 
2097
static void 
 
2098
zoom_out_changed_cb (GtkWidget *widget,
 
2099
                     gpointer data)
 
2100
{
 
2101
  double zoom = 0.0;
 
2102
 
 
2103
  g_return_if_fail (data != NULL);
 
2104
 
 
2105
  zoom = gm_conf_get_float ((char *) data);
 
2106
 
 
2107
  if (zoom > 0.5)
 
2108
    zoom = zoom / 2.0;
 
2109
  
 
2110
  gm_conf_set_float ((char *) data, zoom);
 
2111
}
 
2112
 
 
2113
 
 
2114
static void 
 
2115
zoom_normal_changed_cb (GtkWidget *widget,
 
2116
                        gpointer data)
 
2117
{
 
2118
  double zoom = 1.0;
 
2119
 
 
2120
  g_return_if_fail (data != NULL);
 
2121
 
 
2122
  gm_conf_set_float ((char *) data, zoom);
 
2123
}
 
2124
 
 
2125
 
 
2126
#ifdef HAS_SDL
 
2127
static void 
 
2128
fullscreen_changed_cb (GtkWidget *widget,
 
2129
                       gpointer data)
 
2130
{
 
2131
  gm_mw_toggle_fullscreen (GTK_WIDGET (data));
 
2132
}
 
2133
#endif
 
2134
 
 
2135
 
 
2136
static void
 
2137
speed_dial_menu_item_selected_cb (GtkWidget *w,
 
2138
                                  gpointer data)
 
2139
{
 
2140
  GtkWidget *main_window = NULL;
 
2141
  
 
2142
  GmWindow *mw = NULL;
 
2143
  GMManager *ep = NULL;
 
2144
  
 
2145
  gchar *url = NULL;
 
2146
  
 
2147
  main_window = GnomeMeeting::Process ()->GetMainWindow ();
 
2148
  
 
2149
  mw = gm_mw_get_mw (main_window); 
 
2150
  ep = GnomeMeeting::Process ()->GetManager ();
 
2151
  
 
2152
  g_return_if_fail (data != NULL);
 
2153
 
 
2154
  url = g_strdup_printf ("%s#", (gchar *) data);
 
2155
  gm_main_window_set_call_url (main_window, url);
 
2156
    
 
2157
 
 
2158
  /* Directly Connect or run the transfer dialog */
 
2159
  if (ep->GetCallingState () == GMManager::Connected)
 
2160
    gm_main_window_transfer_dialog_run (main_window, main_window, url);
 
2161
  else
 
2162
    GnomeMeeting::Process ()->Connect (url);
 
2163
 
 
2164
  g_free (url);
 
2165
}
 
2166
 
 
2167
 
 
2168
static void
 
2169
url_changed_cb (GtkEditable  *e, 
 
2170
                gpointer data)
 
2171
{
 
2172
  GmWindow *mw = NULL;
 
2173
  
 
2174
  const char *tip_text = NULL;
 
2175
  
 
2176
  g_return_if_fail (data != NULL);
 
2177
  mw = gm_mw_get_mw (GTK_WIDGET (data));
 
2178
 
 
2179
  tip_text = gtk_entry_get_text (GTK_ENTRY (e));
 
2180
 
 
2181
  gtk_tooltips_set_tip (mw->tips, GTK_WIDGET (e), tip_text, NULL);
 
2182
}
 
2183
 
 
2184
 
 
2185
static gboolean
 
2186
completion_url_selected_cb (GtkEntryCompletion *completion,
 
2187
                            GtkTreeModel *model,
 
2188
                            GtkTreeIter *iter,
 
2189
                            gpointer data)
 
2190
{
 
2191
  gchar *url = NULL;
 
2192
  
 
2193
  gtk_tree_model_get (GTK_TREE_MODEL (model), iter, 1, &url, -1);
 
2194
 
 
2195
  GnomeMeeting::Process ()->Connect (url);
 
2196
 
 
2197
  g_free (url);
 
2198
 
 
2199
  return TRUE;
 
2200
}
 
2201
 
 
2202
 
 
2203
static void 
 
2204
url_activated_cb (GtkWidget *w,
 
2205
                  gpointer data)
 
2206
{
 
2207
  const char *url = NULL;
 
2208
  
 
2209
  url = gtk_entry_get_text (GTK_ENTRY (w));
 
2210
  
 
2211
  GnomeMeeting::Process ()->Connect (url);
 
2212
}
 
2213
 
 
2214
 
 
2215
static void 
 
2216
view_mode_button_clicked_cb (GtkWidget *w, 
 
2217
                             gpointer data)
 
2218
{
 
2219
  int m = SOFTPHONE;
 
2220
 
 
2221
  m = gm_conf_get_int (USER_INTERFACE_KEY "main_window/view_mode");
 
2222
 
 
2223
  m = m + 1;
 
2224
 
 
2225
  if (m == NUM_VIEW_MODES)
 
2226
    m = SOFTPHONE;
 
2227
 
 
2228
  gm_conf_set_int (USER_INTERFACE_KEY "main_window/view_mode", m);
 
2229
}
 
2230
 
 
2231
 
 
2232
static void 
 
2233
toolbar_toggle_button_changed_cb (GtkWidget *widget, 
 
2234
                                  gpointer data)
 
2235
{
 
2236
  bool shown = gm_conf_get_bool ((gchar *) data);
 
2237
 
 
2238
  gm_conf_set_bool ((gchar *) data, !shown);
 
2239
}
 
2240
 
 
2241
 
 
2242
static gboolean 
 
2243
statusbar_clicked_cb (GtkWidget *widget,
 
2244
                      GdkEventButton *event,
 
2245
                      gpointer data)
 
2246
{
 
2247
  GMManager *ep = NULL;
 
2248
  gchar *info = NULL;
 
2249
  
 
2250
  ep = GnomeMeeting::Process ()->GetManager ();
 
2251
  
 
2252
  ep->ResetMissedCallsNumber ();
 
2253
  
 
2254
  info = g_strdup_printf (_("Missed calls: %d - Voice Mails: %s"),
 
2255
                          ep->GetMissedCallsNumber (),
 
2256
                          (const char *) ep->GetMWI ());
 
2257
  gm_main_window_push_info_message (GTK_WIDGET (data), info);
 
2258
  g_free (info);
 
2259
 
 
2260
 
 
2261
  return FALSE;
 
2262
}
 
2263
 
 
2264
 
 
2265
static gboolean
 
2266
delete_incoming_call_dialog_cb (GtkWidget *w,
 
2267
                                GdkEvent *ev,
 
2268
                                gpointer data)
 
2269
{
 
2270
  GmWindow *mw = NULL;
 
2271
 
 
2272
  g_return_val_if_fail (data != NULL, TRUE);
 
2273
 
 
2274
  mw = gm_mw_get_mw (GTK_WIDGET (data));
 
2275
 
 
2276
  g_return_val_if_fail (GTK_WIDGET (data), TRUE);
 
2277
 
 
2278
  mw->incoming_call_popup = NULL;
 
2279
 
 
2280
  GnomeMeeting::Process ()->Disconnect ();
 
2281
  
 
2282
  return FALSE;
 
2283
}
 
2284
 
 
2285
 
 
2286
static void 
 
2287
show_chat_window_cb (GtkWidget *w,
 
2288
                     gpointer data)
 
2289
{
 
2290
  GtkWidget *statusicon = NULL;
 
2291
 
 
2292
  gchar *name = NULL;
 
2293
  gchar *url = NULL;
 
2294
 
 
2295
  GMManager *ep = NULL;
 
2296
  
 
2297
  ep = GnomeMeeting::Process ()->GetManager ();
 
2298
  statusicon = GnomeMeeting::Process ()->GetStatusicon ();
 
2299
  
 
2300
  if (!gnomemeeting_window_is_visible (GTK_WIDGET (data))) {
 
2301
    
 
2302
    /* Check if there is an active call */
 
2303
    gdk_threads_leave ();
 
2304
    ep->GetCurrentConnectionInfo (name, url);
 
2305
    gdk_threads_enter ();
 
2306
 
 
2307
    /* If we are in a call, add a tab with the given URL if there
 
2308
     * is none.
 
2309
     */
 
2310
    if (url && !gm_text_chat_window_has_tab (GTK_WIDGET (data), url)) {
 
2311
 
 
2312
      gm_text_chat_window_add_tab (GTK_WIDGET (data), url, name);
 
2313
      if (url)
 
2314
        gm_chat_window_update_calling_state (GTK_WIDGET (data), 
 
2315
                                             name,
 
2316
                                             url, 
 
2317
                                             GMManager::Connected);
 
2318
    }
 
2319
 
 
2320
    gnomemeeting_window_show (GTK_WIDGET (data));
 
2321
    gm_statusicon_signal_message (GTK_WIDGET (statusicon), FALSE);
 
2322
  }
 
2323
  else
 
2324
    gnomemeeting_window_hide (GTK_WIDGET (data));
 
2325
}
 
2326
 
 
2327
 
 
2328
static gboolean 
 
2329
gm_mw_urls_history_update_cb (gpointer data)
 
2330
{
 
2331
  GmWindow *mw = NULL;
 
2332
 
 
2333
  GmContact *c = NULL;
 
2334
 
 
2335
  GValue val = {0, };
 
2336
 
 
2337
  GtkWidget *main_window = NULL;
 
2338
  
 
2339
  GtkTreeModel *history_model = NULL;
 
2340
  GtkTreeModel *cache_model = NULL;
 
2341
  GtkEntryCompletion *completion = NULL;
 
2342
  
 
2343
  GtkTreeIter tree_iter;
 
2344
  
 
2345
  GSList *c1 = NULL;
 
2346
  GSList *c2 = NULL;
 
2347
  GSList *contacts = NULL;
 
2348
  GSList *iter = NULL;
 
2349
 
 
2350
  unsigned int cpt = 0;
 
2351
  int nbr = 0;
 
2352
 
 
2353
  gchar *entry = NULL;
 
2354
  
 
2355
  main_window = GTK_WIDGET (data);
 
2356
 
 
2357
  g_return_val_if_fail (main_window != NULL, FALSE);
 
2358
  
 
2359
  mw = gm_mw_get_mw (main_window);
 
2360
  
 
2361
  
 
2362
  /* Get the placed calls history */
 
2363
  g_value_init (&val, G_TYPE_INT);
 
2364
  g_value_set_int (&val, -1);
 
2365
  g_object_set_property (G_OBJECT (mw->combo), "active", &val);
 
2366
 
 
2367
  gdk_threads_enter ();
 
2368
  c2 = gm_calls_history_get_calls (PLACED_CALL, 10, FALSE);
 
2369
 
 
2370
  history_model = 
 
2371
    gtk_combo_box_get_model (GTK_COMBO_BOX (mw->combo));
 
2372
  gtk_list_store_clear (GTK_LIST_STORE (history_model));
 
2373
  gdk_threads_leave ();
 
2374
 
 
2375
  iter = c2;
 
2376
  while (iter) {
 
2377
    
 
2378
    c = GM_CONTACT (iter->data);
 
2379
    if (c->url && strcmp (c->url, "")) {
 
2380
 
 
2381
      gdk_threads_enter ();
 
2382
      gtk_combo_box_prepend_text (GTK_COMBO_BOX (mw->combo), c->url);
 
2383
      gdk_threads_leave ();
 
2384
      cpt++;
 
2385
    }
 
2386
    
 
2387
    iter = g_slist_next (iter);
 
2388
  }
 
2389
  g_slist_foreach (c2, (GFunc) gmcontact_delete, NULL);
 
2390
  g_slist_free (c2);
 
2391
  c2 = NULL;
 
2392
 
 
2393
 
 
2394
  /* Get the full address book */
 
2395
  gdk_threads_enter ();
 
2396
  c1 = gnomemeeting_addressbook_get_contacts (NULL,
 
2397
                                              nbr,
 
2398
                                              FALSE,
 
2399
                                              NULL,
 
2400
                                              NULL,
 
2401
                                              NULL,
 
2402
                                              NULL);
 
2403
  
 
2404
  
 
2405
  /* Get the full calls history */
 
2406
  c2 = gm_calls_history_get_calls (MAX_VALUE_CALL, 25, TRUE);
 
2407
  contacts = g_slist_concat (c1, c2);
 
2408
 
 
2409
  completion = 
 
2410
    gtk_entry_get_completion (GTK_ENTRY (GTK_BIN (mw->combo)->child));
 
2411
  cache_model = 
 
2412
    gtk_entry_completion_get_model (GTK_ENTRY_COMPLETION (completion));
 
2413
  gtk_list_store_clear (GTK_LIST_STORE (cache_model));
 
2414
  gdk_threads_leave ();
 
2415
 
 
2416
 
 
2417
  iter = contacts;
 
2418
  while (iter) {
 
2419
 
 
2420
    c = GM_CONTACT (iter->data);
 
2421
    if (c->url && strcmp (c->url, "")) {
 
2422
 
 
2423
      entry = NULL;
 
2424
 
 
2425
      if (c->fullname && strcmp (c->fullname, ""))
 
2426
        entry = g_strdup_printf ("%s [%s]",
 
2427
                                 c-> url, 
 
2428
                                 c->fullname);
 
2429
      else
 
2430
        entry = g_strdup (c->url);
 
2431
      
 
2432
      gdk_threads_enter ();
 
2433
      gtk_list_store_append (GTK_LIST_STORE (cache_model), &tree_iter);
 
2434
      gtk_list_store_set (GTK_LIST_STORE (cache_model), &tree_iter, 
 
2435
                          0, c->fullname,
 
2436
                          1, c->url,
 
2437
                          2, (char *) entry, -1);
 
2438
      gdk_threads_leave ();
 
2439
 
 
2440
      g_free (entry);
 
2441
    }
 
2442
    
 
2443
    iter = g_slist_next (iter);
 
2444
  }
 
2445
 
 
2446
  g_slist_foreach (contacts, (GFunc) gmcontact_delete, NULL);
 
2447
  g_slist_free (contacts);
 
2448
 
 
2449
  return FALSE;
 
2450
}
 
2451
 
 
2452
 
 
2453
/* Public functions */
 
2454
void 
 
2455
gm_main_window_press_dialpad (GtkWidget *main_window,
 
2456
                              const char c)
 
2457
{
 
2458
  guint key = 0;
 
2459
 
 
2460
  if (c == '*')
 
2461
    key = GDK_KP_Multiply;
 
2462
  else if (c == '#')
 
2463
    key = GDK_numbersign;
 
2464
  else
 
2465
    key = GDK_KP_0 + atoi (&c);
 
2466
 
 
2467
  gtk_accel_groups_activate (G_OBJECT (main_window), key, (GdkModifierType) 0);
 
2468
}
 
2469
 
 
2470
 
 
2471
void 
 
2472
gm_main_window_update_video (GtkWidget *main_window,
 
2473
                             const guchar *lbuffer,
 
2474
                             int lf_width,
 
2475
                             int lf_height,
 
2476
                             double lzoom,
 
2477
                             const guchar *rbuffer,
 
2478
                             int rf_width,
 
2479
                             int rf_height,
 
2480
                             double rzoom,
 
2481
                             int display_type,
 
2482
                             gboolean bilinear_filtering)
 
2483
{
 
2484
  GmWindow *mw = NULL;
 
2485
 
 
2486
  GdkPixbuf *lsrc_pic = NULL;
 
2487
  GdkPixbuf *zlsrc_pic = NULL;
 
2488
  GdkPixbuf *rsrc_pic = NULL;
 
2489
  GdkPixbuf *zrsrc_pic = NULL;
 
2490
  GdkPixbuf *framepixbuf = NULL;
 
2491
  GdkPixbuf *nzlsrc_pic = NULL;
 
2492
  GdkPixbuf *tmpframe = NULL;
 
2493
 
 
2494
#ifdef HAS_SDL
 
2495
  Uint32 rmask, gmask, bmask, amask = 0;
 
2496
  SDL_Surface *lsurface = NULL;
 
2497
  SDL_Surface *rsurface = NULL;
 
2498
  SDL_Surface *lblit_conf = NULL;
 
2499
  SDL_Surface *rblit_conf = NULL;
 
2500
  SDL_Rect dest;
 
2501
#endif
 
2502
 
 
2503
  g_return_if_fail (main_window != NULL);
 
2504
 
 
2505
  mw = gm_mw_get_mw (main_window);
 
2506
 
 
2507
  /* to store the actual size of the video frame */
 
2508
  int video_frame_width = 0;
 
2509
  int video_frame_height = 0;
 
2510
  /* to store the actual size of the video frame, excluding some pixels, 
 
2511
   * e.g. the GtkFrame's shadow */
 
2512
  int video_frame_rwidth = 0;
 
2513
  int video_frame_rheight = 0;
 
2514
 
 
2515
  /* some things for the BOTH_INCRUSTED mode: */
 
2516
  /* the small pic's ratio (to the main video frame */
 
2517
  const float incrusted_small_pic_ratio = 0.33;
 
2518
  /* position of the small pic in % of width and height of the main
 
2519
   * video frame */
 
2520
  const float incrusted_small_pic_relative_posx = 0.66;
 
2521
  const float incrusted_small_pic_relative_posy = 0.66;
 
2522
  /* forced minimum distances of the small pic to the main frame border right
 
2523
   * and down */
 
2524
  const int incrusted_small_pic_forced_border_right = 3;
 
2525
  const int incrusted_small_pic_forced_border_down = 5;
 
2526
  /* assumed thickness of the small frame for the local video (used to
 
2527
   * calculate scale of the local video image) */
 
2528
  const int incrusted_small_pic_assumed_frame_thickness = 4;
 
2529
 
 
2530
  /* some preinits */
 
2531
  int incrusted_frame_width = 0;
 
2532
  int incrusted_frame_height = 0;
 
2533
 
 
2534
  int small_frame_absposx = 0;
 
2535
  int small_frame_absposy = 0;
 
2536
 
 
2537
  int incrusted_resulting_width = 0;
 
2538
  int incrusted_resulting_height = 0;
 
2539
  int incrusted_max_resulting_width = 0;
 
2540
  int incrusted_max_resulting_height = 0;
 
2541
 
 
2542
  /* booleans to handle some display types syntactically easier */
 
2543
  gboolean display_both_side = FALSE;
 
2544
  gboolean display_both_incrusted = FALSE;
 
2545
  /* when the GtkFrame was just created, it has a zero size, but we are
 
2546
   * requested to already render...
 
2547
   * used to prevent drawing when the frame isn't ready built (width,height==0,0) */
 
2548
  gboolean video_frame_ready = TRUE;
 
2549
  
 
2550
  /* resize the video frame to the requested size, depending on what we want
 
2551
   * to show */
 
2552
  switch (display_type) {
 
2553
    case LOCAL_VIDEO:
 
2554
      gtk_widget_set_size_request (GTK_WIDGET (mw->video_frame),
 
2555
        (int) (lf_width * lzoom),
 
2556
        (int) (lf_height * lzoom)); break;
 
2557
    case REMOTE_VIDEO:
 
2558
      gtk_widget_set_size_request (GTK_WIDGET (mw->video_frame),
 
2559
        (int) (rf_width * rzoom),
 
2560
        (int) (rf_height * rzoom)); break;
 
2561
    case BOTH_INCRUSTED:
 
2562
      gtk_widget_set_size_request (GTK_WIDGET (mw->video_frame),
 
2563
        (int) (rf_width * rzoom),
 
2564
        (int) (rf_height * rzoom)); break;
 
2565
    case BOTH_SIDE:
 
2566
      gtk_widget_set_size_request (GTK_WIDGET (mw->video_frame),
 
2567
        (int) (rf_width * rzoom * 2),
 
2568
        (int) (rf_height * rzoom)); break;
 
2569
  }
 
2570
 
 
2571
  if (display_type == BOTH_SIDE) display_both_side = TRUE;
 
2572
  if (display_type == BOTH_INCRUSTED) display_both_incrusted = TRUE;
 
2573
  
 
2574
  /* get the actual size of the video frame */
 
2575
  video_frame_width = GTK_WIDGET (mw->video_frame)->allocation.width;
 
2576
  video_frame_height = GTK_WIDGET (mw->video_frame)->allocation.height;
 
2577
  /* compute reduced values, reductions are fixed,
 
2578
   * we will use THESE values as base to scale the images */
 
2579
  video_frame_rwidth = video_frame_width - 3;
 
2580
  video_frame_rheight = video_frame_height;
 
2581
  
 
2582
  if (video_frame_rwidth < 0)
 
2583
     { video_frame_ready = FALSE; video_frame_rwidth = video_frame_width; };
 
2584
  if (video_frame_rheight < 0)
 
2585
     { video_frame_ready = FALSE; video_frame_rheight = video_frame_height; };
 
2586
  
 
2587
  /* Update the display selection in the main and in the video popup menus */
 
2588
  gtk_radio_menu_select_with_id (mw->main_menu, "local_video", display_type);
 
2589
 
 
2590
 
 
2591
#ifdef HAS_SDL
 
2592
  if (display_type != FULLSCREEN)
 
2593
      gm_mw_destroy_fullscreen_video_window (main_window);
 
2594
#endif
 
2595
 
 
2596
  /* Select and show the correct windows */
 
2597
  if (display_type == BOTH) { /* display == BOTH */
 
2598
 
 
2599
    /* Display the GnomeMeeting logo in the main window */
 
2600
    gm_main_window_update_logo (main_window);
 
2601
 
 
2602
    if (!GTK_WIDGET_VISIBLE (mw->local_video_window))
 
2603
      gnomemeeting_window_show (GTK_WIDGET (mw->local_video_window));
 
2604
    if (!GTK_WIDGET_VISIBLE (mw->remote_video_window))
 
2605
      gnomemeeting_window_show (GTK_WIDGET (mw->remote_video_window));
 
2606
  }
 
2607
#ifdef HAS_SDL
 
2608
  else if (display_type == FULLSCREEN) {
 
2609
 
 
2610
    gm_mw_init_fullscreen_video_window (main_window);
 
2611
    if (gm_mw_poll_fullscreen_video_window (main_window)) 
 
2612
      gm_mw_toggle_fullscreen (main_window);
 
2613
  }
 
2614
#endif
 
2615
  else {
 
2616
 
 
2617
    if (GTK_WIDGET_VISIBLE (mw->local_video_window))
 
2618
      gnomemeeting_window_hide (GTK_WIDGET (mw->local_video_window));
 
2619
    if (GTK_WIDGET_VISIBLE (mw->remote_video_window))
 
2620
      gnomemeeting_window_hide (GTK_WIDGET (mw->remote_video_window));
 
2621
 
 
2622
    if (!GTK_WIDGET_VISIBLE (mw->video_frame) && display_type != BOTH)
 
2623
      gtk_widget_show_all (GTK_WIDGET (mw->video_frame));
 
2624
  }
 
2625
 
 
2626
  
 
2627
  /* The real size picture, if required */
 
2628
  if (display_type != REMOTE_VIDEO && lbuffer && video_frame_ready) {
 
2629
    
 
2630
    if (lf_width > 0 && lf_height > 0) 
 
2631
      lsrc_pic =  
 
2632
        gdk_pixbuf_new_from_data (lbuffer, GDK_COLORSPACE_RGB, 
 
2633
                                  FALSE, 8, lf_width, lf_height, 
 
2634
                                  lf_width * 3, 
 
2635
                                  NULL, NULL);
 
2636
 
 
2637
    if (!display_both_incrusted)
 
2638
       /* scale the local image to the full available space, or,
 
2639
        * if BOTH_SIDE: full_space/2 on X axis */ 
 
2640
      zlsrc_pic =
 
2641
        gdk_pixbuf_scale_simple (lsrc_pic,
 
2642
                                 display_both_side?video_frame_rwidth / 2:video_frame_rwidth,
 
2643
                                 video_frame_rheight,
 
2644
                                 bilinear_filtering?GDK_INTERP_BILINEAR:GDK_INTERP_NEAREST);
 
2645
 
 
2646
    else
 
2647
      /* scale the local image to the requested small size
 
2648
       * for BOTH_INCRUSTED */
 
2649
      zlsrc_pic =
 
2650
        gdk_pixbuf_scale_simple (lsrc_pic,
 
2651
                                 (int) (video_frame_rwidth * incrusted_small_pic_ratio),
 
2652
                                 (int) (video_frame_rheight * incrusted_small_pic_ratio),
 
2653
                                 bilinear_filtering?GDK_INTERP_BILINEAR:GDK_INTERP_NEAREST);
 
2654
 
 
2655
    g_object_unref (lsrc_pic);
 
2656
 
 
2657
                    
 
2658
  }
 
2659
  
 
2660
  if (display_type != LOCAL_VIDEO && rbuffer) {
 
2661
   
 
2662
    if (rf_width > 0 && rf_height > 0) {
 
2663
 
 
2664
      rsrc_pic =  
 
2665
        gdk_pixbuf_new_from_data (rbuffer, GDK_COLORSPACE_RGB, 
 
2666
                                  FALSE, 8, rf_width, rf_height, 
 
2667
                                  rf_width * 3, 
 
2668
                                  NULL, NULL);
 
2669
    }
 
2670
    /* scale the remote image to the full available space, or,
 
2671
     * if BOTH_SIDE: full_space/2 on X axis */
 
2672
    zrsrc_pic =
 
2673
      gdk_pixbuf_scale_simple (rsrc_pic,
 
2674
                               display_both_side?video_frame_rwidth / 2:video_frame_rwidth,
 
2675
                               video_frame_rheight,
 
2676
                               bilinear_filtering?GDK_INTERP_BILINEAR:GDK_INTERP_NEAREST);
 
2677
 
 
2678
    g_object_unref (rsrc_pic);
 
2679
  }
 
2680
  
 
2681
  switch (display_type) {
 
2682
 
 
2683
  case LOCAL_VIDEO:
 
2684
    if (zlsrc_pic && video_frame_ready) {
 
2685
      
 
2686
      gtk_image_set_from_pixbuf (GTK_IMAGE (mw->main_video_image), 
 
2687
                                 GDK_PIXBUF (zlsrc_pic));
 
2688
      g_object_unref (zlsrc_pic);
 
2689
    }
 
2690
    break;
 
2691
 
 
2692
  case REMOTE_VIDEO:
 
2693
    if (zrsrc_pic && video_frame_ready) {
 
2694
      
 
2695
      gtk_image_set_from_pixbuf (GTK_IMAGE (mw->main_video_image), 
 
2696
                                 GDK_PIXBUF (zrsrc_pic));
 
2697
      g_object_unref (zrsrc_pic);
 
2698
    }
 
2699
    break;
 
2700
 
 
2701
  case BOTH_INCRUSTED:
 
2702
 
 
2703
    if (zlsrc_pic && zrsrc_pic && video_frame_ready) {
 
2704
      
 
2705
      /* get the frame out of XPM data */
 
2706
      framepixbuf = gdk_pixbuf_new_from_xpm_data ((const char **) gm_both_incrusted_frame_xpm);
 
2707
 
 
2708
      incrusted_frame_width = gdk_pixbuf_get_width (framepixbuf);
 
2709
      incrusted_frame_height = gdk_pixbuf_get_height (framepixbuf);
 
2710
 
 
2711
      /* compute the position of the small frame */
 
2712
      small_frame_absposx =
 
2713
        (int) (video_frame_rwidth * incrusted_small_pic_relative_posx);
 
2714
      small_frame_absposy =
 
2715
        (int) (video_frame_rheight * incrusted_small_pic_relative_posy);
 
2716
      
 
2717
      /* scale the local pic down to fit inside the frame */
 
2718
      nzlsrc_pic =
 
2719
        gdk_pixbuf_scale_simple (zlsrc_pic,
 
2720
                                 incrusted_frame_width - (2 * incrusted_small_pic_assumed_frame_thickness),
 
2721
                                 incrusted_frame_height - (2 * incrusted_small_pic_assumed_frame_thickness),
 
2722
                                 bilinear_filtering?GDK_INTERP_BILINEAR:GDK_INTERP_NEAREST);
 
2723
 
 
2724
      /* copy the local pic inside the frame */
 
2725
      gdk_pixbuf_copy_area (nzlsrc_pic,
 
2726
                            0, 0,
 
2727
                            gdk_pixbuf_get_width (nzlsrc_pic) - incrusted_small_pic_assumed_frame_thickness,
 
2728
                            gdk_pixbuf_get_height (nzlsrc_pic) - incrusted_small_pic_assumed_frame_thickness,
 
2729
                            framepixbuf,
 
2730
                            incrusted_small_pic_assumed_frame_thickness, incrusted_small_pic_assumed_frame_thickness);
 
2731
 
 
2732
      /* scale the frame plus the picture to the requested size */
 
2733
      tmpframe = gdk_pixbuf_scale_simple (framepixbuf,
 
2734
                                          (int) (video_frame_rwidth * incrusted_small_pic_ratio),
 
2735
                                          (int) (video_frame_rheight * incrusted_small_pic_ratio),
 
2736
                                          GDK_INTERP_BILINEAR);
 
2737
      
 
2738
      /* make sure we're respecting the forced border */
 
2739
      incrusted_resulting_width = small_frame_absposx + gdk_pixbuf_get_width (tmpframe);
 
2740
      incrusted_resulting_height = small_frame_absposy + gdk_pixbuf_get_height (tmpframe);
 
2741
 
 
2742
      incrusted_max_resulting_width = video_frame_rwidth - incrusted_small_pic_forced_border_right;
 
2743
      incrusted_max_resulting_height = video_frame_rheight - incrusted_small_pic_forced_border_down;
 
2744
      
 
2745
      if ( incrusted_resulting_width > incrusted_max_resulting_width )
 
2746
        small_frame_absposx =
 
2747
          video_frame_rwidth - gdk_pixbuf_get_width (tmpframe) - incrusted_small_pic_forced_border_right;
 
2748
 
 
2749
      if ( incrusted_resulting_height > incrusted_max_resulting_height )
 
2750
        small_frame_absposy =
 
2751
          video_frame_rheight - gdk_pixbuf_get_height (tmpframe) - incrusted_small_pic_forced_border_down;
 
2752
     
 
2753
      /* copy the small picture into the big one, freshly scaled, positioned
 
2754
       * and polished :-) */ 
 
2755
      gdk_pixbuf_copy_area  (tmpframe, 
 
2756
                             0 , 0,
 
2757
                             gdk_pixbuf_get_width (tmpframe), 
 
2758
                             gdk_pixbuf_get_height (tmpframe),
 
2759
                             zrsrc_pic,
 
2760
                             small_frame_absposx, 
 
2761
                             small_frame_absposy);
 
2762
 
 
2763
      gtk_image_set_from_pixbuf (GTK_IMAGE (mw->main_video_image), 
 
2764
                                 GDK_PIXBUF (zrsrc_pic));
 
2765
 
 
2766
      g_object_unref (framepixbuf);
 
2767
      g_object_unref (tmpframe);
 
2768
      g_object_unref (nzlsrc_pic);
 
2769
      g_object_unref (zrsrc_pic);
 
2770
      g_object_unref (zlsrc_pic);
 
2771
    }
 
2772
    break;
 
2773
 
 
2774
  case BOTH_SIDE:
 
2775
 
 
2776
    if (zlsrc_pic && zrsrc_pic && video_frame_ready) {
 
2777
 
 
2778
      GdkPixbuf *tmp_pixbuf = 
 
2779
        gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, 
 
2780
                        video_frame_rwidth, 
 
2781
                        video_frame_rheight);
 
2782
 
 
2783
      gdk_pixbuf_copy_area (zrsrc_pic,
 
2784
                            0, 0,
 
2785
                            video_frame_rwidth / 2,
 
2786
                            video_frame_rheight,
 
2787
                            tmp_pixbuf,
 
2788
                            0, 0);
 
2789
      
 
2790
      gdk_pixbuf_copy_area (zlsrc_pic,
 
2791
                            0, 0,
 
2792
                            video_frame_rwidth / 2,
 
2793
                            video_frame_rheight,
 
2794
                            tmp_pixbuf,
 
2795
                            video_frame_rwidth / 2, 0);
 
2796
      
 
2797
      gtk_image_set_from_pixbuf (GTK_IMAGE (mw->main_video_image), 
 
2798
                                 GDK_PIXBUF (tmp_pixbuf));
 
2799
      g_object_unref (zrsrc_pic);
 
2800
      g_object_unref (zlsrc_pic);
 
2801
      g_object_unref (tmp_pixbuf);
 
2802
    }
 
2803
 
 
2804
    break;
 
2805
 
 
2806
  case BOTH:
 
2807
 
 
2808
    if (zlsrc_pic && zrsrc_pic) {
 
2809
 
 
2810
      gtk_image_set_from_pixbuf (GTK_IMAGE (mw->remote_video_image), 
 
2811
                                 GDK_PIXBUF (zrsrc_pic));
 
2812
      gtk_image_set_from_pixbuf (GTK_IMAGE (mw->local_video_image), 
 
2813
                                 GDK_PIXBUF (zlsrc_pic));
 
2814
      
 
2815
      g_object_unref (zrsrc_pic);
 
2816
      g_object_unref (zlsrc_pic);
 
2817
    }
 
2818
    break;
 
2819
    
 
2820
#ifdef HAS_SDL
 
2821
  case FULLSCREEN:
 
2822
 
 
2823
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
 
2824
    rmask = 0xff000000;
 
2825
    gmask = 0x00ff0000;
 
2826
    bmask = 0x0000ff00;
 
2827
    amask = 0x000000ff;
 
2828
#else
 
2829
    rmask = 0x000000ff;
 
2830
    gmask = 0x0000ff00;
 
2831
    bmask = 0x00ff0000;
 
2832
    amask = 0xff000000;
 
2833
#endif
 
2834
 
 
2835
    if (zrsrc_pic) {
 
2836
 
 
2837
      rsurface =
 
2838
        SDL_CreateRGBSurfaceFrom ((void *) gdk_pixbuf_get_pixels (zrsrc_pic),
 
2839
                                  (int) (rf_width * rzoom),
 
2840
                                  (int) (rf_height * rzoom),
 
2841
                                  24,
 
2842
                                  (int) (rf_width * rzoom * 3), 
 
2843
                                  rmask, gmask, bmask, amask);
 
2844
 
 
2845
      rblit_conf = SDL_DisplayFormat (rsurface);
 
2846
 
 
2847
      if (zlsrc_pic)
 
2848
        dest.x = (int) (mw->screen->w - (int) (rf_width * rzoom) - (int) (lf_width * lzoom) - 50) / 2;
 
2849
      else
 
2850
        dest.x = (int) (mw->screen->w - (int) (rf_width * rzoom)) / 2;
 
2851
        
 
2852
      dest.y = (int) (mw->screen->h - (int) (rf_height * rzoom)) / 2;
 
2853
      dest.w = (int) (rf_width * rzoom);
 
2854
      dest.h = (int) (rf_height * rzoom);
 
2855
 
 
2856
      SDL_BlitSurface (rblit_conf, NULL, mw->screen, &dest);
 
2857
 
 
2858
      SDL_FreeSurface (rsurface);
 
2859
      SDL_FreeSurface (rblit_conf);
 
2860
 
 
2861
      g_object_unref (zrsrc_pic);
 
2862
 
 
2863
      if (zlsrc_pic) {
 
2864
 
 
2865
        lsurface =
 
2866
          SDL_CreateRGBSurfaceFrom ((void *) gdk_pixbuf_get_pixels (zlsrc_pic),
 
2867
                                    (int) (lf_width * lzoom),
 
2868
                                    (int) (lf_height * lzoom),
 
2869
                                    24,
 
2870
                                    (int) (lf_width * lzoom * 3), 
 
2871
                                    rmask, gmask, bmask, amask);
 
2872
 
 
2873
        lblit_conf = SDL_DisplayFormat (lsurface);
 
2874
 
 
2875
        dest.x = 640 - (int) (lf_width * lzoom);
 
2876
        dest.y = 480 - (int) (lf_height * lzoom);
 
2877
        dest.w = (int) (lf_width * lzoom);
 
2878
        dest.h = (int) (lf_height * lzoom);
 
2879
 
 
2880
        SDL_BlitSurface (lblit_conf, NULL, mw->screen, &dest);
 
2881
 
 
2882
        SDL_FreeSurface (lsurface);
 
2883
        SDL_FreeSurface (lblit_conf);
 
2884
 
 
2885
        g_object_unref (zlsrc_pic);
 
2886
      }
 
2887
    }
 
2888
 
 
2889
    SDL_UpdateRect (mw->screen, 0, 0, 640, 480);
 
2890
 
 
2891
 
 
2892
    break;
 
2893
#endif
 
2894
  } 
 
2895
}
 
2896
 
 
2897
 
 
2898
void 
 
2899
gm_main_window_update_logo (GtkWidget *main_window)
 
2900
{
 
2901
  GmWindow *mw = NULL;
 
2902
  
 
2903
  GdkPixbuf *tmp = NULL;
 
2904
  GdkPixbuf *scaledlogo = NULL;
 
2905
  GdkPixbuf *text_logo_pix = NULL;
 
2906
 
 
2907
  int width = 0;
 
2908
  int height = 0;
 
2909
  
 
2910
  GtkRequisition size_request;
 
2911
 
 
2912
  g_return_if_fail (main_window != NULL);
 
2913
 
 
2914
  mw = gm_mw_get_mw (main_window);
 
2915
  
 
2916
 
 
2917
  gtk_widget_size_request (GTK_WIDGET (mw->video_frame), &size_request);
 
2918
 
 
2919
  if ((size_request.width != GM_QCIF_WIDTH) || 
 
2920
      (size_request.height != GM_QCIF_HEIGHT)) {
 
2921
 
 
2922
     gtk_widget_set_size_request (GTK_WIDGET (mw->video_frame),
 
2923
                                  176 , 144);
 
2924
  }
 
2925
 
 
2926
  text_logo_pix = gdk_pixbuf_new_from_xpm_data ((const char **) text_logo_xpm);
 
2927
  width = gdk_pixbuf_get_width (text_logo_pix);
 
2928
  height = gdk_pixbuf_get_height (text_logo_pix);
 
2929
 
 
2930
  tmp = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, 176, 144);
 
2931
  gdk_pixbuf_fill (tmp, 0x000000FF);  /* Opaque black */
 
2932
 
 
2933
  gdk_pixbuf_copy_area (text_logo_pix, 0, 0, 
 
2934
                        width, height,
 
2935
                        tmp, 
 
2936
                        ((GM_QCIF_WIDTH - width) / 2),
 
2937
                        (GM_QCIF_HEIGHT - height) / 2);
 
2938
 
 
2939
  scaledlogo = gdk_pixbuf_scale_simple (tmp,
 
2940
                                        GM_QCIF_WIDTH - 3,
 
2941
                                        GM_QCIF_HEIGHT,
 
2942
                                        GDK_INTERP_BILINEAR);
 
2943
                                        
 
2944
  gtk_image_set_from_pixbuf (GTK_IMAGE (mw->main_video_image),
 
2945
                             GDK_PIXBUF (scaledlogo));
 
2946
 
 
2947
  g_object_unref (text_logo_pix);
 
2948
  g_object_unref (tmp);
 
2949
  g_object_unref (scaledlogo);
 
2950
}
 
2951
 
 
2952
 
 
2953
void 
 
2954
gm_main_window_set_call_hold (GtkWidget *main_window,
 
2955
                              gboolean is_on_hold)
 
2956
{
 
2957
  GmWindow *mw = NULL;
 
2958
  
 
2959
  GtkWidget *child = NULL;
 
2960
  
 
2961
  
 
2962
  g_return_if_fail (main_window != NULL);
 
2963
  
 
2964
  mw = gm_mw_get_mw (main_window);
 
2965
  
 
2966
  g_return_if_fail (mw != NULL);
 
2967
  
 
2968
  
 
2969
  child = GTK_BIN (gtk_menu_get_widget (mw->main_menu, "hold_call"))->child;
 
2970
 
 
2971
  if (is_on_hold) {
 
2972
 
 
2973
    if (GTK_IS_LABEL (child))
 
2974
      gtk_label_set_text_with_mnemonic (GTK_LABEL (child),
 
2975
                                        _("_Retrieve Call"));
 
2976
 
 
2977
    /* Set the audio and video buttons/menu to unsensitive */
 
2978
    gtk_widget_set_sensitive (GTK_WIDGET (mw->audio_chan_button), FALSE);
 
2979
    gtk_widget_set_sensitive (GTK_WIDGET (mw->video_chan_button), FALSE);
 
2980
    
 
2981
    gtk_menu_set_sensitive (mw->main_menu, "suspend_audio", FALSE);
 
2982
    gtk_menu_set_sensitive (mw->main_menu, "suspend_video", FALSE);
 
2983
    
 
2984
    gm_main_window_set_channel_pause (main_window, TRUE, FALSE);
 
2985
    gm_main_window_set_channel_pause (main_window, TRUE, TRUE);
 
2986
  }
 
2987
  else {
 
2988
 
 
2989
    if (GTK_IS_LABEL (child))
 
2990
      gtk_label_set_text_with_mnemonic (GTK_LABEL (child),
 
2991
                                        _("_Hold Call"));
 
2992
 
 
2993
    gtk_widget_set_sensitive (GTK_WIDGET (mw->audio_chan_button), TRUE);
 
2994
    gtk_widget_set_sensitive (GTK_WIDGET (mw->video_chan_button), TRUE);
 
2995
    
 
2996
    gtk_menu_set_sensitive (mw->main_menu, "suspend_audio", TRUE);
 
2997
    gtk_menu_set_sensitive (mw->main_menu, "suspend_video", TRUE);
 
2998
 
 
2999
    gm_main_window_set_channel_pause (main_window, FALSE, FALSE);
 
3000
    gm_main_window_set_channel_pause (main_window, FALSE, TRUE);
 
3001
  }
 
3002
}
 
3003
 
 
3004
 
 
3005
void 
 
3006
gm_main_window_set_channel_pause (GtkWidget *main_window,
 
3007
                                  gboolean pause,
 
3008
                                  gboolean is_video)
 
3009
{
 
3010
  GmWindow *mw = NULL;
 
3011
  
 
3012
  GtkWidget *child = NULL;
 
3013
  GtkToggleButton *b = NULL;
 
3014
 
 
3015
  gchar *msg = NULL;
 
3016
  
 
3017
  g_return_if_fail (main_window != NULL);
 
3018
  
 
3019
  mw = gm_mw_get_mw (main_window);
 
3020
  
 
3021
  g_return_if_fail (mw != NULL);
 
3022
  
 
3023
 
 
3024
  if (!pause && !is_video)
 
3025
    msg = g_strdup (_("Suspend _Audio"));
 
3026
  else if (!pause && is_video)
 
3027
    msg = g_strdup (_("Suspend _Video"));
 
3028
  else if (pause && !is_video)
 
3029
    msg = g_strdup (_("Resume _Audio"));
 
3030
  else if (pause && is_video)
 
3031
    msg = g_strdup (_("Resume _Video"));
 
3032
 
 
3033
  
 
3034
  if (is_video) {
 
3035
    
 
3036
    b = GTK_TOGGLE_BUTTON (mw->video_chan_button);
 
3037
    child =
 
3038
      GTK_BIN (gtk_menu_get_widget (mw->main_menu, "suspend_video"))->child;
 
3039
  }
 
3040
  else {
 
3041
    
 
3042
    b = GTK_TOGGLE_BUTTON (mw->audio_chan_button);
 
3043
    child =
 
3044
      GTK_BIN (gtk_menu_get_widget (mw->main_menu, "suspend_audio"))->child;
 
3045
  }
 
3046
        
 
3047
 
 
3048
  if (GTK_IS_LABEL (child)) 
 
3049
    gtk_label_set_text_with_mnemonic (GTK_LABEL (child),
 
3050
                                      msg);
 
3051
 
 
3052
  g_signal_handlers_block_by_func (G_OBJECT (b),
 
3053
                                   (gpointer) pause_current_call_channel_cb,
 
3054
                                   GINT_TO_POINTER (is_video));
 
3055
  gtk_toggle_button_set_active (b, pause);
 
3056
  g_signal_handlers_unblock_by_func (G_OBJECT (b),
 
3057
                                     (gpointer) pause_current_call_channel_cb,
 
3058
                                     GINT_TO_POINTER (is_video));
 
3059
 
 
3060
  g_free (msg);
 
3061
}
 
3062
 
 
3063
 
 
3064
void
 
3065
gm_main_window_update_calling_state (GtkWidget *main_window,
 
3066
                                     unsigned calling_state)
 
3067
{
 
3068
  GmWindow *mw = NULL;
 
3069
  
 
3070
  g_return_if_fail (main_window != NULL);
 
3071
 
 
3072
  mw = gm_mw_get_mw (main_window);
 
3073
 
 
3074
  g_return_if_fail (mw!= NULL);
 
3075
 
 
3076
 
 
3077
  switch (calling_state)
 
3078
    {
 
3079
    case GMManager::Standby:
 
3080
 
 
3081
      
 
3082
      /* Update the hold state */
 
3083
      gm_main_window_set_call_hold (main_window, FALSE);
 
3084
 
 
3085
 
 
3086
      /* Update the sensitivity, all channels are closed */
 
3087
      gm_main_window_update_sensitivity (main_window, TRUE, FALSE, FALSE);
 
3088
      gm_main_window_update_sensitivity (main_window, FALSE, FALSE, FALSE);
 
3089
 
 
3090
      
 
3091
      /* Update the menus and toolbar items */
 
3092
      gtk_menu_set_sensitive (mw->main_menu, "connect", TRUE);
 
3093
      gtk_menu_set_sensitive (mw->main_menu, "disconnect", FALSE);
 
3094
      gtk_menu_section_set_sensitive (mw->main_menu, "hold_call", FALSE);
 
3095
      gtk_widget_set_sensitive (GTK_WIDGET (mw->preview_button), TRUE);
 
3096
 
 
3097
      
 
3098
      /* Update the connect button */
 
3099
      gm_connect_button_set_connected (GM_CONNECT_BUTTON (mw->connect_button),
 
3100
                                       FALSE);
 
3101
 
 
3102
        
 
3103
      /* Destroy the incoming call popup */
 
3104
      if (mw->incoming_call_popup) {
 
3105
 
 
3106
        gnomemeeting_threads_widget_destroy (mw->incoming_call_popup);
 
3107
        mw->incoming_call_popup = NULL;
 
3108
      }
 
3109
 
 
3110
      /* Destroy the transfer call popup */
 
3111
      if (mw->transfer_call_popup) 
 
3112
        gtk_dialog_response (GTK_DIALOG (mw->transfer_call_popup),
 
3113
                             GTK_RESPONSE_REJECT);
 
3114
  
 
3115
      
 
3116
      /* Delete the full screen window */
 
3117
#ifdef HAS_SDL
 
3118
      gm_mw_destroy_fullscreen_video_window (main_window);
 
3119
#endif
 
3120
      
 
3121
      
 
3122
      /* Hide the local and remove video windows */
 
3123
      gnomemeeting_window_hide (mw->remote_video_window);
 
3124
      gnomemeeting_window_hide (mw->local_video_window);
 
3125
        
 
3126
      break;
 
3127
 
 
3128
 
 
3129
    case GMManager::Calling:
 
3130
 
 
3131
      /* Update the menus and toolbar items */
 
3132
      gtk_menu_set_sensitive (mw->main_menu, "connect", FALSE);
 
3133
      gtk_menu_set_sensitive (mw->main_menu, "disconnect", TRUE);
 
3134
      gtk_widget_set_sensitive (GTK_WIDGET (mw->preview_button), FALSE);
 
3135
 
 
3136
      /* Update the connect button */
 
3137
      gm_connect_button_set_connected (GM_CONNECT_BUTTON (mw->connect_button),
 
3138
                                       TRUE);
 
3139
      
 
3140
      break;
 
3141
 
 
3142
 
 
3143
    case GMManager::Connected:
 
3144
 
 
3145
      /* Update the menus and toolbar items */
 
3146
      gtk_menu_set_sensitive (mw->main_menu, "connect", FALSE);
 
3147
      gtk_menu_set_sensitive (mw->main_menu, "disconnect", TRUE);
 
3148
      gtk_menu_section_set_sensitive (mw->main_menu, "hold_call", TRUE);
 
3149
      gtk_widget_set_sensitive (GTK_WIDGET (mw->preview_button), FALSE);
 
3150
 
 
3151
      /* Update the connect button */
 
3152
      gm_connect_button_set_connected (GM_CONNECT_BUTTON (mw->connect_button),
 
3153
                                       TRUE);
 
3154
      
 
3155
      /* Destroy the incoming call popup */
 
3156
      if (mw->incoming_call_popup) {
 
3157
 
 
3158
        gtk_widget_destroy (mw->incoming_call_popup);
 
3159
        mw->incoming_call_popup = NULL;
 
3160
      }
 
3161
      break;
 
3162
 
 
3163
 
 
3164
    case GMManager::Called:
 
3165
 
 
3166
      /* Update the menus and toolbar items */
 
3167
      gtk_menu_set_sensitive (mw->main_menu, "disconnect", TRUE);
 
3168
 
 
3169
      /* Update the connect button */
 
3170
      gm_connect_button_set_connected (GM_CONNECT_BUTTON (mw->connect_button),
 
3171
                                       FALSE);
 
3172
      
 
3173
      break;
 
3174
    }
 
3175
}
 
3176
 
 
3177
 
 
3178
void
 
3179
gm_main_window_update_sensitivity (GtkWidget *main_window,
 
3180
                                   BOOL is_video,
 
3181
                                   BOOL is_receiving,
 
3182
                                   BOOL is_transmitting)
 
3183
{
 
3184
  GmWindow *mw = NULL;
 
3185
  
 
3186
  GtkWidget *button = NULL;
 
3187
 
 
3188
  mw = gm_mw_get_mw (main_window);
 
3189
 
 
3190
  g_return_if_fail (mw != NULL);
 
3191
 
 
3192
  
 
3193
  /* We are updating video related items */
 
3194
  if (is_video) {
 
3195
 
 
3196
    /* Receiving and sending => Everything sensitive in the section control */
 
3197
    if (is_receiving && is_transmitting) {
 
3198
 
 
3199
      gtk_menu_section_set_sensitive (mw->main_menu,
 
3200
                                      "local_video", TRUE);
 
3201
      gtk_menu_section_set_sensitive (mw->main_menu,
 
3202
                                      "zoom_in", TRUE);
 
3203
    }
 
3204
    else { /* Not receiving or not sending or both */
 
3205
 
 
3206
      /* Default to nothing being sensitive */
 
3207
      gtk_menu_section_set_sensitive (mw->main_menu,
 
3208
                                      "local_video", FALSE);
 
3209
      
 
3210
      /* We are sending video, but not receiving 
 
3211
       * => local must be sensitive */
 
3212
      if (is_transmitting) {
 
3213
 
 
3214
        gtk_menu_set_sensitive (mw->main_menu,
 
3215
                                "local_video", TRUE);
 
3216
      }
 
3217
      /* We are receiving video, but not transmitting,
 
3218
       * => remote must be sensitive */
 
3219
      else if (is_receiving) {
 
3220
 
 
3221
        gtk_menu_set_sensitive (mw->main_menu,
 
3222
                                "remote_video", TRUE);
 
3223
      }
 
3224
      
 
3225
      /* We are not transmitting, and not receiving anything,
 
3226
       * => Disable the zoom completely */
 
3227
      if (!is_receiving && !is_transmitting) {
 
3228
 
 
3229
        gtk_menu_section_set_sensitive (mw->main_menu,
 
3230
                                        "zoom_in", FALSE);
 
3231
        gtk_menu_set_sensitive (mw->main_menu, "save_picture", FALSE);
 
3232
      }
 
3233
      else {
 
3234
        /* Or activate it as at least something is transmitted or 
 
3235
         * received */
 
3236
        gtk_menu_section_set_sensitive (mw->main_menu,
 
3237
                                        "zoom_in", TRUE);
 
3238
        if (!is_receiving)
 
3239
          gtk_menu_section_set_sensitive (mw->main_menu,
 
3240
                                          "fullscreen", FALSE);
 
3241
          
 
3242
        gtk_menu_set_sensitive (mw->main_menu, "save_picture", TRUE);
 
3243
      }
 
3244
    }
 
3245
 
 
3246
    button = mw->video_chan_button;
 
3247
  }
 
3248
  else {
 
3249
 
 
3250
    button = mw->audio_chan_button;
 
3251
  }
 
3252
  
 
3253
  if (is_transmitting) {
 
3254
 
 
3255
    if (!is_video) 
 
3256
      gtk_menu_set_sensitive (mw->main_menu, "suspend_audio", TRUE);
 
3257
    else 
 
3258
      gtk_menu_set_sensitive (mw->main_menu, "suspend_video", TRUE);
 
3259
  }     
 
3260
  else {
 
3261
 
 
3262
    if (!is_video)
 
3263
      gtk_menu_set_sensitive (mw->main_menu, "suspend_audio", FALSE);
 
3264
    else
 
3265
      gtk_menu_set_sensitive (mw->main_menu, "suspend_video", FALSE);
 
3266
 
 
3267
  }
 
3268
 
 
3269
  if (is_video) {
 
3270
    
 
3271
    GTK_TOGGLE_BUTTON (mw->preview_button)->active = is_transmitting;
 
3272
    gtk_widget_set_state (mw->preview_button, 
 
3273
                          is_transmitting?GTK_STATE_ACTIVE:GTK_STATE_NORMAL);
 
3274
  }
 
3275
 
 
3276
  GTK_TOGGLE_BUTTON (button)->active = !is_transmitting;
 
3277
  gtk_widget_set_state (button, 
 
3278
                        !is_transmitting?GTK_STATE_ACTIVE:GTK_STATE_NORMAL);
 
3279
 
 
3280
  gtk_widget_set_sensitive (GTK_WIDGET (button), is_transmitting);
 
3281
}
 
3282
 
 
3283
 
 
3284
void
 
3285
gm_main_window_set_volume_sliders_values (GtkWidget *main_window,
 
3286
                                          int output_volume, 
 
3287
                                          int input_volume)
 
3288
{
 
3289
  GmWindow *mw = NULL;
 
3290
 
 
3291
  g_return_if_fail (main_window != NULL);
 
3292
 
 
3293
  mw = gm_mw_get_mw (main_window);
 
3294
 
 
3295
  g_return_if_fail (mw != NULL);
 
3296
 
 
3297
  if (output_volume != -1)
 
3298
    GTK_ADJUSTMENT (mw->adj_output_volume)->value = output_volume;
 
3299
 
 
3300
  if (input_volume != -1)
 
3301
    GTK_ADJUSTMENT (mw->adj_input_volume)->value = input_volume;
 
3302
  
 
3303
  gtk_widget_queue_draw (GTK_WIDGET (mw->audio_volume_frame));
 
3304
}
 
3305
 
 
3306
 
 
3307
void gm_main_window_set_signal_levels (GtkWidget *main_window,
 
3308
                                       float output, 
 
3309
                                       float input)
 
3310
{
 
3311
  GmWindow *mw = NULL;
 
3312
 
 
3313
  g_return_if_fail (main_window != NULL);
 
3314
 
 
3315
  mw = gm_mw_get_mw (main_window);
 
3316
 
 
3317
  g_return_if_fail (mw != NULL);
 
3318
 
 
3319
  if (output != -1)
 
3320
    gtk_levelmeter_set_level (GTK_LEVELMETER (mw->output_signal), output);
 
3321
  
 
3322
  if (input != -1)
 
3323
    gtk_levelmeter_set_level (GTK_LEVELMETER (mw->input_signal), input);
 
3324
}
 
3325
 
 
3326
 
 
3327
void gm_main_window_clear_signal_levels (GtkWidget *main_window)
 
3328
{
 
3329
  GmWindow *mw = NULL;
 
3330
 
 
3331
  g_return_if_fail (main_window != NULL);
 
3332
 
 
3333
  mw = gm_mw_get_mw (main_window);
 
3334
 
 
3335
  g_return_if_fail (mw != NULL);
 
3336
 
 
3337
  gtk_levelmeter_clear (GTK_LEVELMETER (mw->output_signal));
 
3338
  gtk_levelmeter_clear (GTK_LEVELMETER (mw->input_signal));
 
3339
}
 
3340
 
 
3341
 
 
3342
void
 
3343
gm_main_window_get_volume_sliders_values (GtkWidget *main_window,
 
3344
                                          int &output_volume, 
 
3345
                                          int &input_volume)
 
3346
{
 
3347
  GmWindow *mw = NULL;
 
3348
 
 
3349
  g_return_if_fail (main_window != NULL);
 
3350
 
 
3351
  mw = gm_mw_get_mw (main_window);
 
3352
 
 
3353
  g_return_if_fail (mw != NULL);
 
3354
 
 
3355
  output_volume = (int) GTK_ADJUSTMENT (mw->adj_output_volume)->value;
 
3356
  input_volume = (int) GTK_ADJUSTMENT (mw->adj_input_volume)->value;
 
3357
}
 
3358
 
 
3359
 
 
3360
void
 
3361
gm_main_window_set_video_sliders_values (GtkWidget *main_window,
 
3362
                                         int whiteness,
 
3363
                                         int brightness,
 
3364
                                         int colour,
 
3365
                                         int contrast)
 
3366
{
 
3367
  GmWindow *mw = NULL;
 
3368
 
 
3369
  g_return_if_fail (main_window != NULL);
 
3370
 
 
3371
  mw = gm_mw_get_mw (main_window);
 
3372
 
 
3373
  g_return_if_fail (mw != NULL);
 
3374
 
 
3375
  if (whiteness != -1)
 
3376
    GTK_ADJUSTMENT (mw->adj_whiteness)->value = whiteness;
 
3377
 
 
3378
  if (brightness != -1)
 
3379
    GTK_ADJUSTMENT (mw->adj_brightness)->value = brightness;
 
3380
  
 
3381
  if (colour != -1)
 
3382
    GTK_ADJUSTMENT (mw->adj_colour)->value = colour;
 
3383
  
 
3384
  if (contrast != -1)
 
3385
    GTK_ADJUSTMENT (mw->adj_contrast)->value = contrast;
 
3386
  
 
3387
  gtk_widget_queue_draw (GTK_WIDGET (mw->video_settings_frame));
 
3388
}
 
3389
 
 
3390
 
 
3391
void
 
3392
gm_main_window_get_video_sliders_values (GtkWidget *main_window,
 
3393
                                         int &whiteness, 
 
3394
                                         int &brightness,
 
3395
                                         int &colour,
 
3396
                                         int &contrast)
 
3397
{
 
3398
  GmWindow *mw = NULL;
 
3399
 
 
3400
  g_return_if_fail (main_window != NULL);
 
3401
 
 
3402
  mw = gm_mw_get_mw (main_window);
 
3403
 
 
3404
  g_return_if_fail (mw != NULL);
 
3405
 
 
3406
  whiteness = (int) GTK_ADJUSTMENT (mw->adj_whiteness)->value;
 
3407
  brightness = (int) GTK_ADJUSTMENT (mw->adj_brightness)->value;
 
3408
  colour = (int) GTK_ADJUSTMENT (mw->adj_colour)->value;
 
3409
  contrast = (int) GTK_ADJUSTMENT (mw->adj_contrast)->value;
 
3410
}
 
3411
 
 
3412
 
 
3413
void 
 
3414
gm_main_window_set_view_mode (GtkWidget *main_window,
 
3415
                              ViewMode m)
 
3416
{
 
3417
  GmWindow *mw = NULL;
 
3418
 
 
3419
  GtkWidget *menu = NULL;
 
3420
 
 
3421
  g_return_if_fail (main_window != NULL);
 
3422
  
 
3423
  mw = gm_mw_get_mw (main_window);
 
3424
 
 
3425
  g_return_if_fail (mw != NULL);
 
3426
 
 
3427
  switch (m) {
 
3428
 
 
3429
  case SOFTPHONE:
 
3430
    if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (mw->preview_button)))
 
3431
      gm_mw_show_video_section (main_window, FALSE);
 
3432
    gm_mw_show_control_panel (main_window, TRUE);
 
3433
    break;
 
3434
 
 
3435
  case VIDEOPHONE:
 
3436
    gm_mw_show_video_section (main_window, TRUE);
 
3437
    gm_mw_show_control_panel (main_window, FALSE);
 
3438
    break;
 
3439
 
 
3440
  case FULLVIEW:
 
3441
    gm_mw_show_video_section (main_window, TRUE);
 
3442
    gm_mw_show_control_panel (main_window, TRUE);
 
3443
    break;
 
3444
 
 
3445
  default:
 
3446
    break;
 
3447
  }
 
3448
  
 
3449
  
 
3450
  menu = gtk_menu_get_widget (mw->main_menu, "softphone");
 
3451
  
 
3452
  gtk_radio_menu_select_with_widget (GTK_WIDGET (menu), m);
 
3453
}
 
3454
 
 
3455
 
 
3456
void 
 
3457
gm_main_window_set_control_panel_section (GtkWidget *main_window,
 
3458
                                          int section)
 
3459
{
 
3460
  GmWindow *mw = NULL;
 
3461
  
 
3462
  GtkWidget *menu = NULL;
 
3463
  
 
3464
  g_return_if_fail (main_window != NULL);
 
3465
  
 
3466
  mw = gm_mw_get_mw (main_window);
 
3467
 
 
3468
  g_return_if_fail (mw != NULL);
 
3469
 
 
3470
  gtk_notebook_set_current_page (GTK_NOTEBOOK (mw->main_notebook), section);
 
3471
  
 
3472
  menu = gtk_menu_get_widget (mw->main_menu, "statistics");
 
3473
  
 
3474
  gtk_radio_menu_select_with_widget (GTK_WIDGET (menu), section);
 
3475
}
 
3476
 
 
3477
 
 
3478
void 
 
3479
gm_main_window_set_incoming_call_mode (GtkWidget *main_window,
 
3480
                                       IncomingCallMode i)
 
3481
{
 
3482
  GmWindow *mw = NULL;
 
3483
  
 
3484
  GtkWidget *menu = NULL;
 
3485
  
 
3486
  g_return_if_fail (main_window != NULL);
 
3487
  
 
3488
  mw = gm_mw_get_mw (main_window);
 
3489
 
 
3490
  g_return_if_fail (mw != NULL);
 
3491
 
 
3492
  
 
3493
  menu = gtk_menu_get_widget (mw->main_menu, "available");
 
3494
  
 
3495
  gtk_radio_menu_select_with_widget (GTK_WIDGET (menu), i);
 
3496
}
 
3497
 
 
3498
 
 
3499
void 
 
3500
gm_main_window_set_call_info (GtkWidget *main_window,
 
3501
                              const char *tr_audio_codec,
 
3502
                              const char *re_audio_codec,
 
3503
                              const char *tr_video_codec,
 
3504
                              const char *re_video_codec)
 
3505
{
 
3506
  GmWindow *mw = NULL;
 
3507
  
 
3508
  gchar *info = NULL;
 
3509
  
 
3510
  g_return_if_fail (main_window != NULL);
 
3511
  
 
3512
  mw = gm_mw_get_mw (main_window);
 
3513
 
 
3514
  g_return_if_fail (mw != NULL);
 
3515
 
 
3516
  info = 
 
3517
    g_strdup_printf ("<b>%s</b> %s/%s\n<b>%s</b> %s/%s",
 
3518
                     _("Out:"), 
 
3519
                     tr_audio_codec?tr_audio_codec:"-", 
 
3520
                     tr_video_codec?tr_video_codec:"-",
 
3521
                     _("In:"), 
 
3522
                     re_audio_codec?re_audio_codec:"-",
 
3523
                     re_video_codec?re_video_codec:"-");
 
3524
  gtk_label_set_markup (GTK_LABEL (mw->info_label), info);
 
3525
  g_free (info);
 
3526
}
 
3527
 
 
3528
 
 
3529
void 
 
3530
gm_main_window_set_account_info (GtkWidget *main_window,
 
3531
                                 int registered_accounts)
 
3532
{
 
3533
  GmWindow *mw = NULL;
 
3534
  
 
3535
  gchar *info = NULL;
 
3536
  
 
3537
  g_return_if_fail (main_window != NULL);
 
3538
  
 
3539
  mw = gm_mw_get_mw (main_window);
 
3540
 
 
3541
  g_return_if_fail (mw != NULL);
 
3542
 
 
3543
  info = 
 
3544
    g_strdup_printf ("\n<small>%s %d</small>",
 
3545
                     _("Registered accounts:"),
 
3546
                     registered_accounts);
 
3547
                   
 
3548
  gtk_label_set_markup (GTK_LABEL (mw->info_label), info);
 
3549
  g_free (info);
 
3550
}
 
3551
 
 
3552
 
 
3553
void 
 
3554
gm_main_window_set_status (GtkWidget *main_window,
 
3555
                           const char *status)
 
3556
{
 
3557
  GmWindow *mw = NULL;
 
3558
  
 
3559
  gchar *info = NULL;
 
3560
  
 
3561
  g_return_if_fail (main_window != NULL);
 
3562
  
 
3563
  mw = gm_mw_get_mw (main_window);
 
3564
 
 
3565
  g_return_if_fail (mw != NULL);
 
3566
  
 
3567
#if !GTK_CHECK_VERSION (2, 6, 0)
 
3568
  gchar *status2 = NULL;
 
3569
  status2 = g_strndup (status, 23);
 
3570
  info = g_strdup_printf ("<i>%s...</i>", status2);
 
3571
  g_free (status2);
 
3572
#else
 
3573
  info = g_strdup_printf ("<i>%s</i>", status);
 
3574
#endif
 
3575
  
 
3576
  gtk_label_set_markup (GTK_LABEL (mw->status_label), info);
 
3577
  g_free (info);
 
3578
}
 
3579
 
 
3580
 
 
3581
void
 
3582
gm_main_window_speed_dials_menu_update (GtkWidget *main_window,
 
3583
                                        GSList *glist)
 
3584
{
 
3585
  GmWindow *mw = NULL;
 
3586
  GmContact *contact = NULL;
 
3587
  
 
3588
  GtkWidget *item = NULL;
 
3589
  GtkWidget *menu = NULL;
 
3590
 
 
3591
  GSList *glist_iter = NULL;
 
3592
  GList *old_glist_iter = NULL;
 
3593
 
 
3594
  gchar *ml = NULL;  
 
3595
 
 
3596
 
 
3597
  g_return_if_fail (main_window != NULL);
 
3598
  
 
3599
  mw = gm_mw_get_mw (main_window);
 
3600
 
 
3601
  menu = gtk_menu_get_widget (mw->main_menu, "speed_dials");
 
3602
 
 
3603
  while ((old_glist_iter = GTK_MENU_SHELL (menu)->children)) 
 
3604
    gtk_container_remove (GTK_CONTAINER (menu),
 
3605
                          GTK_WIDGET (old_glist_iter->data));
 
3606
  
 
3607
  item = gtk_menu_get_attach_widget (GTK_MENU (menu));
 
3608
  if (!g_slist_length (glist)) {
 
3609
 
 
3610
    gtk_widget_set_sensitive (item, FALSE);
 
3611
    return;
 
3612
  }
 
3613
  gtk_widget_set_sensitive (item, TRUE);
 
3614
 
 
3615
  glist_iter = glist;
 
3616
  while (glist_iter && glist_iter->data) {
 
3617
 
 
3618
    contact = GM_CONTACT (glist_iter->data);
 
3619
 
 
3620
    ml = g_strdup_printf ("<b>%s#</b> <i>%s</i>", 
 
3621
                          contact->speeddial, 
 
3622
                          contact->fullname);
 
3623
 
 
3624
    item = gtk_menu_item_new_with_label (ml);
 
3625
    gtk_label_set_markup (GTK_LABEL (gtk_bin_get_child (GTK_BIN (item))),
 
3626
                          ml);
 
3627
    gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
 
3628
    gtk_widget_show (item);
 
3629
 
 
3630
    g_signal_connect_data (G_OBJECT (item), "activate",
 
3631
                           GTK_SIGNAL_FUNC (speed_dial_menu_item_selected_cb),
 
3632
                           (gpointer) g_strdup (contact->speeddial),
 
3633
                           (GClosureNotify) g_free, (GConnectFlags) 0);
 
3634
 
 
3635
 
 
3636
    glist_iter = g_slist_next (glist_iter);
 
3637
 
 
3638
    g_free (ml);
 
3639
  }
 
3640
}
 
3641
 
 
3642
 
 
3643
void 
 
3644
gm_main_window_urls_history_update (GtkWidget *main_window)
 
3645
{
 
3646
  g_idle_add (gm_mw_urls_history_update_cb, main_window);
 
3647
}
 
3648
 
 
3649
 
 
3650
gboolean 
 
3651
gm_main_window_transfer_dialog_run (GtkWidget *main_window,
 
3652
                                    GtkWidget *parent_window,
 
3653
                                    const char *u)
 
3654
{
 
3655
  GMManager *endpoint = NULL;
 
3656
  GmWindow *mw = NULL;
 
3657
  
 
3658
  GMURL url = GMURL (u);
 
3659
 
 
3660
  gint answer = 0;
 
3661
  
 
3662
  const char *forward_url = NULL;
 
3663
 
 
3664
  g_return_val_if_fail (main_window != NULL, FALSE);
 
3665
  g_return_val_if_fail (parent_window != NULL, FALSE);
 
3666
  
 
3667
  mw = gm_mw_get_mw (main_window);
 
3668
 
 
3669
  g_return_val_if_fail (mw != NULL, FALSE);
 
3670
  
 
3671
 
 
3672
  endpoint = GnomeMeeting::Process ()->GetManager ();
 
3673
  
 
3674
  mw->transfer_call_popup = 
 
3675
    gm_entry_dialog_new (_("Transfer call to:"),
 
3676
                         _("Transfer"));
 
3677
  
 
3678
  gtk_window_set_transient_for (GTK_WINDOW (mw->transfer_call_popup),
 
3679
                                GTK_WINDOW (parent_window));
 
3680
  
 
3681
  gtk_dialog_set_default_response (GTK_DIALOG (mw->transfer_call_popup),
 
3682
                                   GTK_RESPONSE_ACCEPT);
 
3683
  
 
3684
  if (!url.IsEmpty ())
 
3685
    gm_entry_dialog_set_text (GM_ENTRY_DIALOG (mw->transfer_call_popup), u);
 
3686
  else
 
3687
    gm_entry_dialog_set_text (GM_ENTRY_DIALOG (mw->transfer_call_popup),
 
3688
                              (const char *) url.GetDefaultURL ());
 
3689
 
 
3690
  gnomemeeting_threads_dialog_show (mw->transfer_call_popup);
 
3691
 
 
3692
  answer = gtk_dialog_run (GTK_DIALOG (mw->transfer_call_popup));
 
3693
  switch (answer) {
 
3694
 
 
3695
  case GTK_RESPONSE_ACCEPT:
 
3696
 
 
3697
    forward_url =
 
3698
      gm_entry_dialog_get_text (GM_ENTRY_DIALOG (mw->transfer_call_popup));
 
3699
    new GMURLHandler (forward_url, TRUE);
 
3700
      
 
3701
    break;
 
3702
 
 
3703
  default:
 
3704
    break;
 
3705
  }
 
3706
 
 
3707
  gtk_widget_destroy (mw->transfer_call_popup);
 
3708
  mw->transfer_call_popup = NULL;
 
3709
 
 
3710
  return (answer == GTK_RESPONSE_ACCEPT);
 
3711
}
 
3712
 
 
3713
 
 
3714
void 
 
3715
gm_main_window_incoming_call_dialog_show (GtkWidget *main_window,
 
3716
                                          gchar *utf8_name, 
 
3717
                                          gchar *utf8_app,
 
3718
                                          gchar *utf8_url)
 
3719
{
 
3720
  GmWindow *mw = NULL;
 
3721
  
 
3722
  GtkWidget *label = NULL;
 
3723
  GtkWidget *vbox = NULL;
 
3724
  GtkWidget *b1 = NULL;
 
3725
  GtkWidget *b2 = NULL;
 
3726
  GtkWidget *b3 = NULL;
 
3727
 
 
3728
  gchar *msg = NULL;
 
3729
 
 
3730
  g_return_if_fail (main_window);
 
3731
  
 
3732
  mw = gm_mw_get_mw (main_window);
 
3733
  
 
3734
  g_return_if_fail (mw != NULL);
 
3735
 
 
3736
 
 
3737
  mw->incoming_call_popup = gtk_dialog_new ();
 
3738
  b2 = gtk_dialog_add_button (GTK_DIALOG (mw->incoming_call_popup),
 
3739
                              _("Reject"), 0);
 
3740
  b3 = gtk_dialog_add_button (GTK_DIALOG (mw->incoming_call_popup),
 
3741
                              _("Transfer"), 1);
 
3742
  b1 = gtk_dialog_add_button (GTK_DIALOG (mw->incoming_call_popup),
 
3743
                              _("Accept"), 2);
 
3744
 
 
3745
  gtk_dialog_set_default_response (GTK_DIALOG (mw->incoming_call_popup), 2);
 
3746
 
 
3747
  vbox = GTK_DIALOG (mw->incoming_call_popup)->vbox;
 
3748
 
 
3749
  msg = g_strdup_printf ("%s <i>%s</i>",
 
3750
                         _("Incoming call from"), (const char*) utf8_name);
 
3751
  label = gtk_label_new (NULL);
 
3752
  gtk_label_set_markup (GTK_LABEL (label), msg);
 
3753
  gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 10);
 
3754
  gtk_misc_set_alignment (GTK_MISC (label), 0.5, 0.0);
 
3755
  gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
 
3756
  g_free (msg);
 
3757
 
 
3758
  if (utf8_url) {
 
3759
    
 
3760
    label = gtk_label_new (NULL);
 
3761
    msg =
 
3762
      g_strdup_printf ("<b>%s</b> <span foreground=\"blue\"><u>%s</u></span>",
 
3763
                       _("Remote URL:"), utf8_url);
 
3764
    gtk_label_set_markup (GTK_LABEL (label), msg);
 
3765
    gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
 
3766
    gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 2);
 
3767
    gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0);
 
3768
    g_free (msg);
 
3769
  }
 
3770
 
 
3771
  if (utf8_app) {
 
3772
 
 
3773
    label = gtk_label_new (NULL);
 
3774
    msg = g_strdup_printf ("<b>%s</b> %s",
 
3775
                           _("Remote Application:"), utf8_app);
 
3776
    gtk_label_set_markup (GTK_LABEL (label), msg);
 
3777
    gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
 
3778
    gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 2);
 
3779
    gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0);
 
3780
    g_free (msg);
 
3781
  }
 
3782
 
 
3783
  
 
3784
  gtk_window_set_title (GTK_WINDOW (mw->incoming_call_popup), utf8_name);
 
3785
  gtk_window_set_modal (GTK_WINDOW (mw->incoming_call_popup), TRUE);
 
3786
  gtk_window_set_keep_above (GTK_WINDOW (mw->incoming_call_popup), TRUE);
 
3787
#if GTK_MINOR_VERSION >= 8
 
3788
  gtk_window_set_urgency_hint (GTK_WINDOW (mw->incoming_call_popup), TRUE);
 
3789
#endif
 
3790
  gtk_window_set_transient_for (GTK_WINDOW (mw->incoming_call_popup),
 
3791
                                GTK_WINDOW (main_window));
 
3792
 
 
3793
  
 
3794
  g_signal_connect (G_OBJECT (b1), "clicked",
 
3795
                    GTK_SIGNAL_FUNC (connect_cb), main_window);
 
3796
  g_signal_connect (G_OBJECT (b2), "clicked",
 
3797
                    GTK_SIGNAL_FUNC (disconnect_cb), NULL);
 
3798
  g_signal_connect (G_OBJECT (b3), "clicked",
 
3799
                    GTK_SIGNAL_FUNC (transfer_current_call_cb), 
 
3800
                    mw->incoming_call_popup);
 
3801
  
 
3802
  g_signal_connect_swapped (G_OBJECT (b1), "clicked",
 
3803
                            GTK_SIGNAL_FUNC (gtk_widget_hide), 
 
3804
                            mw->incoming_call_popup);
 
3805
  g_signal_connect_swapped (G_OBJECT (b2), "clicked",
 
3806
                            GTK_SIGNAL_FUNC (gtk_widget_hide),
 
3807
                            mw->incoming_call_popup);
 
3808
 
 
3809
  g_signal_connect (G_OBJECT (mw->incoming_call_popup), "delete-event",
 
3810
                    GTK_SIGNAL_FUNC (delete_incoming_call_dialog_cb), 
 
3811
                    main_window);
 
3812
 
 
3813
  gtk_widget_show_all (vbox);
 
3814
  gnomemeeting_threads_dialog_show (mw->incoming_call_popup);
 
3815
}
 
3816
 
 
3817
 
 
3818
GtkWidget *
 
3819
gm_main_window_new ()
 
3820
{
 
3821
  GmWindow *mw = NULL;
 
3822
 
 
3823
  GtkWidget *window = NULL;
 
3824
  GtkWidget *table = NULL;      
 
3825
  GtkWidget *frame = NULL;
 
3826
  GdkPixbuf *pixbuf = NULL;
 
3827
  GtkWidget *event_box = NULL;
 
3828
  GtkWidget *vbox = NULL;
 
3829
  gchar     *filename = NULL;
 
3830
 
 
3831
  ControlPanelSection section = DIALPAD;
 
3832
  ViewMode view_mode = SOFTPHONE;
 
3833
  
 
3834
  /* The Top-level window */
 
3835
#ifndef DISABLE_GNOME
 
3836
  window = gnome_app_new ("gnomemeeting", NULL);
 
3837
#else
 
3838
  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
 
3839
#endif
 
3840
  g_object_set_data_full (G_OBJECT (window), "window_name",
 
3841
                          g_strdup ("main_window"), g_free);
 
3842
 
 
3843
  gtk_window_set_title (GTK_WINDOW (window), 
 
3844
                        _("Ekiga"));
 
3845
  gtk_window_set_position (GTK_WINDOW (window), 
 
3846
                           GTK_WIN_POS_CENTER);
 
3847
 
 
3848
 
 
3849
  /* The GMObject data */
 
3850
  mw = new GmWindow ();
 
3851
  mw->incoming_call_popup = mw->transfer_call_popup = NULL;
 
3852
#ifdef HAS_SDL
 
3853
  mw->screen = NULL;
 
3854
#endif
 
3855
  g_object_set_data_full (G_OBJECT (window), "GMObject", 
 
3856
                          mw, (GDestroyNotify) gm_mw_destroy);
 
3857
 
 
3858
  
 
3859
  /* Tooltips and accelerators */
 
3860
  mw->tips = gtk_tooltips_new ();
 
3861
  mw->accel = gtk_accel_group_new ();
 
3862
  gtk_window_add_accel_group (GTK_WINDOW (window), mw->accel);
 
3863
 
 
3864
#ifdef DISABLE_GNOME
 
3865
  mw->window_vbox = gtk_vbox_new (0, FALSE);
 
3866
  gtk_container_add (GTK_CONTAINER (window), mw->window_vbox);
 
3867
  gtk_widget_show_all (mw->window_vbox);
 
3868
 
 
3869
  /* The hbox */
 
3870
  mw->window_hbox = gtk_hbox_new (0, FALSE);
 
3871
  gtk_widget_show_all (mw->window_hbox);
 
3872
#endif
 
3873
  
 
3874
  /* The main menu and the toolbars */
 
3875
  gm_mw_init_menu (window); 
 
3876
#ifdef DISABLE_GNOME
 
3877
  gtk_box_pack_start (GTK_BOX (mw->window_vbox), mw->main_menu,
 
3878
                      FALSE, FALSE, 0);
 
3879
#endif
 
3880
  
 
3881
  gm_mw_init_toolbars (window);
 
3882
 
 
3883
#ifndef DISABLE_GNOME
 
3884
  gnome_app_set_menus (GNOME_APP (window), 
 
3885
                       GTK_MENU_BAR (mw->main_menu));
 
3886
#else
 
3887
  gtk_box_pack_start (GTK_BOX (mw->window_vbox), mw->window_hbox, 
 
3888
                      FALSE, FALSE, 0);
 
3889
#endif
 
3890
  
 
3891
  
 
3892
  /* Create a table in the main window to attach things like buttons */
 
3893
  table = gtk_table_new (3, 4, FALSE);
 
3894
  gtk_container_set_border_width (GTK_CONTAINER (table), 6);
 
3895
#ifdef DISABLE_GNOME
 
3896
  gtk_box_pack_start (GTK_BOX (mw->window_hbox), table, FALSE, FALSE, 0);
 
3897
  gtk_widget_show (table);
 
3898
#else
 
3899
  gnome_app_set_contents (GNOME_APP (window), table);
 
3900
#endif
 
3901
  gtk_widget_show (table);
 
3902
 
 
3903
  /* The Notebook */
 
3904
  mw->main_notebook = gtk_notebook_new ();
 
3905
#ifndef WIN32
 
3906
  gtk_notebook_set_tab_pos (GTK_NOTEBOOK (mw->main_notebook), GTK_POS_BOTTOM);
 
3907
#endif
 
3908
  gtk_notebook_popup_enable (GTK_NOTEBOOK (mw->main_notebook));
 
3909
  gtk_notebook_set_show_tabs (GTK_NOTEBOOK (mw->main_notebook), TRUE);
 
3910
  gtk_notebook_set_scrollable (GTK_NOTEBOOK (mw->main_notebook), TRUE);
 
3911
 
 
3912
  gm_mw_init_dialpad (window);
 
3913
  gm_mw_init_audio_settings (window);
 
3914
  gm_mw_init_video_settings (window);
 
3915
  gm_mw_init_stats (window);
 
3916
 
 
3917
  gtk_table_attach (GTK_TABLE (table), GTK_WIDGET (mw->main_notebook),
 
3918
                    0, 2, 2, 3,
 
3919
                    (GtkAttachOptions) (GTK_FILL | GTK_EXPAND),
 
3920
                    (GtkAttachOptions) (GTK_FILL | GTK_EXPAND),
 
3921
                    18, 3); 
 
3922
 
 
3923
  section = (ControlPanelSection) 
 
3924
    gm_conf_get_int (USER_INTERFACE_KEY "main_window/control_panel_section");
 
3925
  gtk_widget_show_all (GTK_WIDGET (mw->main_notebook));
 
3926
  gm_main_window_set_control_panel_section (window, section);
 
3927
  
 
3928
  
 
3929
  /* The frame that contains information about the call */
 
3930
  frame = gtk_frame_new (NULL);
 
3931
  vbox = gtk_vbox_new (0, FALSE);
 
3932
  gtk_container_add (GTK_CONTAINER (frame), vbox);
 
3933
  gtk_container_set_border_width (GTK_CONTAINER (vbox), 1);
 
3934
  gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN);
 
3935
  mw->status_label = gtk_label_new (NULL);
 
3936
  gtk_misc_set_alignment (GTK_MISC (mw->status_label), 0.0, 0.0);
 
3937
  gtk_box_pack_start (GTK_BOX (vbox), mw->status_label, FALSE, FALSE, 2);
 
3938
 
 
3939
  mw->info_label = gtk_label_new (NULL);
 
3940
  gtk_misc_set_alignment (GTK_MISC (mw->info_label), 0.05, 0.0);
 
3941
  gtk_box_pack_start (GTK_BOX (vbox), mw->info_label, FALSE, FALSE, 0);
 
3942
#if GTK_CHECK_VERSION (2, 6, 0)
 
3943
  gtk_label_set_ellipsize (GTK_LABEL (mw->info_label), PANGO_ELLIPSIZE_END);
 
3944
  gtk_label_set_ellipsize (GTK_LABEL (mw->status_label), PANGO_ELLIPSIZE_END);
 
3945
#endif
 
3946
 
 
3947
  gm_main_window_set_status (window, _("Standby"));
 
3948
  gm_main_window_set_account_info (window, 0);
 
3949
  
 
3950
  gtk_table_attach (GTK_TABLE (table), GTK_WIDGET (frame), 
 
3951
                    0, 2, 1, 2,
 
3952
                    (GtkAttachOptions) (GTK_FILL | GTK_EXPAND),
 
3953
                    (GtkAttachOptions) (GTK_FILL | GTK_EXPAND),
 
3954
                    18, 3);
 
3955
  gtk_widget_show_all (frame);
 
3956
 
 
3957
 
 
3958
  /* The frame that contains the video */
 
3959
  mw->video_frame = gtk_frame_new (NULL);
 
3960
  gtk_frame_set_shadow_type (GTK_FRAME (mw->video_frame), GTK_SHADOW_ETCHED_IN);
 
3961
  
 
3962
  event_box = gtk_event_box_new ();
 
3963
 
 
3964
  gtk_container_add (GTK_CONTAINER (event_box), mw->video_frame);
 
3965
 
 
3966
  mw->main_video_image = gtk_image_new ();
 
3967
  gtk_container_set_border_width (GTK_CONTAINER (mw->video_frame), 0);
 
3968
  gtk_container_add (GTK_CONTAINER (mw->video_frame), mw->main_video_image);
 
3969
 
 
3970
  gtk_widget_set_size_request (GTK_WIDGET (mw->video_frame), 
 
3971
                               GM_QCIF_WIDTH + GM_FRAME_SIZE, 
 
3972
                               GM_QCIF_HEIGHT + GM_FRAME_SIZE); 
 
3973
 
 
3974
  gtk_table_attach (GTK_TABLE (table), GTK_WIDGET (event_box), 
 
3975
                    0, 2, 0, 1,
 
3976
                    (GtkAttachOptions) GTK_EXPAND,
 
3977
                    (GtkAttachOptions) GTK_EXPAND,
 
3978
                    18, 3);
 
3979
  gtk_widget_show (event_box);
 
3980
 
 
3981
  
 
3982
  /* The statusbar */
 
3983
  mw->statusbar_ebox = gtk_event_box_new ();
 
3984
  mw->statusbar = gm_statusbar_new ();
 
3985
  gtk_container_add (GTK_CONTAINER (mw->statusbar_ebox), mw->statusbar);
 
3986
 
 
3987
#ifdef DISABLE_GNOME
 
3988
  gtk_box_pack_start (GTK_BOX (mw->window_vbox), mw->statusbar_ebox, 
 
3989
                      FALSE, FALSE, 0);
 
3990
#else
 
3991
  gnome_app_set_statusbar_custom (GNOME_APP (window), 
 
3992
                                  mw->statusbar_ebox, mw->statusbar);
 
3993
#endif
 
3994
  gtk_widget_show_all (mw->statusbar_ebox);
 
3995
  
 
3996
  g_signal_connect (G_OBJECT (mw->statusbar_ebox), "button-press-event",
 
3997
                    GTK_SIGNAL_FUNC (statusbar_clicked_cb), window);
 
3998
  
 
3999
 
 
4000
  /* The 2 video window popups */
 
4001
  mw->local_video_window =
 
4002
    gm_mw_video_window_new (window,
 
4003
                            TRUE,
 
4004
                            _("Local Video"),
 
4005
                            mw->local_video_image,
 
4006
                            "local_video_window");
 
4007
  mw->remote_video_window =
 
4008
    gm_mw_video_window_new (window,
 
4009
                            FALSE,
 
4010
                            _("Remote Video"),
 
4011
                            mw->remote_video_image,
 
4012
                            "remote_video_window");
 
4013
  
 
4014
  gm_main_window_update_logo (window);
 
4015
 
 
4016
  g_signal_connect (G_OBJECT (mw->local_video_window), "show", 
 
4017
                    GTK_SIGNAL_FUNC (video_window_shown_cb), NULL);
 
4018
  g_signal_connect (G_OBJECT (mw->remote_video_window), "show", 
 
4019
                    GTK_SIGNAL_FUNC (video_window_shown_cb), NULL);
 
4020
 
 
4021
  
 
4022
  /* Add the window icon and title */
 
4023
  gtk_window_set_title (GTK_WINDOW (window), _("Ekiga"));
 
4024
 
 
4025
  filename = g_build_filename (DATA_DIR, "pixmaps", PACKAGE_NAME ".png", NULL);
 
4026
  pixbuf = gdk_pixbuf_new_from_file (filename, NULL);
 
4027
  g_free (filename);
 
4028
  if (pixbuf) {
 
4029
 
 
4030
    gtk_window_set_icon (GTK_WINDOW (window), pixbuf);
 
4031
    g_object_unref (G_OBJECT (pixbuf));
 
4032
  }
 
4033
 
 
4034
  gtk_widget_realize (window);
 
4035
  gtk_window_set_resizable (GTK_WINDOW (window), false);
 
4036
 
 
4037
  g_signal_connect_after (G_OBJECT (mw->main_notebook), "switch-page",
 
4038
                          G_CALLBACK (control_panel_section_changed_cb), 
 
4039
                          window);
 
4040
 
 
4041
  
 
4042
  /* Set the correct view mode */
 
4043
  view_mode = (ViewMode) 
 
4044
    gm_conf_get_int (USER_INTERFACE_KEY "main_window/view_mode");
 
4045
  gm_main_window_set_view_mode (window, view_mode);
 
4046
  
 
4047
 
 
4048
  /* Init the Drag and drop features */
 
4049
  gmcontacts_dnd_set_dest (GTK_WIDGET (window), dnd_call_contact_cb, mw);
 
4050
 
 
4051
  /* if the user tries to close the window : delete_event */
 
4052
  g_signal_connect (G_OBJECT (window), "delete_event",
 
4053
                    G_CALLBACK (window_closed_cb), 
 
4054
                    (gpointer) window);
 
4055
 
 
4056
  g_signal_connect (G_OBJECT (window), "show", 
 
4057
                    GTK_SIGNAL_FUNC (video_window_shown_cb), NULL);
 
4058
 
 
4059
  return window;
 
4060
}
 
4061
 
 
4062
 
 
4063
void 
 
4064
gm_main_window_flash_message (GtkWidget *main_window, 
 
4065
                              const char *msg, 
 
4066
                              ...)
 
4067
{
 
4068
  GmWindow *mw = NULL;
 
4069
 
 
4070
  char buffer [1025];
 
4071
 
 
4072
  g_return_if_fail (main_window != NULL);
 
4073
 
 
4074
  mw = gm_mw_get_mw (main_window);
 
4075
 
 
4076
  va_list args;
 
4077
 
 
4078
  va_start (args, msg);
 
4079
  vsnprintf (buffer, 1024, msg, args);
 
4080
  gm_statusbar_flash_message (GM_STATUSBAR (mw->statusbar), buffer);
 
4081
  va_end (args);
 
4082
}
 
4083
 
 
4084
 
 
4085
void 
 
4086
gm_main_window_push_message (GtkWidget *main_window, 
 
4087
                             int missed,
 
4088
                             const char *vm)
 
4089
{
 
4090
  GmWindow *mw = NULL;
 
4091
 
 
4092
  gchar *info = NULL;
 
4093
  
 
4094
  g_return_if_fail (main_window != NULL);
 
4095
  g_return_if_fail (vm != NULL);
 
4096
 
 
4097
  mw = gm_mw_get_mw (main_window);
 
4098
  
 
4099
  info = g_strdup_printf (_("Missed calls: %d - Voice Mails: %s"), missed, vm);
 
4100
  gm_main_window_push_info_message (main_window, info);
 
4101
 
 
4102
  g_free (info);
 
4103
}
 
4104
 
 
4105
 
 
4106
void 
 
4107
gm_main_window_push_message (GtkWidget *main_window, 
 
4108
                             const char *msg, 
 
4109
                             ...)
 
4110
{
 
4111
  GmWindow *mw = NULL;
 
4112
 
 
4113
  char buffer [1025];
 
4114
 
 
4115
  g_return_if_fail (main_window != NULL);
 
4116
 
 
4117
  mw = gm_mw_get_mw (main_window);
 
4118
 
 
4119
  va_list args;
 
4120
 
 
4121
  va_start (args, msg);
 
4122
  vsnprintf (buffer, 1024, msg, args);
 
4123
  gm_statusbar_push_message (GM_STATUSBAR (mw->statusbar), buffer);
 
4124
  va_end (args);
 
4125
}
 
4126
 
 
4127
 
 
4128
void 
 
4129
gm_main_window_push_info_message (GtkWidget *main_window, 
 
4130
                                  const char *msg, 
 
4131
                                  ...)
 
4132
{
 
4133
  GmWindow *mw = NULL;
 
4134
  
 
4135
  g_return_if_fail (main_window != NULL);
 
4136
 
 
4137
  mw = gm_mw_get_mw (main_window);
 
4138
 
 
4139
  va_list args;
 
4140
 
 
4141
  va_start (args, msg);
 
4142
  gm_statusbar_push_info_message (GM_STATUSBAR (mw->statusbar), msg, args);
 
4143
  va_end (args);
 
4144
}
 
4145
 
 
4146
 
 
4147
void 
 
4148
gm_main_window_set_call_url (GtkWidget *main_window, 
 
4149
                             const char *url)
 
4150
{
 
4151
  GmWindow *mw = NULL;
 
4152
 
 
4153
  GtkWidget *entry = NULL;
 
4154
 
 
4155
  g_return_if_fail (main_window != NULL && url != NULL);
 
4156
 
 
4157
  mw = gm_mw_get_mw (main_window);
 
4158
 
 
4159
  g_return_if_fail (mw != NULL);
 
4160
 
 
4161
  entry = GTK_WIDGET (GTK_BIN (mw->combo)->child);
 
4162
 
 
4163
  gtk_entry_set_text (GTK_ENTRY (entry), url);
 
4164
  gtk_editable_set_position (GTK_EDITABLE (entry), -1);
 
4165
  gtk_widget_grab_focus (GTK_WIDGET (entry));
 
4166
  gtk_editable_select_region (GTK_EDITABLE (entry), -1, -1);
 
4167
}
 
4168
 
 
4169
 
 
4170
void 
 
4171
gm_main_window_append_call_url (GtkWidget *main_window, 
 
4172
                                const char *url)
 
4173
{
 
4174
  GmWindow *mw = NULL;
 
4175
  
 
4176
  GtkWidget *entry = NULL;
 
4177
 
 
4178
  int pos = -1;
 
4179
 
 
4180
  g_return_if_fail (main_window != NULL && url != NULL);
 
4181
 
 
4182
  mw = gm_mw_get_mw (main_window);
 
4183
 
 
4184
  g_return_if_fail (mw != NULL && url != NULL);
 
4185
 
 
4186
  entry = GTK_WIDGET (GTK_BIN (mw->combo)->child);
 
4187
 
 
4188
  if (gtk_editable_get_selection_bounds (GTK_EDITABLE (entry), NULL, NULL)) {
 
4189
 
 
4190
    gtk_editable_delete_selection (GTK_EDITABLE (entry));
 
4191
    pos = gtk_editable_get_position (GTK_EDITABLE (entry));
 
4192
  }
 
4193
  
 
4194
  gtk_editable_insert_text (GTK_EDITABLE (entry), url, strlen (url), &pos);
 
4195
  gtk_widget_grab_focus (GTK_WIDGET (entry));
 
4196
  gtk_editable_select_region (GTK_EDITABLE (entry), -1, -1);
 
4197
}
 
4198
 
 
4199
 
 
4200
const char *
 
4201
gm_main_window_get_call_url (GtkWidget *main_window)
 
4202
{
 
4203
  GmWindow *mw = NULL;
 
4204
 
 
4205
  g_return_val_if_fail (main_window != NULL, NULL);
 
4206
 
 
4207
  mw = gm_mw_get_mw (main_window);
 
4208
 
 
4209
  g_return_val_if_fail (mw != NULL, NULL);
 
4210
 
 
4211
  return gtk_entry_get_text (GTK_ENTRY (GTK_BIN (mw->combo)->child));
 
4212
}
 
4213
 
 
4214
 
 
4215
void 
 
4216
gm_main_window_clear_stats (GtkWidget *main_window)
 
4217
{
 
4218
  GmWindow *mw = NULL;
 
4219
 
 
4220
  g_return_if_fail (main_window != NULL);
 
4221
 
 
4222
  mw = gm_mw_get_mw (main_window);
 
4223
 
 
4224
  g_return_if_fail (mw != NULL);
 
4225
 
 
4226
  gm_main_window_update_stats (main_window, 0, 0, 0, 0, 0, 0, 0, 0);
 
4227
  stats_drawing_area_clear (mw->stats_drawing_area);
 
4228
}
 
4229
 
 
4230
 
 
4231
void 
 
4232
gm_main_window_update_stats (GtkWidget *main_window,
 
4233
                             float lost,
 
4234
                             float late,
 
4235
                             float out_of_order,
 
4236
                             int jitter,
 
4237
                             float new_video_octets_received,
 
4238
                             float new_video_octets_transmitted,
 
4239
                             float new_audio_octets_received,
 
4240
                             float new_audio_octets_transmitted)
 
4241
{
 
4242
  GmWindow *mw = NULL;
 
4243
  
 
4244
  gchar *stats_msg = NULL;
 
4245
 
 
4246
  
 
4247
  g_return_if_fail (main_window != NULL);
 
4248
 
 
4249
  mw = gm_mw_get_mw (main_window);
 
4250
 
 
4251
  g_return_if_fail (mw != NULL);
 
4252
 
 
4253
  
 
4254
  stats_msg =  g_strdup_printf (_("Lost packets: %.1f %%\nLate packets: %.1f %%\nOut of order packets: %.1f %%\nJitter buffer: %d ms"), lost, late, out_of_order, jitter);
 
4255
  gtk_label_set_text (GTK_LABEL (mw->stats_label), stats_msg);
 
4256
  g_free (stats_msg);
 
4257
 
 
4258
  stats_drawing_area_new_data (mw->stats_drawing_area,
 
4259
                               new_video_octets_received,
 
4260
                               new_video_octets_transmitted,
 
4261
                               new_audio_octets_received,
 
4262
                               new_audio_octets_transmitted);
 
4263
}
 
4264
 
 
4265
 
 
4266
GdkPixbuf *
 
4267
gm_main_window_get_current_picture (GtkWidget *main_window)
 
4268
{
 
4269
  GmWindow *mw = NULL;
 
4270
  
 
4271
  g_return_val_if_fail (main_window != NULL, NULL);
 
4272
 
 
4273
  mw = gm_mw_get_mw (main_window);
 
4274
 
 
4275
  g_return_val_if_fail (mw != NULL, NULL);
 
4276
 
 
4277
  return gtk_image_get_pixbuf (GTK_IMAGE (mw->main_video_image));
 
4278
}
 
4279
 
 
4280
 
 
4281
void 
 
4282
gm_main_window_set_stay_on_top (GtkWidget *main_window,
 
4283
                                gboolean stay_on_top)
 
4284
{
 
4285
  GmWindow *mw = NULL;
 
4286
  
 
4287
  GdkWindow *gm_window = NULL;
 
4288
  GdkWindow *local_window = NULL;
 
4289
  GdkWindow *remote_window = NULL;
 
4290
 
 
4291
  g_return_if_fail (main_window != NULL);
 
4292
 
 
4293
  mw = gm_mw_get_mw (main_window);
 
4294
 
 
4295
  g_return_if_fail (mw != NULL);
 
4296
  
 
4297
 
 
4298
  gm_window = GDK_WINDOW (main_window->window);
 
4299
  local_window = GDK_WINDOW (mw->local_video_window->window);
 
4300
  remote_window = GDK_WINDOW (mw->remote_video_window->window);
 
4301
 
 
4302
  /* Update the stay-on-top attribute */
 
4303
  gdk_window_set_always_on_top (GDK_WINDOW (gm_window), stay_on_top);
 
4304
  gdk_window_set_always_on_top (GDK_WINDOW (local_window), stay_on_top);
 
4305
  gdk_window_set_always_on_top (GDK_WINDOW (remote_window), stay_on_top);
 
4306
}
 
4307
 
 
4308
 
 
4309
/* The main () */
 
4310
int 
 
4311
main (int argc, 
 
4312
      char ** argv, 
 
4313
      char ** envp)
 
4314
{
 
4315
  GMManager *endpoint = NULL;
 
4316
 
 
4317
  PProcess::PreInitialise (argc, argv, envp);
 
4318
 
 
4319
  GtkWidget *main_window = NULL;
 
4320
  GtkWidget *druid_window = NULL;
 
4321
  GtkWidget *dialog = NULL;
 
4322
  
 
4323
  gchar *path = NULL;
 
4324
  gchar *url = NULL;
 
4325
  gchar *key_name = NULL;
 
4326
  gchar *msg = NULL;
 
4327
 
 
4328
  int debug_level = 0;
 
4329
 
 
4330
  
 
4331
#ifndef WIN32
 
4332
  setenv ("ESD_NO_SPAWN", "1", 1);
 
4333
#endif
 
4334
  
 
4335
 
 
4336
  /* Threads + Locale Init + config */
 
4337
  g_thread_init (NULL);
 
4338
  gdk_threads_init ();
 
4339
  
 
4340
#ifndef WIN32
 
4341
  gtk_init (&argc, &argv);
 
4342
#else
 
4343
  gtk_init (NULL, NULL);
 
4344
#endif
 
4345
 
 
4346
  xmlInitParser ();
 
4347
 
 
4348
  gm_conf_init (argc, argv);
 
4349
  
 
4350
  /* Upgrade the preferences */
 
4351
  gnomemeeting_conf_upgrade ();
 
4352
 
 
4353
  /* Initialize gettext */
 
4354
  path = g_build_filename (DATA_DIR, "locale", NULL);
 
4355
  textdomain (GETTEXT_PACKAGE);
 
4356
  bindtextdomain (GETTEXT_PACKAGE, path);
 
4357
  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
 
4358
  g_free (path);
 
4359
  
 
4360
#ifndef DISABLE_GNOME
 
4361
  /* Cope with command line options */
 
4362
  struct poptOption arguments [] =
 
4363
    {
 
4364
      {"debug", 'd', POPT_ARG_INT, &debug_level, 
 
4365
       1, N_("Prints debug messages in the console (level between 1 and 6)"), 
 
4366
       NULL},
 
4367
      {"call", 'c', POPT_ARG_STRING, &url,
 
4368
       1, N_("Makes Ekiga call the given URL"), NULL},
 
4369
      {NULL, '\0', 0, NULL, 0, NULL, NULL}
 
4370
    };
 
4371
  
 
4372
  /* GnomeMeeting Initialisation */
 
4373
  gnome_program_init ("ekiga", VERSION,
 
4374
                      LIBGNOMEUI_MODULE, argc, argv,
 
4375
                      GNOME_PARAM_POPT_TABLE, arguments,
 
4376
                      GNOME_PARAM_HUMAN_READABLE_NAME,
 
4377
                      "ekiga",
 
4378
                      GNOME_PARAM_APP_DATADIR, DATA_DIR,
 
4379
                      (void *) NULL);
 
4380
#else
 
4381
  GOptionEntry arguments [] =
 
4382
    {
 
4383
      {
 
4384
        "debug", 'd', 0, G_OPTION_ARG_INT, &debug_level, 
 
4385
       N_("Prints debug messages in the console (level between 1 and 6)"), 
 
4386
       NULL
 
4387
      },
 
4388
      {
 
4389
        "call", 'c', 0, G_OPTION_ARG_STRING, &url,
 
4390
        N_("Makes Ekiga call the given URL"),
 
4391
        NULL
 
4392
      },
 
4393
      {
 
4394
        NULL
 
4395
      }
 
4396
    };
 
4397
  GOptionContext *context = g_option_context_new (NULL);
 
4398
  g_option_context_add_main_entries (context, arguments, PACKAGE_NAME);
 
4399
  g_option_context_set_help_enabled (context, TRUE);
 
4400
  
 
4401
  (void)g_option_context_parse (context, &argc, &argv, NULL);
 
4402
  g_option_context_free (context);
 
4403
#endif
 
4404
  
 
4405
  gdk_threads_enter ();
 
4406
 
 
4407
  /* The factory */
 
4408
#ifndef DISABLE_GNOME
 
4409
  if (bonobo_component_init (argc, argv))
 
4410
    exit (1);
 
4411
#endif
 
4412
 
 
4413
  /* GnomeMeeting main initialisation */
 
4414
  static GnomeMeeting instance;
 
4415
 
 
4416
  /* Debug */
 
4417
  if (debug_level != 0)
 
4418
    PTrace::Initialise (PMAX (PMIN (4, debug_level), 0), NULL,
 
4419
                        PTrace::Timestamp | PTrace::Thread
 
4420
                        | PTrace::Blocks | PTrace::DateAndTime);
 
4421
 
 
4422
  /* Detect the devices, exit if it fails */
 
4423
  if (!GnomeMeeting::Process ()->DetectDevices ()) {
 
4424
 
 
4425
    dialog = gnomemeeting_error_dialog (NULL, _("No usable audio plugin detected"), _("Ekiga didn't find any usable audio plugin. Make sure that your installation is correct."));
 
4426
    
 
4427
    g_signal_handlers_disconnect_by_func (G_OBJECT (dialog),
 
4428
                                          (gpointer) gtk_widget_destroy,
 
4429
                                          G_OBJECT (dialog));
 
4430
 
 
4431
    gtk_dialog_run (GTK_DIALOG (dialog));
 
4432
    gtk_widget_destroy (dialog);
 
4433
    exit (-1);
 
4434
  }
 
4435
  
 
4436
 
 
4437
  /* Build the GUI */
 
4438
  GnomeMeeting::Process ()->BuildGUI ();
 
4439
 
 
4440
 
 
4441
  /* Init the config DB, exit if it fails */
 
4442
  if (!gnomemeeting_conf_init ()) {
 
4443
 
 
4444
    key_name = g_strdup ("\"/apps/" PACKAGE_NAME "/general/gconf_test_age\"");
 
4445
    msg = g_strdup_printf (_("Ekiga got an invalid value for the GConf key %s.\n\nIt probably means that your GConf schemas have not been correctly installed or the that permissions are not correct.\n\nPlease check the FAQ (http://www.ekiga.org/), the throubleshooting 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);
 
4446
    
 
4447
    dialog = gnomemeeting_error_dialog (GTK_WINDOW (main_window),
 
4448
                                        _("Gconf key error"), msg);
 
4449
 
 
4450
    g_signal_handlers_disconnect_by_func (G_OBJECT (dialog),
 
4451
                                          (gpointer) gtk_widget_destroy,
 
4452
                                          G_OBJECT (dialog));
 
4453
 
 
4454
 
 
4455
    g_free (msg);
 
4456
    g_free (key_name);
 
4457
    
 
4458
    gtk_dialog_run (GTK_DIALOG (dialog));
 
4459
    gtk_widget_destroy (dialog);
 
4460
    exit (-1);
 
4461
  }
 
4462
 
 
4463
 
 
4464
  /* Init the process */
 
4465
  GnomeMeeting::Process ()->DetectInterfaces ();
 
4466
  GnomeMeeting::Process ()->Init ();
 
4467
 
 
4468
  main_window = GnomeMeeting::Process ()->GetMainWindow ();
 
4469
  druid_window = GnomeMeeting::Process ()->GetDruidWindow ();
 
4470
  endpoint = GnomeMeeting::Process ()->GetManager ();
 
4471
 
 
4472
  if (gm_conf_get_int (GENERAL_KEY "version") 
 
4473
      < 1000 * MAJOR_VERSION + 10 * MINOR_VERSION + BUILD_NUMBER) {
 
4474
 
 
4475
    gtk_widget_show_all (GTK_WIDGET (druid_window));
 
4476
  }
 
4477
  else {
 
4478
 
 
4479
    /* Show the main window */
 
4480
    if (!gm_conf_get_bool (USER_INTERFACE_KEY "start_hidden")) 
 
4481
      gnomemeeting_window_show (main_window);
 
4482
    else
 
4483
      g_timeout_add (15000, (GtkFunction) gnomemeeting_tray_hack_cb, NULL);
 
4484
  }
 
4485
 
 
4486
 
 
4487
  
 
4488
  /* Call the given host if needed */
 
4489
  if (url) 
 
4490
    GnomeMeeting::Process ()->Connect (url);
 
4491
 
 
4492
  
 
4493
  /* The GTK loop */
 
4494
  gtk_main ();
 
4495
  gdk_threads_leave ();
 
4496
 
 
4497
  GnomeMeeting::Process ()->Exit ();
 
4498
 
 
4499
 
 
4500
  gm_conf_save ();
 
4501
 
 
4502
  return 0;
 
4503
}
 
4504
 
 
4505
 
 
4506
#ifdef WIN32
 
4507
int 
 
4508
APIENTRY WinMain (HINSTANCE hInstance,
 
4509
                  HINSTANCE hPrevInstance,
 
4510
                  LPSTR     lpCmdLine,
 
4511
                  int       nCmdShow)
 
4512
{
 
4513
  return main (0, NULL, NULL);
 
4514
}
 
4515
#endif