[geany/geany] 83f261: filebrowser: Add a flag to the tree model to indicate whether en entry is a directory
Jiří Techet
git-noreply at xxxxx
Thu Jun 18 14:53:52 UTC 2015
Branch: refs/heads/master
Author: Jiří Techet <techet at gmail.com>
Committer: Jiří Techet <techet at gmail.com>
Date: Tue, 14 Apr 2015 21:49:22 UTC
Commit: 83f261fd64b1a1e53782aee4b9ce9970696d3f81
https://github.com/geany/geany/commit/83f261fd64b1a1e53782aee4b9ce9970696d3f81
Log Message:
-----------
filebrowser: Add a flag to the tree model to indicate whether en entry is a directory
Used by the subsequent patch which changes "stock-id" to GIcon and
disables row type detection using FILEVIEW_COLUMN_ICON.
Modified Paths:
--------------
plugins/filebrowser.c
Modified: plugins/filebrowser.c
24 lines changed, 10 insertions(+), 14 deletions(-)
===================================================================
@@ -68,6 +68,7 @@ enum
FILEVIEW_COLUMN_ICON = 0,
FILEVIEW_COLUMN_NAME,
FILEVIEW_COLUMN_FILENAME, /* the full filename, including path for display as tooltip */
+ FILEVIEW_COLUMN_IS_DIR,
FILEVIEW_N_COLUMNS
};
@@ -230,6 +231,7 @@ static void add_item(const gchar *name)
FILEVIEW_COLUMN_ICON, (dir) ? GTK_STOCK_DIRECTORY : GTK_STOCK_FILE,
FILEVIEW_COLUMN_NAME, utf8_name,
FILEVIEW_COLUMN_FILENAME, utf8_fullname,
+ FILEVIEW_COLUMN_IS_DIR, dir,
-1);
done:
g_free(utf8_name);
@@ -256,6 +258,7 @@ static void add_top_level_entry(void)
FILEVIEW_COLUMN_ICON, GTK_STOCK_DIRECTORY,
FILEVIEW_COLUMN_NAME, "..",
FILEVIEW_COLUMN_FILENAME, utf8_dir,
+ FILEVIEW_COLUMN_IS_DIR, TRUE,
-1);
g_free(utf8_dir);
}
@@ -386,21 +389,15 @@ static gboolean is_folder_selected(GList *selected_items)
for (item = selected_items; item != NULL; item = g_list_next(item))
{
- gchar *icon;
GtkTreeIter iter;
GtkTreePath *treepath;
treepath = (GtkTreePath*) item->data;
gtk_tree_model_get_iter(model, &iter, treepath);
- gtk_tree_model_get(model, &iter, FILEVIEW_COLUMN_ICON, &icon, -1);
+ gtk_tree_model_get(model, &iter, FILEVIEW_COLUMN_IS_DIR, &dir_found, -1);
- if (utils_str_equal(icon, GTK_STOCK_DIRECTORY))
- {
- dir_found = TRUE;
- g_free(icon);
+ if (dir_found)
break;
- }
- g_free(icon);
}
return dir_found;
}
@@ -829,7 +826,7 @@ static void prepare_file_view(void)
GtkTreeViewColumn *column;
GtkTreeSelection *selection;
- file_store = gtk_list_store_new(FILEVIEW_N_COLUMNS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
+ file_store = gtk_list_store_new(FILEVIEW_N_COLUMNS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN);
gtk_tree_view_set_model(GTK_TREE_VIEW(file_view), GTK_TREE_MODEL(file_store));
g_object_unref(file_store);
@@ -925,14 +922,14 @@ static GtkWidget *make_filterbar(void)
static gboolean completion_match_func(GtkEntryCompletion *completion, const gchar *key,
GtkTreeIter *iter, gpointer user_data)
{
- gchar *str, *icon;
+ gchar *str;
+ gboolean is_dir;
gboolean result = FALSE;
gtk_tree_model_get(GTK_TREE_MODEL(file_store), iter,
- FILEVIEW_COLUMN_ICON, &icon, FILEVIEW_COLUMN_NAME, &str, -1);
+ FILEVIEW_COLUMN_IS_DIR, &is_dir, FILEVIEW_COLUMN_NAME, &str, -1);
- if (str != NULL && icon != NULL && utils_str_equal(icon, GTK_STOCK_DIRECTORY) &&
- ! g_str_has_suffix(key, G_DIR_SEPARATOR_S))
+ if (str != NULL && is_dir && !g_str_has_suffix(key, G_DIR_SEPARATOR_S))
{
/* key is something like "/tmp/te" and str is a filename like "test",
* so strip the path from key to make them comparable */
@@ -943,7 +940,6 @@ static gboolean completion_match_func(GtkEntryCompletion *completion, const gcha
g_free(str_lowered);
}
g_free(str);
- g_free(icon);
return result;
}
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
More information about the Commits
mailing list