Compare commits

...

54 Commits

Author SHA1 Message Date
Jean Sirmai 368af2790f
A review of demo catalog with a selection of some widgets of interest. 2024-01-05 10:15:44 +01:00
Jean Sirmai 5a604fa05d
How to learn from examples ? window = do_listview_words(NULL); line 944 in main.c 2024-01-04 12:03:46 +01:00
Jean Sirmai 8107c7d2e3
WIP: GDK_DEPRECATED_IN_4_10_FOR(GtkListView) in gtk/deprecated/gtktreeview.h line 194 < mais ça marche 2024-01-03 00:31:18 +01:00
Jean Sirmai 3635308cf5
WIP: removing deprec : in gtk/gtk.h line 93 2024-01-02 19:50:42 +01:00
Jean Sirmai fde2d4594f
WIP: on simplifie avant de repartir. 2024-01-01 23:39:56 +01:00
Jean Sirmai b8fa3b1704
WIP: (gtk4-demo:18707): GLib-GIO-CRITICAL **: g_list_store_insert: assertion 'G_IS_LIST_STORE (store)' failed 2023-12-27 22:38:06 +01:00
Jean Sirmai e9ef7fbeae
WIP: TODO GListModel *create_node_recursive () and all that... 2023-12-25 23:55:28 +01:00
Jean Sirmai b734ab99d4
The quick comparison chart of equivalent functionalities 😮😃😇
https://docs.gtk.org/gtk4/section-list-widget.html
2023-12-25 19:16:52 +01:00
Jean Sirmai 34b43d1dac
WIP: Pourquoi ça marche ? Ça ne devrait pas. > row from iter at [ 0:0:0:1:0:1 ] = 'N' 2023-12-25 18:31:21 +01:00
Jean Sirmai 9c501b296f
WIP: gtk_tree_model_get_data_from_path() OK 2023-12-25 10:04:03 +01:00
Jean Sirmai e9a67bcf4a
WIP: how to walk the tree ? Another (small) step... 2023-12-25 01:08:11 +01:00
Jean Sirmai 7b364f0674
WIP: how to walk the tree ? A first step : first row 0: (ROOT) next row 0: (D) (line 103) 2023-12-25 00:23:13 +01:00
Jean Sirmai 125aea2127
WIP: how to walk the tree ? 2023-12-22 12:46:00 +01:00
Jean Sirmai 7a0abbc5b3
WIP: reading https://developer-old.gnome.org/gtk4/stable/GtkTreeView.html 2023-12-20 18:52:19 +01:00
Jean Sirmai 57bb001d11
WIP: reading https://developer-old.gnome.org/gtk4/stable/GtkTreeModel.html#gtk-tree-row-reference-new 2023-12-20 13:57:03 +01:00
Jean Sirmai 225e40fb53
WIP: before learning GtkCellEditable (cleaning) 2023-12-20 12:02:05 +01:00
Jean Sirmai 63f662ddc9
R E C U R S I V E T R E E (cleaning + comments) 2023-12-18 18:54:58 +01:00
Jean Sirmai 705af8c187
R E C U R S I V E T R E E (cleaning) 2023-12-18 18:48:14 +01:00
Jean Sirmai 4e616b6381
R E C U R S I V E T R E E (1st version) OK 2023-12-18 16:31:04 +01:00
Jean Sirmai 6724424219
manifest 2023-12-18 15:46:50 +01:00
Jean Sirmai 3c3f74e46e
WIP: tree_store.c:217:48: attention: argument 1 de : gtk_tree_view_new_with_model : pointeur incompatible 2023-12-18 12:19:17 +01:00
Jean Sirmai 2f1cd99bfb
WIP: GtkTreeStore * attendu mais l'argument est de type GtkTreeStore. Ma qué ? 2023-12-18 12:05:25 +01:00
Jean Sirmai 3430bd25fe
WIP: tree_model = create_node_recursive ((GtkTreeModel) tree_store, O); << pb de casting ? 2023-12-18 10:17:55 +01:00
Jean Sirmai 5e870ae870
WIP: TreeItem create_node_recursive (GtkTreeStore *model, TreeItem *current_item) {...} 2023-12-18 09:38:59 +01:00
Jean Sirmai 9da50fa49b
WIP: Construction itérative de l'arbre. Préparation de la construction récursive. 2023-12-18 08:49:36 +01:00
Jean Sirmai 0ed20386a7
WIP: gtk_tree_view_set_reorderable (GTK_TREE_VIEW (treeview), TRUE); 2023-12-16 18:19:54 +01:00
Jean Sirmai aa5ca0711f
WIP: Construction itérative de l'arbre. _append() et _set() dans iterate_node() (cleaning +) 2023-12-16 13:17:23 +01:00
Jean Sirmai d9745c0f6e
WIP: Construction itérative de l'arbre. _append() et _set() dans iterate_node() (cleaning) 2023-12-16 13:16:41 +01:00
Jean Sirmai 7278567729
WIP: Construction itérative de l'arbre. _append() et _set() dans iterate_node() 2023-12-16 13:11:50 +01:00
Jean Sirmai c00e97b4bd
WIP: transtyper model de GtkTreeStore en GtkTreeIter ? (ligne 96) 2023-12-16 10:38:34 +01:00
Jean Sirmai 3b5b5585d5
WIP: What the f...? Quand les iterateurs sont-ils egaux aux items ?! 2023-12-16 09:48:16 +01:00
Jean Sirmai 7efd6ee795
WIP: Is a more symetrical iteration possible ? line 92 GtkTreeIter * / GtkTreeStore * 2023-12-16 09:12:06 +01:00
Jean Sirmai 2132b0a7b4
WIP: before recursion, a perfect iteration ? (is OK) 2023-12-16 08:45:54 +01:00
Jean Sirmai 1d1b1fa744
WIP: preparing the recursive loop that builds the tree (0) 2023-12-16 08:30:28 +01:00
Jean Sirmai 8c3884e619
WIP: fonction iterate_node() premier micro-commit 2023-12-15 23:24:39 +01:00
Jean Sirmai 9d5a1ed25a
WIP: (micro) before creating a new function to iterate a node 2023-12-15 23:11:47 +01:00
Jean Sirmai 11c893d2c7
PROFONDEUR DE L'ARBRE (1ère fois) 2023-12-15 22:52:41 +01:00
Jean Sirmai cdc891823f
WIP: simplifications removing COLUMN_1 (ok) 2023-12-15 21:49:58 +01:00
Jean Sirmai 8891d5adfe
WIP: simplifications (TreeItem notation) 57-60 2023-12-15 11:31:09 +01:00
Jean Sirmai f6affc1ebf
WIP: simplifications removing COLUMN_1 2023-12-15 11:12:24 +01:00
Jean Sirmai db3043c274
WIP: simplifications removing the gboolean in struct _TreeItem 2023-12-15 11:02:53 +01:00
Jean Sirmai 8cc77af4f5
WIP: simplifications removing the so called 'VISIBLE_COLUMN' 2023-12-15 10:54:05 +01:00
Jean Sirmai cfc2db00d0
WIP: simplifications removing the 'WORLD_COLUMN' 2023-12-15 10:23:47 +01:00
Jean Sirmai dd37063fff
WIP: simplifications in add_columns(): gtk_cell_renderer_toggle_new() replaced by 'text' 2023-12-15 10:18:09 +01:00
Jean Sirmai f0b8b70bfb
WIP: simplifications in add_columns() 2023-12-15 10:12:13 +01:00
Jean Sirmai cc899e13c9
WIP: before removing item_toggled() 2023-12-14 12:15:49 +01:00
Jean Sirmai 271206f4ec
WIP: simplifications gtk-demo/tree_store.c remove: WORLD_COLUMN ? 2023-12-13 12:06:42 +01:00
Jean Sirmai 0c2f313a3b
WIP: simplifications dans builddir/demos/gtk-demo/tree_store.c 2023-12-13 11:53:11 +01:00
Jean Sirmai 3e52de8a09
WIP: simplifications dans builddir/demos/gtk-demo/demos.h 2023-12-13 09:30:00 +01:00
Jean Sirmai db225bd732
Learning GTK4 Trees _ initial commit (suite) > The Perfect Learning Loop. 2023-12-12 19:49:20 +01:00
Jean Sirmai 375d658cc8
Learning GTK4 Trees _ initial commit (+ simple & light loop) 2023-12-12 19:02:08 +01:00
Jean Sirmai 1a02d93f20
Learning GTK4 Trees _ initial commit (+ simple loop) 2023-12-12 18:40:36 +01:00
Jean Sirmai a0c82f2ade
Learning GTK4 Trees _ initial commit (+ manifest) 2023-12-12 12:48:58 +01:00
Jean Sirmai 8f56c928b1
Learning GTK4 Trees _ initial commit 2023-12-12 12:47:28 +01:00
8 changed files with 1103 additions and 643 deletions

