]> git.0d.be Git - empathy.git/commitdiff
CallWindow: add an avatar to the top toolbar
authorEmilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>
Fri, 22 Jul 2011 15:34:52 +0000 (16:34 +0100)
committerEmilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>
Thu, 28 Jul 2011 08:00:38 +0000 (09:00 +0100)
src/empathy-call-window.c

index d8daf2997596d2a25f851bd297a675a78355f85a..9e1a47e456145258e806272b381a1f673465699f 100644 (file)
@@ -74,6 +74,8 @@
 #define REMOTE_CONTACT_AVATAR_DEFAULT_HEIGHT \
   EMPATHY_VIDEO_WIDGET_DEFAULT_HEIGHT
 
+#define SMALL_TOOLBAR_SIZE 36
+
 /* If an video input error occurs, the error message will start with "v4l" */
 #define VIDEO_INPUT_ERROR_PREFIX "v4l"
 
@@ -120,6 +122,7 @@ struct _EmpathyCallWindowPriv
   ClutterActor *preview_hidden_button;
   GtkWidget *video_container;
   GtkWidget *remote_user_avatar_widget;
+  GtkWidget *remote_user_avatar_toolbar;
   GtkWidget *sidebar;
   GtkWidget *volume_item;
   GtkWidget *status_label;
@@ -291,6 +294,20 @@ empathy_call_window_setup_toolbars (EmpathyCallWindow *self)
   GtkWidget *volume_button;
   GtkToolItem *tool_item;
 
+  /* Add an empty expanded GtkToolItem to the top 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 (priv->toolbar), tool_item, 0);
+
+  /* Set the remote avatar */
+  tool_item = gtk_tool_item_new ();
+  priv->remote_user_avatar_toolbar = gtk_image_new ();
+  gtk_container_add (GTK_CONTAINER (tool_item),
+      priv->remote_user_avatar_toolbar);
+  gtk_widget_show_all (GTK_WIDGET (tool_item));
+  gtk_toolbar_insert (GTK_TOOLBAR (priv->toolbar), tool_item, 0);
+
   /* Set the volume button */
   volume_button = gtk_volume_button_new ();
   /* FIXME listen to the audiosinks signals and update the button according to
@@ -1230,10 +1247,14 @@ contact_name_changed_cb (EmpathyContact *contact,
 
 static void
 contact_avatar_changed_cb (EmpathyContact *contact,
-    GParamSpec *pspec, GtkWidget *avatar_widget)
+    GParamSpec *pspec,
+    EmpathyCallWindow *self)
 {
   int size;
   GtkAllocation allocation;
+  GtkWidget *avatar_widget;
+
+  avatar_widget = self->priv->remote_user_avatar_widget;
 
   gtk_widget_get_allocation (avatar_widget, &allocation);
   size = allocation.height;
@@ -1246,6 +1267,19 @@ contact_avatar_changed_cb (EmpathyContact *contact,
     }
 
   init_contact_avatar_with_size (contact, avatar_widget, size);
+
+  avatar_widget = self->priv->remote_user_avatar_toolbar;
+
+  gtk_widget_get_allocation (avatar_widget, &allocation);
+  size = allocation.height;
+
+  if (size == 0)
+    {
+      /* the widget is not allocated yet, set a default size */
+      size = SMALL_TOOLBAR_SIZE;
+    }
+
+  init_contact_avatar_with_size (contact, avatar_widget, size);
 }
 
 static void
@@ -1257,8 +1291,7 @@ empathy_call_window_setup_avatars (EmpathyCallWindow *self,
   g_signal_connect (priv->contact, "notify::name",
       G_CALLBACK (contact_name_changed_cb), self);
   g_signal_connect (priv->contact, "notify::avatar",
-    G_CALLBACK (contact_avatar_changed_cb),
-    priv->remote_user_avatar_widget);
+    G_CALLBACK (contact_avatar_changed_cb), self);
 
   set_window_title (self);
 
@@ -1267,6 +1300,10 @@ empathy_call_window_setup_avatars (EmpathyCallWindow *self,
       MIN (REMOTE_CONTACT_AVATAR_DEFAULT_WIDTH,
           REMOTE_CONTACT_AVATAR_DEFAULT_HEIGHT));
 
+  init_contact_avatar_with_size (priv->contact,
+      priv->remote_user_avatar_toolbar,
+      SMALL_TOOLBAR_SIZE);
+
   /* The remote avatar is shown by default and will be hidden when we receive
      video from the remote side. */
   clutter_actor_hide (priv->video_output);