summaryrefslogtreecommitdiff
path: root/gtk/gtkfixed.c
diff options
context:
space:
mode:
authorHavoc Pennington <hp@pobox.com>2001-08-10 03:46:08 +0000
committerHavoc Pennington <hp@src.gnome.org>2001-08-10 03:46:08 +0000
commitf37a0627fc3fe7676dc38b8c32856e375be59de1 (patch)
tree3246680255da5aa2ed168d8deb17a6f2a6c7343f /gtk/gtkfixed.c
parent439cd9a3a505424ea64d099ecbe1b4c910b79649 (diff)
downloadgtk+-f37a0627fc3fe7676dc38b8c32856e375be59de1.tar.gz
fix a typo.
2001-08-07 Havoc Pennington <hp@pobox.com> * gtk/gtkfilesel.c (open_ref_dir): fix a typo. * gtk/gtkplug.c (gtk_plug_init): remove setting of auto_shrink; some fixage is needed here, but nothing simple. Owen understands it. ;-) * gtk/gtkwindow.h, gtk/gtkwindow.c: Rework code and API for window sizing and positioning. Also, fix bug in compute_geometry_hints (width/height confusion for setting min size). (gtk_window_move): new function (gtk_window_resize): new function (gtk_window_get_size): new function (gtk_window_get_position): new function (gtk_window_parse_geometry): new function * gtk/gtkwidget.c (gtk_widget_set_size_request): new function (gtk_widget_get_size_request): new function (gtk_widget_get_usize): delete, that was a short-lived function ;-) (gtk_widget_set_usize): deprecate (gtk_widget_set_uposition): deprecate, make it a trivial gtk_window_move() wrapper (gtk_widget_class_init): remove x/y/width/height properties, add width_request height_request * demos/*: update to avoid deprecated functions * gtk/gtklayout.c: add x/y child properties * gtk/gtkfixed.c: add x/y child properties, and get rid of uses of "gint16" * tests/testgtk.c (create_window_sizing): lots of tweaks to window sizing test * gdk/x11/gdkevents-x11.c (gdk_event_translate): Ensure that configure events on toplevel windows are always in root window coordinates, following ICCCM spec that all synthetic events are in root window coords already, while real events are in parent window coords. Previously the code assumed that coords of 0,0 were parent window coords, which was really broken. * gtk/gtkcontainer.c (gtk_container_get_focus_chain): fix warning * gdk/gdkwindow.h (GdkWindowHints): add GDK_HINT_USER_POS and GDK_HINT_USER_SIZE so we can set USSize and USPosition hints in gtk_window_parse_geometry() * gdk/x11/gdkwindow-x11.c (gdk_window_set_geometry_hints): support new USER_POS USER_SIZE hints
Diffstat (limited to 'gtk/gtkfixed.c')
-rw-r--r--gtk/gtkfixed.c190
1 files changed, 173 insertions, 17 deletions
diff --git a/gtk/gtkfixed.c b/gtk/gtkfixed.c
index 3b214886a8..7e3cdff7d2 100644
--- a/gtk/gtkfixed.c
+++ b/gtk/gtkfixed.c
@@ -25,7 +25,13 @@
*/
#include "gtkfixed.h"
+#include "gtkintl.h"
+enum {
+ CHILD_PROP_0,
+ CHILD_PROP_X,
+ CHILD_PROP_Y
+};
static void gtk_fixed_class_init (GtkFixedClass *klass);
static void gtk_fixed_init (GtkFixed *fixed);
@@ -44,6 +50,16 @@ static void gtk_fixed_forall (GtkContainer *container,
gpointer callback_data);
static GtkType gtk_fixed_child_type (GtkContainer *container);
+static void gtk_fixed_set_child_property (GtkContainer *container,
+ GtkWidget *child,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void gtk_fixed_get_child_property (GtkContainer *container,
+ GtkWidget *child,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
static GtkContainerClass *parent_class = NULL;
@@ -94,6 +110,29 @@ gtk_fixed_class_init (GtkFixedClass *class)
container_class->remove = gtk_fixed_remove;
container_class->forall = gtk_fixed_forall;
container_class->child_type = gtk_fixed_child_type;
+
+ container_class->set_child_property = gtk_fixed_set_child_property;
+ container_class->get_child_property = gtk_fixed_get_child_property;
+
+ gtk_container_class_install_child_property (container_class,
+ CHILD_PROP_X,
+ g_param_spec_int ("x",
+ _("X position"),
+ _("X position of child widget"),
+ G_MININT,
+ G_MAXINT,
+ 0,
+ G_PARAM_READWRITE));
+
+ gtk_container_class_install_child_property (container_class,
+ CHILD_PROP_Y,
+ g_param_spec_int ("y",
+ _("Y position"),
+ _("Y position of child widget"),
+ G_MININT,
+ G_MAXINT,
+ 0,
+ G_PARAM_READWRITE));
}
static GtkType
@@ -119,11 +158,32 @@ gtk_fixed_new (void)
return GTK_WIDGET (fixed);
}
+static GtkFixedChild*
+get_child (GtkFixed *fixed,
+ GtkWidget *widget)
+{
+ GList *children;
+
+ children = fixed->children;
+ while (children)
+ {
+ GtkFixedChild *child;
+
+ child = children->data;
+ children = children->next;
+
+ if (child->widget == widget)
+ return child;
+ }
+
+ return NULL;
+}
+
void
gtk_fixed_put (GtkFixed *fixed,
GtkWidget *widget,
- gint16 x,
- gint16 y)
+ gint x,
+ gint y)
{
GtkFixedChild *child_info;
@@ -137,20 +197,121 @@ gtk_fixed_put (GtkFixed *fixed,
gtk_widget_set_parent (widget, GTK_WIDGET (fixed));
- fixed->children = g_list_append (fixed->children, child_info);
+ fixed->children = g_list_append (fixed->children, child_info);
+}
+
+static void
+gtk_fixed_move_internal (GtkFixed *fixed,
+ GtkWidget *widget,
+ gboolean change_x,
+ gint x,
+ gboolean change_y,
+ gint y)
+{
+ GtkFixedChild *child;
+
+ g_return_if_fail (GTK_IS_FIXED (fixed));
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+ g_return_if_fail (widget->parent == GTK_WIDGET (fixed));
+
+ child = get_child (fixed, widget);
+
+ g_assert (child);
+
+ gtk_widget_freeze_child_notify (widget);
+
+ if (change_x)
+ {
+ child->x = x;
+ gtk_widget_child_notify (widget, "x");
+ }
+
+ if (change_y)
+ {
+ child->y = y;
+ gtk_widget_child_notify (widget, "y");
+ }
+
+ gtk_widget_thaw_child_notify (widget);
+
+ if (GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_VISIBLE (fixed))
+ gtk_widget_queue_resize (GTK_WIDGET (fixed));
}
void
gtk_fixed_move (GtkFixed *fixed,
GtkWidget *widget,
- gint16 x,
- gint16 y)
+ gint x,
+ gint y)
+{
+ g_return_if_fail (GTK_IS_FIXED (fixed));
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+ g_return_if_fail (widget->parent == GTK_WIDGET (fixed));
+
+ gtk_fixed_move_internal (fixed, widget, TRUE, x, TRUE, y);
+}
+
+static void
+gtk_fixed_set_child_property (GtkContainer *container,
+ GtkWidget *child,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id)
+ {
+ case CHILD_PROP_X:
+ gtk_fixed_move_internal (GTK_FIXED (container),
+ child,
+ TRUE, g_value_get_int (value),
+ FALSE, 0);
+ break;
+ case CHILD_PROP_Y:
+ gtk_fixed_move_internal (GTK_FIXED (container),
+ child,
+ FALSE, 0,
+ TRUE, g_value_get_int (value));
+ break;
+ default:
+ GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
+ break;
+ }
+}
+
+static void
+gtk_fixed_get_child_property (GtkContainer *container,
+ GtkWidget *child,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
{
+ GtkFixedChild *fixed_child;
+
+ fixed_child = get_child (GTK_FIXED (container), child);
+
+ switch (property_id)
+ {
+ case CHILD_PROP_X:
+ g_value_set_int (value, fixed_child->x);
+ break;
+ case CHILD_PROP_Y:
+ g_value_set_int (value, fixed_child->y);
+ break;
+ default:
+ GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
+ break;
+ }
+}
+
+static void
+gtk_fixed_map (GtkWidget *widget)
+{
+ GtkFixed *fixed;
GtkFixedChild *child;
GList *children;
- g_return_if_fail (GTK_IS_FIXED (fixed));
- g_return_if_fail (widget != NULL);
+ GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
+ fixed = GTK_FIXED (widget);
children = fixed->children;
while (children)
@@ -158,17 +319,12 @@ gtk_fixed_move (GtkFixed *fixed,
child = children->data;
children = children->next;
- if (child->widget == widget)
- {
- child->x = x;
- child->y = y;
-
- if (GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_VISIBLE (fixed))
- gtk_widget_queue_resize (GTK_WIDGET (fixed));
-
- break;
- }
+ if (GTK_WIDGET_VISIBLE (child->widget) &&
+ !GTK_WIDGET_MAPPED (child->widget))
+ gtk_widget_map (child->widget);
}
+
+ gdk_window_show (widget->window);
}
static void