[gtk+/gtk-2-24] filechooserentry: Keep an extra column for the full path
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gtk-2-24] filechooserentry: Keep an extra column for the full path
- Date: Thu, 10 Mar 2016 21:29:43 +0000 (UTC)
commit 83421a5f8ebe9dfc6bed03226ec99f6879e5b1cd
Author: Benjamin Otte <otte redhat com>
Date: Sat Nov 5 22:31:40 2011 +0100
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.
gtk/gtkfilechooserentry.c | 28 +++++++++++++++++++++++-----
1 files changed, 23 insertions(+), 5 deletions(-)
---
diff --git a/gtk/gtkfilechooserentry.c b/gtk/gtkfilechooserentry.c
index 3861601..cd3c5eb 100644
--- a/gtk/gtkfilechooserentry.c
+++ b/gtk/gtkfilechooserentry.c
@@ -72,6 +72,7 @@ struct _GtkFileChooserEntry
GFile *base_folder;
GFile *current_folder_file;
+ gchar *dir_part;
gchar *file_part;
gint file_part_pos;
@@ -93,6 +94,7 @@ struct _GtkFileChooserEntry
enum
{
DISPLAY_NAME_COLUMN,
+ FULL_PATH_COLUMN,
FILE_COLUMN,
N_COLUMNS
};
@@ -245,6 +247,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);
@@ -1292,16 +1295,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 ();
@@ -1324,6 +1339,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);
@@ -1491,13 +1507,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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]