From fdc87782c666ae08d95c81e171b8cad52b45d793 Mon Sep 17 00:00:00 2001 From: Jean Sirmai Date: Sat, 25 Nov 2023 10:29:08 +0100 Subject: [PATCH] WIP: Trying to copy the first example of the tuto (this commit lists what I'm unable to adapt) --- src/main.c | 10 ++++++++++ src/ui/application.c | 2 ++ src/ui/tree.c | 32 +++++++++++++++++++++++--------- 3 files changed, 35 insertions(+), 9 deletions(-) diff --git a/src/main.c b/src/main.c index 8e0a417..8254e07 100644 --- a/src/main.c +++ b/src/main.c @@ -32,6 +32,16 @@ int main(int argc, char **argv) { + GtkWidget *window; + GtkWidget *view; + gtk_init(); + // window = gtk_window_new(GTK_WINDOW_TOPLEVEL); + // g_signal_connect(window, "delete_event", gtk_main_quit, NULL); /* dirty */ + g_signal_connect(window, "delete_event", NULL, NULL); /* dirty */ + // view = create_view_and_model(); + // gtk_container_add(GTK_CONTAINER(window), view); + // gtk_widget_show_all(window); + // gtk_main(); tree_c_test(); diff --git a/src/ui/application.c b/src/ui/application.c index 6312982..5ca6a05 100644 --- a/src/ui/application.c +++ b/src/ui/application.c @@ -135,6 +135,8 @@ static void gem_graph_client_application_class_init( app_class->activate = gem_graph_client_application_activate; } + + GemGraphClientApplication *gem_graph_client_application_new( const char *application_id, GApplicationFlags flags) diff --git a/src/ui/tree.c b/src/ui/tree.c index 3c93c5f..7fe5d1b 100644 --- a/src/ui/tree.c +++ b/src/ui/tree.c @@ -162,23 +162,37 @@ tree_c_test(void) } else g_error("Oops, we should have a first row in the tree store!\n"); + GtkTreeViewColumn *col; + GtkCellRenderer *renderer; + GtkWidget *view; + GtkTreeModel *model; + + GtkWidget *window; + + tree_c_printing_test(); } static void tree_c_printing_test(void) { printf("tree_c_printing_test() \ ----------------------------------------------------------\n\n\ -(https://en.wikibooks.org/wiki/GTK (modulo) 2B_By_Example/Tree_View/Tree_Models)\n\ -(https://en.wikibooks.org/wiki/GTK (modulo) 2B_By_Example/Tree_View/Columns_and_Renderer)\n\n\ -cf. tuto : gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_UINT); - (cf. line 69)\n\ - creates a new list store with two columns.\n\n\ - gtk_tree_store_new(1, G_TYPE_STRING); - (cf. line 108)\n\ - creates a new tree store with one column.\n\n\ -Now : how to display in our window (/panel) what was stored in these models ?.\n\ - (see the commented code at the end)\n"); +------------------------------------------------------------------\n\ +(https://en.wikibooks.org/wiki/GTK (modulo) 2B_By_Example/Tree_View/Columns_and_Renderer)\n\ +Trying to adapt the first example of this tuto to display a simple tree view in our window.\n\ +Can't use :\n\ + - gtk_init(&argc, &argv);\n\ + - window = gtk_tree_view_new(GTK_WINDOW_TOPLEVEL);\n\ + - g_signal_connect(window, 'delete_event', gtk_main_quit, NULL);\n\ + - tree_c_test(); (or : create_view_and_model() or some equivalent tree description)\n\ + - gtk_container_add(GTK_CONTAINER(window), view);\n\ + - gtk_widget_show_all(window);\n\ + - gtk_main();\n\ +(see main.c lines 35-44)\n\ +"); } +// https://en.wikibooks.org/wiki/GTK%2B_By_Example/Tree_View/Tree_Models + /* https://stackoverflow.com/questions/51002454/how-to-list-all-the-rows-of-a-gtk-treeview