~ubuntu-branches/ubuntu/utopic/geany/utopic

« back to all changes in this revision

Viewing changes to src/dialogs.c

  • Committer: Package Import Robot
  • Author(s): Chow Loong Jin
  • Date: 2011-12-10 07:43:26 UTC
  • mfrom: (3.3.7 sid)
  • Revision ID: package-import@ubuntu.com-20111210074326-s8yqbew5i20h33tf
Tags: 0.21-1ubuntu1
* Merge from Debian Unstable, remaining changes:
  - debian/patches/20_use_evince_viewer.patch:
     + use evince as viewer for pdf and dvi files
  - debian/patches/20_use_x_terminal_emulator.patch:
     + use x-terminal-emulator as terminal
  - debian/control
     + Add breaks on geany-plugins-common << 0.20
* Also fixes bugs:
  - Filter for MATLAB/Octave files filters everythign (LP: 885505)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 *      dialogs.c - this file is part of Geany, a fast and lightweight IDE
3
3
 *
4
 
 *      Copyright 2005-2010 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
5
 
 *      Copyright 2006-2010 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
 
4
 *      Copyright 2005-2011 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
 
5
 *      Copyright 2006-2011 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
6
6
 *
7
7
 *      This program is free software; you can redistribute it and/or modify
8
8
 *      it under the terms of the GNU General Public License as published by
18
18
 *      along with this program; if not, write to the Free Software
19
19
 *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20
20
 *
21
 
 * $Id: dialogs.c 5419 2010-11-18 18:53:12Z ntrel $
 
21
 * $Id: dialogs.c 5945 2011-09-22 12:05:05Z ntrel $
22
22
 */
23
23
 
24
24
/*
66
66
};
67
67
 
68
68
 
69
 
static gboolean handle_save_as(const gchar *utf8_filename, gboolean open_new_tab,
70
 
        gboolean rename_file);
71
 
 
72
 
 
73
 
static GtkWidget *add_file_open_extra_widget(void);
74
 
 
75
 
 
76
 
static void
77
 
on_file_open_dialog_response           (GtkDialog *dialog,
78
 
                                        gint response,
79
 
                                        gpointer user_data)
80
 
{
81
 
        gtk_widget_hide(ui_widgets.open_filesel);
82
 
 
 
69
static struct FileSelState
 
70
{
 
71
        struct
 
72
        {
 
73
                guint filter_idx;
 
74
                gint encoding_idx;
 
75
                gint filetype_idx;
 
76
                gboolean show_hidden;
 
77
                gboolean more_options_visible;
 
78
        } open;
 
79
        struct
 
80
        {
 
81
                gboolean open_in_new_tab;
 
82
        } save;
 
83
}
 
84
filesel_state = {
 
85
        {
 
86
                0,
 
87
                GEANY_ENCODINGS_MAX, /* default encoding is detect from file */
 
88
                0,
 
89
                FALSE,
 
90
                FALSE
 
91
        },
 
92
        {
 
93
                FALSE
 
94
        }
 
95
};
 
96
 
 
97
 
 
98
/* gets the ID of the current file filter */
 
99
static guint file_chooser_get_filter_idx(GtkFileChooser *chooser)
 
100
{
 
101
        guint idx = 0;
 
102
        GtkFileFilter *current;
 
103
        GSList *filters, *item;
 
104
 
 
105
        current = gtk_file_chooser_get_filter(chooser);
 
106
        filters = gtk_file_chooser_list_filters(chooser);
 
107
        foreach_slist(item, filters)
 
108
        {
 
109
                if (item->data == current)
 
110
                        break;
 
111
                idx ++;
 
112
        }
 
113
        g_slist_free(filters);
 
114
        return idx;
 
115
}
 
116
 
 
117
 
 
118
/* sets the current file filter from its ID */
 
119
static void file_chooser_set_filter_idx(GtkFileChooser *chooser, guint idx)
 
120
{
 
121
        GtkFileFilter *current;
 
122
        GSList *filters;
 
123
 
 
124
        filters = gtk_file_chooser_list_filters(chooser);
 
125
        current = g_slist_nth_data(filters, idx);
 
126
        g_slist_free(filters);
 
127
        gtk_file_chooser_set_filter(chooser, current);
 
128
}
 
129
 
 
130
 
 
131
static void open_file_dialog_handle_response(GtkWidget *dialog, gint response)
 
