diff options
Diffstat (limited to 'gtk')
197 files changed, 8245 insertions, 4462 deletions
diff --git a/gtk/Makefile.am b/gtk/Makefile.am index a1ab693dab..8fdc74757a 100644 --- a/gtk/Makefile.am +++ b/gtk/Makefile.am @@ -335,7 +335,8 @@ gtk_public_h_sources = \ gtkvscrollbar.h \ gtkvseparator.h \ gtkwidget.h \ - gtkwindow.h + gtkwindow.h \ + gtkwrapbox.h if OS_UNIX gtk_unix_print_public_h_sources = \ @@ -619,6 +620,7 @@ gtk_base_c_sources = \ gtkwidget.c \ gtkwindow-decorate.c \ gtkwindow.c \ + gtkwrapbox.c \ $(gtk_clipboard_dnd_c_sources) gtk_c_sources = $(gtk_base_c_sources) @@ -821,27 +823,23 @@ gtkunixprintinclude_HEADERS = $(gtk_unix_print_public_h_sources) libgtk_x11_3_0_la_SOURCES = $(gtk_c_sources) libgtk_win32_3_0_la_SOURCES = $(gtk_c_sources) libgtk_quartz_3_0_la_SOURCES = $(gtk_c_sources) -libgtk_directfb_3_0_la_SOURCES = $(gtk_c_sources) libgtk_x11_3_0_la_LDFLAGS = $(libtool_opts) libgtk_win32_3_0_la_LDFLAGS = $(libtool_opts) -Wl,-luuid libgtk_quartz_3_0_la_LDFLAGS = $(libtool_opts) -libgtk_directfb_3_0_la_LDFLAGS = $(libtool_opts) libgtk_x11_3_0_la_LIBADD = $(libadd) libgtk_win32_3_0_la_LIBADD = $(libadd) -lole32 -lgdi32 -lcomdlg32 -lwinspool -lcomctl32 libgtk_quartz_3_0_la_LIBADD = $(libadd) -libgtk_directfb_3_0_la_LIBADD = $(libadd) libgtk_x11_3_0_la_DEPENDENCIES = $(deps) libgtk_win32_3_0_la_DEPENDENCIES = $(gtk_def) $(gtk_win32_res) $(deps) libgtk_quartz_3_0_la_DEPENDENCIES = $(deps) -libgtk_directfb_3_0_la_DEPENDENCIES = $(deps) if USE_WIN32 libgtk_target_ldflags = $(gtk_win32_res_ldflag) $(gtk_win32_symbols) endif -EXTRA_LTLIBRARIES = libgtk-x11-3.0.la libgtk-win32-3.0.la libgtk-quartz-3.0.la libgtk-directfb-3.0.la +EXTRA_LTLIBRARIES = libgtk-x11-3.0.la libgtk-win32-3.0.la libgtk-quartz-3.0.la install-exec-hook: if DISABLE_EXPLICIT_DEPS @@ -946,14 +944,14 @@ if OS_WIN32 # Workaround for UAC silliness: programs with "update" in their name # are believed to be installers and require elevated privileges to be # used... Use a manifest file to tell Windows that -# gtk-update-icon-cache.exe doesn't require any special privileges. +# gtk-update-icon-cache-3.0.exe doesn't require any special privileges. GTK_UPDATE_ICON_CACHE_MANIFEST = gtk-update-icon-cache-3.0.exe.manifest bin_SCRIPTS += \ $(GTK_UPDATE_ICON_CACHE_MANIFEST) -gtk-update-icon-cache.exe.manifest: +$(GTK_UPDATE_ICON_CACHE_MANIFEST): (echo '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' ; \ echo '<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">' ; \ echo ' <assemblyIdentity version="1.0.0.0"' ; \ @@ -1022,7 +1020,7 @@ STOCK_ICONS = \ stock-icons/16/format-indent-more-ltr.png \ stock-icons/16/format-indent-more-rtl.png \ stock-icons/16/gtk-index.png \ - stock-icons/16/dialog-info.png \ + stock-icons/16/dialog-information.png \ stock-icons/16/go-jump-ltr.png \ stock-icons/16/go-jump-rtl.png \ stock-icons/16/format-justify-center.png \ @@ -1045,7 +1043,7 @@ STOCK_ICONS = \ stock-icons/16/document-open.png \ stock-icons/16/gtk-page-setup.png \ stock-icons/16/edit-paste.png \ - stock-icons/16/edit-preferences.png \ + stock-icons/16/gtk-preferences.png \ stock-icons/16/document-print.png \ stock-icons/16/printer-error.png \ stock-icons/16/printer-paused.png \ @@ -1127,7 +1125,7 @@ STOCK_ICONS = \ stock-icons/24/format-indent-more-ltr.png \ stock-icons/24/format-indent-more-rtl.png \ stock-icons/24/gtk-index.png \ - stock-icons/24/dialog-info.png \ + stock-icons/24/dialog-information.png \ stock-icons/24/format-text-italic.png \ stock-icons/24/go-jump-ltr.png \ stock-icons/24/go-jump-rtl.png \ @@ -1155,7 +1153,7 @@ STOCK_ICONS = \ stock-icons/24/gtk-orientation-portrait.png \ stock-icons/24/gtk-page-setup.png \ stock-icons/24/edit-paste.png \ - stock-icons/24/edit-preferences.png \ + stock-icons/24/gtk-preferences.png \ stock-icons/24/document-print.png \ stock-icons/24/printer-error.png \ stock-icons/24/printer-paused.png \ @@ -1197,7 +1195,7 @@ STOCK_ICONS = \ stock-icons/32/gtk-dnd.png \ stock-icons/48/dialog-password.png \ stock-icons/48/dialog-error.png \ - stock-icons/48/dialog-info.png \ + stock-icons/48/dialog-information.png \ stock-icons/48/dialog-question.png \ stock-icons/48/dialog-warning.png @@ -218,6 +218,7 @@ #include <gtk/gtkvseparator.h> #include <gtk/gtkwidget.h> #include <gtk/gtkwindow.h> +#include <gtk/gtkwrapbox.h> #undef __GTK_H_INSIDE__ diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols index b2252cf12d..7e1fe789ab 100644 --- a/gtk/gtk.symbols +++ b/gtk/gtk.symbols @@ -694,7 +694,7 @@ gtk_cell_size_request_get_width_for_height #if IN_HEADER(__GTK_CELL_VIEW_H__) #if IN_FILE(__GTK_CELL_VIEW_C__) -gtk_cell_view_get_desired_height_of_row +gtk_cell_view_get_desired_height_for_width_of_row gtk_cell_view_get_desired_width_of_row gtk_cell_view_get_displayed_row gtk_cell_view_get_model @@ -4630,6 +4630,29 @@ gtk_window_unstick #endif #endif + +#if IN_HEADER(__GTK_WRAP_BOX_H__) +#if IN_FILE(__GTK_WRAP_BOX_C__) +gtk_wrap_box_get_allocation_mode +gtk_wrap_box_get_horizontal_spacing +gtk_wrap_box_get_minimum_line_children +gtk_wrap_box_get_natural_line_children +gtk_wrap_box_get_spreading +gtk_wrap_box_get_type G_GNUC_CONST +gtk_wrap_box_get_vertical_spacing +gtk_wrap_box_insert_child +gtk_wrap_box_new +gtk_wrap_box_reorder_child +gtk_wrap_box_set_allocation_mode +gtk_wrap_box_set_horizontal_spacing +gtk_wrap_box_set_minimum_line_children +gtk_wrap_box_set_natural_line_children +gtk_wrap_box_set_spreading +gtk_wrap_box_set_vertical_spacing +#endif +#endif + + #if IN_HEADER(__GTK_WIN32_EMBED_WIDGET_H__) #if IN_FILE(__GTK_WIN32_EMBED_WIDGET_C__) #ifdef G_OS_WIN32 diff --git a/gtk/gtkaboutdialog.c b/gtk/gtkaboutdialog.c index acf1aff93a..388b69abe1 100644 --- a/gtk/gtkaboutdialog.c +++ b/gtk/gtkaboutdialog.c @@ -2010,7 +2010,8 @@ text_view_visibility_notify_event (GtkWidget *text_view, { GdkDevice *dev = d->data; - gdk_window_get_device_position (text_view->window, dev, &wx, &wy, NULL); + gdk_window_get_device_position (gtk_widget_get_window (text_view), dev, + &wx, &wy, NULL); gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view), GTK_TEXT_WINDOW_WIDGET, @@ -2564,7 +2565,7 @@ gtk_about_dialog_set_license_type (GtkAboutDialog *about, g_string_append (str, "\n"); g_string_append (str, priv->copyright); g_string_append (str, "\n\n"); - g_string_append_printf (str, gettext (gtk_license_preamble), url); + g_string_append_printf (str, _(gtk_license_preamble), url); g_free (priv->license); priv->license = g_string_free (str, FALSE); diff --git a/gtk/gtkaccessible.c b/gtk/gtkaccessible.c index 228f88f1df..532f476e7f 100644 --- a/gtk/gtkaccessible.c +++ b/gtk/gtkaccessible.c @@ -35,7 +35,7 @@ * @widget: The GtkWidget whose properties and features are exported via this * accessible instance */ -struct _GtkAccessiblePriv +struct _GtkAccessiblePrivate { GtkWidget *widget; }; @@ -49,7 +49,7 @@ gtk_accessible_init (GtkAccessible *accesible) { accesible->priv = G_TYPE_INSTANCE_GET_PRIVATE (accesible, GTK_TYPE_ACCESSIBLE, - GtkAccessiblePriv); + GtkAccessiblePrivate); } static void @@ -57,7 +57,7 @@ gtk_accessible_class_init (GtkAccessibleClass *klass) { klass->connect_widget_destroyed = gtk_accessible_real_connect_widget_destroyed; - g_type_class_add_private (klass, sizeof (GtkAccessiblePriv)); + g_type_class_add_private (klass, sizeof (GtkAccessiblePrivate)); } /** @@ -121,7 +121,7 @@ gtk_accessible_connect_widget_destroyed (GtkAccessible *accessible) static void gtk_accessible_real_connect_widget_destroyed (GtkAccessible *accessible) { - GtkAccessiblePriv *priv = accessible->priv; + GtkAccessiblePrivate *priv = accessible->priv; if (priv->widget) { diff --git a/gtk/gtkaccessible.h b/gtk/gtkaccessible.h index 584bcc5c41..d3a154e7ed 100644 --- a/gtk/gtkaccessible.h +++ b/gtk/gtkaccessible.h @@ -37,7 +37,7 @@ G_BEGIN_DECLS #define GTK_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_ACCESSIBLE, GtkAccessibleClass)) typedef struct _GtkAccessible GtkAccessible; -typedef struct _GtkAccessiblePriv GtkAccessiblePriv; +typedef struct _GtkAccessiblePrivate GtkAccessiblePrivate; typedef struct _GtkAccessibleClass GtkAccessibleClass; /* @@ -48,7 +48,7 @@ struct _GtkAccessible AtkObject parent; /*< private >*/ - GtkAccessiblePriv *priv; + GtkAccessiblePrivate *priv; }; struct _GtkAccessibleClass diff --git a/gtk/gtkactivatable.c b/gtk/gtkactivatable.c index 77b019ba4d..5f2bbeaad6 100644 --- a/gtk/gtkactivatable.c +++ b/gtk/gtkactivatable.c @@ -268,28 +268,11 @@ #include "gtkintl.h" -static void gtk_activatable_class_init (gpointer g_iface); - -GType -gtk_activatable_get_type (void) -{ - static GType activatable_type = 0; - - if (!activatable_type) { - activatable_type = - g_type_register_static_simple (G_TYPE_INTERFACE, I_("GtkActivatable"), - sizeof (GtkActivatableIface), - (GClassInitFunc) gtk_activatable_class_init, - 0, NULL, 0); - - g_type_interface_add_prerequisite (activatable_type, G_TYPE_OBJECT); - } - - return activatable_type; -} +typedef GtkActivatableIface GtkActivatableInterface; +G_DEFINE_INTERFACE (GtkActivatable, gtk_activatable, G_TYPE_OBJECT) static void -gtk_activatable_class_init (gpointer g_iface) +gtk_activatable_default_init (GtkActivatableInterface *iface) { /** * GtkActivatable:related-action: @@ -302,7 +285,7 @@ gtk_activatable_class_init (gpointer g_iface) * * Since: 2.16 */ - g_object_interface_install_property (g_iface, + g_object_interface_install_property (iface, g_param_spec_object ("related-action", P_("Related Action"), P_("The action this activatable will activate and receive updates from"), @@ -325,7 +308,7 @@ gtk_activatable_class_init (gpointer g_iface) * * Since: 2.16 */ - g_object_interface_install_property (g_iface, + g_object_interface_install_property (iface, g_param_spec_boolean ("use-action-appearance", P_("Use Action Appearance"), P_("Whether to use the related actions appearance properties"), diff --git a/gtk/gtkalignment.c b/gtk/gtkalignment.c index d36da48dd0..c863553924 100644 --- a/gtk/gtkalignment.c +++ b/gtk/gtkalignment.c @@ -50,7 +50,7 @@ #include "gtkintl.h" -struct _GtkAlignmentPriv +struct _GtkAlignmentPrivate { gfloat xalign; gfloat yalign; @@ -221,17 +221,17 @@ gtk_alignment_class_init (GtkAlignmentClass *class) 0, GTK_PARAM_READWRITE)); - g_type_class_add_private (gobject_class, sizeof (GtkAlignmentPriv)); + g_type_class_add_private (gobject_class, sizeof (GtkAlignmentPrivate)); } static void gtk_alignment_init (GtkAlignment *alignment) { - GtkAlignmentPriv *priv; + GtkAlignmentPrivate *priv; alignment->priv = G_TYPE_INSTANCE_GET_PRIVATE (alignment, GTK_TYPE_ALIGNMENT, - GtkAlignmentPriv); + GtkAlignmentPrivate); priv = alignment->priv; gtk_widget_set_has_window (GTK_WIDGET (alignment), FALSE); @@ -274,7 +274,7 @@ gtk_alignment_new (gfloat xalign, gfloat yscale) { GtkAlignment *alignment; - GtkAlignmentPriv *priv; + GtkAlignmentPrivate *priv; alignment = g_object_new (GTK_TYPE_ALIGNMENT, NULL); @@ -295,7 +295,7 @@ gtk_alignment_set_property (GObject *object, GParamSpec *pspec) { GtkAlignment *alignment = GTK_ALIGNMENT (object); - GtkAlignmentPriv *priv = alignment->priv; + GtkAlignmentPrivate *priv = alignment->priv; switch (prop_id) { @@ -371,7 +371,7 @@ gtk_alignment_get_property (GObject *object, GParamSpec *pspec) { GtkAlignment *alignment = GTK_ALIGNMENT (object); - GtkAlignmentPriv *priv = alignment->priv; + GtkAlignmentPrivate *priv = alignment->priv; switch (prop_id) { @@ -432,7 +432,7 @@ gtk_alignment_set (GtkAlignment *alignment, gfloat xscale, gfloat yscale) { - GtkAlignmentPriv *priv; + GtkAlignmentPrivate *priv; GtkWidget *child; g_return_if_fail (GTK_IS_ALIGNMENT (alignment)); @@ -485,7 +485,7 @@ gtk_alignment_size_allocate (GtkWidget *widget, GtkAllocation *allocation) { GtkAlignment *alignment = GTK_ALIGNMENT (widget); - GtkAlignmentPriv *priv = alignment->priv; + GtkAlignmentPrivate *priv = alignment->priv; GtkBin *bin; GtkAllocation child_allocation; GtkWidget *bin_child; @@ -496,7 +496,7 @@ gtk_alignment_size_allocate (GtkWidget *widget, padding_horizontal = 0; padding_vertical = 0; - widget->allocation = *allocation; + gtk_widget_set_allocation (widget, allocation); bin = GTK_BIN (widget); bin_child = gtk_bin_get_child (bin); @@ -576,7 +576,7 @@ gtk_alignment_get_size (GtkSizeRequest *widget, gint *natural_size) { GtkAlignment *alignment = GTK_ALIGNMENT (widget); - GtkAlignmentPriv *priv = alignment->priv; + GtkAlignmentPrivate *priv = alignment->priv; GtkWidget *child; guint minimum, natural; @@ -651,7 +651,7 @@ gtk_alignment_set_padding (GtkAlignment *alignment, guint padding_left, guint padding_right) { - GtkAlignmentPriv *priv; + GtkAlignmentPrivate *priv; GtkWidget *child; g_return_if_fail (GTK_IS_ALIGNMENT (alignment)); @@ -711,7 +711,7 @@ gtk_alignment_get_padding (GtkAlignment *alignment, guint *padding_left, guint *padding_right) { - GtkAlignmentPriv *priv; + GtkAlignmentPrivate *priv; g_return_if_fail (GTK_IS_ALIGNMENT (alignment)); diff --git a/gtk/gtkalignment.h b/gtk/gtkalignment.h index 9b391efda4..498ad93c45 100644 --- a/gtk/gtkalignment.h +++ b/gtk/gtkalignment.h @@ -45,16 +45,16 @@ G_BEGIN_DECLS #define GTK_ALIGNMENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_ALIGNMENT, GtkAlignmentClass)) -typedef struct _GtkAlignment GtkAlignment; -typedef struct _GtkAlignmentPriv GtkAlignmentPriv; -typedef struct _GtkAlignmentClass GtkAlignmentClass; +typedef struct _GtkAlignment GtkAlignment; +typedef struct _GtkAlignmentPrivate GtkAlignmentPrivate; +typedef struct _GtkAlignmentClass GtkAlignmentClass; struct _GtkAlignment { GtkBin bin; /* <private> */ - GtkAlignmentPriv *priv; + GtkAlignmentPrivate *priv; }; struct _GtkAlignmentClass diff --git a/gtk/gtkarrow.c b/gtk/gtkarrow.c index 7da60bf82c..ed1d69c9a1 100644 --- a/gtk/gtkarrow.c +++ b/gtk/gtkarrow.c @@ -52,7 +52,7 @@ #define MIN_ARROW_SIZE 15 -struct _GtkArrowPriv +struct _GtkArrowPrivate { gint16 arrow_type; gint16 shadow_type; @@ -119,7 +119,7 @@ gtk_arrow_class_init (GtkArrowClass *class) 0.0, 1.0, 0.7, GTK_PARAM_READABLE)); - g_type_class_add_private (class, sizeof (GtkArrowPriv)); + g_type_class_add_private (class, sizeof (GtkArrowPrivate)); } static void @@ -129,7 +129,7 @@ gtk_arrow_set_property (GObject *object, GParamSpec *pspec) { GtkArrow *arrow = GTK_ARROW (object); - GtkArrowPriv *priv = arrow->priv; + GtkArrowPrivate *priv = arrow->priv; switch (prop_id) { @@ -156,7 +156,7 @@ gtk_arrow_get_property (GObject *object, GParamSpec *pspec) { GtkArrow *arrow = GTK_ARROW (object); - GtkArrowPriv *priv = arrow->priv; + GtkArrowPrivate *priv = arrow->priv; switch (prop_id) { @@ -175,12 +175,12 @@ gtk_arrow_get_property (GObject *object, static void gtk_arrow_init (GtkArrow *arrow) { - GtkArrowPriv *priv; + GtkArrowPrivate *priv; gint xpad, ypad; arrow->priv = G_TYPE_INSTANCE_GET_PRIVATE (arrow, GTK_TYPE_ARROW, - GtkArrowPriv); + GtkArrowPrivate); priv = arrow->priv; gtk_widget_set_has_window (GTK_WIDGET (arrow), FALSE); @@ -206,7 +206,7 @@ GtkWidget* gtk_arrow_new (GtkArrowType arrow_type, GtkShadowType shadow_type) { - GtkArrowPriv *priv; + GtkArrowPrivate *priv; GtkArrow *arrow; arrow = g_object_new (GTK_TYPE_ARROW, NULL); @@ -232,7 +232,7 @@ gtk_arrow_set (GtkArrow *arrow, GtkArrowType arrow_type, GtkShadowType shadow_type) { - GtkArrowPriv *priv; + GtkArrowPrivate *priv; GtkWidget *widget; g_return_if_fail (GTK_IS_ARROW (arrow)); @@ -272,7 +272,7 @@ gtk_arrow_expose (GtkWidget *widget, if (gtk_widget_is_drawable (widget)) { GtkArrow *arrow = GTK_ARROW (widget); - GtkArrowPriv *priv = arrow->priv; + GtkArrowPrivate *priv = arrow->priv; GtkMisc *misc = GTK_MISC (widget); GtkShadowType shadow_type; gint width, height; diff --git a/gtk/gtkarrow.h b/gtk/gtkarrow.h index 9188448dfe..dc7f5bd134 100644 --- a/gtk/gtkarrow.h +++ b/gtk/gtkarrow.h @@ -45,16 +45,16 @@ G_BEGIN_DECLS #define GTK_IS_ARROW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_ARROW)) #define GTK_ARROW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_ARROW, GtkArrowClass)) -typedef struct _GtkArrow GtkArrow; -typedef struct _GtkArrowPriv GtkArrowPriv; -typedef struct _GtkArrowClass GtkArrowClass; +typedef struct _GtkArrow GtkArrow; +typedef struct _GtkArrowPrivate GtkArrowPrivate; +typedef struct _GtkArrowClass GtkArrowClass; struct _GtkArrow { GtkMisc misc; /*< private >*/ - GtkArrowPriv *priv; + GtkArrowPrivate *priv; }; struct _GtkArrowClass diff --git a/gtk/gtkaspectframe.c b/gtk/gtkaspectframe.c index f2eb19fa81..42b709a50f 100644 --- a/gtk/gtkaspectframe.c +++ b/gtk/gtkaspectframe.c @@ -50,7 +50,7 @@ -struct _GtkAspectFramePriv +struct _GtkAspectFramePrivate { GtkAllocation center_allocation; @@ -128,17 +128,17 @@ gtk_aspect_frame_class_init (GtkAspectFrameClass *class) TRUE, GTK_PARAM_READWRITE)); - g_type_class_add_private (class, sizeof (GtkAspectFramePriv)); + g_type_class_add_private (class, sizeof (GtkAspectFramePrivate)); } static void gtk_aspect_frame_init (GtkAspectFrame *aspect_frame) { - GtkAspectFramePriv *priv; + GtkAspectFramePrivate *priv; aspect_frame->priv = G_TYPE_INSTANCE_GET_PRIVATE (aspect_frame, GTK_TYPE_ASPECT_FRAME, - GtkAspectFramePriv); + GtkAspectFramePrivate); priv = aspect_frame->priv; priv->xalign = 0.5; @@ -154,7 +154,7 @@ gtk_aspect_frame_set_property (GObject *object, GParamSpec *pspec) { GtkAspectFrame *aspect_frame = GTK_ASPECT_FRAME (object); - GtkAspectFramePriv *priv = aspect_frame->priv; + GtkAspectFramePrivate *priv = aspect_frame->priv; switch (prop_id) { @@ -200,7 +200,7 @@ gtk_aspect_frame_get_property (GObject *object, GParamSpec *pspec) { GtkAspectFrame *aspect_frame = GTK_ASPECT_FRAME (object); - GtkAspectFramePriv *priv = aspect_frame->priv; + GtkAspectFramePrivate *priv = aspect_frame->priv; switch (prop_id) { @@ -247,7 +247,7 @@ gtk_aspect_frame_new (const gchar *label, gboolean obey_child) { GtkAspectFrame *aspect_frame; - GtkAspectFramePriv *priv; + GtkAspectFramePrivate *priv; aspect_frame = g_object_new (GTK_TYPE_ASPECT_FRAME, NULL); @@ -285,7 +285,7 @@ gtk_aspect_frame_set (GtkAspectFrame *aspect_frame, gfloat ratio, gboolean obey_child) { - GtkAspectFramePriv *priv; + GtkAspectFramePrivate *priv; g_return_if_fail (GTK_IS_ASPECT_FRAME (aspect_frame)); @@ -334,7 +334,7 @@ gtk_aspect_frame_compute_child_allocation (GtkFrame *frame, GtkAllocation *child_allocation) { GtkAspectFrame *aspect_frame = GTK_ASPECT_FRAME (frame); - GtkAspectFramePriv *priv = aspect_frame->priv; + GtkAspectFramePrivate *priv = aspect_frame->priv; GtkBin *bin = GTK_BIN (frame); GtkWidget *child; gdouble ratio; diff --git a/gtk/gtkaspectframe.h b/gtk/gtkaspectframe.h index 475b0e592a..e1e194e1a5 100644 --- a/gtk/gtkaspectframe.h +++ b/gtk/gtkaspectframe.h @@ -44,16 +44,16 @@ G_BEGIN_DECLS #define GTK_IS_ASPECT_FRAME_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_ASPECT_FRAME)) #define GTK_ASPECT_FRAME_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_ASPECT_FRAME, GtkAspectFrameClass)) -typedef struct _GtkAspectFrame GtkAspectFrame; -typedef struct _GtkAspectFramePriv GtkAspectFramePriv; -typedef struct _GtkAspectFrameClass GtkAspectFrameClass; +typedef struct _GtkAspectFrame GtkAspectFrame; +typedef struct _GtkAspectFramePrivate GtkAspectFramePrivate; +typedef struct _GtkAspectFrameClass GtkAspectFrameClass; struct _GtkAspectFrame { GtkFrame frame; /*< private >*/ - GtkAspectFramePriv *priv; + GtkAspectFramePrivate *priv; }; struct _GtkAspectFrameClass diff --git a/gtk/gtkassistant.c b/gtk/gtkassistant.c index 3d388048c8..5cbfe90214 100644 --- a/gtk/gtkassistant.c +++ b/gtk/gtkassistant.c @@ -1101,7 +1101,7 @@ set_title_font (GtkWidget *assistant, gint size; desc = pango_font_description_new (); - size = pango_font_description_get_size (assistant->style->font_desc); + size = pango_font_description_get_size (gtk_widget_get_style (assistant)->font_desc); pango_font_description_set_weight (desc, PANGO_WEIGHT_ULTRABOLD); pango_font_description_set_size (desc, size * PANGO_SCALE_XX_LARGE); @@ -1206,6 +1206,7 @@ gtk_assistant_size_allocate (GtkWidget *widget, GtkAssistantPrivate *priv = assistant->priv; GtkRequisition header_requisition, action_requisition, sidebar_requisition; GtkAllocation child_allocation, header_allocation; + GtkAllocation action_area_allocation, header_image_allocation; gint header_padding, content_padding; guint border_width; gboolean rtl; @@ -1219,7 +1220,7 @@ gtk_assistant_size_allocate (GtkWidget *widget, "content-padding", &content_padding, NULL); - widget->allocation = *allocation; + gtk_widget_set_allocation (widget, allocation); border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); /* Header */ @@ -1242,6 +1243,9 @@ gtk_assistant_size_allocate (GtkWidget *widget, gtk_widget_size_allocate (priv->action_area, &child_allocation); + gtk_widget_get_allocation (priv->header_image, &header_image_allocation); + gtk_widget_get_allocation (priv->action_area, &action_area_allocation); + /* Sidebar */ gtk_widget_get_child_requisition (priv->sidebar_image, &sidebar_requisition); @@ -1250,27 +1254,31 @@ gtk_assistant_size_allocate (GtkWidget *widget, else child_allocation.x = border_width; - child_allocation.y = border_width + priv->header_image->allocation.height + 2 * header_padding; + child_allocation.y = border_width + header_image_allocation.height + 2 * header_padding; child_allocation.width = sidebar_requisition.width; child_allocation.height = allocation->height - 2 * border_width - - priv->header_image->allocation.height - 2 * header_padding - priv->action_area->allocation.height; + header_image_allocation.height - 2 * header_padding - action_area_allocation.height; gtk_widget_size_allocate (priv->sidebar_image, &child_allocation); /* Pages */ child_allocation.x = border_width + content_padding; child_allocation.y = border_width + - priv->header_image->allocation.height + 2 * header_padding + content_padding; + header_image_allocation.height + 2 * header_padding + content_padding; child_allocation.width = allocation->width - 2 * border_width - 2 * content_padding; child_allocation.height = allocation->height - 2 * border_width - - priv->header_image->allocation.height - 2 * header_padding - ACTION_AREA_SPACING - priv->action_area->allocation.height - 2 * content_padding; + header_image_allocation.height - 2 * header_padding - ACTION_AREA_SPACING - action_area_allocation.height - 2 * content_padding; if (gtk_widget_get_visible (priv->sidebar_image)) { + GtkAllocation sidebar_image_allocation; + + gtk_widget_get_allocation (priv->sidebar_image, &sidebar_image_allocation); + if (!rtl) - child_allocation.x += priv->sidebar_image->allocation.width; + child_allocation.x += sidebar_image_allocation.width; - child_allocation.width -= priv->sidebar_image->allocation.width; + child_allocation.width -= sidebar_image_allocation.width; } while (pages) @@ -1367,12 +1375,14 @@ assistant_paint_colored_box (GtkWidget *widget) { GtkAssistant *assistant = GTK_ASSISTANT (widget); GtkAssistantPrivate *priv = assistant->priv; + GtkAllocation allocation, action_area_allocation, header_image_allocation; + GtkStyle *style; gint border_width, header_padding, content_padding; cairo_t *cr; gint content_x, content_width; gboolean rtl; - cr = gdk_cairo_create (widget->window); + cr = gdk_cairo_create (gtk_widget_get_window (widget)); rtl = (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL); border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); @@ -1381,34 +1391,43 @@ assistant_paint_colored_box (GtkWidget *widget) "content-padding", &content_padding, NULL); + style = gtk_widget_get_style (widget); + gtk_widget_get_allocation (widget, &allocation); + gtk_widget_get_allocation (priv->action_area, &action_area_allocation); + gtk_widget_get_allocation (priv->header_image, &header_image_allocation); + /* colored box */ - gdk_cairo_set_source_color (cr, &widget->style->bg[GTK_STATE_SELECTED]); + gdk_cairo_set_source_color (cr, &style->bg[GTK_STATE_SELECTED]); cairo_rectangle (cr, border_width, border_width, - widget->allocation.width - 2 * border_width, - widget->allocation.height - priv->action_area->allocation.height - 2 * border_width - ACTION_AREA_SPACING); + allocation.width - 2 * border_width, + allocation.height - action_area_allocation.height - 2 * border_width - ACTION_AREA_SPACING); cairo_fill (cr); /* content box */ content_x = content_padding + border_width; - content_width = widget->allocation.width - 2 * content_padding - 2 * border_width; + content_width = allocation.width - 2 * content_padding - 2 * border_width; if (gtk_widget_get_visible (priv->sidebar_image)) { + GtkAllocation sidebar_image_allocation; + + gtk_widget_get_allocation (priv->sidebar_image, &sidebar_image_allocation); + if (!rtl) - content_x += priv->sidebar_image->allocation.width; - content_width -= priv->sidebar_image->allocation.width; + content_x += sidebar_image_allocation.width; + content_width -= sidebar_image_allocation.width; } - - gdk_cairo_set_source_color (cr, &widget->style->bg[GTK_STATE_NORMAL]); + + gdk_cairo_set_source_color (cr, &style->bg[GTK_STATE_NORMAL]); cairo_rectangle (cr, content_x, - priv->header_image->allocation.height + content_padding + 2 * header_padding + border_width, + header_image_allocation.height + content_padding + 2 * header_padding + border_width, content_width, - widget->allocation.height - 2 * border_width - priv->action_area->allocation.height - - priv->header_image->allocation.height - 2 * content_padding - 2 * header_padding - ACTION_AREA_SPACING); + allocation.height - 2 * border_width - action_area_allocation.height - + header_image_allocation.height - 2 * content_padding - 2 * header_padding - ACTION_AREA_SPACING); cairo_fill (cr); cairo_destroy (cr); @@ -1754,7 +1773,7 @@ gtk_assistant_insert_page (GtkAssistant *assistant, g_return_val_if_fail (GTK_IS_ASSISTANT (assistant), 0); g_return_val_if_fail (GTK_IS_WIDGET (page), 0); - g_return_val_if_fail (page->parent == NULL, 0); + g_return_val_if_fail (gtk_widget_get_parent (page) == NULL, 0); g_return_val_if_fail (!gtk_widget_is_toplevel (page), 0); priv = assistant->priv; diff --git a/gtk/gtkbbox.c b/gtk/gtkbbox.c index 655ba9ace9..f0c893c62c 100644 --- a/gtk/gtkbbox.c +++ b/gtk/gtkbbox.c @@ -59,7 +59,7 @@ #include "gtkintl.h" -struct _GtkButtonBoxPriv +struct _GtkButtonBoxPrivate { GtkButtonBoxStyle layout_style; }; @@ -185,17 +185,17 @@ gtk_button_box_class_init (GtkButtonBoxClass *class) FALSE, GTK_PARAM_READWRITE)); - g_type_class_add_private (class, sizeof (GtkButtonBoxPriv)); + g_type_class_add_private (class, sizeof (GtkButtonBoxPrivate)); } static void gtk_button_box_init (GtkButtonBox *button_box) { - GtkButtonBoxPriv *priv; + GtkButtonBoxPrivate *priv; button_box->priv = G_TYPE_INSTANCE_GET_PRIVATE (button_box, GTK_TYPE_BUTTON_BOX, - GtkButtonBoxPriv); + GtkButtonBoxPrivate); priv = button_box->priv; gtk_box_set_spacing (GTK_BOX (button_box), 0); @@ -226,7 +226,7 @@ gtk_button_box_get_property (GObject *object, GValue *value, GParamSpec *pspec) { - GtkButtonBoxPriv *priv = GTK_BUTTON_BOX (object)->priv; + GtkButtonBoxPrivate *priv = GTK_BUTTON_BOX (object)->priv; switch (prop_id) { @@ -303,7 +303,7 @@ void gtk_button_box_set_layout (GtkButtonBox *widget, GtkButtonBoxStyle layout_style) { - GtkButtonBoxPriv *priv; + GtkButtonBoxPrivate *priv; g_return_if_fail (GTK_IS_BUTTON_BOX (widget)); @@ -381,7 +381,7 @@ gtk_button_box_set_child_secondary (GtkButtonBox *widget, { g_return_if_fail (GTK_IS_BUTTON_BOX (widget)); g_return_if_fail (GTK_IS_WIDGET (child)); - g_return_if_fail (child->parent == GTK_WIDGET (widget)); + g_return_if_fail (gtk_widget_get_parent (child) == GTK_WIDGET (widget)); g_object_set_data (G_OBJECT (child), GTK_BOX_SECONDARY_CHILD, @@ -394,22 +394,24 @@ gtk_button_box_set_child_secondary (GtkButtonBox *widget, } /* Ask children how much space they require and round up - to match minimum size and internal padding. - Returns the size each single child should have. */ + * to match minimum size and internal padding. + * Returns the size each single child should have. + */ static void -_gtk_button_box_child_requisition (GtkWidget *widget, - int *nvis_children, - int *nvis_secondaries, - int *width, - int *height) +gtk_button_box_child_requisition (GtkWidget *widget, + gint *nvis_children, + gint *nvis_secondaries, + gint **widths, + gint **heights) { - GtkButtonBoxPriv *priv; + GtkButtonBoxPrivate *priv; GtkButtonBox *bbox; GList *children, *list; gint nchildren; gint nsecondaries; gint needed_width; gint needed_height; + gint avg_w, avg_h; GtkRequisition child_requisition; gint ipad_w; gint ipad_h; @@ -417,12 +419,16 @@ _gtk_button_box_child_requisition (GtkWidget *widget, gint child_min_height; gint ipad_x; gint ipad_y; + gboolean homogeneous; + gint i; g_return_if_fail (GTK_IS_BUTTON_BOX (widget)); bbox = GTK_BUTTON_BOX (widget); priv = bbox->priv; + homogeneous = gtk_box_get_homogeneous (GTK_BOX (widget)); + gtk_widget_style_get (widget, "child-min-width", &child_min_width, "child-min-height", &child_min_height, @@ -437,69 +443,134 @@ _gtk_button_box_child_requisition (GtkWidget *widget, needed_height = child_min_height; ipad_w = ipad_x * 2; ipad_h = ipad_y * 2; - + + avg_w = avg_h = 0; while (children) { GtkWidget *child; - gboolean is_secondary; child = children->data; children = children->next; - is_secondary = gtk_button_box_get_child_secondary (bbox, child); - if (gtk_widget_get_visible (child)) { nchildren += 1; gtk_widget_size_request (child, &child_requisition); + avg_w += child_requisition.width + ipad_w; + avg_h += child_requisition.height + ipad_h; + } + } + avg_w /= MAX (nchildren, 1); + avg_h /= MAX (nchildren, 1); + + *widths = g_new (gint, nchildren); + *heights = g_new (gint, nchildren); - if (child_requisition.width + ipad_w > needed_width) - needed_width = child_requisition.width + ipad_w; - if (child_requisition.height + ipad_h > needed_height) - needed_height = child_requisition.height + ipad_h; + i = 0; + children = list; + while (children) + { + GtkWidget *child; + gboolean is_secondary; + + child = children->data; + children = children->next; + + if (gtk_widget_get_visible (child)) + { + is_secondary = gtk_button_box_get_child_secondary (bbox, child); if (is_secondary) nsecondaries++; + + gtk_widget_get_child_requisition (child, &child_requisition); + + if (homogeneous || (child_requisition.width + ipad_w < avg_w * 1.5)) + { + (*widths)[i] = -1; + if (child_requisition.width + ipad_w > needed_width) + needed_width = child_requisition.width + ipad_w; + } + else + { + (*widths)[i] = child_requisition.width + ipad_w; + } + + if (homogeneous || (child_requisition.height + ipad_h < avg_h * 1.5)) + { + (*heights)[i] = -1; + if (child_requisition.height + ipad_h > needed_height) + needed_height = child_requisition.height + ipad_h; + } + else + { + (*heights)[i] = child_requisition.height + ipad_h; + } + + i++; } } g_list_free (list); + for (i = 0; i < nchildren; i++) + { + if ((*widths)[i] == -1) + (*widths)[i] = needed_width; + if ((*heights)[i] == -1) + (*heights)[i] = needed_height; + } + if (nvis_children) *nvis_children = nchildren; + if (nvis_secondaries) *nvis_secondaries = nsecondaries; - if (width) - *width = needed_width; - if (height) - *height = needed_height; } static void gtk_button_box_size_request (GtkWidget *widget, GtkRequisition *requisition) { - GtkButtonBoxPriv *priv; - GtkBox *box; + GtkButtonBoxPrivate *priv; GtkButtonBox *bbox; gint nvis_children; - gint child_width; - gint child_height; + gint max_size; + gint total_size; gint spacing; guint border_width; GtkOrientation orientation; + gint *widths; + gint *heights; + gint i; - box = GTK_BOX (widget); bbox = GTK_BUTTON_BOX (widget); priv = bbox->priv; orientation = gtk_orientable_get_orientation (GTK_ORIENTABLE (widget)); - spacing = gtk_box_get_spacing (box); + spacing = gtk_box_get_spacing (GTK_BOX (widget)); - _gtk_button_box_child_requisition (widget, - &nvis_children, - NULL, - &child_width, - &child_height); + gtk_button_box_child_requisition (widget, + &nvis_children, + NULL, + &widths, &heights); + + max_size = 0; + total_size = 0; + for (i = 0; i < nvis_children; i++) + { + if (orientation == GTK_ORIENTATION_HORIZONTAL) + { + total_size += widths[i]; + max_size = MAX (max_size, heights[i]); + } + else + { + total_size += heights[i]; + max_size = MAX (max_size, widths[i]); + } + } + g_free (widths); + g_free (heights); if (nvis_children == 0) { @@ -512,11 +583,9 @@ gtk_button_box_size_request (GtkWidget *widget, { case GTK_BUTTONBOX_SPREAD: if (orientation == GTK_ORIENTATION_HORIZONTAL) - requisition->width = - nvis_children*child_width + ((nvis_children+1)*spacing); + requisition->width = total_size + ((nvis_children + 1)*spacing); else - requisition->height = - nvis_children*child_height + ((nvis_children+1)*spacing); + requisition->height = total_size + ((nvis_children + 1)*spacing); break; case GTK_BUTTONBOX_EDGE: @@ -524,11 +593,9 @@ gtk_button_box_size_request (GtkWidget *widget, case GTK_BUTTONBOX_END: case GTK_BUTTONBOX_CENTER: if (orientation == GTK_ORIENTATION_HORIZONTAL) - requisition->width = - nvis_children*child_width + ((nvis_children-1)*spacing); + requisition->width = total_size + ((nvis_children - 1)*spacing); else - requisition->height = - nvis_children*child_height + ((nvis_children-1)*spacing); + requisition->height = total_size + ((nvis_children - 1)*spacing); break; default: @@ -537,12 +604,12 @@ gtk_button_box_size_request (GtkWidget *widget, } if (orientation == GTK_ORIENTATION_HORIZONTAL) - requisition->height = child_height; + requisition->height = max_size; else - requisition->width = child_width; + requisition->width = max_size; } - border_width = gtk_container_get_border_width (GTK_CONTAINER (box)); + border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); requisition->width += border_width * 2; requisition->height += border_width * 2; } @@ -551,40 +618,77 @@ static void gtk_button_box_size_allocate (GtkWidget *widget, GtkAllocation *allocation) { - GtkButtonBoxPriv *priv; - GtkBox *base_box; - GtkButtonBox *box; + GtkButtonBoxPrivate *priv; + GtkButtonBox *bbox; GList *children, *list; GtkAllocation child_allocation; gint nvis_children; + gint n_primaries; gint n_secondaries; - gint child_width; - gint child_height; gint x = 0; gint y = 0; gint secondary_x = 0; gint secondary_y = 0; gint width = 0; gint height = 0; - gint childspace; gint childspacing = 0; gint spacing; guint border_width; GtkOrientation orientation; + gint ipad_x, ipad_y; + gint *widths; + gint *heights; + gint *sizes; + gint primary_size; + gint secondary_size; + gint total_size; + gint i; - base_box = GTK_BOX (widget); - box = GTK_BUTTON_BOX (widget); - priv = box->priv; + bbox = GTK_BUTTON_BOX (widget); + priv = bbox->priv; - border_width = gtk_container_get_border_width (GTK_CONTAINER (box)); + border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); orientation = gtk_orientable_get_orientation (GTK_ORIENTABLE (widget)); - spacing = gtk_box_get_spacing (base_box); - _gtk_button_box_child_requisition (widget, - &nvis_children, - &n_secondaries, - &child_width, - &child_height); - widget->allocation = *allocation; + spacing = gtk_box_get_spacing (GTK_BOX (widget)); + + gtk_widget_style_get (widget, + "child-internal-pad-x", &ipad_x, + "child-internal-pad-y", &ipad_y, + NULL); + gtk_button_box_child_requisition (widget, + &nvis_children, + &n_secondaries, + &widths, &heights); + + n_primaries = nvis_children - n_secondaries; + primary_size = 0; + secondary_size = 0; + if (orientation == GTK_ORIENTATION_HORIZONTAL) + sizes = widths; + else + sizes = heights; + + i = 0; + list = children = _gtk_box_get_children (GTK_BOX (widget)); + while (children) + { + GtkWidget *child; + + child = children->data; + children = children->next; + + if (gtk_widget_get_visible (child)) + { + if (gtk_button_box_get_child_secondary (bbox, child)) + secondary_size += sizes[i]; + else + primary_size += sizes[i]; + i++; + } + } + total_size = primary_size + secondary_size; + + gtk_widget_set_allocation (widget, allocation); if (orientation == GTK_ORIENTATION_HORIZONTAL) width = allocation->width - border_width*2; @@ -597,19 +701,15 @@ gtk_button_box_size_allocate (GtkWidget *widget, if (orientation == GTK_ORIENTATION_HORIZONTAL) { - childspacing = (width - (nvis_children * child_width)) - / (nvis_children + 1); + childspacing = (width - total_size) / (nvis_children + 1); x = allocation->x + border_width + childspacing; - secondary_x = x + ((nvis_children - n_secondaries) - * (child_width + childspacing)); + secondary_x = x + primary_size + n_primaries * childspacing; } else { - childspacing = (height - (nvis_children * child_height)) - / (nvis_children + 1); + childspacing = (height - total_size) / (nvis_children + 1); y = allocation->y + border_width + childspacing; - secondary_y = y + ((nvis_children - n_secondaries) - * (child_height + childspacing)); + secondary_y = y + primary_size + n_primaries * childspacing; } break; @@ -620,36 +720,32 @@ gtk_button_box_size_allocate (GtkWidget *widget, { if (nvis_children >= 2) { - childspacing = (width - (nvis_children * child_width)) - / (nvis_children - 1); + childspacing = (width - total_size) / (nvis_children - 1); x = allocation->x + border_width; - secondary_x = x + ((nvis_children - n_secondaries) - * (child_width + childspacing)); + secondary_x = x + primary_size + n_primaries * childspacing; } else { /* one or zero children, just center */ childspacing = width; x = secondary_x = allocation->x - + (allocation->width - child_width) / 2; + + (allocation->width - widths[0]) / 2; } } else { if (nvis_children >= 2) { - childspacing = (height - (nvis_children*child_height)) - / (nvis_children-1); + childspacing = (height - total_size) / (nvis_children - 1); y = allocation->y + border_width; - secondary_y = y + ((nvis_children - n_secondaries) - * (child_height + childspacing)); + secondary_y = y + primary_size + n_primaries * childspacing; } else { /* one or zero children, just center */ childspacing = height; y = secondary_y = allocation->y - + (allocation->height - child_height) / 2; + + (allocation->height - heights[0]) / 2; } } @@ -662,18 +758,14 @@ gtk_button_box_size_allocate (GtkWidget *widget, childspacing = spacing; x = allocation->x + border_width; secondary_x = allocation->x + allocation->width - - child_width * n_secondaries - - spacing * (n_secondaries - 1) - - border_width; + - secondary_size - spacing * (n_secondaries - 1) - border_width; } else { childspacing = spacing; y = allocation->y + border_width; secondary_y = allocation->y + allocation->height - - child_height * n_secondaries - - spacing * (n_secondaries - 1) - - border_width; + - secondary_size - spacing * (n_secondaries - 1) - border_width; } break; @@ -684,18 +776,14 @@ gtk_button_box_size_allocate (GtkWidget *widget, { childspacing = spacing; x = allocation->x + allocation->width - - child_width * (nvis_children - n_secondaries) - - spacing * (nvis_children - n_secondaries - 1) - - border_width; + - primary_size - spacing * (n_primaries - 1) - border_width; secondary_x = allocation->x + border_width; } else { childspacing = spacing; y = allocation->y + allocation->height - - child_height * (nvis_children - n_secondaries) - - spacing * (nvis_children - n_secondaries - 1) - - border_width; + - primary_size - spacing * (n_primaries - 1) - border_width; secondary_y = allocation->y + border_width; } @@ -708,9 +796,8 @@ gtk_button_box_size_allocate (GtkWidget *widget, childspacing = spacing; x = allocation->x + (allocation->width - - (child_width * (nvis_children - n_secondaries) - + spacing * (nvis_children - n_secondaries - 1))) / 2 - + (n_secondaries * child_width + n_secondaries * spacing) / 2; + - (primary_size + spacing * (n_primaries - 1))) / 2 + + (secondary_size + n_secondaries * spacing) / 2; secondary_x = allocation->x + border_width; } else @@ -718,9 +805,8 @@ gtk_button_box_size_allocate (GtkWidget *widget, childspacing = spacing; y = allocation->y + (allocation->height - - (child_height * (nvis_children - n_secondaries) - + spacing * (nvis_children - n_secondaries - 1))) / 2 - + (n_secondaries * child_height + n_secondaries * spacing) / 2; + - (primary_size + spacing * (n_primaries - 1))) / 2 + + (secondary_size + n_secondaries * spacing) / 2; secondary_y = allocation->y + border_width; } @@ -731,74 +817,63 @@ gtk_button_box_size_allocate (GtkWidget *widget, break; } - if (orientation == GTK_ORIENTATION_HORIZONTAL) - { - y = allocation->y + (allocation->height - child_height) / 2; - childspace = child_width + childspacing; - } - else - { - x = allocation->x + (allocation->width - child_width) / 2; - childspace = child_height + childspacing; - } - - list = children = _gtk_box_get_children (GTK_BOX (box)); - + children = list; + i = 0; while (children) { GtkWidget *child; - gboolean is_secondary; child = children->data; children = children->next; - is_secondary = gtk_button_box_get_child_secondary (box, child); - if (gtk_widget_get_visible (child)) { - child_allocation.width = child_width; - child_allocation.height = child_height; + child_allocation.width = widths[i]; + child_allocation.height = heights[i]; if (orientation == GTK_ORIENTATION_HORIZONTAL) { - child_allocation.y = y; + child_allocation.y = allocation->y + (allocation->height - child_allocation.height) / 2; - if (is_secondary) + if (gtk_button_box_get_child_secondary (bbox, child)) { child_allocation.x = secondary_x; - secondary_x += childspace; + secondary_x += child_allocation.width + childspacing; } else { child_allocation.x = x; - x += childspace; + x += child_allocation.width + childspacing; } if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) child_allocation.x = (allocation->x + allocation->width) - - (child_allocation.x + child_width - allocation->x); + - (child_allocation.x + child_allocation.width - allocation->x); } else { - child_allocation.x = x; + child_allocation.x = allocation->x + (allocation->width - child_allocation.width) / 2; - if (is_secondary) + if (gtk_button_box_get_child_secondary (bbox, child)) { child_allocation.y = secondary_y; - secondary_y += childspace; + secondary_y += child_allocation.height + childspacing; } else { child_allocation.y = y; - y += childspace; + y += child_allocation.height + childspacing; } } gtk_widget_size_allocate (child, &child_allocation); + i++; } } g_list_free (list); + g_free (widths); + g_free (heights); } /** diff --git a/gtk/gtkbbox.h b/gtk/gtkbbox.h index 878ba0a162..df842f7fe6 100644 --- a/gtk/gtkbbox.h +++ b/gtk/gtkbbox.h @@ -44,16 +44,16 @@ G_BEGIN_DECLS #define GTK_BUTTON_BOX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_BUTTON_BOX, GtkButtonBoxClass)) -typedef struct _GtkButtonBox GtkButtonBox; -typedef struct _GtkButtonBoxPriv GtkButtonBoxPriv; -typedef struct _GtkButtonBoxClass GtkButtonBoxClass; +typedef struct _GtkButtonBox GtkButtonBox; +typedef struct _GtkButtonBoxPrivate GtkButtonBoxPrivate; +typedef struct _GtkButtonBoxClass GtkButtonBoxClass; struct _GtkButtonBox { GtkBox box; /*< private >*/ - GtkButtonBoxPriv *priv; + GtkButtonBoxPrivate *priv; }; struct _GtkButtonBoxClass diff --git a/gtk/gtkbin.c b/gtk/gtkbin.c index 388ad7a68e..ecc2b99954 100644 --- a/gtk/gtkbin.c +++ b/gtk/gtkbin.c @@ -43,7 +43,7 @@ #include "gtkintl.h" -struct _GtkBinPriv +struct _GtkBinPrivate { GtkWidget *child; }; @@ -88,17 +88,17 @@ gtk_bin_class_init (GtkBinClass *class) container_class->forall = gtk_bin_forall; container_class->child_type = gtk_bin_child_type; - g_type_class_add_private (class, sizeof (GtkBinPriv)); + g_type_class_add_private (class, sizeof (GtkBinPrivate)); } static void gtk_bin_init (GtkBin *bin) { - GtkBinPriv *priv; + GtkBinPrivate *priv; bin->priv = G_TYPE_INSTANCE_GET_PRIVATE (bin, GTK_TYPE_BIN, - GtkBinPriv); + GtkBinPrivate); priv = bin->priv; gtk_widget_set_has_window (GTK_WIDGET (bin), FALSE); @@ -110,7 +110,7 @@ gtk_bin_init (GtkBin *bin) static GType gtk_bin_child_type (GtkContainer *container) { - GtkBinPriv *priv = GTK_BIN (container)->priv; + GtkBinPrivate *priv = GTK_BIN (container)->priv; if (!priv->child) return GTK_TYPE_WIDGET; @@ -123,7 +123,7 @@ gtk_bin_add (GtkContainer *container, GtkWidget *child) { GtkBin *bin = GTK_BIN (container); - GtkBinPriv *priv = bin->priv; + GtkBinPrivate *priv = bin->priv; if (priv->child != NULL) { @@ -146,7 +146,7 @@ gtk_bin_remove (GtkContainer *container, GtkWidget *child) { GtkBin *bin = GTK_BIN (container); - GtkBinPriv *priv = bin->priv; + GtkBinPrivate *priv = bin->priv; gboolean widget_was_visible; g_return_if_fail (priv->child == child); @@ -170,7 +170,7 @@ gtk_bin_forall (GtkContainer *container, gpointer callback_data) { GtkBin *bin = GTK_BIN (container); - GtkBinPriv *priv = bin->priv; + GtkBinPrivate *priv = bin->priv; if (priv->child) (* callback) (priv->child, callback_data); @@ -200,7 +200,7 @@ static GtkSizeRequestMode gtk_bin_get_request_mode (GtkSizeRequest *widget) { GtkBin *bin = GTK_BIN (widget); - GtkBinPriv *priv = bin->priv; + GtkBinPrivate *priv = bin->priv; if (priv->child) return gtk_size_request_get_request_mode (GTK_SIZE_REQUEST (priv->child)); @@ -213,7 +213,7 @@ get_child_padding_delta (GtkBin *bin, gint *delta_h, gint *delta_v) { - GtkBinPriv *priv = bin->priv; + GtkBinPrivate *priv = bin->priv; gint hmin, vmin, child_hmin, child_vmin; gtk_size_request_get_width (GTK_SIZE_REQUEST (bin), &hmin, NULL); @@ -233,7 +233,7 @@ gtk_bin_get_width_for_height (GtkSizeRequest *widget, gint *natural_width) { GtkBin *bin = GTK_BIN (widget); - GtkBinPriv *priv = bin->priv; + GtkBinPrivate *priv = bin->priv; gint hdelta, vdelta, child_min, child_nat; if (priv->child) @@ -261,7 +261,7 @@ gtk_bin_get_height_for_width (GtkSizeRequest *widget, gint *natural_height) { GtkBin *bin = GTK_BIN (widget); - GtkBinPriv *priv = bin->priv; + GtkBinPrivate *priv = bin->priv; gint hdelta, vdelta, child_min, child_nat; if (priv->child) diff --git a/gtk/gtkbin.h b/gtk/gtkbin.h index 80b6846f2d..c264134d18 100644 --- a/gtk/gtkbin.h +++ b/gtk/gtkbin.h @@ -45,16 +45,16 @@ G_BEGIN_DECLS #define GTK_BIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_BIN, GtkBinClass)) -typedef struct _GtkBin GtkBin; -typedef struct _GtkBinPriv GtkBinPriv; -typedef struct _GtkBinClass GtkBinClass; +typedef struct _GtkBin GtkBin; +typedef struct _GtkBinPrivate GtkBinPrivate; +typedef struct _GtkBinClass GtkBinClass; struct _GtkBin { GtkContainer container; /*< private >*/ - GtkBinPriv *priv; + GtkBinPrivate *priv; }; struct _GtkBinClass diff --git a/gtk/gtkbox.c b/gtk/gtkbox.c index 1f9b63708d..0e8aa0a76b 100644 --- a/gtk/gtkbox.c +++ b/gtk/gtkbox.c @@ -98,7 +98,7 @@ enum { CHILD_PROP_POSITION }; -struct _GtkBoxPriv +struct _GtkBoxPrivate { GtkOrientation orientation; @@ -293,17 +293,17 @@ gtk_box_class_init (GtkBoxClass *class) -1, G_MAXINT, 0, GTK_PARAM_READWRITE)); - g_type_class_add_private (object_class, sizeof (GtkBoxPriv)); + g_type_class_add_private (object_class, sizeof (GtkBoxPrivate)); } static void gtk_box_init (GtkBox *box) { - GtkBoxPriv *private; + GtkBoxPrivate *private; box->priv = G_TYPE_INSTANCE_GET_PRIVATE (box, GTK_TYPE_BOX, - GtkBoxPriv); + GtkBoxPrivate); private = box->priv; gtk_widget_set_has_window (GTK_WIDGET (box), FALSE); @@ -325,7 +325,7 @@ gtk_box_set_property (GObject *object, GParamSpec *pspec) { GtkBox *box = GTK_BOX (object); - GtkBoxPriv *private = box->priv; + GtkBoxPrivate *private = box->priv; switch (prop_id) { @@ -352,7 +352,7 @@ gtk_box_get_property (GObject *object, GParamSpec *pspec) { GtkBox *box = GTK_BOX (object); - GtkBoxPriv *private = box->priv; + GtkBoxPrivate *private = box->priv; switch (prop_id) { @@ -377,7 +377,7 @@ count_expand_children (GtkBox *box, gint *visible_children, gint *expand_children) { - GtkBoxPriv *private = box->priv; + GtkBoxPrivate *private = box->priv; GList *children; GtkBoxChild *child; @@ -401,7 +401,7 @@ gtk_box_size_allocate (GtkWidget *widget, GtkAllocation *allocation) { GtkBox *box = GTK_BOX (widget); - GtkBoxPriv *private = box->priv; + GtkBoxPrivate *private = box->priv; GtkBoxChild *child; GList *children; gint nvis_children; @@ -421,7 +421,7 @@ gtk_box_size_allocate (GtkWidget *widget, gint child_size; - widget->allocation = *allocation; + gtk_widget_set_allocation (widget, allocation); count_expand_children (box, &nvis_children, &nexpand_children); @@ -774,12 +774,12 @@ gtk_box_pack (GtkBox *box, guint padding, GtkPackType pack_type) { - GtkBoxPriv *private = box->priv; + GtkBoxPrivate *private = box->priv; GtkBoxChild *child_info; g_return_if_fail (GTK_IS_BOX (box)); g_return_if_fail (GTK_IS_WIDGET (child)); - g_return_if_fail (child->parent == NULL); + g_return_if_fail (gtk_widget_get_parent (child) == NULL); child_info = g_new (GtkBoxChild, 1); child_info->widget = child; @@ -818,7 +818,7 @@ gtk_box_size_request_init (GtkSizeRequestIface *iface) static GtkSizeRequestMode gtk_box_get_request_mode (GtkSizeRequest *widget) { - GtkBoxPriv *private = GTK_BOX (widget)->priv; + GtkBoxPrivate *private = GTK_BOX (widget)->priv; return (private->orientation == GTK_ORIENTATION_VERTICAL) ? GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH : GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT; @@ -831,7 +831,7 @@ gtk_box_get_size (GtkSizeRequest *widget, gint *natural_size) { GtkBox *box; - GtkBoxPriv *private; + GtkBoxPrivate *private; GList *children; gint nvis_children; gint border_width; @@ -932,7 +932,7 @@ gtk_box_compute_size_for_opposing_orientation (GtkBox *box, gint *minimum_size, gint *natural_size) { - GtkBoxPriv *private = box->priv; + GtkBoxPrivate *private = box->priv; GtkBoxChild *child; GList *children; gint nvis_children; @@ -1110,7 +1110,7 @@ gtk_box_compute_size_for_orientation (GtkBox *box, gint *minimum_size, gint *natural_size) { - GtkBoxPriv *private = box->priv; + GtkBoxPrivate *private = box->priv; GList *children; gint nvis_children = 0; gint required_size = 0, required_natural = 0, child_size, child_natural; @@ -1179,7 +1179,7 @@ gtk_box_get_width_for_height (GtkSizeRequest *widget, gint *natural_width) { GtkBox *box = GTK_BOX (widget); - GtkBoxPriv *private = box->priv; + GtkBoxPrivate *private = box->priv; if (private->orientation == GTK_ORIENTATION_VERTICAL) gtk_box_compute_size_for_opposing_orientation (box, height, minimum_width, natural_width); @@ -1194,7 +1194,7 @@ gtk_box_get_height_for_width (GtkSizeRequest *widget, gint *natural_height) { GtkBox *box = GTK_BOX (widget); - GtkBoxPriv *private = box->priv; + GtkBoxPrivate *private = box->priv; if (private->orientation == GTK_ORIENTATION_HORIZONTAL) gtk_box_compute_size_for_opposing_orientation (box, width, minimum_height, natural_height); @@ -1304,7 +1304,7 @@ void gtk_box_set_homogeneous (GtkBox *box, gboolean homogeneous) { - GtkBoxPriv *private; + GtkBoxPrivate *private; g_return_if_fail (GTK_IS_BOX (box)); @@ -1347,7 +1347,7 @@ void gtk_box_set_spacing (GtkBox *box, gint spacing) { - GtkBoxPriv *private; + GtkBoxPrivate *private; g_return_if_fail (GTK_IS_BOX (box)); @@ -1384,7 +1384,7 @@ void _gtk_box_set_spacing_set (GtkBox *box, gboolean spacing_set) { - GtkBoxPriv *private; + GtkBoxPrivate *private; g_return_if_fail (GTK_IS_BOX (box)); @@ -1396,7 +1396,7 @@ _gtk_box_set_spacing_set (GtkBox *box, gboolean _gtk_box_get_spacing_set (GtkBox *box) { - GtkBoxPriv *private; + GtkBoxPrivate *private; g_return_val_if_fail (GTK_IS_BOX (box), FALSE); @@ -1429,7 +1429,7 @@ gtk_box_reorder_child (GtkBox *box, GtkWidget *child, gint position) { - GtkBoxPriv *priv; + GtkBoxPrivate *priv; GList *old_link; GList *new_link; GtkBoxChild *child_info = NULL; @@ -1491,7 +1491,7 @@ gtk_box_query_child_packing (GtkBox *box, guint *padding, GtkPackType *pack_type) { - GtkBoxPriv *private; + GtkBoxPrivate *private; GList *list; GtkBoxChild *child_info = NULL; @@ -1542,7 +1542,7 @@ gtk_box_set_child_packing (GtkBox *box, guint padding, GtkPackType pack_type) { - GtkBoxPriv *private; + GtkBoxPrivate *private; GList *list; GtkBoxChild *child_info = NULL; @@ -1586,7 +1586,7 @@ gtk_box_set_child_packing (GtkBox *box, void _gtk_box_set_old_defaults (GtkBox *box) { - GtkBoxPriv *private; + GtkBoxPrivate *private; g_return_if_fail (GTK_IS_BOX (box)); @@ -1599,7 +1599,7 @@ static void gtk_box_add (GtkContainer *container, GtkWidget *widget) { - GtkBoxPriv *priv = GTK_BOX (container)->priv; + GtkBoxPrivate *priv = GTK_BOX (container)->priv; gtk_box_pack_start (GTK_BOX (container), widget, priv->default_expand, @@ -1612,7 +1612,7 @@ gtk_box_remove (GtkContainer *container, GtkWidget *widget) { GtkBox *box = GTK_BOX (container); - GtkBoxPriv *priv = box->priv; + GtkBoxPrivate *priv = box->priv; GtkBoxChild *child; GList *children; @@ -1652,7 +1652,7 @@ gtk_box_forall (GtkContainer *container, gpointer callback_data) { GtkBox *box = GTK_BOX (container); - GtkBoxPriv *priv = box->priv; + GtkBoxPrivate *priv = box->priv; GtkBoxChild *child; GList *children; @@ -1680,7 +1680,7 @@ gtk_box_forall (GtkContainer *container, GList * _gtk_box_get_children (GtkBox *box) { - GtkBoxPriv *priv; + GtkBoxPrivate *priv; GtkBoxChild *child; GList *children; GList *retval = NULL; diff --git a/gtk/gtkbox.h b/gtk/gtkbox.h index 85a2f4a4cb..725debdc97 100644 --- a/gtk/gtkbox.h +++ b/gtk/gtkbox.h @@ -46,16 +46,16 @@ G_BEGIN_DECLS #define GTK_BOX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_BOX, GtkBoxClass)) -typedef struct _GtkBox GtkBox; -typedef struct _GtkBoxPriv GtkBoxPriv; -typedef struct _GtkBoxClass GtkBoxClass; +typedef struct _GtkBox GtkBox; +typedef struct _GtkBoxPrivate GtkBoxPrivate; +typedef struct _GtkBoxClass GtkBoxClass; struct _GtkBox { GtkContainer container; /*< private >*/ - GtkBoxPriv *priv; + GtkBoxPrivate *priv; }; struct _GtkBoxClass diff --git a/gtk/gtkbuilderparser.c b/gtk/gtkbuilderparser.c index ef2e5e9e09..a3954d1ae5 100644 --- a/gtk/gtkbuilderparser.c +++ b/gtk/gtkbuilderparser.c @@ -404,7 +404,7 @@ parse_object (GMarkupParseContext *context, { g_set_error (error, GTK_BUILDER_ERROR, GTK_BUILDER_ERROR_DUPLICATE_ID, - _("Duplicate object id '%s' on line %d (previously on line %d)"), + _("Duplicate object ID '%s' on line %d (previously on line %d)"), object_id, line, line2); return; } diff --git a/gtk/gtkbutton.c b/gtk/gtkbutton.c index d9d10478d9..d2417069e8 100644 --- a/gtk/gtkbutton.c +++ b/gtk/gtkbutton.c @@ -1004,9 +1004,13 @@ gtk_button_construct_child (GtkButton *button) if (priv->image && !priv->image_is_stock) { + GtkWidget *parent; + image = g_object_ref (priv->image); - if (image->parent) - gtk_container_remove (GTK_CONTAINER (image->parent), image); + + parent = gtk_widget_get_parent (image); + if (parent) + gtk_container_remove (GTK_CONTAINER (parent), image); } priv->image = NULL; @@ -1275,21 +1279,24 @@ gtk_button_get_relief (GtkButton *button) static void gtk_button_realize (GtkWidget *widget) { - GtkButton *button; + GtkButton *button = GTK_BUTTON (widget); + GtkAllocation allocation; + GdkWindow *window; GdkWindowAttr attributes; gint attributes_mask; gint border_width; - button = GTK_BUTTON (widget); + gtk_widget_get_allocation (widget, &allocation); + gtk_widget_set_realized (widget, TRUE); border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); attributes.window_type = GDK_WINDOW_CHILD; - attributes.x = widget->allocation.x + border_width; - attributes.y = widget->allocation.y + border_width; - attributes.width = widget->allocation.width - border_width * 2; - attributes.height = widget->allocation.height - border_width * 2; + attributes.x = allocation.x + border_width; + attributes.y = allocation.y + border_width; + attributes.width = allocation.width - border_width * 2; + attributes.height = allocation.height - border_width * 2; attributes.wclass = GDK_INPUT_ONLY; attributes.event_mask = gtk_widget_get_events (widget); attributes.event_mask |= (GDK_BUTTON_PRESS_MASK | @@ -1299,14 +1306,15 @@ gtk_button_realize (GtkWidget *widget) attributes_mask = GDK_WA_X | GDK_WA_Y; - widget->window = gtk_widget_get_parent_window (widget); - g_object_ref (widget->window); - - button->event_window = gdk_window_new (gtk_widget_get_parent_window (widget), + window = gtk_widget_get_parent_window (widget); + gtk_widget_set_window (widget, window); + g_object_ref (window); + + button->event_window = gdk_window_new (window, &attributes, attributes_mask); gdk_window_set_user_data (button->event_window, button); - widget->style = gtk_style_attach (widget->style, widget->window); + gtk_widget_style_attach (widget); } static void @@ -1444,47 +1452,50 @@ gtk_button_size_allocate (GtkWidget *widget, { GtkButton *button = GTK_BUTTON (widget); GtkAllocation child_allocation; + GtkStyle *style; GtkWidget *child; guint border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); - gint xthickness = GTK_WIDGET (widget)->style->xthickness; - gint ythickness = GTK_WIDGET (widget)->style->ythickness; + gint xthickness, ythickness; GtkBorder default_border; GtkBorder inner_border; gint focus_width; gint focus_pad; + style = gtk_widget_get_style (widget); + xthickness = style->xthickness; + ythickness = style->ythickness; + gtk_button_get_props (button, &default_border, NULL, &inner_border, NULL); gtk_widget_style_get (GTK_WIDGET (widget), "focus-line-width", &focus_width, "focus-padding", &focus_pad, NULL); - - - widget->allocation = *allocation; + + gtk_widget_set_allocation (widget, allocation); if (gtk_widget_get_realized (widget)) gdk_window_move_resize (button->event_window, - widget->allocation.x + border_width, - widget->allocation.y + border_width, - widget->allocation.width - border_width * 2, - widget->allocation.height - border_width * 2); + allocation->x + border_width, + allocation->y + border_width, + allocation->width - border_width * 2, + allocation->height - border_width * 2); child = gtk_bin_get_child (GTK_BIN (button)); if (child && gtk_widget_get_visible (child)) { - child_allocation.x = widget->allocation.x + border_width + inner_border.left + xthickness; - child_allocation.y = widget->allocation.y + border_width + inner_border.top + ythickness; - - child_allocation.width = - widget->allocation.width - + child_allocation.x = allocation->x + border_width + inner_border.left + xthickness; + child_allocation.y = allocation->y + border_width + inner_border.top + ythickness; + + child_allocation.width = + allocation->width - xthickness * 2 - inner_border.left - inner_border.right - border_width * 2; child_allocation.height = - widget->allocation.height - + allocation->height - ythickness * 2 - inner_border.top - inner_border.bottom - @@ -1548,6 +1559,10 @@ _gtk_button_paint (GtkButton *button, if (gtk_widget_is_drawable (widget)) { + GtkAllocation allocation; + GdkWindow *window; + GtkStyle *style; + border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); gtk_button_get_props (button, &default_border, &default_outside_border, NULL, &interior_focus); @@ -1555,16 +1570,20 @@ _gtk_button_paint (GtkButton *button, "focus-line-width", &focus_width, "focus-padding", &focus_pad, NULL); - - x = widget->allocation.x + border_width; - y = widget->allocation.y + border_width; - width = widget->allocation.width - border_width * 2; - height = widget->allocation.height - border_width * 2; + + gtk_widget_get_allocation (widget, &allocation); + style = gtk_widget_get_style (widget); + window = gtk_widget_get_window (widget); + + x = allocation.x + border_width; + y = allocation.y + border_width; + width = allocation.width - border_width * 2; + height = allocation.height - border_width * 2; if (gtk_widget_has_default (widget) && GTK_BUTTON (widget)->relief == GTK_RELIEF_NORMAL) { - gtk_paint_box (widget->style, widget->window, + gtk_paint_box (style, window, GTK_STATE_NORMAL, GTK_SHADOW_IN, area, widget, "buttondefault", x, y, width, height); @@ -1592,7 +1611,7 @@ _gtk_button_paint (GtkButton *button, if (button->relief != GTK_RELIEF_NONE || button->depressed || gtk_widget_get_state(widget) == GTK_STATE_PRELIGHT) - gtk_paint_box (widget->style, widget->window, + gtk_paint_box (style, window, state_type, shadow_type, area, widget, "button", x, y, width, height); @@ -1611,10 +1630,10 @@ _gtk_button_paint (GtkButton *button, if (interior_focus) { - x += widget->style->xthickness + focus_pad; - y += widget->style->ythickness + focus_pad; - width -= 2 * (widget->style->xthickness + focus_pad); - height -= 2 * (widget->style->ythickness + focus_pad); + x += style->xthickness + focus_pad; + y += style->ythickness + focus_pad; + width -= 2 * (style->xthickness + focus_pad); + height -= 2 * (style->ythickness + focus_pad); } else { @@ -1630,7 +1649,8 @@ _gtk_button_paint (GtkButton *button, y += child_displacement_y; } - gtk_paint_focus (widget->style, widget->window, gtk_widget_get_state (widget), + gtk_paint_focus (style, window, + gtk_widget_get_state (widget), area, widget, "button", x, y, width, height); } @@ -1898,6 +1918,7 @@ gtk_button_get_size (GtkSizeRequest *widget, gint *natural_size) { GtkButton *button = GTK_BUTTON (widget); + GtkStyle *style; GtkWidget *child; GtkBorder default_border; GtkBorder inner_border; @@ -1913,10 +1934,11 @@ gtk_button_get_size (GtkSizeRequest *widget, NULL); border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); + style = gtk_widget_get_style (GTK_WIDGET (widget)); + if (orientation == GTK_ORIENTATION_HORIZONTAL) { - minimum = ((border_width + - GTK_WIDGET (widget)->style->xthickness) * 2 + + minimum = ((border_width + style->xthickness) * 2 + inner_border.left + inner_border.right); if (gtk_widget_get_can_default (GTK_WIDGET (widget))) @@ -1924,8 +1946,7 @@ gtk_button_get_size (GtkSizeRequest *widget, } else { - minimum = ((border_width + - GTK_WIDGET (widget)->style->ythickness) * 2 + + minimum = ((border_width + style->ythickness) * 2 + inner_border.top + inner_border.bottom); if (gtk_widget_get_can_default (GTK_WIDGET (widget))) @@ -2402,14 +2423,19 @@ gtk_button_set_image (GtkButton *button, GtkWidget *image) { GtkButtonPrivate *priv; + GtkWidget *parent; g_return_if_fail (GTK_IS_BUTTON (button)); g_return_if_fail (image == NULL || GTK_IS_WIDGET (image)); priv = GTK_BUTTON_GET_PRIVATE (button); - if (priv->image && priv->image->parent) - gtk_container_remove (GTK_CONTAINER (priv->image->parent), priv->image); + if (priv->image) + { + parent = gtk_widget_get_parent (priv->image); + if (parent) + gtk_container_remove (GTK_CONTAINER (parent), priv->image); + } priv->image = image; priv->image_is_stock = (image == NULL); diff --git a/gtk/gtkcalendar.c b/gtk/gtkcalendar.c index b7f3b5606a..4470a38115 100644 --- a/gtk/gtkcalendar.c +++ b/gtk/gtkcalendar.c @@ -202,16 +202,16 @@ dates_difference(guint year1, guint mm1, guint dd1, #define SCROLL_DELAY_FACTOR 5 /* Color usage */ -#define HEADER_FG_COLOR(widget) (& (widget)->style->fg[gtk_widget_get_state (widget)]) -#define HEADER_BG_COLOR(widget) (& (widget)->style->bg[gtk_widget_get_state (widget)]) -#define SELECTED_BG_COLOR(widget) (& (widget)->style->base[gtk_widget_has_focus (widget) ? GTK_STATE_SELECTED : GTK_STATE_ACTIVE]) -#define SELECTED_FG_COLOR(widget) (& (widget)->style->text[gtk_widget_has_focus (widget) ? GTK_STATE_SELECTED : GTK_STATE_ACTIVE]) -#define NORMAL_DAY_COLOR(widget) (& (widget)->style->text[gtk_widget_get_state (widget)]) -#define PREV_MONTH_COLOR(widget) (& (widget)->style->mid[gtk_widget_get_state (widget)]) -#define NEXT_MONTH_COLOR(widget) (& (widget)->style->mid[gtk_widget_get_state (widget)]) -#define MARKED_COLOR(widget) (& (widget)->style->text[gtk_widget_get_state (widget)]) -#define BACKGROUND_COLOR(widget) (& (widget)->style->base[gtk_widget_get_state (widget)]) -#define HIGHLIGHT_BACK_COLOR(widget) (& (widget)->style->mid[gtk_widget_get_state (widget)]) +#define HEADER_FG_COLOR(widget) (& gtk_widget_get_style (widget)->fg[gtk_widget_get_state (widget)]) +#define HEADER_BG_COLOR(widget) (& gtk_widget_get_style (widget)->bg[gtk_widget_get_state (widget)]) +#define SELECTED_BG_COLOR(widget) (& gtk_widget_get_style (widget)->base[gtk_widget_has_focus (widget) ? GTK_STATE_SELECTED : GTK_STATE_ACTIVE]) +#define SELECTED_FG_COLOR(widget) (& gtk_widget_get_style (widget)->text[gtk_widget_has_focus (widget) ? GTK_STATE_SELECTED : GTK_STATE_ACTIVE]) +#define NORMAL_DAY_COLOR(widget) (& gtk_widget_get_style (widget)->text[gtk_widget_get_state (widget)]) +#define PREV_MONTH_COLOR(widget) (& gtk_widget_get_style (widget)->mid[gtk_widget_get_state (widget)]) +#define NEXT_MONTH_COLOR(widget) (& gtk_widget_get_style (widget)->mid[gtk_widget_get_state (widget)]) +#define MARKED_COLOR(widget) (& gtk_widget_get_style (widget)->text[gtk_widget_get_state (widget)]) +#define BACKGROUND_COLOR(widget) (& gtk_widget_get_style (widget)->base[gtk_widget_get_state (widget)]) +#define HIGHLIGHT_BACK_COLOR(widget) (& gtk_widget_get_style (widget)->mid[gtk_widget_get_state (widget)]) enum { ARROW_YEAR_LEFT, @@ -1258,8 +1258,13 @@ calendar_arrow_rectangle (GtkCalendar *calendar, { GtkWidget *widget = GTK_WIDGET (calendar); GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (calendar); + GtkAllocation allocation; + GtkStyle *style; gboolean year_left; + gtk_widget_get_allocation (widget, &allocation); + style = gtk_widget_get_style (widget); + if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR) year_left = priv->year_before; else @@ -1273,14 +1278,14 @@ calendar_arrow_rectangle (GtkCalendar *calendar, { case ARROW_MONTH_LEFT: if (year_left) - rect->x = (widget->allocation.width - 2 * widget->style->xthickness - - (3 + 2*priv->arrow_width + priv->max_month_width)); + rect->x = (allocation.width - 2 * style->xthickness + - (3 + 2 * priv->arrow_width + priv->max_month_width)); else rect->x = 3; break; case ARROW_MONTH_RIGHT: if (year_left) - rect->x = (widget->allocation.width - 2 * widget->style->xthickness + rect->x = (allocation.width - 2 * style->xthickness - 3 - priv->arrow_width); else rect->x = (priv->arrow_width + priv->max_month_width); @@ -1289,15 +1294,15 @@ calendar_arrow_rectangle (GtkCalendar *calendar, if (year_left) rect->x = 3; else - rect->x = (widget->allocation.width - 2 * widget->style->xthickness - - (3 + 2*priv->arrow_width + priv->max_year_width)); + rect->x = (allocation.width - 2 * style->xthickness + - (3 + 2 * priv->arrow_width + priv->max_year_width)); break; case ARROW_YEAR_RIGHT: if (year_left) rect->x = (priv->arrow_width + priv->max_year_width); else - rect->x = (widget->allocation.width - 2 * widget->style->xthickness - - 3 - priv->arrow_width); + rect->x = (allocation.width - 2 * style->xthickness + - 3 - priv->arrow_width); break; } } @@ -1595,17 +1600,23 @@ calendar_realize_header (GtkCalendar *calendar) /* Header window ------------------------------------- */ if (priv->display_flags & GTK_CALENDAR_SHOW_HEADING) { + GtkAllocation allocation; + GtkStyle *style; + + style = gtk_widget_get_style (widget); + gtk_widget_get_allocation (widget, &allocation); + attributes.wclass = GDK_INPUT_OUTPUT; attributes.window_type = GDK_WINDOW_CHILD; attributes.visual = gtk_widget_get_visual (widget); attributes.colormap = gtk_widget_get_colormap (widget); attributes.event_mask = gtk_widget_get_events (widget) | GDK_EXPOSURE_MASK; attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; - attributes.x = widget->style->xthickness; - attributes.y = widget->style->ythickness; - attributes.width = widget->allocation.width - 2 * attributes.x; + attributes.x = style->xthickness; + attributes.y = style->ythickness; + attributes.width = allocation.width - 2 * attributes.x; attributes.height = priv->header_h; - priv->header_win = gdk_window_new (widget->window, + priv->header_win = gdk_window_new (gtk_widget_get_window (widget), &attributes, attributes_mask); gdk_window_set_background (priv->header_win, @@ -1669,20 +1680,23 @@ calendar_realize_day_names (GtkCalendar *calendar) /* Day names window --------------------------------- */ if ( priv->display_flags & GTK_CALENDAR_SHOW_DAY_NAMES) { + GtkAllocation allocation; + GtkStyle *style; + + style = gtk_widget_get_style (widget); + gtk_widget_get_allocation (widget, &allocation); + attributes.wclass = GDK_INPUT_OUTPUT; attributes.window_type = GDK_WINDOW_CHILD; attributes.visual = gtk_widget_get_visual (widget); attributes.colormap = gtk_widget_get_colormap (widget); attributes.event_mask = gtk_widget_get_events (widget) | GDK_EXPOSURE_MASK; attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; - attributes.x = (widget->style->xthickness + inner_border); - attributes.y = priv->header_h + (widget->style->ythickness - + inner_border); - attributes.width = (widget->allocation.width - - (widget->style->xthickness + inner_border) - * 2); + attributes.x = style->xthickness + inner_border; + attributes.y = priv->header_h + (style->ythickness + inner_border); + attributes.width = allocation.width - (style->xthickness + inner_border) * 2; attributes.height = priv->day_name_h; - priv->day_name_win = gdk_window_new (widget->window, + priv->day_name_win = gdk_window_new (gtk_widget_get_window (widget), &attributes, attributes_mask); gdk_window_set_background (priv->day_name_win, @@ -1708,22 +1722,31 @@ calendar_realize_week_numbers (GtkCalendar *calendar) /* Week number window -------------------------------- */ if (priv->display_flags & GTK_CALENDAR_SHOW_WEEK_NUMBERS) { + GtkStyle *style; + + style = gtk_widget_get_style (widget); + attributes.wclass = GDK_INPUT_OUTPUT; attributes.window_type = GDK_WINDOW_CHILD; attributes.visual = gtk_widget_get_visual (widget); attributes.colormap = gtk_widget_get_colormap (widget); attributes.event_mask = gtk_widget_get_events (widget) | GDK_EXPOSURE_MASK; - attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; - if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR) - attributes.x = widget->style->xthickness + inner_border; - else - attributes.x = widget->allocation.width - priv->week_width - (widget->style->xthickness + inner_border); - attributes.y = (priv->header_h + priv->day_name_h - + (widget->style->ythickness + inner_border)); + if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR) + { + attributes.x = style->xthickness + inner_border; + } + else + { + GtkAllocation allocation; + + gtk_widget_get_allocation (widget, &allocation); + attributes.x = allocation.width - priv->week_width - (style->xthickness + inner_border); + } + attributes.y = priv->header_h + priv->day_name_h + (style->ythickness + inner_border); attributes.width = priv->week_width; attributes.height = priv->main_h; - priv->week_win = gdk_window_new (widget->window, + priv->week_win = gdk_window_new (gtk_widget_get_window (widget), &attributes, attributes_mask); gdk_window_set_background (priv->week_win, BACKGROUND_COLOR (GTK_WIDGET (calendar))); @@ -1741,16 +1764,22 @@ gtk_calendar_realize (GtkWidget *widget) { GtkCalendar *calendar = GTK_CALENDAR (widget); GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (widget); + GtkAllocation allocation; + GtkStyle *style; + GdkWindow *window; GdkWindowAttr attributes; gint attributes_mask; gint inner_border = calendar_get_inner_border (calendar); + gtk_widget_get_allocation (widget, &allocation); + style = gtk_widget_get_style (widget); + gtk_widget_set_realized (widget, TRUE); - - attributes.x = widget->allocation.x; - attributes.y = widget->allocation.y; - attributes.width = widget->allocation.width; - attributes.height = widget->allocation.height; + + attributes.x = allocation.x; + attributes.y = allocation.y; + attributes.width = allocation.width; + attributes.height = allocation.height; attributes.wclass = GDK_INPUT_OUTPUT; attributes.window_type = GDK_WINDOW_CHILD; attributes.event_mask = (gtk_widget_get_events (widget) @@ -1759,11 +1788,13 @@ gtk_calendar_realize (GtkWidget *widget) attributes.colormap = gtk_widget_get_colormap (widget); attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; - widget->window = gdk_window_new (widget->parent->window, - &attributes, attributes_mask); - - widget->style = gtk_style_attach (widget->style, widget->window); - + + window = gdk_window_new (gtk_widget_get_parent_window (widget), + &attributes, attributes_mask); + gtk_widget_set_window (widget, window); + + gtk_widget_style_attach (widget); + /* Header window ------------------------------------- */ calendar_realize_header (calendar); /* Day names window --------------------------------- */ @@ -1776,27 +1807,26 @@ gtk_calendar_realize (GtkWidget *widget) | GDK_POINTER_MOTION_MASK | GDK_LEAVE_NOTIFY_MASK); if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR) - attributes.x = priv->week_width + (widget->style->ythickness + inner_border); + attributes.x = priv->week_width + (style->ythickness + inner_border); else - attributes.x = widget->style->ythickness + inner_border; + attributes.x = style->ythickness + inner_border; + + attributes.y = priv->header_h + priv->day_name_h + (style->ythickness + inner_border); + attributes.width = allocation.width - attributes.x - (style->xthickness + inner_border); - attributes.y = (priv->header_h + priv->day_name_h - + (widget->style->ythickness + inner_border)); - attributes.width = (widget->allocation.width - attributes.x - - (widget->style->xthickness + inner_border)); if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) attributes.width -= priv->week_width; attributes.height = priv->main_h; - priv->main_win = gdk_window_new (widget->window, + priv->main_win = gdk_window_new (window, &attributes, attributes_mask); gdk_window_set_background (priv->main_win, BACKGROUND_COLOR ( GTK_WIDGET ( calendar))); gdk_window_show (priv->main_win); gdk_window_set_user_data (priv->main_win, widget); - gdk_window_set_background (widget->window, BACKGROUND_COLOR (widget)); - gdk_window_show (widget->window); - gdk_window_set_user_data (widget->window, widget); + gdk_window_set_background (window, BACKGROUND_COLOR (widget)); + gdk_window_show (window); + gdk_window_set_user_data (window, widget); } static void @@ -1934,6 +1964,7 @@ gtk_calendar_size_request (GtkWidget *widget, { GtkCalendar *calendar = GTK_CALENDAR (widget); GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (widget); + GtkStyle *style; PangoLayout *layout; PangoRectangle logical_rect; @@ -2125,10 +2156,11 @@ gtk_calendar_size_request (GtkWidget *widget, + (priv->max_week_char_width ? priv->max_week_char_width * 2 + (focus_padding + focus_width) * 2 + calendar_xsep * 2 : 0)); - - - requisition->width = MAX (header_width, main_width + inner_border * 2) + widget->style->xthickness * 2; - + + style = gtk_widget_get_style (widget); + + requisition->width = MAX (header_width, main_width + inner_border * 2) + style->xthickness * 2; + /* * Calculate the requisition height for the widget. */ @@ -2163,8 +2195,8 @@ gtk_calendar_size_request (GtkWidget *widget, height = (priv->header_h + priv->day_name_h + priv->main_h); - - requisition->height = height + (widget->style->ythickness + inner_border) * 2; + + requisition->height = height + (style->ythickness + inner_border) * 2; g_object_unref (layout); } @@ -2175,14 +2207,18 @@ gtk_calendar_size_allocate (GtkWidget *widget, { GtkCalendar *calendar = GTK_CALENDAR (widget); GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (widget); - gint xthickness = widget->style->xthickness; - gint ythickness = widget->style->xthickness; + GtkStyle *style; + gint xthickness, ythickness; guint i; gint inner_border = calendar_get_inner_border (calendar); gint calendar_xsep = calendar_get_xsep (calendar); - widget->allocation = *allocation; - + style = gtk_widget_get_style (widget); + xthickness = style->xthickness; + ythickness = style->xthickness; + + gtk_widget_set_allocation (widget, allocation); + if (priv->display_flags & GTK_CALENDAR_SHOW_WEEK_NUMBERS) { priv->day_width = (priv->min_day_width @@ -2204,7 +2240,7 @@ gtk_calendar_size_allocate (GtkWidget *widget, if (gtk_widget_get_realized (widget)) { - gdk_window_move_resize (widget->window, + gdk_window_move_resize (gtk_widget_get_window (widget), allocation->x, allocation->y, allocation->width, allocation->height); if (priv->header_win) @@ -2225,10 +2261,10 @@ gtk_calendar_size_allocate (GtkWidget *widget, } if (priv->day_name_win) - gdk_window_move_resize (priv->day_name_win, - xthickness + inner_border, - priv->header_h + (widget->style->ythickness + inner_border), - allocation->width - (xthickness + inner_border) * 2, + gdk_window_move_resize (priv->day_name_win, + xthickness + inner_border, + priv->header_h + (style->ythickness + inner_border), + allocation->width - (xthickness + inner_border) * 2, priv->day_name_h); if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR) { @@ -2236,13 +2272,13 @@ gtk_calendar_size_allocate (GtkWidget *widget, gdk_window_move_resize (priv->week_win, (xthickness + inner_border), priv->header_h + priv->day_name_h - + (widget->style->ythickness + inner_border), + + (style->ythickness + inner_border), priv->week_width, priv->main_h); gdk_window_move_resize (priv->main_win, priv->week_width + (xthickness + inner_border), priv->header_h + priv->day_name_h - + (widget->style->ythickness + inner_border), + + (style->ythickness + inner_border), allocation->width - priv->week_width - (xthickness + inner_border) * 2, @@ -2253,7 +2289,7 @@ gtk_calendar_size_allocate (GtkWidget *widget, gdk_window_move_resize (priv->main_win, (xthickness + inner_border), priv->header_h + priv->day_name_h - + (widget->style->ythickness + inner_border), + + (style->ythickness + inner_border), allocation->width - priv->week_width - (xthickness + inner_border) * 2, @@ -2264,7 +2300,7 @@ gtk_calendar_size_allocate (GtkWidget *widget, - priv->week_width - (xthickness + inner_border), priv->header_h + priv->day_name_h - + (widget->style->ythickness + inner_border), + + (style->ythickness + inner_border), priv->week_width, priv->main_h); } @@ -2281,6 +2317,8 @@ calendar_paint_header (GtkCalendar *calendar) { GtkWidget *widget = GTK_WIDGET (calendar); GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (calendar); + GtkAllocation allocation; + GtkStyle *style; cairo_t *cr; char buffer[255]; int x, y; @@ -2300,13 +2338,16 @@ calendar_paint_header (GtkCalendar *calendar) year_left = !priv->year_before; cr = gdk_cairo_create (priv->header_win); - - header_width = widget->allocation.width - 2 * widget->style->xthickness; - + + gtk_widget_get_allocation (widget, &allocation); + style = gtk_widget_get_style (widget); + + header_width = allocation.width - 2 * style->xthickness; + max_month_width = priv->max_month_width; max_year_width = priv->max_year_width; - - gtk_paint_shadow (widget->style, priv->header_win, + + gtk_paint_shadow (style, priv->header_win, GTK_STATE_NORMAL, GTK_SHADOW_OUT, NULL, widget, "calendar", 0, 0, header_width, priv->header_h); @@ -2385,6 +2426,7 @@ calendar_paint_day_names (GtkCalendar *calendar) { GtkWidget *widget = GTK_WIDGET (calendar); GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (calendar); + GtkAllocation allocation; cairo_t *cr; char buffer[255]; int day,i; @@ -2403,9 +2445,11 @@ calendar_paint_day_names (GtkCalendar *calendar) "focus-line-width", &focus_width, "focus-padding", &focus_padding, NULL); - + + gtk_widget_get_allocation (widget, &allocation); + day_width = priv->day_width; - cal_width = widget->allocation.width; + cal_width = allocation.width; day_wid_sep = day_width + DAY_XSEP; /* @@ -2610,6 +2654,7 @@ calendar_paint_day (GtkCalendar *calendar, { GtkWidget *widget = GTK_WIDGET (calendar); GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (calendar); + GtkStyle *style; cairo_t *cr; GdkColor *text_color; gchar *detail; @@ -2626,6 +2671,8 @@ calendar_paint_day (GtkCalendar *calendar, g_return_if_fail (row < 6); g_return_if_fail (col < 7); + style = gtk_widget_get_style (widget); + cr = gdk_cairo_create (priv->main_win); day = priv->day[row][col]; @@ -2706,11 +2753,11 @@ calendar_paint_day (GtkCalendar *calendar, cairo_save (cr); if (priv->selected_day == day) - gdk_cairo_set_source_color (cr, &widget->style->text[GTK_STATE_ACTIVE]); + gdk_cairo_set_source_color (cr, &style->text[GTK_STATE_ACTIVE]); else if (priv->day_month[row][col] == MONTH_CURRENT) - gdk_cairo_set_source_color (cr, &widget->style->base[GTK_STATE_ACTIVE]); + gdk_cairo_set_source_color (cr, &style->base[GTK_STATE_ACTIVE]); else - gdk_cairo_set_source_color (cr, &widget->style->base[GTK_STATE_INSENSITIVE]); + gdk_cairo_set_source_color (cr, &style->base[GTK_STATE_INSENSITIVE]); cairo_set_line_width (cr, 1); cairo_move_to (cr, day_rect.x + 2, y_loc + 0.5); @@ -2764,8 +2811,8 @@ calendar_paint_day (GtkCalendar *calendar, state = gtk_widget_has_focus (widget) ? GTK_STATE_SELECTED : GTK_STATE_ACTIVE; else state = GTK_STATE_NORMAL; - - gtk_paint_focus (widget->style, + + gtk_paint_focus (style, priv->main_win, state, NULL, widget, "calendar-day", @@ -2816,24 +2863,26 @@ calendar_paint_arrow (GtkCalendar *calendar, window = priv->arrow_win[arrow]; if (window) { + GtkStyle *style; cairo_t *cr = gdk_cairo_create (window); gint width, height; gint state; - + + style = gtk_widget_get_style (widget); state = priv->arrow_state[arrow]; - gdk_cairo_set_source_color (cr, &widget->style->bg[state]); + gdk_cairo_set_source_color (cr, &style->bg[state]); cairo_paint (cr); cairo_destroy (cr); gdk_drawable_get_size (window, &width, &height); if (arrow == ARROW_MONTH_LEFT || arrow == ARROW_YEAR_LEFT) - gtk_paint_arrow (widget->style, window, state, + gtk_paint_arrow (style, window, state, GTK_SHADOW_OUT, NULL, widget, "calendar", GTK_ARROW_LEFT, TRUE, width/2 - 3, height/2 - 4, 8, 8); else - gtk_paint_arrow (widget->style, window, state, + gtk_paint_arrow (style, window, state, GTK_SHADOW_OUT, NULL, widget, "calendar", GTK_ARROW_RIGHT, TRUE, width/2 - 4, height/2 - 4, 8, 8); @@ -2850,6 +2899,8 @@ gtk_calendar_expose (GtkWidget *widget, if (gtk_widget_is_drawable (widget)) { + GdkWindow *window; + if (event->window == priv->main_win) calendar_paint_main (calendar); @@ -2865,18 +2916,25 @@ gtk_calendar_expose (GtkWidget *widget, if (event->window == priv->week_win) calendar_paint_week_numbers (calendar); - if (event->window == widget->window) + + window = gtk_widget_get_window (widget); + if (event->window == window) { - gtk_paint_shadow (widget->style, widget->window, gtk_widget_get_state (widget), + GtkAllocation allocation; + + gtk_widget_get_allocation (widget, &allocation); + gtk_paint_shadow (gtk_widget_get_style (widget), + window, + gtk_widget_get_state (widget), GTK_SHADOW_IN, NULL, widget, "calendar", - 0, 0, widget->allocation.width, widget->allocation.height); + 0, 0, allocation.width, allocation.height); } } return FALSE; } - + /**************************************** * Mouse handling * ****************************************/ @@ -3400,6 +3458,7 @@ static void calendar_set_background (GtkWidget *widget) { GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (widget); + GdkWindow *window; gint i; if (gtk_widget_get_realized (widget)) @@ -3422,8 +3481,10 @@ calendar_set_background (GtkWidget *widget) if (priv->main_win) gdk_window_set_background (priv->main_win, BACKGROUND_COLOR (widget)); - if (widget->window) - gdk_window_set_background (widget->window, + + window = gtk_widget_get_window (widget); + if (window) + gdk_window_set_background (window, BACKGROUND_COLOR (widget)); } } diff --git a/gtk/gtkcelllayout.c b/gtk/gtkcelllayout.c index 985457be85..86e8e39644 100644 --- a/gtk/gtkcelllayout.c +++ b/gtk/gtkcelllayout.c @@ -25,34 +25,13 @@ #include "gtkintl.h" -GType -gtk_cell_layout_get_type (void) -{ - static GType cell_layout_type = 0; +typedef GtkCellLayoutIface GtkCellLayoutInterface; +G_DEFINE_INTERFACE (GtkCellLayout, gtk_cell_layout, G_TYPE_OBJECT); - if (! cell_layout_type) - { - const GTypeInfo cell_layout_info = - { - sizeof (GtkCellLayoutIface), - NULL, - NULL, - NULL, - NULL, - NULL, - 0, - 0, - NULL - }; - - cell_layout_type = - g_type_register_static (G_TYPE_INTERFACE, I_("GtkCellLayout"), - &cell_layout_info, 0); - - g_type_interface_add_prerequisite (cell_layout_type, G_TYPE_OBJECT); - } - return cell_layout_type; +static void +gtk_cell_layout_default_init (GtkCellLayoutInterface *iface) +{ } /** diff --git a/gtk/gtkcellrenderer.c b/gtk/gtkcellrenderer.c index 8c940f24d7..865dd96274 100644 --- a/gtk/gtkcellrenderer.c +++ b/gtk/gtkcellrenderer.c @@ -62,7 +62,7 @@ static void gtk_cell_renderer_get_width_for_height (GtkCellSizeRequest -struct _GtkCellRendererPriv +struct _GtkCellRendererPrivate { gfloat xalign; gfloat yalign; @@ -159,11 +159,11 @@ gtk_cell_renderer_get_type (void) static void gtk_cell_renderer_init (GtkCellRenderer *cell) { - GtkCellRendererPriv *priv; + GtkCellRendererPrivate *priv; cell->priv = G_TYPE_INSTANCE_GET_PRIVATE (cell, GTK_TYPE_CELL_RENDERER, - GtkCellRendererPriv); + GtkCellRendererPrivate); priv = cell->priv; priv->mode = GTK_CELL_RENDERER_MODE_INERT; @@ -390,7 +390,7 @@ gtk_cell_renderer_class_init (GtkCellRendererClass *class) P_("Cell background set"), P_("Whether this tag affects the cell background color")); - g_type_class_add_private (class, sizeof (GtkCellRendererPriv)); + g_type_class_add_private (class, sizeof (GtkCellRendererPrivate)); } static void @@ -400,7 +400,7 @@ gtk_cell_renderer_get_property (GObject *object, GParamSpec *pspec) { GtkCellRenderer *cell = GTK_CELL_RENDERER (object); - GtkCellRendererPriv *priv = cell->priv; + GtkCellRendererPrivate *priv = cell->priv; switch (param_id) { @@ -469,7 +469,7 @@ gtk_cell_renderer_set_property (GObject *object, GParamSpec *pspec) { GtkCellRenderer *cell = GTK_CELL_RENDERER (object); - GtkCellRendererPriv *priv = cell->priv; + GtkCellRendererPrivate *priv = cell->priv; switch (param_id) { @@ -539,7 +539,7 @@ static void set_cell_bg_color (GtkCellRenderer *cell, GdkColor *color) { - GtkCellRendererPriv *priv = cell->priv; + GtkCellRendererPrivate *priv = cell->priv; if (color) { @@ -640,7 +640,7 @@ gtk_cell_renderer_render (GtkCellRenderer *cell, GtkCellRendererState flags) { gboolean selected = FALSE; - GtkCellRendererPriv *priv = cell->priv; + GtkCellRendererPrivate *priv = cell->priv; g_return_if_fail (GTK_IS_CELL_RENDERER (cell)); g_return_if_fail (GTK_CELL_RENDERER_GET_CLASS (cell)->render != NULL); @@ -693,7 +693,7 @@ gtk_cell_renderer_activate (GtkCellRenderer *cell, const GdkRectangle *cell_area, GtkCellRendererState flags) { - GtkCellRendererPriv *priv; + GtkCellRendererPrivate *priv; g_return_val_if_fail (GTK_IS_CELL_RENDERER (cell), FALSE); @@ -739,7 +739,7 @@ gtk_cell_renderer_start_editing (GtkCellRenderer *cell, GtkCellRendererState flags) { - GtkCellRendererPriv *priv; + GtkCellRendererPrivate *priv; GtkCellEditable *editable; g_return_val_if_fail (GTK_IS_CELL_RENDERER (cell), NULL); @@ -782,7 +782,7 @@ gtk_cell_renderer_set_fixed_size (GtkCellRenderer *cell, gint width, gint height) { - GtkCellRendererPriv *priv; + GtkCellRendererPrivate *priv; g_return_if_fail (GTK_IS_CELL_RENDERER (cell)); g_return_if_fail (width >= -1 && height >= -1); @@ -822,7 +822,7 @@ gtk_cell_renderer_get_fixed_size (GtkCellRenderer *cell, gint *width, gint *height) { - GtkCellRendererPriv *priv; + GtkCellRendererPrivate *priv; g_return_if_fail (GTK_IS_CELL_RENDERER (cell)); @@ -849,7 +849,7 @@ gtk_cell_renderer_set_alignment (GtkCellRenderer *cell, gfloat xalign, gfloat yalign) { - GtkCellRendererPriv *priv; + GtkCellRendererPrivate *priv; g_return_if_fail (GTK_IS_CELL_RENDERER (cell)); g_return_if_fail (xalign >= 0.0 && xalign <= 1.0); @@ -892,7 +892,7 @@ gtk_cell_renderer_get_alignment (GtkCellRenderer *cell, gfloat *xalign, gfloat *yalign) { - GtkCellRendererPriv *priv; + GtkCellRendererPrivate *priv; g_return_if_fail (GTK_IS_CELL_RENDERER (cell)); @@ -919,7 +919,7 @@ gtk_cell_renderer_set_padding (GtkCellRenderer *cell, gint xpad, gint ypad) { - GtkCellRendererPriv *priv; + GtkCellRendererPrivate *priv; g_return_if_fail (GTK_IS_CELL_RENDERER (cell)); g_return_if_fail (xpad >= 0 && xpad >= 0); @@ -961,7 +961,7 @@ gtk_cell_renderer_get_padding (GtkCellRenderer *cell, gint *xpad, gint *ypad) { - GtkCellRendererPriv *priv; + GtkCellRendererPrivate *priv; g_return_if_fail (GTK_IS_CELL_RENDERER (cell)); @@ -986,7 +986,7 @@ void gtk_cell_renderer_set_visible (GtkCellRenderer *cell, gboolean visible) { - GtkCellRendererPriv *priv; + GtkCellRendererPrivate *priv; g_return_if_fail (GTK_IS_CELL_RENDERER (cell)); @@ -1030,7 +1030,7 @@ void gtk_cell_renderer_set_sensitive (GtkCellRenderer *cell, gboolean sensitive) { - GtkCellRendererPriv *priv; + GtkCellRendererPrivate *priv; g_return_if_fail (GTK_IS_CELL_RENDERER (cell)); @@ -1080,7 +1080,7 @@ void gtk_cell_renderer_stop_editing (GtkCellRenderer *cell, gboolean canceled) { - GtkCellRendererPriv *priv; + GtkCellRendererPrivate *priv; g_return_if_fail (GTK_IS_CELL_RENDERER (cell)); @@ -1199,7 +1199,7 @@ _gtk_cell_renderer_calc_offset (GtkCellRenderer *cell, gint *x_offset, gint *y_offset) { - GtkCellRendererPriv *priv; + GtkCellRendererPrivate *priv; g_return_if_fail (GTK_IS_CELL_RENDERER (cell)); g_return_if_fail (cell_area != NULL); diff --git a/gtk/gtkcellrenderer.h b/gtk/gtkcellrenderer.h index fac5b8daf9..837b7ae13f 100644 --- a/gtk/gtkcellrenderer.h +++ b/gtk/gtkcellrenderer.h @@ -52,16 +52,16 @@ typedef enum #define GTK_IS_CELL_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_CELL_RENDERER)) #define GTK_CELL_RENDERER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_CELL_RENDERER, GtkCellRendererClass)) -typedef struct _GtkCellRenderer GtkCellRenderer; -typedef struct _GtkCellRendererPriv GtkCellRendererPriv; -typedef struct _GtkCellRendererClass GtkCellRendererClass; +typedef struct _GtkCellRenderer GtkCellRenderer; +typedef struct _GtkCellRendererPrivate GtkCellRendererPrivate; +typedef struct _GtkCellRendererClass GtkCellRendererClass; struct _GtkCellRenderer { GtkObject parent; /* <private> */ - GtkCellRendererPriv *priv; + GtkCellRendererPrivate *priv; }; struct _GtkCellRendererClass diff --git a/gtk/gtkcellrendereraccel.c b/gtk/gtkcellrendereraccel.c index 829c513b1f..b5f58574f1 100644 --- a/gtk/gtkcellrendereraccel.c +++ b/gtk/gtkcellrendereraccel.c @@ -71,7 +71,7 @@ enum { PROP_ACCEL_MODE }; -struct _GtkCellRendererAccelPriv +struct _GtkCellRendererAccelPrivate { GtkCellRendererAccelMode accel_mode; @@ -99,7 +99,7 @@ gtk_cell_renderer_accel_init (GtkCellRendererAccel *cell_accel) cell_accel->priv = G_TYPE_INSTANCE_GET_PRIVATE (cell_accel, GTK_TYPE_CELL_RENDERER_ACCEL, - GtkCellRendererAccelPriv); + GtkCellRendererAccelPrivate); text = convert_keysym_state_to_string (cell_accel, 0, 0, 0); g_object_set (cell_accel, "text", text, NULL); @@ -234,7 +234,7 @@ gtk_cell_renderer_accel_class_init (GtkCellRendererAccelClass *cell_accel_class) G_TYPE_NONE, 1, G_TYPE_STRING); - g_type_class_add_private (cell_accel_class, sizeof (GtkCellRendererAccelPriv)); + g_type_class_add_private (cell_accel_class, sizeof (GtkCellRendererAccelPrivate)); } @@ -259,7 +259,7 @@ convert_keysym_state_to_string (GtkCellRendererAccel *accel, GdkModifierType mask, guint keycode) { - GtkCellRendererAccelPriv *priv = accel->priv; + GtkCellRendererAccelPrivate *priv = accel->priv; if (keysym == 0 && keycode == 0) /* This label is displayed in a treeview cell displaying @@ -307,7 +307,7 @@ gtk_cell_renderer_accel_get_property (GObject *object, GValue *value, GParamSpec *pspec) { - GtkCellRendererAccelPriv *priv = GTK_CELL_RENDERER_ACCEL (object)->priv; + GtkCellRendererAccelPrivate *priv = GTK_CELL_RENDERER_ACCEL (object)->priv; switch (param_id) { @@ -339,7 +339,7 @@ gtk_cell_renderer_accel_set_property (GObject *object, GParamSpec *pspec) { GtkCellRendererAccel *accel = GTK_CELL_RENDERER_ACCEL (object); - GtkCellRendererAccelPriv *priv = accel->priv; + GtkCellRendererAccelPrivate *priv = accel->priv; gboolean changed = FALSE; switch (param_id) @@ -407,7 +407,7 @@ gtk_cell_renderer_accel_get_size (GtkCellRenderer *cell, gint *height) { - GtkCellRendererAccelPriv *priv = GTK_CELL_RENDERER_ACCEL (cell)->priv; + GtkCellRendererAccelPrivate *priv = GTK_CELL_RENDERER_ACCEL (cell)->priv; GtkRequisition requisition; if (priv->sizing_label == NULL) @@ -430,7 +430,7 @@ grab_key_callback (GtkWidget *widget, GdkEventKey *event, GtkCellRendererAccel *accel) { - GtkCellRendererAccelPriv *priv = accel->priv; + GtkCellRendererAccelPrivate *priv = accel->priv; GdkModifierType accel_mods = 0; guint accel_key; gchar *path; @@ -525,7 +525,7 @@ static void ungrab_stuff (GtkWidget *widget, GtkCellRendererAccel *accel) { - GtkCellRendererAccelPriv *priv = accel->priv; + GtkCellRendererAccelPrivate *priv = accel->priv; gtk_device_grab_remove (priv->grab_widget, priv->grab_pointer); gdk_device_ungrab (priv->grab_keyboard, GDK_CURRENT_TIME); @@ -579,12 +579,14 @@ gtk_cell_renderer_accel_start_editing (GtkCellRenderer *cell, GdkRectangle *cell_area, GtkCellRendererState flags) { - GtkCellRendererAccelPriv *priv; + GtkCellRendererAccelPrivate *priv; GtkCellRendererText *celltext; GtkCellRendererAccel *accel; + GtkStyle *style; GtkWidget *label; GtkWidget *eventbox; GdkDevice *device, *keyb, *pointer; + GdkWindow *window; gboolean editable; guint32 time; @@ -597,7 +599,10 @@ gtk_cell_renderer_accel_start_editing (GtkCellRenderer *cell, if (editable == FALSE) return NULL; - g_return_val_if_fail (widget->window != NULL, NULL); + window = gtk_widget_get_window (widget); + style = gtk_widget_get_style (widget); + + g_return_val_if_fail (window != NULL, NULL); if (event) device = gdk_event_get_device (event); @@ -620,13 +625,13 @@ gtk_cell_renderer_accel_start_editing (GtkCellRenderer *cell, time = gdk_event_get_time (event); - if (gdk_device_grab (keyb, widget->window, + if (gdk_device_grab (keyb, window, GDK_OWNERSHIP_WINDOW, FALSE, GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK, NULL, time) != GDK_GRAB_SUCCESS) return NULL; - if (gdk_device_grab (pointer, widget->window, + if (gdk_device_grab (pointer, window, GDK_OWNERSHIP_WINDOW, FALSE, GDK_BUTTON_PRESS_MASK, NULL, time) != GDK_GRAB_SUCCESS) @@ -650,13 +655,15 @@ gtk_cell_renderer_accel_start_editing (GtkCellRenderer *cell, label = gtk_label_new (NULL); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + + gtk_widget_modify_bg (eventbox, GTK_STATE_NORMAL, - &widget->style->bg[GTK_STATE_SELECTED]); + &style->bg[GTK_STATE_SELECTED]); gtk_widget_modify_fg (label, GTK_STATE_NORMAL, - &widget->style->fg[GTK_STATE_SELECTED]); - + &style->fg[GTK_STATE_SELECTED]); + /* This label is displayed in a treeview cell displaying * an accelerator when the cell is clicked to change the * acelerator. diff --git a/gtk/gtkcellrendereraccel.h b/gtk/gtkcellrendereraccel.h index 1efe0c1162..73bb90da9c 100644 --- a/gtk/gtkcellrendereraccel.h +++ b/gtk/gtkcellrendereraccel.h @@ -35,9 +35,9 @@ G_BEGIN_DECLS #define GTK_IS_CELL_RENDERER_ACCEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_CELL_RENDERER_ACCEL)) #define GTK_CELL_RENDERER_ACCEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_CELL_RENDERER_ACCEL, GtkCellRendererAccelClass)) -typedef struct _GtkCellRendererAccel GtkCellRendererAccel; -typedef struct _GtkCellRendererAccelPriv GtkCellRendererAccelPriv; -typedef struct _GtkCellRendererAccelClass GtkCellRendererAccelClass; +typedef struct _GtkCellRendererAccel GtkCellRendererAccel; +typedef struct _GtkCellRendererAccelPrivate GtkCellRendererAccelPrivate; +typedef struct _GtkCellRendererAccelClass GtkCellRendererAccelClass; typedef enum @@ -52,7 +52,7 @@ struct _GtkCellRendererAccel GtkCellRendererText parent; /*< private >*/ - GtkCellRendererAccelPriv *priv; + GtkCellRendererAccelPrivate *priv; }; struct _GtkCellRendererAccelClass diff --git a/gtk/gtkcellrenderercombo.c b/gtk/gtkcellrenderercombo.c index 340a1819d6..effbc89db6 100644 --- a/gtk/gtkcellrenderercombo.c +++ b/gtk/gtkcellrenderercombo.c @@ -31,7 +31,7 @@ #include "gtkmarshalers.h" #include "gtkprivate.h" -struct _GtkCellRendererComboPriv +struct _GtkCellRendererComboPrivate { GtkTreeModel *model; @@ -187,17 +187,17 @@ gtk_cell_renderer_combo_class_init (GtkCellRendererComboClass *klass) G_TYPE_STRING, GTK_TYPE_TREE_ITER); - g_type_class_add_private (klass, sizeof (GtkCellRendererComboPriv)); + g_type_class_add_private (klass, sizeof (GtkCellRendererComboPrivate)); } static void gtk_cell_renderer_combo_init (GtkCellRendererCombo *self) { - GtkCellRendererComboPriv *priv; + GtkCellRendererComboPrivate *priv; self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GTK_TYPE_CELL_RENDERER_COMBO, - GtkCellRendererComboPriv); + GtkCellRendererComboPrivate); priv = self->priv; priv->model = NULL; @@ -231,7 +231,7 @@ static void gtk_cell_renderer_combo_finalize (GObject *object) { GtkCellRendererCombo *cell = GTK_CELL_RENDERER_COMBO (object); - GtkCellRendererComboPriv *priv = cell->priv; + GtkCellRendererComboPrivate *priv = cell->priv; if (priv->model) { @@ -249,7 +249,7 @@ gtk_cell_renderer_combo_get_property (GObject *object, GParamSpec *pspec) { GtkCellRendererCombo *cell = GTK_CELL_RENDERER_COMBO (object); - GtkCellRendererComboPriv *priv = cell->priv; + GtkCellRendererComboPrivate *priv = cell->priv; switch (prop_id) { @@ -275,7 +275,7 @@ gtk_cell_renderer_combo_set_property (GObject *object, GParamSpec *pspec) { GtkCellRendererCombo *cell = GTK_CELL_RENDERER_COMBO (object); - GtkCellRendererComboPriv *priv = cell->priv; + GtkCellRendererComboPrivate *priv = cell->priv; switch (prop_id) { @@ -330,7 +330,7 @@ gtk_cell_renderer_combo_editing_done (GtkCellEditable *combo, GtkCellRendererCombo *cell; GtkEntry *entry; gboolean canceled; - GtkCellRendererComboPriv *priv; + GtkCellRendererComboPrivate *priv; cell = GTK_CELL_RENDERER_COMBO (data); priv = cell->priv; @@ -397,7 +397,7 @@ find_text (GtkTreeModel *model, GtkTreeIter *iter, gpointer data) { - GtkCellRendererComboPriv *priv; + GtkCellRendererComboPrivate *priv; SearchData *search_data = (SearchData *)data; gchar *text, *cell_text; @@ -432,7 +432,7 @@ gtk_cell_renderer_combo_start_editing (GtkCellRenderer *cell, GtkCellRendererText *cell_text; GtkWidget *combo; SearchData search_data; - GtkCellRendererComboPriv *priv; + GtkCellRendererComboPrivate *priv; gboolean editable; gchar *text; diff --git a/gtk/gtkcellrenderercombo.h b/gtk/gtkcellrenderercombo.h index 9bd1b8b398..dc72cc2183 100644 --- a/gtk/gtkcellrenderercombo.h +++ b/gtk/gtkcellrenderercombo.h @@ -36,16 +36,16 @@ G_BEGIN_DECLS #define GTK_IS_CELL_RENDERER_COMBO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_CELL_RENDERER_COMBO)) #define GTK_CELL_RENDERER_COMBO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_CELL_RENDERER_COMBO, GtkCellRendererTextClass)) -typedef struct _GtkCellRendererCombo GtkCellRendererCombo; -typedef struct _GtkCellRendererComboPriv GtkCellRendererComboPriv; -typedef struct _GtkCellRendererComboClass GtkCellRendererComboClass; +typedef struct _GtkCellRendererCombo GtkCellRendererCombo; +typedef struct _GtkCellRendererComboPrivate GtkCellRendererComboPrivate; +typedef struct _GtkCellRendererComboClass GtkCellRendererComboClass; struct _GtkCellRendererCombo { GtkCellRendererText parent; /* <private> */ - GtkCellRendererComboPriv *priv; + GtkCellRendererComboPrivate *priv; }; struct _GtkCellRendererComboClass diff --git a/gtk/gtkcellrendererpixbuf.c b/gtk/gtkcellrendererpixbuf.c index 135b63d926..ce88b817a6 100644 --- a/gtk/gtkcellrendererpixbuf.c +++ b/gtk/gtkcellrendererpixbuf.c @@ -67,7 +67,7 @@ enum { }; -struct _GtkCellRendererPixbufPriv +struct _GtkCellRendererPixbufPrivate { GtkIconSize stock_size; @@ -91,11 +91,11 @@ G_DEFINE_TYPE (GtkCellRendererPixbuf, gtk_cell_renderer_pixbuf, GTK_TYPE_CELL_RE static void gtk_cell_renderer_pixbuf_init (GtkCellRendererPixbuf *cellpixbuf) { - GtkCellRendererPixbufPriv *priv; + GtkCellRendererPixbufPrivate *priv; cellpixbuf->priv = G_TYPE_INSTANCE_GET_PRIVATE (cellpixbuf, GTK_TYPE_CELL_RENDERER_PIXBUF, - GtkCellRendererPixbufPriv); + GtkCellRendererPixbufPrivate); priv = cellpixbuf->priv; priv->stock_size = GTK_ICON_SIZE_MENU; @@ -219,14 +219,14 @@ gtk_cell_renderer_pixbuf_class_init (GtkCellRendererPixbufClass *class) - g_type_class_add_private (object_class, sizeof (GtkCellRendererPixbufPriv)); + g_type_class_add_private (object_class, sizeof (GtkCellRendererPixbufPrivate)); } static void gtk_cell_renderer_pixbuf_finalize (GObject *object) { GtkCellRendererPixbuf *cellpixbuf = GTK_CELL_RENDERER_PIXBUF (object); - GtkCellRendererPixbufPriv *priv = cellpixbuf->priv; + GtkCellRendererPixbufPrivate *priv = cellpixbuf->priv; if (priv->pixbuf) g_object_unref (priv->pixbuf); @@ -252,7 +252,7 @@ gtk_cell_renderer_pixbuf_get_property (GObject *object, GParamSpec *pspec) { GtkCellRendererPixbuf *cellpixbuf = GTK_CELL_RENDERER_PIXBUF (object); - GtkCellRendererPixbufPriv *priv = cellpixbuf->priv; + GtkCellRendererPixbufPrivate *priv = cellpixbuf->priv; switch (param_id) { @@ -296,7 +296,7 @@ gtk_cell_renderer_pixbuf_set_property (GObject *object, GParamSpec *pspec) { GtkCellRendererPixbuf *cellpixbuf = GTK_CELL_RENDERER_PIXBUF (object); - GtkCellRendererPixbufPriv *priv = cellpixbuf->priv; + GtkCellRendererPixbufPrivate *priv = cellpixbuf->priv; switch (param_id) { @@ -477,7 +477,7 @@ static void gtk_cell_renderer_pixbuf_create_stock_pixbuf (GtkCellRendererPixbuf *cellpixbuf, GtkWidget *widget) { - GtkCellRendererPixbufPriv *priv = cellpixbuf->priv; + GtkCellRendererPixbufPrivate *priv = cellpixbuf->priv; if (priv->pixbuf) g_object_unref (priv->pixbuf); @@ -494,7 +494,7 @@ static void gtk_cell_renderer_pixbuf_create_themed_pixbuf (GtkCellRendererPixbuf *cellpixbuf, GtkWidget *widget) { - GtkCellRendererPixbufPriv *priv = cellpixbuf->priv; + GtkCellRendererPixbufPrivate *priv = cellpixbuf->priv; GdkScreen *screen; GtkIconTheme *icon_theme; GtkSettings *settings; @@ -553,7 +553,7 @@ create_symbolic_pixbuf (GtkCellRendererPixbuf *cellpixbuf, GtkWidget *widget, GtkStateType state) { - GtkCellRendererPixbufPriv *priv = cellpixbuf->priv; + GtkCellRendererPixbufPrivate *priv = cellpixbuf->priv; GdkScreen *screen; GtkIconTheme *icon_theme; GtkSettings *settings; @@ -674,7 +674,7 @@ gtk_cell_renderer_pixbuf_get_size (GtkCellRenderer *cell, gint *height) { GtkCellRendererPixbuf *cellpixbuf = (GtkCellRendererPixbuf *) cell; - GtkCellRendererPixbufPriv *priv = cellpixbuf->priv; + GtkCellRendererPixbufPrivate *priv = cellpixbuf->priv; gint pixbuf_width = 0; gint pixbuf_height = 0; gint calc_width; @@ -752,7 +752,7 @@ gtk_cell_renderer_pixbuf_render (GtkCellRenderer *cell, { GtkCellRendererPixbuf *cellpixbuf = (GtkCellRendererPixbuf *) cell; - GtkCellRendererPixbufPriv *priv = cellpixbuf->priv; + GtkCellRendererPixbufPrivate *priv = cellpixbuf->priv; GdkPixbuf *pixbuf; GdkPixbuf *invisible = NULL; GdkPixbuf *colorized = NULL; @@ -812,8 +812,8 @@ gtk_cell_renderer_pixbuf_render (GtkCellRenderer *cell, */ gtk_icon_source_set_size (source, GTK_ICON_SIZE_SMALL_TOOLBAR); gtk_icon_source_set_size_wildcarded (source, FALSE); - - invisible = gtk_style_render_icon (widget->style, + + invisible = gtk_style_render_icon (gtk_widget_get_style (widget), source, gtk_widget_get_direction (widget), GTK_STATE_INSENSITIVE, @@ -844,7 +844,7 @@ gtk_cell_renderer_pixbuf_render (GtkCellRenderer *cell, symbolic = create_symbolic_pixbuf (cellpixbuf, widget, state); if (!symbolic) { colorized = create_colorized_pixbuf (pixbuf, - &widget->style->base[state]); + >k_widget_get_style (widget)->base[state]); pixbuf = colorized; } else { diff --git a/gtk/gtkcellrendererpixbuf.h b/gtk/gtkcellrendererpixbuf.h index b4830a0a44..7a8ba49818 100644 --- a/gtk/gtkcellrendererpixbuf.h +++ b/gtk/gtkcellrendererpixbuf.h @@ -37,16 +37,16 @@ G_BEGIN_DECLS #define GTK_IS_CELL_RENDERER_PIXBUF_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_CELL_RENDERER_PIXBUF)) #define GTK_CELL_RENDERER_PIXBUF_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_CELL_RENDERER_PIXBUF, GtkCellRendererPixbufClass)) -typedef struct _GtkCellRendererPixbuf GtkCellRendererPixbuf; -typedef struct _GtkCellRendererPixbufPriv GtkCellRendererPixbufPriv; -typedef struct _GtkCellRendererPixbufClass GtkCellRendererPixbufClass; +typedef struct _GtkCellRendererPixbuf GtkCellRendererPixbuf; +typedef struct _GtkCellRendererPixbufPrivate GtkCellRendererPixbufPrivate; +typedef struct _GtkCellRendererPixbufClass GtkCellRendererPixbufClass; struct _GtkCellRendererPixbuf { GtkCellRenderer parent; /*< private >*/ - GtkCellRendererPixbufPriv *priv; + GtkCellRendererPixbufPrivate *priv; }; struct _GtkCellRendererPixbufClass diff --git a/gtk/gtkcellrendererprogress.c b/gtk/gtkcellrendererprogress.c index f6f3a9937a..60f0bdbdb6 100644 --- a/gtk/gtkcellrendererprogress.c +++ b/gtk/gtkcellrendererprogress.c @@ -534,6 +534,7 @@ gtk_cell_renderer_progress_render (GtkCellRenderer *cell, { GtkCellRendererProgress *cellprogress = GTK_CELL_RENDERER_PROGRESS (cell); GtkCellRendererProgressPrivate *priv= cellprogress->priv; + GtkStyle *style; PangoLayout *layout; PangoRectangle logical_rect; gint x, y, w, h, x_pos, y_pos, bar_position, bar_size, start, full_size; @@ -541,6 +542,8 @@ gtk_cell_renderer_progress_render (GtkCellRenderer *cell, GdkRectangle clip; gboolean is_rtl; + style = gtk_widget_get_style (widget); + is_rtl = gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL; gtk_cell_renderer_get_padding (cell, &xpad, &ypad); @@ -553,7 +556,7 @@ gtk_cell_renderer_progress_render (GtkCellRenderer *cell, * but some engines don't paint anything with that detail for * non-GtkProgressBar widgets. */ - gtk_paint_box (widget->style, + gtk_paint_box (style, window, GTK_STATE_NORMAL, GTK_SHADOW_IN, NULL, widget, NULL, @@ -601,7 +604,7 @@ gtk_cell_renderer_progress_render (GtkCellRenderer *cell, clip.y = bar_position; } - gtk_paint_box (widget->style, + gtk_paint_box (style, window, GTK_STATE_SELECTED, GTK_SHADOW_OUT, &clip, widget, "bar", @@ -620,13 +623,13 @@ gtk_cell_renderer_progress_render (GtkCellRenderer *cell, else text_xalign = priv->text_xalign; - x_pos = x + widget->style->xthickness + text_xalign * - (w - 2 * widget->style->xthickness - logical_rect.width); + x_pos = x + style->xthickness + text_xalign * + (w - 2 * style->xthickness - logical_rect.width); - y_pos = y + widget->style->ythickness + priv->text_yalign * - (h - 2 * widget->style->ythickness - logical_rect.height); - - gtk_paint_layout (widget->style, window, + y_pos = y + style->ythickness + priv->text_yalign * + (h - 2 * style->ythickness - logical_rect.height); + + gtk_paint_layout (style, window, GTK_STATE_SELECTED, FALSE, &clip, widget, "progressbar", x_pos, y_pos, @@ -646,7 +649,7 @@ gtk_cell_renderer_progress_render (GtkCellRenderer *cell, clip.height = bar_position - y; } - gtk_paint_layout (widget->style, window, + gtk_paint_layout (style, window, GTK_STATE_NORMAL, FALSE, &clip, widget, "progressbar", x_pos, y_pos, @@ -667,7 +670,7 @@ gtk_cell_renderer_progress_render (GtkCellRenderer *cell, clip.height = y + h - (bar_position + bar_size); } - gtk_paint_layout (widget->style, window, + gtk_paint_layout (style, window, GTK_STATE_NORMAL, FALSE, &clip, widget, "progressbar", x_pos, y_pos, diff --git a/gtk/gtkcellrendererspinner.c b/gtk/gtkcellrendererspinner.c index 67283ecbcd..9db5377a03 100644 --- a/gtk/gtkcellrendererspinner.c +++ b/gtk/gtkcellrendererspinner.c @@ -376,7 +376,7 @@ gtk_cell_renderer_spinner_render (GtkCellRenderer *cellr, state = GTK_STATE_PRELIGHT; } - gtk_paint_spinner (widget->style, + gtk_paint_spinner (gtk_widget_get_style (widget), window, state, expose_area, diff --git a/gtk/gtkcellrenderertext.c b/gtk/gtkcellrenderertext.c index 5fd484a5ee..f0b44453e1 100644 --- a/gtk/gtkcellrenderertext.c +++ b/gtk/gtkcellrenderertext.c @@ -133,7 +133,7 @@ static guint text_cell_renderer_signals [LAST_SIGNAL]; #define GTK_CELL_RENDERER_TEXT_PATH "gtk-cell-renderer-text-path" -struct _GtkCellRendererTextPriv +struct _GtkCellRendererTextPrivate { GtkWidget *entry; @@ -187,12 +187,12 @@ G_DEFINE_TYPE_WITH_CODE (GtkCellRendererText, gtk_cell_renderer_text, GTK_TYPE_C static void gtk_cell_renderer_text_init (GtkCellRendererText *celltext) { - GtkCellRendererTextPriv *priv; + GtkCellRendererTextPrivate *priv; GtkCellRenderer *cell = GTK_CELL_RENDERER (celltext); celltext->priv = G_TYPE_INSTANCE_GET_PRIVATE (celltext, GTK_TYPE_CELL_RENDERER_TEXT, - GtkCellRendererTextPriv); + GtkCellRendererTextPrivate); priv = celltext->priv; gtk_cell_renderer_set_alignment (cell, 0.0, 0.5); @@ -645,14 +645,14 @@ gtk_cell_renderer_text_class_init (GtkCellRendererTextClass *class) G_TYPE_STRING, G_TYPE_STRING); - g_type_class_add_private (object_class, sizeof (GtkCellRendererTextPriv)); + g_type_class_add_private (object_class, sizeof (GtkCellRendererTextPrivate)); } static void gtk_cell_renderer_text_finalize (GObject *object) { GtkCellRendererText *celltext = GTK_CELL_RENDERER_TEXT (object); - GtkCellRendererTextPriv *priv = celltext->priv; + GtkCellRendererTextPrivate *priv = celltext->priv; pango_font_description_free (priv->font); @@ -696,7 +696,7 @@ gtk_cell_renderer_text_get_property (GObject *object, GParamSpec *pspec) { GtkCellRendererText *celltext = GTK_CELL_RENDERER_TEXT (object); - GtkCellRendererTextPriv *priv = celltext->priv; + GtkCellRendererTextPrivate *priv = celltext->priv; switch (param_id) { @@ -887,7 +887,7 @@ static void set_bg_color (GtkCellRendererText *celltext, GdkColor *color) { - GtkCellRendererTextPriv *priv = celltext->priv; + GtkCellRendererTextPrivate *priv = celltext->priv; if (color) { @@ -916,7 +916,7 @@ static void set_fg_color (GtkCellRendererText *celltext, GdkColor *color) { - GtkCellRendererTextPriv *priv = celltext->priv; + GtkCellRendererTextPrivate *priv = celltext->priv; if (color) { @@ -1020,7 +1020,7 @@ static void set_font_description (GtkCellRendererText *celltext, PangoFontDescription *font_desc) { - GtkCellRendererTextPriv *priv = celltext->priv; + GtkCellRendererTextPrivate *priv = celltext->priv; GObject *object = G_OBJECT (celltext); PangoFontDescription *new_font_desc; PangoFontMask old_mask, new_mask, changed_mask, set_changed_mask; @@ -1072,7 +1072,7 @@ gtk_cell_renderer_text_set_property (GObject *object, GParamSpec *pspec) { GtkCellRendererText *celltext = GTK_CELL_RENDERER_TEXT (object); - GtkCellRendererTextPriv *priv = celltext->priv; + GtkCellRendererTextPrivate *priv = celltext->priv; switch (param_id) { @@ -1433,7 +1433,7 @@ get_layout (GtkCellRendererText *celltext, GdkRectangle *cell_area, GtkCellRendererState flags) { - GtkCellRendererTextPriv *priv = celltext->priv; + GtkCellRendererTextPrivate *priv = celltext->priv; PangoAttrList *attr_list; PangoLayout *layout; PangoUnderline uline; @@ -1574,7 +1574,7 @@ get_size (GtkCellRenderer *cell, gint *height) { GtkCellRendererText *celltext = GTK_CELL_RENDERER_TEXT (cell); - GtkCellRendererTextPriv *priv = celltext->priv; + GtkCellRendererTextPrivate *priv = celltext->priv; PangoRectangle rect; gint xpad, ypad; gint cell_width, cell_height; @@ -1588,7 +1588,7 @@ get_size (GtkCellRenderer *cell, PangoFontDescription *font_desc; gint row_height; - font_desc = pango_font_description_copy_static (widget->style->font_desc); + font_desc = pango_font_description_copy_static (gtk_widget_get_style (widget)->font_desc); pango_font_description_merge_static (font_desc, priv->font, TRUE); if (priv->scale_set) @@ -1642,7 +1642,9 @@ get_size (GtkCellRenderer *cell, gint char_width; context = pango_layout_get_context (layout); - metrics = pango_context_get_metrics (context, widget->style->font_desc, pango_context_get_language (context)); + metrics = pango_context_get_metrics (context, + gtk_widget_get_style (widget)->font_desc, + pango_context_get_language (context)); char_width = pango_font_metrics_get_approximate_char_width (metrics); pango_font_metrics_unref (metrics); @@ -1697,7 +1699,7 @@ gtk_cell_renderer_text_render (GtkCellRenderer *cell, { GtkCellRendererText *celltext = GTK_CELL_RENDERER_TEXT (cell); - GtkCellRendererTextPriv *priv = celltext->priv; + GtkCellRendererTextPrivate *priv = celltext->priv; PangoLayout *layout; GtkStateType state; gint x_offset = 0; @@ -1760,7 +1762,7 @@ gtk_cell_renderer_text_render (GtkCellRenderer *cell, else if (priv->wrap_width == -1) pango_layout_set_width (layout, -1); - gtk_paint_layout (widget->style, + gtk_paint_layout (gtk_widget_get_style (widget), window, state, TRUE, @@ -1778,7 +1780,7 @@ static void gtk_cell_renderer_text_editing_done (GtkCellEditable *entry, gpointer data) { - GtkCellRendererTextPriv *priv; + GtkCellRendererTextPrivate *priv; const gchar *path; const gchar *new_text; gboolean canceled; @@ -1822,7 +1824,7 @@ gtk_cell_renderer_text_editing_done (GtkCellEditable *entry, static gboolean popdown_timeout (gpointer data) { - GtkCellRendererTextPriv *priv; + GtkCellRendererTextPrivate *priv; priv = GTK_CELL_RENDERER_TEXT (data)->priv; @@ -1838,7 +1840,7 @@ static void gtk_cell_renderer_text_popup_unmap (GtkMenu *menu, gpointer data) { - GtkCellRendererTextPriv *priv; + GtkCellRendererTextPrivate *priv; priv = GTK_CELL_RENDERER_TEXT (data)->priv; @@ -1856,7 +1858,7 @@ gtk_cell_renderer_text_populate_popup (GtkEntry *entry, GtkMenu *menu, gpointer data) { - GtkCellRendererTextPriv *priv; + GtkCellRendererTextPrivate *priv; priv = GTK_CELL_RENDERER_TEXT (data)->priv; @@ -1877,7 +1879,7 @@ gtk_cell_renderer_text_focus_out_event (GtkWidget *entry, GdkEvent *event, gpointer data) { - GtkCellRendererTextPriv *priv; + GtkCellRendererTextPrivate *priv; priv = GTK_CELL_RENDERER_TEXT (data)->priv; @@ -1905,7 +1907,7 @@ gtk_cell_renderer_text_start_editing (GtkCellRenderer *cell, { GtkRequisition requisition; GtkCellRendererText *celltext; - GtkCellRendererTextPriv *priv; + GtkCellRendererTextPrivate *priv; gfloat xalign, yalign; celltext = GTK_CELL_RENDERER_TEXT (cell); @@ -1995,7 +1997,7 @@ void gtk_cell_renderer_text_set_fixed_height_from_font (GtkCellRendererText *renderer, gint number_of_rows) { - GtkCellRendererTextPriv *priv; + GtkCellRendererTextPrivate *priv; GtkCellRenderer *cell; g_return_if_fail (GTK_IS_CELL_RENDERER_TEXT (renderer)); @@ -2032,8 +2034,9 @@ gtk_cell_renderer_text_get_width (GtkCellSizeRequest *cell, gint *minimum_size, gint *natural_size) { - GtkCellRendererTextPriv *priv; + GtkCellRendererTextPrivate *priv; GtkCellRendererText *celltext; + GtkStyle *style; PangoLayout *layout; PangoContext *context; PangoFontMetrics *metrics; @@ -2053,6 +2056,8 @@ gtk_cell_renderer_text_get_width (GtkCellSizeRequest *cell, celltext = GTK_CELL_RENDERER_TEXT (cell); priv = celltext->priv; + style = gtk_widget_get_style (widget); + gtk_cell_renderer_get_padding (GTK_CELL_RENDERER (cell), &xpad, NULL); layout = get_layout (celltext, widget, NULL, 0); @@ -2068,7 +2073,7 @@ gtk_cell_renderer_text_get_width (GtkCellSizeRequest *cell, /* Fetch the average size of a charachter */ context = pango_layout_get_context (layout); - metrics = pango_context_get_metrics (context, widget->style->font_desc, + metrics = pango_context_get_metrics (context, style->font_desc, pango_context_get_language (context)); char_width = pango_font_metrics_get_approximate_char_width (metrics); @@ -2124,7 +2129,7 @@ gtk_cell_renderer_text_get_height_for_width (GtkCellSizeRequest *cell, gint *minimum_height, gint *natural_height) { - GtkCellRendererTextPriv *priv; + GtkCellRendererTextPrivate *priv; GtkCellRendererText *celltext; PangoLayout *layout; gint text_height, xpad, ypad; diff --git a/gtk/gtkcellrenderertext.h b/gtk/gtkcellrenderertext.h index c9f8e63492..dcd893641f 100644 --- a/gtk/gtkcellrenderertext.h +++ b/gtk/gtkcellrenderertext.h @@ -38,16 +38,16 @@ G_BEGIN_DECLS #define GTK_IS_CELL_RENDERER_TEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_CELL_RENDERER_TEXT)) #define GTK_CELL_RENDERER_TEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_CELL_RENDERER_TEXT, GtkCellRendererTextClass)) -typedef struct _GtkCellRendererText GtkCellRendererText; -typedef struct _GtkCellRendererTextPriv GtkCellRendererTextPriv; -typedef struct _GtkCellRendererTextClass GtkCellRendererTextClass; +typedef struct _GtkCellRendererText GtkCellRendererText; +typedef struct _GtkCellRendererTextPrivate GtkCellRendererTextPrivate; +typedef struct _GtkCellRendererTextClass GtkCellRendererTextClass; struct _GtkCellRendererText { GtkCellRenderer parent; /*< private >*/ - GtkCellRendererTextPriv *priv; + GtkCellRendererTextPrivate *priv; }; struct _GtkCellRendererTextClass diff --git a/gtk/gtkcellrenderertoggle.c b/gtk/gtkcellrenderertoggle.c index 9087adb324..470a061a0a 100644 --- a/gtk/gtkcellrenderertoggle.c +++ b/gtk/gtkcellrenderertoggle.c @@ -75,7 +75,7 @@ enum { static guint toggle_cell_signals[LAST_SIGNAL] = { 0 }; -struct _GtkCellRendererTogglePriv +struct _GtkCellRendererTogglePrivate { gint indicator_size; @@ -92,11 +92,11 @@ G_DEFINE_TYPE (GtkCellRendererToggle, gtk_cell_renderer_toggle, GTK_TYPE_CELL_RE static void gtk_cell_renderer_toggle_init (GtkCellRendererToggle *celltoggle) { - GtkCellRendererTogglePriv *priv; + GtkCellRendererTogglePrivate *priv; celltoggle->priv = G_TYPE_INSTANCE_GET_PRIVATE (celltoggle, GTK_TYPE_CELL_RENDERER_TOGGLE, - GtkCellRendererTogglePriv); + GtkCellRendererTogglePrivate); priv = celltoggle->priv; priv->activatable = TRUE; @@ -184,7 +184,7 @@ gtk_cell_renderer_toggle_class_init (GtkCellRendererToggleClass *class) G_TYPE_NONE, 1, G_TYPE_STRING); - g_type_class_add_private (object_class, sizeof (GtkCellRendererTogglePriv)); + g_type_class_add_private (object_class, sizeof (GtkCellRendererTogglePrivate)); } static void @@ -194,7 +194,7 @@ gtk_cell_renderer_toggle_get_property (GObject *object, GParamSpec *pspec) { GtkCellRendererToggle *celltoggle = GTK_CELL_RENDERER_TOGGLE (object); - GtkCellRendererTogglePriv *priv = celltoggle->priv; + GtkCellRendererTogglePrivate *priv = celltoggle->priv; switch (param_id) { @@ -227,7 +227,7 @@ gtk_cell_renderer_toggle_set_property (GObject *object, GParamSpec *pspec) { GtkCellRendererToggle *celltoggle = GTK_CELL_RENDERER_TOGGLE (object); - GtkCellRendererTogglePriv *priv = celltoggle->priv; + GtkCellRendererTogglePrivate *priv = celltoggle->priv; switch (param_id) { @@ -280,7 +280,7 @@ gtk_cell_renderer_toggle_get_size (GtkCellRenderer *cell, gint *width, gint *height) { - GtkCellRendererTogglePriv *priv; + GtkCellRendererTogglePrivate *priv; gint calc_width; gint calc_height; gint xpad, ypad; @@ -332,7 +332,7 @@ gtk_cell_renderer_toggle_render (GtkCellRenderer *cell, GtkCellRendererState flags) { GtkCellRendererToggle *celltoggle = GTK_CELL_RENDERER_TOGGLE (cell); - GtkCellRendererTogglePriv *priv = celltoggle->priv; + GtkCellRendererTogglePrivate *priv = celltoggle->priv; gint width, height; gint x_offset, y_offset; gint xpad, ypad; @@ -376,7 +376,7 @@ gtk_cell_renderer_toggle_render (GtkCellRenderer *cell, if (priv->radio) { - gtk_paint_option (widget->style, + gtk_paint_option (gtk_widget_get_style (widget), window, state, shadow, expose_area, widget, "cellradio", @@ -386,7 +386,7 @@ gtk_cell_renderer_toggle_render (GtkCellRenderer *cell, } else { - gtk_paint_check (widget->style, + gtk_paint_check (gtk_widget_get_style (widget), window, state, shadow, expose_area, widget, "cellcheck", @@ -405,7 +405,7 @@ gtk_cell_renderer_toggle_activate (GtkCellRenderer *cell, GdkRectangle *cell_area, GtkCellRendererState flags) { - GtkCellRendererTogglePriv *priv; + GtkCellRendererTogglePrivate *priv; GtkCellRendererToggle *celltoggle; celltoggle = GTK_CELL_RENDERER_TOGGLE (cell); @@ -437,7 +437,7 @@ void gtk_cell_renderer_toggle_set_radio (GtkCellRendererToggle *toggle, gboolean radio) { - GtkCellRendererTogglePriv *priv; + GtkCellRendererTogglePrivate *priv; g_return_if_fail (GTK_IS_CELL_RENDERER_TOGGLE (toggle)); @@ -527,7 +527,7 @@ void gtk_cell_renderer_toggle_set_activatable (GtkCellRendererToggle *toggle, gboolean setting) { - GtkCellRendererTogglePriv *priv; + GtkCellRendererTogglePrivate *priv; g_return_if_fail (GTK_IS_CELL_RENDERER_TOGGLE (toggle)); diff --git a/gtk/gtkcellrenderertoggle.h b/gtk/gtkcellrenderertoggle.h index 16d2464025..ca53af03f9 100644 --- a/gtk/gtkcellrenderertoggle.h +++ b/gtk/gtkcellrenderertoggle.h @@ -37,16 +37,16 @@ G_BEGIN_DECLS #define GTK_IS_CELL_RENDERER_TOGGLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_CELL_RENDERER_TOGGLE)) #define GTK_CELL_RENDERER_TOGGLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_CELL_RENDERER_TOGGLE, GtkCellRendererToggleClass)) -typedef struct _GtkCellRendererToggle GtkCellRendererToggle; -typedef struct _GtkCellRendererTogglePriv GtkCellRendererTogglePriv; -typedef struct _GtkCellRendererToggleClass GtkCellRendererToggleClass; +typedef struct _GtkCellRendererToggle GtkCellRendererToggle; +typedef struct _GtkCellRendererTogglePrivate GtkCellRendererTogglePrivate; +typedef struct _GtkCellRendererToggleClass GtkCellRendererToggleClass; struct _GtkCellRendererToggle { GtkCellRenderer parent; /*< private >*/ - GtkCellRendererTogglePriv *priv; + GtkCellRendererTogglePrivate *priv; }; struct _GtkCellRendererToggleClass diff --git a/gtk/gtkcellsizerequest.c b/gtk/gtkcellsizerequest.c index a09c45e250..8ae6a3967c 100644 --- a/gtk/gtkcellsizerequest.c +++ b/gtk/gtkcellsizerequest.c @@ -29,23 +29,17 @@ #define DEBUG_CELL_SIZE_REQUEST 0 -GType -gtk_cell_size_request_get_type (void) -{ - static GType cell_size_request_type = 0; - if (G_UNLIKELY(!cell_size_request_type)) - { - cell_size_request_type = - g_type_register_static_simple (G_TYPE_INTERFACE, I_("GtkCellSizeRequest"), - sizeof (GtkCellSizeRequestIface), - NULL, 0, NULL, 0); +typedef GtkCellSizeRequestIface GtkCellSizeRequestInterface; +G_DEFINE_INTERFACE (GtkCellSizeRequest, gtk_cell_size_request, GTK_TYPE_CELL_RENDERER); - g_type_interface_add_prerequisite (cell_size_request_type, GTK_TYPE_CELL_RENDERER); - } - return cell_size_request_type; + +static void +gtk_cell_size_request_default_init (GtkCellSizeRequestInterface *iface) +{ } + /** * gtk_cell_size_request_get_request_mode: * @cell: a #GtkCellSizeRequest instance diff --git a/gtk/gtkcellview.c b/gtk/gtkcellview.c index bf15a3e514..305e7e7f14 100644 --- a/gtk/gtkcellview.c +++ b/gtk/gtkcellview.c @@ -344,7 +344,7 @@ gtk_cell_view_size_allocate (GtkWidget *widget, gint extra_per_cell, extra_extra, i; gboolean first_cell = TRUE; - widget->allocation = *allocation; + gtk_widget_set_allocation (widget, allocation); cellview = GTK_CELL_VIEW (widget); @@ -429,6 +429,7 @@ static gboolean gtk_cell_view_expose (GtkWidget *widget, GdkEventExpose *event) { + GtkAllocation allocation; GList *list; GtkCellView *cellview; GdkRectangle area; @@ -441,12 +442,14 @@ gtk_cell_view_expose (GtkWidget *widget, if (!gtk_widget_is_drawable (widget)) return FALSE; + gtk_widget_get_allocation (widget, &allocation); + /* "blank" background */ if (cellview->priv->background_set) { - cairo_t *cr = gdk_cairo_create (GTK_WIDGET (cellview)->window); + cairo_t *cr = gdk_cairo_create (gtk_widget_get_window (GTK_WIDGET (cellview))); - gdk_cairo_rectangle (cr, &widget->allocation); + gdk_cairo_rectangle (cr, &allocation); cairo_set_source_rgb (cr, cellview->priv->background.red / 65535., cellview->priv->background.green / 65535., @@ -463,10 +466,10 @@ gtk_cell_view_expose (GtkWidget *widget, return FALSE; /* render cells */ - area = widget->allocation; + area = allocation; /* we draw on our very own window, initialize x and y to zero */ - area.y = widget->allocation.y; + area.y = allocation.y; if (gtk_widget_get_state (widget) == GTK_STATE_PRELIGHT) state = GTK_CELL_RENDERER_PRELIT; @@ -478,9 +481,9 @@ gtk_cell_view_expose (GtkWidget *widget, for (packing = GTK_PACK_START; packing <= GTK_PACK_END; ++packing) { if (packing == GTK_PACK_START) - area.x = widget->allocation.x + (rtl ? widget->allocation.width : 0); + area.x = allocation.x + (rtl ? allocation.width : 0); else - area.x = rtl ? widget->allocation.x : (widget->allocation.x + widget->allocation.width); + area.x = rtl ? allocation.x : (allocation.x + allocation.width); for (list = cellview->priv->cell_list; list; list = list->next) { diff --git a/gtk/gtkcheckbutton.c b/gtk/gtkcheckbutton.c index 2f1dae0e52..727ad5fcaf 100644 --- a/gtk/gtkcheckbutton.c +++ b/gtk/gtkcheckbutton.c @@ -150,22 +150,39 @@ gtk_check_button_paint (GtkWidget *widget, border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); if (gtk_widget_has_focus (widget)) { + GtkStateType state; + GtkStyle *style; GtkWidget *child = gtk_bin_get_child (GTK_BIN (widget)); - + GdkWindow *window; + + style = gtk_widget_get_style (widget); + window = gtk_widget_get_window (widget); + state = gtk_widget_get_state (widget); + if (interior_focus && child && gtk_widget_get_visible (child)) - gtk_paint_focus (widget->style, widget->window, gtk_widget_get_state (widget), - area, widget, "checkbutton", - child->allocation.x - focus_width - focus_pad, - child->allocation.y - focus_width - focus_pad, - child->allocation.width + 2 * (focus_width + focus_pad), - child->allocation.height + 2 * (focus_width + focus_pad)); + { + GtkAllocation child_allocation; + + gtk_widget_get_allocation (child, &child_allocation); + gtk_paint_focus (style, window, state, + area, widget, "checkbutton", + child_allocation.x - focus_width - focus_pad, + child_allocation.y - focus_width - focus_pad, + child_allocation.width + 2 * (focus_width + focus_pad), + child_allocation.height + 2 * (focus_width + focus_pad)); + } else - gtk_paint_focus (widget->style, widget->window, gtk_widget_get_state (widget), - area, widget, "checkbutton", - border_width + widget->allocation.x, - border_width + widget->allocation.y, - widget->allocation.width - 2 * border_width, - widget->allocation.height - 2 * border_width); + { + GtkAllocation allocation; + + gtk_widget_get_allocation (widget, &allocation); + gtk_paint_focus (style, window, state, + area, widget, "checkbutton", + allocation.x + border_width, + allocation.y + border_width, + allocation.width - 2 * border_width, + allocation.height - 2 * border_width); + } } } } @@ -259,8 +276,9 @@ gtk_check_button_size_allocate (GtkWidget *widget, "focus-line-width", &focus_width, "focus-padding", &focus_pad, NULL); - - widget->allocation = *allocation; + + gtk_widget_set_allocation (widget, allocation); + if (gtk_widget_get_realized (widget)) gdk_window_move_resize (button->event_window, allocation->x, allocation->y, @@ -285,9 +303,8 @@ gtk_check_button_size_allocate (GtkWidget *widget, child_allocation.height = MAX (child_allocation.height, 1); child_allocation.x = (border_width + indicator_size + indicator_spacing * 3 + - widget->allocation.x + focus_width + focus_pad); - child_allocation.y = widget->allocation.y + - (allocation->height - child_allocation.height) / 2; + allocation->x + focus_width + focus_pad); + child_allocation.y = allocation->y + (allocation->height - child_allocation.height) / 2; if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) child_allocation.x = allocation->x + allocation->width @@ -367,9 +384,17 @@ gtk_real_check_button_draw_indicator (GtkCheckButton *check_button, if (gtk_widget_is_drawable (widget)) { + GtkAllocation allocation; + GtkStyle *style; + GdkWindow *window; + button = GTK_BUTTON (check_button); toggle_button = GTK_TOGGLE_BUTTON (check_button); - + + gtk_widget_get_allocation (widget, &allocation); + style = gtk_widget_get_style (widget); + window = gtk_widget_get_window (widget); + gtk_widget_style_get (widget, "interior-focus", &interior_focus, "focus-line-width", &focus_width, @@ -380,8 +405,8 @@ gtk_real_check_button_draw_indicator (GtkCheckButton *check_button, border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); - x = widget->allocation.x + indicator_spacing + border_width; - y = widget->allocation.y + (widget->allocation.height - indicator_size) / 2; + x = allocation.x + indicator_spacing + border_width; + y = allocation.y + (allocation.height - indicator_size) / 2; child = gtk_bin_get_child (GTK_BIN (check_button)); if (!interior_focus || !(child && gtk_widget_get_visible (child))) @@ -404,21 +429,21 @@ gtk_real_check_button_draw_indicator (GtkCheckButton *check_button, state_type = GTK_STATE_NORMAL; if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) - x = widget->allocation.x + widget->allocation.width - (indicator_size + x - widget->allocation.x); + x = allocation.x + allocation.width - (indicator_size + x - allocation.x); if (gtk_widget_get_state (widget) == GTK_STATE_PRELIGHT) { GdkRectangle restrict_area; GdkRectangle new_area; - - restrict_area.x = widget->allocation.x + border_width; - restrict_area.y = widget->allocation.y + border_width; - restrict_area.width = widget->allocation.width - (2 * border_width); - restrict_area.height = widget->allocation.height - (2 * border_width); - + + restrict_area.x = allocation.x + border_width; + restrict_area.y = allocation.y + border_width; + restrict_area.width = allocation.width - (2 * border_width); + restrict_area.height = allocation.height - (2 * border_width); + if (gdk_rectangle_intersect (area, &restrict_area, &new_area)) { - gtk_paint_flat_box (widget->style, widget->window, GTK_STATE_PRELIGHT, + gtk_paint_flat_box (style, window, GTK_STATE_PRELIGHT, GTK_SHADOW_ETCHED_OUT, area, widget, "checkbutton", new_area.x, new_area.y, @@ -426,7 +451,7 @@ gtk_real_check_button_draw_indicator (GtkCheckButton *check_button, } } - gtk_paint_check (widget->style, widget->window, + gtk_paint_check (style, window, state_type, shadow_type, area, widget, "checkbutton", x, y, indicator_size, indicator_size); diff --git a/gtk/gtkcheckmenuitem.c b/gtk/gtkcheckmenuitem.c index 55aa8f4873..9f00e9c9bd 100644 --- a/gtk/gtkcheckmenuitem.c +++ b/gtk/gtkcheckmenuitem.c @@ -35,7 +35,7 @@ -struct _GtkCheckMenuItemPriv +struct _GtkCheckMenuItemPrivate { guint active : 1; guint always_show_toggle : 1; @@ -152,7 +152,7 @@ gtk_check_menu_item_class_init (GtkCheckMenuItemClass *klass) _gtk_marshal_VOID__VOID, G_TYPE_NONE, 0); - g_type_class_add_private (klass, sizeof (GtkCheckMenuItemPriv)); + g_type_class_add_private (klass, sizeof (GtkCheckMenuItemPrivate)); } static void @@ -251,7 +251,7 @@ void gtk_check_menu_item_set_active (GtkCheckMenuItem *check_menu_item, gboolean is_active) { - GtkCheckMenuItemPriv *priv; + GtkCheckMenuItemPrivate *priv; g_return_if_fail (GTK_IS_CHECK_MENU_ITEM (check_menu_item)); @@ -322,7 +322,7 @@ void gtk_check_menu_item_set_inconsistent (GtkCheckMenuItem *check_menu_item, gboolean setting) { - GtkCheckMenuItemPriv *priv; + GtkCheckMenuItemPrivate *priv; g_return_if_fail (GTK_IS_CHECK_MENU_ITEM (check_menu_item)); @@ -367,7 +367,7 @@ void gtk_check_menu_item_set_draw_as_radio (GtkCheckMenuItem *check_menu_item, gboolean draw_as_radio) { - GtkCheckMenuItemPriv *priv; + GtkCheckMenuItemPrivate *priv; g_return_if_fail (GTK_IS_CHECK_MENU_ITEM (check_menu_item)); @@ -406,11 +406,11 @@ gtk_check_menu_item_get_draw_as_radio (GtkCheckMenuItem *check_menu_item) static void gtk_check_menu_item_init (GtkCheckMenuItem *check_menu_item) { - GtkCheckMenuItemPriv *priv; + GtkCheckMenuItemPrivate *priv; check_menu_item->priv = G_TYPE_INSTANCE_GET_PRIVATE (check_menu_item, GTK_TYPE_CHECK_MENU_ITEM, - GtkCheckMenuItemPriv); + GtkCheckMenuItemPrivate); priv = check_menu_item->priv; priv->active = FALSE; @@ -432,7 +432,7 @@ gtk_check_menu_item_expose (GtkWidget *widget, static void gtk_check_menu_item_activate (GtkMenuItem *menu_item) { - GtkCheckMenuItemPriv *priv; + GtkCheckMenuItemPrivate *priv; GtkCheckMenuItem *check_menu_item = GTK_CHECK_MENU_ITEM (menu_item); priv = check_menu_item->priv; @@ -459,7 +459,7 @@ static void gtk_real_check_menu_item_draw_indicator (GtkCheckMenuItem *check_menu_item, GdkRectangle *area) { - GtkCheckMenuItemPriv *priv = check_menu_item->priv; + GtkCheckMenuItemPrivate *priv = check_menu_item->priv; GtkWidget *widget; GtkStateType state_type; GtkShadowType shadow_type; @@ -469,6 +469,8 @@ gtk_real_check_menu_item_draw_indicator (GtkCheckMenuItem *check_menu_item, if (gtk_widget_is_drawable (widget)) { + GtkAllocation allocation; + GtkStyle *style; guint border_width; guint offset; guint toggle_size; @@ -476,6 +478,9 @@ gtk_real_check_menu_item_draw_indicator (GtkCheckMenuItem *check_menu_item, guint horizontal_padding; guint indicator_size; + style = gtk_widget_get_style (widget); + gtk_widget_get_allocation (widget, &allocation); + gtk_widget_style_get (widget, "toggle-spacing", &toggle_spacing, "horizontal-padding", &horizontal_padding, @@ -484,26 +489,29 @@ gtk_real_check_menu_item_draw_indicator (GtkCheckMenuItem *check_menu_item, toggle_size = GTK_MENU_ITEM (check_menu_item)->toggle_size; border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); - offset = border_width + widget->style->xthickness + 2; + offset = border_width + style->xthickness + 2; if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR) { - x = widget->allocation.x + offset + horizontal_padding + + x = allocation.x + offset + horizontal_padding + (toggle_size - toggle_spacing - indicator_size) / 2; } else { - x = widget->allocation.x + widget->allocation.width - + x = allocation.x + allocation.width - offset - horizontal_padding - toggle_size + toggle_spacing + (toggle_size - toggle_spacing - indicator_size) / 2; } - - y = widget->allocation.y + (widget->allocation.height - indicator_size) / 2; + + y = allocation.y + (allocation.height - indicator_size) / 2; if (priv->active || priv->always_show_toggle || (gtk_widget_get_state (widget) == GTK_STATE_PRELIGHT)) { + GdkWindow *window; + + window = gtk_widget_get_window (widget); state_type = gtk_widget_get_state (widget); if (priv->inconsistent) @@ -518,14 +526,14 @@ gtk_real_check_menu_item_draw_indicator (GtkCheckMenuItem *check_menu_item, if (priv->draw_as_radio) { - gtk_paint_option (widget->style, widget->window, + gtk_paint_option (style, window, state_type, shadow_type, area, widget, "option", x, y, indicator_size, indicator_size); } else { - gtk_paint_check (widget->style, widget->window, + gtk_paint_check (style, window, state_type, shadow_type, area, widget, "check", x, y, indicator_size, indicator_size); @@ -542,7 +550,7 @@ gtk_check_menu_item_get_property (GObject *object, GParamSpec *pspec) { GtkCheckMenuItem *checkitem = GTK_CHECK_MENU_ITEM (object); - GtkCheckMenuItemPriv *priv = checkitem->priv; + GtkCheckMenuItemPrivate *priv = checkitem->priv; switch (prop_id) { @@ -602,7 +610,7 @@ void _gtk_check_menu_item_set_active (GtkCheckMenuItem *check_menu_item, gboolean is_active) { - GtkCheckMenuItemPriv *priv = check_menu_item->priv; + GtkCheckMenuItemPrivate *priv = check_menu_item->priv; priv->active = is_active; } diff --git a/gtk/gtkcheckmenuitem.h b/gtk/gtkcheckmenuitem.h index e76ba5e081..773d1ad7ab 100644 --- a/gtk/gtkcheckmenuitem.h +++ b/gtk/gtkcheckmenuitem.h @@ -45,16 +45,16 @@ G_BEGIN_DECLS #define GTK_CHECK_MENU_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_CHECK_MENU_ITEM, GtkCheckMenuItemClass)) -typedef struct _GtkCheckMenuItem GtkCheckMenuItem; -typedef struct _GtkCheckMenuItemPriv GtkCheckMenuItemPriv; -typedef struct _GtkCheckMenuItemClass GtkCheckMenuItemClass; +typedef struct _GtkCheckMenuItem GtkCheckMenuItem; +typedef struct _GtkCheckMenuItemPrivate GtkCheckMenuItemPrivate; +typedef struct _GtkCheckMenuItemClass GtkCheckMenuItemClass; struct _GtkCheckMenuItem { GtkMenuItem menu_item; /* <private> */ - GtkCheckMenuItemPriv *priv; + GtkCheckMenuItemPrivate *priv; }; struct _GtkCheckMenuItemClass diff --git a/gtk/gtkclipboard.c b/gtk/gtkclipboard.c index 5e34975d7b..86caed4af1 100644 --- a/gtk/gtkclipboard.c +++ b/gtk/gtkclipboard.c @@ -413,7 +413,7 @@ clipboard_get_timestamp (GtkClipboard *clipboard) if (timestamp == GDK_CURRENT_TIME) { #ifdef GDK_WINDOWING_X11 - timestamp = gdk_x11_get_server_time (clipboard_widget->window); + timestamp = gdk_x11_get_server_time (gtk_widget_get_window (clipboard_widget)); #elif defined GDK_WINDOWING_WIN32 timestamp = GetMessageTime (); #endif @@ -2025,7 +2025,7 @@ gtk_clipboard_store (GtkClipboard *clipboard) clipboard); gdk_display_store_clipboard (clipboard->display, - clipboard_widget->window, + gtk_widget_get_window (clipboard_widget), clipboard_get_timestamp (clipboard), clipboard->storable_targets, clipboard->n_storable_targets); diff --git a/gtk/gtkcolorbutton.c b/gtk/gtkcolorbutton.c index d977081a14..0fc7bee88f 100644 --- a/gtk/gtkcolorbutton.c +++ b/gtk/gtkcolorbutton.c @@ -309,7 +309,7 @@ expose_event (GtkWidget *widget, if (!gtk_widget_is_sensitive (GTK_WIDGET (color_button))) { - gdk_cairo_set_source_color (cr, >K_WIDGET(color_button)->style->bg[GTK_STATE_INSENSITIVE]); + gdk_cairo_set_source_color (cr, >k_widget_get_style (GTK_WIDGET(color_button))->bg[GTK_STATE_INSENSITIVE]); checkered = gtk_color_button_get_checkered (); cairo_mask (cr, checkered); cairo_pattern_destroy (checkered); diff --git a/gtk/gtkcolorsel.c b/gtk/gtkcolorsel.c index b7034d01f2..659edb0e3f 100644 --- a/gtk/gtkcolorsel.c +++ b/gtk/gtkcolorsel.c @@ -814,6 +814,7 @@ color_sample_drag_handle (GtkWidget *widget, static void color_sample_draw_sample (GtkColorSelection *colorsel, int which) { + GtkAllocation allocation; GtkWidget *da; gint x, y, wid, heig, goff; ColorSelectionPrivate *priv; @@ -833,14 +834,18 @@ color_sample_draw_sample (GtkColorSelection *colorsel, int which) } else { + GtkAllocation old_sample_allocation; + da = priv->cur_sample; - goff = priv->old_sample->allocation.width % 32; + gtk_widget_get_allocation (priv->old_sample, &old_sample_allocation); + goff = old_sample_allocation.width % 32; } - cr = gdk_cairo_create (da->window); - - wid = da->allocation.width; - heig = da->allocation.height; + cr = gdk_cairo_create (gtk_widget_get_window (da)); + + gtk_widget_get_allocation (da, &allocation); + wid = allocation.width; + heig = allocation.height; /* Below needs tweaking for non-power-of-two */ @@ -1046,26 +1051,32 @@ palette_paint (GtkWidget *drawing_area, GdkRectangle *area, gpointer data) { + GdkWindow *window; cairo_t *cr; gint focus_width; - - if (drawing_area->window == NULL) + + window = gtk_widget_get_window (drawing_area); + + if (window == NULL) return; - cr = gdk_cairo_create (drawing_area->window); + cr = gdk_cairo_create (window); - gdk_cairo_set_source_color (cr, &drawing_area->style->bg[GTK_STATE_NORMAL]); + gdk_cairo_set_source_color (cr, >k_widget_get_style (drawing_area)->bg[GTK_STATE_NORMAL]); gdk_cairo_rectangle (cr, area); cairo_fill (cr); if (gtk_widget_has_focus (drawing_area)) { + GtkAllocation allocation; + set_focus_line_attributes (drawing_area, cr, &focus_width); + gtk_widget_get_allocation (drawing_area, &allocation); cairo_rectangle (cr, - focus_width / 2., focus_width / 2., - drawing_area->allocation.width - focus_width, - drawing_area->allocation.height - focus_width); + focus_width / 2., focus_width / 2., + allocation.width - focus_width, + allocation.height - focus_width); cairo_stroke (cr); } @@ -1318,7 +1329,7 @@ palette_expose (GtkWidget *drawing_area, GdkEventExpose *event, gpointer data) { - if (drawing_area->window == NULL) + if (gtk_widget_get_window (drawing_area) == NULL) return FALSE; palette_paint (drawing_area, &(event->area), data); @@ -1333,6 +1344,7 @@ popup_position_func (GtkMenu *menu, gboolean *push_in, gpointer user_data) { + GtkAllocation allocation; GtkWidget *widget; GtkRequisition req; gint root_x, root_y; @@ -1342,13 +1354,15 @@ popup_position_func (GtkMenu *menu, g_return_if_fail (gtk_widget_get_realized (widget)); - gdk_window_get_origin (widget->window, &root_x, &root_y); - + gdk_window_get_origin (gtk_widget_get_window (widget), + &root_x, &root_y); + gtk_widget_size_request (GTK_WIDGET (menu), &req); + gtk_widget_get_allocation (widget, &allocation); /* Put corner of menu centered on color cell */ - *x = root_x + widget->allocation.width / 2; - *y = root_y + widget->allocation.height / 2; + *x = root_x + allocation.width / 2; + *y = root_y + allocation.height / 2; /* Ensure sanity */ screen = gtk_widget_get_screen (widget); @@ -1887,6 +1901,7 @@ get_screen_color (GtkWidget *button) GdkDevice *device, *keyb_device, *pointer_device; GdkCursor *picker_cursor; GdkGrabStatus grab_status; + GdkWindow *window; GtkWidget *grab_widget, *toplevel; guint32 time = gtk_get_current_event_time (); @@ -1919,16 +1934,18 @@ get_screen_color (GtkWidget *button) if (GTK_IS_WINDOW (toplevel)) { - if (GTK_WINDOW (toplevel)->group) - gtk_window_group_add_window (GTK_WINDOW (toplevel)->group, + if (gtk_window_has_group (GTK_WINDOW (toplevel))) + gtk_window_group_add_window (gtk_window_get_group (GTK_WINDOW (toplevel)), GTK_WINDOW (grab_widget)); } priv->dropper_grab_widget = grab_widget; } + window = gtk_widget_get_window (priv->dropper_grab_widget); + if (gdk_device_grab (keyb_device, - priv->dropper_grab_widget->window, + window, GDK_OWNERSHIP_APPLICATION, FALSE, GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK, NULL, time) != GDK_GRAB_SUCCESS) @@ -1936,7 +1953,7 @@ get_screen_color (GtkWidget *button) picker_cursor = make_picker_cursor (screen); grab_status = gdk_device_grab (pointer_device, - priv->dropper_grab_widget->window, + window, GDK_OWNERSHIP_APPLICATION, FALSE, GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_PRESS_MASK | GDK_POINTER_MOTION_MASK, diff --git a/gtk/gtkcolorseldialog.c b/gtk/gtkcolorseldialog.c index a203de4df1..d225ef1517 100644 --- a/gtk/gtkcolorseldialog.c +++ b/gtk/gtkcolorseldialog.c @@ -36,7 +36,7 @@ -struct _GtkColorSelectionDialogPriv +struct _GtkColorSelectionDialogPrivate { GtkWidget *colorsel; GtkWidget *ok_button; @@ -76,7 +76,7 @@ gtk_color_selection_dialog_get_property (GObject *object, GParamSpec *pspec) { GtkColorSelectionDialog *colorsel = GTK_COLOR_SELECTION_DIALOG (object); - GtkColorSelectionDialogPriv *priv = colorsel->priv; + GtkColorSelectionDialogPrivate *priv = colorsel->priv; switch (prop_id) { @@ -133,19 +133,19 @@ gtk_color_selection_dialog_class_init (GtkColorSelectionDialogClass *klass) GTK_TYPE_WIDGET, G_PARAM_READABLE)); - g_type_class_add_private (klass, sizeof (GtkColorSelectionDialogPriv)); + g_type_class_add_private (klass, sizeof (GtkColorSelectionDialogPrivate)); } static void gtk_color_selection_dialog_init (GtkColorSelectionDialog *colorseldiag) { - GtkColorSelectionDialogPriv *priv; + GtkColorSelectionDialogPrivate *priv; GtkDialog *dialog = GTK_DIALOG (colorseldiag); GtkWidget *action_area, *content_area; colorseldiag->priv = G_TYPE_INSTANCE_GET_PRIVATE (colorseldiag, GTK_TYPE_COLOR_SELECTION_DIALOG, - GtkColorSelectionDialogPriv); + GtkColorSelectionDialogPrivate); priv = colorseldiag->priv; content_area = gtk_dialog_get_content_area (dialog); @@ -238,7 +238,7 @@ gtk_color_selection_dialog_buildable_get_internal_child (GtkBuildable *buildable const gchar *childname) { GtkColorSelectionDialog *selection_dialog = GTK_COLOR_SELECTION_DIALOG (buildable); - GtkColorSelectionDialogPriv *priv = selection_dialog->priv; + GtkColorSelectionDialogPrivate *priv = selection_dialog->priv; if (g_strcmp0 (childname, "ok_button") == 0) return G_OBJECT (priv->ok_button); diff --git a/gtk/gtkcolorseldialog.h b/gtk/gtkcolorseldialog.h index 574aaf06ef..0b4f0aaaa7 100644 --- a/gtk/gtkcolorseldialog.h +++ b/gtk/gtkcolorseldialog.h @@ -45,9 +45,9 @@ G_BEGIN_DECLS #define GTK_COLOR_SELECTION_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_COLOR_SELECTION_DIALOG, GtkColorSelectionDialogClass)) -typedef struct _GtkColorSelectionDialog GtkColorSelectionDialog; -typedef struct _GtkColorSelectionDialogPriv GtkColorSelectionDialogPriv; -typedef struct _GtkColorSelectionDialogClass GtkColorSelectionDialogClass; +typedef struct _GtkColorSelectionDialog GtkColorSelectionDialog; +typedef struct _GtkColorSelectionDialogPrivate GtkColorSelectionDialogPrivate; +typedef struct _GtkColorSelectionDialogClass GtkColorSelectionDialogClass; struct _GtkColorSelectionDialog @@ -55,7 +55,7 @@ struct _GtkColorSelectionDialog GtkDialog parent_instance; /* <private> */ - GtkColorSelectionDialogPriv *priv; + GtkColorSelectionDialogPrivate *priv; }; struct _GtkColorSelectionDialogClass diff --git a/gtk/gtkcombobox.c b/gtk/gtkcombobox.c index 57a439fbe0..99c9a88feb 100644 --- a/gtk/gtkcombobox.c +++ b/gtk/gtkcombobox.c @@ -1122,7 +1122,7 @@ gtk_combo_box_state_changed (GtkWidget *widget, { if (priv->tree_view && priv->cell_view) gtk_cell_view_set_background_color (GTK_CELL_VIEW (priv->cell_view), - &widget->style->base[gtk_widget_get_state (widget)]); + >k_widget_get_style (widget)->base[gtk_widget_get_state (widget)]); } gtk_widget_queue_draw (widget); @@ -1206,7 +1206,7 @@ gtk_combo_box_style_set (GtkWidget *widget, if (priv->tree_view && priv->cell_view) gtk_cell_view_set_background_color (GTK_CELL_VIEW (priv->cell_view), - &widget->style->base[gtk_widget_get_state (widget)]); + >k_widget_get_style (widget)->base[gtk_widget_get_state (widget)]); child = gtk_bin_get_child (GTK_BIN (combo_box)); if (GTK_IS_ENTRY (child)) @@ -1237,7 +1237,8 @@ gtk_combo_box_add (GtkContainer *container, GtkComboBox *combo_box = GTK_COMBO_BOX (container); GtkComboBoxPrivate *priv = combo_box->priv; - if (priv->cell_view && priv->cell_view->parent) + if (priv->cell_view && + gtk_widget_get_parent (priv->cell_view)) { gtk_widget_unparent (priv->cell_view); _gtk_bin_set_child (GTK_BIN (container), NULL); @@ -1255,8 +1256,8 @@ gtk_combo_box_add (GtkContainer *container, if (!priv->tree_view && priv->separator) { - gtk_container_remove (GTK_CONTAINER (priv->separator->parent), - priv->separator); + gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (priv->separator)), + priv->separator); priv->separator = NULL; gtk_widget_queue_resize (GTK_WIDGET (container)); @@ -1501,6 +1502,7 @@ gtk_combo_box_menu_position_below (GtkMenu *menu, gpointer user_data) { GtkComboBox *combo_box = GTK_COMBO_BOX (user_data); + GtkAllocation child_allocation; gint sx, sy; GtkWidget *child; GtkRequisition req; @@ -1513,28 +1515,31 @@ gtk_combo_box_menu_position_below (GtkMenu *menu, sx = sy = 0; + gtk_widget_get_allocation (child, &child_allocation); + if (!gtk_widget_get_has_window (child)) { - sx += child->allocation.x; - sy += child->allocation.y; + sx += child_allocation.x; + sy += child_allocation.y; } - gdk_window_get_root_coords (child->window, sx, sy, &sx, &sy); + gdk_window_get_root_coords (gtk_widget_get_window (child), + sx, sy, &sx, &sy); if (GTK_SHADOW_NONE != combo_box->priv->shadow_type) - sx -= GTK_WIDGET (combo_box)->style->xthickness; + sx -= gtk_widget_get_style (GTK_WIDGET (combo_box))->xthickness; gtk_widget_size_request (GTK_WIDGET (menu), &req); if (gtk_widget_get_direction (GTK_WIDGET (combo_box)) == GTK_TEXT_DIR_LTR) *x = sx; else - *x = sx + child->allocation.width - req.width; + *x = sx + child_allocation.width - req.width; *y = sy; screen = gtk_widget_get_screen (GTK_WIDGET (combo_box)); monitor_num = gdk_screen_get_monitor_at_window (screen, - GTK_WIDGET (combo_box)->window); + gtk_widget_get_window (GTK_WIDGET (combo_box))); gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor); if (*x < monitor.x) @@ -1542,12 +1547,12 @@ gtk_combo_box_menu_position_below (GtkMenu *menu, else if (*x + req.width > monitor.x + monitor.width) *x = monitor.x + monitor.width - req.width; - if (monitor.y + monitor.height - *y - child->allocation.height >= req.height) - *y += child->allocation.height; + if (monitor.y + monitor.height - *y - child_allocation.height >= req.height) + *y += child_allocation.height; else if (*y - monitor.y >= req.height) *y -= req.height; - else if (monitor.y + monitor.height - *y - child->allocation.height > *y - monitor.y) - *y += child->allocation.height; + else if (monitor.y + monitor.height - *y - child_allocation.height > *y - monitor.y) + *y += child_allocation.height; else *y -= req.height; @@ -1565,6 +1570,7 @@ gtk_combo_box_menu_position_over (GtkMenu *menu, GtkWidget *active; GtkWidget *child; GtkWidget *widget; + GtkAllocation allocation; GtkAllocation child_allocation; GList *children; gint screen_width; @@ -1577,8 +1583,10 @@ gtk_combo_box_menu_position_over (GtkMenu *menu, active = gtk_menu_get_active (GTK_MENU (combo_box->priv->popup_widget)); - menu_xpos = widget->allocation.x; - menu_ypos = widget->allocation.y + widget->allocation.height / 2 - 2; + gtk_widget_get_allocation (widget, &allocation); + + menu_xpos = allocation.x; + menu_ypos = allocation.y + allocation.height / 2 - 2; gtk_size_request_get_width (GTK_SIZE_REQUEST (menu), &menu_width, NULL); @@ -1607,9 +1615,10 @@ gtk_combo_box_menu_position_over (GtkMenu *menu, } if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) - menu_xpos = menu_xpos + widget->allocation.width - menu_width; + menu_xpos = menu_xpos + allocation.width - menu_width; - gdk_window_get_root_coords (widget->window, menu_xpos, menu_ypos, + gdk_window_get_root_coords (gtk_widget_get_window (widget), + menu_xpos, menu_ypos, &menu_xpos, &menu_ypos); /* Clamp the position on screen */ @@ -1664,27 +1673,34 @@ gtk_combo_box_list_position (GtkComboBox *combo_box, gint *height) { GtkComboBoxPrivate *priv = combo_box->priv; + GtkAllocation allocation; GdkScreen *screen; gint monitor_num; GdkRectangle monitor; GtkRequisition popup_req; GtkPolicyType hpolicy, vpolicy; - + GdkWindow *window; + /* under windows, the drop down list is as wide as the combo box itself. see bug #340204 */ - GtkWidget *sample = GTK_WIDGET (combo_box); + GtkWidget *widget = GTK_WIDGET (combo_box); *x = *y = 0; - if (!gtk_widget_get_has_window (sample)) + gtk_widget_get_allocation (widget, &allocation); + + if (!gtk_widget_get_has_window (widget)) { - *x += sample->allocation.x; - *y += sample->allocation.y; + *x += allocation.x; + *y += allocation.y; } - - gdk_window_get_root_coords (sample->window, *x, *y, x, y); - *width = sample->allocation.width; + window = gtk_widget_get_window (widget); + + gdk_window_get_root_coords (gtk_widget_get_window (widget), + *x, *y, x, y); + + *width = allocation.width; hpolicy = vpolicy = GTK_POLICY_NEVER; gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (priv->scrolled_window), @@ -1702,8 +1718,7 @@ gtk_combo_box_list_position (GtkComboBox *combo_box, *height = popup_req.height; screen = gtk_widget_get_screen (GTK_WIDGET (combo_box)); - monitor_num = gdk_screen_get_monitor_at_window (screen, - GTK_WIDGET (combo_box)->window); + monitor_num = gdk_screen_get_monitor_at_window (screen, window); gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor); if (*x < monitor.x) @@ -1711,13 +1726,13 @@ gtk_combo_box_list_position (GtkComboBox *combo_box, else if (*x + *width > monitor.x + monitor.width) *x = monitor.x + monitor.width - *width; - if (*y + sample->allocation.height + *height <= monitor.y + monitor.height) - *y += sample->allocation.height; + if (*y + allocation.height + *height <= monitor.y + monitor.height) + *y += allocation.height; else if (*y - *height >= monitor.y) *y -= *height; - else if (monitor.y + monitor.height - (*y + sample->allocation.height) > *y - monitor.y) + else if (monitor.y + monitor.height - (*y + allocation.height) > *y - monitor.y) { - *y += sample->allocation.height; + *y += allocation.height; *height = monitor.y + monitor.height - *y; } else @@ -1868,7 +1883,10 @@ gtk_combo_box_menu_popup (GtkComboBox *combo_box, if (priv->wrap_width == 0) { - width = GTK_WIDGET (combo_box)->allocation.width; + GtkAllocation allocation; + + gtk_widget_get_allocation (GTK_WIDGET (combo_box), &allocation); + width = allocation.width; gtk_widget_set_size_request (priv->popup_widget, -1, -1); gtk_size_request_get_width (GTK_SIZE_REQUEST (priv->popup_widget), &min_width, NULL); @@ -2025,7 +2043,7 @@ gtk_combo_box_popup_for_device (GtkComboBox *combo_box, if (!gtk_widget_has_focus (priv->tree_view)) gtk_widget_grab_focus (priv->tree_view); - if (!popup_grab_on_window (priv->popup_window->window, + if (!popup_grab_on_window (gtk_widget_get_window (priv->popup_window), keyboard, pointer, time)) { gtk_widget_hide (priv->popup_window); @@ -2176,20 +2194,22 @@ gtk_combo_box_size_allocate (GtkWidget *widget, gint focus_width, focus_pad; GtkAllocation child; GtkRequisition req; + GtkStyle *style; gboolean is_rtl = gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL; - widget->allocation = *allocation; + gtk_widget_set_allocation (widget, allocation); child_widget = gtk_bin_get_child (GTK_BIN (widget)); - gtk_widget_style_get (GTK_WIDGET (widget), + style = gtk_widget_get_style (widget); + gtk_widget_style_get (widget, "focus-line-width", &focus_width, "focus-padding", &focus_pad, NULL); if (GTK_SHADOW_NONE != priv->shadow_type) { - shadow_width = widget->style->xthickness; - shadow_height = widget->style->ythickness; + shadow_width = style->xthickness; + shadow_height = style->ythickness; } else { @@ -2215,8 +2235,9 @@ gtk_combo_box_size_allocate (GtkWidget *widget, /* set some things ready */ border_width = gtk_container_get_border_width (GTK_CONTAINER (priv->button)); - xthickness = priv->button->style->xthickness; - ythickness = priv->button->style->ythickness; + style = gtk_widget_get_style (priv->button); + xthickness = style->xthickness; + ythickness = style->ythickness; child.x = allocation->x; child.y = allocation->y; @@ -2271,7 +2292,10 @@ gtk_combo_box_size_allocate (GtkWidget *widget, if (priv->wrap_width == 0) { - width = GTK_WIDGET (combo_box)->allocation.width; + GtkAllocation combo_box_allocation; + + gtk_widget_get_allocation (GTK_WIDGET (combo_box), &combo_box_allocation); + width = combo_box_allocation.width; gtk_widget_set_size_request (priv->popup_widget, -1, -1); gtk_size_request_get_width (GTK_SIZE_REQUEST (priv->popup_widget), &min_width, NULL); gtk_widget_set_size_request (priv->popup_widget, @@ -2335,8 +2359,9 @@ gtk_combo_box_size_allocate (GtkWidget *widget, if (priv->has_frame) { border_width = gtk_container_get_border_width (GTK_CONTAINER (priv->cell_view_frame)); - delta_x = border_width + GTK_WIDGET (priv->cell_view_frame)->style->xthickness; - delta_y = border_width + GTK_WIDGET (priv->cell_view_frame)->style->ythickness; + style = gtk_widget_get_style (priv->cell_view_frame); + delta_x = border_width + style->xthickness; + delta_y = border_width + style->ythickness; child.x += delta_x; child.y += delta_y; @@ -2464,11 +2489,16 @@ gtk_combo_box_expose_event (GtkWidget *widget, if (gtk_widget_is_drawable (widget) && GTK_SHADOW_NONE != priv->shadow_type) { - gtk_paint_shadow (widget->style, widget->window, + GtkAllocation allocation; + + gtk_widget_get_allocation (widget, &allocation); + + gtk_paint_shadow (gtk_widget_get_style (widget), + gtk_widget_get_window (widget), GTK_STATE_NORMAL, priv->shadow_type, NULL, widget, "combobox", - widget->allocation.x, widget->allocation.y, - widget->allocation.width, widget->allocation.height); + allocation.x, allocation.y, + allocation.width, allocation.height); } gtk_container_propagate_expose (GTK_CONTAINER (widget), @@ -3582,7 +3612,8 @@ gtk_combo_box_menu_row_changed (GtkTreeModel *model, gtk_combo_box_menu_row_inserted (model, path, iter, combo_box); } - if (priv->wrap_width && item->parent == priv->popup_widget) + if (priv->wrap_width && + gtk_widget_get_parent (item) == priv->popup_widget) { GtkWidget *pitem = NULL; GtkTreePath *prev; @@ -3991,23 +4022,26 @@ gtk_combo_box_list_auto_scroll (GtkComboBox *combo_box, gint x, gint y) { - GtkWidget *tree_view = combo_box->priv->tree_view; GtkAdjustment *adj; + GtkAllocation allocation; + GtkWidget *tree_view = combo_box->priv->tree_view; gdouble value; + gtk_widget_get_allocation (tree_view, &allocation); + adj = gtk_scrolled_window_get_hadjustment (GTK_SCROLLED_WINDOW (combo_box->priv->scrolled_window)); if (adj && adj->upper - adj->lower > adj->page_size) { - if (x <= tree_view->allocation.x && + if (x <= allocation.x && adj->lower < adj->value) { - value = adj->value - (tree_view->allocation.x - x + 1); + value = adj->value - (allocation.x - x + 1); gtk_adjustment_set_value (adj, value); } - else if (x >= tree_view->allocation.x + tree_view->allocation.width && + else if (x >= allocation.x + allocation.width && adj->upper - adj->page_size > adj->value) { - value = adj->value + (x - tree_view->allocation.x - tree_view->allocation.width + 1); + value = adj->value + (x - allocation.x - allocation.width + 1); gtk_adjustment_set_value (adj, MAX (value, 0.0)); } } @@ -4015,16 +4049,16 @@ gtk_combo_box_list_auto_scroll (GtkComboBox *combo_box, adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (combo_box->priv->scrolled_window)); if (adj && adj->upper - adj->lower > adj->page_size) { - if (y <= tree_view->allocation.y && + if (y <= allocation.y && adj->lower < adj->value) { - value = adj->value - (tree_view->allocation.y - y + 1); + value = adj->value - (allocation.y - y + 1); gtk_adjustment_set_value (adj, value); } - else if (y >= tree_view->allocation.height && + else if (y >= allocation.height && adj->upper - adj->page_size > adj->value) { - value = adj->value + (y - tree_view->allocation.height + 1); + value = adj->value + (y - allocation.height + 1); gtk_adjustment_set_value (adj, MAX (value, 0.0)); } } @@ -4038,7 +4072,7 @@ gtk_combo_box_list_scroll_timeout (GtkComboBox *combo_box) if (priv->auto_scroll) { - gdk_window_get_device_position (priv->tree_view->window, + gdk_window_get_device_position (gtk_widget_get_window (priv->tree_view), priv->grab_pointer, &x, &y, NULL); gtk_combo_box_list_auto_scroll (combo_box, x, y); @@ -4958,8 +4992,6 @@ gtk_combo_box_get_active_iter (GtkComboBox *combo_box, * * Sets the current active item to be the one referenced by @iter, or * unsets the active item if @iter is %NULL. - * - * @iter must correspond to a path of depth one, or be %NULL. * * Since: 2.4 */ @@ -6016,6 +6048,7 @@ gtk_combo_box_get_width (GtkSizeRequest *widget, { GtkComboBox *combo_box = GTK_COMBO_BOX (widget); GtkComboBoxPrivate *priv = combo_box->priv; + GtkStyle *style; gint focus_width, focus_pad; gint font_size, arrow_size; PangoContext *context; @@ -6040,7 +6073,7 @@ gtk_combo_box_get_width (GtkSizeRequest *widget, "arrow-size", &arrow_size, NULL); - font_desc = child->style->font_desc; + font_desc = gtk_widget_get_style (child)->font_desc; context = gtk_widget_get_pango_context (GTK_WIDGET (widget)); metrics = pango_context_get_metrics (context, font_desc, pango_context_get_language (context)); @@ -6062,7 +6095,7 @@ gtk_combo_box_get_width (GtkSizeRequest *widget, gint border_width, xthickness, xpad; border_width = gtk_container_get_border_width (GTK_CONTAINER (combo_box)); - xthickness = priv->button->style->xthickness; + xthickness = gtk_widget_get_style (priv->button)->xthickness; gtk_size_request_get_width (GTK_SIZE_REQUEST (priv->separator), &sep_width, NULL); gtk_size_request_get_width (GTK_SIZE_REQUEST (priv->arrow), &arrow_width, NULL); @@ -6100,7 +6133,7 @@ gtk_combo_box_get_width (GtkSizeRequest *widget, if (priv->has_frame) { gint border_width = gtk_container_get_border_width (GTK_CONTAINER (priv->cell_view_frame)); - gint xpad = 2 * (border_width + GTK_WIDGET (priv->cell_view_frame)->style->xthickness); + gint xpad = 2 * (border_width + gtk_widget_get_style (GTK_WIDGET (priv->cell_view_frame))->xthickness); minimum_width += xpad; natural_width += xpad; @@ -6117,8 +6150,10 @@ gtk_combo_box_get_width (GtkSizeRequest *widget, if (GTK_SHADOW_NONE != priv->shadow_type) { - minimum_width += 2 * GTK_WIDGET (widget)->style->xthickness; - natural_width += 2 * GTK_WIDGET (widget)->style->xthickness; + style = gtk_widget_get_style (GTK_WIDGET (widget)); + + minimum_width += 2 * style->xthickness; + natural_width += 2 * style->xthickness; } if (minimum_size) @@ -6161,6 +6196,7 @@ gtk_combo_box_get_height_for_width (GtkSizeRequest *widget, { GtkComboBox *combo_box = GTK_COMBO_BOX (widget); GtkComboBoxPrivate *priv = combo_box->priv; + GtkStyle *style; gint focus_width, focus_pad; gint min_height, nat_height; gint size; @@ -6173,20 +6209,23 @@ gtk_combo_box_get_height_for_width (GtkSizeRequest *widget, size = avail_size; if (GTK_SHADOW_NONE != priv->shadow_type) - size -= GTK_WIDGET (widget)->style->xthickness; + size -= gtk_widget_get_style (GTK_WIDGET (widget))->xthickness; if (!priv->tree_view) { /* menu mode */ if (priv->cell_view) { + GtkStyle *button_style; /* calculate x/y padding and separator/arrow size */ gint sep_width, arrow_width, sep_height, arrow_height; gint border_width, xthickness, ythickness, xpad, ypad; border_width = gtk_container_get_border_width (GTK_CONTAINER (combo_box)); - xthickness = priv->button->style->xthickness; - ythickness = priv->button->style->ythickness; + button_style = gtk_widget_get_style (priv->button); + + xthickness = button_style->xthickness; + ythickness = button_style->ythickness; gtk_size_request_get_width (GTK_SIZE_REQUEST (priv->separator), &sep_width, NULL); gtk_size_request_get_width (GTK_SIZE_REQUEST (priv->arrow), &arrow_width, NULL); @@ -6238,10 +6277,14 @@ gtk_combo_box_get_height_for_width (GtkSizeRequest *widget, if (priv->cell_view_frame && priv->has_frame) { - gint border_width = gtk_container_get_border_width (GTK_CONTAINER (priv->cell_view_frame)); + GtkStyle *cell_style; + gint border_width; + + border_width = gtk_container_get_border_width (GTK_CONTAINER (priv->cell_view_frame)); + cell_style = gtk_widget_get_style (GTK_WIDGET (priv->cell_view_frame)); - xpad = 2 * (border_width + GTK_WIDGET (priv->cell_view_frame)->style->xthickness); - ypad = 2 * (border_width + GTK_WIDGET (priv->cell_view_frame)->style->ythickness); + xpad = 2 * (border_width + cell_style->xthickness); + ypad = 2 * (border_width + cell_style->ythickness); } size -= but_width; @@ -6259,8 +6302,10 @@ gtk_combo_box_get_height_for_width (GtkSizeRequest *widget, if (GTK_SHADOW_NONE != priv->shadow_type) { - min_height += 2 * GTK_WIDGET (widget)->style->ythickness; - nat_height += 2 * GTK_WIDGET (widget)->style->ythickness; + style = gtk_widget_get_style (GTK_WIDGET (widget)); + + min_height += 2 * style->ythickness; + nat_height += 2 * style->ythickness; } if (minimum_size) diff --git a/gtk/gtkcontainer.c b/gtk/gtkcontainer.c index 624b49a7a2..275cda1333 100644 --- a/gtk/gtkcontainer.c +++ b/gtk/gtkcontainer.c @@ -41,7 +41,7 @@ #include <gobject/gobjectnotifyqueue.c> #include <gobject/gvaluecollector.h> -struct _GtkContainerPriv +struct _GtkContainerPrivate { GtkWidget *focus_child; @@ -302,7 +302,7 @@ gtk_container_class_init (GtkContainerClass *class) G_TYPE_NONE, 1, GTK_TYPE_WIDGET); - g_type_class_add_private (class, sizeof (GtkContainerPriv)); + g_type_class_add_private (class, sizeof (GtkContainerPrivate)); } static void @@ -324,7 +324,8 @@ gtk_container_buildable_add_child (GtkBuildable *buildable, { GTK_BUILDER_WARN_INVALID_CHILD_TYPE (buildable, type); } - else if (GTK_IS_WIDGET (child) && GTK_WIDGET (child)->parent == NULL) + else if (GTK_IS_WIDGET (child) && + gtk_widget_get_parent (GTK_WIDGET (child)) == NULL) { gtk_container_add (GTK_CONTAINER (buildable), GTK_WIDGET (child)); } @@ -610,7 +611,7 @@ gtk_container_child_get_valist (GtkContainer *container, g_return_if_fail (GTK_IS_CONTAINER (container)); g_return_if_fail (GTK_IS_WIDGET (child)); - g_return_if_fail (child->parent == GTK_WIDGET (container)); + g_return_if_fail (gtk_widget_get_parent (child) == GTK_WIDGET (container)); g_object_ref (container); g_object_ref (child); @@ -679,7 +680,7 @@ gtk_container_child_get_property (GtkContainer *container, g_return_if_fail (GTK_IS_CONTAINER (container)); g_return_if_fail (GTK_IS_WIDGET (child)); - g_return_if_fail (child->parent == GTK_WIDGET (container)); + g_return_if_fail (gtk_widget_get_parent (child) == GTK_WIDGET (container)); g_return_if_fail (property_name != NULL); g_return_if_fail (G_IS_VALUE (value)); @@ -755,7 +756,7 @@ gtk_container_child_set_valist (GtkContainer *container, g_return_if_fail (GTK_IS_CONTAINER (container)); g_return_if_fail (GTK_IS_WIDGET (child)); - g_return_if_fail (child->parent == GTK_WIDGET (container)); + g_return_if_fail (gtk_widget_get_parent (child) == GTK_WIDGET (container)); g_object_ref (container); g_object_ref (child); @@ -828,7 +829,7 @@ gtk_container_child_set_property (GtkContainer *container, g_return_if_fail (GTK_IS_CONTAINER (container)); g_return_if_fail (GTK_IS_WIDGET (child)); - g_return_if_fail (child->parent == GTK_WIDGET (container)); + g_return_if_fail (gtk_widget_get_parent (child) == GTK_WIDGET (container)); g_return_if_fail (property_name != NULL); g_return_if_fail (G_IS_VALUE (value)); @@ -876,14 +877,14 @@ gtk_container_add_with_properties (GtkContainer *container, { g_return_if_fail (GTK_IS_CONTAINER (container)); g_return_if_fail (GTK_IS_WIDGET (widget)); - g_return_if_fail (widget->parent == NULL); + g_return_if_fail (gtk_widget_get_parent (widget) == NULL); g_object_ref (container); g_object_ref (widget); gtk_widget_freeze_child_notify (widget); g_signal_emit (container, container_signals[ADD], 0, widget); - if (widget->parent) + if (gtk_widget_get_parent (widget)) { va_list var_args; @@ -917,7 +918,7 @@ gtk_container_child_set (GtkContainer *container, g_return_if_fail (GTK_IS_CONTAINER (container)); g_return_if_fail (GTK_IS_WIDGET (child)); - g_return_if_fail (child->parent == GTK_WIDGET (container)); + g_return_if_fail (gtk_widget_get_parent (child) == GTK_WIDGET (container)); va_start (var_args, first_prop_name); gtk_container_child_set_valist (container, child, first_prop_name, var_args); @@ -944,7 +945,7 @@ gtk_container_child_get (GtkContainer *container, g_return_if_fail (GTK_IS_CONTAINER (container)); g_return_if_fail (GTK_IS_WIDGET (child)); - g_return_if_fail (child->parent == GTK_WIDGET (container)); + g_return_if_fail (gtk_widget_get_parent (child) == GTK_WIDGET (container)); va_start (var_args, first_prop_name); gtk_container_child_get_valist (container, child, first_prop_name, var_args); @@ -1054,11 +1055,11 @@ gtk_container_remove_unimplemented (GtkContainer *container, static void gtk_container_init (GtkContainer *container) { - GtkContainerPriv *priv; + GtkContainerPrivate *priv; container->priv = G_TYPE_INSTANCE_GET_PRIVATE (container, GTK_TYPE_CONTAINER, - GtkContainerPriv); + GtkContainerPrivate); priv = container->priv; priv->focus_child = NULL; @@ -1072,7 +1073,7 @@ static void gtk_container_destroy (GtkObject *object) { GtkContainer *container = GTK_CONTAINER (object); - GtkContainerPriv *priv = container->priv; + GtkContainerPrivate *priv = container->priv; if (GTK_CONTAINER_RESIZE_PENDING (container)) _gtk_container_dequeue_resize_handler (container); @@ -1120,7 +1121,7 @@ gtk_container_get_property (GObject *object, GParamSpec *pspec) { GtkContainer *container = GTK_CONTAINER (object); - GtkContainerPriv *priv = container->priv; + GtkContainerPrivate *priv = container->priv; switch (prop_id) { @@ -1157,7 +1158,7 @@ void gtk_container_set_border_width (GtkContainer *container, guint border_width) { - GtkContainerPriv *priv; + GtkContainerPrivate *priv; g_return_if_fail (GTK_IS_CONTAINER (container)); @@ -1208,10 +1209,14 @@ void gtk_container_add (GtkContainer *container, GtkWidget *widget) { + GtkWidget *parent; + g_return_if_fail (GTK_IS_CONTAINER (container)); g_return_if_fail (GTK_IS_WIDGET (widget)); - if (widget->parent != NULL) + parent = gtk_widget_get_parent (widget); + + if (parent != NULL) { g_warning ("Attempting to add a widget with type %s to a container of " "type %s, but the widget is already inside a container of type %s, " @@ -1219,7 +1224,7 @@ gtk_container_add (GtkContainer *container, "explains how to reparent a widget.", g_type_name (G_OBJECT_TYPE (widget)), g_type_name (G_OBJECT_TYPE (container)), - g_type_name (G_OBJECT_TYPE (widget->parent))); + g_type_name (G_OBJECT_TYPE (parent))); return; } @@ -1253,8 +1258,8 @@ gtk_container_remove (GtkContainer *container, * a direct child of the container. */ g_return_if_fail (GTK_IS_TOOLBAR (container) || - widget->parent == GTK_WIDGET (container)); - + gtk_widget_get_parent (widget) == GTK_WIDGET (container)); + g_signal_emit (container, container_signals[REMOVE], 0, widget); } @@ -1283,7 +1288,7 @@ void gtk_container_set_resize_mode (GtkContainer *container, GtkResizeMode resize_mode) { - GtkContainerPriv *priv; + GtkContainerPrivate *priv; g_return_if_fail (GTK_IS_CONTAINER (container)); g_return_if_fail (resize_mode <= GTK_RESIZE_IMMEDIATE); @@ -1344,13 +1349,14 @@ gtk_container_set_reallocate_redraws (GtkContainer *container, static GtkContainer* gtk_container_get_resize_container (GtkContainer *container) { + GtkWidget *parent; GtkWidget *widget = GTK_WIDGET (container); - while (widget->parent) + while ((parent = gtk_widget_get_parent (widget))) { - widget = widget->parent; + widget = parent; if (GTK_IS_RESIZE_CONTAINER (widget)) - break; + break; } return GTK_IS_RESIZE_CONTAINER (widget) ? (GtkContainer*) widget : NULL; @@ -1387,8 +1393,9 @@ gtk_container_idle_sizer (gpointer data) void _gtk_container_queue_resize (GtkContainer *container) { - GtkContainerPriv *priv; + GtkContainerPrivate *priv; GtkContainer *resize_container; + GtkWidget *parent; GtkWidget *widget; g_return_if_fail (GTK_IS_CONTAINER (container)); @@ -1406,10 +1413,10 @@ _gtk_container_queue_resize (GtkContainer *container) GTK_PRIVATE_SET_FLAG (widget, GTK_HEIGHT_REQUEST_NEEDED); if ((resize_container && widget == GTK_WIDGET (resize_container)) || - !widget->parent) + !(parent = gtk_widget_get_parent (widget))) break; - - widget = widget->parent; + + widget = parent; } if (resize_container) @@ -1464,16 +1471,20 @@ static void gtk_container_real_check_resize (GtkContainer *container) { GtkWidget *widget = GTK_WIDGET (container); + GtkAllocation allocation; GtkRequisition requisition; gtk_widget_size_request (widget, &requisition); - - if (requisition.width > widget->allocation.width || - requisition.height > widget->allocation.height) + gtk_widget_get_allocation (widget, &allocation); + + if (requisition.width > allocation.width || + requisition.height > allocation.height) { if (GTK_IS_RESIZE_CONTAINER (container)) - gtk_widget_size_allocate (GTK_WIDGET (container), - >K_WIDGET (container)->allocation); + { + gtk_widget_size_allocate (widget, &allocation); + gtk_widget_set_allocation (widget, &allocation); + } else gtk_widget_queue_resize (widget); } @@ -1493,6 +1504,7 @@ gtk_container_real_check_resize (GtkContainer *container) void gtk_container_resize_children (GtkContainer *container) { + GtkAllocation allocation; GtkWidget *widget; /* resizing invariants: @@ -1503,7 +1515,10 @@ gtk_container_resize_children (GtkContainer *container) g_return_if_fail (GTK_IS_CONTAINER (container)); widget = GTK_WIDGET (container); - gtk_widget_size_allocate (widget, &widget->allocation); + gtk_widget_get_allocation (widget, &allocation); + + gtk_widget_size_allocate (widget, &allocation); + gtk_widget_set_allocation (widget, &allocation); } /** @@ -1673,7 +1688,7 @@ _gtk_container_child_composite_name (GtkContainer *container, g_return_val_if_fail (GTK_IS_CONTAINER (container), NULL); g_return_val_if_fail (GTK_IS_WIDGET (child), NULL); - g_return_val_if_fail (child->parent == GTK_WIDGET (container), NULL); + g_return_val_if_fail (gtk_widget_get_parent (child) == GTK_WIDGET (container), NULL); g_object_get (child, "composite-child", &composite_child, NULL); if (composite_child) @@ -1706,7 +1721,7 @@ static void gtk_container_real_set_focus_child (GtkContainer *container, GtkWidget *child) { - GtkContainerPriv *priv; + GtkContainerPrivate *priv; g_return_if_fail (GTK_IS_CONTAINER (container)); g_return_if_fail (child == NULL || GTK_IS_WIDGET (child)); @@ -1729,6 +1744,7 @@ gtk_container_real_set_focus_child (GtkContainer *container, { GtkAdjustment *hadj; GtkAdjustment *vadj; + GtkAllocation allocation; GtkWidget *focus_child; gint x, y; @@ -1746,14 +1762,17 @@ gtk_container_real_set_focus_child (GtkContainer *container, gtk_widget_translate_coordinates (focus_child, priv->focus_child, 0, 0, &x, &y); - x += priv->focus_child->allocation.x; - y += priv->focus_child->allocation.y; - + gtk_widget_get_allocation (priv->focus_child, &allocation); + x += allocation.x; + y += allocation.y; + + gtk_widget_get_allocation (focus_child, &allocation); + if (vadj) - gtk_adjustment_clamp_page (vadj, y, y + focus_child->allocation.height); - + gtk_adjustment_clamp_page (vadj, y, y + allocation.height); + if (hadj) - gtk_adjustment_clamp_page (hadj, x, x + focus_child->allocation.width); + gtk_adjustment_clamp_page (hadj, x, x + allocation.width); } } } @@ -1786,7 +1805,7 @@ gtk_container_focus (GtkWidget *widget, GList *sorted_children; gint return_val; GtkContainer *container; - GtkContainerPriv *priv; + GtkContainerPrivate *priv; g_return_val_if_fail (GTK_IS_CONTAINER (widget), FALSE); @@ -1839,18 +1858,22 @@ tab_compare (gconstpointer a, gconstpointer b, gpointer data) { + GtkAllocation child1_allocation, child2_allocation; const GtkWidget *child1 = a; const GtkWidget *child2 = b; GtkTextDirection text_direction = GPOINTER_TO_INT (data); - gint y1 = child1->allocation.y + child1->allocation.height / 2; - gint y2 = child2->allocation.y + child2->allocation.height / 2; + gtk_widget_get_allocation ((GtkWidget *) child1, &child1_allocation); + gtk_widget_get_allocation ((GtkWidget *) child2, &child2_allocation); + + gint y1 = child1_allocation.y + child1_allocation.height / 2; + gint y2 = child2_allocation.y + child2_allocation.height / 2; if (y1 == y2) { - gint x1 = child1->allocation.x + child1->allocation.width / 2; - gint x2 = child2->allocation.x + child2->allocation.width / 2; - + gint x1 = child1_allocation.x + child1_allocation.width / 2; + gint x2 = child2_allocation.x + child2_allocation.width / 2; + if (text_direction == GTK_TEXT_DIR_RTL) return (x1 < x2) ? 1 : ((x1 == x2) ? 0 : -1); else @@ -1886,7 +1909,7 @@ get_allocation_coords (GtkContainer *container, GtkWidget *widget, GdkRectangle *allocation) { - *allocation = widget->allocation; + gtk_widget_set_allocation (widget, allocation); return gtk_widget_translate_coordinates (widget, GTK_WIDGET (container), 0, 0, &allocation->x, &allocation->y); @@ -1908,7 +1931,9 @@ find_old_focus (GtkContainer *container, while (widget && widget != (GtkWidget *)container) { - GtkWidget *parent = widget->parent; + GtkWidget *parent; + + parent = gtk_widget_get_parent (widget); if (parent && (gtk_container_get_focus_child (GTK_CONTAINER (parent)) != widget)) goto next; @@ -1931,15 +1956,16 @@ old_focus_coords (GtkContainer *container, { GtkWidget *widget = GTK_WIDGET (container); GtkWidget *toplevel = gtk_widget_get_toplevel (widget); + GtkWidget *old_focus; - if (GTK_IS_WINDOW (toplevel) && GTK_WINDOW (toplevel)->focus_widget) + if (GTK_IS_WINDOW (toplevel)) { - GtkWidget *old_focus = GTK_WINDOW (toplevel)->focus_widget; - - return get_allocation_coords (container, old_focus, old_focus_rect); + old_focus = gtk_window_get_focus (GTK_WINDOW (toplevel)); + if (old_focus) + return get_allocation_coords (container, old_focus, old_focus_rect); } - else - return FALSE; + + return FALSE; } typedef struct _CompareInfo CompareInfo; @@ -2050,9 +2076,12 @@ gtk_container_focus_sort_up_down (GtkContainer *container, { /* No old focus widget, need to figure out starting x,y some other way */ + GtkAllocation allocation; GtkWidget *widget = GTK_WIDGET (container); GdkRectangle old_focus_rect; + gtk_widget_get_allocation (widget, &allocation); + if (old_focus_coords (container, &old_focus_rect)) { compare.x = old_focus_rect.x + old_focus_rect.width / 2; @@ -2060,15 +2089,15 @@ gtk_container_focus_sort_up_down (GtkContainer *container, else { if (!gtk_widget_get_has_window (widget)) - compare.x = widget->allocation.x + widget->allocation.width / 2; + compare.x = allocation.x + allocation.width / 2; else - compare.x = widget->allocation.width / 2; + compare.x = allocation.width / 2; } if (!gtk_widget_get_has_window (widget)) - compare.y = (direction == GTK_DIR_DOWN) ? widget->allocation.y : widget->allocation.y + widget->allocation.height; + compare.y = (direction == GTK_DIR_DOWN) ? allocation.y : allocation.y + allocation.height; else - compare.y = (direction == GTK_DIR_DOWN) ? 0 : + widget->allocation.height; + compare.y = (direction == GTK_DIR_DOWN) ? 0 : + allocation.height; } children = g_list_sort_with_data (children, up_down_compare, &compare); @@ -2177,9 +2206,12 @@ gtk_container_focus_sort_left_right (GtkContainer *container, { /* No old focus widget, need to figure out starting x,y some other way */ + GtkAllocation allocation; GtkWidget *widget = GTK_WIDGET (container); GdkRectangle old_focus_rect; + gtk_widget_get_allocation (widget, &allocation); + if (old_focus_coords (container, &old_focus_rect)) { compare.y = old_focus_rect.y + old_focus_rect.height / 2; @@ -2187,15 +2219,15 @@ gtk_container_focus_sort_left_right (GtkContainer *container, else { if (!gtk_widget_get_has_window (widget)) - compare.y = widget->allocation.y + widget->allocation.height / 2; + compare.y = allocation.y + allocation.height / 2; else - compare.y = widget->allocation.height / 2; + compare.y = allocation.height / 2; } if (!gtk_widget_get_has_window (widget)) - compare.x = (direction == GTK_DIR_RIGHT) ? widget->allocation.x : widget->allocation.x + widget->allocation.width; + compare.x = (direction == GTK_DIR_RIGHT) ? allocation.x : allocation.x + allocation.width; else - compare.x = (direction == GTK_DIR_RIGHT) ? 0 : widget->allocation.width; + compare.x = (direction == GTK_DIR_RIGHT) ? 0 : allocation.width; } children = g_list_sort_with_data (children, left_right_compare, &compare); @@ -2263,7 +2295,7 @@ gtk_container_focus_move (GtkContainer *container, GList *children, GtkDirectionType direction) { - GtkContainerPriv *priv = container->priv; + GtkContainerPrivate *priv = container->priv; GtkWidget *focus_child; GtkWidget *child; @@ -2351,7 +2383,7 @@ gtk_container_set_focus_chain (GtkContainer *container, { GList *chain; GList *tmp_list; - GtkContainerPriv *priv; + GtkContainerPrivate *priv; g_return_if_fail (GTK_IS_CONTAINER (container)); @@ -2415,7 +2447,7 @@ gboolean gtk_container_get_focus_chain (GtkContainer *container, GList **focus_chain) { - GtkContainerPriv *priv; + GtkContainerPrivate *priv; g_return_val_if_fail (GTK_IS_CONTAINER (container), FALSE); @@ -2441,7 +2473,7 @@ gtk_container_get_focus_chain (GtkContainer *container, void gtk_container_unset_focus_chain (GtkContainer *container) { - GtkContainerPriv *priv; + GtkContainerPrivate *priv; g_return_if_fail (GTK_IS_CONTAINER (container)); @@ -2653,7 +2685,7 @@ gtk_container_map_child (GtkWidget *child, gpointer client_data) { if (gtk_widget_get_visible (child) && - GTK_WIDGET_CHILD_VISIBLE (child) && + gtk_widget_get_child_visible (child) && !gtk_widget_get_mapped (child)) gtk_widget_map (child); } @@ -2668,7 +2700,7 @@ gtk_container_map (GtkWidget *widget) NULL); if (gtk_widget_get_has_window (widget)) - gdk_window_show (widget->window); + gdk_window_show (gtk_widget_get_window (widget)); } static void @@ -2677,7 +2709,7 @@ gtk_container_unmap (GtkWidget *widget) gtk_widget_set_mapped (widget, FALSE); if (gtk_widget_get_has_window (widget)) - gdk_window_hide (widget->window); + gdk_window_hide (gtk_widget_get_window (widget)); else gtk_container_forall (GTK_CONTAINER (widget), (GtkCallback)gtk_widget_unmap, @@ -2715,11 +2747,11 @@ gtk_container_propagate_expose (GtkContainer *container, g_return_if_fail (GTK_IS_WIDGET (child)); g_return_if_fail (event != NULL); - g_assert (child->parent == GTK_WIDGET (container)); - + g_assert (gtk_widget_get_parent (child) == GTK_WIDGET (container)); + if (gtk_widget_is_drawable (child) && !gtk_widget_get_has_window (child) && - (child->window == event->window)) + gtk_widget_get_window (child) == event->window) { child_event = gdk_event_new (GDK_EXPOSE); child_event->expose = *event; diff --git a/gtk/gtkcontainer.h b/gtk/gtkcontainer.h index e37de1ee38..ff84ac8ff0 100644 --- a/gtk/gtkcontainer.h +++ b/gtk/gtkcontainer.h @@ -46,16 +46,16 @@ G_BEGIN_DECLS #define GTK_CONTAINER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_CONTAINER, GtkContainerClass)) -typedef struct _GtkContainer GtkContainer; -typedef struct _GtkContainerPriv GtkContainerPriv; -typedef struct _GtkContainerClass GtkContainerClass; +typedef struct _GtkContainer GtkContainer; +typedef struct _GtkContainerPrivate GtkContainerPrivate; +typedef struct _GtkContainerClass GtkContainerClass; struct _GtkContainer { GtkWidget widget; /*< private >*/ - GtkContainerPriv *priv; + GtkContainerPrivate *priv; }; struct _GtkContainerClass diff --git a/gtk/gtkdialog.c b/gtk/gtkdialog.c index 7cce1d4416..fd8180bdfe 100644 --- a/gtk/gtkdialog.c +++ b/gtk/gtkdialog.c @@ -42,7 +42,7 @@ #include "gtkbuildable.h" -struct _GtkDialogPriv +struct _GtkDialogPrivate { GtkWidget *vbox; GtkWidget *action_area; @@ -136,7 +136,7 @@ gtk_dialog_class_init (GtkDialogClass *class) class->close = gtk_dialog_close; - g_type_class_add_private (gobject_class, sizeof (GtkDialogPriv)); + g_type_class_add_private (gobject_class, sizeof (GtkDialogPrivate)); /** * GtkDialog:has-separator: @@ -242,7 +242,7 @@ gtk_dialog_class_init (GtkDialogClass *class) static void update_spacings (GtkDialog *dialog) { - GtkDialogPriv *priv = dialog->priv; + GtkDialogPrivate *priv = dialog->priv; gint content_area_border; gint content_area_spacing; gint button_spacing; @@ -271,11 +271,11 @@ update_spacings (GtkDialog *dialog) static void gtk_dialog_init (GtkDialog *dialog) { - GtkDialogPriv *priv; + GtkDialogPrivate *priv; dialog->priv = G_TYPE_INSTANCE_GET_PRIVATE (dialog, GTK_TYPE_DIALOG, - GtkDialogPriv); + GtkDialogPrivate); priv = dialog->priv; priv->ignore_separator = FALSE; @@ -328,7 +328,7 @@ gtk_dialog_buildable_get_internal_child (GtkBuildable *buildable, GtkBuilder *builder, const gchar *childname) { - GtkDialogPriv *priv = GTK_DIALOG (buildable)->priv; + GtkDialogPrivate *priv = GTK_DIALOG (buildable)->priv; if (strcmp (childname, "vbox") == 0) return G_OBJECT (priv->vbox); @@ -369,7 +369,7 @@ gtk_dialog_get_property (GObject *object, GParamSpec *pspec) { GtkDialog *dialog = GTK_DIALOG (object); - GtkDialogPriv *priv = dialog->priv; + GtkDialogPrivate *priv = dialog->priv; switch (prop_id) { @@ -407,44 +407,50 @@ gtk_dialog_delete_event_handler (GtkWidget *widget, static void gtk_dialog_map (GtkWidget *widget) { + GtkWidget *default_widget, *focus; GtkWindow *window = GTK_WINDOW (widget); GtkDialog *dialog = GTK_DIALOG (widget); - GtkDialogPriv *priv = dialog->priv; + GtkDialogPrivate *priv = dialog->priv; GTK_WIDGET_CLASS (gtk_dialog_parent_class)->map (widget); - if (!window->focus_widget) + focus = gtk_window_get_focus (window); + if (!focus) { GList *children, *tmp_list; GtkWidget *first_focus = NULL; - - do - { - g_signal_emit_by_name (window, "move_focus", GTK_DIR_TAB_FORWARD); - if (first_focus == NULL) - first_focus = window->focus_widget; - else if (first_focus == window->focus_widget) + do + { + g_signal_emit_by_name (window, "move_focus", GTK_DIR_TAB_FORWARD); + + focus = gtk_window_get_focus (window); + if (first_focus == NULL) + first_focus = focus; + else if (first_focus == focus) + { + if (GTK_IS_LABEL (focus) && + !gtk_label_get_current_uri (GTK_LABEL (focus))) + gtk_label_select_region (GTK_LABEL (focus), 0, 0); + break; + } + if (!GTK_IS_LABEL (focus)) break; - if (!GTK_IS_LABEL (window->focus_widget)) - break; - if (!gtk_label_get_current_uri (GTK_LABEL (window->focus_widget))) - gtk_label_select_region (GTK_LABEL (window->focus_widget), 0, 0); - } + } while (TRUE); tmp_list = children = gtk_container_get_children (GTK_CONTAINER (priv->action_area)); - + while (tmp_list) { GtkWidget *child = tmp_list->data; - - if ((window->focus_widget == NULL || - child == window->focus_widget) && - child != window->default_widget && - window->default_widget) + + default_widget = gtk_window_get_default_widget (window); + if ((focus == NULL || child == focus) && + child != default_widget && + default_widget) { - gtk_widget_grab_focus (window->default_widget); + gtk_widget_grab_focus (default_widget); break; } @@ -466,7 +472,7 @@ static GtkWidget * dialog_find_button (GtkDialog *dialog, gint response_id) { - GtkDialogPriv *priv = dialog->priv; + GtkDialogPrivate *priv = dialog->priv; GtkWidget *child = NULL; GList *children, *tmp_list; @@ -497,8 +503,8 @@ gtk_dialog_close (GtkDialog *dialog) GdkEvent *event; event = gdk_event_new (GDK_DELETE); - - event->any.window = g_object_ref (widget->window); + + event->any.window = g_object_ref (gtk_widget_get_window (widget)); event->any.send_event = TRUE; gtk_main_do_event (event); @@ -656,7 +662,7 @@ gtk_dialog_add_action_widget (GtkDialog *dialog, GtkWidget *child, gint response_id) { - GtkDialogPriv *priv; + GtkDialogPrivate *priv; ResponseData *ad; guint signal_id; @@ -803,7 +809,7 @@ gtk_dialog_set_response_sensitive (GtkDialog *dialog, gint response_id, gboolean setting) { - GtkDialogPriv *priv; + GtkDialogPrivate *priv; GList *children; GList *tmp_list; @@ -841,7 +847,7 @@ void gtk_dialog_set_default_response (GtkDialog *dialog, gint response_id) { - GtkDialogPriv *priv; + GtkDialogPrivate *priv; GList *children; GList *tmp_list; @@ -878,7 +884,7 @@ void gtk_dialog_set_has_separator (GtkDialog *dialog, gboolean setting) { - GtkDialogPriv *priv; + GtkDialogPrivate *priv; g_return_if_fail (GTK_IS_DIALOG (dialog)); @@ -1073,7 +1079,7 @@ gtk_dialog_run (GtkDialog *dialog) g_object_ref (dialog); - was_modal = GTK_WINDOW (dialog)->modal; + was_modal = gtk_window_get_modal (GTK_WINDOW (dialog)); if (!was_modal) gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); @@ -1134,7 +1140,7 @@ void _gtk_dialog_set_ignore_separator (GtkDialog *dialog, gboolean ignore_separator) { - GtkDialogPriv *priv = dialog->priv; + GtkDialogPrivate *priv = dialog->priv; priv->ignore_separator = ignore_separator; } @@ -1155,7 +1161,7 @@ GtkWidget* gtk_dialog_get_widget_for_response (GtkDialog *dialog, gint response_id) { - GtkDialogPriv *priv; + GtkDialogPrivate *priv; GList *children; GList *tmp_list; @@ -1251,7 +1257,7 @@ gtk_dialog_set_alternative_button_order_valist (GtkDialog *dialog, gint first_response_id, va_list args) { - GtkDialogPriv *priv = dialog->priv; + GtkDialogPrivate *priv = dialog->priv; GtkWidget *child; gint response_id; gint position; @@ -1356,7 +1362,7 @@ gtk_dialog_set_alternative_button_order_from_array (GtkDialog *dialog, gint n_params, gint *new_order) { - GtkDialogPriv *priv = dialog->priv; + GtkDialogPrivate *priv = dialog->priv; GdkScreen *screen; GtkWidget *child; gint position; @@ -1474,7 +1480,7 @@ gtk_dialog_buildable_custom_finished (GtkBuildable *buildable, gpointer user_data) { GtkDialog *dialog = GTK_DIALOG (buildable); - GtkDialogPriv *priv = dialog->priv; + GtkDialogPrivate *priv = dialog->priv; GSList *l; ActionWidgetsSubParserData *parser_data; GObject *object; diff --git a/gtk/gtkdialog.h b/gtk/gtkdialog.h index 428786e81c..5394209aa0 100644 --- a/gtk/gtkdialog.h +++ b/gtk/gtkdialog.h @@ -91,16 +91,16 @@ typedef enum #define GTK_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_DIALOG, GtkDialogClass)) -typedef struct _GtkDialog GtkDialog; -typedef struct _GtkDialogPriv GtkDialogPriv; -typedef struct _GtkDialogClass GtkDialogClass; +typedef struct _GtkDialog GtkDialog; +typedef struct _GtkDialogPrivate GtkDialogPrivate; +typedef struct _GtkDialogClass GtkDialogClass; struct _GtkDialog { GtkWindow window; /*< private >*/ - GtkDialogPriv *priv; + GtkDialogPrivate *priv; }; struct _GtkDialogClass diff --git a/gtk/gtkdnd.c b/gtk/gtkdnd.c index 78f63c10c0..f190b3953a 100644 --- a/gtk/gtkdnd.c +++ b/gtk/gtkdnd.c @@ -379,8 +379,8 @@ gtk_drag_get_ipc_widget (GtkWidget *widget) if (GTK_IS_WINDOW (toplevel)) { - if (GTK_WINDOW (toplevel)->group) - gtk_window_group_add_window (GTK_WINDOW (toplevel)->group, + if (gtk_window_has_group (GTK_WINDOW (toplevel))) + gtk_window_group_add_window (gtk_window_get_group (GTK_WINDOW (toplevel)), GTK_WINDOW (result)); } @@ -458,7 +458,7 @@ grab_dnd_keys (GtkWidget *widget, GdkWindow *window, *root; gint keycode; - window = widget->window; + window = gtk_widget_get_window (widget); root = gdk_screen_get_root_window (gtk_widget_get_screen (widget)); gdk_error_trap_push (); @@ -489,7 +489,7 @@ ungrab_dnd_keys (GtkWidget *widget, GdkWindow *window, *root; gint keycode; - window = widget->window; + window = gtk_widget_get_window (widget); root = gdk_screen_get_root_window (gtk_widget_get_screen (widget)); gdk_window_remove_filter (NULL, root_key_filter, (gpointer) GDK_WINDOW_XID (window)); @@ -515,7 +515,8 @@ grab_dnd_keys (GtkWidget *widget, GdkDevice *device, guint32 time) { - gdk_device_grab (device, widget->window, + gdk_device_grab (device, + gtk_widget_get_window (widget), GDK_OWNERSHIP_APPLICATION, FALSE, GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK, NULL, time); @@ -559,8 +560,9 @@ gtk_drag_release_ipc_widget (GtkWidget *widget) ungrab_dnd_keys (widget, keyboard, GDK_CURRENT_TIME); } - if (window->group) - gtk_window_group_remove_window (window->group, window); + if (gtk_window_has_group (window)) + gtk_window_group_remove_window (gtk_window_get_group (window), + window); drag_widgets = g_slist_prepend (drag_widgets, widget); g_object_set_data (G_OBJECT (screen), I_("gtk-dnd-ipc-widgets"), @@ -954,7 +956,8 @@ gtk_drag_update_cursor (GtkDragSourceInfo *info) GdkDevice *pointer; pointer = gdk_drag_context_get_device (info->context); - gdk_device_grab (pointer, info->ipc_widget->window, + gdk_device_grab (pointer, + gtk_widget_get_window (info->ipc_widget), GDK_OWNERSHIP_APPLICATION, FALSE, GDK_POINTER_MOTION_MASK | GDK_BUTTON_RELEASE_MASK, cursor, info->grab_time); @@ -1029,8 +1032,8 @@ gtk_drag_get_source_widget (GdkDragContext *context) while (tmp_list) { GtkWidget *ipc_widget = tmp_list->data; - - if (ipc_widget->window == context->source_window) + + if (gtk_widget_get_window (ipc_widget) == context->source_window) { GtkDragSourceInfo *info; info = g_object_get_data (G_OBJECT (ipc_widget), "gtk-info"); @@ -1117,28 +1120,34 @@ gtk_drag_highlight_expose (GtkWidget *widget, if (gtk_widget_is_drawable (widget)) { + GdkWindow *window; cairo_t *cr; - + + window = gtk_widget_get_window (widget); + if (!gtk_widget_get_has_window (widget)) { - x = widget->allocation.x; - y = widget->allocation.y; - width = widget->allocation.width; - height = widget->allocation.height; + GtkAllocation allocation; + + gtk_widget_get_allocation (widget, &allocation); + x = allocation.x; + y = allocation.y; + width = allocation.width; + height = allocation.height; } else { x = 0; y = 0; - gdk_drawable_get_size (widget->window, &width, &height); + gdk_drawable_get_size (window, &width, &height); } - - gtk_paint_shadow (widget->style, widget->window, + + gtk_paint_shadow (gtk_widget_get_style (widget), window, GTK_STATE_NORMAL, GTK_SHADOW_OUT, &event->area, widget, "dnd", x, y, width, height); - cr = gdk_cairo_create (widget->window); + cr = gdk_cairo_create (window); cairo_set_source_rgb (cr, 0.0, 0.0, 0.0); /* black */ cairo_set_line_width (cr, 1.0); cairo_rectangle (cr, @@ -1608,6 +1617,7 @@ _gtk_drag_dest_handle_event (GtkWidget *toplevel, case GDK_DRAG_MOTION: case GDK_DROP_START: { + GdkWindow *window; gint tx, ty; gboolean found; @@ -1624,6 +1634,8 @@ _gtk_drag_dest_handle_event (GtkWidget *toplevel, } } + window = gtk_widget_get_window (toplevel); + #ifdef GDK_WINDOWING_X11 /* Hackaround for: http://bugzilla.gnome.org/show_bug.cgi?id=136112 * @@ -1632,10 +1644,10 @@ _gtk_drag_dest_handle_event (GtkWidget *toplevel, * expensive gdk_window_get_origin(). */ if (GTK_IS_PLUG (toplevel)) - gdk_window_get_origin (toplevel->window, &tx, &ty); + gdk_window_get_origin (window, &tx, &ty); else #endif /* GDK_WINDOWING_X11 */ - gdk_window_get_position (toplevel->window, &tx, &ty); + gdk_window_get_position (window, &tx, &ty); found = gtk_drag_find_widget (toplevel, context, @@ -1947,7 +1959,7 @@ gtk_drag_proxy_begin (GtkWidget *widget, } ipc_widget = gtk_drag_get_ipc_widget (widget); - context = gdk_drag_begin (ipc_widget->window, + context = gdk_drag_begin (gtk_widget_get_window (ipc_widget), dest_info->context->targets); source_info = gtk_drag_get_source_info (context, TRUE); @@ -2041,7 +2053,7 @@ gtk_drag_dest_realized (GtkWidget *widget) GtkWidget *toplevel = gtk_widget_get_toplevel (widget); if (gtk_widget_is_toplevel (toplevel)) - gdk_window_register_dnd (toplevel->window); + gdk_window_register_dnd (gtk_widget_get_window (toplevel)); } static void @@ -2051,7 +2063,7 @@ gtk_drag_dest_hierarchy_changed (GtkWidget *widget, GtkWidget *toplevel = gtk_widget_get_toplevel (widget); if (gtk_widget_is_toplevel (toplevel) && gtk_widget_get_realized (toplevel)) - gdk_window_register_dnd (toplevel->window); + gdk_window_register_dnd (gtk_widget_get_window (toplevel)); } static void @@ -2340,6 +2352,7 @@ gtk_drag_begin_internal (GtkWidget *widget, GtkWidget *ipc_widget; GdkCursor *cursor; GdkDevice *pointer, *keyboard; + GdkWindow *ipc_window; pointer = keyboard = NULL; ipc_widget = gtk_drag_get_ipc_widget (widget); @@ -2379,7 +2392,9 @@ gtk_drag_begin_internal (GtkWidget *widget, if (!pointer) return NULL; - if (gdk_device_grab (pointer, ipc_widget->window, + ipc_window = gtk_widget_get_window (ipc_widget); + + if (gdk_device_grab (pointer, ipc_window, GDK_OWNERSHIP_APPLICATION, FALSE, GDK_POINTER_MOTION_MASK | GDK_BUTTON_RELEASE_MASK, @@ -2408,7 +2423,7 @@ gtk_drag_begin_internal (GtkWidget *widget, source_widgets = g_slist_prepend (source_widgets, ipc_widget); - context = gdk_drag_begin (ipc_widget->window, targets); + context = gdk_drag_begin (ipc_window, targets); gdk_drag_context_set_device (context, pointer); g_list_free (targets); @@ -2500,7 +2515,7 @@ gtk_drag_begin_internal (GtkWidget *widget, if (cursor != info->cursor) { - gdk_device_grab (pointer, widget->window, + gdk_device_grab (pointer, gtk_widget_get_window (widget), GDK_OWNERSHIP_APPLICATION, FALSE, GDK_POINTER_MOTION_MASK | GDK_BUTTON_RELEASE_MASK, @@ -3048,7 +3063,7 @@ gtk_drag_update_icon (GtkDragSourceInfo *info) info->cur_y - hot_y); if (gtk_widget_get_visible (icon_window)) - gdk_window_raise (icon_window->window); + gdk_window_raise (gtk_widget_get_window (icon_window)); else gtk_widget_show (icon_window); } @@ -3127,8 +3142,9 @@ icon_window_realize (GtkWidget *window, gdk_pixbuf_render_pixmap_and_mask_for_colormap (pixbuf, gtk_widget_get_colormap (window), &pixmap, &mask, 128); - - gdk_window_set_back_pixmap (window->window, pixmap, FALSE); + + gdk_window_set_back_pixmap (gtk_widget_get_window (window), + pixmap, FALSE); g_object_unref (pixmap); if (mask) @@ -3317,8 +3333,9 @@ gtk_drag_set_icon_pixmap (GdkDragContext *context, gtk_widget_set_size_request (window, width, height); gtk_widget_realize (window); - gdk_window_set_back_pixmap (window->window, pixmap, FALSE); - + gdk_window_set_back_pixmap (gtk_widget_get_window (window), + pixmap, FALSE); + if (mask) gtk_widget_shape_combine_mask (window, mask, 0, 0); @@ -3460,7 +3477,7 @@ _gtk_drag_source_handle_event (GtkWidget *widget, GdkDevice *pointer; pointer = gdk_drag_context_get_device (context); - gdk_device_grab (pointer, widget->window, + gdk_device_grab (pointer, gtk_widget_get_window (widget), GDK_OWNERSHIP_APPLICATION, FALSE, GDK_POINTER_MOTION_MASK | GDK_BUTTON_RELEASE_MASK, cursor, info->grab_time); @@ -3615,7 +3632,7 @@ gtk_drag_source_release_selections (GtkDragSourceInfo *info, while (tmp_list) { GdkAtom selection = GDK_POINTER_TO_ATOM (tmp_list->data); - if (gdk_selection_owner_get_for_display (display, selection) == info->ipc_widget->window) + if (gdk_selection_owner_get_for_display (display, selection) == gtk_widget_get_window (info->ipc_widget)) gtk_selection_owner_set_for_display (display, NULL, selection, time); tmp_list = tmp_list->next; @@ -3968,7 +3985,7 @@ gtk_drag_update_idle (gpointer data) &action, &possible_actions); gtk_drag_update_icon (info); gdk_drag_find_window_for_screen (info->context, - info->icon_window ? info->icon_window->window : NULL, + info->icon_window ? gtk_widget_get_window (info->icon_window) : NULL, info->cur_screen, info->cur_x, info->cur_y, &dest_window, &protocol); @@ -4274,8 +4291,8 @@ gtk_drag_grab_broken_event_cb (GtkWidget *widget, * example, when changing the drag cursor. */ if (event->implicit - || event->grab_window == info->widget->window - || event->grab_window == info->ipc_widget->window) + || event->grab_window == gtk_widget_get_window (info->widget) + || event->grab_window == gtk_widget_get_window (info->ipc_widget)) return FALSE; gtk_drag_cancel (info, GTK_DRAG_RESULT_GRAB_BROKEN, gtk_get_current_event_time ()); diff --git a/gtk/gtkdrawingarea.c b/gtk/gtkdrawingarea.c index e5968f790b..6357ca649d 100644 --- a/gtk/gtkdrawingarea.c +++ b/gtk/gtkdrawingarea.c @@ -62,6 +62,8 @@ static void gtk_drawing_area_realize (GtkWidget *widget) { GtkDrawingArea *darea = GTK_DRAWING_AREA (widget); + GtkAllocation allocation; + GdkWindow *window; GdkWindowAttr attributes; gint attributes_mask; @@ -73,11 +75,13 @@ gtk_drawing_area_realize (GtkWidget *widget) { gtk_widget_set_realized (widget, TRUE); + gtk_widget_get_allocation (widget, &allocation); + attributes.window_type = GDK_WINDOW_CHILD; - attributes.x = widget->allocation.x; - attributes.y = widget->allocation.y; - attributes.width = widget->allocation.width; - attributes.height = widget->allocation.height; + attributes.x = allocation.x; + attributes.y = allocation.y; + attributes.width = allocation.width; + attributes.height = allocation.height; attributes.wclass = GDK_INPUT_OUTPUT; attributes.visual = gtk_widget_get_visual (widget); attributes.colormap = gtk_widget_get_colormap (widget); @@ -85,12 +89,13 @@ gtk_drawing_area_realize (GtkWidget *widget) attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; - widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), - &attributes, attributes_mask); - gdk_window_set_user_data (widget->window, darea); + window = gdk_window_new (gtk_widget_get_parent_window (widget), + &attributes, attributes_mask); + gdk_window_set_user_data (window, darea); + gtk_widget_set_window (widget, window); - widget->style = gtk_style_attach (widget->style, widget->window); - gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL); + gtk_widget_style_attach (widget); + gtk_style_set_background (gtk_widget_get_style (widget), window, GTK_STATE_NORMAL); } gtk_drawing_area_send_configure (GTK_DRAWING_AREA (widget)); @@ -103,12 +108,12 @@ gtk_drawing_area_size_allocate (GtkWidget *widget, g_return_if_fail (GTK_IS_DRAWING_AREA (widget)); g_return_if_fail (allocation != NULL); - widget->allocation = *allocation; + gtk_widget_set_allocation (widget, allocation); if (gtk_widget_get_realized (widget)) { if (gtk_widget_get_has_window (widget)) - gdk_window_move_resize (widget->window, + gdk_window_move_resize (gtk_widget_get_window (widget), allocation->x, allocation->y, allocation->width, allocation->height); @@ -119,17 +124,19 @@ gtk_drawing_area_size_allocate (GtkWidget *widget, static void gtk_drawing_area_send_configure (GtkDrawingArea *darea) { + GtkAllocation allocation; GtkWidget *widget; GdkEvent *event = gdk_event_new (GDK_CONFIGURE); widget = GTK_WIDGET (darea); + gtk_widget_get_allocation (widget, &allocation); - event->configure.window = g_object_ref (widget->window); + event->configure.window = g_object_ref (gtk_widget_get_window (widget)); event->configure.send_event = TRUE; - event->configure.x = widget->allocation.x; - event->configure.y = widget->allocation.y; - event->configure.width = widget->allocation.width; - event->configure.height = widget->allocation.height; + event->configure.x = allocation.x; + event->configure.y = allocation.y; + event->configure.width = allocation.width; + event->configure.height = allocation.height; gtk_widget_event (widget, event); gdk_event_free (event); diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c index 723098e852..7189921e27 100644 --- a/gtk/gtkentry.c +++ b/gtk/gtkentry.c @@ -2255,7 +2255,7 @@ find_invisible_char (GtkWidget *widget) 0x273a /* SIXTEEN POINTED ASTERISK */ }; - if (widget->style) + if (gtk_widget_get_style (widget)) gtk_widget_style_get (widget, "invisible-char", &invisible_chars[0], NULL); @@ -2673,12 +2673,12 @@ realize_icon_info (GtkWidget *widget, GDK_LEAVE_NOTIFY_MASK); attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; - icon_info->window = gdk_window_new (widget->window, + icon_info->window = gdk_window_new (gtk_widget_get_window (widget), &attributes, attributes_mask); gdk_window_set_user_data (icon_info->window, widget); gdk_window_set_background (icon_info->window, - &widget->style->base[gtk_widget_get_state (widget)]); + >k_widget_get_style (widget)->base[gtk_widget_get_state (widget)]); gtk_widget_queue_resize (widget); } @@ -2752,7 +2752,10 @@ gtk_entry_realize (GtkWidget *widget) { GtkEntry *entry; GtkEntryPrivate *priv; + GtkStateType state; + GtkStyle *style; EntryIconInfo *icon_info; + GdkWindow *window; GdkWindowAttr attributes; gint attributes_mask; int i; @@ -2780,8 +2783,9 @@ gtk_entry_realize (GtkWidget *widget) GDK_LEAVE_NOTIFY_MASK); attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; - widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); - gdk_window_set_user_data (widget->window, entry); + window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); + gtk_widget_set_window (widget, window); + gdk_window_set_user_data (window, entry); get_text_area_size (entry, &attributes.x, &attributes.y, &attributes.width, &attributes.height); @@ -2791,17 +2795,19 @@ gtk_entry_realize (GtkWidget *widget) attributes_mask |= GDK_WA_CURSOR; } - entry->text_area = gdk_window_new (widget->window, &attributes, attributes_mask); + entry->text_area = gdk_window_new (window, &attributes, attributes_mask); gdk_window_set_user_data (entry->text_area, entry); if (attributes_mask & GDK_WA_CURSOR) gdk_cursor_unref (attributes.cursor); - widget->style = gtk_style_attach (widget->style, widget->window); + gtk_widget_style_attach (widget); - gdk_window_set_background (widget->window, &widget->style->base[gtk_widget_get_state (widget)]); - gdk_window_set_background (entry->text_area, &widget->style->base[gtk_widget_get_state (widget)]); + style = gtk_widget_get_style (widget); + state = gtk_widget_get_state (widget); + gdk_window_set_background (window, &style->base[state]); + gdk_window_set_background (entry->text_area, &style->base[state]); gdk_window_show (entry->text_area); @@ -2877,11 +2883,14 @@ _gtk_entry_get_borders (GtkEntry *entry, { GtkWidget *widget = GTK_WIDGET (entry); GtkEntryPrivate *priv = GTK_ENTRY_GET_PRIVATE (widget); + GtkStyle *style; if (entry->has_frame) { - *xborder = widget->style->xthickness; - *yborder = widget->style->ythickness; + style = gtk_widget_get_style (widget); + + *xborder = style->xthickness; + *yborder = style->ythickness; } else { @@ -2912,7 +2921,7 @@ gtk_entry_size_request (GtkWidget *widget, gtk_widget_ensure_style (widget); context = gtk_widget_get_pango_context (widget); metrics = pango_context_get_metrics (context, - widget->style->font_desc, + gtk_widget_get_style (widget)->font_desc, pango_context_get_language (context)); entry->ascent = pango_font_metrics_get_ascent (metrics); @@ -2991,15 +3000,17 @@ gtk_entry_get_text_area_size (GtkEntry *entry, { GtkWidget *widget = GTK_WIDGET (entry); GtkEntryPrivate *priv = GTK_ENTRY_GET_PRIVATE (widget); + GtkAllocation allocation; + GtkRequisition requisition; gint frame_height; gint xborder, yborder; - GtkRequisition requisition; gtk_widget_get_child_requisition (widget, &requisition); + gtk_widget_get_allocation (widget, &allocation); _gtk_entry_get_borders (entry, &xborder, &yborder); if (gtk_widget_get_realized (widget)) - gdk_drawable_get_size (widget->window, NULL, &frame_height); + gdk_drawable_get_size (gtk_widget_get_window (widget), NULL, &frame_height); else frame_height = requisition.height; @@ -3013,7 +3024,7 @@ gtk_entry_get_text_area_size (GtkEntry *entry, *y = frame_height / 2 - (requisition.height - yborder * 2) / 2; if (width) - *width = GTK_WIDGET (entry)->allocation.width - xborder * 2; + *width = allocation.width - xborder * 2; if (height) *height = requisition.height - yborder * 2; @@ -3044,29 +3055,31 @@ get_widget_window_size (GtkEntry *entry, gint *width, gint *height) { + GtkAllocation allocation; GtkRequisition requisition; GtkWidget *widget = GTK_WIDGET (entry); - + gtk_widget_get_child_requisition (widget, &requisition); + gtk_widget_get_allocation (widget, &allocation); if (x) - *x = widget->allocation.x; + *x = allocation.x; if (y) { if (entry->is_cell_renderer) - *y = widget->allocation.y; + *y = allocation.y; else - *y = widget->allocation.y + (widget->allocation.height - requisition.height) / 2; + *y = allocation.y + (allocation.height - requisition.height) / 2; } if (width) - *width = widget->allocation.width; + *width = allocation.width; if (height) { if (entry->is_cell_renderer) - *height = widget->allocation.height; + *height = allocation.height; else *height = requisition.height; } @@ -3103,9 +3116,9 @@ gtk_entry_size_allocate (GtkWidget *widget, GtkAllocation *allocation) { GtkEntry *entry = GTK_ENTRY (widget); - - widget->allocation = *allocation; - + + gtk_widget_set_allocation (widget, allocation); + if (gtk_widget_get_realized (widget)) { /* We call gtk_widget_get_child_requisition, since we want (for @@ -3116,7 +3129,8 @@ gtk_entry_size_allocate (GtkWidget *widget, GtkEntryCompletion* completion; get_widget_window_size (entry, &x, &y, &width, &height); - gdk_window_move_resize (widget->window, x, y, width, height); + gdk_window_move_resize (gtk_widget_get_window (widget), + x, y, width, height); place_windows (entry); gtk_entry_recompute (entry); @@ -3281,11 +3295,15 @@ gtk_entry_draw_frame (GtkWidget *widget, GdkEventExpose *event) { GtkEntryPrivate *priv = GTK_ENTRY_GET_PRIVATE (widget); + GtkStyle *style; + GdkWindow *window; gint x = 0, y = 0, width, height; gboolean state_hint; GtkStateType state; - gdk_drawable_get_size (widget->window, &width, &height); + window = gtk_widget_get_window (widget); + + gdk_drawable_get_size (window, &width, &height); /* Fix a problem with some themes which assume that entry->text_area's * width equals widget->window's width */ @@ -3308,6 +3326,7 @@ gtk_entry_draw_frame (GtkWidget *widget, height -= 2 * priv->focus_width; } + style = gtk_widget_get_style (widget); gtk_widget_style_get (widget, "state-hint", &state_hint, NULL); if (state_hint) state = gtk_widget_has_focus (widget) ? @@ -3315,7 +3334,7 @@ gtk_entry_draw_frame (GtkWidget *widget, else state = GTK_STATE_NORMAL; - gtk_paint_shadow (widget->style, widget->window, + gtk_paint_shadow (style, window, state, priv->shadow_type, &event->area, widget, "entry", x, y, width, height); @@ -3328,8 +3347,8 @@ gtk_entry_draw_frame (GtkWidget *widget, y -= priv->focus_width; width += 2 * priv->focus_width; height += 2 * priv->focus_width; - - gtk_paint_focus (widget->style, widget->window, + + gtk_paint_focus (style, window, gtk_widget_get_state (widget), &event->area, widget, "entry", 0, 0, width, height); @@ -3341,6 +3360,7 @@ gtk_entry_get_progress_border (GtkWidget *widget, GtkBorder *progress_border) { GtkBorder *tmp_border; + GtkStyle *style; gtk_widget_style_get (widget, "progress-border", &tmp_border, NULL); if (tmp_border) @@ -3350,10 +3370,12 @@ gtk_entry_get_progress_border (GtkWidget *widget, } else { - progress_border->left = widget->style->xthickness; - progress_border->right = widget->style->xthickness; - progress_border->top = widget->style->ythickness; - progress_border->bottom = widget->style->ythickness; + style = gtk_widget_get_style (widget); + + progress_border->left = style->xthickness; + progress_border->right = style->xthickness; + progress_border->top = style->ythickness; + progress_border->bottom = style->ythickness; } } @@ -3373,7 +3395,7 @@ get_progress_area (GtkWidget *widget, *x = progress_border.left; *y = progress_border.top; - gdk_drawable_get_size (widget->window, width, height); + gdk_drawable_get_size (gtk_widget_get_window (widget), width, height); *width -= progress_border.left + progress_border.right; *height -= progress_border.top + progress_border.bottom; @@ -3429,7 +3451,7 @@ gtk_entry_draw_progress (GtkWidget *widget, if ((width <= 0) || (height <= 0)) return; - if (event->window != widget->window) + if (event->window != gtk_widget_get_window (widget)) { gint pos_x, pos_y; @@ -3443,7 +3465,7 @@ gtk_entry_draw_progress (GtkWidget *widget, if (!gtk_widget_get_sensitive (widget)) state = GTK_STATE_INSENSITIVE; - gtk_paint_box (widget->style, event->window, + gtk_paint_box (gtk_widget_get_style (widget), event->window, state, GTK_SHADOW_OUT, &event->area, widget, "entry-progress", x, y, @@ -3455,18 +3477,22 @@ gtk_entry_expose (GtkWidget *widget, GdkEventExpose *event) { GtkEntry *entry = GTK_ENTRY (widget); + GtkStyle *style; gboolean state_hint; GtkStateType state; GtkEntryPrivate *priv = GTK_ENTRY_GET_PRIVATE (entry); + style = gtk_widget_get_style (widget); + gtk_widget_style_get (widget, "state-hint", &state_hint, NULL); + if (state_hint) state = gtk_widget_has_focus (widget) ? GTK_STATE_ACTIVE : gtk_widget_get_state (widget); else state = gtk_widget_get_state(widget); - if (widget->window == event->window) + if (gtk_widget_get_window (widget) == event->window) { gtk_entry_draw_frame (widget, event); } @@ -3476,7 +3502,7 @@ gtk_entry_expose (GtkWidget *widget, gdk_drawable_get_size (entry->text_area, &width, &height); - gtk_paint_flat_box (widget->style, entry->text_area, + gtk_paint_flat_box (style, entry->text_area, state, GTK_SHADOW_NONE, &event->area, widget, "entry_bg", 0, 0, width, height); @@ -3508,7 +3534,7 @@ gtk_entry_expose (GtkWidget *widget, gdk_drawable_get_size (icon_info->window, &width, &height); - gtk_paint_flat_box (widget->style, icon_info->window, + gtk_paint_flat_box (style, icon_info->window, gtk_widget_get_state (widget), GTK_SHADOW_NONE, NULL, widget, "entry_bg", 0, 0, width, height); @@ -4251,13 +4277,22 @@ gtk_entry_state_changed (GtkWidget *widget, if (gtk_widget_get_realized (widget)) { - gdk_window_set_background (widget->window, &widget->style->base[gtk_widget_get_state (widget)]); - gdk_window_set_background (entry->text_area, &widget->style->base[gtk_widget_get_state (widget)]); + GtkStateType state; + GtkStyle *style; + + style = gtk_widget_get_style (widget); + state = gtk_widget_get_state (widget); + + gdk_window_set_background (gtk_widget_get_window (widget), + &style->base[state]); + gdk_window_set_background (entry->text_area, + &style->base[state]); for (i = 0; i < MAX_ICONS; i++) { EntryIconInfo *icon_info = priv->icons[i]; if (icon_info && icon_info->window) - gdk_window_set_background (icon_info->window, &widget->style->base[gtk_widget_get_state (widget)]); + gdk_window_set_background (icon_info->window, + &style->base[state]); } if (gtk_widget_is_sensitive (widget)) @@ -4469,13 +4504,20 @@ gtk_entry_style_set (GtkWidget *widget, if (previous_style && gtk_widget_get_realized (widget)) { - gdk_window_set_background (widget->window, &widget->style->base[gtk_widget_get_state (widget)]); - gdk_window_set_background (entry->text_area, &widget->style->base[gtk_widget_get_state (widget)]); + GtkStyle *style; + + style = gtk_widget_get_style (widget); + + gdk_window_set_background (gtk_widget_get_window (widget), + &style->base[gtk_widget_get_state (widget)]); + gdk_window_set_background (entry->text_area, + &style->base[gtk_widget_get_state (widget)]); for (i = 0; i < MAX_ICONS; i++) { EntryIconInfo *icon_info = priv->icons[i]; if (icon_info && icon_info->window) - gdk_window_set_background (icon_info->window, &widget->style->base[gtk_widget_get_state (widget)]); + gdk_window_set_background (icon_info->window, + &style->base[gtk_widget_get_state (widget)]); } } @@ -5134,6 +5176,7 @@ static void gtk_entry_real_activate (GtkEntry *entry) { GtkWindow *window; + GtkWidget *default_widget, *focus_widget; GtkWidget *toplevel; GtkWidget *widget; @@ -5145,12 +5188,15 @@ gtk_entry_real_activate (GtkEntry *entry) if (GTK_IS_WINDOW (toplevel)) { window = GTK_WINDOW (toplevel); - - if (window && - widget != window->default_widget && - !(widget == window->focus_widget && - (!window->default_widget || !gtk_widget_get_sensitive (window->default_widget)))) - gtk_window_activate_default (window); + + if (window) + { + default_widget = gtk_window_get_default_widget (window); + focus_widget = gtk_window_get_focus (window); + if (widget != default_widget && + !(widget == focus_widget && (!default_widget || !gtk_widget_get_sensitive (default_widget)))) + gtk_window_activate_default (window); + } } } } @@ -5541,19 +5587,22 @@ draw_text_with_color (GtkEntry *entry, cairo_t *cr, GdkColor *default_color) PangoRectangle logical_rect; GdkColor *selection_color, *text_color; GtkBorder inner_border; + GtkStyle *style; pango_layout_get_pixel_extents (layout, NULL, &logical_rect); gtk_entry_get_pixel_ranges (entry, &ranges, &n_ranges); + style = gtk_widget_get_style (widget); + if (gtk_widget_has_focus (widget)) { - selection_color = &widget->style->base [GTK_STATE_SELECTED]; - text_color = &widget->style->text [GTK_STATE_SELECTED]; + selection_color = &style->base [GTK_STATE_SELECTED]; + text_color = &style->text [GTK_STATE_SELECTED]; } else { - selection_color = &widget->style->base [GTK_STATE_ACTIVE]; - text_color = &widget->style->text [GTK_STATE_ACTIVE]; + selection_color = &style->base [GTK_STATE_ACTIVE]; + text_color = &style->text [GTK_STATE_ACTIVE]; } _gtk_entry_effective_inner_border (entry, &inner_border); @@ -5591,17 +5640,19 @@ gtk_entry_draw_text (GtkEntry *entry) if (gtk_widget_is_drawable (widget)) { + GtkStateType state; + GtkStyle *style; GdkColor text_color, bar_text_color; gint pos_x, pos_y; gint width, height; gint progress_x, progress_y, progress_width, progress_height; - GtkStateType state; state = GTK_STATE_SELECTED; if (!gtk_widget_get_sensitive (widget)) state = GTK_STATE_INSENSITIVE; - text_color = widget->style->text[widget->state]; - bar_text_color = widget->style->fg[state]; + style = gtk_widget_get_style (widget); + text_color = style->text[gtk_widget_get_state (widget)]; + bar_text_color = style->fg[state]; get_progress_area (widget, &progress_x, &progress_y, @@ -5784,7 +5835,7 @@ gtk_entry_draw_cursor (GtkEntry *entry, gdk_cairo_rectangle (cr, &rect); cairo_clip (cr); cairo_move_to (cr, x, y); - gdk_cairo_set_source_color (cr, &widget->style->base[widget->state]); + gdk_cairo_set_source_color (cr, >k_widget_get_style (widget)->base[gtk_widget_get_state (widget)]); pango_cairo_show_layout (cr, layout); } @@ -6047,26 +6098,29 @@ gtk_entry_adjust_scroll (GtkEntry *entry) static void gtk_entry_move_adjustments (GtkEntry *entry) { + GtkAllocation allocation; + GtkAdjustment *adjustment; PangoContext *context; PangoFontMetrics *metrics; gint x, layout_x, border_x, border_y; gint char_width; - GtkAdjustment *adjustment; adjustment = g_object_get_qdata (G_OBJECT (entry), quark_cursor_hadjustment); if (!adjustment) return; + gtk_widget_get_allocation (&(entry->widget), &allocation); + /* Cursor position, layout offset, border width, and widget allocation */ gtk_entry_get_cursor_locations (entry, CURSOR_STANDARD, &x, NULL); get_layout_position (entry, &layout_x, NULL); _gtk_entry_get_borders (entry, &border_x, &border_y); - x += entry->widget.allocation.x + layout_x + border_x; + x += allocation.x + layout_x + border_x; /* Approximate width of a char, so user can see what is ahead/behind */ context = gtk_widget_get_pango_context (GTK_WIDGET (entry)); metrics = pango_context_get_metrics (context, - entry->widget.style->font_desc, + gtk_widget_get_style (&(entry->widget))->font_desc, pango_context_get_language (context)); char_width = pango_font_metrics_get_approximate_char_width (metrics) / PANGO_SCALE; @@ -8790,14 +8844,16 @@ gtk_entry_drag_motion (GtkWidget *widget, guint time) { GtkEntry *entry = GTK_ENTRY (widget); + GtkStyle *style; GtkWidget *source_widget; GdkDragAction suggested_action; gint new_position, old_position; gint sel1, sel2; - - x -= widget->style->xthickness; - y -= widget->style->ythickness; - + + style = gtk_widget_get_style (widget); + x -= style->xthickness; + y -= style->ythickness; + old_position = entry->dnd_position; new_position = gtk_entry_find_position (entry, x + entry->scroll_offset); @@ -8855,12 +8911,14 @@ gtk_entry_drag_data_received (GtkWidget *widget, { GtkEntry *entry = GTK_ENTRY (widget); GtkEditable *editable = GTK_EDITABLE (widget); + GtkStyle *style; gchar *str; str = (gchar *) gtk_selection_data_get_text (selection_data); - x -= widget->style->xthickness; - y -= widget->style->ythickness; + style = gtk_widget_get_style (widget); + x -= style->xthickness; + y -= style->ythickness; if (str && entry->editable) { diff --git a/gtk/gtkentrycompletion.c b/gtk/gtkentrycompletion.c index 8d066bc211..75f2fd22c4 100644 --- a/gtk/gtkentrycompletion.c +++ b/gtk/gtkentrycompletion.c @@ -1209,7 +1209,7 @@ gtk_entry_completion_insert_action (GtkEntryCompletion *completion, 1, markup, -1); - if (!completion->priv->action_view->parent) + if (!gtk_widget_get_parent (completion->priv->action_view)) { GtkTreePath *path = gtk_tree_path_new_from_indices (0, -1); @@ -1375,12 +1375,14 @@ gtk_entry_completion_list_motion_notify (GtkWidget *widget, gboolean _gtk_entry_completion_resize_popup (GtkEntryCompletion *completion) { + GtkAllocation allocation; gint x, y; gint matches, actions, items, height, x_border, y_border; GdkScreen *screen; gint monitor_num; gint vertical_separator; GdkRectangle monitor; + GdkWindow *window; GtkRequisition popup_req; GtkRequisition entry_req; GtkTreePath *path; @@ -1389,10 +1391,12 @@ _gtk_entry_completion_resize_popup (GtkEntryCompletion *completion) GtkTreeViewColumn *action_column; gint action_height; - if (!completion->priv->entry->window) + window = gtk_widget_get_window (completion->priv->entry); + + if (!window) return FALSE; - gdk_window_get_origin (completion->priv->entry->window, &x, &y); + gdk_window_get_origin (window, &x, &y); _gtk_entry_get_borders (GTK_ENTRY (completion->priv->entry), &x_border, &y_border); matches = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (completion->priv->filter_model), NULL); @@ -1413,8 +1417,7 @@ _gtk_entry_completion_resize_popup (GtkEntryCompletion *completion) gtk_widget_realize (completion->priv->tree_view); screen = gtk_widget_get_screen (GTK_WIDGET (completion->priv->entry)); - monitor_num = gdk_screen_get_monitor_at_window (screen, - GTK_WIDGET (completion->priv->entry)->window); + monitor_num = gdk_screen_get_monitor_at_window (screen, window); gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor); @@ -1429,8 +1432,9 @@ _gtk_entry_completion_resize_popup (GtkEntryCompletion *completion) else gtk_widget_show (completion->priv->scrolled_window); + gtk_widget_get_allocation (completion->priv->entry, &allocation); if (completion->priv->popup_set_width) - width = MIN (completion->priv->entry->allocation.width, monitor.width) - 2 * x_border; + width = MIN (allocation.width, monitor.width) - 2 * x_border; else width = -1; @@ -1504,7 +1508,7 @@ _gtk_entry_completion_popup (GtkEntryCompletion *completion, renderers = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column)); gtk_widget_ensure_style (completion->priv->tree_view); g_object_set (GTK_CELL_RENDERER (renderers->data), "cell-background-gdk", - &completion->priv->tree_view->style->bg[GTK_STATE_NORMAL], + >k_widget_get_style (completion->priv->tree_view)->bg[GTK_STATE_NORMAL], NULL); g_list_free (renderers); @@ -1532,7 +1536,7 @@ _gtk_entry_completion_popup (GtkEntryCompletion *completion, gtk_widget_show (completion->priv->popup_window); gtk_device_grab_add (completion->priv->popup_window, device, TRUE); - gdk_device_grab (device, completion->priv->popup_window->window, + gdk_device_grab (device, gtk_widget_get_window (completion->priv->popup_window), GDK_OWNERSHIP_WINDOW, TRUE, GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | diff --git a/gtk/gtkenums.h b/gtk/gtkenums.h index fd021393a5..f2c931ecaa 100644 --- a/gtk/gtkenums.h +++ b/gtk/gtkenums.h @@ -560,6 +560,52 @@ typedef enum } GtkSizeRequestMode; +/** + * GtkWrapAllocationMode: + * @GTK_WRAP_ALLOCATE_FREE: Items wrap freely in the box's orientation + * @GTK_WRAP_ALLOCATE_ALIGNED: Items are aligned into rows and columns + * @GTK_WRAP_ALLOCATE_HOMOGENEOUS: Items are all allocated the same size + * + * Describes how an #GtkWrapBox positions its children. + */ +typedef enum { + GTK_WRAP_ALLOCATE_FREE = 0, + GTK_WRAP_ALLOCATE_ALIGNED, + GTK_WRAP_ALLOCATE_HOMOGENEOUS +} GtkWrapAllocationMode; + +/** + * GtkWrapBoxSpreading: + * @GTK_WRAP_BOX_SPREAD_BEGIN: Items are allocated no more than their natural size + * in the layout's orientation and any extra space is left trailing at + * the end of each line. + * @GTK_WRAP_BOX_SPREAD_END: Items are allocated no more than their natural size + * in the layout's orientation and any extra space skipped at the beginning + * of each line. + * @GTK_WRAP_BOX_SPREAD_EVEN: Items are allocated no more than their natural size + * in the layout's orientation and any extra space is evenly distributed + * between children. + * @GTK_WRAP_BOX_SPREAD_EXPAND: Items share the extra space evenly (or among children that 'expand' when + * in %GTK_WRAP_ALLOCATE_FREE mode. + * + * Describes how an #GtkWrapBox deals with extra space when allocating children. + * + * The box always tries to fit as many children at their natural size + * in the given orentation as possible with the exception of fitting "minimum-line-children" + * items into the available size. When the available size is larger than + * the size needed to fit a given number of children at their natural size + * then extra space is available to distribute among children. The + * #GtkWrapBoxSpreading option describes what to do with this space. + * + */ +typedef enum { + GTK_WRAP_BOX_SPREAD_BEGIN = 0, + GTK_WRAP_BOX_SPREAD_END, + GTK_WRAP_BOX_SPREAD_EVEN, + GTK_WRAP_BOX_SPREAD_EXPAND +} GtkWrapBoxSpreading; + + G_END_DECLS #endif /* __GTK_ENUMS_H__ */ diff --git a/gtk/gtkeventbox.c b/gtk/gtkeventbox.c index 3e575e1c9c..70fd1aa68d 100644 --- a/gtk/gtkeventbox.c +++ b/gtk/gtkeventbox.c @@ -366,20 +366,24 @@ gtk_event_box_set_above_child (GtkEventBox *event_box, static void gtk_event_box_realize (GtkWidget *widget) { + GtkAllocation allocation; + GdkWindow *window; GdkWindowAttr attributes; gint attributes_mask; gint border_width; GtkEventBoxPrivate *priv; gboolean visible_window; + gtk_widget_get_allocation (widget, &allocation); + gtk_widget_set_realized (widget, TRUE); border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); - - attributes.x = widget->allocation.x + border_width; - attributes.y = widget->allocation.y + border_width; - attributes.width = widget->allocation.width - 2*border_width; - attributes.height = widget->allocation.height - 2*border_width; + + attributes.x = allocation.x + border_width; + attributes.y = allocation.y + border_width; + attributes.width = allocation.width - 2*border_width; + attributes.height = allocation.height - 2*border_width; attributes.window_type = GDK_WINDOW_CHILD; attributes.event_mask = gtk_widget_get_events (widget) | GDK_BUTTON_MOTION_MASK @@ -399,15 +403,17 @@ gtk_event_box_realize (GtkWidget *widget) attributes.wclass = GDK_INPUT_OUTPUT; attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; - - widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), - &attributes, attributes_mask); - gdk_window_set_user_data (widget->window, widget); + + window = gdk_window_new (gtk_widget_get_parent_window (widget), + &attributes, attributes_mask); + gtk_widget_set_window (widget, window); + gdk_window_set_user_data (window, widget); } else { - widget->window = gtk_widget_get_parent_window (widget); - g_object_ref (widget->window); + window = gtk_widget_get_parent_window (widget); + gtk_widget_set_window (widget, window); + g_object_ref (window); } if (!visible_window || priv->above_child) @@ -418,16 +424,15 @@ gtk_event_box_realize (GtkWidget *widget) else attributes_mask = 0; - priv->event_window = gdk_window_new (widget->window, + priv->event_window = gdk_window_new (window, &attributes, attributes_mask); gdk_window_set_user_data (priv->event_window, widget); } + gtk_widget_style_attach (widget); - widget->style = gtk_style_attach (widget->style, widget->window); - if (visible_window) - gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL); + gtk_style_set_background (gtk_widget_get_style (widget), window, GTK_STATE_NORMAL); } static void @@ -512,8 +517,10 @@ gtk_event_box_size_allocate (GtkWidget *widget, guint border_width; GtkWidget *child; - widget->allocation = *allocation; bin = GTK_BIN (widget); + + gtk_widget_set_allocation (widget, allocation); + border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); if (!gtk_widget_get_has_window (widget)) @@ -541,7 +548,7 @@ gtk_event_box_size_allocate (GtkWidget *widget, child_allocation.height); if (gtk_widget_get_has_window (widget)) - gdk_window_move_resize (widget->window, + gdk_window_move_resize (gtk_widget_get_window (widget), allocation->x + border_width, allocation->y + border_width, child_allocation.width, @@ -558,8 +565,10 @@ gtk_event_box_paint (GtkWidget *widget, GdkRectangle *area) { if (!gtk_widget_get_app_paintable (widget)) - gtk_paint_flat_box (widget->style, widget->window, - widget->state, GTK_SHADOW_NONE, + gtk_paint_flat_box (gtk_widget_get_style (widget), + gtk_widget_get_window (widget), + gtk_widget_get_state (widget), + GTK_SHADOW_NONE, area, widget, "eventbox", 0, 0, -1, -1); } diff --git a/gtk/gtkexpander.c b/gtk/gtkexpander.c index a2095368b5..735419eb74 100644 --- a/gtk/gtkexpander.c +++ b/gtk/gtkexpander.c @@ -430,7 +430,9 @@ gtk_expander_destroy (GtkObject *object) static void gtk_expander_realize (GtkWidget *widget) { + GtkAllocation allocation; GtkExpanderPrivate *priv; + GdkWindow *window; GdkWindowAttr attributes; gint attributes_mask; gint border_width; @@ -438,6 +440,7 @@ gtk_expander_realize (GtkWidget *widget) gint label_height; priv = GTK_EXPANDER (widget)->priv; + gtk_widget_set_realized (widget, TRUE); border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); @@ -454,10 +457,12 @@ gtk_expander_realize (GtkWidget *widget) else label_height = 0; + gtk_widget_get_allocation (widget, &allocation); + attributes.window_type = GDK_WINDOW_CHILD; - attributes.x = widget->allocation.x + border_width; - attributes.y = widget->allocation.y + border_width; - attributes.width = MAX (widget->allocation.width - 2 * border_width, 1); + attributes.x = allocation.x + border_width; + attributes.y = allocation.y + border_width; + attributes.width = MAX (allocation.width - 2 * border_width, 1); attributes.height = MAX (expander_rect.height, label_height - 2 * border_width); attributes.wclass = GDK_INPUT_ONLY; attributes.event_mask = gtk_widget_get_events (widget) | @@ -468,14 +473,15 @@ gtk_expander_realize (GtkWidget *widget) attributes_mask = GDK_WA_X | GDK_WA_Y; - widget->window = gtk_widget_get_parent_window (widget); - g_object_ref (widget->window); + window = gtk_widget_get_parent_window (widget); + gtk_widget_set_window (widget, window); + g_object_ref (window); priv->event_window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); gdk_window_set_user_data (priv->event_window, widget); - widget->style = gtk_style_attach (widget->style, widget->window); + gtk_widget_style_attach (widget); } static void @@ -497,6 +503,7 @@ static void get_expander_bounds (GtkExpander *expander, GdkRectangle *rect) { + GtkAllocation allocation; GtkWidget *widget; GtkExpanderPrivate *priv; gint border_width; @@ -510,6 +517,8 @@ get_expander_bounds (GtkExpander *expander, widget = GTK_WIDGET (expander); priv = expander->priv; + gtk_widget_get_allocation (widget, &allocation); + border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); gtk_widget_style_get (widget, @@ -522,20 +531,20 @@ get_expander_bounds (GtkExpander *expander, ltr = gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL; - rect->x = widget->allocation.x + border_width; - rect->y = widget->allocation.y + border_width; + rect->x = allocation.x + border_width; + rect->y = allocation.y + border_width; if (ltr) rect->x += expander_spacing; else - rect->x += widget->allocation.width - 2 * border_width - + rect->x += allocation.width - 2 * border_width - expander_spacing - expander_size; if (priv->label_widget && gtk_widget_get_visible (priv->label_widget)) { GtkAllocation label_allocation; - label_allocation = priv->label_widget->allocation; + gtk_widget_get_allocation (priv->label_widget, &label_allocation); if (expander_size < label_allocation.height) rect->y += focus_width + focus_pad + (label_allocation.height - expander_size) / 2; @@ -583,7 +592,7 @@ gtk_expander_size_allocate (GtkWidget *widget, border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); - widget->allocation = *allocation; + gtk_widget_set_allocation (widget, allocation); gtk_widget_style_get (widget, "interior-focus", &interior_focus, @@ -626,15 +635,14 @@ gtk_expander_size_allocate (GtkWidget *widget, ltr = gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL; if (priv->label_fill) - label_allocation.x = widget->allocation.x + label_xoffset; + label_allocation.x = allocation->x + label_xoffset; else if (ltr) - label_allocation.x = widget->allocation.x + label_xoffset; + label_allocation.x = allocation->x + label_xoffset; else - label_allocation.x = - widget->allocation.x + widget->allocation.width - - (label_allocation.width + label_xoffset); + label_allocation.x = allocation->x + allocation->width - + (label_allocation.width + label_xoffset); - label_allocation.y = widget->allocation.y + border_width + focus_width + focus_pad; + label_allocation.y = allocation->y + border_width + focus_width + focus_pad; label_allocation.height = MIN (label_height, allocation->height - 2 * border_width - 2 * focus_width - 2 * focus_pad - @@ -671,8 +679,8 @@ gtk_expander_size_allocate (GtkWidget *widget, top_height = MAX (top_min_height, label_height + (interior_focus ? 2 * focus_width + 2 * focus_pad : 0)); - child_allocation.x = widget->allocation.x + border_width; - child_allocation.y = widget->allocation.y + top_height + child_yoffset; + child_allocation.x = allocation->x + border_width; + child_allocation.y = allocation->y + top_height + child_yoffset; child_allocation.width = MAX (allocation->width - 2 * border_width, 1); child_allocation.height = allocation->height - top_height - child_ypad; @@ -713,6 +721,7 @@ gtk_expander_unmap (GtkWidget *widget) static void gtk_expander_paint_prelight (GtkExpander *expander) { + GtkAllocation allocation; GtkWidget *widget; GtkContainer *container; GtkExpanderPrivate *priv; @@ -736,13 +745,20 @@ gtk_expander_paint_prelight (GtkExpander *expander) "expander-spacing", &expander_spacing, NULL); + gtk_widget_get_allocation (widget, &allocation); + border_width = gtk_container_get_border_width (container); - area.x = widget->allocation.x + border_width; - area.y = widget->allocation.y + border_width; - area.width = widget->allocation.width - (2 * border_width); + area.x = allocation.x + border_width; + area.y = allocation.y + border_width; + area.width = allocation.width - (2 * border_width); if (priv->label_widget && gtk_widget_get_visible (priv->label_widget)) - area.height = priv->label_widget->allocation.height; + { + GtkAllocation label_widget_allocation; + + gtk_widget_get_allocation (priv->label_widget, &label_widget_allocation); + area.height = label_widget_allocation.height; + } else area.height = 0; @@ -750,7 +766,8 @@ gtk_expander_paint_prelight (GtkExpander *expander) area.height = MAX (area.height, expander_size + 2 * expander_spacing); area.height += !interior_focus ? (focus_width + focus_pad) * 2 : 0; - gtk_paint_flat_box (widget->style, widget->window, + gtk_paint_flat_box (gtk_widget_get_style (widget), + gtk_widget_get_window (widget), GTK_STATE_PRELIGHT, GTK_SHADOW_ETCHED_OUT, &area, widget, "expander", @@ -769,7 +786,7 @@ gtk_expander_paint (GtkExpander *expander) get_expander_bounds (expander, &clip); - state = widget->state; + state = gtk_widget_get_state (widget); if (expander->priv->prelight) { state = GTK_STATE_PRELIGHT; @@ -777,8 +794,8 @@ gtk_expander_paint (GtkExpander *expander) gtk_expander_paint_prelight (expander); } - gtk_paint_expander (widget->style, - widget->window, + gtk_paint_expander (gtk_widget_get_style (widget), + gtk_widget_get_window (widget), state, &clip, widget, @@ -823,6 +840,10 @@ gtk_expander_paint_focus (GtkExpander *expander, if (priv->label_widget) { + GtkAllocation allocation; + + gtk_widget_get_allocation (widget, &allocation); + if (gtk_widget_get_visible (priv->label_widget)) { GtkAllocation label_allocation; @@ -835,8 +856,8 @@ gtk_expander_paint_focus (GtkExpander *expander, width += 2 * focus_pad + 2 * focus_width; height += 2 * focus_pad + 2 * focus_width; - x = widget->allocation.x + border_width; - y = widget->allocation.y + border_width; + x = allocation.x + border_width; + y = allocation.y + border_width; if (ltr) { @@ -845,7 +866,7 @@ gtk_expander_paint_focus (GtkExpander *expander, } else { - x += widget->allocation.width - 2 * border_width + x += allocation.width - 2 * border_width - expander_spacing * 2 - expander_size - width; } @@ -864,8 +885,10 @@ gtk_expander_paint_focus (GtkExpander *expander, width = rect.width + 2 * focus_pad; height = rect.height + 2 * focus_pad; } - - gtk_paint_focus (widget->style, widget->window, gtk_widget_get_state (widget), + + gtk_paint_focus (gtk_widget_get_style (widget), + gtk_widget_get_window (widget), + gtk_widget_get_state (widget), area, widget, "expander", x, y, width, height); } @@ -939,12 +962,14 @@ gtk_expander_state_changed (GtkWidget *widget, static void gtk_expander_redraw_expander (GtkExpander *expander) { - GtkWidget *widget; - - widget = GTK_WIDGET (expander); + GtkAllocation allocation; + GtkWidget *widget = GTK_WIDGET (expander); if (gtk_widget_get_realized (widget)) - gdk_window_invalidate_rect (widget->window, &widget->allocation, FALSE); + { + gtk_widget_get_allocation (widget, &allocation); + gdk_window_invalidate_rect (gtk_widget_get_window (widget), &allocation, FALSE); + } } static gboolean @@ -1521,14 +1546,15 @@ static gboolean gtk_expander_animation_timeout (GtkExpander *expander) { GtkExpanderPrivate *priv = expander->priv; + GtkWidget *widget = GTK_WIDGET (expander); GtkWidget *child; GdkRectangle area; gboolean finish = FALSE; - if (gtk_widget_get_realized (GTK_WIDGET (expander))) + if (gtk_widget_get_realized (widget)) { get_expander_bounds (expander, &area); - gdk_window_invalidate_rect (GTK_WIDGET (expander)->window, &area, TRUE); + gdk_window_invalidate_rect (gtk_widget_get_window (widget), &area, TRUE); } if (priv->expanded) @@ -1563,7 +1589,7 @@ gtk_expander_animation_timeout (GtkExpander *expander) child = gtk_bin_get_child (GTK_BIN (expander)); if (child) gtk_widget_set_child_visible (child, priv->expanded); - gtk_widget_queue_resize (GTK_WIDGET (expander)); + gtk_widget_queue_resize (widget); } return !finish; @@ -1901,7 +1927,7 @@ gtk_expander_set_label_widget (GtkExpander *expander, g_return_if_fail (GTK_IS_EXPANDER (expander)); g_return_if_fail (label_widget == NULL || GTK_IS_WIDGET (label_widget)); - g_return_if_fail (label_widget == NULL || label_widget->parent == NULL); + g_return_if_fail (label_widget == NULL || gtk_widget_get_parent (label_widget) == NULL); priv = expander->priv; diff --git a/gtk/gtkfilechooser.c b/gtk/gtkfilechooser.c index 3dbcfaa414..d58ba41b14 100644 --- a/gtk/gtkfilechooser.c +++ b/gtk/gtkfilechooser.c @@ -524,26 +524,8 @@ */ -static void gtk_file_chooser_class_init (gpointer g_iface); - -GType -gtk_file_chooser_get_type (void) -{ - static GType file_chooser_type = 0; - - if (!file_chooser_type) - { - file_chooser_type = g_type_register_static_simple (G_TYPE_INTERFACE, - I_("GtkFileChooser"), - sizeof (GtkFileChooserIface), - (GClassInitFunc) gtk_file_chooser_class_init, - 0, NULL, 0); - - g_type_interface_add_prerequisite (file_chooser_type, GTK_TYPE_WIDGET); - } - - return file_chooser_type; -} +typedef GtkFileChooserIface GtkFileChooserInterface; +G_DEFINE_INTERFACE (GtkFileChooser, gtk_file_chooser, GTK_TYPE_WIDGET); static gboolean confirm_overwrite_accumulator (GSignalInvocationHint *ihint, @@ -562,9 +544,9 @@ confirm_overwrite_accumulator (GSignalInvocationHint *ihint, } static void -gtk_file_chooser_class_init (gpointer g_iface) +gtk_file_chooser_default_init (GtkFileChooserInterface *iface) { - GType iface_type = G_TYPE_FROM_INTERFACE (g_iface); + GType iface_type = G_TYPE_FROM_INTERFACE (iface); /** * GtkFileChooser::current-folder-changed @@ -753,57 +735,57 @@ gtk_file_chooser_class_init (gpointer g_iface) _gtk_marshal_ENUM__VOID, GTK_TYPE_FILE_CHOOSER_CONFIRMATION, 0); - g_object_interface_install_property (g_iface, + g_object_interface_install_property (iface, g_param_spec_enum ("action", P_("Action"), P_("The type of operation that the file selector is performing"), GTK_TYPE_FILE_CHOOSER_ACTION, GTK_FILE_CHOOSER_ACTION_OPEN, GTK_PARAM_READWRITE)); - g_object_interface_install_property (g_iface, + g_object_interface_install_property (iface, g_param_spec_object ("filter", P_("Filter"), P_("The current filter for selecting which files are displayed"), GTK_TYPE_FILE_FILTER, GTK_PARAM_READWRITE)); - g_object_interface_install_property (g_iface, + g_object_interface_install_property (iface, g_param_spec_boolean ("local-only", P_("Local Only"), P_("Whether the selected file(s) should be limited to local file: URLs"), TRUE, GTK_PARAM_READWRITE)); - g_object_interface_install_property (g_iface, + g_object_interface_install_property (iface, g_param_spec_object ("preview-widget", P_("Preview widget"), P_("Application supplied widget for custom previews."), GTK_TYPE_WIDGET, GTK_PARAM_READWRITE)); - g_object_interface_install_property (g_iface, + g_object_interface_install_property (iface, g_param_spec_boolean ("preview-widget-active", P_("Preview Widget Active"), P_("Whether the application supplied widget for custom previews should be shown."), TRUE, GTK_PARAM_READWRITE)); - g_object_interface_install_property (g_iface, + g_object_interface_install_property (iface, g_param_spec_boolean ("use-preview-label", P_("Use Preview Label"), P_("Whether to display a stock label with the name of the previewed file."), TRUE, GTK_PARAM_READWRITE)); - g_object_interface_install_property (g_iface, + g_object_interface_install_property (iface, g_param_spec_object ("extra-widget", P_("Extra widget"), P_("Application supplied widget for extra options."), GTK_TYPE_WIDGET, GTK_PARAM_READWRITE)); - g_object_interface_install_property (g_iface, + g_object_interface_install_property (iface, g_param_spec_boolean ("select-multiple", P_("Select Multiple"), P_("Whether to allow multiple files to be selected"), FALSE, GTK_PARAM_READWRITE)); - - g_object_interface_install_property (g_iface, + + g_object_interface_install_property (iface, g_param_spec_boolean ("show-hidden", P_("Show Hidden"), P_("Whether the hidden files and folders should be displayed"), @@ -819,7 +801,7 @@ gtk_file_chooser_class_init (gpointer g_iface) * * Since: 2.8 */ - g_object_interface_install_property (g_iface, + g_object_interface_install_property (iface, g_param_spec_boolean ("do-overwrite-confirmation", P_("Do overwrite confirmation"), P_("Whether a file chooser in save mode " @@ -836,7 +818,7 @@ gtk_file_chooser_class_init (gpointer g_iface) * * Since: 2.18 */ - g_object_interface_install_property (g_iface, + g_object_interface_install_property (iface, g_param_spec_boolean ("create-folders", P_("Allow folder creation"), P_("Whether a file chooser not in open mode " diff --git a/gtk/gtkfilechooserbutton.c b/gtk/gtkfilechooserbutton.c index fad706c749..217f8b286e 100644 --- a/gtk/gtkfilechooserbutton.c +++ b/gtk/gtkfilechooserbutton.c @@ -661,7 +661,7 @@ gtk_file_chooser_button_constructor (GType type, gtk_file_chooser_button_set_title (button, _(DEFAULT_TITLE)); } - else if (!GTK_WINDOW (priv->dialog)->title) + else if (!gtk_window_get_title (GTK_WINDOW (priv->dialog))) { gtk_file_chooser_button_set_title (button, _(DEFAULT_TITLE)); } diff --git a/gtk/gtkfilechooserdefault.c b/gtk/gtkfilechooserdefault.c index 6802dc87fe..f413992599 100644 --- a/gtk/gtkfilechooserdefault.c +++ b/gtk/gtkfilechooserdefault.c @@ -872,8 +872,9 @@ error_message_with_parent (GtkWindow *parent, gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s", detail); - if (parent && parent->group) - gtk_window_group_add_window (parent->group, GTK_WINDOW (dialog)); + if (parent && gtk_window_has_group (parent)) + gtk_window_group_add_window (gtk_window_get_group (parent), + GTK_WINDOW (dialog)); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); @@ -3783,14 +3784,21 @@ browse_files_key_press_event_cb (GtkWidget *widget, GtkWindow *window; window = get_toplevel (widget); - if (window - && widget != window->default_widget - && !(widget == window->focus_widget && - (!window->default_widget || !gtk_widget_get_sensitive (window->default_widget)))) - { - gtk_window_activate_default (window); - return TRUE; - } + if (window) + { + GtkWidget *default_widget, *focus_widget; + + default_widget = gtk_window_get_default_widget (window); + focus_widget = gtk_window_get_focus (window); + + if (widget != default_widget && + !(widget == focus_widget && (!default_widget || !gtk_widget_get_sensitive (default_widget)))) + { + gtk_window_activate_default (window); + + return TRUE; + } + } } return FALSE; @@ -4088,6 +4096,7 @@ popup_position_func (GtkMenu *menu, gboolean *push_in, gpointer user_data) { + GtkAllocation allocation; GtkWidget *widget = GTK_WIDGET (user_data); GdkScreen *screen = gtk_widget_get_screen (widget); GtkRequisition req; @@ -4096,12 +4105,13 @@ popup_position_func (GtkMenu *menu, g_return_if_fail (gtk_widget_get_realized (widget)); - gdk_window_get_origin (widget->window, x, y); + gdk_window_get_origin (gtk_widget_get_window (widget), x, y); gtk_widget_size_request (GTK_WIDGET (menu), &req); - *x += (widget->allocation.width - req.width) / 2; - *y += (widget->allocation.height - req.height) / 2; + gtk_widget_get_allocation (widget, &allocation); + *x += (allocation.width - req.width) / 2; + *y += (allocation.height - req.height) / 2; monitor_num = gdk_screen_get_monitor_at_point (screen, *x, *y); gtk_menu_set_monitor (menu, monitor_num); @@ -5978,22 +5988,24 @@ static void set_busy_cursor (GtkFileChooserDefault *impl, gboolean busy) { + GtkWidget *widget; GtkWindow *toplevel; GdkDisplay *display; GdkCursor *cursor; toplevel = get_toplevel (GTK_WIDGET (impl)); - if (!toplevel || !gtk_widget_get_realized (GTK_WIDGET (toplevel))) + widget = GTK_WIDGET (toplevel); + if (!toplevel || !gtk_widget_get_realized (widget)) return; - display = gtk_widget_get_display (GTK_WIDGET (toplevel)); + display = gtk_widget_get_display (widget); if (busy) cursor = gdk_cursor_new_for_display (display, GDK_WATCH); else cursor = NULL; - gdk_window_set_cursor (GTK_WIDGET (toplevel)->window, cursor); + gdk_window_set_cursor (gtk_widget_get_window (widget), cursor); gdk_display_flush (display); if (cursor) @@ -7776,11 +7788,14 @@ find_good_size_from_style (GtkWidget *widget, gint *height) { GtkFileChooserDefault *impl; + GtkStyle *style; int font_size; GdkScreen *screen; double resolution; - g_assert (widget->style != NULL); + style = gtk_widget_get_style (widget); + + g_assert (style != NULL); impl = GTK_FILE_CHOOSER_DEFAULT (widget); screen = gtk_widget_get_screen (widget); @@ -7793,7 +7808,7 @@ find_good_size_from_style (GtkWidget *widget, else resolution = 96.0; /* wheeee */ - font_size = pango_font_description_get_size (widget->style->font_desc); + font_size = pango_font_description_get_size (style->font_desc); font_size = PANGO_PIXELS (font_size) * resolution / 72.0; *width = font_size * NUM_CHARS; @@ -7989,8 +8004,9 @@ confirm_dialog_should_accept_filename (GtkFileChooserDefault *impl, -1); gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT); - if (toplevel->group) - gtk_window_group_add_window (toplevel->group, GTK_WINDOW (dialog)); + if (gtk_window_has_group (toplevel)) + gtk_window_group_add_window (gtk_window_get_group (toplevel), + GTK_WINDOW (dialog)); response = gtk_dialog_run (GTK_DIALOG (dialog)); diff --git a/gtk/gtkfilechooserentry.c b/gtk/gtkfilechooserentry.c index 2a37a79d8b..4032bd8c3c 100644 --- a/gtk/gtkfilechooserentry.c +++ b/gtk/gtkfilechooserentry.c @@ -886,17 +886,19 @@ completion_feedback_window_expose_event_cb (GtkWidget *widget, /* Stolen from gtk_tooltip_paint_window() */ GtkFileChooserEntry *chooser_entry = GTK_FILE_CHOOSER_ENTRY (data); + GtkAllocation allocation; - gtk_paint_flat_box (chooser_entry->completion_feedback_window->style, - chooser_entry->completion_feedback_window->window, + gtk_widget_get_allocation (chooser_entry->completion_feedback_window, &allocation); + + gtk_paint_flat_box (gtk_widget_get_style (chooser_entry->completion_feedback_window), + gtk_widget_get_window (chooser_entry->completion_feedback_window), GTK_STATE_NORMAL, GTK_SHADOW_OUT, NULL, chooser_entry->completion_feedback_window, "tooltip", 0, 0, - chooser_entry->completion_feedback_window->allocation.width, - chooser_entry->completion_feedback_window->allocation.height); + allocation.width, allocation.height); return FALSE; } @@ -923,7 +925,7 @@ completion_feedback_window_realize_cb (GtkWidget *widget, * GtkEntry hides the cursor when the user types. We don't want the cursor to * come back if the completion feedback ends up where the mouse is. */ - set_invisible_mouse_cursor (widget->window); + set_invisible_mouse_cursor (gtk_widget_get_window (widget)); } static void @@ -931,6 +933,7 @@ create_completion_feedback_window (GtkFileChooserEntry *chooser_entry) { /* Stolen from gtk_tooltip_init() */ + GtkStyle *style; GtkWidget *alignment; chooser_entry->completion_feedback_window = gtk_window_new (GTK_WINDOW_POPUP); @@ -941,11 +944,10 @@ create_completion_feedback_window (GtkFileChooserEntry *chooser_entry) gtk_widget_set_name (chooser_entry->completion_feedback_window, "gtk-tooltip"); alignment = gtk_alignment_new (0.5, 0.5, 1.0, 1.0); + style = gtk_widget_get_style (chooser_entry->completion_feedback_window); gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), - chooser_entry->completion_feedback_window->style->ythickness, - chooser_entry->completion_feedback_window->style->ythickness, - chooser_entry->completion_feedback_window->style->xthickness, - chooser_entry->completion_feedback_window->style->xthickness); + style->ythickness, style->ythickness, + style->xthickness, style->xthickness); gtk_container_add (GTK_CONTAINER (chooser_entry->completion_feedback_window), alignment); gtk_widget_show (alignment); @@ -1015,22 +1017,23 @@ show_completion_feedback_window (GtkFileChooserEntry *chooser_entry) /* More or less stolen from gtk_tooltip_position() */ GtkRequisition feedback_req; + GtkWidget *widget = GTK_WIDGET (chooser_entry); gint entry_x, entry_y; gint cursor_x; - GtkAllocation *entry_allocation; + GtkAllocation entry_allocation; int feedback_x, feedback_y; gtk_widget_size_request (chooser_entry->completion_feedback_window, &feedback_req); - gdk_window_get_origin (GTK_WIDGET (chooser_entry)->window, &entry_x, &entry_y); - entry_allocation = &(GTK_WIDGET (chooser_entry)->allocation); + gdk_window_get_origin (gtk_widget_get_window (widget), &entry_x, &entry_y); + gtk_widget_get_allocation (widget, &entry_allocation); get_entry_cursor_x (chooser_entry, &cursor_x); /* FIXME: fit to the screen if we bump on the screen's edge */ /* cheap "half M-width", use height as approximation of character em-size */ - feedback_x = entry_x + cursor_x + entry_allocation->height / 2; - feedback_y = entry_y + (entry_allocation->height - feedback_req.height) / 2; + feedback_x = entry_x + cursor_x + entry_allocation.height / 2; + feedback_y = entry_y + (entry_allocation.height - feedback_req.height) / 2; gtk_window_move (GTK_WINDOW (chooser_entry->completion_feedback_window), feedback_x, feedback_y); gtk_widget_show (chooser_entry->completion_feedback_window); diff --git a/gtk/gtkfilesystem.c b/gtk/gtkfilesystem.c index 93c77b7edc..a4a289653b 100644 --- a/gtk/gtkfilesystem.c +++ b/gtk/gtkfilesystem.c @@ -38,8 +38,6 @@ #define DEBUG(x) #endif -#define GTK_FILE_SYSTEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_TYPE_FILE_SYSTEM, GtkFileSystemPrivate)) -#define GTK_FOLDER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_TYPE_FOLDER, GtkFolderPrivate)) #define FILES_PER_QUERY 100 /* The pointers we return for a GtkFileSystemVolume are opaque tokens; they are @@ -75,8 +73,6 @@ enum { static guint fs_signals [FS_LAST_SIGNAL] = { 0, }; static guint folder_signals [FOLDER_LAST_SIGNAL] = { 0, }; -typedef struct GtkFileSystemPrivate GtkFileSystemPrivate; -typedef struct GtkFolderPrivate GtkFolderPrivate; typedef struct AsyncFuncData AsyncFuncData; struct GtkFileSystemPrivate @@ -163,12 +159,11 @@ volumes_changed (GVolumeMonitor *volume_monitor, static void gtk_file_system_dispose (GObject *object) { - GtkFileSystemPrivate *priv; + GtkFileSystem *file_system = GTK_FILE_SYSTEM (object); + GtkFileSystemPrivate *priv = file_system->priv; DEBUG ("dispose"); - priv = GTK_FILE_SYSTEM_GET_PRIVATE (object); - if (priv->volumes) { g_slist_foreach (priv->volumes, (GFunc) g_object_unref, NULL); @@ -189,12 +184,11 @@ gtk_file_system_dispose (GObject *object) static void gtk_file_system_finalize (GObject *object) { - GtkFileSystemPrivate *priv; + GtkFileSystem *file_system = GTK_FILE_SYSTEM (object); + GtkFileSystemPrivate *priv = file_system->priv; DEBUG ("finalize"); - priv = GTK_FILE_SYSTEM_GET_PRIVATE (object); - if (priv->bookmarks_monitor) g_object_unref (priv->bookmarks_monitor); @@ -335,9 +329,8 @@ bookmarks_file_changed (GFileMonitor *monitor, GFileMonitorEvent event, gpointer data) { - GtkFileSystemPrivate *priv; - - priv = GTK_FILE_SYSTEM_GET_PRIVATE (data); + GtkFileSystem *file_system = GTK_FILE_SYSTEM (data); + GtkFileSystemPrivate *priv = file_system->priv; switch (event) { @@ -396,7 +389,7 @@ mount_referenced_by_volume_activation_root (GList *volumes, GMount *mount) static void get_volumes_list (GtkFileSystem *file_system) { - GtkFileSystemPrivate *priv; + GtkFileSystemPrivate *priv = file_system->priv; GList *l, *ll; GList *drives; GList *volumes; @@ -405,8 +398,6 @@ get_volumes_list (GtkFileSystem *file_system) GVolume *volume; GMount *mount; - priv = GTK_FILE_SYSTEM_GET_PRIVATE (file_system); - if (priv->volumes) { g_slist_foreach (priv->volumes, (GFunc) g_object_unref, NULL); @@ -545,7 +536,10 @@ _gtk_file_system_init (GtkFileSystem *file_system) DEBUG ("init"); - priv = GTK_FILE_SYSTEM_GET_PRIVATE (file_system); + file_system->priv = G_TYPE_INSTANCE_GET_PRIVATE (file_system, + GTK_TYPE_FILE_SYSTEM, + GtkFileSystemPrivate); + priv = file_system->priv; /* Volumes */ priv->volume_monitor = g_volume_monitor_get (); @@ -597,15 +591,12 @@ _gtk_file_system_new (void) GSList * _gtk_file_system_list_volumes (GtkFileSystem *file_system) { - GtkFileSystemPrivate *priv; + GtkFileSystemPrivate *priv = file_system->priv; GSList *list; DEBUG ("list_volumes"); - g_return_val_if_fail (GTK_IS_FILE_SYSTEM (file_system), NULL); - - priv = GTK_FILE_SYSTEM_GET_PRIVATE (file_system); - get_volumes_list (GTK_FILE_SYSTEM (file_system)); + get_volumes_list (file_system); list = g_slist_copy (priv->volumes); @@ -620,12 +611,11 @@ _gtk_file_system_list_volumes (GtkFileSystem *file_system) GSList * _gtk_file_system_list_bookmarks (GtkFileSystem *file_system) { - GtkFileSystemPrivate *priv; + GtkFileSystemPrivate *priv = file_system->priv; GSList *bookmarks, *files = NULL; DEBUG ("list_bookmarks"); - priv = GTK_FILE_SYSTEM_GET_PRIVATE (file_system); bookmarks = priv->bookmarks; while (bookmarks) @@ -1073,13 +1063,12 @@ _gtk_file_system_insert_bookmark (GtkFileSystem *file_system, gint position, GError **error) { - GtkFileSystemPrivate *priv; + GtkFileSystemPrivate *priv = file_system->priv; GSList *bookmarks; GtkFileSystemBookmark *bookmark; gboolean result = TRUE; GFile *bookmarks_file; - priv = GTK_FILE_SYSTEM_GET_PRIVATE (file_system); bookmarks = priv->bookmarks; while (bookmarks) @@ -1129,14 +1118,12 @@ _gtk_file_system_remove_bookmark (GtkFileSystem *file_system, GFile *file, GError **error) { - GtkFileSystemPrivate *priv; + GtkFileSystemPrivate *priv = file_system->priv; GtkFileSystemBookmark *bookmark; GSList *bookmarks; gboolean result = FALSE; GFile *bookmarks_file; - priv = GTK_FILE_SYSTEM_GET_PRIVATE (file_system); - if (!priv->bookmarks) return FALSE; @@ -1186,13 +1173,12 @@ gchar * _gtk_file_system_get_bookmark_label (GtkFileSystem *file_system, GFile *file) { - GtkFileSystemPrivate *priv; + GtkFileSystemPrivate *priv = file_system->priv; GSList *bookmarks; gchar *label = NULL; DEBUG ("get_bookmark_label"); - priv = GTK_FILE_SYSTEM_GET_PRIVATE (file_system); bookmarks = priv->bookmarks; while (bookmarks) @@ -1217,14 +1203,13 @@ _gtk_file_system_set_bookmark_label (GtkFileSystem *file_system, GFile *file, const gchar *label) { - GtkFileSystemPrivate *priv; + GtkFileSystemPrivate *priv = file_system->priv; gboolean changed = FALSE; GFile *bookmarks_file; GSList *bookmarks; DEBUG ("set_bookmark_label"); - priv = GTK_FILE_SYSTEM_GET_PRIVATE (file_system); bookmarks = priv->bookmarks; while (bookmarks) @@ -1255,12 +1240,10 @@ GtkFileSystemVolume * _gtk_file_system_get_volume_for_file (GtkFileSystem *file_system, GFile *file) { - GtkFileSystemPrivate *priv; GMount *mount; DEBUG ("get_volume_for_file"); - priv = GTK_FILE_SYSTEM_GET_PRIVATE (file_system); mount = g_file_find_enclosing_mount (file, NULL, NULL); if (!mount && g_file_is_native (file)) @@ -1276,9 +1259,8 @@ gtk_folder_set_property (GObject *object, const GValue *value, GParamSpec *pspec) { - GtkFolderPrivate *priv; - - priv = GTK_FOLDER_GET_PRIVATE (object); + GtkFolder *folder = GTK_FOLDER (object); + GtkFolderPrivate *priv = folder->priv; switch (prop_id) { @@ -1303,9 +1285,8 @@ gtk_folder_get_property (GObject *object, GValue *value, GParamSpec *pspec) { - GtkFolderPrivate *priv; - - priv = GTK_FOLDER_GET_PRIVATE (object); + GtkFolder *folder = GTK_FOLDER (object); + GtkFolderPrivate *priv = folder->priv; switch (prop_id) { @@ -1360,12 +1341,10 @@ directory_monitor_changed (GFileMonitor *monitor, GFileMonitorEvent event, gpointer data) { - GtkFolderPrivate *priv; - GtkFolder *folder; + GtkFolder *folder = GTK_FOLDER (data); + GtkFolderPrivate *priv = folder->priv; GSList *files; - folder = GTK_FOLDER (data); - priv = GTK_FOLDER_GET_PRIVATE (folder); files = g_slist_prepend (NULL, file); gdk_threads_enter (); @@ -1401,9 +1380,9 @@ enumerator_files_callback (GObject *source_object, GAsyncResult *result, gpointer user_data) { + GtkFolder *folder = GTK_FOLDER (user_data); + GtkFolderPrivate *priv = folder->priv; GFileEnumerator *enumerator; - GtkFolderPrivate *priv; - GtkFolder *folder; GError *error = NULL; GSList *files = NULL; GList *file_infos, *f; @@ -1420,9 +1399,6 @@ enumerator_files_callback (GObject *source_object, return; } - folder = GTK_FOLDER (user_data); - priv = GTK_FOLDER_GET_PRIVATE (folder); - if (!file_infos) { g_file_enumerator_close_async (enumerator, @@ -1464,10 +1440,10 @@ enumerator_files_callback (GObject *source_object, static void gtk_folder_constructed (GObject *object) { - GtkFolderPrivate *priv; + GtkFolder *folder = GTK_FOLDER (object); + GtkFolderPrivate *priv = folder->priv; GError *error = NULL; - priv = GTK_FOLDER_GET_PRIVATE (object); priv->directory_monitor = g_file_monitor_directory (priv->folder_file, G_FILE_MONITOR_NONE, NULL, &error); if (error) @@ -1493,9 +1469,8 @@ gtk_folder_constructed (GObject *object) static void gtk_folder_finalize (GObject *object) { - GtkFolderPrivate *priv; - - priv = GTK_FOLDER_GET_PRIVATE (object); + GtkFolder *folder = GTK_FOLDER (object); + GtkFolderPrivate *priv = folder->priv; g_hash_table_unref (priv->children); @@ -1590,9 +1565,7 @@ _gtk_folder_class_init (GtkFolderClass *class) static void _gtk_folder_init (GtkFolder *folder) { - GtkFolderPrivate *priv; - - priv = GTK_FOLDER_GET_PRIVATE (folder); + GtkFolderPrivate *priv = folder->priv; priv->children = g_hash_table_new_full (g_file_hash, (GEqualFunc) g_file_equal, @@ -1605,9 +1578,8 @@ static void gtk_folder_set_finished_loading (GtkFolder *folder, gboolean finished_loading) { - GtkFolderPrivate *priv; + GtkFolderPrivate *priv = folder->priv; - priv = GTK_FOLDER_GET_PRIVATE (folder); priv->finished_loading = (finished_loading == TRUE); gdk_threads_enter (); @@ -1620,9 +1592,7 @@ gtk_folder_add_file (GtkFolder *folder, GFile *file, GFileInfo *info) { - GtkFolderPrivate *priv; - - priv = GTK_FOLDER_GET_PRIVATE (folder); + GtkFolderPrivate *priv = folder->priv; g_hash_table_insert (priv->children, g_object_ref (file), @@ -1632,11 +1602,10 @@ gtk_folder_add_file (GtkFolder *folder, GSList * _gtk_folder_list_children (GtkFolder *folder) { - GtkFolderPrivate *priv; + GtkFolderPrivate *priv = folder->priv; GList *files, *elem; GSList *children = NULL; - priv = GTK_FOLDER_GET_PRIVATE (folder); files = g_hash_table_get_keys (priv->children); children = NULL; @@ -1652,10 +1621,9 @@ GFileInfo * _gtk_folder_get_info (GtkFolder *folder, GFile *file) { - GtkFolderPrivate *priv; + GtkFolderPrivate *priv = folder->priv; GFileInfo *info; - priv = GTK_FOLDER_GET_PRIVATE (folder); info = g_hash_table_lookup (priv->children, file); if (!info) @@ -1667,11 +1635,7 @@ _gtk_folder_get_info (GtkFolder *folder, gboolean _gtk_folder_is_finished_loading (GtkFolder *folder) { - GtkFolderPrivate *priv; - - priv = GTK_FOLDER_GET_PRIVATE (folder); - - return priv->finished_loading; + return folder->priv->finished_loading; } /* GtkFileSystemVolume public methods */ diff --git a/gtk/gtkfilesystem.h b/gtk/gtkfilesystem.h index a92c8f89e9..ec8266f466 100644 --- a/gtk/gtkfilesystem.h +++ b/gtk/gtkfilesystem.h @@ -33,6 +33,11 @@ G_BEGIN_DECLS #define GTK_IS_FILE_SYSTEM_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), GTK_TYPE_FILE_SYSTEM)) #define GTK_FILE_SYSTEM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTK_TYPE_FILE_SYSTEM, GtkFileSystemClass)) +typedef struct GtkFileSystem GtkFileSystem; +typedef struct GtkFileSystemPrivate GtkFileSystemPrivate; +typedef struct GtkFileSystemClass GtkFileSystemClass; + + #define GTK_TYPE_FOLDER (_gtk_folder_get_type ()) #define GTK_FOLDER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTK_TYPE_FOLDER, GtkFolder)) #define GTK_FOLDER_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), GTK_TYPE_FOLDER, GtkFolderClass)) @@ -40,13 +45,21 @@ G_BEGIN_DECLS #define GTK_IS_FOLDER_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), GTK_TYPE_FOLDER)) #define GTK_FOLDER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTK_TYPE_FOLDER, GtkFolderClass)) -typedef struct GtkFileSystemClass GtkFileSystemClass; -typedef struct GtkFileSystem GtkFileSystem; -typedef struct GtkFolderClass GtkFolderClass; -typedef struct GtkFolder GtkFolder; +typedef struct GtkFolder GtkFolder; +typedef struct GtkFolderPrivate GtkFolderPrivate; +typedef struct GtkFolderClass GtkFolderClass; + typedef struct GtkFileSystemVolume GtkFileSystemVolume; /* opaque struct */ typedef struct GtkFileSystemBookmark GtkFileSystemBookmark; /* opaque struct */ + +struct GtkFileSystem +{ + GObject parent_object; + + GtkFileSystemPrivate *priv; +}; + struct GtkFileSystemClass { GObjectClass parent_class; @@ -55,9 +68,12 @@ struct GtkFileSystemClass void (*volumes_changed) (GtkFileSystem *file_system); }; -struct GtkFileSystem + +struct GtkFolder { GObject parent_object; + + GtkFolderPrivate *priv; }; struct GtkFolderClass @@ -74,10 +90,6 @@ struct GtkFolderClass void (*deleted) (GtkFolder *folder); }; -struct GtkFolder -{ - GObject parent_object; -}; typedef void (* GtkFileSystemGetFolderCallback) (GCancellable *cancellable, GtkFolder *folder, diff --git a/gtk/gtkfilesystemmodel.c b/gtk/gtkfilesystemmodel.c index 5b29b9bc39..c6532c136f 100644 --- a/gtk/gtkfilesystemmodel.c +++ b/gtk/gtkfilesystemmodel.c @@ -1777,7 +1777,10 @@ _gtk_file_system_model_update_file (GtkFileSystemModel *model, id = node_get_for_file (model, file); if (id == 0) - add_file (model, file, info); + { + add_file (model, file, info); + id = node_get_for_file (model, file); + } node = get_node (model, id); diff --git a/gtk/gtkfixed.c b/gtk/gtkfixed.c index 22b77775a3..0a461423f5 100644 --- a/gtk/gtkfixed.c +++ b/gtk/gtkfixed.c @@ -30,7 +30,7 @@ #include "gtkintl.h" -struct _GtkFixedPriv +struct _GtkFixedPrivate { GList *children; }; @@ -110,7 +110,7 @@ gtk_fixed_class_init (GtkFixedClass *class) 0, GTK_PARAM_READWRITE)); - g_type_class_add_private (class, sizeof (GtkFixedPriv)); + g_type_class_add_private (class, sizeof (GtkFixedPrivate)); } static GType @@ -122,11 +122,11 @@ gtk_fixed_child_type (GtkContainer *container) static void gtk_fixed_init (GtkFixed *fixed) { - GtkFixedPriv *priv; + GtkFixedPrivate *priv; fixed->priv = G_TYPE_INSTANCE_GET_PRIVATE (fixed, GTK_TYPE_FIXED, - GtkFixedPriv); + GtkFixedPrivate); priv = fixed->priv; gtk_widget_set_has_window (GTK_WIDGET (fixed), FALSE); @@ -144,7 +144,7 @@ static GtkFixedChild* get_child (GtkFixed *fixed, GtkWidget *widget) { - GtkFixedPriv *priv = fixed->priv; + GtkFixedPrivate *priv = fixed->priv; GList *children; children = priv->children; @@ -168,7 +168,7 @@ gtk_fixed_put (GtkFixed *fixed, gint x, gint y) { - GtkFixedPriv *priv = fixed->priv; + GtkFixedPrivate *priv = fixed->priv; GtkFixedChild *child_info; g_return_if_fail (GTK_IS_FIXED (fixed)); @@ -196,8 +196,8 @@ gtk_fixed_move_internal (GtkFixed *fixed, 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)); - + g_return_if_fail (gtk_widget_get_parent (widget) == GTK_WIDGET (fixed)); + child = get_child (fixed, widget); g_assert (child); @@ -287,6 +287,8 @@ gtk_fixed_get_child_property (GtkContainer *container, static void gtk_fixed_realize (GtkWidget *widget) { + GtkAllocation allocation; + GdkWindow *window; GdkWindowAttr attributes; gint attributes_mask; @@ -296,11 +298,13 @@ gtk_fixed_realize (GtkWidget *widget) { gtk_widget_set_realized (widget, TRUE); + gtk_widget_get_allocation (widget, &allocation); + attributes.window_type = GDK_WINDOW_CHILD; - attributes.x = widget->allocation.x; - attributes.y = widget->allocation.y; - attributes.width = widget->allocation.width; - attributes.height = widget->allocation.height; + attributes.x = allocation.x; + attributes.y = allocation.y; + attributes.width = allocation.width; + attributes.height = allocation.height; attributes.wclass = GDK_INPUT_OUTPUT; attributes.visual = gtk_widget_get_visual (widget); attributes.colormap = gtk_widget_get_colormap (widget); @@ -308,13 +312,14 @@ gtk_fixed_realize (GtkWidget *widget) attributes.event_mask |= GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK; attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; - - widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, - attributes_mask); - gdk_window_set_user_data (widget->window, widget); - - widget->style = gtk_style_attach (widget->style, widget->window); - gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL); + + window = gdk_window_new (gtk_widget_get_parent_window (widget), + &attributes, attributes_mask); + gtk_widget_set_window (widget, window); + gdk_window_set_user_data (window, widget); + + gtk_widget_style_attach (widget); + gtk_style_set_background (gtk_widget_get_style (widget), window, GTK_STATE_NORMAL); } } @@ -322,7 +327,7 @@ static void gtk_fixed_size_request (GtkWidget *widget, GtkRequisition *requisition) { - GtkFixedPriv *priv; + GtkFixedPrivate *priv; GtkFixed *fixed; GtkFixedChild *child; GList *children; @@ -364,19 +369,19 @@ gtk_fixed_size_allocate (GtkWidget *widget, GtkAllocation *allocation) { GtkFixed *fixed = GTK_FIXED (widget); - GtkFixedPriv *priv = fixed->priv; + GtkFixedPrivate *priv = fixed->priv; GtkFixedChild *child; GtkAllocation child_allocation; GtkRequisition child_requisition; GList *children; guint border_width; - widget->allocation = *allocation; + gtk_widget_set_allocation (widget, allocation); if (gtk_widget_get_has_window (widget)) { if (gtk_widget_get_realized (widget)) - gdk_window_move_resize (widget->window, + gdk_window_move_resize (gtk_widget_get_window (widget), allocation->x, allocation->y, allocation->width, @@ -399,8 +404,8 @@ gtk_fixed_size_allocate (GtkWidget *widget, if (!gtk_widget_get_has_window (widget)) { - child_allocation.x += widget->allocation.x; - child_allocation.y += widget->allocation.y; + child_allocation.x += allocation->x; + child_allocation.y += allocation->y; } child_allocation.width = child_requisition.width; @@ -422,7 +427,7 @@ gtk_fixed_remove (GtkContainer *container, GtkWidget *widget) { GtkFixed *fixed = GTK_FIXED (container); - GtkFixedPriv *priv = fixed->priv; + GtkFixedPrivate *priv = fixed->priv; GtkFixedChild *child; GtkWidget *widget_container = GTK_WIDGET (container); GList *children; @@ -459,7 +464,7 @@ gtk_fixed_forall (GtkContainer *container, gpointer callback_data) { GtkFixed *fixed = GTK_FIXED (container); - GtkFixedPriv *priv = fixed->priv; + GtkFixedPrivate *priv = fixed->priv; GtkFixedChild *child; GList *children; diff --git a/gtk/gtkfixed.h b/gtk/gtkfixed.h index fc65f6cae5..2703c6b1c3 100644 --- a/gtk/gtkfixed.h +++ b/gtk/gtkfixed.h @@ -44,17 +44,17 @@ G_BEGIN_DECLS #define GTK_IS_FIXED_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_FIXED)) #define GTK_FIXED_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_FIXED, GtkFixedClass)) -typedef struct _GtkFixed GtkFixed; -typedef struct _GtkFixedPriv GtkFixedPriv; -typedef struct _GtkFixedClass GtkFixedClass; -typedef struct _GtkFixedChild GtkFixedChild; +typedef struct _GtkFixed GtkFixed; +typedef struct _GtkFixedPrivate GtkFixedPrivate; +typedef struct _GtkFixedClass GtkFixedClass; +typedef struct _GtkFixedChild GtkFixedChild; struct _GtkFixed { GtkContainer container; /* <private> */ - GtkFixedPriv *priv; + GtkFixedPrivate *priv; }; struct _GtkFixedClass diff --git a/gtk/gtkfontsel.c b/gtk/gtkfontsel.c index 9f9bed436a..f1a509cab1 100644 --- a/gtk/gtkfontsel.c +++ b/gtk/gtkfontsel.c @@ -61,7 +61,7 @@ #include "gtkprivate.h" #include "gtkbuildable.h" -struct _GtkFontSelectionPriv +struct _GtkFontSelectionPrivate { GtkWidget *font_entry; /* Used _get_family_entry() for consistency, -mr */ GtkWidget *font_style_entry; /* Used _get_face_entry() for consistency, -mr */ @@ -80,7 +80,7 @@ struct _GtkFontSelectionPriv }; -struct _GtkFontSelectionDialogPriv +struct _GtkFontSelectionDialogPrivate { GtkWidget *fontsel; @@ -232,7 +232,7 @@ gtk_font_selection_class_init (GtkFontSelectionClass *klass) _(PREVIEW_TEXT), GTK_PARAM_READWRITE)); - g_type_class_add_private (klass, sizeof (GtkFontSelectionPriv)); + g_type_class_add_private (klass, sizeof (GtkFontSelectionPrivate)); } static void @@ -288,27 +288,30 @@ static void gtk_font_selection_get_property (GObject *object, static gboolean list_row_activated (GtkWidget *widget) { + GtkWidget *default_widget, *focus_widget; GtkWindow *window; window = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (widget))); if (!gtk_widget_is_toplevel (GTK_WIDGET (window))) window = NULL; - - if (window - && widget != window->default_widget - && !(widget == window->focus_widget && - (!window->default_widget || !gtk_widget_get_sensitive (window->default_widget)))) + + if (window) { - gtk_window_activate_default (window); + default_widget = gtk_window_get_default_widget (window); + focus_widget = gtk_window_get_focus (window); + + if (widget != default_widget && + !(widget == focus_widget && (!default_widget || !gtk_widget_get_sensitive (default_widget)))) + gtk_window_activate_default (window); } - + return TRUE; } static void gtk_font_selection_init (GtkFontSelection *fontsel) { - GtkFontSelectionPriv *priv; + GtkFontSelectionPrivate *priv; GtkWidget *scrolled_win; GtkWidget *text_box; GtkWidget *table, *label; @@ -321,7 +324,7 @@ gtk_font_selection_init (GtkFontSelection *fontsel) fontsel->priv = G_TYPE_INSTANCE_GET_PRIVATE (fontsel, GTK_TYPE_FONT_SELECTION, - GtkFontSelectionPriv); + GtkFontSelectionPrivate); priv = fontsel->priv; gtk_widget_push_composite_child (); @@ -608,7 +611,7 @@ static void gtk_font_selection_ref_family (GtkFontSelection *fontsel, PangoFontFamily *family) { - GtkFontSelectionPriv *priv = fontsel->priv; + GtkFontSelectionPrivate *priv = fontsel->priv; if (family) family = g_object_ref (family); @@ -620,7 +623,7 @@ gtk_font_selection_ref_family (GtkFontSelection *fontsel, static void gtk_font_selection_ref_face (GtkFontSelection *fontsel, PangoFontFace *face) { - GtkFontSelectionPriv *priv = fontsel->priv; + GtkFontSelectionPrivate *priv = fontsel->priv; if (face) face = g_object_ref (face); @@ -700,7 +703,7 @@ set_cursor_to_iter (GtkTreeView *view, static void gtk_font_selection_scroll_to_selection (GtkFontSelection *fontsel) { - GtkFontSelectionPriv *priv = fontsel->priv; + GtkFontSelectionPrivate *priv = fontsel->priv; /* Try to scroll the font family list to the selected item */ scroll_to_selection (GTK_TREE_VIEW (priv->family_list)); @@ -727,7 +730,7 @@ gtk_font_selection_select_font (GtkTreeSelection *selection, gpointer data) { GtkFontSelection *fontsel; - GtkFontSelectionPriv *priv; + GtkFontSelectionPrivate *priv; GtkTreeModel *model; GtkTreeIter iter; #ifdef INCLUDE_FONT_ENTRIES @@ -771,7 +774,7 @@ cmp_families (const void *a, const void *b) static void gtk_font_selection_show_available_fonts (GtkFontSelection *fontsel) { - GtkFontSelectionPriv *priv = fontsel->priv; + GtkFontSelectionPrivate *priv = fontsel->priv; GtkListStore *model; PangoFontFamily **families; PangoFontFamily *match_family = NULL; @@ -868,7 +871,7 @@ font_description_style_equal (const PangoFontDescription *a, static void gtk_font_selection_show_available_styles (GtkFontSelection *fontsel) { - GtkFontSelectionPriv *priv = fontsel->priv; + GtkFontSelectionPrivate *priv = fontsel->priv; gint n_faces, i; PangoFontFace **faces; PangoFontDescription *old_desc; @@ -944,7 +947,7 @@ static void gtk_font_selection_select_best_style (GtkFontSelection *fontsel, gboolean use_first) { - GtkFontSelectionPriv *priv = fontsel->priv; + GtkFontSelectionPrivate *priv = fontsel->priv; GtkTreeIter iter; GtkTreeModel *model; @@ -987,7 +990,7 @@ static void gtk_font_selection_show_available_sizes (GtkFontSelection *fontsel, gboolean first_time) { - GtkFontSelectionPriv *priv = fontsel->priv; + GtkFontSelectionPrivate *priv = fontsel->priv; gint i; GtkListStore *model; gchar buffer[128]; @@ -1064,7 +1067,7 @@ static void gtk_font_selection_set_size (GtkFontSelection *fontsel, gint new_size) { - GtkFontSelectionPriv *priv = fontsel->priv; + GtkFontSelectionPrivate *priv = fontsel->priv; if (priv->size != new_size) { @@ -1082,7 +1085,7 @@ gtk_font_selection_size_activate (GtkWidget *w, gpointer data) { GtkFontSelection *fontsel = GTK_FONT_SELECTION (data); - GtkFontSelectionPriv *priv = fontsel->priv; + GtkFontSelectionPrivate *priv = fontsel->priv; gint new_size; const gchar *text; @@ -1101,7 +1104,7 @@ gtk_font_selection_size_focus_out (GtkWidget *w, gpointer data) { GtkFontSelection *fontsel = GTK_FONT_SELECTION (data); - GtkFontSelectionPriv *priv = fontsel->priv; + GtkFontSelectionPrivate *priv = fontsel->priv; gint new_size; const gchar *text; @@ -1139,7 +1142,7 @@ gtk_font_selection_load_font (GtkFontSelection *fontsel) static PangoFontDescription * gtk_font_selection_get_font_description (GtkFontSelection *fontsel) { - GtkFontSelectionPriv *priv = fontsel->priv; + GtkFontSelectionPrivate *priv = fontsel->priv; PangoFontDescription *font_desc; if (priv->face) @@ -1162,7 +1165,7 @@ gtk_font_selection_get_font_description (GtkFontSelection *fontsel) static void gtk_font_selection_update_preview (GtkFontSelection *fontsel) { - GtkFontSelectionPriv *priv = fontsel->priv; + GtkFontSelectionPrivate *priv = fontsel->priv; GtkRcStyle *rc_style; gint new_height; GtkRequisition old_requisition; @@ -1390,7 +1393,7 @@ gtk_font_selection_select_font_desc (GtkFontSelection *fontsel, PangoFontFamily **pfamily, PangoFontFace **pface) { - GtkFontSelectionPriv *priv = fontsel->priv; + GtkFontSelectionPrivate *priv = fontsel->priv; PangoFontFamily *new_family = NULL; PangoFontFace *new_face = NULL; PangoFontFace *fallback_face = NULL; @@ -1528,10 +1531,7 @@ gtk_font_selection_set_font_name (GtkFontSelection *fontsel, pango_font_description_free (new_desc); - g_object_freeze_notify (G_OBJECT (fontsel)); g_object_notify (G_OBJECT (fontsel), "font-name"); - g_object_notify (G_OBJECT (fontsel), "font"); - g_object_thaw_notify (G_OBJECT (fontsel)); return TRUE; } @@ -1549,7 +1549,7 @@ gtk_font_selection_set_font_name (GtkFontSelection *fontsel, G_CONST_RETURN gchar* gtk_font_selection_get_preview_text (GtkFontSelection *fontsel) { - GtkFontSelectionPriv *priv; + GtkFontSelectionPrivate *priv; g_return_val_if_fail (GTK_IS_FONT_SELECTION (fontsel), NULL); @@ -1571,7 +1571,7 @@ void gtk_font_selection_set_preview_text (GtkFontSelection *fontsel, const gchar *text) { - GtkFontSelectionPriv *priv; + GtkFontSelectionPrivate *priv; g_return_if_fail (GTK_IS_FONT_SELECTION (fontsel)); g_return_if_fail (text != NULL); @@ -1600,19 +1600,19 @@ static GtkBuildableIface *parent_buildable_iface; static void gtk_font_selection_dialog_class_init (GtkFontSelectionDialogClass *klass) { - g_type_class_add_private (klass, sizeof (GtkFontSelectionDialogPriv)); + g_type_class_add_private (klass, sizeof (GtkFontSelectionDialogPrivate)); } static void gtk_font_selection_dialog_init (GtkFontSelectionDialog *fontseldiag) { - GtkFontSelectionDialogPriv *priv; + GtkFontSelectionDialogPrivate *priv; GtkDialog *dialog = GTK_DIALOG (fontseldiag); GtkWidget *action_area, *content_area; fontseldiag->priv = G_TYPE_INSTANCE_GET_PRIVATE (fontseldiag, GTK_TYPE_FONT_SELECTION_DIALOG, - GtkFontSelectionDialogPriv); + GtkFontSelectionDialogPrivate); priv = fontseldiag->priv; content_area = gtk_dialog_get_content_area (dialog); @@ -1752,7 +1752,7 @@ gtk_font_selection_dialog_buildable_get_internal_child (GtkBuildable *buildable, GtkBuilder *builder, const gchar *childname) { - GtkFontSelectionDialogPriv *priv; + GtkFontSelectionDialogPrivate *priv; priv = GTK_FONT_SELECTION_DIALOG (buildable)->priv; @@ -1787,7 +1787,7 @@ gtk_font_selection_dialog_buildable_get_internal_child (GtkBuildable *buildable, gchar* gtk_font_selection_dialog_get_font_name (GtkFontSelectionDialog *fsd) { - GtkFontSelectionDialogPriv *priv; + GtkFontSelectionDialogPrivate *priv; g_return_val_if_fail (GTK_IS_FONT_SELECTION_DIALOG (fsd), NULL); @@ -1810,7 +1810,7 @@ gboolean gtk_font_selection_dialog_set_font_name (GtkFontSelectionDialog *fsd, const gchar *fontname) { - GtkFontSelectionDialogPriv *priv; + GtkFontSelectionDialogPrivate *priv; g_return_val_if_fail (GTK_IS_FONT_SELECTION_DIALOG (fsd), FALSE); g_return_val_if_fail (fontname, FALSE); @@ -1833,7 +1833,7 @@ gtk_font_selection_dialog_set_font_name (GtkFontSelectionDialog *fsd, G_CONST_RETURN gchar* gtk_font_selection_dialog_get_preview_text (GtkFontSelectionDialog *fsd) { - GtkFontSelectionDialogPriv *priv; + GtkFontSelectionDialogPrivate *priv; g_return_val_if_fail (GTK_IS_FONT_SELECTION_DIALOG (fsd), NULL); @@ -1853,7 +1853,7 @@ void gtk_font_selection_dialog_set_preview_text (GtkFontSelectionDialog *fsd, const gchar *text) { - GtkFontSelectionDialogPriv *priv; + GtkFontSelectionDialogPrivate *priv; g_return_if_fail (GTK_IS_FONT_SELECTION_DIALOG (fsd)); g_return_if_fail (text != NULL); diff --git a/gtk/gtkfontsel.h b/gtk/gtkfontsel.h index b829464ea5..7ec2b354c6 100644 --- a/gtk/gtkfontsel.h +++ b/gtk/gtkfontsel.h @@ -58,20 +58,20 @@ G_BEGIN_DECLS #define GTK_FONT_SELECTION_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_FONT_SELECTION_DIALOG, GtkFontSelectionDialogClass)) -typedef struct _GtkFontSelection GtkFontSelection; -typedef struct _GtkFontSelectionPriv GtkFontSelectionPriv; -typedef struct _GtkFontSelectionClass GtkFontSelectionClass; +typedef struct _GtkFontSelection GtkFontSelection; +typedef struct _GtkFontSelectionPrivate GtkFontSelectionPrivate; +typedef struct _GtkFontSelectionClass GtkFontSelectionClass; -typedef struct _GtkFontSelectionDialog GtkFontSelectionDialog; -typedef struct _GtkFontSelectionDialogPriv GtkFontSelectionDialogPriv; -typedef struct _GtkFontSelectionDialogClass GtkFontSelectionDialogClass; +typedef struct _GtkFontSelectionDialog GtkFontSelectionDialog; +typedef struct _GtkFontSelectionDialogPrivate GtkFontSelectionDialogPrivate; +typedef struct _GtkFontSelectionDialogClass GtkFontSelectionDialogClass; struct _GtkFontSelection { GtkVBox parent_instance; /* <private> */ - GtkFontSelectionPriv *priv; + GtkFontSelectionPrivate *priv; }; struct _GtkFontSelectionClass @@ -91,7 +91,7 @@ struct _GtkFontSelectionDialog GtkDialog parent_instance; /*< private >*/ - GtkFontSelectionDialogPriv *priv; + GtkFontSelectionDialogPrivate *priv; }; struct _GtkFontSelectionDialogClass diff --git a/gtk/gtkframe.c b/gtk/gtkframe.c index 32b191b35d..8817111c97 100644 --- a/gtk/gtkframe.c +++ b/gtk/gtkframe.c @@ -36,7 +36,7 @@ #define LABEL_PAD 1 #define LABEL_SIDE_PAD 2 -struct _GtkFramePriv +struct _GtkFramePrivate { /* Properties */ GtkWidget *label_widget; @@ -188,7 +188,7 @@ gtk_frame_class_init (GtkFrameClass *class) class->compute_child_allocation = gtk_frame_real_compute_child_allocation; - g_type_class_add_private (class, sizeof (GtkFramePriv)); + g_type_class_add_private (class, sizeof (GtkFramePrivate)); } static void @@ -214,11 +214,11 @@ gtk_frame_buildable_add_child (GtkBuildable *buildable, static void gtk_frame_init (GtkFrame *frame) { - GtkFramePriv *priv; + GtkFramePrivate *priv; frame->priv = G_TYPE_INSTANCE_GET_PRIVATE (frame, GTK_TYPE_FRAME, - GtkFramePriv); + GtkFramePrivate); priv = frame->priv; priv->label_widget = NULL; @@ -234,7 +234,7 @@ gtk_frame_set_property (GObject *object, GParamSpec *pspec) { GtkFrame *frame = GTK_FRAME (object); - GtkFramePriv *priv = frame->priv; + GtkFramePrivate *priv = frame->priv; switch (prop_id) { @@ -269,7 +269,7 @@ gtk_frame_get_property (GObject *object, GParamSpec *pspec) { GtkFrame *frame = GTK_FRAME (object); - GtkFramePriv *priv = frame->priv; + GtkFramePrivate *priv = frame->priv; switch (prop_id) { @@ -317,7 +317,7 @@ gtk_frame_remove (GtkContainer *container, GtkWidget *child) { GtkFrame *frame = GTK_FRAME (container); - GtkFramePriv *priv = frame->priv; + GtkFramePrivate *priv = frame->priv; if (priv->label_widget == child) gtk_frame_set_label_widget (frame, NULL); @@ -333,7 +333,7 @@ gtk_frame_forall (GtkContainer *container, { GtkBin *bin = GTK_BIN (container); GtkFrame *frame = GTK_FRAME (container); - GtkFramePriv *priv = frame->priv; + GtkFramePrivate *priv = frame->priv; GtkWidget *child; child = gtk_bin_get_child (bin); @@ -388,7 +388,7 @@ gtk_frame_set_label (GtkFrame *frame, G_CONST_RETURN gchar * gtk_frame_get_label (GtkFrame *frame) { - GtkFramePriv *priv; + GtkFramePrivate *priv; g_return_val_if_fail (GTK_IS_FRAME (frame), NULL); @@ -413,12 +413,12 @@ void gtk_frame_set_label_widget (GtkFrame *frame, GtkWidget *label_widget) { - GtkFramePriv *priv; + GtkFramePrivate *priv; gboolean need_resize = FALSE; g_return_if_fail (GTK_IS_FRAME (frame)); g_return_if_fail (label_widget == NULL || GTK_IS_WIDGET (label_widget)); - g_return_if_fail (label_widget == NULL || label_widget->parent == NULL); + g_return_if_fail (label_widget == NULL || gtk_widget_get_parent (label_widget) == NULL); priv = frame->priv; @@ -485,7 +485,7 @@ gtk_frame_set_label_align (GtkFrame *frame, gfloat xalign, gfloat yalign) { - GtkFramePriv *priv; + GtkFramePrivate *priv; g_return_if_fail (GTK_IS_FRAME (frame)); @@ -525,7 +525,7 @@ gtk_frame_get_label_align (GtkFrame *frame, gfloat *xalign, gfloat *yalign) { - GtkFramePriv *priv; + GtkFramePrivate *priv; g_return_if_fail (GTK_IS_FRAME (frame)); @@ -548,7 +548,7 @@ void gtk_frame_set_shadow_type (GtkFrame *frame, GtkShadowType type) { - GtkFramePriv *priv; + GtkFramePrivate *priv; GtkWidget *widget; g_return_if_fail (GTK_IS_FRAME (frame)); @@ -592,7 +592,10 @@ gtk_frame_paint (GtkWidget *widget, GdkRectangle *area) { GtkFrame *frame; - GtkFramePriv *priv; + GtkFramePrivate *priv; + GtkStateType state; + GtkStyle *style; + GdkWindow *window; gint x, y, width, height; if (gtk_widget_is_drawable (widget)) @@ -600,10 +603,14 @@ gtk_frame_paint (GtkWidget *widget, frame = GTK_FRAME (widget); priv = frame->priv; - x = priv->child_allocation.x - widget->style->xthickness; - y = priv->child_allocation.y - widget->style->ythickness; - width = priv->child_allocation.width + 2 * widget->style->xthickness; - height = priv->child_allocation.height + 2 * widget->style->ythickness; + style = gtk_widget_get_style (widget); + window = gtk_widget_get_window (widget); + state = gtk_widget_get_state (widget); + + x = priv->child_allocation.x - style->xthickness; + y = priv->child_allocation.y - style->ythickness; + width = priv->child_allocation.width + 2 * style->xthickness; + height = priv->child_allocation.height + 2 * style->ythickness; if (priv->label_widget) { @@ -616,30 +623,29 @@ gtk_frame_paint (GtkWidget *widget, else xalign = 1 - priv->label_xalign; - height_extra = MAX (0, priv->label_allocation.height - widget->style->ythickness) - - priv->label_yalign * priv->label_allocation.height; + height_extra = MAX (0, priv->label_allocation.height - style->ythickness) + - priv->label_yalign * priv->label_allocation.height; y -= height_extra; height += height_extra; - - x2 = widget->style->xthickness + (priv->child_allocation.width - priv->label_allocation.width - 2 * LABEL_PAD - 2 * LABEL_SIDE_PAD) * xalign + LABEL_SIDE_PAD; - + + x2 = style->xthickness + (priv->child_allocation.width - priv->label_allocation.width - 2 * LABEL_PAD - 2 * LABEL_SIDE_PAD) * xalign + LABEL_SIDE_PAD; /* If the label is completely over or under the frame we can omit the gap */ if (priv->label_yalign == 0.0 || priv->label_yalign == 1.0) - gtk_paint_shadow (widget->style, widget->window, - widget->state, priv->shadow_type, + gtk_paint_shadow (style, window, + state, priv->shadow_type, area, widget, "frame", x, y, width, height); else - gtk_paint_shadow_gap (widget->style, widget->window, - widget->state, priv->shadow_type, + gtk_paint_shadow_gap (style, window, + state, priv->shadow_type, area, widget, "frame", x, y, width, height, GTK_POS_TOP, x2, priv->label_allocation.width + 2 * LABEL_PAD); } else - gtk_paint_shadow (widget->style, widget->window, - widget->state, priv->shadow_type, + gtk_paint_shadow (style, window, + state, priv->shadow_type, area, widget, "frame", x, y, width, height); } @@ -664,28 +670,22 @@ gtk_frame_size_allocate (GtkWidget *widget, GtkAllocation *allocation) { GtkFrame *frame = GTK_FRAME (widget); - GtkFramePriv *priv = frame->priv; + GtkFramePrivate *priv = frame->priv; GtkBin *bin = GTK_BIN (widget); GtkAllocation new_allocation; GtkWidget *child; - widget->allocation = *allocation; + gtk_widget_set_allocation (widget, allocation); gtk_frame_compute_child_allocation (frame, &new_allocation); /* If the child allocation changed, that means that the frame is drawn * in a new place, so we must redraw the entire widget. */ - if (gtk_widget_get_mapped (widget) -#if 0 - && - (new_allocation.x != priv->child_allocation.x || - new_allocation.y != priv->child_allocation.y || - new_allocation.width != priv->child_allocation.width || - new_allocation.height != priv->child_allocation.height) -#endif - ) - gdk_window_invalidate_rect (widget->window, &widget->allocation, FALSE); + if (gtk_widget_get_mapped (widget)) + { + gdk_window_invalidate_rect (gtk_widget_get_window (widget), allocation, FALSE); + } child = gtk_bin_get_child (bin); if (child && gtk_widget_get_visible (child)) @@ -695,9 +695,12 @@ gtk_frame_size_allocate (GtkWidget *widget, if (priv->label_widget && gtk_widget_get_visible (priv->label_widget)) { + GtkStyle *style; gint nat_width, width, height; gfloat xalign; + style = gtk_widget_get_style (widget); + if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR) xalign = priv->label_xalign; else @@ -716,8 +719,7 @@ gtk_frame_size_allocate (GtkWidget *widget, priv->label_allocation.width = width; - - priv->label_allocation.y = priv->child_allocation.y - MAX (height, widget->style->ythickness); + priv->label_allocation.y = priv->child_allocation.y - MAX (height, style->ythickness); priv->label_allocation.height = height; gtk_widget_size_allocate (priv->label_widget, &priv->label_allocation); @@ -738,12 +740,17 @@ static void gtk_frame_real_compute_child_allocation (GtkFrame *frame, GtkAllocation *child_allocation) { - GtkFramePriv *priv = frame->priv; + GtkFramePrivate *priv = frame->priv; GtkWidget *widget = GTK_WIDGET (frame); - GtkAllocation *allocation = &widget->allocation; + GtkAllocation allocation; + GtkStyle *style; gint top_margin; guint border_width; + style = gtk_widget_get_style (widget); + + gtk_widget_get_allocation (widget, &allocation); + border_width = gtk_container_get_border_width (GTK_CONTAINER (frame)); if (priv->label_widget) @@ -752,30 +759,28 @@ gtk_frame_real_compute_child_allocation (GtkFrame *frame, gtk_size_request_get_width (GTK_SIZE_REQUEST (priv->label_widget), NULL, &nat_width); - width = widget->allocation.width; + width = allocation.width; width -= 2 * LABEL_PAD + 2 * LABEL_SIDE_PAD; - width -= (border_width + GTK_WIDGET (widget)->style->xthickness) * 2; + width -= (border_width + style->xthickness) * 2; width = MIN (width, nat_width); gtk_size_request_get_height_for_width (GTK_SIZE_REQUEST (priv->label_widget), width, &height, NULL); - top_margin = MAX (height, widget->style->ythickness); + top_margin = MAX (height, style->ythickness); } else - top_margin = widget->style->ythickness; - - child_allocation->x = border_width + widget->style->xthickness; - child_allocation->width = MAX(1, (gint)allocation->width - child_allocation->x * 2); - + top_margin = style->ythickness; + + child_allocation->x = border_width + style->xthickness; child_allocation->y = border_width + top_margin; - child_allocation->height = MAX (1, ((gint)allocation->height - child_allocation->y - - border_width - - (gint)widget->style->ythickness)); - - child_allocation->x += allocation->x; - child_allocation->y += allocation->y; + child_allocation->width = MAX (1, (gint) allocation.width - child_allocation->x * 2); + child_allocation->height = MAX (1, ((gint) allocation.height - child_allocation->y - + border_width - (gint) style->ythickness)); + + child_allocation->x += allocation.x; + child_allocation->y += allocation.y; } static void @@ -784,15 +789,18 @@ gtk_frame_get_size (GtkSizeRequest *request, gint *minimum_size, gint *natural_size) { + GtkFrame *frame = GTK_FRAME (request); + GtkFramePrivate *priv = frame->priv; + GtkStyle *style; GtkWidget *widget = GTK_WIDGET (request); GtkWidget *child; - GtkFrame *frame = GTK_FRAME (widget); - GtkFramePriv *priv = frame->priv; GtkBin *bin = GTK_BIN (widget); gint child_min, child_nat; gint minimum, natural; guint border_width; + style = gtk_widget_get_style (widget); + if (priv->label_widget && gtk_widget_get_visible (priv->label_widget)) { if (orientation == GTK_ORIENTATION_HORIZONTAL) @@ -806,8 +814,8 @@ gtk_frame_get_size (GtkSizeRequest *request, { gtk_size_request_get_height (GTK_SIZE_REQUEST (priv->label_widget), &child_min, &child_nat); - minimum = MAX (0, child_min - widget->style->ythickness); - natural = MAX (0, child_nat - widget->style->ythickness); + minimum = MAX (0, child_min - style->ythickness); + natural = MAX (0, child_nat - style->ythickness); } } else @@ -839,13 +847,13 @@ gtk_frame_get_size (GtkSizeRequest *request, if (orientation == GTK_ORIENTATION_HORIZONTAL) { - minimum += (border_width + GTK_WIDGET (widget)->style->xthickness) * 2; - natural += (border_width + GTK_WIDGET (widget)->style->xthickness) * 2; + minimum += (border_width + style->xthickness) * 2; + natural += (border_width + style->xthickness) * 2; } else { - minimum += (border_width + GTK_WIDGET (widget)->style->ythickness) * 2; - natural += (border_width + GTK_WIDGET (widget)->style->ythickness) * 2; + minimum += (border_width + style->ythickness) * 2; + natural += (border_width + style->ythickness) * 2; } if (minimum_size) @@ -881,17 +889,20 @@ gtk_frame_get_height_for_width (GtkSizeRequest *request, GtkWidget *widget = GTK_WIDGET (request); GtkWidget *child; GtkFrame *frame = GTK_FRAME (widget); - GtkFramePriv *priv = frame->priv; + GtkFramePrivate *priv = frame->priv; GtkBin *bin = GTK_BIN (widget); + GtkStyle *style; gint child_min, child_nat, label_width; gint minimum, natural; guint border_width; + style = gtk_widget_get_style (widget); + border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); - minimum = (border_width + GTK_WIDGET (widget)->style->ythickness) * 2; - natural = (border_width + GTK_WIDGET (widget)->style->ythickness) * 2; + minimum = (border_width + style->ythickness) * 2; + natural = (border_width + style->ythickness) * 2; - width -= (border_width + GTK_WIDGET (widget)->style->xthickness) * 2; + width -= (border_width + style->xthickness) * 2; label_width = width - 2 * LABEL_PAD + 2 * LABEL_SIDE_PAD; if (priv->label_widget && gtk_widget_get_visible (priv->label_widget)) diff --git a/gtk/gtkframe.h b/gtk/gtkframe.h index 8c3aa855f1..91ef2f716e 100644 --- a/gtk/gtkframe.h +++ b/gtk/gtkframe.h @@ -45,16 +45,16 @@ G_BEGIN_DECLS #define GTK_IS_FRAME_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_FRAME)) #define GTK_FRAME_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_FRAME, GtkFrameClass)) -typedef struct _GtkFrame GtkFrame; -typedef struct _GtkFramePriv GtkFramePriv; -typedef struct _GtkFrameClass GtkFrameClass; +typedef struct _GtkFrame GtkFrame; +typedef struct _GtkFramePrivate GtkFramePrivate; +typedef struct _GtkFrameClass GtkFrameClass; struct _GtkFrame { GtkBin bin; /* <private> */ - GtkFramePriv *priv; + GtkFramePrivate *priv; }; struct _GtkFrameClass diff --git a/gtk/gtkhandlebox.c b/gtk/gtkhandlebox.c index ead564c313..7153beb92a 100644 --- a/gtk/gtkhandlebox.c +++ b/gtk/gtkhandlebox.c @@ -37,7 +37,7 @@ -struct _GtkHandleBoxPriv +struct _GtkHandleBoxPrivate { /* Properties */ GtkPositionType handle_position; @@ -270,17 +270,17 @@ gtk_handle_box_class_init (GtkHandleBoxClass *class) G_TYPE_NONE, 1, GTK_TYPE_WIDGET); - g_type_class_add_private (gobject_class, sizeof (GtkHandleBoxPriv)); + g_type_class_add_private (gobject_class, sizeof (GtkHandleBoxPrivate)); } static void gtk_handle_box_init (GtkHandleBox *handle_box) { - GtkHandleBoxPriv *priv; + GtkHandleBoxPrivate *priv; handle_box->priv = G_TYPE_INSTANCE_GET_PRIVATE (handle_box, GTK_TYPE_HANDLE_BOX, - GtkHandleBoxPriv); + GtkHandleBoxPrivate); priv = handle_box->priv; gtk_widget_set_has_window (GTK_WIDGET (handle_box), TRUE); @@ -333,7 +333,7 @@ gtk_handle_box_get_property (GObject *object, GParamSpec *pspec) { GtkHandleBox *handle_box = GTK_HANDLE_BOX (object); - GtkHandleBoxPriv *priv = handle_box->priv; + GtkHandleBoxPrivate *priv = handle_box->priv; switch (prop_id) { @@ -371,7 +371,7 @@ static void gtk_handle_box_map (GtkWidget *widget) { GtkHandleBox *hb = GTK_HANDLE_BOX (widget); - GtkHandleBoxPriv *priv = hb->priv; + GtkHandleBoxPrivate *priv = hb->priv; GtkBin *bin = GTK_BIN (widget); GtkWidget *child; @@ -397,7 +397,7 @@ static void gtk_handle_box_unmap (GtkWidget *widget) { GtkHandleBox *hb = GTK_HANDLE_BOX (widget); - GtkHandleBoxPriv *priv = hb->priv; + GtkHandleBoxPrivate *priv = hb->priv; gtk_widget_set_mapped (widget, FALSE); @@ -413,7 +413,7 @@ static void gtk_handle_box_realize (GtkWidget *widget) { GtkHandleBox *hb = GTK_HANDLE_BOX (widget); - GtkHandleBoxPriv *priv = hb->priv; + GtkHandleBoxPrivate *priv = hb->priv; GtkWidget *child; GdkWindowAttr attributes; gint attributes_mask; @@ -486,7 +486,7 @@ static void gtk_handle_box_unrealize (GtkWidget *widget) { GtkHandleBox *hb = GTK_HANDLE_BOX (widget); - GtkHandleBoxPriv *priv = hb->priv; + GtkHandleBoxPrivate *priv = hb->priv; gdk_window_set_user_data (priv->bin_window, NULL); gdk_window_destroy (priv->bin_window); @@ -503,7 +503,7 @@ gtk_handle_box_style_set (GtkWidget *widget, GtkStyle *previous_style) { GtkHandleBox *hb = GTK_HANDLE_BOX (widget); - GtkHandleBoxPriv *priv = hb->priv; + GtkHandleBoxPrivate *priv = hb->priv; if (gtk_widget_get_realized (widget) && gtk_widget_get_has_window (widget)) @@ -518,7 +518,7 @@ gtk_handle_box_style_set (GtkWidget *widget, static int effective_handle_position (GtkHandleBox *hb) { - GtkHandleBoxPriv *priv = hb->priv; + GtkHandleBoxPrivate *priv = hb->priv; int handle_position; if (gtk_widget_get_direction (GTK_WIDGET (hb)) == GTK_TEXT_DIR_LTR) @@ -548,7 +548,7 @@ gtk_handle_box_size_request (GtkWidget *widget, { GtkBin *bin = GTK_BIN (widget); GtkHandleBox *hb = GTK_HANDLE_BOX (widget); - GtkHandleBoxPriv *priv = hb->priv; + GtkHandleBoxPrivate *priv = hb->priv; GtkRequisition child_requisition; GtkWidget *child; gint handle_position; @@ -626,7 +626,7 @@ gtk_handle_box_size_allocate (GtkWidget *widget, { GtkBin *bin = GTK_BIN (widget); GtkHandleBox *hb = GTK_HANDLE_BOX (widget); - GtkHandleBoxPriv *priv = hb->priv; + GtkHandleBoxPrivate *priv = hb->priv; GtkRequisition child_requisition; GtkWidget *child; gint handle_position; @@ -789,7 +789,7 @@ void gtk_handle_box_set_shadow_type (GtkHandleBox *handle_box, GtkShadowType type) { - GtkHandleBoxPriv *priv; + GtkHandleBoxPrivate *priv; g_return_if_fail (GTK_IS_HANDLE_BOX (handle_box)); @@ -824,7 +824,7 @@ void gtk_handle_box_set_handle_position (GtkHandleBox *handle_box, GtkPositionType position) { - GtkHandleBoxPriv *priv; + GtkHandleBoxPrivate *priv; g_return_if_fail (GTK_IS_HANDLE_BOX (handle_box)); @@ -859,7 +859,7 @@ void gtk_handle_box_set_snap_edge (GtkHandleBox *handle_box, GtkPositionType edge) { - GtkHandleBoxPriv *priv; + GtkHandleBoxPrivate *priv; g_return_if_fail (GTK_IS_HANDLE_BOX (handle_box)); @@ -918,7 +918,7 @@ gtk_handle_box_paint (GtkWidget *widget, GdkRectangle *area) { GtkHandleBox *hb = GTK_HANDLE_BOX (widget); - GtkHandleBoxPriv *priv = hb->priv; + GtkHandleBoxPrivate *priv = hb->priv; GtkBin *bin = GTK_BIN (widget); GtkWidget *child; gint width, height; @@ -1005,7 +1005,7 @@ gtk_handle_box_expose (GtkWidget *widget, GdkEventExpose *event) { GtkHandleBox *hb; - GtkHandleBoxPriv *priv; + GtkHandleBoxPrivate *priv; if (gtk_widget_is_drawable (widget)) { @@ -1043,7 +1043,7 @@ gtk_handle_box_grab_event (GtkWidget *widget, GdkEvent *event, GtkHandleBox *hb) { - GtkHandleBoxPriv *priv = hb->priv; + GtkHandleBoxPrivate *priv = hb->priv; switch (event->type) { @@ -1071,7 +1071,7 @@ gtk_handle_box_button_press (GtkWidget *widget, GdkEventButton *event) { GtkHandleBox *hb = GTK_HANDLE_BOX (widget); - GtkHandleBoxPriv *priv = hb->priv; + GtkHandleBoxPrivate *priv = hb->priv; gboolean event_handled; GdkCursor *fleur; gint handle_position; @@ -1206,7 +1206,7 @@ gtk_handle_box_motion (GtkWidget *widget, GdkEventMotion *event) { GtkHandleBox *hb = GTK_HANDLE_BOX (widget); - GtkHandleBoxPriv *priv = hb->priv; + GtkHandleBoxPrivate *priv = hb->priv; GtkWidget *child; gint new_x, new_y; gint snap_edge; @@ -1416,7 +1416,7 @@ static void gtk_handle_box_add (GtkContainer *container, GtkWidget *widget) { - GtkHandleBoxPriv *priv = GTK_HANDLE_BOX (container)->priv; + GtkHandleBoxPrivate *priv = GTK_HANDLE_BOX (container)->priv; gtk_widget_set_parent_window (widget, priv->bin_window); GTK_CONTAINER_CLASS (gtk_handle_box_parent_class)->add (container, widget); @@ -1436,7 +1436,7 @@ gtk_handle_box_delete_event (GtkWidget *widget, GdkEventAny *event) { GtkHandleBox *hb = GTK_HANDLE_BOX (widget); - GtkHandleBoxPriv *priv = hb->priv; + GtkHandleBoxPrivate *priv = hb->priv; if (event->window == priv->float_window) { @@ -1451,7 +1451,7 @@ gtk_handle_box_delete_event (GtkWidget *widget, static void gtk_handle_box_reattach (GtkHandleBox *hb) { - GtkHandleBoxPriv *priv = hb->priv; + GtkHandleBoxPrivate *priv = hb->priv; GtkWidget *child; GtkWidget *widget = GTK_WIDGET (hb); @@ -1483,7 +1483,7 @@ static void gtk_handle_box_end_drag (GtkHandleBox *hb, guint32 time) { - GtkHandleBoxPriv *priv = hb->priv; + GtkHandleBoxPrivate *priv = hb->priv; GtkWidget *invisible = gtk_handle_box_get_invisible (); priv->in_drag = FALSE; diff --git a/gtk/gtkhandlebox.h b/gtk/gtkhandlebox.h index 0240e362b1..174ce393a9 100644 --- a/gtk/gtkhandlebox.h +++ b/gtk/gtkhandlebox.h @@ -49,16 +49,16 @@ G_BEGIN_DECLS #define GTK_IS_HANDLE_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_HANDLE_BOX)) #define GTK_HANDLE_BOX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_HANDLE_BOX, GtkHandleBoxClass)) -typedef struct _GtkHandleBox GtkHandleBox; -typedef struct _GtkHandleBoxPriv GtkHandleBoxPriv; -typedef struct _GtkHandleBoxClass GtkHandleBoxClass; +typedef struct _GtkHandleBox GtkHandleBox; +typedef struct _GtkHandleBoxPrivate GtkHandleBoxPrivate; +typedef struct _GtkHandleBoxClass GtkHandleBoxClass; struct _GtkHandleBox { GtkBin bin; /* <private> */ - GtkHandleBoxPriv *priv; + GtkHandleBoxPrivate *priv; }; struct _GtkHandleBoxClass diff --git a/gtk/gtkhsv.c b/gtk/gtkhsv.c index c8758b297c..9d936a0062 100644 --- a/gtk/gtkhsv.c +++ b/gtk/gtkhsv.c @@ -56,7 +56,7 @@ typedef enum { } DragMode; /* Private part of the GtkHSV structure */ -struct _GtkHSVPriv +struct _GtkHSVPrivate { /* Color value */ double h; @@ -195,16 +195,16 @@ gtk_hsv_class_init (GtkHSVClass *class) "move", 1, G_TYPE_ENUM, GTK_DIR_LEFT); - g_type_class_add_private (gobject_class, sizeof (GtkHSVPriv)); + g_type_class_add_private (gobject_class, sizeof (GtkHSVPrivate)); } /* Object initialization function for the HSV color selector */ static void gtk_hsv_init (GtkHSV *hsv) { - GtkHSVPriv *priv; + GtkHSVPrivate *priv; - priv = G_TYPE_INSTANCE_GET_PRIVATE (hsv, GTK_TYPE_HSV, GtkHSVPriv); + priv = G_TYPE_INSTANCE_GET_PRIVATE (hsv, GTK_TYPE_HSV, GtkHSVPrivate); hsv->priv = priv; @@ -235,7 +235,7 @@ static void gtk_hsv_map (GtkWidget *widget) { GtkHSV *hsv = GTK_HSV (widget); - GtkHSVPriv *priv = hsv->priv; + GtkHSVPrivate *priv = hsv->priv; GTK_WIDGET_CLASS (gtk_hsv_parent_class)->map (widget); @@ -248,7 +248,7 @@ static void gtk_hsv_unmap (GtkWidget *widget) { GtkHSV *hsv = GTK_HSV (widget); - GtkHSVPriv *priv = hsv->priv; + GtkHSVPrivate *priv = hsv->priv; gdk_window_hide (priv->window); @@ -260,7 +260,8 @@ static void gtk_hsv_realize (GtkWidget *widget) { GtkHSV *hsv = GTK_HSV (widget); - GtkHSVPriv *priv = hsv->priv; + GtkHSVPrivate *priv = hsv->priv; + GtkAllocation allocation; GdkWindow *parent_window; GdkWindowAttr attr; int attr_mask; @@ -268,12 +269,14 @@ gtk_hsv_realize (GtkWidget *widget) gtk_widget_set_realized (widget, TRUE); /* Create window */ - + + gtk_widget_get_allocation (widget, &allocation); + attr.window_type = GDK_WINDOW_CHILD; - attr.x = widget->allocation.x; - attr.y = widget->allocation.y; - attr.width = widget->allocation.width; - attr.height = widget->allocation.height; + attr.x = allocation.x; + attr.y = allocation.y; + attr.width = allocation.width; + attr.height = allocation.height; attr.wclass = GDK_INPUT_ONLY; attr.event_mask = gtk_widget_get_events (widget); attr.event_mask |= (GDK_KEY_PRESS_MASK @@ -282,18 +285,16 @@ gtk_hsv_realize (GtkWidget *widget) | GDK_POINTER_MOTION_MASK | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK); - attr_mask = GDK_WA_X | GDK_WA_Y; - + parent_window = gtk_widget_get_parent_window (widget); - - widget->window = parent_window; - g_object_ref (widget->window); - + gtk_widget_set_window (widget, parent_window); + g_object_ref (parent_window); + priv->window = gdk_window_new (parent_window, &attr, attr_mask); gdk_window_set_user_data (priv->window, hsv); - - widget->style = gtk_style_attach (widget->style, widget->window); + + gtk_widget_style_attach (widget); } /* Unrealize handler for the HSV color selector */ @@ -301,7 +302,7 @@ static void gtk_hsv_unrealize (GtkWidget *widget) { GtkHSV *hsv = GTK_HSV (widget); - GtkHSVPriv *priv = hsv->priv; + GtkHSVPrivate *priv = hsv->priv; gdk_window_set_user_data (priv->window, NULL); gdk_window_destroy (priv->window); @@ -316,7 +317,7 @@ gtk_hsv_size_request (GtkWidget *widget, GtkRequisition *requisition) { GtkHSV *hsv = GTK_HSV (widget); - GtkHSVPriv *priv = hsv->priv; + GtkHSVPrivate *priv = hsv->priv; gint focus_width; gint focus_pad; @@ -335,10 +336,10 @@ gtk_hsv_size_allocate (GtkWidget *widget, GtkAllocation *allocation) { GtkHSV *hsv = GTK_HSV (widget); - GtkHSVPriv *priv = hsv->priv; + GtkHSVPrivate *priv = hsv->priv; + + gtk_widget_set_allocation (widget, allocation); - widget->allocation = *allocation; - if (gtk_widget_get_realized (widget)) gdk_window_move_resize (priv->window, allocation->x, @@ -510,14 +511,18 @@ compute_triangle (GtkHSV *hsv, gint *vx, gint *vy) { - GtkHSVPriv *priv = hsv->priv; + GtkHSVPrivate *priv = hsv->priv; + GtkAllocation allocation; + GtkWidget *widget = GTK_WIDGET (hsv); gdouble center_x; gdouble center_y; gdouble inner, outer; gdouble angle; - center_x = GTK_WIDGET (hsv)->allocation.width / 2.0; - center_y = GTK_WIDGET (hsv)->allocation.height / 2.0; + gtk_widget_get_allocation (widget, &allocation); + + center_x = allocation.width / 2.0; + center_y = allocation.height / 2.0; outer = priv->size / 2.0; inner = outer - priv->ring_width; angle = priv->h * 2.0 * G_PI; @@ -536,14 +541,18 @@ is_in_ring (GtkHSV *hsv, gdouble x, gdouble y) { - GtkHSVPriv *priv = hsv->priv; + GtkHSVPrivate *priv = hsv->priv; + GtkAllocation allocation; + GtkWidget *widget = GTK_WIDGET (hsv); gdouble dx, dy, dist; gdouble center_x; gdouble center_y; gdouble inner, outer; - center_x = GTK_WIDGET (hsv)->allocation.width / 2.0; - center_y = GTK_WIDGET (hsv)->allocation.height / 2.0; + gtk_widget_get_allocation (widget, &allocation); + + center_x = allocation.width / 2.0; + center_y = allocation.height / 2.0; outer = priv->size / 2.0; inner = outer - priv->ring_width; @@ -562,14 +571,18 @@ compute_sv (GtkHSV *hsv, gdouble *s, gdouble *v) { + GtkWidget *widget = GTK_WIDGET (hsv); + GtkAllocation allocation; int ihx, ihy, isx, isy, ivx, ivy; double hx, hy, sx, sy, vx, vy; double center_x; double center_y; + gtk_widget_get_allocation (widget, &allocation); + compute_triangle (hsv, &ihx, &ihy, &isx, &isy, &ivx, &ivy); - center_x = GTK_WIDGET (hsv)->allocation.width / 2.0; - center_y = GTK_WIDGET (hsv)->allocation.height / 2.0; + center_x = allocation.width / 2.0; + center_y = allocation.height / 2.0; hx = ihx - center_x; hy = center_y - ihy; sx = isx - center_x; @@ -665,13 +678,17 @@ compute_v (GtkHSV *hsv, gdouble x, gdouble y) { + GtkAllocation allocation; + GtkWidget *widget = GTK_WIDGET (hsv); double center_x; double center_y; double dx, dy; double angle; - center_x = GTK_WIDGET (hsv)->allocation.width / 2.0; - center_y = GTK_WIDGET (hsv)->allocation.height / 2.0; + gtk_widget_get_allocation (widget, &allocation); + + center_x = allocation.width / 2.0; + center_y = allocation.height / 2.0; dx = x - center_x; dy = center_y - y; @@ -688,7 +705,7 @@ static void set_cross_grab (GtkHSV *hsv, guint32 time) { - GtkHSVPriv *priv = hsv->priv; + GtkHSVPrivate *priv = hsv->priv; GdkCursor *cursor; cursor = gdk_cursor_new_for_display (gtk_widget_get_display (GTK_WIDGET (hsv)), @@ -708,7 +725,7 @@ gtk_hsv_grab_broken (GtkWidget *widget, GdkEventGrabBroken *event) { GtkHSV *hsv = GTK_HSV (widget); - GtkHSVPriv *priv = hsv->priv; + GtkHSVPrivate *priv = hsv->priv; priv->mode = DRAG_NONE; @@ -721,7 +738,7 @@ gtk_hsv_button_press (GtkWidget *widget, GdkEventButton *event) { GtkHSV *hsv = GTK_HSV (widget); - GtkHSVPriv *priv = hsv->priv; + GtkHSVPrivate *priv = hsv->priv; double x, y; if (priv->mode != DRAG_NONE || event->button != 1) @@ -771,7 +788,7 @@ gtk_hsv_button_release (GtkWidget *widget, GdkEventButton *event) { GtkHSV *hsv = GTK_HSV (widget); - GtkHSVPriv *priv = hsv->priv; + GtkHSVPrivate *priv = hsv->priv; DragMode mode; gdouble x, y; @@ -809,7 +826,7 @@ gtk_hsv_motion (GtkWidget *widget, GdkEventMotion *event) { GtkHSV *hsv = GTK_HSV (widget); - GtkHSVPriv *priv = hsv->priv; + GtkHSVPrivate *priv = hsv->priv; GdkModifierType mods; double x, y; @@ -851,7 +868,8 @@ paint_ring (GtkHSV *hsv, gint width, gint height) { - GtkHSVPriv *priv = hsv->priv; + GtkHSVPrivate *priv = hsv->priv; + GtkAllocation allocation; GtkWidget *widget = GTK_WIDGET (hsv); int xx, yy; gdouble dx, dy, dist; @@ -872,11 +890,11 @@ paint_ring (GtkHSV *hsv, "focus-line-width", &focus_width, "focus-padding", &focus_pad, NULL); - - priv = hsv->priv; - center_x = widget->allocation.width / 2.0; - center_y = widget->allocation.height / 2.0; + gtk_widget_get_allocation (widget, &allocation); + + center_x = allocation.width / 2.0; + center_y = allocation.height / 2.0; outer = priv->size / 2.0; inner = outer - priv->ring_width; @@ -1002,7 +1020,7 @@ paint_triangle (GtkHSV *hsv, gint width, gint height) { - GtkHSVPriv *priv = hsv->priv; + GtkHSVPrivate *priv = hsv->priv; GtkWidget *widget = GTK_WIDGET (hsv); gint hx, hy, sx, sy, vx, vy; /* HSV vertices */ gint x1, y1, r1, g1, b1; /* First vertex in scanline order */ @@ -1182,6 +1200,7 @@ paint_triangle (GtkHSV *hsv, if (gtk_widget_has_focus (widget) && !priv->focus_on_ring) { + GtkAllocation allocation; gint focus_width; gint focus_pad; @@ -1189,16 +1208,18 @@ paint_triangle (GtkHSV *hsv, "focus-line-width", &focus_width, "focus-padding", &focus_pad, NULL); - - gtk_paint_focus (widget->style, widget->window, + + gtk_widget_get_allocation (widget, &allocation); + + gtk_paint_focus (gtk_widget_get_style (widget), + gtk_widget_get_window (widget), gtk_widget_get_state (widget), NULL, widget, detail, - widget->allocation.x + xx - FOCUS_RADIUS - focus_width - focus_pad, - widget->allocation.y + yy - FOCUS_RADIUS - focus_width - focus_pad, + allocation.x + xx - FOCUS_RADIUS - focus_width - focus_pad, + allocation.y + yy - FOCUS_RADIUS - focus_width - focus_pad, 2 * (FOCUS_RADIUS + focus_width + focus_pad), 2 * (FOCUS_RADIUS + focus_width + focus_pad)); } - } /* Paints the contents of the HSV color selector */ @@ -1220,38 +1241,43 @@ gtk_hsv_expose (GtkWidget *widget, GdkEventExpose *event) { GtkHSV *hsv = GTK_HSV (widget); - GtkHSVPriv *priv = hsv->priv; + GtkHSVPrivate *priv = hsv->priv; + GtkAllocation allocation; GdkRectangle rect, dest; + GdkWindow *window; cairo_t *cr; - if (!(event->window == widget->window && gtk_widget_is_drawable (widget))) + window = gtk_widget_get_window (widget); + + if (!(event->window == window && gtk_widget_is_drawable (widget))) return FALSE; - rect.x = widget->allocation.x; - rect.y = widget->allocation.y; - rect.width = widget->allocation.width; - rect.height = widget->allocation.height; - + gtk_widget_get_allocation (widget, &allocation); + + rect.x = allocation.x; + rect.y = allocation.y; + rect.width = allocation.width; + rect.height = allocation.height; + if (!gdk_rectangle_intersect (&event->area, &rect, &dest)) return FALSE; - - cr = gdk_cairo_create (widget->window); - cairo_translate (cr, widget->allocation.x, widget->allocation.y); + cr = gdk_cairo_create (window); + + cairo_translate (cr, allocation.x, allocation.y); paint (hsv, cr, - dest.x - widget->allocation.x, - dest.y - widget->allocation.y, + dest.x - allocation.x, + dest.y - allocation.y, dest.width, dest.height); cairo_destroy (cr); if (gtk_widget_has_focus (widget) && priv->focus_on_ring) - gtk_paint_focus (widget->style, widget->window, + gtk_paint_focus (gtk_widget_get_style (widget), + window, gtk_widget_get_state (widget), &event->area, widget, NULL, - widget->allocation.x, - widget->allocation.y, - widget->allocation.width, - widget->allocation.height); + allocation.x, allocation.y, + allocation.width, allocation.height); return FALSE; } @@ -1261,7 +1287,7 @@ gtk_hsv_focus (GtkWidget *widget, GtkDirectionType dir) { GtkHSV *hsv = GTK_HSV (widget); - GtkHSVPriv *priv = hsv->priv; + GtkHSVPrivate *priv = hsv->priv; if (!gtk_widget_has_focus (widget)) { @@ -1345,7 +1371,7 @@ gtk_hsv_set_color (GtkHSV *hsv, gdouble s, gdouble v) { - GtkHSVPriv *priv; + GtkHSVPrivate *priv; g_return_if_fail (GTK_IS_HSV (hsv)); g_return_if_fail (h >= 0.0 && h <= 1.0); @@ -1381,7 +1407,7 @@ gtk_hsv_get_color (GtkHSV *hsv, double *s, double *v) { - GtkHSVPriv *priv = hsv->priv; + GtkHSVPrivate *priv = hsv->priv; g_return_if_fail (GTK_IS_HSV (hsv)); @@ -1412,7 +1438,7 @@ gtk_hsv_set_metrics (GtkHSV *hsv, gint size, gint ring_width) { - GtkHSVPriv *priv = hsv->priv; + GtkHSVPrivate *priv = hsv->priv; int same_size; g_return_if_fail (GTK_IS_HSV (hsv)); @@ -1448,7 +1474,7 @@ gtk_hsv_get_metrics (GtkHSV *hsv, gint *size, gint *ring_width) { - GtkHSVPriv *priv = hsv->priv; + GtkHSVPrivate *priv = hsv->priv; g_return_if_fail (GTK_IS_HSV (hsv)); @@ -1479,7 +1505,7 @@ gtk_hsv_get_metrics (GtkHSV *hsv, gboolean gtk_hsv_is_adjusting (GtkHSV *hsv) { - GtkHSVPriv *priv = hsv->priv; + GtkHSVPrivate *priv = hsv->priv; g_return_val_if_fail (GTK_IS_HSV (hsv), FALSE); @@ -1570,7 +1596,7 @@ static void gtk_hsv_move (GtkHSV *hsv, GtkDirectionType dir) { - GtkHSVPriv *priv = hsv->priv; + GtkHSVPrivate *priv = hsv->priv; gdouble hue, sat, val; gint hx, hy, sx, sy, vx, vy; /* HSV vertices */ gint x, y; /* position in triangle */ diff --git a/gtk/gtkhsv.h b/gtk/gtkhsv.h index d9ba2db651..fda2861f11 100644 --- a/gtk/gtkhsv.h +++ b/gtk/gtkhsv.h @@ -48,16 +48,16 @@ G_BEGIN_DECLS #define GTK_HSV_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_HSV, GtkHSVClass)) -typedef struct _GtkHSV GtkHSV; -typedef struct _GtkHSVPriv GtkHSVPriv; -typedef struct _GtkHSVClass GtkHSVClass; +typedef struct _GtkHSV GtkHSV; +typedef struct _GtkHSVPrivate GtkHSVPrivate; +typedef struct _GtkHSVClass GtkHSVClass; struct _GtkHSV { GtkWidget parent_instance; /* <private> */ - GtkHSVPriv *priv; + GtkHSVPrivate *priv; }; struct _GtkHSVClass diff --git a/gtk/gtkiconfactory.c b/gtk/gtkiconfactory.c index 450c921f18..8155ac8953 100644 --- a/gtk/gtkiconfactory.c +++ b/gtk/gtkiconfactory.c @@ -42,7 +42,7 @@ static GSList *all_icon_factories = NULL; -struct _GtkIconFactoryPriv +struct _GtkIconFactoryPrivate { GHashTable *icons; }; @@ -122,11 +122,11 @@ G_DEFINE_TYPE_WITH_CODE (GtkIconFactory, gtk_icon_factory, G_TYPE_OBJECT, static void gtk_icon_factory_init (GtkIconFactory *factory) { - GtkIconFactoryPriv *priv; + GtkIconFactoryPrivate *priv; factory->priv = G_TYPE_INSTANCE_GET_PRIVATE (factory, GTK_TYPE_ICON_FACTORY, - GtkIconFactoryPriv); + GtkIconFactoryPrivate); priv = factory->priv; priv->icons = g_hash_table_new (g_str_hash, g_str_equal); @@ -140,7 +140,7 @@ gtk_icon_factory_class_init (GtkIconFactoryClass *klass) object_class->finalize = gtk_icon_factory_finalize; - g_type_class_add_private (klass, sizeof (GtkIconFactoryPriv)); + g_type_class_add_private (klass, sizeof (GtkIconFactoryPrivate)); } static void @@ -161,7 +161,7 @@ static void gtk_icon_factory_finalize (GObject *object) { GtkIconFactory *factory = GTK_ICON_FACTORY (object); - GtkIconFactoryPriv *priv = factory->priv; + GtkIconFactoryPrivate *priv = factory->priv; all_icon_factories = g_slist_remove (all_icon_factories, factory); @@ -219,7 +219,7 @@ gtk_icon_factory_add (GtkIconFactory *factory, const gchar *stock_id, GtkIconSet *icon_set) { - GtkIconFactoryPriv *priv = factory->priv; + GtkIconFactoryPrivate *priv = factory->priv; gpointer old_key = NULL; gpointer old_value = NULL; @@ -262,7 +262,7 @@ GtkIconSet * gtk_icon_factory_lookup (GtkIconFactory *factory, const gchar *stock_id) { - GtkIconFactoryPriv *priv; + GtkIconFactoryPrivate *priv; g_return_val_if_fail (GTK_IS_ICON_FACTORY (factory), NULL); g_return_val_if_fail (stock_id != NULL, NULL); @@ -408,7 +408,7 @@ get_default_icons (GtkIconFactory *factory) register_stock_icon (factory, GTK_STOCK_DIALOG_AUTHENTICATION, "dialog-password"); register_stock_icon (factory, GTK_STOCK_DIALOG_ERROR, "dialog-error"); - register_stock_icon (factory, GTK_STOCK_DIALOG_INFO, "dialog-info"); + register_stock_icon (factory, GTK_STOCK_DIALOG_INFO, "dialog-information"); register_stock_icon (factory, GTK_STOCK_DIALOG_QUESTION, "dialog-question"); register_stock_icon (factory, GTK_STOCK_DIALOG_WARNING, "dialog-warning"); register_stock_icon (factory, GTK_STOCK_DND, GTK_STOCK_DND); @@ -439,7 +439,7 @@ get_default_icons (GtkIconFactory *factory) register_stock_icon (factory, GTK_STOCK_HARDDISK, "drive-harddisk"); register_stock_icon (factory, GTK_STOCK_HELP, "help-contents"); register_stock_icon (factory, GTK_STOCK_HOME, "go-home"); - register_stock_icon (factory, GTK_STOCK_INFO, "dialog-info"); + register_stock_icon (factory, GTK_STOCK_INFO, "dialog-information"); register_bidi_stock_icon (factory, GTK_STOCK_JUMP_TO, "go-jump"); register_bidi_stock_icon (factory, GTK_STOCK_GOTO_LAST, "go-last"); register_bidi_stock_icon (factory, GTK_STOCK_GO_BACK, "go-previous"); @@ -453,7 +453,7 @@ get_default_icons (GtkIconFactory *factory) register_stock_icon (factory, GTK_STOCK_ORIENTATION_REVERSE_LANDSCAPE, GTK_STOCK_ORIENTATION_REVERSE_LANDSCAPE); register_stock_icon (factory, GTK_STOCK_PAGE_SETUP, GTK_STOCK_PAGE_SETUP); register_stock_icon (factory, GTK_STOCK_PASTE, "edit-paste"); - register_stock_icon (factory, GTK_STOCK_PREFERENCES, "edit-preferences"); + register_stock_icon (factory, GTK_STOCK_PREFERENCES, GTK_STOCK_PREFERENCES); register_stock_icon (factory, GTK_STOCK_PRINT, "document-print"); register_stock_icon (factory, GTK_STOCK_PRINT_ERROR, "printer-error"); register_stock_icon (factory, GTK_STOCK_PRINT_PAUSED, "printer-paused"); @@ -1462,8 +1462,8 @@ render_icon_name_pixbuf (GtkIconSource *icon_source, names[2] = NULL; info = gtk_icon_theme_choose_icon (icon_theme, - names, - pixel_size, GTK_ICON_LOOKUP_USE_BUILTIN); + (const char **) names, + pixel_size, GTK_ICON_LOOKUP_USE_BUILTIN); g_free (names[0]); if (info) { @@ -2686,7 +2686,7 @@ _gtk_icon_factory_list_ids (void) { GList *these_ids; GtkIconFactory *factory = GTK_ICON_FACTORY (tmp_list->data); - GtkIconFactoryPriv *priv = factory->priv; + GtkIconFactoryPrivate *priv = factory->priv; these_ids = g_hash_table_get_keys (priv->icons); diff --git a/gtk/gtkiconfactory.h b/gtk/gtkiconfactory.h index d51708a6dd..990b12a458 100644 --- a/gtk/gtkiconfactory.h +++ b/gtk/gtkiconfactory.h @@ -46,15 +46,15 @@ G_BEGIN_DECLS #define GTK_TYPE_ICON_SET (gtk_icon_set_get_type ()) #define GTK_TYPE_ICON_SOURCE (gtk_icon_source_get_type ()) -typedef struct _GtkIconFactoryPriv GtkIconFactoryPriv; -typedef struct _GtkIconFactoryClass GtkIconFactoryClass; +typedef struct _GtkIconFactoryPrivate GtkIconFactoryPrivate; +typedef struct _GtkIconFactoryClass GtkIconFactoryClass; struct _GtkIconFactory { GObject parent_instance; /* <private> */ - GtkIconFactoryPriv *priv; + GtkIconFactoryPrivate *priv; }; struct _GtkIconFactoryClass diff --git a/gtk/gtkimage.c b/gtk/gtkimage.c index 2a41329683..e7aadcf6aa 100644 --- a/gtk/gtkimage.c +++ b/gtk/gtkimage.c @@ -127,7 +127,7 @@ */ -struct _GtkImagePriv +struct _GtkImagePrivate { GtkIconSize icon_size; /* Only used with GTK_IMAGE_STOCK, GTK_IMAGE_ICON_SET, GTK_IMAGE_ICON_NAME */ GtkImageType storage_type; @@ -352,17 +352,17 @@ gtk_image_class_init (GtkImageClass *class) GTK_IMAGE_EMPTY, GTK_PARAM_READABLE)); - g_type_class_add_private (object_class, sizeof (GtkImagePriv)); + g_type_class_add_private (object_class, sizeof (GtkImagePrivate)); } static void gtk_image_init (GtkImage *image) { - GtkImagePriv *priv; + GtkImagePrivate *priv; image->priv = G_TYPE_INSTANCE_GET_PRIVATE (image, GTK_TYPE_IMAGE, - GtkImagePriv); + GtkImagePrivate); priv = image->priv; gtk_widget_set_has_window (GTK_WIDGET (image), FALSE); @@ -393,7 +393,7 @@ gtk_image_set_property (GObject *object, GParamSpec *pspec) { GtkImage *image = GTK_IMAGE (object); - GtkImagePriv *priv = image->priv; + GtkImagePrivate *priv = image->priv; switch (prop_id) { @@ -486,7 +486,7 @@ gtk_image_get_property (GObject *object, GParamSpec *pspec) { GtkImage *image = GTK_IMAGE (object); - GtkImagePriv *priv = image->priv; + GtkImagePrivate *priv = image->priv; /* The "getter" functions whine if you try to get the wrong * storage type. This function is instead robust against that, @@ -812,7 +812,7 @@ gtk_image_set_from_pixmap (GtkImage *image, GdkPixmap *pixmap, GdkBitmap *mask) { - GtkImagePriv *priv; + GtkImagePrivate *priv; g_return_if_fail (GTK_IS_IMAGE (image)); g_return_if_fail (pixmap == NULL || @@ -865,7 +865,7 @@ void gtk_image_set_from_file (GtkImage *image, const gchar *filename) { - GtkImagePriv *priv; + GtkImagePrivate *priv; GdkPixbufAnimation *anim; g_return_if_fail (GTK_IS_IMAGE (image)); @@ -923,7 +923,7 @@ void gtk_image_set_from_pixbuf (GtkImage *image, GdkPixbuf *pixbuf) { - GtkImagePriv *priv; + GtkImagePrivate *priv; g_return_if_fail (GTK_IS_IMAGE (image)); g_return_if_fail (pixbuf == NULL || @@ -967,7 +967,7 @@ gtk_image_set_from_stock (GtkImage *image, const gchar *stock_id, GtkIconSize size) { - GtkImagePriv *priv; + GtkImagePrivate *priv; gchar *new_id; g_return_if_fail (GTK_IS_IMAGE (image)); @@ -1013,7 +1013,7 @@ gtk_image_set_from_icon_set (GtkImage *image, GtkIconSet *icon_set, GtkIconSize size) { - GtkImagePriv *priv; + GtkImagePrivate *priv; g_return_if_fail (GTK_IS_IMAGE (image)); @@ -1056,7 +1056,7 @@ void gtk_image_set_from_animation (GtkImage *image, GdkPixbufAnimation *animation) { - GtkImagePriv *priv; + GtkImagePrivate *priv; g_return_if_fail (GTK_IS_IMAGE (image)); g_return_if_fail (animation == NULL || @@ -1105,7 +1105,7 @@ gtk_image_set_from_icon_name (GtkImage *image, GtkIconSize size) { gchar *new_name; - GtkImagePriv *priv; + GtkImagePrivate *priv; g_return_if_fail (GTK_IS_IMAGE (image)); @@ -1152,7 +1152,7 @@ gtk_image_set_from_gicon (GtkImage *image, GIcon *icon, GtkIconSize size) { - GtkImagePriv *priv; + GtkImagePrivate *priv; g_return_if_fail (GTK_IS_IMAGE (image)); @@ -1222,7 +1222,7 @@ gtk_image_get_pixmap (GtkImage *image, GdkPixmap **pixmap, GdkBitmap **mask) { - GtkImagePriv *priv; + GtkImagePrivate *priv; g_return_if_fail (GTK_IS_IMAGE (image)); @@ -1254,7 +1254,7 @@ gtk_image_get_pixmap (GtkImage *image, GdkPixbuf* gtk_image_get_pixbuf (GtkImage *image) { - GtkImagePriv *priv; + GtkImagePrivate *priv; g_return_val_if_fail (GTK_IS_IMAGE (image), NULL); @@ -1288,7 +1288,7 @@ gtk_image_get_stock (GtkImage *image, gchar **stock_id, GtkIconSize *size) { - GtkImagePriv *priv; + GtkImagePrivate *priv; g_return_if_fail (GTK_IS_IMAGE (image)); @@ -1324,7 +1324,7 @@ gtk_image_get_icon_set (GtkImage *image, GtkIconSet **icon_set, GtkIconSize *size) { - GtkImagePriv *priv; + GtkImagePrivate *priv; g_return_if_fail (GTK_IS_IMAGE (image)); @@ -1356,7 +1356,7 @@ gtk_image_get_icon_set (GtkImage *image, GdkPixbufAnimation* gtk_image_get_animation (GtkImage *image) { - GtkImagePriv *priv; + GtkImagePrivate *priv; g_return_val_if_fail (GTK_IS_IMAGE (image), NULL); @@ -1393,7 +1393,7 @@ gtk_image_get_icon_name (GtkImage *image, G_CONST_RETURN gchar **icon_name, GtkIconSize *size) { - GtkImagePriv *priv; + GtkImagePrivate *priv; g_return_if_fail (GTK_IS_IMAGE (image)); @@ -1433,7 +1433,7 @@ gtk_image_get_gicon (GtkImage *image, GIcon **gicon, GtkIconSize *size) { - GtkImagePriv *priv; + GtkImagePrivate *priv; g_return_if_fail (GTK_IS_IMAGE (image)); @@ -1468,7 +1468,7 @@ gtk_image_new (void) static void gtk_image_reset_anim_iter (GtkImage *image) { - GtkImagePriv *priv = image->priv; + GtkImagePrivate *priv = image->priv; if (priv->storage_type == GTK_IMAGE_ANIMATION) { @@ -1508,7 +1508,7 @@ static gint animation_timeout (gpointer data) { GtkImage *image = GTK_IMAGE (data); - GtkImagePriv *priv = image->priv; + GtkImagePrivate *priv = image->priv; int delay; priv->data.anim.frame_timeout = 0; @@ -1533,7 +1533,7 @@ animation_timeout (gpointer data) static void icon_theme_changed (GtkImage *image) { - GtkImagePriv *priv = image->priv; + GtkImagePrivate *priv = image->priv; if (priv->storage_type == GTK_IMAGE_ICON_NAME) { @@ -1557,7 +1557,7 @@ static void ensure_pixbuf_for_icon_name (GtkImage *image, GtkStateType state) { - GtkImagePriv *priv = image->priv; + GtkImagePrivate *priv = image->priv; GdkScreen *screen; GtkIconTheme *icon_theme; GtkSettings *settings; @@ -1663,7 +1663,7 @@ static void ensure_pixbuf_for_gicon (GtkImage *image, GtkStateType state) { - GtkImagePriv *priv = image->priv; + GtkImagePrivate *priv = image->priv; GdkScreen *screen; GtkIconTheme *icon_theme; GtkSettings *settings; @@ -1778,7 +1778,7 @@ gtk_image_expose (GtkWidget *widget, GdkEventExpose *event) { GtkImage *image; - GtkImagePriv *priv; + GtkImagePrivate *priv; g_return_val_if_fail (GTK_IS_IMAGE (widget), FALSE); g_return_val_if_fail (event != NULL, FALSE); @@ -2088,7 +2088,7 @@ gtk_image_expose (GtkWidget *widget, static void gtk_image_reset (GtkImage *image) { - GtkImagePriv *priv = image->priv; + GtkImagePrivate *priv = image->priv; g_object_freeze_notify (G_OBJECT (image)); @@ -2211,7 +2211,7 @@ gtk_image_reset (GtkImage *image) void gtk_image_clear (GtkImage *image) { - GtkImagePriv *priv = image->priv; + GtkImagePrivate *priv = image->priv; priv->need_calc_size = 1; @@ -2223,7 +2223,7 @@ static void gtk_image_calc_size (GtkImage *image) { GtkWidget *widget = GTK_WIDGET (image); - GtkImagePriv *priv = image->priv; + GtkImagePrivate *priv = image->priv; GdkPixbuf *pixbuf = NULL; priv->need_calc_size = 0; @@ -2354,7 +2354,7 @@ void gtk_image_set_pixel_size (GtkImage *image, gint pixel_size) { - GtkImagePriv *priv; + GtkImagePrivate *priv; g_return_if_fail (GTK_IS_IMAGE (image)); diff --git a/gtk/gtkimage.h b/gtk/gtkimage.h index 0a02219cc0..9085fcb25e 100644 --- a/gtk/gtkimage.h +++ b/gtk/gtkimage.h @@ -46,9 +46,9 @@ G_BEGIN_DECLS #define GTK_IMAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_IMAGE, GtkImageClass)) -typedef struct _GtkImage GtkImage; -typedef struct _GtkImagePriv GtkImagePriv; -typedef struct _GtkImageClass GtkImageClass; +typedef struct _GtkImage GtkImage; +typedef struct _GtkImagePrivate GtkImagePrivate; +typedef struct _GtkImageClass GtkImageClass; typedef struct _GtkImagePixmapData GtkImagePixmapData; typedef struct _GtkImageImageData GtkImageImageData; @@ -145,7 +145,7 @@ struct _GtkImage GtkMisc misc; /* <private> */ - GtkImagePriv *priv; + GtkImagePrivate *priv; }; struct _GtkImageClass diff --git a/gtk/gtkimagemenuitem.c b/gtk/gtkimagemenuitem.c index d9e46259df..8c5a63afa3 100644 --- a/gtk/gtkimagemenuitem.c +++ b/gtk/gtkimagemenuitem.c @@ -39,7 +39,7 @@ -struct _GtkImageMenuItemPriv +struct _GtkImageMenuItemPrivate { GtkWidget *image; @@ -194,17 +194,17 @@ gtk_image_menu_item_class_init (GtkImageMenuItemClass *klass) TRUE, GTK_PARAM_READWRITE)); - g_type_class_add_private (object_class, sizeof (GtkImageMenuItemPriv)); + g_type_class_add_private (object_class, sizeof (GtkImageMenuItemPrivate)); } static void gtk_image_menu_item_init (GtkImageMenuItem *image_menu_item) { - GtkImageMenuItemPriv *priv; + GtkImageMenuItemPrivate *priv; image_menu_item->priv = G_TYPE_INSTANCE_GET_PRIVATE (image_menu_item, GTK_TYPE_IMAGE_MENU_ITEM, - GtkImageMenuItemPriv); + GtkImageMenuItemPrivate); priv = image_menu_item->priv; priv->image = NULL; @@ -215,7 +215,7 @@ gtk_image_menu_item_init (GtkImageMenuItem *image_menu_item) static void gtk_image_menu_item_finalize (GObject *object) { - GtkImageMenuItemPriv *priv = GTK_IMAGE_MENU_ITEM (object)->priv; + GtkImageMenuItemPrivate *priv = GTK_IMAGE_MENU_ITEM (object)->priv; g_free (priv->label); priv->label = NULL; @@ -279,7 +279,7 @@ gtk_image_menu_item_get_property (GObject *object, static gboolean show_image (GtkImageMenuItem *image_menu_item) { - GtkImageMenuItemPriv *priv = image_menu_item->priv; + GtkImageMenuItemPrivate *priv = image_menu_item->priv; GtkSettings *settings = gtk_widget_get_settings (GTK_WIDGET (image_menu_item)); gboolean show; @@ -295,7 +295,7 @@ static void gtk_image_menu_item_map (GtkWidget *widget) { GtkImageMenuItem *image_menu_item = GTK_IMAGE_MENU_ITEM (widget); - GtkImageMenuItemPriv *priv = image_menu_item->priv; + GtkImageMenuItemPrivate *priv = image_menu_item->priv; GTK_WIDGET_CLASS (gtk_image_menu_item_parent_class)->map (widget); @@ -309,7 +309,7 @@ static void gtk_image_menu_item_destroy (GtkObject *object) { GtkImageMenuItem *image_menu_item = GTK_IMAGE_MENU_ITEM (object); - GtkImageMenuItemPriv *priv = image_menu_item->priv; + GtkImageMenuItemPrivate *priv = image_menu_item->priv; if (priv->image) gtk_container_remove (GTK_CONTAINER (image_menu_item), @@ -323,11 +323,15 @@ gtk_image_menu_item_toggle_size_request (GtkMenuItem *menu_item, gint *requisition) { GtkImageMenuItem *image_menu_item = GTK_IMAGE_MENU_ITEM (menu_item); - GtkImageMenuItemPriv *priv = image_menu_item->priv; + GtkImageMenuItemPrivate *priv = image_menu_item->priv; GtkPackDirection pack_dir; + GtkWidget *parent; + GtkWidget *widget = GTK_WIDGET (menu_item); - if (GTK_IS_MENU_BAR (GTK_WIDGET (menu_item)->parent)) - pack_dir = gtk_menu_bar_get_child_pack_direction (GTK_MENU_BAR (GTK_WIDGET (menu_item)->parent)); + parent = gtk_widget_get_parent (widget); + + if (GTK_IS_MENU_BAR (parent)) + pack_dir = gtk_menu_bar_get_child_pack_direction (GTK_MENU_BAR (parent)); else pack_dir = GTK_PACK_DIRECTION_LTR; @@ -360,7 +364,7 @@ gtk_image_menu_item_toggle_size_request (GtkMenuItem *menu_item, static void gtk_image_menu_item_recalculate (GtkImageMenuItem *image_menu_item) { - GtkImageMenuItemPriv *priv = image_menu_item->priv; + GtkImageMenuItemPrivate *priv = image_menu_item->priv; GtkStockItem stock_item; GtkWidget *image; const gchar *resolved_label = priv->label; @@ -389,7 +393,7 @@ static void gtk_image_menu_item_set_label (GtkMenuItem *menu_item, const gchar *label) { - GtkImageMenuItemPriv *priv = GTK_IMAGE_MENU_ITEM (menu_item)->priv; + GtkImageMenuItemPrivate *priv = GTK_IMAGE_MENU_ITEM (menu_item)->priv; if (priv->label != label) { @@ -406,7 +410,7 @@ gtk_image_menu_item_set_label (GtkMenuItem *menu_item, static G_CONST_RETURN gchar * gtk_image_menu_item_get_label (GtkMenuItem *menu_item) { - GtkImageMenuItemPriv *priv = GTK_IMAGE_MENU_ITEM (menu_item)->priv; + GtkImageMenuItemPrivate *priv = GTK_IMAGE_MENU_ITEM (menu_item)->priv; return priv->label; } @@ -416,13 +420,16 @@ gtk_image_menu_item_size_request (GtkWidget *widget, GtkRequisition *requisition) { GtkImageMenuItem *image_menu_item = GTK_IMAGE_MENU_ITEM (widget); - GtkImageMenuItemPriv *priv = image_menu_item->priv; + GtkImageMenuItemPrivate *priv = image_menu_item->priv; gint child_width = 0; gint child_height = 0; GtkPackDirection pack_dir; - - if (GTK_IS_MENU_BAR (widget->parent)) - pack_dir = gtk_menu_bar_get_child_pack_direction (GTK_MENU_BAR (widget->parent)); + GtkWidget *parent; + + parent = gtk_widget_get_parent (widget); + + if (GTK_IS_MENU_BAR (parent)) + pack_dir = gtk_menu_bar_get_child_pack_direction (GTK_MENU_BAR (parent)); else pack_dir = GTK_PACK_DIRECTION_LTR; @@ -459,11 +466,15 @@ gtk_image_menu_item_size_allocate (GtkWidget *widget, GtkAllocation *allocation) { GtkImageMenuItem *image_menu_item = GTK_IMAGE_MENU_ITEM (widget); - GtkImageMenuItemPriv *priv = image_menu_item->priv; + GtkImageMenuItemPrivate *priv = image_menu_item->priv; + GtkAllocation widget_allocation; GtkPackDirection pack_dir; - - if (GTK_IS_MENU_BAR (widget->parent)) - pack_dir = gtk_menu_bar_get_child_pack_direction (GTK_MENU_BAR (widget->parent)); + GtkWidget *parent; + + parent = gtk_widget_get_parent (widget); + + if (GTK_IS_MENU_BAR (parent)) + pack_dir = gtk_menu_bar_get_child_pack_direction (GTK_MENU_BAR (parent)); else pack_dir = GTK_PACK_DIRECTION_LTR; @@ -488,48 +499,50 @@ gtk_image_menu_item_size_allocate (GtkWidget *widget, gtk_widget_get_child_requisition (priv->image, &child_requisition); + gtk_widget_get_allocation (widget, &widget_allocation); + if (pack_dir == GTK_PACK_DIRECTION_LTR || pack_dir == GTK_PACK_DIRECTION_RTL) { offset = gtk_container_get_border_width (GTK_CONTAINER (image_menu_item)) + - widget->style->xthickness; - + gtk_widget_get_style (widget)->xthickness; + if ((gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR) == (pack_dir == GTK_PACK_DIRECTION_LTR)) x = offset + horizontal_padding + (GTK_MENU_ITEM (image_menu_item)->toggle_size - toggle_spacing - child_requisition.width) / 2; else - x = widget->allocation.width - offset - horizontal_padding - + x = widget_allocation.width - offset - horizontal_padding - GTK_MENU_ITEM (image_menu_item)->toggle_size + toggle_spacing + (GTK_MENU_ITEM (image_menu_item)->toggle_size - toggle_spacing - child_requisition.width) / 2; - - y = (widget->allocation.height - child_requisition.height) / 2; + + y = (widget_allocation.height - child_requisition.height) / 2; } else { offset = gtk_container_get_border_width (GTK_CONTAINER (image_menu_item)) + - widget->style->ythickness; - + gtk_widget_get_style (widget)->ythickness; + if ((gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR) == (pack_dir == GTK_PACK_DIRECTION_TTB)) y = offset + horizontal_padding + (GTK_MENU_ITEM (image_menu_item)->toggle_size - toggle_spacing - child_requisition.height) / 2; else - y = widget->allocation.height - offset - horizontal_padding - + y = widget_allocation.height - offset - horizontal_padding - GTK_MENU_ITEM (image_menu_item)->toggle_size + toggle_spacing + (GTK_MENU_ITEM (image_menu_item)->toggle_size - toggle_spacing - child_requisition.height) / 2; - x = (widget->allocation.width - child_requisition.width) / 2; + x = (widget_allocation.width - child_requisition.width) / 2; } child_allocation.width = child_requisition.width; child_allocation.height = child_requisition.height; - child_allocation.x = widget->allocation.x + MAX (x, 0); - child_allocation.y = widget->allocation.y + MAX (y, 0); + child_allocation.x = widget_allocation.x + MAX (x, 0); + child_allocation.y = widget_allocation.y + MAX (y, 0); gtk_widget_size_allocate (priv->image, &child_allocation); } @@ -542,7 +555,7 @@ gtk_image_menu_item_forall (GtkContainer *container, gpointer callback_data) { GtkImageMenuItem *image_menu_item = GTK_IMAGE_MENU_ITEM (container); - GtkImageMenuItemPriv *priv = image_menu_item->priv; + GtkImageMenuItemPrivate *priv = image_menu_item->priv; GTK_CONTAINER_CLASS (gtk_image_menu_item_parent_class)->forall (container, include_internals, @@ -771,7 +784,7 @@ void gtk_image_menu_item_set_use_stock (GtkImageMenuItem *image_menu_item, gboolean use_stock) { - GtkImageMenuItemPriv *priv; + GtkImageMenuItemPrivate *priv; g_return_if_fail (GTK_IS_IMAGE_MENU_ITEM (image_menu_item)); @@ -824,7 +837,7 @@ void gtk_image_menu_item_set_always_show_image (GtkImageMenuItem *image_menu_item, gboolean always_show) { - GtkImageMenuItemPriv *priv; + GtkImageMenuItemPrivate *priv; g_return_if_fail (GTK_IS_IMAGE_MENU_ITEM (image_menu_item)); @@ -885,7 +898,7 @@ void gtk_image_menu_item_set_accel_group (GtkImageMenuItem *image_menu_item, GtkAccelGroup *accel_group) { - GtkImageMenuItemPriv *priv; + GtkImageMenuItemPrivate *priv; GtkStockItem stock_item; /* Silent return for the constructor */ @@ -924,7 +937,7 @@ void gtk_image_menu_item_set_image (GtkImageMenuItem *image_menu_item, GtkWidget *image) { - GtkImageMenuItemPriv *priv; + GtkImageMenuItemPrivate *priv; g_return_if_fail (GTK_IS_IMAGE_MENU_ITEM (image_menu_item)); @@ -972,7 +985,7 @@ gtk_image_menu_item_remove (GtkContainer *container, GtkWidget *child) { GtkImageMenuItem *image_menu_item = GTK_IMAGE_MENU_ITEM (container); - GtkImageMenuItemPriv *priv = image_menu_item->priv; + GtkImageMenuItemPrivate *priv = image_menu_item->priv; if (child == priv->image) { @@ -998,7 +1011,7 @@ gtk_image_menu_item_remove (GtkContainer *container, static void show_image_change_notify (GtkImageMenuItem *image_menu_item) { - GtkImageMenuItemPriv *priv = image_menu_item->priv; + GtkImageMenuItemPrivate *priv = image_menu_item->priv; if (priv->image) { diff --git a/gtk/gtkimagemenuitem.h b/gtk/gtkimagemenuitem.h index 1a27d1b33d..1904a7b626 100644 --- a/gtk/gtkimagemenuitem.h +++ b/gtk/gtkimagemenuitem.h @@ -45,16 +45,16 @@ G_BEGIN_DECLS #define GTK_IMAGE_MENU_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_IMAGE_MENU_ITEM, GtkImageMenuItemClass)) -typedef struct _GtkImageMenuItem GtkImageMenuItem; -typedef struct _GtkImageMenuItemPriv GtkImageMenuItemPriv; -typedef struct _GtkImageMenuItemClass GtkImageMenuItemClass; +typedef struct _GtkImageMenuItem GtkImageMenuItem; +typedef struct _GtkImageMenuItemPrivate GtkImageMenuItemPrivate; +typedef struct _GtkImageMenuItemClass GtkImageMenuItemClass; struct _GtkImageMenuItem { GtkMenuItem menu_item; /*< private >*/ - GtkImageMenuItemPriv *priv; + GtkImageMenuItemPrivate *priv; }; struct _GtkImageMenuItemClass diff --git a/gtk/gtkimcontextsimple.c b/gtk/gtkimcontextsimple.c index 7a17340883..9b73f8445e 100644 --- a/gtk/gtkimcontextsimple.c +++ b/gtk/gtkimcontextsimple.c @@ -33,7 +33,7 @@ typedef struct _GtkComposeTable GtkComposeTable; typedef struct _GtkComposeTableCompact GtkComposeTableCompact; -struct _GtkIMContextSimplePriv +struct _GtkIMContextSimplePrivate { GSList *tables; @@ -119,7 +119,7 @@ gtk_im_context_simple_class_init (GtkIMContextSimpleClass *class) im_context_class->get_preedit_string = gtk_im_context_simple_get_preedit_string; gobject_class->finalize = gtk_im_context_simple_finalize; - g_type_class_add_private (class, sizeof (GtkIMContextSimplePriv)); + g_type_class_add_private (class, sizeof (GtkIMContextSimplePrivate)); } static void @@ -127,14 +127,14 @@ gtk_im_context_simple_init (GtkIMContextSimple *im_context_simple) { im_context_simple->priv = G_TYPE_INSTANCE_GET_PRIVATE (im_context_simple, GTK_TYPE_IM_CONTEXT_SIMPLE, - GtkIMContextSimplePriv); + GtkIMContextSimplePrivate); } static void gtk_im_context_simple_finalize (GObject *obj) { GtkIMContextSimple *context_simple = GTK_IM_CONTEXT_SIMPLE (obj); - GtkIMContextSimplePriv *priv = context_simple->priv; + GtkIMContextSimplePrivate *priv = context_simple->priv; if (priv->tables) { @@ -165,7 +165,7 @@ gtk_im_context_simple_commit_char (GtkIMContext *context, gunichar ch) { GtkIMContextSimple *context_simple = GTK_IM_CONTEXT_SIMPLE (context); - GtkIMContextSimplePriv *priv = context_simple->priv; + GtkIMContextSimplePrivate *priv = context_simple->priv; gchar buf[10]; gint len; @@ -225,7 +225,7 @@ check_table (GtkIMContextSimple *context_simple, const GtkComposeTable *table, gint n_compose) { - GtkIMContextSimplePriv *priv = context_simple->priv; + GtkIMContextSimplePrivate *priv = context_simple->priv; gint row_stride = table->max_seq_len + 2; guint16 *seq; @@ -313,7 +313,7 @@ static gboolean check_win32_special_cases (GtkIMContextSimple *context_simple, gint n_compose) { - GtkIMContextSimplePriv *priv = context_simple->priv; + GtkIMContextSimplePrivate *priv = context_simple->priv; if (n_compose == 2 && priv->compose_buffer[1] == GDK_space) { @@ -343,7 +343,7 @@ check_win32_special_case_after_compact_match (GtkIMContextSimple *context_sim gint n_compose, guint value) { - GtkIMContextSimplePriv *priv = context_simple->priv; + GtkIMContextSimplePrivate *priv = context_simple->priv; /* On Windows user expectation is that typing two dead accents will input * two corresponding spacing accents. @@ -364,7 +364,7 @@ check_compact_table (GtkIMContextSimple *context_simple, const GtkComposeTableCompact *table, gint n_compose) { - GtkIMContextSimplePriv *priv = context_simple->priv; + GtkIMContextSimplePrivate *priv = context_simple->priv; gint row_stride; guint16 *seq_index; guint16 *seq; @@ -519,7 +519,7 @@ check_algorithmically (GtkIMContextSimple *context_simple, gint n_compose) { - GtkIMContextSimplePriv *priv = context_simple->priv; + GtkIMContextSimplePrivate *priv = context_simple->priv; gint i; gunichar combination_buffer[GTK_MAX_COMPOSE_LEN]; gchar *combination_utf8, *nfc; @@ -626,7 +626,7 @@ static gboolean check_hex (GtkIMContextSimple *context_simple, gint n_compose) { - GtkIMContextSimplePriv *priv = context_simple->priv; + GtkIMContextSimplePrivate *priv = context_simple->priv; /* See if this is a hex sequence, return TRUE if so */ gint i; GString *str; @@ -711,7 +711,7 @@ no_sequence_matches (GtkIMContextSimple *context_simple, gint n_compose, GdkEventKey *event) { - GtkIMContextSimplePriv *priv = context_simple->priv; + GtkIMContextSimplePrivate *priv = context_simple->priv; GtkIMContext *context; gunichar ch; @@ -816,7 +816,7 @@ gtk_im_context_simple_filter_keypress (GtkIMContext *context, GdkEventKey *event) { GtkIMContextSimple *context_simple = GTK_IM_CONTEXT_SIMPLE (context); - GtkIMContextSimplePriv *priv = context_simple->priv; + GtkIMContextSimplePrivate *priv = context_simple->priv; GSList *tmp_list; int n_compose = 0; gboolean have_hex_mods; @@ -1068,7 +1068,7 @@ static void gtk_im_context_simple_reset (GtkIMContext *context) { GtkIMContextSimple *context_simple = GTK_IM_CONTEXT_SIMPLE (context); - GtkIMContextSimplePriv *priv = context_simple->priv; + GtkIMContextSimplePrivate *priv = context_simple->priv; priv->compose_buffer[0] = 0; @@ -1089,7 +1089,7 @@ gtk_im_context_simple_get_preedit_string (GtkIMContext *context, gint *cursor_pos) { GtkIMContextSimple *context_simple = GTK_IM_CONTEXT_SIMPLE (context); - GtkIMContextSimplePriv *priv = context_simple->priv; + GtkIMContextSimplePrivate *priv = context_simple->priv; char outbuf[37]; /* up to 6 hex digits */ int len = 0; @@ -1158,7 +1158,7 @@ gtk_im_context_simple_add_table (GtkIMContextSimple *context_simple, gint max_seq_len, gint n_seqs) { - GtkIMContextSimplePriv *priv = context_simple->priv; + GtkIMContextSimplePrivate *priv = context_simple->priv; GtkComposeTable *table; g_return_if_fail (GTK_IS_IM_CONTEXT_SIMPLE (context_simple)); diff --git a/gtk/gtkimcontextsimple.h b/gtk/gtkimcontextsimple.h index ee02e1b53f..a215110c51 100644 --- a/gtk/gtkimcontextsimple.h +++ b/gtk/gtkimcontextsimple.h @@ -38,9 +38,9 @@ G_BEGIN_DECLS #define GTK_IM_CONTEXT_SIMPLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_IM_CONTEXT_SIMPLE, GtkIMContextSimpleClass)) -typedef struct _GtkIMContextSimple GtkIMContextSimple; -typedef struct _GtkIMContextSimplePriv GtkIMContextSimplePriv; -typedef struct _GtkIMContextSimpleClass GtkIMContextSimpleClass; +typedef struct _GtkIMContextSimple GtkIMContextSimple; +typedef struct _GtkIMContextSimplePrivate GtkIMContextSimplePrivate; +typedef struct _GtkIMContextSimpleClass GtkIMContextSimpleClass; #define GTK_MAX_COMPOSE_LEN 7 @@ -49,7 +49,7 @@ struct _GtkIMContextSimple GtkIMContext object; /* <private> */ - GtkIMContextSimplePriv *priv; + GtkIMContextSimplePrivate *priv; }; struct _GtkIMContextSimpleClass diff --git a/gtk/gtkinfobar.c b/gtk/gtkinfobar.c index 08de226266..7de08fb5a5 100644 --- a/gtk/gtkinfobar.c +++ b/gtk/gtkinfobar.c @@ -310,21 +310,22 @@ gtk_info_bar_expose (GtkWidget *widget, if (priv->message_type != GTK_MESSAGE_OTHER) { + GtkAllocation allocation; const char *detail; detail = type_detail[priv->message_type]; - gtk_paint_box (widget->style, - widget->window, + gtk_widget_get_allocation (widget, &allocation); + + gtk_paint_box (gtk_widget_get_style (widget), + gtk_widget_get_window (widget), GTK_STATE_NORMAL, GTK_SHADOW_OUT, NULL, widget, detail, - widget->allocation.x, - widget->allocation.y, - widget->allocation.width, - widget->allocation.height); + allocation.x, allocation.y, + allocation.width, allocation.height); } if (GTK_WIDGET_CLASS (gtk_info_bar_parent_class)->expose_event) @@ -569,9 +570,9 @@ gtk_info_bar_update_colors (GtkInfoBar *info_bar) } } - if (!gdk_color_equal (bg, &widget->style->bg[GTK_STATE_NORMAL])) + if (!gdk_color_equal (bg, &style->bg[GTK_STATE_NORMAL])) gtk_widget_modify_bg (widget, GTK_STATE_NORMAL, bg); - if (!gdk_color_equal (fg, &widget->style->fg[GTK_STATE_NORMAL])) + if (!gdk_color_equal (fg, &style->fg[GTK_STATE_NORMAL])) gtk_widget_modify_fg (widget, GTK_STATE_NORMAL, fg); } diff --git a/gtk/gtkinvisible.c b/gtk/gtkinvisible.c index 2d8bd65b74..dc349e990b 100644 --- a/gtk/gtkinvisible.c +++ b/gtk/gtkinvisible.c @@ -30,7 +30,7 @@ #include "gtkprivate.h" #include "gtkintl.h" -struct _GtkInvisiblePriv +struct _GtkInvisiblePrivate { GdkScreen *screen; gboolean has_user_ref_count; @@ -93,18 +93,18 @@ gtk_invisible_class_init (GtkInvisibleClass *class) GDK_TYPE_SCREEN, GTK_PARAM_READWRITE)); - g_type_class_add_private (class, sizeof (GtkInvisiblePriv)); + g_type_class_add_private (class, sizeof (GtkInvisiblePrivate)); } static void gtk_invisible_init (GtkInvisible *invisible) { - GtkInvisiblePriv *priv; + GtkInvisiblePrivate *priv; GdkColormap *colormap; invisible->priv = G_TYPE_INSTANCE_GET_PRIVATE (invisible, GTK_TYPE_INVISIBLE, - GtkInvisiblePriv); + GtkInvisiblePrivate); priv = invisible->priv; gtk_widget_set_has_window (GTK_WIDGET (invisible), TRUE); @@ -124,7 +124,7 @@ static void gtk_invisible_destroy (GtkObject *object) { GtkInvisible *invisible = GTK_INVISIBLE (object); - GtkInvisiblePriv *priv = invisible->priv; + GtkInvisiblePrivate *priv = invisible->priv; if (priv->has_user_ref_count) { @@ -180,7 +180,7 @@ void gtk_invisible_set_screen (GtkInvisible *invisible, GdkScreen *screen) { - GtkInvisiblePriv *priv; + GtkInvisiblePrivate *priv; GtkWidget *widget; GdkScreen *previous_screen; gboolean was_realized; @@ -232,6 +232,7 @@ static void gtk_invisible_realize (GtkWidget *widget) { GdkWindow *parent; + GdkWindow *window; GdkWindowAttr attributes; gint attributes_mask; @@ -252,11 +253,11 @@ gtk_invisible_realize (GtkWidget *widget) attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_NOREDIR; - widget->window = gdk_window_new (parent, &attributes, attributes_mask); - - gdk_window_set_user_data (widget->window, widget); - - widget->style = gtk_style_attach (widget->style, widget->window); + window = gdk_window_new (parent, &attributes, attributes_mask); + gtk_widget_set_window (widget, window); + gdk_window_set_user_data (window, widget); + + gtk_widget_style_attach (widget); } static void @@ -275,10 +276,10 @@ gtk_invisible_show (GtkWidget *widget) static void gtk_invisible_size_allocate (GtkWidget *widget, - GtkAllocation *allocation) + GtkAllocation *allocation) { - widget->allocation = *allocation; -} + gtk_widget_set_allocation (widget, allocation); +} static void @@ -307,7 +308,7 @@ gtk_invisible_get_property (GObject *object, GParamSpec *pspec) { GtkInvisible *invisible = GTK_INVISIBLE (object); - GtkInvisiblePriv *priv = invisible->priv; + GtkInvisiblePrivate *priv = invisible->priv; switch (prop_id) { diff --git a/gtk/gtkinvisible.h b/gtk/gtkinvisible.h index 9cda19d289..830974d888 100644 --- a/gtk/gtkinvisible.h +++ b/gtk/gtkinvisible.h @@ -43,16 +43,16 @@ G_BEGIN_DECLS #define GTK_INVISIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_INVISIBLE, GtkInvisibleClass)) -typedef struct _GtkInvisible GtkInvisible; -typedef struct _GtkInvisiblePriv GtkInvisiblePriv; -typedef struct _GtkInvisibleClass GtkInvisibleClass; +typedef struct _GtkInvisible GtkInvisible; +typedef struct _GtkInvisiblePrivate GtkInvisiblePrivate; +typedef struct _GtkInvisibleClass GtkInvisibleClass; struct _GtkInvisible { GtkWidget widget; /* <private> */ - GtkInvisiblePriv *priv; + GtkInvisiblePrivate *priv; }; struct _GtkInvisibleClass diff --git a/gtk/gtkitem.c b/gtk/gtkitem.c index ddcf571c7f..97d45f9bc3 100644 --- a/gtk/gtkitem.c +++ b/gtk/gtkitem.c @@ -121,15 +121,19 @@ gtk_item_toggle (GtkItem *item) static void gtk_item_realize (GtkWidget *widget) { + GtkAllocation allocation; + GdkWindow *window; GdkWindowAttr attributes; gint attributes_mask; gtk_widget_set_realized (widget, TRUE); - attributes.x = widget->allocation.x; - attributes.y = widget->allocation.y; - attributes.width = widget->allocation.width; - attributes.height = widget->allocation.height; + gtk_widget_get_allocation (widget, &allocation); + + attributes.x = allocation.x; + attributes.y = allocation.y; + attributes.width = allocation.width; + attributes.height = allocation.height; attributes.window_type = GDK_WINDOW_CHILD; attributes.wclass = GDK_INPUT_OUTPUT; attributes.visual = gtk_widget_get_visual (widget); @@ -143,12 +147,15 @@ gtk_item_realize (GtkWidget *widget) GDK_POINTER_MOTION_MASK); attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; - widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); - gdk_window_set_user_data (widget->window, widget); - widget->style = gtk_style_attach (widget->style, widget->window); - gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL); - gdk_window_set_back_pixmap (widget->window, NULL, TRUE); + window = gdk_window_new (gtk_widget_get_parent_window (widget), + &attributes, attributes_mask); + gtk_widget_set_window (widget, window); + gdk_window_set_user_data (window, widget); + + gtk_widget_style_attach (widget); + gtk_style_set_background (gtk_widget_get_style (widget), window, GTK_STATE_NORMAL); + gdk_window_set_back_pixmap (window, NULL, TRUE); } static gint @@ -158,7 +165,7 @@ gtk_item_enter (GtkWidget *widget, g_return_val_if_fail (GTK_IS_ITEM (widget), FALSE); g_return_val_if_fail (event != NULL, FALSE); - return gtk_widget_event (widget->parent, (GdkEvent*) event); + return gtk_widget_event (gtk_widget_get_parent (widget), (GdkEvent *) event); } static gint @@ -168,5 +175,5 @@ gtk_item_leave (GtkWidget *widget, g_return_val_if_fail (GTK_IS_ITEM (widget), FALSE); g_return_val_if_fail (event != NULL, FALSE); - return gtk_widget_event (widget->parent, (GdkEvent*) event); + return gtk_widget_event (gtk_widget_get_parent (widget), (GdkEvent*) event); } diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c index a6ddc3b5ca..6e6a0d2484 100644 --- a/gtk/gtklabel.c +++ b/gtk/gtklabel.c @@ -53,7 +53,7 @@ #include "gtkprivate.h" -struct _GtkLabelPriv +struct _GtkLabelPrivate { GtkLabelSelectionInfo *select_info; GtkWidget *mnemonic_widget; @@ -906,7 +906,7 @@ gtk_label_class_init (GtkLabelClass *class) TRUE, GTK_PARAM_READWRITE)); - g_type_class_add_private (class, sizeof (GtkLabelPriv)); + g_type_class_add_private (class, sizeof (GtkLabelPrivate)); } static void @@ -980,7 +980,7 @@ gtk_label_get_property (GObject *object, GParamSpec *pspec) { GtkLabel *label = GTK_LABEL (object); - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; switch (prop_id) { @@ -1061,11 +1061,11 @@ gtk_label_get_property (GObject *object, static void gtk_label_init (GtkLabel *label) { - GtkLabelPriv *priv; + GtkLabelPrivate *priv; label->priv = G_TYPE_INSTANCE_GET_PRIVATE (label, GTK_TYPE_LABEL, - GtkLabelPriv); + GtkLabelPrivate); priv = label->priv; gtk_widget_set_has_window (GTK_WIDGET (label), FALSE); @@ -1485,7 +1485,7 @@ gtk_label_mnemonic_activate (GtkWidget *widget, gboolean group_cycling) { GtkLabel *label = GTK_LABEL (widget); - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; GtkWidget *parent; if (priv->mnemonic_widget) @@ -1494,7 +1494,7 @@ gtk_label_mnemonic_activate (GtkWidget *widget, /* Try to find the widget to activate by traversing the * widget's ancestry. */ - parent = widget->parent; + parent = gtk_widget_get_parent (widget); if (GTK_IS_NOTEBOOK (parent)) return FALSE; @@ -1503,10 +1503,10 @@ gtk_label_mnemonic_activate (GtkWidget *widget, { if (gtk_widget_get_can_focus (parent) || (!group_cycling && GTK_WIDGET_GET_CLASS (parent)->activate_signal) || - GTK_IS_NOTEBOOK (parent->parent) || + GTK_IS_NOTEBOOK (gtk_widget_get_parent (parent)) || GTK_IS_MENU_ITEM (parent)) return gtk_widget_mnemonic_activate (parent, group_cycling); - parent = parent->parent; + parent = gtk_widget_get_parent (parent); } /* barf if there was nothing to activate */ @@ -1520,7 +1520,7 @@ static void gtk_label_setup_mnemonic (GtkLabel *label, guint last_key) { - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; GtkWidget *widget = GTK_WIDGET (label); GtkWidget *toplevel; GtkWidget *mnemonic_menu; @@ -1584,7 +1584,7 @@ gtk_label_hierarchy_changed (GtkWidget *widget, GtkWidget *old_toplevel) { GtkLabel *label = GTK_LABEL (widget); - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; gtk_label_setup_mnemonic (label, priv->mnemonic_keyval); } @@ -1632,7 +1632,7 @@ mnemonics_visible_apply (GtkWidget *widget, gboolean mnemonics_visible) { GtkLabel *label = GTK_LABEL (widget); - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; mnemonics_visible = mnemonics_visible != FALSE; @@ -1717,7 +1717,7 @@ label_mnemonic_widget_weak_notify (gpointer data, GObject *where_the_object_was) { GtkLabel *label = data; - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; priv->mnemonic_widget = NULL; g_object_notify (G_OBJECT (label), "mnemonic-widget"); @@ -1747,7 +1747,7 @@ void gtk_label_set_mnemonic_widget (GtkLabel *label, GtkWidget *widget) { - GtkLabelPriv *priv; + GtkLabelPrivate *priv; g_return_if_fail (GTK_IS_LABEL (label)); @@ -1815,7 +1815,7 @@ static void gtk_label_set_text_internal (GtkLabel *label, gchar *str) { - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; g_free (priv->text); @@ -1828,7 +1828,7 @@ static void gtk_label_set_label_internal (GtkLabel *label, gchar *str) { - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; g_free (priv->label); @@ -1841,7 +1841,7 @@ static void gtk_label_set_use_markup_internal (GtkLabel *label, gboolean val) { - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; val = val != FALSE; if (priv->use_markup != val) @@ -1856,7 +1856,7 @@ static void gtk_label_set_use_underline_internal (GtkLabel *label, gboolean val) { - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; val = val != FALSE; if (priv->use_underline != val) @@ -1870,7 +1870,7 @@ gtk_label_set_use_underline_internal (GtkLabel *label, static void gtk_label_compose_effective_attrs (GtkLabel *label) { - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; PangoAttrIterator *iter; PangoAttribute *attr; GSList *iter_attrs, *l; @@ -1905,7 +1905,7 @@ static void gtk_label_set_attributes_internal (GtkLabel *label, PangoAttrList *attrs) { - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; if (attrs) pango_attr_list_ref (attrs); @@ -1924,7 +1924,7 @@ gtk_label_set_attributes_internal (GtkLabel *label, static void gtk_label_recalculate (GtkLabel *label) { - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; guint keyval = priv->mnemonic_keyval; if (priv->use_markup) @@ -2095,7 +2095,7 @@ start_element_handler (GMarkupParseContext *context, gpointer user_data, GError **error) { - GtkLabelPriv *priv; + GtkLabelPrivate *priv; UriParserData *pdata = user_data; if (strcmp (element_name, "a") == 0) @@ -2347,7 +2347,7 @@ failed: static void gtk_label_ensure_has_tooltip (GtkLabel *label) { - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; GList *l; gboolean has_tooltip = FALSE; @@ -2369,7 +2369,7 @@ gtk_label_set_markup_internal (GtkLabel *label, const gchar *str, gboolean with_uline) { - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; gchar *text = NULL; GError *error = NULL; PangoAttrList *attrs = NULL; @@ -2477,7 +2477,7 @@ void gtk_label_set_markup (GtkLabel *label, const gchar *str) { - GtkLabelPriv *priv; + GtkLabelPrivate *priv; g_return_if_fail (GTK_IS_LABEL (label)); @@ -2511,7 +2511,7 @@ void gtk_label_set_markup_with_mnemonic (GtkLabel *label, const gchar *str) { - GtkLabelPriv *priv; + GtkLabelPrivate *priv; g_return_if_fail (GTK_IS_LABEL (label)); @@ -2551,7 +2551,7 @@ static PangoAttrList * gtk_label_pattern_to_attrs (GtkLabel *label, const gchar *pattern) { - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; const char *start; const char *p = priv->text; const char *q = pattern; @@ -2593,7 +2593,7 @@ gtk_label_set_pattern_internal (GtkLabel *label, const gchar *pattern, gboolean is_mnemonic) { - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; PangoAttrList *attrs; gboolean enable_mnemonics; gboolean auto_mnemonics; @@ -2629,7 +2629,7 @@ void gtk_label_set_pattern (GtkLabel *label, const gchar *pattern) { - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; g_return_if_fail (GTK_IS_LABEL (label)); @@ -2666,7 +2666,7 @@ void gtk_label_set_justify (GtkLabel *label, GtkJustification jtype) { - GtkLabelPriv *priv; + GtkLabelPrivate *priv; g_return_if_fail (GTK_IS_LABEL (label)); g_return_if_fail (jtype >= GTK_JUSTIFY_LEFT && jtype <= GTK_JUSTIFY_FILL); @@ -2715,7 +2715,7 @@ void gtk_label_set_ellipsize (GtkLabel *label, PangoEllipsizeMode mode) { - GtkLabelPriv *priv; + GtkLabelPrivate *priv; g_return_if_fail (GTK_IS_LABEL (label)); g_return_if_fail (mode >= PANGO_ELLIPSIZE_NONE && mode <= PANGO_ELLIPSIZE_END); @@ -2765,7 +2765,7 @@ void gtk_label_set_width_chars (GtkLabel *label, gint n_chars) { - GtkLabelPriv *priv; + GtkLabelPrivate *priv; g_return_if_fail (GTK_IS_LABEL (label)); @@ -2812,7 +2812,7 @@ void gtk_label_set_max_width_chars (GtkLabel *label, gint n_chars) { - GtkLabelPriv *priv; + GtkLabelPrivate *priv; g_return_if_fail (GTK_IS_LABEL (label)); @@ -2866,7 +2866,7 @@ void gtk_label_set_line_wrap (GtkLabel *label, gboolean wrap) { - GtkLabelPriv *priv; + GtkLabelPrivate *priv; g_return_if_fail (GTK_IS_LABEL (label)); @@ -2916,7 +2916,7 @@ void gtk_label_set_line_wrap_mode (GtkLabel *label, PangoWrapMode wrap_mode) { - GtkLabelPriv *priv; + GtkLabelPrivate *priv; g_return_if_fail (GTK_IS_LABEL (label)); @@ -2963,7 +2963,7 @@ static void gtk_label_finalize (GObject *object) { GtkLabel *label = GTK_LABEL (object); - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; g_free (priv->label); g_free (priv->text); @@ -2986,7 +2986,7 @@ gtk_label_finalize (GObject *object) static void gtk_label_clear_layout (GtkLabel *label) { - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; if (priv->layout) { @@ -3004,7 +3004,7 @@ get_label_width (GtkLabel *label, gint *natural) { GtkWidgetAuxInfo *aux_info; - GtkLabelPriv *priv; + GtkLabelPrivate *priv; PangoLayout *layout; PangoContext *context; PangoFontMetrics *metrics; @@ -3016,7 +3016,8 @@ get_label_width (GtkLabel *label, layout = pango_layout_copy (priv->layout); context = pango_layout_get_context (layout); - metrics = pango_context_get_metrics (context, GTK_WIDGET (label)->style->font_desc, + metrics = pango_context_get_metrics (context, + gtk_widget_get_style (GTK_WIDGET (label))->font_desc, pango_context_get_language (context)); char_width = pango_font_metrics_get_approximate_char_width (metrics); @@ -3110,7 +3111,7 @@ get_label_width (GtkLabel *label, static void gtk_label_invalidate_wrap_width (GtkLabel *label) { - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; priv->wrap_width = -1; } @@ -3118,7 +3119,7 @@ gtk_label_invalidate_wrap_width (GtkLabel *label) static gint get_label_wrap_width (GtkLabel *label) { - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; if (priv->wrap_width < 0) { @@ -3132,7 +3133,8 @@ get_label_wrap_width (GtkLabel *label) layout = pango_layout_copy (priv->layout); context = pango_layout_get_context (layout); - metrics = pango_context_get_metrics (context, GTK_WIDGET (label)->style->font_desc, + metrics = pango_context_get_metrics (context, + gtk_widget_get_style (GTK_WIDGET (label))->font_desc, pango_context_get_language (context)); char_width = pango_font_metrics_get_approximate_char_width (metrics); @@ -3165,7 +3167,7 @@ get_label_wrap_width (GtkLabel *label) static void gtk_label_ensure_layout (GtkLabel *label, gboolean guess_wrap_width) { - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; GtkWidget *widget; PangoRectangle logical_rect; gboolean rtl; @@ -3176,6 +3178,7 @@ gtk_label_ensure_layout (GtkLabel *label, gboolean guess_wrap_width) if (!priv->layout) { + GtkAllocation allocation; PangoAlignment align = PANGO_ALIGN_LEFT; /* Quiet gcc */ gdouble angle = gtk_label_get_angle (label); @@ -3231,9 +3234,10 @@ gtk_label_ensure_layout (GtkLabel *label, gboolean guess_wrap_width) pango_layout_set_ellipsize (priv->layout, priv->ellipsize); pango_layout_set_single_paragraph_mode (priv->layout, priv->single_line_mode); + gtk_widget_get_allocation (widget, &allocation); + if (priv->ellipsize) - pango_layout_set_width (priv->layout, - widget->allocation.width * PANGO_SCALE); + pango_layout_set_width (priv->layout, allocation.width * PANGO_SCALE); else if (priv->wrap) { GtkWidgetAuxInfo *aux_info = _gtk_widget_get_aux_info (widget, FALSE); @@ -3248,17 +3252,16 @@ gtk_label_ensure_layout (GtkLabel *label, gboolean guess_wrap_width) if (aux_width > 0) pango_layout_set_width (priv->layout, aux_width * PANGO_SCALE); - else if (guess_wrap_width == FALSE && - widget->allocation.width > 1 && widget->allocation.height > 1) + else if (guess_wrap_width == FALSE && allocation.width > 1 && allocation.height > 1) { PangoRectangle rect; gint xpad, ypad, natural_width; gtk_misc_get_padding (GTK_MISC (label), &xpad, &ypad); if (angle == 90 || angle == 270) - width = widget->allocation.height - ypad * 2; + width = allocation.height - ypad * 2; else - width = widget->allocation.width - xpad * 2; + width = allocation.width - xpad * 2; /* dont set a wrap width wider than the label's natural width * incase we're allocated more space than needed */ @@ -3340,7 +3343,7 @@ get_single_line_height (GtkWidget *widget, gint ascent, descent; context = pango_layout_get_context (layout); - metrics = pango_context_get_metrics (context, widget->style->font_desc, + metrics = pango_context_get_metrics (context, gtk_widget_get_style (widget)->font_desc, pango_context_get_language (context)); ascent = pango_font_metrics_get_ascent (metrics); @@ -3379,7 +3382,7 @@ get_size_for_allocation (GtkLabel *label, gint *minimum_size, gint *natural_size) { - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; PangoLayout *layout; GtkWidgetAuxInfo *aux_info = _gtk_widget_get_aux_info (GTK_WIDGET (label), FALSE); @@ -3422,7 +3425,7 @@ gtk_label_get_size (GtkSizeRequest *widget, gint *natural_size) { GtkLabel *label = GTK_LABEL (widget); - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; PangoRectangle required_rect; PangoRectangle natural_rect; gint xpad, ypad; @@ -3586,7 +3589,7 @@ gtk_label_get_width_for_height (GtkSizeRequest *widget, gint *natural_width) { GtkLabel *label = GTK_LABEL (widget); - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; if (priv->wrap && (priv->angle == 90 || priv->angle == 270)) { @@ -3618,7 +3621,7 @@ gtk_label_get_height_for_width (GtkSizeRequest *widget, gint *natural_height) { GtkLabel *label = GTK_LABEL (widget); - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; if (priv->wrap && (priv->angle == 0 || priv->angle == 180 || priv->angle == 360)) { @@ -3648,7 +3651,7 @@ gtk_label_size_allocate (GtkWidget *widget, GtkAllocation *allocation) { GtkLabel *label = GTK_LABEL (widget); - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; GTK_WIDGET_CLASS (gtk_label_parent_class)->size_allocate (widget, allocation); @@ -3750,7 +3753,7 @@ gtk_label_size_allocate (GtkWidget *widget, static void gtk_label_update_cursor (GtkLabel *label) { - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; GtkWidget *widget; if (!priv->select_info) @@ -3789,7 +3792,7 @@ gtk_label_state_changed (GtkWidget *widget, GtkStateType prev_state) { GtkLabel *label = GTK_LABEL (widget); - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; if (priv->select_info) { @@ -3817,7 +3820,7 @@ gtk_label_direction_changed (GtkWidget *widget, GtkTextDirection previous_dir) { GtkLabel *label = GTK_LABEL (widget); - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; if (priv->layout) pango_layout_context_changed (priv->layout); @@ -3830,9 +3833,10 @@ get_layout_location (GtkLabel *label, gint *xp, gint *yp) { + GtkAllocation allocation; GtkMisc *misc; GtkWidget *widget; - GtkLabelPriv *priv; + GtkLabelPrivate *priv; gint req_width, x, y; gint req_height; gint xpad, ypad; @@ -3866,13 +3870,14 @@ get_layout_location (GtkLabel *label, req_width += 2 * xpad; req_height += 2 * ypad; - x = floor (widget->allocation.x + xpad + - xalign * (widget->allocation.width - req_width)); + gtk_widget_get_allocation (widget, &allocation); + + x = floor (allocation.x + xpad + xalign * (allocation.width - req_width)); if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR) - x = MAX (x, widget->allocation.x + xpad); + x = MAX (x, allocation.x + xpad); else - x = MIN (x, widget->allocation.x + widget->allocation.width - xpad); + x = MIN (x, allocation.x + allocation.width - xpad); /* bgo#315462 - For single-line labels, *do* align the requisition with @@ -3889,15 +3894,9 @@ get_layout_location (GtkLabel *label, * middle". You want to read the first line, at least, to get some context. */ if (pango_layout_get_line_count (priv->layout) == 1) - { - y = floor (widget->allocation.y + ypad - + (widget->allocation.height - req_height) * yalign); - } + y = floor (allocation.y + ypad + (allocation.height - req_height) * yalign); else - { - y = floor (widget->allocation.y + ypad - + MAX ((widget->allocation.height - req_height) * yalign, 0)); - } + y = floor (allocation.y + ypad + MAX ((allocation.height - req_height) * yalign, 0)); if (xp) *xp = x; @@ -3914,6 +3913,7 @@ draw_insertion_cursor (GtkLabel *label, gboolean draw_arrow) { GtkWidget *widget = GTK_WIDGET (label); + GtkAllocation allocation; GtkTextDirection text_dir; if (direction == PANGO_DIRECTION_LTR) @@ -3921,15 +3921,16 @@ draw_insertion_cursor (GtkLabel *label, else text_dir = GTK_TEXT_DIR_RTL; - gtk_draw_insertion_cursor (widget, widget->window, &(widget->allocation), - cursor_location, + gtk_widget_get_allocation (widget, &allocation); + gtk_draw_insertion_cursor (widget, gtk_widget_get_window (widget), + &allocation, cursor_location, is_primary, text_dir, draw_arrow); } static PangoDirection get_cursor_direction (GtkLabel *label) { - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; GSList *l; g_assert (priv->select_info); @@ -3957,7 +3958,7 @@ get_cursor_direction (GtkLabel *label) static void gtk_label_draw_cursor (GtkLabel *label, gint xoffset, gint yoffset) { - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; GtkWidget *widget; if (priv->select_info == NULL) @@ -4036,7 +4037,7 @@ gtk_label_draw_cursor (GtkLabel *label, gint xoffset, gint yoffset) static GtkLabelLink * gtk_label_get_focus_link (GtkLabel *label) { - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; GtkLabelSelectionInfo *info = priv->select_info; GList *l; @@ -4062,8 +4063,10 @@ gtk_label_expose (GtkWidget *widget, GdkEventExpose *event) { GtkLabel *label = GTK_LABEL (widget); - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; GtkLabelSelectionInfo *info = priv->select_info; + GtkStyle *style; + GdkWindow *window; gint x, y; gtk_label_ensure_layout (label, FALSE); @@ -4073,8 +4076,11 @@ gtk_label_expose (GtkWidget *widget, { get_layout_location (label, &x, &y); - gtk_paint_layout (widget->style, - widget->window, + style = gtk_widget_get_style (widget); + window = gtk_widget_get_window (widget); + + gtk_paint_layout (style, + window, gtk_widget_get_state (widget), FALSE, &event->area, @@ -4120,10 +4126,10 @@ gtk_label_expose (GtkWidget *widget, if (!gtk_widget_has_focus (widget)) state = GTK_STATE_ACTIVE; - gdk_cairo_set_source_color (cr, &widget->style->base[state]); + gdk_cairo_set_source_color (cr, &style->base[state]); cairo_paint (cr); - gdk_cairo_set_source_color (cr, &widget->style->text[state]); + gdk_cairo_set_source_color (cr, &style->text[state]); cairo_move_to (cr, x, y); _gtk_pango_fill_layout (cr, priv->layout); @@ -4175,9 +4181,9 @@ gtk_label_expose (GtkWidget *widget, else text_color = link_color; if (info->link_clicked) - base_color = &widget->style->base[GTK_STATE_ACTIVE]; + base_color = &style->base[GTK_STATE_ACTIVE]; else - base_color = &widget->style->base[GTK_STATE_PRELIGHT]; + base_color = &style->base[GTK_STATE_PRELIGHT]; gdk_cairo_set_source_color (cr, base_color); cairo_paint (cr); @@ -4203,7 +4209,7 @@ gtk_label_expose (GtkWidget *widget, 1); cairo_region_get_extents (clip, &rect); - gtk_paint_focus (widget->style, widget->window, gtk_widget_get_state (widget), + gtk_paint_focus (style, window, gtk_widget_get_state (widget), &event->area, widget, "label", rect.x, rect.y, rect.width, rect.height); @@ -4295,7 +4301,7 @@ static void gtk_label_set_uline_text_internal (GtkLabel *label, const gchar *str) { - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; guint accel_key = GDK_VoidSymbol; gchar *new_str; gchar *pattern; @@ -4349,7 +4355,7 @@ static void gtk_label_realize (GtkWidget *widget) { GtkLabel *label = GTK_LABEL (widget); - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; GTK_WIDGET_CLASS (gtk_label_parent_class)->realize (widget); @@ -4361,7 +4367,7 @@ static void gtk_label_unrealize (GtkWidget *widget) { GtkLabel *label = GTK_LABEL (widget); - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; if (priv->select_info) gtk_label_destroy_window (label); @@ -4373,7 +4379,7 @@ static void gtk_label_map (GtkWidget *widget) { GtkLabel *label = GTK_LABEL (widget); - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; GTK_WIDGET_CLASS (gtk_label_parent_class)->map (widget); @@ -4385,7 +4391,7 @@ static void gtk_label_unmap (GtkWidget *widget) { GtkLabel *label = GTK_LABEL (widget); - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; if (priv->select_info) gdk_window_hide (priv->select_info->window); @@ -4398,6 +4404,7 @@ window_to_layout_coords (GtkLabel *label, gint *x, gint *y) { + GtkAllocation allocation; gint lx, ly; GtkWidget *widget; @@ -4405,16 +4412,18 @@ window_to_layout_coords (GtkLabel *label, /* get layout location in widget->window coords */ get_layout_location (label, &lx, &ly); - + + gtk_widget_get_allocation (widget, &allocation); + if (x) { - *x += widget->allocation.x; /* go to widget->window */ + *x += allocation.x; /* go to widget->window */ *x -= lx; /* go to layout */ } if (y) { - *y += widget->allocation.y; /* go to widget->window */ + *y += allocation.y; /* go to widget->window */ *y -= ly; /* go to layout */ } } @@ -4453,7 +4462,7 @@ get_layout_index (GtkLabel *label, gint y, gint *index) { - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; gint trailing = 0; const gchar *cluster; const gchar *cluster_end; @@ -4488,7 +4497,7 @@ get_layout_index (GtkLabel *label, static void gtk_label_select_word (GtkLabel *label) { - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; gint min, max; gint start_index = gtk_label_move_backward_word (label, priv->select_info->selection_end); @@ -4509,7 +4518,7 @@ static void gtk_label_grab_focus (GtkWidget *widget) { GtkLabel *label = GTK_LABEL (widget); - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; gboolean select_on_focus; GtkLabelLink *link; @@ -4544,7 +4553,7 @@ gtk_label_focus (GtkWidget *widget, GtkDirectionType direction) { GtkLabel *label = GTK_LABEL (widget); - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; GtkLabelSelectionInfo *info = priv->select_info; GtkLabelLink *focus_link; GList *l; @@ -4654,7 +4663,7 @@ gtk_label_button_press (GtkWidget *widget, GdkEventButton *event) { GtkLabel *label = GTK_LABEL (widget); - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; GtkLabelSelectionInfo *info = priv->select_info; gint index = 0; gint min, max; @@ -4761,7 +4770,7 @@ gtk_label_button_release (GtkWidget *widget, { GtkLabel *label = GTK_LABEL (widget); - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; GtkLabelSelectionInfo *info = priv->select_info; gint index; @@ -4800,7 +4809,7 @@ gtk_label_button_release (GtkWidget *widget, static void connect_mnemonics_visible_notify (GtkLabel *label) { - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; GtkWidget *toplevel; gboolean connected; @@ -4835,7 +4844,7 @@ drag_begin_cb (GtkWidget *widget, gpointer data) { GtkLabel *label = GTK_LABEL (widget); - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; GdkPixmap *pixmap = NULL; g_signal_handlers_disconnect_by_func (widget, drag_begin_cb, NULL); @@ -4883,7 +4892,7 @@ gtk_label_motion (GtkWidget *widget, GdkEventMotion *event) { GtkLabel *label = GTK_LABEL (widget); - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; GtkLabelSelectionInfo *info = priv->select_info; gint index; @@ -5019,7 +5028,7 @@ gtk_label_leave_notify (GtkWidget *widget, GdkEventCrossing *event) { GtkLabel *label = GTK_LABEL (widget); - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; if (priv->select_info) { @@ -5037,7 +5046,8 @@ gtk_label_leave_notify (GtkWidget *widget, static void gtk_label_create_window (GtkLabel *label) { - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; + GtkAllocation allocation; GtkWidget *widget; GdkWindowAttr attributes; gint attributes_mask; @@ -5049,10 +5059,12 @@ gtk_label_create_window (GtkLabel *label) if (priv->select_info->window) return; - attributes.x = widget->allocation.x; - attributes.y = widget->allocation.y; - attributes.width = widget->allocation.width; - attributes.height = widget->allocation.height; + gtk_widget_get_allocation (widget, &allocation); + + attributes.x = allocation.x; + attributes.y = allocation.y; + attributes.width = allocation.width; + attributes.height = allocation.height; attributes.window_type = GDK_WINDOW_CHILD; attributes.wclass = GDK_INPUT_ONLY; attributes.override_redirect = TRUE; @@ -5072,7 +5084,7 @@ gtk_label_create_window (GtkLabel *label) } - priv->select_info->window = gdk_window_new (widget->window, + priv->select_info->window = gdk_window_new (gtk_widget_get_window (widget), &attributes, attributes_mask); gdk_window_set_user_data (priv->select_info->window, widget); @@ -5083,7 +5095,7 @@ gtk_label_create_window (GtkLabel *label) static void gtk_label_destroy_window (GtkLabel *label) { - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; g_assert (priv->select_info); @@ -5098,7 +5110,7 @@ gtk_label_destroy_window (GtkLabel *label) static void gtk_label_ensure_select_info (GtkLabel *label) { - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; if (priv->select_info == NULL) { @@ -5117,7 +5129,7 @@ gtk_label_ensure_select_info (GtkLabel *label) static void gtk_label_clear_select_info (GtkLabel *label) { - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; if (priv->select_info == NULL) return; @@ -5145,7 +5157,7 @@ void gtk_label_set_selectable (GtkLabel *label, gboolean setting) { - GtkLabelPriv *priv; + GtkLabelPrivate *priv; gboolean old_setting; g_return_if_fail (GTK_IS_LABEL (label)); @@ -5195,7 +5207,7 @@ gtk_label_set_selectable (GtkLabel *label, gboolean gtk_label_get_selectable (GtkLabel *label) { - GtkLabelPriv *priv; + GtkLabelPrivate *priv; g_return_val_if_fail (GTK_IS_LABEL (label), FALSE); @@ -5221,7 +5233,7 @@ void gtk_label_set_angle (GtkLabel *label, gdouble angle) { - GtkLabelPriv *priv; + GtkLabelPrivate *priv; g_return_if_fail (GTK_IS_LABEL (label)); @@ -5268,7 +5280,7 @@ static void gtk_label_set_selection_text (GtkLabel *label, GtkSelectionData *selection_data) { - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; if ((priv->select_info->selection_anchor != priv->select_info->selection_end) && @@ -5320,7 +5332,7 @@ clear_text_callback (GtkClipboard *clipboard, gpointer user_data_or_owner) { GtkLabel *label; - GtkLabelPriv *priv; + GtkLabelPrivate *priv; label = GTK_LABEL (user_data_or_owner); priv = label->priv; @@ -5338,7 +5350,7 @@ gtk_label_select_region_index (GtkLabel *label, gint anchor_index, gint end_index) { - GtkLabelPriv *priv; + GtkLabelPrivate *priv; g_return_if_fail (GTK_IS_LABEL (label)); @@ -5408,7 +5420,7 @@ gtk_label_select_region (GtkLabel *label, gint start_offset, gint end_offset) { - GtkLabelPriv *priv; + GtkLabelPrivate *priv; g_return_if_fail (GTK_IS_LABEL (label)); @@ -5444,7 +5456,7 @@ gtk_label_get_selection_bounds (GtkLabel *label, gint *start, gint *end) { - GtkLabelPriv *priv; + GtkLabelPrivate *priv; g_return_val_if_fail (GTK_IS_LABEL (label), FALSE); @@ -5515,7 +5527,7 @@ gtk_label_get_selection_bounds (GtkLabel *label, PangoLayout* gtk_label_get_layout (GtkLabel *label) { - GtkLabelPriv *priv; + GtkLabelPrivate *priv; g_return_val_if_fail (GTK_IS_LABEL (label), NULL); @@ -5639,7 +5651,7 @@ void gtk_label_set_single_line_mode (GtkLabel *label, gboolean single_line_mode) { - GtkLabelPriv *priv; + GtkLabelPrivate *priv; g_return_if_fail (GTK_IS_LABEL (label)); @@ -5687,7 +5699,7 @@ get_better_cursor (GtkLabel *label, gint *x, gint *y) { - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; GdkKeymap *keymap = gdk_keymap_get_for_display (gtk_widget_get_display (GTK_WIDGET (label))); PangoDirection keymap_direction = gdk_keymap_get_direction (keymap); PangoDirection cursor_direction = get_cursor_direction (label); @@ -5729,7 +5741,7 @@ gtk_label_move_logically (GtkLabel *label, gint start, gint count) { - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; gint offset = g_utf8_pointer_to_offset (priv->text, priv->text + start); @@ -5773,7 +5785,7 @@ gtk_label_move_visually (GtkLabel *label, gint start, gint count) { - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; gint index; index = start; @@ -5827,7 +5839,7 @@ static gint gtk_label_move_forward_word (GtkLabel *label, gint start) { - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; gint new_pos = g_utf8_pointer_to_offset (priv->text, priv->text + start); gint length; @@ -5858,7 +5870,7 @@ static gint gtk_label_move_backward_word (GtkLabel *label, gint start) { - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; gint new_pos = g_utf8_pointer_to_offset (priv->text, priv->text + start); @@ -5889,7 +5901,7 @@ gtk_label_move_cursor (GtkLabel *label, gint count, gboolean extend_selection) { - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; gint old_pos; gint new_pos; @@ -6015,7 +6027,7 @@ gtk_label_move_cursor (GtkLabel *label, static void gtk_label_copy_clipboard (GtkLabel *label) { - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; if (priv->text && priv->select_info) { @@ -6054,7 +6066,7 @@ gtk_label_copy_clipboard (GtkLabel *label) static void gtk_label_select_all (GtkLabel *label) { - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; gtk_label_select_region_index (label, 0, strlen (priv->text)); } @@ -6093,7 +6105,7 @@ popup_menu_detach (GtkWidget *attach_widget, GtkMenu *menu) { GtkLabel *label = GTK_LABEL (attach_widget); - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; if (priv->select_info) priv->select_info->popup_menu = NULL; @@ -6108,6 +6120,7 @@ popup_position_func (GtkMenu *menu, { GtkLabel *label; GtkWidget *widget; + GtkAllocation allocation; GtkRequisition req; GdkScreen *screen; @@ -6117,15 +6130,19 @@ popup_position_func (GtkMenu *menu, g_return_if_fail (gtk_widget_get_realized (widget)); screen = gtk_widget_get_screen (widget); - gdk_window_get_origin (widget->window, x, y); + gdk_window_get_origin (gtk_widget_get_window (widget), x, y); + + gtk_widget_get_allocation (widget, &allocation); - *x += widget->allocation.x; - *y += widget->allocation.y; + *x += allocation.x; + *y += allocation.y; gtk_widget_size_request (GTK_WIDGET (menu), &req); - *x += widget->allocation.width / 2; - *y += widget->allocation.height; + gtk_widget_get_allocation (widget, &allocation); + + *x += allocation.width / 2; + *y += allocation.height; *x = CLAMP (*x, 0, MAX (0, gdk_screen_get_width (screen) - req.width)); *y = CLAMP (*y, 0, MAX (0, gdk_screen_get_height (screen) - req.height)); @@ -6170,7 +6187,7 @@ static void gtk_label_do_popup (GtkLabel *label, GdkEventButton *event) { - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; GtkWidget *menuitem; GtkWidget *menu; GtkWidget *image; @@ -6266,7 +6283,7 @@ gtk_label_do_popup (GtkLabel *label, static void gtk_label_clear_links (GtkLabel *label) { - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; if (!priv->select_info) return; @@ -6280,7 +6297,7 @@ gtk_label_clear_links (GtkLabel *label) static void gtk_label_rescan_links (GtkLabel *label) { - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; PangoLayout *layout = priv->layout; PangoAttrList *attlist; PangoAttrIterator *iter; @@ -6353,7 +6370,7 @@ static void emit_activate_link (GtkLabel *label, GtkLabelLink *link) { - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; gboolean handled; g_signal_emit (label, signals[ACTIVATE_LINK], 0, link->uri, &handled); @@ -6381,17 +6398,22 @@ gtk_label_activate_current_link (GtkLabel *label) { GtkWidget *toplevel; GtkWindow *window; + GtkWidget *default_widget, *focus_widget; toplevel = gtk_widget_get_toplevel (widget); if (GTK_IS_WINDOW (toplevel)) { window = GTK_WINDOW (toplevel); - if (window && - window->default_widget != widget && - !(widget == window->focus_widget && - (!window->default_widget || !gtk_widget_is_sensitive (window->default_widget)))) - gtk_window_activate_default (window); + if (window) + { + default_widget = gtk_window_get_default_widget (window); + focus_widget = gtk_window_get_focus (window); + + if (default_widget != widget && + !(widget == focus_widget && (!default_widget || !gtk_widget_is_sensitive (default_widget)))) + gtk_window_activate_default (window); + } } } } @@ -6399,7 +6421,7 @@ gtk_label_activate_current_link (GtkLabel *label) static GtkLabelLink * gtk_label_get_current_link (GtkLabel *label) { - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; GtkLabelLink *link; if (!priv->select_info) @@ -6459,7 +6481,7 @@ void gtk_label_set_track_visited_links (GtkLabel *label, gboolean track_links) { - GtkLabelPriv *priv; + GtkLabelPrivate *priv; g_return_if_fail (GTK_IS_LABEL (label)); @@ -6505,7 +6527,7 @@ gtk_label_query_tooltip (GtkWidget *widget, GtkTooltip *tooltip) { GtkLabel *label = GTK_LABEL (widget); - GtkLabelPriv *priv = label->priv; + GtkLabelPrivate *priv = label->priv; GtkLabelSelectionInfo *info = priv->select_info; gint index = -1; GList *l; diff --git a/gtk/gtklabel.h b/gtk/gtklabel.h index 3fa3b651bf..9e76ebd1ea 100644 --- a/gtk/gtklabel.h +++ b/gtk/gtklabel.h @@ -46,9 +46,9 @@ G_BEGIN_DECLS #define GTK_LABEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_LABEL, GtkLabelClass)) -typedef struct _GtkLabel GtkLabel; -typedef struct _GtkLabelPriv GtkLabelPriv; -typedef struct _GtkLabelClass GtkLabelClass; +typedef struct _GtkLabel GtkLabel; +typedef struct _GtkLabelPrivate GtkLabelPrivate; +typedef struct _GtkLabelClass GtkLabelClass; typedef struct _GtkLabelSelectionInfo GtkLabelSelectionInfo; @@ -57,7 +57,7 @@ struct _GtkLabel GtkMisc misc; /*< private >*/ - GtkLabelPriv *priv; + GtkLabelPrivate *priv; }; struct _GtkLabelClass diff --git a/gtk/gtklayout.c b/gtk/gtklayout.c index fb87768701..fab1875673 100644 --- a/gtk/gtklayout.c +++ b/gtk/gtklayout.c @@ -39,7 +39,7 @@ typedef struct _GtkLayoutChild GtkLayoutChild; -struct _GtkLayoutPriv +struct _GtkLayoutPrivate { /* Properties */ guint width; @@ -233,7 +233,7 @@ gtk_layout_set_adjustments (GtkLayout *layout, GtkAdjustment *hadj, GtkAdjustment *vadj) { - GtkLayoutPriv *priv = layout->priv; + GtkLayoutPrivate *priv = layout->priv; gboolean need_adjust = FALSE; if (hadj) @@ -295,7 +295,7 @@ static void gtk_layout_finalize (GObject *object) { GtkLayout *layout = GTK_LAYOUT (object); - GtkLayoutPriv *priv = layout->priv; + GtkLayoutPrivate *priv = layout->priv; g_object_unref (priv->hadjustment); g_object_unref (priv->vadjustment); @@ -317,7 +317,7 @@ void gtk_layout_set_hadjustment (GtkLayout *layout, GtkAdjustment *adjustment) { - GtkLayoutPriv *priv; + GtkLayoutPrivate *priv; g_return_if_fail (GTK_IS_LAYOUT (layout)); @@ -341,7 +341,7 @@ void gtk_layout_set_vadjustment (GtkLayout *layout, GtkAdjustment *adjustment) { - GtkLayoutPriv *priv; + GtkLayoutPrivate *priv; g_return_if_fail (GTK_IS_LAYOUT (layout)); @@ -355,7 +355,7 @@ static GtkLayoutChild* get_child (GtkLayout *layout, GtkWidget *widget) { - GtkLayoutPriv *priv = layout->priv; + GtkLayoutPrivate *priv = layout->priv; GList *children; children = priv->children; @@ -390,7 +390,7 @@ gtk_layout_put (GtkLayout *layout, gint x, gint y) { - GtkLayoutPriv *priv; + GtkLayoutPrivate *priv; GtkLayoutChild *child; g_return_if_fail (GTK_IS_LAYOUT (layout)); @@ -465,7 +465,7 @@ gtk_layout_move (GtkLayout *layout, { g_return_if_fail (GTK_IS_LAYOUT (layout)); g_return_if_fail (GTK_IS_WIDGET (child_widget)); - g_return_if_fail (child_widget->parent == GTK_WIDGET (layout)); + g_return_if_fail (gtk_widget_get_parent (child_widget) == GTK_WIDGET (layout)); gtk_layout_move_internal (layout, child_widget, TRUE, x, TRUE, y); } @@ -512,7 +512,7 @@ gtk_layout_set_size (GtkLayout *layout, guint width, guint height) { - GtkLayoutPriv *priv; + GtkLayoutPrivate *priv; GtkWidget *widget; g_return_if_fail (GTK_IS_LAYOUT (layout)); @@ -540,8 +540,11 @@ gtk_layout_set_size (GtkLayout *layout, if (gtk_widget_get_realized (widget)) { - width = MAX (width, widget->allocation.width); - height = MAX (height, widget->allocation.height); + GtkAllocation allocation; + + gtk_widget_get_allocation (widget, &allocation); + width = MAX (width, allocation.width); + height = MAX (height, allocation.height); gdk_window_resize (priv->bin_window, width, height); } } @@ -561,7 +564,7 @@ gtk_layout_get_size (GtkLayout *layout, guint *width, guint *height) { - GtkLayoutPriv *priv; + GtkLayoutPrivate *priv; g_return_if_fail (GTK_IS_LAYOUT (layout)); @@ -682,7 +685,7 @@ gtk_layout_class_init (GtkLayoutClass *class) GTK_TYPE_ADJUSTMENT, GTK_TYPE_ADJUSTMENT); - g_type_class_add_private (class, sizeof (GtkLayoutPriv)); + g_type_class_add_private (class, sizeof (GtkLayoutPrivate)); } static void @@ -692,7 +695,7 @@ gtk_layout_get_property (GObject *object, GParamSpec *pspec) { GtkLayout *layout = GTK_LAYOUT (object); - GtkLayoutPriv *priv = layout->priv; + GtkLayoutPrivate *priv = layout->priv; switch (prop_id) { @@ -721,7 +724,7 @@ gtk_layout_set_property (GObject *object, GParamSpec *pspec) { GtkLayout *layout = GTK_LAYOUT (object); - GtkLayoutPriv *priv = layout->priv; + GtkLayoutPrivate *priv = layout->priv; switch (prop_id) { @@ -802,11 +805,11 @@ gtk_layout_get_child_property (GtkContainer *container, static void gtk_layout_init (GtkLayout *layout) { - GtkLayoutPriv *priv; + GtkLayoutPrivate *priv; layout->priv = G_TYPE_INSTANCE_GET_PRIVATE (layout, GTK_TYPE_LAYOUT, - GtkLayoutPriv); + GtkLayoutPrivate); priv = layout->priv; priv->children = NULL; @@ -831,7 +834,7 @@ gtk_layout_constructor (GType type, guint n_properties, GObjectConstructParam *properties) { - GtkLayoutPriv *priv; + GtkLayoutPrivate *priv; GtkLayout *layout; GObject *object; GtkAdjustment *hadj, *vadj; @@ -859,18 +862,22 @@ static void gtk_layout_realize (GtkWidget *widget) { GtkLayout *layout = GTK_LAYOUT (widget); - GtkLayoutPriv *priv = layout->priv; - GList *tmp_list; + GtkLayoutPrivate *priv = layout->priv; + GtkAllocation allocation; + GdkWindow *window; GdkWindowAttr attributes; + GList *tmp_list; gint attributes_mask; gtk_widget_set_realized (widget, TRUE); + gtk_widget_get_allocation (widget, &allocation); + attributes.window_type = GDK_WINDOW_CHILD; - attributes.x = widget->allocation.x; - attributes.y = widget->allocation.y; - attributes.width = widget->allocation.width; - attributes.height = widget->allocation.height; + attributes.x = allocation.x; + attributes.y = allocation.y; + attributes.width = allocation.width; + attributes.height = allocation.height; attributes.wclass = GDK_INPUT_OUTPUT; attributes.visual = gtk_widget_get_visual (widget); attributes.colormap = gtk_widget_get_colormap (widget); @@ -878,24 +885,27 @@ gtk_layout_realize (GtkWidget *widget) attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; - widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), - &attributes, attributes_mask); - gdk_window_set_back_pixmap (widget->window, NULL, FALSE); - gdk_window_set_user_data (widget->window, widget); + window = gdk_window_new (gtk_widget_get_parent_window (widget), + &attributes, attributes_mask); + gtk_widget_set_window (widget, window); + gdk_window_set_back_pixmap (window, NULL, FALSE); + gdk_window_set_user_data (window, widget); + + gtk_widget_get_allocation (widget, &allocation); attributes.x = - priv->hadjustment->value, attributes.y = - priv->vadjustment->value; - attributes.width = MAX (priv->width, widget->allocation.width); - attributes.height = MAX (priv->height, widget->allocation.height); + attributes.width = MAX (priv->width, allocation.width); + attributes.height = MAX (priv->height, allocation.height); attributes.event_mask = GDK_EXPOSURE_MASK | GDK_SCROLL_MASK | gtk_widget_get_events (widget); - priv->bin_window = gdk_window_new (widget->window, - &attributes, attributes_mask); + priv->bin_window = gdk_window_new (window, + &attributes, attributes_mask); gdk_window_set_user_data (priv->bin_window, widget); - widget->style = gtk_style_attach (widget->style, widget->window); - gtk_style_set_background (widget->style, priv->bin_window, GTK_STATE_NORMAL); + gtk_widget_style_attach (widget); + gtk_style_set_background (gtk_widget_get_style (widget), priv->bin_window, GTK_STATE_NORMAL); tmp_list = priv->children; while (tmp_list) @@ -911,14 +921,14 @@ static void gtk_layout_style_set (GtkWidget *widget, GtkStyle *old_style) { - GtkLayoutPriv *priv; + GtkLayoutPrivate *priv; GTK_WIDGET_CLASS (gtk_layout_parent_class)->style_set (widget, old_style); if (gtk_widget_get_realized (widget)) { priv = GTK_LAYOUT (widget)->priv; - gtk_style_set_background (widget->style, priv->bin_window, GTK_STATE_NORMAL); + gtk_style_set_background (gtk_widget_get_style (widget), priv->bin_window, GTK_STATE_NORMAL); } } @@ -926,7 +936,7 @@ static void gtk_layout_map (GtkWidget *widget) { GtkLayout *layout = GTK_LAYOUT (widget); - GtkLayoutPriv *priv = layout->priv; + GtkLayoutPrivate *priv = layout->priv; GList *tmp_list; gtk_widget_set_mapped (widget, TRUE); @@ -945,14 +955,14 @@ gtk_layout_map (GtkWidget *widget) } gdk_window_show (priv->bin_window); - gdk_window_show (widget->window); + gdk_window_show (gtk_widget_get_window (widget)); } static void gtk_layout_unrealize (GtkWidget *widget) { GtkLayout *layout = GTK_LAYOUT (widget); - GtkLayoutPriv *priv = layout->priv; + GtkLayoutPrivate *priv = layout->priv; gdk_window_set_user_data (priv->bin_window, NULL); gdk_window_destroy (priv->bin_window); @@ -966,7 +976,7 @@ gtk_layout_size_request (GtkWidget *widget, GtkRequisition *requisition) { GtkLayout *layout = GTK_LAYOUT (widget); - GtkLayoutPriv *priv = layout->priv; + GtkLayoutPrivate *priv = layout->priv; GList *tmp_list; requisition->width = 0; @@ -990,10 +1000,10 @@ gtk_layout_size_allocate (GtkWidget *widget, GtkAllocation *allocation) { GtkLayout *layout = GTK_LAYOUT (widget); - GtkLayoutPriv *priv = layout->priv; + GtkLayoutPrivate *priv = layout->priv; GList *tmp_list; - widget->allocation = *allocation; + gtk_widget_set_allocation (widget, allocation); tmp_list = priv->children; @@ -1007,7 +1017,7 @@ gtk_layout_size_allocate (GtkWidget *widget, if (gtk_widget_get_realized (widget)) { - gdk_window_move_resize (widget->window, + gdk_window_move_resize (gtk_widget_get_window (widget), allocation->x, allocation->y, allocation->width, allocation->height); @@ -1034,7 +1044,7 @@ gtk_layout_expose (GtkWidget *widget, GdkEventExpose *event) { GtkLayout *layout = GTK_LAYOUT (widget); - GtkLayoutPriv *priv = layout->priv; + GtkLayoutPrivate *priv = layout->priv; if (event->window != priv->bin_window) return FALSE; @@ -1058,7 +1068,7 @@ gtk_layout_remove (GtkContainer *container, GtkWidget *widget) { GtkLayout *layout = GTK_LAYOUT (container); - GtkLayoutPriv *priv = layout->priv; + GtkLayoutPrivate *priv = layout->priv; GList *tmp_list; GtkLayoutChild *child = NULL; @@ -1088,7 +1098,7 @@ gtk_layout_forall (GtkContainer *container, gpointer callback_data) { GtkLayout *layout = GTK_LAYOUT (container); - GtkLayoutPriv *priv = layout->priv; + GtkLayoutPrivate *priv = layout->priv; GtkLayoutChild *child; GList *tmp_list; @@ -1127,7 +1137,7 @@ static void gtk_layout_adjustment_changed (GtkAdjustment *adjustment, GtkLayout *layout) { - GtkLayoutPriv *priv = layout->priv; + GtkLayoutPrivate *priv = layout->priv; if (priv->freeze_count) return; diff --git a/gtk/gtklayout.h b/gtk/gtklayout.h index ae1fb25b5a..d29e7331ab 100644 --- a/gtk/gtklayout.h +++ b/gtk/gtklayout.h @@ -50,16 +50,16 @@ G_BEGIN_DECLS #define GTK_LAYOUT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_LAYOUT, GtkLayoutClass)) -typedef struct _GtkLayout GtkLayout; -typedef struct _GtkLayoutPriv GtkLayoutPriv; -typedef struct _GtkLayoutClass GtkLayoutClass; +typedef struct _GtkLayout GtkLayout; +typedef struct _GtkLayoutPrivate GtkLayoutPrivate; +typedef struct _GtkLayoutClass GtkLayoutClass; struct _GtkLayout { GtkContainer container; /* <private> */ - GtkLayoutPriv *priv; + GtkLayoutPrivate *priv; }; struct _GtkLayoutClass diff --git a/gtk/gtklinkbutton.c b/gtk/gtklinkbutton.c index 7bca09eb33..16fbdc5d3a 100644 --- a/gtk/gtklinkbutton.c +++ b/gtk/gtklinkbutton.c @@ -332,7 +332,7 @@ set_hand_cursor (GtkWidget *widget, if (show_hand) cursor = gdk_cursor_new_for_display (display, GDK_HAND2); - gdk_window_set_cursor (widget->window, cursor); + gdk_window_set_cursor (gtk_widget_get_window (widget), cursor); gdk_display_flush (display); if (cursor) @@ -357,6 +357,7 @@ popup_position_func (GtkMenu *menu, { GtkLinkButton *link_button = GTK_LINK_BUTTON (user_data); GtkLinkButtonPrivate *priv = link_button->priv; + GtkAllocation allocation; GtkWidget *widget = GTK_WIDGET (link_button); GdkScreen *screen = gtk_widget_get_screen (widget); GtkRequisition req; @@ -365,12 +366,13 @@ popup_position_func (GtkMenu *menu, g_return_if_fail (gtk_widget_get_realized (widget)); - gdk_window_get_origin (widget->window, x, y); + gdk_window_get_origin (gtk_widget_get_window (widget), x, y); gtk_widget_size_request (priv->popup_menu, &req); - *x += widget->allocation.width / 2; - *y += widget->allocation.height; + gtk_widget_get_allocation (widget, &allocation); + *x += allocation.width / 2; + *y += allocation.height; monitor_num = gdk_screen_get_monitor_at_point (screen, *x, *y); gtk_menu_set_monitor (menu, monitor_num); diff --git a/gtk/gtkliststore.c b/gtk/gtkliststore.c index b8b01f6b7b..fc43eba05c 100644 --- a/gtk/gtkliststore.c +++ b/gtk/gtkliststore.c @@ -31,7 +31,7 @@ #include "gtkbuilderprivate.h" -struct _GtkListStorePriv +struct _GtkListStorePrivate { GtkSortType order; GtkTreeIterCompareFunc default_sort_func; @@ -174,7 +174,7 @@ gtk_list_store_class_init (GtkListStoreClass *class) object_class->finalize = gtk_list_store_finalize; - g_type_class_add_private (class, sizeof (GtkListStorePriv)); + g_type_class_add_private (class, sizeof (GtkListStorePrivate)); } static void @@ -229,11 +229,11 @@ gtk_list_store_buildable_init (GtkBuildableIface *iface) static void gtk_list_store_init (GtkListStore *list_store) { - GtkListStorePriv *priv; + GtkListStorePrivate *priv; list_store->priv = G_TYPE_INSTANCE_GET_PRIVATE (list_store, GTK_TYPE_LIST_STORE, - GtkListStorePriv); + GtkListStorePrivate); priv = list_store->priv; priv->seq = g_sequence_new (NULL); @@ -345,7 +345,7 @@ gtk_list_store_set_column_types (GtkListStore *list_store, gint n_columns, GType *types) { - GtkListStorePriv *priv; + GtkListStorePrivate *priv; gint i; g_return_if_fail (GTK_IS_LIST_STORE (list_store)); @@ -370,7 +370,7 @@ static void gtk_list_store_set_n_columns (GtkListStore *list_store, gint n_columns) { - GtkListStorePriv *priv = list_store->priv; + GtkListStorePrivate *priv = list_store->priv; int i; if (priv->n_columns == n_columns) @@ -391,7 +391,7 @@ gtk_list_store_set_column_type (GtkListStore *list_store, gint column, GType type) { - GtkListStorePriv *priv = list_store->priv; + GtkListStorePrivate *priv = list_store->priv; if (!_gtk_tree_data_list_check_type (type)) { @@ -406,7 +406,7 @@ static void gtk_list_store_finalize (GObject *object) { GtkListStore *list_store = GTK_LIST_STORE (object); - GtkListStorePriv *priv = list_store->priv; + GtkListStorePrivate *priv = list_store->priv; g_sequence_foreach (priv->seq, (GFunc) _gtk_tree_data_list_free, priv->column_headers); @@ -439,7 +439,7 @@ static gint gtk_list_store_get_n_columns (GtkTreeModel *tree_model) { GtkListStore *list_store = GTK_LIST_STORE (tree_model); - GtkListStorePriv *priv = list_store->priv; + GtkListStorePrivate *priv = list_store->priv; priv->columns_dirty = TRUE; @@ -451,7 +451,7 @@ gtk_list_store_get_column_type (GtkTreeModel *tree_model, gint index) { GtkListStore *list_store = GTK_LIST_STORE (tree_model); - GtkListStorePriv *priv = list_store->priv; + GtkListStorePrivate *priv = list_store->priv; g_return_val_if_fail (index < priv->n_columns, G_TYPE_INVALID); @@ -466,7 +466,7 @@ gtk_list_store_get_iter (GtkTreeModel *tree_model, GtkTreePath *path) { GtkListStore *list_store = GTK_LIST_STORE (tree_model); - GtkListStorePriv *priv = list_store->priv; + GtkListStorePrivate *priv = list_store->priv; GSequence *seq; gint i; @@ -490,7 +490,7 @@ gtk_list_store_get_path (GtkTreeModel *tree_model, GtkTreeIter *iter) { GtkListStore *list_store = GTK_LIST_STORE (tree_model); - GtkListStorePriv *priv = list_store->priv; + GtkListStorePrivate *priv = list_store->priv; GtkTreePath *path; g_return_val_if_fail (iter->stamp == priv->stamp, NULL); @@ -511,7 +511,7 @@ gtk_list_store_get_value (GtkTreeModel *tree_model, GValue *value) { GtkListStore *list_store = GTK_LIST_STORE (tree_model); - GtkListStorePriv *priv = list_store->priv; + GtkListStorePrivate *priv = list_store->priv; GtkTreeDataList *list; gint tmp_column = column; @@ -536,7 +536,7 @@ gtk_list_store_iter_next (GtkTreeModel *tree_model, GtkTreeIter *iter) { GtkListStore *list_store = GTK_LIST_STORE (tree_model); - GtkListStorePriv *priv = list_store->priv; + GtkListStorePrivate *priv = list_store->priv; gboolean retval; g_return_val_if_fail (priv->stamp == iter->stamp, FALSE); @@ -555,7 +555,7 @@ gtk_list_store_iter_children (GtkTreeModel *tree_model, GtkTreeIter *parent) { GtkListStore *list_store = (GtkListStore *) tree_model; - GtkListStorePriv *priv = list_store->priv; + GtkListStorePrivate *priv = list_store->priv; /* this is a list, nodes have no children */ if (parent) @@ -589,7 +589,7 @@ gtk_list_store_iter_n_children (GtkTreeModel *tree_model, GtkTreeIter *iter) { GtkListStore *list_store = GTK_LIST_STORE (tree_model); - GtkListStorePriv *priv = list_store->priv; + GtkListStorePrivate *priv = list_store->priv; if (iter == NULL) return g_sequence_get_length (priv->seq); @@ -606,7 +606,7 @@ gtk_list_store_iter_nth_child (GtkTreeModel *tree_model, gint n) { GtkListStore *list_store = GTK_LIST_STORE (tree_model); - GtkListStorePriv *priv = list_store->priv; + GtkListStorePrivate *priv = list_store->priv; GSequenceIter *child; iter->stamp = 0; @@ -641,7 +641,7 @@ gtk_list_store_real_set_value (GtkListStore *list_store, GValue *value, gboolean sort) { - GtkListStorePriv *priv = list_store->priv; + GtkListStorePrivate *priv = list_store->priv; GtkTreeDataList *list; GtkTreeDataList *prev; gint old_column = column; @@ -749,7 +749,7 @@ gtk_list_store_set_value (GtkListStore *list_store, gint column, GValue *value) { - GtkListStorePriv *priv = list_store->priv; + GtkListStorePrivate *priv = list_store->priv; g_return_if_fail (GTK_IS_LIST_STORE (list_store)); g_return_if_fail (VALID_ITER (iter, list_store)); @@ -770,7 +770,7 @@ gtk_list_store_set_value (GtkListStore *list_store, static GtkTreeIterCompareFunc gtk_list_store_get_compare_func (GtkListStore *list_store) { - GtkListStorePriv *priv = list_store->priv; + GtkListStorePrivate *priv = list_store->priv; GtkTreeIterCompareFunc func = NULL; if (GTK_LIST_STORE_IS_SORTED (list_store)) @@ -802,7 +802,7 @@ gtk_list_store_set_vector_internal (GtkListStore *list_store, GValue *values, gint n_values) { - GtkListStorePriv *priv = list_store->priv; + GtkListStorePrivate *priv = list_store->priv; gint i; GtkTreeIterCompareFunc func = NULL; @@ -831,7 +831,7 @@ gtk_list_store_set_valist_internal (GtkListStore *list_store, gboolean *maybe_need_sort, va_list var_args) { - GtkListStorePriv *priv = list_store->priv; + GtkListStorePrivate *priv = list_store->priv; gint column; GtkTreeIterCompareFunc func = NULL; @@ -905,7 +905,7 @@ gtk_list_store_set_valuesv (GtkListStore *list_store, GValue *values, gint n_values) { - GtkListStorePriv *priv; + GtkListStorePrivate *priv; gboolean emit_signal = FALSE; gboolean maybe_need_sort = FALSE; @@ -947,7 +947,7 @@ gtk_list_store_set_valist (GtkListStore *list_store, GtkTreeIter *iter, va_list var_args) { - GtkListStorePriv *priv; + GtkListStorePrivate *priv; gboolean emit_signal = FALSE; gboolean maybe_need_sort = FALSE; @@ -1017,7 +1017,7 @@ gboolean gtk_list_store_remove (GtkListStore *list_store, GtkTreeIter *iter) { - GtkListStorePriv *priv; + GtkListStorePrivate *priv; GtkTreePath *path; GSequenceIter *ptr, *next; @@ -1070,7 +1070,7 @@ gtk_list_store_insert (GtkListStore *list_store, GtkTreeIter *iter, gint position) { - GtkListStorePriv *priv; + GtkListStorePrivate *priv; GtkTreePath *path; GSequence *seq; GSequenceIter *ptr; @@ -1123,7 +1123,7 @@ gtk_list_store_insert_before (GtkListStore *list_store, GtkTreeIter *iter, GtkTreeIter *sibling) { - GtkListStorePriv *priv; + GtkListStorePrivate *priv; GSequenceIter *after; g_return_if_fail (GTK_IS_LIST_STORE (list_store)); @@ -1159,7 +1159,7 @@ gtk_list_store_insert_after (GtkListStore *list_store, GtkTreeIter *iter, GtkTreeIter *sibling) { - GtkListStorePriv *priv; + GtkListStorePrivate *priv; GSequenceIter *after; g_return_if_fail (GTK_IS_LIST_STORE (list_store)); @@ -1212,7 +1212,7 @@ void gtk_list_store_append (GtkListStore *list_store, GtkTreeIter *iter) { - GtkListStorePriv *priv; + GtkListStorePrivate *priv; g_return_if_fail (GTK_IS_LIST_STORE (list_store)); g_return_if_fail (iter != NULL); @@ -1225,7 +1225,7 @@ gtk_list_store_append (GtkListStore *list_store, static void gtk_list_store_increment_stamp (GtkListStore *list_store) { - GtkListStorePriv *priv = list_store->priv; + GtkListStorePrivate *priv = list_store->priv; do { @@ -1244,7 +1244,7 @@ gtk_list_store_increment_stamp (GtkListStore *list_store) void gtk_list_store_clear (GtkListStore *list_store) { - GtkListStorePriv *priv; + GtkListStorePrivate *priv; GtkTreeIter iter; g_return_if_fail (GTK_IS_LIST_STORE (list_store)); @@ -1279,7 +1279,7 @@ gboolean gtk_list_store_iter_is_valid (GtkListStore *list_store, GtkTreeIter *iter) { - GtkListStorePriv *priv; + GtkListStorePrivate *priv; g_return_val_if_fail (GTK_IS_LIST_STORE (list_store), FALSE); g_return_val_if_fail (iter != NULL, FALSE); @@ -1349,7 +1349,7 @@ gtk_list_store_drag_data_received (GtkTreeDragDest *drag_dest, { GtkTreeModel *tree_model = GTK_TREE_MODEL (drag_dest); GtkListStore *list_store = GTK_LIST_STORE (tree_model); - GtkListStorePriv *priv = list_store->priv; + GtkListStorePrivate *priv = list_store->priv; GtkTreeModel *src_model = NULL; GtkTreePath *src_path = NULL; gboolean retval = FALSE; @@ -1523,7 +1523,7 @@ void gtk_list_store_reorder (GtkListStore *store, gint *new_order) { - GtkListStorePriv *priv; + GtkListStorePrivate *priv; gint i; GtkTreePath *path; GHashTable *new_positions; @@ -1618,7 +1618,7 @@ gtk_list_store_swap (GtkListStore *store, GtkTreeIter *a, GtkTreeIter *b) { - GtkListStorePriv *priv; + GtkListStorePrivate *priv; GHashTable *old_positions; gint *order; GtkTreePath *path; @@ -1652,7 +1652,7 @@ gtk_list_store_move_to (GtkListStore *store, GtkTreeIter *iter, gint new_pos) { - GtkListStorePriv *priv = store->priv; + GtkListStorePrivate *priv = store->priv; GHashTable *old_positions; GtkTreePath *path; gint *order; @@ -1743,7 +1743,7 @@ gtk_list_store_compare_func (GSequenceIter *a, gpointer user_data) { GtkListStore *list_store = user_data; - GtkListStorePriv *priv = list_store->priv; + GtkListStorePrivate *priv = list_store->priv; GtkTreeIter iter_a; GtkTreeIter iter_b; gint retval; @@ -1793,7 +1793,7 @@ gtk_list_store_compare_func (GSequenceIter *a, static void gtk_list_store_sort (GtkListStore *list_store) { - GtkListStorePriv *priv = list_store->priv; + GtkListStorePrivate *priv = list_store->priv; gint *new_order; GtkTreePath *path; GHashTable *old_positions; @@ -1845,7 +1845,7 @@ gtk_list_store_sort_iter_changed (GtkListStore *list_store, gint column) { - GtkListStorePriv *priv = list_store->priv; + GtkListStorePrivate *priv = list_store->priv; GtkTreePath *path; path = gtk_list_store_get_path (GTK_TREE_MODEL (list_store), iter); @@ -1876,7 +1876,7 @@ gtk_list_store_get_sort_column_id (GtkTreeSortable *sortable, GtkSortType *order) { GtkListStore *list_store = GTK_LIST_STORE (sortable); - GtkListStorePriv *priv = list_store->priv; + GtkListStorePrivate *priv = list_store->priv; if (sort_column_id) * sort_column_id = priv->sort_column_id; @@ -1896,7 +1896,7 @@ gtk_list_store_set_sort_column_id (GtkTreeSortable *sortable, GtkSortType order) { GtkListStore *list_store = GTK_LIST_STORE (sortable); - GtkListStorePriv *priv = list_store->priv; + GtkListStorePrivate *priv = list_store->priv; if ((priv->sort_column_id == sort_column_id) && (priv->order == order)) @@ -1938,7 +1938,7 @@ gtk_list_store_set_sort_func (GtkTreeSortable *sortable, GDestroyNotify destroy) { GtkListStore *list_store = GTK_LIST_STORE (sortable); - GtkListStorePriv *priv = list_store->priv; + GtkListStorePrivate *priv = list_store->priv; priv->sort_list = _gtk_tree_data_list_set_header (priv->sort_list, sort_column_id, @@ -1955,7 +1955,7 @@ gtk_list_store_set_default_sort_func (GtkTreeSortable *sortable, GDestroyNotify destroy) { GtkListStore *list_store = GTK_LIST_STORE (sortable); - GtkListStorePriv *priv = list_store->priv; + GtkListStorePrivate *priv = list_store->priv; if (priv->default_sort_destroy) { @@ -1977,7 +1977,7 @@ static gboolean gtk_list_store_has_default_sort_func (GtkTreeSortable *sortable) { GtkListStore *list_store = GTK_LIST_STORE (sortable); - GtkListStorePriv *priv = list_store->priv; + GtkListStorePrivate *priv = list_store->priv; return (priv->default_sort_func != NULL); } @@ -2017,7 +2017,7 @@ gtk_list_store_insert_with_values (GtkListStore *list_store, gint position, ...) { - GtkListStorePriv *priv; + GtkListStorePrivate *priv; GtkTreePath *path; GSequence *seq; GSequenceIter *ptr; @@ -2096,7 +2096,7 @@ gtk_list_store_insert_with_valuesv (GtkListStore *list_store, GValue *values, gint n_values) { - GtkListStorePriv *priv; + GtkListStorePrivate *priv; GtkTreePath *path; GSequence *seq; GSequenceIter *ptr; diff --git a/gtk/gtkliststore.h b/gtk/gtkliststore.h index 8c702f9f74..594fc329c8 100644 --- a/gtk/gtkliststore.h +++ b/gtk/gtkliststore.h @@ -39,16 +39,16 @@ G_BEGIN_DECLS #define GTK_IS_LIST_STORE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_LIST_STORE)) #define GTK_LIST_STORE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_LIST_STORE, GtkListStoreClass)) -typedef struct _GtkListStore GtkListStore; -typedef struct _GtkListStorePriv GtkListStorePriv; -typedef struct _GtkListStoreClass GtkListStoreClass; +typedef struct _GtkListStore GtkListStore; +typedef struct _GtkListStorePrivate GtkListStorePrivate; +typedef struct _GtkListStoreClass GtkListStoreClass; struct _GtkListStore { GObject parent; /*< private >*/ - GtkListStorePriv *priv; + GtkListStorePrivate *priv; }; struct _GtkListStoreClass diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c index ea922a8772..a7cd8461f1 100644 --- a/gtk/gtkmain.c +++ b/gtk/gtkmain.c @@ -1543,7 +1543,7 @@ gtk_main_do_event (GdkEvent *event) /* Unexpected GDK_DESTROY from the outside, ignore for * child windows, handle like a GDK_DELETE for toplevels */ - if (!event_widget->parent) + if (!gtk_widget_get_parent (event_widget)) { g_object_ref (event_widget); if (!gtk_widget_event (event_widget, event) && @@ -2411,8 +2411,8 @@ gtk_propagate_event (GtkWidget *widget, handled_event = event->type != GDK_SCROLL; else handled_event = gtk_widget_event (widget, event); - - tmp = widget->parent; + + tmp = gtk_widget_get_parent (widget); g_object_unref (widget); widget = tmp; diff --git a/gtk/gtkmenubar.c b/gtk/gtkmenubar.c index a34d1d3ae3..91338d4cdd 100644 --- a/gtk/gtkmenubar.c +++ b/gtk/gtkmenubar.c @@ -345,8 +345,11 @@ gtk_menu_bar_size_request (GtkWidget *widget, if (get_shadow_type (menu_bar) != GTK_SHADOW_NONE) { - requisition->width += widget->style->xthickness * 2; - requisition->height += widget->style->ythickness * 2; + GtkStyle *style; + + style = gtk_widget_get_style (widget); + requisition->width += style->xthickness * 2; + requisition->height += style->ythickness * 2; } } } @@ -377,9 +380,10 @@ gtk_menu_bar_size_allocate (GtkWidget *widget, direction = gtk_widget_get_direction (widget); - widget->allocation = *allocation; + gtk_widget_set_allocation (widget, allocation); + if (gtk_widget_get_realized (widget)) - gdk_window_move_resize (widget->window, + gdk_window_move_resize (gtk_widget_get_window (widget), allocation->x, allocation->y, allocation->width, allocation->height); @@ -396,8 +400,11 @@ gtk_menu_bar_size_allocate (GtkWidget *widget, if (get_shadow_type (menu_bar) != GTK_SHADOW_NONE) { - child_allocation.x += widget->style->xthickness; - child_allocation.y += widget->style->ythickness; + GtkStyle *style; + + style = gtk_widget_get_style (widget); + child_allocation.x += style->xthickness; + child_allocation.y += style->ythickness; } if (priv->pack_direction == GTK_PACK_DIRECTION_LTR || @@ -512,18 +519,20 @@ gtk_menu_bar_paint (GtkWidget *widget, if (gtk_widget_is_drawable (widget)) { + GtkAllocation allocation; guint border; border = gtk_container_get_border_width (GTK_CONTAINER (widget)); - - gtk_paint_box (widget->style, - widget->window, + gtk_widget_get_allocation (widget, &allocation); + + gtk_paint_box (gtk_widget_get_style (widget), + gtk_widget_get_window (widget), gtk_widget_get_state (widget), get_shadow_type (GTK_MENU_BAR (widget)), area, widget, "menubar", border, border, - widget->allocation.width - border * 2, - widget->allocation.height - border * 2); + allocation.width - border * 2, + allocation.height - border * 2); } } @@ -567,8 +576,8 @@ get_viewable_menu_bars (GtkWindow *window) { if (!gtk_widget_get_mapped (widget)) viewable = FALSE; - - widget = widget->parent; + + widget = gtk_widget_get_parent (widget); } if (viewable) diff --git a/gtk/gtkmenuitem.c b/gtk/gtkmenuitem.c index 8bdc5b46f3..aa631f8337 100644 --- a/gtk/gtkmenuitem.c +++ b/gtk/gtkmenuitem.c @@ -585,7 +585,7 @@ get_arrow_size (GtkWidget *widget, context = gtk_widget_get_pango_context (child); metrics = pango_context_get_metrics (context, - child->style->font_desc, + gtk_widget_get_style (child)->font_desc, pango_context_get_language (context)); *size = (PANGO_PIXELS (pango_font_metrics_get_ascent (metrics) + @@ -626,7 +626,7 @@ get_minimum_width (GtkWidget *widget) context = gtk_widget_get_pango_context (widget); metrics = pango_context_get_metrics (context, - widget->style->font_desc, + gtk_widget_get_style (widget)->font_desc, pango_context_get_language (context)); width = pango_font_metrics_get_approximate_char_width (metrics); @@ -654,6 +654,7 @@ gtk_menu_item_get_width (GtkSizeRequest *request, GtkMenuItem *menu_item; GtkBin *bin; GtkWidget *child, *widget = GTK_WIDGET (request); + GtkWidget *parent; guint accel_width; guint horizontal_padding; guint border_width; @@ -669,11 +670,12 @@ gtk_menu_item_get_width (GtkSizeRequest *request, bin = GTK_BIN (widget); menu_item = GTK_MENU_ITEM (widget); + parent = gtk_widget_get_parent (widget); - if (GTK_IS_MENU_BAR (widget->parent)) + if (GTK_IS_MENU_BAR (parent)) { - pack_dir = gtk_menu_bar_get_pack_direction (GTK_MENU_BAR (widget->parent)); - child_pack_dir = gtk_menu_bar_get_child_pack_direction (GTK_MENU_BAR (widget->parent)); + pack_dir = gtk_menu_bar_get_pack_direction (GTK_MENU_BAR (parent)); + child_pack_dir = gtk_menu_bar_get_child_pack_direction (GTK_MENU_BAR (parent)); } else { @@ -683,7 +685,7 @@ gtk_menu_item_get_width (GtkSizeRequest *request, border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); - min_width = (border_width + widget->style->xthickness) * 2; + min_width = (border_width + gtk_widget_get_style (widget)->xthickness) * 2; if ((pack_dir == GTK_PACK_DIRECTION_LTR || pack_dir == GTK_PACK_DIRECTION_RTL) && (child_pack_dir == GTK_PACK_DIRECTION_LTR || child_pack_dir == GTK_PACK_DIRECTION_RTL)) @@ -745,7 +747,9 @@ gtk_menu_item_get_height (GtkSizeRequest *request, { GtkMenuItem *menu_item; GtkBin *bin; + GtkStyle *style; GtkWidget *child, *widget = GTK_WIDGET (request); + GtkWidget *parent; guint accel_width; guint horizontal_padding; guint border_width; @@ -755,17 +759,20 @@ gtk_menu_item_get_height (GtkSizeRequest *request, min_height = nat_height = 0; + style = gtk_widget_get_style (widget); + gtk_widget_style_get (widget, "horizontal-padding", &horizontal_padding, NULL); bin = GTK_BIN (widget); menu_item = GTK_MENU_ITEM (widget); + parent = gtk_widget_get_parent (widget); - if (GTK_IS_MENU_BAR (widget->parent)) + if (GTK_IS_MENU_BAR (parent)) { - pack_dir = gtk_menu_bar_get_pack_direction (GTK_MENU_BAR (widget->parent)); - child_pack_dir = gtk_menu_bar_get_child_pack_direction (GTK_MENU_BAR (widget->parent)); + pack_dir = gtk_menu_bar_get_pack_direction (GTK_MENU_BAR (parent)); + child_pack_dir = gtk_menu_bar_get_child_pack_direction (GTK_MENU_BAR (parent)); } else { @@ -774,7 +781,7 @@ gtk_menu_item_get_height (GtkSizeRequest *request, } border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); - min_height = (border_width + widget->style->ythickness) * 2; + min_height = (border_width + style->ythickness) * 2; if ((pack_dir == GTK_PACK_DIRECTION_TTB || pack_dir == GTK_PACK_DIRECTION_BTT) && (child_pack_dir == GTK_PACK_DIRECTION_TTB || child_pack_dir == GTK_PACK_DIRECTION_BTT)) @@ -814,9 +821,9 @@ gtk_menu_item_get_height (GtkSizeRequest *request, NULL); if (wide_separators) - min_height += separator_height + widget->style->ythickness; + min_height += separator_height + style->ythickness; else - min_height += widget->style->ythickness * 2; + min_height += style->ythickness * 2; nat_height = min_height; } @@ -842,7 +849,9 @@ gtk_menu_item_get_height_for_width (GtkSizeRequest *request, { GtkMenuItem *menu_item; GtkBin *bin; + GtkStyle *style; GtkWidget *child, *widget = GTK_WIDGET (request); + GtkWidget *parent; guint horizontal_padding; guint border_width; GtkPackDirection pack_dir; @@ -852,17 +861,20 @@ gtk_menu_item_get_height_for_width (GtkSizeRequest *request, min_height = nat_height = 0; + style = gtk_widget_get_style (widget); + gtk_widget_style_get (widget, "horizontal-padding", &horizontal_padding, NULL); bin = GTK_BIN (widget); menu_item = GTK_MENU_ITEM (widget); + parent = gtk_widget_get_parent (widget); - if (GTK_IS_MENU_BAR (widget->parent)) + if (GTK_IS_MENU_BAR (parent)) { - pack_dir = gtk_menu_bar_get_pack_direction (GTK_MENU_BAR (widget->parent)); - child_pack_dir = gtk_menu_bar_get_child_pack_direction (GTK_MENU_BAR (widget->parent)); + pack_dir = gtk_menu_bar_get_pack_direction (GTK_MENU_BAR (parent)); + child_pack_dir = gtk_menu_bar_get_child_pack_direction (GTK_MENU_BAR (parent)); } else { @@ -871,10 +883,10 @@ gtk_menu_item_get_height_for_width (GtkSizeRequest *request, } border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); - min_height = (border_width + widget->style->ythickness) * 2; + min_height = (border_width + style->ythickness) * 2; avail_size = for_size; - avail_size -= (border_width + widget->style->xthickness) * 2; + avail_size -= (border_width + style->xthickness) * 2; if ((pack_dir == GTK_PACK_DIRECTION_TTB || pack_dir == GTK_PACK_DIRECTION_BTT) && (child_pack_dir == GTK_PACK_DIRECTION_TTB || child_pack_dir == GTK_PACK_DIRECTION_BTT)) @@ -930,9 +942,9 @@ gtk_menu_item_get_height_for_width (GtkSizeRequest *request, NULL); if (wide_separators) - min_height += separator_height + widget->style->ythickness; + min_height += separator_height + style->ythickness; else - min_height += widget->style->ythickness * 2; + min_height += style->ythickness * 2; nat_height = min_height; } @@ -979,14 +991,15 @@ gtk_menu_item_buildable_custom_finished (GtkBuildable *buildable, if (strcmp (tagname, "accelerator") == 0) { - GtkMenuShell *menu_shell = (GtkMenuShell *) GTK_WIDGET (buildable)->parent; + GtkMenuShell *menu_shell; GtkWidget *attach; + menu_shell = GTK_MENU_SHELL (gtk_widget_get_parent (GTK_WIDGET (buildable))); if (menu_shell) { while (GTK_IS_MENU (menu_shell) && (attach = gtk_menu_get_attach_widget (GTK_MENU (menu_shell))) != NULL) - menu_shell = (GtkMenuShell *)attach->parent; + menu_shell = GTK_MENU_SHELL (gtk_widget_get_parent (attach)); toplevel = gtk_widget_get_toplevel (GTK_WIDGET (menu_shell)); } @@ -1175,7 +1188,7 @@ gtk_menu_item_set_submenu (GtkMenuItem *menu_item, gtk_menu_item_detacher); } - if (GTK_WIDGET (menu_item)->parent) + if (gtk_widget_get_parent (GTK_WIDGET (menu_item))) gtk_widget_queue_resize (GTK_WIDGET (menu_item)); g_object_notify (G_OBJECT (menu_item), "submenu"); @@ -1214,6 +1227,8 @@ _gtk_menu_item_set_placement (GtkMenuItem *menu_item, void gtk_menu_item_select (GtkMenuItem *menu_item) { + GtkWidget *parent; + g_return_if_fail (GTK_IS_MENU_ITEM (menu_item)); gtk_item_select (GTK_ITEM (menu_item)); @@ -1221,9 +1236,10 @@ gtk_menu_item_select (GtkMenuItem *menu_item) /* Enable themeing of the parent menu item depending on whether * something is selected in its submenu */ - if (GTK_IS_MENU (GTK_WIDGET (menu_item)->parent)) + parent = gtk_widget_get_parent (GTK_WIDGET (menu_item)); + if (GTK_IS_MENU (parent)) { - GtkMenu *menu = GTK_MENU (GTK_WIDGET (menu_item)->parent); + GtkMenu *menu = GTK_MENU (parent); if (menu->parent_menu_item) gtk_widget_queue_draw (GTK_WIDGET (menu->parent_menu_item)); @@ -1233,6 +1249,8 @@ gtk_menu_item_select (GtkMenuItem *menu_item) void gtk_menu_item_deselect (GtkMenuItem *menu_item) { + GtkWidget *parent; + g_return_if_fail (GTK_IS_MENU_ITEM (menu_item)); gtk_item_deselect (GTK_ITEM (menu_item)); @@ -1240,9 +1258,10 @@ gtk_menu_item_deselect (GtkMenuItem *menu_item) /* Enable themeing of the parent menu item depending on whether * something is selected in its submenu */ - if (GTK_IS_MENU (GTK_WIDGET (menu_item)->parent)) + parent = gtk_widget_get_parent (GTK_WIDGET (menu_item)); + if (GTK_IS_MENU (parent)) { - GtkMenu *menu = GTK_MENU (GTK_WIDGET (menu_item)->parent); + GtkMenu *menu = GTK_MENU (parent); if (menu->parent_menu_item) gtk_widget_queue_draw (GTK_WIDGET (menu->parent_menu_item)); @@ -1286,6 +1305,7 @@ gtk_menu_item_size_allocate (GtkWidget *widget, GtkPackDirection pack_dir; GtkPackDirection child_pack_dir; GtkWidget *child; + GtkWidget *parent; g_return_if_fail (GTK_IS_MENU_ITEM (widget)); g_return_if_fail (allocation != NULL); @@ -1295,33 +1315,36 @@ gtk_menu_item_size_allocate (GtkWidget *widget, direction = gtk_widget_get_direction (widget); - if (GTK_IS_MENU_BAR (widget->parent)) + parent = gtk_widget_get_parent (widget); + if (GTK_IS_MENU_BAR (parent)) { - pack_dir = gtk_menu_bar_get_pack_direction (GTK_MENU_BAR (widget->parent)); - child_pack_dir = gtk_menu_bar_get_child_pack_direction (GTK_MENU_BAR (widget->parent)); + pack_dir = gtk_menu_bar_get_pack_direction (GTK_MENU_BAR (parent)); + child_pack_dir = gtk_menu_bar_get_child_pack_direction (GTK_MENU_BAR (parent)); } else { pack_dir = GTK_PACK_DIRECTION_LTR; child_pack_dir = GTK_PACK_DIRECTION_LTR; } - - widget->allocation = *allocation; + + gtk_widget_set_allocation (widget, allocation); child = gtk_bin_get_child (bin); if (child) { GtkRequisition child_requisition; + GtkStyle *style; guint horizontal_padding; guint border_width; + style = gtk_widget_get_style (widget); gtk_widget_style_get (widget, "horizontal-padding", &horizontal_padding, NULL); border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); - child_allocation.x = border_width + widget->style->xthickness; - child_allocation.y = border_width + widget->style->ythickness; + child_allocation.x = border_width + style->xthickness; + child_allocation.y = border_width + style->ythickness; if ((pack_dir == GTK_PACK_DIRECTION_LTR || pack_dir == GTK_PACK_DIRECTION_RTL) && (child_pack_dir == GTK_PACK_DIRECTION_LTR || child_pack_dir == GTK_PACK_DIRECTION_RTL)) @@ -1329,7 +1352,7 @@ gtk_menu_item_size_allocate (GtkWidget *widget, else if ((pack_dir == GTK_PACK_DIRECTION_TTB || pack_dir == GTK_PACK_DIRECTION_BTT) && (child_pack_dir == GTK_PACK_DIRECTION_TTB || child_pack_dir == GTK_PACK_DIRECTION_BTT)) child_allocation.y += horizontal_padding; - + child_allocation.width = MAX (1, (gint)allocation->width - child_allocation.x * 2); child_allocation.height = MAX (1, (gint)allocation->height - child_allocation.y * 2); @@ -1347,8 +1370,8 @@ gtk_menu_item_size_allocate (GtkWidget *widget, child_allocation.height -= GTK_MENU_ITEM (widget)->toggle_size; } - child_allocation.x += widget->allocation.x; - child_allocation.y += widget->allocation.y; + child_allocation.x += allocation->x; + child_allocation.y += allocation->y; gtk_widget_get_child_requisition (child, &child_requisition); if (menu_item->submenu && menu_item->show_submenu_indicator) @@ -1376,19 +1399,24 @@ gtk_menu_item_size_allocate (GtkWidget *widget, static void gtk_menu_item_realize (GtkWidget *widget) { + GtkAllocation allocation; GtkMenuItem *menu_item = GTK_MENU_ITEM (widget); + GdkWindow *window; GdkWindowAttr attributes; gint attributes_mask; gtk_widget_set_realized (widget, TRUE); - widget->window = gtk_widget_get_parent_window (widget); - g_object_ref (widget->window); - - attributes.x = widget->allocation.x; - attributes.y = widget->allocation.y; - attributes.width = widget->allocation.width; - attributes.height = widget->allocation.height; + window = gtk_widget_get_parent_window (widget); + gtk_widget_set_window (widget, window); + g_object_ref (window); + + gtk_widget_get_allocation (widget, &allocation); + + attributes.x = allocation.x; + attributes.y = allocation.y; + attributes.width = allocation.width; + attributes.height = allocation.height; attributes.window_type = GDK_WINDOW_CHILD; attributes.wclass = GDK_INPUT_ONLY; attributes.event_mask = (gtk_widget_get_events (widget) | @@ -1399,10 +1427,12 @@ gtk_menu_item_realize (GtkWidget *widget) GDK_POINTER_MOTION_MASK); attributes_mask = GDK_WA_X | GDK_WA_Y; - menu_item->event_window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); + + menu_item->event_window = gdk_window_new (gtk_widget_get_parent_window (widget), + &attributes, attributes_mask); gdk_window_set_user_data (menu_item->event_window, widget); - widget->style = gtk_style_attach (widget->style, widget->window); + gtk_widget_style_attach (widget); } static void @@ -1441,10 +1471,13 @@ static void gtk_menu_item_paint (GtkWidget *widget, GdkRectangle *area) { + GtkAllocation allocation; GtkMenuItem *menu_item; GtkStateType state_type; GtkShadowType shadow_type, selected_shadow_type; + GtkStyle *style; GtkWidget *child; + GdkWindow *window; gint width, height; gint x, y; guint border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); @@ -1453,12 +1486,15 @@ gtk_menu_item_paint (GtkWidget *widget, { menu_item = GTK_MENU_ITEM (widget); - state_type = widget->state; - - x = widget->allocation.x + border_width; - y = widget->allocation.y + border_width; - width = widget->allocation.width - border_width * 2; - height = widget->allocation.height - border_width * 2; + gtk_widget_get_allocation (widget, &allocation); + state_type = gtk_widget_get_state (widget); + style = gtk_widget_get_style (widget); + window = gtk_widget_get_window (widget); + + x = allocation.x + border_width; + y = allocation.y + border_width; + width = allocation.width - border_width * 2; + height = allocation.height - border_width * 2; child = gtk_bin_get_child (GTK_BIN (menu_item)); @@ -1467,8 +1503,8 @@ gtk_menu_item_paint (GtkWidget *widget, gtk_widget_style_get (widget, "selected-shadow-type", &selected_shadow_type, NULL); - gtk_paint_box (widget->style, - widget->window, + gtk_paint_box (style, + window, GTK_STATE_PRELIGHT, selected_shadow_type, area, widget, "menuitem", @@ -1508,7 +1544,7 @@ gtk_menu_item_paint (GtkWidget *widget, arrow_y = y + (height - arrow_size) / 2; - gtk_paint_arrow (widget->style, widget->window, + gtk_paint_arrow (style, window, state_type, shadow_type, area, widget, "menuitem", arrow_type, TRUE, @@ -1528,23 +1564,19 @@ gtk_menu_item_paint (GtkWidget *widget, NULL); if (wide_separators) - gtk_paint_box (widget->style, widget->window, + gtk_paint_box (style, window, GTK_STATE_NORMAL, GTK_SHADOW_ETCHED_OUT, area, widget, "hseparator", - widget->allocation.x + horizontal_padding + widget->style->xthickness, - widget->allocation.y + (widget->allocation.height - - separator_height - - widget->style->ythickness) / 2, - widget->allocation.width - - 2 * (horizontal_padding + widget->style->xthickness), + allocation.x + horizontal_padding + style->xthickness, + allocation.y + (allocation.height - separator_height - style->ythickness) / 2, + allocation.width - 2 * (horizontal_padding + style->xthickness), separator_height); else - gtk_paint_hline (widget->style, widget->window, + gtk_paint_hline (style, window, GTK_STATE_NORMAL, area, widget, "menuitem", - widget->allocation.x + horizontal_padding + widget->style->xthickness, - widget->allocation.x + widget->allocation.width - horizontal_padding - widget->style->xthickness - 1, - widget->allocation.y + (widget->allocation.height - - widget->style->ythickness) / 2); + allocation.x + horizontal_padding + style->xthickness, + allocation.x + allocation.width - horizontal_padding - style->xthickness - 1, + allocation.y + (allocation.height - style->ythickness) / 2); } } } @@ -1612,15 +1644,19 @@ static gboolean gtk_menu_item_mnemonic_activate (GtkWidget *widget, gboolean group_cycling) { - if (GTK_IS_MENU_SHELL (widget->parent)) - _gtk_menu_shell_set_keyboard_mode (GTK_MENU_SHELL (widget->parent), TRUE); + GtkWidget *parent; + + parent = gtk_widget_get_parent (widget); + + if (GTK_IS_MENU_SHELL (parent)) + _gtk_menu_shell_set_keyboard_mode (GTK_MENU_SHELL (parent), TRUE); if (group_cycling && - widget->parent && - GTK_IS_MENU_SHELL (widget->parent) && - GTK_MENU_SHELL (widget->parent)->active) + parent && + GTK_IS_MENU_SHELL (parent) && + GTK_MENU_SHELL (parent)->active) { - gtk_menu_shell_select_item (GTK_MENU_SHELL (widget->parent), + gtk_menu_shell_select_item (GTK_MENU_SHELL (parent), widget); } else @@ -1645,26 +1681,27 @@ static void gtk_real_menu_item_activate_item (GtkMenuItem *menu_item) { GtkMenuItemPrivate *priv; + GtkWidget *parent; GtkWidget *widget; g_return_if_fail (GTK_IS_MENU_ITEM (menu_item)); priv = GET_PRIVATE (menu_item); widget = GTK_WIDGET (menu_item); - - if (widget->parent && - GTK_IS_MENU_SHELL (widget->parent)) + parent = gtk_widget_get_parent (widget); + + if (parent && GTK_IS_MENU_SHELL (parent)) { + GtkMenuShell *menu_shell = GTK_MENU_SHELL (parent); + if (menu_item->submenu == NULL) - gtk_menu_shell_activate_item (GTK_MENU_SHELL (widget->parent), + gtk_menu_shell_activate_item (menu_shell, widget, TRUE); else { - GtkMenuShell *menu_shell = GTK_MENU_SHELL (widget->parent); - _gtk_menu_shell_activate (menu_shell); - gtk_menu_shell_select_item (GTK_MENU_SHELL (widget->parent), widget); + gtk_menu_shell_select_item (menu_shell, widget); _gtk_menu_item_popup_submenu (widget, FALSE); gtk_menu_shell_select_first (GTK_MENU_SHELL (menu_item->submenu), TRUE); @@ -1732,13 +1769,16 @@ gtk_menu_item_real_popup_submenu (GtkWidget *widget, gboolean remember_exact_time) { GtkMenuItem *menu_item = GTK_MENU_ITEM (widget); + GtkWidget *parent; + + parent = gtk_widget_get_parent (widget); - if (gtk_widget_is_sensitive (menu_item->submenu) && widget->parent) + if (gtk_widget_is_sensitive (menu_item->submenu) && parent) { gboolean take_focus; GtkMenuPositionFunc menu_position_func; - take_focus = gtk_menu_shell_get_take_focus (GTK_MENU_SHELL (widget->parent)); + take_focus = gtk_menu_shell_get_take_focus (GTK_MENU_SHELL (parent)); gtk_menu_shell_set_take_focus (GTK_MENU_SHELL (menu_item->submenu), take_focus); @@ -1764,17 +1804,17 @@ gtk_menu_item_real_popup_submenu (GtkWidget *widget, * positioning function instead which places the submenu at the * mouse cursor. */ - if (widget->window) + if (gtk_widget_get_window (widget)) menu_position_func = gtk_menu_item_position_menu; else menu_position_func = NULL; gtk_menu_popup (GTK_MENU (menu_item->submenu), - widget->parent, + parent, widget, menu_position_func, menu_item, - GTK_MENU_SHELL (widget->parent)->button, + GTK_MENU_SHELL (parent)->button, 0); } @@ -1792,7 +1832,7 @@ gtk_menu_item_popup_timeout (gpointer data) menu_item = GTK_MENU_ITEM (data); - parent = GTK_WIDGET (menu_item)->parent; + parent = gtk_widget_get_parent (GTK_WIDGET (menu_item)); if ((GTK_IS_MENU_SHELL (parent) && GTK_MENU_SHELL (parent)->active) || (GTK_IS_MENU (parent) && GTK_MENU (parent)->torn_off)) @@ -1810,9 +1850,12 @@ gtk_menu_item_popup_timeout (gpointer data) static gint get_popup_delay (GtkWidget *widget) { - if (GTK_IS_MENU_SHELL (widget->parent)) + GtkWidget *parent; + + parent = gtk_widget_get_parent (widget); + if (GTK_IS_MENU_SHELL (parent)) { - return _gtk_menu_shell_get_popup_delay (GTK_MENU_SHELL (widget->parent)); + return _gtk_menu_shell_get_popup_delay (GTK_MENU_SHELL (parent)); } else { @@ -1907,7 +1950,7 @@ get_offsets (GtkMenu *menu, "vertical-padding", &vertical_padding, NULL); - *vertical_offset -= GTK_WIDGET (menu)->style->ythickness; + *vertical_offset -= gtk_widget_get_style (GTK_WIDGET (menu))->ythickness; *vertical_offset -= vertical_padding; *horizontal_offset += horizontal_padding; } @@ -1919,9 +1962,12 @@ gtk_menu_item_position_menu (GtkMenu *menu, gboolean *push_in, gpointer user_data) { + GtkAllocation allocation; GtkMenuItem *menu_item; GtkWidget *widget; GtkMenuItem *parent_menu_item; + GtkRequisition requisition; + GtkWidget *parent; GdkScreen *screen; gint twidth, theight; gint tx, ty; @@ -1932,7 +1978,6 @@ gtk_menu_item_position_menu (GtkMenu *menu, gint vertical_offset; gint parent_xthickness; gint available_left, available_right; - GtkRequisition requisition; g_return_if_fail (menu != NULL); g_return_if_fail (x != NULL); @@ -1947,7 +1992,6 @@ gtk_menu_item_position_menu (GtkMenu *menu, direction = gtk_widget_get_direction (widget); gtk_size_request_get_size (GTK_SIZE_REQUEST (menu), &requisition, NULL); - twidth = requisition.width; theight = requisition.height; @@ -1957,28 +2001,32 @@ gtk_menu_item_position_menu (GtkMenu *menu, monitor_num = 0; gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor); - if (!gdk_window_get_origin (widget->window, &tx, &ty)) + if (!gdk_window_get_origin (gtk_widget_get_window (widget), + &tx, &ty)) { g_warning ("Menu not on screen"); return; } - tx += widget->allocation.x; - ty += widget->allocation.y; + gtk_widget_get_allocation (widget, &allocation); + + tx += allocation.x; + ty += allocation.y; get_offsets (menu, &horizontal_offset, &vertical_offset); available_left = tx - monitor.x; - available_right = monitor.x + monitor.width - (tx + widget->allocation.width); + available_right = monitor.x + monitor.width - (tx + allocation.width); - if (GTK_IS_MENU_BAR (widget->parent)) + parent = gtk_widget_get_parent (widget); + if (GTK_IS_MENU_BAR (parent)) { menu_item->from_menubar = TRUE; } - else if (GTK_IS_MENU (widget->parent)) + else if (GTK_IS_MENU (parent)) { - if (GTK_MENU (widget->parent)->parent_menu_item) - menu_item->from_menubar = GTK_MENU_ITEM (GTK_MENU (widget->parent)->parent_menu_item)->from_menubar; + if (GTK_MENU (parent)->parent_menu_item) + menu_item->from_menubar = GTK_MENU_ITEM (GTK_MENU (parent)->parent_menu_item)->from_menubar; else menu_item->from_menubar = FALSE; } @@ -1995,27 +2043,27 @@ gtk_menu_item_position_menu (GtkMenu *menu, else { menu_item->submenu_direction = GTK_DIRECTION_LEFT; - tx += widget->allocation.width - twidth; + tx += allocation.width - twidth; } - if ((ty + widget->allocation.height + theight) <= monitor.y + monitor.height) - ty += widget->allocation.height; + if ((ty + allocation.height + theight) <= monitor.y + monitor.height) + ty += allocation.height; else if ((ty - theight) >= monitor.y) ty -= theight; - else if (monitor.y + monitor.height - (ty + widget->allocation.height) > ty) - ty += widget->allocation.height; + else if (monitor.y + monitor.height - (ty + allocation.height) > ty) + ty += allocation.height; else ty -= theight; break; case GTK_LEFT_RIGHT: - if (GTK_IS_MENU (widget->parent)) - parent_menu_item = GTK_MENU_ITEM (GTK_MENU (widget->parent)->parent_menu_item); + if (GTK_IS_MENU (parent)) + parent_menu_item = GTK_MENU_ITEM (GTK_MENU (parent)->parent_menu_item); else parent_menu_item = NULL; - - parent_xthickness = widget->parent->style->xthickness; - if (parent_menu_item && !GTK_MENU (widget->parent)->torn_off) + parent_xthickness = gtk_widget_get_style (parent)->xthickness; + + if (parent_menu_item && !GTK_MENU (parent)->torn_off) { menu_item->submenu_direction = parent_menu_item->submenu_direction; } @@ -2036,14 +2084,14 @@ gtk_menu_item_position_menu (GtkMenu *menu, else { menu_item->submenu_direction = GTK_DIRECTION_RIGHT; - tx += widget->allocation.width + parent_xthickness + horizontal_offset; + tx += allocation.width + parent_xthickness + horizontal_offset; } break; case GTK_DIRECTION_RIGHT: - if (tx + widget->allocation.width + parent_xthickness + horizontal_offset + twidth <= monitor.x + monitor.width || + if (tx + allocation.width + parent_xthickness + horizontal_offset + twidth <= monitor.x + monitor.width || available_right >= available_left) - tx += widget->allocation.width + parent_xthickness + horizontal_offset; + tx += allocation.width + parent_xthickness + horizontal_offset; else { menu_item->submenu_direction = GTK_DIRECTION_LEFT; @@ -2158,9 +2206,12 @@ static gboolean gtk_menu_item_can_activate_accel (GtkWidget *widget, guint signal_id) { + GtkWidget *parent; + + parent = gtk_widget_get_parent (widget); /* Chain to the parent GtkMenu for further checks */ return (gtk_widget_is_sensitive (widget) && gtk_widget_get_visible (widget) && - widget->parent && gtk_widget_can_activate_accel (widget->parent, signal_id)); + parent && gtk_widget_can_activate_accel (parent, signal_id)); } static void @@ -2189,7 +2240,11 @@ gtk_menu_item_parent_set (GtkWidget *widget, GtkWidget *previous_parent) { GtkMenuItem *menu_item = GTK_MENU_ITEM (widget); - GtkMenu *menu = GTK_IS_MENU (widget->parent) ? GTK_MENU (widget->parent) : NULL; + GtkMenu *menu; + GtkWidget *parent; + + parent = gtk_widget_get_parent (widget); + menu = GTK_IS_MENU (parent) ? GTK_MENU (parent) : NULL; if (menu) _gtk_menu_item_refresh_accel_path (menu_item, @@ -2277,6 +2332,7 @@ void gtk_menu_item_set_accel_path (GtkMenuItem *menu_item, const gchar *accel_path) { + GtkWidget *parent; GtkWidget *widget; g_return_if_fail (GTK_IS_MENU_ITEM (menu_item)); @@ -2292,9 +2348,10 @@ gtk_menu_item_set_accel_path (GtkMenuItem *menu_item, gtk_widget_set_accel_path (widget, NULL, NULL); /* install accelerators associated with new path */ - if (GTK_IS_MENU (widget->parent)) + parent = gtk_widget_get_parent (widget); + if (GTK_IS_MENU (parent)) { - GtkMenu *menu = GTK_MENU (widget->parent); + GtkMenu *menu = GTK_MENU (parent); if (menu->accel_group) _gtk_menu_item_refresh_accel_path (GTK_MENU_ITEM (widget), diff --git a/gtk/gtkmenushell.c b/gtk/gtkmenushell.c index 3fb8ee6a96..31f5f99619 100644 --- a/gtk/gtkmenushell.c +++ b/gtk/gtkmenushell.c @@ -515,15 +515,19 @@ gtk_menu_shell_deactivate (GtkMenuShell *menu_shell) static void gtk_menu_shell_realize (GtkWidget *widget) { + GtkAllocation allocation; + GdkWindow *window; GdkWindowAttr attributes; gint attributes_mask; gtk_widget_set_realized (widget, TRUE); - attributes.x = widget->allocation.x; - attributes.y = widget->allocation.y; - attributes.width = widget->allocation.width; - attributes.height = widget->allocation.height; + gtk_widget_get_allocation (widget, &allocation); + + attributes.x = allocation.x; + attributes.y = allocation.y; + attributes.width = allocation.width; + attributes.height = allocation.height; attributes.window_type = GDK_WINDOW_CHILD; attributes.wclass = GDK_INPUT_OUTPUT; attributes.visual = gtk_widget_get_visual (widget); @@ -537,11 +541,14 @@ gtk_menu_shell_realize (GtkWidget *widget) GDK_LEAVE_NOTIFY_MASK); attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; - widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); - gdk_window_set_user_data (widget->window, widget); - widget->style = gtk_style_attach (widget->style, widget->window); - gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL); + window = gdk_window_new (gtk_widget_get_parent_window (widget), + &attributes, attributes_mask); + gtk_widget_set_window (widget, window); + gdk_window_set_user_data (window, widget); + + gtk_widget_style_attach (widget); + gtk_style_set_background (gtk_widget_get_style (widget), window, GTK_STATE_NORMAL); } void @@ -567,6 +574,7 @@ gtk_menu_shell_button_press (GtkWidget *widget, { GtkMenuShell *menu_shell; GtkWidget *menu_item; + GtkWidget *parent; if (event->type != GDK_BUTTON_PRESS) return FALSE; @@ -578,19 +586,21 @@ gtk_menu_shell_button_press (GtkWidget *widget, menu_item = gtk_menu_shell_get_item (menu_shell, (GdkEvent *)event); - if (menu_item && _gtk_menu_item_is_selectable (menu_item) && - menu_item != GTK_MENU_SHELL (menu_item->parent)->active_menu_item) + if (menu_item && _gtk_menu_item_is_selectable (menu_item)) { - /* select the menu item *before* activating the shell, so submenus - * which might be open are closed the friendly way. If we activate - * (and thus grab) this menu shell first, we might get grab_broken - * events which will close the entire menu hierarchy. Selecting the - * menu item also fixes up the state as if enter_notify() would - * have run before (which normally selects the item). - */ - if (GTK_MENU_SHELL_GET_CLASS (menu_item->parent)->submenu_placement != GTK_TOP_BOTTOM) + parent = gtk_widget_get_parent (menu_item); + + if (menu_item != GTK_MENU_SHELL (parent)->active_menu_item) { - gtk_menu_shell_select_item (GTK_MENU_SHELL (menu_item->parent), menu_item); + /* select the menu item *before* activating the shell, so submenus + * which might be open are closed the friendly way. If we activate + * (and thus grab) this menu shell first, we might get grab_broken + * events which will close the entire menu hierarchy. Selecting the + * menu item also fixes up the state as if enter_notify() would + * have run before (which normally selects the item). + */ + if (GTK_MENU_SHELL_GET_CLASS (parent)->submenu_placement != GTK_TOP_BOTTOM) + gtk_menu_shell_select_item (GTK_MENU_SHELL (parent), menu_item); } } @@ -603,7 +613,7 @@ gtk_menu_shell_button_press (GtkWidget *widget, if (menu_item) { if (_gtk_menu_item_is_selectable (menu_item) && - menu_item->parent == widget && + gtk_widget_get_parent (menu_item) == widget && menu_item != menu_shell->active_menu_item) { _gtk_menu_shell_activate (menu_shell); @@ -656,7 +666,7 @@ gtk_menu_shell_button_press (GtkWidget *widget, _gtk_menu_item_popup_submenu (menu_item, FALSE); - priv = GTK_MENU_SHELL_GET_PRIVATE (menu_item->parent); + priv = GTK_MENU_SHELL_GET_PRIVATE (gtk_widget_get_parent (menu_item)); priv->activated_submenu = TRUE; } @@ -927,6 +937,7 @@ gtk_menu_shell_enter_notify (GtkWidget *widget, if (menu_shell->active) { GtkWidget *menu_item; + GtkWidget *parent; menu_item = gtk_get_event_widget ((GdkEvent*) event); @@ -944,7 +955,8 @@ gtk_menu_shell_enter_notify (GtkWidget *widget, return TRUE; } - if (menu_item->parent == widget && + parent = gtk_widget_get_parent (menu_item); + if (parent == widget && GTK_IS_MENU_ITEM (menu_item)) { if (menu_shell->ignore_enter) @@ -968,7 +980,7 @@ gtk_menu_shell_enter_notify (GtkWidget *widget, { GtkMenuShellPrivate *priv; - priv = GTK_MENU_SHELL_GET_PRIVATE (menu_item->parent); + priv = GTK_MENU_SHELL_GET_PRIVATE (parent); priv->activated_submenu = TRUE; if (!gtk_widget_get_visible (GTK_MENU_ITEM (menu_item)->submenu)) @@ -1153,7 +1165,7 @@ gtk_menu_shell_is_item (GtkMenuShell *menu_shell, g_return_val_if_fail (GTK_IS_MENU_SHELL (menu_shell), FALSE); g_return_val_if_fail (child != NULL, FALSE); - parent = child->parent; + parent = gtk_widget_get_parent (child); while (GTK_IS_MENU_SHELL (parent)) { if (parent == (GtkWidget*) menu_shell) @@ -1173,7 +1185,7 @@ gtk_menu_shell_get_item (GtkMenuShell *menu_shell, menu_item = gtk_get_event_widget ((GdkEvent*) event); while (menu_item && !GTK_IS_MENU_ITEM (menu_item)) - menu_item = menu_item->parent; + menu_item = gtk_widget_get_parent (menu_item); if (menu_item && gtk_menu_shell_is_item (menu_shell, menu_item)) return menu_item; diff --git a/gtk/gtkmenutoolbutton.c b/gtk/gtkmenutoolbutton.c index 9e8cfc45da..a7d792b510 100644 --- a/gtk/gtkmenutoolbutton.c +++ b/gtk/gtkmenutoolbutton.c @@ -67,6 +67,7 @@ gtk_menu_tool_button_construct_contents (GtkMenuToolButton *button) { GtkMenuToolButtonPrivate *priv = button->priv; GtkWidget *box; + GtkWidget *parent; GtkOrientation orientation; orientation = gtk_tool_item_get_orientation (GTK_TOOL_ITEM (button)); @@ -82,19 +83,21 @@ gtk_menu_tool_button_construct_contents (GtkMenuToolButton *button) gtk_arrow_set (GTK_ARROW (priv->arrow), GTK_ARROW_RIGHT, GTK_SHADOW_NONE); } - if (priv->button && priv->button->parent) + parent = gtk_widget_get_parent (priv->button); + if (priv->button && parent) { g_object_ref (priv->button); - gtk_container_remove (GTK_CONTAINER (priv->button->parent), + gtk_container_remove (GTK_CONTAINER (parent), priv->button); gtk_container_add (GTK_CONTAINER (box), priv->button); g_object_unref (priv->button); } - if (priv->arrow_button && priv->arrow_button->parent) + parent = gtk_widget_get_parent (priv->arrow_button); + if (priv->arrow_button && parent) { g_object_ref (priv->arrow_button); - gtk_container_remove (GTK_CONTAINER (priv->arrow_button->parent), + gtk_container_remove (GTK_CONTAINER (parent), priv->arrow_button); gtk_box_pack_end (GTK_BOX (box), priv->arrow_button, FALSE, FALSE, 0); @@ -253,6 +256,7 @@ menu_position_func (GtkMenu *menu, GtkMenuToolButton *button) { GtkMenuToolButtonPrivate *priv = button->priv; + GtkAllocation arrow_allocation; GtkWidget *widget = GTK_WIDGET (button); GtkRequisition req; GtkRequisition menu_req; @@ -261,35 +265,42 @@ menu_position_func (GtkMenu *menu, GdkRectangle monitor; gint monitor_num; GdkScreen *screen; + GdkWindow *window; gtk_widget_size_request (GTK_WIDGET (priv->menu), &menu_req); orientation = gtk_tool_item_get_orientation (GTK_TOOL_ITEM (button)); direction = gtk_widget_get_direction (widget); + window = gtk_widget_get_window (widget); screen = gtk_widget_get_screen (GTK_WIDGET (menu)); - monitor_num = gdk_screen_get_monitor_at_window (screen, widget->window); + monitor_num = gdk_screen_get_monitor_at_window (screen, window); if (monitor_num < 0) monitor_num = 0; gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor); if (orientation == GTK_ORIENTATION_HORIZONTAL) { - gdk_window_get_origin (widget->window, x, y); - *x += widget->allocation.x; - *y += widget->allocation.y; + GtkAllocation allocation; + + gtk_widget_get_allocation (widget, &allocation); + gtk_widget_get_allocation (priv->arrow_button, &arrow_allocation); + + gdk_window_get_origin (window, x, y); + *x += allocation.x; + *y += allocation.y; if (direction == GTK_TEXT_DIR_LTR) - *x += MAX (widget->allocation.width - menu_req.width, 0); - else if (menu_req.width > widget->allocation.width) - *x -= menu_req.width - widget->allocation.width; + *x += MAX (allocation.width - menu_req.width, 0); + else if (menu_req.width > allocation.width) + *x -= menu_req.width - allocation.width; - if ((*y + priv->arrow_button->allocation.height + menu_req.height) <= monitor.y + monitor.height) - *y += priv->arrow_button->allocation.height; + if ((*y + arrow_allocation.height + menu_req.height) <= monitor.y + monitor.height) + *y += arrow_allocation.height; else if ((*y - menu_req.height) >= monitor.y) *y -= menu_req.height; - else if (monitor.y + monitor.height - (*y + priv->arrow_button->allocation.height) > *y) - *y += priv->arrow_button->allocation.height; + else if (monitor.y + monitor.height - (*y + arrow_allocation.height) > *y) + *y += arrow_allocation.height; else *y -= menu_req.height; } @@ -298,14 +309,16 @@ menu_position_func (GtkMenu *menu, gdk_window_get_origin (GTK_BUTTON (priv->arrow_button)->event_window, x, y); gtk_widget_size_request (priv->arrow_button, &req); + gtk_widget_get_allocation (priv->arrow_button, &arrow_allocation); + if (direction == GTK_TEXT_DIR_LTR) - *x += priv->arrow_button->allocation.width; + *x += arrow_allocation.width; else *x -= menu_req.width; if (*y + menu_req.height > monitor.y + monitor.height && - *y + priv->arrow_button->allocation.height - monitor.y > monitor.y + monitor.height - *y) - *y += priv->arrow_button->allocation.height - menu_req.height; + *y + arrow_allocation.height - monitor.y > monitor.y + monitor.height - *y) + *y += arrow_allocation.height - menu_req.height; } *push_in = FALSE; diff --git a/gtk/gtkmessagedialog.c b/gtk/gtkmessagedialog.c index 9220efc432..5458bd54f1 100644 --- a/gtk/gtkmessagedialog.c +++ b/gtk/gtkmessagedialog.c @@ -95,7 +95,7 @@ * </refsect2> */ -struct _GtkMessageDialogPriv +struct _GtkMessageDialogPrivate { GtkWidget *image; GtkWidget *label; @@ -320,7 +320,7 @@ gtk_message_dialog_class_init (GtkMessageDialogClass *class) GTK_TYPE_WIDGET, GTK_PARAM_READABLE)); - g_type_class_add_private (gobject_class, sizeof (GtkMessageDialogPriv)); + g_type_class_add_private (gobject_class, sizeof (GtkMessageDialogPrivate)); } static void @@ -329,11 +329,11 @@ gtk_message_dialog_init (GtkMessageDialog *dialog) GtkWidget *hbox; GtkDialog *message_dialog = GTK_DIALOG (dialog); GtkWidget *action_area, *content_area; - GtkMessageDialogPriv *priv; + GtkMessageDialogPrivate *priv; dialog->priv = G_TYPE_INSTANCE_GET_PRIVATE (dialog, GTK_TYPE_MESSAGE_DIALOG, - GtkMessageDialogPriv); + GtkMessageDialogPrivate); priv = dialog->priv; content_area = gtk_dialog_get_content_area (message_dialog); @@ -393,7 +393,7 @@ gtk_message_dialog_init (GtkMessageDialog *dialog) static void setup_primary_label_font (GtkMessageDialog *dialog) { - GtkMessageDialogPriv *priv = dialog->priv; + GtkMessageDialogPrivate *priv = dialog->priv; gint size; PangoFontDescription *font_desc; @@ -402,7 +402,7 @@ setup_primary_label_font (GtkMessageDialog *dialog) if (priv->has_secondary_text && !priv->has_primary_markup) { - size = pango_font_description_get_size (priv->label->style->font_desc); + size = pango_font_description_get_size (gtk_widget_get_style (priv->label)->font_desc); font_desc = pango_font_description_new (); pango_font_description_set_weight (font_desc, PANGO_WEIGHT_BOLD); pango_font_description_set_size (font_desc, size * PANGO_SCALE_LARGE); @@ -415,7 +415,7 @@ static void setup_type (GtkMessageDialog *dialog, GtkMessageType type) { - GtkMessageDialogPriv *priv = dialog->priv; + GtkMessageDialogPrivate *priv = dialog->priv; const gchar *stock_id = NULL; AtkObject *atk_obj; @@ -472,7 +472,7 @@ gtk_message_dialog_set_property (GObject *object, GParamSpec *pspec) { GtkMessageDialog *dialog = GTK_MESSAGE_DIALOG (object); - GtkMessageDialogPriv *priv = dialog->priv; + GtkMessageDialogPrivate *priv = dialog->priv; switch (prop_id) { @@ -539,7 +539,7 @@ gtk_message_dialog_get_property (GObject *object, GParamSpec *pspec) { GtkMessageDialog *dialog = GTK_MESSAGE_DIALOG (object); - GtkMessageDialogPriv *priv = dialog->priv; + GtkMessageDialogPrivate *priv = dialog->priv; switch (prop_id) { @@ -729,7 +729,7 @@ void gtk_message_dialog_set_image (GtkMessageDialog *dialog, GtkWidget *image) { - GtkMessageDialogPriv *priv; + GtkMessageDialogPrivate *priv; GtkWidget *parent; g_return_if_fail (GTK_IS_MESSAGE_DIALOG (dialog)); @@ -745,7 +745,7 @@ gtk_message_dialog_set_image (GtkMessageDialog *dialog, priv->message_type = GTK_MESSAGE_OTHER; - parent = priv->image->parent; + parent = gtk_widget_get_parent (priv->image); gtk_container_add (GTK_CONTAINER (parent), image); gtk_container_remove (GTK_CONTAINER (parent), priv->image); gtk_box_reorder_child (GTK_BOX (parent), image, 0); @@ -788,7 +788,7 @@ void gtk_message_dialog_set_markup (GtkMessageDialog *message_dialog, const gchar *str) { - GtkMessageDialogPriv *priv; + GtkMessageDialogPrivate *priv; g_return_if_fail (GTK_IS_MESSAGE_DIALOG (message_dialog)); @@ -819,7 +819,7 @@ gtk_message_dialog_format_secondary_text (GtkMessageDialog *message_dialog, { va_list args; gchar *msg = NULL; - GtkMessageDialogPriv *priv; + GtkMessageDialogPrivate *priv; g_return_if_fail (GTK_IS_MESSAGE_DIALOG (message_dialog)); @@ -883,7 +883,7 @@ gtk_message_dialog_format_secondary_markup (GtkMessageDialog *message_dialog, { va_list args; gchar *msg = NULL; - GtkMessageDialogPriv *priv; + GtkMessageDialogPrivate *priv; g_return_if_fail (GTK_IS_MESSAGE_DIALOG (message_dialog)); @@ -1005,7 +1005,7 @@ gtk_message_dialog_style_set (GtkWidget *widget, GtkWidget *parent; gint border_width; - parent = gtk_message_dialog_get_image (GTK_MESSAGE_DIALOG (widget))->parent; + parent = gtk_widget_get_parent (gtk_message_dialog_get_image (dialog)); if (parent) { diff --git a/gtk/gtkmessagedialog.h b/gtk/gtkmessagedialog.h index fba60e21ec..1905d6c6bf 100644 --- a/gtk/gtkmessagedialog.h +++ b/gtk/gtkmessagedialog.h @@ -44,16 +44,16 @@ G_BEGIN_DECLS #define GTK_IS_MESSAGE_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_MESSAGE_DIALOG)) #define GTK_MESSAGE_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_MESSAGE_DIALOG, GtkMessageDialogClass)) -typedef struct _GtkMessageDialog GtkMessageDialog; -typedef struct _GtkMessageDialogPriv GtkMessageDialogPriv; -typedef struct _GtkMessageDialogClass GtkMessageDialogClass; +typedef struct _GtkMessageDialog GtkMessageDialog; +typedef struct _GtkMessageDialogPrivate GtkMessageDialogPrivate; +typedef struct _GtkMessageDialogClass GtkMessageDialogClass; struct _GtkMessageDialog { GtkDialog parent_instance; /*< private >*/ - GtkMessageDialogPriv *priv; + GtkMessageDialogPrivate *priv; }; struct _GtkMessageDialogClass diff --git a/gtk/gtkmisc.c b/gtk/gtkmisc.c index fc711aade0..94d3052b61 100644 --- a/gtk/gtkmisc.c +++ b/gtk/gtkmisc.c @@ -31,7 +31,7 @@ #include "gtkprivate.h" -struct _GtkMiscPriv +struct _GtkMiscPrivate { gfloat xalign; gfloat yalign; @@ -115,17 +115,17 @@ gtk_misc_class_init (GtkMiscClass *class) 0, GTK_PARAM_READWRITE)); - g_type_class_add_private (class, sizeof (GtkMiscPriv)); + g_type_class_add_private (class, sizeof (GtkMiscPrivate)); } static void gtk_misc_init (GtkMisc *misc) { - GtkMiscPriv *priv; + GtkMiscPrivate *priv; misc->priv = G_TYPE_INSTANCE_GET_PRIVATE (misc, GTK_TYPE_MISC, - GtkMiscPriv); + GtkMiscPrivate); priv = misc->priv; priv->xalign = 0.5; @@ -141,7 +141,7 @@ gtk_misc_set_property (GObject *object, GParamSpec *pspec) { GtkMisc *misc = GTK_MISC (object); - GtkMiscPriv *priv = misc->priv; + GtkMiscPrivate *priv = misc->priv; switch (prop_id) { @@ -170,7 +170,7 @@ gtk_misc_get_property (GObject *object, GParamSpec *pspec) { GtkMisc *misc = GTK_MISC (object); - GtkMiscPriv *priv = misc->priv; + GtkMiscPrivate *priv = misc->priv; switch (prop_id) { @@ -197,7 +197,7 @@ gtk_misc_set_alignment (GtkMisc *misc, gfloat xalign, gfloat yalign) { - GtkMiscPriv *priv; + GtkMiscPrivate *priv; GtkWidget *widget; g_return_if_fail (GTK_IS_MISC (misc)); @@ -250,7 +250,7 @@ gtk_misc_get_alignment (GtkMisc *misc, gfloat *xalign, gfloat *yalign) { - GtkMiscPriv *priv; + GtkMiscPrivate *priv; g_return_if_fail (GTK_IS_MISC (misc)); @@ -267,7 +267,7 @@ gtk_misc_set_padding (GtkMisc *misc, gint xpad, gint ypad) { - GtkMiscPriv *priv; + GtkMiscPrivate *priv; GtkRequisition *requisition; g_return_if_fail (GTK_IS_MISC (misc)); @@ -319,7 +319,7 @@ gtk_misc_get_padding (GtkMisc *misc, gint *xpad, gint *ypad) { - GtkMiscPriv *priv; + GtkMiscPrivate *priv; g_return_if_fail (GTK_IS_MISC (misc)); diff --git a/gtk/gtkmisc.h b/gtk/gtkmisc.h index 697f8a6185..fe6b7c9df8 100644 --- a/gtk/gtkmisc.h +++ b/gtk/gtkmisc.h @@ -45,16 +45,16 @@ G_BEGIN_DECLS #define GTK_MISC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_MISC, GtkMiscClass)) -typedef struct _GtkMisc GtkMisc; -typedef struct _GtkMiscPriv GtkMiscPriv; -typedef struct _GtkMiscClass GtkMiscClass; +typedef struct _GtkMisc GtkMisc; +typedef struct _GtkMiscPrivate GtkMiscPrivate; +typedef struct _GtkMiscClass GtkMiscClass; struct _GtkMisc { GtkWidget widget; /* <private> */ - GtkMiscPriv *priv; + GtkMiscPrivate *priv; }; struct _GtkMiscClass diff --git a/gtk/gtkmnemonichash.c b/gtk/gtkmnemonichash.c index 6f85d04f6e..37ee01644a 100644 --- a/gtk/gtkmnemonichash.c +++ b/gtk/gtkmnemonichash.c @@ -113,6 +113,7 @@ _gtk_mnemonic_hash_activate (GtkMnemonicHash *mnemonic_hash, { GSList *list, *targets; GtkWidget *widget, *chosen_widget; + GdkWindow *window; gboolean overloaded; targets = g_hash_table_lookup (mnemonic_hash->hash, @@ -125,11 +126,11 @@ _gtk_mnemonic_hash_activate (GtkMnemonicHash *mnemonic_hash, for (list = targets; list; list = list->next) { widget = GTK_WIDGET (list->data); - + window = gtk_widget_get_window (widget); + if (gtk_widget_is_sensitive (widget) && gtk_widget_get_mapped (widget) && - widget->window && - gdk_window_is_viewable (widget->window)) + window && gdk_window_is_viewable (window)) { if (chosen_widget) { diff --git a/gtk/gtkmountoperation-stub.c b/gtk/gtkmountoperation-stub.c index c7b8d1a9ed..27b09ae7f9 100644 --- a/gtk/gtkmountoperation-stub.c +++ b/gtk/gtkmountoperation-stub.c @@ -61,7 +61,7 @@ _gtk_mount_operation_kill_process (GPid pid, g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, - _("Cannot kill process with pid %d. Operation is not implemented."), + _("Cannot kill process with PID %d. Operation is not implemented."), pid); return FALSE; } diff --git a/gtk/gtkmountoperation-x11.c b/gtk/gtkmountoperation-x11.c index 3ba7930808..af0c291bd3 100644 --- a/gtk/gtkmountoperation-x11.c +++ b/gtk/gtkmountoperation-x11.c @@ -960,7 +960,7 @@ _gtk_mount_operation_kill_process (GPid pid, g_set_error (error, G_IO_ERROR, g_io_error_from_errno (errsv), - _("Cannot end process with pid %d: %s"), + _("Cannot end process with PID %d: %s"), pid, g_strerror (errsv)); } diff --git a/gtk/gtkmountoperation.c b/gtk/gtkmountoperation.c index e30d13c7b0..c2489ce59d 100644 --- a/gtk/gtkmountoperation.c +++ b/gtk/gtkmountoperation.c @@ -881,7 +881,7 @@ add_pid_to_process_list_store (GtkMountOperation *mount_operation, &pixbuf); if (name == NULL) - name = g_strdup_printf (_("Unknown Application (pid %d)"), pid); + name = g_strdup_printf (_("Unknown Application (PID %d)"), pid); if (command_line == NULL) command_line = g_strdup (""); diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c index 44d1c9a1d6..5cd2998b73 100644 --- a/gtk/gtknotebook.c +++ b/gtk/gtknotebook.c @@ -65,7 +65,7 @@ enum { N_ACTION_WIDGETS }; -struct _GtkNotebookPriv +struct _GtkNotebookPrivate { GtkNotebookDragOperation operation; GtkNotebookPage *cur_page; @@ -1038,20 +1038,20 @@ gtk_notebook_class_init (GtkNotebookClass *class) add_tab_bindings (binding_set, GDK_CONTROL_MASK, GTK_DIR_TAB_FORWARD); add_tab_bindings (binding_set, GDK_CONTROL_MASK | GDK_SHIFT_MASK, GTK_DIR_TAB_BACKWARD); - g_type_class_add_private (class, sizeof (GtkNotebookPriv)); + g_type_class_add_private (class, sizeof (GtkNotebookPrivate)); } static void gtk_notebook_init (GtkNotebook *notebook) { - GtkNotebookPriv *priv; + GtkNotebookPrivate *priv; gtk_widget_set_can_focus (GTK_WIDGET (notebook), TRUE); gtk_widget_set_has_window (GTK_WIDGET (notebook), FALSE); notebook->priv = G_TYPE_INSTANCE_GET_PRIVATE (notebook, GTK_TYPE_NOTEBOOK, - GtkNotebookPriv); + GtkNotebookPrivate); priv = notebook->priv; priv->cur_page = NULL; @@ -1144,7 +1144,7 @@ static gboolean gtk_notebook_select_page (GtkNotebook *notebook, gboolean move_focus) { - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; if (gtk_widget_is_focus (GTK_WIDGET (notebook)) && priv->show_tabs) { @@ -1159,7 +1159,7 @@ static gboolean gtk_notebook_focus_tab (GtkNotebook *notebook, GtkNotebookTab type) { - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; GList *list; if (gtk_widget_is_focus (GTK_WIDGET (notebook)) && priv->show_tabs) @@ -1188,7 +1188,7 @@ static gboolean gtk_notebook_change_current_page (GtkNotebook *notebook, gint offset) { - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; GList *current = NULL; if (!priv->show_tabs) @@ -1234,7 +1234,7 @@ static GtkDirectionType get_effective_direction (GtkNotebook *notebook, GtkDirectionType direction) { - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; /* Remap the directions into the effective direction it would be for a * GTK_POS_TOP notebook @@ -1263,7 +1263,7 @@ get_effective_direction (GtkNotebook *notebook, static gint get_effective_tab_pos (GtkNotebook *notebook) { - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; if (gtk_widget_get_direction (GTK_WIDGET (notebook)) == GTK_TEXT_DIR_RTL) { @@ -1309,7 +1309,7 @@ static void gtk_notebook_move_focus_out (GtkNotebook *notebook, GtkDirectionType direction_type) { - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; GtkDirectionType effective_direction = get_effective_direction (notebook, direction_type); GtkWidget *toplevel; @@ -1339,7 +1339,7 @@ gtk_notebook_move_focus_out (GtkNotebook *notebook, static gint reorder_tab (GtkNotebook *notebook, GList *position, GList *tab) { - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; GList *elem; if (position == tab) @@ -1386,7 +1386,7 @@ gtk_notebook_reorder_tab (GtkNotebook *notebook, GtkDirectionType direction_type, gboolean move_to_last) { - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; GtkDirectionType effective_direction = get_effective_direction (notebook, direction_type); GtkNotebookPage *page; GList *last, *child; @@ -1472,7 +1472,7 @@ static void gtk_notebook_destroy (GtkObject *object) { GtkNotebook *notebook = GTK_NOTEBOOK (object); - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; if (priv->menu) gtk_notebook_popup_disable (notebook); @@ -1541,7 +1541,7 @@ gtk_notebook_get_property (GObject *object, GParamSpec *pspec) { GtkNotebook *notebook = GTK_NOTEBOOK (object); - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; switch (prop_id) { @@ -1602,7 +1602,7 @@ static gboolean gtk_notebook_get_event_window_position (GtkNotebook *notebook, GdkRectangle *rectangle) { - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; GtkWidget *widget = GTK_WIDGET (notebook); guint border_width = gtk_container_get_border_width (GTK_CONTAINER (notebook)); GtkNotebookPage *visible_page = NULL; @@ -1690,7 +1690,7 @@ static void gtk_notebook_map (GtkWidget *widget) { GtkNotebook *notebook = GTK_NOTEBOOK (widget); - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; GtkNotebookPage *page; GList *children; gint i; @@ -1737,7 +1737,7 @@ static void gtk_notebook_unmap (GtkWidget *widget) { GtkNotebook *notebook = GTK_NOTEBOOK (widget); - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; stop_scrolling (notebook); @@ -1752,7 +1752,7 @@ static void gtk_notebook_realize (GtkWidget *widget) { GtkNotebook *notebook = GTK_NOTEBOOK (widget); - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; GdkWindowAttr attributes; gint attributes_mask; GdkRectangle event_window_pos; @@ -1788,7 +1788,7 @@ static void gtk_notebook_unrealize (GtkWidget *widget) { GtkNotebook *notebook = GTK_NOTEBOOK (widget); - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; gdk_window_set_user_data (priv->event_window, NULL); gdk_window_destroy (priv->event_window); @@ -1809,7 +1809,7 @@ gtk_notebook_size_request (GtkWidget *widget, GtkRequisition *requisition) { GtkNotebook *notebook = GTK_NOTEBOOK (widget); - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; GtkNotebookPage *page; GList *children; GtkRequisition child_requisition; @@ -2102,7 +2102,7 @@ gtk_notebook_size_allocate (GtkWidget *widget, GtkAllocation *allocation) { GtkNotebook *notebook = GTK_NOTEBOOK (widget); - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; gint tab_pos = get_effective_tab_pos (notebook); gboolean is_rtl; gint focus_width; @@ -2238,7 +2238,7 @@ gtk_notebook_expose (GtkWidget *widget, GdkEventExpose *event) { GtkNotebook *notebook = GTK_NOTEBOOK (widget); - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; gint i; if (event->window == priv->drag_window) @@ -2312,7 +2312,7 @@ gtk_notebook_expose (GtkWidget *widget, static gboolean gtk_notebook_show_arrows (GtkNotebook *notebook) { - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; gboolean show_arrow = FALSE; GList *children; @@ -2338,7 +2338,7 @@ gtk_notebook_get_arrow_rect (GtkNotebook *notebook, GdkRectangle *rectangle, GtkNotebookArrow arrow) { - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; GdkRectangle event_window_pos; gboolean before = ARROW_IS_BEFORE (arrow); gboolean left = ARROW_IS_LEFT (arrow); @@ -2402,7 +2402,7 @@ gtk_notebook_get_arrow (GtkNotebook *notebook, gint x, gint y) { - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; GdkRectangle arrow_rect; GdkRectangle event_window_pos; gint i; @@ -2440,7 +2440,7 @@ static void gtk_notebook_do_arrow (GtkNotebook *notebook, GtkNotebookArrow arrow) { - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; GtkWidget *widget = GTK_WIDGET (notebook); gboolean is_rtl, left; @@ -2463,7 +2463,7 @@ gtk_notebook_arrow_button_press (GtkNotebook *notebook, GtkNotebookArrow arrow, gint button) { - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; GtkWidget *widget = GTK_WIDGET (notebook); gboolean is_rtl = gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL; gboolean left = (ARROW_IS_LEFT (arrow) && !is_rtl) || @@ -2532,7 +2532,7 @@ gtk_notebook_scroll (GtkWidget *widget, GdkEventScroll *event) { GtkNotebook *notebook = GTK_NOTEBOOK (widget); - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; GtkWidget *child, *event_widget; gint i; @@ -2573,7 +2573,7 @@ gtk_notebook_scroll (GtkWidget *widget, static GList* get_tab_at_pos (GtkNotebook *notebook, gint x, gint y) { - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; GtkNotebookPage *page; GList *children; @@ -2601,7 +2601,7 @@ gtk_notebook_button_press (GtkWidget *widget, GdkEventButton *event) { GtkNotebook *notebook = GTK_NOTEBOOK (widget); - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; GtkNotebookPage *page; GList *tab; GtkNotebookArrow arrow; @@ -2672,7 +2672,7 @@ popup_position_func (GtkMenu *menu, gpointer data) { GtkNotebook *notebook = data; - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; GtkWidget *w; GtkRequisition requisition; @@ -2705,7 +2705,7 @@ static gboolean gtk_notebook_popup_menu (GtkWidget *widget) { GtkNotebook *notebook = GTK_NOTEBOOK (widget); - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; if (priv->menu) { @@ -2722,7 +2722,7 @@ gtk_notebook_popup_menu (GtkWidget *widget) static void stop_scrolling (GtkNotebook *notebook) { - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; if (priv->timer) { @@ -2739,7 +2739,7 @@ static GList* get_drop_position (GtkNotebook *notebook, guint pack) { - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; GList *children, *last_child; GtkNotebookPage *page; gboolean is_rtl; @@ -2800,7 +2800,7 @@ get_drop_position (GtkNotebook *notebook, static void show_drag_window (GtkNotebook *notebook, - GtkNotebookPriv *priv, + GtkNotebookPrivate *priv, GtkNotebookPage *page, GdkDevice *device) { @@ -2848,7 +2848,7 @@ show_drag_window (GtkNotebook *notebook, */ static void hide_drag_window (GtkNotebook *notebook, - GtkNotebookPriv *priv, + GtkNotebookPrivate *priv, GtkNotebookPage *page) { GtkWidget *widget = GTK_WIDGET (notebook); @@ -2879,7 +2879,7 @@ hide_drag_window (GtkNotebook *notebook, static void gtk_notebook_stop_reorder (GtkNotebook *notebook) { - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; GtkNotebookPage *page; if (priv->operation == DRAG_OPERATION_DETACH) @@ -2931,7 +2931,7 @@ gtk_notebook_button_release (GtkWidget *widget, GdkEventButton *event) { GtkNotebook *notebook; - GtkNotebookPriv *priv; + GtkNotebookPrivate *priv; GtkNotebookPage *page; if (event->type != GDK_BUTTON_RELEASE) @@ -2961,7 +2961,7 @@ gtk_notebook_leave_notify (GtkWidget *widget, GdkEventCrossing *event) { GtkNotebook *notebook = GTK_NOTEBOOK (widget); - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; gint x, y; if (!get_widget_coordinates (widget, (GdkEvent *)event, &x, &y)) @@ -2979,7 +2979,7 @@ gtk_notebook_leave_notify (GtkWidget *widget, static GtkNotebookPointerPosition get_pointer_position (GtkNotebook *notebook) { - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; GtkWidget *widget = GTK_WIDGET (notebook); gint wx, wy, width, height; gboolean is_rtl; @@ -3023,7 +3023,7 @@ static gboolean scroll_notebook_timer (gpointer data) { GtkNotebook *notebook = GTK_NOTEBOOK (data); - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; GtkNotebookPointerPosition pointer_position; GList *element, *first_tab; @@ -3055,7 +3055,7 @@ check_threshold (GtkNotebook *notebook, gint current_x, gint current_y) { - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; GtkWidget *widget; gint dnd_threshold; GdkRectangle rectangle = { 0, }; /* shut up gcc */ @@ -3087,7 +3087,7 @@ gtk_notebook_motion_notify (GtkWidget *widget, GdkEventMotion *event) { GtkNotebook *notebook = GTK_NOTEBOOK (widget); - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; GtkNotebookPage *page; GtkNotebookArrow arrow; GtkNotebookPointerPosition pointer_position; @@ -3239,7 +3239,7 @@ gtk_notebook_draw_focus (GtkWidget *widget, GdkEventExpose *event) { GtkNotebook *notebook = GTK_NOTEBOOK (widget); - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; if (gtk_widget_has_focus (widget) && gtk_widget_is_drawable (widget) && priv->show_tabs && priv->cur_page && @@ -3273,7 +3273,7 @@ gtk_notebook_style_set (GtkWidget *widget, GtkStyle *previous) { GtkNotebook *notebook = GTK_NOTEBOOK (widget); - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; gboolean has_before_previous; gboolean has_before_next; @@ -3328,7 +3328,7 @@ gtk_notebook_drag_begin (GtkWidget *widget, GdkDragContext *context) { GtkNotebook *notebook = GTK_NOTEBOOK (widget); - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; GtkWidget *tab_label; if (priv->dnd_timer) @@ -3366,7 +3366,7 @@ gtk_notebook_drag_end (GtkWidget *widget, GdkDragContext *context) { GtkNotebook *notebook = GTK_NOTEBOOK (widget); - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; gtk_notebook_stop_reorder (notebook); @@ -3401,7 +3401,7 @@ gtk_notebook_drag_failed (GtkWidget *widget, if (result == GTK_DRAG_RESULT_NO_TARGET) { GtkNotebook *notebook = GTK_NOTEBOOK (widget); - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; GtkNotebook *dest_notebook = NULL; GdkDisplay *display; gint x, y; @@ -3425,7 +3425,7 @@ static gboolean gtk_notebook_switch_tab_timeout (gpointer data) { GtkNotebook *notebook = GTK_NOTEBOOK (data); - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; GList *tab; gint x, y; @@ -3453,7 +3453,7 @@ gtk_notebook_drag_motion (GtkWidget *widget, guint time) { GtkNotebook *notebook = GTK_NOTEBOOK (widget); - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; GdkRectangle position; GtkSettings *settings; GtkNotebookArrow arrow; @@ -3540,7 +3540,7 @@ gtk_notebook_drag_leave (GtkWidget *widget, guint time) { GtkNotebook *notebook = GTK_NOTEBOOK (widget); - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; if (priv->switch_tab_timer) { @@ -3579,7 +3579,7 @@ do_detach_tab (GtkNotebook *from, gint x, gint y) { - GtkNotebookPriv *to_priv = to->priv; + GtkNotebookPrivate *to_priv = to->priv; GtkWidget *tab_label, *menu_label; gboolean tab_expand, tab_fill, reorderable, detachable; GList *element; @@ -3645,7 +3645,7 @@ gtk_notebook_drag_data_get (GtkWidget *widget, if (data->target == gdk_atom_intern_static_string ("GTK_NOTEBOOK_TAB")) { GtkNotebook *notebook = GTK_NOTEBOOK (widget); - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; gtk_selection_data_set (data, data->target, @@ -3770,7 +3770,7 @@ gtk_notebook_get_child_property (GtkContainer *container, GParamSpec *pspec) { GtkNotebook *notebook = GTK_NOTEBOOK (container); - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; GList *list; GtkWidget *label; gboolean expand; @@ -3849,7 +3849,7 @@ gtk_notebook_remove (GtkContainer *container, GtkWidget *widget) { GtkNotebook *notebook = GTK_NOTEBOOK (container); - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; GtkNotebookPage *page; GList *children; gint page_num = 0; @@ -3885,7 +3885,7 @@ gtk_notebook_remove (GtkContainer *container, static gboolean focus_tabs_in (GtkNotebook *notebook) { - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; if (priv->show_tabs && priv->cur_page) { @@ -3906,7 +3906,7 @@ focus_tabs_move (GtkNotebook *notebook, GtkDirectionType direction, gint search_direction) { - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; GList *new_page; new_page = gtk_notebook_search_page (notebook, priv->focus_tab, @@ -3936,7 +3936,7 @@ static gboolean focus_child_in (GtkNotebook *notebook, GtkDirectionType direction) { - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; if (priv->cur_page) return gtk_widget_child_focus (priv->cur_page->child, direction); @@ -3949,7 +3949,7 @@ focus_action_in (GtkNotebook *notebook, gint action, GtkDirectionType direction) { - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; if (priv->action_widget[action] && gtk_widget_get_visible (priv->action_widget[action])) @@ -3966,7 +3966,7 @@ gtk_notebook_focus (GtkWidget *widget, GtkDirectionType direction) { GtkNotebook *notebook = GTK_NOTEBOOK (widget); - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; GtkWidget *old_focus_child; GtkDirectionType effective_direction; gint first_action; @@ -4140,7 +4140,7 @@ gtk_notebook_set_focus_child (GtkContainer *container, GtkWidget *child) { GtkNotebook *notebook = GTK_NOTEBOOK (container); - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; GtkWidget *page_child; GtkWidget *toplevel; @@ -4152,7 +4152,7 @@ gtk_notebook_set_focus_child (GtkContainer *container, toplevel = gtk_widget_get_toplevel (GTK_WIDGET (container)); if (toplevel && gtk_widget_is_toplevel (toplevel)) { - page_child = GTK_WINDOW (toplevel)->focus_widget; + page_child = gtk_window_get_focus (GTK_WINDOW (toplevel)); while (page_child) { if (page_child->parent == GTK_WIDGET (container)) @@ -4164,8 +4164,8 @@ gtk_notebook_set_focus_child (GtkContainer *container, if (page->last_focus_child) g_object_remove_weak_pointer (G_OBJECT (page->last_focus_child), (gpointer *)&page->last_focus_child); - - page->last_focus_child = GTK_WINDOW (toplevel)->focus_widget; + + page->last_focus_child = gtk_window_get_focus (GTK_WINDOW (toplevel)); g_object_add_weak_pointer (G_OBJECT (page->last_focus_child), (gpointer *)&page->last_focus_child); break; @@ -4209,7 +4209,7 @@ gtk_notebook_forall (GtkContainer *container, gpointer callback_data) { GtkNotebook *notebook = GTK_NOTEBOOK (container); - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; GList *children; gint i; @@ -4254,7 +4254,7 @@ page_visible_cb (GtkWidget *page, gpointer data) { GtkNotebook *notebook = GTK_NOTEBOOK (data); - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; GList *list; GList *next = NULL; @@ -4282,7 +4282,7 @@ gtk_notebook_real_insert_page (GtkNotebook *notebook, GtkWidget *menu_label, gint position) { - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; GtkNotebookPage *page; gint nchildren; @@ -4392,7 +4392,7 @@ gtk_notebook_real_insert_page (GtkNotebook *notebook, static void gtk_notebook_redraw_tabs (GtkNotebook *notebook) { - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; GtkWidget *widget; GtkNotebookPage *page; GdkRectangle redraw_rect; @@ -4451,7 +4451,7 @@ gtk_notebook_redraw_tabs (GtkNotebook *notebook) static void gtk_notebook_redraw_arrows (GtkNotebook *notebook) { - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; if (gtk_widget_get_mapped (GTK_WIDGET (notebook)) && gtk_notebook_show_arrows (notebook)) @@ -4480,7 +4480,7 @@ gtk_notebook_redraw_arrows (GtkNotebook *notebook) static gboolean gtk_notebook_timer (GtkNotebook *notebook) { - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; gboolean retval = FALSE; if (priv->timer) @@ -4510,7 +4510,7 @@ gtk_notebook_timer (GtkNotebook *notebook) static void gtk_notebook_set_scroll_timer (GtkNotebook *notebook) { - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; GtkWidget *widget = GTK_WIDGET (notebook); if (!priv->timer) @@ -4539,7 +4539,7 @@ gtk_notebook_find_child (GtkNotebook *notebook, GtkWidget *child, const gchar *function) { - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; GList *list = g_list_find_custom (priv->children, child, gtk_notebook_page_compare); @@ -4573,7 +4573,7 @@ static void gtk_notebook_real_remove (GtkNotebook *notebook, GList *list) { - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; GtkNotebookPage *page; GList * next_list; gint need_resize = FALSE; @@ -4654,7 +4654,7 @@ gtk_notebook_real_remove (GtkNotebook *notebook, static void gtk_notebook_update_labels (GtkNotebook *notebook) { - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; GtkNotebookPage *page; GList *list; gchar string[32]; @@ -4705,7 +4705,7 @@ static gint gtk_notebook_real_page_position (GtkNotebook *notebook, GList *list) { - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; GList *work; gint count_start; @@ -4729,7 +4729,7 @@ gtk_notebook_search_page (GtkNotebook *notebook, gint direction, gboolean find_visible) { - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; GtkNotebookPage *page = NULL; GList *old_list = NULL; gint flag = 0; @@ -4801,7 +4801,7 @@ gtk_notebook_paint (GtkWidget *widget, GdkRectangle *area) { GtkNotebook *notebook; - GtkNotebookPriv *priv; + GtkNotebookPrivate *priv; GtkNotebookPage *page; GList *children; gboolean showarrow; @@ -4934,7 +4934,7 @@ gtk_notebook_draw_tab (GtkNotebook *notebook, GtkNotebookPage *page, GdkRectangle *area) { - GtkNotebookPriv *priv; + GtkNotebookPrivate *priv; GdkRectangle child_area; GdkRectangle page_area; GtkStateType state_type; @@ -4982,7 +4982,7 @@ static void gtk_notebook_draw_arrow (GtkNotebook *notebook, GtkNotebookArrow nbarrow) { - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; GtkStateType state_type; GtkShadowType shadow_type; GtkWidget *widget; @@ -5067,7 +5067,7 @@ gtk_notebook_tab_space (GtkNotebook *notebook, gint *max, gint *tab_space) { - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; GtkWidget *widget; GList *children; gint tab_pos = get_effective_tab_pos (notebook); @@ -5230,7 +5230,7 @@ gtk_notebook_calculate_shown_tabs (GtkNotebook *notebook, gint *n, gint *remaining_space) { - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; GtkWidget *widget; GtkContainer *container; GList *children; @@ -5459,7 +5459,7 @@ gtk_notebook_calculate_tabs_allocation (GtkNotebook *notebook, gint min, gint max) { - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; GtkWidget *widget; GtkContainer *container; GtkNotebookPage *page; @@ -5780,7 +5780,7 @@ gtk_notebook_calculate_tabs_allocation (GtkNotebook *notebook, static void gtk_notebook_pages_allocate (GtkNotebook *notebook) { - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; GList *children = NULL; GList *last_child = NULL; gboolean showarrow = FALSE; @@ -5834,7 +5834,7 @@ gtk_notebook_page_allocate (GtkNotebook *notebook, GtkNotebookPage *page) { GtkWidget *widget = GTK_WIDGET (notebook); - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; GtkAllocation child_allocation; GtkRequisition tab_requisition; gint xthickness; @@ -6046,7 +6046,7 @@ gtk_notebook_calc_tabs (GtkNotebook *notebook, static void gtk_notebook_update_tab_states (GtkNotebook *notebook) { - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; GList *list; for (list = priv->children; list != NULL; list = list->next) @@ -6072,7 +6072,7 @@ gtk_notebook_real_switch_page (GtkNotebook *notebook, GtkWidget* child, guint page_num) { - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; GList *list = gtk_notebook_find_child (notebook, GTK_WIDGET (child), NULL); GtkNotebookPage *page = GTK_NOTEBOOK_PAGE (list); gboolean child_has_focus; @@ -6125,7 +6125,7 @@ static void gtk_notebook_switch_page (GtkNotebook *notebook, GtkNotebookPage *page) { - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; guint page_num; if (priv->cur_page == page) @@ -6144,7 +6144,7 @@ static gint gtk_notebook_page_select (GtkNotebook *notebook, gboolean move_focus) { - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; GtkNotebookPage *page; GtkDirectionType dir = GTK_DIR_DOWN; /* Quiet GCC */ gint tab_pos = get_effective_tab_pos (notebook); @@ -6183,7 +6183,7 @@ static void gtk_notebook_switch_focus_tab (GtkNotebook *notebook, GList *new_child) { - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; GList *old_child; GtkNotebookPage *page; @@ -6212,7 +6212,7 @@ static void gtk_notebook_menu_switch_page (GtkWidget *widget, GtkNotebookPage *page) { - GtkNotebookPriv *priv; + GtkNotebookPrivate *priv; GtkNotebook *notebook; GList *children; guint page_num; @@ -6249,7 +6249,7 @@ static void gtk_notebook_menu_item_create (GtkNotebook *notebook, GList *list) { - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; GtkNotebookPage *page; GtkWidget *menu_item; @@ -6287,7 +6287,7 @@ gtk_notebook_menu_detacher (GtkWidget *widget, GtkMenu *menu) { GtkNotebook *notebook = GTK_NOTEBOOK (widget); - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; g_return_if_fail (priv->menu == (GtkWidget*) menu); @@ -6459,7 +6459,7 @@ gtk_notebook_mnemonic_activate_switch_page (GtkWidget *child, gpointer data) { GtkNotebook *notebook = GTK_NOTEBOOK (data); - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; GList *list; list = g_list_find_custom (priv->children, child, @@ -6530,7 +6530,7 @@ void gtk_notebook_remove_page (GtkNotebook *notebook, gint page_num) { - GtkNotebookPriv *priv; + GtkNotebookPrivate *priv; GList *list = NULL; g_return_if_fail (GTK_IS_NOTEBOOK (notebook)); @@ -6567,7 +6567,7 @@ gtk_notebook_remove_page (GtkNotebook *notebook, gint gtk_notebook_get_current_page (GtkNotebook *notebook) { - GtkNotebookPriv *priv; + GtkNotebookPrivate *priv; g_return_val_if_fail (GTK_IS_NOTEBOOK (notebook), -1); @@ -6594,7 +6594,7 @@ GtkWidget* gtk_notebook_get_nth_page (GtkNotebook *notebook, gint page_num) { - GtkNotebookPriv *priv; + GtkNotebookPrivate *priv; GtkNotebookPage *page; GList *list; @@ -6629,7 +6629,7 @@ gtk_notebook_get_nth_page (GtkNotebook *notebook, gint gtk_notebook_get_n_pages (GtkNotebook *notebook) { - GtkNotebookPriv *priv; + GtkNotebookPrivate *priv; g_return_val_if_fail (GTK_IS_NOTEBOOK (notebook), 0); @@ -6653,7 +6653,7 @@ gint gtk_notebook_page_num (GtkNotebook *notebook, GtkWidget *child) { - GtkNotebookPriv *priv; + GtkNotebookPrivate *priv; GList *children; gint num; @@ -6696,7 +6696,7 @@ void gtk_notebook_set_current_page (GtkNotebook *notebook, gint page_num) { - GtkNotebookPriv *priv; + GtkNotebookPrivate *priv; GList *list; g_return_if_fail (GTK_IS_NOTEBOOK (notebook)); @@ -6721,7 +6721,7 @@ gtk_notebook_set_current_page (GtkNotebook *notebook, void gtk_notebook_next_page (GtkNotebook *notebook) { - GtkNotebookPriv *priv; + GtkNotebookPrivate *priv; GList *list; g_return_if_fail (GTK_IS_NOTEBOOK (notebook)); @@ -6749,7 +6749,7 @@ gtk_notebook_next_page (GtkNotebook *notebook) void gtk_notebook_prev_page (GtkNotebook *notebook) { - GtkNotebookPriv *priv; + GtkNotebookPrivate *priv; GList *list; g_return_if_fail (GTK_IS_NOTEBOOK (notebook)); @@ -6793,7 +6793,7 @@ void gtk_notebook_set_show_border (GtkNotebook *notebook, gboolean show_border) { - GtkNotebookPriv *priv; + GtkNotebookPrivate *priv; g_return_if_fail (GTK_IS_NOTEBOOK (notebook)); @@ -6838,7 +6838,7 @@ void gtk_notebook_set_show_tabs (GtkNotebook *notebook, gboolean show_tabs) { - GtkNotebookPriv *priv; + GtkNotebookPrivate *priv; GtkNotebookPage *page; GList *children; gint i; @@ -6918,7 +6918,7 @@ void gtk_notebook_set_tab_pos (GtkNotebook *notebook, GtkPositionType pos) { - GtkNotebookPriv *priv; + GtkNotebookPrivate *priv; g_return_if_fail (GTK_IS_NOTEBOOK (notebook)); @@ -6963,7 +6963,7 @@ void gtk_notebook_set_scrollable (GtkNotebook *notebook, gboolean scrollable) { - GtkNotebookPriv *priv; + GtkNotebookPrivate *priv; g_return_if_fail (GTK_IS_NOTEBOOK (notebook)); @@ -7053,7 +7053,7 @@ gtk_notebook_get_tab_vborder (GtkNotebook *notebook) void gtk_notebook_popup_enable (GtkNotebook *notebook) { - GtkNotebookPriv *priv; + GtkNotebookPrivate *priv; GList *list; g_return_if_fail (GTK_IS_NOTEBOOK (notebook)); @@ -7086,7 +7086,7 @@ gtk_notebook_popup_enable (GtkNotebook *notebook) void gtk_notebook_popup_disable (GtkNotebook *notebook) { - GtkNotebookPriv *priv; + GtkNotebookPrivate *priv; g_return_if_fail (GTK_IS_NOTEBOOK (notebook)); @@ -7163,7 +7163,7 @@ gtk_notebook_set_tab_label (GtkNotebook *notebook, GtkWidget *child, GtkWidget *tab_label) { - GtkNotebookPriv *priv; + GtkNotebookPrivate *priv; GtkNotebookPage *page; GList *list; @@ -7323,7 +7323,7 @@ gtk_notebook_set_menu_label (GtkNotebook *notebook, GtkWidget *child, GtkWidget *menu_label) { - GtkNotebookPriv *priv; + GtkNotebookPrivate *priv; GtkNotebookPage *page; GList *list; @@ -7424,7 +7424,7 @@ static void gtk_notebook_child_reordered (GtkNotebook *notebook, GtkNotebookPage *page) { - GtkNotebookPriv *priv = notebook->priv; + GtkNotebookPrivate *priv = notebook->priv; if (priv->menu) { @@ -7447,7 +7447,7 @@ gtk_notebook_set_tab_label_packing (GtkNotebook *notebook, gboolean fill, GtkPackType pack_type) { - GtkNotebookPriv *priv; + GtkNotebookPrivate *priv; GtkNotebookPage *page; GList *list; @@ -7523,7 +7523,7 @@ gtk_notebook_reorder_child (GtkNotebook *notebook, GtkWidget *child, gint position) { - GtkNotebookPriv *priv; + GtkNotebookPrivate *priv; GList *list, *new_list; GtkNotebookPage *page; gint old_pos; @@ -7618,7 +7618,7 @@ void gtk_notebook_set_group (GtkNotebook *notebook, gpointer group) { - GtkNotebookPriv *priv; + GtkNotebookPrivate *priv; g_return_if_fail (GTK_IS_NOTEBOOK (notebook)); @@ -7842,7 +7842,7 @@ gtk_notebook_set_action_widget (GtkNotebook *notebook, GtkWidget *widget, GtkPackType pack_type) { - GtkNotebookPriv *priv; + GtkNotebookPrivate *priv; g_return_if_fail (GTK_IS_NOTEBOOK (notebook)); g_return_if_fail (!widget || GTK_IS_WIDGET (widget)); diff --git a/gtk/gtknotebook.h b/gtk/gtknotebook.h index 9ced43b033..4240338595 100644 --- a/gtk/gtknotebook.h +++ b/gtk/gtknotebook.h @@ -52,16 +52,16 @@ typedef enum GTK_NOTEBOOK_TAB_LAST } GtkNotebookTab; -typedef struct _GtkNotebook GtkNotebook; -typedef struct _GtkNotebookPriv GtkNotebookPriv; -typedef struct _GtkNotebookClass GtkNotebookClass; +typedef struct _GtkNotebook GtkNotebook; +typedef struct _GtkNotebookPrivate GtkNotebookPrivate; +typedef struct _GtkNotebookClass GtkNotebookClass; struct _GtkNotebook { GtkContainer container; /* <private> */ - GtkNotebookPriv *priv; + GtkNotebookPrivate *priv; }; struct _GtkNotebookClass diff --git a/gtk/gtkoffscreenwindow.c b/gtk/gtkoffscreenwindow.c index 1c51abe2b4..bdd29c626c 100644 --- a/gtk/gtkoffscreenwindow.c +++ b/gtk/gtkoffscreenwindow.c @@ -92,12 +92,12 @@ gtk_offscreen_window_size_allocate (GtkWidget *widget, GtkWidget *child; gint border_width; - widget->allocation = *allocation; + gtk_widget_set_allocation (widget, allocation); border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); if (gtk_widget_get_realized (widget)) - gdk_window_move_resize (widget->window, + gdk_window_move_resize (gtk_widget_get_window (widget), allocation->x, allocation->y, allocation->width, @@ -123,8 +123,10 @@ gtk_offscreen_window_size_allocate (GtkWidget *widget, static void gtk_offscreen_window_realize (GtkWidget *widget) { + GtkAllocation allocation; GtkBin *bin; GtkWidget *child; + GdkWindow *window; GdkWindowAttr attributes; gint attributes_mask; gint border_width; @@ -135,10 +137,12 @@ gtk_offscreen_window_realize (GtkWidget *widget) border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); - attributes.x = widget->allocation.x; - attributes.y = widget->allocation.y; - attributes.width = widget->allocation.width; - attributes.height = widget->allocation.height; + gtk_widget_get_allocation (widget, &allocation); + + attributes.x = allocation.x; + attributes.y = allocation.y; + attributes.width = allocation.width; + attributes.height = allocation.height; attributes.window_type = GDK_WINDOW_OFFSCREEN; attributes.event_mask = gtk_widget_get_events (widget) | GDK_EXPOSURE_MASK; attributes.visual = gtk_widget_get_visual (widget); @@ -147,17 +151,18 @@ gtk_offscreen_window_realize (GtkWidget *widget) attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; - widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), - &attributes, attributes_mask); - gdk_window_set_user_data (widget->window, widget); + window = gdk_window_new (gtk_widget_get_parent_window (widget), + &attributes, attributes_mask); + gtk_widget_set_window (widget, window); + gdk_window_set_user_data (window, widget); child = gtk_bin_get_child (bin); if (child) - gtk_widget_set_parent_window (child, widget->window); - - widget->style = gtk_style_attach (widget->style, widget->window); + gtk_widget_set_parent_window (child, window); - gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL); + gtk_widget_style_attach (widget); + gtk_style_set_background (gtk_widget_get_style (widget), + window, GTK_STATE_NORMAL); } static void @@ -280,7 +285,7 @@ gtk_offscreen_window_get_pixmap (GtkOffscreenWindow *offscreen) { g_return_val_if_fail (GTK_IS_OFFSCREEN_WINDOW (offscreen), NULL); - return gdk_offscreen_window_get_pixmap (GTK_WIDGET (offscreen)->window); + return gdk_offscreen_window_get_pixmap (gtk_widget_get_window (GTK_WIDGET (offscreen))); } /** @@ -304,7 +309,7 @@ gtk_offscreen_window_get_pixbuf (GtkOffscreenWindow *offscreen) g_return_val_if_fail (GTK_IS_OFFSCREEN_WINDOW (offscreen), NULL); - pixmap = gdk_offscreen_window_get_pixmap (GTK_WIDGET (offscreen)->window); + pixmap = gdk_offscreen_window_get_pixmap (gtk_widget_get_window (GTK_WIDGET (offscreen))); if (pixmap != NULL) { diff --git a/gtk/gtkpaned.c b/gtk/gtkpaned.c index c03d6e8346..6d95aa19e2 100644 --- a/gtk/gtkpaned.c +++ b/gtk/gtkpaned.c @@ -648,7 +648,7 @@ gtk_paned_set_property (GObject *object, priv->cursor_type = GDK_SB_V_DOUBLE_ARROW; /* state_changed updates the cursor */ - gtk_paned_state_changed (GTK_WIDGET (paned), GTK_WIDGET (paned)->state); + gtk_paned_state_changed (GTK_WIDGET (paned), gtk_widget_get_state (GTK_WIDGET (paned))); gtk_widget_queue_resize (GTK_WIDGET (paned)); break; case PROP_POSITION: @@ -848,8 +848,12 @@ static void flip_child (GtkWidget *widget, GtkAllocation *child_pos) { - gint x = widget->allocation.x; - gint width = widget->allocation.width; + GtkAllocation allocation; + gint x, width; + + gtk_widget_get_allocation (widget, &allocation); + x = allocation.x; + width = allocation.width; child_pos->x = 2 * x + width - child_pos->x - child_pos->width; } @@ -860,11 +864,12 @@ gtk_paned_size_allocate (GtkWidget *widget, { GtkPaned *paned = GTK_PANED (widget); GtkPanedPrivate *priv = paned->priv; + GtkAllocation widget_allocation; guint border_width; border_width = gtk_container_get_border_width (GTK_CONTAINER (paned)); - widget->allocation = *allocation; + gtk_widget_set_allocation (widget, allocation); if (priv->child1 && gtk_widget_get_visible (priv->child1) && priv->child2 && gtk_widget_get_visible (priv->child2)) @@ -873,6 +878,7 @@ gtk_paned_size_allocate (GtkWidget *widget, GtkRequisition child2_requisition; GtkAllocation child1_allocation; GtkAllocation child2_allocation; + GtkAllocation priv_child1_allocation; GdkRectangle old_handle_pos; gint handle_size; @@ -883,27 +889,29 @@ gtk_paned_size_allocate (GtkWidget *widget, old_handle_pos = priv->handle_pos; + gtk_widget_get_allocation (widget, &widget_allocation); + if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) { gtk_paned_calc_position (paned, - MAX (1, widget->allocation.width + MAX (1, widget_allocation.width - handle_size - 2 * border_width), child1_requisition.width, child2_requisition.width); - priv->handle_pos.x = widget->allocation.x + priv->child1_size + border_width; - priv->handle_pos.y = widget->allocation.y + border_width; + priv->handle_pos.x = widget_allocation.x + priv->child1_size + border_width; + priv->handle_pos.y = widget_allocation.y + border_width; priv->handle_pos.width = handle_size; - priv->handle_pos.height = MAX (1, widget->allocation.height - 2 * border_width); + priv->handle_pos.height = MAX (1, widget_allocation.height - 2 * border_width); child1_allocation.height = child2_allocation.height = MAX (1, (gint) allocation->height - border_width * 2); child1_allocation.width = MAX (1, priv->child1_size); - child1_allocation.x = widget->allocation.x + border_width; - child1_allocation.y = child2_allocation.y = widget->allocation.y + border_width; + child1_allocation.x = widget_allocation.x + border_width; + child1_allocation.y = child2_allocation.y = widget_allocation.y + border_width; child2_allocation.x = child1_allocation.x + priv->child1_size + priv->handle_pos.width; - child2_allocation.width = MAX (1, widget->allocation.x + widget->allocation.width - child2_allocation.x - border_width); + child2_allocation.width = MAX (1, widget_allocation.x + widget_allocation.width - child2_allocation.x - border_width); if (gtk_widget_get_direction (GTK_WIDGET (widget)) == GTK_TEXT_DIR_RTL) { @@ -915,24 +923,24 @@ gtk_paned_size_allocate (GtkWidget *widget, else { gtk_paned_calc_position (paned, - MAX (1, widget->allocation.height + MAX (1, widget_allocation.height - handle_size - 2 * border_width), child1_requisition.height, child2_requisition.height); - priv->handle_pos.x = widget->allocation.x + border_width; - priv->handle_pos.y = widget->allocation.y + priv->child1_size + border_width; - priv->handle_pos.width = MAX (1, (gint) widget->allocation.width - 2 * border_width); + priv->handle_pos.x = widget_allocation.x + border_width; + priv->handle_pos.y = widget_allocation.y + priv->child1_size + border_width; + priv->handle_pos.width = MAX (1, (gint) widget_allocation.width - 2 * border_width); priv->handle_pos.height = handle_size; child1_allocation.width = child2_allocation.width = MAX (1, (gint) allocation->width - border_width * 2); child1_allocation.height = MAX (1, priv->child1_size); - child1_allocation.x = child2_allocation.x = widget->allocation.x + border_width; - child1_allocation.y = widget->allocation.y + border_width; + child1_allocation.x = child2_allocation.x = widget_allocation.x + border_width; + child1_allocation.y = widget_allocation.y + border_width; child2_allocation.y = child1_allocation.y + priv->child1_size + priv->handle_pos.height; - child2_allocation.height = MAX (1, widget->allocation.y + widget->allocation.height - child2_allocation.y - border_width); + child2_allocation.height = MAX (1, widget_allocation.y + widget_allocation.height - child2_allocation.y - border_width); } if (gtk_widget_get_mapped (widget) && @@ -941,8 +949,11 @@ gtk_paned_size_allocate (GtkWidget *widget, old_handle_pos.width != priv->handle_pos.width || old_handle_pos.height != priv->handle_pos.height)) { - gdk_window_invalidate_rect (widget->window, &old_handle_pos, FALSE); - gdk_window_invalidate_rect (widget->window, &priv->handle_pos, FALSE); + GdkWindow *window; + + window = gtk_widget_get_window (widget); + gdk_window_invalidate_rect (window, &old_handle_pos, FALSE); + gdk_window_invalidate_rect (window, &priv->handle_pos, FALSE); } if (gtk_widget_get_realized (widget)) @@ -971,13 +982,13 @@ gtk_paned_size_allocate (GtkWidget *widget, /* Now allocate the childen, making sure, when resizing not to * overlap the windows */ + gtk_widget_get_allocation (priv->child1, &priv_child1_allocation); if (gtk_widget_get_mapped (widget) && - ((priv->orientation == GTK_ORIENTATION_HORIZONTAL && - priv->child1->allocation.width < child1_allocation.width) || + priv_child1_allocation.width < child1_allocation.width) || (priv->orientation == GTK_ORIENTATION_VERTICAL && - priv->child1->allocation.height < child1_allocation.height))) + priv_child1_allocation.height < child1_allocation.height))) { gtk_widget_size_allocate (priv->child2, &child2_allocation); gtk_widget_size_allocate (priv->child1, &child1_allocation); @@ -1000,8 +1011,10 @@ gtk_paned_size_allocate (GtkWidget *widget, if (priv->child2) gtk_widget_set_child_visible (priv->child2, TRUE); - child_allocation.x = widget->allocation.x + border_width; - child_allocation.y = widget->allocation.y + border_width; + gtk_widget_get_allocation (widget, &widget_allocation); + + child_allocation.x = widget_allocation.x + border_width; + child_allocation.y = widget_allocation.y + border_width; child_allocation.width = MAX (1, allocation->width - 2 * border_width); child_allocation.height = MAX (1, allocation->height - 2 * border_width); @@ -1017,14 +1030,16 @@ gtk_paned_realize (GtkWidget *widget) { GtkPaned *paned = GTK_PANED (widget); GtkPanedPrivate *priv = paned->priv; + GdkWindow *window; GdkWindowAttr attributes; gint attributes_mask; gtk_widget_set_realized (widget, TRUE); - widget->window = gtk_widget_get_parent_window (widget); - g_object_ref (widget->window); - + window = gtk_widget_get_parent_window (widget); + gtk_widget_set_window (widget, window); + g_object_ref (window); + attributes.window_type = GDK_WINDOW_CHILD; attributes.wclass = GDK_INPUT_ONLY; attributes.x = priv->handle_pos.x; @@ -1046,13 +1061,13 @@ gtk_paned_realize (GtkWidget *widget) attributes_mask |= GDK_WA_CURSOR; } - priv->handle = gdk_window_new (widget->window, - &attributes, attributes_mask); + priv->handle = gdk_window_new (window, + &attributes, attributes_mask); gdk_window_set_user_data (priv->handle, paned); if (attributes_mask & GDK_WA_CURSOR) gdk_cursor_unref (attributes.cursor); - widget->style = gtk_style_attach (widget->style, widget->window); + gtk_widget_style_attach (widget); if (priv->child1 && gtk_widget_get_visible (priv->child1) && priv->child2 && gtk_widget_get_visible (priv->child2)) @@ -1121,8 +1136,9 @@ gtk_paned_expose (GtkWidget *widget, state = GTK_STATE_PRELIGHT; else state = gtk_widget_get_state (widget); - - gtk_paint_handle (widget->style, widget->window, + + gtk_paint_handle (gtk_widget_get_style (widget), + gtk_widget_get_window (widget), state, GTK_SHADOW_NONE, &priv->handle_pos, widget, "paned", priv->handle_pos.x, priv->handle_pos.y, @@ -1154,24 +1170,27 @@ static void update_drag (GtkPaned *paned) { GtkPanedPrivate *priv = paned->priv; + GtkAllocation allocation; + GtkWidget *widget = GTK_WIDGET (paned); gint pos; gint handle_size; gint size; if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) - gtk_widget_get_pointer (GTK_WIDGET (paned), &pos, NULL); + gtk_widget_get_pointer (widget, &pos, NULL); else - gtk_widget_get_pointer (GTK_WIDGET (paned), NULL, &pos); + gtk_widget_get_pointer (widget, NULL, &pos); pos -= priv->drag_pos; if (is_rtl (paned)) { - gtk_widget_style_get (GTK_WIDGET (paned), + gtk_widget_style_get (widget, "handle-size", &handle_size, NULL); - - size = GTK_WIDGET (paned)->allocation.width - pos - handle_size; + + gtk_widget_get_allocation (widget, &allocation); + size = allocation.width - pos - handle_size; } else { @@ -1783,7 +1802,7 @@ paned_get_focus_widget (GtkPaned *paned) toplevel = gtk_widget_get_toplevel (GTK_WIDGET (paned)); if (gtk_widget_is_toplevel (toplevel)) - return GTK_WINDOW (toplevel)->focus_widget; + return gtk_window_get_focus (GTK_WINDOW (toplevel)); return NULL; } @@ -1813,7 +1832,7 @@ gtk_paned_set_focus_child (GtkContainer *container, /* If there is one or more paned widgets between us and the * focus widget, we want the topmost of those as last_focus */ - for (w = last_focus; w != GTK_WIDGET (paned); w = w->parent) + for (w = last_focus; w != GTK_WIDGET (paned); w = gtk_widget_get_parent (w)) if (GTK_IS_PANED (w)) last_focus = w; @@ -1838,6 +1857,8 @@ gtk_paned_get_cycle_chain (GtkPaned *paned, GtkContainer *container = GTK_CONTAINER (paned); GtkWidget *ancestor = NULL; GtkWidget *focus_child; + GtkWidget *parent; + GtkWidget *widget = GTK_WIDGET (paned); GList *temp_list = NULL; GList *list; @@ -1847,19 +1868,20 @@ gtk_paned_get_cycle_chain (GtkPaned *paned, g_assert (widgets != NULL); if (priv->last_child1_focus && - !gtk_widget_is_ancestor (priv->last_child1_focus, GTK_WIDGET (paned))) + !gtk_widget_is_ancestor (priv->last_child1_focus, widget)) { gtk_paned_set_last_child1_focus (paned, NULL); } if (priv->last_child2_focus && - !gtk_widget_is_ancestor (priv->last_child2_focus, GTK_WIDGET (paned))) + !gtk_widget_is_ancestor (priv->last_child2_focus, widget)) { gtk_paned_set_last_child2_focus (paned, NULL); } - if (GTK_WIDGET (paned)->parent) - ancestor = gtk_widget_get_ancestor (GTK_WIDGET (paned)->parent, GTK_TYPE_PANED); + parent = gtk_widget_get_parent (widget); + if (parent) + ancestor = gtk_widget_get_ancestor (parent, GTK_TYPE_PANED); /* The idea here is that temp_list is a list of widgets we want to cycle * to. The list is prioritized so that the first element is our first @@ -1997,8 +2019,8 @@ get_all_panes (GtkPaned *paned) GtkPaned *topmost = NULL; GList *result = NULL; GtkWidget *w; - - for (w = GTK_WIDGET (paned); w != NULL; w = w->parent) + + for (w = GTK_WIDGET (paned); w != NULL; w = gtk_widget_get_parent (w)) { if (GTK_IS_PANED (w)) topmost = GTK_PANED (w); @@ -2298,7 +2320,7 @@ gtk_paned_cycle_handle_focus (GtkPaned *paned, toplevel = gtk_widget_get_toplevel (GTK_WIDGET (paned)); if (GTK_IS_WINDOW (toplevel)) - gtk_paned_set_saved_focus (focus, GTK_WINDOW (toplevel)->focus_widget); + gtk_paned_set_saved_focus (focus, gtk_window_get_focus (GTK_WINDOW (toplevel))); gtk_paned_set_first_paned (focus, first); focus->priv->original_position = gtk_paned_get_position (focus); diff --git a/gtk/gtkplug-x11.c b/gtk/gtkplug-x11.c index a02876582c..8a2544d49b 100644 --- a/gtk/gtkplug-x11.c +++ b/gtk/gtkplug-x11.c @@ -57,31 +57,33 @@ static void xembed_set_info (GdkWindow *window, GdkNativeWindow _gtk_plug_windowing_get_id (GtkPlug *plug) { - return GDK_WINDOW_XWINDOW (GTK_WIDGET (plug)->window); + return GDK_WINDOW_XWINDOW (gtk_widget_get_window (GTK_WIDGET (plug))); } void _gtk_plug_windowing_realize_toplevel (GtkPlug *plug) { - xembed_set_info (GTK_WIDGET (plug)->window, 0); + xembed_set_info (gtk_widget_get_window (GTK_WIDGET (plug)), 0); } void _gtk_plug_windowing_map_toplevel (GtkPlug *plug) { - xembed_set_info (GTK_WIDGET (plug)->window, XEMBED_MAPPED); + xembed_set_info (gtk_widget_get_window (GTK_WIDGET (plug)), XEMBED_MAPPED); } void _gtk_plug_windowing_unmap_toplevel (GtkPlug *plug) { - xembed_set_info (GTK_WIDGET (plug)->window, 0); + xembed_set_info (gtk_widget_get_window (GTK_WIDGET (plug)), 0); } void _gtk_plug_windowing_set_focus (GtkPlug *plug) { - _gtk_xembed_send_message (plug->socket_window, + GtkPlugPrivate *priv = plug->priv; + + _gtk_xembed_send_message (priv->socket_window, XEMBED_REQUEST_FOCUS, 0, 0, 0); } @@ -90,7 +92,9 @@ _gtk_plug_windowing_add_grabbed_key (GtkPlug *plug, guint accelerator_key, GdkModifierType accelerator_mods) { - _gtk_xembed_send_message (plug->socket_window, XEMBED_GTK_GRAB_KEY, 0, + GtkPlugPrivate *priv = plug->priv; + + _gtk_xembed_send_message (priv->socket_window, XEMBED_GTK_GRAB_KEY, 0, accelerator_key, accelerator_mods); } @@ -99,7 +103,9 @@ _gtk_plug_windowing_remove_grabbed_key (GtkPlug *plug, guint accelerator_key, GdkModifierType accelerator_mods) { - _gtk_xembed_send_message (plug->socket_window, XEMBED_GTK_UNGRAB_KEY, 0, + GtkPlugPrivate *priv = plug->priv; + + _gtk_xembed_send_message (priv->socket_window, XEMBED_GTK_UNGRAB_KEY, 0, accelerator_key, accelerator_mods); } @@ -107,6 +113,7 @@ void _gtk_plug_windowing_focus_to_parent (GtkPlug *plug, GtkDirectionType direction) { + GtkPlugPrivate *priv = plug->priv; XEmbedMessageType message = XEMBED_FOCUS_PREV; /* Quiet GCC */ switch (direction) @@ -122,8 +129,8 @@ _gtk_plug_windowing_focus_to_parent (GtkPlug *plug, message = XEMBED_FOCUS_NEXT; break; } - - _gtk_xembed_send_focus_message (plug->socket_window, message, 0); + + _gtk_xembed_send_focus_message (priv->socket_window, message, 0); } static void @@ -220,6 +227,7 @@ _gtk_plug_windowing_filter_func (GdkXEvent *gdk_xevent, GdkScreen *screen = gdk_drawable_get_screen (event->any.window); GdkDisplay *display = gdk_screen_get_display (screen); GtkPlug *plug = GTK_PLUG (data); + GtkPlugPrivate *priv = plug->priv; XEvent *xevent = (XEvent *)gdk_xevent; GdkFilterReturn return_val; @@ -254,7 +262,7 @@ _gtk_plug_windowing_filter_func (GdkXEvent *gdk_xevent, case ReparentNotify: { XReparentEvent *xre = &xevent->xreparent; - gboolean was_embedded = plug->socket_window != NULL; + gboolean was_embedded = priv->socket_window != NULL; GTK_NOTE (PLUGSOCKET, g_message("GtkPlug: ReparentNotify received")); @@ -271,14 +279,14 @@ _gtk_plug_windowing_filter_func (GdkXEvent *gdk_xevent, * then add to a local window before we get notification * Probably need check in _gtk_plug_add_to_socket */ - - if (xre->parent != GDK_WINDOW_XWINDOW (plug->socket_window)) + + if (xre->parent != GDK_WINDOW_XWINDOW (priv->socket_window)) { GtkWidget *widget = GTK_WIDGET (plug); - gdk_window_set_user_data (plug->socket_window, NULL); - g_object_unref (plug->socket_window); - plug->socket_window = NULL; + gdk_window_set_user_data (priv->socket_window, NULL); + g_object_unref (priv->socket_window); + priv->socket_window = NULL; /* Emit a delete window, as if the user attempted * to close the toplevel. Simple as to how we @@ -306,25 +314,26 @@ _gtk_plug_windowing_filter_func (GdkXEvent *gdk_xevent, /* Start of embedding protocol */ GTK_NOTE (PLUGSOCKET, g_message ("GtkPlug: start of embedding")); - plug->socket_window = gdk_window_lookup_for_display (display, xre->parent); - if (plug->socket_window) + + priv->socket_window = gdk_window_lookup_for_display (display, xre->parent); + if (priv->socket_window) { gpointer user_data = NULL; - gdk_window_get_user_data (plug->socket_window, &user_data); + gdk_window_get_user_data (priv->socket_window, &user_data); if (user_data) { g_warning (G_STRLOC "Plug reparented unexpectedly into window in the same process"); - plug->socket_window = NULL; + priv->socket_window = NULL; break; /* FIXME: shouldn't this unref the plug? i.e. "goto done;" instead */ } - g_object_ref (plug->socket_window); + g_object_ref (priv->socket_window); } else { - plug->socket_window = gdk_window_foreign_new_for_display (display, xre->parent); - if (!plug->socket_window) /* Already gone */ + priv->socket_window = gdk_window_foreign_new_for_display (display, xre->parent); + if (!priv->socket_window) /* Already gone */ break; /* FIXME: shouldn't this unref the plug? i.e. "goto done;" instead */ } diff --git a/gtk/gtkplug.c b/gtk/gtkplug.c index 443bad608b..4504d84900 100644 --- a/gtk/gtkplug.c +++ b/gtk/gtkplug.c @@ -110,14 +110,15 @@ gtk_plug_get_property (GObject *object, GParamSpec *pspec) { GtkPlug *plug = GTK_PLUG (object); + GtkPlugPrivate *priv = plug->priv; switch (prop_id) { case PROP_EMBEDDED: - g_value_set_boolean (value, plug->socket_window != NULL); + g_value_set_boolean (value, priv->socket_window != NULL); break; case PROP_SOCKET_WINDOW: - g_value_set_object (value, plug->socket_window); + g_value_set_object (value, priv->socket_window); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -201,14 +202,18 @@ gtk_plug_class_init (GtkPlugClass *class) NULL, NULL, _gtk_marshal_VOID__VOID, G_TYPE_NONE, 0); + + g_type_class_add_private (class, sizeof (GtkPlugPrivate)); } static void gtk_plug_init (GtkPlug *plug) { - GtkWindow *window; + GtkWindow *window = GTK_WINDOW (plug); - window = GTK_WINDOW (plug); + plug->priv = G_TYPE_INSTANCE_GET_PRIVATE (plug, + GTK_TYPE_PLUG, + GtkPlugPrivate); window->type = GTK_WINDOW_TOPLEVEL; } @@ -217,18 +222,21 @@ static void gtk_plug_set_is_child (GtkPlug *plug, gboolean is_child) { - g_assert (!GTK_WIDGET (plug)->parent); - + GtkPlugPrivate *priv = plug->priv; + GtkWidget *widget = GTK_WIDGET (plug); + + g_assert (!gtk_widget_get_parent (widget)); + if (is_child) { - if (plug->modality_window) + if (priv->modality_window) _gtk_plug_handle_modality_off (plug); - if (plug->modality_group) + if (priv->modality_group) { - gtk_window_group_remove_window (plug->modality_group, GTK_WINDOW (plug)); - g_object_unref (plug->modality_group); - plug->modality_group = NULL; + gtk_window_group_remove_window (priv->modality_group, GTK_WINDOW (plug)); + g_object_unref (priv->modality_group); + priv->modality_group = NULL; } /* As a toplevel, the MAPPED flag doesn't correspond @@ -236,13 +244,13 @@ gtk_plug_set_is_child (GtkPlug *plug, * here, but don't bother remapping -- we will get mapped * by gtk_widget_set_parent (). */ - if (gtk_widget_get_mapped (GTK_WIDGET (plug))) - gtk_widget_unmap (GTK_WIDGET (plug)); - + if (gtk_widget_get_mapped (widget)) + gtk_widget_unmap (widget); + _gtk_window_set_is_toplevel (GTK_WINDOW (plug), FALSE); gtk_container_set_resize_mode (GTK_CONTAINER (plug), GTK_RESIZE_PARENT); - _gtk_widget_propagate_hierarchy_changed (GTK_WIDGET (plug), GTK_WIDGET (plug)); + _gtk_widget_propagate_hierarchy_changed (widget, widget); } else { @@ -250,10 +258,10 @@ gtk_plug_set_is_child (GtkPlug *plug, gtk_window_set_focus (GTK_WINDOW (plug), NULL); if (GTK_WINDOW (plug)->default_widget) gtk_window_set_default (GTK_WINDOW (plug), NULL); - - plug->modality_group = gtk_window_group_new (); - gtk_window_group_add_window (plug->modality_group, GTK_WINDOW (plug)); - + + priv->modality_group = gtk_window_group_new (); + gtk_window_group_add_window (priv->modality_group, GTK_WINDOW (plug)); + _gtk_window_set_is_toplevel (GTK_WINDOW (plug), TRUE); gtk_container_set_resize_mode (GTK_CONTAINER (plug), GTK_RESIZE_QUEUE); @@ -297,7 +305,7 @@ gtk_plug_get_embedded (GtkPlug *plug) { g_return_val_if_fail (GTK_IS_PLUG (plug), FALSE); - return plug->socket_window != NULL; + return plug->priv->socket_window != NULL; } /** @@ -315,7 +323,7 @@ gtk_plug_get_socket_window (GtkPlug *plug) { g_return_val_if_fail (GTK_IS_PLUG (plug), NULL); - return plug->socket_window; + return plug->priv->socket_window; } /** @@ -329,6 +337,7 @@ void _gtk_plug_add_to_socket (GtkPlug *plug, GtkSocket *socket_) { + GtkPlugPrivate *priv; GtkWidget *widget; gint w, h; @@ -336,22 +345,26 @@ _gtk_plug_add_to_socket (GtkPlug *plug, g_return_if_fail (GTK_IS_SOCKET (socket_)); g_return_if_fail (gtk_widget_get_realized (GTK_WIDGET (socket_))); + priv = plug->priv; widget = GTK_WIDGET (plug); gtk_plug_set_is_child (plug, TRUE); - plug->same_app = TRUE; + priv->same_app = TRUE; socket_->same_app = TRUE; socket_->plug_widget = widget; - plug->socket_window = GTK_WIDGET (socket_)->window; - g_object_ref (plug->socket_window); + priv->socket_window = gtk_widget_get_window (GTK_WIDGET (socket_)); + g_object_ref (priv->socket_window); g_signal_emit (plug, plug_signals[EMBEDDED], 0); g_object_notify (G_OBJECT (plug), "embedded"); if (gtk_widget_get_realized (widget)) { - gdk_drawable_get_size (GDK_DRAWABLE (widget->window), &w, &h); - gdk_window_reparent (widget->window, plug->socket_window, -w, -h); + GdkWindow *window; + + window = gtk_widget_get_window (widget); + gdk_drawable_get_size (GDK_DRAWABLE (window), &w, &h); + gdk_window_reparent (window, priv->socket_window, -w, -h); } gtk_widget_set_parent (widget, GTK_WIDGET (socket_)); @@ -372,7 +385,7 @@ _gtk_plug_send_delete_event (GtkWidget *widget) { GdkEvent *event = gdk_event_new (GDK_DELETE); - event->any.window = g_object_ref (widget->window); + event->any.window = g_object_ref (gtk_widget_get_window (widget)); event->any.send_event = FALSE; g_object_ref (widget); @@ -396,7 +409,9 @@ void _gtk_plug_remove_from_socket (GtkPlug *plug, GtkSocket *socket_) { + GtkPlugPrivate *priv; GtkWidget *widget; + GdkWindow *window; gboolean result; gboolean widget_was_visible; @@ -404,6 +419,7 @@ _gtk_plug_remove_from_socket (GtkPlug *plug, g_return_if_fail (GTK_IS_SOCKET (socket_)); g_return_if_fail (gtk_widget_get_realized (GTK_WIDGET (plug))); + priv = plug->priv; widget = GTK_WIDGET (plug); if (GTK_WIDGET_IN_REPARENT (widget)) @@ -413,10 +429,11 @@ _gtk_plug_remove_from_socket (GtkPlug *plug, g_object_ref (socket_); widget_was_visible = gtk_widget_get_visible (widget); - - gdk_window_hide (widget->window); + window = gtk_widget_get_window (widget); + + gdk_window_hide (window); GTK_PRIVATE_SET_FLAG (plug, GTK_IN_REPARENT); - gdk_window_reparent (widget->window, + gdk_window_reparent (window, gtk_widget_get_root_window (widget), 0, 0); gtk_widget_unparent (GTK_WIDGET (plug)); @@ -431,11 +448,11 @@ _gtk_plug_remove_from_socket (GtkPlug *plug, socket_->same_app = FALSE; - plug->same_app = FALSE; - if (plug->socket_window != NULL) + priv->same_app = FALSE; + if (priv->socket_window != NULL) { - g_object_unref (plug->socket_window); - plug->socket_window = NULL; + g_object_unref (priv->socket_window); + priv->socket_window = NULL; } gtk_plug_set_is_child (plug, FALSE); @@ -443,7 +460,7 @@ _gtk_plug_remove_from_socket (GtkPlug *plug, if (!result) gtk_widget_destroy (GTK_WIDGET (socket_)); - if (widget->window) + if (window) _gtk_plug_send_delete_event (widget); g_object_unref (plug); @@ -487,14 +504,21 @@ gtk_plug_construct_for_display (GtkPlug *plug, GdkDisplay *display, GdkNativeWindow socket_id) { + GtkPlugPrivate *priv; + + g_return_if_fail (GTK_IS_PLUG (plug)); + g_return_if_fail (GDK_IS_DISPLAY (display)); + + priv = plug->priv; + if (socket_id) { gpointer user_data = NULL; - plug->socket_window = gdk_window_lookup_for_display (display, socket_id); - if (plug->socket_window) + priv->socket_window = gdk_window_lookup_for_display (display, socket_id); + if (priv->socket_window) { - gdk_window_get_user_data (plug->socket_window, &user_data); + gdk_window_get_user_data (priv->socket_window, &user_data); if (user_data) { @@ -503,16 +527,16 @@ gtk_plug_construct_for_display (GtkPlug *plug, else { g_warning (G_STRLOC "Can't create GtkPlug as child of non-GtkSocket"); - plug->socket_window = NULL; + priv->socket_window = NULL; } } else - g_object_ref (plug->socket_window); + g_object_ref (priv->socket_window); } else - plug->socket_window = gdk_window_foreign_new_for_display (display, socket_id); + priv->socket_window = gdk_window_foreign_new_for_display (display, socket_id); - if (plug->socket_window) { + if (priv->socket_window) { g_signal_emit (plug, plug_signals[EMBEDDED], 0); g_object_notify (G_OBJECT (plug), "embedded"); @@ -553,6 +577,8 @@ gtk_plug_new_for_display (GdkDisplay *display, { GtkPlug *plug; + g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL); + plug = g_object_new (GTK_TYPE_PLUG, NULL); gtk_plug_construct_for_display (plug, display, socket_id); return GTK_WIDGET (plug); @@ -562,11 +588,12 @@ static void gtk_plug_finalize (GObject *object) { GtkPlug *plug = GTK_PLUG (object); + GtkPlugPrivate *priv = plug->priv; - if (plug->grabbed_keys) + if (priv->grabbed_keys) { - g_hash_table_destroy (plug->grabbed_keys); - plug->grabbed_keys = NULL; + g_hash_table_destroy (priv->grabbed_keys); + priv->grabbed_keys = NULL; } G_OBJECT_CLASS (gtk_plug_parent_class)->finalize (object); @@ -576,23 +603,24 @@ static void gtk_plug_unrealize (GtkWidget *widget) { GtkPlug *plug = GTK_PLUG (widget); + GtkPlugPrivate *priv = plug->priv; - if (plug->socket_window != NULL) + if (priv->socket_window != NULL) { - gdk_window_set_user_data (plug->socket_window, NULL); - g_object_unref (plug->socket_window); - plug->socket_window = NULL; + gdk_window_set_user_data (priv->socket_window, NULL); + g_object_unref (priv->socket_window); + priv->socket_window = NULL; g_object_notify (G_OBJECT (widget), "embedded"); } - if (!plug->same_app) + if (!priv->same_app) { - if (plug->modality_window) + if (priv->modality_window) _gtk_plug_handle_modality_off (plug); - gtk_window_group_remove_window (plug->modality_group, GTK_WINDOW (plug)); - g_object_unref (plug->modality_group); + gtk_window_group_remove_window (priv->modality_group, GTK_WINDOW (plug)); + g_object_unref (priv->modality_group); } GTK_WIDGET_CLASS (gtk_plug_parent_class)->unrealize (widget); @@ -601,19 +629,24 @@ gtk_plug_unrealize (GtkWidget *widget) static void gtk_plug_realize (GtkWidget *widget) { - GtkWindow *window = GTK_WINDOW (widget); + GtkAllocation allocation; GtkPlug *plug = GTK_PLUG (widget); + GtkPlugPrivate *priv = plug->priv; + GtkWindow *window = GTK_WINDOW (widget); + GdkWindow *gdk_window; GdkWindowAttr attributes; gint attributes_mask; gtk_widget_set_realized (widget, TRUE); + gtk_widget_get_allocation (widget, &allocation); + attributes.window_type = GDK_WINDOW_CHILD; /* XXX GDK_WINDOW_PLUG ? */ attributes.title = window->title; attributes.wmclass_name = window->wmclass_name; attributes.wmclass_class = window->wmclass_class; - attributes.width = widget->allocation.width; - attributes.height = widget->allocation.height; + attributes.width = allocation.width; + attributes.height = allocation.height; attributes.wclass = GDK_INPUT_OUTPUT; /* this isn't right - we should match our parent's visual/colormap. @@ -637,43 +670,49 @@ gtk_plug_realize (GtkWidget *widget) attributes.window_type = GDK_WINDOW_TOPLEVEL; gdk_error_trap_push (); - if (plug->socket_window) - widget->window = gdk_window_new (plug->socket_window, - &attributes, attributes_mask); + if (priv->socket_window) + gdk_window = gdk_window_new (priv->socket_window, + &attributes, attributes_mask); else /* If it's a passive plug, we use the root window */ - widget->window = gdk_window_new (gtk_widget_get_root_window (widget), - &attributes, attributes_mask); + gdk_window = gdk_window_new (gtk_widget_get_root_window (widget), + &attributes, attributes_mask); + gtk_widget_set_window (widget, gdk_window); gdk_display_sync (gtk_widget_get_display (widget)); if (gdk_error_trap_pop ()) /* Uh-oh */ { gdk_error_trap_push (); - gdk_window_destroy (widget->window); + gdk_window_destroy (gdk_window); gdk_flush (); gdk_error_trap_pop (); - widget->window = gdk_window_new (gtk_widget_get_root_window (widget), - &attributes, attributes_mask); + gdk_window = gdk_window_new (gtk_widget_get_root_window (widget), + &attributes, attributes_mask); + gtk_widget_set_window (widget, gdk_window); } - - gdk_window_add_filter (widget->window, + + gdk_window_add_filter (gdk_window, _gtk_plug_windowing_filter_func, widget); - plug->modality_group = gtk_window_group_new (); - gtk_window_group_add_window (plug->modality_group, window); - + priv->modality_group = gtk_window_group_new (); + gtk_window_group_add_window (priv->modality_group, window); + _gtk_plug_windowing_realize_toplevel (plug); } else - widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), - &attributes, attributes_mask); - - gdk_window_set_user_data (widget->window, window); + { + gdk_window = gdk_window_new (gtk_widget_get_parent_window (widget), + &attributes, attributes_mask); + gtk_widget_set_window (widget, gdk_window); + } + + gdk_window_set_user_data (gdk_window, window); - widget->style = gtk_style_attach (widget->style, widget->window); - gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL); + gtk_widget_style_attach (widget); + gtk_style_set_background (gtk_widget_get_style (widget), + gdk_window, GTK_STATE_NORMAL); - gdk_window_enable_synchronized_configure (widget->window); + gdk_window_enable_synchronized_configure (gdk_window); } static void @@ -717,8 +756,8 @@ gtk_plug_map (GtkWidget *widget) gtk_widget_map (child); _gtk_plug_windowing_map_toplevel (plug); - - gdk_synthesize_window_state (widget->window, + + gdk_synthesize_window_state (gtk_widget_get_window (widget), GDK_WINDOW_STATE_WITHDRAWN, 0); } @@ -732,14 +771,17 @@ gtk_plug_unmap (GtkWidget *widget) if (gtk_widget_is_toplevel (widget)) { GtkPlug *plug = GTK_PLUG (widget); + GdkWindow *window; + + window = gtk_widget_get_window (widget); gtk_widget_set_mapped (widget, FALSE); - gdk_window_hide (widget->window); + gdk_window_hide (window); _gtk_plug_windowing_unmap_toplevel (plug); - - gdk_synthesize_window_state (widget->window, + + gdk_synthesize_window_state (window, 0, GDK_WINDOW_STATE_WITHDRAWN); } @@ -761,10 +803,12 @@ gtk_plug_size_allocate (GtkWidget *widget, GTK_WIDGET_CLASS (gtk_plug_parent_class)->size_allocate (widget, allocation); else { - widget->allocation = *allocation; + GtkBin *bin = GTK_BIN (widget); + + gtk_widget_set_allocation (widget, allocation); if (gtk_widget_get_realized (widget)) - gdk_window_move_resize (widget->window, + gdk_window_move_resize (gtk_widget_get_window (widget), allocation->x, allocation->y, allocation->width, allocation->height); @@ -852,9 +896,10 @@ add_grabbed_key (gpointer key, gpointer val, gpointer data) { GrabbedKey *grabbed_key = key; GtkPlug *plug = data; + GtkPlugPrivate *priv = plug->priv; - if (!plug->grabbed_keys || - !g_hash_table_lookup (plug->grabbed_keys, grabbed_key)) + if (!priv->grabbed_keys || + !g_hash_table_lookup (priv->grabbed_keys, grabbed_key)) { _gtk_plug_windowing_add_grabbed_key (plug, grabbed_key->accelerator_key, @@ -886,8 +931,10 @@ add_grabbed_key_always (gpointer key, void _gtk_plug_add_all_grabbed_keys (GtkPlug *plug) { - if (plug->grabbed_keys) - g_hash_table_foreach (plug->grabbed_keys, add_grabbed_key_always, plug); + GtkPlugPrivate *priv = plug->priv; + + if (priv->grabbed_keys) + g_hash_table_foreach (priv->grabbed_keys, add_grabbed_key_always, plug); } static void @@ -895,9 +942,10 @@ remove_grabbed_key (gpointer key, gpointer val, gpointer data) { GrabbedKey *grabbed_key = key; GtkPlug *plug = data; + GtkPlugPrivate *priv = plug->priv; - if (!plug->grabbed_keys || - !g_hash_table_lookup (plug->grabbed_keys, grabbed_key)) + if (!priv->grabbed_keys || + !g_hash_table_lookup (priv->grabbed_keys, grabbed_key)) { _gtk_plug_windowing_remove_grabbed_key (plug, grabbed_key->accelerator_key, @@ -932,19 +980,20 @@ gtk_plug_keys_changed (GtkWindow *window) { GHashTable *new_grabbed_keys, *old_grabbed_keys; GtkPlug *plug = GTK_PLUG (window); + GtkPlugPrivate *priv = plug->priv; new_grabbed_keys = g_hash_table_new_full (grabbed_key_hash, grabbed_key_equal, (GDestroyNotify)grabbed_key_free, NULL); _gtk_window_keys_foreach (window, keys_foreach, new_grabbed_keys); - if (plug->socket_window) + if (priv->socket_window) g_hash_table_foreach (new_grabbed_keys, add_grabbed_key, plug); - old_grabbed_keys = plug->grabbed_keys; - plug->grabbed_keys = new_grabbed_keys; + old_grabbed_keys = priv->grabbed_keys; + priv->grabbed_keys = new_grabbed_keys; if (old_grabbed_keys) { - if (plug->socket_window) + if (priv->socket_window) g_hash_table_foreach (old_grabbed_keys, remove_grabbed_key, plug); g_hash_table_destroy (old_grabbed_keys); } @@ -973,11 +1022,11 @@ gtk_plug_focus (GtkWidget *widget, if (window->focus_widget) { /* Wrapped off the end, clear the focus setting for the toplevel */ - parent = window->focus_widget->parent; + parent = gtk_widget_get_parent (window->focus_widget); while (parent) { gtk_container_set_focus_child (GTK_CONTAINER (parent), NULL); - parent = GTK_WIDGET (parent)->parent; + parent = gtk_widget_get_parent (parent); } gtk_window_set_focus (GTK_WINDOW (container), NULL); @@ -1017,14 +1066,16 @@ gtk_plug_check_resize (GtkContainer *container) void _gtk_plug_handle_modality_on (GtkPlug *plug) { - if (!plug->modality_window) + GtkPlugPrivate *priv = plug->priv; + + if (!priv->modality_window) { - plug->modality_window = gtk_window_new (GTK_WINDOW_POPUP); - gtk_window_set_screen (GTK_WINDOW (plug->modality_window), + priv->modality_window = gtk_window_new (GTK_WINDOW_POPUP); + gtk_window_set_screen (GTK_WINDOW (priv->modality_window), gtk_widget_get_screen (GTK_WIDGET (plug))); - gtk_widget_realize (plug->modality_window); - gtk_window_group_add_window (plug->modality_group, GTK_WINDOW (plug->modality_window)); - gtk_grab_add (plug->modality_window); + gtk_widget_realize (priv->modality_window); + gtk_window_group_add_window (priv->modality_group, GTK_WINDOW (priv->modality_window)); + gtk_grab_add (priv->modality_window); } } @@ -1039,10 +1090,12 @@ _gtk_plug_handle_modality_on (GtkPlug *plug) void _gtk_plug_handle_modality_off (GtkPlug *plug) { - if (plug->modality_window) + GtkPlugPrivate *priv = plug->priv; + + if (priv->modality_window) { - gtk_widget_destroy (plug->modality_window); - plug->modality_window = NULL; + gtk_widget_destroy (priv->modality_window); + priv->modality_window = NULL; } } @@ -1064,11 +1117,11 @@ _gtk_plug_focus_first_last (GtkPlug *plug, if (window->focus_widget) { - parent = window->focus_widget->parent; + parent = gtk_widget_get_parent (window->focus_widget); while (parent) { gtk_container_set_focus_child (GTK_CONTAINER (parent), NULL); - parent = GTK_WIDGET (parent)->parent; + parent = gtk_widget_get_parent (parent); } gtk_window_set_focus (GTK_WINDOW (plug), NULL); diff --git a/gtk/gtkplug.h b/gtk/gtkplug.h index c96ca774fa..679c065463 100644 --- a/gtk/gtkplug.h +++ b/gtk/gtkplug.h @@ -45,20 +45,16 @@ G_BEGIN_DECLS #define GTK_PLUG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_PLUG, GtkPlugClass)) -typedef struct _GtkPlug GtkPlug; -typedef struct _GtkPlugClass GtkPlugClass; +typedef struct _GtkPlug GtkPlug; +typedef struct _GtkPlugPrivate GtkPlugPrivate; +typedef struct _GtkPlugClass GtkPlugClass; struct _GtkPlug { GtkWindow window; - GdkWindow *GSEAL (socket_window); - GtkWidget *GSEAL (modality_window); - GtkWindowGroup *GSEAL (modality_group); - GHashTable *GSEAL (grabbed_keys); - - guint GSEAL (same_app) : 1; + GtkPlugPrivate *priv; }; struct _GtkPlugClass diff --git a/gtk/gtkplugprivate.h b/gtk/gtkplugprivate.h index 83dcaaf7ff..a9d1679c2f 100644 --- a/gtk/gtkplugprivate.h +++ b/gtk/gtkplugprivate.h @@ -26,6 +26,18 @@ #ifndef __GTK_PLUG_PRIVATE_H__ #define __GTK_PLUG_PRIVATE_H__ +struct _GtkPlugPrivate +{ + GtkWidget *modality_window; + GtkWindowGroup *modality_group; + + GdkWindow *socket_window; + + GHashTable *grabbed_keys; + + guint same_app : 1; +}; + /* In gtkplug.c: */ void _gtk_plug_send_delete_event (GtkWidget *widget); void _gtk_plug_add_all_grabbed_keys (GtkPlug *plug); diff --git a/gtk/gtkprintoperation.c b/gtk/gtkprintoperation.c index 85ecf0ef29..d043e4fece 100644 --- a/gtk/gtkprintoperation.c +++ b/gtk/gtkprintoperation.c @@ -2934,8 +2934,9 @@ print_pages (GtkPrintOperation *op, gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (error_dialog), _("The most probable reason is that a temporary file could not be created.")); - if (parent && parent->group) - gtk_window_group_add_window (parent->group, GTK_WINDOW (error_dialog)); + if (parent && gtk_window_has_group (parent)) + gtk_window_group_add_window (gtk_window_get_group (parent), + GTK_WINDOW (error_dialog)); g_signal_connect (error_dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL); diff --git a/gtk/gtkprintunixdialog.c b/gtk/gtkprintunixdialog.c index 3b596f50d3..f4ce65620a 100644 --- a/gtk/gtkprintunixdialog.c +++ b/gtk/gtkprintunixdialog.c @@ -379,22 +379,26 @@ static void set_busy_cursor (GtkPrintUnixDialog *dialog, gboolean busy) { + GtkWidget *widget; GtkWindow *toplevel; GdkDisplay *display; GdkCursor *cursor; toplevel = get_toplevel (GTK_WIDGET (dialog)); - if (!toplevel || !gtk_widget_get_realized (GTK_WIDGET (toplevel))) + widget = GTK_WIDGET (toplevel); + + if (!toplevel || !gtk_widget_get_realized (widget)) return; - display = gtk_widget_get_display (GTK_WIDGET (toplevel)); + display = gtk_widget_get_display (widget); if (busy) cursor = gdk_cursor_new_for_display (display, GDK_WATCH); else cursor = NULL; - gdk_window_set_cursor (GTK_WIDGET (toplevel)->window, cursor); + gdk_window_set_cursor (gtk_widget_get_window (widget), + cursor); gdk_display_flush (display); if (cursor) @@ -494,8 +498,8 @@ error_dialogs (GtkPrintUnixDialog *print_dialog, gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT); - if (toplevel->group) - gtk_window_group_add_window (toplevel->group, + if (gtk_window_has_group (toplevel)) + gtk_window_group_add_window (gtk_window_get_group (toplevel), GTK_WINDOW (dialog)); response = gtk_dialog_run (GTK_DIALOG (dialog)); @@ -1954,6 +1958,7 @@ paint_page (GtkWidget *widget, gchar *text, gint text_x) { + GtkStyle *style; gint x, y, width, height; gint text_y, linewidth; @@ -1965,11 +1970,13 @@ paint_page (GtkWidget *widget, linewidth = 2; text_y = 21; - gdk_cairo_set_source_color (cr, &widget->style->base[GTK_STATE_NORMAL]); + style = gtk_widget_get_style (widget); + + gdk_cairo_set_source_color (cr, &style->base[GTK_STATE_NORMAL]); cairo_rectangle (cr, x, y, width, height); cairo_fill (cr); - gdk_cairo_set_source_color (cr, &widget->style->text[GTK_STATE_NORMAL]); + gdk_cairo_set_source_color (cr, &style->text[GTK_STATE_NORMAL]); cairo_set_line_width (cr, linewidth); cairo_rectangle (cr, x + linewidth/2.0, y + linewidth/2.0, width - linewidth, height - linewidth); cairo_stroke (cr); @@ -1987,6 +1994,7 @@ draw_collate_cb (GtkWidget *widget, GdkEventExpose *event, GtkPrintUnixDialog *dialog) { + GtkAllocation allocation; GtkSettings *settings; cairo_t *cr; gint size; @@ -2009,9 +2017,11 @@ draw_collate_cb (GtkWidget *widget, scale = size / 48.0; text_x = rtl ? 4 : 11; - cr = gdk_cairo_create (widget->window); + cr = gdk_cairo_create (gtk_widget_get_window (widget)); - cairo_translate (cr, widget->allocation.x, widget->allocation.y); + gtk_widget_get_allocation (widget, &allocation); + cairo_translate (cr, allocation.x, allocation.y); + gtk_widget_set_allocation (widget, &allocation); if (copies == 1) { @@ -2580,6 +2590,8 @@ draw_page_cb (GtkWidget *widget, GtkPrintUnixDialog *dialog) { GtkPrintUnixDialogPrivate *priv = dialog->priv; + GtkAllocation allocation; + GtkStyle *style; cairo_t *cr; gdouble ratio; gint w, h, tmp, shadow_offset; @@ -2608,7 +2620,7 @@ draw_page_cb (GtkWidget *widget, number_up_layout = dialog_get_number_up_layout (dialog); - cr = gdk_cairo_create (widget->window); + cr = gdk_cairo_create (gtk_widget_get_window (widget)); cairo_save (cr); @@ -2688,25 +2700,27 @@ draw_page_cb (GtkWidget *widget, pages_y = tmp; } - pos_x = widget->allocation.x + (widget->allocation.width - w) / 2; - pos_y = widget->allocation.y + (widget->allocation.height - h) / 2 - 10; - color = &widget->style->text[GTK_STATE_NORMAL]; + style = gtk_widget_get_style (widget); + + gtk_widget_get_allocation (widget, &allocation); + pos_x = allocation.x + (allocation.width - w) / 2; + pos_y = allocation.y + (allocation.height - h) / 2 - 10; cairo_translate (cr, pos_x, pos_y); shadow_offset = 3; - color = &widget->style->text[GTK_STATE_NORMAL]; + color = &style->text[GTK_STATE_NORMAL]; cairo_set_source_rgba (cr, color->red / 65535., color->green / 65535., color->blue / 65535, 0.5); cairo_rectangle (cr, shadow_offset + 1, shadow_offset + 1, w, h); cairo_fill (cr); - gdk_cairo_set_source_color (cr, &widget->style->base[GTK_STATE_NORMAL]); + gdk_cairo_set_source_color (cr, &style->base[GTK_STATE_NORMAL]); cairo_rectangle (cr, 1, 1, w, h); cairo_fill (cr); cairo_set_line_width (cr, 1.0); cairo_rectangle (cr, 0.5, 0.5, w + 1, h + 1); - gdk_cairo_set_source_color (cr, &widget->style->text[GTK_STATE_NORMAL]); + gdk_cairo_set_source_color (cr, &style->text[GTK_STATE_NORMAL]); cairo_stroke (cr); i = 1; @@ -2900,12 +2914,13 @@ draw_page_cb (GtkWidget *widget, ltr = gtk_widget_get_direction (GTK_WIDGET (dialog)) == GTK_TEXT_DIR_LTR; + gtk_widget_get_allocation (widget, &allocation); if (ltr) cairo_translate (cr, pos_x - layout_w / PANGO_SCALE - 2 * RULER_DISTANCE, - widget->allocation.y + (widget->allocation.height - layout_h / PANGO_SCALE) / 2); + allocation.y + (allocation.height - layout_h / PANGO_SCALE) / 2); else cairo_translate (cr, pos_x + w + shadow_offset + 2 * RULER_DISTANCE, - widget->allocation.y + (widget->allocation.height - layout_h / PANGO_SCALE) / 2); + allocation.y + (allocation.height - layout_h / PANGO_SCALE) / 2); pango_cairo_show_layout (cr, layout); @@ -2921,7 +2936,7 @@ draw_page_cb (GtkWidget *widget, g_free (text); pango_layout_get_size (layout, &layout_w, &layout_h); - cairo_translate (cr, widget->allocation.x + (widget->allocation.width - layout_w / PANGO_SCALE) / 2, + cairo_translate (cr, allocation.x + (allocation.width - layout_w / PANGO_SCALE) / 2, pos_y + h + shadow_offset + 2 * RULER_DISTANCE); pango_cairo_show_layout (cr, layout); diff --git a/gtk/gtkprogressbar.c b/gtk/gtkprogressbar.c index 55a3ccee20..daba35d6dc 100644 --- a/gtk/gtkprogressbar.c +++ b/gtk/gtkprogressbar.c @@ -39,7 +39,7 @@ #define MIN_VERTICAL_BAR_HEIGHT 80 -struct _GtkProgressBarPriv +struct _GtkProgressBarPrivate { GtkProgressBarOrientation orientation; @@ -242,17 +242,17 @@ gtk_progress_bar_class_init (GtkProgressBarClass *class) 1, G_MAXINT, MIN_VERTICAL_BAR_HEIGHT, G_PARAM_READWRITE)); - g_type_class_add_private (class, sizeof (GtkProgressBarPriv)); + g_type_class_add_private (class, sizeof (GtkProgressBarPrivate)); } static void gtk_progress_bar_init (GtkProgressBar *pbar) { - GtkProgressBarPriv *priv; + GtkProgressBarPrivate *priv; pbar->priv = G_TYPE_INSTANCE_GET_PRIVATE (pbar, GTK_TYPE_PROGRESS_BAR, - GtkProgressBarPriv); + GtkProgressBarPrivate); priv = pbar->priv; priv->blocks = 10; @@ -273,16 +273,20 @@ gtk_progress_bar_init (GtkProgressBar *pbar) static void gtk_progress_bar_realize (GtkWidget *widget) { + GtkAllocation allocation; + GdkWindow *window; GdkWindowAttr attributes; gint attributes_mask; gtk_widget_set_realized (widget, TRUE); + gtk_widget_get_allocation (widget, &allocation); + attributes.window_type = GDK_WINDOW_CHILD; - attributes.x = widget->allocation.x; - attributes.y = widget->allocation.y; - attributes.width = widget->allocation.width; - attributes.height = widget->allocation.height; + attributes.x = allocation.x; + attributes.y = allocation.y; + attributes.width = allocation.width; + attributes.height = allocation.height; attributes.wclass = GDK_INPUT_OUTPUT; attributes.visual = gtk_widget_get_visual (widget); attributes.colormap = gtk_widget_get_colormap (widget); @@ -290,12 +294,14 @@ gtk_progress_bar_realize (GtkWidget *widget) attributes.event_mask |= GDK_EXPOSURE_MASK; attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; - widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), - &attributes, attributes_mask); - gdk_window_set_user_data (widget->window, widget); - - widget->style = gtk_style_attach (widget->style, widget->window); - gtk_style_set_background (widget->style, widget->window, GTK_STATE_ACTIVE); + window = gdk_window_new (gtk_widget_get_parent_window (widget), + &attributes, attributes_mask); + gtk_widget_set_window (widget, window); + gdk_window_set_user_data (window, widget); + + gtk_widget_style_attach (widget); + gtk_style_set_background (gtk_widget_get_style (widget), + window, GTK_STATE_ACTIVE); } static void @@ -341,7 +347,7 @@ gtk_progress_bar_get_property (GObject *object, GParamSpec *pspec) { GtkProgressBar *pbar = GTK_PROGRESS_BAR (object); - GtkProgressBarPriv* priv = pbar->priv; + GtkProgressBarPrivate* priv = pbar->priv; switch (prop_id) { @@ -382,7 +388,7 @@ gtk_progress_bar_new (void) static void gtk_progress_bar_real_update (GtkProgressBar *pbar) { - GtkProgressBarPriv *priv; + GtkProgressBarPrivate *priv; GtkWidget *widget; g_return_if_fail (GTK_IS_PROGRESS_BAR (pbar)); @@ -392,33 +398,37 @@ gtk_progress_bar_real_update (GtkProgressBar *pbar) if (priv->activity_mode) { + GtkAllocation allocation; + GtkStyle *style; guint size; + gtk_widget_get_allocation (widget, &allocation); + style = gtk_widget_get_style (widget); + /* advance the block */ if (priv->orientation == GTK_PROGRESS_LEFT_TO_RIGHT || priv->orientation == GTK_PROGRESS_RIGHT_TO_LEFT) { /* Update our activity step. */ - priv->activity_step = widget->allocation.width * priv->pulse_fraction; + priv->activity_step = allocation.width * priv->pulse_fraction; - size = MAX (2, widget->allocation.width / priv->activity_blocks); + size = MAX (2, allocation.width / priv->activity_blocks); if (priv->activity_dir == 0) { priv->activity_pos += priv->activity_step; - if (priv->activity_pos + size >= widget->allocation.width - widget->style->xthickness) + if (priv->activity_pos + size >= allocation.width - style->xthickness) { - priv->activity_pos = widget->allocation.width - - widget->style->xthickness - size; + priv->activity_pos = allocation.width - style->xthickness - size; priv->activity_dir = 1; } } else { priv->activity_pos -= priv->activity_step; - if (priv->activity_pos <= widget->style->xthickness) + if (priv->activity_pos <= style->xthickness) { - priv->activity_pos = widget->style->xthickness; + priv->activity_pos = style->xthickness; priv->activity_dir = 0; } } @@ -426,26 +436,25 @@ gtk_progress_bar_real_update (GtkProgressBar *pbar) else { /* Update our activity step. */ - priv->activity_step = widget->allocation.height * priv->pulse_fraction; + priv->activity_step = allocation.height * priv->pulse_fraction; - size = MAX (2, widget->allocation.height / priv->activity_blocks); + size = MAX (2, allocation.height / priv->activity_blocks); if (priv->activity_dir == 0) { priv->activity_pos += priv->activity_step; - if (priv->activity_pos + size >= widget->allocation.height - widget->style->ythickness) + if (priv->activity_pos + size >= allocation.height - style->ythickness) { - priv->activity_pos = widget->allocation.height - - widget->style->ythickness - size; + priv->activity_pos = allocation.height - style->ythickness - size; priv->activity_dir = 1; } } else { priv->activity_pos -= priv->activity_step; - if (priv->activity_pos <= widget->style->ythickness) + if (priv->activity_pos <= style->ythickness) { - priv->activity_pos = widget->style->ythickness; + priv->activity_pos = style->ythickness; priv->activity_dir = 0; } } @@ -458,7 +467,7 @@ static void gtk_progress_bar_finalize (GObject *object) { GtkProgressBar *pbar = GTK_PROGRESS_BAR (object); - GtkProgressBarPriv *priv = pbar->priv; + GtkProgressBarPrivate *priv = pbar->priv; g_free (priv->text); @@ -480,7 +489,7 @@ gtk_progress_bar_expose (GtkWidget *widget, static gchar * get_current_text (GtkProgressBar *pbar) { - GtkProgressBarPriv *priv = pbar->priv; + GtkProgressBarPrivate *priv = pbar->priv; if (priv->text) return g_strdup (priv->text); @@ -493,7 +502,8 @@ gtk_progress_bar_size_request (GtkWidget *widget, GtkRequisition *requisition) { GtkProgressBar *pbar; - GtkProgressBarPriv *priv; + GtkProgressBarPrivate *priv; + GtkStyle *style; gchar *buf; PangoRectangle logical_rect; PangoLayout *layout; @@ -504,6 +514,7 @@ gtk_progress_bar_size_request (GtkWidget *widget, g_return_if_fail (GTK_IS_PROGRESS_BAR (widget)); g_return_if_fail (requisition != NULL); + style = gtk_widget_get_style (widget); gtk_widget_style_get (widget, "xspacing", &xspacing, "yspacing", &yspacing, @@ -512,8 +523,8 @@ gtk_progress_bar_size_request (GtkWidget *widget, pbar = GTK_PROGRESS_BAR (widget); priv = pbar->priv; - width = 2 * widget->style->xthickness + xspacing; - height = 2 * widget->style->ythickness + yspacing; + width = 2 * style->xthickness + xspacing; + height = 2 * style->ythickness + yspacing; if (priv->show_text) { @@ -530,7 +541,7 @@ gtk_progress_bar_size_request (GtkWidget *widget, /* The minimum size for ellipsized text is ~ 3 chars */ context = pango_layout_get_context (layout); - metrics = pango_context_get_metrics (context, widget->style->font_desc, pango_context_get_language (context)); + metrics = pango_context_get_metrics (context, style->font_desc, pango_context_get_language (context)); char_width = pango_font_metrics_get_approximate_char_width (metrics); pango_font_metrics_unref (metrics); @@ -566,11 +577,11 @@ static void gtk_progress_bar_size_allocate (GtkWidget *widget, GtkAllocation *allocation) { - widget->allocation = *allocation; + gtk_widget_set_allocation (widget, allocation); if (gtk_widget_get_realized (widget)) { - gdk_window_move_resize (widget->window, + gdk_window_move_resize (gtk_widget_get_window (widget), allocation->x, allocation->y, allocation->width, allocation->height); } @@ -579,10 +590,14 @@ gtk_progress_bar_size_allocate (GtkWidget *widget, static void gtk_progress_bar_act_mode_enter (GtkProgressBar *pbar) { - GtkProgressBarPriv *priv = pbar->priv; + GtkProgressBarPrivate *priv = pbar->priv; + GtkAllocation allocation; + GtkStyle *style; GtkWidget *widget = GTK_WIDGET (pbar); GtkProgressBarOrientation orientation; + style = gtk_widget_get_style (widget); + orientation = priv->orientation; if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) { @@ -599,14 +614,14 @@ gtk_progress_bar_act_mode_enter (GtkProgressBar *pbar) { if (orientation == GTK_PROGRESS_LEFT_TO_RIGHT) { - priv->activity_pos = widget->style->xthickness; + priv->activity_pos = style->xthickness; priv->activity_dir = 0; } else { - priv->activity_pos = widget->allocation.width - - widget->style->xthickness - (widget->allocation.height - - widget->style->ythickness * 2); + gtk_widget_get_allocation (widget, &allocation); + priv->activity_pos = allocation.width - style->xthickness - + (allocation.height - style->ythickness * 2); priv->activity_dir = 1; } } @@ -614,14 +629,14 @@ gtk_progress_bar_act_mode_enter (GtkProgressBar *pbar) { if (orientation == GTK_PROGRESS_TOP_TO_BOTTOM) { - priv->activity_pos = widget->style->ythickness; + priv->activity_pos = style->ythickness; priv->activity_dir = 0; } else { - priv->activity_pos = widget->allocation.height - - widget->style->ythickness - (widget->allocation.width - - widget->style->xthickness * 2); + gtk_widget_get_allocation (widget, &allocation); + priv->activity_pos = allocation.height - style->ythickness - + (allocation.width - style->xthickness * 2); priv->activity_dir = 1; } } @@ -633,21 +648,24 @@ gtk_progress_bar_get_activity (GtkProgressBar *pbar, gint *offset, gint *amount) { - GtkProgressBarPriv *priv = pbar->priv; + GtkProgressBarPrivate *priv = pbar->priv; + GtkAllocation allocation; GtkWidget *widget = GTK_WIDGET (pbar); *offset = priv->activity_pos; + gtk_widget_get_allocation (widget, &allocation); + switch (orientation) { case GTK_PROGRESS_LEFT_TO_RIGHT: case GTK_PROGRESS_RIGHT_TO_LEFT: - *amount = MAX (2, widget->allocation.width / priv->activity_blocks); + *amount = MAX (2, allocation.width / priv->activity_blocks); break; case GTK_PROGRESS_TOP_TO_BOTTOM: case GTK_PROGRESS_BOTTOM_TO_TOP: - *amount = MAX (2, widget->allocation.height / priv->activity_blocks); + *amount = MAX (2, allocation.height / priv->activity_blocks); break; } } @@ -656,23 +674,28 @@ static void gtk_progress_bar_paint_activity (GtkProgressBar *pbar, GtkProgressBarOrientation orientation) { + GtkAllocation allocation; + GtkStyle *style; GtkWidget *widget = GTK_WIDGET (pbar); GdkRectangle area; + style = gtk_widget_get_style (widget); + gtk_widget_get_allocation (widget, &allocation); + switch (orientation) { case GTK_PROGRESS_LEFT_TO_RIGHT: case GTK_PROGRESS_RIGHT_TO_LEFT: gtk_progress_bar_get_activity (pbar, orientation, &area.x, &area.width); - area.y = widget->style->ythickness; - area.height = widget->allocation.height - 2 * widget->style->ythickness; + area.y = style->ythickness; + area.height = allocation.height - 2 * style->ythickness; break; case GTK_PROGRESS_TOP_TO_BOTTOM: case GTK_PROGRESS_BOTTOM_TO_TOP: gtk_progress_bar_get_activity (pbar, orientation, &area.y, &area.height); - area.x = widget->style->xthickness; - area.width = widget->allocation.width - 2 * widget->style->xthickness; + area.x = style->xthickness; + area.width = allocation.width - 2 * style->xthickness; break; default: @@ -680,7 +703,7 @@ gtk_progress_bar_paint_activity (GtkProgressBar *pbar, break; } - gtk_paint_box (widget->style, + gtk_paint_box (style, gtk_widget_get_window (widget), GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, &area, widget, "bar", @@ -692,34 +715,39 @@ gtk_progress_bar_paint_continuous (GtkProgressBar *pbar, gint amount, GtkProgressBarOrientation orientation) { + GtkAllocation allocation; + GtkStyle *style; GtkWidget *widget = GTK_WIDGET (pbar); GdkRectangle area; if (amount <= 0) return; + style = gtk_widget_get_style (widget); + gtk_widget_get_allocation (widget, &allocation); + switch (orientation) { case GTK_PROGRESS_LEFT_TO_RIGHT: case GTK_PROGRESS_RIGHT_TO_LEFT: area.width = amount; - area.height = widget->allocation.height - widget->style->ythickness * 2; - area.y = widget->style->ythickness; + area.height = allocation.height - style->ythickness * 2; + area.y = style->ythickness; - area.x = widget->style->xthickness; + area.x = style->xthickness; if (orientation == GTK_PROGRESS_RIGHT_TO_LEFT) - area.x = widget->allocation.width - amount - area.x; + area.x = allocation.width - amount - area.x; break; case GTK_PROGRESS_TOP_TO_BOTTOM: case GTK_PROGRESS_BOTTOM_TO_TOP: - area.width = widget->allocation.width - widget->style->xthickness * 2; + area.width = allocation.width - style->xthickness * 2; area.height = amount; - area.x = widget->style->xthickness; + area.x = style->xthickness; - area.y = widget->style->ythickness; + area.y = style->ythickness; if (orientation == GTK_PROGRESS_BOTTOM_TO_TOP) - area.y = widget->allocation.height - amount - area.y; + area.y = allocation.height - amount - area.y; break; default: @@ -727,7 +755,7 @@ gtk_progress_bar_paint_continuous (GtkProgressBar *pbar, break; } - gtk_paint_box (widget->style, + gtk_paint_box (style, gtk_widget_get_window (widget), GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, &area, widget, "bar", @@ -740,7 +768,9 @@ gtk_progress_bar_paint_text (GtkProgressBar *pbar, gint amount, GtkProgressBarOrientation orientation) { - GtkProgressBarPriv *priv = pbar->priv; + GtkProgressBarPrivate *priv = pbar->priv; + GtkAllocation allocation; + GtkStyle *style; GtkWidget *widget = GTK_WIDGET (pbar); gint x; gint y; @@ -752,6 +782,9 @@ gtk_progress_bar_paint_text (GtkProgressBar *pbar, gfloat text_xalign = 0.5; gfloat text_yalign = 0.5; + style = gtk_widget_get_style (widget); + gtk_widget_get_allocation (widget, &allocation); + if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_LTR) text_xalign = 1.0 - text_xalign; @@ -760,22 +793,18 @@ gtk_progress_bar_paint_text (GtkProgressBar *pbar, layout = gtk_widget_create_pango_layout (widget, buf); pango_layout_set_ellipsize (layout, priv->ellipsize); if (priv->ellipsize) - pango_layout_set_width (layout, widget->allocation.width * PANGO_SCALE); + pango_layout_set_width (layout, allocation.width * PANGO_SCALE); pango_layout_get_pixel_extents (layout, NULL, &logical_rect); - x = widget->style->xthickness + 1 + text_xalign * - (widget->allocation.width - 2 * widget->style->xthickness - - 2 - logical_rect.width); + x = style->xthickness + 1 + text_xalign * (allocation.width - 2 * style->xthickness - 2 - logical_rect.width); - y = widget->style->ythickness + 1 + text_yalign * - (widget->allocation.height - 2 * widget->style->ythickness - - 2 - logical_rect.height); + y = style->ythickness + 1 + text_yalign * (allocation.height - 2 * style->ythickness - 2 - logical_rect.height); - rect.x = widget->style->xthickness; - rect.y = widget->style->ythickness; - rect.width = widget->allocation.width - 2 * widget->style->xthickness; - rect.height = widget->allocation.height - 2 * widget->style->ythickness; + rect.x = style->xthickness; + rect.y = style->ythickness; + rect.width = allocation.width - 2 * style->xthickness; + rect.height = allocation.height - 2 * style->ythickness; prelight_clip = start_clip = end_clip = rect; @@ -823,7 +852,7 @@ gtk_progress_bar_paint_text (GtkProgressBar *pbar, } if (start_clip.width > 0 && start_clip.height > 0) - gtk_paint_layout (widget->style, + gtk_paint_layout (style, gtk_widget_get_window (widget), GTK_STATE_NORMAL, FALSE, @@ -834,7 +863,7 @@ gtk_progress_bar_paint_text (GtkProgressBar *pbar, layout); if (end_clip.width > 0 && end_clip.height > 0) - gtk_paint_layout (widget->style, + gtk_paint_layout (style, gtk_widget_get_window (widget), GTK_STATE_NORMAL, FALSE, @@ -844,7 +873,7 @@ gtk_progress_bar_paint_text (GtkProgressBar *pbar, x, y, layout); - gtk_paint_layout (widget->style, + gtk_paint_layout (style, gtk_widget_get_window (widget), GTK_STATE_PRELIGHT, FALSE, @@ -861,9 +890,14 @@ gtk_progress_bar_paint_text (GtkProgressBar *pbar, static void gtk_progress_bar_paint (GtkProgressBar *pbar) { - GtkProgressBarPriv *priv = pbar->priv; + GtkProgressBarPrivate *priv = pbar->priv; + GtkAllocation allocation; GtkWidget *widget = GTK_WIDGET (pbar); GtkProgressBarOrientation orientation; + GtkStyle *style; + + style = gtk_widget_get_style (widget); + gtk_widget_get_allocation (widget, &allocation); orientation = priv->orientation; if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) @@ -874,13 +908,13 @@ gtk_progress_bar_paint (GtkProgressBar *pbar) orientation = GTK_PROGRESS_LEFT_TO_RIGHT; } - gtk_paint_box (widget->style, + gtk_paint_box (style, gtk_widget_get_window (widget), GTK_STATE_NORMAL, GTK_SHADOW_IN, NULL, widget, "trough", 0, 0, - widget->allocation.width, - widget->allocation.height); + allocation.width, + allocation.height); if (priv->activity_mode) { @@ -902,9 +936,9 @@ gtk_progress_bar_paint (GtkProgressBar *pbar) if (orientation == GTK_PROGRESS_LEFT_TO_RIGHT || orientation == GTK_PROGRESS_RIGHT_TO_LEFT) - space = widget->allocation.width - 2 * widget->style->xthickness; + space = allocation.width - 2 * style->xthickness; else - space = widget->allocation.height - 2 * widget->style->ythickness; + space = allocation.height - 2 * style->ythickness; amount = space * gtk_progress_bar_get_fraction (pbar); @@ -919,7 +953,7 @@ static void gtk_progress_bar_set_activity_mode (GtkProgressBar *pbar, gboolean activity_mode) { - GtkProgressBarPriv *priv = pbar->priv; + GtkProgressBarPrivate *priv = pbar->priv; activity_mode = !!activity_mode; @@ -949,7 +983,7 @@ void gtk_progress_bar_set_fraction (GtkProgressBar *pbar, gdouble fraction) { - GtkProgressBarPriv* priv; + GtkProgressBarPrivate* priv; g_return_if_fail (GTK_IS_PROGRESS_BAR (pbar)); @@ -992,7 +1026,7 @@ void gtk_progress_bar_set_text (GtkProgressBar *pbar, const gchar *text) { - GtkProgressBarPriv *priv; + GtkProgressBarPrivate *priv; g_return_if_fail (GTK_IS_PROGRESS_BAR (pbar)); @@ -1023,7 +1057,7 @@ void gtk_progress_bar_set_show_text (GtkProgressBar *pbar, gboolean show_text) { - GtkProgressBarPriv *priv; + GtkProgressBarPrivate *priv; g_return_if_fail (GTK_IS_PROGRESS_BAR (pbar)); @@ -1073,7 +1107,7 @@ void gtk_progress_bar_set_pulse_step (GtkProgressBar *pbar, gdouble fraction) { - GtkProgressBarPriv *priv; + GtkProgressBarPrivate *priv; g_return_if_fail (GTK_IS_PROGRESS_BAR (pbar)); @@ -1096,7 +1130,7 @@ void gtk_progress_bar_set_orientation (GtkProgressBar *pbar, GtkProgressBarOrientation orientation) { - GtkProgressBarPriv *priv; + GtkProgressBarPrivate *priv; g_return_if_fail (GTK_IS_PROGRESS_BAR (pbar)); @@ -1195,7 +1229,7 @@ void gtk_progress_bar_set_ellipsize (GtkProgressBar *pbar, PangoEllipsizeMode mode) { - GtkProgressBarPriv *priv; + GtkProgressBarPrivate *priv; g_return_if_fail (GTK_IS_PROGRESS_BAR (pbar)); g_return_if_fail (mode >= PANGO_ELLIPSIZE_NONE && diff --git a/gtk/gtkprogressbar.h b/gtk/gtkprogressbar.h index 9d32e520ec..1c4d51a61f 100644 --- a/gtk/gtkprogressbar.h +++ b/gtk/gtkprogressbar.h @@ -43,9 +43,9 @@ G_BEGIN_DECLS #define GTK_PROGRESS_BAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_PROGRESS_BAR, GtkProgressBarClass)) -typedef struct _GtkProgressBar GtkProgressBar; -typedef struct _GtkProgressBarPriv GtkProgressBarPriv; -typedef struct _GtkProgressBarClass GtkProgressBarClass; +typedef struct _GtkProgressBar GtkProgressBar; +typedef struct _GtkProgressBarPrivate GtkProgressBarPrivate; +typedef struct _GtkProgressBarClass GtkProgressBarClass; typedef enum { @@ -60,7 +60,7 @@ struct _GtkProgressBar GtkWidget parent; /* <private> */ - GtkProgressBarPriv *priv; + GtkProgressBarPrivate *priv; }; struct _GtkProgressBarClass diff --git a/gtk/gtkradiobutton.c b/gtk/gtkradiobutton.c index 675c29a3d8..fc78eadb46 100644 --- a/gtk/gtkradiobutton.c +++ b/gtk/gtkradiobutton.c @@ -103,7 +103,7 @@ */ -struct _GtkRadioButtonPriv +struct _GtkRadioButtonPrivate { GSList *group; }; @@ -194,17 +194,17 @@ gtk_radio_button_class_init (GtkRadioButtonClass *class) _gtk_marshal_VOID__VOID, G_TYPE_NONE, 0); - g_type_class_add_private (class, sizeof (GtkRadioButtonPriv)); + g_type_class_add_private (class, sizeof (GtkRadioButtonPrivate)); } static void gtk_radio_button_init (GtkRadioButton *radio_button) { - GtkRadioButtonPriv *priv; + GtkRadioButtonPrivate *priv; radio_button->priv = G_TYPE_INSTANCE_GET_PRIVATE (radio_button, GTK_TYPE_RADIO_BUTTON, - GtkRadioButtonPriv); + GtkRadioButtonPrivate); priv = radio_button->priv; gtk_widget_set_has_window (GTK_WIDGET (radio_button), FALSE); @@ -279,7 +279,7 @@ void gtk_radio_button_set_group (GtkRadioButton *radio_button, GSList *group) { - GtkRadioButtonPriv *priv; + GtkRadioButtonPrivate *priv; GtkWidget *old_group_singleton = NULL; GtkWidget *new_group_singleton = NULL; @@ -507,7 +507,7 @@ gtk_radio_button_destroy (GtkObject *object) { GtkWidget *old_group_singleton = NULL; GtkRadioButton *radio_button = GTK_RADIO_BUTTON (object); - GtkRadioButtonPriv *priv = radio_button->priv; + GtkRadioButtonPrivate *priv = radio_button->priv; GtkRadioButton *tmp_button; GSList *tmp_list; gboolean was_in_group; @@ -545,9 +545,12 @@ get_coordinates (GtkWidget *widget, gint *x, gint *y) { - *x = widget->allocation.x + widget->allocation.width / 2; - *y = widget->allocation.y + widget->allocation.height / 2; - + GtkAllocation allocation; + + gtk_widget_get_allocation (widget, &allocation); + *x = allocation.x + allocation.width / 2; + *y = allocation.y + allocation.height / 2; + gtk_widget_translate_coordinates (widget, reference, *x, *y, x, y); } @@ -588,7 +591,7 @@ gtk_radio_button_focus (GtkWidget *widget, GtkDirectionType direction) { GtkRadioButton *radio_button = GTK_RADIO_BUTTON (widget); - GtkRadioButtonPriv *priv = radio_button->priv; + GtkRadioButtonPrivate *priv = radio_button->priv; GSList *tmp_slist; /* Radio buttons with draw_indicator unset focus "normally", since @@ -725,7 +728,7 @@ static void gtk_radio_button_clicked (GtkButton *button) { GtkRadioButton *radio_button = GTK_RADIO_BUTTON (button); - GtkRadioButtonPriv *priv = radio_button->priv; + GtkRadioButtonPrivate *priv = radio_button->priv; GtkToggleButton *toggle_button = GTK_TOGGLE_BUTTON (button); GtkToggleButton *tmp_button; GtkStateType new_state; @@ -813,12 +816,15 @@ static void gtk_radio_button_draw_indicator (GtkCheckButton *check_button, GdkRectangle *area) { + GtkAllocation allocation; GtkWidget *widget; GtkWidget *child; GtkButton *button; GtkToggleButton *toggle_button; GtkStateType state_type; GtkShadowType shadow_type; + GtkStyle *style; + GdkWindow *window; gint x, y; gint indicator_size, indicator_spacing; gint focus_width; @@ -835,16 +841,21 @@ gtk_radio_button_draw_indicator (GtkCheckButton *check_button, border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); + style = gtk_widget_get_style (widget); gtk_widget_style_get (widget, "interior-focus", &interior_focus, "focus-line-width", &focus_width, "focus-padding", &focus_pad, NULL); + window = gtk_widget_get_window (widget); + _gtk_check_button_get_props (check_button, &indicator_size, &indicator_spacing); - x = widget->allocation.x + indicator_spacing + border_width; - y = widget->allocation.y + (widget->allocation.height - indicator_size) / 2; + gtk_widget_get_allocation (widget, &allocation); + + x = allocation.x + indicator_spacing + border_width; + y = allocation.y + (allocation.height - indicator_size) / 2; child = gtk_bin_get_child (GTK_BIN (check_button)); if (!interior_focus || !(child && gtk_widget_get_visible (child))) @@ -867,21 +878,22 @@ gtk_radio_button_draw_indicator (GtkCheckButton *check_button, state_type = GTK_STATE_NORMAL; if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) - x = widget->allocation.x + widget->allocation.width - (indicator_size + x - widget->allocation.x); + x = allocation.x + allocation.width - (indicator_size + x - allocation.x); if (gtk_widget_get_state (widget) == GTK_STATE_PRELIGHT) { GdkRectangle restrict_area; GdkRectangle new_area; - - restrict_area.x = widget->allocation.x + border_width; - restrict_area.y = widget->allocation.y + border_width; - restrict_area.width = widget->allocation.width - (2 * border_width); - restrict_area.height = widget->allocation.height - (2 * border_width); - + + restrict_area.x = allocation.x + border_width; + restrict_area.y = allocation.y + border_width; + restrict_area.width = allocation.width - (2 * border_width); + restrict_area.height = allocation.height - (2 * border_width); + if (gdk_rectangle_intersect (area, &restrict_area, &new_area)) { - gtk_paint_flat_box (widget->style, widget->window, GTK_STATE_PRELIGHT, + gtk_paint_flat_box (style, window, + GTK_STATE_PRELIGHT, GTK_SHADOW_ETCHED_OUT, area, widget, "checkbutton", new_area.x, new_area.y, @@ -889,7 +901,7 @@ gtk_radio_button_draw_indicator (GtkCheckButton *check_button, } } - gtk_paint_option (widget->style, widget->window, + gtk_paint_option (style, window, state_type, shadow_type, area, widget, "radiobutton", x, y, indicator_size, indicator_size); diff --git a/gtk/gtkradiobutton.h b/gtk/gtkradiobutton.h index 7c1e5b4cd6..84e7042821 100644 --- a/gtk/gtkradiobutton.h +++ b/gtk/gtkradiobutton.h @@ -45,16 +45,16 @@ G_BEGIN_DECLS #define GTK_RADIO_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_RADIO_BUTTON, GtkRadioButtonClass)) -typedef struct _GtkRadioButton GtkRadioButton; -typedef struct _GtkRadioButtonPriv GtkRadioButtonPriv; -typedef struct _GtkRadioButtonClass GtkRadioButtonClass; +typedef struct _GtkRadioButton GtkRadioButton; +typedef struct _GtkRadioButtonPrivate GtkRadioButtonPrivate; +typedef struct _GtkRadioButtonClass GtkRadioButtonClass; struct _GtkRadioButton { GtkCheckButton check_button; /* <private> */ - GtkRadioButtonPriv *priv; + GtkRadioButtonPrivate *priv; }; struct _GtkRadioButtonClass diff --git a/gtk/gtkradiomenuitem.c b/gtk/gtkradiomenuitem.c index abf7a4c028..8fdd12b300 100644 --- a/gtk/gtkradiomenuitem.c +++ b/gtk/gtkradiomenuitem.c @@ -33,7 +33,7 @@ #include "gtkintl.h" -struct _GtkRadioMenuItemPriv +struct _GtkRadioMenuItemPrivate { GSList *group; }; @@ -116,7 +116,7 @@ void gtk_radio_menu_item_set_group (GtkRadioMenuItem *radio_menu_item, GSList *group) { - GtkRadioMenuItemPriv *priv; + GtkRadioMenuItemPrivate *priv; GtkWidget *old_group_singleton = NULL; GtkWidget *new_group_singleton = NULL; @@ -387,17 +387,17 @@ gtk_radio_menu_item_class_init (GtkRadioMenuItemClass *klass) _gtk_marshal_VOID__VOID, G_TYPE_NONE, 0); - g_type_class_add_private (klass, sizeof (GtkRadioMenuItemPriv)); + g_type_class_add_private (klass, sizeof (GtkRadioMenuItemPrivate)); } static void gtk_radio_menu_item_init (GtkRadioMenuItem *radio_menu_item) { - GtkRadioMenuItemPriv *priv; + GtkRadioMenuItemPrivate *priv; radio_menu_item->priv = G_TYPE_INSTANCE_GET_PRIVATE (radio_menu_item, GTK_TYPE_RADIO_MENU_ITEM, - GtkRadioMenuItemPriv); + GtkRadioMenuItemPrivate); priv = radio_menu_item->priv; priv->group = g_slist_prepend (NULL, radio_menu_item); @@ -408,7 +408,7 @@ static void gtk_radio_menu_item_destroy (GtkObject *object) { GtkRadioMenuItem *radio_menu_item = GTK_RADIO_MENU_ITEM (object); - GtkRadioMenuItemPriv *priv = radio_menu_item->priv; + GtkRadioMenuItemPrivate *priv = radio_menu_item->priv; GtkWidget *old_group_singleton = NULL; GtkRadioMenuItem *tmp_menu_item; GSList *tmp_list; @@ -445,7 +445,7 @@ static void gtk_radio_menu_item_activate (GtkMenuItem *menu_item) { GtkRadioMenuItem *radio_menu_item = GTK_RADIO_MENU_ITEM (menu_item); - GtkRadioMenuItemPriv *priv = radio_menu_item->priv; + GtkRadioMenuItemPrivate *priv = radio_menu_item->priv; GtkCheckMenuItem *check_menu_item = GTK_CHECK_MENU_ITEM (menu_item); GtkCheckMenuItem *tmp_menu_item; GtkAction *action; diff --git a/gtk/gtkradiomenuitem.h b/gtk/gtkradiomenuitem.h index e7fdb796f3..865ce42c92 100644 --- a/gtk/gtkradiomenuitem.h +++ b/gtk/gtkradiomenuitem.h @@ -45,16 +45,16 @@ G_BEGIN_DECLS #define GTK_RADIO_MENU_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_RADIO_MENU_ITEM, GtkRadioMenuItemClass)) -typedef struct _GtkRadioMenuItem GtkRadioMenuItem; -typedef struct _GtkRadioMenuItemPriv GtkRadioMenuItemPriv; -typedef struct _GtkRadioMenuItemClass GtkRadioMenuItemClass; +typedef struct _GtkRadioMenuItem GtkRadioMenuItem; +typedef struct _GtkRadioMenuItemPrivate GtkRadioMenuItemPrivate; +typedef struct _GtkRadioMenuItemClass GtkRadioMenuItemClass; struct _GtkRadioMenuItem { GtkCheckMenuItem check_menu_item; /* <private> */ - GtkRadioMenuItemPriv *priv; + GtkRadioMenuItemPrivate *priv; }; struct _GtkRadioMenuItemClass diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c index 8c1c9c3493..31b62fd3b1 100644 --- a/gtk/gtkrange.c +++ b/gtk/gtkrange.c @@ -58,26 +58,7 @@ #define SCROLL_DELAY_FACTOR 5 /* Scroll repeat multiplier */ #define UPDATE_DELAY 300 /* Delay for queued update */ -enum { - PROP_0, - PROP_ORIENTATION, - PROP_UPDATE_POLICY, - PROP_ADJUSTMENT, - PROP_INVERTED, - PROP_LOWER_STEPPER_SENSITIVITY, - PROP_UPPER_STEPPER_SENSITIVITY, - PROP_SHOW_FILL_LEVEL, - PROP_RESTRICT_TO_FILL_LEVEL, - PROP_FILL_LEVEL -}; - -enum { - VALUE_CHANGED, - ADJUST_BOUNDS, - MOVE_SLIDER, - CHANGE_VALUE, - LAST_SIGNAL -}; +typedef struct _GtkRangeStepTimer GtkRangeStepTimer; typedef enum { MOUSE_OUTSIDE, @@ -90,64 +71,106 @@ typedef enum { MOUSE_WIDGET /* inside widget but not in any of the above GUI elements */ } MouseLocation; -typedef enum { - STEPPER_A, - STEPPER_B, - STEPPER_C, - STEPPER_D -} Stepper; +struct _GtkRangePrivate +{ + MouseLocation mouse_location; + /* last mouse coords we got, or -1 if mouse is outside the range */ + gint mouse_x; + gint mouse_y; + MouseLocation grab_location; /* "grabbed" mouse location, OUTSIDE for no grab */ + guint grab_button : 8; /* 0 if none */ -#define GTK_RANGE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_RANGE, GtkRangeLayout)) + GtkRangeStepTimer *timer; -struct _GtkRangeLayout -{ + GtkAdjustment *adjustment; + GtkOrientation orientation; + GtkSensitivityType lower_sensitivity; + GtkSensitivityType upper_sensitivity; + GtkUpdateType update_policy; + + GdkDevice *grab_device; + GdkRectangle range_rect; /* Area of entire stepper + trough assembly in widget->window coords */ /* These are in widget->window coordinates */ - GdkRectangle stepper_a; - GdkRectangle stepper_b; - GdkRectangle stepper_c; - GdkRectangle stepper_d; - /* The trough rectangle is the area the thumb can slide in, not the - * entire range_rect - */ - GdkRectangle trough; - GdkRectangle slider; + GdkRectangle stepper_a; + GdkRectangle stepper_b; + GdkRectangle stepper_c; + GdkRectangle stepper_d; + GdkRectangle trough; /* The trough rectangle is the area the thumb can slide in, not the entire range_rect */ + GdkRectangle slider; + GdkWindow *event_window; - /* Layout-related state */ + GQuark slider_detail_quark; + GQuark stepper_detail_quark[4]; - MouseLocation mouse_location; - /* last mouse coords we got, or -1 if mouse is outside the range */ - gint mouse_x; - gint mouse_y; + gboolean recalc_marks; + + gdouble fill_level; + gdouble *marks; - /* "grabbed" mouse location, OUTSIDE for no grab */ - MouseLocation grab_location; - guint grab_button : 8; /* 0 if none */ + gint *mark_pos; + gint min_slider_size; + gint n_marks; + gint round_digits; /* Round off value to this many digits, -1 for no rounding */ + gint slide_initial_slider_position; + gint slide_initial_coordinate; + gint slider_start; /* Slider range along the long dimension, in widget->window coords */ + gint slider_end; + + guint repaint_id; + guint update_timeout_id; + + /* Steppers are: < > ---- < > + * a b c d + */ + guint has_stepper_a : 1; + guint has_stepper_b : 1; + guint has_stepper_c : 1; + guint has_stepper_d : 1; + + guint flippable : 1; + guint inverted : 1; + guint need_recalc : 1; + guint slider_size_fixed : 1; + guint trough_click_forward : 1; /* trough click was on the forward side of slider */ + guint update_pending : 1; /* need to emit value_changed */ /* Stepper sensitivity */ - guint lower_sensitive : 1; - guint upper_sensitive : 1; + guint lower_sensitive : 1; + guint upper_sensitive : 1; /* Fill level */ - guint show_fill_level : 1; + guint show_fill_level : 1; guint restrict_to_fill_level : 1; +}; - GtkSensitivityType lower_sensitivity; - GtkSensitivityType upper_sensitivity; - guint repaint_id; - - gdouble fill_level; - - GQuark slider_detail_quark; - GQuark stepper_detail_quark[4]; - gdouble *marks; - gint *mark_pos; - gint n_marks; - gboolean recalc_marks; +enum { + PROP_0, + PROP_ORIENTATION, + PROP_UPDATE_POLICY, + PROP_ADJUSTMENT, + PROP_INVERTED, + PROP_LOWER_STEPPER_SENSITIVITY, + PROP_UPPER_STEPPER_SENSITIVITY, + PROP_SHOW_FILL_LEVEL, + PROP_RESTRICT_TO_FILL_LEVEL, + PROP_FILL_LEVEL +}; - GdkDevice *grab_device; +enum { + VALUE_CHANGED, + ADJUST_BOUNDS, + MOVE_SLIDER, + CHANGE_VALUE, + LAST_SIGNAL }; +typedef enum { + STEPPER_A, + STEPPER_B, + STEPPER_C, + STEPPER_D +} Stepper; static void gtk_range_set_property (GObject *object, guint prop_id, @@ -604,7 +627,7 @@ gtk_range_class_init (GtkRangeClass *class) FALSE, GTK_PARAM_READABLE)); - g_type_class_add_private (class, sizeof (GtkRangeLayout)); + g_type_class_add_private (class, sizeof (GtkRangePrivate)); } static void @@ -614,17 +637,18 @@ gtk_range_set_property (GObject *object, GParamSpec *pspec) { GtkRange *range = GTK_RANGE (object); + GtkRangePrivate *priv = range->priv; switch (prop_id) { case PROP_ORIENTATION: - range->orientation = g_value_get_enum (value); + priv->orientation = g_value_get_enum (value); - range->layout->slider_detail_quark = 0; - range->layout->stepper_detail_quark[0] = 0; - range->layout->stepper_detail_quark[1] = 0; - range->layout->stepper_detail_quark[2] = 0; - range->layout->stepper_detail_quark[3] = 0; + priv->slider_detail_quark = 0; + priv->stepper_detail_quark[0] = 0; + priv->stepper_detail_quark[1] = 0; + priv->stepper_detail_quark[2] = 0; + priv->stepper_detail_quark[3] = 0; gtk_widget_queue_resize (GTK_WIDGET (range)); break; @@ -665,20 +689,21 @@ gtk_range_get_property (GObject *object, GParamSpec *pspec) { GtkRange *range = GTK_RANGE (object); + GtkRangePrivate *priv = range->priv; switch (prop_id) { case PROP_ORIENTATION: - g_value_set_enum (value, range->orientation); + g_value_set_enum (value, priv->orientation); break; case PROP_UPDATE_POLICY: - g_value_set_enum (value, range->update_policy); + g_value_set_enum (value, priv->update_policy); break; case PROP_ADJUSTMENT: - g_value_set_object (value, range->adjustment); + g_value_set_object (value, priv->adjustment); break; case PROP_INVERTED: - g_value_set_boolean (value, range->inverted); + g_value_set_boolean (value, priv->inverted); break; case PROP_LOWER_STEPPER_SENSITIVITY: g_value_set_enum (value, gtk_range_get_lower_stepper_sensitivity (range)); @@ -704,34 +729,40 @@ gtk_range_get_property (GObject *object, static void gtk_range_init (GtkRange *range) { + GtkRangePrivate *priv; + + range->priv = G_TYPE_INSTANCE_GET_PRIVATE (range, + GTK_TYPE_RANGE, + GtkRangePrivate); + priv = range->priv; + gtk_widget_set_has_window (GTK_WIDGET (range), FALSE); - range->orientation = GTK_ORIENTATION_HORIZONTAL; - range->adjustment = NULL; - range->update_policy = GTK_UPDATE_CONTINUOUS; - range->inverted = FALSE; - range->flippable = FALSE; - range->min_slider_size = 1; - range->has_stepper_a = FALSE; - range->has_stepper_b = FALSE; - range->has_stepper_c = FALSE; - range->has_stepper_d = FALSE; - range->need_recalc = TRUE; - range->round_digits = -1; - range->layout = GTK_RANGE_GET_PRIVATE (range); - range->layout->mouse_location = MOUSE_OUTSIDE; - range->layout->mouse_x = -1; - range->layout->mouse_y = -1; - range->layout->grab_location = MOUSE_OUTSIDE; - range->layout->grab_button = 0; - range->layout->lower_sensitivity = GTK_SENSITIVITY_AUTO; - range->layout->upper_sensitivity = GTK_SENSITIVITY_AUTO; - range->layout->lower_sensitive = TRUE; - range->layout->upper_sensitive = TRUE; - range->layout->show_fill_level = FALSE; - range->layout->restrict_to_fill_level = TRUE; - range->layout->fill_level = G_MAXDOUBLE; - range->timer = NULL; + priv->orientation = GTK_ORIENTATION_HORIZONTAL; + priv->adjustment = NULL; + priv->update_policy = GTK_UPDATE_CONTINUOUS; + priv->inverted = FALSE; + priv->flippable = FALSE; + priv->min_slider_size = 1; + priv->has_stepper_a = FALSE; + priv->has_stepper_b = FALSE; + priv->has_stepper_c = FALSE; + priv->has_stepper_d = FALSE; + priv->need_recalc = TRUE; + priv->round_digits = -1; + priv->mouse_location = MOUSE_OUTSIDE; + priv->mouse_x = -1; + priv->mouse_y = -1; + priv->grab_location = MOUSE_OUTSIDE; + priv->grab_button = 0; + priv->lower_sensitivity = GTK_SENSITIVITY_AUTO; + priv->upper_sensitivity = GTK_SENSITIVITY_AUTO; + priv->lower_sensitive = TRUE; + priv->upper_sensitive = TRUE; + priv->show_fill_level = FALSE; + priv->restrict_to_fill_level = TRUE; + priv->fill_level = G_MAXDOUBLE; + priv->timer = NULL; } /** @@ -748,12 +779,16 @@ gtk_range_init (GtkRange *range) GtkAdjustment* gtk_range_get_adjustment (GtkRange *range) { + GtkRangePrivate *priv; + g_return_val_if_fail (GTK_IS_RANGE (range), NULL); - if (!range->adjustment) + priv = range->priv; + + if (!priv->adjustment) gtk_range_set_adjustment (range, NULL); - return range->adjustment; + return priv->adjustment; } /** @@ -774,11 +809,15 @@ void gtk_range_set_update_policy (GtkRange *range, GtkUpdateType policy) { + GtkRangePrivate *priv; + g_return_if_fail (GTK_IS_RANGE (range)); - if (range->update_policy != policy) + priv = range->priv; + + if (priv->update_policy != policy) { - range->update_policy = policy; + priv->update_policy = policy; g_object_notify (G_OBJECT (range), "update-policy"); } } @@ -796,7 +835,7 @@ gtk_range_get_update_policy (GtkRange *range) { g_return_val_if_fail (GTK_IS_RANGE (range), GTK_UPDATE_CONTINUOUS); - return range->update_policy; + return range->priv->update_policy; } /** @@ -816,27 +855,31 @@ void gtk_range_set_adjustment (GtkRange *range, GtkAdjustment *adjustment) { + GtkRangePrivate *priv; + g_return_if_fail (GTK_IS_RANGE (range)); - + + priv = range->priv; + if (!adjustment) adjustment = (GtkAdjustment*) gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0); else g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment)); - if (range->adjustment != adjustment) + if (priv->adjustment != adjustment) { - if (range->adjustment) + if (priv->adjustment) { - g_signal_handlers_disconnect_by_func (range->adjustment, + g_signal_handlers_disconnect_by_func (priv->adjustment, gtk_range_adjustment_changed, range); - g_signal_handlers_disconnect_by_func (range->adjustment, + g_signal_handlers_disconnect_by_func (priv->adjustment, gtk_range_adjustment_value_changed, range); - g_object_unref (range->adjustment); + g_object_unref (priv->adjustment); } - range->adjustment = adjustment; + priv->adjustment = adjustment; g_object_ref_sink (adjustment); g_signal_connect (adjustment, "changed", @@ -865,13 +908,17 @@ void gtk_range_set_inverted (GtkRange *range, gboolean setting) { + GtkRangePrivate *priv; + g_return_if_fail (GTK_IS_RANGE (range)); - + + priv = range->priv; + setting = setting != FALSE; - if (setting != range->inverted) + if (setting != priv->inverted) { - range->inverted = setting; + priv->inverted = setting; g_object_notify (G_OBJECT (range), "inverted"); gtk_widget_queue_resize (GTK_WIDGET (range)); } @@ -890,7 +937,7 @@ gtk_range_get_inverted (GtkRange *range) { g_return_val_if_fail (GTK_IS_RANGE (range), FALSE); - return range->inverted; + return range->priv->inverted; } /** @@ -909,13 +956,17 @@ void gtk_range_set_flippable (GtkRange *range, gboolean flippable) { + GtkRangePrivate *priv; + g_return_if_fail (GTK_IS_RANGE (range)); + priv = range->priv; + flippable = flippable ? TRUE : FALSE; - if (flippable != range->flippable) + if (flippable != priv->flippable) { - range->flippable = flippable; + priv->flippable = flippable; gtk_widget_queue_draw (GTK_WIDGET (range)); } @@ -936,7 +987,7 @@ gtk_range_get_flippable (GtkRange *range) { g_return_val_if_fail (GTK_IS_RANGE (range), FALSE); - return range->flippable; + return range->priv->flippable; } /** @@ -955,15 +1006,22 @@ void gtk_range_set_slider_size_fixed (GtkRange *range, gboolean size_fixed) { + GtkRangePrivate *priv; + g_return_if_fail (GTK_IS_RANGE (range)); - if (size_fixed != range->slider_size_fixed) + priv = range->priv; + + if (size_fixed != priv->slider_size_fixed) { - range->slider_size_fixed = size_fixed ? TRUE : FALSE; + priv->slider_size_fixed = size_fixed ? TRUE : FALSE; - range->need_recalc = TRUE; - gtk_range_calc_layout (range, range->adjustment->value); - gtk_widget_queue_draw (GTK_WIDGET (range)); + if (priv->adjustment && gtk_widget_get_mapped (GTK_WIDGET (range))) + { + priv->need_recalc = TRUE; + gtk_range_calc_layout (range, gtk_adjustment_get_value (priv->adjustment)); + gtk_widget_queue_draw (GTK_WIDGET (range)); + } } } @@ -984,7 +1042,7 @@ gtk_range_get_slider_size_fixed (GtkRange *range) { g_return_val_if_fail (GTK_IS_RANGE (range), FALSE); - return range->slider_size_fixed; + return range->priv->slider_size_fixed; } /** @@ -1002,15 +1060,19 @@ void gtk_range_set_min_slider_size (GtkRange *range, gint min_size) { + GtkRangePrivate *priv; + g_return_if_fail (GTK_IS_RANGE (range)); g_return_if_fail (min_size > 0); - if (min_size != range->min_slider_size) + priv = range->priv; + + if (min_size != priv->min_slider_size) { - range->min_slider_size = min_size; + priv->min_slider_size = min_size; - range->need_recalc = TRUE; - gtk_range_calc_layout (range, range->adjustment->value); + priv->need_recalc = TRUE; + gtk_range_calc_layout (range, priv->adjustment->value); gtk_widget_queue_draw (GTK_WIDGET (range)); } } @@ -1032,7 +1094,7 @@ gtk_range_get_min_slider_size (GtkRange *range) { g_return_val_if_fail (GTK_IS_RANGE (range), FALSE); - return range->min_slider_size; + return range->priv->min_slider_size; } /** @@ -1051,12 +1113,16 @@ void gtk_range_get_range_rect (GtkRange *range, GdkRectangle *range_rect) { + GtkRangePrivate *priv; + g_return_if_fail (GTK_IS_RANGE (range)); g_return_if_fail (range_rect != NULL); - gtk_range_calc_layout (range, range->adjustment->value); + priv = range->priv; + + gtk_range_calc_layout (range, priv->adjustment->value); - *range_rect = range->range_rect; + *range_rect = priv->range_rect; } /** @@ -1077,15 +1143,19 @@ gtk_range_get_slider_range (GtkRange *range, gint *slider_start, gint *slider_end) { + GtkRangePrivate *priv; + g_return_if_fail (GTK_IS_RANGE (range)); - gtk_range_calc_layout (range, range->adjustment->value); + priv = range->priv; + + gtk_range_calc_layout (range, priv->adjustment->value); if (slider_start) - *slider_start = range->slider_start; + *slider_start = priv->slider_start; if (slider_end) - *slider_end = range->slider_end; + *slider_end = priv->slider_end; } /** @@ -1102,14 +1172,18 @@ void gtk_range_set_lower_stepper_sensitivity (GtkRange *range, GtkSensitivityType sensitivity) { + GtkRangePrivate *priv; + g_return_if_fail (GTK_IS_RANGE (range)); - if (range->layout->lower_sensitivity != sensitivity) + priv = range->priv; + + if (priv->lower_sensitivity != sensitivity) { - range->layout->lower_sensitivity = sensitivity; + priv->lower_sensitivity = sensitivity; - range->need_recalc = TRUE; - gtk_range_calc_layout (range, range->adjustment->value); + priv->need_recalc = TRUE; + gtk_range_calc_layout (range, priv->adjustment->value); gtk_widget_queue_draw (GTK_WIDGET (range)); g_object_notify (G_OBJECT (range), "lower-stepper-sensitivity"); @@ -1132,7 +1206,7 @@ gtk_range_get_lower_stepper_sensitivity (GtkRange *range) { g_return_val_if_fail (GTK_IS_RANGE (range), GTK_SENSITIVITY_AUTO); - return range->layout->lower_sensitivity; + return range->priv->lower_sensitivity; } /** @@ -1149,14 +1223,18 @@ void gtk_range_set_upper_stepper_sensitivity (GtkRange *range, GtkSensitivityType sensitivity) { + GtkRangePrivate *priv; + g_return_if_fail (GTK_IS_RANGE (range)); - if (range->layout->upper_sensitivity != sensitivity) + priv = range->priv; + + if (priv->upper_sensitivity != sensitivity) { - range->layout->upper_sensitivity = sensitivity; + priv->upper_sensitivity = sensitivity; - range->need_recalc = TRUE; - gtk_range_calc_layout (range, range->adjustment->value); + priv->need_recalc = TRUE; + gtk_range_calc_layout (range, priv->adjustment->value); gtk_widget_queue_draw (GTK_WIDGET (range)); g_object_notify (G_OBJECT (range), "upper-stepper-sensitivity"); @@ -1179,7 +1257,7 @@ gtk_range_get_upper_stepper_sensitivity (GtkRange *range) { g_return_val_if_fail (GTK_IS_RANGE (range), GTK_SENSITIVITY_AUTO); - return range->layout->upper_sensitivity; + return range->priv->upper_sensitivity; } /** @@ -1198,12 +1276,16 @@ gtk_range_set_increments (GtkRange *range, gdouble step, gdouble page) { + GtkRangePrivate *priv; + g_return_if_fail (GTK_IS_RANGE (range)); - range->adjustment->step_increment = step; - range->adjustment->page_increment = page; + priv = range->priv; - gtk_adjustment_changed (range->adjustment); + priv->adjustment->step_increment = step; + priv->adjustment->page_increment = page; + + gtk_adjustment_changed (priv->adjustment); } /** @@ -1221,22 +1303,25 @@ gtk_range_set_range (GtkRange *range, gdouble min, gdouble max) { + GtkRangePrivate *priv; gdouble value; g_return_if_fail (GTK_IS_RANGE (range)); g_return_if_fail (min < max); - - range->adjustment->lower = min; - range->adjustment->upper = max; - value = range->adjustment->value; + priv = range->priv; - if (range->layout->restrict_to_fill_level) - value = MIN (value, MAX (range->adjustment->lower, - range->layout->fill_level)); + priv->adjustment->lower = min; + priv->adjustment->upper = max; - gtk_adjustment_set_value (range->adjustment, value); - gtk_adjustment_changed (range->adjustment); + value = priv->adjustment->value; + + if (priv->restrict_to_fill_level) + value = MIN (value, MAX (priv->adjustment->lower, + priv->fill_level)); + + gtk_adjustment_set_value (priv->adjustment, value); + gtk_adjustment_changed (priv->adjustment); } /** @@ -1253,13 +1338,17 @@ void gtk_range_set_value (GtkRange *range, gdouble value) { + GtkRangePrivate *priv; + g_return_if_fail (GTK_IS_RANGE (range)); - if (range->layout->restrict_to_fill_level) - value = MIN (value, MAX (range->adjustment->lower, - range->layout->fill_level)); + priv = range->priv; + + if (priv->restrict_to_fill_level) + value = MIN (value, MAX (priv->adjustment->lower, + priv->fill_level)); - gtk_adjustment_set_value (range->adjustment, value); + gtk_adjustment_set_value (priv->adjustment, value); } /** @@ -1275,7 +1364,7 @@ gtk_range_get_value (GtkRange *range) { g_return_val_if_fail (GTK_IS_RANGE (range), 0.0); - return range->adjustment->value; + return range->priv->adjustment->value; } /** @@ -1293,13 +1382,17 @@ void gtk_range_set_show_fill_level (GtkRange *range, gboolean show_fill_level) { + GtkRangePrivate *priv; + g_return_if_fail (GTK_IS_RANGE (range)); + priv = range->priv; + show_fill_level = show_fill_level ? TRUE : FALSE; - if (show_fill_level != range->layout->show_fill_level) + if (show_fill_level != priv->show_fill_level) { - range->layout->show_fill_level = show_fill_level; + priv->show_fill_level = show_fill_level; g_object_notify (G_OBJECT (range), "show-fill-level"); gtk_widget_queue_draw (GTK_WIDGET (range)); } @@ -1320,7 +1413,7 @@ gtk_range_get_show_fill_level (GtkRange *range) { g_return_val_if_fail (GTK_IS_RANGE (range), FALSE); - return range->layout->show_fill_level; + return range->priv->show_fill_level; } /** @@ -1338,13 +1431,17 @@ void gtk_range_set_restrict_to_fill_level (GtkRange *range, gboolean restrict_to_fill_level) { + GtkRangePrivate *priv; + g_return_if_fail (GTK_IS_RANGE (range)); + priv = range->priv; + restrict_to_fill_level = restrict_to_fill_level ? TRUE : FALSE; - if (restrict_to_fill_level != range->layout->restrict_to_fill_level) + if (restrict_to_fill_level != priv->restrict_to_fill_level) { - range->layout->restrict_to_fill_level = restrict_to_fill_level; + priv->restrict_to_fill_level = restrict_to_fill_level; g_object_notify (G_OBJECT (range), "restrict-to-fill-level"); gtk_range_set_value (range, gtk_range_get_value (range)); @@ -1366,7 +1463,7 @@ gtk_range_get_restrict_to_fill_level (GtkRange *range) { g_return_val_if_fail (GTK_IS_RANGE (range), FALSE); - return range->layout->restrict_to_fill_level; + return range->priv->restrict_to_fill_level; } /** @@ -1398,17 +1495,21 @@ void gtk_range_set_fill_level (GtkRange *range, gdouble fill_level) { + GtkRangePrivate *priv; + g_return_if_fail (GTK_IS_RANGE (range)); - if (fill_level != range->layout->fill_level) + priv = range->priv; + + if (fill_level != priv->fill_level) { - range->layout->fill_level = fill_level; + priv->fill_level = fill_level; g_object_notify (G_OBJECT (range), "fill-level"); - if (range->layout->show_fill_level) + if (priv->show_fill_level) gtk_widget_queue_draw (GTK_WIDGET (range)); - if (range->layout->restrict_to_fill_level) + if (priv->restrict_to_fill_level) gtk_range_set_value (range, gtk_range_get_value (range)); } } @@ -1428,52 +1529,55 @@ gtk_range_get_fill_level (GtkRange *range) { g_return_val_if_fail (GTK_IS_RANGE (range), 0.0); - return range->layout->fill_level; + return range->priv->fill_level; } static gboolean should_invert (GtkRange *range) -{ - if (range->orientation == GTK_ORIENTATION_HORIZONTAL) +{ + GtkRangePrivate *priv = range->priv; + + if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) return - (range->inverted && !range->flippable) || - (range->inverted && range->flippable && gtk_widget_get_direction (GTK_WIDGET (range)) == GTK_TEXT_DIR_LTR) || - (!range->inverted && range->flippable && gtk_widget_get_direction (GTK_WIDGET (range)) == GTK_TEXT_DIR_RTL); + (priv->inverted && !priv->flippable) || + (priv->inverted && priv->flippable && gtk_widget_get_direction (GTK_WIDGET (range)) == GTK_TEXT_DIR_LTR) || + (!priv->inverted && priv->flippable && gtk_widget_get_direction (GTK_WIDGET (range)) == GTK_TEXT_DIR_RTL); else - return range->inverted; + return priv->inverted; } static void gtk_range_destroy (GtkObject *object) { GtkRange *range = GTK_RANGE (object); + GtkRangePrivate *priv = range->priv; gtk_range_remove_step_timer (range); gtk_range_remove_update_timer (range); - if (range->layout->repaint_id) - g_source_remove (range->layout->repaint_id); - range->layout->repaint_id = 0; + if (priv->repaint_id) + g_source_remove (priv->repaint_id); + priv->repaint_id = 0; - if (range->adjustment) + if (priv->adjustment) { - g_signal_handlers_disconnect_by_func (range->adjustment, + g_signal_handlers_disconnect_by_func (priv->adjustment, gtk_range_adjustment_changed, range); - g_signal_handlers_disconnect_by_func (range->adjustment, + g_signal_handlers_disconnect_by_func (priv->adjustment, gtk_range_adjustment_value_changed, range); - g_object_unref (range->adjustment); - range->adjustment = NULL; + g_object_unref (priv->adjustment); + priv->adjustment = NULL; } - if (range->layout->n_marks) + if (priv->n_marks) { - g_free (range->layout->marks); - range->layout->marks = NULL; - g_free (range->layout->mark_pos); - range->layout->mark_pos = NULL; - range->layout->n_marks = 0; + g_free (priv->marks); + priv->marks = NULL; + g_free (priv->mark_pos); + priv->mark_pos = NULL; + priv->n_marks = 0; } GTK_OBJECT_CLASS (gtk_range_parent_class)->destroy (object); @@ -1509,46 +1613,47 @@ static void gtk_range_size_allocate (GtkWidget *widget, GtkAllocation *allocation) { - GtkRange *range; + GtkRange *range = GTK_RANGE (widget); + GtkRangePrivate *priv = range->priv; - range = GTK_RANGE (widget); + gtk_widget_set_allocation (widget, allocation); - widget->allocation = *allocation; - - range->layout->recalc_marks = TRUE; + priv->recalc_marks = TRUE; - range->need_recalc = TRUE; - gtk_range_calc_layout (range, range->adjustment->value); + priv->need_recalc = TRUE; + gtk_range_calc_layout (range, priv->adjustment->value); if (gtk_widget_get_realized (widget)) - gdk_window_move_resize (range->event_window, - widget->allocation.x, - widget->allocation.y, - widget->allocation.width, - widget->allocation.height); + gdk_window_move_resize (priv->event_window, + allocation->x, allocation->y, + allocation->width, allocation->height); } static void gtk_range_realize (GtkWidget *widget) { - GtkRange *range; + GtkAllocation allocation; + GtkRange *range = GTK_RANGE (widget); + GtkRangePrivate *priv = range->priv; + GdkWindow *window; GdkWindowAttr attributes; gint attributes_mask; - range = GTK_RANGE (widget); - - gtk_range_calc_layout (range, range->adjustment->value); + gtk_range_calc_layout (range, priv->adjustment->value); gtk_widget_set_realized (widget, TRUE); - widget->window = gtk_widget_get_parent_window (widget); - g_object_ref (widget->window); - + window = gtk_widget_get_parent_window (widget); + gtk_widget_set_window (widget, window); + g_object_ref (window); + + gtk_widget_get_allocation (widget, &allocation); + attributes.window_type = GDK_WINDOW_CHILD; - attributes.x = widget->allocation.x; - attributes.y = widget->allocation.y; - attributes.width = widget->allocation.width; - attributes.height = widget->allocation.height; + attributes.x = allocation.x; + attributes.y = allocation.y; + attributes.width = allocation.width; + attributes.height = allocation.height; attributes.wclass = GDK_INPUT_ONLY; attributes.event_mask = gtk_widget_get_events (widget); attributes.event_mask |= (GDK_BUTTON_PRESS_MASK | @@ -1560,24 +1665,25 @@ gtk_range_realize (GtkWidget *widget) attributes_mask = GDK_WA_X | GDK_WA_Y; - range->event_window = gdk_window_new (gtk_widget_get_parent_window (widget), + priv->event_window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); - gdk_window_set_user_data (range->event_window, range); + gdk_window_set_user_data (priv->event_window, range); - widget->style = gtk_style_attach (widget->style, widget->window); + gtk_widget_style_attach (widget); } static void gtk_range_unrealize (GtkWidget *widget) { GtkRange *range = GTK_RANGE (widget); + GtkRangePrivate *priv = range->priv; gtk_range_remove_step_timer (range); gtk_range_remove_update_timer (range); - - gdk_window_set_user_data (range->event_window, NULL); - gdk_window_destroy (range->event_window); - range->event_window = NULL; + + gdk_window_set_user_data (priv->event_window, NULL); + gdk_window_destroy (priv->event_window); + priv->event_window = NULL; GTK_WIDGET_CLASS (gtk_range_parent_class)->unrealize (widget); } @@ -1586,8 +1692,9 @@ static void gtk_range_map (GtkWidget *widget) { GtkRange *range = GTK_RANGE (widget); - - gdk_window_show (range->event_window); + GtkRangePrivate *priv = range->priv; + + gdk_window_show (priv->event_window); GTK_WIDGET_CLASS (gtk_range_parent_class)->map (widget); } @@ -1596,10 +1703,11 @@ static void gtk_range_unmap (GtkWidget *widget) { GtkRange *range = GTK_RANGE (widget); - + GtkRangePrivate *priv = range->priv; + stop_scrolling (range); - gdk_window_hide (range->event_window); + gdk_window_hide (priv->event_window); GTK_WIDGET_CLASS (gtk_range_parent_class)->unmap (widget); } @@ -1607,10 +1715,11 @@ gtk_range_unmap (GtkWidget *widget) static const gchar * gtk_range_get_slider_detail (GtkRange *range) { + GtkRangePrivate *priv = range->priv; const gchar *slider_detail; - if (range->layout->slider_detail_quark) - return g_quark_to_string (range->layout->slider_detail_quark); + if (priv->slider_detail_quark) + return g_quark_to_string (priv->slider_detail_quark); slider_detail = GTK_RANGE_GET_CLASS (range)->slider_detail; @@ -1618,13 +1727,13 @@ gtk_range_get_slider_detail (GtkRange *range) { gchar *detail = g_strdup (slider_detail); - detail[0] = range->orientation == GTK_ORIENTATION_HORIZONTAL ? 'h' : 'v'; + detail[0] = priv->orientation == GTK_ORIENTATION_HORIZONTAL ? 'h' : 'v'; - range->layout->slider_detail_quark = g_quark_from_string (detail); + priv->slider_detail_quark = g_quark_from_string (detail); g_free (detail); - return g_quark_to_string (range->layout->slider_detail_quark); + return g_quark_to_string (priv->slider_detail_quark); } return slider_detail; @@ -1634,12 +1743,13 @@ static const gchar * gtk_range_get_stepper_detail (GtkRange *range, Stepper stepper) { + GtkRangePrivate *priv = range->priv; const gchar *stepper_detail; gboolean need_orientation; gboolean need_position; - if (range->layout->stepper_detail_quark[stepper]) - return g_quark_to_string (range->layout->stepper_detail_quark[stepper]); + if (priv->stepper_detail_quark[stepper]) + return g_quark_to_string (priv->stepper_detail_quark[stepper]); stepper_detail = GTK_RANGE_GET_CLASS (range)->stepper_detail; @@ -1662,13 +1772,13 @@ gtk_range_get_stepper_detail (GtkRange *range, position = "_start"; break; case STEPPER_B: - if (range->has_stepper_a) + if (priv->has_stepper_a) position = "_start_inner"; else position = "_start"; break; case STEPPER_C: - if (range->has_stepper_d) + if (priv->has_stepper_d) position = "_end_inner"; else position = "_end"; @@ -1684,13 +1794,13 @@ gtk_range_get_stepper_detail (GtkRange *range, detail = g_strconcat (stepper_detail, position, NULL); if (need_orientation) - detail[0] = range->orientation == GTK_ORIENTATION_HORIZONTAL ? 'h' : 'v'; + detail[0] = priv->orientation == GTK_ORIENTATION_HORIZONTAL ? 'h' : 'v'; - range->layout->stepper_detail_quark[stepper] = g_quark_from_string (detail); + priv->stepper_detail_quark[stepper] = g_quark_from_string (detail); g_free (detail); - return g_quark_to_string (range->layout->stepper_detail_quark[stepper]); + return g_quark_to_string (priv->stepper_detail_quark[stepper]); } return stepper_detail; @@ -1704,10 +1814,14 @@ draw_stepper (GtkRange *range, gboolean prelighted, GdkRectangle *area) { + GtkRangePrivate *priv = range->priv; + GtkAllocation allocation; GtkStateType state_type; GtkShadowType shadow_type; - GdkRectangle intersection; + GtkStyle *style; GtkWidget *widget = GTK_WIDGET (range); + GdkRectangle intersection; + GdkWindow *window; gfloat arrow_scaling; GdkRectangle *rect; gint arrow_x; @@ -1718,16 +1832,16 @@ draw_stepper (GtkRange *range, switch (stepper) { case STEPPER_A: - rect = &range->layout->stepper_a; + rect = &priv->stepper_a; break; case STEPPER_B: - rect = &range->layout->stepper_b; + rect = &priv->stepper_b; break; case STEPPER_C: - rect = &range->layout->stepper_c; + rect = &priv->stepper_c; break; case STEPPER_D: - rect = &range->layout->stepper_d; + rect = &priv->stepper_d; break; default: g_assert_not_reached (); @@ -1739,19 +1853,21 @@ draw_stepper (GtkRange *range, if (!gdk_rectangle_intersect (area, rect, &intersection)) return; - intersection.x += widget->allocation.x; - intersection.y += widget->allocation.y; + gtk_widget_get_allocation (widget, &allocation); - if ((!range->inverted && (arrow_type == GTK_ARROW_DOWN || + intersection.x += allocation.x; + intersection.y += allocation.y; + + if ((!priv->inverted && (arrow_type == GTK_ARROW_DOWN || arrow_type == GTK_ARROW_RIGHT)) || - (range->inverted && (arrow_type == GTK_ARROW_UP || + (priv->inverted && (arrow_type == GTK_ARROW_UP || arrow_type == GTK_ARROW_LEFT))) { - arrow_sensitive = range->layout->upper_sensitive; + arrow_sensitive = priv->upper_sensitive; } else { - arrow_sensitive = range->layout->lower_sensitive; + arrow_sensitive = priv->lower_sensitive; } if (!gtk_widget_is_sensitive (GTK_WIDGET (range)) || !arrow_sensitive) @@ -1768,13 +1884,15 @@ draw_stepper (GtkRange *range, else shadow_type = GTK_SHADOW_OUT; - gtk_paint_box (widget->style, - widget->window, + style = gtk_widget_get_style (widget); + window = gtk_widget_get_window (widget); + + gtk_paint_box (style, window, state_type, shadow_type, &intersection, widget, gtk_range_get_stepper_detail (range, stepper), - widget->allocation.x + rect->x, - widget->allocation.y + rect->y, + allocation.x + rect->x, + allocation.y + rect->y, rect->width, rect->height); @@ -1782,8 +1900,8 @@ draw_stepper (GtkRange *range, arrow_width = rect->width * arrow_scaling; arrow_height = rect->height * arrow_scaling; - arrow_x = widget->allocation.x + rect->x + (rect->width - arrow_width) / 2; - arrow_y = widget->allocation.y + rect->y + (rect->height - arrow_height) / 2; + arrow_x = allocation.x + rect->x + (rect->width - arrow_width) / 2; + arrow_y = allocation.y + rect->y + (rect->height - arrow_height) / 2; if (clicked && arrow_sensitive) { @@ -1797,9 +1915,8 @@ draw_stepper (GtkRange *range, arrow_x += arrow_displacement_x; arrow_y += arrow_displacement_y; } - - gtk_paint_arrow (widget->style, - widget->window, + + gtk_paint_arrow (style, window, state_type, shadow_type, &intersection, widget, gtk_range_get_stepper_detail (range, stepper), @@ -1812,12 +1929,16 @@ static gboolean gtk_range_expose (GtkWidget *widget, GdkEventExpose *event) { + GtkAllocation allocation; GtkRange *range = GTK_RANGE (widget); + GtkRangePrivate *priv = range->priv; gboolean sensitive; GtkStateType state; GtkShadowType shadow_type; + GtkStyle *style; GdkRectangle expose_area; /* Relative to widget->allocation */ GdkRectangle area; + GdkWindow *window; gint focus_line_width = 0; gint focus_padding = 0; gboolean touchscreen; @@ -1825,23 +1946,29 @@ gtk_range_expose (GtkWidget *widget, g_object_get (gtk_widget_get_settings (widget), "gtk-touchscreen-mode", &touchscreen, NULL); + + style = gtk_widget_get_style (widget); if (gtk_widget_get_can_focus (GTK_WIDGET (range))) gtk_widget_style_get (GTK_WIDGET (range), "focus-line-width", &focus_line_width, "focus-padding", &focus_padding, NULL); + window = gtk_widget_get_window (widget); + /* we're now exposing, so there's no need to force early repaints */ - if (range->layout->repaint_id) - g_source_remove (range->layout->repaint_id); - range->layout->repaint_id = 0; + if (priv->repaint_id) + g_source_remove (priv->repaint_id); + priv->repaint_id = 0; + + gtk_widget_get_allocation (widget, &allocation); expose_area = event->area; - expose_area.x -= widget->allocation.x; - expose_area.y -= widget->allocation.y; - + expose_area.x -= allocation.x; + expose_area.y -= allocation.y; + gtk_range_calc_marks (range); - gtk_range_calc_layout (range, range->adjustment->value); + gtk_range_calc_layout (range, priv->adjustment->value); sensitive = gtk_widget_is_sensitive (widget); @@ -1852,24 +1979,24 @@ gtk_range_expose (GtkWidget *widget, /* The gdk_rectangle_intersect is more to get the right * clip region (limited to range_rect) than for efficiency */ - if (gdk_rectangle_intersect (&expose_area, &range->range_rect, + if (gdk_rectangle_intersect (&expose_area, &priv->range_rect, &area)) { - gint x = (widget->allocation.x + range->range_rect.x + + gint x = (allocation.x + priv->range_rect.x + focus_line_width + focus_padding); - gint y = (widget->allocation.y + range->range_rect.y + + gint y = (allocation.y + priv->range_rect.y + focus_line_width + focus_padding); - gint width = (range->range_rect.width - + gint width = (priv->range_rect.width - 2 * (focus_line_width + focus_padding)); - gint height = (range->range_rect.height - + gint height = (priv->range_rect.height - 2 * (focus_line_width + focus_padding)); gboolean trough_side_details; gboolean trough_under_steppers; gint stepper_size; gint stepper_spacing; - area.x += widget->allocation.x; - area.y += widget->allocation.y; + area.x += allocation.x; + area.y += allocation.y; gtk_widget_style_get (GTK_WIDGET (range), "trough-side-details", &trough_side_details, @@ -1886,32 +2013,32 @@ gtk_range_expose (GtkWidget *widget, gint offset = 0; gint shorter = 0; - if (range->has_stepper_a) + if (priv->has_stepper_a) offset += stepper_size; - if (range->has_stepper_b) + if (priv->has_stepper_b) offset += stepper_size; shorter += offset; - if (range->has_stepper_c) + if (priv->has_stepper_c) shorter += stepper_size; - if (range->has_stepper_d) + if (priv->has_stepper_d) shorter += stepper_size; - if (range->has_stepper_a || range->has_stepper_b) + if (priv->has_stepper_a || priv->has_stepper_b) { offset += stepper_spacing; shorter += stepper_spacing; } - if (range->has_stepper_c || range->has_stepper_d) + if (priv->has_stepper_c || priv->has_stepper_d) { shorter += stepper_spacing; } - if (range->orientation == GTK_ORIENTATION_HORIZONTAL) + if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) { x += offset; width -= shorter; @@ -1925,8 +2052,7 @@ gtk_range_expose (GtkWidget *widget, if (! trough_side_details) { - gtk_paint_box (widget->style, - widget->window, + gtk_paint_box (style, window, sensitive ? GTK_STATE_ACTIVE : GTK_STATE_INSENSITIVE, GTK_SHADOW_IN, &area, GTK_WIDGET(range), "trough", @@ -1938,17 +2064,16 @@ gtk_range_expose (GtkWidget *widget, gint trough_change_pos_x = width; gint trough_change_pos_y = height; - if (range->orientation == GTK_ORIENTATION_HORIZONTAL) - trough_change_pos_x = (range->layout->slider.x + - range->layout->slider.width / 2 - - (x - widget->allocation.x)); + if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) + trough_change_pos_x = (priv->slider.x + + priv->slider.width / 2 - + (x - allocation.x)); else - trough_change_pos_y = (range->layout->slider.y + - range->layout->slider.height / 2 - - (y - widget->allocation.y)); + trough_change_pos_y = (priv->slider.y + + priv->slider.height / 2 - + (y - allocation.y)); - gtk_paint_box (widget->style, - widget->window, + gtk_paint_box (style, window, sensitive ? GTK_STATE_ACTIVE : GTK_STATE_INSENSITIVE, GTK_SHADOW_IN, &area, GTK_WIDGET (range), @@ -1956,13 +2081,12 @@ gtk_range_expose (GtkWidget *widget, x, y, trough_change_pos_x, trough_change_pos_y); - if (range->orientation == GTK_ORIENTATION_HORIZONTAL) + if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) trough_change_pos_y = 0; else trough_change_pos_x = 0; - gtk_paint_box (widget->style, - widget->window, + gtk_paint_box (style, window, sensitive ? GTK_STATE_ACTIVE : GTK_STATE_INSENSITIVE, GTK_SHADOW_IN, &area, GTK_WIDGET (range), @@ -1972,57 +2096,56 @@ gtk_range_expose (GtkWidget *widget, height - trough_change_pos_y); } - if (range->layout->show_fill_level && - range->adjustment->upper - range->adjustment->page_size - - range->adjustment->lower != 0) + if (priv->show_fill_level && + priv->adjustment->upper - priv->adjustment->page_size - + priv->adjustment->lower != 0) { - gdouble fill_level = range->layout->fill_level; + gdouble fill_level = priv->fill_level; gint fill_x = x; gint fill_y = y; gint fill_width = width; gint fill_height = height; gchar *fill_detail; - fill_level = CLAMP (fill_level, range->adjustment->lower, - range->adjustment->upper - - range->adjustment->page_size); + fill_level = CLAMP (fill_level, priv->adjustment->lower, + priv->adjustment->upper - + priv->adjustment->page_size); - if (range->orientation == GTK_ORIENTATION_HORIZONTAL) + if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) { - fill_x = widget->allocation.x + range->layout->trough.x; - fill_width = (range->layout->slider.width + - (fill_level - range->adjustment->lower) / - (range->adjustment->upper - - range->adjustment->lower - - range->adjustment->page_size) * - (range->layout->trough.width - - range->layout->slider.width)); + fill_x = allocation.x + priv->trough.x; + fill_width = (priv->slider.width + + (fill_level - priv->adjustment->lower) / + (priv->adjustment->upper - + priv->adjustment->lower - + priv->adjustment->page_size) * + (priv->trough.width - + priv->slider.width)); if (should_invert (range)) - fill_x += range->layout->trough.width - fill_width; + fill_x += priv->trough.width - fill_width; } else { - fill_y = widget->allocation.y + range->layout->trough.y; - fill_height = (range->layout->slider.height + - (fill_level - range->adjustment->lower) / - (range->adjustment->upper - - range->adjustment->lower - - range->adjustment->page_size) * - (range->layout->trough.height - - range->layout->slider.height)); + fill_y = allocation.y + priv->trough.y; + fill_height = (priv->slider.height + + (fill_level - priv->adjustment->lower) / + (priv->adjustment->upper - + priv->adjustment->lower - + priv->adjustment->page_size) * + (priv->trough.height - + priv->slider.height)); if (should_invert (range)) - fill_y += range->layout->trough.height - fill_height; + fill_y += priv->trough.height - fill_height; } - if (fill_level < range->adjustment->upper - range->adjustment->page_size) + if (fill_level < priv->adjustment->upper - priv->adjustment->page_size) fill_detail = "trough-fill-level-full"; else fill_detail = "trough-fill-level"; - gtk_paint_box (widget->style, - widget->window, + gtk_paint_box (style, window, sensitive ? GTK_STATE_ACTIVE : GTK_STATE_INSENSITIVE, GTK_SHADOW_OUT, &area, GTK_WIDGET (range), fill_detail, @@ -2031,24 +2154,25 @@ gtk_range_expose (GtkWidget *widget, } if (sensitive && gtk_widget_has_focus (widget)) - gtk_paint_focus (widget->style, widget->window, gtk_widget_get_state (widget), + gtk_paint_focus (style, window, + gtk_widget_get_state (widget), &area, widget, "trough", - widget->allocation.x + range->range_rect.x, - widget->allocation.y + range->range_rect.y, - range->range_rect.width, - range->range_rect.height); + allocation.x + priv->range_rect.x, + allocation.y + priv->range_rect.y, + priv->range_rect.width, + priv->range_rect.height); } shadow_type = GTK_SHADOW_OUT; if (!sensitive) state = GTK_STATE_INSENSITIVE; - else if (!touchscreen && range->layout->mouse_location == MOUSE_SLIDER) + else if (!touchscreen && priv->mouse_location == MOUSE_SLIDER) state = GTK_STATE_PRELIGHT; else state = GTK_STATE_NORMAL; - if (range->layout->grab_location == MOUSE_SLIDER) + if (priv->grab_location == MOUSE_SLIDER) { gboolean activate_slider; @@ -2062,52 +2186,52 @@ gtk_range_expose (GtkWidget *widget, } if (gdk_rectangle_intersect (&expose_area, - &range->layout->slider, + &priv->slider, &area)) { - area.x += widget->allocation.x; - area.y += widget->allocation.y; - - gtk_paint_slider (widget->style, - widget->window, + area.x += allocation.x; + area.y += allocation.y; + + gtk_paint_slider (style, + window, state, shadow_type, &area, widget, gtk_range_get_slider_detail (range), - widget->allocation.x + range->layout->slider.x, - widget->allocation.y + range->layout->slider.y, - range->layout->slider.width, - range->layout->slider.height, - range->orientation); + allocation.x + priv->slider.x, + allocation.y + priv->slider.y, + priv->slider.width, + priv->slider.height, + priv->orientation); } - - if (range->has_stepper_a) + + if (priv->has_stepper_a) draw_stepper (range, STEPPER_A, - range->orientation == GTK_ORIENTATION_VERTICAL ? GTK_ARROW_UP : GTK_ARROW_LEFT, - range->layout->grab_location == MOUSE_STEPPER_A, - !touchscreen && range->layout->mouse_location == MOUSE_STEPPER_A, + priv->orientation == GTK_ORIENTATION_VERTICAL ? GTK_ARROW_UP : GTK_ARROW_LEFT, + priv->grab_location == MOUSE_STEPPER_A, + !touchscreen && priv->mouse_location == MOUSE_STEPPER_A, &expose_area); - if (range->has_stepper_b) + if (priv->has_stepper_b) draw_stepper (range, STEPPER_B, - range->orientation == GTK_ORIENTATION_VERTICAL ? GTK_ARROW_DOWN : GTK_ARROW_RIGHT, - range->layout->grab_location == MOUSE_STEPPER_B, - !touchscreen && range->layout->mouse_location == MOUSE_STEPPER_B, + priv->orientation == GTK_ORIENTATION_VERTICAL ? GTK_ARROW_DOWN : GTK_ARROW_RIGHT, + priv->grab_location == MOUSE_STEPPER_B, + !touchscreen && priv->mouse_location == MOUSE_STEPPER_B, &expose_area); - if (range->has_stepper_c) + if (priv->has_stepper_c) draw_stepper (range, STEPPER_C, - range->orientation == GTK_ORIENTATION_VERTICAL ? GTK_ARROW_UP : GTK_ARROW_LEFT, - range->layout->grab_location == MOUSE_STEPPER_C, - !touchscreen && range->layout->mouse_location == MOUSE_STEPPER_C, + priv->orientation == GTK_ORIENTATION_VERTICAL ? GTK_ARROW_UP : GTK_ARROW_LEFT, + priv->grab_location == MOUSE_STEPPER_C, + !touchscreen && priv->mouse_location == MOUSE_STEPPER_C, &expose_area); - if (range->has_stepper_d) + if (priv->has_stepper_d) draw_stepper (range, STEPPER_D, - range->orientation == GTK_ORIENTATION_VERTICAL ? GTK_ARROW_DOWN : GTK_ARROW_RIGHT, - range->layout->grab_location == MOUSE_STEPPER_D, - !touchscreen && range->layout->mouse_location == MOUSE_STEPPER_D, + priv->orientation == GTK_ORIENTATION_VERTICAL ? GTK_ARROW_DOWN : GTK_ARROW_RIGHT, + priv->grab_location == MOUSE_STEPPER_D, + !touchscreen && priv->mouse_location == MOUSE_STEPPER_D, &expose_area); return FALSE; @@ -2119,23 +2243,23 @@ range_grab_add (GtkRange *range, MouseLocation location, gint button) { - GtkRangeLayout *layout = range->layout; + GtkRangePrivate *priv = range->priv; - if (device == layout->grab_device) + if (device == priv->grab_device) return; - if (layout->grab_device != NULL) + if (priv->grab_device != NULL) { g_warning ("GtkRange already had a grab device, releasing device grab"); - gtk_device_grab_remove (GTK_WIDGET (range), layout->grab_device); + gtk_device_grab_remove (GTK_WIDGET (range), priv->grab_device); } /* we don't actually gdk_grab, since a button is down */ gtk_device_grab_add (GTK_WIDGET (range), device, TRUE); - range->layout->grab_location = location; - range->layout->grab_button = button; - range->layout->grab_device = device; + priv->grab_location = location; + priv->grab_button = button; + priv->grab_device = device; if (gtk_range_update_mouse_location (range)) gtk_widget_queue_draw (GTK_WIDGET (range)); @@ -2144,19 +2268,19 @@ range_grab_add (GtkRange *range, static void range_grab_remove (GtkRange *range) { - GtkRangeLayout *layout = range->layout; + GtkRangePrivate *priv = range->priv; MouseLocation location; - if (layout->grab_device) + if (priv->grab_device) { gtk_device_grab_remove (GTK_WIDGET (range), - layout->grab_device); - layout->grab_device = NULL; + priv->grab_device); + priv->grab_device = NULL; } - location = range->layout->grab_location; - range->layout->grab_location = MOUSE_OUTSIDE; - range->layout->grab_button = 0; + location = priv->grab_location; + priv->grab_location = MOUSE_OUTSIDE; + priv->grab_button = 0; if (gtk_range_update_mouse_location (range) || location != MOUSE_OUTSIDE) @@ -2165,16 +2289,17 @@ range_grab_remove (GtkRange *range) static GtkScrollType range_get_scroll_for_grab (GtkRange *range) -{ +{ + GtkRangePrivate *priv = range->priv; gboolean invert; invert = should_invert (range); - switch (range->layout->grab_location) + switch (priv->grab_location) { /* Backward stepper */ case MOUSE_STEPPER_A: case MOUSE_STEPPER_C: - switch (range->layout->grab_button) + switch (priv->grab_button) { case 1: return invert ? GTK_SCROLL_STEP_FORWARD : GTK_SCROLL_STEP_BACKWARD; @@ -2191,7 +2316,7 @@ range_get_scroll_for_grab (GtkRange *range) /* Forward stepper */ case MOUSE_STEPPER_B: case MOUSE_STEPPER_D: - switch (range->layout->grab_button) + switch (priv->grab_button) { case 1: return invert ? GTK_SCROLL_STEP_BACKWARD : GTK_SCROLL_STEP_FORWARD; @@ -2208,7 +2333,7 @@ range_get_scroll_for_grab (GtkRange *range) /* In the trough */ case MOUSE_TROUGH: { - if (range->trough_click_forward) + if (priv->trough_click_forward) return GTK_SCROLL_PAGE_FORWARD; else return GTK_SCROLL_PAGE_BACKWARD; @@ -2228,6 +2353,7 @@ static gdouble coord_to_value (GtkRange *range, gint coord) { + GtkRangePrivate *priv = range->priv; gdouble frac; gdouble value; gint trough_length; @@ -2236,17 +2362,17 @@ coord_to_value (GtkRange *range, gint trough_border; gint trough_under_steppers; - if (range->orientation == GTK_ORIENTATION_VERTICAL) + if (priv->orientation == GTK_ORIENTATION_VERTICAL) { - trough_length = range->layout->trough.height; - trough_start = range->layout->trough.y; - slider_length = range->layout->slider.height; + trough_length = priv->trough.height; + trough_start = priv->trough.y; + slider_length = priv->slider.height; } else { - trough_length = range->layout->trough.width; - trough_start = range->layout->trough.x; - slider_length = range->layout->slider.width; + trough_length = priv->trough.width; + trough_start = priv->trough.x; + slider_length = priv->slider.width; } gtk_range_get_props (range, NULL, NULL, NULL, &trough_border, NULL, @@ -2267,9 +2393,9 @@ coord_to_value (GtkRange *range, if (should_invert (range)) frac = 1.0 - frac; - value = range->adjustment->lower + frac * (range->adjustment->upper - - range->adjustment->lower - - range->adjustment->page_size); + value = priv->adjustment->lower + frac * (priv->adjustment->upper - + priv->adjustment->lower - + priv->adjustment->page_size); return value; } @@ -2280,20 +2406,20 @@ gtk_range_key_press (GtkWidget *widget, { GdkDevice *device; GtkRange *range = GTK_RANGE (widget); - GtkRangeLayout *layout = range->layout; + GtkRangePrivate *priv = range->priv; device = gdk_event_get_device ((GdkEvent *) event); device = gdk_device_get_associated_device (device); - if (device == layout->grab_device && + if (device == priv->grab_device && event->keyval == GDK_Escape && - range->layout->grab_location != MOUSE_OUTSIDE) + priv->grab_location != MOUSE_OUTSIDE) { stop_scrolling (range); update_slider_position (range, - range->slide_initial_coordinate, - range->slide_initial_coordinate); + priv->slide_initial_coordinate, + priv->slide_initial_coordinate); return TRUE; } @@ -2306,23 +2432,24 @@ gtk_range_button_press (GtkWidget *widget, GdkEventButton *event) { GtkRange *range = GTK_RANGE (widget); + GtkRangePrivate *priv = range->priv; GdkDevice *device; - + if (!gtk_widget_has_focus (widget)) gtk_widget_grab_focus (widget); /* ignore presses when we're already doing something else. */ - if (range->layout->grab_location != MOUSE_OUTSIDE) + if (priv->grab_location != MOUSE_OUTSIDE) return FALSE; device = gdk_event_get_device ((GdkEvent *) event); - range->layout->mouse_x = event->x; - range->layout->mouse_y = event->y; + priv->mouse_x = event->x; + priv->mouse_y = event->y; if (gtk_range_update_mouse_location (range)) gtk_widget_queue_draw (widget); - - if (range->layout->mouse_location == MOUSE_TROUGH && + + if (priv->mouse_location == MOUSE_TROUGH && event->button == 1) { /* button 1 steps by page increment, as with button 2 on a stepper @@ -2331,10 +2458,10 @@ gtk_range_button_press (GtkWidget *widget, gdouble click_value; click_value = coord_to_value (range, - range->orientation == GTK_ORIENTATION_VERTICAL ? + priv->orientation == GTK_ORIENTATION_VERTICAL ? event->y : event->x); - - range->trough_click_forward = click_value > range->adjustment->value; + + priv->trough_click_forward = click_value > priv->adjustment->value; range_grab_add (range, device, MOUSE_TROUGH, event->button); scroll = range_get_scroll_for_grab (range); @@ -2343,21 +2470,24 @@ gtk_range_button_press (GtkWidget *widget, return TRUE; } - else if ((range->layout->mouse_location == MOUSE_STEPPER_A || - range->layout->mouse_location == MOUSE_STEPPER_B || - range->layout->mouse_location == MOUSE_STEPPER_C || - range->layout->mouse_location == MOUSE_STEPPER_D) && + else if ((priv->mouse_location == MOUSE_STEPPER_A || + priv->mouse_location == MOUSE_STEPPER_B || + priv->mouse_location == MOUSE_STEPPER_C || + priv->mouse_location == MOUSE_STEPPER_D) && (event->button == 1 || event->button == 2 || event->button == 3)) { + GtkAllocation allocation; GdkRectangle *stepper_area; GtkScrollType scroll; - - range_grab_add (range, device, range->layout->mouse_location, event->button); - stepper_area = get_area (range, range->layout->mouse_location); + range_grab_add (range, device, priv->mouse_location, event->button); + + gtk_widget_get_allocation (widget, &allocation); + stepper_area = get_area (range, priv->mouse_location); + gtk_widget_queue_draw_area (widget, - widget->allocation.x + stepper_area->x, - widget->allocation.y + stepper_area->y, + allocation.x + stepper_area->x, + allocation.y + stepper_area->y, stepper_area->width, stepper_area->height); @@ -2367,9 +2497,9 @@ gtk_range_button_press (GtkWidget *widget, return TRUE; } - else if ((range->layout->mouse_location == MOUSE_TROUGH && + else if ((priv->mouse_location == MOUSE_TROUGH && event->button == 2) || - range->layout->mouse_location == MOUSE_SLIDER) + priv->mouse_location == MOUSE_SLIDER) { gboolean need_value_update = FALSE; gboolean activate_slider; @@ -2385,21 +2515,21 @@ gtk_range_button_press (GtkWidget *widget, slider_high_value = coord_to_value (range, - range->orientation == GTK_ORIENTATION_VERTICAL ? + priv->orientation == GTK_ORIENTATION_VERTICAL ? event->y : event->x); slider_low_value = coord_to_value (range, - range->orientation == GTK_ORIENTATION_VERTICAL ? - event->y - range->layout->slider.height : - event->x - range->layout->slider.width); - + priv->orientation == GTK_ORIENTATION_VERTICAL ? + event->y - priv->slider.height : + event->x - priv->slider.width); + /* compute new value for warped slider */ new_value = slider_low_value + (slider_high_value - slider_low_value) / 2; /* recalc slider, so we can set slide_initial_slider_position * properly */ - range->need_recalc = TRUE; + priv->need_recalc = TRUE; gtk_range_calc_layout (range, new_value); /* defer adjustment updates to update_slider_position() in order @@ -2407,16 +2537,16 @@ gtk_range_button_press (GtkWidget *widget, */ need_value_update = TRUE; } - - if (range->orientation == GTK_ORIENTATION_VERTICAL) + + if (priv->orientation == GTK_ORIENTATION_VERTICAL) { - range->slide_initial_slider_position = range->layout->slider.y; - range->slide_initial_coordinate = event->y; + priv->slide_initial_slider_position = priv->slider.y; + priv->slide_initial_coordinate = event->y; } else { - range->slide_initial_slider_position = range->layout->slider.x; - range->slide_initial_coordinate = event->x; + priv->slide_initial_slider_position = priv->slider.x; + priv->slide_initial_coordinate = event->x; } range_grab_add (range, device, MOUSE_SLIDER, event->button); @@ -2444,6 +2574,7 @@ update_slider_position (GtkRange *range, gint mouse_x, gint mouse_y) { + GtkRangePrivate *priv = range->priv; gint delta; gint c; gdouble new_value; @@ -2453,24 +2584,24 @@ update_slider_position (GtkRange *range, gdouble mark_delta; gint i; - if (range->orientation == GTK_ORIENTATION_VERTICAL) - delta = mouse_y - range->slide_initial_coordinate; + if (priv->orientation == GTK_ORIENTATION_VERTICAL) + delta = mouse_y - priv->slide_initial_coordinate; else - delta = mouse_x - range->slide_initial_coordinate; + delta = mouse_x - priv->slide_initial_coordinate; - c = range->slide_initial_slider_position + delta; + c = priv->slide_initial_slider_position + delta; new_value = coord_to_value (range, c); next_value = coord_to_value (range, c + 1); mark_delta = fabs (next_value - new_value); - for (i = 0; i < range->layout->n_marks; i++) + for (i = 0; i < priv->n_marks; i++) { - mark_value = range->layout->marks[i]; + mark_value = priv->marks[i]; - if (fabs (range->adjustment->value - mark_value) < 3 * mark_delta) + if (fabs (priv->adjustment->value - mark_value) < 3 * mark_delta) { - if (fabs (new_value - mark_value) < (range->slider_end - range->slider_start) * 0.5 * mark_delta) + if (fabs (new_value - mark_value) < (priv->slider_end - priv->slider_start) * 0.5 * mark_delta) { new_value = mark_value; break; @@ -2496,16 +2627,17 @@ gtk_range_grab_broken (GtkWidget *widget, GdkEventGrabBroken *event) { GtkRange *range = GTK_RANGE (widget); + GtkRangePrivate *priv = range->priv; GdkDevice *device; device = gdk_event_get_device ((GdkEvent *) event); - if (device == range->layout->grab_device && - range->layout->grab_location != MOUSE_OUTSIDE) + if (device == priv->grab_device && + priv->grab_location != MOUSE_OUTSIDE) { - if (range->layout->grab_location == MOUSE_SLIDER) - update_slider_position (range, range->layout->mouse_x, range->layout->mouse_y); - + if (priv->grab_location == MOUSE_SLIDER) + update_slider_position (range, priv->mouse_x, priv->mouse_y); + stop_scrolling (range); return TRUE; @@ -2519,29 +2651,30 @@ gtk_range_button_release (GtkWidget *widget, GdkEventButton *event) { GtkRange *range = GTK_RANGE (widget); + GtkRangePrivate *priv = range->priv; GdkDevice *device; - if (event->window == range->event_window) + if (event->window == priv->event_window) { - range->layout->mouse_x = event->x; - range->layout->mouse_y = event->y; + priv->mouse_x = event->x; + priv->mouse_y = event->y; } else { - gdk_window_get_device_position (range->event_window, + gdk_window_get_device_position (priv->event_window, event->device, - &range->layout->mouse_x, - &range->layout->mouse_y, + &priv->mouse_x, + &priv->mouse_y, NULL); } device = gdk_event_get_device ((GdkEvent *) event); - if (range->layout->grab_device == device && - range->layout->grab_button == event->button) + if (priv->grab_device == device && + priv->grab_button == event->button) { - if (range->layout->grab_location == MOUSE_SLIDER) - update_slider_position (range, range->layout->mouse_x, range->layout->mouse_y); + if (priv->grab_location == MOUSE_SLIDER) + update_slider_position (range, priv->mouse_x, priv->mouse_y); stop_scrolling (range); @@ -2566,7 +2699,8 @@ gdouble _gtk_range_get_wheel_delta (GtkRange *range, GdkScrollDirection direction) { - GtkAdjustment *adj = range->adjustment; + GtkRangePrivate *priv = range->priv; + GtkAdjustment *adj = priv->adjustment; gdouble delta; if (GTK_IS_SCROLLBAR (range)) @@ -2578,7 +2712,7 @@ _gtk_range_get_wheel_delta (GtkRange *range, direction == GDK_SCROLL_LEFT) delta = - delta; - if (range->inverted) + if (priv->inverted) delta = - delta; return delta; @@ -2589,10 +2723,11 @@ gtk_range_scroll_event (GtkWidget *widget, GdkEventScroll *event) { GtkRange *range = GTK_RANGE (widget); + GtkRangePrivate *priv = range->priv; if (gtk_widget_get_realized (widget)) { - GtkAdjustment *adj = GTK_RANGE (range)->adjustment; + GtkAdjustment *adj = priv->adjustment; gdouble delta; gboolean handled; @@ -2606,7 +2741,7 @@ gtk_range_scroll_event (GtkWidget *widget, * but DISCONTINUOUS doesn't, so we update immediately * for DISCONTINUOUS */ - if (range->update_policy == GTK_UPDATE_DISCONTINUOUS) + if (priv->update_policy == GTK_UPDATE_DISCONTINUOUS) gtk_range_update_value (range); } @@ -2617,23 +2752,22 @@ static gboolean gtk_range_motion_notify (GtkWidget *widget, GdkEventMotion *event) { - GtkRange *range; - - range = GTK_RANGE (widget); + GtkRange *range = GTK_RANGE (widget); + GtkRangePrivate *priv = range->priv; gdk_event_request_motions (event); - - range->layout->mouse_x = event->x; - range->layout->mouse_y = event->y; + + priv->mouse_x = event->x; + priv->mouse_y = event->y; if (gtk_range_update_mouse_location (range)) gtk_widget_queue_draw (widget); - if (range->layout->grab_location == MOUSE_SLIDER) + if (priv->grab_location == MOUSE_SLIDER) update_slider_position (range, event->x, event->y); /* We handled the event if the mouse was in the range_rect */ - return range->layout->mouse_location != MOUSE_OUTSIDE; + return priv->mouse_location != MOUSE_OUTSIDE; } static gboolean @@ -2641,9 +2775,10 @@ gtk_range_enter_notify (GtkWidget *widget, GdkEventCrossing *event) { GtkRange *range = GTK_RANGE (widget); + GtkRangePrivate *priv = range->priv; - range->layout->mouse_x = event->x; - range->layout->mouse_y = event->y; + priv->mouse_x = event->x; + priv->mouse_y = event->y; if (gtk_range_update_mouse_location (range)) gtk_widget_queue_draw (widget); @@ -2656,9 +2791,10 @@ gtk_range_leave_notify (GtkWidget *widget, GdkEventCrossing *event) { GtkRange *range = GTK_RANGE (widget); + GtkRangePrivate *priv = range->priv; - range->layout->mouse_x = -1; - range->layout->mouse_y = -1; + priv->mouse_x = -1; + priv->mouse_y = -1; if (gtk_range_update_mouse_location (range)) gtk_widget_queue_draw (widget); @@ -2670,10 +2806,10 @@ static void gtk_range_grab_notify (GtkWidget *widget, gboolean was_grabbed) { - GtkRangeLayout *layout = GTK_RANGE (widget)->layout; + GtkRangePrivate *priv = GTK_RANGE (widget)->priv; - if (layout->grab_device && - gtk_widget_device_is_shadowed (widget, layout->grab_device)) + if (priv->grab_device && + gtk_widget_device_is_shadowed (widget, priv->grab_device)) stop_scrolling (GTK_RANGE (widget)); } @@ -2694,18 +2830,18 @@ gtk_range_state_changed (GtkWidget *widget, } static gboolean -layout_changed (GtkRangeLayout *layout1, - GtkRangeLayout *layout2) +layout_changed (GtkRangePrivate *priv1, + GtkRangePrivate *priv2) { - check_rectangle (layout1->slider, layout2->slider); - check_rectangle (layout1->trough, layout2->trough); - check_rectangle (layout1->stepper_a, layout2->stepper_a); - check_rectangle (layout1->stepper_d, layout2->stepper_d); - check_rectangle (layout1->stepper_b, layout2->stepper_b); - check_rectangle (layout1->stepper_c, layout2->stepper_c); + check_rectangle (priv1->slider, priv2->slider); + check_rectangle (priv1->trough, priv2->trough); + check_rectangle (priv1->stepper_a, priv2->stepper_a); + check_rectangle (priv1->stepper_d, priv2->stepper_d); + check_rectangle (priv1->stepper_b, priv2->stepper_b); + check_rectangle (priv1->stepper_c, priv2->stepper_c); - if (layout1->upper_sensitive != layout2->upper_sensitive) return TRUE; - if (layout1->lower_sensitive != layout2->lower_sensitive) return TRUE; + if (priv1->upper_sensitive != priv2->upper_sensitive) return TRUE; + if (priv1->lower_sensitive != priv2->lower_sensitive) return TRUE; return FALSE; } @@ -2715,18 +2851,18 @@ gtk_range_adjustment_changed (GtkAdjustment *adjustment, gpointer data) { GtkRange *range = GTK_RANGE (data); - /* create a copy of the layout */ - GtkRangeLayout layout = *range->layout; + GtkRangePrivate *priv = range->priv; + GtkRangePrivate priv_aux = *priv; + + priv->recalc_marks = TRUE; + priv->need_recalc = TRUE; + gtk_range_calc_layout (range, priv->adjustment->value); - range->layout->recalc_marks = TRUE; - range->need_recalc = TRUE; - gtk_range_calc_layout (range, range->adjustment->value); - /* now check whether the layout changed */ - if (layout_changed (range->layout, &layout)) + if (layout_changed (priv, &priv_aux)) gtk_widget_queue_draw (GTK_WIDGET (range)); - /* Note that we don't round off to range->round_digits here. + /* Note that we don't round off to priv->round_digits here. * that's because it's really broken to change a value * in response to a change signal on that value; round_digits * is therefore defined to be a filter on what the GtkRange @@ -2739,10 +2875,12 @@ static gboolean force_repaint (gpointer data) { GtkRange *range = GTK_RANGE (data); + GtkRangePrivate *priv = range->priv; + GtkWidget *widget = GTK_WIDGET (range); - range->layout->repaint_id = 0; - if (gtk_widget_is_drawable (GTK_WIDGET (range))) - gdk_window_process_updates (GTK_WIDGET (range)->window, FALSE); + priv->repaint_id = 0; + if (gtk_widget_is_drawable (widget)) + gdk_window_process_updates (gtk_widget_get_window (widget), FALSE); return FALSE; } @@ -2752,23 +2890,23 @@ gtk_range_adjustment_value_changed (GtkAdjustment *adjustment, gpointer data) { GtkRange *range = GTK_RANGE (data); - /* create a copy of the layout */ - GtkRangeLayout layout = *range->layout; + GtkRangePrivate *priv = range->priv; + GtkRangePrivate priv_aux = *priv; - range->need_recalc = TRUE; - gtk_range_calc_layout (range, range->adjustment->value); + priv->need_recalc = TRUE; + gtk_range_calc_layout (range, priv->adjustment->value); /* now check whether the layout changed */ - if (layout_changed (range->layout, &layout) || + if (layout_changed (priv, &priv_aux) || (GTK_IS_SCALE (range) && gtk_scale_get_draw_value (GTK_SCALE (range)))) { gtk_widget_queue_draw (GTK_WIDGET (range)); /* setup a timer to ensure the range isn't lagging too much behind the scroll position */ - if (!range->layout->repaint_id) - range->layout->repaint_id = gdk_threads_add_timeout_full (GDK_PRIORITY_EVENTS, 181, force_repaint, range, NULL); + if (!priv->repaint_id) + priv->repaint_id = gdk_threads_add_timeout_full (GDK_PRIORITY_EVENTS, 181, force_repaint, range, NULL); } - /* Note that we don't round off to range->round_digits here. + /* Note that we don't round off to priv->round_digits here. * that's because it's really broken to change a value * in response to a change signal on that value; round_digits * is therefore defined to be a filter on what the GtkRange @@ -2784,8 +2922,9 @@ gtk_range_style_set (GtkWidget *widget, GtkStyle *previous_style) { GtkRange *range = GTK_RANGE (widget); + GtkRangePrivate *priv = range->priv; - range->need_recalc = TRUE; + priv->need_recalc = TRUE; GTK_WIDGET_CLASS (gtk_range_parent_class)->style_set (widget, previous_style); } @@ -2795,12 +2934,13 @@ apply_marks (GtkRange *range, gdouble oldval, gdouble *newval) { + GtkRangePrivate *priv = range->priv; gint i; gdouble mark; - for (i = 0; i < range->layout->n_marks; i++) + for (i = 0; i < priv->n_marks; i++) { - mark = range->layout->marks[i]; + mark = priv->marks[i]; if ((oldval < mark && mark < *newval) || (oldval > mark && mark > *newval)) { @@ -2813,11 +2953,12 @@ apply_marks (GtkRange *range, static void step_back (GtkRange *range) { + GtkRangePrivate *priv = range->priv; gdouble newval; gboolean handled; - - newval = range->adjustment->value - range->adjustment->step_increment; - apply_marks (range, range->adjustment->value, &newval); + + newval = priv->adjustment->value - priv->adjustment->step_increment; + apply_marks (range, priv->adjustment->value, &newval); g_signal_emit (range, signals[CHANGE_VALUE], 0, GTK_SCROLL_STEP_BACKWARD, newval, &handled); } @@ -2825,11 +2966,12 @@ step_back (GtkRange *range) static void step_forward (GtkRange *range) { + GtkRangePrivate *priv = range->priv; gdouble newval; gboolean handled; - newval = range->adjustment->value + range->adjustment->step_increment; - apply_marks (range, range->adjustment->value, &newval); + newval = priv->adjustment->value + priv->adjustment->step_increment; + apply_marks (range, priv->adjustment->value, &newval); g_signal_emit (range, signals[CHANGE_VALUE], 0, GTK_SCROLL_STEP_FORWARD, newval, &handled); } @@ -2838,11 +2980,12 @@ step_forward (GtkRange *range) static void page_back (GtkRange *range) { + GtkRangePrivate *priv = range->priv; gdouble newval; gboolean handled; - newval = range->adjustment->value - range->adjustment->page_increment; - apply_marks (range, range->adjustment->value, &newval); + newval = priv->adjustment->value - priv->adjustment->page_increment; + apply_marks (range, priv->adjustment->value, &newval); g_signal_emit (range, signals[CHANGE_VALUE], 0, GTK_SCROLL_PAGE_BACKWARD, newval, &handled); } @@ -2850,11 +2993,12 @@ page_back (GtkRange *range) static void page_forward (GtkRange *range) { + GtkRangePrivate *priv = range->priv; gdouble newval; gboolean handled; - newval = range->adjustment->value + range->adjustment->page_increment; - apply_marks (range, range->adjustment->value, &newval); + newval = priv->adjustment->value + priv->adjustment->page_increment; + apply_marks (range, priv->adjustment->value, &newval); g_signal_emit (range, signals[CHANGE_VALUE], 0, GTK_SCROLL_PAGE_FORWARD, newval, &handled); } @@ -2862,19 +3006,22 @@ page_forward (GtkRange *range) static void scroll_begin (GtkRange *range) { + GtkRangePrivate *priv = range->priv; gboolean handled; + g_signal_emit (range, signals[CHANGE_VALUE], 0, - GTK_SCROLL_START, range->adjustment->lower, + GTK_SCROLL_START, priv->adjustment->lower, &handled); } static void scroll_end (GtkRange *range) { + GtkRangePrivate *priv = range->priv; gdouble newval; gboolean handled; - newval = range->adjustment->upper - range->adjustment->page_size; + newval = priv->adjustment->upper - priv->adjustment->page_size; g_signal_emit (range, signals[CHANGE_VALUE], 0, GTK_SCROLL_END, newval, &handled); } @@ -2883,7 +3030,8 @@ static gboolean gtk_range_scroll (GtkRange *range, GtkScrollType scroll) { - gdouble old_value = range->adjustment->value; + GtkRangePrivate *priv = range->priv; + gdouble old_value = priv->adjustment->value; switch (scroll) { @@ -2975,13 +3123,14 @@ gtk_range_scroll (GtkRange *range, break; } - return range->adjustment->value != old_value; + return priv->adjustment->value != old_value; } static void gtk_range_move_slider (GtkRange *range, GtkScrollType scroll) { + GtkRangePrivate *priv = range->priv; gboolean cursor_only; g_object_get (gtk_widget_get_settings (GTK_WIDGET (range)), @@ -2992,7 +3141,7 @@ gtk_range_move_slider (GtkRange *range, { GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (range)); - if (range->orientation == GTK_ORIENTATION_HORIZONTAL) + if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) { if (scroll == GTK_SCROLL_STEP_UP || scroll == GTK_SCROLL_STEP_DOWN) @@ -3025,7 +3174,7 @@ gtk_range_move_slider (GtkRange *range, * but DISCONTINUOUS doesn't, so we update immediately * for DISCONTINUOUS */ - if (range->update_policy == GTK_UPDATE_DISCONTINUOUS) + if (priv->update_policy == GTK_UPDATE_DISCONTINUOUS) gtk_range_update_value (range); } @@ -3110,37 +3259,39 @@ gtk_range_get_props (GtkRange *range, static gboolean gtk_range_update_mouse_location (GtkRange *range) { + GtkRangePrivate *priv = range->priv; + GtkAllocation allocation; gint x, y; MouseLocation old; - GtkWidget *widget; + GtkWidget *widget = GTK_WIDGET (range); - widget = GTK_WIDGET (range); - - old = range->layout->mouse_location; - - x = range->layout->mouse_x; - y = range->layout->mouse_y; - - if (range->layout->grab_location != MOUSE_OUTSIDE) - range->layout->mouse_location = range->layout->grab_location; - else if (POINT_IN_RECT (x, y, range->layout->stepper_a)) - range->layout->mouse_location = MOUSE_STEPPER_A; - else if (POINT_IN_RECT (x, y, range->layout->stepper_b)) - range->layout->mouse_location = MOUSE_STEPPER_B; - else if (POINT_IN_RECT (x, y, range->layout->stepper_c)) - range->layout->mouse_location = MOUSE_STEPPER_C; - else if (POINT_IN_RECT (x, y, range->layout->stepper_d)) - range->layout->mouse_location = MOUSE_STEPPER_D; - else if (POINT_IN_RECT (x, y, range->layout->slider)) - range->layout->mouse_location = MOUSE_SLIDER; - else if (POINT_IN_RECT (x, y, range->layout->trough)) - range->layout->mouse_location = MOUSE_TROUGH; - else if (POINT_IN_RECT (x, y, widget->allocation)) - range->layout->mouse_location = MOUSE_WIDGET; + old = priv->mouse_location; + + x = priv->mouse_x; + y = priv->mouse_y; + + gtk_widget_get_allocation (widget, &allocation); + + if (priv->grab_location != MOUSE_OUTSIDE) + priv->mouse_location = priv->grab_location; + else if (POINT_IN_RECT (x, y, priv->stepper_a)) + priv->mouse_location = MOUSE_STEPPER_A; + else if (POINT_IN_RECT (x, y, priv->stepper_b)) + priv->mouse_location = MOUSE_STEPPER_B; + else if (POINT_IN_RECT (x, y, priv->stepper_c)) + priv->mouse_location = MOUSE_STEPPER_C; + else if (POINT_IN_RECT (x, y, priv->stepper_d)) + priv->mouse_location = MOUSE_STEPPER_D; + else if (POINT_IN_RECT (x, y, priv->slider)) + priv->mouse_location = MOUSE_SLIDER; + else if (POINT_IN_RECT (x, y, priv->trough)) + priv->mouse_location = MOUSE_TROUGH; + else if (POINT_IN_RECT (x, y, allocation)) + priv->mouse_location = MOUSE_WIDGET; else - range->layout->mouse_location = MOUSE_OUTSIDE; + priv->mouse_location = MOUSE_OUTSIDE; - return old != range->layout->mouse_location; + return old != priv->mouse_location; } /* Clamp rect, border inside widget->allocation, such that we prefer @@ -3153,6 +3304,7 @@ clamp_dimensions (GtkWidget *widget, GtkBorder *border, gboolean border_expands_horizontally) { + GtkAllocation allocation; gint extra, shortage; g_return_if_fail (rect->x == 0); @@ -3160,9 +3312,11 @@ clamp_dimensions (GtkWidget *widget, g_return_if_fail (rect->width >= 0); g_return_if_fail (rect->height >= 0); + gtk_widget_get_allocation (widget, &allocation); + /* Width */ - - extra = widget->allocation.width - border->left - border->right - rect->width; + + extra = allocation.width - border->left - border->right - rect->width; if (extra > 0) { if (border_expands_horizontally) @@ -3177,10 +3331,10 @@ clamp_dimensions (GtkWidget *widget, } /* See if we can fit rect, if not kill the border */ - shortage = rect->width - widget->allocation.width; + shortage = rect->width - allocation.width; if (shortage > 0) { - rect->width = widget->allocation.width; + rect->width = allocation.width; /* lose the border */ border->left = 0; border->right = 0; @@ -3188,8 +3342,7 @@ clamp_dimensions (GtkWidget *widget, else { /* See if we can fit rect with borders */ - shortage = rect->width + border->left + border->right - - widget->allocation.width; + shortage = rect->width + border->left + border->right - allocation.width; if (shortage > 0) { /* Shrink borders */ @@ -3199,8 +3352,8 @@ clamp_dimensions (GtkWidget *widget, } /* Height */ - - extra = widget->allocation.height - border->top - border->bottom - rect->height; + + extra = allocation.height - border->top - border->bottom - rect->height; if (extra > 0) { if (border_expands_horizontally) @@ -3216,10 +3369,10 @@ clamp_dimensions (GtkWidget *widget, } /* See if we can fit rect, if not kill the border */ - shortage = rect->height - widget->allocation.height; + shortage = rect->height - allocation.height; if (shortage > 0) { - rect->height = widget->allocation.height; + rect->height = allocation.height; /* lose the border */ border->top = 0; border->bottom = 0; @@ -3227,8 +3380,7 @@ clamp_dimensions (GtkWidget *widget, else { /* See if we can fit rect with borders */ - shortage = rect->height + border->top + border->bottom - - widget->allocation.height; + shortage = rect->height + border->top + border->bottom - allocation.height; if (shortage > 0) { /* Shrink borders */ @@ -3252,6 +3404,7 @@ gtk_range_calc_request (GtkRange *range, gboolean *has_steppers_cd, gint *slider_length_p) { + GtkRangePrivate *priv = range->priv; gint slider_length; gint n_steppers; gint n_steppers_ab; @@ -3268,18 +3421,18 @@ gtk_range_calc_request (GtkRange *range, n_steppers_ab = 0; n_steppers_cd = 0; - if (range->has_stepper_a) + if (priv->has_stepper_a) n_steppers_ab += 1; - if (range->has_stepper_b) + if (priv->has_stepper_b) n_steppers_ab += 1; - if (range->has_stepper_c) + if (priv->has_stepper_c) n_steppers_cd += 1; - if (range->has_stepper_d) + if (priv->has_stepper_d) n_steppers_cd += 1; n_steppers = n_steppers_ab + n_steppers_cd; - slider_length = range->min_slider_size; + slider_length = priv->min_slider_size; range_rect->x = 0; range_rect->y = 0; @@ -3287,7 +3440,7 @@ gtk_range_calc_request (GtkRange *range, /* We never expand to fill available space in the small dimension * (i.e. vertical scrollbars are always a fixed width) */ - if (range->orientation == GTK_ORIENTATION_VERTICAL) + if (priv->orientation == GTK_ORIENTATION_VERTICAL) { range_rect->width = (focus_width + trough_border) * 2 + slider_width; range_rect->height = stepper_size * n_steppers + (focus_width + trough_border) * 2 + slider_length; @@ -3327,6 +3480,7 @@ static void gtk_range_calc_layout (GtkRange *range, gdouble adjustment_value) { + GtkRangePrivate *priv = range->priv; gint slider_width, stepper_size, focus_width, trough_border, stepper_spacing; gint slider_length; GtkBorder border; @@ -3335,10 +3489,9 @@ gtk_range_calc_layout (GtkRange *range, gboolean has_steppers_cd; gboolean trough_under_steppers; GdkRectangle range_rect; - GtkRangeLayout *layout; GtkWidget *widget; - - if (!range->need_recalc) + + if (!priv->need_recalc) return; /* If we have a too-small allocation, we prefer the steppers over @@ -3348,12 +3501,11 @@ gtk_range_calc_layout (GtkRange *range, * Also, we prefer to draw the range itself rather than the border * areas if there's a conflict, since the borders will be decoration * not controls. Though this depends on subclasses cooperating by - * not drawing on range->range_rect. + * not drawing on priv->range_rect. */ widget = GTK_WIDGET (range); - layout = range->layout; - + gtk_range_get_props (range, &slider_width, &stepper_size, &focus_width, &trough_border, @@ -3369,7 +3521,7 @@ gtk_range_calc_layout (GtkRange *range, /* We never expand to fill available space in the small dimension * (i.e. vertical scrollbars are always a fixed width) */ - if (range->orientation == GTK_ORIENTATION_VERTICAL) + if (priv->orientation == GTK_ORIENTATION_VERTICAL) { clamp_dimensions (widget, &range_rect, &border, TRUE); } @@ -3380,10 +3532,10 @@ gtk_range_calc_layout (GtkRange *range, range_rect.x = border.left; range_rect.y = border.top; - - range->range_rect = range_rect; - - if (range->orientation == GTK_ORIENTATION_VERTICAL) + + priv->range_rect = range_rect; + + if (priv->orientation == GTK_ORIENTATION_VERTICAL) { gint stepper_width, stepper_height; @@ -3406,88 +3558,88 @@ gtk_range_calc_layout (GtkRange *range, /* Stepper A */ - layout->stepper_a.x = range_rect.x + focus_width + trough_border * trough_under_steppers; - layout->stepper_a.y = range_rect.y + focus_width + trough_border * trough_under_steppers; + priv->stepper_a.x = range_rect.x + focus_width + trough_border * trough_under_steppers; + priv->stepper_a.y = range_rect.y + focus_width + trough_border * trough_under_steppers; - if (range->has_stepper_a) + if (priv->has_stepper_a) { - layout->stepper_a.width = stepper_width; - layout->stepper_a.height = stepper_height; + priv->stepper_a.width = stepper_width; + priv->stepper_a.height = stepper_height; } else { - layout->stepper_a.width = 0; - layout->stepper_a.height = 0; + priv->stepper_a.width = 0; + priv->stepper_a.height = 0; } /* Stepper B */ - layout->stepper_b.x = layout->stepper_a.x; - layout->stepper_b.y = layout->stepper_a.y + layout->stepper_a.height; + priv->stepper_b.x = priv->stepper_a.x; + priv->stepper_b.y = priv->stepper_a.y + priv->stepper_a.height; - if (range->has_stepper_b) + if (priv->has_stepper_b) { - layout->stepper_b.width = stepper_width; - layout->stepper_b.height = stepper_height; + priv->stepper_b.width = stepper_width; + priv->stepper_b.height = stepper_height; } else { - layout->stepper_b.width = 0; - layout->stepper_b.height = 0; + priv->stepper_b.width = 0; + priv->stepper_b.height = 0; } /* Stepper D */ - if (range->has_stepper_d) + if (priv->has_stepper_d) { - layout->stepper_d.width = stepper_width; - layout->stepper_d.height = stepper_height; + priv->stepper_d.width = stepper_width; + priv->stepper_d.height = stepper_height; } else { - layout->stepper_d.width = 0; - layout->stepper_d.height = 0; + priv->stepper_d.width = 0; + priv->stepper_d.height = 0; } - layout->stepper_d.x = layout->stepper_a.x; - layout->stepper_d.y = range_rect.y + range_rect.height - layout->stepper_d.height - focus_width - trough_border * trough_under_steppers; + priv->stepper_d.x = priv->stepper_a.x; + priv->stepper_d.y = range_rect.y + range_rect.height - priv->stepper_d.height - focus_width - trough_border * trough_under_steppers; /* Stepper C */ - if (range->has_stepper_c) + if (priv->has_stepper_c) { - layout->stepper_c.width = stepper_width; - layout->stepper_c.height = stepper_height; + priv->stepper_c.width = stepper_width; + priv->stepper_c.height = stepper_height; } else { - layout->stepper_c.width = 0; - layout->stepper_c.height = 0; + priv->stepper_c.width = 0; + priv->stepper_c.height = 0; } - layout->stepper_c.x = layout->stepper_a.x; - layout->stepper_c.y = layout->stepper_d.y - layout->stepper_c.height; + priv->stepper_c.x = priv->stepper_a.x; + priv->stepper_c.y = priv->stepper_d.y - priv->stepper_c.height; /* Now the trough is the remaining space between steppers B and C, * if any, minus spacing */ - layout->trough.x = range_rect.x; - layout->trough.y = layout->stepper_b.y + layout->stepper_b.height + stepper_spacing * has_steppers_ab; - layout->trough.width = range_rect.width; - layout->trough.height = layout->stepper_c.y - layout->trough.y - stepper_spacing * has_steppers_cd; + priv->trough.x = range_rect.x; + priv->trough.y = priv->stepper_b.y + priv->stepper_b.height + stepper_spacing * has_steppers_ab; + priv->trough.width = range_rect.width; + priv->trough.height = priv->stepper_c.y - priv->trough.y - stepper_spacing * has_steppers_cd; /* Slider fits into the trough, with stepper_spacing on either side, * and the size/position based on the adjustment or fixed, depending. */ - layout->slider.x = layout->trough.x + focus_width + trough_border; - layout->slider.width = layout->trough.width - (focus_width + trough_border) * 2; + priv->slider.x = priv->trough.x + focus_width + trough_border; + priv->slider.width = priv->trough.width - (focus_width + trough_border) * 2; /* Compute slider position/length */ { gint y, bottom, top, height; - top = layout->trough.y; - bottom = layout->trough.y + layout->trough.height; + top = priv->trough.y; + bottom = priv->trough.y + priv->trough.height; if (! trough_under_steppers) { @@ -3499,35 +3651,35 @@ gtk_range_calc_layout (GtkRange *range, * total_adjustment_range) times the trough height in pixels */ - if (range->adjustment->upper - range->adjustment->lower != 0) - height = ((bottom - top) * (range->adjustment->page_size / - (range->adjustment->upper - range->adjustment->lower))); + if (priv->adjustment->upper - priv->adjustment->lower != 0) + height = ((bottom - top) * (priv->adjustment->page_size / + (priv->adjustment->upper - priv->adjustment->lower))); else - height = range->min_slider_size; - - if (height < range->min_slider_size || - range->slider_size_fixed) - height = range->min_slider_size; + height = priv->min_slider_size; + + if (height < priv->min_slider_size || + priv->slider_size_fixed) + height = priv->min_slider_size; - height = MIN (height, layout->trough.height); + height = MIN (height, priv->trough.height); y = top; - - if (range->adjustment->upper - range->adjustment->lower - range->adjustment->page_size != 0) - y += (bottom - top - height) * ((adjustment_value - range->adjustment->lower) / - (range->adjustment->upper - range->adjustment->lower - range->adjustment->page_size)); - + + if (priv->adjustment->upper - priv->adjustment->lower - priv->adjustment->page_size != 0) + y += (bottom - top - height) * ((adjustment_value - priv->adjustment->lower) / + (priv->adjustment->upper - priv->adjustment->lower - priv->adjustment->page_size)); + y = CLAMP (y, top, bottom); if (should_invert (range)) y = bottom - (y - top + height); - layout->slider.y = y; - layout->slider.height = height; + priv->slider.y = y; + priv->slider.height = height; /* These are publically exported */ - range->slider_start = layout->slider.y; - range->slider_end = layout->slider.y + layout->slider.height; + priv->slider_start = priv->slider.y; + priv->slider_end = priv->slider.y + priv->slider.height; } } else @@ -3553,90 +3705,90 @@ gtk_range_calc_layout (GtkRange *range, /* Stepper A */ - layout->stepper_a.x = range_rect.x + focus_width + trough_border * trough_under_steppers; - layout->stepper_a.y = range_rect.y + focus_width + trough_border * trough_under_steppers; + priv->stepper_a.x = range_rect.x + focus_width + trough_border * trough_under_steppers; + priv->stepper_a.y = range_rect.y + focus_width + trough_border * trough_under_steppers; - if (range->has_stepper_a) + if (priv->has_stepper_a) { - layout->stepper_a.width = stepper_width; - layout->stepper_a.height = stepper_height; + priv->stepper_a.width = stepper_width; + priv->stepper_a.height = stepper_height; } else { - layout->stepper_a.width = 0; - layout->stepper_a.height = 0; + priv->stepper_a.width = 0; + priv->stepper_a.height = 0; } /* Stepper B */ - layout->stepper_b.x = layout->stepper_a.x + layout->stepper_a.width; - layout->stepper_b.y = layout->stepper_a.y; + priv->stepper_b.x = priv->stepper_a.x + priv->stepper_a.width; + priv->stepper_b.y = priv->stepper_a.y; - if (range->has_stepper_b) + if (priv->has_stepper_b) { - layout->stepper_b.width = stepper_width; - layout->stepper_b.height = stepper_height; + priv->stepper_b.width = stepper_width; + priv->stepper_b.height = stepper_height; } else { - layout->stepper_b.width = 0; - layout->stepper_b.height = 0; + priv->stepper_b.width = 0; + priv->stepper_b.height = 0; } /* Stepper D */ - if (range->has_stepper_d) + if (priv->has_stepper_d) { - layout->stepper_d.width = stepper_width; - layout->stepper_d.height = stepper_height; + priv->stepper_d.width = stepper_width; + priv->stepper_d.height = stepper_height; } else { - layout->stepper_d.width = 0; - layout->stepper_d.height = 0; + priv->stepper_d.width = 0; + priv->stepper_d.height = 0; } - layout->stepper_d.x = range_rect.x + range_rect.width - layout->stepper_d.width - focus_width - trough_border * trough_under_steppers; - layout->stepper_d.y = layout->stepper_a.y; + priv->stepper_d.x = range_rect.x + range_rect.width - priv->stepper_d.width - focus_width - trough_border * trough_under_steppers; + priv->stepper_d.y = priv->stepper_a.y; /* Stepper C */ - if (range->has_stepper_c) + if (priv->has_stepper_c) { - layout->stepper_c.width = stepper_width; - layout->stepper_c.height = stepper_height; + priv->stepper_c.width = stepper_width; + priv->stepper_c.height = stepper_height; } else { - layout->stepper_c.width = 0; - layout->stepper_c.height = 0; + priv->stepper_c.width = 0; + priv->stepper_c.height = 0; } - layout->stepper_c.x = layout->stepper_d.x - layout->stepper_c.width; - layout->stepper_c.y = layout->stepper_a.y; + priv->stepper_c.x = priv->stepper_d.x - priv->stepper_c.width; + priv->stepper_c.y = priv->stepper_a.y; /* Now the trough is the remaining space between steppers B and C, * if any */ - layout->trough.x = layout->stepper_b.x + layout->stepper_b.width + stepper_spacing * has_steppers_ab; - layout->trough.y = range_rect.y; + priv->trough.x = priv->stepper_b.x + priv->stepper_b.width + stepper_spacing * has_steppers_ab; + priv->trough.y = range_rect.y; - layout->trough.width = layout->stepper_c.x - layout->trough.x - stepper_spacing * has_steppers_cd; - layout->trough.height = range_rect.height; + priv->trough.width = priv->stepper_c.x - priv->trough.x - stepper_spacing * has_steppers_cd; + priv->trough.height = range_rect.height; /* Slider fits into the trough, with stepper_spacing on either side, * and the size/position based on the adjustment or fixed, depending. */ - layout->slider.y = layout->trough.y + focus_width + trough_border; - layout->slider.height = layout->trough.height - (focus_width + trough_border) * 2; + priv->slider.y = priv->trough.y + focus_width + trough_border; + priv->slider.height = priv->trough.height - (focus_width + trough_border) * 2; /* Compute slider position/length */ { gint x, left, right, width; - left = layout->trough.x; - right = layout->trough.x + layout->trough.width; + left = priv->trough.x; + right = priv->trough.x + priv->trough.width; if (! trough_under_steppers) { @@ -3647,71 +3799,71 @@ gtk_range_calc_layout (GtkRange *range, /* slider width is the fraction (page_size / * total_adjustment_range) times the trough width in pixels */ - - if (range->adjustment->upper - range->adjustment->lower != 0) - width = ((right - left) * (range->adjustment->page_size / - (range->adjustment->upper - range->adjustment->lower))); + + if (priv->adjustment->upper - priv->adjustment->lower != 0) + width = ((right - left) * (priv->adjustment->page_size / + (priv->adjustment->upper - priv->adjustment->lower))); else - width = range->min_slider_size; - - if (width < range->min_slider_size || - range->slider_size_fixed) - width = range->min_slider_size; - - width = MIN (width, layout->trough.width); + width = priv->min_slider_size; + + if (width < priv->min_slider_size || + priv->slider_size_fixed) + width = priv->min_slider_size; + + width = MIN (width, priv->trough.width); x = left; - - if (range->adjustment->upper - range->adjustment->lower - range->adjustment->page_size != 0) - x += (right - left - width) * ((adjustment_value - range->adjustment->lower) / - (range->adjustment->upper - range->adjustment->lower - range->adjustment->page_size)); + + if (priv->adjustment->upper - priv->adjustment->lower - priv->adjustment->page_size != 0) + x += (right - left - width) * ((adjustment_value - priv->adjustment->lower) / + (priv->adjustment->upper - priv->adjustment->lower - priv->adjustment->page_size)); x = CLAMP (x, left, right); if (should_invert (range)) x = right - (x - left + width); - layout->slider.x = x; - layout->slider.width = width; + priv->slider.x = x; + priv->slider.width = width; /* These are publically exported */ - range->slider_start = layout->slider.x; - range->slider_end = layout->slider.x + layout->slider.width; + priv->slider_start = priv->slider.x; + priv->slider_end = priv->slider.x + priv->slider.width; } } gtk_range_update_mouse_location (range); - switch (range->layout->upper_sensitivity) + switch (priv->upper_sensitivity) { case GTK_SENSITIVITY_AUTO: - range->layout->upper_sensitive = - (range->adjustment->value < - (range->adjustment->upper - range->adjustment->page_size)); + priv->upper_sensitive = + (priv->adjustment->value < + (priv->adjustment->upper - priv->adjustment->page_size)); break; case GTK_SENSITIVITY_ON: - range->layout->upper_sensitive = TRUE; + priv->upper_sensitive = TRUE; break; case GTK_SENSITIVITY_OFF: - range->layout->upper_sensitive = FALSE; + priv->upper_sensitive = FALSE; break; } - switch (range->layout->lower_sensitivity) + switch (priv->lower_sensitivity) { case GTK_SENSITIVITY_AUTO: - range->layout->lower_sensitive = - (range->adjustment->value > range->adjustment->lower); + priv->lower_sensitive = + (priv->adjustment->value > priv->adjustment->lower); break; case GTK_SENSITIVITY_ON: - range->layout->lower_sensitive = TRUE; + priv->lower_sensitive = TRUE; break; case GTK_SENSITIVITY_OFF: - range->layout->lower_sensitive = FALSE; + priv->lower_sensitive = FALSE; break; } } @@ -3720,20 +3872,22 @@ static GdkRectangle* get_area (GtkRange *range, MouseLocation location) { + GtkRangePrivate *priv = range->priv; + switch (location) { case MOUSE_STEPPER_A: - return &range->layout->stepper_a; + return &priv->stepper_a; case MOUSE_STEPPER_B: - return &range->layout->stepper_b; + return &priv->stepper_b; case MOUSE_STEPPER_C: - return &range->layout->stepper_c; + return &priv->stepper_c; case MOUSE_STEPPER_D: - return &range->layout->stepper_d; + return &priv->stepper_d; case MOUSE_TROUGH: - return &range->layout->trough; + return &priv->trough; case MOUSE_SLIDER: - return &range->layout->slider; + return &priv->slider; case MOUSE_WIDGET: case MOUSE_OUTSIDE: break; @@ -3746,24 +3900,25 @@ get_area (GtkRange *range, static void gtk_range_calc_marks (GtkRange *range) { + GtkRangePrivate *priv = range->priv; gint i; - - if (!range->layout->recalc_marks) + + if (!priv->recalc_marks) return; - range->layout->recalc_marks = FALSE; + priv->recalc_marks = FALSE; - for (i = 0; i < range->layout->n_marks; i++) + for (i = 0; i < priv->n_marks; i++) { - range->need_recalc = TRUE; - gtk_range_calc_layout (range, range->layout->marks[i]); - if (range->orientation == GTK_ORIENTATION_HORIZONTAL) - range->layout->mark_pos[i] = range->layout->slider.x + range->layout->slider.width / 2; + priv->need_recalc = TRUE; + gtk_range_calc_layout (range, priv->marks[i]); + if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) + priv->mark_pos[i] = priv->slider.x + priv->slider.width / 2; else - range->layout->mark_pos[i] = range->layout->slider.y + range->layout->slider.height / 2; + priv->mark_pos[i] = priv->slider.y + priv->slider.height / 2; } - range->need_recalc = TRUE; + priv->need_recalc = TRUE; } static gboolean @@ -3771,39 +3926,41 @@ gtk_range_real_change_value (GtkRange *range, GtkScrollType scroll, gdouble value) { + GtkRangePrivate *priv = range->priv; + /* potentially adjust the bounds _before_ we clamp */ g_signal_emit (range, signals[ADJUST_BOUNDS], 0, value); - if (range->layout->restrict_to_fill_level) - value = MIN (value, MAX (range->adjustment->lower, - range->layout->fill_level)); + if (priv->restrict_to_fill_level) + value = MIN (value, MAX (priv->adjustment->lower, + priv->fill_level)); - value = CLAMP (value, range->adjustment->lower, - (range->adjustment->upper - range->adjustment->page_size)); + value = CLAMP (value, priv->adjustment->lower, + (priv->adjustment->upper - priv->adjustment->page_size)); - if (range->round_digits >= 0) + if (priv->round_digits >= 0) { gdouble power; gint i; - i = range->round_digits; + i = priv->round_digits; power = 1; while (i--) power *= 10; value = floor ((value * power) + 0.5) / power; } - - if (range->adjustment->value != value) + + if (priv->adjustment->value != value) { - range->need_recalc = TRUE; + priv->need_recalc = TRUE; gtk_widget_queue_draw (GTK_WIDGET (range)); - - switch (range->update_policy) + + switch (priv->update_policy) { case GTK_UPDATE_CONTINUOUS: - gtk_adjustment_set_value (range->adjustment, value); + gtk_adjustment_set_value (priv->adjustment, value); break; /* Delayed means we update after a period of inactivity */ @@ -3814,8 +3971,8 @@ gtk_range_real_change_value (GtkRange *range, /* Discontinuous means we update on button release */ case GTK_UPDATE_DISCONTINUOUS: /* don't emit value_changed signal */ - range->adjustment->value = value; - range->update_pending = TRUE; + priv->adjustment->value = value; + priv->update_pending = TRUE; break; } } @@ -3825,13 +3982,15 @@ gtk_range_real_change_value (GtkRange *range, static void gtk_range_update_value (GtkRange *range) { + GtkRangePrivate *priv = range->priv; + gtk_range_remove_update_timer (range); - - if (range->update_pending) + + if (priv->update_pending) { - gtk_adjustment_value_changed (range->adjustment); + gtk_adjustment_value_changed (priv->adjustment); - range->update_pending = FALSE; + priv->update_pending = FALSE; } } @@ -3844,26 +4003,26 @@ struct _GtkRangeStepTimer static gboolean second_timeout (gpointer data) { - GtkRange *range; + GtkRange *range = GTK_RANGE (data); + GtkRangePrivate *priv = range->priv; + + gtk_range_scroll (range, priv->timer->step); - range = GTK_RANGE (data); - gtk_range_scroll (range, range->timer->step); - return TRUE; } static gboolean initial_timeout (gpointer data) { - GtkRange *range; + GtkRange *range = GTK_RANGE (data); + GtkRangePrivate *priv = range->priv; GtkSettings *settings; guint timeout; settings = gtk_widget_get_settings (GTK_WIDGET (data)); g_object_get (settings, "gtk-timeout-repeat", &timeout, NULL); - range = GTK_RANGE (data); - range->timer->timeout_id = gdk_threads_add_timeout (timeout * SCROLL_DELAY_FACTOR, + priv->timer->timeout_id = gdk_threads_add_timeout (timeout * SCROLL_DELAY_FACTOR, second_timeout, range); /* remove self */ @@ -3874,47 +4033,50 @@ static void gtk_range_add_step_timer (GtkRange *range, GtkScrollType step) { + GtkRangePrivate *priv = range->priv; GtkSettings *settings; guint timeout; - g_return_if_fail (range->timer == NULL); + g_return_if_fail (priv->timer == NULL); g_return_if_fail (step != GTK_SCROLL_NONE); settings = gtk_widget_get_settings (GTK_WIDGET (range)); g_object_get (settings, "gtk-timeout-initial", &timeout, NULL); - range->timer = g_new (GtkRangeStepTimer, 1); + priv->timer = g_new (GtkRangeStepTimer, 1); - range->timer->timeout_id = gdk_threads_add_timeout (timeout, + priv->timer->timeout_id = gdk_threads_add_timeout (timeout, initial_timeout, range); - range->timer->step = step; + priv->timer->step = step; - gtk_range_scroll (range, range->timer->step); + gtk_range_scroll (range, priv->timer->step); } static void gtk_range_remove_step_timer (GtkRange *range) { - if (range->timer) + GtkRangePrivate *priv = range->priv; + + if (priv->timer) { - if (range->timer->timeout_id != 0) - g_source_remove (range->timer->timeout_id); + if (priv->timer->timeout_id != 0) + g_source_remove (priv->timer->timeout_id); - g_free (range->timer); + g_free (priv->timer); - range->timer = NULL; + priv->timer = NULL; } } static gboolean update_timeout (gpointer data) { - GtkRange *range; + GtkRange *range = GTK_RANGE (data); + GtkRangePrivate *priv = range->priv; - range = GTK_RANGE (data); gtk_range_update_value (range); - range->update_timeout_id = 0; + priv->update_timeout_id = 0; /* self-remove */ return FALSE; @@ -3923,9 +4085,11 @@ update_timeout (gpointer data) static void gtk_range_reset_update_timer (GtkRange *range) { + GtkRangePrivate *priv = range->priv; + gtk_range_remove_update_timer (range); - range->update_timeout_id = gdk_threads_add_timeout (UPDATE_DELAY, + priv->update_timeout_id = gdk_threads_add_timeout (UPDATE_DELAY, update_timeout, range); } @@ -3933,10 +4097,12 @@ gtk_range_reset_update_timer (GtkRange *range) static void gtk_range_remove_update_timer (GtkRange *range) { - if (range->update_timeout_id != 0) + GtkRangePrivate *priv = range->priv; + + if (priv->update_timeout_id != 0) { - g_source_remove (range->update_timeout_id); - range->update_timeout_id = 0; + g_source_remove (priv->update_timeout_id); + priv->update_timeout_id = 0; } } @@ -3945,30 +4111,53 @@ _gtk_range_set_stop_values (GtkRange *range, gdouble *values, gint n_values) { + GtkRangePrivate *priv = range->priv; gint i; - g_free (range->layout->marks); - range->layout->marks = g_new (gdouble, n_values); + g_free (priv->marks); + priv->marks = g_new (gdouble, n_values); - g_free (range->layout->mark_pos); - range->layout->mark_pos = g_new (gint, n_values); + g_free (priv->mark_pos); + priv->mark_pos = g_new (gint, n_values); - range->layout->n_marks = n_values; + priv->n_marks = n_values; for (i = 0; i < n_values; i++) - range->layout->marks[i] = values[i]; + priv->marks[i] = values[i]; - range->layout->recalc_marks = TRUE; + priv->recalc_marks = TRUE; } gint _gtk_range_get_stop_positions (GtkRange *range, gint **values) { + GtkRangePrivate *priv = range->priv; + gtk_range_calc_marks (range); if (values) - *values = g_memdup (range->layout->mark_pos, range->layout->n_marks * sizeof (gint)); + *values = g_memdup (priv->mark_pos, priv->n_marks * sizeof (gint)); - return range->layout->n_marks; + return priv->n_marks; +} + +void +_gtk_range_set_round_digits (GtkRange *range, + gint round_digits) +{ + range->priv->round_digits = round_digits; +} + +void +_gtk_range_set_steppers (GtkRange *range, + gboolean has_a, + gboolean has_b, + gboolean has_c, + gboolean has_d) +{ + range->priv->has_stepper_a = has_a; + range->priv->has_stepper_b = has_b; + range->priv->has_stepper_c = has_c; + range->priv->has_stepper_d = has_d; } diff --git a/gtk/gtkrange.h b/gtk/gtkrange.h index 52de231a4c..f2b91b8edc 100644 --- a/gtk/gtkrange.h +++ b/gtk/gtkrange.h @@ -46,60 +46,15 @@ G_BEGIN_DECLS #define GTK_IS_RANGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_RANGE)) #define GTK_RANGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_RANGE, GtkRangeClass)) -/* These two are private/opaque types, ignore */ -typedef struct _GtkRangeLayout GtkRangeLayout; -typedef struct _GtkRangeStepTimer GtkRangeStepTimer; - -typedef struct _GtkRange GtkRange; -typedef struct _GtkRangeClass GtkRangeClass; +typedef struct _GtkRange GtkRange; +typedef struct _GtkRangePrivate GtkRangePrivate; +typedef struct _GtkRangeClass GtkRangeClass; struct _GtkRange { GtkWidget widget; - GtkAdjustment *GSEAL (adjustment); - GtkUpdateType GSEAL (update_policy); - guint GSEAL (inverted) : 1; - - /*< protected >*/ - - guint GSEAL (flippable) : 1; - - /* Steppers are: < > ---- < > - * a b c d - */ - - guint GSEAL (has_stepper_a) : 1; - guint GSEAL (has_stepper_b) : 1; - guint GSEAL (has_stepper_c) : 1; - guint GSEAL (has_stepper_d) : 1; - - guint GSEAL (need_recalc) : 1; - - guint GSEAL (slider_size_fixed) : 1; - - gint GSEAL (min_slider_size); - - GtkOrientation GSEAL (orientation); - - /* Area of entire stepper + trough assembly in widget->window coords */ - GdkRectangle GSEAL (range_rect); - /* Slider range along the long dimension, in widget->window coords */ - gint GSEAL (slider_start); - gint GSEAL (slider_end); - - /* Round off value to this many digits, -1 for no rounding */ - gint GSEAL (round_digits); - - /*< private >*/ - guint GSEAL (trough_click_forward) : 1; /* trough click was on the forward side of slider */ - guint GSEAL (update_pending) : 1; /* need to emit value_changed */ - GtkRangeLayout *GSEAL (layout); - GtkRangeStepTimer *GSEAL (timer); - gint GSEAL (slide_initial_slider_position); - gint GSEAL (slide_initial_coordinate); - guint GSEAL (update_timeout_id); - GdkWindow *GSEAL (event_window); + GtkRangePrivate *priv; }; struct _GtkRangeClass @@ -201,7 +156,13 @@ void _gtk_range_set_stop_values (GtkRange *range gint n_values); gint _gtk_range_get_stop_positions (GtkRange *range, gint **values); - +void _gtk_range_set_round_digits (GtkRange *range, + gint round_digits); +void _gtk_range_set_steppers (GtkRange *range, + gboolean has_a, + gboolean has_b, + gboolean has_c, + gboolean has_d); G_END_DECLS diff --git a/gtk/gtkrc.c b/gtk/gtkrc.c index d462136ea2..145715f2dc 100644 --- a/gtk/gtkrc.c +++ b/gtk/gtkrc.c @@ -908,7 +908,6 @@ _gtk_rc_init (void) "widget \"gtk-tooltip*\" style : gtk \"gtk-default-tooltips-style\"\n" "widget_class \"*<GtkMenuItem>*\" style : gtk \"gtk-default-menu-item-style\"\n" "widget_class \"*<GtkMenuBar>*<GtkMenuItem>\" style : gtk \"gtk-default-menu-bar-item-style\"\n" - "class \"GtkLabel\" style : gtk \"gtk-default-label-style\"\n" ); } diff --git a/gtk/gtkrecentchooser.c b/gtk/gtkrecentchooser.c index 8bcc8e2541..51ce5de9eb 100644 --- a/gtk/gtkrecentchooser.c +++ b/gtk/gtkrecentchooser.c @@ -56,7 +56,6 @@ enum LAST_SIGNAL }; -static void gtk_recent_chooser_class_init (gpointer g_iface); static gboolean recent_chooser_has_show_numbers (GtkRecentChooser *chooser); static GQuark quark_gtk_related_action = 0; @@ -67,29 +66,15 @@ static const gchar gtk_use_action_appearance_key[] = "gtk-use-action-appe static guint chooser_signals[LAST_SIGNAL] = { 0, }; -GType -gtk_recent_chooser_get_type (void) -{ - static GType chooser_type = 0; - - if (!chooser_type) - { - chooser_type = g_type_register_static_simple (G_TYPE_INTERFACE, - I_("GtkRecentChooser"), - sizeof (GtkRecentChooserIface), - (GClassInitFunc) gtk_recent_chooser_class_init, - 0, NULL, 0); - - g_type_interface_add_prerequisite (chooser_type, G_TYPE_OBJECT); - } - - return chooser_type; -} + +typedef GtkRecentChooserIface GtkRecentChooserInterface; +G_DEFINE_INTERFACE (GtkRecentChooser, gtk_recent_chooser, G_TYPE_OBJECT); + static void -gtk_recent_chooser_class_init (gpointer g_iface) +gtk_recent_chooser_default_init (GtkRecentChooserInterface *iface) { - GType iface_type = G_TYPE_FROM_INTERFACE (g_iface); + GType iface_type = G_TYPE_FROM_INTERFACE (iface); quark_gtk_related_action = g_quark_from_static_string (gtk_related_action_key); quark_gtk_use_action_appearance = g_quark_from_static_string (gtk_use_action_appearance_key); @@ -142,7 +127,7 @@ gtk_recent_chooser_class_init (gpointer g_iface) * * Since: 2.10 */ - g_object_interface_install_property (g_iface, + g_object_interface_install_property (iface, g_param_spec_object ("recent-manager", P_("Recent Manager"), P_("The RecentManager object to use"), @@ -157,7 +142,7 @@ gtk_recent_chooser_class_init (gpointer g_iface) * * Since: 2.10 */ - g_object_interface_install_property (g_iface, + g_object_interface_install_property (iface, g_param_spec_boolean ("show-private", P_("Show Private"), P_("Whether the private items should be displayed"), @@ -171,7 +156,7 @@ gtk_recent_chooser_class_init (gpointer g_iface) * * Since: 2.10 */ - g_object_interface_install_property (g_iface, + g_object_interface_install_property (iface, g_param_spec_boolean ("show-tips", P_("Show Tooltips"), P_("Whether there should be a tooltip on the item"), @@ -184,7 +169,7 @@ gtk_recent_chooser_class_init (gpointer g_iface) * * Since: 2.10 */ - g_object_interface_install_property (g_iface, + g_object_interface_install_property (iface, g_param_spec_boolean ("show-icons", P_("Show Icons"), P_("Whether there should be an icon near the item"), @@ -200,7 +185,7 @@ gtk_recent_chooser_class_init (gpointer g_iface) * * Since: 2.10 */ - g_object_interface_install_property (g_iface, + g_object_interface_install_property (iface, g_param_spec_boolean ("show-not-found", P_("Show Not Found"), P_("Whether the items pointing to unavailable resources should be displayed"), @@ -213,7 +198,7 @@ gtk_recent_chooser_class_init (gpointer g_iface) * * Since: 2.10 */ - g_object_interface_install_property (g_iface, + g_object_interface_install_property (iface, g_param_spec_boolean ("select-multiple", P_("Select Multiple"), P_("Whether to allow multiple items to be selected"), @@ -227,7 +212,7 @@ gtk_recent_chooser_class_init (gpointer g_iface) * * Since: 2.10 */ - g_object_interface_install_property (g_iface, + g_object_interface_install_property (iface, g_param_spec_boolean ("local-only", P_("Local only"), P_("Whether the selected resource(s) should be limited to local file: URIs"), @@ -244,7 +229,7 @@ gtk_recent_chooser_class_init (gpointer g_iface) * * Since: 2.10 */ - g_object_interface_install_property (g_iface, + g_object_interface_install_property (iface, g_param_spec_int ("limit", P_("Limit"), P_("The maximum number of items to be displayed"), @@ -259,7 +244,7 @@ gtk_recent_chooser_class_init (gpointer g_iface) * * Since: 2.10 */ - g_object_interface_install_property (g_iface, + g_object_interface_install_property (iface, g_param_spec_enum ("sort-type", P_("Sort Type"), P_("The sorting order of the items displayed"), @@ -274,7 +259,7 @@ gtk_recent_chooser_class_init (gpointer g_iface) * * Since: 2.10 */ - g_object_interface_install_property (g_iface, + g_object_interface_install_property (iface, g_param_spec_object ("filter", P_("Filter"), P_("The current filter for selecting which resources are displayed"), diff --git a/gtk/gtkrecentchooserdefault.c b/gtk/gtkrecentchooserdefault.c index 612a8ec1df..9a04611d95 100644 --- a/gtk/gtkrecentchooserdefault.c +++ b/gtk/gtkrecentchooserdefault.c @@ -710,8 +710,9 @@ error_message_with_parent (GtkWindow *parent, gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s", detail); - if (parent->group) - gtk_window_group_add_window (parent->group, GTK_WINDOW (dialog)); + if (gtk_window_has_group (parent)) + gtk_window_group_add_window (gtk_window_get_group (parent), + GTK_WINDOW (dialog)); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); @@ -757,7 +758,8 @@ set_busy_cursor (GtkRecentChooserDefault *impl, if (show_busy_cursor) cursor = gdk_cursor_new_for_display (display, GDK_WATCH); - gdk_window_set_cursor (GTK_WIDGET (toplevel)->window, cursor); + gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET (toplevel)), + cursor); gdk_display_flush (display); if (cursor) @@ -936,7 +938,7 @@ set_default_size (GtkRecentChooserDefault *impl) widget = GTK_WIDGET (impl); /* Size based on characters and the icon size */ - font_size = pango_font_description_get_size (widget->style->font_desc); + font_size = pango_font_description_get_size (gtk_widget_get_style (widget)->font_desc); font_size = PANGO_PIXELS (font_size); width = impl->icon_size + font_size * NUM_CHARS; @@ -949,7 +951,8 @@ set_default_size (GtkRecentChooserDefault *impl) /* ... but no larger than the monitor */ screen = gtk_widget_get_screen (widget); - monitor_num = gdk_screen_get_monitor_at_window (screen, widget->window); + monitor_num = gdk_screen_get_monitor_at_window (screen, + gtk_widget_get_window (widget)); gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor); @@ -1831,6 +1834,7 @@ popup_position_func (GtkMenu *menu, gboolean *push_in, gpointer user_data) { + GtkAllocation allocation; GtkWidget *widget = GTK_WIDGET (user_data); GdkScreen *screen = gtk_widget_get_screen (widget); GtkRequisition req; @@ -1840,12 +1844,14 @@ popup_position_func (GtkMenu *menu, if (G_UNLIKELY (!gtk_widget_get_realized (widget))) return; - gdk_window_get_origin (widget->window, x, y); + gdk_window_get_origin (gtk_widget_get_window (widget), + x, y); gtk_widget_size_request (GTK_WIDGET (menu), &req); - *x += (widget->allocation.width - req.width) / 2; - *y += (widget->allocation.height - req.height) / 2; + gtk_widget_get_allocation (widget, &allocation); + *x += (allocation.width - req.width) / 2; + *y += (allocation.height - req.height) / 2; monitor_num = gdk_screen_get_monitor_at_point (screen, *x, *y); gtk_menu_set_monitor (menu, monitor_num); diff --git a/gtk/gtkruler.c b/gtk/gtkruler.c index 1e32dc6a3f..eff3bfe824 100644 --- a/gtk/gtkruler.c +++ b/gtk/gtkruler.c @@ -41,7 +41,7 @@ #define ROUND(x) ((int) ((x) + 0.5)) -struct _GtkRulerPriv +struct _GtkRulerPrivate { GtkOrientation orientation; GtkRulerMetric *metric; @@ -183,18 +183,18 @@ gtk_ruler_class_init (GtkRulerClass *class) GTK_PIXELS, GTK_PARAM_READWRITE)); - g_type_class_add_private (gobject_class, sizeof (GtkRulerPriv)); + g_type_class_add_private (gobject_class, sizeof (GtkRulerPrivate)); } static void gtk_ruler_init (GtkRuler *ruler) { GtkWidget *widget = GTK_WIDGET (ruler); - GtkRulerPriv *priv; + GtkRulerPrivate *priv; ruler->priv = G_TYPE_INSTANCE_GET_PRIVATE (ruler, GTK_TYPE_RULER, - GtkRulerPriv); + GtkRulerPrivate); priv = ruler->priv; priv->orientation = GTK_ORIENTATION_HORIZONTAL; @@ -221,7 +221,7 @@ gtk_ruler_set_property (GObject *object, GParamSpec *pspec) { GtkRuler *ruler = GTK_RULER (object); - GtkRulerPriv *priv = ruler->priv; + GtkRulerPrivate *priv = ruler->priv; switch (prop_id) { @@ -261,7 +261,7 @@ gtk_ruler_get_property (GObject *object, GParamSpec *pspec) { GtkRuler *ruler = GTK_RULER (object); - GtkRulerPriv *priv = ruler->priv; + GtkRulerPrivate *priv = ruler->priv; switch (prop_id) { @@ -311,7 +311,7 @@ void gtk_ruler_set_metric (GtkRuler *ruler, GtkMetricType metric) { - GtkRulerPriv *priv; + GtkRulerPrivate *priv; g_return_if_fail (GTK_IS_RULER (ruler)); @@ -336,7 +336,7 @@ gtk_ruler_set_metric (GtkRuler *ruler, GtkMetricType gtk_ruler_get_metric (GtkRuler *ruler) { - GtkRulerPriv *priv; + GtkRulerPrivate *priv; gint i; g_return_val_if_fail (GTK_IS_RULER (ruler), 0); @@ -370,7 +370,7 @@ gtk_ruler_set_range (GtkRuler *ruler, gdouble position, gdouble max_size) { - GtkRulerPriv *priv; + GtkRulerPrivate *priv; g_return_if_fail (GTK_IS_RULER (ruler)); @@ -422,7 +422,7 @@ gtk_ruler_get_range (GtkRuler *ruler, gdouble *position, gdouble *max_size) { - GtkRulerPriv *priv; + GtkRulerPrivate *priv; g_return_if_fail (GTK_IS_RULER (ruler)); @@ -496,7 +496,7 @@ static void gtk_ruler_unrealize (GtkWidget *widget) { GtkRuler *ruler = GTK_RULER (widget); - GtkRulerPriv *priv = ruler->priv; + GtkRulerPrivate *priv = ruler->priv; if (priv->backing_store) { @@ -512,7 +512,7 @@ gtk_ruler_size_request (GtkWidget *widget, GtkRequisition *requisition) { GtkRuler *ruler = GTK_RULER (widget); - GtkRulerPriv *priv = ruler->priv; + GtkRulerPrivate *priv = ruler->priv; if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) { @@ -549,7 +549,7 @@ gtk_ruler_motion_notify (GtkWidget *widget, GdkEventMotion *event) { GtkRuler *ruler = GTK_RULER (widget); - GtkRulerPriv *priv = ruler->priv; + GtkRulerPrivate *priv = ruler->priv; gint x; gint y; @@ -578,7 +578,7 @@ gtk_ruler_expose (GtkWidget *widget, if (gtk_widget_is_drawable (widget)) { GtkRuler *ruler = GTK_RULER (widget); - GtkRulerPriv *priv = ruler->priv; + GtkRulerPrivate *priv = ruler->priv; cairo_t *cr; gtk_ruler_draw_ticks (ruler); @@ -598,7 +598,7 @@ gtk_ruler_expose (GtkWidget *widget, static void gtk_ruler_make_pixmap (GtkRuler *ruler) { - GtkRulerPriv *priv = ruler->priv; + GtkRulerPrivate *priv = ruler->priv; GtkWidget *widget; gint width; gint height; @@ -628,7 +628,7 @@ static void gtk_ruler_real_draw_ticks (GtkRuler *ruler) { GtkWidget *widget = GTK_WIDGET (ruler); - GtkRulerPriv *priv = ruler->priv; + GtkRulerPrivate *priv = ruler->priv; cairo_t *cr; gint i, j; gint width, height; @@ -841,7 +841,7 @@ static void gtk_ruler_real_draw_pos (GtkRuler *ruler) { GtkWidget *widget = GTK_WIDGET (ruler); - GtkRulerPriv *priv = ruler->priv; + GtkRulerPrivate *priv = ruler->priv; gint x, y; gint width, height; gint bs_width, bs_height; diff --git a/gtk/gtkruler.h b/gtk/gtkruler.h index b86bd27734..f3ebf0ce3b 100644 --- a/gtk/gtkruler.h +++ b/gtk/gtkruler.h @@ -55,10 +55,10 @@ G_BEGIN_DECLS #define GTK_RULER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_RULER, GtkRulerClass)) -typedef struct _GtkRuler GtkRuler; -typedef struct _GtkRulerPriv GtkRulerPriv; -typedef struct _GtkRulerClass GtkRulerClass; -typedef struct _GtkRulerMetric GtkRulerMetric; +typedef struct _GtkRuler GtkRuler; +typedef struct _GtkRulerPrivate GtkRulerPrivate; +typedef struct _GtkRulerClass GtkRulerClass; +typedef struct _GtkRulerMetric GtkRulerMetric; /* All distances below are in 1/72nd's of an inch. (According to * Adobe that's a point, but points are really 1/72.27 in.) @@ -68,7 +68,7 @@ struct _GtkRuler GtkWidget widget; /* <private> */ - GtkRulerPriv *priv; + GtkRulerPrivate *priv; }; struct _GtkRulerClass diff --git a/gtk/gtkscale.c b/gtk/gtkscale.c index eb930ba6ee..e03013dc23 100644 --- a/gtk/gtkscale.c +++ b/gtk/gtkscale.c @@ -36,6 +36,7 @@ #include "gtkicontheme.h" #include "gtkmarshalers.h" #include "gtkbindings.h" +#include "gtkorientable.h" #include "gtkprivate.h" #include "gtkintl.h" #include "gtkbuildable.h" @@ -50,7 +51,7 @@ typedef struct _GtkScaleMark GtkScaleMark; -struct _GtkScalePriv +struct _GtkScalePrivate { PangoLayout *layout; @@ -376,39 +377,39 @@ gtk_scale_class_init (GtkScaleClass *class) add_slider_binding (binding_set, GDK_KP_End, 0, GTK_SCROLL_END); - g_type_class_add_private (gobject_class, sizeof (GtkScalePriv)); + g_type_class_add_private (gobject_class, sizeof (GtkScalePrivate)); } static void gtk_scale_orientation_notify (GtkRange *range, const GParamSpec *pspec) { - range->flippable = (range->orientation == GTK_ORIENTATION_HORIZONTAL); + GtkOrientation orientation; + + orientation = gtk_orientable_get_orientation (GTK_ORIENTABLE (range)); + gtk_range_set_flippable (range, + orientation == GTK_ORIENTATION_HORIZONTAL); } static void gtk_scale_init (GtkScale *scale) { - GtkScalePriv *priv; + GtkScalePrivate *priv; GtkRange *range = GTK_RANGE (scale); scale->priv = G_TYPE_INSTANCE_GET_PRIVATE (scale, GTK_TYPE_SCALE, - GtkScalePriv); + GtkScalePrivate); priv = scale->priv; gtk_widget_set_can_focus (GTK_WIDGET (scale), TRUE); - range->slider_size_fixed = TRUE; - range->has_stepper_a = FALSE; - range->has_stepper_b = FALSE; - range->has_stepper_c = FALSE; - range->has_stepper_d = FALSE; + gtk_range_set_slider_size_fixed (range, TRUE); priv->draw_value = TRUE; priv->value_pos = GTK_POS_TOP; priv->digits = 1; - range->round_digits = priv->digits; + _gtk_range_set_round_digits (range, priv->digits); gtk_scale_orientation_notify (range, NULL); g_signal_connect (scale, "notify::orientation", @@ -450,7 +451,7 @@ gtk_scale_get_property (GObject *object, GParamSpec *pspec) { GtkScale *scale = GTK_SCALE (object); - GtkScalePriv *priv = scale->priv; + GtkScalePrivate *priv = scale->priv; switch (prop_id) { @@ -561,7 +562,7 @@ void gtk_scale_set_digits (GtkScale *scale, gint digits) { - GtkScalePriv *priv; + GtkScalePrivate *priv; GtkRange *range; g_return_if_fail (GTK_IS_SCALE (scale)); @@ -575,8 +576,8 @@ gtk_scale_set_digits (GtkScale *scale, { priv->digits = digits; if (priv->draw_value) - range->round_digits = digits; - + _gtk_range_set_round_digits (range, digits); + _gtk_scale_clear_layout (scale); gtk_widget_queue_resize (GTK_WIDGET (scale)); @@ -612,7 +613,7 @@ void gtk_scale_set_draw_value (GtkScale *scale, gboolean draw_value) { - GtkScalePriv *priv; + GtkScalePrivate *priv; g_return_if_fail (GTK_IS_SCALE (scale)); @@ -624,9 +625,9 @@ gtk_scale_set_draw_value (GtkScale *scale, { priv->draw_value = draw_value; if (draw_value) - GTK_RANGE (scale)->round_digits = priv->digits; + _gtk_range_set_round_digits (GTK_RANGE (scale), priv->digits); else - GTK_RANGE (scale)->round_digits = -1; + _gtk_range_set_round_digits (GTK_RANGE (scale), -1); _gtk_scale_clear_layout (scale); @@ -664,7 +665,7 @@ void gtk_scale_set_value_pos (GtkScale *scale, GtkPositionType pos) { - GtkScalePriv *priv; + GtkScalePrivate *priv; GtkWidget *widget; g_return_if_fail (GTK_IS_SCALE (scale)); @@ -704,7 +705,7 @@ static void gtk_scale_get_range_border (GtkRange *range, GtkBorder *border) { - GtkScalePriv *priv; + GtkScalePrivate *priv; GtkWidget *widget; GtkScale *scale; gint w, h; @@ -754,7 +755,7 @@ gtk_scale_get_range_border (GtkRange *range, NULL); - if (GTK_RANGE (scale)->orientation == GTK_ORIENTATION_HORIZONTAL) + if (gtk_orientable_get_orientation (GTK_ORIENTABLE (scale)) == GTK_ORIENTATION_HORIZONTAL) { gtk_scale_get_mark_label_size (scale, GTK_POS_TOP, &n1, &w1, &h1, &n2, &w2, &h2); if (n1 > 0) @@ -779,11 +780,12 @@ _gtk_scale_get_value_size (GtkScale *scale, gint *width, gint *height) { - GtkScalePriv *priv = scale->priv; + GtkScalePrivate *priv = scale->priv; GtkRange *range; if (priv->draw_value) { + GtkAdjustment *adjustment; PangoLayout *layout; PangoRectangle logical_rect; gchar *txt; @@ -791,8 +793,9 @@ _gtk_scale_get_value_size (GtkScale *scale, range = GTK_RANGE (scale); layout = gtk_widget_create_pango_layout (GTK_WIDGET (scale), NULL); + adjustment = gtk_range_get_adjustment (range); - txt = _gtk_scale_format_value (scale, range->adjustment->lower); + txt = _gtk_scale_format_value (scale, gtk_adjustment_get_lower (adjustment)); pango_layout_set_text (layout, txt, -1); g_free (txt); @@ -803,7 +806,7 @@ _gtk_scale_get_value_size (GtkScale *scale, if (height) *height = logical_rect.height; - txt = _gtk_scale_format_value (scale, range->adjustment->upper); + txt = _gtk_scale_format_value (scale, gtk_adjustment_get_upper (adjustment)); pango_layout_set_text (layout, txt, -1); g_free (txt); @@ -836,7 +839,7 @@ gtk_scale_get_mark_label_size (GtkScale *scale, gint *width2, gint *height2) { - GtkScalePriv *priv = scale->priv; + GtkScalePrivate *priv = scale->priv; PangoLayout *layout; PangoRectangle logical_rect; GSList *m; @@ -895,9 +898,9 @@ gtk_scale_style_set (GtkWidget *widget, gtk_widget_style_get (widget, "slider-length", &slider_length, NULL); - - range->min_slider_size = slider_length; - + + gtk_range_set_min_slider_size (range, slider_length); + _gtk_scale_clear_layout (GTK_SCALE (widget)); GTK_WIDGET_CLASS (gtk_scale_parent_class)->style_set (widget, previous); @@ -923,7 +926,7 @@ gtk_scale_size_request (GtkWidget *widget, gtk_widget_style_get (widget, "slider-length", &slider_length, NULL); - if (range->orientation == GTK_ORIENTATION_HORIZONTAL) + if (gtk_orientable_get_orientation (GTK_ORIENTABLE (range)) == GTK_ORIENTATION_HORIZONTAL) { gtk_scale_get_mark_label_size (GTK_SCALE (widget), GTK_POS_TOP, &n1, &w1, &h1, &n2, &w2, &h2); @@ -947,6 +950,7 @@ find_next_pos (GtkWidget *widget, GtkPositionType pos, gint match) { + GtkAllocation allocation; GSList *m; gint i; @@ -958,10 +962,11 @@ find_next_pos (GtkWidget *widget, return marks[i]; } + gtk_widget_get_allocation (widget, &allocation); if (pos == GTK_POS_TOP || pos == GTK_POS_BOTTOM) - return widget->allocation.width; + return allocation.width; else - return widget->allocation.height; + return allocation.height; } static gboolean @@ -969,9 +974,11 @@ gtk_scale_expose (GtkWidget *widget, GdkEventExpose *event) { GtkScale *scale = GTK_SCALE (widget); - GtkScalePriv *priv = scale->priv; + GtkScalePrivate *priv = scale->priv; GtkRange *range = GTK_RANGE (scale); GtkStateType state_type; + GtkStyle *style; + GdkWindow *window; gint n_marks; gint *marks; gint focus_padding; @@ -979,6 +986,7 @@ gtk_scale_expose (GtkWidget *widget, gint value_spacing; gint min_sep = 4; + style = gtk_widget_get_style (widget); gtk_widget_style_get (widget, "focus-padding", &focus_padding, "slider-width", &slider_width, @@ -990,12 +998,17 @@ gtk_scale_expose (GtkWidget *widget, */ GTK_WIDGET_CLASS (gtk_scale_parent_class)->expose_event (widget, event); + window = gtk_widget_get_window (widget); + state_type = GTK_STATE_NORMAL; if (!gtk_widget_is_sensitive (widget)) state_type = GTK_STATE_INSENSITIVE; if (priv->marks) { + GtkAllocation allocation; + GtkOrientation orientation; + GdkRectangle range_rect; gint i; gint x1, x2, x3, y1, y2, y3; PangoLayout *layout; @@ -1004,36 +1017,39 @@ gtk_scale_expose (GtkWidget *widget, gint min_pos_before, min_pos_after; gint min_pos, max_pos; + orientation = gtk_orientable_get_orientation (GTK_ORIENTABLE (range)); n_marks = _gtk_range_get_stop_positions (range, &marks); layout = gtk_widget_create_pango_layout (widget, NULL); + gtk_widget_get_allocation (widget, &allocation); + gtk_range_get_range_rect (range, &range_rect); - if (range->orientation == GTK_ORIENTATION_HORIZONTAL) - min_pos_before = min_pos_after = widget->allocation.x; + if (orientation == GTK_ORIENTATION_HORIZONTAL) + min_pos_before = min_pos_after = allocation.x; else - min_pos_before = min_pos_after = widget->allocation.y; + min_pos_before = min_pos_after = allocation.y; for (m = priv->marks, i = 0; m; m = m->next, i++) { GtkScaleMark *mark = m->data; - - if (range->orientation == GTK_ORIENTATION_HORIZONTAL) + + if (orientation == GTK_ORIENTATION_HORIZONTAL) { - x1 = widget->allocation.x + marks[i]; + x1 = allocation.x + marks[i]; if (mark->position == GTK_POS_TOP) { - y1 = widget->allocation.y + range->range_rect.y; + y1 = allocation.y + range_rect.y; y2 = y1 - slider_width / 2; min_pos = min_pos_before; - max_pos = widget->allocation.x + find_next_pos (widget, m, marks + i, GTK_POS_TOP, 1) - min_sep; + max_pos = allocation.x + find_next_pos (widget, m, marks + i, GTK_POS_TOP, 1) - min_sep; } else { - y1 = widget->allocation.y + range->range_rect.y + range->range_rect.height; + y1 = allocation.y + range_rect.y + range_rect.height; y2 = y1 + slider_width / 2; min_pos = min_pos_after; - max_pos = widget->allocation.x + find_next_pos (widget, m, marks + i, GTK_POS_TOP, 0) - min_sep; + max_pos = allocation.x + find_next_pos (widget, m, marks + i, GTK_POS_TOP, 0) - min_sep; } - gtk_paint_vline (widget->style, widget->window, state_type, + gtk_paint_vline (style, window, state_type, NULL, widget, "scale-mark", y1, y2, x1); if (mark->markup) @@ -1046,8 +1062,8 @@ gtk_scale_expose (GtkWidget *widget, x3 = min_pos; if (x3 + logical_rect.width > max_pos) x3 = max_pos - logical_rect.width; - if (x3 < widget->allocation.x) - x3 = widget->allocation.x; + if (x3 < allocation.x) + x3 = allocation.x; if (mark->position == GTK_POS_TOP) { y3 = y2 - value_spacing - logical_rect.height; @@ -1059,7 +1075,7 @@ gtk_scale_expose (GtkWidget *widget, min_pos_after = x3 + logical_rect.width + min_sep; } - gtk_paint_layout (widget->style, widget->window, state_type, + gtk_paint_layout (style, window, state_type, FALSE, NULL, widget, "scale-mark", x3, y3, layout); } @@ -1068,21 +1084,21 @@ gtk_scale_expose (GtkWidget *widget, { if (mark->position == GTK_POS_LEFT) { - x1 = widget->allocation.x + range->range_rect.x; - x2 = widget->allocation.x + range->range_rect.x - slider_width / 2; + x1 = allocation.x + range_rect.x; + x2 = allocation.x + range_rect.x - slider_width / 2; min_pos = min_pos_before; - max_pos = widget->allocation.y + find_next_pos (widget, m, marks + i, GTK_POS_LEFT, 1) - min_sep; + max_pos = allocation.y + find_next_pos (widget, m, marks + i, GTK_POS_LEFT, 1) - min_sep; } else { - x1 = widget->allocation.x + range->range_rect.x + range->range_rect.width; - x2 = widget->allocation.x + range->range_rect.x + range->range_rect.width + slider_width / 2; + x1 = allocation.x + range_rect.x + range_rect.width; + x2 = allocation.x + range_rect.x + range_rect.width + slider_width / 2; min_pos = min_pos_after; - max_pos = widget->allocation.y + find_next_pos (widget, m, marks + i, GTK_POS_LEFT, 0) - min_sep; + max_pos = allocation.y + find_next_pos (widget, m, marks + i, GTK_POS_LEFT, 0) - min_sep; } - y1 = widget->allocation.y + marks[i]; + y1 = allocation.y + marks[i]; - gtk_paint_hline (widget->style, widget->window, state_type, + gtk_paint_hline (style, window, state_type, NULL, widget, "range-mark", x1, x2, y1); if (mark->markup) @@ -1095,8 +1111,8 @@ gtk_scale_expose (GtkWidget *widget, y3 = min_pos; if (y3 + logical_rect.height > max_pos) y3 = max_pos - logical_rect.height; - if (y3 < widget->allocation.y) - y3 = widget->allocation.y; + if (y3 < allocation.y) + y3 = allocation.y; if (mark->position == GTK_POS_LEFT) { x3 = x2 - value_spacing - logical_rect.width; @@ -1108,7 +1124,7 @@ gtk_scale_expose (GtkWidget *widget, min_pos_after = y3 + logical_rect.height + min_sep; } - gtk_paint_layout (widget->style, widget->window, state_type, + gtk_paint_layout (style, window, state_type, FALSE, NULL, widget, "scale-mark", x3, y3, layout); } @@ -1121,19 +1137,21 @@ gtk_scale_expose (GtkWidget *widget, if (priv->draw_value) { + GtkOrientation orientation; PangoLayout *layout; gint x, y; + orientation = gtk_orientable_get_orientation (GTK_ORIENTABLE (range)); layout = gtk_scale_get_layout (scale); gtk_scale_get_layout_offsets (scale, &x, &y); - gtk_paint_layout (widget->style, - widget->window, + gtk_paint_layout (style, + window, state_type, FALSE, NULL, widget, - range->orientation == GTK_ORIENTATION_HORIZONTAL ? + orientation == GTK_ORIENTATION_HORIZONTAL ? "hscale" : "vscale", x, y, layout); @@ -1148,11 +1166,14 @@ gtk_scale_real_get_layout_offsets (GtkScale *scale, gint *x, gint *y) { - GtkScalePriv *priv = scale->priv; + GtkScalePrivate *priv = scale->priv; + GtkAllocation allocation; GtkWidget *widget = GTK_WIDGET (scale); GtkRange *range = GTK_RANGE (widget); + GdkRectangle range_rect; PangoLayout *layout = gtk_scale_get_layout (scale); PangoRectangle logical_rect; + gint slider_start, slider_end; gint value_spacing; if (!layout) @@ -1167,32 +1188,36 @@ gtk_scale_real_get_layout_offsets (GtkScale *scale, pango_layout_get_pixel_extents (layout, NULL, &logical_rect); - if (range->orientation == GTK_ORIENTATION_HORIZONTAL) + gtk_widget_get_allocation (widget, &allocation); + gtk_range_get_range_rect (range, &range_rect); + gtk_range_get_slider_range (range, + &slider_start, + &slider_end); + + if (gtk_orientable_get_orientation (GTK_ORIENTABLE (range)) == GTK_ORIENTATION_HORIZONTAL) { switch (priv->value_pos) { case GTK_POS_LEFT: - *x = range->range_rect.x - value_spacing - logical_rect.width; - *y = range->range_rect.y + (range->range_rect.height - logical_rect.height) / 2; + *x = range_rect.x - value_spacing - logical_rect.width; + *y = range_rect.y + (range_rect.height - logical_rect.height) / 2; break; case GTK_POS_RIGHT: - *x = range->range_rect.x + range->range_rect.width + value_spacing; - *y = range->range_rect.y + (range->range_rect.height - logical_rect.height) / 2; + *x = range_rect.x + range_rect.width + value_spacing; + *y = range_rect.y + (range_rect.height - logical_rect.height) / 2; break; case GTK_POS_TOP: - *x = range->slider_start + - (range->slider_end - range->slider_start - logical_rect.width) / 2; - *x = CLAMP (*x, 0, widget->allocation.width - logical_rect.width); - *y = range->range_rect.y - logical_rect.height - value_spacing; + *x = slider_start + (slider_end - slider_start - logical_rect.width) / 2; + *x = CLAMP (*x, 0, allocation.width - logical_rect.width); + *y = range_rect.y - logical_rect.height - value_spacing; break; case GTK_POS_BOTTOM: - *x = range->slider_start + - (range->slider_end - range->slider_start - logical_rect.width) / 2; - *x = CLAMP (*x, 0, widget->allocation.width - logical_rect.width); - *y = range->range_rect.y + range->range_rect.height + value_spacing; + *x = slider_start + (slider_end - slider_start - logical_rect.width) / 2; + *x = CLAMP (*x, 0, allocation.width - logical_rect.width); + *y = range_rect.y + range_rect.height + value_spacing; break; default: @@ -1205,25 +1230,25 @@ gtk_scale_real_get_layout_offsets (GtkScale *scale, switch (priv->value_pos) { case GTK_POS_LEFT: - *x = range->range_rect.x - logical_rect.width - value_spacing; - *y = range->slider_start + (range->slider_end - range->slider_start - logical_rect.height) / 2; - *y = CLAMP (*y, 0, widget->allocation.height - logical_rect.height); + *x = range_rect.x - logical_rect.width - value_spacing; + *y = slider_start + (slider_end - slider_start - logical_rect.height) / 2; + *y = CLAMP (*y, 0, allocation.height - logical_rect.height); break; case GTK_POS_RIGHT: - *x = range->range_rect.x + range->range_rect.width + value_spacing; - *y = range->slider_start + (range->slider_end - range->slider_start - logical_rect.height) / 2; - *y = CLAMP (*y, 0, widget->allocation.height - logical_rect.height); + *x = range_rect.x + range_rect.width + value_spacing; + *y = slider_start + (slider_end - slider_start - logical_rect.height) / 2; + *y = CLAMP (*y, 0, allocation.height - logical_rect.height); break; case GTK_POS_TOP: - *x = range->range_rect.x + (range->range_rect.width - logical_rect.width) / 2; - *y = range->range_rect.y - logical_rect.height - value_spacing; + *x = range_rect.x + (range_rect.width - logical_rect.width) / 2; + *y = range_rect.y - logical_rect.height - value_spacing; break; case GTK_POS_BOTTOM: - *x = range->range_rect.x + (range->range_rect.width - logical_rect.width) / 2; - *y = range->range_rect.y + range->range_rect.height + value_spacing; + *x = range_rect.x + (range_rect.width - logical_rect.width) / 2; + *y = range_rect.y + range_rect.height + value_spacing; break; default: @@ -1231,8 +1256,8 @@ gtk_scale_real_get_layout_offsets (GtkScale *scale, } } - *x += widget->allocation.x; - *y += widget->allocation.y; + *x += allocation.x; + *y += allocation.y; } /** @@ -1249,7 +1274,7 @@ gchar* _gtk_scale_format_value (GtkScale *scale, gdouble value) { - GtkScalePriv *priv = scale->priv; + GtkScalePrivate *priv = scale->priv; gchar *fmt = NULL; g_signal_emit (scale, @@ -1292,7 +1317,7 @@ gtk_scale_finalize (GObject *object) PangoLayout * gtk_scale_get_layout (GtkScale *scale) { - GtkScalePriv *priv; + GtkScalePrivate *priv; gchar *txt; g_return_val_if_fail (GTK_IS_SCALE (scale), NULL); @@ -1308,7 +1333,7 @@ gtk_scale_get_layout (GtkScale *scale) if (priv->draw_value) { txt = _gtk_scale_format_value (scale, - GTK_RANGE (scale)->adjustment->value); + gtk_adjustment_get_value (gtk_range_get_adjustment (GTK_RANGE (scale)))); pango_layout_set_text (priv->layout, txt, -1); g_free (txt); } @@ -1355,7 +1380,7 @@ gtk_scale_get_layout_offsets (GtkScale *scale, void _gtk_scale_clear_layout (GtkScale *scale) { - GtkScalePriv *priv = scale->priv; + GtkScalePrivate *priv = scale->priv; g_return_if_fail (GTK_IS_SCALE (scale)); @@ -1384,7 +1409,7 @@ gtk_scale_mark_free (GtkScaleMark *mark) void gtk_scale_clear_marks (GtkScale *scale) { - GtkScalePriv *priv; + GtkScalePrivate *priv; g_return_if_fail (GTK_IS_SCALE (scale)); @@ -1439,7 +1464,7 @@ gtk_scale_add_mark (GtkScale *scale, GtkPositionType position, const gchar *markup) { - GtkScalePriv *priv; + GtkScalePrivate *priv; GtkScaleMark *mark; GSList *m; gdouble *values; diff --git a/gtk/gtkscale.h b/gtk/gtkscale.h index b3ac39737a..7436b020e7 100644 --- a/gtk/gtkscale.h +++ b/gtk/gtkscale.h @@ -45,16 +45,16 @@ G_BEGIN_DECLS #define GTK_SCALE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_SCALE, GtkScaleClass)) -typedef struct _GtkScale GtkScale; -typedef struct _GtkScalePriv GtkScalePriv; -typedef struct _GtkScaleClass GtkScaleClass; +typedef struct _GtkScale GtkScale; +typedef struct _GtkScalePrivate GtkScalePrivate; +typedef struct _GtkScaleClass GtkScaleClass; struct _GtkScale { GtkRange range; /* <private> */ - GtkScalePriv *priv; + GtkScalePrivate *priv; }; struct _GtkScaleClass diff --git a/gtk/gtkscalebutton.c b/gtk/gtkscalebutton.c index 6e1cad9479..5905d91ac0 100644 --- a/gtk/gtkscalebutton.c +++ b/gtk/gtkscalebutton.c @@ -896,10 +896,12 @@ gtk_scale_popup (GtkWidget *widget, GdkEvent *event, guint32 time) { + GtkAllocation allocation, dock_allocation, scale_allocation; GtkScaleButton *button; GtkScaleButtonPrivate *priv; GtkAdjustment *adj; gint x, y, m, dx, dy, sx, sy, startoff; + gint min_slider_size; gdouble v; GdkDisplay *display; GdkScreen *screen; @@ -913,13 +915,15 @@ gtk_scale_popup (GtkWidget *widget, display = gtk_widget_get_display (widget); screen = gtk_widget_get_screen (widget); + gtk_widget_get_allocation (widget, &allocation); /* position roughly */ gtk_window_set_screen (GTK_WINDOW (priv->dock), screen); - gdk_window_get_origin (widget->window, &x, &y); - x += widget->allocation.x; - y += widget->allocation.y; + gdk_window_get_origin (gtk_widget_get_window (widget), + &x, &y); + x += allocation.x; + y += allocation.y; if (priv->orientation == GTK_ORIENTATION_VERTICAL) gtk_window_move (GTK_WINDOW (priv->dock), x, y - (SCALE_SIZE / 2)); @@ -928,28 +932,33 @@ gtk_scale_popup (GtkWidget *widget, gtk_widget_show_all (priv->dock); - gdk_window_get_origin (priv->dock->window, &dx, &dy); - dx += priv->dock->allocation.x; - dy += priv->dock->allocation.y; + gdk_window_get_origin (gtk_widget_get_window (priv->dock), + &dx, &dy); + gtk_widget_get_allocation (priv->dock, &dock_allocation); + dx += dock_allocation.x; + dy += dock_allocation.y; - gdk_window_get_origin (priv->scale->window, &sx, &sy); - sx += priv->scale->allocation.x; - sy += priv->scale->allocation.y; + + gdk_window_get_origin (gtk_widget_get_window (priv->scale), + &sx, &sy); + gtk_widget_get_allocation (priv->scale, &scale_allocation); + sx += scale_allocation.x; + sy += scale_allocation.y; priv->timeout = TRUE; /* position (needs widget to be shown already) */ v = gtk_scale_button_get_value (button) / (adj->upper - adj->lower); + min_slider_size = gtk_range_get_min_slider_size (GTK_RANGE (priv->scale)); if (priv->orientation == GTK_ORIENTATION_VERTICAL) { startoff = sy - dy; - x += (widget->allocation.width - priv->dock->allocation.width) / 2; + x += (allocation.width - dock_allocation.width) / 2; y -= startoff; - y -= GTK_RANGE (priv->scale)->min_slider_size / 2; - m = priv->scale->allocation.height - - GTK_RANGE (priv->scale)->min_slider_size; + y -= min_slider_size / 2; + m = scale_allocation.height - min_slider_size; y -= m * (1.0 - v); } else @@ -957,16 +966,16 @@ gtk_scale_popup (GtkWidget *widget, startoff = sx - dx; x -= startoff; - y += (widget->allocation.height - priv->dock->allocation.height) / 2; - x -= GTK_RANGE (priv->scale)->min_slider_size / 2; - m = priv->scale->allocation.width - - GTK_RANGE (priv->scale)->min_slider_size; + y += (allocation.height - dock_allocation.height) / 2; + x -= min_slider_size / 2; + m = scale_allocation.width - min_slider_size; x -= m * v; } /* Make sure the dock stays inside the monitor */ if (event->type == GDK_BUTTON_PRESS) { + GtkAllocation d_allocation; int monitor; GdkEventButton *button_event = (GdkEventButton *) event; GdkRectangle rect; @@ -986,14 +995,15 @@ gtk_scale_popup (GtkWidget *widget, /* Move the dock, but set is_moved so we * don't forward the first click later on, * as it could make the scale go to the bottom */ + gtk_widget_get_allocation (d, &d_allocation); if (y < rect.y) { y = rect.y; is_moved = TRUE; } - else if (y + d->allocation.height > rect.height + rect.y) + else if (y + d_allocation.height > rect.height + rect.y) { - y = rect.y + rect.height - d->allocation.height; + y = rect.y + rect.height - d_allocation.height; is_moved = TRUE; } @@ -1002,9 +1012,9 @@ gtk_scale_popup (GtkWidget *widget, x = rect.x; is_moved = TRUE; } - else if (x + d->allocation.width > rect.width + rect.x) + else if (x + d_allocation.width > rect.width + rect.x) { - x = rect.x + rect.width - d->allocation.width; + x = rect.x + rect.width - d_allocation.width; is_moved = TRUE; } } @@ -1030,7 +1040,7 @@ gtk_scale_popup (GtkWidget *widget, /* grab focus */ gtk_device_grab_add (priv->dock, pointer, TRUE); - if (gdk_device_grab (pointer, priv->dock->window, + if (gdk_device_grab (pointer, gtk_widget_get_window (priv->dock), GDK_OWNERSHIP_WINDOW, TRUE, GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK, NULL, time) != GDK_GRAB_SUCCESS) @@ -1040,7 +1050,7 @@ gtk_scale_popup (GtkWidget *widget, return FALSE; } - if (gdk_device_grab (keyboard, priv->dock->window, + if (gdk_device_grab (keyboard, gtk_widget_get_window (priv->dock), GDK_OWNERSHIP_WINDOW, TRUE, GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK, NULL, time) != GDK_GRAB_SUCCESS) @@ -1062,26 +1072,25 @@ gtk_scale_popup (GtkWidget *widget, /* forward event to the slider */ e = (GdkEventButton *) gdk_event_copy ((GdkEvent *) event); - e->window = priv->scale->window; + e->window = gtk_widget_get_window (priv->scale); /* position: the X position isn't relevant, halfway will work just fine. * The vertical position should be *exactly* in the middle of the slider * of the scale; if we don't do that correctly, it'll move from its current * position, which means a position change on-click, which is bad. */ + gtk_widget_get_allocation (priv->scale, &scale_allocation); if (priv->orientation == GTK_ORIENTATION_VERTICAL) { - e->x = priv->scale->allocation.width / 2; - m = priv->scale->allocation.height - - GTK_RANGE (priv->scale)->min_slider_size; - e->y = ((1.0 - v) * m) + GTK_RANGE (priv->scale)->min_slider_size / 2; + e->x = scale_allocation.width / 2; + m = scale_allocation.height - min_slider_size; + e->y = ((1.0 - v) * m) + min_slider_size / 2; } else { - e->y = priv->scale->allocation.height / 2; - m = priv->scale->allocation.width - - GTK_RANGE (priv->scale)->min_slider_size; - e->x = (v * m) + GTK_RANGE (priv->scale)->min_slider_size / 2; + e->y = scale_allocation.height / 2; + m = scale_allocation.width - min_slider_size; + e->x = (v * m) + min_slider_size / 2; } gtk_widget_event (priv->scale, (GdkEvent *) e); @@ -1319,7 +1328,7 @@ gtk_scale_button_release_grab (GtkScaleButton *button, priv->timeout = FALSE; e = (GdkEventButton *) gdk_event_copy ((GdkEvent *) event); - e->window = GTK_WIDGET (button)->window; + e->window = gtk_widget_get_window (GTK_WIDGET (button)); e->type = GDK_BUTTON_RELEASE; gtk_widget_event (GTK_WIDGET (button), (GdkEvent *) e); e->window = event->window; diff --git a/gtk/gtkscrollbar.c b/gtk/gtkscrollbar.c index 34ef5b60ce..ce41a231bd 100644 --- a/gtk/gtkscrollbar.c +++ b/gtk/gtkscrollbar.c @@ -113,13 +113,10 @@ gtk_scrollbar_style_set (GtkWidget *widget, "has-forward-stepper", &has_d, NULL); - range->min_slider_size = slider_length; - range->slider_size_fixed = fixed_size; - - range->has_stepper_a = has_a; - range->has_stepper_b = has_b; - range->has_stepper_c = has_c; - range->has_stepper_d = has_d; + gtk_range_set_min_slider_size (range, slider_length); + gtk_range_set_slider_size_fixed (range, fixed_size); + _gtk_range_set_steppers (range, + has_a, has_b, has_c, has_d); GTK_WIDGET_CLASS (gtk_scrollbar_parent_class)->style_set (widget, previous); } diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c index e769fdf5f3..e3ccbedf82 100644 --- a/gtk/gtkscrolledwindow.c +++ b/gtk/gtkscrolledwindow.c @@ -1045,19 +1045,24 @@ gtk_scrolled_window_paint (GtkWidget *widget, if (scrolled_window->shadow_type != GTK_SHADOW_NONE) { + GtkAllocation allocation; GtkAllocation relative_allocation; + GtkStyle *style; gboolean scrollbars_within_bevel; + style = gtk_widget_get_style (widget); gtk_widget_style_get (widget, "scrollbars-within-bevel", &scrollbars_within_bevel, NULL); - + + gtk_widget_get_allocation (widget, &allocation); + if (!scrollbars_within_bevel) { gtk_scrolled_window_relative_allocation (widget, &relative_allocation); - relative_allocation.x -= widget->style->xthickness; - relative_allocation.y -= widget->style->ythickness; - relative_allocation.width += 2 * widget->style->xthickness; - relative_allocation.height += 2 * widget->style->ythickness; + relative_allocation.x -= style->xthickness; + relative_allocation.y -= style->ythickness; + relative_allocation.width += 2 * style->xthickness; + relative_allocation.height += 2 * style->ythickness; } else { @@ -1068,15 +1073,16 @@ gtk_scrolled_window_paint (GtkWidget *widget, relative_allocation.x = border_width; relative_allocation.y = border_width; - relative_allocation.width = widget->allocation.width - 2 * border_width; - relative_allocation.height = widget->allocation.height - 2 * border_width; + relative_allocation.width = allocation.width - 2 * border_width; + relative_allocation.height = allocation.height - 2 * border_width; } - gtk_paint_shadow (widget->style, widget->window, + gtk_paint_shadow (style, + gtk_widget_get_window (widget), GTK_STATE_NORMAL, scrolled_window->shadow_type, area, widget, "scrolled_window", - widget->allocation.x + relative_allocation.x, - widget->allocation.y + relative_allocation.y, + allocation.x + relative_allocation.x, + allocation.y + relative_allocation.y, relative_allocation.width, relative_allocation.height); } @@ -1253,8 +1259,10 @@ static void gtk_scrolled_window_relative_allocation (GtkWidget *widget, GtkAllocation *allocation) { + GtkAllocation widget_allocation; GtkScrolledWindow *scrolled_window; GtkScrolledWindowPrivate *priv; + GtkStyle *style; gint scrollbar_spacing; guint border_width; @@ -1272,12 +1280,14 @@ gtk_scrolled_window_relative_allocation (GtkWidget *widget, if (scrolled_window->shadow_type != GTK_SHADOW_NONE) { - allocation->x += widget->style->xthickness; - allocation->y += widget->style->ythickness; + style = gtk_widget_get_style (widget); + allocation->x += style->xthickness; + allocation->y += style->ythickness; } - - allocation->width = MAX (1, (gint)widget->allocation.width - allocation->x * 2); - allocation->height = MAX (1, (gint)widget->allocation.height - allocation->y * 2); + + gtk_widget_get_allocation (widget, &widget_allocation); + allocation->width = MAX (1, (gint) widget_allocation.width - allocation->x * 2); + allocation->height = MAX (1, (gint) widget_allocation.height - allocation->y * 2); if (scrolled_window->vscrollbar_visible) { @@ -1318,6 +1328,7 @@ gtk_scrolled_window_size_allocate (GtkWidget *widget, { GtkScrolledWindow *scrolled_window; GtkScrolledWindowPrivate *priv; + GtkStyle *style; GtkBin *bin; GtkAllocation relative_allocation; GtkAllocation child_allocation; @@ -1333,12 +1344,15 @@ gtk_scrolled_window_size_allocate (GtkWidget *widget, bin = GTK_BIN (scrolled_window); scrollbar_spacing = _gtk_scrolled_window_get_scrollbar_spacing (scrolled_window); + + style = gtk_widget_get_style (widget); gtk_widget_style_get (widget, "scrollbars-within-bevel", &scrollbars_within_bevel, NULL); priv = GTK_SCROLLED_WINDOW_GET_PRIVATE (scrolled_window); border_width = gtk_container_get_border_width (GTK_CONTAINER (scrolled_window)); - widget->allocation = *allocation; + + gtk_widget_set_allocation (widget, allocation); if (scrolled_window->hscrollbar_policy == GTK_POLICY_ALWAYS) scrolled_window->hscrollbar_visible = TRUE; @@ -1414,7 +1428,7 @@ gtk_scrolled_window_size_allocate (GtkWidget *widget, relative_allocation.height + scrollbar_spacing + (scrolled_window->shadow_type == GTK_SHADOW_NONE ? - 0 : widget->style->ythickness)); + 0 : style->ythickness)); else child_allocation.y = border_width; @@ -1427,17 +1441,17 @@ gtk_scrolled_window_size_allocate (GtkWidget *widget, { if (!scrollbars_within_bevel) { - child_allocation.x -= widget->style->xthickness; - child_allocation.width += 2 * widget->style->xthickness; + child_allocation.x -= style->xthickness; + child_allocation.width += 2 * style->xthickness; } else if (GTK_CORNER_TOP_RIGHT == priv->real_window_placement || GTK_CORNER_TOP_LEFT == priv->real_window_placement) { - child_allocation.y -= widget->style->ythickness; + child_allocation.y -= style->ythickness; } else { - child_allocation.y += widget->style->ythickness; + child_allocation.y += style->ythickness; } } @@ -1465,7 +1479,7 @@ gtk_scrolled_window_size_allocate (GtkWidget *widget, relative_allocation.width + scrollbar_spacing + (scrolled_window->shadow_type == GTK_SHADOW_NONE ? - 0 : widget->style->xthickness)); + 0 : style->xthickness)); else child_allocation.x = border_width; @@ -1479,17 +1493,17 @@ gtk_scrolled_window_size_allocate (GtkWidget *widget, { if (!scrollbars_within_bevel) { - child_allocation.y -= widget->style->ythickness; - child_allocation.height += 2 * widget->style->ythickness; + child_allocation.y -= style->ythickness; + child_allocation.height += 2 * style->ythickness; } else if (GTK_CORNER_BOTTOM_LEFT == priv->real_window_placement || GTK_CORNER_TOP_LEFT == priv->real_window_placement) { - child_allocation.x -= widget->style->xthickness; + child_allocation.x -= style->xthickness; } else { - child_allocation.x += widget->style->xthickness; + child_allocation.x += style->xthickness; } } @@ -1515,7 +1529,7 @@ gtk_scrolled_window_scroll_event (GtkWidget *widget, if (range && gtk_widget_get_visible (range)) { - GtkAdjustment *adj = GTK_RANGE (range)->adjustment; + GtkAdjustment *adj = gtk_range_get_adjustment (GTK_RANGE (range)); gdouble delta; delta = _gtk_range_get_wheel_delta (GTK_RANGE (range), event->direction); @@ -1679,7 +1693,7 @@ gtk_scrolled_window_add_with_viewport (GtkScrolledWindow *scrolled_window, g_return_if_fail (GTK_IS_SCROLLED_WINDOW (scrolled_window)); g_return_if_fail (GTK_IS_WIDGET (child)); - g_return_if_fail (child->parent == NULL); + g_return_if_fail (gtk_widget_get_parent (child) == NULL); bin = GTK_BIN (scrolled_window); child_widget = gtk_bin_get_child (bin); @@ -1756,6 +1770,7 @@ gtk_scrolled_window_get_width (GtkSizeRequest *widget, GtkScrolledWindow *scrolled_window; GtkRequisition hscrollbar_requisition; GtkRequisition vscrollbar_requisition; + GtkStyle *style; GtkWidget *child; gint min_width, nat_width; gint min_child_size, nat_child_size; @@ -1825,8 +1840,9 @@ gtk_scrolled_window_get_width (GtkSizeRequest *widget, if (scrolled_window->shadow_type != GTK_SHADOW_NONE) { - min_width += 2 * GTK_WIDGET (widget)->style->xthickness; - nat_width += 2 * GTK_WIDGET (widget)->style->xthickness; + style = gtk_widget_get_style (GTK_WIDGET (widget)); + min_width += 2 * style->xthickness; + nat_width += 2 * style->xthickness; } if (minimum_size) @@ -1844,6 +1860,7 @@ gtk_scrolled_window_get_height (GtkSizeRequest *widget, GtkRequisition hscrollbar_requisition; GtkRequisition vscrollbar_requisition; GtkWidget *child; + GtkStyle *style; gint min_height, nat_height; gint min_child_size, nat_child_size; gint extra_height, border_width; @@ -1912,8 +1929,9 @@ gtk_scrolled_window_get_height (GtkSizeRequest *widget, if (scrolled_window->shadow_type != GTK_SHADOW_NONE) { - min_height += 2 * GTK_WIDGET (widget)->style->ythickness; - nat_height += 2 * GTK_WIDGET (widget)->style->ythickness; + style = gtk_widget_get_style (GTK_WIDGET (widget)); + min_height += 2 * style->ythickness; + nat_height += 2 * style->ythickness; } if (minimum_size) diff --git a/gtk/gtkselection.c b/gtk/gtkselection.c index 2e34884596..d7a2f45e1b 100644 --- a/gtk/gtkselection.c +++ b/gtk/gtkselection.c @@ -664,7 +664,7 @@ gtk_selection_owner_set_for_display (GdkDisplay *display, if (widget == NULL) window = NULL; else - window = widget->window; + window = gtk_widget_get_window (widget); tmp_list = current_selections; while (tmp_list) @@ -719,8 +719,8 @@ gtk_selection_owner_set_for_display (GdkDisplay *display, if (old_owner && old_owner != widget) { GdkEvent *event = gdk_event_new (GDK_SELECTION_CLEAR); - - event->selection.window = g_object_ref (old_owner->window); + + event->selection.window = g_object_ref (gtk_widget_get_window (old_owner)); event->selection.selection = selection; event->selection.time = time; @@ -1103,7 +1103,7 @@ gtk_selection_convert (GtkWidget *widget, /* Otherwise, we need to go through X */ current_retrievals = g_list_append (current_retrievals, info); - gdk_selection_convert (widget->window, selection, target, time_); + gdk_selection_convert (gtk_widget_get_window (widget), selection, target, time_); gdk_threads_add_timeout (1000, (GSourceFunc) gtk_selection_retrieval_timeout, info); @@ -2670,21 +2670,24 @@ gtk_selection_incr_timeout (GtkIncrInfo *info) *************************************************************/ gboolean -_gtk_selection_notify (GtkWidget *widget, +_gtk_selection_notify (GtkWidget *widget, GdkEventSelection *event) { GList *tmp_list; GtkRetrievalInfo *info = NULL; + GdkWindow *window; guchar *buffer = NULL; gint length; GdkAtom type; gint format; - + #ifdef DEBUG_SELECTION g_message ("Initial receipt of selection %ld, target %ld (property = %ld)", event->selection, event->target, event->property); #endif - + + window = gtk_widget_get_window (widget); + tmp_list = current_retrievals; while (tmp_list) { @@ -2698,7 +2701,7 @@ _gtk_selection_notify (GtkWidget *widget, return FALSE; if (event->property != GDK_NONE) - length = gdk_selection_property_get (widget->window, &buffer, + length = gdk_selection_property_get (window, &buffer, &type, &format); else length = 0; /* silence gcc */ @@ -2722,8 +2725,8 @@ _gtk_selection_notify (GtkWidget *widget, info->notify_time = event->time; info->idle_time = 0; info->offset = 0; /* Mark as OK to proceed */ - gdk_window_set_events (widget->window, - gdk_window_get_events (widget->window) + gdk_window_set_events (window, + gdk_window_get_events (window) | GDK_PROPERTY_CHANGE_MASK); } else @@ -2737,9 +2740,9 @@ _gtk_selection_notify (GtkWidget *widget, type, format, buffer, length, event->time); } - - gdk_property_delete (widget->window, event->property); - + + gdk_property_delete (window, event->property); + g_free (buffer); return TRUE; @@ -2764,6 +2767,7 @@ _gtk_selection_property_notify (GtkWidget *widget, { GList *tmp_list; GtkRetrievalInfo *info = NULL; + GdkWindow *window; guchar *new_buffer; int length; GdkAtom type; @@ -2800,11 +2804,12 @@ _gtk_selection_property_notify (GtkWidget *widget, return FALSE; info->idle_time = 0; - - length = gdk_selection_property_get (widget->window, &new_buffer, + + window = gtk_widget_get_window (widget); + length = gdk_selection_property_get (window, &new_buffer, &type, &format); - gdk_property_delete (widget->window, event->atom); - + gdk_property_delete (window, event->atom); + /* We could do a lot better efficiency-wise by paying attention to what length was sent in the initial INCR transaction, instead of doing memory allocation at every step. But its only guaranteed to diff --git a/gtk/gtkseparator.c b/gtk/gtkseparator.c index 45e93f3fb8..43f9ae5c9b 100644 --- a/gtk/gtkseparator.c +++ b/gtk/gtkseparator.c @@ -42,21 +42,16 @@ */ -enum { - PROP_0, - PROP_ORIENTATION -}; - - -typedef struct _GtkSeparatorPrivate GtkSeparatorPrivate; - struct _GtkSeparatorPrivate { GtkOrientation orientation; }; -#define GTK_SEPARATOR_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_SEPARATOR, GtkSeparatorPrivate)) +enum { + PROP_0, + PROP_ORIENTATION +}; static void gtk_separator_set_property (GObject *object, guint prop_id, @@ -101,7 +96,12 @@ static void gtk_separator_init (GtkSeparator *separator) { GtkWidget *widget = GTK_WIDGET (separator); - GtkSeparatorPrivate *private = GTK_SEPARATOR_GET_PRIVATE (separator); + GtkSeparatorPrivate *private; + + separator->priv = G_TYPE_INSTANCE_GET_PRIVATE (separator, + GTK_TYPE_SEPARATOR, + GtkSeparatorPrivate); + private = separator->priv; gtk_widget_set_has_window (GTK_WIDGET (separator), FALSE); @@ -117,7 +117,8 @@ gtk_separator_set_property (GObject *object, const GValue *value, GParamSpec *pspec) { - GtkSeparatorPrivate *private = GTK_SEPARATOR_GET_PRIVATE (object); + GtkSeparator *separator = GTK_SEPARATOR (object); + GtkSeparatorPrivate *private = separator->priv; switch (prop_id) { @@ -137,7 +138,8 @@ gtk_separator_get_property (GObject *object, GValue *value, GParamSpec *pspec) { - GtkSeparatorPrivate *private = GTK_SEPARATOR_GET_PRIVATE (object); + GtkSeparator *separator = GTK_SEPARATOR (object); + GtkSeparatorPrivate *private = separator->priv; switch (prop_id) { @@ -154,7 +156,8 @@ static void gtk_separator_size_request (GtkWidget *widget, GtkRequisition *requisition) { - GtkSeparatorPrivate *private = GTK_SEPARATOR_GET_PRIVATE (widget); + GtkSeparator *separator = GTK_SEPARATOR (widget); + GtkSeparatorPrivate *private = separator->priv; gboolean wide_separators; gint separator_width; gint separator_height; @@ -188,7 +191,8 @@ static gboolean gtk_separator_expose (GtkWidget *widget, GdkEventExpose *event) { - GtkSeparatorPrivate *private = GTK_SEPARATOR_GET_PRIVATE (widget); + GtkSeparator *separator = GTK_SEPARATOR (widget); + GtkSeparatorPrivate *private = separator->priv; gboolean wide_separators; gint separator_width; gint separator_height; diff --git a/gtk/gtkseparator.h b/gtk/gtkseparator.h index 6b3e519395..64096cd3e4 100644 --- a/gtk/gtkseparator.h +++ b/gtk/gtkseparator.h @@ -45,12 +45,15 @@ G_BEGIN_DECLS #define GTK_SEPARATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_SEPARATOR, GtkSeparatorClass)) -typedef struct _GtkSeparator GtkSeparator; -typedef struct _GtkSeparatorClass GtkSeparatorClass; +typedef struct _GtkSeparator GtkSeparator; +typedef struct _GtkSeparatorPrivate GtkSeparatorPrivate; +typedef struct _GtkSeparatorClass GtkSeparatorClass; struct _GtkSeparator { GtkWidget widget; + + GtkSeparatorPrivate *priv; }; struct _GtkSeparatorClass diff --git a/gtk/gtkseparatortoolitem.c b/gtk/gtkseparatortoolitem.c index e5a04dba6a..a26dd4f127 100644 --- a/gtk/gtkseparatortoolitem.c +++ b/gtk/gtkseparatortoolitem.c @@ -89,8 +89,10 @@ static gint get_space_size (GtkToolItem *tool_item) { gint space_size = _gtk_toolbar_get_default_space_size(); - GtkWidget *parent = GTK_WIDGET (tool_item)->parent; - + GtkWidget *parent; + + parent = gtk_widget_get_parent (GTK_WIDGET (tool_item)); + if (GTK_IS_TOOLBAR (parent)) { gtk_widget_style_get (parent, @@ -236,32 +238,36 @@ gtk_separator_tool_item_size_allocate (GtkWidget *widget, GtkSeparatorToolItem *separator = GTK_SEPARATOR_TOOL_ITEM (widget); GtkSeparatorToolItemPrivate *priv = separator->priv; - widget->allocation = *allocation; + gtk_widget_set_allocation (widget, allocation); if (gtk_widget_get_realized (widget)) gdk_window_move_resize (priv->event_window, - widget->allocation.x, - widget->allocation.y, - widget->allocation.width, - widget->allocation.height); + allocation->x, + allocation->y, + allocation->width, + allocation->height); } static void gtk_separator_tool_item_realize (GtkWidget *widget) { + GtkAllocation allocation; GtkSeparatorToolItem *separator = GTK_SEPARATOR_TOOL_ITEM (widget); GtkSeparatorToolItemPrivate *priv = separator->priv; + GdkWindow *window; GdkWindowAttr attributes; gint attributes_mask; gtk_widget_set_realized (widget, TRUE); + gtk_widget_get_allocation (widget, &allocation); + attributes.window_type = GDK_WINDOW_CHILD; - attributes.x = widget->allocation.x; - attributes.y = widget->allocation.y; - attributes.width = widget->allocation.width; - attributes.height = widget->allocation.height; + attributes.x = allocation.x; + attributes.y = allocation.y; + attributes.width = allocation.width; + attributes.height = allocation.height; attributes.wclass = GDK_INPUT_ONLY; attributes.visual = gtk_widget_get_visual (widget); attributes.colormap = gtk_widget_get_colormap (widget); @@ -270,14 +276,15 @@ gtk_separator_tool_item_realize (GtkWidget *widget) GDK_BUTTON_RELEASE_MASK; attributes_mask = GDK_WA_X | GDK_WA_Y; - widget->window = gtk_widget_get_parent_window (widget); - g_object_ref (widget->window); + window = gtk_widget_get_parent_window (widget); + gtk_widget_set_window (widget, window); + g_object_ref (window); priv->event_window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); gdk_window_set_user_data (priv->event_window, widget); - widget->style = gtk_style_attach (widget->style, widget->window); + gtk_widget_style_attach (widget); } static void @@ -337,17 +344,21 @@ static gboolean gtk_separator_tool_item_expose (GtkWidget *widget, GdkEventExpose *event) { + GtkAllocation allocation; GtkToolbar *toolbar = NULL; GtkSeparatorToolItem *separator = GTK_SEPARATOR_TOOL_ITEM (widget); GtkSeparatorToolItemPrivate *priv = separator->priv; + GtkWidget *parent; if (priv->draw) { - if (GTK_IS_TOOLBAR (widget->parent)) - toolbar = GTK_TOOLBAR (widget->parent); + parent = gtk_widget_get_parent (widget); + if (GTK_IS_TOOLBAR (parent)) + toolbar = GTK_TOOLBAR (parent); + gtk_widget_get_allocation (widget, &allocation); _gtk_toolbar_paint_space_line (widget, toolbar, - &(event->area), &widget->allocation); + &(event->area), &allocation); } return FALSE; diff --git a/gtk/gtksizegroup.c b/gtk/gtksizegroup.c index c1a8feb0f9..87f5c48584 100644 --- a/gtk/gtksizegroup.c +++ b/gtk/gtksizegroup.c @@ -29,7 +29,7 @@ -struct _GtkSizeGroupPriv +struct _GtkSizeGroupPrivate { GtkRequisition requisition; @@ -138,7 +138,7 @@ add_group_to_closure (GtkSizeGroup *group, GSList **groups, GSList **widgets) { - GtkSizeGroupPriv *priv = group->priv; + GtkSizeGroupPrivate *priv = group->priv; GSList *tmp_widgets; *groups = g_slist_prepend (*groups, group); @@ -171,7 +171,7 @@ add_widget_to_closure (GtkWidget *widget, while (tmp_groups) { GtkSizeGroup *tmp_group = tmp_groups->data; - GtkSizeGroupPriv *tmp_priv = tmp_group->priv; + GtkSizeGroupPrivate *tmp_priv = tmp_group->priv; if ((tmp_priv->mode == GTK_SIZE_GROUP_BOTH || tmp_priv->mode == mode) && !is_visited (tmp_group)) @@ -184,13 +184,16 @@ add_widget_to_closure (GtkWidget *widget, static void real_queue_resize (GtkWidget *widget) { + GtkWidget *parent; + GTK_PRIVATE_SET_FLAG (widget, GTK_ALLOC_NEEDED); GTK_PRIVATE_SET_FLAG (widget, GTK_REQUEST_NEEDED); GTK_PRIVATE_SET_FLAG (widget, GTK_WIDTH_REQUEST_NEEDED); GTK_PRIVATE_SET_FLAG (widget, GTK_HEIGHT_REQUEST_NEEDED); - - if (widget->parent) - _gtk_container_queue_resize (GTK_CONTAINER (widget->parent)); + + parent = gtk_widget_get_parent (widget); + if (parent) + _gtk_container_queue_resize (GTK_CONTAINER (parent)); else if (gtk_widget_is_toplevel (widget) && GTK_IS_CONTAINER (widget)) _gtk_container_queue_resize (GTK_CONTAINER (widget)); } @@ -202,7 +205,7 @@ reset_group_sizes (GSList *groups) while (tmp_list) { GtkSizeGroup *tmp_group = tmp_list->data; - GtkSizeGroupPriv *tmp_priv = tmp_group->priv; + GtkSizeGroupPrivate *tmp_priv = tmp_group->priv; tmp_priv->have_width = FALSE; tmp_priv->have_height = FALSE; @@ -227,7 +230,7 @@ queue_resize_on_widget (GtkWidget *widget, if (widget == parent && !check_siblings) { real_queue_resize (widget); - parent = parent->parent; + parent = gtk_widget_get_parent (parent); continue; } @@ -237,7 +240,7 @@ queue_resize_on_widget (GtkWidget *widget, if (widget == parent) real_queue_resize (widget); - parent = parent->parent; + parent = gtk_widget_get_parent (parent); continue; } @@ -300,15 +303,15 @@ queue_resize_on_widget (GtkWidget *widget, g_slist_free (widgets); g_slist_free (groups); - - parent = parent->parent; + + parent = gtk_widget_get_parent (parent); } } static void queue_resize_on_group (GtkSizeGroup *size_group) { - GtkSizeGroupPriv *priv = size_group->priv; + GtkSizeGroupPrivate *priv = size_group->priv; if (priv->widgets) queue_resize_on_widget (priv->widgets->data, TRUE); @@ -359,7 +362,7 @@ gtk_size_group_class_init (GtkSizeGroupClass *klass) FALSE, GTK_PARAM_READWRITE)); - g_type_class_add_private (klass, sizeof (GtkSizeGroupPriv)); + g_type_class_add_private (klass, sizeof (GtkSizeGroupPrivate)); initialize_size_group_quarks (); } @@ -367,11 +370,11 @@ gtk_size_group_class_init (GtkSizeGroupClass *klass) static void gtk_size_group_init (GtkSizeGroup *size_group) { - GtkSizeGroupPriv *priv; + GtkSizeGroupPrivate *priv; size_group->priv = G_TYPE_INSTANCE_GET_PRIVATE (size_group, GTK_TYPE_SIZE_GROUP, - GtkSizeGroupPriv); + GtkSizeGroupPrivate); priv = size_group->priv; priv->widgets = NULL; @@ -421,7 +424,7 @@ gtk_size_group_get_property (GObject *object, GParamSpec *pspec) { GtkSizeGroup *size_group = GTK_SIZE_GROUP (object); - GtkSizeGroupPriv *priv = size_group->priv; + GtkSizeGroupPrivate *priv = size_group->priv; switch (prop_id) { @@ -449,7 +452,7 @@ GtkSizeGroup * gtk_size_group_new (GtkSizeGroupMode mode) { GtkSizeGroup *size_group = g_object_new (GTK_TYPE_SIZE_GROUP, NULL); - GtkSizeGroupPriv *priv = size_group->priv; + GtkSizeGroupPrivate *priv = size_group->priv; priv->mode = mode; @@ -472,7 +475,7 @@ void gtk_size_group_set_mode (GtkSizeGroup *size_group, GtkSizeGroupMode mode) { - GtkSizeGroupPriv *priv; + GtkSizeGroupPrivate *priv; g_return_if_fail (GTK_IS_SIZE_GROUP (size_group)); @@ -521,7 +524,7 @@ void gtk_size_group_set_ignore_hidden (GtkSizeGroup *size_group, gboolean ignore_hidden) { - GtkSizeGroupPriv *priv; + GtkSizeGroupPrivate *priv; g_return_if_fail (GTK_IS_SIZE_GROUP (size_group)); @@ -580,7 +583,7 @@ void gtk_size_group_add_widget (GtkSizeGroup *size_group, GtkWidget *widget) { - GtkSizeGroupPriv *priv; + GtkSizeGroupPrivate *priv; GSList *groups; g_return_if_fail (GTK_IS_SIZE_GROUP (size_group)); @@ -618,7 +621,7 @@ void gtk_size_group_remove_widget (GtkSizeGroup *size_group, GtkWidget *widget) { - GtkSizeGroupPriv *priv; + GtkSizeGroupPrivate *priv; GSList *groups; g_return_if_fail (GTK_IS_SIZE_GROUP (size_group)); @@ -720,7 +723,7 @@ compute_dimension (GtkWidget *widget, else { GtkSizeGroup *group = groups->data; - GtkSizeGroupPriv *priv = group->priv; + GtkSizeGroupPrivate *priv = group->priv; if (mode == GTK_SIZE_GROUP_HORIZONTAL && priv->have_width) result = priv->requisition.width; @@ -752,7 +755,7 @@ compute_dimension (GtkWidget *widget, while (tmp_list) { GtkSizeGroup *tmp_group = tmp_list->data; - GtkSizeGroupPriv *tmp_priv = tmp_group->priv; + GtkSizeGroupPrivate *tmp_priv = tmp_group->priv; if (mode == GTK_SIZE_GROUP_HORIZONTAL) { diff --git a/gtk/gtksizegroup.h b/gtk/gtksizegroup.h index ec39c710d8..a014881ce5 100644 --- a/gtk/gtksizegroup.h +++ b/gtk/gtksizegroup.h @@ -37,16 +37,16 @@ G_BEGIN_DECLS #define GTK_SIZE_GROUP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_SIZE_GROUP, GtkSizeGroupClass)) -typedef struct _GtkSizeGroup GtkSizeGroup; -typedef struct _GtkSizeGroupPriv GtkSizeGroupPriv; -typedef struct _GtkSizeGroupClass GtkSizeGroupClass; +typedef struct _GtkSizeGroup GtkSizeGroup; +typedef struct _GtkSizeGroupPrivate GtkSizeGroupPrivate; +typedef struct _GtkSizeGroupClass GtkSizeGroupClass; struct _GtkSizeGroup { GObject parent_instance; /* <private> */ - GtkSizeGroupPriv *priv; + GtkSizeGroupPrivate *priv; }; struct _GtkSizeGroupClass diff --git a/gtk/gtksizerequest.c b/gtk/gtksizerequest.c index 908cc39be0..02d2e79cb5 100644 --- a/gtk/gtksizerequest.c +++ b/gtk/gtksizerequest.c @@ -121,26 +121,19 @@ typedef struct { static GQuark quark_cache = 0; -GType -gtk_size_request_get_type (void) -{ - static GType size_request_type = 0; - - if (G_UNLIKELY(!size_request_type)) - { - size_request_type = - g_type_register_static_simple (G_TYPE_INTERFACE, I_("GtkSizeRequest"), - sizeof (GtkSizeRequestIface), - NULL, 0, NULL, 0); - - g_type_interface_add_prerequisite (size_request_type, GTK_TYPE_WIDGET); +typedef GtkSizeRequestIface GtkSizeRequestInterface; +G_DEFINE_INTERFACE_WITH_CODE (GtkSizeRequest, + gtk_size_request, + GTK_TYPE_WIDGET, + quark_cache = g_quark_from_static_string ("gtk-size-request-cache")); - quark_cache = g_quark_from_static_string ("gtk-size-request-cache"); - } - return size_request_type; +static void +gtk_size_request_default_init (GtkSizeRequestInterface *iface) +{ } + /* looks for a cached size request for this for_size. If not * found, returns the oldest entry so it can be overwritten * diff --git a/gtk/gtksocket-x11.c b/gtk/gtksocket-x11.c index 9dd9aec67b..d1f4dc8c66 100644 --- a/gtk/gtksocket-x11.c +++ b/gtk/gtksocket-x11.c @@ -57,15 +57,17 @@ static gboolean xembed_get_info (GdkWindow *gdk_window, GdkNativeWindow _gtk_socket_windowing_get_id (GtkSocket *socket) { - return GDK_WINDOW_XWINDOW (GTK_WIDGET (socket)->window); + return GDK_WINDOW_XWINDOW (gtk_widget_get_window (GTK_WIDGET (socket))); } void _gtk_socket_windowing_realize_window (GtkSocket *socket) { - GdkWindow *window = GTK_WIDGET (socket)->window; + GdkWindow *window; XWindowAttributes xattrs; + window = gtk_widget_get_window (GTK_WIDGET (socket)); + XGetWindowAttributes (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XWINDOW (window), &xattrs); @@ -267,6 +269,7 @@ _gtk_socket_windowing_focus (GtkSocket *socket, void _gtk_socket_windowing_send_configure_event (GtkSocket *socket) { + GtkAllocation allocation; XConfigureEvent xconfigure; gint x, y; @@ -285,11 +288,12 @@ _gtk_socket_windowing_send_configure_event (GtkSocket *socket) gdk_error_trap_push (); gdk_window_get_origin (socket->plug_window, &x, &y); gdk_error_trap_pop (); - + + gtk_widget_get_allocation (GTK_WIDGET(socket), &allocation); xconfigure.x = x; xconfigure.y = y; - xconfigure.width = GTK_WIDGET(socket)->allocation.width; - xconfigure.height = GTK_WIDGET(socket)->allocation.height; + xconfigure.width = allocation.width; + xconfigure.height = allocation.height; xconfigure.border_width = 0; xconfigure.above = None; @@ -342,7 +346,7 @@ _gtk_socket_windowing_embed_notify (GtkSocket *socket) #endif _gtk_xembed_send_message (socket->plug_window, XEMBED_EMBEDDED_NOTIFY, 0, - GDK_WINDOW_XWINDOW (GTK_WIDGET (socket)->window), + GDK_WINDOW_XWINDOW (gtk_widget_get_window (GTK_WIDGET (socket))), socket->xembed_version); } @@ -667,10 +671,14 @@ _gtk_socket_windowing_filter_func (GdkXEvent *gdk_xevent, break; case ReparentNotify: { + GdkWindow *window; XReparentEvent *xre = &xevent->xreparent; + window = gtk_widget_get_window (widget); + GTK_NOTE (PLUGSOCKET, g_message ("GtkSocket - ReparentNotify received")); - if (!socket->plug_window && xre->parent == GDK_WINDOW_XWINDOW (widget->window)) + if (!socket->plug_window && + xre->parent == GDK_WINDOW_XWINDOW (window)) { _gtk_socket_add_window (socket, xre->window, FALSE); @@ -683,7 +691,9 @@ _gtk_socket_windowing_filter_func (GdkXEvent *gdk_xevent, } else { - if (socket->plug_window && xre->window == GDK_WINDOW_XWINDOW (socket->plug_window) && xre->parent != GDK_WINDOW_XWINDOW (widget->window)) + if (socket->plug_window && + xre->window == GDK_WINDOW_XWINDOW (socket->plug_window) && + xre->parent != GDK_WINDOW_XWINDOW (window)) { gboolean result; diff --git a/gtk/gtksocket.c b/gtk/gtksocket.c index 68a600162c..381665d3b9 100644 --- a/gtk/gtksocket.c +++ b/gtk/gtksocket.c @@ -382,17 +382,21 @@ gtk_socket_get_plug_window (GtkSocket *socket) static void gtk_socket_realize (GtkWidget *widget) { + GtkAllocation allocation; GtkSocket *socket = GTK_SOCKET (widget); + GdkWindow *window; GdkWindowAttr attributes; gint attributes_mask; gtk_widget_set_realized (widget, TRUE); + gtk_widget_get_allocation (widget, &allocation); + attributes.window_type = GDK_WINDOW_CHILD; - attributes.x = widget->allocation.x; - attributes.y = widget->allocation.y; - attributes.width = widget->allocation.width; - attributes.height = widget->allocation.height; + attributes.x = allocation.x; + attributes.y = allocation.y; + attributes.width = allocation.width; + attributes.height = allocation.height; attributes.wclass = GDK_INPUT_OUTPUT; attributes.visual = gtk_widget_get_visual (widget); attributes.colormap = gtk_widget_get_colormap (widget); @@ -400,16 +404,18 @@ gtk_socket_realize (GtkWidget *widget) attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; - widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), - &attributes, attributes_mask); - gdk_window_set_user_data (widget->window, socket); + window = gdk_window_new (gtk_widget_get_parent_window (widget), + &attributes, attributes_mask); + gtk_widget_set_window (widget, window); + gdk_window_set_user_data (window, socket); - widget->style = gtk_style_attach (widget->style, widget->window); - gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL); + gtk_widget_style_attach (widget); + gtk_style_set_background (gtk_widget_get_style (widget), + window, GTK_STATE_NORMAL); _gtk_socket_windowing_realize_window (socket); - gdk_window_add_filter (widget->window, + gdk_window_add_filter (window, _gtk_socket_windowing_filter_func, widget); @@ -498,10 +504,10 @@ gtk_socket_size_allocate (GtkWidget *widget, { GtkSocket *socket = GTK_SOCKET (widget); - widget->allocation = *allocation; + gtk_widget_set_allocation (widget, allocation); if (gtk_widget_get_realized (widget)) { - gdk_window_move_resize (widget->window, + gdk_window_move_resize (gtk_widget_get_window (widget), allocation->x, allocation->y, allocation->width, allocation->height); @@ -663,7 +669,7 @@ socket_update_focus_in (GtkSocket *socket) GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (socket)); if (gtk_widget_is_toplevel (toplevel) && - GTK_WINDOW (toplevel)->has_toplevel_focus && + gtk_window_has_toplevel_focus (GTK_WINDOW (toplevel)) && gtk_widget_is_focus (GTK_WIDGET (socket))) focus_in = TRUE; } @@ -686,7 +692,7 @@ socket_update_active (GtkSocket *socket) GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (socket)); if (gtk_widget_is_toplevel (toplevel) && - GTK_WINDOW (toplevel)->is_active) + gtk_window_is_active (GTK_WINDOW (toplevel))) active = TRUE; } @@ -914,7 +920,9 @@ _gtk_socket_add_window (GtkSocket *socket, if (need_reparent) { gdk_window_hide (socket->plug_window); /* Shouldn't actually be necessary for XEMBED, but just in case */ - gdk_window_reparent (socket->plug_window, widget->window, 0, 0); + gdk_window_reparent (socket->plug_window, + gtk_widget_get_window (widget), + 0, 0); } socket->have_size = FALSE; @@ -1005,6 +1013,7 @@ _gtk_socket_advance_toplevel_focus (GtkSocket *socket, GtkWindow *window; GtkContainer *container; GtkWidget *child; + GtkWidget *focus_widget; GtkWidget *toplevel; GtkWidget *old_focus_child; GtkWidget *parent; @@ -1042,14 +1051,15 @@ _gtk_socket_advance_toplevel_focus (GtkSocket *socket, _gtk_socket_windowing_embed_set_focus_wrapped (); } - if (window->focus_widget) + focus_widget = gtk_window_get_focus (window); + if (window) { /* Wrapped off the end, clear the focus setting for the toplevel */ - parent = window->focus_widget->parent; + parent = gtk_widget_get_parent (focus_widget); while (parent) { gtk_container_set_focus_child (GTK_CONTAINER (parent), NULL); - parent = GTK_WIDGET (parent)->parent; + parent = gtk_widget_get_parent (parent); } gtk_window_set_focus (GTK_WINDOW (container), NULL); diff --git a/gtk/gtkspinbutton.c b/gtk/gtkspinbutton.c index 330f3277ce..19b00291e6 100644 --- a/gtk/gtkspinbutton.c +++ b/gtk/gtkspinbutton.c @@ -50,7 +50,7 @@ #define MIN_ARROW_WIDTH 6 -struct _GtkSpinButtonPriv +struct _GtkSpinButtonPrivate { GtkSpinButtonUpdatePolicy update_policy; GtkAdjustment *adjustment; @@ -400,7 +400,7 @@ gtk_spin_button_class_init (GtkSpinButtonClass *class) add_spin_binding (binding_set, GDK_Page_Up, GDK_CONTROL_MASK, GTK_SCROLL_END); add_spin_binding (binding_set, GDK_Page_Down, GDK_CONTROL_MASK, GTK_SCROLL_START); - g_type_class_add_private (class, sizeof (GtkSpinButtonPriv)); + g_type_class_add_private (class, sizeof (GtkSpinButtonPrivate)); } static void @@ -416,7 +416,7 @@ gtk_spin_button_set_property (GObject *object, GParamSpec *pspec) { GtkSpinButton *spin_button = GTK_SPIN_BUTTON (object); - GtkSpinButtonPriv *priv = spin_button->priv; + GtkSpinButtonPrivate *priv = spin_button->priv; switch (prop_id) { @@ -468,7 +468,7 @@ gtk_spin_button_get_property (GObject *object, GParamSpec *pspec) { GtkSpinButton *spin_button = GTK_SPIN_BUTTON (object); - GtkSpinButtonPriv *priv = spin_button->priv; + GtkSpinButtonPrivate *priv = spin_button->priv; switch (prop_id) { @@ -505,11 +505,11 @@ gtk_spin_button_get_property (GObject *object, static void gtk_spin_button_init (GtkSpinButton *spin_button) { - GtkSpinButtonPriv *priv; + GtkSpinButtonPrivate *priv; spin_button->priv = G_TYPE_INSTANCE_GET_PRIVATE (spin_button, GTK_TYPE_SPIN_BUTTON, - GtkSpinButtonPriv); + GtkSpinButtonPrivate); priv = spin_button->priv; priv->adjustment = NULL; @@ -552,7 +552,7 @@ static void gtk_spin_button_map (GtkWidget *widget) { GtkSpinButton *spin_button = GTK_SPIN_BUTTON (widget); - GtkSpinButtonPriv *priv = spin_button->priv; + GtkSpinButtonPrivate *priv = spin_button->priv; if (gtk_widget_get_realized (widget) && !gtk_widget_get_mapped (widget)) { @@ -565,7 +565,7 @@ static void gtk_spin_button_unmap (GtkWidget *widget) { GtkSpinButton *spin_button = GTK_SPIN_BUTTON (widget); - GtkSpinButtonPriv *priv = spin_button->priv; + GtkSpinButtonPrivate *priv = spin_button->priv; if (gtk_widget_get_mapped (widget)) { @@ -580,7 +580,7 @@ static void gtk_spin_button_realize (GtkWidget *widget) { GtkSpinButton *spin_button = GTK_SPIN_BUTTON (widget); - GtkSpinButtonPriv *priv = spin_button->priv; + GtkSpinButtonPrivate *priv = spin_button->priv; GdkWindowAttr attributes; gint attributes_mask; gboolean return_val; @@ -628,7 +628,7 @@ static void gtk_spin_button_unrealize (GtkWidget *widget) { GtkSpinButton *spin = GTK_SPIN_BUTTON (widget); - GtkSpinButtonPriv *priv = spin->priv; + GtkSpinButtonPrivate *priv = spin->priv; GTK_WIDGET_CLASS (gtk_spin_button_parent_class)->unrealize (widget); @@ -668,7 +668,7 @@ gtk_spin_button_size_request (GtkWidget *widget, GtkRequisition *requisition) { GtkSpinButton *spin_button = GTK_SPIN_BUTTON (widget); - GtkSpinButtonPriv *priv = spin_button->priv; + GtkSpinButtonPrivate *priv = spin_button->priv; GtkEntry *entry = GTK_ENTRY (widget); gint arrow_size; @@ -735,7 +735,7 @@ gtk_spin_button_size_allocate (GtkWidget *widget, GtkAllocation *allocation) { GtkSpinButton *spin = GTK_SPIN_BUTTON (widget); - GtkSpinButtonPriv *priv = spin->priv; + GtkSpinButtonPrivate *priv = spin->priv; GtkAllocation panel_allocation; gint arrow_size; gint panel_width; @@ -774,7 +774,7 @@ gtk_spin_button_expose (GtkWidget *widget, GdkEventExpose *event) { GtkSpinButton *spin = GTK_SPIN_BUTTON (widget); - GtkSpinButtonPriv *priv = spin->priv; + GtkSpinButtonPrivate *priv = spin->priv; if (gtk_widget_is_drawable (widget)) { @@ -819,7 +819,7 @@ static gboolean spin_button_at_limit (GtkSpinButton *spin_button, GtkArrowType arrow) { - GtkSpinButtonPriv *priv = spin_button->priv; + GtkSpinButtonPrivate *priv = spin_button->priv; GtkArrowType effective_arrow; if (priv->wrap) @@ -846,7 +846,7 @@ gtk_spin_button_draw_arrow (GtkSpinButton *spin_button, GdkRectangle *area, GtkArrowType arrow_type) { - GtkSpinButtonPriv *priv; + GtkSpinButtonPrivate *priv; GtkStateType state_type; GtkShadowType shadow_type; GtkWidget *widget; @@ -957,7 +957,7 @@ gtk_spin_button_enter_notify (GtkWidget *widget, GdkEventCrossing *event) { GtkSpinButton *spin = GTK_SPIN_BUTTON (widget); - GtkSpinButtonPriv *priv = spin->priv; + GtkSpinButtonPrivate *priv = spin->priv; if (event->window == priv->panel) { @@ -987,7 +987,7 @@ gtk_spin_button_leave_notify (GtkWidget *widget, GdkEventCrossing *event) { GtkSpinButton *spin = GTK_SPIN_BUTTON (widget); - GtkSpinButtonPriv *priv = spin->priv; + GtkSpinButtonPrivate *priv = spin->priv; priv->in_child = NO_ARROW; gtk_widget_queue_draw (GTK_WIDGET (spin)); @@ -1039,7 +1039,7 @@ gtk_spin_button_style_set (GtkWidget *widget, GtkStyle *previous_style) { GtkSpinButton *spin = GTK_SPIN_BUTTON (widget); - GtkSpinButtonPriv *priv = spin->priv; + GtkSpinButtonPrivate *priv = spin->priv; if (previous_style && gtk_widget_get_realized (widget)) gtk_style_set_background (widget->style, priv->panel, GTK_STATE_NORMAL); @@ -1053,7 +1053,7 @@ gtk_spin_button_scroll (GtkWidget *widget, GdkEventScroll *event) { GtkSpinButton *spin = GTK_SPIN_BUTTON (widget); - GtkSpinButtonPriv *priv = spin->priv; + GtkSpinButtonPrivate *priv = spin->priv; if (event->direction == GDK_SCROLL_UP) { @@ -1076,7 +1076,7 @@ gtk_spin_button_scroll (GtkWidget *widget, static void gtk_spin_button_stop_spinning (GtkSpinButton *spin) { - GtkSpinButtonPriv *priv = spin->priv; + GtkSpinButtonPrivate *priv = spin->priv; if (priv->timer) { @@ -1100,7 +1100,7 @@ start_spinning (GtkSpinButton *spin, GtkArrowType click_child, gdouble step) { - GtkSpinButtonPriv *priv; + GtkSpinButtonPrivate *priv; g_return_if_fail (click_child == GTK_ARROW_UP || click_child == GTK_ARROW_DOWN); @@ -1131,7 +1131,7 @@ gtk_spin_button_button_press (GtkWidget *widget, GdkEventButton *event) { GtkSpinButton *spin = GTK_SPIN_BUTTON (widget); - GtkSpinButtonPriv *priv = spin->priv; + GtkSpinButtonPrivate *priv = spin->priv; if (!priv->button) { @@ -1175,7 +1175,7 @@ gtk_spin_button_button_release (GtkWidget *widget, GdkEventButton *event) { GtkSpinButton *spin = GTK_SPIN_BUTTON (widget); - GtkSpinButtonPriv *priv = spin->priv; + GtkSpinButtonPrivate *priv = spin->priv; gint arrow_size; arrow_size = spin_button_get_arrow_size (spin); @@ -1225,7 +1225,7 @@ gtk_spin_button_motion_notify (GtkWidget *widget, GdkEventMotion *event) { GtkSpinButton *spin = GTK_SPIN_BUTTON (widget); - GtkSpinButtonPriv *priv = spin->priv; + GtkSpinButtonPrivate *priv = spin->priv; if (priv->button) return FALSE; @@ -1258,7 +1258,7 @@ gtk_spin_button_motion_notify (GtkWidget *widget, static gint gtk_spin_button_timer (GtkSpinButton *spin_button) { - GtkSpinButtonPriv *priv = spin_button->priv; + GtkSpinButtonPrivate *priv = spin_button->priv; gboolean retval = FALSE; if (priv->timer) @@ -1324,7 +1324,7 @@ static void gtk_spin_button_real_change_value (GtkSpinButton *spin, GtkScrollType scroll) { - GtkSpinButtonPriv *priv = spin->priv; + GtkSpinButtonPrivate *priv = spin->priv; gdouble old_value; /* When the key binding is activated, there may be an outstanding @@ -1422,7 +1422,7 @@ gtk_spin_button_key_release (GtkWidget *widget, GdkEventKey *event) { GtkSpinButton *spin = GTK_SPIN_BUTTON (widget); - GtkSpinButtonPriv *priv = spin->priv; + GtkSpinButtonPrivate *priv = spin->priv; /* We only get a release at the end of a key repeat run, so reset the timer_step */ priv->timer_step = priv->adjustment->step_increment; @@ -1435,7 +1435,7 @@ static void gtk_spin_button_snap (GtkSpinButton *spin_button, gdouble val) { - GtkSpinButtonPriv *priv = spin_button->priv; + GtkSpinButtonPrivate *priv = spin_button->priv; gdouble inc; gdouble tmp; @@ -1492,7 +1492,7 @@ gtk_spin_button_insert_text (GtkEditable *editable, { GtkEntry *entry = GTK_ENTRY (editable); GtkSpinButton *spin = GTK_SPIN_BUTTON (editable); - GtkSpinButtonPriv *priv = spin->priv; + GtkSpinButtonPrivate *priv = spin->priv; GtkEditableClass *parent_editable_iface = g_type_interface_peek (gtk_spin_button_parent_class, GTK_TYPE_EDITABLE); if (priv->numeric) @@ -1593,7 +1593,7 @@ static void gtk_spin_button_real_spin (GtkSpinButton *spin_button, gdouble increment) { - GtkSpinButtonPriv *priv = spin_button->priv; + GtkSpinButtonPrivate *priv = spin_button->priv; GtkAdjustment *adj; gdouble new_value = 0.0; gboolean wrapped = FALSE; @@ -1658,7 +1658,7 @@ gtk_spin_button_default_input (GtkSpinButton *spin_button, static gint gtk_spin_button_default_output (GtkSpinButton *spin_button) { - GtkSpinButtonPriv *priv = spin_button->priv; + GtkSpinButtonPrivate *priv = spin_button->priv; gchar *buf = g_strdup_printf ("%0.*f", priv->digits, priv->adjustment->value); @@ -1692,7 +1692,7 @@ gtk_spin_button_configure (GtkSpinButton *spin_button, gdouble climb_rate, guint digits) { - GtkSpinButtonPriv *priv; + GtkSpinButtonPrivate *priv; g_return_if_fail (GTK_IS_SPIN_BUTTON (spin_button)); @@ -1793,7 +1793,7 @@ static void adjustment_changed_cb (GtkAdjustment *adjustment, gpointer data) { GtkSpinButton *spin_button = GTK_SPIN_BUTTON (data); - GtkSpinButtonPriv *priv = spin_button->priv; + GtkSpinButtonPrivate *priv = spin_button->priv; priv->timer_step = priv->adjustment->step_increment; gtk_widget_queue_resize (GTK_WIDGET (spin_button)); @@ -1810,7 +1810,7 @@ void gtk_spin_button_set_adjustment (GtkSpinButton *spin_button, GtkAdjustment *adjustment) { - GtkSpinButtonPriv *priv; + GtkSpinButtonPrivate *priv; g_return_if_fail (GTK_IS_SPIN_BUTTON (spin_button)); @@ -1875,7 +1875,7 @@ void gtk_spin_button_set_digits (GtkSpinButton *spin_button, guint digits) { - GtkSpinButtonPriv *priv; + GtkSpinButtonPrivate *priv; g_return_if_fail (GTK_IS_SPIN_BUTTON (spin_button)); @@ -1922,7 +1922,7 @@ gtk_spin_button_set_increments (GtkSpinButton *spin_button, gdouble step, gdouble page) { - GtkSpinButtonPriv *priv; + GtkSpinButtonPrivate *priv; g_return_if_fail (GTK_IS_SPIN_BUTTON (spin_button)); @@ -1946,7 +1946,7 @@ gtk_spin_button_get_increments (GtkSpinButton *spin_button, gdouble *step, gdouble *page) { - GtkSpinButtonPriv *priv; + GtkSpinButtonPrivate *priv; g_return_if_fail (GTK_IS_SPIN_BUTTON (spin_button)); @@ -1971,7 +1971,7 @@ gtk_spin_button_set_range (GtkSpinButton *spin_button, gdouble min, gdouble max) { - GtkSpinButtonPriv *priv; + GtkSpinButtonPrivate *priv; gdouble value; g_return_if_fail (GTK_IS_SPIN_BUTTON (spin_button)); @@ -2005,7 +2005,7 @@ gtk_spin_button_get_range (GtkSpinButton *spin_button, gdouble *min, gdouble *max) { - GtkSpinButtonPriv *priv; + GtkSpinButtonPrivate *priv; g_return_if_fail (GTK_IS_SPIN_BUTTON (spin_button)); @@ -2044,7 +2044,7 @@ gtk_spin_button_get_value (GtkSpinButton *spin_button) gint gtk_spin_button_get_value_as_int (GtkSpinButton *spin_button) { - GtkSpinButtonPriv *priv; + GtkSpinButtonPrivate *priv; gdouble val; g_return_val_if_fail (GTK_IS_SPIN_BUTTON (spin_button), 0); @@ -2069,7 +2069,7 @@ void gtk_spin_button_set_value (GtkSpinButton *spin_button, gdouble value) { - GtkSpinButtonPriv *priv; + GtkSpinButtonPrivate *priv; g_return_if_fail (GTK_IS_SPIN_BUTTON (spin_button)); @@ -2098,7 +2098,7 @@ void gtk_spin_button_set_update_policy (GtkSpinButton *spin_button, GtkSpinButtonUpdatePolicy policy) { - GtkSpinButtonPriv *priv; + GtkSpinButtonPrivate *priv; g_return_if_fail (GTK_IS_SPIN_BUTTON (spin_button)); @@ -2140,7 +2140,7 @@ void gtk_spin_button_set_numeric (GtkSpinButton *spin_button, gboolean numeric) { - GtkSpinButtonPriv *priv; + GtkSpinButtonPrivate *priv; g_return_if_fail (GTK_IS_SPIN_BUTTON (spin_button)); @@ -2184,7 +2184,7 @@ void gtk_spin_button_set_wrap (GtkSpinButton *spin_button, gboolean wrap) { - GtkSpinButtonPriv *priv; + GtkSpinButtonPrivate *priv; g_return_if_fail (GTK_IS_SPIN_BUTTON (spin_button)); @@ -2260,7 +2260,7 @@ void gtk_spin_button_set_snap_to_ticks (GtkSpinButton *spin_button, gboolean snap_to_ticks) { - GtkSpinButtonPriv *priv; + GtkSpinButtonPrivate *priv; guint new_val; g_return_if_fail (GTK_IS_SPIN_BUTTON (spin_button)); @@ -2310,7 +2310,7 @@ gtk_spin_button_spin (GtkSpinButton *spin_button, GtkSpinType direction, gdouble increment) { - GtkSpinButtonPriv *priv; + GtkSpinButtonPrivate *priv; GtkAdjustment *adj; gdouble diff; @@ -2386,7 +2386,7 @@ gtk_spin_button_spin (GtkSpinButton *spin_button, void gtk_spin_button_update (GtkSpinButton *spin_button) { - GtkSpinButtonPriv *priv; + GtkSpinButtonPrivate *priv; gdouble val; gint error = 0; gint return_val; diff --git a/gtk/gtkspinbutton.h b/gtk/gtkspinbutton.h index ba38984f26..2e431631cf 100644 --- a/gtk/gtkspinbutton.h +++ b/gtk/gtkspinbutton.h @@ -68,9 +68,9 @@ typedef enum } GtkSpinType; -typedef struct _GtkSpinButton GtkSpinButton; -typedef struct _GtkSpinButtonPriv GtkSpinButtonPriv; -typedef struct _GtkSpinButtonClass GtkSpinButtonClass; +typedef struct _GtkSpinButton GtkSpinButton; +typedef struct _GtkSpinButtonPrivate GtkSpinButtonPrivate; +typedef struct _GtkSpinButtonClass GtkSpinButtonClass; struct _GtkSpinButton @@ -78,7 +78,7 @@ struct _GtkSpinButton GtkEntry entry; /* <private> */ - GtkSpinButtonPriv *priv; + GtkSpinButtonPrivate *priv; }; struct _GtkSpinButtonClass diff --git a/gtk/gtkspinner.c b/gtk/gtkspinner.c index 6261d82698..e25dc431d2 100644 --- a/gtk/gtkspinner.c +++ b/gtk/gtkspinner.c @@ -217,14 +217,16 @@ static gboolean gtk_spinner_expose (GtkWidget *widget, GdkEventExpose *event) { + GtkAllocation allocation; GtkStateType state_type; GtkSpinnerPrivate *priv; int width, height; priv = GTK_SPINNER (widget)->priv; - width = widget->allocation.width; - height = widget->allocation.height; + gtk_widget_get_allocation (widget, &allocation); + width = allocation.width; + height = allocation.height; if ((width < 12) || (height <12)) gtk_widget_set_size_request (widget, 12, 12); @@ -233,8 +235,8 @@ gtk_spinner_expose (GtkWidget *widget, if (!gtk_widget_is_sensitive (widget)) state_type = GTK_STATE_INSENSITIVE; - gtk_paint_spinner (widget->style, - widget->window, + gtk_paint_spinner (gtk_widget_get_style (widget), + gtk_widget_get_window (widget), state_type, &event->area, widget, @@ -473,6 +475,7 @@ gtk_spinner_accessible_image_get_size (AtkImage *image, gint *width, gint *height) { + GtkAllocation allocation; GtkWidget *widget; widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (image)); @@ -482,8 +485,9 @@ gtk_spinner_accessible_image_get_size (AtkImage *image, } else { - *width = widget->allocation.width; - *height = widget->allocation.height; + gtk_widget_get_allocation (widget, &allocation); + *width = allocation.width; + *height = allocation.height; } } diff --git a/gtk/gtkstatusbar.c b/gtk/gtkstatusbar.c index ded06208c6..7924067700 100644 --- a/gtk/gtkstatusbar.c +++ b/gtk/gtkstatusbar.c @@ -75,7 +75,7 @@ */ typedef struct _GtkStatusbarMsg GtkStatusbarMsg; -struct _GtkStatusbarPriv +struct _GtkStatusbarPrivate { GtkWidget *frame; GtkWidget *label; @@ -250,20 +250,20 @@ gtk_statusbar_class_init (GtkStatusbarClass *class) GTK_SHADOW_IN, GTK_PARAM_READABLE)); - g_type_class_add_private (class, sizeof (GtkStatusbarPriv)); + g_type_class_add_private (class, sizeof (GtkStatusbarPrivate)); } static void gtk_statusbar_init (GtkStatusbar *statusbar) { - GtkStatusbarPriv *priv; + GtkStatusbarPrivate *priv; GtkBox *box = GTK_BOX (statusbar); GtkWidget *message_area; GtkShadowType shadow_type; statusbar->priv = G_TYPE_INSTANCE_GET_PRIVATE (statusbar, GTK_TYPE_STATUSBAR, - GtkStatusbarPriv); + GtkStatusbarPrivate); priv = statusbar->priv; gtk_widget_set_redraw_on_allocate (GTK_WIDGET (box), TRUE); @@ -314,7 +314,7 @@ gtk_statusbar_buildable_get_internal_child (GtkBuildable *buildable, const gchar *childname) { GtkStatusbar *statusbar = GTK_STATUSBAR (buildable); - GtkStatusbarPriv *priv = statusbar->priv; + GtkStatusbarPrivate *priv = statusbar->priv; if (strcmp (childname, "message_area") == 0) return G_OBJECT (gtk_bin_get_child (GTK_BIN (priv->frame))); @@ -342,7 +342,7 @@ gtk_statusbar_update (GtkStatusbar *statusbar, guint context_id, const gchar *text) { - GtkStatusbarPriv *priv; + GtkStatusbarPrivate *priv; g_return_if_fail (GTK_IS_STATUSBAR (statusbar)); @@ -370,7 +370,7 @@ guint gtk_statusbar_get_context_id (GtkStatusbar *statusbar, const gchar *context_description) { - GtkStatusbarPriv *priv; + GtkStatusbarPrivate *priv; gchar *string; guint id; @@ -412,7 +412,7 @@ gtk_statusbar_push (GtkStatusbar *statusbar, guint context_id, const gchar *text) { - GtkStatusbarPriv *priv; + GtkStatusbarPrivate *priv; GtkStatusbarMsg *msg; g_return_val_if_fail (GTK_IS_STATUSBAR (statusbar), 0); @@ -452,7 +452,7 @@ void gtk_statusbar_pop (GtkStatusbar *statusbar, guint context_id) { - GtkStatusbarPriv *priv; + GtkStatusbarPrivate *priv; GtkStatusbarMsg *msg; g_return_if_fail (GTK_IS_STATUSBAR (statusbar)); @@ -502,7 +502,7 @@ gtk_statusbar_remove (GtkStatusbar *statusbar, guint context_id, guint message_id) { - GtkStatusbarPriv *priv; + GtkStatusbarPrivate *priv; GtkStatusbarMsg *msg; g_return_if_fail (GTK_IS_STATUSBAR (statusbar)); @@ -555,7 +555,7 @@ void gtk_statusbar_remove_all (GtkStatusbar *statusbar, guint context_id) { - GtkStatusbarPriv *priv; + GtkStatusbarPrivate *priv; GtkStatusbarMsg *msg; GSList *prev, *list; @@ -622,7 +622,7 @@ void gtk_statusbar_set_has_resize_grip (GtkStatusbar *statusbar, gboolean setting) { - GtkStatusbarPriv *priv; + GtkStatusbarPrivate *priv; g_return_if_fail (GTK_IS_STATUSBAR (statusbar)); @@ -681,7 +681,7 @@ gtk_statusbar_get_has_resize_grip (GtkStatusbar *statusbar) GtkWidget* gtk_statusbar_get_message_area (GtkStatusbar *statusbar) { - GtkStatusbarPriv *priv; + GtkStatusbarPrivate *priv; g_return_val_if_fail (GTK_IS_STATUSBAR (statusbar), NULL); @@ -694,7 +694,7 @@ static void gtk_statusbar_destroy (GtkObject *object) { GtkStatusbar *statusbar = GTK_STATUSBAR (object); - GtkStatusbarPriv *priv = statusbar->priv; + GtkStatusbarPrivate *priv = statusbar->priv; GSList *list; for (list = priv->messages; list; list = list->next) @@ -742,7 +742,7 @@ gtk_statusbar_get_property (GObject *object, GParamSpec *pspec) { GtkStatusbar *statusbar = GTK_STATUSBAR (object); - GtkStatusbarPriv *priv = statusbar->priv; + GtkStatusbarPrivate *priv = statusbar->priv; switch (prop_id) { @@ -770,35 +770,38 @@ static void get_grip_rect (GtkStatusbar *statusbar, GdkRectangle *rect) { - GtkWidget *widget; + GtkAllocation allocation; + GtkStyle *style; + GtkWidget *widget = GTK_WIDGET (statusbar); gint w, h; - - widget = GTK_WIDGET (statusbar); + + gtk_widget_get_allocation (widget, &allocation); + style = gtk_widget_get_style (widget); /* These are in effect the max/default size of the grip. */ w = 18; h = 18; - if (w > widget->allocation.width) - w = widget->allocation.width; + if (w > allocation.width) + w = allocation.width; + + if (h > allocation.height - style->ythickness) + h = allocation.height - style->ythickness; - if (h > widget->allocation.height - widget->style->ythickness) - h = widget->allocation.height - widget->style->ythickness; - rect->width = w; rect->height = h; - rect->y = widget->allocation.y + widget->allocation.height - h; + rect->y = allocation.y + allocation.height - h; if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR) - rect->x = widget->allocation.x + widget->allocation.width - w; - else - rect->x = widget->allocation.x + widget->style->xthickness; + rect->x = allocation.x + allocation.width - w; + else + rect->x = allocation.x + style->xthickness; } static void set_grip_cursor (GtkStatusbar *statusbar) { - GtkStatusbarPriv *priv = statusbar->priv; + GtkStatusbarPrivate *priv = statusbar->priv; if (priv->has_resize_grip && priv->grip_window != NULL) { @@ -827,7 +830,7 @@ static void gtk_statusbar_create_window (GtkStatusbar *statusbar) { GtkWidget *widget; - GtkStatusbarPriv *priv = statusbar->priv; + GtkStatusbarPrivate *priv = statusbar->priv; GdkWindowAttr attributes; gint attributes_mask; GdkRectangle rect; @@ -850,9 +853,8 @@ gtk_statusbar_create_window (GtkStatusbar *statusbar) attributes_mask = GDK_WA_X | GDK_WA_Y; - priv->grip_window = gdk_window_new (widget->window, - &attributes, attributes_mask); - + priv->grip_window = gdk_window_new (gtk_widget_get_window (widget), + &attributes, attributes_mask); gdk_window_set_user_data (priv->grip_window, widget); gdk_window_raise (priv->grip_window); @@ -881,7 +883,7 @@ gtk_statusbar_state_changed (GtkWidget *widget, static void gtk_statusbar_destroy_window (GtkStatusbar *statusbar) { - GtkStatusbarPriv *priv = statusbar->priv; + GtkStatusbarPrivate *priv = statusbar->priv; gdk_window_set_user_data (priv->grip_window, NULL); gdk_window_destroy (priv->grip_window); @@ -892,7 +894,7 @@ static void gtk_statusbar_realize (GtkWidget *widget) { GtkStatusbar *statusbar = GTK_STATUSBAR (widget); - GtkStatusbarPriv *priv = statusbar->priv; + GtkStatusbarPrivate *priv = statusbar->priv; GTK_WIDGET_CLASS (gtk_statusbar_parent_class)->realize (widget); @@ -904,7 +906,7 @@ static void gtk_statusbar_unrealize (GtkWidget *widget) { GtkStatusbar *statusbar = GTK_STATUSBAR (widget); - GtkStatusbarPriv *priv = statusbar->priv; + GtkStatusbarPrivate *priv = statusbar->priv; if (priv->grip_window) gtk_statusbar_destroy_window (statusbar); @@ -916,7 +918,7 @@ static void gtk_statusbar_map (GtkWidget *widget) { GtkStatusbar *statusbar = GTK_STATUSBAR (widget); - GtkStatusbarPriv *priv = statusbar->priv; + GtkStatusbarPrivate *priv = statusbar->priv; GTK_WIDGET_CLASS (gtk_statusbar_parent_class)->map (widget); @@ -928,7 +930,7 @@ static void gtk_statusbar_unmap (GtkWidget *widget) { GtkStatusbar *statusbar = GTK_STATUSBAR (widget); - GtkStatusbarPriv *priv = statusbar->priv; + GtkStatusbarPrivate *priv = statusbar->priv; if (priv->grip_window) gdk_window_hide (priv->grip_window); @@ -941,7 +943,7 @@ gtk_statusbar_button_press (GtkWidget *widget, GdkEventButton *event) { GtkStatusbar *statusbar = GTK_STATUSBAR (widget); - GtkStatusbarPriv *priv = statusbar->priv; + GtkStatusbarPrivate *priv = statusbar->priv; GtkWidget *ancestor; GdkWindowEdge edge; @@ -979,7 +981,8 @@ gtk_statusbar_expose_event (GtkWidget *widget, GdkEventExpose *event) { GtkStatusbar *statusbar = GTK_STATUSBAR (widget); - GtkStatusbarPriv *priv = statusbar->priv; + GtkStatusbarPrivate *priv = statusbar->priv; + GtkStyle *style; GdkRectangle rect; GTK_WIDGET_CLASS (gtk_statusbar_parent_class)->expose_event (widget, event); @@ -992,8 +995,9 @@ gtk_statusbar_expose_event (GtkWidget *widget, get_grip_rect (statusbar, &rect); - gtk_paint_resize_grip (widget->style, - widget->window, + style = gtk_widget_get_style (widget); + gtk_paint_resize_grip (style, + gtk_widget_get_window (widget), gtk_widget_get_state (widget), &event->area, widget, @@ -1003,8 +1007,8 @@ gtk_statusbar_expose_event (GtkWidget *widget, /* don't draw grip over the frame, though you * can click on the frame. */ - rect.width - widget->style->xthickness, - rect.height - widget->style->ythickness); + rect.width - style->xthickness, + rect.height - style->ythickness); } return FALSE; @@ -1015,7 +1019,7 @@ gtk_statusbar_size_request (GtkWidget *widget, GtkRequisition *requisition) { GtkStatusbar *statusbar = GTK_STATUSBAR (widget); - GtkStatusbarPriv *priv = statusbar->priv; + GtkStatusbarPrivate *priv = statusbar->priv; GtkShadowType shadow_type; gtk_widget_style_get (GTK_WIDGET (statusbar), "shadow-type", &shadow_type, NULL); @@ -1030,7 +1034,7 @@ gtk_statusbar_size_request (GtkWidget *widget, static gboolean has_extra_children (GtkStatusbar *statusbar) { - GtkStatusbarPriv *priv = statusbar->priv; + GtkStatusbarPrivate *priv = statusbar->priv; GtkPackType child_pack_type, frame_pack_type; GtkWidget *child, *frame; GList *l, *children; @@ -1080,7 +1084,7 @@ gtk_statusbar_size_allocate (GtkWidget *widget, GtkAllocation *allocation) { GtkStatusbar *statusbar = GTK_STATUSBAR (widget); - GtkStatusbarPriv *priv = statusbar->priv; + GtkStatusbarPrivate *priv = statusbar->priv; gboolean extra_children = FALSE; GdkRectangle rect; @@ -1116,10 +1120,11 @@ gtk_statusbar_size_allocate (GtkWidget *widget, if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) allocation->x -= rect.width; - widget->allocation = *allocation; + gtk_widget_set_allocation (widget, allocation); } else { + GtkAllocation child_allocation, frame_allocation; GtkWidget *child; /* Use the frame's child instead of priv->label directly, in case @@ -1128,13 +1133,15 @@ gtk_statusbar_size_allocate (GtkWidget *widget, */ child = gtk_bin_get_child (GTK_BIN (priv->frame)); - if (child->allocation.width + rect.width > priv->frame->allocation.width) + gtk_widget_get_allocation (child, &child_allocation); + gtk_widget_get_allocation (priv->frame, &frame_allocation); + if (child_allocation.width + rect.width > frame_allocation.width) { /* shrink the label to make room for the grip */ - *allocation = child->allocation; + *allocation = child_allocation; allocation->width = MAX (1, allocation->width - rect.width); if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) - allocation->x += child->allocation.width - allocation->width; + allocation->x += child_allocation.width - allocation->width; gtk_widget_size_allocate (child, allocation); } @@ -1159,7 +1166,7 @@ label_selectable_changed (GtkWidget *label, gpointer data) { GtkStatusbar *statusbar = GTK_STATUSBAR (data); - GtkStatusbarPriv *priv = statusbar->priv; + GtkStatusbarPrivate *priv = statusbar->priv; if (statusbar && priv->has_resize_grip && priv->grip_window) diff --git a/gtk/gtkstatusbar.h b/gtk/gtkstatusbar.h index a9cc43c156..8c39403e9f 100644 --- a/gtk/gtkstatusbar.h +++ b/gtk/gtkstatusbar.h @@ -44,16 +44,16 @@ G_BEGIN_DECLS #define GTK_STATUSBAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_STATUSBAR, GtkStatusbarClass)) -typedef struct _GtkStatusbar GtkStatusbar; -typedef struct _GtkStatusbarPriv GtkStatusbarPriv; -typedef struct _GtkStatusbarClass GtkStatusbarClass; +typedef struct _GtkStatusbar GtkStatusbar; +typedef struct _GtkStatusbarPrivate GtkStatusbarPrivate; +typedef struct _GtkStatusbarClass GtkStatusbarClass; struct _GtkStatusbar { GtkHBox parent_widget; /* <private> */ - GtkStatusbarPriv *priv; + GtkStatusbarPrivate *priv; }; struct _GtkStatusbarClass diff --git a/gtk/gtkstatusicon.c b/gtk/gtkstatusicon.c index 2f040188dc..0ab4564eea 100644 --- a/gtk/gtkstatusicon.c +++ b/gtk/gtkstatusicon.c @@ -2489,7 +2489,7 @@ gtk_status_icon_is_embedded (GtkStatusIcon *status_icon) #ifdef GDK_WINDOWING_X11 plug = GTK_PLUG (status_icon->priv->tray_icon); - if (plug->socket_window) + if (gtk_plug_get_embedded (plug)) return TRUE; else return FALSE; @@ -2524,6 +2524,7 @@ gtk_status_icon_position_menu (GtkMenu *menu, gpointer user_data) { #ifdef GDK_WINDOWING_X11 + GtkAllocation allocation; GtkStatusIcon *status_icon; GtkStatusIconPrivate *priv; GtkTrayIcon *tray_icon; @@ -2532,6 +2533,7 @@ gtk_status_icon_position_menu (GtkMenu *menu, GtkTextDirection direction; GtkRequisition menu_req; GdkRectangle monitor; + GdkWindow *window; gint monitor_num, height, width, xoffset, yoffset; g_return_if_fail (GTK_IS_MENU (menu)); @@ -2547,30 +2549,32 @@ gtk_status_icon_position_menu (GtkMenu *menu, screen = gtk_widget_get_screen (widget); gtk_menu_set_screen (menu, screen); - monitor_num = gdk_screen_get_monitor_at_window (screen, widget->window); + window = gtk_widget_get_window (widget); + monitor_num = gdk_screen_get_monitor_at_window (screen, window); if (monitor_num < 0) monitor_num = 0; gtk_menu_set_monitor (menu, monitor_num); gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor); - gdk_window_get_origin (widget->window, x, y); - + gdk_window_get_origin (window, x, y); + gtk_widget_size_request (GTK_WIDGET (menu), &menu_req); + gtk_widget_get_allocation (widget, &allocation); if (_gtk_tray_icon_get_orientation (tray_icon) == GTK_ORIENTATION_VERTICAL) { width = 0; - height = widget->allocation.height; - xoffset = widget->allocation.width; + height = allocation.height; + xoffset = allocation.width; yoffset = 0; } else { - width = widget->allocation.width; + width = allocation.width; height = 0; xoffset = 0; - yoffset = widget->allocation.height; + yoffset = allocation.height; } if (direction == GTK_TEXT_DIR_RTL) @@ -2661,6 +2665,7 @@ gtk_status_icon_get_geometry (GtkStatusIcon *status_icon, GtkOrientation *orientation) { #ifdef GDK_WINDOWING_X11 + GtkAllocation allocation; GtkWidget *widget; GtkStatusIconPrivate *priv; gint x, y; @@ -2675,11 +2680,14 @@ gtk_status_icon_get_geometry (GtkStatusIcon *status_icon, if (area) { - gdk_window_get_origin (widget->window, &x, &y); + gdk_window_get_origin (gtk_widget_get_window (widget), + &x, &y); + + gtk_widget_get_allocation (widget, &allocation); area->x = x; area->y = y; - area->width = widget->allocation.width; - area->height = widget->allocation.height; + area->width = allocation.width; + area->height = allocation.height; } if (orientation) @@ -2961,7 +2969,7 @@ gtk_status_icon_get_x11_window_id (GtkStatusIcon *status_icon) { #ifdef GDK_WINDOWING_X11 gtk_widget_realize (GTK_WIDGET (status_icon->priv->tray_icon)); - return GDK_WINDOW_XID (GTK_WIDGET (status_icon->priv->tray_icon)->window); + return GDK_WINDOW_XID (gtk_widget_get_window (GTK_WIDGET (status_icon->priv->tray_icon))); #else return 0; #endif diff --git a/gtk/gtkstock.c b/gtk/gtkstock.c index 64cb72d5f2..ff73fc40cd 100644 --- a/gtk/gtkstock.c +++ b/gtk/gtkstock.c @@ -323,7 +323,7 @@ static const GtkStockItem builtin_items [] = { GTK_STOCK_APPLY, NC_("Stock label", "_Apply"), 0, 0, GETTEXT_PACKAGE }, { GTK_STOCK_BOLD, NC_("Stock label", "_Bold"), 0, 0, GETTEXT_PACKAGE }, { GTK_STOCK_CANCEL, NC_("Stock label", "_Cancel"), 0, 0, GETTEXT_PACKAGE }, - { GTK_STOCK_CDROM, NC_("Stock label", "_CD-Rom"), 0, 0, GETTEXT_PACKAGE }, + { GTK_STOCK_CDROM, NC_("Stock label", "_CD-ROM"), 0, 0, GETTEXT_PACKAGE }, { GTK_STOCK_CLEAR, NC_("Stock label", "_Clear"), 0, 0, GETTEXT_PACKAGE }, { GTK_STOCK_CLOSE, NC_("Stock label", "_Close"), GDK_CONTROL_MASK, 'w', GETTEXT_PACKAGE }, { GTK_STOCK_CONNECT, NC_("Stock label", "C_onnect"), 0, 0, GETTEXT_PACKAGE }, @@ -357,7 +357,7 @@ static const GtkStockItem builtin_items [] = { GTK_STOCK_GO_FORWARD, NC_("Stock label, navigation", "_Forward"), 0, 0, GETTEXT_PACKAGE "-navigation" }, /* This is a navigation label as in "go up" */ { GTK_STOCK_GO_UP, NC_("Stock label, navigation", "_Up"), 0, 0, GETTEXT_PACKAGE "-navigation" }, - { GTK_STOCK_HARDDISK, NC_("Stock label", "_Harddisk"), 0, 0, GETTEXT_PACKAGE }, + { GTK_STOCK_HARDDISK, NC_("Stock label", "_Hard Disk"), 0, 0, GETTEXT_PACKAGE }, { GTK_STOCK_HELP, NC_("Stock label", "_Help"), GDK_CONTROL_MASK, 'h', GETTEXT_PACKAGE }, { GTK_STOCK_HOME, NC_("Stock label", "_Home"), 0, 0, GETTEXT_PACKAGE }, { GTK_STOCK_INDENT, NC_("Stock label", "Increase Indent"), 0, 0, GETTEXT_PACKAGE }, diff --git a/gtk/gtkstock.h b/gtk/gtkstock.h index a8a7701812..5307966831 100644 --- a/gtk/gtkstock.h +++ b/gtk/gtkstock.h @@ -308,6 +308,8 @@ void gtk_stock_set_translate_func (const gchar *domain, * The "File" item. * <inlinegraphic fileref="gtk-file.png" format="PNG"></inlinegraphic> * + * Since 3.0, this item has a label, before it only had an icon. + * * Since: 2.6 */ #define GTK_STOCK_FILE "gtk-file" diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c index f836ab101e..e8b13f372e 100644 --- a/gtk/gtkstyle.c +++ b/gtk/gtkstyle.c @@ -5698,13 +5698,16 @@ get_insertion_cursor_color (GtkWidget *widget, gboolean is_primary) { CursorInfo *cursor_info; + GtkStyle *style; GdkColor *cursor_color; - cursor_info = g_object_get_data (G_OBJECT (widget->style), "gtk-style-cursor-info"); + style = gtk_widget_get_style (widget); + + cursor_info = g_object_get_data (G_OBJECT (style), "gtk-style-cursor-info"); if (!cursor_info) { cursor_info = g_new0 (CursorInfo, 1); - g_object_set_data (G_OBJECT (widget->style), I_("gtk-style-cursor-info"), cursor_info); + g_object_set_data (G_OBJECT (style), I_("gtk-style-cursor-info"), cursor_info); cursor_info->for_type = G_TYPE_INVALID; } @@ -5728,7 +5731,7 @@ get_insertion_cursor_color (GtkWidget *widget, } else { - cursor_info->primary = widget->style->text[GTK_STATE_NORMAL]; + cursor_info->primary = style->text[GTK_STATE_NORMAL]; } gtk_widget_style_get (widget, "secondary-cursor-color", &cursor_color, NULL); @@ -5741,7 +5744,7 @@ get_insertion_cursor_color (GtkWidget *widget, { /* text_aa is the average of text and base colors, * in usual black-on-white case it's grey. */ - cursor_info->secondary = widget->style->text_aa[GTK_STATE_NORMAL]; + cursor_info->secondary = style->text_aa[GTK_STATE_NORMAL]; } } @@ -5768,7 +5771,7 @@ _gtk_widget_get_cursor_color (GtkWidget *widget, gdk_color_free (style_color); } else - *color = widget->style->text[GTK_STATE_NORMAL]; + *color = gtk_widget_get_style (widget)->text[GTK_STATE_NORMAL]; } static void diff --git a/gtk/gtktable.c b/gtk/gtktable.c index e011611215..0380aa0c39 100644 --- a/gtk/gtktable.c +++ b/gtk/gtktable.c @@ -31,7 +31,7 @@ -struct _GtkTablePriv +struct _GtkTablePrivate { GtkTableRowCol *cols; GtkTableRowCol *rows; @@ -240,7 +240,7 @@ gtk_table_class_init (GtkTableClass *class) 0, 65535, 0, GTK_PARAM_READWRITE)); - g_type_class_add_private (class, sizeof (GtkTablePriv)); + g_type_class_add_private (class, sizeof (GtkTablePrivate)); } static GType @@ -256,7 +256,7 @@ gtk_table_get_property (GObject *object, GParamSpec *pspec) { GtkTable *table = GTK_TABLE (object); - GtkTablePriv *priv = table->priv; + GtkTablePrivate *priv = table->priv; switch (prop_id) { @@ -288,7 +288,7 @@ gtk_table_set_property (GObject *object, GParamSpec *pspec) { GtkTable *table = GTK_TABLE (object); - GtkTablePriv *priv = table->priv; + GtkTablePrivate *priv = table->priv; switch (prop_id) { @@ -321,7 +321,7 @@ gtk_table_set_child_property (GtkContainer *container, GParamSpec *pspec) { GtkTable *table = GTK_TABLE (container); - GtkTablePriv *priv = table->priv; + GtkTablePrivate *priv = table->priv; GtkTableChild *table_child; GList *list; @@ -402,7 +402,7 @@ gtk_table_get_child_property (GtkContainer *container, GParamSpec *pspec) { GtkTable *table = GTK_TABLE (container); - GtkTablePriv *priv = table->priv; + GtkTablePrivate *priv = table->priv; GtkTableChild *table_child; GList *list; @@ -459,11 +459,11 @@ gtk_table_get_child_property (GtkContainer *container, static void gtk_table_init (GtkTable *table) { - GtkTablePriv *priv; + GtkTablePrivate *priv; table->priv = G_TYPE_INSTANCE_GET_PRIVATE (table, GTK_TYPE_TABLE, - GtkTablePriv); + GtkTablePrivate); priv = table->priv; gtk_widget_set_has_window (GTK_WIDGET (table), FALSE); @@ -487,7 +487,7 @@ gtk_table_new (guint rows, gboolean homogeneous) { GtkTable *table; - GtkTablePriv *priv; + GtkTablePrivate *priv; if (rows == 0) rows = 1; @@ -509,7 +509,7 @@ gtk_table_resize (GtkTable *table, guint n_rows, guint n_cols) { - GtkTablePriv *priv; + GtkTablePrivate *priv; g_return_if_fail (GTK_IS_TABLE (table)); g_return_if_fail (n_rows > 0 && n_rows <= 65535); @@ -593,13 +593,13 @@ gtk_table_attach (GtkTable *table, guint xpadding, guint ypadding) { - GtkTablePriv *priv = table->priv; + GtkTablePrivate *priv = table->priv; GtkTableChild *table_child; g_return_if_fail (GTK_IS_TABLE (table)); g_return_if_fail (GTK_IS_WIDGET (child)); - g_return_if_fail (child->parent == NULL); - + g_return_if_fail (gtk_widget_get_parent (child) == NULL); + /* g_return_if_fail (left_attach >= 0); */ g_return_if_fail (left_attach < right_attach); /* g_return_if_fail (top_attach >= 0); */ @@ -654,7 +654,7 @@ gtk_table_set_row_spacing (GtkTable *table, guint row, guint spacing) { - GtkTablePriv *priv; + GtkTablePrivate *priv; g_return_if_fail (GTK_IS_TABLE (table)); @@ -685,7 +685,7 @@ guint gtk_table_get_row_spacing (GtkTable *table, guint row) { - GtkTablePriv *priv; + GtkTablePrivate *priv; g_return_val_if_fail (GTK_IS_TABLE (table), 0); @@ -701,7 +701,7 @@ gtk_table_set_col_spacing (GtkTable *table, guint column, guint spacing) { - GtkTablePriv *priv; + GtkTablePrivate *priv; g_return_if_fail (GTK_IS_TABLE (table)); @@ -732,7 +732,7 @@ guint gtk_table_get_col_spacing (GtkTable *table, guint column) { - GtkTablePriv *priv; + GtkTablePrivate *priv; g_return_val_if_fail (GTK_IS_TABLE (table), 0); @@ -747,7 +747,7 @@ void gtk_table_set_row_spacings (GtkTable *table, guint spacing) { - GtkTablePriv *priv; + GtkTablePrivate *priv; guint row; g_return_if_fail (GTK_IS_TABLE (table)); @@ -786,7 +786,7 @@ void gtk_table_set_col_spacings (GtkTable *table, guint spacing) { - GtkTablePriv *priv; + GtkTablePrivate *priv; guint col; g_return_if_fail (GTK_IS_TABLE (table)); @@ -825,7 +825,7 @@ void gtk_table_set_homogeneous (GtkTable *table, gboolean homogeneous) { - GtkTablePriv *priv; + GtkTablePrivate *priv; g_return_if_fail (GTK_IS_TABLE (table)); @@ -877,7 +877,7 @@ gtk_table_get_size (GtkTable *table, guint *rows, guint *columns) { - GtkTablePriv *priv; + GtkTablePrivate *priv; g_return_if_fail (GTK_IS_TABLE (table)); @@ -894,7 +894,7 @@ static void gtk_table_finalize (GObject *object) { GtkTable *table = GTK_TABLE (object); - GtkTablePriv *priv = table->priv; + GtkTablePrivate *priv = table->priv; g_free (priv->rows); g_free (priv->cols); @@ -907,7 +907,7 @@ gtk_table_size_request (GtkWidget *widget, GtkRequisition *requisition) { GtkTable *table = GTK_TABLE (widget); - GtkTablePriv *priv = table->priv; + GtkTablePrivate *priv = table->priv; gint row, col; guint border_width; @@ -941,7 +941,7 @@ gtk_table_size_allocate (GtkWidget *widget, { GtkTable *table = GTK_TABLE (widget); - widget->allocation = *allocation; + gtk_widget_set_allocation (widget, allocation); gtk_table_size_allocate_init (table); gtk_table_size_allocate_pass1 (table); @@ -960,7 +960,7 @@ gtk_table_remove (GtkContainer *container, GtkWidget *widget) { GtkTable *table = GTK_TABLE (container); - GtkTablePriv *priv = table->priv; + GtkTablePrivate *priv = table->priv; GtkTableChild *child; GtkWidget *widget_container = GTK_WIDGET (container); GList *children; @@ -995,7 +995,7 @@ gtk_table_forall (GtkContainer *container, gpointer callback_data) { GtkTable *table = GTK_TABLE (container); - GtkTablePriv *priv = table->priv; + GtkTablePrivate *priv = table->priv; GtkTableChild *child; GList *children; @@ -1013,7 +1013,7 @@ gtk_table_forall (GtkContainer *container, static void gtk_table_size_request_init (GtkTable *table) { - GtkTablePriv *priv = table->priv; + GtkTablePrivate *priv = table->priv; GtkTableChild *child; GList *children; gint row, col; @@ -1049,7 +1049,7 @@ gtk_table_size_request_init (GtkTable *table) static void gtk_table_size_request_pass1 (GtkTable *table) { - GtkTablePriv *priv = table->priv; + GtkTablePrivate *priv = table->priv; GtkTableChild *child; GList *children; gint width; @@ -1088,7 +1088,7 @@ gtk_table_size_request_pass1 (GtkTable *table) static void gtk_table_size_request_pass2 (GtkTable *table) { - GtkTablePriv *priv = table->priv; + GtkTablePrivate *priv = table->priv; gint max_width; gint max_height; gint row, col; @@ -1113,7 +1113,7 @@ gtk_table_size_request_pass2 (GtkTable *table) static void gtk_table_size_request_pass3 (GtkTable *table) { - GtkTablePriv *priv = table->priv; + GtkTablePrivate *priv = table->priv; GtkTableChild *child; GList *children; gint width, height; @@ -1238,7 +1238,7 @@ gtk_table_size_request_pass3 (GtkTable *table) static void gtk_table_size_allocate_init (GtkTable *table) { - GtkTablePriv *priv = table->priv; + GtkTablePrivate *priv = table->priv; GtkTableChild *child; GList *children; gint row, col; @@ -1433,7 +1433,8 @@ gtk_table_size_allocate_init (GtkTable *table) static void gtk_table_size_allocate_pass1 (GtkTable *table) { - GtkTablePriv *priv = table->priv; + GtkTablePrivate *priv = table->priv; + GtkAllocation allocation; gint real_width; gint real_height; gint width, height; @@ -1447,9 +1448,10 @@ gtk_table_size_allocate_pass1 (GtkTable *table) * then we have to expand any expandable rows and columns * to fill in the extra space. */ + gtk_widget_get_allocation (GTK_WIDGET (table), &allocation); border_width = gtk_container_get_border_width (GTK_CONTAINER (table)); - real_width = GTK_WIDGET (table)->allocation.width - border_width * 2; - real_height = GTK_WIDGET (table)->allocation.height - border_width * 2; + real_width = allocation.width - border_width * 2; + real_height = allocation.height - border_width * 2; if (priv->homogeneous) { @@ -1638,7 +1640,7 @@ gtk_table_size_allocate_pass1 (GtkTable *table) static void gtk_table_size_allocate_pass2 (GtkTable *table) { - GtkTablePriv *priv = table->priv; + GtkTablePrivate *priv = table->priv; GtkTableChild *child; GList *children; gint max_width; @@ -1646,6 +1648,7 @@ gtk_table_size_allocate_pass2 (GtkTable *table) gint x, y; gint row, col; GtkAllocation allocation; + GtkAllocation table_allocation, widget_allocation; GtkWidget *widget = GTK_WIDGET (table); children = priv->children; @@ -1661,9 +1664,10 @@ gtk_table_size_allocate_pass2 (GtkTable *table) gtk_widget_get_child_requisition (child->widget, &child_requisition); + gtk_widget_get_allocation (GTK_WIDGET (table), &table_allocation); border_width = gtk_container_get_border_width (GTK_CONTAINER (table)); - x = GTK_WIDGET (table)->allocation.x + border_width; - y = GTK_WIDGET (table)->allocation.y + border_width; + x = table_allocation.x + border_width; + y = table_allocation.y + border_width; max_width = 0; max_height = 0; @@ -1715,10 +1719,11 @@ gtk_table_size_allocate_pass2 (GtkTable *table) allocation.y = y + (max_height - allocation.height) / 2; } + gtk_widget_get_allocation (widget, &widget_allocation); if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) - allocation.x = widget->allocation.x + widget->allocation.width - - (allocation.x - widget->allocation.x) - allocation.width; - + allocation.x = widget_allocation.x + widget_allocation.width + - (allocation.x - widget_allocation.x) - allocation.width; + gtk_widget_size_allocate (child->widget, &allocation); } } diff --git a/gtk/gtktable.h b/gtk/gtktable.h index f71b3e7d4f..b2f807ad90 100644 --- a/gtk/gtktable.h +++ b/gtk/gtktable.h @@ -45,18 +45,18 @@ G_BEGIN_DECLS #define GTK_TABLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_TABLE, GtkTableClass)) -typedef struct _GtkTable GtkTable; -typedef struct _GtkTablePriv GtkTablePriv; -typedef struct _GtkTableClass GtkTableClass; -typedef struct _GtkTableChild GtkTableChild; -typedef struct _GtkTableRowCol GtkTableRowCol; +typedef struct _GtkTable GtkTable; +typedef struct _GtkTablePrivate GtkTablePrivate; +typedef struct _GtkTableClass GtkTableClass; +typedef struct _GtkTableChild GtkTableChild; +typedef struct _GtkTableRowCol GtkTableRowCol; struct _GtkTable { GtkContainer container; /* <private> */ - GtkTablePriv *priv; + GtkTablePrivate *priv; }; struct _GtkTableClass diff --git a/gtk/gtktearoffmenuitem.c b/gtk/gtktearoffmenuitem.c index 0a1de9a587..5e68892069 100644 --- a/gtk/gtktearoffmenuitem.c +++ b/gtk/gtktearoffmenuitem.c @@ -34,7 +34,7 @@ #define TEAR_LENGTH 5 #define BORDER_SPACING 3 -struct _GtkTearoffMenuItemPriv +struct _GtkTearoffMenuItemPrivate { guint torn_off : 1; }; @@ -70,17 +70,17 @@ gtk_tearoff_menu_item_class_init (GtkTearoffMenuItemClass *klass) menu_item_class->activate = gtk_tearoff_menu_item_activate; - g_type_class_add_private (klass, sizeof (GtkTearoffMenuItemPriv)); + g_type_class_add_private (klass, sizeof (GtkTearoffMenuItemPrivate)); } static void gtk_tearoff_menu_item_init (GtkTearoffMenuItem *tearoff_menu_item) { - GtkTearoffMenuItemPriv *priv; + GtkTearoffMenuItemPrivate *priv; tearoff_menu_item->priv = G_TYPE_INSTANCE_GET_PRIVATE (tearoff_menu_item, GTK_TYPE_TEAROFF_MENU_ITEM, - GtkTearoffMenuItemPriv); + GtkTearoffMenuItemPrivate); priv = tearoff_menu_item->priv; priv->torn_off = FALSE; @@ -90,19 +90,24 @@ static void gtk_tearoff_menu_item_size_request (GtkWidget *widget, GtkRequisition *requisition) { + GtkStyle *style; + GtkWidget *parent; guint border_width; + style = gtk_widget_get_style (widget); + border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); - requisition->width = (border_width + widget->style->xthickness + BORDER_SPACING) * 2; - requisition->height = (border_width + widget->style->ythickness) * 2; + requisition->width = (border_width + style->xthickness + BORDER_SPACING) * 2; + requisition->height = (border_width + style->ythickness) * 2; - if (GTK_IS_MENU (widget->parent) && GTK_MENU (widget->parent)->torn_off) + parent = gtk_widget_get_parent (widget); + if (GTK_IS_MENU (parent) && GTK_MENU (parent)->torn_off) { requisition->height += ARROW_SIZE; } else { - requisition->height += widget->style->ythickness + 4; + requisition->height += style->ythickness + 4; } } @@ -110,50 +115,61 @@ static void gtk_tearoff_menu_item_paint (GtkWidget *widget, GdkRectangle *area) { + GtkAllocation allocation; GtkMenuItem *menu_item; GtkShadowType shadow_type; + GtkStateType state; + GtkStyle *style; gint width, height; gint x, y; gint right_max; guint border_width; GtkArrowType arrow_type; GtkTextDirection direction; - + GtkWidget *parent; + GdkWindow *window; + if (gtk_widget_is_drawable (widget)) { menu_item = GTK_MENU_ITEM (widget); + style = gtk_widget_get_style (widget); + window = gtk_widget_get_window (widget); direction = gtk_widget_get_direction (widget); border_width = gtk_container_get_border_width (GTK_CONTAINER (menu_item)); - x = widget->allocation.x + border_width; - y = widget->allocation.y + border_width; - width = widget->allocation.width - border_width * 2; - height = widget->allocation.height - border_width * 2; + gtk_widget_get_allocation (widget, &allocation); + x = allocation.x + border_width; + y = allocation.y + border_width; + width = allocation.width - border_width * 2; + height = allocation.height - border_width * 2; right_max = x + width; - if (widget->state == GTK_STATE_PRELIGHT) + state = gtk_widget_get_state (widget); + + if (state == GTK_STATE_PRELIGHT) { gint selected_shadow_type; gtk_widget_style_get (widget, "selected-shadow-type", &selected_shadow_type, NULL); - gtk_paint_box (widget->style, - widget->window, + gtk_paint_box (style, + window, GTK_STATE_PRELIGHT, selected_shadow_type, area, widget, "menuitem", x, y, width, height); } else - gdk_window_clear_area (widget->window, area->x, area->y, area->width, area->height); + gdk_window_clear_area (window, area->x, area->y, area->width, area->height); - if (GTK_IS_MENU (widget->parent) && GTK_MENU (widget->parent)->torn_off) + parent = gtk_widget_get_parent (widget); + if (GTK_IS_MENU (parent) && GTK_MENU (parent)->torn_off) { gint arrow_x; - if (widget->state == GTK_STATE_PRELIGHT) + if (state == GTK_STATE_PRELIGHT) shadow_type = GTK_SHADOW_IN; else shadow_type = GTK_SHADOW_OUT; @@ -184,8 +200,8 @@ gtk_tearoff_menu_item_paint (GtkWidget *widget, } - gtk_paint_arrow (widget->style, widget->window, - widget->state, shadow_type, + gtk_paint_arrow (style, window, + state, shadow_type, NULL, widget, "tearoffmenuitem", arrow_type, FALSE, arrow_x, y + height / 2 - 5, @@ -204,10 +220,10 @@ gtk_tearoff_menu_item_paint (GtkWidget *widget, x1 = right_max - x; x2 = MAX (right_max - x - TEAR_LENGTH, 0); } - - gtk_paint_hline (widget->style, widget->window, GTK_STATE_NORMAL, + + gtk_paint_hline (style, window, GTK_STATE_NORMAL, NULL, widget, "tearoffmenuitem", - x1, x2, y + (height - widget->style->ythickness) / 2); + x1, x2, y + (height - style->ythickness) / 2); x += 2 * TEAR_LENGTH; } } @@ -225,12 +241,15 @@ gtk_tearoff_menu_item_expose (GtkWidget *widget, static void gtk_tearoff_menu_item_activate (GtkMenuItem *menu_item) { - if (GTK_IS_MENU (GTK_WIDGET (menu_item)->parent)) + GtkWidget *parent; + + parent = gtk_widget_get_parent (GTK_WIDGET (menu_item)); + if (GTK_IS_MENU (parent)) { - GtkMenu *menu = GTK_MENU (GTK_WIDGET (menu_item)->parent); - + GtkMenu *menu = GTK_MENU (parent); + gtk_widget_queue_resize (GTK_WIDGET (menu_item)); - gtk_menu_set_tearoff_state (GTK_MENU (GTK_WIDGET (menu_item)->parent), + gtk_menu_set_tearoff_state (GTK_MENU (parent), !menu->torn_off); } } @@ -241,7 +260,7 @@ tearoff_state_changed (GtkMenu *menu, gpointer data) { GtkTearoffMenuItem *tearoff_menu_item = GTK_TEAROFF_MENU_ITEM (data); - GtkTearoffMenuItemPriv *priv = tearoff_menu_item->priv; + GtkTearoffMenuItemPrivate *priv = tearoff_menu_item->priv; priv->torn_off = gtk_menu_get_tearoff_state (menu); } @@ -251,8 +270,12 @@ gtk_tearoff_menu_item_parent_set (GtkWidget *widget, GtkWidget *previous) { GtkTearoffMenuItem *tearoff_menu_item = GTK_TEAROFF_MENU_ITEM (widget); - GtkTearoffMenuItemPriv *priv = tearoff_menu_item->priv; - GtkMenu *menu = GTK_IS_MENU (widget->parent) ? GTK_MENU (widget->parent) : NULL; + GtkTearoffMenuItemPrivate *priv = tearoff_menu_item->priv; + GtkMenu *menu; + GtkWidget *parent; + + parent = gtk_widget_get_parent (widget); + menu = GTK_IS_MENU (parent) ? GTK_MENU (parent) : NULL; if (previous) g_signal_handlers_disconnect_by_func (previous, diff --git a/gtk/gtktearoffmenuitem.h b/gtk/gtktearoffmenuitem.h index 2b84059638..80a4dad65a 100644 --- a/gtk/gtktearoffmenuitem.h +++ b/gtk/gtktearoffmenuitem.h @@ -45,16 +45,16 @@ G_BEGIN_DECLS #define GTK_TEAROFF_MENU_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_TEAROFF_MENU_ITEM, GtkTearoffMenuItemClass)) -typedef struct _GtkTearoffMenuItem GtkTearoffMenuItem; -typedef struct _GtkTearoffMenuItemPriv GtkTearoffMenuItemPriv; -typedef struct _GtkTearoffMenuItemClass GtkTearoffMenuItemClass; +typedef struct _GtkTearoffMenuItem GtkTearoffMenuItem; +typedef struct _GtkTearoffMenuItemPrivate GtkTearoffMenuItemPrivate; +typedef struct _GtkTearoffMenuItemClass GtkTearoffMenuItemClass; struct _GtkTearoffMenuItem { GtkMenuItem menu_item; /* <private> */ - GtkTearoffMenuItemPriv *priv; + GtkTearoffMenuItemPrivate *priv; }; struct _GtkTearoffMenuItemClass diff --git a/gtk/gtktestutils.c b/gtk/gtktestutils.c index 3a76d6bae8..cedb5e7c46 100644 --- a/gtk/gtktestutils.c +++ b/gtk/gtktestutils.c @@ -84,12 +84,16 @@ static GSList* test_find_widget_input_windows (GtkWidget *widget, gboolean input_only) { + GdkWindow *window; GList *node, *children; GSList *matches = NULL; gpointer udata; - gdk_window_get_user_data (widget->window, &udata); - if (udata == widget && (!input_only || (GDK_IS_WINDOW (widget->window) && gdk_window_is_input_only (GDK_WINDOW (widget->window))))) - matches = g_slist_prepend (matches, widget->window); + + window = gtk_widget_get_window (widget); + + gdk_window_get_user_data (window, &udata); + if (udata == widget && (!input_only || (GDK_IS_WINDOW (window) && gdk_window_is_input_only (GDK_WINDOW (window))))) + matches = g_slist_prepend (matches, window); children = gdk_window_get_children (gtk_widget_get_parent_window (widget)); for (node = children; node; node = node->next) { @@ -272,13 +276,19 @@ widget_geo_dist (GtkWidget *a, GtkWidget *b, GtkWidget *base) { + GtkAllocation allocation; int ax0, ay0, ax1, ay1, bx0, by0, bx1, by1, xdist = 0, ydist = 0; + + gtk_widget_get_allocation (a, &allocation); if (!gtk_widget_translate_coordinates (a, base, 0, 0, &ax0, &ay0) || - !gtk_widget_translate_coordinates (a, base, a->allocation.width, a->allocation.height, &ax1, &ay1)) + !gtk_widget_translate_coordinates (a, base, allocation.width, allocation.height, &ax1, &ay1)) return -G_MAXINT; + + gtk_widget_get_allocation (b, &allocation); if (!gtk_widget_translate_coordinates (b, base, 0, 0, &bx0, &by0) || - !gtk_widget_translate_coordinates (b, base, b->allocation.width, b->allocation.height, &bx1, &by1)) + !gtk_widget_translate_coordinates (b, base, allocation.width, allocation.height, &bx1, &by1)) return +G_MAXINT; + if (bx0 >= ax1) xdist = bx0 - ax1; else if (ax0 >= bx1) @@ -287,6 +297,7 @@ widget_geo_dist (GtkWidget *a, ydist = by0 - ay1; else if (ay0 >= by1) ydist = ay0 - by1; + return xdist + ydist; } @@ -329,7 +340,7 @@ gtk_test_find_sibling (GtkWidget *base_widget, /* find all sibling candidates */ while (tmpwidget) { - tmpwidget = tmpwidget->parent; + tmpwidget = gtk_widget_get_parent (tmpwidget); siblings = g_list_concat (siblings, test_list_descendants (tmpwidget, widget_type)); } /* sort them by distance to base_widget */ diff --git a/gtk/gtktextbufferserialize.c b/gtk/gtktextbufferserialize.c index 76040f25c3..04f684bd4f 100644 --- a/gtk/gtktextbufferserialize.c +++ b/gtk/gtktextbufferserialize.c @@ -842,7 +842,7 @@ check_id_or_name (GMarkupParseContext *context, { set_error (error, context, G_MARKUP_ERROR, G_MARKUP_ERROR_PARSE, - _("<%s> element has invalid id \"%s\""), attribute_values[i]); + _("<%s> element has invalid ID \"%s\""), attribute_values[i]); return FALSE; } } diff --git a/gtk/gtktextdisplay.c b/gtk/gtktextdisplay.c index 8e6d4521b7..67938280bd 100644 --- a/gtk/gtktextdisplay.c +++ b/gtk/gtktextdisplay.c @@ -179,6 +179,7 @@ gtk_text_renderer_prepare_run (PangoRenderer *renderer, PangoLayoutRun *run) { GtkTextRenderer *text_renderer = GTK_TEXT_RENDERER (renderer); + GtkStyle *style; GdkColor *bg_color, *fg_color, *underline_color; GtkTextAppearance *appearance; @@ -194,15 +195,16 @@ gtk_text_renderer_prepare_run (PangoRenderer *renderer, text_renderer_set_gdk_color (text_renderer, PANGO_RENDER_PART_BACKGROUND, bg_color); + style = gtk_widget_get_style (text_renderer->widget); if (text_renderer->state == SELECTED) { if (gtk_widget_has_focus (text_renderer->widget)) - fg_color = &text_renderer->widget->style->text[GTK_STATE_SELECTED]; + fg_color = &style->text[GTK_STATE_SELECTED]; else - fg_color = &text_renderer->widget->style->text[GTK_STATE_ACTIVE]; + fg_color = &style->text[GTK_STATE_ACTIVE]; } else if (text_renderer->state == CURSOR && gtk_widget_has_focus (text_renderer->widget)) - fg_color = &text_renderer->widget->style->base[GTK_STATE_NORMAL]; + fg_color = &style->base[GTK_STATE_NORMAL]; else fg_color = &appearance->fg_color; @@ -352,20 +354,22 @@ gtk_text_renderer_draw_shape (PangoRenderer *renderer, int y) { GtkTextRenderer *text_renderer = GTK_TEXT_RENDERER (renderer); + GtkStyle *style; GdkColor *fg; + style = gtk_widget_get_style (text_renderer->widget); if (text_renderer->state == SELECTED) { if (gtk_widget_has_focus (text_renderer->widget)) - fg = &text_renderer->widget->style->text[GTK_STATE_SELECTED]; + fg = &style->text[GTK_STATE_SELECTED]; else - fg = &text_renderer->widget->style->text[GTK_STATE_SELECTED]; + fg = &style->text[GTK_STATE_SELECTED]; } else if (text_renderer->state == CURSOR && gtk_widget_has_focus (text_renderer->widget)) - fg = &text_renderer->widget->style->base[GTK_STATE_NORMAL]; + fg = &style->base[GTK_STATE_NORMAL]; else - fg = &text_renderer->widget->style->text[GTK_STATE_NORMAL]; - + fg = &style->text[GTK_STATE_NORMAL]; + if (attr->data == NULL) { /* This happens if we have an empty widget anchor. Draw @@ -537,6 +541,7 @@ render_para (GtkTextRenderer *text_renderer, int selection_start_index, int selection_end_index) { + GtkStyle *style; PangoLayout *layout = line_display->layout; int byte_offset = 0; PangoLayoutIter *iter; @@ -544,9 +549,10 @@ render_para (GtkTextRenderer *text_renderer, int screen_width; GdkColor *selection; gint state; - gboolean first = TRUE; + style = gtk_widget_get_style (text_renderer->widget); + iter = pango_layout_get_iter (layout); pango_layout_iter_get_layout_extents (iter, NULL, &layout_logical); @@ -563,7 +569,7 @@ render_para (GtkTextRenderer *text_renderer, else state = GTK_STATE_ACTIVE; - selection = &text_renderer->widget->style->base [state]; + selection = &style->base [state]; do { @@ -752,8 +758,12 @@ render_para (GtkTextRenderer *text_renderer, /* draw text under the cursor if any */ if (!line_display->cursor_at_line_end) { - gdk_cairo_set_source_color (cr, - &text_renderer->widget->style->base[text_renderer->widget->state]); + GtkStateType state; + GtkStyle *style; + + style = gtk_widget_get_style (text_renderer->widget); + state = gtk_widget_get_state (text_renderer->widget); + gdk_cairo_set_source_color (cr, &style->base[state]); text_renderer_set_state (text_renderer, CURSOR); @@ -841,7 +851,7 @@ gtk_text_layout_draw (GtkTextLayout *layout, clip.width = width; clip.height = height; - gdk_cairo_set_source_color (cr, &widget->style->text[widget->state]); + gdk_cairo_set_source_color (cr, >k_widget_get_style (widget)->text[gtk_widget_get_state (widget)]); text_renderer = get_text_renderer (); text_renderer_begin (text_renderer, widget, cr); diff --git a/gtk/gtktexttagtable.c b/gtk/gtktexttagtable.c index 1b311a6a87..b8b7afd604 100644 --- a/gtk/gtktexttagtable.c +++ b/gtk/gtktexttagtable.c @@ -33,7 +33,7 @@ #include <stdlib.h> -struct _GtkTextTagTablePriv +struct _GtkTextTagTablePrivate { GHashTable *hash; GSList *anonymous; @@ -112,17 +112,17 @@ gtk_text_tag_table_class_init (GtkTextTagTableClass *klass) 1, GTK_TYPE_TEXT_TAG); - g_type_class_add_private (klass, sizeof (GtkTextTagTablePriv)); + g_type_class_add_private (klass, sizeof (GtkTextTagTablePrivate)); } static void gtk_text_tag_table_init (GtkTextTagTable *table) { - GtkTextTagTablePriv *priv; + GtkTextTagTablePrivate *priv; table->priv = G_TYPE_INSTANCE_GET_PRIVATE (table, GTK_TYPE_TEXT_TAG_TABLE, - GtkTextTagTablePriv); + GtkTextTagTablePrivate); priv = table->priv; priv->hash = g_hash_table_new (g_str_hash, g_str_equal); @@ -150,7 +150,7 @@ static void foreach_unref (GtkTextTag *tag, gpointer data) { GtkTextTagTable *table = GTK_TEXT_TAG_TABLE (tag->table); - GtkTextTagTablePriv *priv = table->priv; + GtkTextTagTablePrivate *priv = table->priv; GSList *tmp; /* We don't want to emit the remove signal here; so we just unparent @@ -174,7 +174,7 @@ static void gtk_text_tag_table_finalize (GObject *object) { GtkTextTagTable *table = GTK_TEXT_TAG_TABLE (object); - GtkTextTagTablePriv *priv = table->priv; + GtkTextTagTablePrivate *priv = table->priv; gtk_text_tag_table_foreach (table, foreach_unref, NULL); @@ -231,7 +231,7 @@ void gtk_text_tag_table_add (GtkTextTagTable *table, GtkTextTag *tag) { - GtkTextTagTablePriv *priv; + GtkTextTagTablePrivate *priv; guint size; g_return_if_fail (GTK_IS_TEXT_TAG_TABLE (table)); @@ -282,7 +282,7 @@ GtkTextTag* gtk_text_tag_table_lookup (GtkTextTagTable *table, const gchar *name) { - GtkTextTagTablePriv *priv; + GtkTextTagTablePrivate *priv; g_return_val_if_fail (GTK_IS_TEXT_TAG_TABLE (table), NULL); g_return_val_if_fail (name != NULL, NULL); @@ -305,7 +305,7 @@ void gtk_text_tag_table_remove (GtkTextTagTable *table, GtkTextTag *tag) { - GtkTextTagTablePriv *priv; + GtkTextTagTablePrivate *priv; GSList *tmp; g_return_if_fail (GTK_IS_TEXT_TAG_TABLE (table)); @@ -387,7 +387,7 @@ gtk_text_tag_table_foreach (GtkTextTagTable *table, GtkTextTagTableForeach func, gpointer data) { - GtkTextTagTablePriv *priv; + GtkTextTagTablePrivate *priv; struct ForeachData d; g_return_if_fail (GTK_IS_TEXT_TAG_TABLE (table)); @@ -413,7 +413,7 @@ gtk_text_tag_table_foreach (GtkTextTagTable *table, gint gtk_text_tag_table_get_size (GtkTextTagTable *table) { - GtkTextTagTablePriv *priv; + GtkTextTagTablePrivate *priv; g_return_val_if_fail (GTK_IS_TEXT_TAG_TABLE (table), 0); @@ -426,7 +426,7 @@ void _gtk_text_tag_table_add_buffer (GtkTextTagTable *table, gpointer buffer) { - GtkTextTagTablePriv *priv = table->priv; + GtkTextTagTablePrivate *priv = table->priv; priv->buffers = g_slist_prepend (priv->buffers, buffer); } @@ -445,7 +445,7 @@ void _gtk_text_tag_table_remove_buffer (GtkTextTagTable *table, gpointer buffer) { - GtkTextTagTablePriv *priv = table->priv; + GtkTextTagTablePrivate *priv = table->priv; gtk_text_tag_table_foreach (table, foreach_remove_tag, buffer); diff --git a/gtk/gtktexttagtable.h b/gtk/gtktexttagtable.h index 9ce2feb61c..9697b87bda 100644 --- a/gtk/gtktexttagtable.h +++ b/gtk/gtktexttagtable.h @@ -44,14 +44,14 @@ typedef void (* GtkTextTagTableForeach) (GtkTextTag *tag, gpointer data); #define GTK_IS_TEXT_TAG_TABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_TEXT_TAG_TABLE)) #define GTK_TEXT_TAG_TABLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_TEXT_TAG_TABLE, GtkTextTagTableClass)) -typedef struct _GtkTextTagTablePriv GtkTextTagTablePriv; -typedef struct _GtkTextTagTableClass GtkTextTagTableClass; +typedef struct _GtkTextTagTablePrivate GtkTextTagTablePrivate; +typedef struct _GtkTextTagTableClass GtkTextTagTableClass; struct _GtkTextTagTable { GObject parent_instance; - GtkTextTagTablePriv *priv; + GtkTextTagTablePrivate *priv; }; struct _GtkTextTagTableClass diff --git a/gtk/gtktextutil.c b/gtk/gtktextutil.c index d33512056b..af869b9e3b 100644 --- a/gtk/gtktextutil.c +++ b/gtk/gtktextutil.c @@ -208,6 +208,8 @@ _gtk_text_util_create_drag_icon (GtkWidget *widget, gchar *text, gsize len) { + GtkStyle *style; + GtkStateType state; GdkDrawable *drawable = NULL; PangoContext *context; PangoLayout *layout; @@ -236,16 +238,18 @@ _gtk_text_util_create_drag_icon (GtkWidget *widget, pixmap_width = layout_width / PANGO_SCALE + DRAG_ICON_LAYOUT_BORDER * 2; pixmap_height = layout_height / PANGO_SCALE + DRAG_ICON_LAYOUT_BORDER * 2; - drawable = gdk_pixmap_new (widget->window, + drawable = gdk_pixmap_new (gtk_widget_get_window (widget), pixmap_width + 2, pixmap_height + 2, -1); cr = gdk_cairo_create (drawable); + style = gtk_widget_get_style (widget); + state = gtk_widget_get_state (widget); - gdk_cairo_set_source_color (cr, &widget->style->base [gtk_widget_get_state (widget)]); + gdk_cairo_set_source_color (cr, &style->base [state]); cairo_paint (cr); - gdk_cairo_set_source_color (cr, &widget->style->text [gtk_widget_get_state (widget)]); + gdk_cairo_set_source_color (cr, &style->text [state]); cairo_move_to (cr, 1 + DRAG_ICON_LAYOUT_BORDER, 1 + DRAG_ICON_LAYOUT_BORDER); pango_cairo_show_layout (cr, layout); @@ -280,9 +284,11 @@ _gtk_text_util_create_rich_drag_icon (GtkWidget *widget, GtkTextIter *start, GtkTextIter *end) { + GtkAllocation allocation; GdkDrawable *drawable = NULL; gint pixmap_height, pixmap_width; gint layout_width, layout_height; + GtkStyle *widget_style; GtkTextBuffer *new_buffer; GtkTextLayout *layout; GtkTextAttributes *style; @@ -295,6 +301,8 @@ _gtk_text_util_create_rich_drag_icon (GtkWidget *widget, g_return_val_if_fail (start != NULL, NULL); g_return_val_if_fail (end != NULL, NULL); + widget_style = gtk_widget_get_style (widget); + new_buffer = gtk_text_buffer_new (gtk_text_buffer_get_tag_table (buffer)); gtk_text_buffer_get_start_iter (new_buffer, &iter); @@ -316,13 +324,14 @@ _gtk_text_util_create_rich_drag_icon (GtkWidget *widget, style = gtk_text_attributes_new (); - layout_width = widget->allocation.width; + gtk_widget_get_allocation (widget, &allocation); + layout_width = allocation.width; if (GTK_IS_TEXT_VIEW (widget)) { gtk_widget_ensure_style (widget); gtk_text_view_set_attributes_from_style (GTK_TEXT_VIEW (widget), - style, widget->style); + style, widget_style); layout_width = layout_width - gtk_text_view_get_border_window_size (GTK_TEXT_VIEW (widget), GTK_TEXT_WINDOW_LEFT) @@ -348,12 +357,12 @@ _gtk_text_util_create_rich_drag_icon (GtkWidget *widget, pixmap_width = layout_width + DRAG_ICON_LAYOUT_BORDER * 2; pixmap_height = layout_height + DRAG_ICON_LAYOUT_BORDER * 2; - drawable = gdk_pixmap_new (widget->window, + drawable = gdk_pixmap_new (gtk_widget_get_window (widget), pixmap_width + 2, pixmap_height + 2, -1); cr = gdk_cairo_create (drawable); - gdk_cairo_set_source_color (cr, &widget->style->base [gtk_widget_get_state (widget)]); + gdk_cairo_set_source_color (cr, &widget_style->base [gtk_widget_get_state (widget)]); cairo_paint (cr); gtk_text_layout_draw (layout, widget, drawable, diff --git a/gtk/gtktoolbar.c b/gtk/gtktoolbar.c index 3ff73c5975..69938f1c9e 100644 --- a/gtk/gtktoolbar.c +++ b/gtk/gtktoolbar.c @@ -80,7 +80,7 @@ typedef struct _ToolbarContent ToolbarContent; #define ACCEL_THRESHOLD 0.18 /* After how much time in seconds will items start speeding up */ -struct _GtkToolbarPriv +struct _GtkToolbarPrivate { GtkIconSize icon_size; GtkMenu *menu; @@ -602,7 +602,7 @@ gtk_toolbar_class_init (GtkToolbarClass *klass) add_ctrl_tab_bindings (binding_set, 0, GTK_DIR_TAB_FORWARD); add_ctrl_tab_bindings (binding_set, GDK_SHIFT_MASK, GTK_DIR_TAB_BACKWARD); - g_type_class_add_private (gobject_class, sizeof (GtkToolbarPriv)); + g_type_class_add_private (gobject_class, sizeof (GtkToolbarPrivate)); } static void @@ -618,11 +618,11 @@ toolbar_tool_shell_iface_init (GtkToolShellIface *iface) static void gtk_toolbar_init (GtkToolbar *toolbar) { - GtkToolbarPriv *priv; + GtkToolbarPrivate *priv; toolbar->priv = G_TYPE_INSTANCE_GET_PRIVATE (toolbar, GTK_TYPE_TOOLBAR, - GtkToolbarPriv); + GtkToolbarPrivate); priv = toolbar->priv; gtk_widget_set_can_focus (GTK_WIDGET (toolbar), FALSE); @@ -667,7 +667,7 @@ gtk_toolbar_set_property (GObject *object, GParamSpec *pspec) { GtkToolbar *toolbar = GTK_TOOLBAR (object); - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; switch (prop_id) { @@ -703,7 +703,7 @@ gtk_toolbar_get_property (GObject *object, GParamSpec *pspec) { GtkToolbar *toolbar = GTK_TOOLBAR (object); - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; switch (prop_id) { @@ -732,7 +732,7 @@ static void gtk_toolbar_map (GtkWidget *widget) { GtkToolbar *toolbar = GTK_TOOLBAR (widget); - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; GTK_WIDGET_CLASS (gtk_toolbar_parent_class)->map (widget); @@ -744,7 +744,7 @@ static void gtk_toolbar_unmap (GtkWidget *widget) { GtkToolbar *toolbar = GTK_TOOLBAR (widget); - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; if (priv->event_window) gdk_window_hide (priv->event_window); @@ -755,22 +755,25 @@ gtk_toolbar_unmap (GtkWidget *widget) static void gtk_toolbar_realize (GtkWidget *widget) { + GtkAllocation allocation; GtkToolbar *toolbar = GTK_TOOLBAR (widget); - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; + GdkWindow *window; GdkWindowAttr attributes; gint attributes_mask; guint border_width; gtk_widget_set_realized (widget, TRUE); + gtk_widget_get_allocation (widget, &allocation); border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); attributes.wclass = GDK_INPUT_ONLY; attributes.window_type = GDK_WINDOW_CHILD; - attributes.x = widget->allocation.x + border_width; - attributes.y = widget->allocation.y + border_width; - attributes.width = widget->allocation.width - border_width * 2; - attributes.height = widget->allocation.height - border_width * 2; + attributes.x = allocation.x + border_width; + attributes.y = allocation.y + border_width; + attributes.width = allocation.width - border_width * 2; + attributes.height = allocation.height - border_width * 2; attributes.event_mask = gtk_widget_get_events (widget); attributes.event_mask |= (GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | @@ -779,9 +782,11 @@ gtk_toolbar_realize (GtkWidget *widget) attributes_mask = GDK_WA_X | GDK_WA_Y; - widget->window = gtk_widget_get_parent_window (widget); - g_object_ref (widget->window); - widget->style = gtk_style_attach (widget->style, widget->window); + window = gtk_widget_get_parent_window (widget); + gtk_widget_set_window (widget, window); + g_object_ref (window); + + gtk_widget_style_attach (widget); priv->event_window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); @@ -792,7 +797,7 @@ static void gtk_toolbar_unrealize (GtkWidget *widget) { GtkToolbar *toolbar = GTK_TOOLBAR (widget); - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; if (priv->event_window) { @@ -808,9 +813,9 @@ static gint gtk_toolbar_expose (GtkWidget *widget, GdkEventExpose *event) { + GtkAllocation allocation; GtkToolbar *toolbar = GTK_TOOLBAR (widget); - GtkToolbarPriv *priv = toolbar->priv; - + GtkToolbarPrivate *priv = toolbar->priv; GList *list; guint border_width; @@ -818,15 +823,16 @@ gtk_toolbar_expose (GtkWidget *widget, if (gtk_widget_is_drawable (widget)) { - gtk_paint_box (widget->style, - widget->window, + gtk_widget_get_allocation (widget, &allocation); + gtk_paint_box (gtk_widget_get_style (widget), + gtk_widget_get_window (widget), gtk_widget_get_state (widget), get_shadow_type (toolbar), &event->area, widget, "toolbar", - border_width + widget->allocation.x, - border_width + widget->allocation.y, - widget->allocation.width - 2 * border_width, - widget->allocation.height - 2 * border_width); + border_width + allocation.x, + border_width + allocation.y, + allocation.width - 2 * border_width, + allocation.height - 2 * border_width); } for (list = priv->content; list != NULL; list = list->next) @@ -848,7 +854,7 @@ gtk_toolbar_size_request (GtkWidget *widget, GtkRequisition *requisition) { GtkToolbar *toolbar = GTK_TOOLBAR (widget); - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; GList *list; gint max_child_height; gint max_child_width; @@ -960,8 +966,11 @@ gtk_toolbar_size_request (GtkWidget *widget, if (get_shadow_type (toolbar) != GTK_SHADOW_NONE) { - requisition->width += 2 * widget->style->xthickness; - requisition->height += 2 * widget->style->ythickness; + GtkStyle *style; + + style = gtk_widget_get_style (widget); + requisition->width += 2 * style->xthickness; + requisition->height += 2 * style->ythickness; } priv->button_maxw = max_homogeneous_child_width; @@ -974,7 +983,7 @@ position (GtkToolbar *toolbar, gint to, gdouble elapsed) { - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; gint n_pixels; if (!priv->animation) @@ -1007,7 +1016,7 @@ compute_intermediate_allocation (GtkToolbar *toolbar, const GtkAllocation *goal, GtkAllocation *intermediate) { - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; gdouble elapsed = g_timer_elapsed (priv->timer, NULL); intermediate->x = position (toolbar, start->x, goal->x, elapsed); @@ -1045,7 +1054,7 @@ static gint get_item_size (GtkToolbar *toolbar, ToolbarContent *content) { - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; GtkRequisition requisition; toolbar_content_size_request (content, toolbar, &requisition); @@ -1070,7 +1079,7 @@ static gboolean slide_idle_handler (gpointer data) { GtkToolbar *toolbar = GTK_TOOLBAR (data); - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; GList *list; if (priv->need_sync) @@ -1163,8 +1172,10 @@ rect_within (GtkAllocation *a1, static void gtk_toolbar_begin_sliding (GtkToolbar *toolbar) { + GtkAllocation allocation; GtkWidget *widget = GTK_WIDGET (toolbar); - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; + GtkStyle *style; GList *list; gint cur_x; gint cur_y; @@ -1184,25 +1195,28 @@ gtk_toolbar_begin_sliding (GtkToolbar *toolbar) if (!priv->idle_id) priv->idle_id = gdk_threads_add_idle (slide_idle_handler, toolbar); - + + gtk_widget_get_allocation (widget, &allocation); + style = gtk_widget_get_style (widget); + rtl = (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL); vertical = (priv->orientation == GTK_ORIENTATION_VERTICAL); border_width = get_internal_padding (toolbar) + gtk_container_get_border_width (GTK_CONTAINER (toolbar)); if (rtl) { - cur_x = widget->allocation.width - border_width - widget->style->xthickness; - cur_y = widget->allocation.height - border_width - widget->style->ythickness; + cur_x = allocation.width - border_width - style->xthickness; + cur_y = allocation.height - border_width - style->ythickness; } else { - cur_x = border_width + widget->style->xthickness; - cur_y = border_width + widget->style->ythickness; + cur_x = border_width + style->xthickness; + cur_y = border_width + style->ythickness; } - - cur_x += widget->allocation.x; - cur_y += widget->allocation.y; - + + cur_x += allocation.x; + cur_y += allocation.y; + for (list = priv->content; list != NULL; list = list->next) { ToolbarContent *content = list->data; @@ -1214,7 +1228,7 @@ gtk_toolbar_begin_sliding (GtkToolbar *toolbar) toolbar_content_get_allocation (content, &item_allocation); if ((state == NORMAL && - rect_within (&item_allocation, &(widget->allocation))) || + rect_within (&item_allocation, &allocation)) || state == OVERFLOWN) { new_start_allocation = item_allocation; @@ -1226,15 +1240,15 @@ gtk_toolbar_begin_sliding (GtkToolbar *toolbar) if (vertical) { - new_start_allocation.width = widget->allocation.width - - 2 * border_width - 2 * widget->style->xthickness; + new_start_allocation.width = allocation.width - + 2 * border_width - 2 * style->xthickness; new_start_allocation.height = 0; } else { new_start_allocation.width = 0; - new_start_allocation.height = widget->allocation.height - - 2 * border_width - 2 * widget->style->ythickness; + new_start_allocation.height = allocation.height - + 2 * border_width - 2 * style->ythickness; } } @@ -1260,7 +1274,7 @@ gtk_toolbar_begin_sliding (GtkToolbar *toolbar) static void gtk_toolbar_stop_sliding (GtkToolbar *toolbar) { - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; if (priv->is_sliding) { @@ -1295,14 +1309,15 @@ static void remove_item (GtkWidget *menu_item, gpointer data) { - gtk_container_remove (GTK_CONTAINER (menu_item->parent), menu_item); + gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (menu_item)), + menu_item); } static void menu_deactivated (GtkWidget *menu, GtkToolbar *toolbar) { - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->arrow_button), FALSE); } @@ -1312,7 +1327,7 @@ menu_detached (GtkWidget *widget, GtkMenu *menu) { GtkToolbar *toolbar = GTK_TOOLBAR (widget); - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; priv->menu = NULL; } @@ -1320,7 +1335,7 @@ menu_detached (GtkWidget *widget, static void rebuild_menu (GtkToolbar *toolbar) { - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; GList *list, *children; if (!priv->menu) @@ -1386,11 +1401,13 @@ static void gtk_toolbar_size_allocate (GtkWidget *widget, GtkAllocation *allocation) { + GtkAllocation widget_allocation; GtkToolbar *toolbar = GTK_TOOLBAR (widget); - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; GtkAllocation *allocations; ItemState *new_states; GtkAllocation arrow_allocation; + GtkStyle *style; gint arrow_size; gint size, pos, short_size; GList *list; @@ -1407,20 +1424,23 @@ gtk_toolbar_size_allocate (GtkWidget *widget, gdouble elapsed; GtkAllocation item_area; GtkShadowType shadow_type; - + + style = gtk_widget_get_style (widget); + + gtk_widget_get_allocation (widget, &widget_allocation); size_changed = FALSE; - if (widget->allocation.x != allocation->x || - widget->allocation.y != allocation->y || - widget->allocation.width != allocation->width || - widget->allocation.height != allocation->height) + if (widget_allocation.x != allocation->x || + widget_allocation.y != allocation->y || + widget_allocation.width != allocation->width || + widget_allocation.height != allocation->height) { size_changed = TRUE; } if (size_changed) gtk_toolbar_stop_sliding (toolbar); - - widget->allocation = *allocation; + + gtk_widget_set_allocation (widget, allocation); border_width = gtk_container_get_border_width (GTK_CONTAINER (toolbar)); @@ -1448,8 +1468,8 @@ gtk_toolbar_size_allocate (GtkWidget *widget, if (shadow_type != GTK_SHADOW_NONE) { - available_size -= 2 * widget->style->xthickness; - short_size -= 2 * widget->style->ythickness; + available_size -= 2 * style->xthickness; + short_size -= 2 * style->ythickness; } } else @@ -1460,8 +1480,8 @@ gtk_toolbar_size_allocate (GtkWidget *widget, if (shadow_type != GTK_SHADOW_NONE) { - available_size -= 2 * widget->style->ythickness; - short_size -= 2 * widget->style->xthickness; + available_size -= 2 * style->ythickness; + short_size -= 2 * style->xthickness; } } @@ -1637,8 +1657,8 @@ gtk_toolbar_size_allocate (GtkWidget *widget, if (shadow_type != GTK_SHADOW_NONE) { - allocations[i].x += widget->style->xthickness; - allocations[i].y += widget->style->ythickness; + allocations[i].x += style->xthickness; + allocations[i].y += style->ythickness; } } @@ -1649,8 +1669,8 @@ gtk_toolbar_size_allocate (GtkWidget *widget, if (shadow_type != GTK_SHADOW_NONE) { - arrow_allocation.x += widget->style->xthickness; - arrow_allocation.y += widget->style->ythickness; + arrow_allocation.x += style->xthickness; + arrow_allocation.y += style->ythickness; } } @@ -1658,8 +1678,8 @@ gtk_toolbar_size_allocate (GtkWidget *widget, item_area.y += allocation->y; if (shadow_type != GTK_SHADOW_NONE) { - item_area.x += widget->style->xthickness; - item_area.y += widget->style->ythickness; + item_area.x += style->xthickness; + item_area.y += style->ythickness; } /* did anything change? */ @@ -1766,7 +1786,7 @@ gtk_toolbar_size_allocate (GtkWidget *widget, static void gtk_toolbar_update_button_relief (GtkToolbar *toolbar) { - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; GtkReliefStyle relief; relief = get_button_relief (toolbar); @@ -1784,13 +1804,15 @@ gtk_toolbar_style_set (GtkWidget *widget, GtkStyle *prev_style) { GtkToolbar *toolbar = GTK_TOOLBAR (widget); - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; priv->max_homogeneous_pixels = -1; if (gtk_widget_get_realized (widget)) - gtk_style_set_background (widget->style, widget->window, widget->state); - + gtk_style_set_background (gtk_widget_get_style (widget), + gtk_widget_get_window (widget), + gtk_widget_get_state (widget)); + if (prev_style) gtk_toolbar_update_button_relief (GTK_TOOLBAR (widget)); } @@ -1799,7 +1821,7 @@ static GList * gtk_toolbar_list_children_in_focus_order (GtkToolbar *toolbar, GtkDirectionType dir) { - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; GList *result = NULL; GList *list; gboolean rtl; @@ -1952,7 +1974,7 @@ toolbar_get_settings (GtkToolbar *toolbar) static void style_change_notify (GtkToolbar *toolbar) { - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; if (!priv->style_set) { @@ -1965,7 +1987,7 @@ style_change_notify (GtkToolbar *toolbar) static void icon_size_change_notify (GtkToolbar *toolbar) { - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; if (!priv->icon_size_set) { @@ -1978,7 +2000,7 @@ icon_size_change_notify (GtkToolbar *toolbar) static void animation_change_notify (GtkToolbar *toolbar) { - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; GtkSettings *settings = toolbar_get_settings (toolbar); gboolean animation; @@ -2010,7 +2032,7 @@ gtk_toolbar_screen_changed (GtkWidget *widget, GdkScreen *previous_screen) { GtkToolbar *toolbar = GTK_TOOLBAR (widget); - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; GtkSettings *old_settings = toolbar_get_settings (toolbar); GtkSettings *settings; @@ -2051,7 +2073,7 @@ find_drop_index (GtkToolbar *toolbar, gint x, gint y) { - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; GList *interesting_content; GList *list; GtkOrientation orientation; @@ -2141,7 +2163,7 @@ find_drop_index (GtkToolbar *toolbar, static void reset_all_placeholders (GtkToolbar *toolbar) { - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; GList *list; for (list = priv->content; list != NULL; list = list->next) @@ -2156,7 +2178,7 @@ static gint physical_to_logical (GtkToolbar *toolbar, gint physical) { - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; GList *list; int logical; @@ -2181,7 +2203,7 @@ static gint logical_to_physical (GtkToolbar *toolbar, gint logical) { - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; GList *list; gint physical; @@ -2231,7 +2253,7 @@ gtk_toolbar_set_drop_highlight_item (GtkToolbar *toolbar, gint index_) { ToolbarContent *content; - GtkToolbarPriv *priv; + GtkToolbarPrivate *priv; gint n_items; GtkRequisition requisition; GtkRequisition old_requisition; @@ -2387,7 +2409,7 @@ static void gtk_toolbar_show_all (GtkWidget *widget) { GtkToolbar *toolbar = GTK_TOOLBAR (widget); - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; GList *list; for (list = priv->content; list != NULL; list = list->next) @@ -2404,7 +2426,7 @@ static void gtk_toolbar_hide_all (GtkWidget *widget) { GtkToolbar *toolbar = GTK_TOOLBAR (widget); - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; GList *list; for (list = priv->content; list != NULL; list = list->next) @@ -2431,7 +2453,7 @@ gtk_toolbar_remove (GtkContainer *container, GtkWidget *widget) { GtkToolbar *toolbar = GTK_TOOLBAR (container); - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; ToolbarContent *content_to_remove; GList *list; @@ -2462,7 +2484,7 @@ gtk_toolbar_forall (GtkContainer *container, gpointer callback_data) { GtkToolbar *toolbar = GTK_TOOLBAR (container); - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; GList *list; g_return_if_fail (callback != NULL); @@ -2497,7 +2519,7 @@ gtk_toolbar_child_type (GtkContainer *container) static void gtk_toolbar_reconfigured (GtkToolbar *toolbar) { - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; GList *list; list = priv->content; @@ -2516,7 +2538,7 @@ static void gtk_toolbar_orientation_changed (GtkToolbar *toolbar, GtkOrientation orientation) { - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; if (priv->orientation != orientation) { @@ -2538,7 +2560,7 @@ static void gtk_toolbar_real_style_changed (GtkToolbar *toolbar, GtkToolbarStyle style) { - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; if (priv->style != style) { @@ -2558,8 +2580,9 @@ menu_position_func (GtkMenu *menu, gboolean *push_in, gpointer user_data) { + GtkAllocation allocation; GtkToolbar *toolbar = GTK_TOOLBAR (user_data); - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; GtkRequisition req; GtkRequisition menu_req; GdkRectangle monitor; @@ -2570,38 +2593,41 @@ menu_position_func (GtkMenu *menu, gtk_widget_size_request (GTK_WIDGET (menu), &menu_req); screen = gtk_widget_get_screen (GTK_WIDGET (menu)); - monitor_num = gdk_screen_get_monitor_at_window (screen, priv->arrow_button->window); + monitor_num = gdk_screen_get_monitor_at_window (screen, + gtk_widget_get_window (priv->arrow_button)); if (monitor_num < 0) monitor_num = 0; gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor); + gtk_widget_get_allocation (priv->arrow_button, &allocation); + gdk_window_get_origin (GTK_BUTTON (priv->arrow_button)->event_window, x, y); if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) { if (gtk_widget_get_direction (GTK_WIDGET (toolbar)) == GTK_TEXT_DIR_LTR) - *x += priv->arrow_button->allocation.width - req.width; + *x += allocation.width - req.width; else *x += req.width - menu_req.width; - if ((*y + priv->arrow_button->allocation.height + menu_req.height) <= monitor.y + monitor.height) - *y += priv->arrow_button->allocation.height; + if ((*y + allocation.height + menu_req.height) <= monitor.y + monitor.height) + *y += allocation.height; else if ((*y - menu_req.height) >= monitor.y) *y -= menu_req.height; - else if (monitor.y + monitor.height - (*y + priv->arrow_button->allocation.height) > *y) - *y += priv->arrow_button->allocation.height; + else if (monitor.y + monitor.height - (*y + allocation.height) > *y) + *y += allocation.height; else *y -= menu_req.height; } else { if (gtk_widget_get_direction (GTK_WIDGET (toolbar)) == GTK_TEXT_DIR_LTR) - *x += priv->arrow_button->allocation.width; + *x += allocation.width; else *x -= menu_req.width; if (*y + menu_req.height > monitor.y + monitor.height && - *y + priv->arrow_button->allocation.height - monitor.y > monitor.y + monitor.height - *y) - *y += priv->arrow_button->allocation.height - menu_req.height; + *y + allocation.height - monitor.y > monitor.y + monitor.height - *y) + *y += allocation.height - menu_req.height; } *push_in = FALSE; @@ -2611,7 +2637,7 @@ static void show_menu (GtkToolbar *toolbar, GdkEventButton *event) { - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; rebuild_menu (toolbar); @@ -2627,7 +2653,7 @@ static void gtk_toolbar_arrow_button_clicked (GtkWidget *button, GtkToolbar *toolbar) { - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->arrow_button)) && (!priv->menu || !gtk_widget_get_visible (GTK_WIDGET (priv->menu)))) @@ -2766,13 +2792,13 @@ gint gtk_toolbar_get_item_index (GtkToolbar *toolbar, GtkToolItem *item) { - GtkToolbarPriv *priv; + GtkToolbarPrivate *priv; GList *list; int n; g_return_val_if_fail (GTK_IS_TOOLBAR (toolbar), -1); g_return_val_if_fail (GTK_IS_TOOL_ITEM (item), -1); - g_return_val_if_fail (GTK_WIDGET (item)->parent == GTK_WIDGET (toolbar), -1); + g_return_val_if_fail (gtk_widget_get_parent (GTK_WIDGET (item)) == GTK_WIDGET (toolbar), -1); priv = toolbar->priv; @@ -2804,7 +2830,7 @@ void gtk_toolbar_set_style (GtkToolbar *toolbar, GtkToolbarStyle style) { - GtkToolbarPriv *priv; + GtkToolbarPrivate *priv; g_return_if_fail (GTK_IS_TOOLBAR (toolbar)); @@ -2841,7 +2867,7 @@ gtk_toolbar_get_style (GtkToolbar *toolbar) void gtk_toolbar_unset_style (GtkToolbar *toolbar) { - GtkToolbarPriv *priv; + GtkToolbarPrivate *priv; GtkToolbarStyle style; g_return_if_fail (GTK_IS_TOOLBAR (toolbar)); @@ -2879,7 +2905,7 @@ gtk_toolbar_unset_style (GtkToolbar *toolbar) gint gtk_toolbar_get_n_items (GtkToolbar *toolbar) { - GtkToolbarPriv *priv; + GtkToolbarPrivate *priv; g_return_val_if_fail (GTK_IS_TOOLBAR (toolbar), -1); @@ -2905,7 +2931,7 @@ GtkToolItem * gtk_toolbar_get_nth_item (GtkToolbar *toolbar, gint n) { - GtkToolbarPriv *priv; + GtkToolbarPrivate *priv; ToolbarContent *content; gint n_items; @@ -2978,7 +3004,7 @@ void gtk_toolbar_set_show_arrow (GtkToolbar *toolbar, gboolean show_arrow) { - GtkToolbarPriv *priv; + GtkToolbarPrivate *priv; g_return_if_fail (GTK_IS_TOOLBAR (toolbar)); @@ -3049,7 +3075,7 @@ gtk_toolbar_finalize (GObject *object) { GList *list; GtkToolbar *toolbar = GTK_TOOLBAR (object); - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; if (priv->arrow_button) gtk_widget_unparent (priv->arrow_button); @@ -3094,7 +3120,7 @@ void gtk_toolbar_set_icon_size (GtkToolbar *toolbar, GtkIconSize icon_size) { - GtkToolbarPriv *priv; + GtkToolbarPrivate *priv; g_return_if_fail (GTK_IS_TOOLBAR (toolbar)); g_return_if_fail (icon_size != GTK_ICON_SIZE_INVALID); @@ -3128,7 +3154,7 @@ gtk_toolbar_set_icon_size (GtkToolbar *toolbar, void gtk_toolbar_unset_icon_size (GtkToolbar *toolbar) { - GtkToolbarPriv *priv; + GtkToolbarPrivate *priv; GtkIconSize size; g_return_if_fail (GTK_IS_TOOLBAR (toolbar)); @@ -3186,7 +3212,7 @@ toolbar_content_new_tool_item (GtkToolbar *toolbar, gboolean is_placeholder, gint pos) { - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; ToolbarContent *content; content = g_slice_new0 (ToolbarContent); @@ -3216,7 +3242,7 @@ static void toolbar_content_remove (ToolbarContent *content, GtkToolbar *toolbar) { - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; gtk_widget_unparent (GTK_WIDGET (content->item)); @@ -3244,7 +3270,7 @@ calculate_max_homogeneous_pixels (GtkWidget *widget) context = gtk_widget_get_pango_context (widget); metrics = pango_context_get_metrics (context, - widget->style->font_desc, + gtk_widget_get_style (widget)->font_desc, pango_context_get_language (context)); char_width = pango_font_metrics_get_approximate_char_width (metrics); pango_font_metrics_unref (metrics); @@ -3270,7 +3296,7 @@ static gboolean toolbar_content_visible (ToolbarContent *content, GtkToolbar *toolbar) { - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; GtkToolItem *item; item = content->item; @@ -3308,7 +3334,7 @@ static gboolean toolbar_content_is_homogeneous (ToolbarContent *content, GtkToolbar *toolbar) { - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; GtkRequisition requisition; gboolean result; @@ -3593,8 +3619,11 @@ _gtk_toolbar_paint_space_line (GtkWidget *widget, const GdkRectangle *area, const GtkAllocation *allocation) { - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; GtkOrientation orientation; + GtkStateType state; + GtkStyle *style; + GdkWindow *window; const double start_fraction = (SPACE_LINE_START / SPACE_LINE_DIVISION); const double end_fraction = (SPACE_LINE_END / SPACE_LINE_DIVISION); @@ -3602,6 +3631,10 @@ _gtk_toolbar_paint_space_line (GtkWidget *widget, orientation = toolbar? priv->orientation : GTK_ORIENTATION_HORIZONTAL; + style = gtk_widget_get_style (widget); + window = gtk_widget_get_window (widget); + state = gtk_widget_get_state (widget); + if (orientation == GTK_ORIENTATION_HORIZONTAL) { gboolean wide_separators; @@ -3613,20 +3646,20 @@ _gtk_toolbar_paint_space_line (GtkWidget *widget, NULL); if (wide_separators) - gtk_paint_box (widget->style, widget->window, - gtk_widget_get_state (widget), GTK_SHADOW_ETCHED_OUT, + gtk_paint_box (style, window, + state, GTK_SHADOW_ETCHED_OUT, area, widget, "vseparator", allocation->x + (allocation->width - separator_width) / 2, allocation->y + allocation->height * start_fraction, separator_width, allocation->height * (end_fraction - start_fraction)); else - gtk_paint_vline (widget->style, widget->window, - gtk_widget_get_state (widget), area, widget, + gtk_paint_vline (style, window, + state, area, widget, "toolbar", allocation->y + allocation->height * start_fraction, allocation->y + allocation->height * end_fraction, - allocation->x + (allocation->width - widget->style->xthickness) / 2); + allocation->x + (allocation->width - style->xthickness) / 2); } else { @@ -3639,20 +3672,20 @@ _gtk_toolbar_paint_space_line (GtkWidget *widget, NULL); if (wide_separators) - gtk_paint_box (widget->style, widget->window, - gtk_widget_get_state (widget), GTK_SHADOW_ETCHED_OUT, + gtk_paint_box (style, window, + state, GTK_SHADOW_ETCHED_OUT, area, widget, "hseparator", allocation->x + allocation->width * start_fraction, allocation->y + (allocation->height - separator_height) / 2, allocation->width * (end_fraction - start_fraction), separator_height); else - gtk_paint_hline (widget->style, widget->window, - gtk_widget_get_state (widget), area, widget, + gtk_paint_hline (style, window, + state, area, widget, "toolbar", allocation->x + allocation->width * start_fraction, allocation->x + allocation->width * end_fraction, - allocation->y + (allocation->height - widget->style->ythickness) / 2); + allocation->y + (allocation->height - style->ythickness) / 2); } } @@ -3703,7 +3736,7 @@ static GtkIconSize toolbar_get_icon_size (GtkToolShell *shell) { GtkToolbar *toolbar = GTK_TOOLBAR (shell); - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; return priv->icon_size; } @@ -3712,7 +3745,7 @@ static GtkOrientation toolbar_get_orientation (GtkToolShell *shell) { GtkToolbar *toolbar = GTK_TOOLBAR (shell); - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; return priv->orientation; } @@ -3721,7 +3754,7 @@ static GtkToolbarStyle toolbar_get_style (GtkToolShell *shell) { GtkToolbar *toolbar = GTK_TOOLBAR (shell); - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; return priv->style; } @@ -3736,7 +3769,7 @@ static void toolbar_rebuild_menu (GtkToolShell *shell) { GtkToolbar *toolbar = GTK_TOOLBAR (shell); - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; GList *list; priv->need_rebuild = TRUE; diff --git a/gtk/gtktoolbar.h b/gtk/gtktoolbar.h index 4aa7c23984..922fa0e790 100644 --- a/gtk/gtktoolbar.h +++ b/gtk/gtktoolbar.h @@ -56,15 +56,15 @@ typedef enum GTK_TOOLBAR_SPACE_LINE } GtkToolbarSpaceStyle; -typedef struct _GtkToolbar GtkToolbar; -typedef struct _GtkToolbarPriv GtkToolbarPriv; -typedef struct _GtkToolbarClass GtkToolbarClass; +typedef struct _GtkToolbar GtkToolbar; +typedef struct _GtkToolbarPrivate GtkToolbarPrivate; +typedef struct _GtkToolbarClass GtkToolbarClass; struct _GtkToolbar { GtkContainer container; - GtkToolbarPriv *priv; + GtkToolbarPrivate *priv; }; struct _GtkToolbarClass diff --git a/gtk/gtktoolbutton.c b/gtk/gtktoolbutton.c index d0c850331d..bf61d25121 100644 --- a/gtk/gtktoolbutton.c +++ b/gtk/gtktoolbutton.c @@ -323,6 +323,7 @@ gtk_tool_button_construct_contents (GtkToolItem *tool_item) guint icon_spacing; GtkOrientation text_orientation = GTK_ORIENTATION_HORIZONTAL; GtkSizeGroup *size_group = NULL; + GtkWidget *parent; button->priv->contents_invalid = FALSE; @@ -330,16 +331,24 @@ gtk_tool_button_construct_contents (GtkToolItem *tool_item) "icon-spacing", &icon_spacing, NULL); - if (button->priv->icon_widget && button->priv->icon_widget->parent) + if (button->priv->icon_widget) { - gtk_container_remove (GTK_CONTAINER (button->priv->icon_widget->parent), - button->priv->icon_widget); + parent = gtk_widget_get_parent (button->priv->icon_widget); + if (parent) + { + gtk_container_remove (GTK_CONTAINER (parent), + button->priv->icon_widget); + } } - if (button->priv->label_widget && button->priv->label_widget->parent) + if (button->priv->label_widget) { - gtk_container_remove (GTK_CONTAINER (button->priv->label_widget->parent), - button->priv->label_widget); + parent = gtk_widget_get_parent (button->priv->label_widget); + if (parent) + { + gtk_container_remove (GTK_CONTAINER (parent), + button->priv->label_widget); + } } child = gtk_bin_get_child (GTK_BIN (button->priv->button)); @@ -1193,9 +1202,12 @@ gtk_tool_button_set_icon_widget (GtkToolButton *button, { if (button->priv->icon_widget) { - if (button->priv->icon_widget->parent) - gtk_container_remove (GTK_CONTAINER (button->priv->icon_widget->parent), - button->priv->icon_widget); + GtkWidget *parent; + + parent = gtk_widget_get_parent (button->priv->icon_widget); + if (parent) + gtk_container_remove (GTK_CONTAINER (parent), + button->priv->icon_widget); g_object_unref (button->priv->icon_widget); } @@ -1234,10 +1246,13 @@ gtk_tool_button_set_label_widget (GtkToolButton *button, { if (button->priv->label_widget) { - if (button->priv->label_widget->parent) - gtk_container_remove (GTK_CONTAINER (button->priv->label_widget->parent), - button->priv->label_widget); - + GtkWidget *parent; + + parent = gtk_widget_get_parent (button->priv->label_widget); + if (parent) + gtk_container_remove (GTK_CONTAINER (parent), + button->priv->label_widget); + g_object_unref (button->priv->label_widget); } diff --git a/gtk/gtktoolitem.c b/gtk/gtktoolitem.c index 94b5ea8cc8..20ad6d821f 100644 --- a/gtk/gtktoolitem.c +++ b/gtk/gtktoolitem.c @@ -318,7 +318,7 @@ static void gtk_tool_item_parent_set (GtkWidget *toolitem, GtkWidget *prev_parent) { - if (GTK_WIDGET (toolitem)->parent != NULL) + if (gtk_widget_get_parent (GTK_WIDGET (toolitem)) != NULL) gtk_tool_item_toolbar_reconfigured (GTK_TOOL_ITEM (toolitem)); } @@ -398,6 +398,7 @@ gtk_tool_item_property_notify (GObject *object, static void create_drag_window (GtkToolItem *toolitem) { + GtkAllocation allocation; GtkWidget *widget; GdkWindowAttr attributes; gint attributes_mask, border_width; @@ -405,13 +406,15 @@ create_drag_window (GtkToolItem *toolitem) g_return_if_fail (toolitem->priv->use_drag_window == TRUE); widget = GTK_WIDGET (toolitem); + border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); + gtk_widget_get_allocation (widget, &allocation); attributes.window_type = GDK_WINDOW_CHILD; - attributes.x = widget->allocation.x + border_width; - attributes.y = widget->allocation.y + border_width; - attributes.width = widget->allocation.width - border_width * 2; - attributes.height = widget->allocation.height - border_width * 2; + attributes.x = allocation.x + border_width; + attributes.y = allocation.y + border_width; + attributes.width = allocation.width - border_width * 2; + attributes.height = allocation.height - border_width * 2; attributes.wclass = GDK_INPUT_ONLY; attributes.event_mask = gtk_widget_get_events (widget); attributes.event_mask |= (GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK); @@ -427,17 +430,19 @@ static void gtk_tool_item_realize (GtkWidget *widget) { GtkToolItem *toolitem; + GdkWindow *window; toolitem = GTK_TOOL_ITEM (widget); gtk_widget_set_realized (widget, TRUE); - widget->window = gtk_widget_get_parent_window (widget); - g_object_ref (widget->window); + window = gtk_widget_get_parent_window (widget); + gtk_widget_set_window (widget, window); + g_object_ref (window); if (toolitem->priv->use_drag_window) create_drag_window(toolitem); - widget->style = gtk_style_attach (widget->style, widget->window); + gtk_widget_style_attach (widget); } static void @@ -517,17 +522,18 @@ gtk_tool_item_size_allocate (GtkWidget *widget, gint border_width; GtkWidget *child; - child = gtk_bin_get_child (GTK_BIN (widget)); - widget->allocation = *allocation; + gtk_widget_set_allocation (widget, allocation); + border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); if (toolitem->priv->drag_window) gdk_window_move_resize (toolitem->priv->drag_window, - widget->allocation.x + border_width, - widget->allocation.y + border_width, - widget->allocation.width - border_width * 2, - widget->allocation.height - border_width * 2); - + allocation->x + border_width, + allocation->y + border_width, + allocation->width - border_width * 2, + allocation->height - border_width * 2); + + child = gtk_bin_get_child (GTK_BIN (widget)); if (child && gtk_widget_get_visible (child)) { child_allocation.x = allocation->x + border_width; @@ -694,7 +700,7 @@ gtk_tool_item_get_ellipsize_mode (GtkToolItem *tool_item) g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), GTK_ORIENTATION_HORIZONTAL); - parent = GTK_WIDGET (tool_item)->parent; + parent = gtk_widget_get_parent (GTK_WIDGET (tool_item)); if (!parent || !GTK_IS_TOOL_SHELL (parent)) return PANGO_ELLIPSIZE_NONE; @@ -721,7 +727,7 @@ gtk_tool_item_get_icon_size (GtkToolItem *tool_item) g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), GTK_ICON_SIZE_LARGE_TOOLBAR); - parent = GTK_WIDGET (tool_item)->parent; + parent = gtk_widget_get_parent (GTK_WIDGET (tool_item)); if (!parent || !GTK_IS_TOOL_SHELL (parent)) return GTK_ICON_SIZE_LARGE_TOOLBAR; @@ -748,7 +754,7 @@ gtk_tool_item_get_orientation (GtkToolItem *tool_item) g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), GTK_ORIENTATION_HORIZONTAL); - parent = GTK_WIDGET (tool_item)->parent; + parent = gtk_widget_get_parent (GTK_WIDGET (tool_item)); if (!parent || !GTK_IS_TOOL_SHELL (parent)) return GTK_ORIENTATION_HORIZONTAL; @@ -791,7 +797,7 @@ gtk_tool_item_get_toolbar_style (GtkToolItem *tool_item) g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), GTK_TOOLBAR_ICONS); - parent = GTK_WIDGET (tool_item)->parent; + parent = gtk_widget_get_parent (GTK_WIDGET (tool_item)); if (!parent || !GTK_IS_TOOL_SHELL (parent)) return GTK_TOOLBAR_ICONS; @@ -819,7 +825,7 @@ gtk_tool_item_get_relief_style (GtkToolItem *tool_item) g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), GTK_RELIEF_NONE); - parent = GTK_WIDGET (tool_item)->parent; + parent = gtk_widget_get_parent (GTK_WIDGET (tool_item)); if (!parent || !GTK_IS_TOOL_SHELL (parent)) return GTK_RELIEF_NONE; @@ -846,7 +852,7 @@ gtk_tool_item_get_text_alignment (GtkToolItem *tool_item) g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), GTK_ORIENTATION_HORIZONTAL); - parent = GTK_WIDGET (tool_item)->parent; + parent = gtk_widget_get_parent (GTK_WIDGET (tool_item)); if (!parent || !GTK_IS_TOOL_SHELL (parent)) return 0.5; @@ -873,7 +879,7 @@ gtk_tool_item_get_text_orientation (GtkToolItem *tool_item) g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), GTK_ORIENTATION_HORIZONTAL); - parent = GTK_WIDGET (tool_item)->parent; + parent = gtk_widget_get_parent (GTK_WIDGET (tool_item)); if (!parent || !GTK_IS_TOOL_SHELL (parent)) return GTK_ORIENTATION_HORIZONTAL; @@ -898,7 +904,7 @@ gtk_tool_item_get_text_size_group (GtkToolItem *tool_item) g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), NULL); - parent = GTK_WIDGET (tool_item)->parent; + parent = gtk_widget_get_parent (GTK_WIDGET (tool_item)); if (!parent || !GTK_IS_TOOL_SHELL (parent)) return NULL; @@ -1325,14 +1331,16 @@ gtk_tool_item_get_proxy_menu_item (GtkToolItem *tool_item, void gtk_tool_item_rebuild_menu (GtkToolItem *tool_item) { + GtkWidget *parent; GtkWidget *widget; - + g_return_if_fail (GTK_IS_TOOL_ITEM (tool_item)); widget = GTK_WIDGET (tool_item); - if (GTK_IS_TOOL_SHELL (widget->parent)) - gtk_tool_shell_rebuild_menu (GTK_TOOL_SHELL (widget->parent)); + parent = gtk_widget_get_parent (widget); + if (GTK_IS_TOOL_SHELL (parent)) + gtk_tool_shell_rebuild_menu (GTK_TOOL_SHELL (parent)); } /** diff --git a/gtk/gtktoolitemgroup.c b/gtk/gtktoolitemgroup.c index a6b9721e90..26a0815256 100644 --- a/gtk/gtktoolitemgroup.c +++ b/gtk/gtktoolitemgroup.c @@ -264,6 +264,7 @@ gtk_tool_item_group_header_expose_event_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data) { + GtkAllocation allocation; GtkToolItemGroup *group = GTK_TOOL_ITEM_GROUP (data); GtkToolItemGroupPrivate* priv = group->priv; GtkExpanderStyle expander_style; @@ -275,18 +276,20 @@ gtk_tool_item_group_header_expose_event_cb (GtkWidget *widget, expander_style = priv->expander_style; direction = gtk_widget_get_direction (widget); + gtk_widget_get_allocation (widget, &allocation); if (GTK_ORIENTATION_VERTICAL == orientation) { if (GTK_TEXT_DIR_RTL == direction) - x = widget->allocation.x + widget->allocation.width - priv->expander_size / 2; + x = allocation.x + allocation.width - priv->expander_size / 2; else - x = widget->allocation.x + priv->expander_size / 2; - y = widget->allocation.y + widget->allocation.height / 2; + x = allocation.x + priv->expander_size / 2; + + y = allocation.y + allocation.height / 2; } else { - x = widget->allocation.x + widget->allocation.width / 2; - y = widget->allocation.y + priv->expander_size / 2; + x = allocation.x + allocation.width / 2; + y = allocation.y + priv->expander_size / 2; /* Unfortunatly gtk_paint_expander() doesn't support rotated drawing * modes. Luckily the following shady arithmetics produce the desired @@ -294,8 +297,9 @@ gtk_tool_item_group_header_expose_event_cb (GtkWidget *widget, expander_style = GTK_EXPANDER_EXPANDED - expander_style; } - gtk_paint_expander (widget->style, widget->window, - priv->header->state, + gtk_paint_expander (gtk_widget_get_style (widget), + gtk_widget_get_window (widget), + gtk_widget_get_state (priv->header), &event->area, GTK_WIDGET (group), "tool-palette-header", x, y, expander_style); @@ -1047,7 +1051,7 @@ gtk_tool_item_group_size_allocate (GtkWidget *widget, gtk_tool_item_group_real_size_allocate (widget, allocation); if (gtk_widget_get_mapped (widget)) - gdk_window_invalidate_rect (widget->window, NULL, FALSE); + gdk_window_invalidate_rect (gtk_widget_get_window (widget), NULL, FALSE); } static void @@ -1056,6 +1060,7 @@ gtk_tool_item_group_set_focus_cb (GtkWidget *window, gpointer user_data) { GtkAdjustment *adjustment; + GtkAllocation allocation, p_allocation; GtkWidget *p; /* Find this group's parent widget in the focused widget's anchestry. */ @@ -1071,26 +1076,27 @@ gtk_tool_item_group_set_focus_cb (GtkWidget *window, /* Check that the focused widgets is fully visible within * the group's parent widget and make it visible otherwise. */ - adjustment = gtk_tool_palette_get_hadjustment (GTK_TOOL_PALETTE (p)); adjustment = gtk_tool_palette_get_vadjustment (GTK_TOOL_PALETTE (p)); if (adjustment) { int y; + gtk_widget_get_allocation (widget, &allocation); + gtk_widget_get_allocation (p, &p_allocation); + /* Handle vertical adjustment. */ if (gtk_widget_translate_coordinates (widget, p, 0, 0, NULL, &y) && y < 0) { y += adjustment->value; - gtk_adjustment_clamp_page (adjustment, y, y + widget->allocation.height); + gtk_adjustment_clamp_page (adjustment, y, y + allocation.height); } - else if (gtk_widget_translate_coordinates - (widget, p, 0, widget->allocation.height, NULL, &y) && - y > p->allocation.height) + else if (gtk_widget_translate_coordinates (widget, p, 0, allocation.height, NULL, &y) && + y > p_allocation.height) { y += adjustment->value; - gtk_adjustment_clamp_page (adjustment, y - widget->allocation.height, y); + gtk_adjustment_clamp_page (adjustment, y - allocation.height, y); } } @@ -1100,19 +1106,21 @@ gtk_tool_item_group_set_focus_cb (GtkWidget *window, { int x; + gtk_widget_get_allocation (widget, &allocation); + gtk_widget_get_allocation (p, &p_allocation); + /* Handle horizontal adjustment. */ if (gtk_widget_translate_coordinates (widget, p, 0, 0, &x, NULL) && x < 0) { x += adjustment->value; - gtk_adjustment_clamp_page (adjustment, x, x + widget->allocation.width); + gtk_adjustment_clamp_page (adjustment, x, x + allocation.width); } - else if (gtk_widget_translate_coordinates - (widget, p, widget->allocation.width, 0, &x, NULL) && - x > p->allocation.width) + else if (gtk_widget_translate_coordinates (widget, p, allocation.width, 0, &x, NULL) && + x > p_allocation.width) { x += adjustment->value; - gtk_adjustment_clamp_page (adjustment, x - widget->allocation.width, x); + gtk_adjustment_clamp_page (adjustment, x - allocation.width, x); } return; @@ -1162,19 +1170,25 @@ gtk_tool_item_group_set_toplevel_window (GtkToolItemGroup *group, static void gtk_tool_item_group_realize (GtkWidget *widget) { + GtkAllocation allocation; GtkWidget *toplevel_window; - gint attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; + GdkWindow *window; GdkWindowAttr attributes; GdkDisplay *display; + gint attributes_mask; guint border_width; + gtk_widget_set_realized (widget, TRUE); + border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); + gtk_widget_get_allocation (widget, &allocation); + attributes.window_type = GDK_WINDOW_CHILD; - attributes.x = widget->allocation.x + border_width; - attributes.y = widget->allocation.y + border_width; - attributes.width = widget->allocation.width - border_width * 2; - attributes.height = widget->allocation.height - border_width * 2; + attributes.x = allocation.x + border_width; + attributes.y = allocation.y + border_width; + attributes.width = allocation.width - border_width * 2; + attributes.height = allocation.height - border_width * 2; attributes.wclass = GDK_INPUT_OUTPUT; attributes.visual = gtk_widget_get_visual (widget); attributes.colormap = gtk_widget_get_colormap (widget); @@ -1182,23 +1196,26 @@ gtk_tool_item_group_realize (GtkWidget *widget) | GDK_VISIBILITY_NOTIFY_MASK | GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_MOTION_MASK; + attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; - widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), - &attributes, attributes_mask); + window = gdk_window_new (gtk_widget_get_parent_window (widget), + &attributes, attributes_mask); + gtk_widget_set_window (widget, window); - display = gdk_drawable_get_display (widget->window); + display = gdk_drawable_get_display (window); if (gdk_display_supports_composite (display)) - gdk_window_set_composited (widget->window, TRUE); + gdk_window_set_composited (window, TRUE); - gdk_window_set_user_data (widget->window, widget); - widget->style = gtk_style_attach (widget->style, widget->window); - gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL); - gtk_widget_set_realized (widget, TRUE); + gdk_window_set_user_data (window, widget); + + gtk_widget_style_attach (widget); + gtk_style_set_background (gtk_widget_get_style (widget), + window, GTK_STATE_NORMAL); gtk_container_forall (GTK_CONTAINER (widget), (GtkCallback) gtk_widget_set_parent_window, - widget->window); + window); gtk_widget_queue_resize_no_redraw (widget); @@ -1701,7 +1718,7 @@ gtk_tool_item_group_set_label_widget (GtkToolItemGroup *group, g_return_if_fail (GTK_IS_TOOL_ITEM_GROUP (group)); g_return_if_fail (label_widget == NULL || GTK_IS_WIDGET (label_widget)); - g_return_if_fail (label_widget == NULL || label_widget->parent == NULL); + g_return_if_fail (label_widget == NULL || gtk_widget_get_parent (label_widget) == NULL); priv = group->priv; @@ -1773,34 +1790,41 @@ gtk_tool_item_group_force_expose (GtkToolItemGroup *group) if (gtk_widget_get_realized (priv->header)) { + GtkAllocation alignment_allocation; GtkWidget *alignment = gtk_tool_item_group_get_alignment (group); GdkRectangle area; /* Find the header button's arrow area... */ - area.x = alignment->allocation.x; - area.y = alignment->allocation.y + (alignment->allocation.height - priv->expander_size) / 2; + gtk_widget_get_allocation (alignment, &alignment_allocation); + area.x = alignment_allocation.x; + area.y = alignment_allocation.y + (alignment_allocation.height - priv->expander_size) / 2; area.height = priv->expander_size; area.width = priv->expander_size; /* ... and invalidated it to get it animated. */ - gdk_window_invalidate_rect (priv->header->window, &area, TRUE); + gdk_window_invalidate_rect (gtk_widget_get_window (priv->header), &area, TRUE); } if (gtk_widget_get_realized (widget)) { + GtkAllocation allocation; GtkWidget *parent = gtk_widget_get_parent (widget); int x, y, width, height; /* Find the tool item area button's arrow area... */ - width = widget->allocation.width; - height = widget->allocation.height; + gtk_widget_get_allocation (widget, &allocation); + width = allocation.width; + height = allocation.height; gtk_widget_translate_coordinates (widget, parent, 0, 0, &x, &y); if (gtk_widget_get_visible (priv->header)) { - height -= priv->header->allocation.height; - y += priv->header->allocation.height; + GtkAllocation header_allocation; + + gtk_widget_get_allocation (priv->header, &header_allocation); + height -= header_allocation.height; + y += header_allocation.height; } /* ... and invalidated it to get it animated. */ @@ -2202,17 +2226,17 @@ gtk_tool_item_group_get_drop_item (GtkToolItemGroup *group, gint x, gint y) { - GtkAllocation *allocation; + GtkAllocation allocation; GtkOrientation orientation; GList *it; g_return_val_if_fail (GTK_IS_TOOL_ITEM_GROUP (group), NULL); - allocation = >K_WIDGET (group)->allocation; + gtk_widget_get_allocation (GTK_WIDGET (group), &allocation); orientation = gtk_tool_shell_get_orientation (GTK_TOOL_SHELL (group)); - g_return_val_if_fail (x >= 0 && x < allocation->width, NULL); - g_return_val_if_fail (y >= 0 && y < allocation->height, NULL); + g_return_val_if_fail (x >= 0 && x < allocation.width, NULL); + g_return_val_if_fail (y >= 0 && y < allocation.height, NULL); for (it = group->priv->children; it != NULL; it = it->next) { @@ -2223,13 +2247,13 @@ gtk_tool_item_group_get_drop_item (GtkToolItemGroup *group, if (!item || !gtk_tool_item_group_is_item_visible (group, child)) continue; - allocation = >K_WIDGET (item)->allocation; + gtk_widget_get_allocation (GTK_WIDGET (item), &allocation); - x0 = x - allocation->x; - y0 = y - allocation->y; + x0 = x - allocation.x; + y0 = y - allocation.y; - if (x0 >= 0 && x0 < allocation->width && - y0 >= 0 && y0 < allocation->height) + if (x0 >= 0 && x0 < allocation.width && + y0 >= 0 && y0 < allocation.height) return item; } @@ -2288,46 +2312,51 @@ void _gtk_tool_item_group_paint (GtkToolItemGroup *group, cairo_t *cr) { + GtkAllocation allocation; GtkWidget *widget = GTK_WIDGET (group); GtkToolItemGroupPrivate* priv = group->priv; - gdk_cairo_set_source_pixmap (cr, widget->window, - widget->allocation.x, - widget->allocation.y); + gtk_widget_get_allocation (widget, &allocation); + + gdk_cairo_set_source_pixmap (cr, gtk_widget_get_window (widget), + allocation.x, + allocation.y); if (priv->animation_timeout) { + GtkAllocation header_allocation; GtkOrientation orientation = gtk_tool_item_group_get_orientation (GTK_TOOL_SHELL (group)); cairo_pattern_t *mask; gdouble v0, v1; if (GTK_ORIENTATION_VERTICAL == orientation) - v1 = widget->allocation.height; + v1 = allocation.height; else - v1 = widget->allocation.width; + v1 = allocation.width; v0 = v1 - 256; + gtk_widget_get_allocation (priv->header, &header_allocation); if (!gtk_widget_get_visible (priv->header)) v0 = MAX (v0, 0); else if (GTK_ORIENTATION_VERTICAL == orientation) - v0 = MAX (v0, priv->header->allocation.height); + v0 = MAX (v0, header_allocation.height); else - v0 = MAX (v0, priv->header->allocation.width); + v0 = MAX (v0, header_allocation.width); v1 = MIN (v0 + 256, v1); if (GTK_ORIENTATION_VERTICAL == orientation) { - v0 += widget->allocation.y; - v1 += widget->allocation.y; + v0 += allocation.y; + v1 += allocation.y; mask = cairo_pattern_create_linear (0.0, v0, 0.0, v1); } else { - v0 += widget->allocation.x; - v1 += widget->allocation.x; + v0 += allocation.x; + v1 += allocation.x; mask = cairo_pattern_create_linear (v0, 0.0, v1, 0.0); } diff --git a/gtk/gtktoolpalette.c b/gtk/gtktoolpalette.c index 76f4db9dfe..15ecf3eba8 100644 --- a/gtk/gtktoolpalette.c +++ b/gtk/gtktoolpalette.c @@ -620,15 +620,18 @@ gtk_tool_palette_expose_event (GtkWidget *widget, { GtkToolPalette *palette = GTK_TOOL_PALETTE (widget); GdkDisplay *display; + GdkWindow *window; cairo_t *cr; guint i; - display = gdk_drawable_get_display (widget->window); + window = gtk_widget_get_window (widget); + + display = gdk_drawable_get_display (window); if (!gdk_display_supports_composite (display)) return FALSE; - cr = gdk_cairo_create (widget->window); + cr = gdk_cairo_create (window); gdk_cairo_region (cr, event->region); cairo_clip (cr); @@ -652,17 +655,23 @@ gtk_tool_palette_expose_event (GtkWidget *widget, static void gtk_tool_palette_realize (GtkWidget *widget) { + GtkAllocation allocation; + GdkWindow *window; GdkWindowAttr attributes; - gint attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; + gint attributes_mask; guint border_width; + gtk_widget_set_realized (widget, TRUE); + border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); + gtk_widget_get_allocation (widget, &allocation); + attributes.window_type = GDK_WINDOW_CHILD; - attributes.x = widget->allocation.x + border_width; - attributes.y = widget->allocation.y + border_width; - attributes.width = widget->allocation.width - border_width * 2; - attributes.height = widget->allocation.height - border_width * 2; + attributes.x = allocation.x + border_width; + attributes.y = allocation.y + border_width; + attributes.width = allocation.width - border_width * 2; + attributes.height = allocation.height - border_width * 2; attributes.wclass = GDK_INPUT_OUTPUT; attributes.visual = gtk_widget_get_visual (widget); attributes.colormap = gtk_widget_get_colormap (widget); @@ -670,18 +679,19 @@ gtk_tool_palette_realize (GtkWidget *widget) | GDK_VISIBILITY_NOTIFY_MASK | GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_MOTION_MASK; + attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; - widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), - &attributes, attributes_mask); + window = gdk_window_new (gtk_widget_get_parent_window (widget), + &attributes, attributes_mask); + gdk_window_set_user_data (window, widget); - gdk_window_set_user_data (widget->window, widget); - widget->style = gtk_style_attach (widget->style, widget->window); - gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL); - gtk_widget_set_realized (widget, TRUE); + gtk_widget_style_attach (widget); + gtk_style_set_background (gtk_widget_get_style (widget), + window, GTK_STATE_NORMAL); gtk_container_forall (GTK_CONTAINER (widget), (GtkCallback) gtk_widget_set_parent_window, - widget->window); + window); gtk_widget_queue_resize_no_redraw (widget); } @@ -690,8 +700,11 @@ static void gtk_tool_palette_adjustment_value_changed (GtkAdjustment *adjustment, gpointer data) { + GtkAllocation allocation; GtkWidget *widget = GTK_WIDGET (data); - gtk_tool_palette_size_allocate (widget, &widget->allocation); + + gtk_widget_get_allocation (widget, &allocation); + gtk_tool_palette_size_allocate (widget, &allocation); } static void @@ -1554,13 +1567,17 @@ gtk_tool_palette_get_drop_item (GtkToolPalette *palette, gint x, gint y) { + GtkAllocation allocation; GtkToolItemGroup *group = gtk_tool_palette_get_drop_group (palette, x, y); GtkWidget *widget = GTK_WIDGET (group); if (group) - return gtk_tool_item_group_get_drop_item (group, - x - widget->allocation.x, - y - widget->allocation.y); + { + gtk_widget_get_allocation (widget, &allocation); + return gtk_tool_item_group_get_drop_item (group, + x - allocation.x, + y - allocation.y); + } return NULL; } @@ -1583,15 +1600,15 @@ gtk_tool_palette_get_drop_group (GtkToolPalette *palette, gint x, gint y) { - GtkAllocation *allocation; + GtkAllocation allocation; guint i; g_return_val_if_fail (GTK_IS_TOOL_PALETTE (palette), NULL); - allocation = >K_WIDGET (palette)->allocation; + gtk_widget_get_allocation (GTK_WIDGET (palette), &allocation); - g_return_val_if_fail (x >= 0 && x < allocation->width, NULL); - g_return_val_if_fail (y >= 0 && y < allocation->height, NULL); + g_return_val_if_fail (x >= 0 && x < allocation.width, NULL); + g_return_val_if_fail (y >= 0 && y < allocation.height, NULL); for (i = 0; i < palette->priv->groups->len; ++i) { @@ -1603,12 +1620,13 @@ gtk_tool_palette_get_drop_group (GtkToolPalette *palette, continue; widget = GTK_WIDGET (group->widget); + gtk_widget_get_allocation (widget, &allocation); - x0 = x - widget->allocation.x; - y0 = y - widget->allocation.y; + x0 = x - allocation.x; + y0 = y - allocation.y; - if (x0 >= 0 && x0 < widget->allocation.width && - y0 >= 0 && y0 < widget->allocation.height) + if (x0 >= 0 && x0 < allocation.width && + y0 >= 0 && y0 < allocation.height) return GTK_TOOL_ITEM_GROUP (widget); } diff --git a/gtk/gtktoolshell.c b/gtk/gtktoolshell.c index 5a73c08d38..ead74d41d9 100644 --- a/gtk/gtktoolshell.c +++ b/gtk/gtktoolshell.c @@ -43,22 +43,17 @@ * Dummy structure for accessing instances of #GtkToolShellIface. */ -GType -gtk_tool_shell_get_type (void) -{ - static GType type = 0; - if (!type) - { - type = g_type_register_static_simple (G_TYPE_INTERFACE, I_("GtkToolShell"), - sizeof (GtkToolShellIface), - NULL, 0, NULL, 0); - g_type_interface_add_prerequisite (type, GTK_TYPE_WIDGET); - } +typedef GtkToolShellIface GtkToolShellInterface; +G_DEFINE_INTERFACE (GtkToolShell, gtk_tool_shell, GTK_TYPE_WIDGET); + - return type; +static void +gtk_tool_shell_default_init (GtkToolShellInterface *iface) +{ } + /** * gtk_tool_shell_get_icon_size: * @shell: a #GtkToolShell diff --git a/gtk/gtktooltip.c b/gtk/gtktooltip.c index c75f251a8c..ea4375ce74 100644 --- a/gtk/gtktooltip.c +++ b/gtk/gtktooltip.c @@ -113,6 +113,8 @@ gtk_tooltip_class_init (GtkTooltipClass *klass) static void gtk_tooltip_init (GtkTooltip *tooltip) { + GtkStyle *style; + tooltip->timeout_id = 0; tooltip->browse_mode_timeout_id = 0; @@ -136,12 +138,12 @@ gtk_tooltip_init (GtkTooltip *tooltip) g_signal_connect (tooltip->window, "hide", G_CALLBACK (gtk_tooltip_window_hide), tooltip); + style = gtk_widget_get_style (tooltip->window); + tooltip->alignment = gtk_alignment_new (0.5, 0.5, 1.0, 1.0); gtk_alignment_set_padding (GTK_ALIGNMENT (tooltip->alignment), - tooltip->window->style->ythickness, - tooltip->window->style->ythickness, - tooltip->window->style->xthickness, - tooltip->window->style->xthickness); + style->ythickness, style->ythickness, + style->xthickness, style->xthickness); gtk_container_add (GTK_CONTAINER (tooltip->window), tooltip->alignment); gtk_widget_show (tooltip->alignment); @@ -150,7 +152,7 @@ gtk_tooltip_init (GtkTooltip *tooltip) g_signal_connect_swapped (tooltip->window, "expose-event", G_CALLBACK (gtk_tooltip_paint_window), tooltip); - tooltip->box = gtk_hbox_new (FALSE, tooltip->window->style->xthickness); + tooltip->box = gtk_hbox_new (FALSE, style->xthickness); gtk_container_add (GTK_CONTAINER (tooltip->alignment), tooltip->box); gtk_widget_show (tooltip->box); @@ -498,13 +500,16 @@ gtk_tooltip_reset (GtkTooltip *tooltip) static void gtk_tooltip_window_style_set (GtkTooltip *tooltip) { + GtkStyle *style; + + style = gtk_widget_get_style (tooltip->window); + gtk_alignment_set_padding (GTK_ALIGNMENT (tooltip->alignment), - tooltip->window->style->ythickness, - tooltip->window->style->ythickness, - tooltip->window->style->xthickness, - tooltip->window->style->xthickness); + style->ythickness, style->ythickness, + style->xthickness, style->xthickness); + gtk_box_set_spacing (GTK_BOX (tooltip->box), - tooltip->window->style->xthickness); + style->xthickness); gtk_widget_queue_draw (tooltip->window); } @@ -512,16 +517,18 @@ gtk_tooltip_window_style_set (GtkTooltip *tooltip) static gboolean gtk_tooltip_paint_window (GtkTooltip *tooltip) { - gtk_paint_flat_box (tooltip->window->style, - tooltip->window->window, + GtkAllocation allocation; + + gtk_widget_get_allocation (tooltip->window, &allocation); + gtk_paint_flat_box (gtk_widget_get_style (tooltip->window), + gtk_widget_get_window (tooltip->window), GTK_STATE_NORMAL, GTK_SHADOW_OUT, NULL, tooltip->window, "tooltip", 0, 0, - tooltip->window->allocation.width, - tooltip->window->allocation.height); + allocation.width, allocation.height); return FALSE; } @@ -550,6 +557,7 @@ static void child_location_foreach (GtkWidget *child, gpointer data) { + GtkAllocation child_allocation; gint x, y; struct ChildLocation *child_loc = data; @@ -557,6 +565,8 @@ child_location_foreach (GtkWidget *child, if (!gtk_widget_is_drawable (child)) return; + gtk_widget_get_allocation (child, &child_allocation); + x = 0; y = 0; @@ -572,17 +582,17 @@ child_location_foreach (GtkWidget *child, #ifdef DEBUG_TOOLTIP g_print ("candidate: %s alloc=[(%d,%d) %dx%d] (%d, %d)->(%d, %d)\n", gtk_widget_get_name (child), - child->allocation.x, - child->allocation.y, - child->allocation.width, - child->allocation.height, + child_allocation.x, + child_allocation.y, + child_allocation.width, + child_allocation.height, child_loc->x, child_loc->y, x, y); #endif /* DEBUG_TOOLTIP */ /* (x, y) relative to child's allocation. */ - if (x >= 0 && x < child->allocation.width - && y >= 0 && y < child->allocation.height) + if (x >= 0 && x < child_allocation.width + && y >= 0 && y < child_allocation.height) { if (GTK_IS_CONTAINER (child)) { @@ -619,22 +629,28 @@ window_to_alloc (GtkWidget *dest_widget, gint *dest_x, gint *dest_y) { + GtkAllocation allocation; + + gtk_widget_get_allocation (dest_widget, &allocation); + /* Translate from window relative to allocation relative */ - if (gtk_widget_get_has_window (dest_widget) && dest_widget->parent) + if (gtk_widget_get_has_window (dest_widget) && + gtk_widget_get_parent (dest_widget)) { gint wx, wy; - gdk_window_get_position (dest_widget->window, &wx, &wy); + gdk_window_get_position (gtk_widget_get_window (dest_widget), + &wx, &wy); /* Offset coordinates if widget->window is smaller than * widget->allocation. */ - src_x += wx - dest_widget->allocation.x; - src_y += wy - dest_widget->allocation.y; + src_x += wx - allocation.x; + src_y += wy - allocation.y; } else { - src_x -= dest_widget->allocation.x; - src_y -= dest_widget->allocation.y; + src_x -= allocation.x; + src_y -= allocation.y; } if (dest_x) @@ -677,7 +693,7 @@ _gtk_widget_find_at_coords (GdkWindow *window, * coordinates stay relative to the current window. * We end up with window == widget->window, coordinates relative to that. */ - while (window && window != event_widget->window) + while (window && window != gtk_widget_get_window (event_widget)) { gdouble px, py; @@ -747,6 +763,7 @@ find_topmost_widget_coords_from_event (GdkEvent *event, gint *x, gint *y) { + GtkAllocation allocation; gint tx, ty; gdouble dx, dy; GtkWidget *tmp; @@ -760,8 +777,9 @@ find_topmost_widget_coords_from_event (GdkEvent *event, return NULL; /* Make sure the pointer can actually be on the widget returned. */ - if (tx < 0 || tx >= tmp->allocation.width || - ty < 0 || ty >= tmp->allocation.height) + gtk_widget_get_allocation (tmp, &allocation); + if (tx < 0 || tx >= allocation.width || + ty < 0 || ty >= allocation.height) return NULL; if (x) @@ -842,7 +860,7 @@ gtk_tooltip_run_requery (GtkWidget **widget, if (!return_value) { - GtkWidget *parent = (*widget)->parent; + GtkWidget *parent = gtk_widget_get_parent (*widget); if (parent) gtk_widget_translate_coordinates (*widget, parent, *x, *y, x, y); @@ -867,6 +885,7 @@ static void get_bounding_box (GtkWidget *widget, GdkRectangle *bounds) { + GtkAllocation allocation; GdkWindow *window; gint x, y; gint w, h; @@ -879,10 +898,11 @@ get_bounding_box (GtkWidget *widget, if (window == NULL) window = gtk_widget_get_window (widget); - x = widget->allocation.x; - y = widget->allocation.y; - w = widget->allocation.width; - h = widget->allocation.height; + gtk_widget_get_allocation (widget, &allocation); + x = allocation.x; + y = allocation.y; + w = allocation.width; + h = allocation.height; gdk_window_get_root_coords (window, x, y, &x1, &y1); gdk_window_get_root_coords (window, x + w, y, &x2, &y2); @@ -1276,7 +1296,8 @@ _gtk_tooltip_focus_in (GtkWidget *widget) tooltip->keyboard_widget = g_object_ref (widget); - gdk_window_get_device_position (widget->window, device, &x, &y, NULL); + gdk_window_get_device_position (gtk_widget_get_window (widget), + device, &x, &y, NULL); return_value = gtk_tooltip_run_requery (&widget, tooltip, &x, &y); if (!return_value) @@ -1376,7 +1397,7 @@ _gtk_tooltip_hide (GtkWidget *widget) toplevel = gtk_widget_get_toplevel (widget); if (widget == tooltip->tooltip_widget - || toplevel->window == tooltip->toplevel_window) + || gtk_widget_get_window (toplevel) == tooltip->toplevel_window) gtk_tooltip_hide_tooltip (tooltip); } diff --git a/gtk/gtktrayicon-x11.c b/gtk/gtktrayicon-x11.c index 5e7a75cf3b..5575277550 100644 --- a/gtk/gtktrayicon-x11.c +++ b/gtk/gtktrayicon-x11.c @@ -311,14 +311,18 @@ gtk_tray_icon_expose (GtkWidget *widget, GdkEventExpose *event) { GtkTrayIcon *icon = GTK_TRAY_ICON (widget); + GtkAllocation allocation; GtkWidget *focus_child; + GdkWindow *window; gint border_width, x, y, width, height; gboolean retval = FALSE; + window = gtk_widget_get_window (widget); + if (icon->priv->manager_visual_rgba) { /* Clear to transparent */ - cairo_t *cr = gdk_cairo_create (widget->window); + cairo_t *cr = gdk_cairo_create (window); cairo_set_source_rgba (cr, 0, 0, 0, 0); cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE); gdk_cairo_region (cr, event->region); @@ -328,7 +332,7 @@ gtk_tray_icon_expose (GtkWidget *widget, else { /* Clear to parent-relative pixmap */ - gdk_window_clear_area (widget->window, event->area.x, event->area.y, + gdk_window_clear_area (window, event->area.x, event->area.y, event->area.width, event->area.height); } @@ -338,15 +342,17 @@ gtk_tray_icon_expose (GtkWidget *widget, focus_child = gtk_container_get_focus_child (GTK_CONTAINER (widget)); if (focus_child && gtk_widget_has_focus (focus_child)) { + gtk_widget_get_allocation (widget, &allocation); border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); - x = widget->allocation.x + border_width; - y = widget->allocation.y + border_width; + x = allocation.x + border_width; + y = allocation.y + border_width; - width = widget->allocation.width - 2 * border_width; - height = widget->allocation.height - 2 * border_width; + width = allocation.width - 2 * border_width; + height = allocation.height - 2 * border_width; - gtk_paint_focus (widget->style, widget->window, + gtk_paint_focus (gtk_widget_get_style (widget), + window, gtk_widget_get_state (widget), &event->area, widget, "tray_icon", x, y, width, height); @@ -666,26 +672,29 @@ gtk_tray_icon_send_manager_message (GtkTrayIcon *icon, long data2, long data3) { + GtkWidget *widget; XClientMessageEvent ev; Display *display; - + + widget = GTK_WIDGET (icon); + memset (&ev, 0, sizeof (ev)); ev.type = ClientMessage; ev.window = window; ev.message_type = icon->priv->system_tray_opcode_atom; ev.format = 32; - ev.data.l[0] = gdk_x11_get_server_time (GTK_WIDGET (icon)->window); + ev.data.l[0] = gdk_x11_get_server_time (gtk_widget_get_window (widget)); ev.data.l[1] = message; ev.data.l[2] = data1; ev.data.l[3] = data2; ev.data.l[4] = data3; - display = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (icon))); - + display = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (widget)); + gdk_error_trap_push (); XSendEvent (display, icon->priv->manager_window, False, NoEventMask, (XEvent *)&ev); - gdk_display_sync (gtk_widget_get_display (GTK_WIDGET (icon))); + gdk_display_sync (gtk_widget_get_display (widget)); gdk_error_trap_pop (); } @@ -847,29 +856,31 @@ static void gtk_tray_icon_realize (GtkWidget *widget) { GtkTrayIcon *icon = GTK_TRAY_ICON (widget); + GdkWindow *window; /* Set our colormap before realizing */ gtk_tray_icon_set_colormap (icon); GTK_WIDGET_CLASS (gtk_tray_icon_parent_class)->realize (widget); + window = gtk_widget_get_window (widget); if (icon->priv->manager_visual_rgba) { /* Set a transparent background */ GdkColor transparent = { 0, 0, 0, 0 }; /* Only pixel=0 matters */ - gdk_window_set_background (widget->window, &transparent); + gdk_window_set_background (window, &transparent); } else { /* Set a parent-relative background pixmap */ - gdk_window_set_back_pixmap (widget->window, NULL, TRUE); + gdk_window_set_back_pixmap (window, NULL, TRUE); } GTK_NOTE (PLUGSOCKET, g_print ("GtkStatusIcon %p: realized, window: %lx, socket window: %lx\n", widget, - (gulong) GDK_WINDOW_XWINDOW (widget->window), - GTK_PLUG (icon)->socket_window ? - (gulong) GDK_WINDOW_XWINDOW (GTK_PLUG (icon)->socket_window) : 0UL)); + (gulong) GDK_WINDOW_XWINDOW (window), + gtk_plug_get_socket_window (GTK_PLUG (icon)) ? + (gulong) GDK_WINDOW_XWINDOW (gtk_plug_get_socket_window (GTK_PLUG (icon))) : 0UL)); if (icon->priv->manager_window != None) gtk_tray_icon_send_dock_request (icon); diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c index 68b5c7276e..0c43d366f7 100644 --- a/gtk/gtktreeview.c +++ b/gtk/gtktreeview.c @@ -678,7 +678,7 @@ gtk_tree_view_class_init (GtkTreeViewClass *class) /** * GtkTreeView:hover-selection: * - * Enables of disables the hover selection mode of @tree_view. + * Enables or disables the hover selection mode of @tree_view. * Hover selection makes the selected row follow the pointer. * Currently, this works only for the selection modes * %GTK_SELECTION_SINGLE and %GTK_SELECTION_BROWSE. @@ -699,7 +699,7 @@ gtk_tree_view_class_init (GtkTreeViewClass *class) /** * GtkTreeView:hover-expand: * - * Enables of disables the hover expansion mode of @tree_view. + * Enables or disables the hover expansion mode of @tree_view. * Hover expansion makes rows expand or collapse if the pointer moves * over them. * @@ -10492,21 +10492,23 @@ gtk_tree_view_ensure_interactive_directory (GtkTreeView *tree_view) if (tree_view->priv->search_window != NULL) { - if (GTK_WINDOW (toplevel)->group) - gtk_window_group_add_window (GTK_WINDOW (toplevel)->group, - GTK_WINDOW (tree_view->priv->search_window)); - else if (GTK_WINDOW (tree_view->priv->search_window)->group) - gtk_window_group_remove_window (GTK_WINDOW (tree_view->priv->search_window)->group, - GTK_WINDOW (tree_view->priv->search_window)); + if (gtk_window_has_group (GTK_WINDOW (toplevel))) + gtk_window_group_add_window (gtk_window_get_group (GTK_WINDOW (toplevel)), + GTK_WINDOW (tree_view->priv->search_window)); + else if (gtk_window_has_group (GTK_WINDOW (tree_view->priv->search_window))) + gtk_window_group_remove_window (gtk_window_get_group (GTK_WINDOW (tree_view->priv->search_window)), + GTK_WINDOW (tree_view->priv->search_window)); + gtk_window_set_screen (GTK_WINDOW (tree_view->priv->search_window), screen); + return; } tree_view->priv->search_window = gtk_window_new (GTK_WINDOW_POPUP); gtk_window_set_screen (GTK_WINDOW (tree_view->priv->search_window), screen); - if (GTK_WINDOW (toplevel)->group) - gtk_window_group_add_window (GTK_WINDOW (toplevel)->group, + if (gtk_window_has_group (GTK_WINDOW (toplevel))) + gtk_window_group_add_window (gtk_window_get_group (GTK_WINDOW (toplevel)), GTK_WINDOW (tree_view->priv->search_window)); gtk_window_set_type_hint (GTK_WINDOW (tree_view->priv->search_window), diff --git a/gtk/gtktreeviewcolumn.c b/gtk/gtktreeviewcolumn.c index 02b91c86f0..15efb835a1 100644 --- a/gtk/gtktreeviewcolumn.c +++ b/gtk/gtktreeviewcolumn.c @@ -1277,6 +1277,7 @@ gtk_tree_view_column_setup_sort_column_id_callback (GtkTreeViewColumn *tree_colu void _gtk_tree_view_column_realize_button (GtkTreeViewColumn *column) { + GtkAllocation allocation; GtkTreeView *tree_view; GdkWindowAttr attr; guint attributes_mask; @@ -1312,7 +1313,8 @@ _gtk_tree_view_column_realize_button (GtkTreeViewColumn *column) attr.width = TREE_VIEW_DRAG_WIDTH; attr.height = tree_view->priv->header_height; - attr.x = (column->button->allocation.x + (rtl ? 0 : column->button->allocation.width)) - TREE_VIEW_DRAG_WIDTH / 2; + gtk_widget_get_allocation (column->button, &allocation); + attr.x = (allocation.x + (rtl ? 0 : allocation.width)) - TREE_VIEW_DRAG_WIDTH / 2; column->window = gdk_window_new (tree_view->priv->header_window, &attr, attributes_mask); gdk_window_set_user_data (column->window, tree_view); @@ -3366,7 +3368,7 @@ _gtk_tree_view_column_cell_draw_focus (GtkTreeViewColumn *tree_column, cell_state = flags & GTK_CELL_RENDERER_SELECTED ? GTK_STATE_SELECTED : (flags & GTK_CELL_RENDERER_PRELIT ? GTK_STATE_PRELIGHT : (flags & GTK_CELL_RENDERER_INSENSITIVE ? GTK_STATE_INSENSITIVE : GTK_STATE_NORMAL)); - gtk_paint_focus (tree_column->tree_view->style, + gtk_paint_focus (gtk_widget_get_style (tree_column->tree_view), window, cell_state, cell_area, diff --git a/gtk/gtkuimanager.c b/gtk/gtkuimanager.c index 0fb76e3d0e..04c9517f5a 100644 --- a/gtk/gtkuimanager.c +++ b/gtk/gtkuimanager.c @@ -2395,7 +2395,7 @@ update_node (GtkUIManager *self, } gtk_activatable_set_related_action (GTK_ACTIVATABLE (info->proxy), NULL); - gtk_container_remove (GTK_CONTAINER (info->proxy->parent), + gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (info->proxy)), info->proxy); g_object_unref (info->proxy); info->proxy = NULL; @@ -2506,14 +2506,14 @@ update_node (GtkUIManager *self, { if (info->proxy) { - gtk_container_remove (GTK_CONTAINER (info->proxy->parent), + gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (info->proxy)), info->proxy); g_object_unref (info->proxy); info->proxy = NULL; } if (info->extra) { - gtk_container_remove (GTK_CONTAINER (info->extra->parent), + gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (info->extra)), info->extra); g_object_unref (info->extra); info->extra = NULL; @@ -2553,14 +2553,14 @@ update_node (GtkUIManager *self, { if (info->proxy) { - gtk_container_remove (GTK_CONTAINER (info->proxy->parent), + gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (info->proxy)), info->proxy); g_object_unref (info->proxy); info->proxy = NULL; } if (info->extra) { - gtk_container_remove (GTK_CONTAINER (info->extra->parent), + gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (info->extra)), info->extra); g_object_unref (info->extra); info->extra = NULL; @@ -2603,7 +2603,7 @@ update_node (GtkUIManager *self, G_CALLBACK (update_smart_separators), NULL); gtk_activatable_set_related_action (GTK_ACTIVATABLE (info->proxy), NULL); - gtk_container_remove (GTK_CONTAINER (info->proxy->parent), + gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (info->proxy)), info->proxy); g_object_unref (info->proxy); info->proxy = NULL; @@ -2661,7 +2661,7 @@ update_node (GtkUIManager *self, G_CALLBACK (update_smart_separators), NULL); gtk_activatable_set_related_action (GTK_ACTIVATABLE (info->proxy), NULL); - gtk_container_remove (GTK_CONTAINER (info->proxy->parent), + gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (info->proxy)), info->proxy); g_object_unref (info->proxy); info->proxy = NULL; @@ -2707,7 +2707,7 @@ update_node (GtkUIManager *self, if (GTK_IS_SEPARATOR_TOOL_ITEM (info->proxy)) { - gtk_container_remove (GTK_CONTAINER (info->proxy->parent), + gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (info->proxy)), info->proxy); g_object_unref (info->proxy); info->proxy = NULL; @@ -2742,7 +2742,7 @@ update_node (GtkUIManager *self, if (GTK_IS_SEPARATOR_MENU_ITEM (info->proxy)) { - gtk_container_remove (GTK_CONTAINER (info->proxy->parent), + gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (info->proxy)), info->proxy); g_object_unref (info->proxy); info->proxy = NULL; diff --git a/gtk/gtkviewport.c b/gtk/gtkviewport.c index 71fd7b167c..59a5084c5e 100644 --- a/gtk/gtkviewport.c +++ b/gtk/gtkviewport.c @@ -51,7 +51,7 @@ * exactly this, so you can ignore the presence of the viewport. */ -struct _GtkViewportPriv +struct _GtkViewportPrivate { GtkAdjustment *hadjustment; GtkAdjustment *vadjustment; @@ -183,7 +183,7 @@ gtk_viewport_class_init (GtkViewportClass *class) GTK_TYPE_ADJUSTMENT, GTK_TYPE_ADJUSTMENT); - g_type_class_add_private (class, sizeof (GtkViewportPriv)); + g_type_class_add_private (class, sizeof (GtkViewportPrivate)); } static void @@ -220,7 +220,7 @@ gtk_viewport_get_property (GObject *object, GParamSpec *pspec) { GtkViewport *viewport = GTK_VIEWPORT (object); - GtkViewportPriv *priv = viewport->priv; + GtkViewportPrivate *priv = viewport->priv; switch (prop_id) { @@ -242,11 +242,11 @@ gtk_viewport_get_property (GObject *object, static void gtk_viewport_init (GtkViewport *viewport) { - GtkViewportPriv *priv; + GtkViewportPrivate *priv; viewport->priv = G_TYPE_INSTANCE_GET_PRIVATE (viewport, GTK_TYPE_VIEWPORT, - GtkViewportPriv); + GtkViewportPrivate); priv = viewport->priv; gtk_widget_set_has_window (GTK_WIDGET (viewport), TRUE); @@ -337,7 +337,7 @@ gtk_viewport_destroy (GtkObject *object) GtkAdjustment* gtk_viewport_get_hadjustment (GtkViewport *viewport) { - GtkViewportPriv *priv; + GtkViewportPrivate *priv; g_return_val_if_fail (GTK_IS_VIEWPORT (viewport), NULL); @@ -360,7 +360,7 @@ gtk_viewport_get_hadjustment (GtkViewport *viewport) GtkAdjustment* gtk_viewport_get_vadjustment (GtkViewport *viewport) { - GtkViewportPriv *priv; + GtkViewportPrivate *priv; g_return_val_if_fail (GTK_IS_VIEWPORT (viewport), NULL); @@ -376,11 +376,13 @@ static void viewport_get_view_allocation (GtkViewport *viewport, GtkAllocation *view_allocation) { - GtkViewportPriv *priv = viewport->priv; + GtkViewportPrivate *priv = viewport->priv; + GtkStyle *style; GtkWidget *widget = GTK_WIDGET (viewport); - GtkAllocation *allocation = &widget->allocation; + GtkAllocation allocation; guint border_width; + gtk_widget_get_allocation (widget, &allocation); border_width = gtk_container_get_border_width (GTK_CONTAINER (viewport)); view_allocation->x = 0; @@ -388,12 +390,13 @@ viewport_get_view_allocation (GtkViewport *viewport, if (priv->shadow_type != GTK_SHADOW_NONE) { - view_allocation->x = widget->style->xthickness; - view_allocation->y = widget->style->ythickness; + style = gtk_widget_get_style (widget); + view_allocation->x = style->xthickness; + view_allocation->y = style->ythickness; } - view_allocation->width = MAX (1, allocation->width - view_allocation->x * 2 - border_width * 2); - view_allocation->height = MAX (1, allocation->height - view_allocation->y * 2 - border_width * 2); + view_allocation->width = MAX (1, allocation.width - view_allocation->x * 2 - border_width * 2); + view_allocation->height = MAX (1, allocation.height - view_allocation->y * 2 - border_width * 2); } static void @@ -587,20 +590,25 @@ void gtk_viewport_set_shadow_type (GtkViewport *viewport, GtkShadowType type) { - GtkViewportPriv *priv; + GtkViewportPrivate *priv; + GtkAllocation allocation; + GtkWidget *widget; g_return_if_fail (GTK_IS_VIEWPORT (viewport)); + widget = GTK_WIDGET (viewport); priv = viewport->priv; if ((GtkShadowType) priv->shadow_type != type) { priv->shadow_type = type; - if (gtk_widget_get_visible (GTK_WIDGET (viewport))) + if (gtk_widget_get_visible (widget)) { - gtk_widget_size_allocate (GTK_WIDGET (viewport), &(GTK_WIDGET (viewport)->allocation)); - gtk_widget_queue_draw (GTK_WIDGET (viewport)); + gtk_widget_get_allocation (widget, &allocation); + gtk_widget_size_allocate (widget, &allocation); + gtk_widget_set_allocation (widget, &allocation); + gtk_widget_queue_draw (widget); } g_object_notify (G_OBJECT (viewport), "shadow-type"); @@ -664,12 +672,15 @@ static void gtk_viewport_realize (GtkWidget *widget) { GtkViewport *viewport = GTK_VIEWPORT (widget); - GtkViewportPriv *priv = viewport->priv; + GtkViewportPrivate *priv = viewport->priv; GtkBin *bin = GTK_BIN (widget); GtkAdjustment *hadjustment = gtk_viewport_get_hadjustment (viewport); GtkAdjustment *vadjustment = gtk_viewport_get_vadjustment (viewport); + GtkAllocation allocation; GtkAllocation view_allocation; + GtkStyle *style; GtkWidget *child; + GdkWindow *window; GdkWindowAttr attributes; gint attributes_mask; gint event_mask; @@ -679,10 +690,12 @@ gtk_viewport_realize (GtkWidget *widget) gtk_widget_set_realized (widget, TRUE); - attributes.x = widget->allocation.x + border_width; - attributes.y = widget->allocation.y + border_width; - attributes.width = widget->allocation.width - border_width * 2; - attributes.height = widget->allocation.height - border_width * 2; + gtk_widget_get_allocation (widget, &allocation); + + attributes.x = allocation.x + border_width; + attributes.y = allocation.y + border_width; + attributes.width = allocation.width - border_width * 2; + attributes.height = allocation.height - border_width * 2; attributes.window_type = GDK_WINDOW_CHILD; attributes.wclass = GDK_INPUT_OUTPUT; attributes.visual = gtk_widget_get_visual (widget); @@ -695,9 +708,10 @@ gtk_viewport_realize (GtkWidget *widget) attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; - widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), - &attributes, attributes_mask); - gdk_window_set_user_data (widget->window, viewport); + window = gdk_window_new (gtk_widget_get_parent_window (widget), + &attributes, attributes_mask); + gtk_widget_set_window (widget, window); + gdk_window_set_user_data (window, viewport); viewport_get_view_allocation (viewport, &view_allocation); @@ -707,7 +721,8 @@ gtk_viewport_realize (GtkWidget *widget) attributes.height = view_allocation.height; attributes.event_mask = 0; - priv->view_window = gdk_window_new (widget->window, &attributes, attributes_mask); + priv->view_window = gdk_window_new (window, + &attributes, attributes_mask); gdk_window_set_user_data (priv->view_window, viewport); gdk_window_set_back_pixmap (priv->view_window, NULL, FALSE); @@ -726,13 +741,14 @@ gtk_viewport_realize (GtkWidget *widget) if (child) gtk_widget_set_parent_window (child, priv->bin_window); - widget->style = gtk_style_attach (widget->style, widget->window); - gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL); - gtk_style_set_background (widget->style, priv->bin_window, GTK_STATE_NORMAL); + gtk_widget_style_attach (widget); + style = gtk_widget_get_style (widget); + gtk_style_set_background (style, window, GTK_STATE_NORMAL); + gtk_style_set_background (style, priv->bin_window, GTK_STATE_NORMAL); /* Call paint here to allow a theme to set the background without flashing */ - gtk_paint_flat_box(widget->style, priv->bin_window, GTK_STATE_NORMAL, + gtk_paint_flat_box(style, priv->bin_window, GTK_STATE_NORMAL, GTK_SHADOW_NONE, NULL, widget, "viewportbin", 0, 0, -1, -1); @@ -745,7 +761,7 @@ static void gtk_viewport_unrealize (GtkWidget *widget) { GtkViewport *viewport = GTK_VIEWPORT (widget); - GtkViewportPriv *priv = viewport->priv; + GtkViewportPrivate *priv = viewport->priv; gdk_window_set_user_data (priv->view_window, NULL); gdk_window_destroy (priv->view_window); @@ -765,9 +781,10 @@ gtk_viewport_paint (GtkWidget *widget, if (gtk_widget_is_drawable (widget)) { GtkViewport *viewport = GTK_VIEWPORT (widget); - GtkViewportPriv *priv = viewport->priv; + GtkViewportPrivate *priv = viewport->priv; - gtk_paint_shadow (widget->style, widget->window, + gtk_paint_shadow (gtk_widget_get_style (widget), + gtk_widget_get_window (widget), GTK_STATE_NORMAL, priv->shadow_type, area, widget, "viewport", 0, 0, -1, -1); @@ -783,13 +800,13 @@ gtk_viewport_expose (GtkWidget *widget, if (gtk_widget_is_drawable (widget)) { viewport = GTK_VIEWPORT (widget); - GtkViewportPriv *priv = viewport->priv; + GtkViewportPrivate *priv = viewport->priv; - if (event->window == widget->window) + if (event->window == gtk_widget_get_window (widget)) gtk_viewport_paint (widget, &event->area); else if (event->window == priv->bin_window) { - gtk_paint_flat_box(widget->style, priv->bin_window, + gtk_paint_flat_box(gtk_widget_get_style (widget), priv->bin_window, GTK_STATE_NORMAL, GTK_SHADOW_NONE, &event->area, widget, "viewportbin", 0, 0, -1, -1); @@ -807,7 +824,7 @@ gtk_viewport_add (GtkContainer *container, { GtkBin *bin = GTK_BIN (container); GtkViewport *viewport = GTK_VIEWPORT (bin); - GtkViewportPriv *priv = viewport->priv; + GtkViewportPrivate *priv = viewport->priv; g_return_if_fail (gtk_bin_get_child (bin) == NULL); @@ -820,8 +837,9 @@ static void gtk_viewport_size_allocate (GtkWidget *widget, GtkAllocation *allocation) { + GtkAllocation widget_allocation; GtkViewport *viewport = GTK_VIEWPORT (widget); - GtkViewportPriv *priv = viewport->priv; + GtkViewportPrivate *priv = viewport->priv; GtkBin *bin = GTK_BIN (widget); guint border_width; gboolean hadjustment_value_changed, vadjustment_value_changed; @@ -835,14 +853,15 @@ gtk_viewport_size_allocate (GtkWidget *widget, /* If our size changed, and we have a shadow, queue a redraw on widget->window to * redraw the shadow correctly. */ + gtk_widget_get_allocation (widget, &widget_allocation); if (gtk_widget_get_mapped (widget) && priv->shadow_type != GTK_SHADOW_NONE && - (widget->allocation.width != allocation->width || - widget->allocation.height != allocation->height)) - gdk_window_invalidate_rect (widget->window, NULL, FALSE); - - widget->allocation = *allocation; - + (widget_allocation.width != allocation->width || + widget_allocation.height != allocation->height)) + gdk_window_invalidate_rect (gtk_widget_get_window (widget), NULL, FALSE); + + gtk_widget_set_allocation (widget, allocation); + viewport_set_hadjustment_values (viewport, &hadjustment_value_changed); viewport_set_vadjustment_values (viewport, &vadjustment_value_changed); @@ -853,7 +872,8 @@ gtk_viewport_size_allocate (GtkWidget *widget, if (gtk_widget_get_realized (widget)) { GtkAllocation view_allocation; - gdk_window_move_resize (widget->window, + + gdk_window_move_resize (gtk_widget_get_window (widget), allocation->x + border_width, allocation->y + border_width, allocation->width - border_width * 2, @@ -889,7 +909,7 @@ gtk_viewport_adjustment_value_changed (GtkAdjustment *adjustment, gpointer data) { GtkViewport *viewport = GTK_VIEWPORT (data); - GtkViewportPriv *priv = viewport->priv; + GtkViewportPrivate *priv = viewport->priv; GtkBin *bin = GTK_BIN (data); GtkWidget *child; @@ -921,11 +941,15 @@ gtk_viewport_style_set (GtkWidget *widget, if (gtk_widget_get_realized (widget) && gtk_widget_get_has_window (widget)) { + GtkStyle *style; GtkViewport *viewport = GTK_VIEWPORT (widget); - GtkViewportPriv *priv = viewport->priv; + GtkViewportPrivate *priv = viewport->priv; - gtk_style_set_background (widget->style, priv->bin_window, GTK_STATE_NORMAL); - gtk_style_set_background (widget->style, widget->window, widget->state); + style = gtk_widget_get_style (widget); + gtk_style_set_background (style, priv->bin_window, GTK_STATE_NORMAL); + gtk_style_set_background (style, + gtk_widget_get_window (widget), + gtk_widget_get_state (widget)); } } @@ -944,7 +968,8 @@ gtk_viewport_get_size (GtkSizeRequest *widget, gint *natural_size) { GtkViewport *viewport = GTK_VIEWPORT (widget); - GtkViewportPriv *priv = viewport->priv; + GtkViewportPrivate *priv = viewport->priv; + GtkStyle *style; GtkWidget *child; gint child_min, child_nat; gint minimum, natural; @@ -958,10 +983,11 @@ gtk_viewport_get_size (GtkSizeRequest *widget, if (priv->shadow_type != GTK_SHADOW_NONE) { + style = gtk_widget_get_style (GTK_WIDGET (widget)); if (orientation == GTK_ORIENTATION_HORIZONTAL) - minimum += 2 * GTK_WIDGET (widget)->style->xthickness; + minimum += 2 * style->xthickness; else - minimum += 2 * GTK_WIDGET (widget)->style->ythickness; + minimum += 2 * style->ythickness; } natural = minimum; diff --git a/gtk/gtkviewport.h b/gtk/gtkviewport.h index 3495410c5a..fcbff21dd8 100644 --- a/gtk/gtkviewport.h +++ b/gtk/gtkviewport.h @@ -47,16 +47,16 @@ G_BEGIN_DECLS #define GTK_VIEWPORT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_VIEWPORT, GtkViewportClass)) -typedef struct _GtkViewport GtkViewport; -typedef struct _GtkViewportPriv GtkViewportPriv; -typedef struct _GtkViewportClass GtkViewportClass; +typedef struct _GtkViewport GtkViewport; +typedef struct _GtkViewportPrivate GtkViewportPrivate; +typedef struct _GtkViewportClass GtkViewportClass; struct _GtkViewport { GtkBin bin; /* <private> */ - GtkViewportPriv *priv; + GtkViewportPrivate *priv; }; struct _GtkViewportClass diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 5bdd0a9c89..68833acd13 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -5210,8 +5210,7 @@ gtk_widget_real_grab_focus (GtkWidget *focus_widget) toplevel = gtk_widget_get_toplevel (focus_widget); if (gtk_widget_is_toplevel (toplevel) && GTK_IS_WINDOW (toplevel)) { - widget = GTK_WINDOW (toplevel)->focus_widget; - + widget = gtk_window_get_focus (GTK_WINDOW (toplevel)); if (widget == focus_widget) { /* We call _gtk_window_internal_set_focus() here so that the @@ -5442,7 +5441,7 @@ gtk_widget_is_focus (GtkWidget *widget) toplevel = gtk_widget_get_toplevel (widget); if (GTK_IS_WINDOW (toplevel)) - return widget == GTK_WINDOW (toplevel)->focus_widget; + return widget == gtk_window_get_focus (GTK_WINDOW (toplevel)); else return FALSE; } @@ -7516,7 +7515,7 @@ gtk_widget_get_screen_unchecked (GtkWidget *widget) if (gtk_widget_is_toplevel (toplevel)) { if (GTK_IS_WINDOW (toplevel)) - return GTK_WINDOW (toplevel)->screen; + return gtk_window_get_screen (GTK_WINDOW (toplevel)); else if (GTK_IS_INVISIBLE (toplevel)) return gtk_invisible_get_screen (GTK_INVISIBLE (widget)); } diff --git a/gtk/gtkwin32embedwidget.c b/gtk/gtkwin32embedwidget.c index c8d892f0ae..2efb763760 100644 --- a/gtk/gtkwin32embedwidget.c +++ b/gtk/gtkwin32embedwidget.c @@ -111,13 +111,15 @@ BOOL _gtk_win32_embed_widget_dialog_procedure (GtkWin32EmbedWidget *embed_widget, HWND wnd, UINT message, WPARAM wparam, LPARAM lparam) { + GtkAllocation allocation; GtkWidget *widget = GTK_WIDGET (embed_widget); if (message == WM_SIZE) { - widget->allocation.width = LOWORD(lparam); - widget->allocation.height = HIWORD(lparam); - + allocation.width = LOWORD(lparam); + allocation.height = HIWORD(lparam); + gtk_widget_set_allocation (widget, &allocation); + gtk_widget_queue_resize (widget); } @@ -172,15 +174,17 @@ gtk_win32_embed_widget_realize (GtkWidget *widget) { GtkWindow *window = GTK_WINDOW (widget); GtkWin32EmbedWidget *embed_widget = GTK_WIN32_EMBED_WIDGET (widget); + GtkAllocation allocation; + GdkWindow *gdk_window; GdkWindowAttr attributes; gint attributes_mask; LONG_PTR styles; + gtk_widget_get_allocation (widget, &allocation); + /* ensure widget tree is properly size allocated */ - if (widget->allocation.x == -1 && - widget->allocation.y == -1 && - widget->allocation.width == 1 && - widget->allocation.height == 1) + if (allocation.x == -1 && allocation.y == -1 && + allocation.width == 1 && allocation.height == 1) { GtkRequisition requisition; GtkAllocation allocation = { 0, 0, 200, 200 }; @@ -201,12 +205,14 @@ gtk_win32_embed_widget_realize (GtkWidget *widget) gtk_widget_set_realized (widget, TRUE); + gtk_widget_get_allocation (widget, &allocation); + attributes.window_type = GDK_WINDOW_CHILD; attributes.title = window->title; attributes.wmclass_name = window->wmclass_name; attributes.wmclass_class = window->wmclass_class; - attributes.width = widget->allocation.width; - attributes.height = widget->allocation.height; + attributes.width = allocation.width; + attributes.height = allocation.height; attributes.wclass = GDK_INPUT_OUTPUT; /* this isn't right - we should match our parent's visual/colormap. @@ -226,22 +232,22 @@ gtk_win32_embed_widget_realize (GtkWidget *widget) attributes_mask |= (window->title ? GDK_WA_TITLE : 0); attributes_mask |= (window->wmclass_name ? GDK_WA_WMCLASS : 0); - widget->window = gdk_window_new (embed_widget->parent_window, - &attributes, attributes_mask); - - gdk_window_set_user_data (widget->window, window); + gdk_window = gdk_window_new (embed_widget->parent_window, + &attributes, attributes_mask); + gtk_widget_set_window (widget, gdk_window); + gdk_window_set_user_data (gdk_window, window); embed_widget->old_window_procedure = (gpointer) - SetWindowLongPtrW(GDK_WINDOW_HWND (widget->window), + SetWindowLongPtrW(GDK_WINDOW_HWND (gdk_window), GWLP_WNDPROC, (LONG_PTR)gtk_win32_embed_widget_window_process); /* Enable tab to focus the widget */ - styles = GetWindowLongPtr(GDK_WINDOW_HWND (widget->window), GWL_STYLE); - SetWindowLongPtrW(GDK_WINDOW_HWND (widget->window), GWL_STYLE, styles | WS_TABSTOP); - - widget->style = gtk_style_attach (widget->style, widget->window); - gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL); + styles = GetWindowLongPtr(GDK_WINDOW_HWND (gdk_window), GWL_STYLE); + SetWindowLongPtrW(GDK_WINDOW_HWND (gdk_window), GWL_STYLE, styles | WS_TABSTOP); + + gtk_widget_style_attach (widget); + gtk_style_set_background (gtk_widget_get_style (widget), gdk_window, GTK_STATE_NORMAL); } static void @@ -275,14 +281,14 @@ gtk_win32_embed_widget_map (GtkWidget *widget) !gtk_widget_get_mapped (child)) gtk_widget_map (child); - gdk_window_show (widget->window); + gdk_window_show (gtk_widget_get_window (widget)); } static void gtk_win32_embed_widget_unmap (GtkWidget *widget) { gtk_widget_set_mapped (widget, FALSE); - gdk_window_hide (widget->window); + gdk_window_hide (gtk_widget_get_window (widget)); } static void @@ -292,10 +298,10 @@ gtk_win32_embed_widget_size_allocate (GtkWidget *widget, GtkBin *bin = GTK_BIN (widget); GtkWidget *child; - widget->allocation = *allocation; + gtk_widget_set_allocation (widget, allocation); if (gtk_widget_get_realized (widget)) - gdk_window_move_resize (widget->window, + gdk_window_move_resize (gtk_widget_get_window (widget), allocation->x, allocation->y, allocation->width, allocation->height); @@ -383,5 +389,5 @@ gtk_win32_embed_widget_set_focus (GtkWindow *window, { GTK_WINDOW_CLASS (gtk_win32_embed_widget_parent_class)->set_focus (window, focus); - gdk_window_focus (GTK_WIDGET(window)->window, 0); + gdk_window_focus (gtk_widget_get_window (GTK_WIDGET(window)), 0); } diff --git a/gtk/gtkwindow-decorate.c b/gtk/gtkwindow-decorate.c index 010b76ee29..ea14b5218c 100644 --- a/gtk/gtkwindow-decorate.c +++ b/gtk/gtkwindow-decorate.c @@ -278,20 +278,6 @@ gtk_decorated_window_realize (GtkWindow *window) font_desc = pango_font_description_from_string(DECORATION_TITLE_FONT); pango_layout_set_font_description (deco->title_layout, font_desc); pango_font_description_free (font_desc); - -#if 0 - /* What is this code exactly doing? I remember we were using the - decorated windows with the DirectFB port and it did just work, - and there was definitely no code in linux-fb involved. */ - gdk_fb_window_set_child_handler (window->frame, - gtk_decorated_window_inner_change, - gtk_decorated_window_inner_get_pos, - window); - - /* This is a huge hack to make frames have the same shape as - the window they wrap */ - gdk_window_shape_combine_mask (window->frame, GDK_FB_USE_CHILD_SHAPE, 0, 0); -#endif } @@ -816,7 +802,7 @@ gtk_decorated_window_move_resize_window (GtkWindow *window, gint width, gint height) { - gdk_window_move_resize (GTK_WIDGET (window)->window, + gdk_window_move_resize (gtk_widget_get_window (GTK_WIDGET (window)), x, y, width, height); } #endif diff --git a/gtk/gtkwrapbox.c b/gtk/gtkwrapbox.c new file mode 100644 index 0000000000..eba306f50b --- /dev/null +++ b/gtk/gtkwrapbox.c @@ -0,0 +1,2403 @@ +/* gtkwrapbox.c + * Copyright (C) 2007-2010 Openismus GmbH + * + * Authors: + * Tristan Van Berkom <tristanvb@openismus.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + + +/** + * SECTION:gtkwrapbox + * @Short_Description: A container that wraps its children; + * @Title: GtkWrapBox + * + * #GtkWrapBox allocates space for an ordered list of children + * by wrapping them over in the box's orentation. + * + */ + +#include "config.h" +#include "gtksizerequest.h" +#include "gtkorientable.h" +#include "gtkwrapbox.h" +#include "gtkintl.h" + + +typedef struct _GtkWrapBoxChild GtkWrapBoxChild; + +enum { + PROP_0, + PROP_ORIENTATION, + PROP_ALLOCATION_MODE, + PROP_SPREADING, + PROP_HORIZONTAL_SPACING, + PROP_VERTICAL_SPACING, + PROP_MINIMUM_LINE_CHILDREN, + PROP_NATURAL_LINE_CHILDREN +}; + +enum { + CHILD_PROP_0, + CHILD_PROP_X_EXPAND, + CHILD_PROP_X_FILL, + CHILD_PROP_Y_EXPAND, + CHILD_PROP_Y_FILL, + CHILD_PROP_X_PADDING, + CHILD_PROP_Y_PADDING +}; + +struct _GtkWrapBoxPriv { + GtkOrientation orientation; + GtkWrapAllocationMode mode; + GtkWrapBoxSpreading spreading; + + guint16 vertical_spacing; + guint16 horizontal_spacing; + + guint16 minimum_line_children; + guint16 natural_line_children; + + GList *children; +}; + +struct _GtkWrapBoxChild { + GtkWidget *widget; + + guint16 xpadding; + guint16 ypadding; + + guint16 xexpand : 1; + guint16 xfill : 1; + guint16 yexpand : 1; + guint16 yfill : 1; +}; + +/* GObjectClass */ +static void gtk_wrap_box_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec); +static void gtk_wrap_box_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec); + +/* GtkWidgetClass */ +static void gtk_wrap_box_size_allocate (GtkWidget *widget, + GtkAllocation *allocation); + +/* GtkContainerClass */ +static void gtk_wrap_box_add (GtkContainer *container, + GtkWidget *widget); +static void gtk_wrap_box_remove (GtkContainer *container, + GtkWidget *widget); +static void gtk_wrap_box_forall (GtkContainer *container, + gboolean include_internals, + GtkCallback callback, + gpointer callback_data); +static void gtk_wrap_box_set_child_property (GtkContainer *container, + GtkWidget *child, + guint property_id, + const GValue *value, + GParamSpec *pspec); +static void gtk_wrap_box_get_child_property (GtkContainer *container, + GtkWidget *child, + guint property_id, + GValue *value, + GParamSpec *pspec); +static GType gtk_wrap_box_child_type (GtkContainer *container); + + +/* GtkSizeRequest */ +static void gtk_wrap_box_size_request_init (GtkSizeRequestIface *iface); +static GtkSizeRequestMode gtk_wrap_box_get_request_mode (GtkSizeRequest *widget); +static void gtk_wrap_box_get_width (GtkSizeRequest *widget, + gint *minimum_size, + gint *natural_size); +static void gtk_wrap_box_get_height (GtkSizeRequest *widget, + gint *minimum_size, + gint *natural_size); +static void gtk_wrap_box_get_height_for_width (GtkSizeRequest *box, + gint width, + gint *minimum_height, + gint *natural_height); +static void gtk_wrap_box_get_width_for_height (GtkSizeRequest *box, + gint width, + gint *minimum_height, + gint *natural_height); + + +G_DEFINE_TYPE_WITH_CODE (GtkWrapBox, gtk_wrap_box, GTK_TYPE_CONTAINER, + G_IMPLEMENT_INTERFACE (GTK_TYPE_SIZE_REQUEST, + gtk_wrap_box_size_request_init) + G_IMPLEMENT_INTERFACE (GTK_TYPE_ORIENTABLE, NULL)) + + +static void +gtk_wrap_box_class_init (GtkWrapBoxClass *class) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS (class); + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class); + GtkContainerClass *container_class = GTK_CONTAINER_CLASS (class); + + gobject_class->get_property = gtk_wrap_box_get_property; + gobject_class->set_property = gtk_wrap_box_set_property; + + widget_class->size_allocate = gtk_wrap_box_size_allocate; + + container_class->add = gtk_wrap_box_add; + container_class->remove = gtk_wrap_box_remove; + container_class->forall = gtk_wrap_box_forall; + container_class->child_type = gtk_wrap_box_child_type; + container_class->set_child_property = gtk_wrap_box_set_child_property; + container_class->get_child_property = gtk_wrap_box_get_child_property; + + /* GObjectClass properties */ + g_object_class_override_property (gobject_class, PROP_ORIENTATION, "orientation"); + + /** + * GtkWrapBox:allocation-mode: + * + * The #GtkWrapAllocationMode to use. + */ + g_object_class_install_property (gobject_class, + PROP_ALLOCATION_MODE, + g_param_spec_enum ("allocation-mode", + P_("Allocation Mode"), + P_("The allocation mode to use"), + GTK_TYPE_WRAP_ALLOCATION_MODE, + GTK_WRAP_ALLOCATE_FREE, + G_PARAM_READABLE | G_PARAM_WRITABLE)); + + /** + * GtkWrapBox:spreading: + * + * The #GtkWrapBoxSpreading to used to define what is done with extra + * space. + */ + g_object_class_install_property (gobject_class, + PROP_SPREADING, + g_param_spec_enum ("spreading", + P_("Spreading"), + P_("The spreading mode to use"), + GTK_TYPE_WRAP_BOX_SPREADING, + GTK_WRAP_BOX_SPREAD_BEGIN, + G_PARAM_READABLE | G_PARAM_WRITABLE)); + + + /** + * GtkWrapBox:minimum-line-children: + * + * The minimum number of children to allocate consecutively in the given orientation. + * + * <note><para>Setting the minimum children per line ensures + * that a reasonably small height will be requested + * for the overall minimum width of the box.</para></note> + * + */ + g_object_class_install_property (gobject_class, + PROP_MINIMUM_LINE_CHILDREN, + g_param_spec_uint ("minimum-line-children", + P_("Minimum Line Children"), + P_("The minimum number of children to allocate " + "consecutively in the given orientation."), + 0, + 65535, + 0, + G_PARAM_READABLE | G_PARAM_WRITABLE)); + + + /** + * GtkWrapBox:natural-line-children: + * + * The maximum amount of children to request space for consecutively in the given orientation. + * + */ + g_object_class_install_property (gobject_class, + PROP_NATURAL_LINE_CHILDREN, + g_param_spec_uint ("natural-line-children", + P_("Natural Line Children"), + P_("The maximum amount of children to request space for " + "consecutively in the given orientation."), + 0, + 65535, + 0, + G_PARAM_READABLE | G_PARAM_WRITABLE)); + + /** + * GtkWrapBox:vertical-spacing: + * + * The amount of vertical space between two children. + * + */ + g_object_class_install_property (gobject_class, + PROP_VERTICAL_SPACING, + g_param_spec_uint ("vertical-spacing", + P_("Vertical spacing"), + P_("The amount of vertical space between two children"), + 0, + 65535, + 0, + G_PARAM_READABLE | G_PARAM_WRITABLE)); + + /** + * GtkWrapBox:horizontal-spacing: + * + * The amount of horizontal space between two children. + * + */ + g_object_class_install_property (gobject_class, + PROP_HORIZONTAL_SPACING, + g_param_spec_uint ("horizontal-spacing", + P_("Horizontal spacing"), + P_("The amount of horizontal space between two children"), + 0, + 65535, + 0, + G_PARAM_READABLE | G_PARAM_WRITABLE)); + + /* GtkContainerClass child properties */ + + /** + * GtkWrapBox:x-expand: + * + * Whether the child expands horizontally. + * + */ + gtk_container_class_install_child_property (container_class, + CHILD_PROP_X_EXPAND, + g_param_spec_boolean + ("x-expand", + P_("Horizontally expand"), + P_("Whether the child expands horizontally."), + FALSE, + G_PARAM_READABLE | G_PARAM_WRITABLE)); + + /** + * GtkWrapBox:x-fill: + * + * Whether the child fills its allocated horizontal space. + * + */ + gtk_container_class_install_child_property (container_class, + CHILD_PROP_X_FILL, + g_param_spec_boolean + ("x-fill", + P_("Horizontally fills"), + P_("Whether the child fills its allocated horizontal space."), + FALSE, + G_PARAM_READABLE | G_PARAM_WRITABLE)); + + /** + * GtkWrapBox:y-expand: + * + * Whether the child expands vertically. + * + */ + gtk_container_class_install_child_property (container_class, + CHILD_PROP_Y_EXPAND, + g_param_spec_boolean + ("y-expand", + P_("Vertically expand"), + P_("Whether the child expands vertically."), + FALSE, + G_PARAM_READABLE | G_PARAM_WRITABLE)); + + /** + * GtkWrapBox:y-fill: + * + * Whether the child fills its allocated vertical space. + * + */ + gtk_container_class_install_child_property (container_class, + CHILD_PROP_Y_FILL, + g_param_spec_boolean + ("y-fill", + P_("Vertically fills"), + P_("Whether the child fills its allocated vertical space."), + FALSE, + G_PARAM_READABLE | G_PARAM_WRITABLE)); + + /** + * GtkWrapBox:x-padding: + * + * Extra space to put between the child and its left and right neighbors, in pixels. + * + */ + gtk_container_class_install_child_property (container_class, + CHILD_PROP_X_PADDING, + g_param_spec_uint + ("x-padding", + P_("Horizontal padding"), + P_("Extra space to put between the child and " + "its left and right neighbors, in pixels"), + 0, 65535, 0, + G_PARAM_READABLE | G_PARAM_WRITABLE)); + + + /** + * GtkWrapBox:y-padding: + * + * Extra space to put between the child and its upper and lower neighbors, in pixels. + * + */ + gtk_container_class_install_child_property (container_class, + CHILD_PROP_Y_PADDING, + g_param_spec_uint + ("y-padding", + P_("Vertical padding"), + P_("Extra space to put between the child and " + "its upper and lower neighbors, in pixels"), + 0, 65535, 0, + G_PARAM_READABLE | G_PARAM_WRITABLE)); + + g_type_class_add_private (class, sizeof (GtkWrapBoxPriv)); +} + +static void +gtk_wrap_box_init (GtkWrapBox *box) +{ + GtkWrapBoxPriv *priv; + + box->priv = priv = + G_TYPE_INSTANCE_GET_PRIVATE (box, GTK_TYPE_WRAP_BOX, GtkWrapBoxPriv); + + priv->orientation = GTK_ORIENTATION_HORIZONTAL; + priv->mode = GTK_WRAP_ALLOCATE_FREE; + priv->spreading = GTK_WRAP_BOX_SPREAD_BEGIN; + priv->vertical_spacing = 0; + priv->horizontal_spacing = 0; + priv->children = NULL; + + gtk_widget_set_has_window (GTK_WIDGET (box), FALSE); +} + +/***************************************************** + * GObectClass * + *****************************************************/ +static void +gtk_wrap_box_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + GtkWrapBox *box = GTK_WRAP_BOX (object); + GtkWrapBoxPriv *priv = box->priv; + + switch (prop_id) + { + case PROP_ORIENTATION: + g_value_set_boolean (value, priv->orientation); + break; + case PROP_ALLOCATION_MODE: + g_value_set_enum (value, priv->mode); + break; + case PROP_SPREADING: + g_value_set_enum (value, priv->spreading); + break; + case PROP_VERTICAL_SPACING: + g_value_set_uint (value, priv->vertical_spacing); + break; + case PROP_HORIZONTAL_SPACING: + g_value_set_uint (value, priv->horizontal_spacing); + break; + case PROP_MINIMUM_LINE_CHILDREN: + g_value_set_uint (value, priv->minimum_line_children); + break; + case PROP_NATURAL_LINE_CHILDREN: + g_value_set_uint (value, priv->natural_line_children); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +gtk_wrap_box_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + GtkWrapBox *box = GTK_WRAP_BOX (object); + GtkWrapBoxPriv *priv = box->priv; + + switch (prop_id) + { + case PROP_ORIENTATION: + priv->orientation = g_value_get_enum (value); + + /* Re-box the children in the new orientation */ + gtk_widget_queue_resize (GTK_WIDGET (box)); + break; + case PROP_ALLOCATION_MODE: + gtk_wrap_box_set_allocation_mode (box, g_value_get_enum (value)); + break; + case PROP_SPREADING: + gtk_wrap_box_set_spreading (box, g_value_get_enum (value)); + break; + case PROP_VERTICAL_SPACING: + gtk_wrap_box_set_vertical_spacing (box, g_value_get_uint (value)); + break; + case PROP_HORIZONTAL_SPACING: + gtk_wrap_box_set_horizontal_spacing (box, g_value_get_uint (value)); + break; + case PROP_MINIMUM_LINE_CHILDREN: + gtk_wrap_box_set_minimum_line_children (box, g_value_get_uint (value)); + break; + case PROP_NATURAL_LINE_CHILDREN: + gtk_wrap_box_set_natural_line_children (box, g_value_get_uint (value)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +/***************************************************** + * GtkWidgetClass * + *****************************************************/ + +static gint +get_visible_children (GtkWrapBox *box) +{ + GtkWrapBoxPriv *priv = box->priv; + GList *list; + gint i = 0; + + for (list = priv->children; list; list = list->next) + { + GtkWrapBoxChild *child = list->data; + + if (!gtk_widget_get_visible (child->widget)) + continue; + + i++; + } + + return i; +} + +static gint +get_visible_expand_children (GtkWrapBox *box, + GtkOrientation orientation, + GList *cursor, + gint n_visible) +{ + GList *list; + gint i, expand_children = 0; + + for (i = 0, list = cursor; (n_visible > 0 ? i < n_visible : TRUE) && list; list = list->next) + { + GtkWrapBoxChild *child = list->data; + + if (!gtk_widget_get_visible (child->widget)) + continue; + + if ((orientation == GTK_ORIENTATION_HORIZONTAL && child->xexpand) || + (orientation == GTK_ORIENTATION_VERTICAL && child->yexpand)) + expand_children++; + + i++; + } + + return expand_children; +} + +/* Used in columned modes where all items share at least their + * equal widths or heights + */ +static void +get_average_item_size (GtkWrapBox *box, + GtkOrientation orientation, + gint *min_size, + gint *nat_size) +{ + GtkWrapBoxPriv *priv = box->priv; + GList *list; + gint max_min_size = 0; + gint max_nat_size = 0; + + for (list = priv->children; list; list = list->next) + { + GtkWrapBoxChild *child = list->data; + gint child_min, child_nat; + + if (!gtk_widget_get_visible (child->widget)) + continue; + + if (orientation == GTK_ORIENTATION_HORIZONTAL) + { + gtk_size_request_get_width (GTK_SIZE_REQUEST (child->widget), + &child_min, &child_nat); + + child_min += child->xpadding * 2; + child_nat += child->xpadding * 2; + } + else + { + gtk_size_request_get_height (GTK_SIZE_REQUEST (child->widget), + &child_min, &child_nat); + + child_min += child->ypadding * 2; + child_nat += child->ypadding * 2; + } + max_min_size = MAX (max_min_size, child_min); + max_nat_size = MAX (max_nat_size, child_nat); + } + + if (min_size) + *min_size = max_min_size; + + if (nat_size) + *nat_size = max_nat_size; +} + + +/* Gets the largest minimum/natural size for a given size + * (used to get the largest item heights for a fixed item width and the opposite) */ +static void +get_largest_size_for_opposing_orientation (GtkWrapBox *box, + GtkOrientation orientation, + gint item_size, + gint *min_item_size, + gint *nat_item_size) +{ + GtkWrapBoxPriv *priv = box->priv; + GList *list; + gint max_min_size = 0; + gint max_nat_size = 0; + + for (list = priv->children; list; list = list->next) + { + GtkWrapBoxChild *child = list->data; + gint child_min, child_nat; + + if (!gtk_widget_get_visible (child->widget)) + continue; + + if (orientation == GTK_ORIENTATION_HORIZONTAL) + { + gtk_size_request_get_height_for_width (GTK_SIZE_REQUEST (child->widget), + item_size - child->xpadding * 2, + &child_min, &child_nat); + child_min += child->ypadding * 2; + child_nat += child->ypadding * 2; + } + else + { + gtk_size_request_get_width_for_height (GTK_SIZE_REQUEST (child->widget), + item_size - child->ypadding * 2, + &child_min, &child_nat); + child_min += child->xpadding * 2; + child_nat += child->xpadding * 2; + } + + max_min_size = MAX (max_min_size, child_min); + max_nat_size = MAX (max_nat_size, child_nat); + } + + if (min_item_size) + *min_item_size = max_min_size; + + if (nat_item_size) + *nat_item_size = max_nat_size; +} + + +/* Gets the largest minimum/natural size on a single line for a given size + * (used to get the largest line heights for a fixed item width and the opposite + * while itterating over a list of children, note the new index is returned) */ +GList * +get_largest_size_for_line_in_opposing_orientation (GtkWrapBox *box, + GtkOrientation orientation, + GList *cursor, + gint line_length, + gint item_size, + gint extra_pixels, + gint *min_item_size, + gint *nat_item_size) +{ + GtkWrapBoxPriv *priv = box->priv; + GList *list; + gint max_min_size = 0; + gint max_nat_size = 0; + gint i; + + for (list = cursor, i = 0; list && i < line_length; list = list->next) + { + GtkWrapBoxChild *child = list->data; + gint child_min, child_nat, this_item_size; + + if (!gtk_widget_get_visible (child->widget)) + continue; + + /* Distribute the extra pixels to the first children in the line + * (could be fancier and spread them out more evenly) */ + this_item_size = item_size; + if (extra_pixels > 0 && + priv->spreading == GTK_WRAP_BOX_SPREAD_EXPAND) + { + this_item_size++; + extra_pixels--; + } + + if (orientation == GTK_ORIENTATION_HORIZONTAL) + { + gtk_size_request_get_height_for_width (GTK_SIZE_REQUEST (child->widget), + this_item_size - child->xpadding * 2, + &child_min, &child_nat); + child_min += child->ypadding * 2; + child_nat += child->ypadding * 2; + } + else + { + gtk_size_request_get_width_for_height (GTK_SIZE_REQUEST (child->widget), + this_item_size - child->ypadding * 2, + &child_min, &child_nat); + child_min += child->xpadding * 2; + child_nat += child->xpadding * 2; + } + + max_min_size = MAX (max_min_size, child_min); + max_nat_size = MAX (max_nat_size, child_nat); + + i++; + } + + if (min_item_size) + *min_item_size = max_min_size; + + if (nat_item_size) + *nat_item_size = max_nat_size; + + /* Return next item in the list */ + return list; +} + + +/* Gets the largest minimum/natural size on a single line for a given allocated line size + * (used to get the largest line heights for a width in pixels and the opposite + * while itterating over a list of children, note the new index is returned) */ +GList * +get_largest_size_for_free_line_in_opposing_orientation (GtkWrapBox *box, + GtkOrientation orientation, + GList *cursor, + gint min_items, + gint avail_size, + gint *min_item_size, + gint *nat_item_size, + gint *extra_pixels, + GArray **ret_array) +{ + GtkWrapBoxPriv *priv = box->priv; + GtkRequestedSize *sizes; + GList *list; + GArray *array; + gint max_min_size = 0; + gint max_nat_size = 0; + gint i, size = avail_size; + gint line_length, spacing; + gint expand_children = 0; + gint expand_per_child; + gint expand_remainder; + + if (orientation == GTK_ORIENTATION_HORIZONTAL) + spacing = priv->horizontal_spacing; + else + spacing = priv->vertical_spacing; + + /* First determine the length of this line in items (how many items fit) */ + for (i = 0, list = cursor; size > 0 && list; list = list->next) + { + GtkWrapBoxChild *child = list->data; + gint child_size; + + if (!gtk_widget_get_visible (child->widget)) + continue; + + if (orientation == GTK_ORIENTATION_HORIZONTAL) + { + gtk_size_request_get_width (GTK_SIZE_REQUEST (child->widget), + NULL, &child_size); + child_size += child->xpadding * 2; + } + else + { + gtk_size_request_get_height (GTK_SIZE_REQUEST (child->widget), + NULL, &child_size); + child_size += child->ypadding * 2; + } + + if (i > 0) + child_size += spacing; + + if (size - child_size >= 0) + size -= child_size; + else + break; + + i++; + } + + line_length = MAX (min_items, i); + size = avail_size; + + /* Collect the sizes of the items on this line */ + array = g_array_new (0, TRUE, sizeof (GtkRequestedSize)); + + for (i = 0, list = cursor; i < line_length && list; list = list->next) + { + GtkWrapBoxChild *child = list->data; + GtkRequestedSize requested; + + if (!gtk_widget_get_visible (child->widget)) + continue; + + requested.data = child; + if (orientation == GTK_ORIENTATION_HORIZONTAL) + { + gtk_size_request_get_width (GTK_SIZE_REQUEST (child->widget), + &requested.minimum_size, + &requested.natural_size); + + size -= child->xpadding * 2; + } + else + { + gtk_size_request_get_height (GTK_SIZE_REQUEST (child->widget), + &requested.minimum_size, + &requested.natural_size); + + size -= child->ypadding * 2; + } + + if (i > 0) + size -= spacing; + + size -= requested.minimum_size; + + g_array_append_val (array, requested); + + i++; + } + + sizes = (GtkRequestedSize *)array->data; + size = gtk_distribute_natural_allocation (size, array->len, sizes); + + if (extra_pixels) + *extra_pixels = size; + + /* Cut out any expand space if we're not distributing any */ + if (priv->spreading != GTK_WRAP_BOX_SPREAD_EXPAND) + size = 0; + + /* Count how many children are going to expand... */ + expand_children = get_visible_expand_children (box, orientation, + cursor, line_length); + + /* If no child prefers to expand, they all get some expand space */ + if (expand_children == 0) + { + expand_per_child = size / line_length; + expand_remainder = size % line_length; + } + else + { + expand_per_child = size / expand_children; + expand_remainder = size % expand_children; + } + + /* Now add the remaining expand space and get the collective size of this line + * in the opposing orientation */ + for (i = 0, list = cursor; i < line_length && list; list = list->next) + { + GtkWrapBoxChild *child = list->data; + gint child_min, child_nat; + + if (!gtk_widget_get_visible (child->widget)) + continue; + + g_assert (child == sizes[i].data); + + if ((orientation == GTK_ORIENTATION_HORIZONTAL && child->xexpand) || + (orientation == GTK_ORIENTATION_VERTICAL && child->yexpand) || + expand_children == 0) + { + sizes[i].minimum_size += expand_per_child; + if (expand_remainder) + { + sizes[i].minimum_size++; + expand_remainder--; + } + } + + if (orientation == GTK_ORIENTATION_HORIZONTAL) + { + gtk_size_request_get_height_for_width (GTK_SIZE_REQUEST (child->widget), + sizes[i].minimum_size, + &child_min, &child_nat); + child_min += child->ypadding * 2; + child_nat += child->ypadding * 2; + } + else + { + gtk_size_request_get_width_for_height (GTK_SIZE_REQUEST (child->widget), + sizes[i].minimum_size, + &child_min, &child_nat); + child_min += child->xpadding * 2; + child_nat += child->xpadding * 2; + } + + max_min_size = MAX (max_min_size, child_min); + max_nat_size = MAX (max_nat_size, child_nat); + + i++; + } + + if (ret_array) + *ret_array = array; + else + g_array_free (array, TRUE); + + if (min_item_size) + *min_item_size = max_min_size; + + if (nat_item_size) + *nat_item_size = max_nat_size; + + /* Return the next item */ + return list; +} + +static void +allocate_child (GtkWrapBox *box, + GtkWrapBoxChild *child, + gint item_offset, + gint line_offset, + gint item_size, + gint line_size) +{ + GtkWrapBoxPriv *priv = box->priv; + GtkAllocation widget_allocation; + GtkAllocation child_allocation; + GtkSizeRequestMode request_mode; + + gtk_widget_get_allocation (GTK_WIDGET (box), &widget_allocation); + + if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) + { + child_allocation.x = widget_allocation.x + item_offset + child->xpadding; + child_allocation.y = widget_allocation.y + line_offset + child->ypadding; + child_allocation.width = item_size - child->xpadding * 2; + child_allocation.height = line_size - child->ypadding * 2; + } + else /* GTK_ORIENTATION_VERTICAL */ + { + child_allocation.x = widget_allocation.x + line_offset + child->xpadding; + child_allocation.y = widget_allocation.y + item_offset + child->ypadding; + child_allocation.width = line_size - child->xpadding * 2; + child_allocation.height = item_size - child->ypadding * 2; + } + + request_mode = gtk_size_request_get_request_mode (GTK_SIZE_REQUEST (child->widget)); + if (!child->xfill) + { + gint width, height; + + if (!child->yfill && request_mode == GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT) + { + gtk_size_request_get_height (GTK_SIZE_REQUEST (child->widget), NULL, &height); + + height = MIN (child_allocation.height, height); + } + else + height = child_allocation.height; + + if (request_mode == GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT) + gtk_size_request_get_width_for_height (GTK_SIZE_REQUEST (child->widget), + height, NULL, &width); + else + gtk_size_request_get_width (GTK_SIZE_REQUEST (child->widget), NULL, &width); + + width = MIN (child_allocation.width, width); + child_allocation.x = child_allocation.x + (child_allocation.width - width) / 2; + child_allocation.width = width; + } + + if (!child->yfill) + { + gint height; + + /* Note here child_allocation.width is already changed if (!child->xfill) */ + if (request_mode == GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH) + gtk_size_request_get_height_for_width (GTK_SIZE_REQUEST (child->widget), + child_allocation.width, NULL, &height); + else + gtk_size_request_get_height (GTK_SIZE_REQUEST (child->widget), NULL, &height); + + height = MIN (child_allocation.height, height); + child_allocation.y = child_allocation.y + (child_allocation.height - height) / 2; + child_allocation.height = height; + } + + gtk_widget_size_allocate (child->widget, &child_allocation); +} + + +typedef struct { + GArray *requested; + gint extra_pixels; +} AllocatedLine; + +static void +gtk_wrap_box_size_allocate (GtkWidget *widget, + GtkAllocation *allocation) +{ + GtkWrapBox *box = GTK_WRAP_BOX (widget); + GtkWrapBoxPriv *priv = box->priv; + GtkRequestedSize *sizes = NULL; + GArray *array; + guint border_width; + gint avail_size, avail_other_size, min_items, item_spacing, line_spacing; + + gtk_widget_set_allocation (widget, allocation); + + border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); + min_items = MAX (1, priv->minimum_line_children); + + /* Collect the line sizes for GTK_WRAP_ALLOCATE_FREE and + * GTK_WRAP_ALLOCATE_ALIGNED modes */ + array = g_array_new (0, TRUE, sizeof (GtkRequestedSize)); + + if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) + { + avail_size = allocation->width - border_width * 2; + avail_other_size = allocation->height - border_width * 2; + item_spacing = priv->horizontal_spacing; + line_spacing = priv->vertical_spacing; + } + else /* GTK_ORIENTATION_VERTICAL */ + { + avail_size = allocation->height - border_width * 2; + avail_other_size = allocation->width - border_width * 2; + item_spacing = priv->vertical_spacing; + line_spacing = priv->horizontal_spacing; + } + + + if (priv->mode == GTK_WRAP_ALLOCATE_ALIGNED || + priv->mode == GTK_WRAP_ALLOCATE_HOMOGENEOUS) + { + GList *list; + gint min_item_size, nat_item_size; + gint line_length; + gint item_size; + gint line_size = 0, min_fixed_line_size = 0, nat_fixed_line_size = 0; + gint line_offset, n_children, n_lines, line_count; + gint extra_pixels, extra_per_item, extra_extra; + gint i; + + get_average_item_size (box, priv->orientation, &min_item_size, &nat_item_size); + + /* By default wrap at the natural item width */ + line_length = avail_size / (nat_item_size + item_spacing); + + /* After the above aproximation, check if we cant fit one more on the line */ + if (line_length * item_spacing + (line_length + 1) * nat_item_size <= avail_size) + line_length++; + + /* Its possible we were allocated just less than the natural width of the + * minimum item wrap length */ + line_length = MAX (min_items, line_length); + + /* Now we need the real item allocation size */ + item_size = (avail_size - (line_length - 1) * item_spacing) / line_length; + + /* Cut out the expand space if we're not distributing any */ + if (priv->spreading != GTK_WRAP_BOX_SPREAD_EXPAND) + item_size = MIN (item_size, nat_item_size); + + /* Get the real extra pixels incase of GTK_WRAP_BOX_SPREAD_BEGIN lines */ + extra_pixels = avail_size - (line_length - 1) * item_spacing - item_size * line_length; + extra_per_item = extra_pixels / MAX (line_length -1, 1); + extra_extra = extra_pixels % MAX (line_length -1, 1); + + /* Get how many lines that wraps to */ + n_children = get_visible_children (box); + n_lines = n_children / line_length; + if ((n_children % line_length) > 0) + n_lines++; + + n_lines = MAX (n_lines, 1); + + /* Here we just use the largest height-for-width and use that for the height + * of all lines */ + if (priv->mode == GTK_WRAP_ALLOCATE_HOMOGENEOUS) + { + get_largest_size_for_opposing_orientation (box, priv->orientation, item_size, + &min_fixed_line_size, + &nat_fixed_line_size); + + /* resolve a fixed 'line_size' */ + line_size = (avail_other_size - (n_lines - 1) * line_spacing) / n_lines; + line_size = MIN (line_size, nat_fixed_line_size); + } + else /* GTK_WRAP_ALLOCATE_ALIGNED */ + { + /* spread out the available size in the opposing orientation into an array of + * lines (and then allocate those lines naturally) */ + GList *list; + gboolean first_line = TRUE; + + /* In ALIGNED mode, all items have the same size in the box's orientation except + * individual lines may have a different size */ + for (i = 0, list = priv->children; list != NULL; i++) + { + GtkRequestedSize requested; + + list = + get_largest_size_for_line_in_opposing_orientation (box, priv->orientation, + list, line_length, + item_size, extra_pixels, + &requested.minimum_size, + &requested.natural_size); + + + /* Its possible a line is made of completely invisible children */ + if (requested.natural_size > 0) + { + if (first_line) + first_line = FALSE; + else + avail_other_size -= line_spacing; + + avail_other_size -= requested.minimum_size; + + requested.data = GINT_TO_POINTER (i); + g_array_append_val (array, requested); + } + } + + /* Distribute space among lines naturally */ + sizes = (GtkRequestedSize *)array->data; + avail_other_size = gtk_distribute_natural_allocation (avail_other_size, array->len, sizes); + } + + line_offset = border_width; + + for (i = 0, line_count = 0, list = priv->children; list; list = list->next) + { + GtkWrapBoxChild *child = list->data; + gint position, this_line_size, item_offset; + gint this_item_size; + + if (!gtk_widget_get_visible (child->widget)) + continue; + + /* Get item position */ + position = i % line_length; + + /* adjust the line_offset/count at the beginning of each new line */ + if (i > 0 && position == 0) + { + if (priv->mode == GTK_WRAP_ALLOCATE_HOMOGENEOUS) + line_offset += line_size + line_spacing; + else /* aligned mode */ + line_offset += sizes[line_count].minimum_size + line_spacing; + + line_count++; + } + + /* We could be smarter here and distribute the extra pixels more + * evenly across the children */ + if (position < extra_pixels && priv->spreading == GTK_WRAP_BOX_SPREAD_EXPAND) + this_item_size = item_size + 1; + else + this_item_size = item_size; + + /* Push the index along for the last line when spreading to the end */ + if (priv->spreading == GTK_WRAP_BOX_SPREAD_END && + line_count == n_lines -1) + { + gint extra_items = n_children % line_length; + + position += line_length - extra_items; + } + + item_offset = border_width + (position * item_size) + (position * item_spacing); + + if (priv->spreading == GTK_WRAP_BOX_SPREAD_EVEN) + { + item_offset += position * extra_per_item; + item_offset += MIN (position, extra_extra); + } + else if (priv->spreading == GTK_WRAP_BOX_SPREAD_END) + item_offset += extra_pixels; + else if (priv->spreading == GTK_WRAP_BOX_SPREAD_EXPAND) + item_offset += MIN (position, extra_pixels); + + /* Get the allocation size for this line */ + if (priv->mode == GTK_WRAP_ALLOCATE_HOMOGENEOUS) + this_line_size = line_size; + else + this_line_size = sizes[line_count].minimum_size; + + /* Do the actual allocation */ + allocate_child (box, child, item_offset, line_offset, this_item_size, this_line_size); + + i++; + } + } + else /* GTK_WRAP_ALLOCATE_FREE */ + { + /* Here we just fit as many children as we can allocate their natural size to + * on each line and add the heights for each of them on each line */ + GtkRequestedSize requested; + GList *list = priv->children; + gboolean first_line = TRUE; + gint i, line_count = 0; + gint line_offset, item_offset; + gint extra_pixels; + + while (list != NULL) + { + GArray *line_array; + AllocatedLine *line; + + list = + get_largest_size_for_free_line_in_opposing_orientation (box, priv->orientation, + list, min_items, avail_size, + &requested.minimum_size, + &requested.natural_size, + &extra_pixels, + &line_array); + + /* Its possible a line is made of completely invisible children */ + if (requested.natural_size > 0) + { + if (first_line) + first_line = FALSE; + else + avail_other_size -= line_spacing; + + avail_other_size -= requested.minimum_size; + + line = g_slice_new0 (AllocatedLine); + line->requested = line_array; + line->extra_pixels = extra_pixels; + + requested.data = line; + + g_array_append_val (array, requested); + } + } + + /* Distribute space among lines naturally, dont give lines expand space just let them + * unwrap/wrap in and out of the allocated extra space */ + sizes = (GtkRequestedSize *)array->data; + avail_other_size = gtk_distribute_natural_allocation (avail_other_size, array->len, sizes); + + for (line_offset = border_width, line_count = 0; line_count < array->len; line_count++) + { + AllocatedLine *line = (AllocatedLine *)sizes[line_count].data; + GArray *line_array = line->requested; + GtkRequestedSize *line_sizes = (GtkRequestedSize *)line_array->data; + gint line_size = sizes[line_count].minimum_size; + gint extra_per_item = 0; + gint extra_extra = 0; + + /* Set line start offset */ + item_offset = border_width; + + if (priv->spreading == GTK_WRAP_BOX_SPREAD_END) + item_offset += line->extra_pixels; + else if (priv->spreading == GTK_WRAP_BOX_SPREAD_EVEN) + { + extra_per_item = line->extra_pixels / MAX (line_array->len -1, 1); + extra_extra = line->extra_pixels % MAX (line_array->len -1, 1); + } + + for (i = 0; i < line_array->len; i++) + { + GtkWrapBoxChild *child = line_sizes[i].data; + gint item_size = line_sizes[i].minimum_size; + + item_size += (priv->orientation == GTK_ORIENTATION_HORIZONTAL) ? + child->xpadding * 2 : child->ypadding * 2; + + /* Do the actual allocation */ + allocate_child (box, child, item_offset, line_offset, item_size, line_size); + + /* Add extra space evenly between children */ + if (priv->spreading == GTK_WRAP_BOX_SPREAD_EVEN) + { + item_offset += extra_per_item; + if (i < extra_extra) + item_offset++; + } + + /* Move item cursor along for the next allocation */ + item_offset += item_spacing; + item_offset += item_size; + } + + /* New line, increment offset and reset item cursor */ + line_offset += line_spacing; + line_offset += line_size; + + /* Free the array for this line now its not needed anymore */ + g_array_free (line_array, TRUE); + g_slice_free (AllocatedLine, line); + } + } + + g_array_free (array, TRUE); +} + +/***************************************************** + * GtkContainerClass * + *****************************************************/ +static void +gtk_wrap_box_add (GtkContainer *container, + GtkWidget *widget) +{ + gtk_wrap_box_insert_child (GTK_WRAP_BOX (container), widget, -1, + 0, 0, FALSE, FALSE, FALSE, FALSE); +} + +static gint +find_child_in_list (GtkWrapBoxChild *child_in_list, + GtkWidget *search) +{ + return (child_in_list->widget == search) ? 0 : -1; +} + +static void +gtk_wrap_box_remove (GtkContainer *container, + GtkWidget *widget) +{ + GtkWrapBox *box = GTK_WRAP_BOX (container); + GtkWrapBoxPriv *priv = box->priv; + GList *list; + + list = g_list_find_custom (priv->children, widget, + (GCompareFunc)find_child_in_list); + + if (list) + { + GtkWrapBoxChild *child = list->data; + gboolean was_visible = gtk_widget_get_visible (widget); + + gtk_widget_unparent (widget); + + g_slice_free (GtkWrapBoxChild, child); + priv->children = g_list_delete_link (priv->children, list); + + if (was_visible && gtk_widget_get_visible (GTK_WIDGET (container))) + gtk_widget_queue_resize (GTK_WIDGET (container)); + } +} + +static void +gtk_wrap_box_forall (GtkContainer *container, + gboolean include_internals, + GtkCallback callback, + gpointer callback_data) +{ + GtkWrapBox *box = GTK_WRAP_BOX (container); + GtkWrapBoxPriv *priv = box->priv; + GtkWrapBoxChild *child; + GList *list; + + for (list = priv->children; list; list = list->next) + { + child = list->data; + + (* callback) (child->widget, callback_data); + } +} + +static GType +gtk_wrap_box_child_type (GtkContainer *container) +{ + return GTK_TYPE_WIDGET; +} + +static void +gtk_wrap_box_set_child_property (GtkContainer *container, + GtkWidget *widget, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + GtkWrapBox *box = GTK_WRAP_BOX (container); + GtkWrapBoxPriv *priv = box->priv; + GtkWrapBoxChild *child; + GList *list; + + list = g_list_find_custom (priv->children, widget, + (GCompareFunc)find_child_in_list); + g_return_if_fail (list != NULL); + + child = list->data; + + switch (property_id) + { + case CHILD_PROP_X_EXPAND: + child->xexpand = g_value_get_boolean (value); + break; + case CHILD_PROP_X_FILL: + child->xfill = g_value_get_boolean (value); + break; + case CHILD_PROP_Y_EXPAND: + child->yexpand = g_value_get_boolean (value); + break; + case CHILD_PROP_Y_FILL: + child->yfill = g_value_get_boolean (value); + break; + case CHILD_PROP_X_PADDING: + child->xpadding = g_value_get_uint (value); + break; + case CHILD_PROP_Y_PADDING: + child->ypadding = g_value_get_uint (value); + break; + default: + GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec); + break; + } + + if (gtk_widget_get_visible (widget) && + gtk_widget_get_visible (GTK_WIDGET (box))) + gtk_widget_queue_resize (widget); +} + +static void +gtk_wrap_box_get_child_property (GtkContainer *container, + GtkWidget *widget, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + GtkWrapBox *box = GTK_WRAP_BOX (container); + GtkWrapBoxPriv *priv = box->priv; + GtkWrapBoxChild *child; + GList *list; + + list = g_list_find_custom (priv->children, widget, + (GCompareFunc)find_child_in_list); + g_return_if_fail (list != NULL); + + child = list->data; + + switch (property_id) + { + case CHILD_PROP_X_EXPAND: + g_value_set_boolean (value, child->xexpand); + break; + case CHILD_PROP_X_FILL: + g_value_set_boolean (value, child->xfill); + break; + case CHILD_PROP_Y_EXPAND: + g_value_set_boolean (value, child->yexpand); + break; + case CHILD_PROP_Y_FILL: + g_value_set_boolean (value, child->yfill); + break; + case CHILD_PROP_X_PADDING: + g_value_set_uint (value, child->xpadding); + break; + case CHILD_PROP_Y_PADDING: + g_value_set_uint (value, child->ypadding); + break; + default: + GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec); + break; + } +} + +/***************************************************** + * GtkSizeRequestIface * + *****************************************************/ + +static void +gtk_wrap_box_size_request_init (GtkSizeRequestIface *iface) +{ + iface->get_request_mode = gtk_wrap_box_get_request_mode; + iface->get_width = gtk_wrap_box_get_width; + iface->get_height = gtk_wrap_box_get_height; + iface->get_height_for_width = gtk_wrap_box_get_height_for_width; + iface->get_width_for_height = gtk_wrap_box_get_width_for_height; +} + +static GtkSizeRequestMode +gtk_wrap_box_get_request_mode (GtkSizeRequest *widget) +{ + GtkWrapBox *box = GTK_WRAP_BOX (widget); + GtkWrapBoxPriv *priv = box->priv; + + return (priv->orientation == GTK_ORIENTATION_HORIZONTAL) ? + GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH : GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT; +} + +/* Gets the largest minimum and natural length of + * 'line_length' consecutive items */ +static void +get_largest_line_length (GtkWrapBox *box, + GtkOrientation orientation, + gint line_length, + gint *min_size, + gint *nat_size) +{ + GtkWrapBoxPriv *priv = box->priv; + GList *list; + gint max_min_size = 0; + gint max_nat_size = 0; + gint spacing; + + if (orientation == GTK_ORIENTATION_HORIZONTAL) + spacing = priv->horizontal_spacing; + else + spacing = priv->vertical_spacing; + + /* Get the largest size of 'line_length' consecutive items in the list. + */ + for (list = priv->children; list; list = list->next) + { + GList *l; + gint line_min = 0; + gint line_nat = 0; + gint i; + + for (l = list, i = 0; l && i < line_length; l = l->next) + { + GtkWrapBoxChild *child = list->data; + gint child_min, child_nat; + + if (!gtk_widget_get_visible (child->widget)) + continue; + + if (orientation == GTK_ORIENTATION_HORIZONTAL) + { + gtk_size_request_get_width (GTK_SIZE_REQUEST (child->widget), + &child_min, &child_nat); + + child_min += child->xpadding * 2; + child_nat += child->xpadding * 2; + } + else /* GTK_ORIENTATION_VERTICAL */ + { + gtk_size_request_get_height (GTK_SIZE_REQUEST (child->widget), + &child_min, &child_nat); + + child_min += child->ypadding * 2; + child_nat += child->ypadding * 2; + } + + if (i > 0) + { + line_min += spacing; + line_nat += spacing; + } + + line_min += child_min; + line_nat += child_nat; + + i++; + } + + max_min_size = MAX (max_min_size, line_min); + max_nat_size = MAX (max_nat_size, line_nat); + } + + if (min_size) + *min_size = max_min_size; + + if (nat_size) + *nat_size = max_nat_size; +} + + +static void +gtk_wrap_box_get_width (GtkSizeRequest *widget, + gint *minimum_size, + gint *natural_size) +{ + GtkWrapBox *box = GTK_WRAP_BOX (widget); + GtkWrapBoxPriv *priv = box->priv; + guint border_width; + gint min_item_width, nat_item_width; + gint min_items, nat_items; + gint min_width, nat_width; + + min_items = MAX (1, priv->minimum_line_children); + nat_items = MAX (min_items, priv->natural_line_children); + + if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) + { + border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); + min_width = nat_width = border_width * 2; + + if (priv->mode == GTK_WRAP_ALLOCATE_FREE) + { + if (priv->minimum_line_children <= 1) + { + get_average_item_size (box, GTK_ORIENTATION_HORIZONTAL, + &min_item_width, &nat_item_width); + + min_width += min_item_width; + nat_width += nat_item_width; + } + else + { + gint min_line_length, nat_line_length; + + get_largest_line_length (box, GTK_ORIENTATION_HORIZONTAL, min_items, + &min_line_length, &nat_line_length); + + if (nat_items > min_items) + get_largest_line_length (box, GTK_ORIENTATION_HORIZONTAL, nat_items, + NULL, &nat_line_length); + + min_width += min_line_length; + nat_width += nat_line_length; + } + } + else /* In ALIGNED or HOMOGENEOUS modes; horizontally oriented boxs + * give the same width to all children */ + { + get_average_item_size (box, GTK_ORIENTATION_HORIZONTAL, + &min_item_width, &nat_item_width); + + min_width += min_item_width * min_items; + min_width += (min_items -1) * priv->horizontal_spacing; + + nat_width += nat_item_width * nat_items; + nat_width += (nat_items -1) * priv->horizontal_spacing; + } + } + else /* GTK_ORIENTATION_VERTICAL */ + { + /* Return the width for the minimum height */ + gint min_height; + + gtk_size_request_get_height (widget, &min_height, NULL); + gtk_size_request_get_width_for_height (widget, min_height, &min_width, &nat_width); + + } + + if (minimum_size) + *minimum_size = min_width; + + if (natural_size) + *natural_size = nat_width; +} + +static void +gtk_wrap_box_get_height (GtkSizeRequest *widget, + gint *minimum_size, + gint *natural_size) +{ + GtkWrapBox *box = GTK_WRAP_BOX (widget); + GtkWrapBoxPriv *priv = box->priv; + guint border_width; + gint min_item_height, nat_item_height; + gint min_items, nat_items; + gint min_height, nat_height; + + min_items = MAX (1, priv->minimum_line_children); + nat_items = MAX (min_items, priv->natural_line_children); + + if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) + { + /* Return the height for the minimum width */ + gint min_width; + + gtk_size_request_get_width (widget, &min_width, NULL); + gtk_size_request_get_height_for_width (widget, min_width, &min_height, &nat_height); + } + else /* GTK_ORIENTATION_VERTICAL */ + { + border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); + min_height = nat_height = border_width * 2; + + if (priv->mode == GTK_WRAP_ALLOCATE_FREE) + { + if (priv->minimum_line_children <= 1) + { + get_average_item_size (box, GTK_ORIENTATION_VERTICAL, + &min_item_height, &nat_item_height); + + min_height += min_item_height; + nat_height += nat_item_height; + } + else + { + gint min_line_length, nat_line_length; + + get_largest_line_length (box, GTK_ORIENTATION_VERTICAL, min_items, + &min_line_length, &nat_line_length); + + if (nat_items > min_items) + get_largest_line_length (box, GTK_ORIENTATION_VERTICAL, nat_items, + NULL, &nat_line_length); + + min_height += min_line_length; + nat_height += nat_line_length; + } + } + else /* In ALIGNED or HOMOGENEOUS modes; horizontally oriented boxs + * give the same width to all children */ + { + get_average_item_size (box, GTK_ORIENTATION_VERTICAL, + &min_item_height, &nat_item_height); + + min_height += min_item_height * min_items; + min_height += (min_items -1) * priv->vertical_spacing; + + nat_height += nat_item_height * nat_items; + nat_height += (nat_items -1) * priv->vertical_spacing; + } + } + + if (minimum_size) + *minimum_size = min_height; + + if (natural_size) + *natural_size = nat_height; +} + +static void +gtk_wrap_box_get_height_for_width (GtkSizeRequest *widget, + gint width, + gint *minimum_height, + gint *natural_height) +{ + GtkWrapBox *box = GTK_WRAP_BOX (widget); + GtkWrapBoxPriv *priv = box->priv; + guint border_width; + gint min_item_width, nat_item_width; + gint min_items; + gint min_height, nat_height; + gint avail_size; + + min_items = MAX (1, priv->minimum_line_children); + + min_height = 0; + nat_height = 0; + + if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) + { + gint min_width; + + /* Make sure its no smaller than the minimum */ + gtk_size_request_get_width (widget, &min_width, NULL); + + border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); + + avail_size = MAX (width, min_width); + avail_size -= border_width * 2; + + if (priv->mode == GTK_WRAP_ALLOCATE_ALIGNED || + priv->mode == GTK_WRAP_ALLOCATE_HOMOGENEOUS) + { + gint line_length; + gint item_size, extra_pixels; + + get_average_item_size (box, GTK_ORIENTATION_HORIZONTAL, &min_item_width, &nat_item_width); + + /* By default wrap at the natural item width */ + line_length = avail_size / (nat_item_width + priv->horizontal_spacing); + + /* After the above aproximation, check if we cant fit one more on the line */ + if (line_length * priv->horizontal_spacing + (line_length + 1) * nat_item_width <= avail_size) + line_length++; + + /* Its possible we were allocated just less than the natural width of the + * minimum item wrap length */ + line_length = MAX (min_items, line_length); + + /* Now we need the real item allocation size */ + item_size = (avail_size - (line_length - 1) * priv->horizontal_spacing) / line_length; + + /* Cut out the expand space if we're not distributing any */ + if (priv->spreading != GTK_WRAP_BOX_SPREAD_EXPAND) + { + item_size = MIN (item_size, nat_item_width); + extra_pixels = 0; + } + else + /* Collect the extra pixels for expand children */ + extra_pixels = (avail_size - (line_length - 1) * priv->horizontal_spacing) % line_length; + + if (priv->mode == GTK_WRAP_ALLOCATE_HOMOGENEOUS) + { + gint min_item_height, nat_item_height; + gint lines, n_children; + + /* Here we just use the largest height-for-width and + * add up the size accordingly */ + get_largest_size_for_opposing_orientation (box, GTK_ORIENTATION_HORIZONTAL, item_size, + &min_item_height, &nat_item_height); + + /* Round up how many lines we need to allocate for */ + n_children = get_visible_children (box); + lines = n_children / line_length; + if ((n_children % line_length) > 0) + lines++; + + min_height = min_item_height * lines; + nat_height = nat_item_height * lines; + + min_height += (lines - 1) * priv->vertical_spacing; + nat_height += (lines - 1) * priv->vertical_spacing; + } + else /* GTK_WRAP_ALLOCATE_ALIGNED */ + { + GList *list = priv->children; + gint min_line_height, nat_line_height; + gboolean first_line = TRUE; + + /* In ALIGNED mode, all items have the same size in the box's orientation except + * individual rows may have a different size */ + while (list != NULL) + { + list = + get_largest_size_for_line_in_opposing_orientation (box, GTK_ORIENTATION_HORIZONTAL, + list, line_length, + item_size, extra_pixels, + &min_line_height, &nat_line_height); + + + /* Its possible the line only had invisible widgets */ + if (nat_line_height > 0) + { + if (first_line) + first_line = FALSE; + else + { + min_height += priv->vertical_spacing; + nat_height += priv->vertical_spacing; + } + + min_height += min_line_height; + nat_height += nat_line_height; + } + } + } + } + else /* GTK_WRAP_ALLOCATE_FREE */ + { + /* Here we just fit as many children as we can allocate their natural size to + * on each line and add the heights for each of them on each line */ + GList *list = priv->children; + gint min_line_height = 0, nat_line_height = 0; + gboolean first_line = TRUE; + + while (list != NULL) + { + list = + get_largest_size_for_free_line_in_opposing_orientation (box, GTK_ORIENTATION_HORIZONTAL, + list, min_items, avail_size, + &min_line_height, &nat_line_height, + NULL, NULL); + + /* Its possible the last line only had invisible widgets */ + if (nat_line_height > 0) + { + if (first_line) + first_line = FALSE; + else + { + min_height += priv->vertical_spacing; + nat_height += priv->vertical_spacing; + } + + min_height += min_line_height; + nat_height += nat_line_height; + } + } + } + + min_height += border_width * 2; + nat_height += border_width * 2; + } + else /* GTK_ORIENTATION_VERTICAL */ + { + /* Return the minimum height */ + gtk_size_request_get_height (widget, &min_height, &nat_height); + } + + if (minimum_height) + *minimum_height = min_height; + + if (natural_height) + *natural_height = nat_height; +} + +static void +gtk_wrap_box_get_width_for_height (GtkSizeRequest *widget, + gint height, + gint *minimum_width, + gint *natural_width) +{ + GtkWrapBox *box = GTK_WRAP_BOX (widget); + GtkWrapBoxPriv *priv = box->priv; + guint border_width; + gint min_item_height, nat_item_height; + gint min_items; + gint min_width, nat_width; + gint avail_size; + + min_items = MAX (1, priv->minimum_line_children); + + min_width = 0; + nat_width = 0; + + if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) + { + /* Return the minimum width */ + gtk_size_request_get_width (widget, &min_width, &nat_width); + } + else /* GTK_ORIENTATION_VERTICAL */ + { + gint min_height; + + /* Make sure its no smaller than the minimum */ + gtk_size_request_get_height (widget, &min_height, NULL); + + border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); + + avail_size = MAX (height, min_height); + avail_size -= border_width * 2; + + if (priv->mode == GTK_WRAP_ALLOCATE_ALIGNED || + priv->mode == GTK_WRAP_ALLOCATE_HOMOGENEOUS) + { + gint line_length; + gint item_size, extra_pixels; + + get_average_item_size (box, GTK_ORIENTATION_VERTICAL, &min_item_height, &nat_item_height); + + /* By default wrap at the natural item width */ + line_length = avail_size / (nat_item_height + priv->vertical_spacing); + + /* After the above aproximation, check if we cant fit one more on the line */ + if (line_length * priv->vertical_spacing + (line_length + 1) * nat_item_height <= avail_size) + line_length++; + + /* Its possible we were allocated just less than the natural width of the + * minimum item wrap length */ + line_length = MAX (min_items, line_length); + + /* Now we need the real item allocation size */ + item_size = (avail_size - (line_length - 1) * priv->vertical_spacing) / line_length; + + /* Cut out the expand space if we're not distributing any */ + if (priv->spreading != GTK_WRAP_BOX_SPREAD_EXPAND) + { + item_size = MIN (item_size, nat_item_height); + extra_pixels = 0; + } + else + /* Collect the extra pixels for expand children */ + extra_pixels = (avail_size - (line_length - 1) * priv->vertical_spacing) % line_length; + + if (priv->mode == GTK_WRAP_ALLOCATE_HOMOGENEOUS) + { + gint min_item_width, nat_item_width; + gint lines, n_children; + + /* Here we just use the largest height-for-width and + * add up the size accordingly */ + get_largest_size_for_opposing_orientation (box, GTK_ORIENTATION_VERTICAL, item_size, + &min_item_width, &nat_item_width); + + /* Round up how many lines we need to allocate for */ + n_children = get_visible_children (box); + lines = n_children / line_length; + if ((n_children % line_length) > 0) + lines++; + + min_width = min_item_width * lines; + nat_width = nat_item_width * lines; + + min_width += (lines - 1) * priv->horizontal_spacing; + nat_width += (lines - 1) * priv->horizontal_spacing; + } + else /* GTK_WRAP_ALLOCATE_ALIGNED */ + { + GList *list = priv->children; + gint min_line_width, nat_line_width; + gboolean first_line = TRUE; + + /* In ALIGNED mode, all items have the same size in the box's orientation except + * individual rows may have a different size */ + while (list != NULL) + { + list = + get_largest_size_for_line_in_opposing_orientation (box, GTK_ORIENTATION_VERTICAL, + list, line_length, + item_size, extra_pixels, + &min_line_width, &nat_line_width); + + /* Its possible the last line only had invisible widgets */ + if (nat_line_width > 0) + { + if (first_line) + first_line = FALSE; + else + { + min_width += priv->horizontal_spacing; + nat_width += priv->horizontal_spacing; + } + + min_width += min_line_width; + nat_width += nat_line_width; + } + } + } + } + else /* GTK_WRAP_ALLOCATE_FREE */ + { + /* Here we just fit as many children as we can allocate their natural size to + * on each line and add the heights for each of them on each line */ + GList *list = priv->children; + gint min_line_width = 0, nat_line_width = 0; + gboolean first_line = TRUE; + + while (list != NULL) + { + list = + get_largest_size_for_free_line_in_opposing_orientation (box, GTK_ORIENTATION_VERTICAL, + list, min_items, avail_size, + &min_line_width, &nat_line_width, + NULL, NULL); + + /* Its possible the last line only had invisible widgets */ + if (nat_line_width > 0) + { + if (first_line) + first_line = FALSE; + else + { + min_width += priv->horizontal_spacing; + nat_width += priv->horizontal_spacing; + } + + min_width += min_line_width; + nat_width += nat_line_width; + } + } + } + + min_width += border_width * 2; + nat_width += border_width * 2; + } + + if (minimum_width) + *minimum_width = min_width; + + if (natural_width) + *natural_width = nat_width; +} + +/***************************************************** + * API * + *****************************************************/ + +/** + * gtk_wrap_box_new: + * @allocation_mode: The #GtkWrapAllocationMode to use + * @spreading: The #GtkWrapBoxSpreading policy to use + * @horizontal_spacing: The horizontal spacing to add between children + * @vertical_spacing: The vertical spacing to add between children + * + * Creates an #GtkWrapBox. + * + * Returns: A new #GtkWrapBox container + */ +GtkWidget * +gtk_wrap_box_new (GtkWrapAllocationMode mode, + GtkWrapBoxSpreading spreading, + guint horizontal_spacing, + guint vertical_spacing) +{ + return (GtkWidget *)g_object_new (GTK_TYPE_WRAP_BOX, + "allocation-mode", mode, + "spreading", spreading, + "vertical-spacing", vertical_spacing, + "horizontal-spacing", horizontal_spacing, + NULL); +} + +/** + * gtk_wrap_box_set_allocation_mode: + * @box: An #GtkWrapBox + * @mode: The #GtkWrapAllocationMode to use. + * + * Sets the allocation mode for @box's children. + */ +void +gtk_wrap_box_set_allocation_mode (GtkWrapBox *box, + GtkWrapAllocationMode mode) +{ + GtkWrapBoxPriv *priv; + + g_return_if_fail (GTK_IS_WRAP_BOX (box)); + + priv = box->priv; + + if (priv->mode != mode) + { + priv->mode = mode; + + gtk_widget_queue_resize (GTK_WIDGET (box)); + + g_object_notify (G_OBJECT (box), "allocation-mode"); + } +} + +/** + * gtk_wrap_box_get_allocation_mode: + * @box: An #GtkWrapBox + * + * Gets the allocation mode. + * + * Returns: The #GtkWrapAllocationMode for @box. + */ +GtkWrapAllocationMode +gtk_wrap_box_get_allocation_mode (GtkWrapBox *box) +{ + g_return_val_if_fail (GTK_IS_WRAP_BOX (box), FALSE); + + return box->priv->mode; +} + + +/** + * gtk_wrap_box_set_spreading: + * @box: An #GtkWrapBox + * @spreading: The #GtkWrapBoxSpreading to use. + * + * Sets the spreading mode for @box's children. + */ +void +gtk_wrap_box_set_spreading (GtkWrapBox *box, + GtkWrapBoxSpreading spreading) +{ + GtkWrapBoxPriv *priv; + + g_return_if_fail (GTK_IS_WRAP_BOX (box)); + + priv = box->priv; + + if (priv->spreading != spreading) + { + priv->spreading = spreading; + + gtk_widget_queue_resize (GTK_WIDGET (box)); + + g_object_notify (G_OBJECT (box), "spreading"); + } +} + +/** + * gtk_wrap_box_get_spreading: + * @box: An #GtkWrapBox + * + * Gets the spreading mode. + * + * Returns: The #GtkWrapBoxSpreading for @box. + */ +GtkWrapBoxSpreading +gtk_wrap_box_get_spreading (GtkWrapBox *box) +{ + g_return_val_if_fail (GTK_IS_WRAP_BOX (box), FALSE); + + return box->priv->spreading; +} + + +/** + * gtk_wrap_box_set_vertical_spacing: + * @box: An #GtkWrapBox + * @spacing: The spacing to use. + * + * Sets the vertical space to add between children. + */ +void +gtk_wrap_box_set_vertical_spacing (GtkWrapBox *box, + guint spacing) +{ + GtkWrapBoxPriv *priv; + + g_return_if_fail (GTK_IS_WRAP_BOX (box)); + + priv = box->priv; + + if (priv->vertical_spacing != spacing) + { + priv->vertical_spacing = spacing; + + gtk_widget_queue_resize (GTK_WIDGET (box)); + + g_object_notify (G_OBJECT (box), "vertical-spacing"); + } +} + +/** + * gtk_wrap_box_get_vertical_spacing: + * @box: An #GtkWrapBox + * + * Gets the vertical spacing. + * + * Returns: The vertical spacing. + */ +guint +gtk_wrap_box_get_vertical_spacing (GtkWrapBox *box) +{ + g_return_val_if_fail (GTK_IS_WRAP_BOX (box), FALSE); + + return box->priv->vertical_spacing; +} + +/** + * gtk_wrap_box_set_horizontal_spacing: + * @box: An #GtkWrapBox + * @spacing: The spacing to use. + * + * Sets the horizontal space to add between children. + */ +void +gtk_wrap_box_set_horizontal_spacing (GtkWrapBox *box, + guint spacing) +{ + GtkWrapBoxPriv *priv; + + g_return_if_fail (GTK_IS_WRAP_BOX (box)); + + priv = box->priv; + + if (priv->horizontal_spacing != spacing) + { + priv->horizontal_spacing = spacing; + + gtk_widget_queue_resize (GTK_WIDGET (box)); + + g_object_notify (G_OBJECT (box), "horizontal-spacing"); + } +} + +/** + * gtk_wrap_box_get_horizontal_spacing: + * @box: An #GtkWrapBox + * + * Gets the horizontal spacing. + * + * Returns: The horizontal spacing. + */ +guint +gtk_wrap_box_get_horizontal_spacing (GtkWrapBox *box) +{ + g_return_val_if_fail (GTK_IS_WRAP_BOX (box), FALSE); + + return box->priv->horizontal_spacing; +} + +/** + * gtk_wrap_box_set_minimum_line_children: + * @box: An #GtkWrapBox + * @n_children: The minimum amount of children per line. + * + * Sets the minimum amount of children to line up + * in @box's orientation before wrapping. + */ +void +gtk_wrap_box_set_minimum_line_children (GtkWrapBox *box, + guint n_children) +{ + GtkWrapBoxPriv *priv; + + g_return_if_fail (GTK_IS_WRAP_BOX (box)); + + priv = box->priv; + + if (priv->minimum_line_children != n_children) + { + priv->minimum_line_children = n_children; + + gtk_widget_queue_resize (GTK_WIDGET (box)); + + g_object_notify (G_OBJECT (box), "minimum-line-children"); + } +} + +/** + * gtk_wrap_box_get_minimum_line_children: + * @box: An #GtkWrapBox + * + * Gets the minimum amount of children per line. + * + * Returns: The minimum amount of children per line. + */ +guint +gtk_wrap_box_get_minimum_line_children (GtkWrapBox *box) +{ + g_return_val_if_fail (GTK_IS_WRAP_BOX (box), FALSE); + + return box->priv->minimum_line_children; +} + +/** + * gtk_wrap_box_set_natural_line_children: + * @box: An #GtkWrapBox + * @n_children: The natural amount of children per line. + * + * Sets the natural length of items to request and + * allocate space for in @box's orientation. + * + * Setting the natural amount of children per line + * limits the overall natural size request to be no more + * than @n_children items long in the given orientation. + */ +void +gtk_wrap_box_set_natural_line_children (GtkWrapBox *box, + guint n_children) +{ + GtkWrapBoxPriv *priv; + + g_return_if_fail (GTK_IS_WRAP_BOX (box)); + + priv = box->priv; + + if (priv->natural_line_children != n_children) + { + priv->natural_line_children = n_children; + + gtk_widget_queue_resize (GTK_WIDGET (box)); + + g_object_notify (G_OBJECT (box), "natural-line-children"); + } +} + +/** + * gtk_wrap_box_get_natural_line_children: + * @box: An #GtkWrapBox + * + * Gets the natural amount of children per line. + * + * Returns: The natural amount of children per line. + */ +guint +gtk_wrap_box_get_natural_line_children (GtkWrapBox *box) +{ + g_return_val_if_fail (GTK_IS_WRAP_BOX (box), FALSE); + + return box->priv->natural_line_children; +} + + +/** + * gtk_wrap_box_insert_child: + * @box: And #GtkWrapBox + * @widget: the child #GtkWidget to add + * @index: the position in the child list to insert, specify -1 to append to the list. + * @xpad: horizontal spacing for this child + * @ypad: vertical spacing for this child + * @xexpand: whether this child expands horizontally + * @yexpand: whether this child expands vertically + * @xfill: whether this child fills its horizontal allocation + * @yfill: whether this child fills its vertical allocation + * + * Adds a child to an #GtkWrapBox with its packing options set + * + */ +void +gtk_wrap_box_insert_child (GtkWrapBox *box, + GtkWidget *widget, + gint index, + guint xpad, + guint ypad, + gboolean xexpand, + gboolean yexpand, + gboolean xfill, + gboolean yfill) +{ + GtkWrapBoxPriv *priv; + GtkWrapBoxChild *child; + GList *list; + + g_return_if_fail (GTK_IS_WRAP_BOX (box)); + g_return_if_fail (GTK_IS_WIDGET (widget)); + + priv = box->priv; + + list = g_list_find_custom (priv->children, widget, + (GCompareFunc)find_child_in_list); + g_return_if_fail (list == NULL); + + child = g_slice_new0 (GtkWrapBoxChild); + child->widget = widget; + child->xpadding = xpad; + child->ypadding = ypad; + child->xexpand = xexpand; + child->yexpand = yexpand; + child->xfill = xfill; + child->yfill = yfill; + + priv->children = g_list_insert (priv->children, child, index); + + gtk_widget_set_parent (widget, GTK_WIDGET (box)); +} + +/** + * gtk_wrap_box_reorder_child: + * @box: An #GtkWrapBox + * @widget: The child to reorder + * @index: The new child position + * + * Reorders the child @widget in @box's list of children. + */ +void +gtk_wrap_box_reorder_child (GtkWrapBox *box, + GtkWidget *widget, + guint index) +{ + GtkWrapBoxPriv *priv; + GtkWrapBoxChild *child; + GList *list; + + g_return_if_fail (GTK_IS_WRAP_BOX (box)); + g_return_if_fail (GTK_IS_WIDGET (widget)); + + priv = box->priv; + + list = g_list_find_custom (priv->children, widget, + (GCompareFunc)find_child_in_list); + g_return_if_fail (list != NULL); + + if (g_list_position (priv->children, list) != index) + { + child = list->data; + priv->children = g_list_delete_link (priv->children, list); + priv->children = g_list_insert (priv->children, child, index); + + gtk_widget_queue_resize (GTK_WIDGET (box)); + } +} diff --git a/gtk/gtkwrapbox.h b/gtk/gtkwrapbox.h new file mode 100644 index 0000000000..76c6370771 --- /dev/null +++ b/gtk/gtkwrapbox.h @@ -0,0 +1,101 @@ +/* + * Copyright (C) 2010 Openismus GmbH + * + * Authors: + * Tristan Van Berkom <tristanvb@openismus.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef __GTK_WRAP_BOX_H__ +#define __GTK_WRAP_BOX_H__ + +#include <gtk/gtkcontainer.h> + +G_BEGIN_DECLS + + +#define GTK_TYPE_WRAP_BOX (gtk_wrap_box_get_type ()) +#define GTK_WRAP_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_WRAP_BOX, GtkWrapBox)) +#define GTK_WRAP_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_WRAP_BOX, GtkWrapBoxClass)) +#define GTK_IS_WRAP_BOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_WRAP_BOX)) +#define GTK_IS_WRAP_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_WRAP_BOX)) +#define GTK_WRAP_BOX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_WRAP_BOX, GtkWrapBoxClass)) + +typedef struct _GtkWrapBox GtkWrapBox; +typedef struct _GtkWrapBoxPriv GtkWrapBoxPriv; +typedef struct _GtkWrapBoxClass GtkWrapBoxClass; + +struct _GtkWrapBox +{ + GtkContainer container; + + /*< private >*/ + GtkWrapBoxPriv *priv; +}; + +struct _GtkWrapBoxClass +{ + GtkContainerClass parent_class; +}; + +GType gtk_wrap_box_get_type (void) G_GNUC_CONST; + +GtkWidget *gtk_wrap_box_new (GtkWrapAllocationMode mode, + GtkWrapBoxSpreading spreading, + guint horizontal_spacing, + guint vertical_spacing); +void gtk_wrap_box_set_allocation_mode (GtkWrapBox *layout, + GtkWrapAllocationMode mode); +GtkWrapAllocationMode gtk_wrap_box_get_allocation_mode (GtkWrapBox *layout); + +void gtk_wrap_box_set_spreading (GtkWrapBox *layout, + GtkWrapBoxSpreading spreading); +GtkWrapBoxSpreading gtk_wrap_box_get_spreading (GtkWrapBox *layout); + +void gtk_wrap_box_set_vertical_spacing (GtkWrapBox *layout, + guint spacing); +guint gtk_wrap_box_get_vertical_spacing (GtkWrapBox *layout); + +void gtk_wrap_box_set_horizontal_spacing (GtkWrapBox *layout, + guint spacing); +guint gtk_wrap_box_get_horizontal_spacing (GtkWrapBox *layout); + +void gtk_wrap_box_set_minimum_line_children (GtkWrapBox *layout, + guint n_children); +guint gtk_wrap_box_get_minimum_line_children (GtkWrapBox *layout); + +void gtk_wrap_box_set_natural_line_children (GtkWrapBox *layout, + guint n_children); +guint gtk_wrap_box_get_natural_line_children (GtkWrapBox *layout); + +void gtk_wrap_box_insert_child (GtkWrapBox *layout, + GtkWidget *widget, + gint index, + guint xpad, + guint ypad, + gboolean xexpand, + gboolean yexpand, + gboolean xfill, + gboolean yfill); +void gtk_wrap_box_reorder_child (GtkWrapBox *layout, + GtkWidget *widget, + guint index); + +G_END_DECLS + + +#endif /* __GTK_WRAP_BOX_H__ */ diff --git a/gtk/stock-icons/16/dialog-info.png b/gtk/stock-icons/16/dialog-information.png Binary files differindex df87def2f2..df87def2f2 100644 --- a/gtk/stock-icons/16/dialog-info.png +++ b/gtk/stock-icons/16/dialog-information.png diff --git a/gtk/stock-icons/16/dialog-info.svg b/gtk/stock-icons/16/dialog-information.svg index 15b6b52193..15b6b52193 100644 --- a/gtk/stock-icons/16/dialog-info.svg +++ b/gtk/stock-icons/16/dialog-information.svg diff --git a/gtk/stock-icons/16/edit-preferences.png b/gtk/stock-icons/16/gtk-preferences.png Binary files differindex 9703a40dff..9703a40dff 100644 --- a/gtk/stock-icons/16/edit-preferences.png +++ b/gtk/stock-icons/16/gtk-preferences.png diff --git a/gtk/stock-icons/16/edit-preferences.svg b/gtk/stock-icons/16/gtk-preferences.svg index 986766d9d6..986766d9d6 100644 --- a/gtk/stock-icons/16/edit-preferences.svg +++ b/gtk/stock-icons/16/gtk-preferences.svg diff --git a/gtk/stock-icons/24/dialog-info.png b/gtk/stock-icons/24/dialog-information.png Binary files differindex b66871a941..b66871a941 100644 --- a/gtk/stock-icons/24/dialog-info.png +++ b/gtk/stock-icons/24/dialog-information.png diff --git a/gtk/stock-icons/24/dialog-info.svg b/gtk/stock-icons/24/dialog-information.svg index cf616019b7..cf616019b7 100644 --- a/gtk/stock-icons/24/dialog-info.svg +++ b/gtk/stock-icons/24/dialog-information.svg diff --git a/gtk/stock-icons/24/edit-preferences.png b/gtk/stock-icons/24/gtk-preferences.png Binary files differindex 2596f3cc5e..2596f3cc5e 100644 --- a/gtk/stock-icons/24/edit-preferences.png +++ b/gtk/stock-icons/24/gtk-preferences.png diff --git a/gtk/stock-icons/24/edit-preferences.svg b/gtk/stock-icons/24/gtk-preferences.svg index 30277ad816..30277ad816 100644 --- a/gtk/stock-icons/24/edit-preferences.svg +++ b/gtk/stock-icons/24/gtk-preferences.svg diff --git a/gtk/stock-icons/48/dialog-info.png b/gtk/stock-icons/48/dialog-information.png Binary files differindex d73990ecca..d73990ecca 100644 --- a/gtk/stock-icons/48/dialog-info.png +++ b/gtk/stock-icons/48/dialog-information.png diff --git a/gtk/stock-icons/48/dialog-info.svg b/gtk/stock-icons/48/dialog-information.svg index 91de3730aa..91de3730aa 100644 --- a/gtk/stock-icons/48/dialog-info.svg +++ b/gtk/stock-icons/48/dialog-information.svg diff --git a/gtk/tests/builder.c b/gtk/tests/builder.c index b45cc414f3..e35abd446a 100644 --- a/gtk/tests/builder.c +++ b/gtk/tests/builder.c @@ -352,7 +352,7 @@ test_uimanager_simple (void) children = gtk_container_get_children (GTK_CONTAINER (menubar)); menu = children->data; g_assert (GTK_IS_MENU_ITEM (menu)); - g_assert (strcmp (GTK_WIDGET (menu)->name, "file") == 0); + g_assert (strcmp (gtk_widget_get_name (GTK_WIDGET (menu)), "file") == 0); g_list_free (children); label = G_OBJECT (gtk_bin_get_child (GTK_BIN (menu))); @@ -1009,8 +1009,8 @@ test_children (void) button = gtk_builder_get_object (builder, "button1"); g_assert (button != NULL); g_assert (GTK_IS_BUTTON (button)); - g_assert (GTK_WIDGET(button)->parent != NULL); - g_assert (strcmp (gtk_buildable_get_name (GTK_BUILDABLE (GTK_WIDGET (button)->parent)), "window1") == 0); + g_assert (gtk_widget_get_parent (GTK_WIDGET(button)) != NULL); + g_assert (strcmp (gtk_buildable_get_name (GTK_BUILDABLE (gtk_widget_get_parent (GTK_WIDGET (button)))), "window1") == 0); gtk_widget_destroy (GTK_WIDGET (window)); g_object_unref (builder); @@ -1027,7 +1027,7 @@ test_children (void) content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog)); g_assert (vbox != NULL); g_assert (GTK_IS_VBOX (vbox)); - g_assert (strcmp (gtk_buildable_get_name (GTK_BUILDABLE (GTK_WIDGET (vbox)->parent)), "dialog1") == 0); + g_assert (strcmp (gtk_buildable_get_name (GTK_BUILDABLE (gtk_widget_get_parent (GTK_WIDGET (vbox)))), "dialog1") == 0); g_assert (gtk_container_get_border_width (GTK_CONTAINER (vbox)) == 10); g_assert (strcmp (gtk_buildable_get_name (GTK_BUILDABLE (content_area)), "dialog1-vbox") == 0); @@ -1035,7 +1035,7 @@ test_children (void) dialog_action_area = gtk_dialog_get_action_area (GTK_DIALOG (dialog)); g_assert (action_area != NULL); g_assert (GTK_IS_HBUTTON_BOX (action_area)); - g_assert (GTK_WIDGET (action_area)->parent != NULL); + g_assert (gtk_widget_get_parent (GTK_WIDGET (action_area)) != NULL); g_assert (gtk_container_get_border_width (GTK_CONTAINER (action_area)) == 20); g_assert (dialog_action_area != NULL); g_assert (gtk_buildable_get_name (GTK_BUILDABLE (action_area)) != NULL); @@ -2292,7 +2292,7 @@ test_add_objects (void) menu = children->data; g_assert (menu != NULL); g_assert (GTK_IS_MENU_ITEM (menu)); - g_assert (strcmp (GTK_WIDGET (menu)->name, "file") == 0); + g_assert (strcmp (gtk_widget_get_name (GTK_WIDGET (menu)), "file") == 0); g_list_free (children); label = G_OBJECT (gtk_bin_get_child (GTK_BIN (menu))); @@ -2319,7 +2319,7 @@ test_add_objects (void) menu = children->data; g_assert (menu != NULL); g_assert (GTK_IS_MENU_ITEM (menu)); - g_assert (strcmp (GTK_WIDGET (menu)->name, "file") == 0); + g_assert (strcmp (gtk_widget_get_name (GTK_WIDGET (menu)), "file") == 0); g_list_free (children); label = G_OBJECT (gtk_bin_get_child (GTK_BIN (menu))); @@ -2333,16 +2333,18 @@ test_add_objects (void) static GtkWidget * get_parent_menubar (GtkWidget *menuitem) { - GtkMenuShell *menu_shell = (GtkMenuShell *)menuitem->parent; + GtkMenuShell *menu_shell; GtkWidget *attach = NULL; + menu_shell = GTK_MENU_SHELL (gtk_widget_get_parent (menuitem)); + g_assert (GTK_IS_MENU_SHELL (menu_shell)); while (menu_shell && !GTK_IS_MENU_BAR (menu_shell)) { if (GTK_IS_MENU (menu_shell) && (attach = gtk_menu_get_attach_widget (GTK_MENU (menu_shell))) != NULL) - menu_shell = (GtkMenuShell *)attach->parent; + menu_shell = GTK_MENU_SHELL (gtk_widget_get_parent (attach)); else menu_shell = NULL; } @@ -2477,7 +2479,7 @@ test_menus (void) item = (GtkWidget *)gtk_builder_get_object (builder, "imagemenuitem1"); custom = (GtkWidget *)gtk_builder_get_object (builder, "custom1"); - g_assert (custom->parent == item); + g_assert (gtk_widget_get_parent (custom) == item); gtk_widget_destroy (GTK_WIDGET (window)); g_object_unref (builder); diff --git a/gtk/tests/testing.c b/gtk/tests/testing.c index 85fadeff9f..c684555c15 100644 --- a/gtk/tests/testing.c +++ b/gtk/tests/testing.c @@ -132,14 +132,18 @@ test_xserver_sync (void) GtkWidget *window = gtk_test_create_simple_window ("Test Window", "Test: test_xserver_sync"); GtkWidget *darea = gtk_drawing_area_new (); GtkWidget *child; + GdkWindow *gdk_window; GTimer *gtimer = g_timer_new(); gint sync_is_slower = 0, repeat = 5; child = gtk_bin_get_child (GTK_BIN (window)); + //gdk_window = gtk_widget_get_window (darea); + gtk_widget_set_size_request (darea, 320, 200); gtk_container_add (GTK_CONTAINER (child), darea); gtk_widget_show (darea); gtk_widget_show_now (window); + while (repeat--) { gint i, many = 200; @@ -148,7 +152,8 @@ test_xserver_sync (void) while (gtk_events_pending ()) gtk_main_iteration (); - cr = gdk_cairo_create (darea->window); + gdk_window = gtk_widget_get_window (darea); + cr = gdk_cairo_create (gdk_window); cairo_set_source_rgba (cr, 0, 1, 0, 0.1); /* run a number of consecutive drawing requests, just using drawing queue */ g_timer_start (gtimer); @@ -166,7 +171,7 @@ test_xserver_sync (void) for (i = 0; i < many; i++) { cairo_paint (cr); - gdk_test_render_sync (darea->window); + gdk_test_render_sync (gdk_window); } g_timer_stop (gtimer); sync_time = g_timer_elapsed (gtimer, NULL); diff --git a/gtk/tests/treeview-scrolling.c b/gtk/tests/treeview-scrolling.c index 81dfd8d752..6b2d13c9d9 100644 --- a/gtk/tests/treeview-scrolling.c +++ b/gtk/tests/treeview-scrolling.c @@ -416,6 +416,7 @@ test_position (GtkTreeView *tree_view, /* This is only tested for during test_single() */ model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view)); if (gtk_tree_model_iter_n_children (model, NULL) == 1) { + GtkAllocation allocation; GtkTreePath *tmppath; /* Test nothing is dangling at the bottom; read @@ -423,7 +424,8 @@ test_position (GtkTreeView *tree_view, */ /* FIXME: hardcoded width */ - if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (tree_view), 0, GTK_WIDGET (tree_view)->allocation.height - 30, &tmppath, NULL, NULL, NULL)) { + gtk_widget_get_allocation (GTK_WIDGET (tree_view), &allocation); + if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (tree_view), 0, allocation.height - 30, &tmppath, NULL, NULL, NULL)) { g_assert_not_reached (); gtk_tree_path_free (tmppath); } @@ -715,6 +717,7 @@ test_editable_position (GtkWidget *tree_view, GtkWidget *editable, GtkTreePath *cursor_path) { + GtkAllocation allocation; GdkRectangle rect; GtkAdjustment *vadj; @@ -724,7 +727,8 @@ test_editable_position (GtkWidget *tree_view, vadj = gtk_tree_view_get_vadjustment (GTK_TREE_VIEW (tree_view)); /* There are all in bin_window coordinates */ - g_assert (editable->allocation.y == rect.y + ((rect.height - editable->allocation.height) / 2)); + gtk_widget_get_allocation (editable, &allocation); + g_assert (allocation.y == rect.y + ((rect.height - allocation.height) / 2)); } static void |