Branch: refs/heads/master Author: Jiří Techet techet@gmail.com Committer: Jiří Techet techet@gmail.com Date: Sun, 07 May 2023 21:27:13 UTC Commit: f822e69395f88a9c7df7139e2ced19d8486011ca https://github.com/geany/geany-plugins/commit/f822e69395f88a9c7df7139e2ced19...
Log Message: ----------- projectorganizer: Use gchar** instead of GPtrArray to simplify code
Modified Paths: -------------- projectorganizer/src/prjorg-main.c projectorganizer/src/prjorg-project.c projectorganizer/src/prjorg-sidebar.c projectorganizer/src/prjorg-sidebar.h
Modified: projectorganizer/src/prjorg-main.c 1 lines changed, 0 insertions(+), 1 deletions(-) =================================================================== @@ -136,7 +136,6 @@ static void on_project_open(G_GNUC_UNUSED GObject * obj, GKeyFile * config, prjorg_sidebar_update_full(TRUE, arr); prjorg_sidebar_activate(TRUE); prjorg_menu_activate_menu_items(TRUE); - g_strfreev(arr); } }
Modified: projectorganizer/src/prjorg-project.c 12 lines changed, 3 insertions(+), 9 deletions(-) =================================================================== @@ -380,17 +380,11 @@ static void update_project(
static void save_expanded_paths(GKeyFile * key_file) { - GPtrArray *expanded_paths = prjorg_sidebar_get_expanded_paths(); - gchar **expanded_paths_v = g_new (gchar *, expanded_paths->len + 1); - guint i; + gchar **expanded_paths = prjorg_sidebar_get_expanded_paths();
- for (i = 0; i < expanded_paths->len; i++) - expanded_paths_v[i] = expanded_paths->pdata[i]; - expanded_paths_v[expanded_paths->len] = NULL; g_key_file_set_string_list(key_file, "prjorg", "expanded_paths", - (const gchar**) expanded_paths_v, g_strv_length(expanded_paths_v)); - g_free(expanded_paths_v); - g_ptr_array_free(expanded_paths, TRUE); + (const gchar**) expanded_paths, g_strv_length(expanded_paths)); + g_strfreev(expanded_paths); }
Modified: projectorganizer/src/prjorg-sidebar.c 28 lines changed, 10 insertions(+), 18 deletions(-) =================================================================== @@ -51,7 +51,7 @@ typedef enum typedef struct { GeanyProject *project; - GPtrArray *expanded_paths; + gchar **expanded_paths; gchar *selected_path; } ExpandData;
@@ -1496,12 +1496,10 @@ static gboolean expand_on_idle(ExpandData *expand_data) if (geany_data->app->project == expand_data->project && expand_data->expanded_paths) { - gchar *item; - guint i; - - foreach_ptr_array(item, i, expand_data->expanded_paths) - expand_path(item, FALSE); - g_ptr_array_free(expand_data->expanded_paths, TRUE); + gchar **item; + foreach_strv(item, expand_data->expanded_paths) + expand_path(*item, FALSE); + g_strfreev(expand_data->expanded_paths); }
if (expand_data->selected_path) @@ -1556,14 +1554,15 @@ static void on_map_expanded(GtkTreeView *tree_view, GtkTreePath *tree_path, GPtr }
-GPtrArray *prjorg_sidebar_get_expanded_paths(void) +gchar **prjorg_sidebar_get_expanded_paths(void) { - GPtrArray *expanded_paths = g_ptr_array_new_with_free_func(g_free); + GPtrArray *expanded_paths = g_ptr_array_new();
gtk_tree_view_map_expanded_rows(GTK_TREE_VIEW(s_file_view), (GtkTreeViewMappingFunc)on_map_expanded, expanded_paths); + g_ptr_array_add(expanded_paths, NULL);
- return expanded_paths; + return g_ptr_array_free(expanded_paths, FALSE); }
@@ -1591,15 +1590,8 @@ void prjorg_sidebar_update_full(gboolean reload, gchar **expanded_paths) GtkTreeSelection *treesel; GtkTreeIter iter; GtkTreeModel *model; - gchar **path; - GPtrArray *exp_paths_arr = g_ptr_array_new(); - - foreach_strv (path, expanded_paths) - { - g_ptr_array_add(exp_paths_arr, g_strdup(*path)); - }
- expand_data->expanded_paths = expanded_paths != NULL ? exp_paths_arr : prjorg_sidebar_get_expanded_paths(); + expand_data->expanded_paths = expanded_paths != NULL ? expanded_paths : prjorg_sidebar_get_expanded_paths(); expand_data->selected_path = get_selected_path();
load_project();
Modified: projectorganizer/src/prjorg-sidebar.h 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -32,7 +32,7 @@ void prjorg_sidebar_update_full(gboolean reload, gchar **expanded_paths);
void prjorg_sidebar_focus_project_tab(void);
-GPtrArray *prjorg_sidebar_get_expanded_paths(void); +gchar **prjorg_sidebar_get_expanded_paths(void);
void on_open_file_manager(G_GNUC_UNUSED GtkMenuItem * menuitem, G_GNUC_UNUSED gpointer user_data); void on_open_terminal(G_GNUC_UNUSED GtkMenuItem * menuitem, G_GNUC_UNUSED gpointer user_data);
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
plugins-commits@lists.geany.org