132
{
83
133
        if (response == GTK_RESPONSE_ACCEPT || response == GEANY_RESPONSE_VIEW)
84
134
        {
85
135
                GSList *filelist;
86
 
                gint filetype_idx = gtk_combo_box_get_active(GTK_COMBO_BOX(
87
 
                                                ui_lookup_widget(GTK_WIDGET(dialog), "filetype_combo")));
88
 
                gint encoding_idx;
89
136
                GtkTreeModel *encoding_model;
90
137
                GtkTreeIter encoding_iter;
91
138
                GeanyFiletype *ft = NULL;
92
139
                const gchar *charset = NULL;
 
140
                GtkWidget *expander = ui_lookup_widget(dialog, "more_options_expander");
 
141
                GtkWidget *filetype_combo = ui_lookup_widget(dialog, "filetype_combo");
 
142
                GtkWidget *encoding_combo = ui_lookup_widget(dialog, "encoding_combo");
93
143
                gboolean ro = (response == GEANY_RESPONSE_VIEW);        /* View clicked */
94
144
 
 
145
                filesel_state.open.more_options_visible = gtk_expander_get_expanded(GTK_EXPANDER(expander));
 
146
                filesel_state.open.filter_idx = file_chooser_get_filter_idx(GTK_FILE_CHOOSER(dialog));
 
147
                filesel_state.open.filetype_idx = gtk_combo_box_get_active(GTK_COMBO_BOX(filetype_combo));
 
148
 
95
149
                /* ignore detect from file item */
96
 
                if (filetype_idx > 0)
97
 
                        ft = g_slist_nth_data(filetypes_by_title, filetype_idx);
98
 
 
99
 
                encoding_model = gtk_combo_box_get_model(GTK_COMBO_BOX(
100
 
                        ui_lookup_widget(GTK_WIDGET(dialog), "encoding_combo")));
101
 
                gtk_combo_box_get_active_iter(GTK_COMBO_BOX(
102
 
                        ui_lookup_widget(GTK_WIDGET(dialog), "encoding_combo")), &encoding_iter);
103
 
                gtk_tree_model_get(encoding_model, &encoding_iter, 0, &encoding_idx, -1);
104
 
                if (encoding_idx >= 0 && encoding_idx < GEANY_ENCODINGS_MAX)
105
 
                        charset = encodings[encoding_idx].charset;
106
 
 
107
 
                filelist = gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(ui_widgets.open_filesel));
 
150
                if (filesel_state.open.filetype_idx > 0)
 
151
                        ft = g_slist_nth_data(filetypes_by_title, filesel_state.open.filetype_idx);
 
152
 
 
153
                encoding_model = gtk_combo_box_get_model(GTK_COMBO_BOX(encoding_combo));
 
154
                gtk_combo_box_get_active_iter(GTK_COMBO_BOX(encoding_combo), &encoding_iter);
 
155
                gtk_tree_model_get(encoding_model, &encoding_iter, 0, &filesel_state.open.encoding_idx, -1);
 
156
                if (filesel_state.open.encoding_idx >= 0 && filesel_state.open.encoding_idx < GEANY_ENCODINGS_MAX)
 
157
                        charset = encodings[filesel_state.open.encoding_idx].charset;
 
158
 
 
159
                filelist = gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(dialog));
108
160
                if (filelist != NULL)
109
161
                {
110
162
                        document_open_files(filelist, ro, ft, charset);
113
165
                g_slist_free(filelist);
114
166
        }
115
167
        if (app->project && NZV(app->project->base_path))
116
 
                gtk_file_chooser_remove_shortcut_folder(GTK_FILE_CHOOSER(ui_widgets.open_filesel),
 
168
                gtk_file_chooser_remove_shortcut_folder(GTK_FILE_CHOOSER(dialog),
117
169
                        app->project->base_path, NULL);
118
170
}
119
171
 
132
184
 
133
185
 
134
186
static void
135
 
on_file_open_check_hidden_toggled(GtkToggleButton *togglebutton, gpointer user_data)
 
187
on_file_open_check_hidden_toggled(GtkToggleButton *togglebutton, GtkWidget *dialog)
136
188
{
137
 
        gboolean is_on = gtk_toggle_button_get_active(togglebutton);
138
 
 
139
 
        gtk_file_chooser_set_show_hidden(GTK_FILE_CHOOSER(ui_widgets.open_filesel), is_on);
 
189
        filesel_state.open.show_hidden = gtk_toggle_button_get_active(togglebutton);
 
190
        gtk_file_chooser_set_show_hidden(GTK_FILE_CHOOSER(dialog), filesel_state.open.show_hidden);
140
191
}
141
192
 
142
193
 
170
221
                                iter_utf8, iter_middleeast;
171
222
        GtkTreeIter *iter_parent;
172
223
        gchar *encoding_string;
173
 
        guint i;
 
224
        gint i;
174
225
 
175
226
        store = gtk_tree_store_new(2, G_TYPE_INT, G_TYPE_STRING);
176
227
 
207
258
                encoding_string = encodings_to_string(&encodings[i]);
208
259
                gtk_tree_store_set(store, &iter_current, 0, i, 1, encoding_string, -1);
209
260
                g_free(encoding_string);
 
261
                /* restore the saved state */
 
262
                if (i == filesel_state.open.encoding_idx)
 
263
                        *iter_detect = iter_current;
210
264
        }
211
265
 
212
266
        gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(store), 1, GTK_SORT_ASCENDING);
228
282
}
229
283
 
230
284
 
231
 
static void create_open_file_dialog(void)
232
 