389
Gtk text example Normal file
View File

@ -0,0 +1,389 @@
/* GTK - The GIMP Toolkit
* Copyright (C) 2019 Red Hat, Inc.
*
* Authors:
* - Matthias Clasen <mclasen@redhat.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "demotaggedentry.h"
#include <gtk/gtk.h>
struct _DemoTaggedEntry
{
GtkWidget parent_instance;
GtkWidget *text;
};
struct _DemoTaggedEntryClass
{
GtkWidgetClass parent_class;
};
static void demo_tagged_entry_editable_init (GtkEditableInterface *iface);
G_DEFINE_TYPE_WITH_CODE (DemoTaggedEntry, demo_tagged_entry, GTK_TYPE_WIDGET,
G_IMPLEMENT_INTERFACE (GTK_TYPE_EDITABLE, demo_tagged_entry_editable_init))
static void
demo_tagged_entry_init (DemoTaggedEntry *entry)
{
GtkCssProvider *provider;
entry->text = gtk_text_new ();
gtk_widget_set_hexpand (entry->text, TRUE);
gtk_widget_set_vexpand (entry->text, TRUE);
gtk_widget_set_parent (entry->text, GTK_WIDGET (entry));
gtk_editable_init_delegate (GTK_EDITABLE (entry));
gtk_editable_set_width_chars (GTK_EDITABLE (entry->text), 6);
gtk_editable_set_max_width_chars (GTK_EDITABLE (entry->text), 6);
gtk_widget_add_css_class (GTK_WIDGET (entry), "tagged");
provider = gtk_css_provider_new ();
gtk_css_provider_load_from_resource (provider, "/tagged_entry/tagstyle.css");
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
GTK_STYLE_PROVIDER (provider),
800);
g_object_unref (provider);
}
static void
demo_tagged_entry_dispose (GObject *object)
{
DemoTaggedEntry *entry = DEMO_TAGGED_ENTRY (object);
GtkWidget *child;
if (entry->text)
gtk_editable_finish_delegate (GTK_EDITABLE (entry));
while ((child = gtk_widget_get_first_child (GTK_WIDGET (entry))))
gtk_widget_unparent (child);
entry->text = NULL;
G_OBJECT_CLASS (demo_tagged_entry_parent_class)->dispose (object);
}
static void
demo_tagged_entry_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
if (gtk_editable_delegate_set_property (object, prop_id, value, pspec))
return;
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
static void
demo_tagged_entry_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
if (gtk_editable_delegate_get_property (object, prop_id, value, pspec))
return;
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
static gboolean
demo_tagged_entry_grab_focus (GtkWidget *widget)
{
DemoTaggedEntry *entry = DEMO_TAGGED_ENTRY (widget);
return gtk_widget_grab_focus (entry->text);
}
static void
demo_tagged_entry_class_init (DemoTaggedEntryClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
object_class->dispose = demo_tagged_entry_dispose;
object_class->get_property = demo_tagged_entry_get_property;
object_class->set_property = demo_tagged_entry_set_property;
widget_class->grab_focus = demo_tagged_entry_grab_focus;
gtk_editable_install_properties (object_class, 1);
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BOX_LAYOUT);
gtk_widget_class_set_css_name (widget_class, "entry");
gtk_widget_class_set_accessible_role (widget_class, GTK_ACCESSIBLE_ROLE_TEXT_BOX);
}
static GtkEditable *
demo_tagged_entry_get_delegate (GtkEditable *editable)
{
return GTK_EDITABLE (DEMO_TAGGED_ENTRY (editable)->text);
}
static void
demo_tagged_entry_editable_init (GtkEditableInterface *iface)
{
iface->get_delegate = demo_tagged_entry_get_delegate;
}
GtkWidget *
demo_tagged_entry_new (void)
{
return GTK_WIDGET (g_object_new (DEMO_TYPE_TAGGED_ENTRY, NULL));
}
void
demo_tagged_entry_add_tag (DemoTaggedEntry *entry,
GtkWidget *tag)
{
g_return_if_fail (DEMO_IS_TAGGED_ENTRY (entry));
gtk_widget_set_parent (tag, GTK_WIDGET (entry));
}
void
demo_tagged_entry_insert_tag_after (DemoTaggedEntry *entry,
GtkWidget *tag,
GtkWidget *sibling)
{
g_return_if_fail (DEMO_IS_TAGGED_ENTRY (entry));
gtk_widget_insert_after (tag, GTK_WIDGET (entry), sibling);
}
void
demo_tagged_entry_remove_tag (DemoTaggedEntry *entry,
GtkWidget *tag)
{
g_return_if_fail (DEMO_IS_TAGGED_ENTRY (entry));
gtk_widget_unparent (tag);
}
struct _DemoTaggedEntryTag
{
GtkWidget parent;
GtkWidget *box;
GtkWidget *label;
GtkWidget *button;
gboolean has_close_button;
char *style;
};
struct _DemoTaggedEntryTagClass
{
GtkWidgetClass parent_class;
};
enum {
PROP_0,
PROP_LABEL,
PROP_HAS_CLOSE_BUTTON,
};
enum {
SIGNAL_CLICKED,
SIGNAL_BUTTON_CLICKED,
LAST_SIGNAL
};
static guint signals[LAST_SIGNAL] = { 0, };
G_DEFINE_TYPE (DemoTaggedEntryTag, demo_tagged_entry_tag, GTK_TYPE_WIDGET)
static void
on_released (GtkGestureClick *gesture,
int n_press,
double x,
double y,
DemoTaggedEntryTag *tag)
{
g_signal_emit (tag, signals[SIGNAL_CLICKED], 0);
}
static void
demo_tagged_entry_tag_init (DemoTaggedEntryTag *tag)
{
GtkGesture *gesture;
tag->box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_widget_set_parent (tag->box, GTK_WIDGET (tag));
tag->label = gtk_label_new ("");
gtk_box_append (GTK_BOX (tag->box), tag->label);
gesture = gtk_gesture_click_new ();
g_signal_connect (gesture, "released", G_CALLBACK (on_released), tag);
gtk_widget_add_controller (GTK_WIDGET (tag), GTK_EVENT_CONTROLLER (gesture));
}
static void
demo_tagged_entry_tag_dispose (GObject *object)
{
DemoTaggedEntryTag *tag = DEMO_TAGGED_ENTRY_TAG (object);
g_clear_pointer (&tag->box, gtk_widget_unparent);
G_OBJECT_CLASS (demo_tagged_entry_tag_parent_class)->dispose (object);
}
static void
demo_tagged_entry_tag_finalize (GObject *object)
{
DemoTaggedEntryTag *tag = DEMO_TAGGED_ENTRY_TAG (object);
g_clear_pointer (&tag->box, gtk_widget_unparent);
g_clear_pointer (&tag->style, g_free);
G_OBJECT_CLASS (demo_tagged_entry_tag_parent_class)->finalize (object);
}
static void
demo_tagged_entry_tag_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
DemoTaggedEntryTag *tag = DEMO_TAGGED_ENTRY_TAG (object);
switch (prop_id)
{
case PROP_LABEL:
demo_tagged_entry_tag_set_label (tag, g_value_get_string (value));
break;
case PROP_HAS_CLOSE_BUTTON:
demo_tagged_entry_tag_set_has_close_button (tag, g_value_get_boolean (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
demo_tagged_entry_tag_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
DemoTaggedEntryTag *tag = DEMO_TAGGED_ENTRY_TAG (object);
switch (prop_id)
{
case PROP_LABEL:
g_value_set_string (value, demo_tagged_entry_tag_get_label (tag));
break;
case PROP_HAS_CLOSE_BUTTON:
g_value_set_boolean (value, demo_tagged_entry_tag_get_has_close_button (tag));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
demo_tagged_entry_tag_measure (GtkWidget *widget,
GtkOrientation orientation,
int for_size,
int *minimum,
int *natural,
int *minimum_baseline,
int *natural_baseline)
{
DemoTaggedEntryTag *tag = DEMO_TAGGED_ENTRY_TAG (widget);
gtk_widget_measure (tag->box, orientation, for_size,
minimum, natural,
minimum_baseline, natural_baseline);
}
static void
demo_tagged_entry_tag_size_allocate (GtkWidget *widget,
int width,
int height,
int baseline)
{
DemoTaggedEntryTag *tag = DEMO_TAGGED_ENTRY_TAG (widget);
gtk_widget_size_allocate (tag->box,
&(GtkAllocation) { 0, 0, width, height },
baseline);
}
static void
demo_tagged_entry_tag_class_init (DemoTaggedEntryTagClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
object_class->dispose = demo_tagged_entry_tag_dispose;
object_class->finalize = demo_tagged_entry_tag_finalize;
object_class->set_property = demo_tagged_entry_tag_set_property;
object_class->get_property = demo_tagged_entry_tag_get_property;
widget_class->measure = demo_tagged_entry_tag_measure;
widget_class->size_allocate = demo_tagged_entry_tag_size_allocate;
signals[SIGNAL_CLICKED] =
g_signal_new ("clicked",
DEMO_TYPE_TAGGED_ENTRY_TAG,
G_SIGNAL_RUN_FIRST,
0, NULL, NULL, NULL,
G_TYPE_NONE, 0);
signals[SIGNAL_BUTTON_CLICKED] =
g_signal_new ("button-clicked",
DEMO_TYPE_TAGGED_ENTRY_TAG,
G_SIGNAL_RUN_FIRST,
0, NULL, NULL, NULL,
G_TYPE_NONE, 0);
g_object_class_install_property (object_class, PROP_LABEL,
g_param_spec_string ("label", "Label", "Label",
NULL, G_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_HAS_CLOSE_BUTTON,
g_param_spec_boolean ("has-close-button", "Has close button", "Whether this tag has a close button",
FALSE, G_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
gtk_widget_class_set_css_name (widget_class, "tag");
}
DemoTaggedEntryTag *
demo_tagged_entry_tag_new (const char *label)
{
return DEMO_TAGGED_ENTRY_TAG (g_object_new (DEMO_TYPE_TAGGED_ENTRY_TAG,
"label", label,
NULL));
}
const char *
demo_tagged_entry_tag_get_label (DemoTaggedEntryTag *tag)
{
g_return_val_if_fail (DEMO_IS_TAGGED_ENTRY_TAG (tag), NULL);
return gtk_label_get_label (GTK_LABEL (tag->label));
}
void
demo_tagged_entry_tag_set_label (DemoTaggedEntryTag *tag,
const char *label)
{
g_return_if_fail (DEMO_IS_TAGGED_ENTRY_TAG (tag));
gtk_label_set_label (GTK_LABEL (tag->label), label);
}
static void
on_button_clicked (GtkButton *button,
DemoTaggedEntryTag *tag)
{
g_signal_emit (tag, signals[SIGNAL_BUTTON_CLICKED], 0);
}
void
demo_tagged_entry_tag_set_has_close_button (DemoTaggedEntryTag *tag,
gboolean has_close_button)
{
g_return_if_fail (DEMO_IS_TAGGED_ENTRY_TAG (tag));
if ((tag->button != NULL) == has_close_button)
return;
if (!has_close_button && tag->button)
{
gtk_box_remove (GTK_BOX (tag->box), tag->button);
tag->button = NULL;
}
else if (has_close_button && tag->button == NULL)
{
GtkWidget *image;
image = gtk_image_new_from_icon_name ("window-close-symbolic");
tag->button = gtk_button_new ();
gtk_button_set_child (GTK_BUTTON (tag->button), image);
gtk_widget_set_halign (tag->button, GTK_ALIGN_CENTER);
gtk_widget_set_valign (tag->button, GTK_ALIGN_CENTER);
gtk_button_set_has_frame (GTK_BUTTON (tag->button), FALSE);
gtk_box_append (GTK_BOX (tag->box), tag->button);
g_signal_connect (tag->button, "clicked", G_CALLBACK (on_button_clicked), tag);
}
g_object_notify (G_OBJECT (tag), "has-close-button");
}
gboolean
demo_tagged_entry_tag_get_has_close_button (DemoTaggedEntryTag *tag)
{
g_return_val_if_fail (DEMO_IS_TAGGED_ENTRY_TAG (tag), FALSE);
return tag->button != NULL;
}

View File

@ -191,7 +191,7 @@ do_listview_words (GtkWidget *do_widget)
else
{
char **words;
words = g_strsplit ("lorem ipsum dolor sit amet consectetur adipisci elit sed eiusmod tempor incidunt labore et dolore magna aliqua ut enim ad minim veniam quis nostrud exercitation ullamco laboris nisi ut aliquid ex ea commodi consequat", " ", -1);
words = g_strsplit ("Les sanglots longs des violons de lautomne blessent mon cœur dune langueur monotone", " ", -1);
stringlist = gtk_string_list_new ((const char **) words);
g_strfreev (words);
}
@ -202,7 +202,7 @@ do_listview_words (GtkWidget *do_widget)
gtk_filter_list_model_set_incremental (filter_model, TRUE);
window = gtk_window_new ();
gtk_window_set_default_size (GTK_WINDOW (window), 400, 600);
gtk_window_set_default_size (GTK_WINDOW (window), 300, 400);
header = gtk_header_bar_new ();
gtk_header_bar_set_show_title_buttons (GTK_HEADER_BAR (header), TRUE);

View File

@ -1,3 +1,23 @@
/************************************************** R E M E M B E R ! *****************************************************/
/* */
/* jean@Project:~/Gem-Graph/gem-graph-client/tree (learning)/The_Gnome_way/gtk$ guix shell -m manifest.scm --check */
/* guix shell: vérification des variables d'environnement visibles depuis le shell « /gnu/store/ --- (a commit) --- /bin/bash »… */
/* guix shell: Tout va bien ! Le shell a les bonnes variables d'environnement. */
/* jean@Project:~/Gem-Graph/gem-graph-client/tree (learning)/The_Gnome_way/gtk [env] $ cd builddir/ */
/* jean@Project:~/Gem-Graph/gem-graph-client/tree (learning)/The_Gnome_way/gtk/builddir [env] $ */
/* */
/* >>>>>>>>>>>>>>>>>> Modify line 944 in this file to run examples <<<<<<<<<<<<<<<<< */
/* */
/* jean@Project:~/Gem-Graph/gem-graph-client/tree...way/gtk/builddir [env] $ clear && meson compile && demos/gtk-demo/gtk4-demo */
/* */
/* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- A Session -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- */
/* */
/* jean@Project:~/Gem-Graph/gem-graph-client/tree (learning)/The_Gnome_way/gtk/builddir [env] $ ctrl D (avant de fermer builder) */
/* */
/*************************************************************************************************************************************/
/* GTK Demo
*
* GTK Demo is a collection of useful examples to demonstrate
@ -11,6 +31,152 @@
* You can also use the GTK Inspector, available from the menu on the
* top right, to poke at the running demos, and see how they are put
* together.
*
In the following list (*.c in gtk-demo dir)
!! <> doesn't work (see line 1087 sqq. in this file)
!!application.c
!!application_demo.c ?? Failed to execute
assistant.c //
!!bluroverlay.c
??builder.c
clipboard.c //
combobox.c //
constraints_builder.c // layouts
constraints.c // simple layout
constraints_interactive.c //
constraints_vfl.c // very simple layout
css_accordion.c //
css_basics.c //
css_blendmodes.c // pictures colors
css_multiplebgs.c //
css_pixbufs.c // animated background
css_shadows.c // stripped background
cursors.c //
!!demo2layout.c
!!demo2widget.c
!!demo3widget.c
!!demo4widget.c
!!demochild.c
!!demoimage.c
!!demolayout.c
!!demotaggedentry.c
!!demowidget.c
dialog.c //
dnd.c // drag and drop
drawingarea.c //
editable_cells.c //
entry_completion.c //
entry_undo.c //
errorstates.c // ?
expander.c //
filtermodel.c //
fishbowl.c //
fixed.c // layout
flowbox.c // layout
font_features.c //
!!fontify.c
!!fontplane.c
fontrendering.c // fontrendering
!!four_point_transform.c
frames.c // backgr. color varies
gears.c // 3D animation
gestures.c // draws a line
glarea.c // triangle in 3D
gltransition.c // complicated !
!!graphwidget.c
!!gskshaderpaintable.c
!!gtkfishbowl.c
!!gtkgears.c
!!gtkshaderbin.c
!!gtkshaderstack.c
!!gtkshadertoy.c
headerbar.c //
!!hsla.c
hypertext.c //
iconscroll.c //
iconview.c //
iconview_edit.c // drag and drop
images.c //
image_scaling.c //
infobar.c //
!!language-names.c
layoutmanager2.c //
layoutmanager.c //
links.c // Ok
listbox.c //
listbox_controls.c //
list_store.c // many columns
listview_applauncher.c //
listview_clocks.c //
listview_colors.c //
!!listview_filebrowser.c
!!listview_minesweeper.c
listview_selections.c //
listview_settings2.c //
listview_settings.c //
listview_ucd.c // char
listview_weather.c //
listview_words.c // OK (favourite)
//main.c
markup.c // text
mask.c //
!!nodewidget.c
overlay.c // grid of numbers
overlay_decorative.c // Dear diary...
pagesetup.c //
paintable_animated.c // sympa
paintable.c //
paintable_emblem.c //
!!paintable_c.c
paintable_svg.c //
paintable_symbolic.c //
paint.c // Ok
panes.c //
password_entry.c //
path_fill.c //
path_maze.c //
path_spinner.c //
path_text.c // whouuh (text)
path_walk.c // whooh (world)
peg_solitaire.c //
pickers.c //
pixbufpaintable.c // (avoid : err)
printing.c // (avoid : err)
!!puzzlepiece.c
read_more.c //
revealer.c //
rotated_text.c //
scale.c //
!!script-names.c
search_entry2.c // Ok
search_entry.c //
!!settings-key.c
shadertoy.c // dynamq view
!!shortcuts.c
shortcut_triggers.c // buttons assoc
sidebar.c //
!!singular_value_decomposition.c
sizegroup.c // layout
sliding_puzzle.c // George Boole
spinbutton.c // increment val
spinner.c //
stack.c //
!!suggestionentry.c
!!svgpaintable.c
tabs.c //
tagged_entry.c //
textmask.c // pango power !
textscroll.c // automatic
textundo.c //
textview.c //
themes.c // flashes !
theming_style_classes.c // (poor)
transparent.c //
tree_store.c // my first one
!!unicode-names.c
video_player.c //
*/
#include <errno.h>
#include <stdio.h>
@ -21,7 +187,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"
@ -32,9 +198,9 @@ static GtkWidget *source_view;
static char *current_file = NULL;
static GtkWidget *notebook;
static GtkSingleSelection *selection;
static GtkWidget *toplevel;
static char **search_needle;
// static GtkSingleSelection *selection;
// static GtkWidget *toplevel;
// static char **search_needle;
typedef struct _GtkDemo GtkDemo;
struct _GtkDemo
@ -142,26 +308,26 @@ struct _CallbackData
GtkTreePath *path;
};
static gboolean
gtk_demo_run (GtkDemo *self,
GtkWidget *window)
{
GtkWidget *result;
/* static gboolean */
/* gtk_demo_run (GtkDemo *self, */
/* GtkWidget *window) */
/* { */
/* GtkWidget *result; */
if (!self->func)
return FALSE;
/* if (!self->func) */
/* return FALSE; */
result = self->func (window);
if (result == NULL)
return FALSE;
/* result = self->func (window); */
/* if (result == NULL) */
/* return FALSE; */
if (GTK_IS_WINDOW (result))
{
gtk_window_set_transient_for (GTK_WINDOW (result), GTK_WINDOW (window));
gtk_window_set_modal (GTK_WINDOW (result), TRUE);
}
return TRUE;
}
/* if (GTK_IS_WINDOW (result)) */
/* { */
/* gtk_window_set_transient_for (GTK_WINDOW (result), GTK_WINDOW (window)); */
/* gtk_window_set_modal (GTK_WINDOW (result), TRUE); */
/* } */
/* return TRUE; */
/* } */
static void
activate_about (GSimpleAction *action,
@ -255,16 +421,16 @@ activate_inspector (GSimpleAction *action,
gtk_window_set_interactive_debugging (TRUE);
}
static void
activate_run (GSimpleAction *action,
GVariant *parameter,
gpointer window)
{
GtkTreeListRow *row = gtk_single_selection_get_selected_item (selection);
GtkDemo *demo = gtk_tree_list_row_get_item (row);
/* static void */
/* activate_run (GSimpleAction *action, */
/* GVariant *parameter, */
/* gpointer window) */
/* { */
/* GtkTreeListRow *row = gtk_single_selection_get_selected_item (selection); */
/* GtkDemo *demo = gtk_tree_list_row_get_item (row); */
gtk_demo_run (demo, window);
}
/* gtk_demo_run (demo, window); */
/* } */
static GtkWidget *
display_image (const char *format,
@ -681,284 +847,318 @@ load_file (const char *demoname,
g_object_unref (info_buffer);
}
static void
activate_cb (GtkWidget *widget,
guint position,
gpointer window)
{
GListModel *model = G_LIST_MODEL (gtk_list_view_get_model (GTK_LIST_VIEW (widget)));
GtkTreeListRow *row = g_list_model_get_item (model, position);
GtkDemo *demo = gtk_tree_list_row_get_item (row);
/* static void */
/* activate_cb (GtkWidget *widget, */
/* guint position, */
/* gpointer window) */
/* { */
/* GListModel *model = G_LIST_MODEL (gtk_list_view_get_model (GTK_LIST_VIEW (widget))); */
/* GtkTreeListRow *row = g_list_model_get_item (model, position); */
/* GtkDemo *demo = gtk_tree_list_row_get_item (row); */
gtk_demo_run (demo, window);
/* gtk_demo_run (demo, window); */
g_object_unref (row);
}
/* g_object_unref (row); */
/* } */
static void
selection_cb (GtkSingleSelection *sel,
GParamSpec *pspec,
gpointer user_data)
{
GtkTreeListRow *row = gtk_single_selection_get_selected_item (sel);
GtkDemo *demo;
GAction *action;
/* static void */
/* selection_cb (GtkSingleSelection *sel, */
/* GParamSpec *pspec, */
/* gpointer user_data) */
/* { */
/* GtkTreeListRow *row = gtk_single_selection_get_selected_item (sel); */
/* GtkDemo *demo; */
/* GAction *action; */
gtk_widget_set_sensitive (GTK_WIDGET (notebook), !!row);
/* gtk_widget_set_sensitive (GTK_WIDGET (notebook), !!row); */
if (!row)
{
gtk_window_set_title (GTK_WINDOW (toplevel), "No match");
/* if (!row) */
/* { */
/* gtk_window_set_title (GTK_WINDOW (toplevel), "No match"); */
return;
}
/* return; */
/* } */
demo = gtk_tree_list_row_get_item (row);
/* demo = gtk_tree_list_row_get_item (row); */
if (demo->filename)
load_file (demo->name, demo->filename);
/* if (demo->filename) */
/* load_file (demo->name, demo->filename); */
action = g_action_map_lookup_action (G_ACTION_MAP (toplevel), "run");
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), demo->func != NULL);
/* action = g_action_map_lookup_action (G_ACTION_MAP (toplevel), "run"); */
/* g_simple_action_set_enabled (G_SIMPLE_ACTION (action), demo->func != NULL); */
gtk_window_set_title (GTK_WINDOW (toplevel), demo->title);
}
/* gtk_window_set_title (GTK_WINDOW (toplevel), demo->title); */
/* } */
static gboolean
filter_demo (GtkDemo *demo)
{
int i;
/* static gboolean */
/* filter_demo (GtkDemo *demo) */
/* { */
/* int i; */
/* Show only if the name matches every needle */
for (i = 0; search_needle[i]; i++)
{
if (!demo->title)
return FALSE;
/* for (i = 0; search_needle[i]; i++) */
/* { */
/* if (!demo->title) */
/* return FALSE; */
if (g_str_match_string (search_needle[i], demo->title, TRUE))
continue;
/* if (g_str_match_string (search_needle[i], demo->title, TRUE)) */
/* continue; */
if (demo->keywords)
{
int j;
gboolean found = FALSE;
/* if (demo->keywords) */
/* { */
/* int j; */
/* gboolean found = FALSE; */
for (j = 0; !found && demo->keywords[j]; j++)
{
if (strstr (demo->keywords[j], search_needle[i]))
found = TRUE;
}
/* for (j = 0; !found && demo->keywords[j]; j++) */
/* { */
/* if (strstr (demo->keywords[j], search_needle[i])) */
/* found = TRUE; */
/* } */
if (found)
continue;
}
/* if (found) */
/* continue; */
/* } */
return FALSE;
}
/* return FALSE; */
/* } */
return TRUE;
}
/* return TRUE; */
/* } */
static gboolean
demo_filter_by_name (gpointer item,
gpointer user_data)
{
GtkTreeListRow *row = item;
GListModel *children;
GtkDemo *demo;
guint i, n;
GtkTreeListRow *parent;
/* static gboolean */
/* demo_filter_by_name (gpointer item, */
/* gpointer user_data) */
/* { */
/* GtkTreeListRow *row = item; */
/* GListModel *children; */
/* GtkDemo *demo; */
/* guint i, n; */
/* GtkTreeListRow *parent; */
/* Show all items if search is empty */
if (!search_needle || !search_needle[0] || !*search_needle[0])
return TRUE;
/* if (!search_needle || !search_needle[0] || !*search_needle[0]) */
/* return TRUE; */
g_assert (GTK_IS_TREE_LIST_ROW (row));
g_assert (GTK_IS_FILTER_LIST_MODEL (user_data));
/* g_assert (GTK_IS_TREE_LIST_ROW (row)); */
/* g_assert (GTK_IS_FILTER_LIST_MODEL (user_data)); */
/* Show a row if itself of any parent matches */
for (parent = row; parent; parent = gtk_tree_list_row_get_parent (parent))
{
demo = gtk_tree_list_row_get_item (parent);
g_assert (GTK_IS_DEMO (demo));
/* for (parent = row; parent; parent = gtk_tree_list_row_get_parent (parent)) */
/* { */
/* demo = gtk_tree_list_row_get_item (parent); */
/* g_assert (GTK_IS_DEMO (demo)); */
if (filter_demo (demo))
return TRUE;
}
/* if (filter_demo (demo)) */
/* return TRUE; */
/* } */
/* Show a row if any child matches */
children = gtk_tree_list_row_get_children (row);
if (children)
{
n = g_list_model_get_n_items (children);
for (i = 0; i < n; i++)
{
demo = g_list_model_get_item (children, i);
g_assert (GTK_IS_DEMO (demo));
/* children = gtk_tree_list_row_get_children (row); */
/* if (children) */
/* { */
/* n = g_list_model_get_n_items (children); */
/* for (i = 0; i < n; i++) */
/* { */
/* demo = g_list_model_get_item (children, i); */
/* g_assert (GTK_IS_DEMO (demo)); */
if (filter_demo (demo))
{
g_object_unref (demo);
return TRUE;
}
g_object_unref (demo);
}
}
/* if (filter_demo (demo)) */
/* { */
/* g_object_unref (demo); */
/* return TRUE; */
/* } */
/* g_object_unref (demo); */
/* } */
/* } */
return FALSE;
}
/* return FALSE; */
/* } */
static void
demo_search_changed_cb (GtkSearchEntry *entry,
GtkFilter *filter)
{
const char *text;
/* static void */
/* demo_search_changed_cb (GtkSearchEntry *entry, */
/* GtkFilter *filter) */
/* { */
/* const char *text; */
g_assert (GTK_IS_SEARCH_ENTRY (entry));
g_assert (GTK_IS_FILTER (filter));
/* g_assert (GTK_IS_SEARCH_ENTRY (entry)); */
/* g_assert (GTK_IS_FILTER (filter)); */
text = gtk_editable_get_text (GTK_EDITABLE (entry));
/* text = gtk_editable_get_text (GTK_EDITABLE (entry)); */
g_clear_pointer (&search_needle, g_strfreev);
/* g_clear_pointer (&search_needle, g_strfreev); */
if (text && *text)
search_needle = g_str_tokenize_and_fold (text, NULL, NULL);
/* if (text && *text) */
/* search_needle = g_str_tokenize_and_fold (text, NULL, NULL); */
gtk_filter_changed (filter, GTK_FILTER_CHANGE_DIFFERENT);
}
/* gtk_filter_changed (filter, GTK_FILTER_CHANGE_DIFFERENT); */
/* } */
static GListModel *
create_demo_model (void)
{
GListStore *store = g_list_store_new (GTK_TYPE_DEMO);
DemoData *demo = gtk_demos;
GtkDemo *d;
/* static GListModel * */
/* create_demo_model (void) */
/* { */
/* GListStore *store = g_list_store_new (GTK_TYPE_DEMO); */
/* DemoData *demo = gtk_demos; */
/* GtkDemo *d; */
d = GTK_DEMO (g_object_new (GTK_TYPE_DEMO, NULL));
d->name = "main";
d->title = "GTK Demo";
d->keywords = NULL;
d->filename = "main.c";
d->func = NULL;
/* d = GTK_DEMO (g_object_new (GTK_TYPE_DEMO, NULL)); */
/* d->name = "main"; */
/* d->title = "GTK Demo"; */
/* d->keywords = NULL; */
/* d->filename = "main.c"; */
/* d->func = NULL; */
g_list_store_append (store, d);
/* g_list_store_append (store, d); */
while (demo->title)
{
d = GTK_DEMO (g_object_new (GTK_TYPE_DEMO, NULL));
DemoData *children = demo->children;
/* while (demo->title) */
/* { */
/* d = GTK_DEMO (g_object_new (GTK_TYPE_DEMO, NULL)); */
/* DemoData *children = demo->children; */
d->name = demo->name;
d->title = demo->title;
d->keywords = demo->keywords;
d->filename = demo->filename;
d->func = demo->func;
/* d->name = demo->name; */
/* d->title = demo->title; */
/* d->keywords = demo->keywords; */
/* d->filename = demo->filename; */
/* d->func = demo->func; */
g_list_store_append (store, d);
/* g_list_store_append (store, d); */
if (children)
{
d->children_model = G_LIST_MODEL (g_list_store_new (GTK_TYPE_DEMO));
/* if (children) */
/* { */
/* d->children_model = G_LIST_MODEL (g_list_store_new (GTK_TYPE_DEMO)); */
while (children->title)
{
GtkDemo *child = GTK_DEMO (g_object_new (GTK_TYPE_DEMO, NULL));
/* while (children->title) */
/* { */
/* GtkDemo *child = GTK_DEMO (g_object_new (GTK_TYPE_DEMO, NULL)); */
child->name = children->name;
child->title = children->title;
child->keywords = children->keywords;
child->filename = children->filename;
child->func = children->func;
/* child->name = children->name; */
/* child->title = children->title; */
/* child->keywords = children->keywords; */
/* child->filename = children->filename; */
/* child->func = children->func; */
g_list_store_append (G_LIST_STORE (d->children_model), child);
children++;
}
}
/* g_list_store_append (G_LIST_STORE (d->children_model), child); */
/* children++; */
/* } */
/* } */
demo++;
}
/* demo++; */
/* } */
return G_LIST_MODEL (store);
}
/* return G_LIST_MODEL (store); */
/* } */
static GListModel *
get_child_model (gpointer item,
gpointer user_data)
{
GtkDemo *demo = item;
/* static GListModel * */
/* get_child_model (gpointer item, */
/* gpointer user_data) */
/* { */
/* GtkDemo *demo = item; */
if (demo->children_model)
return g_object_ref (G_LIST_MODEL (demo->children_model));
/* if (demo->children_model) */
/* return g_object_ref (G_LIST_MODEL (demo->children_model)); */
return NULL;
}
/* return NULL; */
/* } */
static void
clear_search (GtkSearchBar *bar)
{
if (!gtk_search_bar_get_search_mode (bar))
{
GtkWidget *entry = gtk_search_bar_get_child (GTK_SEARCH_BAR (bar));
gtk_editable_set_text (GTK_EDITABLE (entry), "");
}
}
/* static void */
/* clear_search (GtkSearchBar *bar) */
/* { */
/* if (!gtk_search_bar_get_search_mode (bar)) */
/* { */
/* GtkWidget *entry = gtk_search_bar_get_child (GTK_SEARCH_BAR (bar)); */
/* gtk_editable_set_text (GTK_EDITABLE (entry), ""); */
/* } */
/* } */
static void
activate (GApplication *app)
{
GtkBuilder *builder;
GListModel *listmodel;
GtkTreeListModel *treemodel;
GtkWidget *window, *listview, *search_entry, *search_bar;
GtkFilterListModel *filter_model;
GtkFilter *filter;
GSimpleAction *action;
// GtkBuilder *builder;
// GListModel *listmodel;
// GtkTreeListModel *treemodel;
GtkWidget *window;//, *listview, *search_entry, *search_bar;
// GtkFilterListModel *filter_model;
// GtkFilter *filter;
// GSimpleAction *action;
builder = gtk_builder_new_from_resource ("/ui/main.ui");
// https://www.gtk.org/
/******************************************************************************/
/* */
/* W I N D O W = D O _ S O M E _ A P P L I C A T I O N _ E X A M P L E */
/* */
// window = do_tree_store(NULL);
// window = do_listview_words(NULL);
// window = do_editable_cells(NULL);
// window = do_dnd(NULL); // drag and drop
// window = do_drawingarea(NULL);
// window = do_entry_undo(NULL);
// window = do_expander(NULL);
// window = do_textundo(NULL);
// window = do_search_entry2(NULL);
// window = do_scale(NULL); // scale entries from bars
// window = do_font_features(NULL);
// window = do_hypertext(NULL);
// window = do_iconview_edit(NULL); // drag and drop
// window = do_image_scaling(NULL);
// window = do_infobar(NULL);
// window = do_links(NULL);
// window = do_listbox_controls(NULL);
// window = do_list_store(NULL);
// window = do_listview_colors(NULL);
// window = do_listview_selections(NULL);
// window = do_mask(NULL);
window = do_tree_store(NULL);
/* */
/******************************************************************************/
window = (GtkWidget *)gtk_builder_get_object (builder, "window");
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
@ -1123,8 +1323,13 @@ main (int argc, char **argv)
g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
g_signal_connect (app, "command-line", G_CALLBACK (command_line), NULL);
g_signal_connect (app, "handle-local-options", G_CALLBACK (local_options), NULL);
printf("... tracking ... (line 1327)\n");
g_application_run (G_APPLICATION (app), argc, argv);
printf(" (line 1331 in demos/gtk-demo/main.c)\
>> [env] $ clear && meson compile && demos/gtk-demo/gtk4-demo\n");
return 0;
}

