Branch: refs/heads/master Author: Colomban Wendling ban@herbesfolles.org Committer: Colomban Wendling ban@herbesfolles.org Date: Wed, 10 Sep 2014 17:52:03 UTC Commit: bdb5077e6f579e2b438b61b13c9ad9c16419fa98 https://github.com/geany/geany-plugins/commit/bdb5077e6f579e2b438b61b13c9ad9...
Log Message: ----------- commander: Add debug code for displaying the row score
This comes real handy when working on the sort algorithm to see the actual score it gave to each row.
Modified Paths: -------------- commander/src/commander-plugin.c
Modified: commander/src/commander-plugin.c 49 lines changed, 49 insertions(+), 0 deletions(-) =================================================================== @@ -28,6 +28,10 @@ #include <geanyplugin.h>
+/* uncomment to display each row score (for debugging sort) */ +/*#define DISPLAY_SCORE 1*/ + + GeanyPlugin *geany_plugin; GeanyData *geany_data; GeanyFunctions *geany_functions; @@ -586,6 +590,44 @@ on_view_row_activated (GtkTreeView *view, } }
+#ifdef DISPLAY_SCORE +static void +score_cell_data (GtkTreeViewColumn *column, + GtkCellRenderer *cell, + GtkTreeModel *model, + GtkTreeIter *iter, + gpointer col) +{ + gint score; + gchar *text; + gchar *path; + gint pathtype; + gint type; + gint width, old_width; + const gchar *key = get_key (&type); + + gtk_tree_model_get (model, iter, COL_PATH, &path, COL_TYPE, &pathtype, -1); + + score = key_score (key, path); + if (! (pathtype & type)) { + score -= 0xf000; + } + + text = g_strdup_printf ("%d", score); + g_object_set (cell, "text", text, NULL); + + /* automatic column sizing is buggy, so just make an acceptable wild guess */ + width = 8 + strlen (text) * 10; + old_width = gtk_tree_view_column_get_fixed_width (col); + if (old_width < width) { + gtk_tree_view_column_set_fixed_width (col, width); + } + + g_free (text); + g_free (path); +} +#endif + static void create_panel (void) { @@ -649,6 +691,13 @@ create_panel (void) plugin_data.view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (plugin_data.sort)); gtk_widget_set_can_focus (plugin_data.view, FALSE); gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (plugin_data.view), FALSE); +#ifdef DISPLAY_SCORE + cell = gtk_cell_renderer_text_new (); + col = gtk_tree_view_column_new_with_attributes (NULL, cell, NULL); + gtk_tree_view_column_set_sizing (col, GTK_TREE_VIEW_COLUMN_FIXED); + gtk_tree_view_column_set_cell_data_func(col, cell, score_cell_data, col, NULL); + gtk_tree_view_append_column (GTK_TREE_VIEW (plugin_data.view), col); +#endif cell = gtk_cell_renderer_text_new (); g_object_set (cell, "ellipsize", PANGO_ELLIPSIZE_END, NULL); col = gtk_tree_view_column_new_with_attributes (NULL, cell,
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
plugins-commits@lists.geany.org