summaryrefslogtreecommitdiff
path: root/gtk/gtkfilechooserentry.c
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2011-11-05 22:31:40 +0100
committerBenjamin Otte <otte@redhat.com>2011-12-16 20:09:12 +0100
commitcde8ae7b1ec232d36933c5bca4e60432d00e9469 (patch)
tree099e8385aa6bf24308aab6511553835e5192fbe3 /gtk/gtkfilechooserentry.c
parentfc775dfa5be74efba4cee9a80f67a802e9c98121 (diff)
downloadgtk+-cde8ae7b1ec232d36933c5bca4e60432d00e9469.tar.gz
filechooserentry: Keep an extra column for the full path
This is identical to the display name when not having a path that changes the folder. Otherwise it will have the full path that was entered in the entry. Say when from your home dir, you type "../../usr/li", the full path for "lib" and "lib64" will be "../../usr/lib" and "../../usr/lib64" respectively. This value isn't used yet, but will be soon.
Diffstat (limited to 'gtk/gtkfilechooserentry.c')
-rw-r--r--gtk/gtkfilechooserentry.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/gtk/gtkfilechooserentry.c b/gtk/gtkfilechooserentry.c
index a14116e907..fc2900b9b8 100644
--- a/gtk/gtkfilechooserentry.c
+++ b/gtk/gtkfilechooserentry.c
@@ -69,6 +69,7 @@ struct _GtkFileChooserEntry
GFile *base_folder;
GFile *current_folder_file;
+ gchar *dir_part;
gchar *file_part;
gint file_part_pos;
@@ -90,6 +91,7 @@ struct _GtkFileChooserEntry
enum
{
DISPLAY_NAME_COLUMN,
+ FULL_PATH_COLUMN,
FILE_COLUMN,
N_COLUMNS
};
@@ -242,6 +244,7 @@ gtk_file_chooser_entry_finalize (GObject *object)
if (chooser_entry->current_folder_file)
g_object_unref (chooser_entry->current_folder_file);
+ g_free (chooser_entry->dir_part);
g_free (chooser_entry->file_part);
G_OBJECT_CLASS (_gtk_file_chooser_entry_parent_class)->finalize (object);
@@ -1294,16 +1297,28 @@ completion_store_set (GtkFileSystemModel *model,
GValue *value,
gpointer data)
{
+ GtkFileChooserEntry *chooser_entry = data;
+
+ const char *prefix = "";
+ const char *suffix = "";
+
switch (column)
{
case FILE_COLUMN:
g_value_set_object (value, file);
break;
+ case FULL_PATH_COLUMN:
+ prefix = chooser_entry->dir_part;
+ /* fall through */
case DISPLAY_NAME_COLUMN:
if (_gtk_file_info_consider_as_directory (info))
- g_value_take_string (value, g_strconcat (g_file_info_get_display_name (info), G_DIR_SEPARATOR_S, NULL));
- else
- g_value_set_string (value, g_file_info_get_display_name (info));
+ suffix = G_DIR_SEPARATOR_S;
+
+ g_value_take_string (value, g_strconcat (
+ prefix,
+ g_file_info_get_display_name (info),
+ suffix,
+ NULL));
break;
default:
g_assert_not_reached ();
@@ -1326,6 +1341,7 @@ populate_completion_store (GtkFileChooserEntry *chooser_entry)
chooser_entry,
N_COLUMNS,
G_TYPE_STRING,
+ G_TYPE_STRING,
G_TYPE_FILE));
g_signal_connect (chooser_entry->completion_store, "finished-loading",
G_CALLBACK (finished_loading_cb), chooser_entry);
@@ -1493,13 +1509,15 @@ refresh_current_folder_and_file_part (GtkFileChooserEntry *chooser_entry,
result = REFRESH_OK;
}
- g_free (text);
-
g_free (chooser_entry->file_part);
+ g_free (chooser_entry->dir_part);
+ chooser_entry->dir_part = file_part_pos > 0 ? g_strndup (text, file_part_pos) : g_strdup ("");
chooser_entry->file_part = file_part;
chooser_entry->file_part_pos = file_part_pos;
+ g_free (text);
+
if (result == REFRESH_OK)
{
result = reload_current_folder (chooser_entry, folder_file);