Learning GTK4 Trees _ initial commit (+ simple loop)
This commit is contained in:
parent
a0c82f2ade
commit
1a02d93f20
|
@ -21,7 +21,7 @@
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <glib/gstdio.h>
|
#include <glib/gstdio.h>
|
||||||
|
|
||||||
#include "demos.h"
|
#include "demos.h" // la liste de toutes les démos
|
||||||
#include "fontify.h"
|
#include "fontify.h"
|
||||||
|
|
||||||
#include "demo_conf.h"
|
#include "demo_conf.h"
|
||||||
|
@ -914,51 +914,54 @@ activate (GApplication *app)
|
||||||
GtkFilter *filter;
|
GtkFilter *filter;
|
||||||
GSimpleAction *action;
|
GSimpleAction *action;
|
||||||
|
|
||||||
builder = gtk_builder_new_from_resource ("/ui/main.ui");
|
window= do_tree_store(NULL);
|
||||||
|
|
||||||
window = (GtkWidget *)gtk_builder_get_object (builder, "window");
|
|
||||||
gtk_application_add_window (GTK_APPLICATION (app), GTK_WINDOW (window));
|
gtk_application_add_window (GTK_APPLICATION (app), GTK_WINDOW (window));
|
||||||
|
|
||||||
if (g_strcmp0 (PROFILE, "devel") == 0)
|
/* builder = gtk_builder_new_from_resource ("/ui/main.ui"); */
|
||||||
gtk_widget_add_css_class (window, "devel");
|
|
||||||
|
|
||||||
action = g_simple_action_new ("run", NULL);
|
/* window = (GtkWidget *)gtk_builder_get_object (builder, "window"); */
|
||||||
g_signal_connect (action, "activate", G_CALLBACK (activate_run), window);
|
/* gtk_application_add_window (GTK_APPLICATION (app), GTK_WINDOW (window)); */
|
||||||
g_action_map_add_action (G_ACTION_MAP (window), G_ACTION (action));
|
|
||||||
|
|
||||||
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"));
|
/* action = g_simple_action_new ("run", NULL); */
|
||||||
source_view = GTK_WIDGET (gtk_builder_get_object (builder, "source-textview"));
|
/* g_signal_connect (action, "activate", G_CALLBACK (activate_run), window); */
|
||||||
toplevel = GTK_WIDGET (window);
|
/* g_action_map_add_action (G_ACTION_MAP (window), G_ACTION (action)); */
|
||||||
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);
|
|
||||||
|
|
||||||
listmodel = create_demo_model ();
|
/* notebook = GTK_WIDGET (gtk_builder_get_object (builder, "notebook")); */
|
||||||
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);
|
|
||||||
|
|
||||||
search_entry = GTK_WIDGET (gtk_builder_get_object (builder, "search-entry"));
|
/* info_view = GTK_WIDGET (gtk_builder_get_object (builder, "info-textview")); */
|
||||||
g_signal_connect (search_entry, "search-changed", G_CALLBACK (demo_search_changed_cb), filter);
|
/* 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));
|
/* listmodel = create_demo_model (); */
|
||||||
g_signal_connect (selection, "notify::selected-item", G_CALLBACK (selection_cb), NULL);
|
/* treemodel = gtk_tree_list_model_new (G_LIST_MODEL (listmodel), */
|
||||||
gtk_list_view_set_model (GTK_LIST_VIEW (listview), GTK_SELECTION_MODEL (selection));
|
/* 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);
|
/* search_entry = GTK_WIDGET (gtk_builder_get_object (builder, "search-entry")); */
|
||||||
g_object_unref (selection);
|
/* 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
|
static gboolean
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||||
|
|
||||||
|
@ -394,8 +395,8 @@ do_tree_store (GtkWidget *do_widget)
|
||||||
|
|
||||||
/* create window, etc */
|
/* create window, etc */
|
||||||
window = gtk_window_new ();
|
window = gtk_window_new ();
|
||||||
gtk_window_set_display (GTK_WINDOW (window),
|
//gtk_window_set_display (GTK_WINDOW (window),
|
||||||
gtk_widget_get_display (do_widget));
|
// gtk_widget_get_display (do_widget));
|
||||||
gtk_window_set_title (GTK_WINDOW (window), "Tree Store");
|
gtk_window_set_title (GTK_WINDOW (window), "Tree Store");
|
||||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ gdk_draw_context_default_surface_resized (GdkDrawContext *context)
|
||||||
static void
|
static void
|
||||||
gdk_draw_context_default_empty_frame (GdkDrawContext *context)
|
gdk_draw_context_default_empty_frame (GdkDrawContext *context)
|
||||||
{
|
{
|
||||||
g_warning ("FIXME: Implement");
|
// g_warning ("FIXME: Implement");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Reference in New Issue