]> git.0d.be Git - empathy.git/commitdiff
EmpathyChat: inherit from a GtkBox instead of a GtkBin
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Tue, 21 Jun 2011 09:19:00 +0000 (11:19 +0200)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Tue, 21 Jun 2011 09:19:00 +0000 (11:19 +0200)
This allows us to get rid of the size_allocate method.

libempathy-gtk/empathy-chat.c
libempathy-gtk/empathy-chat.h

index ecf849aafaa3133dfab681cf3eeb022aa60d0b0f..bb33130e37a1d8f1c5faaa652e8d42288495497f 100644 (file)
@@ -180,7 +180,7 @@ enum {
 
 static guint signals[LAST_SIGNAL] = { 0 };
 
-G_DEFINE_TYPE (EmpathyChat, empathy_chat, GTK_TYPE_BIN);
+G_DEFINE_TYPE (EmpathyChat, empathy_chat, GTK_TYPE_BOX);
 
 static gboolean update_misspelled_words (gpointer data);
 
@@ -2941,33 +2941,10 @@ chat_create_ui (EmpathyChat *chat)
        g_list_free (list);
 
        /* Add the main widget in the chat widget */
-       gtk_container_add (GTK_CONTAINER (chat), priv->widget);
+       gtk_box_pack_start (GTK_BOX (chat), priv->widget, TRUE, TRUE, 0);
        g_object_unref (gui);
 }
 
-static void
-chat_size_allocate (GtkWidget     *widget,
-                   GtkAllocation *allocation)
-{
-  GtkBin *bin = GTK_BIN (widget);
-  GtkAllocation child_allocation;
-  GtkWidget *child;
-
-  gtk_widget_set_allocation (widget, allocation);
-
-  child = gtk_bin_get_child (bin);
-
-  if (child && gtk_widget_get_visible (child))
-    {
-      child_allocation.x = allocation->x + gtk_container_get_border_width (GTK_CONTAINER (widget));
-      child_allocation.y = allocation->y + gtk_container_get_border_width (GTK_CONTAINER (widget));
-      child_allocation.width = MAX (allocation->width - gtk_container_get_border_width (GTK_CONTAINER (widget)) * 2, 0);
-      child_allocation.height = MAX (allocation->height - gtk_container_get_border_width (GTK_CONTAINER (widget)) * 2, 0);
-
-      gtk_widget_size_allocate (child, &child_allocation);
-    }
-}
-
 static void
 chat_finalize (GObject *object)
 {
@@ -3058,7 +3035,6 @@ chat_constructed (GObject *object)
 static void
 empathy_chat_class_init (EmpathyChatClass *klass)
 {
-       GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
        GObjectClass   *object_class = G_OBJECT_CLASS (klass);
 
        object_class->finalize = chat_finalize;
@@ -3066,8 +3042,6 @@ empathy_chat_class_init (EmpathyChatClass *klass)
        object_class->set_property = chat_set_property;
        object_class->constructed = chat_constructed;
 
-       widget_class->size_allocate = chat_size_allocate;
-
        g_object_class_install_property (object_class,
                                         PROP_TP_CHAT,
                                         g_param_spec_object ("tp-chat",
index 4b0540b2021c338f11211750df332e56e0743eeb..0031410d65006a931f33dbe8f4af8b9f694b7456 100644 (file)
@@ -50,7 +50,7 @@ typedef struct _EmpathyChatClass  EmpathyChatClass;
 typedef struct _EmpathyChatPriv   EmpathyChatPriv;
 
 struct _EmpathyChat {
-       GtkBin parent;
+       GtkBox parent;
        EmpathyChatPriv *priv;
 
        /* Protected */
@@ -59,7 +59,7 @@ struct _EmpathyChat {
 };
 
 struct _EmpathyChatClass {
-       GtkBinClass parent;
+       GtkBoxClass parent;
 };
 
 GType              empathy_chat_get_type             (void);