From ea43778291132392279d590e1b07f9e3ce79b447 Mon Sep 17 00:00:00 2001 From: Jean Sirmai Date: Fri, 24 Nov 2023 16:50:51 +0100 Subject: [PATCH] WIP: (micro) adding : void onTreeViewRowActivated(). --- include/ui.h | 2 ++ src/ui/tree.c | 39 ++++++++++++++++++++++++++++++++++++--- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/include/ui.h b/include/ui.h index 6b4dd5c..d595d32 100644 --- a/include/ui.h +++ b/include/ui.h @@ -118,5 +118,7 @@ void ui_send_internal_notification (const char *message); void ui_close_internal_notification (void); void ui_toggle_sidebar (); +void onTreeViewRowActivated (GtkTreeView *view, GtkTreePath *path, + GtkTreeViewColumn *col, gpointer userdata); void tree_c_printing_test(void); diff --git a/src/ui/tree.c b/src/ui/tree.c index f8265ae..20f174b 100644 --- a/src/ui/tree.c +++ b/src/ui/tree.c @@ -30,14 +30,47 @@ GtkListStore *list_store; + /************************************************************* + * * + * Converting a GtkTreePath into a GtkTreeIter * + * * + *************************************************************/ -void tree_c_printing_test(void) + /************************************************************* + * * + * onTreeViewRowActivated: a row has been double-clicked * + * * + *************************************************************/ + +void +onTreeViewRowActivated (GtkTreeView *view, GtkTreePath *path, + GtkTreeViewColumn *col, gpointer userdata) +{ + GtkTreeIter iter; + GtkTreeModel *model; + + model = gtk_tree_view_get_model(view); + + if (gtk_tree_model_get_iter(model, &iter, path)) + { + gchar *name; + + gtk_tree_model_get(model, &iter, "ANY_COLUMN_NAME", &name, -1); + + g_print ("The row containing the name '%s' has been double-clicked.\n", name); + + g_free(name); + } +} + +void +tree_c_printing_test(void) { list_store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_UINT); printf("tree_c_printing_test() \ -------------------------------------------------------\n\n\ -trying : https://en.wikibooks.org/wiki/GTK\%\2B_By_Example/Tree_View/Tree_Models\n\n\ +---------------------------------------------------------\n\n\ +(https://en.wikibooks.org/wiki/GTK (modulo) 2B_By_Example/Tree_View/Tree_Models)\n\n\ cf. tuto : This creates a new list store with two columns.\n\ Column 0 stores a string and column 1 stores an unsigned integer for each row.\n\ At this point the model has no rows yet of course.\n");