Change configuration system from Autotools to Meson
[geeqie.git] / src / ui_utildlg.c
1 /*
2  * Copyright (C) 2004 John Ellis
3  * Copyright (C) 2008 - 2016 The Geeqie Team
4  *
5  * Author: John Ellis
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  */
21
22 #include <config.h>
23 #include "intl.h"
24
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <string.h>
28 #include <sys/types.h>
29 #include <gtk/gtk.h>
30
31 #include <gdk/gdkkeysyms.h> /* for keyboard values */
32
33 #include "main.h"
34 #include "ui_utildlg.h"
35
36 #include "filedata.h"
37 #include "rcfile.h"
38 #include "ui_fileops.h"
39 #include "ui_misc.h"
40 #include "ui_pathsel.h"
41 #include "ui_tabcomp.h"
42 #include "window.h"
43
44 /*
45  *-----------------------------------------------------------------------------
46  * generic dialog
47  *-----------------------------------------------------------------------------
48  */
49
50 typedef struct _DialogWindow DialogWindow;
51 struct _DialogWindow
52 {
53         gint x;
54         gint y;
55         gint w;
56         gint h;
57         gchar *title;
58         gchar *role;
59 };
60
61 static GList *dialog_windows = NULL;
62
63 static void generic_dialog_save_window(const gchar *title, const gchar *role, gint x, gint y, gint h, gint w)
64 {
65         GList *work;
66
67         work = g_list_first(dialog_windows);
68         while (work)
69                 {
70                 DialogWindow *dw = work->data;
71                 if (g_strcmp0(dw->title ,title) == 0 && g_strcmp0(dw->role, role) == 0)
72                         {
73                         dw->x = x;
74                         dw->y = y;
75                         dw->w = w;
76                         dw->h = h;
77                         return;
78                         }
79                 work = work->next;
80                 }
81
82         DialogWindow *dw = g_new0(DialogWindow, 1);
83         dw->title = g_strdup(title);
84         dw->role = g_strdup(role);
85         dw->x = x;
86         dw->y = y;
87         dw->w = w;
88         dw->h = h;
89
90         dialog_windows = g_list_append(dialog_windows, dw);
91 }
92
93 static gboolean generic_dialog_find_window(const gchar *title, const gchar *role, gint *x, gint *y, gint *h, gint *w)
94 {
95         GList *work;
96
97         work = g_list_first(dialog_windows);
98         while (work)
99                 {
100                 DialogWindow *dw = work->data;
101
102                 if (g_strcmp0(dw->title,title) == 0 && g_strcmp0(dw->role, role) == 0)
103                         {
104                         *x = dw->x;
105                         *y = dw->y;
106                         *w = dw->w;
107                         *h = dw->h;
108                         return TRUE;
109                         }
110                 work = work->next;
111                 }
112         return FALSE;
113 }
114
115 void generic_dialog_close(GenericDialog *gd)
116 {
117         gchar *ident_string;
118         gchar *full_title;
119         gchar *actual_title;
120         gint x, y, h, w;
121
122         gdk_window_get_root_origin(gtk_widget_get_window (gd->dialog), &x, &y);
123         w = gdk_window_get_width(gtk_widget_get_window (gd->dialog));
124         h = gdk_window_get_height(gtk_widget_get_window (gd->dialog));
125
126         /* The window title is modified in window.c: window_new()
127          * by appending the string " - Geeqie"
128          */
129         ident_string = g_strconcat(" - ", GQ_APPNAME, NULL);
130         full_title = g_strdup(gtk_window_get_title(GTK_WINDOW(gd->dialog)));
131         actual_title = strndup(full_title, g_strrstr(full_title, ident_string) - full_title);
132
133         generic_dialog_save_window(actual_title, gtk_window_get_role(GTK_WINDOW(gd->dialog)), x, y, w, h);
134
135         gtk_widget_destroy(gd->dialog);
136         g_free(gd);
137         g_free(ident_string);
138         g_free(full_title);
139         g_free(actual_title);
140 }
141
142 static void generic_dialog_click_cb(GtkWidget *widget, gpointer data)
143 {
144         GenericDialog *gd = data;
145         void (*func)(GenericDialog *, gpointer);
146         gboolean auto_close;
147
148         func = g_object_get_data(G_OBJECT(widget), "dialog_function");
149         auto_close = gd->auto_close;
150
151         if (func) func(gd, gd->data);
152         if (auto_close) generic_dialog_close(gd);
153 }
154
155 static gboolean generic_dialog_default_key_press_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
156 {
157         GenericDialog *gd = data;
158
159         if (event->keyval == GDK_KEY_Return && gtk_widget_has_focus(widget)
160             && gd->default_cb)
161                 {
162                 gboolean auto_close;
163
164                 auto_close = gd->auto_close;
165                 gd->default_cb(gd, gd->data);
166                 if (auto_close) generic_dialog_close(gd);
167
168                 return TRUE;
169                 }
170         return FALSE;
171 }
172
173 void generic_dialog_attach_default(GenericDialog *gd, GtkWidget *widget)
174 {
175         if (!gd || !widget) return;
176         g_signal_connect(G_OBJECT(widget), "key_press_event",
177                          G_CALLBACK(generic_dialog_default_key_press_cb), gd);
178 }
179
180 static gboolean generic_dialog_key_press_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
181 {
182         GenericDialog *gd = data;
183         gboolean auto_close = gd->auto_close;
184
185         if (event->keyval == GDK_KEY_Escape)
186                 {
187                 if (gd->cancel_cb)
188                         {
189                         gd->cancel_cb(gd, gd->data);
190                         if (auto_close) generic_dialog_close(gd);
191                         }
192                 else
193                         {
194                         if (auto_close) generic_dialog_click_cb(widget, data);
195                         }
196                 return TRUE;
197                 }
198         return FALSE;
199 }
200
201 static gboolean generic_dialog_delete_cb(GtkWidget *w, GdkEventAny *event, gpointer data)
202 {
203         GenericDialog *gd = data;
204         gboolean auto_close;
205
206         auto_close = gd->auto_close;
207
208         if (gd->cancel_cb) gd->cancel_cb(gd, gd->data);
209         if (auto_close) generic_dialog_close(gd);
210
211         return TRUE;
212 }
213
214 static void generic_dialog_show_cb(GtkWidget *widget, gpointer data)
215 {
216         GenericDialog *gd = data;
217         if (gd->cancel_button)
218                 {
219                 gtk_box_reorder_child(GTK_BOX(gd->hbox), gd->cancel_button, -1);
220                 }
221
222         g_signal_handlers_disconnect_by_func(G_OBJECT(widget),
223                                              G_CALLBACK(generic_dialog_show_cb), gd);
224 }
225
226 gboolean generic_dialog_get_alternative_button_order(GtkWidget *widget)
227 {
228         GtkSettings *settings;
229         GObjectClass *klass;
230         gboolean alternative_order = FALSE;
231
232         settings = gtk_settings_get_for_screen(gtk_widget_get_screen(widget));
233         klass = G_OBJECT_CLASS(GTK_SETTINGS_GET_CLASS(settings));
234         if (g_object_class_find_property(klass, "gtk-alternative-button-order"))
235                 {
236                 g_object_get(settings, "gtk-alternative-button-order", &alternative_order, NULL);
237                 }
238
239         return alternative_order;
240 }
241
242 GtkWidget *generic_dialog_add_button(GenericDialog *gd, const gchar *stock_id, const gchar *text,
243                                      void (*func_cb)(GenericDialog *, gpointer), gboolean is_default)
244 {
245         GtkWidget *button;
246         gboolean alternative_order;
247
248         button = pref_button_new(NULL, stock_id, text, FALSE,
249                                  G_CALLBACK(generic_dialog_click_cb), gd);
250
251         gtk_widget_set_can_default(button, TRUE);
252         g_object_set_data(G_OBJECT(button), "dialog_function", func_cb);
253
254         gtk_container_add(GTK_CONTAINER(gd->hbox), button);
255
256         alternative_order = generic_dialog_get_alternative_button_order(gd->hbox);
257
258         if (is_default)
259                 {
260                 gtk_widget_grab_default(button);
261                 gtk_widget_grab_focus(button);
262                 gd->default_cb = func_cb;
263
264                 if (!alternative_order) gtk_box_reorder_child(GTK_BOX(gd->hbox), button, -1);
265                 }
266         else
267                 {
268                 if (!alternative_order) gtk_box_reorder_child(GTK_BOX(gd->hbox), button, 0);
269                 }
270
271         gtk_widget_show(button);
272
273         return button;
274 }
275
276 /**
277  * @brief 
278  * @param gd 
279  * @param icon_stock_id 
280  * @param heading 
281  * @param text 
282  * @param expand Used as the "expand" and "fill" parameters in the eventual call to gtk_box_pack_start() 
283  * @returns 
284  * 
285  * 
286  */
287 GtkWidget *generic_dialog_add_message(GenericDialog *gd, const gchar *icon_stock_id,
288                                       const gchar *heading, const gchar *text, gboolean expand)
289 {
290         GtkWidget *hbox;
291         GtkWidget *vbox;
292         GtkWidget *label;
293
294         hbox = pref_box_new(gd->vbox, expand, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_SPACE);
295         if (icon_stock_id)
296                 {
297                 GtkWidget *image;
298
299                 image = gtk_image_new_from_stock(icon_stock_id, GTK_ICON_SIZE_DIALOG);
300 #if GTK_CHECK_VERSION(3,16,0)
301                 gtk_widget_set_halign(GTK_WIDGET(image), GTK_ALIGN_CENTER);
302                 gtk_widget_set_valign(GTK_WIDGET(image), GTK_ALIGN_START);
303 #else
304                 gtk_misc_set_alignment(GTK_MISC(image), 0.5, 0.0);
305 #endif
306                 gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0);
307                 gtk_widget_show(image);
308                 }
309
310         vbox = pref_box_new(hbox, TRUE, GTK_ORIENTATION_VERTICAL, PREF_PAD_SPACE);
311         if (heading)
312                 {
313                 label = pref_label_new(vbox, heading);
314                 pref_label_bold(label, TRUE, TRUE);
315 #if GTK_CHECK_VERSION(3,16,0)
316                 gtk_label_set_xalign(GTK_LABEL(label), 0.0);
317                 gtk_label_set_yalign(GTK_LABEL(label), 0.5);
318 #else
319                 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
320 #endif
321                 }
322         if (text)
323                 {
324                 label = pref_label_new(vbox, text);
325 #if GTK_CHECK_VERSION(3,16,0)
326                 gtk_label_set_xalign(GTK_LABEL(label), 0.0);
327                 gtk_label_set_yalign(GTK_LABEL(label), 0.5);
328 #else
329                 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
330 #endif
331                 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
332                 }
333
334         return vbox;
335 }
336
337 void generic_dialog_windows_load_config(const gchar **attribute_names, const gchar **attribute_values)
338 {
339         DialogWindow *dw =  g_new0(DialogWindow, 1);
340         gchar *title = NULL;
341         gchar *role = NULL;
342         gint x = 0;
343         gint y = 0;
344         gint w = 0;
345         gint h = 0;
346
347         while (*attribute_names)
348                 {
349                 const gchar *option = *attribute_names++;
350                 const gchar *value = *attribute_values++;
351                 if (READ_CHAR_FULL("title", title)) continue;
352                 if (READ_CHAR_FULL("role", role)) continue;
353                 if (READ_INT_FULL("x", x)) continue;
354                 if (READ_INT_FULL("y", y)) continue;
355                 if (READ_INT_FULL("w", w)) continue;
356                 if (READ_INT_FULL("h", h)) continue;
357
358                 log_printf("unknown attribute %s = %s\n", option, value);
359                 }
360
361         if (title && title[0] != 0)
362                 {
363                 dw->title = g_strdup(title);
364                 dw->role = g_strdup(role);
365                 dw->x = x;
366                 dw->y = y;
367                 dw->w = w;
368                 dw->h = h;
369
370                 dialog_windows = g_list_append(dialog_windows, dw);
371                 }
372 }
373
374 void generic_dialog_windows_write_config(GString *outstr, gint indent)
375 {
376         GList *work;
377
378         if (options->save_dialog_window_positions && dialog_windows)
379                 {
380                 WRITE_NL(); WRITE_STRING("<%s>", "dialogs");
381                 indent++;
382
383                 work = g_list_first(dialog_windows);
384                 while (work)
385                         {
386                         DialogWindow *dw = work->data;
387                         WRITE_NL(); WRITE_STRING("<window ");
388                         write_char_option(outstr, indent + 1, "title", dw->title);
389                         write_char_option(outstr, indent + 1, "role", dw->role);
390                         WRITE_INT(*dw, x);
391                         WRITE_INT(*dw, y);
392                         WRITE_INT(*dw, w);
393                         WRITE_INT(*dw, h);
394                         WRITE_STRING("/>");
395                         work = work->next;
396                         }
397                 indent--;
398                 WRITE_NL(); WRITE_STRING("</%s>", "dialogs");
399                 }
400 }
401
402 static void generic_dialog_setup(GenericDialog *gd,
403                                  const gchar *title,
404                                  const gchar *role,
405                                  GtkWidget *parent, gboolean auto_close,
406                                  void (*cancel_cb)(GenericDialog *, gpointer), gpointer data)
407 {
408         GtkWidget *vbox;
409         gint x, y, w, h;
410         GtkWidget *scrolled;
411
412         gd->auto_close = auto_close;
413         gd->data = data;
414         gd->cancel_cb = cancel_cb;
415
416         gd->dialog = window_new(GTK_WINDOW_TOPLEVEL, role, NULL, NULL, title);
417         DEBUG_NAME(gd->dialog);
418         gtk_window_set_type_hint(GTK_WINDOW(gd->dialog), GDK_WINDOW_TYPE_HINT_DIALOG);
419
420         if (options->save_dialog_window_positions)
421                 {
422                 if (generic_dialog_find_window(title, role, &x, &y, &w, &h))
423                         {
424                         gtk_window_set_default_size(GTK_WINDOW(gd->dialog), w, h);
425                         gtk_window_move(GTK_WINDOW(gd->dialog), x, y);
426                         }
427                 }
428
429         if (parent)
430                 {
431                 GtkWindow *window = NULL;
432
433                 if (GTK_IS_WINDOW(parent))
434                         {
435                         window = GTK_WINDOW(parent);
436                         }
437                 else
438                         {
439                         GtkWidget *top;
440
441                         top = gtk_widget_get_toplevel(parent);
442                         if (GTK_IS_WINDOW(top) && gtk_widget_is_toplevel(top)) window = GTK_WINDOW(top);
443                         }
444
445                 if (window) gtk_window_set_transient_for(GTK_WINDOW(gd->dialog), window);
446                 }
447
448         g_signal_connect(G_OBJECT(gd->dialog), "delete_event",
449                          G_CALLBACK(generic_dialog_delete_cb), gd);
450         g_signal_connect(G_OBJECT(gd->dialog), "key_press_event",
451                          G_CALLBACK(generic_dialog_key_press_cb), gd);
452
453         gtk_window_set_resizable(GTK_WINDOW(gd->dialog), TRUE);
454         gtk_container_set_border_width(GTK_CONTAINER(gd->dialog), PREF_PAD_BORDER);
455
456 #if GTK_CHECK_VERSION(3,22,0)
457         scrolled = gtk_scrolled_window_new(NULL, NULL);
458         gtk_scrolled_window_set_propagate_natural_height(GTK_SCROLLED_WINDOW(scrolled), TRUE);
459         gtk_scrolled_window_set_propagate_natural_width(GTK_SCROLLED_WINDOW(scrolled), TRUE);
460         vbox = gtk_vbox_new(FALSE, PREF_PAD_BUTTON_SPACE);
461         gtk_container_add(GTK_CONTAINER(scrolled), vbox);
462         gtk_container_add(GTK_CONTAINER(gd->dialog), scrolled);
463         gtk_widget_show(scrolled);
464 #else
465         vbox = gtk_vbox_new(FALSE, PREF_PAD_BUTTON_SPACE);
466         gtk_container_add(GTK_CONTAINER(gd->dialog), vbox);
467 #endif
468         gtk_widget_show(vbox);
469
470         gd->vbox = gtk_vbox_new(FALSE, PREF_PAD_GAP);
471         gtk_box_pack_start(GTK_BOX(vbox), gd->vbox, TRUE, TRUE, 0);
472         gtk_widget_show(gd->vbox);
473
474         gd->hbox = gtk_hbutton_box_new();
475         gtk_button_box_set_layout(GTK_BUTTON_BOX(gd->hbox), GTK_BUTTONBOX_END);
476         gtk_box_set_spacing(GTK_BOX(gd->hbox), PREF_PAD_BUTTON_GAP);
477         gtk_box_pack_start(GTK_BOX(vbox), gd->hbox, FALSE, FALSE, 0);
478         gtk_widget_show(gd->hbox);
479
480         if (gd->cancel_cb)
481                 {
482                 gd->cancel_button = generic_dialog_add_button(gd, GTK_STOCK_CANCEL, NULL, gd->cancel_cb, TRUE);
483                 }
484         else
485                 {
486                 gd->cancel_button = NULL;
487                 }
488
489         if (generic_dialog_get_alternative_button_order(gd->hbox))
490                 {
491                 g_signal_connect(G_OBJECT(gd->dialog), "show",
492                                  G_CALLBACK(generic_dialog_show_cb), gd);
493                 }
494
495         gd->default_cb = NULL;
496 }
497
498 GenericDialog *generic_dialog_new(const gchar *title,
499                                   const gchar *role,
500                                   GtkWidget *parent, gboolean auto_close,
501                                   void (*cancel_cb)(GenericDialog *, gpointer), gpointer data)
502 {
503         GenericDialog *gd;
504
505         gd = g_new0(GenericDialog, 1);
506         generic_dialog_setup(gd, title, role,
507                              parent, auto_close, cancel_cb, data);
508         return gd;
509 }
510 /*
511  *-----------------------------------------------------------------------------
512  * simple warning dialog
513  *-----------------------------------------------------------------------------
514  */
515
516 static void warning_dialog_ok_cb(GenericDialog *gd, gpointer data)
517 {
518         /* no op */
519 }
520
521 GenericDialog *warning_dialog(const gchar *heading, const gchar *text,
522                               const gchar *icon_stock_id, GtkWidget *parent)
523 {
524         GenericDialog *gd;
525
526         gd = generic_dialog_new(heading, "warning", parent, TRUE, NULL, NULL);
527         generic_dialog_add_button(gd, GTK_STOCK_OK, NULL, warning_dialog_ok_cb, TRUE);
528
529         generic_dialog_add_message(gd, icon_stock_id, heading, text, TRUE);
530
531         gtk_widget_show(gd->dialog);
532
533         return gd;
534 }
535
536 /*
537  *-----------------------------------------------------------------------------
538  * generic file ops dialog routines
539  *-----------------------------------------------------------------------------
540  */
541
542 void file_dialog_close(FileDialog *fdlg)
543 {
544         file_data_unref(fdlg->source_fd);
545         g_free(fdlg->dest_path);
546         if (fdlg->source_list) filelist_free(fdlg->source_list);
547
548         generic_dialog_close(GENERIC_DIALOG(fdlg));
549 }
550
551 FileDialog *file_dialog_new(const gchar *title,
552                             const gchar *role,
553                             GtkWidget *parent,
554                             void (*cancel_cb)(FileDialog *, gpointer), gpointer data)
555 {
556         FileDialog *fdlg = NULL;
557
558         fdlg = g_new0(FileDialog, 1);
559
560         generic_dialog_setup(GENERIC_DIALOG(fdlg), title,
561                              role, parent, FALSE,
562                              (gpointer)cancel_cb, data);
563
564         return fdlg;
565 }
566
567 GtkWidget *file_dialog_add_button(FileDialog *fdlg, const gchar *stock_id, const gchar *text,
568                                   void (*func_cb)(FileDialog *, gpointer), gboolean is_default)
569 {
570         return generic_dialog_add_button(GENERIC_DIALOG(fdlg), stock_id, text,
571                                          (gpointer)func_cb, is_default);
572 }
573
574 static void file_dialog_entry_cb(GtkWidget *widget, gpointer data)
575 {
576         FileDialog *fdlg = data;
577         g_free(fdlg->dest_path);
578         fdlg->dest_path = remove_trailing_slash(gtk_entry_get_text(GTK_ENTRY(fdlg->entry)));
579 }
580
581 static void file_dialog_entry_enter_cb(const gchar *path, gpointer data)
582 {
583         GenericDialog *gd = data;
584
585         file_dialog_entry_cb(NULL, data);
586
587         if (gd->default_cb) gd->default_cb(gd, gd->data);
588 }
589
590 void file_dialog_add_path_widgets(FileDialog *fdlg, const gchar *default_path, const gchar *path,
591                                   const gchar *history_key, const gchar *filter, const gchar *filter_desc)
592 {
593         GtkWidget *tabcomp;
594         GtkWidget *list;
595
596         if (fdlg->entry) return;
597
598         tabcomp = tab_completion_new_with_history(&fdlg->entry, NULL,
599                   history_key, -1, file_dialog_entry_enter_cb, fdlg);
600         gtk_box_pack_end(GTK_BOX(GENERIC_DIALOG(fdlg)->vbox), tabcomp, FALSE, FALSE, 0);
601         generic_dialog_attach_default(GENERIC_DIALOG(fdlg), fdlg->entry);
602         gtk_widget_show(tabcomp);
603
604         if (path && path[0] == G_DIR_SEPARATOR)
605                 {
606                 fdlg->dest_path = g_strdup(path);
607                 }
608         else
609                 {
610                 const gchar *base;
611
612                 base = tab_completion_set_to_last_history(fdlg->entry);
613
614                 if (!base) base = default_path;
615                 if (!base) base = homedir();
616
617                 if (path)
618                         {
619                         fdlg->dest_path = g_build_filename(base, path, NULL);
620                         }
621                 else
622                         {
623                         fdlg->dest_path = g_strdup(base);
624                         }
625                 }
626
627         list = path_selection_new_with_files(fdlg->entry, fdlg->dest_path, filter, filter_desc);
628         path_selection_add_select_func(fdlg->entry, file_dialog_entry_enter_cb, fdlg);
629         gtk_box_pack_end(GTK_BOX(GENERIC_DIALOG(fdlg)->vbox), list, TRUE, TRUE, 0);
630         gtk_widget_show(list);
631
632         gtk_widget_grab_focus(fdlg->entry);
633         if (fdlg->dest_path)
634                 {
635                 gtk_entry_set_text(GTK_ENTRY(fdlg->entry), fdlg->dest_path);
636                 gtk_editable_set_position(GTK_EDITABLE(fdlg->entry), strlen(fdlg->dest_path));
637                 }
638
639         g_signal_connect(G_OBJECT(fdlg->entry), "changed",
640                          G_CALLBACK(file_dialog_entry_cb), fdlg);
641 }
642
643 void file_dialog_add_filter(FileDialog *fdlg, const gchar *filter, const gchar *filter_desc, gboolean set)
644 {
645         if (!fdlg->entry) return;
646         path_selection_add_filter(fdlg->entry, filter, filter_desc, set);
647 }
648
649 void file_dialog_clear_filter(FileDialog *fdlg)
650 {
651         if (!fdlg->entry) return;
652         path_selection_clear_filter(fdlg->entry);
653 }
654
655 void file_dialog_sync_history(FileDialog *fdlg, gboolean dir_only)
656 {
657         if (!fdlg->dest_path) return;
658
659         if (!dir_only ||
660             (dir_only && isdir(fdlg->dest_path)) )
661                 {
662                 tab_completion_append_to_history(fdlg->entry, fdlg->dest_path);
663                 }
664         else
665                 {
666                 gchar *buf = remove_level_from_path(fdlg->dest_path);
667                 tab_completion_append_to_history(fdlg->entry, buf);
668                 g_free(buf);
669                 }
670 }
671 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */