1 /* GTK - The GIMP Toolkit
2 * gtkfilechooserentry.c: Entry with filename completion
3 * Copyright (C) 2003, Red Hat, Inc.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
24 #include "gtkcelllayout.h"
25 #include "gtkcellrenderertext.h"
27 #include "gtkfilechooserentry.h"
30 typedef struct _GtkFileChooserEntryClass GtkFileChooserEntryClass;
32 #define GTK_FILE_CHOOSER_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_FILE_CHOOSER_ENTRY, GtkFileChooserEntryClass))
33 #define GTK_IS_FILE_CHOOSER_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_FILE_CHOOSER_ENTRY))
34 #define GTK_FILE_CHOOSER_ENTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_FILE_CHOOSER_ENTRY, GtkFileChooserEntryClass))
36 struct _GtkFileChooserEntryClass
38 GtkEntryClass parent_class;
41 struct _GtkFileChooserEntry
43 GtkEntry parent_instance;
45 GtkFileSystem *file_system;
46 GtkFilePath *base_folder;
47 GtkFilePath *current_folder_path;
50 GSource *check_completion_idle;
51 GSource *load_directory_idle;
53 GtkFileFolder *current_folder;
55 GtkListStore *completion_store;
57 guint has_completion : 1;
68 static void gtk_file_chooser_entry_class_init (GtkFileChooserEntryClass *class);
69 static void gtk_file_chooser_entry_iface_init (GtkEditableClass *iface);
70 static void gtk_file_chooser_entry_init (GtkFileChooserEntry *chooser_entry);
72 static void gtk_file_chooser_entry_finalize (GObject *object);
73 static gboolean gtk_file_chooser_entry_focus (GtkWidget *widget,
74 GtkDirectionType direction);
75 static void gtk_file_chooser_entry_activate (GtkEntry *entry);
76 static void gtk_file_chooser_entry_changed (GtkEditable *editable);
77 static void gtk_file_chooser_entry_do_insert_text (GtkEditable *editable,
78 const gchar *new_text,
82 static void clear_completion_callback (GtkFileChooserEntry *chooser_entry,
84 static gboolean match_selected_callback (GtkEntryCompletion *completion,
87 GtkFileChooserEntry *chooser_entry);
88 static gboolean completion_match_func (GtkEntryCompletion *comp,
92 static void files_added_cb (GtkFileSystem *file_system,
94 GtkFileChooserEntry *chooser_entry);
95 static void files_deleted_cb (GtkFileSystem *file_system,
97 GtkFileChooserEntry *chooser_entry);
98 static char *maybe_append_separator_to_path (GtkFileChooserEntry *chooser_entry,
100 gchar *display_name);
103 static GObjectClass *parent_class;
104 static GtkEditableClass *parent_editable_iface;
107 _gtk_file_chooser_entry_get_type (void)
109 static GType file_chooser_entry_type = 0;
111 if (!file_chooser_entry_type)
113 static const GTypeInfo file_chooser_entry_info =
115 sizeof (GtkFileChooserEntryClass),
116 NULL, /* base_init */
117 NULL, /* base_finalize */
118 (GClassInitFunc) gtk_file_chooser_entry_class_init,
119 NULL, /* class_finalize */
120 NULL, /* class_data */
121 sizeof (GtkFileChooserEntry),
123 (GInstanceInitFunc) gtk_file_chooser_entry_init,
126 static const GInterfaceInfo editable_info =
128 (GInterfaceInitFunc) gtk_file_chooser_entry_iface_init, /* interface_init */
129 NULL, /* interface_finalize */
130 NULL /* interface_data */
134 file_chooser_entry_type = g_type_register_static (GTK_TYPE_ENTRY, "GtkFileChooserEntry",
135 &file_chooser_entry_info, 0);
136 g_type_add_interface_static (file_chooser_entry_type,
142 return file_chooser_entry_type;
146 gtk_file_chooser_entry_class_init (GtkFileChooserEntryClass *class)
148 GObjectClass *gobject_class = G_OBJECT_CLASS (class);
149 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
150 GtkEntryClass *entry_class = GTK_ENTRY_CLASS (class);
152 parent_class = g_type_class_peek_parent (class);
154 gobject_class->finalize = gtk_file_chooser_entry_finalize;
156 widget_class->focus = gtk_file_chooser_entry_focus;
158 entry_class->activate = gtk_file_chooser_entry_activate;
162 gtk_file_chooser_entry_iface_init (GtkEditableClass *iface)
164 parent_editable_iface = g_type_interface_peek_parent (iface);
166 iface->do_insert_text = gtk_file_chooser_entry_do_insert_text;
167 iface->changed = gtk_file_chooser_entry_changed;
171 gtk_file_chooser_entry_init (GtkFileChooserEntry *chooser_entry)
173 GtkEntryCompletion *comp;
174 GtkCellRenderer *cell;
176 comp = gtk_entry_completion_new ();
177 gtk_entry_completion_set_match_func (comp,
178 completion_match_func,
182 cell = gtk_cell_renderer_text_new ();
183 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (comp),
185 gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (comp),
189 g_signal_connect (comp, "match-selected",
190 G_CALLBACK (match_selected_callback), chooser_entry);
192 gtk_entry_set_completion (GTK_ENTRY (chooser_entry), comp);
193 g_object_unref (comp);
195 g_signal_connect (chooser_entry, "notify::cursor-position",
196 G_CALLBACK (clear_completion_callback), NULL);
197 g_signal_connect (chooser_entry, "notify::selection-bound",
198 G_CALLBACK (clear_completion_callback), NULL);
202 gtk_file_chooser_entry_finalize (GObject *object)
204 GtkFileChooserEntry *chooser_entry = GTK_FILE_CHOOSER_ENTRY (object);
206 if (chooser_entry->completion_store)
207 g_object_unref (chooser_entry->completion_store);
209 if (chooser_entry->current_folder)
211 g_signal_handlers_disconnect_by_func (chooser_entry->current_folder,
212 G_CALLBACK (files_added_cb), chooser_entry);
213 g_signal_handlers_disconnect_by_func (chooser_entry->current_folder,
214 G_CALLBACK (files_deleted_cb), chooser_entry);
215 g_object_unref (chooser_entry->current_folder);
218 if (chooser_entry->file_system)
219 g_object_unref (chooser_entry->file_system);
221 gtk_file_path_free (chooser_entry->base_folder);
222 gtk_file_path_free (chooser_entry->current_folder_path);
223 g_free (chooser_entry->file_part);
225 parent_class->finalize (object);
228 /* Match functions for the GtkEntryCompletion */
230 match_selected_callback (GtkEntryCompletion *completion,
233 GtkFileChooserEntry *chooser_entry)
239 gtk_tree_model_get (model, iter,
240 DISPLAY_NAME_COLUMN, &display_name,
244 if (!display_name || !path)
246 /* these shouldn't complain if passed NULL */
247 gtk_file_path_free (path);
248 g_free (display_name);
252 display_name = maybe_append_separator_to_path (chooser_entry, path, display_name);
254 pos = chooser_entry->file_part_pos;
256 /* We don't set in_change here as we want to update the current_folder
258 gtk_editable_delete_text (GTK_EDITABLE (chooser_entry),
260 gtk_editable_insert_text (GTK_EDITABLE (chooser_entry),
263 gtk_editable_set_position (GTK_EDITABLE (chooser_entry), -1);
265 gtk_file_path_free (path);
266 g_free (display_name);
271 /* Match function for the GtkEntryCompletion */
273 completion_match_func (GtkEntryCompletion *comp,
274 const char *key_unused,
278 GtkFileChooserEntry *chooser_entry;
281 char *norm_file_part;
284 chooser_entry = GTK_FILE_CHOOSER_ENTRY (data);
286 /* We ignore the key because it is the contents of the entry. Instead, we
287 * just use our precomputed file_part.
289 if (!chooser_entry->file_part)
294 gtk_tree_model_get (GTK_TREE_MODEL (chooser_entry->completion_store), iter, DISPLAY_NAME_COLUMN, &name, -1);
297 return FALSE; /* Uninitialized row, ugh */
300 /* If we have an empty file_part, then we're at the root of a directory. In
301 * that case, we want to match all non-dot files. We might want to match
302 * dot_files too if show_hidden is TRUE on the fileselector in the future.
304 /* Additionally, support for gnome .hidden files would be sweet, too */
305 if (chooser_entry->file_part[0] == '\000')
317 norm_file_part = g_utf8_normalize (chooser_entry->file_part, -1, G_NORMALIZE_ALL);
318 norm_name = g_utf8_normalize (name, -1, G_NORMALIZE_ALL);
320 result = (strncmp (norm_file_part, norm_name, strlen (norm_file_part)) == 0);
322 g_free (norm_file_part);
329 /* This function will append a '/' character to paths to display_name iff the
330 * path associated with it is a directory. maybe_append_separator_to_path will
331 * g_free the display_name and return a new one if needed. Otherwise, it will
332 * return the old one. You should be safe calling
334 * display_name = maybe_append_separator_to_path (entry, path, display_name);
336 * g_free (display_name);
339 maybe_append_separator_to_path (GtkFileChooserEntry *chooser_entry,
347 info = gtk_file_folder_get_info (chooser_entry->current_folder,
348 path, NULL); /* NULL-GError */
352 if (gtk_file_info_get_is_folder (info))
354 gchar *tmp = display_name;
355 display_name = g_strconcat (tmp, "/", NULL);
359 gtk_file_info_free (info);
368 check_completion_callback (GtkFileChooserEntry *chooser_entry)
371 gchar *common_prefix = NULL;
372 GtkFilePath *unique_path = NULL;
375 g_assert (chooser_entry->file_part);
377 chooser_entry->check_completion_idle = NULL;
379 if (strcmp (chooser_entry->file_part, "") == 0)
382 if (chooser_entry->completion_store == NULL)
385 valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (chooser_entry->completion_store),
393 gtk_tree_model_get (GTK_TREE_MODEL (chooser_entry->completion_store),
395 DISPLAY_NAME_COLUMN, &display_name,
399 if (g_str_has_prefix (display_name, chooser_entry->file_part))
403 common_prefix = g_strdup (display_name);
404 unique_path = gtk_file_path_copy (path);
408 gchar *p = common_prefix;
409 const gchar *q = display_name;
411 while (*p && *p == *q)
419 gtk_file_path_free (unique_path);
424 g_free (display_name);
425 gtk_file_path_free (path);
426 valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (chooser_entry->completion_store),
432 common_prefix = maybe_append_separator_to_path (chooser_entry,
435 gtk_file_path_free (unique_path);
441 gint common_prefix_len;
444 file_part_len = g_utf8_strlen (chooser_entry->file_part, -1);
445 common_prefix_len = g_utf8_strlen (common_prefix, -1);
447 if (common_prefix_len > file_part_len)
449 pos = chooser_entry->file_part_pos;
451 chooser_entry->in_change = TRUE;
452 gtk_editable_delete_text (GTK_EDITABLE (chooser_entry),
454 gtk_editable_insert_text (GTK_EDITABLE (chooser_entry),
457 gtk_editable_select_region (GTK_EDITABLE (chooser_entry),
458 chooser_entry->file_part_pos + file_part_len,
459 chooser_entry->file_part_pos + common_prefix_len);
460 chooser_entry->in_change = FALSE;
462 chooser_entry->has_completion = TRUE;
465 g_free (common_prefix);
472 add_completion_idle (GtkFileChooserEntry *chooser_entry)
474 /* idle to update the selection based on the file list */
475 if (chooser_entry->check_completion_idle == NULL)
477 chooser_entry->check_completion_idle = g_idle_source_new ();
478 g_source_set_priority (chooser_entry->check_completion_idle, G_PRIORITY_HIGH);
479 g_source_set_closure (chooser_entry->check_completion_idle,
480 g_cclosure_new_object (G_CALLBACK (check_completion_callback),
481 G_OBJECT (chooser_entry)));
482 g_source_attach (chooser_entry->check_completion_idle, NULL);
488 update_current_folder_files (GtkFileChooserEntry *chooser_entry,
493 g_assert (chooser_entry->completion_store != NULL);
495 /* Bah. Need to turn off sorting */
496 for (tmp_list = added_uris; tmp_list; tmp_list = tmp_list->next)
501 path = tmp_list->data;
503 info = gtk_file_folder_get_info (chooser_entry->current_folder,
505 NULL); /* NULL-GError */
508 const gchar *display_name = gtk_file_info_get_display_name (info);
511 gtk_list_store_append (chooser_entry->completion_store, &iter);
512 gtk_list_store_set (chooser_entry->completion_store, &iter,
513 DISPLAY_NAME_COLUMN, display_name,
517 gtk_file_info_free (info);
521 /* FIXME: we want to turn off sorting temporarily. I suck... */
522 gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (chooser_entry->completion_store),
523 DISPLAY_NAME_COLUMN, GTK_SORT_ASCENDING);
525 add_completion_idle (chooser_entry);
529 files_added_cb (GtkFileSystem *file_system,
531 GtkFileChooserEntry *chooser_entry)
533 update_current_folder_files (chooser_entry, added_uris);
537 files_deleted_cb (GtkFileSystem *file_system,
538 GSList *deleted_uris,
539 GtkFileChooserEntry *chooser_entry)
541 /* FIXME: gravy... */
545 load_directory_callback (GtkFileChooserEntry *chooser_entry)
547 GSList *child_paths = NULL;
549 chooser_entry->load_directory_idle = NULL;
551 /* guard against bogus settings*/
552 if (chooser_entry->current_folder_path == NULL ||
553 chooser_entry->file_system == NULL)
556 if (chooser_entry->current_folder != NULL)
558 g_warning ("idle activate multiple times without clearing the folder object first.");
561 g_assert (chooser_entry->completion_store == NULL);
563 /* Load the folder */
564 chooser_entry->current_folder = gtk_file_system_get_folder (chooser_entry->file_system,
565 chooser_entry->current_folder_path,
566 GTK_FILE_INFO_DISPLAY_NAME | GTK_FILE_INFO_IS_FOLDER,
567 NULL); /* NULL-GError */
569 /* There is no folder by that name */
570 if (!chooser_entry->current_folder)
572 g_signal_connect (chooser_entry->current_folder, "files-added",
573 G_CALLBACK (files_added_cb), chooser_entry);
574 g_signal_connect (chooser_entry->current_folder, "files-removed",
575 G_CALLBACK (files_deleted_cb), chooser_entry);
577 gtk_file_folder_list_children (chooser_entry->current_folder,
579 NULL); /* NULL-GError */
580 chooser_entry->completion_store = gtk_list_store_new (N_COLUMNS,
586 update_current_folder_files (chooser_entry, child_paths);
587 add_completion_idle (chooser_entry);
588 gtk_file_paths_free (child_paths);
591 gtk_entry_completion_set_model (gtk_entry_get_completion (GTK_ENTRY (chooser_entry)),
592 GTK_TREE_MODEL (chooser_entry->completion_store));
597 gtk_file_chooser_entry_do_insert_text (GtkEditable *editable,
598 const gchar *new_text,
599 gint new_text_length,
602 GtkFileChooserEntry *chooser_entry = GTK_FILE_CHOOSER_ENTRY (editable);
604 parent_editable_iface->do_insert_text (editable, new_text, new_text_length, position);
606 if (! chooser_entry->in_change)
607 add_completion_idle (GTK_FILE_CHOOSER_ENTRY (editable));
611 gtk_file_chooser_entry_focus (GtkWidget *widget,
612 GtkDirectionType direction)
614 GtkFileChooserEntry *chooser_entry = GTK_FILE_CHOOSER_ENTRY (widget);
615 GdkModifierType state;
616 gboolean control_pressed = FALSE;
618 if (gtk_get_current_event_state (&state))
620 if ((state & GDK_CONTROL_MASK) == GDK_CONTROL_MASK)
621 control_pressed = TRUE;
624 /* This is a bit evil -- it makes Tab never leave the entry. It basically
625 * makes it 'safe' for people to hit. */
626 if ((direction == GTK_DIR_TAB_FORWARD) &&
627 (GTK_WIDGET_HAS_FOCUS (widget)) &&
630 if (chooser_entry->has_completion)
632 gtk_editable_set_position (GTK_EDITABLE (widget),
633 GTK_ENTRY (widget)->text_length);
638 return GTK_WIDGET_CLASS (parent_class)->focus (widget, direction);
642 gtk_file_chooser_entry_activate (GtkEntry *entry)
644 GtkFileChooserEntry *chooser_entry = GTK_FILE_CHOOSER_ENTRY (entry);
646 if (chooser_entry->has_completion)
648 gtk_editable_set_position (GTK_EDITABLE (entry),
652 GTK_ENTRY_CLASS (parent_class)->activate (entry);
655 /* This will see if a path typed by the user is new, and installs the loading
659 gtk_file_chooser_entry_maybe_update_directory (GtkFileChooserEntry *chooser_entry,
660 GtkFilePath *folder_path)
662 gboolean queue_idle = FALSE;
664 if (chooser_entry->current_folder_path)
666 if (gtk_file_path_compare (folder_path, chooser_entry->current_folder_path) != 0)
668 /* We changed our current directory. We need to clear out the old
669 * directory information.
671 if (chooser_entry->current_folder)
673 g_signal_handlers_disconnect_by_func (chooser_entry->current_folder,
674 G_CALLBACK (files_added_cb), chooser_entry);
675 g_signal_handlers_disconnect_by_func (chooser_entry->current_folder,
676 G_CALLBACK (files_deleted_cb), chooser_entry);
678 g_object_unref (chooser_entry->current_folder);
679 chooser_entry->current_folder = NULL;
681 if (chooser_entry->completion_store)
683 gtk_list_store_clear (GTK_LIST_STORE (chooser_entry->completion_store));
684 /* FIXME: Uncomment this line and get rid of the _clear above
685 * after #137211 is fixed */
686 /* gtk_entry_completion_set_model (gtk_entry_get_completion (GTK_ENTRY (chooser_entry)), NULL);*/
687 g_object_unref (chooser_entry->completion_store);
688 chooser_entry->completion_store = NULL;
694 gtk_file_path_free (chooser_entry->current_folder_path);
701 chooser_entry->current_folder_path = folder_path;
703 if (queue_idle && chooser_entry->load_directory_idle == NULL)
705 chooser_entry->load_directory_idle = g_idle_source_new ();
706 g_source_set_priority (chooser_entry->load_directory_idle, G_PRIORITY_HIGH);
707 g_source_set_closure (chooser_entry->load_directory_idle,
708 g_cclosure_new_object (G_CALLBACK (load_directory_callback),
709 G_OBJECT (chooser_entry)));
710 g_source_attach (chooser_entry->load_directory_idle, NULL);
717 gtk_file_chooser_entry_changed (GtkEditable *editable)
719 GtkFileChooserEntry *chooser_entry = GTK_FILE_CHOOSER_ENTRY (editable);
721 GtkFilePath *folder_path;
723 gsize total_len, file_part_len;
726 if (chooser_entry->in_change)
729 text = gtk_entry_get_text (GTK_ENTRY (editable));
731 if (!chooser_entry->file_system ||
732 !chooser_entry->base_folder ||
733 !gtk_file_system_parse (chooser_entry->file_system,
734 chooser_entry->base_folder, text,
735 &folder_path, &file_part, NULL)) /* NULL-GError */
737 folder_path = gtk_file_path_copy (chooser_entry->base_folder);
738 file_part = g_strdup ("");
741 file_part_len = strlen (file_part);
742 total_len = strlen (text);
743 if (total_len > file_part_len)
744 file_part_pos = g_utf8_strlen (text, total_len - file_part_len);
748 gtk_file_chooser_entry_maybe_update_directory (chooser_entry, folder_path);
750 if (chooser_entry->file_part)
751 g_free (chooser_entry->file_part);
753 chooser_entry->file_part = file_part;
754 chooser_entry->file_part_pos = file_part_pos;
758 clear_completion_callback (GtkFileChooserEntry *chooser_entry,
761 if (chooser_entry->has_completion)
763 chooser_entry->has_completion = FALSE;
764 gtk_file_chooser_entry_changed (GTK_EDITABLE (chooser_entry));
769 * _gtk_file_chooser_entry_new:
771 * Creates a new #GtkFileChooserEntry object. #GtkFileChooserEntry
772 * is an internal implementation widget for the GTK+ file chooser
773 * which is an entry with completion with respect to a
774 * #GtkFileSystem object.
776 * Return value: the newly created #GtkFileChooserEntry
779 _gtk_file_chooser_entry_new (void)
781 return g_object_new (GTK_TYPE_FILE_CHOOSER_ENTRY, NULL);
785 * _gtk_file_chooser_entry_set_file_system:
786 * @chooser_entry: a #GtkFileChooser
787 * @file_system: an object implementing #GtkFileSystem
789 * Sets the file system for @chooser_entry.
792 _gtk_file_chooser_entry_set_file_system (GtkFileChooserEntry *chooser_entry,
793 GtkFileSystem *file_system)
795 g_return_if_fail (GTK_IS_FILE_CHOOSER_ENTRY (chooser_entry));
796 g_return_if_fail (GTK_IS_FILE_SYSTEM (file_system));
798 if (file_system != chooser_entry->file_system)
800 if (chooser_entry->file_system)
801 g_object_unref (chooser_entry->file_system);
803 chooser_entry->file_system = g_object_ref (file_system);
808 * _gtk_file_chooser_entry_set_base_folder:
809 * @chooser_entry: a #GtkFileChooserEntry
810 * @path: path of a folder in the chooser entries current file system.
812 * Sets the folder with respect to which completions occur.
815 _gtk_file_chooser_entry_set_base_folder (GtkFileChooserEntry *chooser_entry,
816 const GtkFilePath *path)
818 if (chooser_entry->base_folder)
819 gtk_file_path_free (chooser_entry->base_folder);
821 chooser_entry->base_folder = gtk_file_path_copy (path);
823 gtk_editable_select_region (GTK_EDITABLE (chooser_entry), 0, -1);
827 * _gtk_file_chooser_entry_get_current_folder:
828 * @chooser_entry: a #GtkFileChooserEntry
830 * Gets the current folder for the #GtkFileChooserEntry. If the
831 * user has only entered a filename, this will be the base folder
832 * (see _gtk_file_chooser_entry_set_base_folder()), but if the
833 * user has entered a relative or absolute path, then it will
834 * be different. If the user has entered a relative or absolute
835 * path that doesn't point to a folder in the file system, it will
838 * Return value: the path of current folder - this value is owned by the
839 * chooser entry and must not be modified or freed.
842 _gtk_file_chooser_entry_get_current_folder (GtkFileChooserEntry *chooser_entry)
844 return chooser_entry->current_folder_path;
848 * _gtk_file_chooser_entry_get_file_part:
849 * @chooser_entry: a #GtkFileChooserEntry
851 * Gets the non-folder portion of whatever the user has entered
852 * into the file selector. What is returned is a UTF-8 string,
853 * and if a filename path is needed, gtk_file_system_make_path()
856 * Return value: the entered filename - this value is owned by the
857 * chooser entry and must not be modified or freed.
860 _gtk_file_chooser_entry_get_file_part (GtkFileChooserEntry *chooser_entry)
862 return chooser_entry->file_part;
866 * _gtk_file_chooser_entry_set_file_part:
867 * @chooser_entry: a #GtkFileChooserEntry
868 * @file_part: text to display in the entry, in UTF-8
870 * Sets the current text shown in the file chooser entry.
873 _gtk_file_chooser_entry_set_file_part (GtkFileChooserEntry *chooser_entry,
874 const gchar *file_part)
876 g_return_if_fail (GTK_IS_FILE_CHOOSER_ENTRY (chooser_entry));
878 gtk_entry_set_text (GTK_ENTRY (chooser_entry), file_part);