[gnome-chat] embed: Set the presence icon and message in the status area



commit 2e35e9f5d73d54c48f4661fde97f16c05da4ea28
Author: Debarshi Ray <debarshir gnome org>
Date:   Wed Sep 11 15:01:05 2013 +0200

    embed: Set the presence icon and message in the status area

 src/chat-embed.c  |   17 +++++++++++++++++
 src/chat-embed.ui |   47 ++++++++++++++++++++++++++++++++++++++++++-----
 2 files changed, 59 insertions(+), 5 deletions(-)
---
diff --git a/src/chat-embed.c b/src/chat-embed.c
index d6e3eb2..9e81edc 100644
--- a/src/chat-embed.c
+++ b/src/chat-embed.c
@@ -29,6 +29,8 @@
 #include "chat-conversations-list.h"
 #include "chat-embed.h"
 #include "chat-main-toolbar.h"
+#include "empathy-ui-utils.h"
+#include "empathy-utils.h"
 #include "polari-fixed-size-frame.h"
 
 
@@ -44,6 +46,8 @@ struct _ChatEmbedPrivate
   GtkWidget *sidebar_frame;
   GtkWidget *status_area;
   GtkWidget *status_area_label;
+  GtkWidget *status_area_presence_icon;
+  GtkWidget *status_area_presence_message;
   GtkWidget *toolbar;
   TplLogManager *lm;
 };
@@ -117,11 +121,14 @@ chat_embed_row_activated (ChatEmbed *self, GtkListBoxRow *row)
   ChatEmbedPrivate *priv = self->priv;
   GtkWidget *sw;
   TpAccount *account;
+  TpConnectionPresenceType presence;
   TpContact *contact;
   TplEntity *entity;
+  const gchar *icon_name;
   const gchar *identifier;
   const gchar *nickname;
   gchar *markup = NULL;
+  gchar *status_message = NULL;
 
   contact = g_object_get_data (G_OBJECT (row), "chat-conversations-list-contact");
   account = tp_contact_get_account (contact);
@@ -130,6 +137,13 @@ chat_embed_row_activated (ChatEmbed *self, GtkListBoxRow *row)
   markup = g_markup_printf_escaped ("<b>%s</b>", nickname);
   gtk_label_set_markup (GTK_LABEL (priv->status_area_label), markup);
 
+  presence = tp_account_get_current_presence (account, NULL, &status_message);
+  if (status_message == NULL)
+    status_message = g_strdup (empathy_presence_get_default_message (presence));
+  icon_name = empathy_icon_name_for_presence (presence);
+  gtk_image_set_from_icon_name (GTK_IMAGE (priv->status_area_presence_icon), icon_name, GTK_ICON_SIZE_MENU);
+  gtk_label_set_label (GTK_LABEL (priv->status_area_presence_message), status_message);
+
   identifier = tp_contact_get_identifier (contact);
   priv->current_view = g_hash_table_lookup (priv->conversations, identifier);
   if (priv->current_view != NULL)
@@ -165,6 +179,7 @@ chat_embed_row_activated (ChatEmbed *self, GtkListBoxRow *row)
  out:
   gtk_stack_set_visible_child_name (GTK_STACK (priv->conversations_stack), identifier);
   g_free (markup);
+  g_free (status_message);
 }
 
 
@@ -247,6 +262,8 @@ chat_embed_class_init (ChatEmbedClass *class)
   gtk_widget_class_bind_template_child_private (widget_class, ChatEmbed, sidebar_frame);
   gtk_widget_class_bind_template_child_private (widget_class, ChatEmbed, status_area);
   gtk_widget_class_bind_template_child_private (widget_class, ChatEmbed, status_area_label);
+  gtk_widget_class_bind_template_child_private (widget_class, ChatEmbed, status_area_presence_icon);
+  gtk_widget_class_bind_template_child_private (widget_class, ChatEmbed, status_area_presence_message);
 }
 
 
diff --git a/src/chat-embed.ui b/src/chat-embed.ui
index 00d8e4b..8c7d277 100644
--- a/src/chat-embed.ui
+++ b/src/chat-embed.ui
@@ -55,14 +55,51 @@
                         <property name="vexpand">False</property>
                         <property name="visible">True</property>
                         <child>
-                          <object class="GtkLabel" id="status_area_label">
+                          <object class="GtkGrid" id="status_area_grid1">
                             <property name="can_focus">False</property>
-                            <property name="ellipsize">end</property>
-                            <property name="halign">start</property>
                             <property name="hexpand">True</property>
-                            <property name="valign">center</property>
-                            <property name="vexpand">True</property>
+                            <property name="orientation">vertical</property>
+                            <property name="vexpand">False</property>
                             <property name="visible">True</property>
+                            <child>
+                              <object class="GtkLabel" id="status_area_label">
+                                <property name="can_focus">False</property>
+                                <property name="ellipsize">end</property>
+                                <property name="halign">start</property>
+                                <property name="hexpand">True</property>
+                                <property name="valign">center</property>
+                                <property name="vexpand">True</property>
+                                <property name="visible">True</property>
+                              </object>
+                            </child>
+                            <child>
+                              <object class="GtkGrid" id="status_area_grid2">
+                                <property name="can_focus">False</property>
+                                <property name="column_spacing">3</property>
+                                <property name="hexpand">True</property>
+                                <property name="orientation">horizontal</property>
+                                <property name="vexpand">False</property>
+                                <property name="visible">True</property>
+                                <child>
+                                  <object class="GtkImage" id="status_area_presence_icon">
+                                    <property name="can_focus">False</property>
+                                    <property name="icon_size">1</property>
+                                    <property name="visible">True</property>
+                                  </object>
+                                </child>
+                                <child>
+                                  <object class="GtkLabel" id="status_area_presence_message">
+                                    <property name="can_focus">False</property>
+                                    <property name="ellipsize">end</property>
+                                    <property name="halign">start</property>
+                                    <property name="hexpand">True</property>
+                                    <property name="valign">center</property>
+                                    <property name="vexpand">True</property>
+                                    <property name="visible">True</property>
+                                  </object>
+                                </child>
+                              </object>
+                            </child>
                           </object>
                         </child>
                       </object>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]