{
 
285
static GtkWidget *add_file_open_extra_widget(GtkWidget *dialog)
 
286
{
 
287
        GtkWidget *expander, *vbox, *table, *check_hidden;
 
288
        GtkWidget *filetype_ebox, *filetype_label, *filetype_combo;
 
289
        GtkWidget *encoding_ebox, *encoding_label, *encoding_combo;
 
290
 
 
291
        expander = gtk_expander_new_with_mnemonic(_("_More Options"));
 
292
        vbox = gtk_vbox_new(FALSE, 6);
 
293
        gtk_container_add(GTK_CONTAINER(expander), vbox);
 
294
 
 
295
        table = gtk_table_new(2, 4, FALSE);
 
296
 
 
297
        /* line 1 with checkbox and encoding combo */
 
298
        check_hidden = gtk_check_button_new_with_mnemonic(_("Show _hidden files"));
 
299
        gtk_widget_show(check_hidden);
 
300
        gtk_table_attach(GTK_TABLE(table), check_hidden, 0, 1, 0, 1,
 
301
                                        (GtkAttachOptions) (GTK_FILL | GTK_EXPAND),
 
302
                                        (GtkAttachOptions) (0), 0, 5);
 
303
 
 
304
        /* spacing */
 
305
        gtk_table_attach(GTK_TABLE(table), gtk_label_new(""), 1, 2, 0, 1,
 
306
                                        (GtkAttachOptions) (GTK_FILL),
 
307
                                        (GtkAttachOptions) (0), 5, 5);
 
308
 
 
309
        encoding_label = gtk_label_new(_("Set encoding:"));
 
310
        gtk_misc_set_alignment(GTK_MISC(encoding_label), 1, 0);
 
311
        gtk_table_attach(GTK_TABLE(table), encoding_label, 2, 3, 0, 1,
 
312
                                        (GtkAttachOptions) (GTK_FILL),
 
313
                                        (GtkAttachOptions) (0), 4, 5);
 
314
        /* the ebox is for the tooltip, because gtk_combo_box can't show tooltips */
 
315
        encoding_ebox = gtk_event_box_new();
 
316
        encoding_combo = gtk_combo_box_new();
 
317
        gtk_widget_set_tooltip_text(encoding_ebox,
 
318
                _("Explicitly defines an encoding for the file, if it would not be detected. This is useful when you know that the encoding of a file cannot be detected correctly by Geany.\nNote if you choose multiple files, they will all be opened with the chosen encoding."));
 
319
        gtk_container_add(GTK_CONTAINER(encoding_ebox), encoding_combo);
 
320
        gtk_table_attach(GTK_TABLE(table), encoding_ebox, 3, 4, 0, 1,
 
321
                                        (GtkAttachOptions) (GTK_FILL),
 
322
                                        (GtkAttachOptions) (0), 0, 5);
 
323
 
 
324
        /* line 2 with filetype combo */
 
325
        filetype_label = gtk_label_new(_("Set filetype:"));
 
326
        gtk_misc_set_alignment(GTK_MISC(filetype_label), 1, 0);
 
327
        gtk_table_attach(GTK_TABLE(table), filetype_label, 2, 3, 1, 2,
 
328
                                        (GtkAttachOptions) (GTK_FILL),
 
329
                                        (GtkAttachOptions) (0), 4, 5);
 
330
        /* the ebox is for the tooltip, because gtk_combo_box can't show tooltips */
 
331
        filetype_ebox = gtk_event_box_new();
 
332
        filetype_combo = gtk_combo_box_new_text();
 
333
        gtk_combo_box_set_wrap_width(GTK_COMBO_BOX(filetype_combo), 2);
 
334
        gtk_widget_set_tooltip_text(filetype_ebox,
 
335
                _("Explicitly defines a filetype for the file, if it would not be detected by filename extension.\nNote if you choose multiple files, they will all be opened with the chosen filetype."));
 
336
        gtk_container_add(GTK_CONTAINER(filetype_ebox), filetype_combo);
 
337
        gtk_table_attach(GTK_TABLE(table), filetype_ebox, 3, 4, 1, 2,
 
338
                                        (GtkAttachOptions) (GTK_FILL),
 
339
                                        (GtkAttachOptions) (0), 0, 5);
 
340
 
 
341
        gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0);
 
342
        gtk_widget_show_all(vbox);
 
343
 
 
344
        g_signal_connect(check_hidden, "toggled", G_CALLBACK(on_file_open_check_hidden_toggled), dialog);
 
345
 
 
346
        ui_hookup_widget(dialog, expander, "more_options_expander");
 
347
        ui_hookup_widget(dialog, check_hidden, "check_hidden");
 
348
        ui_hookup_widget(dialog, filetype_combo, "filetype_combo");
 
349
        ui_hookup_widget(dialog, encoding_combo, "encoding_combo");
 
350
 
 
351
        return expander;
 
352
}
 
353
 
 
354
 
 
355
static GtkWidget *create_open_file_dialog(void)
 
356
{
 
357
        GtkWidget *dialog;
233
358
        GtkWidget *filetype_combo, *encoding_combo;
234
359
        GtkWidget *viewbtn;
235
360
        GtkCellRenderer *encoding_renderer;
236
361
        GtkTreeIter encoding_iter;
237
362
        GSList *node;
238
363
 
239
 
        ui_widgets.open_filesel = gtk_file_chooser_dialog_new(_("Open File"), GTK_WINDOW(main_widgets.window),
 
364
        dialog = gtk_file_chooser_dialog_new(_("Open File"), GTK_WINDOW(main_widgets.window),
240
365
                        GTK_FILE_CHOOSER_ACTION_OPEN, NULL, NULL);
241
 
        gtk_widget_set_name(ui_widgets.open_filesel, "GeanyDialog");
 
366
        gtk_widget_set_name(dialog, "GeanyDialog");
242
367
 
243
 
        viewbtn = gtk_dialog_add_button(GTK_DIALOG(ui_widgets.open_filesel), _("_View"),
244
 
                                GEANY_RESPONSE_VIEW);
245
 
        ui_widget_set_tooltip_text(viewbtn,
 
368
        viewbtn = gtk_dialog_add_button(GTK_DIALOG(dialog), _("_View"), GEANY_RESPONSE_VIEW);
 
369
        gtk_widget_set_tooltip_text(viewbtn,
246
370
                _("Opens the file in read-only mode. If you choose more than one file to open, all files will be opened read-only."));
247
371
 
248
 
        gtk_dialog_add_buttons(GTK_DIALOG(ui_widgets.open_filesel),
 
372
        gtk_dialog_add_buttons(GTK_DIALOG(dialog),
249
373
                GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
250
374
                GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL);
251
 
        gtk_dialog_set_default_response(GTK_DIALOG(ui_widgets.open_filesel), GTK_RESPONSE_ACCEPT);
 
375
        gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT);
252
376
 
253
 
        gtk_widget_set_size_request(ui_widgets.open_filesel, -1, 460);
254
 
        gtk_window_set_modal(GTK_WINDOW(ui_widgets.open_filesel), TRUE);
255
 
        gtk_window_set_destroy_with_parent(GTK_WINDOW(ui_widgets.open_filesel), TRUE);
256
 
        gtk_window_set_skip_taskbar_hint(GTK_WINDOW(ui_widgets.open_filesel), FALSE);
257
 
        gtk_window_set_type_hint(GTK_WINDOW(ui_widgets.open_filesel), GDK_WINDOW_TYPE_HINT_DIALOG);
258
 
        gtk_window_set_transient_for(GTK_WINDOW(ui_widgets.open_filesel), GTK_WINDOW(main_widgets.window));
259
 
        gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(ui_widgets.open_filesel), TRUE);
 
377
        gtk_widget_set_size_request(dialog, -1, 460);
 
378
        gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
 
379
        gtk_window_set_destroy_with_parent(GTK_WINDOW(dialog), TRUE);
 
380
        gtk_window_set_skip_taskbar_hint(GTK_WINDOW(dialog), FALSE);
 
381
        gtk_window_set_type_hint(GTK_WINDOW(dialog), GDK_WINDOW_TYPE_HINT_DIALOG);
 
382
        gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(main_widgets.window));
 
383
        gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog), TRUE);
