]> git.0d.be Git - empathy.git/blobdiff - src/empathy-call-window.c
Add an empty expanded GtkToolItem so the volume button is at the end of the toolbar.
[empathy.git] / src / empathy-call-window.c
index 4911f03737de6a4907a34976a4fee0246b4428f4..d39a333d897efe6cb3ff96ac4f9286d8ad521632 100644 (file)
@@ -26,6 +26,7 @@
 #include <gtk/gtk.h>
 #include <glib/gi18n.h>
 
+#include <telepathy-farsight/channel.h>
 
 #include <libempathy/empathy-utils.h>
 #include <libempathy-gtk/empathy-video-widget.h>
@@ -66,6 +67,7 @@ struct _EmpathyCallWindowPriv
   GtkWidget *video_preview;
   GtkWidget *sidebar;
   GtkWidget *sidebar_button;
+  GtkWidget *statusbar;
 
   GstElement *video_input;
   GstElement *audio_input;
@@ -74,6 +76,7 @@ struct _EmpathyCallWindowPriv
   GstElement *video_tee;
 
   GladeXML *glade;
+  guint context_id;
 };
 
 #define GET_PRIV(o) \
@@ -89,11 +92,17 @@ static gboolean empathy_call_window_delete_cb (GtkWidget *widget,
 static void empathy_call_window_sidebar_toggled_cb (GtkToggleButton *toggle,
   EmpathyCallWindow *window);
 
+static void empathy_call_window_camera_toggled_cb (GtkToggleToolButton *toggle,
+  EmpathyCallWindow *window);
+
 static void empathy_call_window_sidebar_hidden_cb (EmpathySidebar *sidebar,
   EmpathyCallWindow *window);
 
 static void empathy_call_window_hangup (EmpathyCallWindow *window);
 
+static void empathy_call_window_status_message (EmpathyCallWindow *window,
+  gchar *message);
+
 static void
 empathy_call_window_setup_menubar (EmpathyCallWindow *self)
 {
@@ -111,9 +120,10 @@ empathy_call_window_setup_toolbar (EmpathyCallWindow *self)
   EmpathyCallWindowPriv *priv = GET_PRIV (self);
   GtkWidget *hangup;
   GtkWidget *mic;
-  GtkWidget *volume;
   GtkWidget *volume_button;
   GtkWidget *camera;
+  GtkWidget *toolbar;
+  GtkToolItem *tool_item;
 
   hangup = glade_xml_get_widget (priv->glade, "hangup");
 
@@ -123,13 +133,27 @@ empathy_call_window_setup_toolbar (EmpathyCallWindow *self)
   mic = glade_xml_get_widget (priv->glade, "microphone");
   gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (mic), TRUE);
 
-  volume = glade_xml_get_widget (priv->glade, "volume");
+  toolbar = glade_xml_get_widget (priv->glade, "toolbar1");
+
+  /* Add an empty expanded GtkToolItem so the volume button is at the end of
+   * the toolbar. */
+  tool_item = gtk_tool_item_new ();
+  gtk_tool_item_set_expand (tool_item, TRUE);
+  gtk_widget_show (GTK_WIDGET (tool_item));
+  gtk_toolbar_insert (GTK_TOOLBAR (toolbar), tool_item, -1);
+
+  tool_item = gtk_tool_item_new ();
   volume_button = gtk_volume_button_new ();
-  gtk_container_add (GTK_CONTAINER (volume), volume_button);
+  gtk_container_add (GTK_CONTAINER (tool_item), volume_button);
   gtk_scale_button_set_value (GTK_SCALE_BUTTON (volume_button), 0.5);
+  gtk_widget_show_all (GTK_WIDGET (tool_item));
+  gtk_toolbar_insert (GTK_TOOLBAR (toolbar), tool_item, -1);
 
   camera = glade_xml_get_widget (priv->glade, "camera");
   gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (camera), FALSE);
+
+  g_signal_connect (G_OBJECT (camera), "toggled",
+    G_CALLBACK (empathy_call_window_camera_toggled_cb), self);
 }
 
 static GtkWidget *
@@ -225,6 +249,7 @@ empathy_call_window_init (EmpathyCallWindow *self)
   priv->glade = empathy_glade_get_file (filename, "call_window", NULL,
     "call_window_vbox", &top_vbox,
     "pane", &pane,
+    "statusbar", &priv->statusbar,
     NULL);
 
   gtk_widget_reparent (top_vbox, GTK_WIDGET (self));
@@ -235,6 +260,7 @@ empathy_call_window_init (EmpathyCallWindow *self)
   priv->pipeline = gst_pipeline_new (NULL);
 
   hbox = gtk_hbox_new (FALSE, 3);
+  gtk_container_set_border_width (GTK_CONTAINER (hbox), 6);
   gtk_paned_pack1 (GTK_PANED(pane), hbox, TRUE, FALSE);
 
   bus = gst_pipeline_get_bus (GST_PIPELINE (priv->pipeline));
@@ -250,7 +276,7 @@ empathy_call_window_init (EmpathyCallWindow *self)
   gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 3);
 
   priv->video_preview = empathy_video_widget_new_with_size (bus, 160, 120);
