]> git.0d.be Git - empathy.git/commitdiff
Redefine size_request and size_allocation on EmpathyChatClass
authorXavier Claessens <xclaesse@src.gnome.org>
Wed, 2 Apr 2008 09:42:13 +0000 (09:42 +0000)
committerXavier Claessens <xclaesse@src.gnome.org>
Wed, 2 Apr 2008 09:42:13 +0000 (09:42 +0000)
svn path=/trunk/; revision=850

libempathy-gtk/empathy-chat.c
libempathy-gtk/empathy-chat.glade
src/empathy-chat-window.c

index 7079775cf0eead5049e3a31e2b5479f074a9e537..5533541ff65ce24e488e865245ad6e2c19b26a99 100644 (file)
@@ -1266,6 +1266,46 @@ chat_create_ui (EmpathyChat *chat)
        gtk_container_add (GTK_CONTAINER (chat), priv->widget);
 }
 
+static void
+chat_size_request (GtkWidget      *widget,
+                  GtkRequisition *requisition)
+{
+  GtkBin *bin = GTK_BIN (widget);
+
+  requisition->width = GTK_CONTAINER (widget)->border_width * 2;
+  requisition->height = GTK_CONTAINER (widget)->border_width * 2;
+
+  if (bin->child && GTK_WIDGET_VISIBLE (bin->child))
+    {
+      GtkRequisition child_requisition;
+      
+      gtk_widget_size_request (bin->child, &child_requisition);
+
+      requisition->width += child_requisition.width;
+      requisition->height += child_requisition.height;
+    }
+}
+
+static void
+chat_size_allocate (GtkWidget     *widget,
+                   GtkAllocation *allocation)
+{
+  GtkBin *bin = GTK_BIN (widget);
+  GtkAllocation child_allocation;
+  
+  widget->allocation = *allocation;
+
+  if (bin->child && GTK_WIDGET_VISIBLE (bin->child))
+    {
+      child_allocation.x = allocation->x + GTK_CONTAINER (widget)->border_width;
+      child_allocation.y = allocation->y + GTK_CONTAINER (widget)->border_width;
+      child_allocation.width = MAX (allocation->width - GTK_CONTAINER (widget)->border_width * 2, 0);
+      child_allocation.height = MAX (allocation->height - GTK_CONTAINER (widget)->border_width * 2, 0);
+
+      gtk_widget_size_allocate (bin->child, &child_allocation);
+    }
+}
+
 static void
 chat_finalize (GObject *object)
 {
@@ -1294,7 +1334,6 @@ chat_finalize (GObject *object)
        g_object_unref (priv->mc);
        g_object_unref (priv->log_manager);
 
-
        if (priv->tp_chat) {
                g_object_unref (priv->tp_chat);
        }
@@ -1323,15 +1362,17 @@ chat_constructed (GObject *object)
 static void
 empathy_chat_class_init (EmpathyChatClass *klass)
 {
-       GObjectClass *object_class;
-
-       object_class = G_OBJECT_CLASS (klass);
+       GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+       GObjectClass   *object_class = G_OBJECT_CLASS (klass);
 
        object_class->finalize = chat_finalize;
        object_class->get_property = chat_get_property;
        object_class->set_property = chat_set_property;
        object_class->constructed = chat_constructed;
 
+       widget_class->size_request = chat_size_request;
+       widget_class->size_allocate = chat_size_allocate;
+
        g_object_class_install_property (object_class,
                                         PROP_TP_CHAT,
                                         g_param_spec_object ("tp-chat",
@@ -1396,7 +1437,7 @@ static void
 empathy_chat_init (EmpathyChat *chat)
 {
        EmpathyChatPriv *priv = GET_PRIV (chat);
-       GtkTextBuffer  *buffer;
+       GtkTextBuffer   *buffer;
 
        chat_create_ui (chat);
 
index 0a801adc02170a7897c8ce31c394ae9a2ad475f3..9428474b5f20ebe15ec441ffe06afaa2f80d7d73 100644 (file)
@@ -3,6 +3,7 @@
 <!--*- mode: xml -*-->
 <glade-interface>
   <widget class="GtkWindow" id="chat_window">
+    <property name="visible">True</property>
     <property name="border_width">6</property>
     <property name="title" translatable="yes">Group Chat</property>
     <property name="icon_name">system-users</property>
index 6dd55cbae8b39ab2fe0554f5323fa340deff0ba4..7e4d1d1ccb5a8a8ad48bc9eb5d2861c197bdfb88 100644 (file)
@@ -1399,6 +1399,7 @@ empathy_chat_window_add_chat (EmpathyChatWindow *window,
 
        child = GTK_WIDGET (chat);
        label = chat_window_create_label (window, chat); 
+       gtk_widget_show (child);
 
        g_signal_connect (chat, "notify::name",
                          G_CALLBACK (chat_window_chat_notify_cb),
@@ -1416,7 +1417,6 @@ empathy_chat_window_add_chat (EmpathyChatWindow *window,
        gtk_notebook_set_tab_detachable (GTK_NOTEBOOK (priv->notebook), child, TRUE);
        gtk_notebook_set_tab_label_packing (GTK_NOTEBOOK (priv->notebook), child,
                                            TRUE, TRUE, GTK_PACK_START); 
-       gtk_widget_show (child);
 
        empathy_debug (DEBUG_DOMAIN, 
                      "Chat added (%d references)",