Skip to content

Commit

Permalink
Deprecate GtkDialog
Browse files Browse the repository at this point in the history
GtkDialog is too flexible in terms of UI (headerbars vs action bar,
etc), and has archaic APIs. It is time to retire it.
  • Loading branch information
Matthias Clasen committed Oct 29, 2022
1 parent f1af804 commit 9948053
Show file tree
Hide file tree
Showing 34 changed files with 91 additions and 35 deletions.
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ feedback on our plans.
* GtkMessageDialog has been deprecated and
replaced by a new async dialog API

* GtkDialog has been deprecated

* GtkColorChooser, GtkFontChooser, GtkFileChooser
interfaces and their implementations have been
deprecated. A new family of async dialog APIs
Expand Down
2 changes: 2 additions & 0 deletions demos/gtk-demo/spinner.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ do_spinner (GtkWidget *do_widget)

if (!window)
{
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
window = gtk_dialog_new_with_buttons ("Spinner",
GTK_WINDOW (do_widget),
0,
Expand All @@ -48,6 +49,7 @@ do_spinner (GtkWidget *do_widget)
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);

content_area = gtk_dialog_get_content_area (GTK_DIALOG (window));
G_GNUC_END_IGNORE_DEPRECATIONS

vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
gtk_widget_set_margin_start (vbox, 5);
Expand Down
2 changes: 2 additions & 0 deletions demos/widget-factory/widget-factory.c
Original file line number Diff line number Diff line change
Expand Up @@ -1467,7 +1467,9 @@ close_selection_dialog (GtkWidget *dialog, int response, GtkWidget *tv)
if (response == GTK_RESPONSE_CANCEL)
return;

G_GNUC_BEGIN_IGNORE_DEPRECATIONS
box = gtk_widget_get_first_child (gtk_dialog_get_content_area (GTK_DIALOG (dialog)));
G_GNUC_END_IGNORE_DEPRECATIONS
g_assert (GTK_IS_FLOW_BOX (box));
children = gtk_flow_box_get_selected_children (GTK_FLOW_BOX (box));

Expand Down
8 changes: 8 additions & 0 deletions docs/reference/gtk/migrating-4to5.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,11 @@ There are also equivalents for some of the 'button' widgets:
Like the Chooser interfaces, GtkMessageDialog has been replaced by
a new async API that will be more convenient, in particular for
language binding. The new API is [[email protected]].

## GtkDialog is going away

After gtk_dialog_run() was removed, the usefulness of GtkDialog
is much reduced, and it has awkward, archaice APIs. Therefore,
it is dropped. The recommended replacement is to just create
your own window and add buttons as required, either in the header
or elsewhere.
2 changes: 2 additions & 0 deletions examples/bp/bloatpad.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include <stdlib.h>
#include <gtk/gtk.h>

G_GNUC_BEGIN_IGNORE_DEPRECATIONS

typedef struct
{
GtkApplication parent_instance;
Expand Down
2 changes: 1 addition & 1 deletion gtk/deprecated/gtkappchooserdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#error "Only <gtk/gtk.h> can be included directly."
#endif

#include <gtk/gtkdialog.h>
#include <gtk/deprecated/gtkdialog.h>
#include <gio/gio.h>

G_BEGIN_DECLS
Expand Down
2 changes: 1 addition & 1 deletion gtk/deprecated/gtkcolorchooserdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#error "Only <gtk/gtk.h> can be included directly."
#endif

#include <gtk/gtkdialog.h>
#include <gtk/deprecated/gtkdialog.h>

G_BEGIN_DECLS

Expand Down
2 changes: 2 additions & 0 deletions gtk/gtkdialog.c → gtk/deprecated/gtkdialog.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
#include "gtktypebuiltins.h"
#include "gtksizegroup.h"

G_GNUC_BEGIN_IGNORE_DEPRECATIONS

/**
* GtkDialog:
*
Expand Down
24 changes: 12 additions & 12 deletions gtk/gtkdialog.h → gtk/deprecated/gtkdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,51 +127,51 @@ struct _GtkDialogClass

GDK_AVAILABLE_IN_ALL
GType gtk_dialog_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
GDK_DEPRECATED_IN_4_10
GtkWidget* gtk_dialog_new (void);

GDK_AVAILABLE_IN_ALL
GDK_DEPRECATED_IN_4_10
GtkWidget* gtk_dialog_new_with_buttons (const char *title,
GtkWindow *parent,
GtkDialogFlags flags,
const char *first_button_text,
...) G_GNUC_NULL_TERMINATED;

GDK_AVAILABLE_IN_ALL
GDK_DEPRECATED_IN_4_10
void gtk_dialog_add_action_widget (GtkDialog *dialog,
GtkWidget *child,
int response_id);
GDK_AVAILABLE_IN_ALL
GDK_DEPRECATED_IN_4_10
GtkWidget* gtk_dialog_add_button (GtkDialog *dialog,
const char *button_text,
int response_id);
GDK_AVAILABLE_IN_ALL
GDK_DEPRECATED_IN_4_10
void gtk_dialog_add_buttons (GtkDialog *dialog,
const char *first_button_text,
...) G_GNUC_NULL_TERMINATED;

GDK_AVAILABLE_IN_ALL
GDK_DEPRECATED_IN_4_10
void gtk_dialog_set_response_sensitive (GtkDialog *dialog,
int response_id,
gboolean setting);
GDK_AVAILABLE_IN_ALL
GDK_DEPRECATED_IN_4_10
void gtk_dialog_set_default_response (GtkDialog *dialog,
int response_id);
GDK_AVAILABLE_IN_ALL
GDK_DEPRECATED_IN_4_10
GtkWidget* gtk_dialog_get_widget_for_response (GtkDialog *dialog,
int response_id);
GDK_AVAILABLE_IN_ALL
GDK_DEPRECATED_IN_4_10
int gtk_dialog_get_response_for_widget (GtkDialog *dialog,
GtkWidget *widget);

/* Emit response signal */
GDK_AVAILABLE_IN_ALL
GDK_DEPRECATED_IN_4_10
void gtk_dialog_response (GtkDialog *dialog,
int response_id);

GDK_AVAILABLE_IN_ALL
GDK_DEPRECATED_IN_4_10
GtkWidget * gtk_dialog_get_content_area (GtkDialog *dialog);
GDK_AVAILABLE_IN_ALL
GDK_DEPRECATED_IN_4_10
GtkWidget * gtk_dialog_get_header_bar (GtkDialog *dialog);

G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkDialog, g_object_unref)
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion gtk/deprecated/gtkfilechooserdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#error "Only <gtk/gtk.h> can be included directly."
#endif

#include <gtk/gtkdialog.h>
#include <gtk/deprecated/gtkdialog.h>
#include <gtk/deprecated/gtkfilechooser.h>

G_BEGIN_DECLS
Expand Down
2 changes: 1 addition & 1 deletion gtk/deprecated/gtkfontchooserdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#error "Only <gtk/gtk.h> can be included directly."
#endif

#include <gtk/gtkdialog.h>
#include <gtk/deprecated/gtkdialog.h>

G_BEGIN_DECLS

Expand Down
2 changes: 1 addition & 1 deletion gtk/deprecated/gtkmessagedialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#error "Only <gtk/gtk.h> can be included directly."
#endif

#include <gtk/gtkdialog.h>
#include <gtk/deprecated/gtkdialog.h>
#include <gtk/gtkenums.h>

G_BEGIN_DECLS
Expand Down
2 changes: 2 additions & 0 deletions gtk/deprecated/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ gtk_deprecated_sources = [
'deprecated/gtkcolorchooser.c',
'deprecated/gtkcombobox.c',
'deprecated/gtkcomboboxtext.c',
'deprecated/gtkdialog.c',
'deprecated/gtkentrycompletion.c',
'deprecated/gtkfilechooser.c',
'deprecated/gtkfontbutton.c',
Expand Down Expand Up @@ -71,6 +72,7 @@ gtk_deprecated_headers = [
'deprecated/gtkcolorchooserwidget.h',
'deprecated/gtkcombobox.h',
'deprecated/gtkcomboboxtext.h',
'deprecated/gtkdialog.h',
'deprecated/gtkentrycompletion.h',
'deprecated/gtkfilechooser.h',
'deprecated/gtkfilechooserdialog.h',
Expand Down
2 changes: 1 addition & 1 deletion gtk/gtk.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
#include <gtk/gtkcustomlayout.h>
#include <gtk/gtkcustomsorter.h>
#include <gtk/gtkdebug.h>
#include <gtk/gtkdialog.h>
#include <gtk/deprecated/gtkdialog.h>
#include <gtk/gtkdialogerror.h>
#include <gtk/gtkdirectorylist.h>
#include <gtk/gtkdragicon.h>
Expand Down
2 changes: 2 additions & 0 deletions gtk/gtkalertdialog.c
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,7 @@ gtk_alert_dialog_choose (GtkAlertDialog *self,

g_return_if_fail (GTK_IS_ALERT_DIALOG (self));

G_GNUC_BEGIN_IGNORE_DEPRECATIONS
window = g_object_new (GTK_TYPE_MESSAGE_DIALOG,
"transient-for", parent,
"destroy-with-parent", TRUE,
Expand All @@ -689,6 +690,7 @@ gtk_alert_dialog_choose (GtkAlertDialog *self,
gtk_dialog_set_default_response (GTK_DIALOG (window), 0);
self->cancel_return = 0;
}
G_GNUC_END_IGNORE_DEPRECATIONS

task = g_task_new (self, cancellable, callback, user_data);
g_task_set_source_tag (task, gtk_alert_dialog_choose);
Expand Down
4 changes: 2 additions & 2 deletions gtk/gtkcolorchooserdialog.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

#include "config.h"

#include "gtkdialog.h"
#include "gtkdialogprivate.h"
#include "deprecated/gtkdialog.h"
#include "deprecated/gtkdialogprivate.h"
#include "gtkbutton.h"
#include "gtkbox.h"
#include "gtkprivate.h"
Expand Down
9 changes: 8 additions & 1 deletion gtk/gtkcustompaperunixdialog.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#include "gtkcustompaperunixdialog.h"
#include "gtkprintbackendprivate.h"
#include "gtkprintutils.h"
#include "gtkdialogprivate.h"
#include "deprecated/gtkdialogprivate.h"

#define LEGACY_CUSTOM_PAPER_FILENAME ".gtk-custom-papers"
#define CUSTOM_PAPER_FILENAME "custom-papers"
Expand Down Expand Up @@ -283,7 +283,9 @@ gtk_custom_paper_unix_dialog_init (GtkCustomPaperUnixDialog *dialog)
GListModel *full_list;
GtkFilter *filter;

G_GNUC_BEGIN_IGNORE_DEPRECATIONS
gtk_dialog_set_use_header_bar_from_setting (GTK_DIALOG (dialog));
G_GNUC_END_IGNORE_DEPRECATIONS

dialog->print_backends = NULL;

Expand Down Expand Up @@ -318,6 +320,7 @@ gtk_custom_paper_unix_dialog_constructed (GObject *object)

G_OBJECT_CLASS (gtk_custom_paper_unix_dialog_parent_class)->constructed (object);

G_GNUC_BEGIN_IGNORE_DEPRECATIONS
g_object_get (object, "use-header-bar", &use_header, NULL);
if (!use_header)
{
Expand All @@ -326,6 +329,7 @@ gtk_custom_paper_unix_dialog_constructed (GObject *object)
NULL);
gtk_dialog_set_default_response (GTK_DIALOG (object), GTK_RESPONSE_CLOSE);
}
G_GNUC_END_IGNORE_DEPRECATIONS
}

static void
Expand Down Expand Up @@ -847,7 +851,10 @@ populate_dialog (GtkCustomPaperUnixDialog *dialog)
GtkSelectionModel *model;
GtkListItemFactory *factory;

G_GNUC_BEGIN_IGNORE_DEPRECATIONS
content_area = gtk_dialog_get_content_area (cpu_dialog);
G_GNUC_END_IGNORE_DEPRECATIONS

gtk_box_set_spacing (GTK_BOX (content_area), 2); /* 2 * 5 + 2 = 12 */

hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 18);
Expand Down
2 changes: 1 addition & 1 deletion gtk/gtkfilechooserdialog.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include "gtksettings.h"
#include "gtktogglebutton.h"
#include "gtkheaderbar.h"
#include "gtkdialogprivate.h"
#include "deprecated/gtkdialogprivate.h"
#include "gtklabel.h"
#include "gtkfilechooserentry.h"
#include "gtkbox.h"
Expand Down
2 changes: 1 addition & 1 deletion gtk/gtkfilechoosernativeportal.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "gtknativedialogprivate.h"

#include "gtkprivate.h"
#include "gtkdialog.h"
#include "deprecated/gtkdialog.h"
#include "gtkfilechooserprivate.h"
#include "gtksizerequest.h"
#include "gtktypebuiltins.h"
Expand Down
2 changes: 1 addition & 1 deletion gtk/gtkfiledialog.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

#include "gtkfiledialog.h"

#include "gtkdialog.h"
#include "deprecated/gtkdialog.h"
#include "deprecated/gtkfilechoosernative.h"
#include "gtkdialogerror.h"
#include <glib/gi18n-lib.h>
Expand Down
2 changes: 1 addition & 1 deletion gtk/gtkfontchooserdialog.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include "gtkprivate.h"
#include "gtkwidget.h"
#include "gtksettings.h"
#include "gtkdialogprivate.h"
#include "deprecated/gtkdialogprivate.h"
#include "gtktogglebutton.h"
#include "gtkheaderbar.h"
#include "gtkactionable.h"
Expand Down
2 changes: 1 addition & 1 deletion gtk/gtkfontchooserwidget.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
#include "gtktextview.h"
#include "gtkwidgetprivate.h"
#include "gtksettings.h"
#include "gtkdialog.h"
#include "deprecated/gtkdialog.h"
#include "gtkgestureclick.h"
#include "gtkeventcontrollerscroll.h"
#include "gtkroot.h"
Expand Down
2 changes: 1 addition & 1 deletion gtk/gtkinfobar.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#include "gtklabel.h"
#include "gtkbutton.h"
#include "gtkenums.h"
#include "gtkdialog.h"
#include "deprecated/gtkdialog.h"
#include "gtkrevealer.h"
#include "gtkprivate.h"
#include "gtktypebuiltins.h"
Expand Down
2 changes: 1 addition & 1 deletion gtk/gtkmessagedialog.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

#include "gtkbox.h"
#include "gtkbuildable.h"
#include "gtkdialogprivate.h"
#include "deprecated/gtkdialogprivate.h"
#include <glib/gi18n-lib.h>
#include "gtklabel.h"
#include "gtkprivate.h"
Expand Down
Loading

0 comments on commit 9948053

Please sign in to comment.