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;
49 GSource *check_completion_idle;
50 GSource *load_directory_idle;
52 GtkFileFolder *current_folder;
54 GtkListStore *completion_store;
56 guint has_completion : 1;
58 guint no_pop_down : 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)
238 gint selected_part_len;
243 gtk_tree_model_get (model, iter,
244 DISPLAY_NAME_COLUMN, &display_name,
248 if (!display_name || !path)
250 /* these shouldn't complain if passed NULL */
251 gtk_file_path_free (path);
252 g_free (display_name);
256 display_name = maybe_append_separator_to_path (chooser_entry, path, display_name);
258 /* We have to jump through hoops to figure out where to append this to */
259 text = gtk_entry_get_text (GTK_ENTRY (chooser_entry));
260 total_len = g_utf8_strlen (text, -1);
261 file_part_len = g_utf8_strlen (chooser_entry->file_part, -1);
263 selected_part_len = 0;
265 if (chooser_entry->has_completion)
267 gint sel_start, sel_end;
269 /* Gosh, there should be a more efficient way of doing this... */
270 if (gtk_editable_get_selection_bounds (GTK_EDITABLE (chooser_entry),
271 &sel_start, &sel_end))
273 gchar *str = gtk_editable_get_chars (GTK_EDITABLE (chooser_entry),
275 selected_part_len = g_utf8_strlen (str, -1);
280 pos = total_len - (file_part_len + selected_part_len);
282 /* We don't set in_change here as we want to update the current_folder
284 gtk_editable_delete_text (GTK_EDITABLE (chooser_entry),
286 gtk_editable_insert_text (GTK_EDITABLE (chooser_entry),
289 gtk_editable_set_position (GTK_EDITABLE (chooser_entry), -1);
291 gtk_file_path_free (path);
292 g_free (display_name);
294 /* We surpress the completion for a second. It's confusing to click on an
295 * entry and have it pop back up immediately */
296 chooser_entry->no_pop_down = TRUE;
301 /* Match function for the GtkEntryCompletion */
303 completion_match_func (GtkEntryCompletion *comp,
304 const char *key_unused,
308 GtkFileChooserEntry *chooser_entry;
311 char *norm_file_part;
314 chooser_entry = GTK_FILE_CHOOSER_ENTRY (data);
316 /* We ignore the key because it is the contents of the entry. Instead, we
317 * just use our precomputed file_part.
319 if (!chooser_entry->file_part)
324 /* If this is set, than someone is surpressing the popdown temporarily */
325 if (chooser_entry->no_pop_down)
328 gtk_tree_model_get (GTK_TREE_MODEL (chooser_entry->completion_store), iter, 0, &name, -1);
331 return FALSE; /* Uninitialized row, ugh */
334 /* If we have an empty file_part, then we're at the root of a directory. In
335 * that case, we want to match all non-dot files. We might want to match
336 * dot_files too if show_hidden is TRUE on the fileselector in the future.
338 /* Additionally, support for gnome .hidden files would be sweet, too */
339 if (chooser_entry->file_part[0] == '\000')
351 norm_file_part = g_utf8_normalize (chooser_entry->file_part, -1, G_NORMALIZE_ALL);
352 norm_name = g_utf8_normalize (name, -1, G_NORMALIZE_ALL);
354 result = (strncmp (norm_file_part, norm_name, strlen (norm_file_part)) == 0);
356 g_free (norm_file_part);
363 /* This function will append a '/' character to paths to display_name iff the
364 * path associated with it is a directory. maybe_append_separator_to_path will
365 * g_free the display_name and return a new one if needed. Otherwise, it will
366 * return the old one. You should be safe calling
368 * display_name = maybe_append_separator_to_path (entry, path, display_name);
370 * g_free (display_name);
373 maybe_append_separator_to_path (GtkFileChooserEntry *chooser_entry,
381 info = gtk_file_folder_get_info (chooser_entry->current_folder,
382 path, NULL); /* NULL-GError */
386 if (gtk_file_info_get_is_folder (info))
388 gchar *tmp = display_name;
389 display_name = g_strconcat (tmp, "/", NULL);
393 gtk_file_info_free (info);
402 check_completion_callback (GtkFileChooserEntry *chooser_entry)
405 gchar *common_prefix = NULL;
406 GtkFilePath *unique_path = NULL;
409 g_assert (chooser_entry->file_part);
411 chooser_entry->check_completion_idle = NULL;
413 if (strcmp (chooser_entry->file_part, "") == 0)
416 if (chooser_entry->completion_store == NULL)
419 valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (chooser_entry->completion_store),
427 gtk_tree_model_get (GTK_TREE_MODEL (chooser_entry->completion_store),
429 DISPLAY_NAME_COLUMN, &display_name,
433 if (g_str_has_prefix (display_name, chooser_entry->file_part))
437 common_prefix = g_strdup (display_name);
438 unique_path = gtk_file_path_copy (path);
442 gchar *p = common_prefix;
443 const gchar *q = display_name;
445 while (*p && *p == *q)
453 gtk_file_path_free (unique_path);
458 g_free (display_name);
459 valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (chooser_entry->completion_store),
465 common_prefix = maybe_append_separator_to_path (chooser_entry,
468 gtk_file_path_free (unique_path);
475 gint common_prefix_len;
478 total_len = g_utf8_strlen (gtk_entry_get_text (GTK_ENTRY (chooser_entry)), -1);
479 file_part_len = g_utf8_strlen (chooser_entry->file_part, -1);
480 common_prefix_len = g_utf8_strlen (common_prefix, -1);
482 if (common_prefix_len > file_part_len)
484 pos = total_len - file_part_len;
486 chooser_entry->in_change = TRUE;
487 gtk_editable_delete_text (GTK_EDITABLE (chooser_entry),
489 gtk_editable_insert_text (GTK_EDITABLE (chooser_entry),
492 gtk_editable_select_region (GTK_EDITABLE (chooser_entry),
494 total_len - file_part_len + common_prefix_len);
495 chooser_entry->in_change = FALSE;
497 chooser_entry->has_completion = TRUE;
500 g_free (common_prefix);
507 add_completion_idle (GtkFileChooserEntry *chooser_entry)
509 /* idle to update the selection based on the file list */
510 if (chooser_entry->check_completion_idle == NULL)
512 chooser_entry->check_completion_idle = g_idle_source_new ();
513 g_source_set_priority (chooser_entry->check_completion_idle, G_PRIORITY_HIGH);
514 g_source_set_closure (chooser_entry->check_completion_idle,
515 g_cclosure_new_object (G_CALLBACK (check_completion_callback),
516 G_OBJECT (chooser_entry)));
517 g_source_attach (chooser_entry->check_completion_idle, NULL);
523 update_current_folder_files (GtkFileChooserEntry *chooser_entry,
528 g_assert (chooser_entry->completion_store != NULL);
530 /* Bah. Need to turn off sorting */
531 for (tmp_list = added_uris; tmp_list; tmp_list = tmp_list->next)
536 path = tmp_list->data;
538 info = gtk_file_folder_get_info (chooser_entry->current_folder,
540 NULL); /* NULL-GError */
543 const gchar *display_name = gtk_file_info_get_display_name (info);
546 gtk_list_store_append (chooser_entry->completion_store, &iter);
547 gtk_list_store_set (chooser_entry->completion_store, &iter,
548 DISPLAY_NAME_COLUMN, display_name,
552 gtk_file_info_free (info);
556 /* FIXME: we want to turn off sorting temporarily. I suck... */
557 gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (chooser_entry->completion_store),
558 DISPLAY_NAME_COLUMN, GTK_SORT_ASCENDING);
560 add_completion_idle (chooser_entry);
564 files_added_cb (GtkFileSystem *file_system,
566 GtkFileChooserEntry *chooser_entry)
568 update_current_folder_files (chooser_entry, added_uris);
572 files_deleted_cb (GtkFileSystem *file_system,
573 GSList *deleted_uris,
574 GtkFileChooserEntry *chooser_entry)
576 /* FIXME: gravy... */
580 load_directory_callback (GtkFileChooserEntry *chooser_entry)
582 GSList *child_paths = NULL;
584 chooser_entry->load_directory_idle = NULL;
586 /* guard against bogus settings*/
587 if (chooser_entry->current_folder_path == NULL ||
588 chooser_entry->file_system == NULL)
591 if (chooser_entry->current_folder != NULL)
593 g_warning ("idle activate multiple times without clearing the folder object first.");
596 g_assert (chooser_entry->completion_store == NULL);
598 /* Load the folder */
599 chooser_entry->current_folder = gtk_file_system_get_folder (chooser_entry->file_system,
600 chooser_entry->current_folder_path,
601 GTK_FILE_INFO_DISPLAY_NAME | GTK_FILE_INFO_IS_FOLDER,
602 NULL); /* NULL-GError */
604 /* There is no folder by that name */
605 if (!chooser_entry->current_folder)
607 g_signal_connect (chooser_entry->current_folder, "files-added",
608 G_CALLBACK (files_added_cb), chooser_entry);
609 g_signal_connect (chooser_entry->current_folder, "files-removed",
610 G_CALLBACK (files_deleted_cb), chooser_entry);
612 gtk_file_folder_list_children (chooser_entry->current_folder,
614 NULL); /* NULL-GError */
615 chooser_entry->completion_store = gtk_list_store_new (N_COLUMNS,
621 update_current_folder_files (chooser_entry, child_paths);
622 add_completion_idle (chooser_entry);
623 gtk_file_paths_free (child_paths);
626 gtk_entry_completion_set_model (gtk_entry_get_completion (GTK_ENTRY (chooser_entry)),
627 GTK_TREE_MODEL (chooser_entry->completion_store));
632 gtk_file_chooser_entry_do_insert_text (GtkEditable *editable,
633 const gchar *new_text,
634 gint new_text_length,
637 GtkFileChooserEntry *chooser_entry = GTK_FILE_CHOOSER_ENTRY (editable);
639 parent_editable_iface->do_insert_text (editable, new_text, new_text_length, position);
641 if (! chooser_entry->in_change)
642 add_completion_idle (GTK_FILE_CHOOSER_ENTRY (editable));
646 gtk_file_chooser_entry_focus (GtkWidget *widget,
647 GtkDirectionType direction)
649 GtkFileChooserEntry *chooser_entry = GTK_FILE_CHOOSER_ENTRY (widget);
650 GdkModifierType state;
651 gboolean control_pressed = FALSE;
653 if (gtk_get_current_event_state (&state))
655 if ((state & GDK_CONTROL_MASK) == GDK_CONTROL_MASK)
656 control_pressed = TRUE;
659 /* This is a bit evil -- it makes Tab never leave the entry. It basically
660 * makes it 'safe' for people to hit. */
661 if ((direction == GTK_DIR_TAB_FORWARD) &&
662 (GTK_WIDGET_HAS_FOCUS (widget)) &&
665 if (chooser_entry->has_completion)
667 gtk_editable_set_position (GTK_EDITABLE (widget),
668 GTK_ENTRY (widget)->text_length);
673 return GTK_WIDGET_CLASS (parent_class)->focus (widget, direction);
677 gtk_file_chooser_entry_activate (GtkEntry *entry)
679 GtkFileChooserEntry *chooser_entry = GTK_FILE_CHOOSER_ENTRY (entry);
681 if (chooser_entry->has_completion)
683 gtk_editable_set_position (GTK_EDITABLE (entry),
687 GTK_ENTRY_CLASS (parent_class)->activate (entry);
690 /* This will see if a path typed by the user is new, and installs the loading
694 gtk_file_chooser_entry_maybe_update_directory (GtkFileChooserEntry *chooser_entry,
695 GtkFilePath *folder_path)
697 gboolean queue_idle = FALSE;
699 if (chooser_entry->current_folder_path)
701 if (gtk_file_path_compare (folder_path, chooser_entry->current_folder_path) != 0)
703 /* We changed our current directory. We need to clear out the old
704 * directory information.
706 if (chooser_entry->current_folder)
708 g_signal_handlers_disconnect_by_func (chooser_entry->current_folder,
709 G_CALLBACK (files_added_cb), chooser_entry);
710 g_signal_handlers_disconnect_by_func (chooser_entry->current_folder,
711 G_CALLBACK (files_deleted_cb), chooser_entry);
713 g_object_unref (chooser_entry->current_folder);
714 chooser_entry->current_folder = NULL;
716 if (chooser_entry->completion_store)
718 gtk_list_store_clear (GTK_LIST_STORE (chooser_entry->completion_store));
719 /* FIXME: Uncomment this line and get rid of the _clear above
720 * after #137211 is fixed */
721 /* gtk_entry_completion_set_model (gtk_entry_get_completion (GTK_ENTRY (chooser_entry)), NULL);*/
722 g_object_unref (chooser_entry->completion_store);
723 chooser_entry->completion_store = NULL;
729 gtk_file_path_free (chooser_entry->current_folder_path);
736 chooser_entry->current_folder_path = folder_path;
738 if (queue_idle && chooser_entry->load_directory_idle == NULL)
740 chooser_entry->load_directory_idle = g_idle_source_new ();
741 g_source_set_priority (chooser_entry->load_directory_idle, G_PRIORITY_HIGH);
742 g_source_set_closure (chooser_entry->load_directory_idle,
743 g_cclosure_new_object (G_CALLBACK (load_directory_callback),
744 G_OBJECT (chooser_entry)));
745 g_source_attach (chooser_entry->load_directory_idle, NULL);
752 gtk_file_chooser_entry_changed (GtkEditable *editable)
754 GtkFileChooserEntry *chooser_entry = GTK_FILE_CHOOSER_ENTRY (editable);
756 GtkFilePath *folder_path;
759 if (chooser_entry->in_change)
762 text = gtk_entry_get_text (GTK_ENTRY (editable));
764 if (!chooser_entry->file_system ||
765 !chooser_entry->base_folder ||
766 !gtk_file_system_parse (chooser_entry->file_system,
767 chooser_entry->base_folder, text,
768 &folder_path, &file_part, NULL)) /* NULL-GError */
770 folder_path = gtk_file_path_copy (chooser_entry->base_folder);
771 file_part = g_strdup ("");
774 gtk_file_chooser_entry_maybe_update_directory (chooser_entry, folder_path);
776 if (chooser_entry->file_part)
777 g_free (chooser_entry->file_part);
779 chooser_entry->file_part = file_part;
783 clear_completion_callback (GtkFileChooserEntry *chooser_entry,
786 if (chooser_entry->has_completion)
788 chooser_entry->has_completion = FALSE;
789 gtk_file_chooser_entry_changed (GTK_EDITABLE (chooser_entry));
791 chooser_entry->no_pop_down = FALSE;
795 * _gtk_file_chooser_entry_new:
797 * Creates a new #GtkFileChooserEntry object. #GtkFileChooserEntry
798 * is an internal implementation widget for the GTK+ file chooser
799 * which is an entry with completion with respect to a
800 * #GtkFileSystem object.
802 * Return value: the newly created #GtkFileChooserEntry
805 _gtk_file_chooser_entry_new (void)
807 return g_object_new (GTK_TYPE_FILE_CHOOSER_ENTRY, NULL);
811 * _gtk_file_chooser_entry_set_file_system:
812 * @chooser_entry: a #GtkFileChooser
813 * @file_system: an object implementing #GtkFileSystem
815 * Sets the file system for @chooser_entry.
818 _gtk_file_chooser_entry_set_file_system (GtkFileChooserEntry *chooser_entry,
819 GtkFileSystem *file_system)
821 g_return_if_fail (GTK_IS_FILE_CHOOSER_ENTRY (chooser_entry));
822 g_return_if_fail (GTK_IS_FILE_SYSTEM (file_system));
824 if (file_system != chooser_entry->file_system)
826 if (chooser_entry->file_system)
827 g_object_unref (chooser_entry->file_system);
829 chooser_entry->file_system = g_object_ref (file_system);
834 * _gtk_file_chooser_entry_set_base_folder:
835 * @chooser_entry: a #GtkFileChooserEntry
836 * @path: path of a folder in the chooser entries current file system.
838 * Sets the folder with respect to which completions occur.
841 _gtk_file_chooser_entry_set_base_folder (GtkFileChooserEntry *chooser_entry,
842 const GtkFilePath *path)
844 if (chooser_entry->base_folder)
845 gtk_file_path_free (chooser_entry->base_folder);
847 chooser_entry->base_folder = gtk_file_path_copy (path);
849 gtk_editable_select_region (GTK_EDITABLE (chooser_entry), 0, -1);
853 * _gtk_file_chooser_entry_get_current_folder:
854 * @chooser_entry: a #GtkFileChooserEntry
856 * Gets the current folder for the #GtkFileChooserEntry. If the
857 * user has only entered a filename, this will be the base folder
858 * (see _gtk_file_chooser_entry_set_base_folder()), but if the
859 * user has entered a relative or absolute path, then it will
860 * be different. If the user has entered a relative or absolute
861 * path that doesn't point to a folder in the file system, it will
864 * Return value: the path of current folder - this value is owned by the
865 * chooser entry and must not be modified or freed.
868 _gtk_file_chooser_entry_get_current_folder (GtkFileChooserEntry *chooser_entry)
870 return chooser_entry->current_folder_path;
874 * _gtk_file_chooser_entry_get_file_part:
875 * @chooser_entry: a #GtkFileChooserEntry
877 * Gets the non-folder portion of whatever the user has entered
878 * into the file selector. What is returned is a UTF-8 string,
879 * and if a filename path is needed, gtk_file_system_make_path()
882 * Return value: the entered filename - this value is owned by the
883 * chooser entry and must not be modified or freed.
886 _gtk_file_chooser_entry_get_file_part (GtkFileChooserEntry *chooser_entry)
888 return chooser_entry->file_part;
892 * _gtk_file_chooser_entry_set_file_part:
893 * @chooser_entry: a #GtkFileChooserEntry
894 * @file_part: text to display in the entry, in UTF-8
896 * Sets the current text shown in the file chooser entry.
899 _gtk_file_chooser_entry_set_file_part (GtkFileChooserEntry *chooser_entry,
900 const gchar *file_part)
902 g_return_if_fail (GTK_IS_FILE_CHOOSER_ENTRY (chooser_entry));
904 gtk_entry_set_text (GTK_ENTRY (chooser_entry), file_part);