260
384
        if (gtk_check_version(2, 14, 0) == NULL)
261
 
                gtk_file_chooser_set_local_only(GTK_FILE_CHOOSER(ui_widgets.open_filesel), FALSE);
 
385
                gtk_file_chooser_set_local_only(GTK_FILE_CHOOSER(dialog), FALSE);
262
386
 
263
387
        /* add checkboxes and filename entry */
264
 
        gtk_file_chooser_set_extra_widget(GTK_FILE_CHOOSER(ui_widgets.open_filesel),
265
 
                add_file_open_extra_widget());
266
 
        filetype_combo = ui_lookup_widget(ui_widgets.open_filesel, "filetype_combo");
 
388
        gtk_file_chooser_set_extra_widget(GTK_FILE_CHOOSER(dialog), add_file_open_extra_widget(dialog));
 
389
        filetype_combo = ui_lookup_widget(dialog, "filetype_combo");
267
390
 
268
391
        gtk_combo_box_append_text(GTK_COMBO_BOX(filetype_combo), _("Detect by file extension"));
269
392
        /* add FileFilters(start with "All Files") */
270
 
        gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(ui_widgets.open_filesel),
 
393
        gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog),
271
394
                                filetypes_create_file_filter(filetypes[GEANY_FILETYPES_NONE]));
272
395
        /* now create meta filter "All Source" */
273
 
        gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(ui_widgets.open_filesel),
 
396
        gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog),
274
397
                                filetypes_create_file_filter_all_source());
275
398
        foreach_slist(node, filetypes_by_title)
276
399
        {
279
402
                if (G_UNLIKELY(ft->id == GEANY_FILETYPES_NONE))
280
403
                        continue;
281
404
                gtk_combo_box_append_text(GTK_COMBO_BOX(filetype_combo), ft->title);
282
 
                gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(ui_widgets.open_filesel),
283
 
                                filetypes_create_file_filter(ft));
 
405
                gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), filetypes_create_file_filter(ft));
284
406
        }
285
407
        gtk_combo_box_set_active(GTK_COMBO_BOX(filetype_combo), 0);
286
408
 
287
409
        /* fill encoding combo box */
288
 
        encoding_combo = ui_lookup_widget(ui_widgets.open_filesel, "encoding_combo");
 
410
        encoding_combo = ui_lookup_widget(dialog, "encoding_combo");
289
411
        gtk_combo_box_set_model(GTK_COMBO_BOX(encoding_combo), GTK_TREE_MODEL(
290
 
                create_encoding_combo_store(&encoding_iter)));
 
412
                        create_encoding_combo_store(&encoding_iter)));
291
413
        gtk_combo_box_set_active_iter(GTK_COMBO_BOX(encoding_combo), &encoding_iter);
292
414
        encoding_renderer = gtk_cell_renderer_text_new();
293
415
        gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(encoding_combo), encoding_renderer, TRUE);
294
416
        gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(encoding_combo), encoding_renderer, "text", 1);
295
417
        gtk_cell_layout_set_cell_data_func(GTK_CELL_LAYOUT(encoding_combo), encoding_renderer,
296
 
                encoding_combo_cell_data_func, NULL, NULL);
297
 
 
298
 
        g_signal_connect(ui_widgets.open_filesel, "notify::show-hidden",
299
 
                                G_CALLBACK(on_file_open_notify), NULL);
300
 
        g_signal_connect(ui_widgets.open_filesel, "delete-event",
301
 
                                G_CALLBACK(gtk_widget_hide_on_delete), NULL);
302
 
        g_signal_connect(ui_widgets.open_filesel, "response",
303
 
                                G_CALLBACK(on_file_open_dialog_response), NULL);
 
418
                        encoding_combo_cell_data_func, NULL, NULL);
 
419
 
 
420
        g_signal_connect(dialog, "notify::show-hidden", G_CALLBACK(on_file_open_notify), NULL);
 
421
 
 
422
        return dialog;
 
423
}
 
424
 
 
425
 
 
426
static void open_file_dialog_apply_settings(GtkWidget *dialog)
 
427
{
 
428
        static gboolean initialized = FALSE;
 
429
        GtkWidget *check_hidden = ui_lookup_widget(dialog, "check_hidden");
 
430
        GtkWidget *filetype_combo = ui_lookup_widget(dialog, "filetype_combo");
 
431
        GtkWidget *expander = ui_lookup_widget(dialog, "more_options_expander");
 
432
 
 
433
        /* we can't know the initial position of combo boxes, so retreive it the first time */
 
434
        if (! initialized)
 
435
        {
 
436
                filesel_state.open.filter_idx = file_chooser_get_filter_idx(GTK_FILE_CHOOSER(dialog));
 
437
                filesel_state.open.filetype_idx = gtk_combo_box_get_active(GTK_COMBO_BOX(filetype_combo));
 
438
 
 
439
                initialized = TRUE;
 
440
        }
 
441
        else
 
442
        {
 
443
                file_chooser_set_filter_idx(GTK_FILE_CHOOSER(dialog), filesel_state.open.filter_idx);
 
444
                gtk_combo_box_set_active(GTK_COMBO_BOX(filetype_combo), filesel_state.open.filetype_idx);
 
445
        }
 
446
        gtk_expander_set_expanded(GTK_EXPANDER(expander), filesel_state.open.more_options_visible);
 
447
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_hidden), filesel_state.open.show_hidden);
 
