diff options
author | Thomas Wood <thomas.wood@intel.com> | 2010-07-06 14:13:26 +0100 |
---|---|---|
committer | Thomas Wood <thomas.wood@intel.com> | 2010-07-06 17:20:53 +0100 |
commit | 3d9ada13f0e771ad8a4faf42b6c3f8779d94484f (patch) | |
tree | 9e3d60a4486a47d826c276502e86770422b12a73 | |
parent | 59920f88a0ebfa4d4bb9b19029a99c108989e583 (diff) | |
download | gnome-control-center-3d9ada13f0e771ad8a4faf42b6c3f8779d94484f.tar.gz |
CcPanel: derive from GtkBin, rather than GtkAlignment
CcPanel does not require any features of GtkAlignment, so derive from
GtkBin directly.
-rw-r--r-- | libgnome-control-center/cc-panel.c | 47 | ||||
-rw-r--r-- | libgnome-control-center/cc-panel.h | 4 |
2 files changed, 48 insertions, 3 deletions
diff --git a/libgnome-control-center/cc-panel.c b/libgnome-control-center/cc-panel.c index c26a6f88e..d93f18c49 100644 --- a/libgnome-control-center/cc-panel.c +++ b/libgnome-control-center/cc-panel.c @@ -60,7 +60,7 @@ enum PROP_SHELL, }; -G_DEFINE_ABSTRACT_TYPE (CcPanel, cc_panel, GTK_TYPE_ALIGNMENT) +G_DEFINE_ABSTRACT_TYPE (CcPanel, cc_panel, GTK_TYPE_BIN) static void cc_panel_set_property (GObject *object, @@ -123,17 +123,62 @@ cc_panel_finalize (GObject *object) G_OBJECT_CLASS (cc_panel_parent_class)->finalize (object); } +static void +cc_panel_size_request (GtkWidget *widget, + GtkRequisition *requisition) +{ + GtkBin *bin = GTK_BIN (widget); + GtkWidget *child; + guint border_width; + + if ((child = gtk_bin_get_child (bin))) + { + GtkRequisition child_requisition; + + gtk_widget_size_request (child, &child_requisition); + + requisition->width = child_requisition.width; + requisition->height = child_requisition.height; + } + + border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); + requisition->width += 2 * border_width; + requisition->height += 2 * border_width; +} + +static void +cc_panel_size_allocate (GtkWidget *widget, + GtkAllocation *allocation) +{ + GtkAllocation child_allocation; + guint border_width; + + child_allocation = *allocation; + + border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); + + + child_allocation.width -= 2 * border_width; + child_allocation.height -= 2 * border_width; + + gtk_widget_size_allocate (gtk_bin_get_child (GTK_BIN (widget)), + &child_allocation); +} static void cc_panel_class_init (CcPanelClass *klass) { GParamSpec *pspec; GObjectClass *object_class = G_OBJECT_CLASS (klass); + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); object_class->get_property = cc_panel_get_property; object_class->set_property = cc_panel_set_property; object_class->finalize = cc_panel_finalize; + widget_class->size_request = cc_panel_size_request; + widget_class->size_allocate = cc_panel_size_allocate; + g_type_class_add_private (klass, sizeof (CcPanelPrivate)); pspec = g_param_spec_object ("shell", diff --git a/libgnome-control-center/cc-panel.h b/libgnome-control-center/cc-panel.h index 1451d3aad..b2f9ca8ee 100644 --- a/libgnome-control-center/cc-panel.h +++ b/libgnome-control-center/cc-panel.h @@ -54,7 +54,7 @@ typedef struct _CcPanelClass CcPanelClass; struct _CcPanel { /*< private >*/ - GtkAlignment parent; + GtkBin parent; CcPanelPrivate *priv; }; /** @@ -65,7 +65,7 @@ struct _CcPanel struct _CcPanelClass { /*< private >*/ - GtkAlignmentClass parent_class; + GtkBinClass parent_class; }; GType cc_panel_get_type (void); |