[gedit] FileChooserDialog: simplify create(), have standard response codes
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit] FileChooserDialog: simplify create(), have standard response codes
- Date: Thu, 4 Jun 2020 21:43:11 +0000 (UTC)
commit 3a95f2cae02f455bf2ce585be558a291ed8a138c
Author: Sébastien Wilmet <swilmet gnome org>
Date: Thu Jun 4 23:34:55 2020 +0200
FileChooserDialog: simplify create(), have standard response codes
gedit/gedit-commands-file.c | 8 ++++----
gedit/gedit-file-chooser-dialog-gtk.c | 10 ++++------
gedit/gedit-file-chooser-dialog-gtk.h | 4 +---
gedit/gedit-file-chooser-dialog-osx.h | 4 +---
gedit/gedit-file-chooser-dialog-osx.m | 14 +++-----------
gedit/gedit-file-chooser-dialog.c | 12 +++---------
gedit/gedit-file-chooser-dialog.h | 4 +---
7 files changed, 17 insertions(+), 39 deletions(-)
---
diff --git a/gedit/gedit-commands-file.c b/gedit/gedit-commands-file.c
index 65039e6a6..eb9a64267 100644
--- a/gedit/gedit-commands-file.c
+++ b/gedit/gedit-commands-file.c
@@ -454,8 +454,8 @@ _gedit_cmd_file_open (GSimpleAction *action,
open_dialog = gedit_file_chooser_dialog_create (C_("window title", "Open Files"),
window != NULL ? GTK_WINDOW (window) : NULL,
GEDIT_FILE_CHOOSER_OPEN,
- _("_Cancel"), GTK_RESPONSE_CANCEL,
- _("_Open"), GTK_RESPONSE_ACCEPT);
+ _("_Cancel"),
+ _("_Open"));
if (window != NULL)
{
@@ -842,8 +842,8 @@ save_as_tab_async (GeditTab *tab,
save_dialog = gedit_file_chooser_dialog_create (C_("window title", "Save As"),
GTK_WINDOW (window),
GEDIT_FILE_CHOOSER_SAVE,
- _("_Cancel"), GTK_RESPONSE_CANCEL,
- _("_Save"), GTK_RESPONSE_ACCEPT);
+ _("_Cancel"),
+ _("_Save"));
gedit_file_chooser_dialog_set_do_overwrite_confirmation (save_dialog, TRUE);
diff --git a/gedit/gedit-file-chooser-dialog-gtk.c b/gedit/gedit-file-chooser-dialog-gtk.c
index 241b8f5ca..ea25c7a2b 100644
--- a/gedit/gedit-file-chooser-dialog-gtk.c
+++ b/gedit/gedit-file-chooser-dialog-gtk.c
@@ -551,9 +551,7 @@ gedit_file_chooser_dialog_gtk_create (const gchar *title,
GtkWindow *parent,
GeditFileChooserFlags flags,
const gchar *cancel_label,
- GtkResponseType cancel_response,
- const gchar *accept_label,
- GtkResponseType accept_response)
+ const gchar *accept_label)
{
GeditFileChooserDialogGtk *result;
GtkFileFilter *filter;
@@ -628,9 +626,9 @@ gedit_file_chooser_dialog_gtk_create (const gchar *title,
gtk_window_set_destroy_with_parent (GTK_WINDOW (result), TRUE);
}
- gtk_dialog_add_button (GTK_DIALOG (result), cancel_label, cancel_response);
- gtk_dialog_add_button (GTK_DIALOG (result), accept_label, accept_response);
- gtk_dialog_set_default_response (GTK_DIALOG (result), accept_response);
+ gtk_dialog_add_button (GTK_DIALOG (result), cancel_label, GTK_RESPONSE_CANCEL);
+ gtk_dialog_add_button (GTK_DIALOG (result), accept_label, GTK_RESPONSE_ACCEPT);
+ gtk_dialog_set_default_response (GTK_DIALOG (result), GTK_RESPONSE_ACCEPT);
return GEDIT_FILE_CHOOSER_DIALOG (result);
}
diff --git a/gedit/gedit-file-chooser-dialog-gtk.h b/gedit/gedit-file-chooser-dialog-gtk.h
index c1e7f2cb6..533e94ab1 100644
--- a/gedit/gedit-file-chooser-dialog-gtk.h
+++ b/gedit/gedit-file-chooser-dialog-gtk.h
@@ -37,9 +37,7 @@ GeditFileChooserDialog * gedit_file_chooser_dialog_gtk_create (const gchar
GtkWindow *parent,
GeditFileChooserFlags flags,
const gchar *cancel_label,
- GtkResponseType
cancel_response,
- const gchar *accept_label,
- GtkResponseType
accept_response);
+ const gchar *accept_label);
G_END_DECLS
diff --git a/gedit/gedit-file-chooser-dialog-osx.h b/gedit/gedit-file-chooser-dialog-osx.h
index b8f246d54..c9e776ce3 100644
--- a/gedit/gedit-file-chooser-dialog-osx.h
+++ b/gedit/gedit-file-chooser-dialog-osx.h
@@ -37,9 +37,7 @@ GeditFileChooserDialog * gedit_file_chooser_dialog_osx_create (const gchar
GtkWindow *parent,
GeditFileChooserFlags flags,
const gchar *cancel_label,
- GtkResponseType
cancel_response,
- const gchar *accept_label,
- GtkResponseType
accept_response);
+ const gchar *accept_label);
G_END_DECLS
diff --git a/gedit/gedit-file-chooser-dialog-osx.m b/gedit/gedit-file-chooser-dialog-osx.m
index 686a59706..5fc7f0a67 100644
--- a/gedit/gedit-file-chooser-dialog-osx.m
+++ b/gedit/gedit-file-chooser-dialog-osx.m
@@ -46,9 +46,6 @@ struct _GeditFileChooserDialogOSX
gboolean is_modal;
gboolean is_running;
- GtkResponseType cancel_response;
- GtkResponseType accept_response;
-
gulong destroy_id;
GeditFileChooserFlags flags;
@@ -714,11 +711,11 @@ chooser_show (GeditFileChooserDialog *dialog)
if (result == NSFileHandlingPanelOKButton)
{
- response = dialog_osx->accept_response;
+ response = GTK_RESPONSE_ACCEPT;
}
else
{
- response = dialog_osx->cancel_response;
+ response = GTK_RESPONSE_CANCEL;
}
g_signal_emit_by_name (dialog, "response", response);
@@ -866,18 +863,13 @@ gedit_file_chooser_dialog_osx_create (const gchar *title,
GtkWindow *parent,
GeditFileChooserFlags flags,
const gchar *cancel_label,
- GtkResponseType cancel_response,
- const gchar *accept_label,
- GtkResponseType accept_response)
+ const gchar *accept_label)
{
GeditFileChooserDialogOSX *ret;
gchar *nomnem;
ret = g_object_new (GEDIT_TYPE_FILE_CHOOSER_DIALOG_OSX, NULL);
- ret->cancel_response = cancel_response;
- ret->accept_response = accept_response;
-
if ((flags & GEDIT_FILE_CHOOSER_SAVE) != 0)
{
NSSavePanel *panel = [[NSSavePanel savePanel] retain];
diff --git a/gedit/gedit-file-chooser-dialog.c b/gedit/gedit-file-chooser-dialog.c
index 2a3af34d4..ef60a73c2 100644
--- a/gedit/gedit-file-chooser-dialog.c
+++ b/gedit/gedit-file-chooser-dialog.c
@@ -72,26 +72,20 @@ gedit_file_chooser_dialog_create (const gchar *title,
GtkWindow *parent,
GeditFileChooserFlags flags,
const gchar *cancel_label,
- GtkResponseType cancel_response,
- const gchar *accept_label,
- GtkResponseType accept_response)
+ const gchar *accept_label)
{
#ifdef OS_OSX
return gedit_file_chooser_dialog_osx_create (title,
parent,
flags,
cancel_label,
- cancel_response,
- accept_label,
- accept_response);
+ accept_label);
#else
return gedit_file_chooser_dialog_gtk_create (title,
parent,
flags,
cancel_label,
- cancel_response,
- accept_label,
- accept_response);
+ accept_label);
#endif
}
diff --git a/gedit/gedit-file-chooser-dialog.h b/gedit/gedit-file-chooser-dialog.h
index c90cf17eb..3619d14f4 100644
--- a/gedit/gedit-file-chooser-dialog.h
+++ b/gedit/gedit-file-chooser-dialog.h
@@ -86,9 +86,7 @@ GeditFileChooserDialog *
GtkWindow *parent,
GeditFileChooserFlags flags,
const gchar *cancel_label,
- GtkResponseType cancel_response,
- const gchar *accept_label,
- GtkResponseType accept_response);
+ const gchar *accept_label);
void gedit_file_chooser_dialog_destroy (GeditFileChooserDialog *dialog);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]