448
        /* encoding combo is restored at creating time, see create_encoding_combo_store() */
304
449
}
305
450
 
306
451
 
307
452
/* This shows the file selection dialog to open a file. */
308
 
void dialogs_show_open_file()
 
453
void dialogs_show_open_file(void)
309
454
{
310
455
        gchar *initdir;
311
456
 
325
470
        else
326
471
#endif
327
472
        {
328
 
                /* We use the same file selection widget each time, so first of all we create it
329
 
                 * if it hasn't already been created. */
330
 
                if (ui_widgets.open_filesel == NULL)
331
 
                        create_open_file_dialog();
332
 
 
333
 
                if (initdir != NULL)
334
 
                {
335
 
                        if (g_path_is_absolute(initdir))
336
 
                                gtk_file_chooser_set_current_folder(
337
 
                                        GTK_FILE_CHOOSER(ui_widgets.open_filesel), initdir);
338
 
                }
 
473
                GtkWidget *dialog = create_open_file_dialog();
 
474
                gint response;
 
475
 
 
476
                open_file_dialog_apply_settings(dialog);
 
477
 
 
478
                if (initdir != NULL && g_path_is_absolute(initdir))
 
479
                                gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), initdir);
339
480
 
340
481
                if (app->project && NZV(app->project->base_path))
341
 
                        gtk_file_chooser_add_shortcut_folder(GTK_FILE_CHOOSER(ui_widgets.open_filesel),
342
 
                                app->project->base_path, NULL);
 
482
                        gtk_file_chooser_add_shortcut_folder(GTK_FILE_CHOOSER(dialog),
 
483
                                        app->project->base_path, NULL);
343
484
 
344
 
                gtk_file_chooser_unselect_all(GTK_FILE_CHOOSER(ui_widgets.open_filesel));
345
 
                gtk_window_present(GTK_WINDOW(ui_widgets.open_filesel));
 
485
                response = gtk_dialog_run(GTK_DIALOG(dialog));
 
486
                open_file_dialog_handle_response(dialog, response);
 
487
                gtk_widget_destroy(dialog);
346
488
        }
347
489
        g_free(initdir);
348
490
}
349
491
 
350
492
 
351
 
static GtkWidget *add_file_open_extra_widget()
352
 
{
353
 
        GtkWidget *expander, *vbox, *table, *check_hidden;
354
 
        GtkWidget *filetype_ebox, *filetype_label, *filetype_combo;
355
 
        GtkWidget *encoding_ebox, *encoding_label, *encoding_combo;
356
 
 
357
 
        expander = gtk_expander_new_with_mnemonic(_("_More Options"));
358
 
        vbox = gtk_vbox_new(FALSE, 6);
359
 
        gtk_container_add(GTK_CONTAINER(expander), vbox);
360
 
 
361
 
        table = gtk_table_new(2, 4, FALSE);
362
 
 
363
 
        /* line 1 with checkbox and encoding combo */
364
 
        check_hidden = gtk_check_button_new_with_mnemonic(_("Show _hidden files"));
365
 
        gtk_widget_show(check_hidden);
366
 
        gtk_table_attach(GTK_TABLE(table), check_hidden, 0, 1, 0, 1,
367
 
                                        (GtkAttachOptions) (GTK_FILL | GTK_EXPAND),
368
 
                                        (GtkAttachOptions) (0), 0, 5);
369
 
 
370
 
        /* spacing */
371
 
        gtk_table_attach(GTK_TABLE(table), gtk_label_new(""), 1, 2, 0, 1,
372
 
                                        (GtkAttachOptions) (GTK_FILL),
373
 
                                        (GtkAttachOptions) (0), 5, 5);
374
 
 
375
 
        encoding_label = gtk_label_new(_("Set encoding:"));
376
 
        gtk_misc_set_alignment(GTK_MISC(encoding_label), 1, 0);
377
 
        gtk_table_attach(GTK_TABLE(table), encoding_label, 2, 3, 0, 1,
378
 
                                        (GtkAttachOptions) (GTK_FILL),
379
 
                                        (GtkAttachOptions) (0), 4, 5);
380
 
        /* the ebox is for the tooltip, because gtk_combo_box can't show tooltips */
381
 
        encoding_ebox = gtk_event_box_new();
382
 
        encoding_combo = gtk_combo_box_new();
383
 
        ui_widget_set_tooltip_text(encoding_ebox,
384
 
                _("Explicitly defines an encoding for the file, if it would not be detected. This is useful when you know that the encoding of a file cannot be detected correctly by Geany.\nNote if you choose multiple files, they will all be opened with the chosen encoding."));
385
 
        gtk_container_add(GTK_CONTAINER(encoding_ebox), encoding_combo);
386
 
        gtk_table_attach(GTK_TABLE(table), encoding_ebox, 3, 4, 0, 1,
387
 
                                        (GtkAttachOptions) (GTK_FILL),
388
 
                                        (GtkAttachOptions) (0), 0, 5);
389
 
 
390
 
        /* line 2 with filetype combo */
391
 
        filetype_label = gtk_label_new(_("Set filetype:"));
392
 
        gtk_misc_set_alignment(GTK_MISC(filetype_label), 1, 0);
393
 
        gtk_table_attach(GTK_TABLE(table), filetype_label, 2, 3, 1, 2,
394
 
                                        (GtkAttachOptions) (GTK_FILL),
395
 
                                        (GtkAttachOptions) (0), 4, 5);
396
 
        /* the ebox is for the tooltip, because gtk_combo_box can't show tooltips */
397
 
        filetype_ebox = gtk_event_box_new();
398
 
        filetype_combo = gtk_combo_box_new_text();
399
 
        gtk_combo_box_set_wrap_width(GTK_COMBO_BOX(filetype_combo), 2);
400
 
        ui_widget_set_tooltip_text(filetype_ebox,
401
 
                _("Explicitly defines a filetype for the file, if it would not be detected by filename extension.\nNote if you choose multiple files, they will all be opened with the chosen filetype."));
402
 
        gtk_container_add(GTK_CONTAINER(filetype_ebox), filetype_combo);
403
 
        gtk_table_attach(GTK_TABLE(table), filetype_ebox, 3, 4, 1, 2,
404
 
                                        (GtkAttachOptions) (GTK_FILL),
405
 
                                        (GtkAttachOptions) (0), 0, 5);
406
 
 
407
 
        gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0);