View File

@ -1,444 +1,281 @@
/* Tree View/Tree Store
/*************************************************** R E M E M B E R ! *******************************************************/
/* */
/* jean@Project:~/Gem-Graph/gem-graph-client/tree (learning)/The_Gnome_way/gtk$ guix shell -m manifest.scm --check */
/* guix shell: vérification des variables d'environnement visibles depuis le shell « /gnu/store/ --- (a commit) --- /bin/bash »… */
/* guix shell: Tout va bien ! Le shell a les bonnes variables d'environnement. */
/* jean@Project:~/Gem-Graph/gem-graph-client/tree (learning)/The_Gnome_way/gtk [env] $ cd builddir/ */
/* jean@Project:~/Gem-Graph/gem-graph-client/tree...way/gtk/builddir [env] $ clear && meson compile && demos/gtk-demo/gtk4-demo */
/* */
/* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- A Session -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- */
/* */
/* >>>>>>>>>>>>>>>>>> Modify line 944 in the main file to run examples <<<<<<<<<<<<<<<<< */
/* */
/* (gtk4-demo:24025): Gtk-CRITICAL **: 18:52:50.048: gtk_widget_get_display: assertion 'GTK_IS_WIDGET (widget)' failed */
/* in gtk/gtkwidget.c line 6902 : GdkDisplay *gtk_widget_get_display (GtkWidget *widget) { */
/* g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL); return _gtk_widget_get_display (widget); } */
/* */
/* (gtk4-demo:24025): Gtk-CRITICAL **: 18:52:50.048: gtk_window_set_display: assertion 'GDK_IS_DISPLAY (display)' failed */
/* in gtk/gtkwindow.c line 5700 : void gtk_window_set_display (GtkWindow *window, GdkDisplay *display) { } */
/* */
/* */
/* jean@Project:~/Gem-Graph/gem-graph-client/tree (learning)/The_Gnome_way/gtk/builddir [env] $ ctrl D (avant de fermer builder) */
/* */
/****************************************************************************************************************************************/
/******************************************** The basic ideas behind list views: ************************************************/
/* */
/* The data for items is provided in the form of a model (containing objects) */
/* Widgets are created just for the viewable range of items */
/* Widgets can be recycled by binding them to different items */
/* Avoid iterating over all items in the model as much as possible, */
/* and just deal with the items in the visible range which are bound to widgets */
/* from https://blog.gtk.org/2020/06/07/scalable-lists-in-gtk-4/ */
/* */
/****************************************************************************************************************************************/
// GtkListItemFactory is the object that is tasked with creating widgets for the items in the model.
// One implementations of this factory, GtkBuilderListItemFactory, is using ui files as templates for the list item widgets.
// https://gitlab.gnome.org/GNOME/gtk/-/blob/main/demos/gtk-demo/listview_settings.ui
/* Lists/Application launcher #Keywords: GtkListItemFactory, GListModel
* This demo uses the GtkListView widget as a fancy application launcher. It is also a very small introduction to listviews.
* https://gitlab.gnome.org/GNOME/gtk/-/blob/main/demos/gtk-demo/listview_applauncher.c */
/************************************************** W I D G E T S ********************************************************/
/* _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */
/* _ _ _ _ _ _ _ _ _ _ _ _ _ E D I T A B L E _ _ _ _ _ _ _ _ _ _ _ _ _ _ */
/* */
/* https://developer-old.gnome.org/gtk4/stable/ch03s02.html Which widget should I use ?... */
/* https://developer-old.gnome.org/gtk4/stable/GtkCellEditable.html#GtkCellEditable-struct */
/* The GtkCellEditable interface must be implemented for widgets to be usable to edit the contents of a GtkTreeView cell. */
/* It provides a way to specify how temporary widgets should be configured for editing, get the new value, etc. */
/* _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */
/* _ _ _ _ _ _ _ _ _ _ _ _ _ _ T R E E _ _ _ _ _ _ _ _ _ _ _ _ _ _ */
/* */
/* https://toshiocp.github.io/Gtk4-tutorial/sec29.html <<< TODO */
/* https://docs.gtk.org/gtk4/ */
/* https://docs.gtk.org/gtk4/section-list-widget.html << (see below the "quick comparison chart of equivalent functionalities") */
/* https://docs.gtk.org/gtk4/class.TreeListModel.html */
/* */
/* */
/* https://developer-old.gnome.org/gtk4/stable/GtkTreeView.html */
/* https://en.wikibooks.org/wiki/GTK%2B_By_Example/Tree_View/Custom_Models */
/* https://developer-old.gnome.org/gtk4/stable/GtkTreeSelection.html#GtkTreeSelection-struct */
/* https://developer-old.gnome.org/gtk4/stable/GtkTreeView.html#gtk-tree-view-get-path-at-pos << get-path-at-pos */
/* Finds the path at the point (x , y ), relative to bin_window coordinates. Use gtk_tree_view_convert_widget_to_bin_window_coords(). */
/* https://www.gnu.org/software/guile-gnome/docs/gtk/html/GtkCellRenderer.html */
/* GtkTreeSelection, GtkTreeView drag-and-drop, GtkTreeSortable, GtkTreeModelSort, GtkCellEditable, GtkCellRendererText,... */
/* gtk_tree_view_get_search_entry (treeview) https://blog.gtk.org/2020/09/08/on-list-models/ */
/* */
/****************************************************************************************************************************************/
// ? utile ?
// gtk_tree_model_foreach (model, TRUE, my_user_data); https://developer-old.gnome.org/gtk4/stable/GtkTreeModel.html#GtkTreeModelForeachFunc
/* ... Finally heres a quick comparison chart of equivalent functionalitqy
to look for when transitioning code:
Old New
..................................................................
GtkTreeModel GListModel
GtkTreePath guint position, GtkTreeListRow
GtkTreeIter guint position
GtkTreeRowReference GObject item
GtkListStore GListStore
GtkTreeStore GtkTreeListModel, GtkTreeExpander
GtkTreeSelection GtkSelectionModel
GtkTreeViewColumn GtkColumnView
GtkTreeView GtkListView, GtkColumnView
GtkCellView GtkListItem
GtkComboBox GtkDropDown
GtkIconView GtkGridView
GtkTreeSortable GtkColumnView
GtkTreeModelSort GtkSortListModel
GtkTreeModelFilter GtkFilterListModel
GtkCellLayout GtkListItemFactory
GtkCellArea GtkWidget
GtkCellRenderer GtkWidget
..............................................................................*/
/*..............................................................................
*
* The GtkTreeStore is used to store data in tree form, to be
* used later on by a GtkTreeView to display it. This demo builds
* a simple GtkTreeStore and displays it. If you're new to the
* GtkTreeView widgets and associates, look into the GtkListStore
* example first.
* >>> GtkStringList <<<
*
*/
* GtkStringList is a list model that wraps an array of strings.
* The objects in the model are of type GtkStringObject
* and have a string property that can be used inside expressions.
* Use it where/when you would typically use a char*[], but need a list model.
*
* implements GtkBuildable interface
* <item> are GObject instances; support translatable, context and comments
*
* <object class="GtkStringList">
* <items>
* <item translatable="yes">Factory</item>
* <item translatable="yes">Home</item>
* <item translatable="yes">Subway</item>
* </items>
* </object>
*
* Every item in a model has a position (= unsigned integer)
* "factories" takes care of mapping the items of the model
* to widgets that can be shown in the view
* by creating a listitem for each item that is currently in use.
* List items are always GtkListItem instances. Widgets can be recycled.
*
* GtkStringList can only handle strings. It is backed by a dynamically allocated array.
* GListStore is backed by a balanced tree.
*
* GTK provides functionality to make lists look and behave like trees
* by using the GtkTreeListModel and the GtkTreeExpander widget.
*
* Widgets are styleable using GTK CSS. Use the .rich-list style class.
*
*
* GListModel is an interface that represents a mutable list of GObjects.
* https://gnome.pages.gitlab.gnome.org/libsoup/gio/GListModel.html
* https://docs.gtk.org/gio/iface.ListModel.html < +++
* https://blog.gtk.org/2020/09/08/on-list-models/
*
*............................................................................*/
#include <gtk/gtk.h>
#include <stdio.h>
#include "config.h"
#include "custom-list.h"
#include <gio/gio.h>
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
enum
{
STRING_COLUMN,
NUM_COLUMNS
};
/* TreeItem structure */
typedef struct _TreeItem TreeItem;
struct _TreeItem
{
const char *label;
gboolean alex;
gboolean havoc;
gboolean tim;
gboolean owen;
gboolean dave;
gboolean world_holiday; /* shared by the European hackers */
TreeItem *children;
};
/* columns */
enum
{
HOLIDAY_NAME_COLUMN = 0,
ALEX_COLUMN,
HAVOC_COLUMN,
TIM_COLUMN,
OWEN_COLUMN,
DAVE_COLUMN,
VISIBLE_COLUMN,
WORLD_COLUMN,
NUM_COLUMNS
};
/* tree data */
static TreeItem january[] =
{
{"New Years Day", TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, NULL },
{"Presidential Inauguration", FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, NULL },
{"Martin Luther King Jr. day", FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, NULL },
{ NULL }
};
static TreeItem february[] =
{
{ "Presidents' Day", FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, NULL },
{ "Groundhog Day", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
{ "Valentine's Day", FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, NULL },
{ NULL }
};
static TreeItem march[] =
{
{ "National Tree Planting Day", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
{ "St Patrick's Day", FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, NULL },
{ NULL }
};
static TreeItem april[] =
{
{ "April Fools' Day", FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, NULL },
{ "Army Day", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
{ "Earth Day", FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, NULL },
{ "Administrative Professionals' Day", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
{ NULL }
};
static TreeItem may[] =
{
{ "Nurses' Day", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
{ "National Day of Prayer", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
{ "Mothers' Day", FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, NULL },
{ "Armed Forces Day", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
{ "Memorial Day", TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, NULL },
{ NULL }
};
static TreeItem june[] =
{
{ "June Fathers' Day", FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, NULL },
{ "Juneteenth (Liberation Day)", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
{ "Flag Day", FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, NULL },
{ NULL }
};
static TreeItem july[] =
{
{ "Parents' Day", FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, NULL },
{ "Independence Day", FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, NULL },
{ NULL }
};
static TreeItem august[] =
{
{ "Air Force Day", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
{ "Coast Guard Day", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
{ "Friendship Day", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
{ NULL }
};
static TreeItem september[] =
{
{ "Grandparents' Day", FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, NULL },
{ "Citizenship Day or Constitution Day", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
{ "Labor Day", TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, NULL },
{ NULL }
};
static TreeItem october[] =
{
{ "National Children's Day", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
{ "Bosses' Day", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
{ "Sweetest Day", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
{ "Mother-in-Law's Day", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
{ "Navy Day", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
{ "Columbus Day", FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, NULL },
{ "Halloween", FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, NULL },
{ NULL }
};
static TreeItem november[] =
{
{ "Marine Corps Day", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
{ "Veterans' Day", TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, NULL },
{ "Thanksgiving", FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, NULL },
{ NULL }
};
static TreeItem december[] =
{
{ "Pearl Harbor Remembrance Day", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
{ "Christmas", TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, NULL },
{ "Kwanzaa", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
{ NULL }
};
static TreeItem E[] = {NULL}, F[] = {NULL}, G[] = {NULL}, H[] = {NULL};
static TreeItem I[] = {NULL}, K[] = {NULL}, N[] = {NULL}, M[] = {NULL};
static TreeItem L[] = {{"M", M}, {"N", N}, {NULL }}, J[] = {{"L", L}, {NULL}};
static TreeItem D[] = {{"I", I}, {"J", J}, {"K", K}, {NULL}};
static TreeItem C[] = {{"F", F}, {"G", G}, {"H", H}, {NULL}};
static TreeItem A[] = {{"D", D}, {NULL}}, B[] = {{"E", E}, {NULL}};
static TreeItem R[] = {{"A", A}, {"B", B}, {"C", C}, {NULL}};
static TreeItem O[] = {{"ROOT", R}, {NULL}}; // Artefact added for symmetry
static TreeItem toplevel[] =
static GListStore *create_node_recursive (GListModel *model, // GListStore* g_list_store_new (GType item_type)
TreeItem *current_item,
GtkTreeIter *iter_parent,
int depth)
{
{"January", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, january},
{"February", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, february},
{"March", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, march},
{"April", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, april},
{"May", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, may},
{"June", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, june},
{"July", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, july},
{"August", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, august},
{"September", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, september},
{"October", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, october},
{"November", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, november},
{"December", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, december},
{NULL}
};
static GtkTreeModel *
create_model (void)
{
GtkTreeStore *model;
GtkTreeIter iter;
TreeItem *month = toplevel;
/* create tree store */
model = gtk_tree_store_new (NUM_COLUMNS,
G_TYPE_STRING,
G_TYPE_BOOLEAN,
G_TYPE_BOOLEAN,
G_TYPE_BOOLEAN,
G_TYPE_BOOLEAN,
G_TYPE_BOOLEAN,
G_TYPE_BOOLEAN,
G_TYPE_BOOLEAN);
if (model == NULL)
model = gtk_tree_store_new (NUM_COLUMNS, G_TYPE_STRING);
/* add data to the tree store */
while (month->label)
{
TreeItem *holiday = month->children;
while (current_item->label) {
if (0) printf("[%d] Current label : %s\n", depth, current_item->label);
gtk_tree_store_append (model, &iter, iter_parent);
gtk_tree_store_set (model, &iter, STRING_COLUMN, current_item->label, -1);
gtk_tree_store_append (model, &iter, NULL);
gtk_tree_store_set (model, &iter,
HOLIDAY_NAME_COLUMN, month->label,
ALEX_COLUMN, FALSE,
HAVOC_COLUMN, FALSE,
TIM_COLUMN, FALSE,
OWEN_COLUMN, FALSE,
DAVE_COLUMN, FALSE,
VISIBLE_COLUMN, FALSE,
WORLD_COLUMN, FALSE,
-1);
if (current_item->children)
create_node_recursive (model, current_item->children, &iter, depth + 1);
else
break;
/* add children */
while (holiday->label)
{
GtkTreeIter child_iter;
current_item++;
}
gtk_tree_store_append (model, &child_iter, &iter);
gtk_tree_store_set (model, &child_iter,
HOLIDAY_NAME_COLUMN, holiday->label,
ALEX_COLUMN, holiday->alex,
HAVOC_COLUMN, holiday->havoc,
TIM_COLUMN, holiday->tim,
OWEN_COLUMN, holiday->owen,
DAVE_COLUMN, holiday->dave,
VISIBLE_COLUMN, TRUE,
WORLD_COLUMN, holiday->world_holiday,
-1);
holiday++;
}
month++;
}
return GTK_TREE_MODEL (model);
if (depth == 0)
return G_LIST_MODEL(model); // can cast to GListModel or to GtkTreeStore ?
else
return NULL;
}
static void
item_toggled (GtkCellRendererToggle *cell,
char *path_str,
gpointer data)
{
GtkTreeModel *model = (GtkTreeModel *)data;
GtkTreePath *path = gtk_tree_path_new_from_string (path_str);
GtkTreeIter iter;
gboolean toggle_item;
int *column;
column = g_object_get_data (G_OBJECT (cell), "column");
/* get toggled iter */
gtk_tree_model_get_iter (model, &iter, path);
gtk_tree_model_get (model, &iter, column, &toggle_item, -1);
/* do something with the value */
toggle_item ^= 1;
/* set new value */
gtk_tree_store_set (GTK_TREE_STORE (model), &iter, column,
toggle_item, -1);
/* clean up */
gtk_tree_path_free (path);
}
static void
add_columns (GtkTreeView *treeview)
{
int col_offset;
GtkCellRenderer *renderer;
GtkTreeViewColumn *column;
GtkTreeModel *model = gtk_tree_view_get_model (treeview);
/* column for holiday names */
renderer = gtk_cell_renderer_text_new ();
g_object_set (renderer, "xalign", 0.0, NULL);
col_offset = gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview),
-1, "Holiday",
renderer, "text",
HOLIDAY_NAME_COLUMN,
NULL);
column = gtk_tree_view_get_column (GTK_TREE_VIEW (treeview), col_offset - 1);
gtk_tree_view_column_set_clickable (GTK_TREE_VIEW_COLUMN (column), TRUE);
/* alex column */
renderer = gtk_cell_renderer_toggle_new ();
g_object_set (renderer, "xalign", 0.0, NULL);
g_object_set_data (G_OBJECT (renderer), "column", (int *)ALEX_COLUMN);
g_signal_connect (renderer, "toggled", G_CALLBACK (item_toggled), model);
col_offset = gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview),
-1, "Alex",
renderer,
"active",
ALEX_COLUMN,
"visible",
VISIBLE_COLUMN,
"activatable",
WORLD_COLUMN, NULL);
column = gtk_tree_view_get_column (GTK_TREE_VIEW (treeview), col_offset - 1);
gtk_tree_view_column_set_sizing (GTK_TREE_VIEW_COLUMN (column),
GTK_TREE_VIEW_COLUMN_FIXED);
gtk_tree_view_column_set_clickable (GTK_TREE_VIEW_COLUMN (column), TRUE);
/* havoc column */
renderer = gtk_cell_renderer_toggle_new ();
g_object_set (renderer, "xalign", 0.0, NULL);
g_object_set_data (G_OBJECT (renderer), "column", (int *)HAVOC_COLUMN);
g_signal_connect (renderer, "toggled", G_CALLBACK (item_toggled), model);
col_offset = gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview),
-1, "Havoc",
renderer,
"active",
HAVOC_COLUMN,
"visible",
VISIBLE_COLUMN,
NULL);
column = gtk_tree_view_get_column (GTK_TREE_VIEW (treeview), col_offset - 1);
gtk_tree_view_column_set_sizing (GTK_TREE_VIEW_COLUMN (column),
GTK_TREE_VIEW_COLUMN_FIXED);
gtk_tree_view_column_set_clickable (GTK_TREE_VIEW_COLUMN (column), TRUE);
/* tim column */
renderer = gtk_cell_renderer_toggle_new ();
g_object_set (renderer, "xalign", 0.0, NULL);
g_object_set_data (G_OBJECT (renderer), "column", (int *)TIM_COLUMN);
g_signal_connect (renderer, "toggled", G_CALLBACK (item_toggled), model);
col_offset = gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview),
-1, "Tim",
renderer,
"active",
TIM_COLUMN,
"visible",
VISIBLE_COLUMN,
"activatable",
WORLD_COLUMN, NULL);
column = gtk_tree_view_get_column (GTK_TREE_VIEW (treeview), col_offset - 1);
gtk_tree_view_column_set_sizing (GTK_TREE_VIEW_COLUMN (column),
GTK_TREE_VIEW_COLUMN_FIXED);
gtk_tree_view_column_set_clickable (GTK_TREE_VIEW_COLUMN (column), TRUE);
/* owen column */
renderer = gtk_cell_renderer_toggle_new ();
g_object_set (renderer, "xalign", 0.0, NULL);
g_object_set_data (G_OBJECT (renderer), "column", (int *)OWEN_COLUMN);
g_signal_connect (renderer, "toggled", G_CALLBACK (item_toggled), model);
col_offset = gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview),
-1, "Owen",
renderer,
"active",
OWEN_COLUMN,
"visible",
VISIBLE_COLUMN,
NULL);
column = gtk_tree_view_get_column (GTK_TREE_VIEW (treeview), col_offset - 1);
gtk_tree_view_column_set_sizing (GTK_TREE_VIEW_COLUMN (column),
GTK_TREE_VIEW_COLUMN_FIXED);
gtk_tree_view_column_set_clickable (GTK_TREE_VIEW_COLUMN (column), TRUE);
/* dave column */
renderer = gtk_cell_renderer_toggle_new ();
g_object_set (renderer, "xalign", 0.0, NULL);
g_object_set_data (G_OBJECT (renderer), "column", (int *)DAVE_COLUMN);
g_signal_connect (renderer, "toggled", G_CALLBACK (item_toggled), model);
col_offset = gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview),
-1, "Dave",
renderer,
"active",
DAVE_COLUMN,
"visible",
VISIBLE_COLUMN,
NULL);
column = gtk_tree_view_get_column (GTK_TREE_VIEW (treeview), col_offset - 1);
gtk_tree_view_column_set_sizing (GTK_TREE_VIEW_COLUMN (column),
GTK_TREE_VIEW_COLUMN_FIXED);
gtk_tree_view_column_set_clickable (GTK_TREE_VIEW_COLUMN (column), TRUE);
}
GtkWidget *
do_tree_store (GtkWidget *do_widget)
{
static GtkWidget *window = NULL;
static GtkWidget *my_window = NULL;
if (!window)
if (! my_window)
{
GtkWidget *vbox;
GtkWidget *sw;
GtkWidget *treeview;
GtkTreeModel *model;
GtkWidget *my_tree_box;
GtkWidget *my_scrolled_window;
GtkWidget *my_tree_view;
GListStore *my_list_model = NULL;
/* create window, etc */
window = gtk_window_new ();
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);
my_window = gtk_window_new ();
gtk_window_set_title (GTK_WINDOW (my_window), "Tree Store");
g_object_add_weak_pointer (G_OBJECT (my_window), (gpointer *)&my_window);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
gtk_widget_set_margin_start (vbox, 8);
gtk_widget_set_margin_end (vbox, 8);
gtk_widget_set_margin_top (vbox, 8);
gtk_widget_set_margin_bottom (vbox, 8);
gtk_window_set_child (GTK_WINDOW (window), vbox);
my_tree_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
gtk_widget_set_margin_start (my_tree_box, 8);
gtk_widget_set_margin_end (my_tree_box, 8);
gtk_widget_set_margin_top (my_tree_box, 8);
gtk_widget_set_margin_bottom (my_tree_box, 8);
gtk_window_set_child (GTK_WINDOW (my_window), my_tree_box);
gtk_box_append (GTK_BOX (vbox),
gtk_label_new ("Jonathan's Holiday Card Planning Sheet"));
gtk_box_append (GTK_BOX (my_tree_box), gtk_label_new ("Learning GTK trees"));
sw = gtk_scrolled_window_new ();
gtk_scrolled_window_set_has_frame (GTK_SCROLLED_WINDOW (sw), TRUE);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
my_scrolled_window = gtk_scrolled_window_new ();
gtk_scrolled_window_set_has_frame (GTK_SCROLLED_WINDOW (my_scrolled_window), TRUE);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (my_scrolled_window),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
gtk_box_append (GTK_BOX (vbox), sw);
gtk_box_append (GTK_BOX (my_tree_box), my_scrolled_window);
/* create model */
model = create_model ();
/* create tree_model */
my_list_model = create_node_recursive (my_list_model, O, NULL, 0);
/* create tree view */
treeview = gtk_tree_view_new_with_model (model);
gtk_widget_set_vexpand (treeview, TRUE);
g_object_unref (model);
gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview)),
my_tree_view = gtk_tree_view_new_with_model (my_list_model);
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (my_tree_view), FALSE);
gtk_tree_view_set_enable_tree_lines (GTK_TREE_VIEW (my_tree_view), TRUE);
gtk_widget_set_vexpand (my_tree_view, TRUE);
gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (my_tree_view)),
GTK_SELECTION_MULTIPLE);
gtk_tree_view_set_reorderable (GTK_TREE_VIEW (my_tree_view), TRUE);
g_object_unref (my_list_model);
add_columns (GTK_TREE_VIEW (treeview));
GtkCellRenderer *renderer;
renderer = gtk_cell_renderer_text_new (); g_object_set (renderer, "xalign", 0.0, NULL);
gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (my_tree_view), -1,
"Col 0", renderer, "text", STRING_COLUMN, NULL);
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), treeview);
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (my_scrolled_window), my_tree_view);
/* expand all rows after the treeview widget has been realized */
g_signal_connect (treeview, "realize",
/* expand all rows after the my_tree_view widget has been realized */
g_signal_connect (my_tree_view, "realize",
G_CALLBACK (gtk_tree_view_expand_all), NULL);
gtk_window_set_default_size (GTK_WINDOW (window), 650, 400);
gtk_window_set_default_size (GTK_WINDOW (my_window), 200, 400);
}
if (!gtk_widget_get_visible (window))
gtk_widget_set_visible (window, TRUE);
if (!gtk_widget_get_visible (my_window))
gtk_widget_set_visible (my_window, TRUE);
else
gtk_window_destroy (GTK_WINDOW (window));
return window;
gtk_window_destroy (GTK_WINDOW (my_window));
return my_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

