[gtk/default-handling: 10/18] file chooser: Stop using gtk_window_activate_default
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/default-handling: 10/18] file chooser: Stop using gtk_window_activate_default
- Date: Sun, 28 Apr 2019 19:32:39 +0000 (UTC)
commit 5bf840a9cd22af25bb41820f32c1888757d13054
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Apr 28 18:33:27 2019 +0000
file chooser: Stop using gtk_window_activate_default
Instead, use the new way of activating default.
I think most of the default handling in
GtkFileChooserDialog should be dropped, but
for now this keeps things working.
gtk/gtkfilechooserdialog.c | 27 ++-------------------------
gtk/gtkfilechooserwidget.c | 21 ++-------------------
2 files changed, 4 insertions(+), 44 deletions(-)
---
diff --git a/gtk/gtkfilechooserdialog.c b/gtk/gtkfilechooserdialog.c
index ce29143f8b..667c768e8c 100644
--- a/gtk/gtkfilechooserdialog.c
+++ b/gtk/gtkfilechooserdialog.c
@@ -341,17 +341,7 @@ static void
file_chooser_widget_file_activated (GtkFileChooser *chooser,
GtkFileChooserDialog *dialog)
{
- GtkWidget *widget;
-
- if (gtk_window_activate_default (GTK_WINDOW (dialog)))
- return;
-
- /* There probably isn't a default widget, so make things easier for the
- * programmer by looking for a reasonable button on our own.
- */
- widget = get_accept_action_widget (GTK_DIALOG (dialog), TRUE);
- if (widget)
- gtk_widget_activate (widget);
+ gtk_widget_activate_action (GTK_WIDGET (chooser), "gtk.activate-default", NULL);
}
static void
@@ -405,22 +395,9 @@ static void
file_chooser_widget_response_requested (GtkWidget *widget,
GtkFileChooserDialog *dialog)
{
- GtkWidget *button;
-
dialog->priv->response_requested = TRUE;
- if (gtk_window_activate_default (GTK_WINDOW (dialog)))
- return;
-
- /* There probably isn't a default widget, so make things easier for the
- * programmer by looking for a reasonable button on our own.
- */
- button = get_accept_action_widget (GTK_DIALOG (dialog), TRUE);
- if (button)
- {
- gtk_widget_activate (button);
- return;
- }
+ gtk_widget_activate_action (widget, "gtk.activate-default", NULL);
dialog->priv->response_requested = FALSE;
}
diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c
index fcc2ebc540..bbc19cf499 100644
--- a/gtk/gtkfilechooserwidget.c
+++ b/gtk/gtkfilechooserwidget.c
@@ -1347,25 +1347,8 @@ key_press_cb (GtkEventControllerKey *controller,
&& !(priv->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER ||
priv->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER))
{
- GtkWidget *widget = GTK_WIDGET (impl);
- GtkWindow *window;
-
- window = get_toplevel (widget);
- if (window)
- {
- GtkWidget *default_widget, *focus_widget;
-
- default_widget = gtk_window_get_default_widget (window);
- focus_widget = gtk_root_get_focus (GTK_ROOT (window));
-
- if (widget != default_widget &&
- !(widget == focus_widget && (!default_widget || !gtk_widget_get_sensitive (default_widget))))
- {
- gtk_window_activate_default (window);
-
- return GDK_EVENT_STOP;
- }
- }
+ gtk_widget_activate_action (GTK_WIDGET (impl), "gtk.activate-default", NULL);
+ return GDK_EVENT_STOP;
}
if (keyval == GDK_KEY_Escape &&
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]