Learning GTK4 Trees _ initial commit (+ simple loop)

This commit is contained in:
Jean Sirmai 2023-12-12 18:40:36 +01:00
parent a0c82f2ade
commit 1a02d93f20
Signed by: jean
GPG Key ID: FB3115C340E057E3
3 changed files with 46 additions and 42 deletions

View File

@ -21,7 +21,7 @@
#include <gtk/gtk.h>
#include <glib/gstdio.h>
#include "demos.h"
#include "demos.h" // la liste de toutes les démos
#include "fontify.h"
#include "demo_conf.h"
@ -914,51 +914,54 @@ activate (GApplication *app)
GtkFilter *filter;
GSimpleAction *action;
builder = gtk_builder_new_from_resource ("/ui/main.ui");
window = (GtkWidget *)gtk_builder_get_object (builder, "window");
window= do_tree_store(NULL);
gtk_application_add_window (GTK_APPLICATION (app), GTK_WINDOW (window));
if (g_strcmp0 (PROFILE, "devel") == 0)
gtk_widget_add_css_class (window, "devel");
/* builder = gtk_builder_new_from_resource ("/ui/main.ui"); */
action = g_simple_action_new ("run", NULL);
g_signal_connect (action, "activate", G_CALLBACK (activate_run), window);
g_action_map_add_action (G_ACTION_MAP (window), G_ACTION (action));
/* window = (GtkWidget *)gtk_builder_get_object (builder, "window"); */
/* gtk_application_add_window (GTK_APPLICATION (app), GTK_WINDOW (window)); */
notebook = GTK_WIDGET (gtk_builder_get_object (builder, "notebook"));
/* if (g_strcmp0 (PROFILE, "devel") == 0) */
/* gtk_widget_add_css_class (window, "devel"); */
info_view = GTK_WIDGET (gtk_builder_get_object (builder, "info-textview"));
source_view = GTK_WIDGET (gtk_builder_get_object (builder, "source-textview"));
toplevel = GTK_WIDGET (window);
listview = GTK_WIDGET (gtk_builder_get_object (builder, "listview"));
g_signal_connect (listview, "activate", G_CALLBACK (activate_cb), window);
search_bar = GTK_WIDGET (gtk_builder_get_object (builder, "searchbar"));
g_signal_connect (search_bar, "notify::search-mode-enabled", G_CALLBACK (clear_search), NULL);
/* action = g_simple_action_new ("run", NULL); */
/* g_signal_connect (action, "activate", G_CALLBACK (activate_run), window); */
/* g_action_map_add_action (G_ACTION_MAP (window), G_ACTION (action)); */
listmodel = create_demo_model ();
treemodel = gtk_tree_list_model_new (G_LIST_MODEL (listmodel),
FALSE,
TRUE,
get_child_model,
NULL,
NULL);
filter_model = gtk_filter_list_model_new (G_LIST_MODEL (treemodel), NULL);
filter = GTK_FILTER (gtk_custom_filter_new (demo_filter_by_name, filter_model, NULL));
gtk_filter_list_model_set_filter (filter_model, filter);
g_object_unref (filter);
/* notebook = GTK_WIDGET (gtk_builder_get_object (builder, "notebook")); */
search_entry = GTK_WIDGET (gtk_builder_get_object (builder, "search-entry"));
g_signal_connect (search_entry, "search-changed", G_CALLBACK (demo_search_changed_cb), filter);
/* info_view = GTK_WIDGET (gtk_builder_get_object (builder, "info-textview")); */
/* source_view = GTK_WIDGET (gtk_builder_get_object (builder, "source-textview")); */
/* toplevel = GTK_WIDGET (window); */
/* listview = GTK_WIDGET (gtk_builder_get_object (builder, "listview")); */
/* g_signal_connect (listview, "activate", G_CALLBACK (activate_cb), window); */
/* search_bar = GTK_WIDGET (gtk_builder_get_object (builder, "searchbar")); */
/* g_signal_connect (search_bar, "notify::search-mode-enabled", G_CALLBACK (clear_search), NULL); */
selection = gtk_single_selection_new (G_LIST_MODEL (filter_model));
g_signal_connect (selection, "notify::selected-item", G_CALLBACK (selection_cb), NULL);
gtk_list_view_set_model (GTK_LIST_VIEW (listview), GTK_SELECTION_MODEL (selection));
/* listmodel = create_demo_model (); */
/* treemodel = gtk_tree_list_model_new (G_LIST_MODEL (listmodel), */
/* FALSE, */
/* TRUE, */
/* get_child_model, */
/* NULL, */
/* NULL); */
/* filter_model = gtk_filter_list_model_new (G_LIST_MODEL (treemodel), NULL); */
/* filter = GTK_FILTER (gtk_custom_filter_new (demo_filter_by_name, filter_model, NULL)); */
/* gtk_filter_list_model_set_filter (filter_model, filter); */
/* g_object_unref (filter); */
selection_cb (selection, NULL, NULL);
g_object_unref (selection);
/* search_entry = GTK_WIDGET (gtk_builder_get_object (builder, "search-entry")); */
/* g_signal_connect (search_entry, "search-changed", G_CALLBACK (demo_search_changed_cb), filter); */
g_object_unref (builder);
/* selection = gtk_single_selection_new (G_LIST_MODEL (filter_model)); */
/* g_signal_connect (selection, "notify::selected-item", G_CALLBACK (selection_cb), NULL); */
/* gtk_list_view_set_model (GTK_LIST_VIEW (listview), GTK_SELECTION_MODEL (selection)); */
/* selection_cb (selection, NULL, NULL); */
/* g_object_unref (selection); */
/* g_object_unref (builder); */
}
static gboolean

View File

@ -9,6 +9,7 @@
*/
#include <gtk/gtk.h>
#include <stdio.h>
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
@ -394,8 +395,8 @@ do_tree_store (GtkWidget *do_widget)
/* create window, etc */
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
//gtk_window_set_display (GTK_WINDOW (window),
// gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Tree Store");
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);

View File

@ -71,7 +71,7 @@ gdk_draw_context_default_surface_resized (GdkDrawContext *context)
static void
gdk_draw_context_default_empty_frame (GdkDrawContext *context)
{
g_warning ("FIXME: Implement");
// g_warning ("FIXME: Implement");
}
static void