[empathy] EmpathySearchBar: inherit from a GtkBox instead of a GtkBin



commit b95223f0d32b6c8424341bf0c406e4422c831de6
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date:   Tue Jun 21 12:01:47 2011 +0200

    EmpathySearchBar: inherit from a GtkBox instead of a GtkBin

 libempathy-gtk/empathy-search-bar.c |   48 +---------------------------------
 libempathy-gtk/empathy-search-bar.h |    4 +-
 2 files changed, 4 insertions(+), 48 deletions(-)
---
diff --git a/libempathy-gtk/empathy-search-bar.c b/libempathy-gtk/empathy-search-bar.c
index fe5f167..d23380d 100644
--- a/libempathy-gtk/empathy-search-bar.c
+++ b/libempathy-gtk/empathy-search-bar.c
@@ -33,7 +33,7 @@
 
 #define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathySearchBar)
 
-G_DEFINE_TYPE (EmpathySearchBar, empathy_search_bar, GTK_TYPE_BIN);
+G_DEFINE_TYPE (EmpathySearchBar, empathy_search_bar, GTK_TYPE_BOX);
 
 typedef struct _EmpathySearchBarPriv EmpathySearchBarPriv;
 struct _EmpathySearchBarPriv
@@ -63,45 +63,6 @@ empathy_search_bar_new (EmpathyChatView *view)
 }
 
 static void
-empathy_search_bar_get_preferred_height (GtkWidget *widget,
-    gint *minimun_height,
-    gint *natural_height)
-{
-  GtkBin *bin;
-  GtkWidget *child;
-
-  bin = GTK_BIN (widget);
-  child = gtk_bin_get_child (bin);
-
-  if (child && gtk_widget_get_visible (child))
-      gtk_widget_get_preferred_height (child, minimun_height, natural_height);
-}
-
-static void
-empathy_search_bar_size_allocate (GtkWidget *widget,
-    GtkAllocation *allocation)
-{
-  GtkBin *bin;
-  GtkWidget *child;
-  GtkAllocation child_allocation;
-
-  bin = GTK_BIN (widget);
-  child = gtk_bin_get_child (bin);
-
-  gtk_widget_set_allocation (widget, allocation);
-
-  if (child && gtk_widget_get_visible (child))
-    {
-      child_allocation.x = allocation->x;
-      child_allocation.y = allocation->y;
-      child_allocation.width = MAX (allocation->width, 0);
-      child_allocation.height = MAX (allocation->height, 0);
-
-      gtk_widget_size_allocate (child, &child_allocation);
-    }
-}
-
-static void
 empathy_search_bar_update_buttons (EmpathySearchBar *self,
     gchar *search,
     gboolean match_case)
@@ -332,7 +293,7 @@ empathy_search_bar_init (EmpathySearchBar * self)
   g_signal_connect (G_OBJECT (self), "key-press-event",
       G_CALLBACK (empathy_search_bar_key_pressed), NULL);
 
-  gtk_container_add (GTK_CONTAINER (self), internal);
+  gtk_box_pack_start (GTK_BOX (self), internal, TRUE, TRUE, 0);
   gtk_widget_show_all (internal);
   gtk_widget_hide (priv->search_not_found);
   g_object_unref (gui);
@@ -342,13 +303,8 @@ static void
 empathy_search_bar_class_init (EmpathySearchBarClass *class)
 {
   GObjectClass *gobject_class = G_OBJECT_CLASS (class);
-  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
 
   g_type_class_add_private (gobject_class, sizeof (EmpathySearchBarPriv));
-
-  /* Neither GtkBin nor GtkContainer seems to do this for us :( */
-  widget_class->get_preferred_height = empathy_search_bar_get_preferred_height;
-  widget_class->size_allocate = empathy_search_bar_size_allocate;
 }
 
 void
diff --git a/libempathy-gtk/empathy-search-bar.h b/libempathy-gtk/empathy-search-bar.h
index 2e4e0d7..4b07f92 100644
--- a/libempathy-gtk/empathy-search-bar.h
+++ b/libempathy-gtk/empathy-search-bar.h
@@ -44,7 +44,7 @@ typedef struct _EmpathySearchBarClass EmpathySearchBarClass;
 
 struct _EmpathySearchBar
 {
-  GtkBin parent;
+  GtkBox parent;
 
   /*<private>*/
   gpointer priv;
@@ -52,7 +52,7 @@ struct _EmpathySearchBar
 
 struct _EmpathySearchBarClass
 {
-  GtkBinClass parent_class;
+  GtkBoxClass parent_class;
 };
 
 GType       empathy_search_bar_get_type (void) G_GNUC_CONST;



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