408
 
        gtk_widget_show_all(vbox);
409
 
 
410
 
        g_signal_connect(check_hidden, "toggled",
411
 
                                G_CALLBACK(on_file_open_check_hidden_toggled), NULL);
412
 
 
413
 
        ui_hookup_widget(ui_widgets.open_filesel, check_hidden, "check_hidden");
414
 
        ui_hookup_widget(ui_widgets.open_filesel, filetype_combo, "filetype_combo");
415
 
        ui_hookup_widget(ui_widgets.open_filesel, encoding_combo, "encoding_combo");
416
 
 
417
 
        return expander;
418
 
}
419
 
 
420
 
 
421
493
static void on_save_as_new_tab_toggled(GtkToggleButton *togglebutton, gpointer user_data)
422
494
{
423
 
        gtk_widget_set_sensitive(GTK_WIDGET(user_data),
424
 
                ! gtk_toggle_button_get_active(togglebutton));
 
495
        gtk_widget_set_sensitive(GTK_WIDGET(user_data), ! gtk_toggle_button_get_active(togglebutton));
425
496
}
426
497
 
427
498
 
457
528
}
458
529
 
459
530
 
460
 
static void
461
 
on_file_save_dialog_response           (GtkDialog *dialog,
462
 
                                        gint response,
463
 
                                        gpointer user_data)
 
531
static gboolean save_as_dialog_handle_response(GtkWidget *dialog, gint response)
464
532
{
465
533
        gboolean rename_file = FALSE;
466
534
        gboolean success = FALSE;
467
 
        gchar *new_filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(ui_widgets.save_filesel));
 
535
        gchar *new_filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
468
536
 
469
537
        switch (response)
470
538
        {
471
539
                case GEANY_RESPONSE_RENAME:
472
540
                        /* rename doesn't check for empty filename or overwriting */
473
 
                        if (! NZV(new_filename))
 
541
                        if (G_UNLIKELY(! NZV(new_filename)))
474
542
                        {
475
543
                                utils_beep();
476
544
                                break;
485
553
                case GTK_RESPONSE_ACCEPT:
486
554
                {
487
555
                        gboolean open_new_tab = gtk_toggle_button_get_active(
488
 
                                        GTK_TOGGLE_BUTTON(ui_lookup_widget(ui_widgets.save_filesel, "check_open_new_tab")));
 
556
                                        GTK_TOGGLE_BUTTON(ui_lookup_widget(dialog, "check_open_new_tab")));
489
557
                        gchar *utf8_filename;
490
558
 
491
559
                        utf8_filename = utils_get_utf8_from_locale(new_filename);
492
560
                        success = handle_save_as(utf8_filename, open_new_tab, rename_file);
493
561
 
 
562
                        if (success)
 
563
                                filesel_state.save.open_in_new_tab = open_new_tab;
 
564
 
494
565
                        g_free(utf8_filename);
495
566
                        break;
496
567
                }
 
568
                case GTK_RESPONSE_DELETE_EVENT:
497
569
                case GTK_RESPONSE_CANCEL:
498
570
                        success = TRUE;
499
571
                        break;
500
572
        }
501
573
        g_free(new_filename);
502
574
 
503
 
        if (success)
504
 
                gtk_widget_hide(ui_widgets.save_filesel);
 
575
        return success;
505
576
}
506
577
 
507
578
 
508
 
static void create_save_file_dialog(void)
 
579
static GtkWidget *create_save_file_dialog(void)
509
580
{
510
 
        GtkWidget *vbox, *check_open_new_tab, *rename_btn;
 
581
        GtkWidget *dialog, *vbox, *check_open_new_tab, *rename_btn;
511
582
        const gchar *initdir;
512
583
 
513
 
        ui_widgets.save_filesel = gtk_file_chooser_dialog_new(_("Save File"), GTK_WINDOW(main_widgets.window),
 
584
        dialog = gtk_file_chooser_dialog_new(_("Save File"), GTK_WINDOW(main_widgets.window),
514
585
                                GTK_FILE_CHOOSER_ACTION_SAVE, NULL, NULL);
515
 
        gtk_window_set_modal(GTK_WINDOW(ui_widgets.save_filesel), TRUE);
516
 
        gtk_window_set_destroy_with_parent(GTK_WINDOW(ui_widgets.save_filesel), TRUE);
517
 
        gtk_window_set_skip_taskbar_hint(GTK_WINDOW(ui_widgets.save_filesel), FALSE);
518
 
        gtk_window_set_type_hint(GTK_WINDOW(ui_widgets.save_filesel), GDK_WINDOW_TYPE_HINT_DIALOG);
519
 
        gtk_widget_set_name(ui_widgets.save_filesel, "GeanyDialog");
520
 
 
521
 
        rename_btn = gtk_dialog_add_button(GTK_DIALOG(ui_widgets.save_filesel), _("R_ename"),
522
 
                                        GEANY_RESPONSE_RENAME);
523
 
        ui_widget_set_tooltip_text(rename_btn, _("Save the file and rename it"));
524
 
 
525
 
        gtk_dialog_add_buttons(GTK_DIALOG(ui_widgets.save_filesel),
 
586
        gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
 
587
        gtk_window_set_destroy_with_parent(GTK_WINDOW(dialog), TRUE);
 
588
        gtk_window_set_skip_taskbar_hint(GTK_WINDOW(dialog), FALSE);
 
589
        gtk_window_set_type_hint(GTK_WINDOW(dialog), GDK_WINDOW_TYPE_HINT_DIALOG);
 
590
        gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(main_widgets.window));
 
591
        gtk_widget_set_name(dialog, "GeanyDialog");
 
592
 
 
593
        rename_btn = gtk_dialog_add_button(GTK_DIALOG(dialog), _("R_ename"), GEANY_RESPONSE_RENAME);
 
594
        gtk_widget_set_tooltip_text(rename_btn, _("Save the file and rename it"));
 
595
 
 
596
        gtk_dialog_add_buttons(GTK_DIALOG(dialog),
526
597
                GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
527
598
                GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, NULL);
528
 
        gtk_dialog_set_default_response(GTK_DIALOG(ui_widgets.save_filesel), GTK_RESPONSE_ACCEPT);
 
599
        gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT);
529
600
 
530
601
        vbox = gtk_vbox_new(FALSE, 0);
531
602
        check_open_new_tab = gtk_check_button_new_with_mnemonic(_("_Open file in a new tab"));
532
 
        ui_widget_set_tooltip_text(check_open_new_tab,
 
603
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_open_new_tab), filesel_state.save.open_in_new_tab);
 
