Skip to content

Commit 3e4cc96

Browse files
committed
patch 8.2.1649: GTK3: using old file chooser
Problem: GTK3: using old file chooser. Solution: Use native file chooser on GTK 3.20 and above. (Yogeshwar Velingker, closes #6909)
1 parent a62372b commit 3e4cc96

2 files changed

Lines changed: 29 additions & 6 deletions

File tree

src/gui_gtk.c

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,7 +1199,11 @@ gui_mch_browse(int saving UNUSED,
11991199
char_u *filter)
12001200
{
12011201
#ifdef USE_FILE_CHOOSER
1202-
GtkWidget *fc;
1202+
# if GTK_CHECK_VERSION(3,20,0)
1203+
GtkFileChooserNative *fc;
1204+
# else
1205+
GtkWidget *fc;
1206+
# endif
12031207
#endif
12041208
char_u dirbuf[MAXPATHL];
12051209
guint log_handler;
@@ -1226,18 +1230,27 @@ gui_mch_browse(int saving UNUSED,
12261230
#ifdef USE_FILE_CHOOSER
12271231
// We create the dialog each time, so that the button text can be "Open"
12281232
// or "Save" according to the action.
1229-
fc = gtk_file_chooser_dialog_new((const gchar *)title,
1233+
# if GTK_CHECK_VERSION(3,20,0)
1234+
fc = gtk_file_chooser_native_new(
1235+
# else
1236+
fc = gtk_file_chooser_dialog_new(
1237+
# endif
1238+
(const gchar *)title,
12301239
GTK_WINDOW(gui.mainwin),
12311240
saving ? GTK_FILE_CHOOSER_ACTION_SAVE
12321241
: GTK_FILE_CHOOSER_ACTION_OPEN,
1233-
# if GTK_CHECK_VERSION(3,10,0)
1242+
# if GTK_CHECK_VERSION(3,20,0)
1243+
saving ? _("_Save") : _("_Open"), _("_Cancel"));
1244+
# else
1245+
# if GTK_CHECK_VERSION(3,10,0)
12341246
_("_Cancel"), GTK_RESPONSE_CANCEL,
12351247
saving ? _("_Save") : _("_Open"), GTK_RESPONSE_ACCEPT,
1236-
# else
1248+
# else
12371249
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
12381250
saving ? GTK_STOCK_SAVE : GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
1239-
# endif
1251+
# endif
12401252
NULL);
1253+
# endif
12411254
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(fc),
12421255
(const gchar *)dirbuf);
12431256

@@ -1263,7 +1276,7 @@ gui_mch_browse(int saving UNUSED,
12631276
gtk_file_filter_add_pattern(gfilter, (gchar *)patt);
12641277
if (*p == '\n')
12651278
{
1266-
gtk_file_chooser_add_filter((GtkFileChooser *)fc,
1279+
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(fc),
12671280
gfilter);
12681281
if (*(p + 1) != NUL)
12691282
gfilter = gtk_file_filter_new();
@@ -1284,15 +1297,23 @@ gui_mch_browse(int saving UNUSED,
12841297
gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(fc), (char *)dflt);
12851298

12861299
gui.browse_fname = NULL;
1300+
# if GTK_CHECK_VERSION(3,20,0)
1301+
if (gtk_native_dialog_run(GTK_NATIVE_DIALOG(fc)) == GTK_RESPONSE_ACCEPT)
1302+
# else
12871303
if (gtk_dialog_run(GTK_DIALOG(fc)) == GTK_RESPONSE_ACCEPT)
1304+
#endif
12881305
{
12891306
char *filename;
12901307

12911308
filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(fc));
12921309
gui.browse_fname = (char_u *)g_strdup(filename);
12931310
g_free(filename);
12941311
}
1312+
# if GTK_CHECK_VERSION(3,20,0)
1313+
g_object_unref(fc);
1314+
# else
12951315
gtk_widget_destroy(GTK_WIDGET(fc));
1316+
# endif
12961317

12971318
#else // !USE_FILE_CHOOSER
12981319

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,8 @@ static char *(features[]) =
750750

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
1649,
753755
/**/
754756
1648,
755757
/**/

0 commit comments

Comments
 (0)