[gtk+/native-layout] Implemented GtkExtendedLayout on GtkWindow.
- From: Tristan Van Berkom <tvb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/native-layout] Implemented GtkExtendedLayout on GtkWindow.
- Date: Mon, 19 Apr 2010 00:15:52 +0000 (UTC)
commit 6dc5cdb98165a8dd75846d1ac7122efbef48dfef
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date: Sun Apr 18 20:13:46 2010 -0400
Implemented GtkExtendedLayout on GtkWindow.
gtk/gtkwindow.c | 102 +++++++++++++++++++++++++++++++++++++------------------
1 files changed, 69 insertions(+), 33 deletions(-)
---
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 388bfa7..dfbb5d7 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -208,8 +208,6 @@ static void gtk_window_map (GtkWidget *widget);
static void gtk_window_unmap (GtkWidget *widget);
static void gtk_window_realize (GtkWidget *widget);
static void gtk_window_unrealize (GtkWidget *widget);
-static void gtk_window_size_request (GtkWidget *widget,
- GtkRequisition *requisition);
static void gtk_window_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
static gint gtk_window_event (GtkWidget *widget,
@@ -351,9 +349,19 @@ static void gtk_window_buildable_custom_finished (GtkBuildable *buildable,
gpointer user_data);
+static void gtk_window_extended_layout_init (GtkExtendedLayoutIface *iface);
+static void gtk_window_get_desired_width (GtkExtendedLayout *layout,
+ gint *minimum_size,
+ gint *natural_size);
+static void gtk_window_get_desired_height (GtkExtendedLayout *layout,
+ gint *minimum_size,
+ gint *natural_size);
+
G_DEFINE_TYPE_WITH_CODE (GtkWindow, gtk_window, GTK_TYPE_BIN,
G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
- gtk_window_buildable_interface_init))
+ gtk_window_buildable_interface_init)
+ G_IMPLEMENT_INTERFACE (GTK_TYPE_EXTENDED_LAYOUT,
+ gtk_window_extended_layout_init))
static void
add_tab_bindings (GtkBindingSet *binding_set,
@@ -452,7 +460,6 @@ gtk_window_class_init (GtkWindowClass *klass)
widget_class->unmap = gtk_window_unmap;
widget_class->realize = gtk_window_realize;
widget_class->unrealize = gtk_window_unrealize;
- widget_class->size_request = gtk_window_size_request;
widget_class->size_allocate = gtk_window_size_allocate;
widget_class->configure_event = gtk_window_configure_event;
widget_class->key_press_event = gtk_window_key_press_event;
@@ -4935,35 +4942,6 @@ gtk_window_unrealize (GtkWidget *widget)
}
static void
-gtk_window_size_request (GtkWidget *widget,
- GtkRequisition *requisition)
-{
- GtkWindow *window;
- GtkBin *bin;
-
- window = GTK_WINDOW (widget);
- bin = GTK_BIN (window);
-
- requisition->width = GTK_CONTAINER (window)->border_width * 2;
- requisition->height = GTK_CONTAINER (window)->border_width * 2;
-
- if (bin->child && gtk_widget_get_visible (bin->child))
- {
- /* Use the minimum width for the natural height; even if its an hbox.
- *
- * This doesnt need to be here; naturally it will use the preference of the child
- * except for testing purposes its more interesting this way.
- */
- GtkRequisition child_req;
-
- gtk_extended_layout_get_desired_size (GTK_EXTENDED_LAYOUT (bin->child), &child_req, NULL);
-
- requisition->width += child_req.width;
- requisition->height += child_req.height;
- }
-}
-
-static void
gtk_window_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
@@ -5562,6 +5540,64 @@ gtk_window_real_set_focus (GtkWindow *window,
}
}
+
+static void
+gtk_window_extended_layout_init (GtkExtendedLayoutIface *iface)
+{
+ iface->get_desired_width = gtk_window_get_desired_width;
+ iface->get_desired_height = gtk_window_get_desired_height;
+}
+
+
+static void
+gtk_window_get_desired_width (GtkExtendedLayout *layout,
+ gint *minimum_size,
+ gint *natural_size)
+{
+ GtkWindow *window;
+ GtkWidget *child;
+
+ window = GTK_WINDOW (layout);
+ child = gtk_bin_get_child (GTK_BIN (window));
+
+ *minimum_size = GTK_CONTAINER (window)->border_width * 2;
+ *natural_size = GTK_CONTAINER (window)->border_width * 2;
+
+ if (child && gtk_widget_get_visible (child))
+ {
+ gint child_min, child_nat;
+ gtk_extended_layout_get_desired_width (GTK_EXTENDED_LAYOUT (child), &child_min, &child_nat);
+
+ *minimum_size += child_min;
+ *natural_size += child_nat;
+ }
+}
+
+static void
+gtk_window_get_desired_height (GtkExtendedLayout *layout,
+ gint *minimum_size,
+ gint *natural_size)
+{
+ GtkWindow *window;
+ GtkWidget *child;
+
+ window = GTK_WINDOW (layout);
+ child = gtk_bin_get_child (GTK_BIN (window));
+
+ *minimum_size = GTK_CONTAINER (window)->border_width * 2;
+ *natural_size = GTK_CONTAINER (window)->border_width * 2;
+
+ if (child && gtk_widget_get_visible (child))
+ {
+ gint child_min, child_nat;
+ gtk_extended_layout_get_desired_height (GTK_EXTENDED_LAYOUT (child), &child_min, &child_nat);
+
+ *minimum_size += child_min;
+ *natural_size += child_nat;
+ }
+}
+
+
/**
* _gtk_window_unset_focus_and_default:
* @window: a #GtkWindow
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]