View File

@ -90,7 +90,7 @@
#include <gtk/gtkcolumnviewcolumn.h>
#include <gtk/gtkcolumnviewrow.h>
#include <gtk/gtkcolumnviewsorter.h>
#include <gtk/deprecated/gtkcombobox.h>
//#include <gtk/deprecated/gtkcombobox.h>
#include <gtk/deprecated/gtkcomboboxtext.h>
#include <gtk/gtkconstraintlayout.h>
#include <gtk/gtkconstraint.h>

36
manifest.scm Normal file
View File

@ -0,0 +1,36 @@
(specifications->manifest
(list
"clang"
"cmark"
"desktop-file-utils"
"devhelp"
"flatpak"
"gettext-minimal"
"glade"
"glib"
"gspell"
"gst-plugins-bad"
"gtk+"
"gtksourceview"
"json-glib"
"jsonrpc-glib"
"libdazzle"
"libgit2-glib"
"libhandy"
"libostree"
"libpeas"
"libportal"
"libsoup-minimal"
"llvm"
"meson"
"ninja"
"gcc-toolchain"
"pkg-config"
"python-pygobject"
"python"
"sysprof"
"template-glib"
"vala"
"vte"
"webkitgtk-with-libsoup2"
"xorg-server"))

View File

@ -50,13 +50,6 @@ foreach setup : setups
'GDK_BACKEND=@0@'.format(backend),
] + setup.get('env', [])
add_test_setup(
name,
env: env + ['TEST_OUTPUT_SUBDIR=@0@'.format(name)],
exclude_suites: exclude_unstable + exclude,
is_default: setup.get('is_default', false),
)
add_test_setup(
'@0@_unstable'.format(name),
env: env + ['TEST_OUTPUT_SUBDIR=@0@_unstable'.format(name)],