diff --git a/gtk/gtkaboutdialog.c b/gtk/gtkaboutdialog.c index a2c95994c..9cac0c49f 100644 --- a/gtk/gtkaboutdialog.c +++ b/gtk/gtkaboutdialog.c @@ -188,6 +188,8 @@ static void gtk_about_dialog_set_property (GObject guint prop_id, const GValue *value, GParamSpec *pspec); +static void gtk_about_dialog_realize (GtkWidget *widget); +static void gtk_about_dialog_unrealize (GtkWidget *widget); static void gtk_about_dialog_show (GtkWidget *widge); static void update_name_version (GtkAboutDialog *about); static GtkIconSet * icon_set_new_from_pixbufs (GList *pixbufs); @@ -293,6 +295,8 @@ gtk_about_dialog_class_init (GtkAboutDialogClass *klass) object_class->finalize = gtk_about_dialog_finalize; widget_class->show = gtk_about_dialog_show; + widget_class->realize = gtk_about_dialog_realize; + widget_class->unrealize = gtk_about_dialog_unrealize; klass->activate_link = gtk_about_dialog_activate_link; @@ -583,8 +587,8 @@ gtk_about_dialog_init (GtkAboutDialog *about) priv->documenters = NULL; priv->artists = NULL; - priv->hand_cursor = gdk_cursor_new (GDK_HAND2); - priv->regular_cursor = gdk_cursor_new (GDK_XTERM); + priv->hand_cursor = NULL; + priv->regular_cursor = NULL; priv->hovering_over_link = FALSE; priv->wrap_license = FALSE; @@ -699,12 +703,44 @@ gtk_about_dialog_finalize (GObject *object) g_slist_foreach (priv->visited_links, (GFunc)g_free, NULL); g_slist_free (priv->visited_links); - gdk_cursor_unref (priv->hand_cursor); - gdk_cursor_unref (priv->regular_cursor); - G_OBJECT_CLASS (gtk_about_dialog_parent_class)->finalize (object); } +/* The cursors must belong to the display the dialog is on, not to the + * default display, so create them on realize. + */ +static void +gtk_about_dialog_realize (GtkWidget *widget) +{ + GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)GTK_ABOUT_DIALOG (widget)->private_data; + GdkDisplay *display; + + GTK_WIDGET_CLASS (gtk_about_dialog_parent_class)->realize (widget); + + display = gtk_widget_get_display (widget); + priv->hand_cursor = gdk_cursor_new_for_display (display, GDK_HAND2); + priv->regular_cursor = gdk_cursor_new_for_display (display, GDK_XTERM); +} + +static void +gtk_about_dialog_unrealize (GtkWidget *widget) +{ + GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)GTK_ABOUT_DIALOG (widget)->private_data; + + if (priv->hand_cursor) + { + gdk_cursor_unref (priv->hand_cursor); + priv->hand_cursor = NULL; + } + if (priv->regular_cursor) + { + gdk_cursor_unref (priv->regular_cursor); + priv->regular_cursor = NULL; + } + + GTK_WIDGET_CLASS (gtk_about_dialog_parent_class)->unrealize (widget); +} + static void gtk_about_dialog_set_property (GObject *object, guint prop_id, diff --git a/gtk/gtkdnd.c b/gtk/gtkdnd.c index d97445fac..8beba0a9e 100644 --- a/gtk/gtkdnd.c +++ b/gtk/gtkdnd.c @@ -1274,7 +1274,7 @@ gtk_drag_dest_set (GtkWidget *widget, g_return_if_fail (GTK_IS_WIDGET (widget)); - site = g_new (GtkDragDestSite, 1); + site = g_new0 (GtkDragDestSite, 1); site->flags = flags; site->have_drag = FALSE; @@ -1314,7 +1314,7 @@ gtk_drag_dest_set_proxy (GtkWidget *widget, g_return_if_fail (GTK_IS_WIDGET (widget)); g_return_if_fail (!proxy_window || GDK_IS_WINDOW (proxy_window)); - site = g_new (GtkDragDestSite, 1); + site = g_new0 (GtkDragDestSite, 1); site->flags = 0; site->have_drag = FALSE; @@ -1980,7 +1980,7 @@ gtk_drag_get_dest_info (GdkDragContext *context, info = g_object_get_qdata (G_OBJECT (context), info_quark); if (!info && create) { - info = g_new (GtkDragDestInfo, 1); + info = g_new0 (GtkDragDestInfo, 1); info->widget = NULL; info->context = context; info->proxy_source = NULL; diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c index 3ee1ecf82..2fb71bd1d 100644 --- a/gtk/gtklabel.c +++ b/gtk/gtklabel.c @@ -2317,6 +2317,7 @@ gtk_label_set_markup_internal (GtkLabel *label, PangoAttrList *attrs = NULL; gunichar accel_char = 0; gchar *new_str; + gchar *str_for_accel = NULL; GList *links = NULL; if (!parse_uri_markup (label, str, &new_str, &links, &error)) @@ -2357,7 +2358,10 @@ gtk_label_set_markup_internal (GtkLabel *label, if (separate_uline_pattern (new_str, &key, &tmp, &pattern)) { - g_free (new_str); + /* Keep the unstripped string, the mnemonic keyval must + * be extracted even if the underline is not displayed. + */ + str_for_accel = new_str; new_str = tmp; g_free (pattern); } @@ -2375,12 +2379,33 @@ gtk_label_set_markup_internal (GtkLabel *label, g_warning ("Failed to set text from markup due to error parsing markup: %s", error->message); g_free (new_str); + g_free (str_for_accel); g_error_free (error); return; } g_free (new_str); + if (str_for_accel) + { + /* Extract the accelerator character from the unstripped string */ + accel_char = 0; + if (!pango_parse_markup (str_for_accel, + -1, + '_', + NULL, + NULL, + &accel_char, + &error)) + { + accel_char = 0; + g_error_free (error); + error = NULL; + } + + g_free (str_for_accel); + } + if (text) gtk_label_set_text_internal (label, text); @@ -4897,8 +4922,12 @@ gtk_label_select_region_index (GtkLabel *label, label->select_info->selection_anchor = anchor_index; label->select_info->selection_end = end_index; - clipboard = gtk_widget_get_clipboard (GTK_WIDGET (label), - GDK_SELECTION_PRIMARY); + /* The label may not be anchored to a toplevel (yet or anymore) */ + if (gtk_widget_has_screen (GTK_WIDGET (label))) + clipboard = gtk_widget_get_clipboard (GTK_WIDGET (label), + GDK_SELECTION_PRIMARY); + else + clipboard = NULL; if (anchor_index != end_index) { @@ -4910,18 +4939,20 @@ gtk_label_select_region_index (GtkLabel *label, gtk_target_list_add_text_targets (list, 0); targets = gtk_target_table_new_from_list (list, &n_targets); - gtk_clipboard_set_with_owner (clipboard, - targets, n_targets, - get_text_callback, - clear_text_callback, - G_OBJECT (label)); + if (clipboard) + gtk_clipboard_set_with_owner (clipboard, + targets, n_targets, + get_text_callback, + clear_text_callback, + G_OBJECT (label)); gtk_target_table_free (targets, n_targets); gtk_target_list_unref (list); } else { - if (gtk_clipboard_get_owner (clipboard) == G_OBJECT (label)) + if (clipboard && + gtk_clipboard_get_owner (clipboard) == G_OBJECT (label)) gtk_clipboard_clear (clipboard); } diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c index 03265384f..87ea13e20 100644 --- a/gtk/gtknotebook.c +++ b/gtk/gtknotebook.c @@ -2249,6 +2249,7 @@ gtk_notebook_size_allocate (GtkWidget *widget, for (i = 0; i < N_ACTION_WIDGETS; i++) { GtkAllocation widget_allocation; + GtkRequisition action_requisition; if (!priv->action_widget[i]) continue; @@ -2257,6 +2258,11 @@ gtk_notebook_size_allocate (GtkWidget *widget, widget_allocation.y = widget->allocation.y + border_width; is_rtl = gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL; + /* Use the requisition as adjusted by gtk_widget_set_size_request(), + * which is what gtk_notebook_size_request() reserved space for */ + gtk_widget_get_child_requisition (priv->action_widget[i], + &action_requisition); + switch (tab_pos) { case GTK_POS_BOTTOM: @@ -2264,14 +2270,14 @@ gtk_notebook_size_allocate (GtkWidget *widget, widget->allocation.height - 2 * border_width - notebook->cur_page->requisition.height; /* fall through */ case GTK_POS_TOP: - widget_allocation.width = priv->action_widget[i]->requisition.width; + widget_allocation.width = action_requisition.width; widget_allocation.height = notebook->cur_page->requisition.height - widget->style->ythickness; if ((i == ACTION_WIDGET_START && is_rtl) || (i == ACTION_WIDGET_END && !is_rtl)) widget_allocation.x += widget->allocation.width - 2 * border_width - - priv->action_widget[i]->requisition.width; + action_requisition.width; if (tab_pos == GTK_POS_TOP) /* no fall through */ widget_allocation.y += 2 * focus_width; break; @@ -2280,13 +2286,13 @@ gtk_notebook_size_allocate (GtkWidget *widget, widget->allocation.width - 2 * border_width - notebook->cur_page->requisition.width; /* fall through */ case GTK_POS_LEFT: - widget_allocation.height = priv->action_widget[i]->requisition.height; + widget_allocation.height = action_requisition.height; widget_allocation.width = notebook->cur_page->requisition.width - widget->style->xthickness; if (i == ACTION_WIDGET_END) widget_allocation.y += widget->allocation.height - 2 * border_width - - priv->action_widget[i]->requisition.height; + action_requisition.height; if (tab_pos == GTK_POS_LEFT) /* no fall through */ widget_allocation.x += 2 * focus_width; break; diff --git a/gtk/gtkradiomenuitem.c b/gtk/gtkradiomenuitem.c index d2d8b7bbe..6d408ca9f 100644 --- a/gtk/gtkradiomenuitem.c +++ b/gtk/gtkradiomenuitem.c @@ -90,10 +90,9 @@ gtk_radio_menu_item_set_property (GObject *object, GSList *slist; case PROP_GROUP: - if (G_VALUE_HOLDS_OBJECT (value)) + slist = NULL; + if (g_value_get_object (value) != NULL) slist = gtk_radio_menu_item_get_group ((GtkRadioMenuItem*) g_value_get_object (value)); - else - slist = NULL; gtk_radio_menu_item_set_group (radio_menu_item, slist); break; default: @@ -273,7 +272,7 @@ gtk_radio_menu_item_new_with_mnemonic (GSList *group, /** * gtk_radio_menu_item_new_from_widget: - * @group: An existing #GtkRadioMenuItem + * @group: (allow-none): An existing #GtkRadioMenuItem, or %NULL * * Creates a new #GtkRadioMenuItem adding it to the same group as @group. * @@ -286,7 +285,7 @@ gtk_radio_menu_item_new_from_widget (GtkRadioMenuItem *group) { GSList *list = NULL; - g_return_val_if_fail (GTK_IS_RADIO_MENU_ITEM (group), NULL); + g_return_val_if_fail (group == NULL || GTK_IS_RADIO_MENU_ITEM (group), NULL); if (group) list = gtk_radio_menu_item_get_group (group); @@ -296,7 +295,7 @@ gtk_radio_menu_item_new_from_widget (GtkRadioMenuItem *group) /** * gtk_radio_menu_item_new_with_mnemonic_from_widget: - * @group: An existing #GtkRadioMenuItem + * @group: (allow-none): An existing #GtkRadioMenuItem, or %NULL * @label: the text of the button, with an underscore in front of the * mnemonic character * @@ -316,7 +315,7 @@ gtk_radio_menu_item_new_with_mnemonic_from_widget (GtkRadioMenuItem *group, { GSList *list = NULL; - g_return_val_if_fail (GTK_IS_RADIO_MENU_ITEM (group), NULL); + g_return_val_if_fail (group == NULL || GTK_IS_RADIO_MENU_ITEM (group), NULL); if (group) list = gtk_radio_menu_item_get_group (group); @@ -326,7 +325,7 @@ gtk_radio_menu_item_new_with_mnemonic_from_widget (GtkRadioMenuItem *group, /** * gtk_radio_menu_item_new_with_label_from_widget: - * @group: an existing #GtkRadioMenuItem + * @group: (allow-none): an existing #GtkRadioMenuItem, or %NULL * @label: the text for the label * * Creates a new GtkRadioMenuItem whose child is a simple GtkLabel. @@ -342,7 +341,7 @@ gtk_radio_menu_item_new_with_label_from_widget (GtkRadioMenuItem *group, { GSList *list = NULL; - g_return_val_if_fail (GTK_IS_RADIO_MENU_ITEM (group), NULL); + g_return_val_if_fail (group == NULL || GTK_IS_RADIO_MENU_ITEM (group), NULL); if (group) list = gtk_radio_menu_item_get_group (group); diff --git a/gtk/gtktextbufferserialize.c b/gtk/gtktextbufferserialize.c index 886d47463..9f9f25af0 100644 --- a/gtk/gtktextbufferserialize.c +++ b/gtk/gtktextbufferserialize.c @@ -846,7 +846,8 @@ 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\""), + element_name, attribute_values[i]); return FALSE; } } diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index 75aab87e7..689cede21 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -197,6 +197,8 @@ struct _GtkWindowPrivate gdouble opacity; gchar *startup_id; + + guint32 initial_timestamp; }; static void gtk_window_dispose (GObject *object); @@ -956,6 +958,7 @@ gtk_window_init (GtkWindow *window) priv->type_hint = GDK_WINDOW_TYPE_HINT_NORMAL; priv->opacity = 1.0; priv->startup_id = NULL; + priv->initial_timestamp = GDK_CURRENT_TIME; priv->mnemonics_visible = TRUE; colormap = _gtk_widget_peek_colormap (); @@ -4902,6 +4905,12 @@ gtk_window_realize (GtkWidget *widget) gdk_window_set_startup_id (widget->window, priv->startup_id); } +#ifdef GDK_WINDOWING_X11 + /* Timestamp passed to gtk_window_present_with_time() while hidden */ + if (priv->initial_timestamp != GDK_CURRENT_TIME) + gdk_x11_window_set_user_time (widget->window, priv->initial_timestamp); +#endif + /* Icons */ gtk_window_realize_icon (window); } @@ -6816,6 +6825,9 @@ gtk_window_present_with_time (GtkWindow *window, } else { + GtkWindowPrivate *priv = GTK_WINDOW_GET_PRIVATE (window); + + priv->initial_timestamp = timestamp; gtk_widget_show (widget); } }