604
        gtk_widget_set_tooltip_text(check_open_new_tab,
533
605
                _("Keep the current unsaved document open"
534
606
                " and open the newly saved file in a new tab"));
535
607
        gtk_box_pack_start(GTK_BOX(vbox), check_open_new_tab, FALSE, FALSE, 0);
536
608
        gtk_widget_show_all(vbox);
537
 
        gtk_file_chooser_set_extra_widget(GTK_FILE_CHOOSER(ui_widgets.save_filesel), vbox);
538
 
        gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(ui_widgets.save_filesel), TRUE);
 
609
        gtk_file_chooser_set_extra_widget(GTK_FILE_CHOOSER(dialog), vbox);
 
610
        gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(dialog), TRUE);
539
611
        if (gtk_check_version(2, 14, 0) == NULL)
540
 
                gtk_file_chooser_set_local_only(GTK_FILE_CHOOSER(ui_widgets.save_filesel), FALSE);
 
612
                gtk_file_chooser_set_local_only(GTK_FILE_CHOOSER(dialog), FALSE);
541
613
 
542
614
        /* set the folder by default to the project base dir or the global pref for opening files */
543
615
        initdir = utils_get_default_dir_utf8();
544
616
        if (initdir)
545
617
        {
546
618
                gchar *linitdir = utils_get_locale_from_utf8(initdir);
547
 
                gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(ui_widgets.save_filesel), linitdir);
 
619
                gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), linitdir);
548
620
                g_free(linitdir);
549
621
        }
550
622
 
551
623
        g_signal_connect(check_open_new_tab, "toggled",
552
624
                                G_CALLBACK(on_save_as_new_tab_toggled), rename_btn);
553
625
 
554
 
        ui_hookup_widget(ui_widgets.save_filesel, check_open_new_tab, "check_open_new_tab");
555
 
 
556
 
        g_signal_connect(ui_widgets.save_filesel, "delete-event",
557
 
                G_CALLBACK(gtk_widget_hide_on_delete), NULL);
558
 
        g_signal_connect(ui_widgets.save_filesel, "response",
559
 
                G_CALLBACK(on_file_save_dialog_response), NULL);
560
 
 
561
 
        gtk_window_set_transient_for(GTK_WINDOW(ui_widgets.save_filesel), GTK_WINDOW(main_widgets.window));
 
626
        ui_hookup_widget(dialog, check_open_new_tab, "check_open_new_tab");
 
627
 
 
628
        return dialog;
562
629
}
563
630
 
564
631
 
565
 
static gboolean gtk_show_save_as(void)
 
632
static gboolean show_save_as_gtk(void)
566
633
{
 
634
        GtkWidget *dialog;
567
635
        GeanyDocument *doc = document_get_current();
568
636
        gint resp;
569
637
 
570
638
        g_return_val_if_fail(doc != NULL, FALSE);
571
639
 
572
 
        if (G_UNLIKELY(ui_widgets.save_filesel == NULL))
573
 
                create_save_file_dialog();
574
 
 
575
 
        gtk_file_chooser_unselect_all(GTK_FILE_CHOOSER(ui_widgets.save_filesel));
 
640
        dialog = create_save_file_dialog();
576
641
 
577
642
        if (doc->file_name != NULL)
578
643
        {
582
647
                        gchar *locale_basename = g_path_get_basename(locale_filename);
583
648
                        gchar *locale_dirname = g_path_get_dirname(locale_filename);
584
649
 
585
 
                        gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(ui_widgets.save_filesel),
586
 
                                locale_dirname);
587
 
                        gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(ui_widgets.save_filesel),
588
 
                                locale_basename);
 
650
                        gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), locale_dirname);
 
651
                        gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), locale_basename);
589
652
 
590
653
                        g_free(locale_filename);
591
654
                        g_free(locale_basename);
592
655
                        g_free(locale_dirname);
593
656
                }
594
657
                else
595
 
                        gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(ui_widgets.save_filesel),
596
 
                                doc->file_name);
 
658
                        gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), doc->file_name);
597
659
        }
598
660
        else
599
661
        {
605
667
                else
606
668
                        fname = g_strdup(GEANY_STRING_UNTITLED);
607
669
 
608
 
                gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(ui_widgets.save_filesel), fname);
 
670
                gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), fname);
609
671
 
610
672
                g_free(fname);
611
673
        }
612
674
 
613
675
        if (app->project && NZV(app->project->base_path))