-  gtk_box_pack_start (GTK_BOX (vbox), priv->video_preview, FALSE, FALSE, 3);
+  gtk_box_pack_start (GTK_BOX (vbox), priv->video_preview, FALSE, FALSE, 0);
 
   priv->video_input = empathy_video_src_new ();
   gst_object_ref (priv->video_input);
@@ -284,7 +310,7 @@ empathy_call_window_init (EmpathyCallWindow *self)
   gtk_paned_pack2 (GTK_PANED(pane), priv->sidebar, FALSE, FALSE);
 
   page = empathy_call_window_create_dtmf (self);
-  empathy_sidebar_add_page (EMPATHY_SIDEBAR (priv->sidebar), _("Dailpad"),
+  empathy_sidebar_add_page (EMPATHY_SIDEBAR (priv->sidebar), _("Dialpad"),
     page);
 
   page = empathy_call_window_create_audio_input (self);
@@ -304,6 +330,8 @@ empathy_call_window_init (EmpathyCallWindow *self)
 
   g_signal_connect (G_OBJECT (self), "delete-event",
     G_CALLBACK (empathy_call_window_delete_cb), self);
+
+  empathy_call_window_status_message (self, _("Connecting..."));
 }
 
 static void empathy_call_window_dispose (GObject *object);
@@ -436,8 +464,14 @@ empathy_call_window_conference_added_cb (EmpathyCallHandler *handler,
   gst_bin_add (GST_BIN (priv->pipeline), conference);
 
   gst_element_set_state (conference, GST_STATE_PLAYING);
+}
+
+static void
+empathy_call_window_channel_closed_cb (TfChannel *channel, gpointer user_data)
+{
+  EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
 
-  printf ("ADDING CONFERENCE\n");
+  empathy_call_window_status_message (self, _("Disconnected"));
 }
 
 static void
@@ -449,8 +483,11 @@ empathy_call_window_src_added_cb (EmpathyCallHandler *handler,
 
   GstPad *pad;
   GstElement *element;
+  gchar *str;
 
-  printf ("ADDING SRC PAD %d\n", media_type);
+  str = g_strdup_printf (_("Connected -- %d:%02dm"), 0, 0);
+  empathy_call_window_status_message (self, str);
+  g_free (str);
 
   switch (media_type)
     {
@@ -473,6 +510,8 @@ empathy_call_window_src_added_cb (EmpathyCallHandler *handler,
   gst_element_set_state (element, GST_STATE_PLAYING);
 
   gst_pad_link (src, pad);
+
+  gst_object_unref (pad);
 }
 
 static void
@@ -483,8 +522,6 @@ empathy_call_window_sink_added_cb (EmpathyCallHandler *handler,
   EmpathyCallWindowPriv *priv = GET_PRIV (self);
   GstPad *pad;
 
-  printf ("ADDING SINK PAD %d\n", media_type);
-
   switch (media_type)
     {
       case TP_MEDIA_STREAM_TYPE_AUDIO:
@@ -513,6 +550,8 @@ empathy_call_window_realized_cb (GtkWidget *widget, EmpathyCallWindow *window)
 
   g_signal_connect (priv->handler, "conference-added",
     G_CALLBACK (empathy_call_window_conference_added_cb), window);
+  g_signal_connect (priv->handler, "closed",
+    G_CALLBACK (empathy_call_window_channel_closed_cb), window);
   g_signal_connect (priv->handler, "src-pad-added",
     G_CALLBACK (empathy_call_window_src_added_cb), window);
   g_signal_connect (priv->handler, "sink-pad-added",
@@ -567,6 +606,23 @@ empathy_call_window_sidebar_toggled_cb (GtkToggleButton *toggle,
   gtk_button_set_image (GTK_BUTTON (priv->sidebar_button), arrow);
 }
 
+static void
+empathy_call_window_camera_toggled_cb (GtkToggleToolButton *toggle,
+  EmpathyCallWindow *window)
+{
+  EmpathyCallWindowPriv *priv = GET_PRIV (window);
+  gboolean active;
+  EmpathyTpCall *call;
+
+  active = (gtk_toggle_tool_button_get_active (toggle));
+
+  g_object_get (priv->handler, "tp-call", &call, NULL);
+
+  empathy_tp_call_request_video_stream_direction (call, active);
+
+  g_object_unref (call);
+}
+
 static void
 empathy_call_window_sidebar_hidden_cb (EmpathySidebar *sidebar,
   EmpathyCallWindow *window)
@@ -585,3 +641,23 @@ empathy_call_window_hangup (EmpathyCallWindow *window)
   gst_element_set_state (priv->pipeline, GST_STATE_NULL);
   gtk_widget_destroy (GTK_WIDGET (window));
 }
+
+static void
+empathy_call_window_status_message (EmpathyCallWindow *window,
+  gchar *message)
+{
+  EmpathyCallWindowPriv *priv = GET_PRIV (window);
+
+  if (priv->context_id == 0)
+    {
+      priv->context_id = gtk_statusbar_get_context_id (
+        GTK_STATUSBAR (priv->statusbar), "voip call status messages");
+    }
+  else
+    {
+      gtk_statusbar_pop (GTK_STATUSBAR (priv->statusbar), priv->context_id);
+    }
+
+  gtk_statusbar_push (GTK_STATUSBAR (priv->statusbar), priv->context_id,
+    message);
+}