static void gs_cmd_show_results_categories (GPtrArray *list) { GPtrArray *subcats; GsCategory *cat; GsCategory *parent; guint i; for (i = 0; i < list->len; i++) { g_autofree gchar *tmp = NULL; cat = GS_CATEGORY (g_ptr_array_index (list, i)); parent = gs_category_get_parent (cat); if (parent != NULL){ g_autofree gchar *id = NULL; id = g_strdup_printf ("%s/%s [%u]", gs_category_get_id (parent), gs_category_get_id (cat), gs_category_get_size (cat)); tmp = gs_cmd_pad_spaces (id, 32); g_print ("%s : %s\n", tmp, gs_category_get_name (cat)); } else { tmp = gs_cmd_pad_spaces (gs_category_get_id (cat), 32); g_print ("%s : %s\n", tmp, gs_category_get_name (cat)); subcats = gs_category_get_children (cat); gs_cmd_show_results_categories (subcats); } } }
/** * gs_cmd_show_results_categories: **/ static void gs_cmd_show_results_categories (GList *list) { GList *l; GList *subcats; GsCategory *cat; GsCategory *parent; for (l = list; l != NULL; l = l->next) { _cleanup_free_ gchar *tmp = NULL; cat = GS_CATEGORY (l->data); parent = gs_category_get_parent (cat); if (parent != NULL){ _cleanup_free_ gchar *id = NULL; id = g_strdup_printf ("%s/%s", gs_category_get_id (parent), gs_category_get_id (cat)); tmp = gs_cmd_pad_spaces (id, 32); g_print ("%s : %s\n", tmp, gs_category_get_name (cat)); } else { tmp = gs_cmd_pad_spaces (gs_category_get_id (cat), 32); g_print ("%s : %s\n", tmp, gs_category_get_name (cat)); subcats = gs_category_get_subcategories (cat); gs_cmd_show_results_categories (subcats); } } }