diff options
Diffstat (limited to 'gtk/gtklabel.c')
-rw-r--r-- | gtk/gtklabel.c | 316 |
1 files changed, 169 insertions, 147 deletions
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; |