From: Matthias Clasen Date: Sat, 29 Oct 2022 14:36:29 +0000 (-0400) Subject: Deprecate GtkMessageDialog X-Git-Tag: archive/raspbian/4.12.3+ds-1+rpi1~1^2^2^2~22^2~9^2~132^2~2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=66b062a9761ca86130658adb66e929b3c5acb7ba;p=gtk4.git Deprecate GtkMessageDialog It is getting replaced by GtkAlertDialog This commit only moves the header to deprecated/, and keeps the implementation in gtk/, since it will eventually be salvaged into a private, dialog-free widget. --- diff --git a/demos/gtk-demo/dialog.c b/demos/gtk-demo/dialog.c index 3b355fef3e..b5a709ad38 100644 --- a/demos/gtk-demo/dialog.c +++ b/demos/gtk-demo/dialog.c @@ -8,6 +8,8 @@ #include #include +G_GNUC_BEGIN_IGNORE_DEPRECATIONS + static GtkWidget *window = NULL; static GtkWidget *entry1 = NULL; static GtkWidget *entry2 = NULL; diff --git a/demos/gtk-demo/expander.c b/demos/gtk-demo/expander.c index 6a36b52302..7b3d792915 100644 --- a/demos/gtk-demo/expander.c +++ b/demos/gtk-demo/expander.c @@ -10,6 +10,8 @@ #include #include +G_GNUC_BEGIN_IGNORE_DEPRECATIONS + static GtkWidget *window = NULL; static void diff --git a/gtk/deprecated/gtkmessagedialog.h b/gtk/deprecated/gtkmessagedialog.h new file mode 100644 index 0000000000..afbe0319f8 --- /dev/null +++ b/gtk/deprecated/gtkmessagedialog.h @@ -0,0 +1,118 @@ +/* GTK - The GIMP Toolkit + * Copyright (C) 2000 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + */ + +/* + * Modified by the GTK+ Team and others 1997-2003. See the AUTHORS + * file for a list of people on the GTK+ Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GTK+ at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __GTK_MESSAGE_DIALOG_H__ +#define __GTK_MESSAGE_DIALOG_H__ + +#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include + +G_BEGIN_DECLS + + +#define GTK_TYPE_MESSAGE_DIALOG (gtk_message_dialog_get_type ()) +#define GTK_MESSAGE_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_MESSAGE_DIALOG, GtkMessageDialog)) +#define GTK_IS_MESSAGE_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_MESSAGE_DIALOG)) + +typedef struct _GtkMessageDialog GtkMessageDialog; +typedef struct _GtkMessageDialogClass GtkMessageDialogClass; + +struct _GtkMessageDialog +{ + GtkDialog parent_instance; +}; + +/** + * GtkButtonsType: + * @GTK_BUTTONS_NONE: no buttons at all + * @GTK_BUTTONS_OK: an OK button + * @GTK_BUTTONS_CLOSE: a Close button + * @GTK_BUTTONS_CANCEL: a Cancel button + * @GTK_BUTTONS_YES_NO: Yes and No buttons + * @GTK_BUTTONS_OK_CANCEL: OK and Cancel buttons + * + * Prebuilt sets of buttons for `GtkDialog`. + * + * If none of these choices are appropriate, simply use + * %GTK_BUTTONS_NONE and call [method@Gtk.Dialog.add_buttons]. + * + * > Please note that %GTK_BUTTONS_OK, %GTK_BUTTONS_YES_NO + * > and %GTK_BUTTONS_OK_CANCEL are discouraged by the + * > [GNOME Human Interface Guidelines](http://library.gnome.org/devel/hig-book/stable/). + */ +typedef enum +{ + GTK_BUTTONS_NONE, + GTK_BUTTONS_OK, + GTK_BUTTONS_CLOSE, + GTK_BUTTONS_CANCEL, + GTK_BUTTONS_YES_NO, + GTK_BUTTONS_OK_CANCEL +} GtkButtonsType; + +GDK_AVAILABLE_IN_ALL +GType gtk_message_dialog_get_type (void) G_GNUC_CONST; + +GDK_DEPRECATED_IN_4_10 +GtkWidget* gtk_message_dialog_new (GtkWindow *parent, + GtkDialogFlags flags, + GtkMessageType type, + GtkButtonsType buttons, + const char *message_format, + ...) G_GNUC_PRINTF (5, 6); + +GDK_DEPRECATED_IN_4_10 +GtkWidget* gtk_message_dialog_new_with_markup (GtkWindow *parent, + GtkDialogFlags flags, + GtkMessageType type, + GtkButtonsType buttons, + const char *message_format, + ...) G_GNUC_PRINTF (5, 6); + +GDK_DEPRECATED_IN_4_10 +void gtk_message_dialog_set_markup (GtkMessageDialog *message_dialog, + const char *str); + +GDK_DEPRECATED_IN_4_10 +void gtk_message_dialog_format_secondary_text (GtkMessageDialog *message_dialog, + const char *message_format, + ...) G_GNUC_PRINTF (2, 3); + +GDK_DEPRECATED_IN_4_10 +void gtk_message_dialog_format_secondary_markup (GtkMessageDialog *message_dialog, + const char *message_format, + ...) G_GNUC_PRINTF (2, 3); + +GDK_DEPRECATED_IN_4_10 +GtkWidget *gtk_message_dialog_get_message_area (GtkMessageDialog *message_dialog); + +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkMessageDialog, g_object_unref) + +G_END_DECLS + +#endif /* __GTK_MESSAGE_DIALOG_H__ */ diff --git a/gtk/deprecated/meson.build b/gtk/deprecated/meson.build index 3e1051825d..def0f5da5e 100644 --- a/gtk/deprecated/meson.build +++ b/gtk/deprecated/meson.build @@ -77,6 +77,7 @@ gtk_deprecated_headers = [ 'deprecated/gtkfontchooserwidget.h', 'deprecated/gtkiconview.h', 'deprecated/gtkliststore.h', + 'deprecated/gtkmessagedialog.h', 'deprecated/gtkrender.h', 'deprecated/gtkstylecontext.h', 'deprecated/gtktreednd.h', diff --git a/gtk/gtk.h b/gtk/gtk.h index 1444da20ed..5a6ed8ca3e 100644 --- a/gtk/gtk.h +++ b/gtk/gtk.h @@ -183,7 +183,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/gtk/gtkalertdialog.c b/gtk/gtkalertdialog.c index c1fbcd413f..4048c6bb1f 100644 --- a/gtk/gtkalertdialog.c +++ b/gtk/gtkalertdialog.c @@ -22,7 +22,7 @@ #include "gtkalertdialog.h" #include "gtkbutton.h" -#include "gtkmessagedialog.h" +#include "deprecated/gtkmessagedialog.h" #include /** diff --git a/gtk/gtkmessagedialog.c b/gtk/gtkmessagedialog.c index 477f9c405a..07e2c0e2c2 100644 --- a/gtk/gtkmessagedialog.c +++ b/gtk/gtkmessagedialog.c @@ -25,7 +25,7 @@ #include "config.h" -#include "gtkmessagedialog.h" +#include "deprecated/gtkmessagedialog.h" #include "gtkbox.h" #include "gtkbuildable.h" @@ -37,6 +37,8 @@ #include +G_GNUC_BEGIN_IGNORE_DEPRECATIONS + /** * GtkMessageDialog: * @@ -96,6 +98,8 @@ * * The `GtkMessageDialog` implementation of the `GtkBuildable` interface exposes * the message area as an internal child with the name “message_area”. + * + * Deprecated: 4.10: Use [class@Gtk.AlertDialog] instead */ typedef struct @@ -479,6 +483,8 @@ gtk_message_dialog_init (GtkMessageDialog *dialog) * for more details. * * Returns: (transfer none): a new `GtkMessageDialog` + * + * Deprecated: 4.10: Use [class@Gtk.AlertDialog] instead */ GtkWidget* gtk_message_dialog_new (GtkWindow *parent, @@ -565,6 +571,8 @@ gtk_message_dialog_new (GtkWindow *parent, * ``` * * Returns: a new `GtkMessageDialog` + * + * Deprecated: 4.10: Use [class@Gtk.AlertDialog] instead **/ GtkWidget* gtk_message_dialog_new_with_markup (GtkWindow *parent, @@ -602,6 +610,8 @@ gtk_message_dialog_new_with_markup (GtkWindow *parent, * @str: string with Pango markup * * Sets the text of the message dialog. + * + * Deprecated: 4.10: Use [class@Gtk.AlertDialog] instead */ void gtk_message_dialog_set_markup (GtkMessageDialog *message_dialog, @@ -622,6 +632,8 @@ gtk_message_dialog_set_markup (GtkMessageDialog *message_dialog, * @...: arguments for @message_format * * Sets the secondary text of the message dialog. + * + * Deprecated: 4.10: Use [class@Gtk.AlertDialog] instead */ void gtk_message_dialog_format_secondary_text (GtkMessageDialog *message_dialog, @@ -679,6 +691,8 @@ gtk_message_dialog_format_secondary_text (GtkMessageDialog *message_dialog, * "%s", msg); * g_free (msg); * ``` + * + * Deprecated: 4.10: Use [class@Gtk.AlertDialog] instead */ void gtk_message_dialog_format_secondary_markup (GtkMessageDialog *message_dialog, @@ -726,6 +740,8 @@ gtk_message_dialog_format_secondary_markup (GtkMessageDialog *message_dialog, * * Returns: (transfer none): A `GtkBox` corresponding to the * “message area” in the @message_dialog + * + * Deprecated: 4.10: Use [class@Gtk.AlertDialog] instead */ GtkWidget * gtk_message_dialog_get_message_area (GtkMessageDialog *message_dialog) diff --git a/gtk/gtkmessagedialog.h b/gtk/gtkmessagedialog.h deleted file mode 100644 index a1de879493..0000000000 --- a/gtk/gtkmessagedialog.h +++ /dev/null @@ -1,118 +0,0 @@ -/* GTK - The GIMP Toolkit - * Copyright (C) 2000 Red Hat, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . - */ - -/* - * Modified by the GTK+ Team and others 1997-2003. See the AUTHORS - * file for a list of people on the GTK+ Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GTK+ at ftp://ftp.gtk.org/pub/gtk/. - */ - -#ifndef __GTK_MESSAGE_DIALOG_H__ -#define __GTK_MESSAGE_DIALOG_H__ - -#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION) -#error "Only can be included directly." -#endif - -#include -#include - -G_BEGIN_DECLS - - -#define GTK_TYPE_MESSAGE_DIALOG (gtk_message_dialog_get_type ()) -#define GTK_MESSAGE_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_MESSAGE_DIALOG, GtkMessageDialog)) -#define GTK_IS_MESSAGE_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_MESSAGE_DIALOG)) - -typedef struct _GtkMessageDialog GtkMessageDialog; -typedef struct _GtkMessageDialogClass GtkMessageDialogClass; - -struct _GtkMessageDialog -{ - GtkDialog parent_instance; -}; - -/** - * GtkButtonsType: - * @GTK_BUTTONS_NONE: no buttons at all - * @GTK_BUTTONS_OK: an OK button - * @GTK_BUTTONS_CLOSE: a Close button - * @GTK_BUTTONS_CANCEL: a Cancel button - * @GTK_BUTTONS_YES_NO: Yes and No buttons - * @GTK_BUTTONS_OK_CANCEL: OK and Cancel buttons - * - * Prebuilt sets of buttons for `GtkDialog`. - * - * If none of these choices are appropriate, simply use - * %GTK_BUTTONS_NONE and call [method@Gtk.Dialog.add_buttons]. - * - * > Please note that %GTK_BUTTONS_OK, %GTK_BUTTONS_YES_NO - * > and %GTK_BUTTONS_OK_CANCEL are discouraged by the - * > [GNOME Human Interface Guidelines](http://library.gnome.org/devel/hig-book/stable/). - */ -typedef enum -{ - GTK_BUTTONS_NONE, - GTK_BUTTONS_OK, - GTK_BUTTONS_CLOSE, - GTK_BUTTONS_CANCEL, - GTK_BUTTONS_YES_NO, - GTK_BUTTONS_OK_CANCEL -} GtkButtonsType; - -GDK_AVAILABLE_IN_ALL -GType gtk_message_dialog_get_type (void) G_GNUC_CONST; - -GDK_AVAILABLE_IN_ALL -GtkWidget* gtk_message_dialog_new (GtkWindow *parent, - GtkDialogFlags flags, - GtkMessageType type, - GtkButtonsType buttons, - const char *message_format, - ...) G_GNUC_PRINTF (5, 6); - -GDK_AVAILABLE_IN_ALL -GtkWidget* gtk_message_dialog_new_with_markup (GtkWindow *parent, - GtkDialogFlags flags, - GtkMessageType type, - GtkButtonsType buttons, - const char *message_format, - ...) G_GNUC_PRINTF (5, 6); - -GDK_AVAILABLE_IN_ALL -void gtk_message_dialog_set_markup (GtkMessageDialog *message_dialog, - const char *str); - -GDK_AVAILABLE_IN_ALL -void gtk_message_dialog_format_secondary_text (GtkMessageDialog *message_dialog, - const char *message_format, - ...) G_GNUC_PRINTF (2, 3); - -GDK_AVAILABLE_IN_ALL -void gtk_message_dialog_format_secondary_markup (GtkMessageDialog *message_dialog, - const char *message_format, - ...) G_GNUC_PRINTF (2, 3); - -GDK_AVAILABLE_IN_ALL -GtkWidget *gtk_message_dialog_get_message_area (GtkMessageDialog *message_dialog); - -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkMessageDialog, g_object_unref) - -G_END_DECLS - -#endif /* __GTK_MESSAGE_DIALOG_H__ */ diff --git a/gtk/gtkprintoperation-unix.c b/gtk/gtkprintoperation-unix.c index 297840d7f8..4fbcd77c1c 100644 --- a/gtk/gtkprintoperation-unix.c +++ b/gtk/gtkprintoperation-unix.c @@ -31,7 +31,6 @@ #include #include "gtkprintoperation-private.h" #include "gtkprintoperation-portal.h" -#include "gtkmessagedialog.h" #include #include diff --git a/gtk/gtkprintoperation.c b/gtk/gtkprintoperation.c index 399faf328d..a2f0a3d7bd 100644 --- a/gtk/gtkprintoperation.c +++ b/gtk/gtkprintoperation.c @@ -29,7 +29,7 @@ #include "gtkmarshalers.h" #include #include "gtkprivate.h" -#include "gtkmessagedialog.h" +#include "deprecated/gtkmessagedialog.h" #include "gtkwindowgroup.h" #include "gtktypebuiltins.h" @@ -2848,15 +2848,17 @@ print_pages (GtkPrintOperation *op, { GtkWidget *progress; - progress = gtk_message_dialog_new (parent, 0, - GTK_MESSAGE_OTHER, - GTK_BUTTONS_CANCEL, - _("Preparing")); - g_signal_connect (progress, "response", - G_CALLBACK (handle_progress_response), op); - - priv->show_progress_timeout_id = - g_timeout_add (SHOW_PROGRESS_TIME, +G_GNUC_BEGIN_IGNORE_DEPRECATIONS + progress = gtk_message_dialog_new (parent, 0, + GTK_MESSAGE_OTHER, + GTK_BUTTONS_CANCEL, + _("Preparing")); +G_GNUC_END_IGNORE_DEPRECATIONS + g_signal_connect (progress, "response", + G_CALLBACK (handle_progress_response), op); + + priv->show_progress_timeout_id = + g_timeout_add (SHOW_PROGRESS_TIME, (GSourceFunc) show_progress_timeout, data); gdk_source_set_static_name_by_id (priv->show_progress_timeout_id, "[gtk] show_progress_timeout"); @@ -2878,6 +2880,7 @@ print_pages (GtkPrintOperation *op, { GtkWidget *error_dialog; +G_GNUC_BEGIN_IGNORE_DEPRECATIONS error_dialog = gtk_message_dialog_new (parent, GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, @@ -2886,6 +2889,7 @@ 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.")); +G_GNUC_END_IGNORE_DEPRECATIONS if (parent && gtk_window_has_group (parent)) gtk_window_group_add_window (gtk_window_get_group (parent), diff --git a/gtk/gtkprintunixdialog.c b/gtk/gtkprintunixdialog.c index a2823abfdf..dd950c31ff 100644 --- a/gtk/gtkprintunixdialog.c +++ b/gtk/gtkprintunixdialog.c @@ -44,7 +44,7 @@ #include "gtkframe.h" #include "gtklabel.h" #include "gtkbuildable.h" -#include "gtkmessagedialog.h" +#include "deprecated/gtkmessagedialog.h" #include "gtkbutton.h" #include "gtksnapshot.h" #include "gtkrenderbackgroundprivate.h" @@ -637,6 +637,7 @@ error_dialogs (GtkPrintUnixDialog *dialog, dirname = g_file_get_parse_name (parent); g_object_unref (parent); +G_GNUC_BEGIN_IGNORE_DEPRECATIONS message_dialog = gtk_message_dialog_new (toplevel, GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, @@ -658,6 +659,7 @@ error_dialogs (GtkPrintUnixDialog *dialog, GTK_RESPONSE_ACCEPT); gtk_dialog_set_default_response (GTK_DIALOG (message_dialog), GTK_RESPONSE_ACCEPT); +G_GNUC_END_IGNORE_DEPRECATIONS if (gtk_window_has_group (toplevel)) gtk_window_group_add_window (gtk_window_get_group (toplevel), diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index 6b4e2d77a7..d5141c10b6 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -47,7 +47,7 @@ #include #include "gtkmain.h" #include "gtkmarshalers.h" -#include "gtkmessagedialog.h" +#include "deprecated/gtkmessagedialog.h" #include "gtkpointerfocusprivate.h" #include "gtkprivate.h" #include "gtkroot.h" @@ -6130,6 +6130,7 @@ gtk_window_set_debugging (GdkDisplay *display, if (warn) { +G_GNUC_BEGIN_IGNORE_DEPRECATIONS dialog = gtk_message_dialog_new (GTK_WINDOW (inspector_window), GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION, @@ -6141,6 +6142,7 @@ gtk_window_set_debugging (GdkDisplay *display, "application to break or crash.")); area = gtk_message_dialog_get_message_area (GTK_MESSAGE_DIALOG (dialog)); +G_GNUC_END_IGNORE_DEPRECATIONS check = gtk_check_button_new_with_label (_("Don’t show this message again")); gtk_widget_set_margin_start (check, 10); gtk_widget_show (check); diff --git a/gtk/inspector/logs.c b/gtk/inspector/logs.c index d0e6fc9b3d..14fcfe49ef 100644 --- a/gtk/inspector/logs.c +++ b/gtk/inspector/logs.c @@ -27,7 +27,6 @@ #include "window.h" #include "gtktextview.h" -#include "gtkmessagedialog.h" #include "gtkfilechooserdialog.h" #include "gtkcheckbutton.h" #include "gtklabel.h" diff --git a/gtk/meson.build b/gtk/meson.build index 7b294cbaa4..d47249005b 100644 --- a/gtk/meson.build +++ b/gtk/meson.build @@ -535,7 +535,6 @@ gtk_public_headers = files([ 'gtkmediafile.h', 'gtkmediastream.h', 'gtkmenubutton.h', - 'gtkmessagedialog.h', 'gtkmountoperation.h', 'gtkmultifilter.h', 'gtkmultiselection.h', diff --git a/tests/testfilechooser.c b/tests/testfilechooser.c index c06f636884..65f15e49d6 100644 --- a/tests/testfilechooser.c +++ b/tests/testfilechooser.c @@ -35,6 +35,8 @@ # endif #endif +G_GNUC_BEGIN_IGNORE_DEPRECATIONS + #if 0 static GtkWidget *preview_label; static GtkWidget *preview_image; diff --git a/tests/testvolumebutton.c b/tests/testvolumebutton.c index 0291d3d7b4..982d5c285d 100644 --- a/tests/testvolumebutton.c +++ b/tests/testvolumebutton.c @@ -17,6 +17,8 @@ #include +G_GNUC_BEGIN_IGNORE_DEPRECATIONS + static void value_changed (GtkWidget *button, double volume,