614
 
                gtk_file_chooser_add_shortcut_folder(GTK_FILE_CHOOSER(ui_widgets.save_filesel),
 
676
                gtk_file_chooser_add_shortcut_folder(GTK_FILE_CHOOSER(dialog),
615
677
                        app->project->base_path, NULL);
616
678
 
617
679
        /* Run the dialog synchronously, pausing this function call */
618
 
        resp = gtk_dialog_run(GTK_DIALOG(ui_widgets.save_filesel));
 
680
        do
 
681
        {
 
682
                resp = gtk_dialog_run(GTK_DIALOG(dialog));
 
683
        }
 
684
        while (! save_as_dialog_handle_response(dialog, resp));
619
685
 
620
686
        if (app->project && NZV(app->project->base_path))
621
 
                gtk_file_chooser_remove_shortcut_folder(GTK_FILE_CHOOSER(ui_widgets.save_filesel),
 
687
                gtk_file_chooser_remove_shortcut_folder(GTK_FILE_CHOOSER(dialog),
622
688
                        app->project->base_path, NULL);
623
689
 
 
690
        gtk_widget_destroy(dialog);
 
691
 
624
692
        return (resp == GTK_RESPONSE_ACCEPT);
625
693
}
626
694
 
645
713
        }
646
714
        else
647
715
#endif
648
 
        result = gtk_show_save_as();
 
716
        result = show_save_as_gtk();
649
717
        return result;
650
718
}
651
719
 
711
779
        win32_message_dialog(GTK_WIDGET(parent), type, string);
712
780
#else
713
781
        dialog = gtk_message_dialog_new(parent, GTK_DIALOG_DESTROY_WITH_PARENT,
714
 
                                  type, GTK_BUTTONS_OK, "%s", string);
 
782
                        type, GTK_BUTTONS_OK, "%s", string);
715
783
        show_msgbox_dialog(dialog, type, parent);
716
784
#endif
717
785
        g_free(string);
729
797
#else
730
798
        GtkWidget *dialog;
731
799
        dialog = gtk_message_dialog_new(parent, GTK_DIALOG_DESTROY_WITH_PARENT,
732
 
                                  type, GTK_BUTTONS_OK, "%s", text);
 
800
                        type, GTK_BUTTONS_OK, "%s", text);
733
801
        gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog), "%s", secondary);
734
802
        show_msgbox_dialog(dialog, type, parent);
735
803
#endif
743
811
        gint ret;
744
812
 
745
813
        dialog = gtk_message_dialog_new(GTK_WINDOW(main_widgets.window), GTK_DIALOG_DESTROY_WITH_PARENT,
746
 
                                  GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE, "%s", msg);
 
814
                        GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE, "%s", msg);
747
815
        gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog), "%s", msg2);
748
816
        gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
749
817
 
815
883
 
816
884
#ifndef G_OS_WIN32
817
885
static void
818
 
on_font_apply_button_clicked           (GtkButton       *button,
819
 
                                        gpointer         user_data)
 
886
on_font_apply_button_clicked(GtkButton *button, gpointer user_data)
820
887
{
821
888
        gchar *fontname;
822
889
 
828
895
 
829
896
 
830
897
static void
831
 
on_font_ok_button_clicked              (GtkButton       *button,
832
 
                                        gpointer         user_data)
 
898
on_font_ok_button_clicked(GtkButton *button, gpointer user_data)
833
899
{
834
900
        /* We do the same thing as apply, but we close the dialog after. */
835
901
        on_font_apply_button_clicked(button, NULL);
838
904
 
839
905
 
840
906
static void
841
 
on_font_cancel_button_clicked         (GtkButton       *button,
842
 
                                        gpointer         user_data)
 
907
on_font_cancel_button_clicked(GtkButton *button, gpointer user_data)
843
908
{
844
909
        gtk_widget_hide(ui_widgets.open_fontsel);
845
910
}
906
971
 
907
972
 
908
973
static void
909
 
on_input_dialog_response(GtkDialog *dialog,
910
 
                         gint response,
911
 
                         GtkWidget *entry)
 
974
on_input_dialog_response(GtkDialog *dialog, gint response, GtkWidget *entry)
912
975
{
913
976
        gboolean persistent = (gboolean) GPOINTER_TO_INT(g_object_get_data(G_OBJECT(dialog), "has_combo"));
914
977
 
1126
1189
        GtkWidget *dialog, *label, *table, *hbox, *image, *perm_table, *check, *vbox;
1127
1190
        gchar *file_size, *title, *base_name, *time_changed, *time_modified, *time_accessed, *enctext;
1128
1191
        gchar *short_name;
 
1192
        GdkPixbuf *pixbuf;
1129
1193
#ifdef HAVE_SYS_TYPES_H
1130
1194
        struct stat st;
1131
1195
        off_t filesize;
1205
1269
        label = ui_label_new_bold(base_name);
1206
1270
        gtk_label_set_selectable(GTK_LABEL(label), TRUE);
1207
1271
        gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
1208
 
        image = gtk_image_new_from_stock("gtk-file", GTK_ICON_SIZE_BUTTON);
 
1272
        pixbuf = ui_get_mime_icon(doc->file_type->mime_type, GTK_ICON_SIZE_BUTTON);
 
1273
        image = gtk_image_new_from_pixbuf(pixbuf);
 
1274
        g_object_unref(pixbuf);
1209
1275
        gtk_misc_set_alignment(GTK_MISC(image), 1.0, 0.5);
1210
1276
        hbox = gtk_hbox_new(FALSE, 6);
1211
1277
        gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
1522
1588
 
1523
1589
#ifdef G_OS_WIN32
1524
1590
        /* our native dialog code doesn't support custom buttons */
1525
 
        if (btn_3 == GTK_STOCK_YES && btn_2 == GTK_STOCK_NO && btn_1 == NULL)
 
1591
        if (btn_3 == (gchar*)GTK_STOCK_YES && btn_2 == (gchar*)GTK_STOCK_NO && btn_1 == NULL)
1526
1592
        {
1527
1593
                gchar *string = (extra_text == NULL) ? g_strdup(question_text) :
1528
1594
                        g_strconcat(question_text, "\n\n", extra_text, NULL);