From: Sjoerd Simons Date: Tue, 3 Feb 2009 09:02:51 +0000 (+0000) Subject: Toss out the old EmpathyCallWindow initialise the CallFactory and hook into its signals X-Git-Url: https://git.0d.be/?p=empathy.git;a=commitdiff_plain;h=a7630dc453ae60fde8191beca2003b5427743b7d Toss out the old EmpathyCallWindow initialise the CallFactory and hook into its signals Signed-off-by: Sjoerd Simons svn path=/trunk/; revision=2383 --- diff --git a/src/Makefile.am b/src/Makefile.am index db6479ea..864eada0 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -46,7 +46,6 @@ empathy_logs_SOURCES = empathy-logs.c gladedir = $(datadir)/empathy glade_DATA = \ empathy-accounts-dialog.glade \ - empathy-call-window.glade \ empathy-chatrooms-window.glade \ empathy-chat-window.glade \ empathy-ft-manager.glade \ diff --git a/src/empathy-call-window.c b/src/empathy-call-window.c index 34f5fd20..6957278e 100644 --- a/src/empathy-call-window.c +++ b/src/empathy-call-window.c @@ -1,7 +1,7 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* - * Copyright (C) 2007 Elliot Fairweather - * Copyright (C) 2007-2008 Collabora Ltd. + * empathy-call-window.c - Source for EmpathyCallWindow + * Copyright (C) 2008 Collabora Ltd. + * @author Sjoerd Simons * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -16,640 +16,93 @@ * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: Elliot Fairweather - * Xavier Claessens */ -#include - -#include -#include -#include - -#include -#include -#include -#include +#include +#include #include "empathy-call-window.h" -#define DEBUG_FLAG EMPATHY_DEBUG_OTHER -#include - -typedef struct -{ - EmpathyTpCall *call; - GTimeVal start_time; - guint timeout_event_id; - gboolean is_drawing; - guint status; - - GtkWidget *window; - GtkWidget *main_hbox; - GtkWidget *controls_vbox; - GtkWidget *volume_hbox; - GtkWidget *status_label; - GtkWidget *input_volume_button; - GtkWidget *output_volume_button; - GtkWidget *preview_video_socket; - GtkWidget *output_video_socket; - GtkWidget *video_button; - GtkWidget *hang_up_button; - GtkWidget *confirmation_dialog; - GtkWidget *keypad_expander; -} EmpathyCallWindow; - -static void call_window_update (EmpathyCallWindow *window); - -static GSList *windows = NULL; +G_DEFINE_TYPE(EmpathyCallWindow, empathy_call_window, GTK_TYPE_WINDOW) -static gboolean -call_window_update_timer (gpointer data) +/* signal enum */ +#if 0 +enum { - EmpathyCallWindow *window = data; - GTimeVal current; - gchar *str; - glong now, then; - glong time, seconds, minutes, hours; - - g_get_current_time (¤t); - - now = current.tv_sec; - then = (window->start_time).tv_sec; - - time = now - then; - - seconds = time % 60; - time /= 60; - minutes = time % 60; - time /= 60; - hours = time % 60; - - if (hours > 0) - str = g_strdup_printf ("Connected - %02ld : %02ld : %02ld", hours, - minutes, seconds); - else - str = g_strdup_printf ("Connected - %02ld : %02ld", minutes, seconds); - - gtk_label_set_text (GTK_LABEL (window->status_label), str); - - g_free (str); - - return TRUE; -} - -static void -call_window_stop_timeout (EmpathyCallWindow *window) -{ - DEBUG ("Timer stopped"); - - if (window->timeout_event_id) - { - g_source_remove (window->timeout_event_id); - window->timeout_event_id = 0; - } -} - -static void -call_window_set_output_video_is_drawing (EmpathyCallWindow *window, - gboolean is_drawing) -{ - DEBUG ("Setting output video is drawing - %d", is_drawing); - - if (is_drawing && !window->is_drawing) - { - gtk_window_set_resizable (GTK_WINDOW (window->window), TRUE); - gtk_box_pack_end (GTK_BOX (window->main_hbox), - window->output_video_socket, TRUE, TRUE, 0); - empathy_tp_call_add_output_video (window->call, - gtk_socket_get_id (GTK_SOCKET (window->output_video_socket))); - } - if (!is_drawing && window->is_drawing) - { - gtk_window_set_resizable (GTK_WINDOW (window->window), FALSE); - empathy_tp_call_add_output_video (window->call, 0); - gtk_container_remove (GTK_CONTAINER (window->main_hbox), - window->output_video_socket); - } - - window->is_drawing = is_drawing; -} - -static void -call_window_finalize (EmpathyCallWindow *window) -{ - gtk_label_set_text (GTK_LABEL (window->status_label), _("Closed")); - gtk_widget_set_sensitive (window->hang_up_button, FALSE); - gtk_widget_set_sensitive (window->video_button, FALSE); - gtk_widget_set_sensitive (window->output_volume_button, FALSE); - gtk_widget_set_sensitive (window->input_volume_button, FALSE); - gtk_widget_set_sensitive (window->keypad_expander, FALSE); - - if (window->call) - { - call_window_stop_timeout (window); - call_window_set_output_video_is_drawing (window, FALSE); - empathy_tp_call_remove_preview_video (window->call, - gtk_socket_get_id (GTK_SOCKET (window->preview_video_socket))); - - g_signal_handlers_disconnect_by_func (window->call, - call_window_update, window); - - empathy_tp_call_close (window->call); - g_object_unref (window->call); - window->call = NULL; - } - - if (window->confirmation_dialog) - gtk_widget_destroy (window->confirmation_dialog); -} - -static void -call_window_socket_realized_cb (GtkWidget *widget, - EmpathyCallWindow *window) -{ - if (widget == window->preview_video_socket) - { - DEBUG ("Preview socket realized"); - empathy_tp_call_add_preview_video (window->call, - gtk_socket_get_id (GTK_SOCKET (window->preview_video_socket))); - } - else - DEBUG ("Output socket realized"); -} - -static void -call_window_video_button_toggled_cb (GtkWidget *button, - EmpathyCallWindow *window) -{ - gboolean is_sending; - guint status; - - is_sending = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)); - - DEBUG ("Send video toggled - %d", is_sending); - - g_object_get (window->call, "status", &status, NULL); - if (status == EMPATHY_TP_CALL_STATUS_ACCEPTED) - empathy_tp_call_request_video_stream_direction (window->call, is_sending); -} - -static void -call_window_hang_up_button_clicked_cb (GtkWidget *widget, - EmpathyCallWindow *window) -{ - empathy_sound_play (GTK_WIDGET (window->window), - EMPATHY_SOUND_PHONE_HANGUP); - - DEBUG ("Call clicked, end call"); - call_window_finalize (window); -} - -static void -call_window_output_volume_changed_cb (GtkScaleButton *button, - gdouble value, - EmpathyCallWindow *window) -{ - if (!window->call) - return; - - if (value <= 0) - empathy_tp_call_mute_output (window->call, TRUE); - else - { - empathy_tp_call_mute_output (window->call, FALSE); - empathy_tp_call_set_output_volume (window->call, value * 100); - } -} + LAST_SIGNAL +}; -static void -call_window_input_volume_changed_cb (GtkScaleButton *button, - gdouble value, - EmpathyCallWindow *window) -{ - if (!window->call) - return; +static guint signals[LAST_SIGNAL] = {0}; +#endif - if (value <= 0) - empathy_tp_call_mute_input (window->call, TRUE); - else - { - empathy_tp_call_mute_input (window->call, FALSE); - /* FIXME: Not implemented? - empathy_tp_call_set_input_volume (window->call, value * 100);*/ - } -} +/* private structure */ +typedef struct _EmpathyCallWindowPrivate EmpathyCallWindowPrivate; -static gboolean -call_window_delete_event_cb (GtkWidget *widget, - GdkEvent *event, - EmpathyCallWindow *window) +struct _EmpathyCallWindowPrivate { - GtkWidget *dialog; - gint result; - guint status = EMPATHY_TP_CALL_STATUS_CLOSED; - - DEBUG ("Delete event occurred"); + gboolean dispose_has_run; +}; - if (window->call) - g_object_get (window->call, "status", &status, NULL); - - if (status == EMPATHY_TP_CALL_STATUS_ACCEPTED) - { - dialog = gtk_message_dialog_new (GTK_WINDOW (window->window), - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_WARNING, GTK_BUTTONS_CANCEL, _("End this call?")); - gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), - _("Closing this window will end the call in progress.")); - gtk_dialog_add_button (GTK_DIALOG (dialog), _("_End Call"), GTK_RESPONSE_OK); - gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); - - result = gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); - - if (result != GTK_RESPONSE_OK) - return TRUE; - } - - return FALSE; -} +#define EMPATHY_CALL_WINDOW_GET_PRIVATE(o) \ + (G_TYPE_INSTANCE_GET_PRIVATE ((o), EMPATHY_TYPE_CALL_WINDOW, \ + EmpathyCallWindowPrivate)) static void -call_window_destroy_cb (GtkWidget *widget, - EmpathyCallWindow *window) +empathy_call_window_init (EmpathyCallWindow *obj) { - call_window_finalize (window); - - g_object_unref (window->output_video_socket); - g_object_unref (window->preview_video_socket); + //EmpathyCallWindowPrivate *priv = EMPATHY_CALL_WINDOW_GET_PRIVATE (obj); - windows = g_slist_remove (windows, window); - g_slice_free (EmpathyCallWindow, window); + /* allocate any data required by the object here */ } -static void -call_window_confirmation_dialog_response_cb (GtkDialog *dialog, - gint response, - EmpathyCallWindow *window) -{ - if (response == GTK_RESPONSE_OK && window->call) - empathy_tp_call_accept_incoming_call (window->call); - else - call_window_finalize (window); - - gtk_widget_destroy (window->confirmation_dialog); - window->confirmation_dialog = NULL; -} +static void empathy_call_window_dispose (GObject *object); +static void empathy_call_window_finalize (GObject *object); static void -call_window_show_confirmation_dialog (EmpathyCallWindow *window) +empathy_call_window_class_init (EmpathyCallWindowClass *empathy_call_window_class) { - EmpathyContact *contact; - GtkWidget *button; - GtkWidget *image; - - if (window->confirmation_dialog) - return; + GObjectClass *object_class = G_OBJECT_CLASS (empathy_call_window_class); - g_object_get (window->call, "contact", &contact, NULL); + g_type_class_add_private (empathy_call_window_class, + sizeof (EmpathyCallWindowPrivate)); - window->confirmation_dialog = gtk_message_dialog_new (GTK_WINDOW (window->window), - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE, _("Incoming call")); - gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (window->confirmation_dialog), - _("%s is calling you, do you want to answer?"), - empathy_contact_get_name (contact)); - gtk_dialog_set_default_response (GTK_DIALOG (window->confirmation_dialog), - GTK_RESPONSE_OK); + object_class->dispose = empathy_call_window_dispose; + object_class->finalize = empathy_call_window_finalize; - button = gtk_dialog_add_button (GTK_DIALOG (window->confirmation_dialog), - _("_Reject"), GTK_RESPONSE_CANCEL); - image = gtk_image_new_from_icon_name (GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON); - gtk_button_set_image (GTK_BUTTON (button), image); - - button = gtk_dialog_add_button (GTK_DIALOG (window->confirmation_dialog), - _("_Answer"), GTK_RESPONSE_OK); - image = gtk_image_new_from_icon_name (GTK_STOCK_APPLY, GTK_ICON_SIZE_BUTTON); - gtk_button_set_image (GTK_BUTTON (button), image); - - g_signal_connect (window->confirmation_dialog, "response", - G_CALLBACK (call_window_confirmation_dialog_response_cb), - window); - - gtk_widget_show (window->confirmation_dialog); - g_object_unref (contact); } -static void -call_window_update (EmpathyCallWindow *window) +void +empathy_call_window_dispose (GObject *object) { - EmpathyContact *contact; - guint stream_state; - EmpathyTpCallStream *audio_stream; - EmpathyTpCallStream *video_stream; - gboolean is_incoming; - gchar *title; + EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (object); + EmpathyCallWindowPrivate *priv = EMPATHY_CALL_WINDOW_GET_PRIVATE (self); - if (window->call == NULL) + if (priv->dispose_has_run) return; - g_object_get (window->call, - "status", &window->status, - "audio-stream", &audio_stream, - "video-stream", &video_stream, - "contact", &contact, - "is-incoming", &is_incoming, - NULL); - - if (video_stream->state > audio_stream->state) - stream_state = video_stream->state; - else - stream_state = audio_stream->state; - - DEBUG ("Status changed - status: %d, stream state: %d, " - "is-incoming: %d video-stream direction: %d", - window->status, stream_state, is_incoming, video_stream->direction); - - if (empathy_tp_call_has_dtmf (window->call)) - { - gtk_widget_show (window->keypad_expander); - } - else - { - gtk_widget_hide (window->keypad_expander); - } + priv->dispose_has_run = TRUE; - /* Depending on the status we have to set: - * - window's title - * - status's label - * - sensibility of all buttons - * */ - if (window->status == EMPATHY_TP_CALL_STATUS_READYING) - { - gtk_window_set_title (GTK_WINDOW (window->window), _("Empathy Call")); - /* To translators: Readying is the first state of the call, it is - * preparing the connection and it does not yet ring. */ - gtk_label_set_text (GTK_LABEL (window->status_label), _("Readying")); - gtk_widget_set_sensitive (window->video_button, FALSE); - gtk_widget_set_sensitive (window->output_volume_button, FALSE); - gtk_widget_set_sensitive (window->input_volume_button, FALSE); - gtk_widget_set_sensitive (window->hang_up_button, FALSE); - gtk_widget_set_sensitive (window->keypad_expander, FALSE); - } - else if (window->status == EMPATHY_TP_CALL_STATUS_PENDING) - { - title = g_strdup_printf (_("%s - Empathy Call"), - empathy_contact_get_name (contact)); + /* release any references held by the object here */ - gtk_window_set_title (GTK_WINDOW (window->window), title); - gtk_label_set_text (GTK_LABEL (window->status_label), _("Ringing")); - gtk_widget_set_sensitive (window->hang_up_button, TRUE); - - if (is_incoming) - { - call_window_show_confirmation_dialog (window); - empathy_sound_play (GTK_WIDGET (window->window), - EMPATHY_SOUND_PHONE_INCOMING); - } - else - { - empathy_sound_play (GTK_WIDGET (window->window), - EMPATHY_SOUND_PHONE_OUTGOING); - } - } - else if (window->status == EMPATHY_TP_CALL_STATUS_ACCEPTED) - { - gboolean receiving_video; - gboolean sending_video; - - if (stream_state == TP_MEDIA_STREAM_STATE_DISCONNECTED) - gtk_label_set_text (GTK_LABEL (window->status_label), _("Disconnected")); - if (stream_state == TP_MEDIA_STREAM_STATE_CONNECTING) - gtk_label_set_text (GTK_LABEL (window->status_label), _("Connecting")); - else if (stream_state == TP_MEDIA_STREAM_STATE_CONNECTED && - window->timeout_event_id == 0) - { - /* The call started, launch the timer */ - g_get_current_time (&(window->start_time)); - window->timeout_event_id = g_timeout_add_seconds (1, - call_window_update_timer, window); - call_window_update_timer (window); - } - - receiving_video = video_stream->direction & TP_MEDIA_STREAM_DIRECTION_RECEIVE; - sending_video = video_stream->direction & TP_MEDIA_STREAM_DIRECTION_SEND; - call_window_set_output_video_is_drawing (window, receiving_video); - g_signal_handlers_block_by_func (window->video_button, - call_window_video_button_toggled_cb, window); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (window->video_button), - sending_video); - g_signal_handlers_unblock_by_func (window->video_button, - call_window_video_button_toggled_cb, window); - - gtk_widget_set_sensitive (window->video_button, TRUE); - gtk_widget_set_sensitive (window->output_volume_button, TRUE); - gtk_widget_set_sensitive (window->input_volume_button, TRUE); - gtk_widget_set_sensitive (window->hang_up_button, TRUE); - gtk_widget_set_sensitive (window->keypad_expander, TRUE); - } - else if (window->status == EMPATHY_TP_CALL_STATUS_CLOSED) - call_window_finalize (window); - - if (contact) - g_object_unref (contact); + if (G_OBJECT_CLASS (empathy_call_window_parent_class)->dispose) + G_OBJECT_CLASS (empathy_call_window_parent_class)->dispose (object); } -static gboolean -call_window_dtmf_button_release_event_cb (GtkWidget *widget, - GdkEventButton *event, - EmpathyCallWindow *window) +void +empathy_call_window_finalize (GObject *object) { - empathy_tp_call_stop_tone (window->call); - return FALSE; -} + //EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (object); + //EmpathyCallWindowPrivate *priv = EMPATHY_CALL_WINDOW_GET_PRIVATE (self); -static gboolean -call_window_dtmf_button_press_event_cb (GtkWidget *widget, - GdkEventButton *event, - EmpathyCallWindow *window) -{ - TpDTMFEvent dtmf_event; + /* free any data held directly by the object here */ - dtmf_event = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (widget), "code")); - empathy_tp_call_start_tone (window->call, dtmf_event); - return FALSE; + G_OBJECT_CLASS (empathy_call_window_parent_class)->finalize (object); } -static void -call_window_dtmf_connect (GladeXML *glade, - EmpathyCallWindow *window, - const gchar *name, - TpDTMFEvent event) -{ - GtkWidget *widget; - - widget = glade_xml_get_widget (glade, name); - g_object_set_data (G_OBJECT (widget), "code", GUINT_TO_POINTER (event)); - g_signal_connect (widget, "button-press-event", - G_CALLBACK (call_window_dtmf_button_press_event_cb), window); - g_signal_connect (widget, "button-release-event", - G_CALLBACK (call_window_dtmf_button_release_event_cb), window); - /* FIXME: Connect "key-[press/release]-event" to*/ -} -GtkWidget * -empathy_call_window_new (EmpathyTpCall *call) +EmpathyCallWindow * +empathy_call_window_new (EmpathyCallHandler *handler) { - EmpathyCallWindow *window; - GladeXML *glade; - gchar *filename; - const gchar *icons[] = {"audio-input-microphone", NULL}; - - g_return_val_if_fail (EMPATHY_IS_TP_CALL (call), NULL); - - if (windows) - { - window = (EmpathyCallWindow*) windows->data; - if (!window->call) - { - window->call = g_object_ref (call); - g_signal_connect_swapped (G_OBJECT (window->call), "notify", - G_CALLBACK (call_window_update), window); - call_window_update (window); - - if (GTK_WIDGET_REALIZED (GTK_WIDGET (window->preview_video_socket))) - { - call_window_socket_realized_cb (window->preview_video_socket, - window); - } - } - else - { - GtkWidget *dialog; - EmpathyContact *contact; - TpChannel *channel; - - g_object_get ( G_OBJECT (call), - "contact", &contact, - "channel", &channel, - NULL); - - empathy_contact_run_until_ready (contact, EMPATHY_CONTACT_READY_NAME, - NULL); - - /* We don't want to have multiple calls running. - * FIXME: We should use the hold interface... */ - tp_cli_channel_call_close (channel, -1, NULL, NULL, NULL, NULL); - - dialog = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_INFO, - GTK_BUTTONS_CLOSE, - _("Incoming call from %s rejected because there is already a" - " running call."), empathy_contact_get_name (contact)); - - g_object_unref (contact); - g_object_unref (channel); - - g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), - NULL); - gtk_widget_show (dialog); - } - - gtk_window_present (GTK_WINDOW (window->window)); - return window->window; - } - - window = g_slice_new0 (EmpathyCallWindow); - windows = g_slist_prepend (windows, window); - window->call = g_object_ref (call); - - filename = empathy_file_lookup ("empathy-call-window.glade", "src"); - glade = empathy_glade_get_file (filename, - "window", - NULL, - "window", &window->window, - "main_hbox", &window->main_hbox, - "controls_vbox", &window->controls_vbox, - "volume_hbox", &window->volume_hbox, - "status_label", &window->status_label, - "video_button", &window->video_button, - "hang_up_button", &window->hang_up_button, - "keypad_expander", &window->keypad_expander, - NULL); - g_free (filename); - - empathy_glade_connect (glade, - window, - "window", "destroy", call_window_destroy_cb, - "window", "delete_event", call_window_delete_event_cb, - "hang_up_button", "clicked", call_window_hang_up_button_clicked_cb, - "video_button", "toggled", call_window_video_button_toggled_cb, - NULL); - - /* Setup DTMF buttons */ - call_window_dtmf_connect (glade, window, "button_0", TP_DTMF_EVENT_DIGIT_0); - call_window_dtmf_connect (glade, window, "button_1", TP_DTMF_EVENT_DIGIT_1); - call_window_dtmf_connect (glade, window, "button_2", TP_DTMF_EVENT_DIGIT_2); - call_window_dtmf_connect (glade, window, "button_3", TP_DTMF_EVENT_DIGIT_3); - call_window_dtmf_connect (glade, window, "button_4", TP_DTMF_EVENT_DIGIT_4); - call_window_dtmf_connect (glade, window, "button_5", TP_DTMF_EVENT_DIGIT_5); - call_window_dtmf_connect (glade, window, "button_6", TP_DTMF_EVENT_DIGIT_6); - call_window_dtmf_connect (glade, window, "button_7", TP_DTMF_EVENT_DIGIT_7); - call_window_dtmf_connect (glade, window, "button_8", TP_DTMF_EVENT_DIGIT_8); - call_window_dtmf_connect (glade, window, "button_9", TP_DTMF_EVENT_DIGIT_9); - call_window_dtmf_connect (glade, window, "button_asterisk", TP_DTMF_EVENT_ASTERISK); - call_window_dtmf_connect (glade, window, "button_hash", TP_DTMF_EVENT_HASH); - - g_object_unref (glade); - - /* Output volume button */ - window->output_volume_button = gtk_volume_button_new (); - gtk_scale_button_set_value (GTK_SCALE_BUTTON (window->output_volume_button), 1); - gtk_box_pack_start (GTK_BOX (window->volume_hbox), - window->output_volume_button, FALSE, FALSE, 0); - gtk_widget_show (window->output_volume_button); - g_signal_connect (window->output_volume_button, "value-changed", - G_CALLBACK (call_window_output_volume_changed_cb), window); - - /* Input volume button */ - window->input_volume_button = gtk_volume_button_new (); - gtk_scale_button_set_icons (GTK_SCALE_BUTTON (window->input_volume_button), - icons); - gtk_scale_button_set_value (GTK_SCALE_BUTTON (window->input_volume_button), 1); - gtk_box_pack_start (GTK_BOX (window->volume_hbox), - window->input_volume_button, FALSE, FALSE, 0); - gtk_widget_show (window->input_volume_button); - g_signal_connect (window->input_volume_button, "value-changed", - G_CALLBACK (call_window_input_volume_changed_cb), window); - - /* Output video socket */ - window->output_video_socket = g_object_ref (gtk_socket_new ()); - gtk_widget_set_size_request (window->output_video_socket, 400, 300); - g_signal_connect (GTK_OBJECT (window->output_video_socket), "realize", - G_CALLBACK (call_window_socket_realized_cb), window); - gtk_widget_show (window->output_video_socket); - - /* Preview video socket */ - window->preview_video_socket = g_object_ref (gtk_socket_new ()); - gtk_widget_set_size_request (window->preview_video_socket, 176, 144); - g_signal_connect (GTK_OBJECT (window->preview_video_socket), "realize", - G_CALLBACK (call_window_socket_realized_cb), window); - gtk_widget_show (window->preview_video_socket); - - /* FIXME: We shouldn't do this if there is no video input */ - gtk_box_pack_start (GTK_BOX (window->controls_vbox), - window->preview_video_socket, FALSE, FALSE, 0); - gtk_box_reorder_child (GTK_BOX (window->controls_vbox), - window->preview_video_socket, 0); - - g_signal_connect_swapped (G_OBJECT (window->call), "notify", - G_CALLBACK (call_window_update), - window); - - call_window_update (window); - gtk_widget_show (window->window); - - return window->window; + return EMPATHY_CALL_WINDOW (g_object_new (EMPATHY_TYPE_CALL_WINDOW, NULL)); } - diff --git a/src/empathy-call-window.glade b/src/empathy-call-window.glade deleted file mode 100644 index 1fccc479..00000000 --- a/src/empathy-call-window.glade +++ /dev/null @@ -1,335 +0,0 @@ - - - - - - call - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 5 - 5 - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 6 - - - True - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - Send Video - 0 - True - - - False - False - - - - - True - 0 - GTK_SHADOW_NONE - - - True - - - - - - - - - - - True - <b>Volume</b> - True - - - label_item - - - - - False - False - 1 - - - - - True - True - - - True - 4 - 3 - True - - - True - True - # - True - 0 - - - 2 - 3 - 3 - 4 - - - - - - True - True - 0 - True - 0 - - - 1 - 2 - 3 - 4 - - - - - - True - True - * - True - 0 - - - 3 - 4 - - - - - - True - True - 9 - True - 0 - - - 2 - 3 - 2 - 3 - - - - - - True - True - 8 - True - 0 - - - 1 - 2 - 2 - 3 - - - - - - True - True - 7 - True - 0 - - - 2 - 3 - - - - - - True - True - 6 - True - 0 - - - 2 - 3 - 1 - 2 - - - - - - True - True - 5 - True - 0 - - - 1 - 2 - 1 - 2 - - - - - - True - True - 4 - True - 0 - - - 1 - 2 - - - - - - True - True - 3 - True - 0 - - - 2 - 3 - - - - - - True - True - 2 - True - 0 - - - 1 - 2 - - - - - - True - True - 1 - True - 0 - - - - - - - - - - True - <b>Keypad</b> - True - - - label_item - - - - - False - False - 2 - - - - - True - 0 - PANGO_ELLIPSIZE_END - - - False - False - GTK_PACK_END - 4 - - - - - True - True - True - 1 - - - True - 6 - - - True - gtk-cancel - - - False - False - - - - - True - Hang Up - - - False - False - 1 - - - - - - - False - False - GTK_PACK_END - 3 - - - - - False - False - - - - - - diff --git a/src/empathy-call-window.h b/src/empathy-call-window.h index eef1c9a9..26b0e788 100644 --- a/src/empathy-call-window.h +++ b/src/empathy-call-window.h @@ -1,7 +1,7 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* - * Copyright (C) 2007 Elliot Fairweather - * Copyright (C) 2007-2008 Collabora Ltd. + * empathy-call-window.h - Header for EmpathyCallWindow + * Copyright (C) 2008 Collabora Ltd. + * @author Sjoerd Simons * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -16,22 +16,50 @@ * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: Elliot Fairweather - * Xavier Claessens */ #ifndef __EMPATHY_CALL_WINDOW_H__ #define __EMPATHY_CALL_WINDOW_H__ +#include #include - -#include +#include G_BEGIN_DECLS -GtkWidget *empathy_call_window_new (EmpathyTpCall *call); +typedef struct _EmpathyCallWindow EmpathyCallWindow; +typedef struct _EmpathyCallWindowClass EmpathyCallWindowClass; + +struct _EmpathyCallWindowClass { + GtkWindowClass parent_class; +}; + +struct _EmpathyCallWindow { + GtkWindow parent; +}; + +GType empathy_call_window_get_type(void); + +/* TYPE MACROS */ +#define EMPATHY_TYPE_CALL_WINDOW \ + (empathy_call_window_get_type()) +#define EMPATHY_CALL_WINDOW(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj), EMPATHY_TYPE_CALL_WINDOW, \ + EmpathyCallWindow)) +#define EMPATHY_CALL_WINDOW_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST((klass), EMPATHY_TYPE_CALL_WINDOW, \ + EmpathyCallWindowClass)) +#define EMPATHY_IS_CALL_WINDOW(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE((obj), EMPATHY_TYPE_CALL_WINDOW)) +#define EMPATHY_IS_CALL_WINDOW_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE((klass), EMPATHY_TYPE_CALL_WINDOW)) +#define EMPATHY_CALL_WINDOW_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS ((obj), EMPATHY_TYPE_CALL_WINDOW, \ + EmpathyCallWindowClass)) + +EmpathyCallWindow * +empathy_call_window_new (EmpathyCallHandler *handler); G_END_DECLS -#endif /* __EMPATHY_CALL_WINDOW_H__ */ +#endif /* #ifndef __EMPATHY_CALL_WINDOW_H__*/ diff --git a/src/empathy.c b/src/empathy.c index dce92870..a7311ebe 100644 --- a/src/empathy.c +++ b/src/empathy.c @@ -40,6 +40,7 @@ #include #include +#include #include #include #include @@ -110,14 +111,10 @@ dispatch_cb (EmpathyDispatcher *dispatcher, empathy_dispatch_operation_claim (operation); } else if (channel_type == TP_IFACE_QUARK_CHANNEL_TYPE_STREAMED_MEDIA) { - EmpathyTpCall *call; + EmpathyCallFactory *factory; - call = EMPATHY_TP_CALL ( - empathy_dispatch_operation_get_channel_wrapper (operation)); - - empathy_dispatch_operation_claim (operation); - - empathy_call_window_new (call); + factory = empathy_call_factory_get (); + empathy_call_factory_claim_channel (factory, operation); } else if (channel_type == EMP_IFACE_QUARK_CHANNEL_TYPE_FILE_TRANSFER) { EmpathyFTManager *ft_manager; EmpathyTpFile *tp_file; @@ -397,6 +394,16 @@ show_version_cb (const char *option_name, return FALSE; } +static void +new_call_handler_cb (EmpathyCallFactory *factory, EmpathyCallHandler *handler, + gboolean outgoing, gpointer user_data) +{ + EmpathyCallWindow *window; + + window = empathy_call_window_new (handler); + gtk_widget_show (GTK_WIDGET (window)); +} + int main (int argc, char *argv[]) { @@ -404,6 +411,7 @@ main (int argc, char *argv[]) EmpathyStatusIcon *icon; EmpathyDispatcher *dispatcher; EmpathyChatroomManager *chatroom_manager; + EmpathyCallFactory *call_factory; GtkWidget *window; MissionControl *mc; EmpathyIdle *idle; @@ -543,6 +551,10 @@ main (int argc, char *argv[]) empathy_chatroom_manager_observe (chatroom_manager, dispatcher); notify_init (_(PACKAGE_NAME)); + /* Create the call factory */ + call_factory = empathy_call_factory_initialise (); + g_signal_connect (G_OBJECT (call_factory), "new-call-handler", + G_CALLBACK (new_call_handler_cb), NULL); gtk_main ();