WIP: cleaning (static GtkWindow *main_window, *dialog_window; < in widgets.c)

This commit is contained in:
Jean Sirmai 2024-07-02 17:59:43 +02:00
parent a4a80c63fe
commit 27f3804025
Signed by: jean
GPG Key ID: FB3115C340E057E3
5 changed files with 425 additions and 45 deletions

363
(mes notes) Normal file
View File

@ -0,0 +1,363 @@
src/libide/tree/ide-tree.c (597) static void ide_tree_init (IdeTree *self) {.}
src/libide/tree/ide-tree-model.c (663) static void tree_model_iface_init (GtkTreeModelIface *iface) {.}
src/libide/tree/ide-tree-node.c (31) Since: 3.32
* The #IdeTreeNode class is used to represent an item that should be displayed in the tree of the Ide application.
* The #IdeTreeAddin plugins create and maintain these nodes during the lifetime of the program.
* Plugins that want to add items to the tree should implement the #IdeTreeAddin interface and register it during plugin initialization.
src/libide/tree/ide-tree-node.c (127) enum {
PROP_0,
PROP_CHILDREN_POSSIBLE,
PROP_DESTROY_ITEM,
PROP_DISPLAY_NAME,
PROP_EXPANDED_ICON,
PROP_EXPANDED_ICON_NAME,
PROP_HAS_ERROR,
PROP_ICON,
PROP_ICON_NAME,
PROP_IS_HEADER,
PROP_ITEM,
PROP_RESET_ON_COLLAPSE,
PROP_TAG,
PROP_USE_MARKUP,
N_PROPS
};
src/libide/tree/ide-tree-node.c (48) struct _IdeTreeNode
{
GObject parent_instance;
/* A pointer to the model, which is only set on the root node. */
IdeTreeModel *model;
/* The following are fields containing the values for various properties on the tree node.
* Usually, icon, display_name, and item will be set on all nodes. */
GIcon *icon;
GIcon *expanded_icon;
gchar *display_name;
GObject *item;
gchar *tag;
GList *emblems;
/* The following items are used to maintain a tree structure of nodes for which we can use O(1) operations.
* The link is inserted into the parents children queue. The parent pointer is unowned, and set by the parent (cleared upon removal).
* This also allows maintaining the tree structure with zero additional allocations beyond the nodes themselves.
*/
IdeTreeNode *parent;
GQueue children;
GList link;
/* Foreground and Background colors */
GdkRGBA background;
GdkRGBA foreground;
/* Flags for state cell renderer */
IdeTreeNodeFlags flags;
/* When did we start loading? This is used to avoid drawing "Loading..." when the tree loads really quickly. Otherwise, we risk looking janky when the loads are quite fast. */
gint64 started_loading_at;
/* If we're currently loading */
guint is_loading : 1;
/* If the node is a header (bold, etc) */
guint is_header : 1;
/* If this is a synthesized empty node */
guint is_empty : 1;
/* If there are errors associated with the node's item */
guint has_error : 1;
/* If the node maybe has children */
guint children_possible : 1;
/* If this node needs to have the children built */
guint needs_build_children : 1;
/* If true, we remove all children on collapse */
guint reset_on_collapse : 1;
/* If pango markup should be used */
guint use_markup : 1;
/* If true, we use ide_clear_and_destroy_object() */
guint destroy_item : 1;
/* If colors are set */
guint background_set : 1;
guint foreground_set : 1;
};
src/libide/tree/ide-tree-node.c (1763) /* If the node is not on screen, we need to animate until we get there. */
src/libide/tree/ide-tree-node.c (1776) /* FIXME: Time period comes from gtk animation duration. Not curently available in pubic API.
* We need to be greater than the max timeout it could take to move, since we must have it on screen by then.
* One alternative might be to check the result and if we are still not on screen, then just pin it to a row-height from the top or bottom.
/----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------/
src/libide/tree/ide-tree-addin.c (108) /* ide_tree_addin_build_children_async() Since: 3.32
* This function is called when building the children of a node.
* This happens when expanding an node that might have children, or building the root node.
* You may want to use ide_tree_node_holds() to determine if the node contains an item that you are interested in.
* This function will call the synchronous form of IdeTreeAddin.build_children() if no asynchronous form is available.
src/libide/tree/ide-tree-addin.c (143) /* ide_tree_addin_build_children_finish() Since: 3.32
* Completes an asynchronous request to ide_tree_addin_build_children_async().
* Returns: %TRUE if successful; otherwise %FALSE and @error is set.
src/libide/tree/ide-tree-addin.c (167) /* ide_tree_addin_build_node() Since: 3.32
* This function is called when preparing a node for display in the tree.
* Addins should adjust any state on the node that makes sense based on the addin.
* You may want to use ide_tree_node_holds() to determine if the node contains an item that you are interested in.
src/libide/tree/ide-tree-addin.c (194) /* ide_tree_addin_activated() Since: 3.32
* This function is called when a node has been activated in the tree and allows for the addin to perform any necessary operations in response to that.
* If the addin performs an action based on the activation request, then it should return %TRUE from this function so that no further addins may respond to the action.
* Returns: %TRUE if the activation was handled, otherwise %FALSE
/----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------/
src/libide/tree/ide-cell-renderer-status (29) #define CELL_HEIGHT 16, CELL_WIDTH 16, RPAD 8, LPAD 3
/----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------/
src/libide/gui/ide-cell-renderer-fancy.c (166)
HACK: @width is the min_width returned in our get_preferred_width() function. That results in pretty bad values here, so we will do this by assuming we are the only widget in the tree view.
* This makes this cell very much not usable for generic situations, but it does make it so we can do text wrapping without resorting to GtkListBox *for our exact usecase only*.
* The problem here is that we require the widget to already be realized and allocated and that we are the only renderer within the only column (and also, in a treeview) without exotic styling.
* If we get something absurdly small (like 50) that is because we are hitting our minimum size of (xpad * 2).
* So this works around the issue and tries to get something reasonable with wrapping at the 200px mark (our ~default width for panels).
* Furthermore, we need to queue a resize when the column size changes (as it will from resizing the widget). So the tree view must also call gtk_tree_view_column_queue_resize().
https://en.wikibooks.org/wiki/GTK%2B_By_Example/Tree_View/Custom_Models
Working Example: Custom List Model Source Code
Here is the complete source code for the custom list model presented above. Compile with:
gcc -o customlist custom-list.c main.c `pkg-config --cflags --libs gtk+-2.0`
* custom-list.h
* custom-list.c
* main.c
https://blog.gtk.org/2020/06/07/scalable-lists-in-gtk-4/
https://docs.gtk.org/gtk4/section-list-widget.html
A GtkListItemFactory creates widgets for the items taken from a GListModel.
https://docs.gtk.org/gtk4/class.ListItemFactory.html
GtkBuilderListItemFactory is a GtkListItemFactory that creates widgets by instantiating GtkBuilder UI templates.
The templates must be extending GtkListItem, and typically use GtkExpressions to obtain data from the items in the model.
https://docs.gtk.org/gtk4/class.BuilderListItemFactory.html
GListModel is an interface that represents a mutable list of GObjects. Its main intention is as a model for various widgets in user interfaces, such as list views, but it can also be used as a convenient method of returning lists of data, with support for updates.
https://docs.gtk.org/gio/iface.ListModel.html
----------------------------------------------------------------------------------------------------------------
https://docs.gtk.org/gtk4/getting_started.html
https://docs.gtk.org/gtk4/overview.html
https://flathub.org/apps/details/ar.xjuan.Cambalache
https://github.com/Taiko2k/GTK4PythonTutorial
https://github.com/ToshioCP/Gtk4-tutorial
https://developer.gnome.org/documentation/tutorials/beginners/getting_started.html
https://github.com/Taiko2k/GTK4PythonTutorial#readme
----------------------------------------------------------------------------------------------------------------
GTK Development Blog
All things GTK
Scalable lists in GTK 4
One of the last big missing pieces in GTK 4 is the infrastructure for new list and grid widgets. It has just been merged and is included in the 3.98.5 release. So it is time to take a closer look.
History: tree views and list boxes
Since ancient times (ie GTK 2), GtkTreeView has been the go-to data display widget in GTK. It uses a model-view pattern to keep the data separate from the display infrastructure. Over the years, it has grown a grid-display sibling (GtkIconView) and a selection cousin (GtkComboBox), using the same infrastructure (tree models and cell renderers).
Unfortunately, the approach taken for rendering in GtkTreeView with cell renderers left us with a schism: widgets use one set of vfuncs and technologies for size allocation and rendering, and cell renderers use another. One of the unfortunate consequences of this split is that it is very hard to do animations in tree views (since cell renderers dont keep state). Another is that most of the advances of the GTK CSS rendering machinery are unavailable in cell renderers.
Therefore, we would really like to use widgets for displaying the data in lists. During the GTK 3 era, we have introduced a number of containers for this purpose: GtkListBox for lists, and GtkFlowBox for grids. They dont use cell renderers, so the aforementioned limitations are not a concern. And they can even use list models to hold the data. But they generate a widget for each data item, and this severely limits their scalability. As a rule of thumb, GtkListBox can handle 1000 items well, while GtkTreeView works fine for 100000.
Overcoming the scalability limitations, while still using widgets for all rendering has been on our roadmap for a long time.
Scalability limits Widget Scalability
GtkIconView 100
GtkListBox 1000
GtkTreeView 100000
GtkListView unlimited
New infrastructure
With list view family of widgets, we hope to finally achieve that. The goal is to handle unlimited numbers of items well. If youve worked with things like the Android recycler view, you will recognize 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
Models
For the model side of our model-view architecture, weve moved away from GtkTreeModel, and are now using GListModel. There are several reasons for this. One is that we want the items to be objects with properties, so we can use property bindings. Another one is that GtkTreeModel is not all that scalable in the first place (see e.g. this case of unintentional quadratic behavior).
GTK 4 comes with a rich assortment of GListModel implementations, from various ways to combine or modify existing models to filtering and sorting. Filtering and sorting is supported by several GtkFilter and GtkSorter classes. Selections are also handled on the model side, with GtkSelectionModel and its subclasses.
Finally, there are concrete models for the kinds of data that we are dealing with: GtkDirectoryList for files, PangoFontMap for fonts.
APIs that have traditionally returns GLists of various items have been changed or supplemented with APIs returning a GListModel, for example gdk_display_get_monitors(), gtk_window_get_toplevels() and gtk_stack_get_pages().
Factories
Since we are talking about automatically creating widgets on demand, there will be factories involved. GtkListItemFactory is the object that is tasked with creating widgets for the items in the model.
There are different implementations of this factory. One of them, GtkBuilderListItemFactory, is using ui files as templates for the list item widgets. Here is a typical example:
<interface>
<template class="GtkListItem">
<property name="child">
<object class="GtkLabel">
<property name="xalign">0</property>
<property name="wrap">1</property>
<property name="width-chars">50</property>
<property name="max-width-chars">50</property>
<binding name="label">
<lookup name="summary" type="SettingsKey">
<lookup name="item">GtkListItem</lookup>
</lookup>
</binding>
</object>
</property>
</template>
</interface>
The full example can be found in gtk4-demo.
Another list item factory implementation, GtkSignalListItemFactory, takes callbacks to setup, teardown, bind and unbind widgets from the items.
static void
setup_listitem_cb (GtkListItemFactory *factory,
GtkListItem *list_item)
{
GtkWidget *image;
image = gtk_image_new ();
gtk_image_set_icon_size (GTK_IMAGE (image), GTK_ICON_SIZE_LARGE);
gtk_list_item_set_child (list_item, image);
}
static void
bind_listitem_cb (GtkListItemFactory *factory,
GtkListItem *list_item)
{
GtkWidget *image;
GAppInfo *app_info;
image = gtk_list_item_get_child (list_item);
app_info = gtk_list_item_get_item (list_item);
gtk_image_set_from_gicon (GTK_IMAGE (image),
g_app_info_get_icon (app_info));
}
static void
activate_cb (GtkListView *list,
guint position,
gpointer unused)
{
GListModel *model;
GAppInfo *app_info;
model = gtk_list_view_get_model (list);
app_info = g_list_model_get_item (model, position);
g_app_info_launch (app_info, NULL, NULL, NULL);
g_object_unref (app_info);
}
...
factory = gtk_signal_list_item_factory_new ();
g_signal_connect (factory, "setup", setup_listitem_cb, NULL);
g_signal_connect (factory, "bind", bind_listitem_cb, NULL);
list = gtk_list_view_new_with_factory (factory);
g_signal_connect (list, "activate", activate_cb, NULL);
model = create_application_list ();
gtk_list_view_set_model (GTK_LIST_VIEW (list), model);
g_object_unref (model);
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), list);
The full example can be found here.
Expressions
To bind the widgets that are created by the factory to the data in your items, we need a flexible mechanism for binding properties. GObjects GBinding mechanism goes in the right direction, but is not flexible enough to handle situations where you may need to bind properties of sub-objects or widgets deep inside the hierarchy of your widget, and where the objects in questions may not even exist at the time you are setting up the binding.
To handle this, weve introduced GtkExpression as a more flexible binding system which can express things like:
label = this->item->value
where this is a GtkListItem, which has an item property (of type SettingsKey), whose value property we want to bind to the label property. Expressing the same in a GtkBuilder ui file looks a bit more unwieldy:
<binding name="label">
<lookup name="value" type="SettingsKey">
<lookup name="item">GtkListItem</lookup>
</lookup>
</binding>
New widgets
GtkListView is a simple list, without columns or headers. An example where this kind of list is used is GtkFontChooser. One little way in which GtkListView breaks new ground is that it can be set up as a horizontal list, as well as the usual vertical orientation.
GtkGridView puts the widgets in a reflowing grid, much like GtkFlowBox or GtkIconView.
GtkColumnView is the equivalent of a full GtkTreeView, with multiple columns and headers, and features such as interactive resizing and reordering. Just like a GtkTreeView has GtkTreeViewColumns, a GtkColumnView has a list of GtkColumnViewColumns. Each column has a factory that produces a cell for each item. The cells are then combined into the row for the item.
Examples
Many of the lists in complex GTK dialogs (although not all yet) have been replaced with the new list widgets. For example, the font chooser is now using a GtkListView, and most of the lists in the GTK inspector use GtkColumnView.
But gtk4-demo contains a number of examples for the new widgets. Here are a few:
The clocks examples shows the advantages of having the full flexibility of widget rendering available.
The colors example shows the a medium-size dataset rendered in various ways.
The settings example shows that the column view more or less matches GtkTreeView, feature-wise.
Summary
This post gave an introduction to the new list widgets. Theres more that we havent touched on here, such as trees or the combo box replacement. One place to learn more about the new apis is the detailed introduction in the GTK documentation.
Weve merged the listview infrastructure to master now. That doesnt mean that it is finished. But we think it is ready for some wider use, and we hope to get feedback from you on what works, what doesnt and what is missing.
And, to be clear, it also does not mean that we are removing treeviews and combo boxes from GTK 4—it is too late for that, and they are still used in many places inside GTK. That may be a GTK 5 goal.

View File

@ -38,10 +38,16 @@
#define W_IMAGE_LOCAL W / 16
#define H_IMAGE_LOCAL H / 16
void set_main_window (GtkApplication *app);
void set_dialog_window (GtkApplication *app);
void main_window_design (GtkWindow *main_window);
void dialog_window_design (GtkWindow *main_window,
GtkWindow *dialog_window);
GtkWindow *get_main_window();
GtkWindow *get_dialog_window();
GtkWidget *get_window_child_STATE();
GtkWidget *get_window_child_RULES();
GtkWidget *get_window_child_DATA();
@ -51,7 +57,7 @@ GtkWidget *get_rules_tree_hpaned_new();
GtkWidget *get_rules_page_new();
GtkWidget *get_TIME_EXEC_controls_box();
GtkWidget *get_SPACE_EDIT_controls_box();
//GtkWidget *get_SPACE_EDIT_controls_box();
GtkWidget *get_OBJECTS_and_SITUATIONS();
GtkWidget *get_text_view();
@ -83,6 +89,7 @@ struct TreeNode_t {gchar *text; struct TreeNode_t *child, *next;};
void add_child_node (struct TreeNode_t *parent, struct TreeNode_t *child);
struct TreeNode_t *create_user_tree_node (const gchar* text);
void let_us_create_a_complex_useless_and_expensive_tree (struct TreeNode_t *tree_root);
GtkScrolledWindow *get_user_rules_tree ();
void icons_for_fun (GtkHeaderBar *header_bar);

View File

@ -35,24 +35,22 @@
/* W I N D O W S A C T I V A T I O N S */
/******************************************************************************/
static GtkWindow *main_window, *dialog_window;
void on_main_window_activation (GtkApplication *app,
gpointer no_user_data)
{
main_window = GTK_WINDOW (gtk_application_window_new (app));
main_window_design (main_window);
set_main_window (app);
main_window_design (get_main_window());
}
void on_dialog_window_activation (GtkApplication *app,
gpointer no_user_data)
{
dialog_window = GTK_WINDOW (gtk_application_window_new (app));
dialog_window_design (main_window,
dialog_window);
set_dialog_window (app);
dialog_window_design (get_main_window(),
get_dialog_window());
gtk_window_present (GTK_WINDOW (dialog_window));
gtk_window_present (GTK_WINDOW (get_dialog_window()));
}
@ -225,15 +223,15 @@ static void switch_STATE_RULES_DATA() {
switch (get_STATE_RULES_DATA()) {
case (STATE) :
gtk_window_set_child (main_window, GTK_WIDGET (get_window_child_STATE()));
gtk_window_set_child (get_main_window(), GTK_WIDGET (get_window_child_STATE()));
break;
case (RULES) :
gtk_window_set_child (main_window, GTK_WIDGET (get_window_child_RULES()));
gtk_window_set_child (get_main_window(), GTK_WIDGET (get_window_child_RULES()));
break;
case (DATA) :
gtk_window_set_child (main_window, GTK_WIDGET (get_window_child_DATA()));
gtk_window_set_child (get_main_window(), GTK_WIDGET (get_window_child_DATA()));
break;
default :
@ -255,7 +253,7 @@ void on_toggle_EXEC_EDIT (GtkWidget *toggled_button, gpointer user_data) {
"text-editor-symbolic");
// https://docs.gtk.org/gtk4/class.Window.html TODO 2024-06-30
// gtk_window_present (GTK_WINDOW (dialog_window)); // works once only !
// gtk_window_present (GTK_WINDOW (get_dialog_window())); // works once only !
set_EXEC_EDIT (EDIT);
}

View File

@ -30,18 +30,36 @@
#include "../include/callbacks.h"
#include "../include/widgets.h"
// https://blog.gtk.org/2020/09/08/on-list-models/ < TODO
// https://docs.gtk.org/gtk4/visual_index.html < widgets gallery
static GtkWindow *main_window, *dialog_window;
static GtkButton *btt_open_STATE, *btt_open_RULES, *btt_open_DATA;
GtkWindow *get_main_window() {return main_window;}
GtkWindow *get_dialog_window() {return dialog_window;}
void set_main_window (GtkApplication *app) {
main_window = GTK_WINDOW (gtk_application_window_new (app));
}
void set_dialog_window (GtkApplication *app) {
dialog_window = GTK_WINDOW (gtk_application_window_new (app));
}
GtkButton *get_GtkButton (char *btt_name) {
if (strcmp (btt_name, "state")) return btt_open_STATE;
if (strcmp (btt_name, "rules")) return btt_open_RULES;
if (strcmp (btt_name, "data analysis")) return btt_open_DATA;
return NULL;
}
GtkFrame *get_frame_with_label(){ // EN ATTENDANT DE SAVOIR UTILISER : GtkTextTagTable , GtkTextBuffer
GtkFrame *get_frame_with_label() { // EN ATTENDANT DE SAVOIR UTILISER : GtkTextTagTable , GtkTextBuffer
GtkFrame *space_specif = GTK_FRAME(gtk_frame_new ("Space (run / edit) specifications"));
GtkWidget *any_Label = GTK_WIDGET (gtk_label_new (get_space_run_edit_specif()));
gtk_frame_set_child (GTK_FRAME (space_specif), GTK_WIDGET (any_Label));
return space_specif;
}
GtkWidget *get_edit_rules_page_new(){
GtkWidget *get_edit_rules_page_new() {
GtkPaned *hpaned = GTK_PANED (gtk_paned_new (GTK_ORIENTATION_HORIZONTAL));
GtkWidget *arbre_des_règles = gtk_frame_new ("Arbre des règles");
@ -55,28 +73,28 @@ GtkWidget *get_edit_rules_page_new(){
return GTK_WIDGET (hpaned);
}
GtkWidget *get_edit_measures_page_new(){
GtkWidget *get_edit_measures_page_new() {
GtkWidget *measures_grid = gtk_grid_new();
return measures_grid;
}
GtkWidget *get_edit_results_page_new(){
GtkWidget *get_edit_results_page_new() {
GtkWidget *xxx_grid = gtk_grid_new();
return xxx_grid;
}
GtkWidget *get_edit_discuss_page_new(){
GtkWidget *get_edit_discuss_page_new() {
GtkWidget *xxx_grid = gtk_grid_new();
return xxx_grid;
}
GtkWidget *get_edit_help_page_new(){
GtkWidget *get_edit_help_page_new() {
GtkWidget *edit_help_grid = gtk_grid_new();
gtk_grid_attach (GTK_GRID(edit_help_grid), GTK_WIDGET(get_frame_with_label()), 0, 0, 1, 1);
return edit_help_grid;
}
GtkWidget *get_measures_page_new(){
GtkWidget *get_measures_page_new() {
GtkWidget *measures_grid = gtk_grid_new();
gtk_grid_attach (GTK_GRID (measures_grid), gtk_button_new_with_label ("movements"), 0, 0, 1, 1);
gtk_grid_attach (GTK_GRID (measures_grid), gtk_button_new_with_label ("transports"), 1, 0, 1, 1);
@ -86,7 +104,7 @@ GtkWidget *get_measures_page_new(){
return measures_grid;
}
GtkWidget *get_results_page_new(){
GtkWidget *get_results_page_new() {
GtkWidget *results_grid = gtk_grid_new();
gtk_grid_attach (GTK_GRID(results_grid), gtk_button_new_with_label ("Repartitions"), 0, 0, 1, 1);
gtk_grid_attach (GTK_GRID(results_grid), gtk_button_new_with_label ("Correlations"), 0, 1, 1, 1);
@ -94,20 +112,20 @@ GtkWidget *get_results_page_new(){
return results_grid;
}
GtkWidget *get_discuss_page_new(){
GtkWidget *get_discuss_page_new() {
GtkWidget *discuss_grid = gtk_grid_new();
gtk_grid_attach (GTK_GRID (discuss_grid), gtk_button_new_with_label ("Interpretations"), 0, 0, 1, 1);
gtk_grid_attach (GTK_GRID (discuss_grid), gtk_button_new_with_label ("Discussions"), 0, 1, 1, 1);
return discuss_grid;
}
GtkWidget *get_help_page_new(){
GtkWidget *get_help_page_new() {
GtkWidget *run_help_grid = gtk_grid_new();
gtk_grid_attach (GTK_GRID(run_help_grid), GTK_WIDGET(get_frame_with_label()), 0, 0, 1, 1);
return run_help_grid;
}
GtkWidget *get_edit_space_page_new(){
GtkWidget *get_edit_space_page_new() {
GtkWidget *space_grid = gtk_grid_new();
gtk_grid_attach (GTK_GRID(space_grid), get_image_ALL_SPACE(), 0, 0, 1, 3);
gtk_grid_attach (GTK_GRID(space_grid), get_OBJECTS_and_SITUATIONS(), 0, 4, 1, 1);
@ -120,7 +138,7 @@ GtkWidget *get_edit_space_page_new(){
//------------------------------------------------------------------------------
GtkWidget *get_selected_rules_vpaned_new(){
GtkWidget *get_selected_rules_vpaned_new() {
GtkPaned *V_selected_1_vs_2 = GTK_PANED (gtk_paned_new (GTK_ORIENTATION_VERTICAL));
GtkBox *up_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2));
@ -141,7 +159,7 @@ GtkWidget *get_selected_rules_vpaned_new(){
GtkWidget *get_TIME_EXEC_controls_box(){
GtkWidget *get_TIME_EXEC_controls_box() {
GtkBox *top_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2));
gtk_box_append (top_box, GTK_WIDGET (get_ELAPSED_TIME_ProgressBar()));
gtk_box_append (top_box, GTK_WIDGET(gtk_separator_new (GTK_ORIENTATION_VERTICAL)));
@ -149,7 +167,7 @@ GtkWidget *get_TIME_EXEC_controls_box(){
return GTK_WIDGET (top_box);
}
GtkWidget *get_SPACE_VIEW_box(){
GtkWidget *get_SPACE_VIEW_box() {
GtkBox *right_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 2));
gtk_box_append (right_box, GTK_WIDGET (get_XYZ_box()));
gtk_box_append (right_box, GTK_WIDGET (gtk_separator_new (GTK_ORIENTATION_HORIZONTAL)));
@ -167,31 +185,20 @@ GtkWidget *get_SPACE_VIEW_box(){
return GTK_WIDGET (middle_box);
}
GtkWidget *get_SPACE_EDIT_controls_box() {
static GtkWidget *get_SPACE_EDIT_controls_box() {
GtkWidget *label_ad_hoc = gtk_label_new ("_____________\n\
SPACE EDIT\n controls\n_____________");
return GTK_WIDGET (label_ad_hoc);
}
static GtkButton *btt_open_STATE;
static GtkButton *btt_open_RULES;
static GtkButton *btt_open_DATA;
GtkButton *get_GtkButton (char *btt_name) {
if (strcmp (btt_name, "state")) return btt_open_STATE;
if (strcmp (btt_name, "rules")) return btt_open_RULES;
if (strcmp (btt_name, "data analysis")) return btt_open_DATA;
return NULL;
}
void set_check_button_active (GtkButton *button, int active){
const char *lab = gtk_button_get_label (button);
if (strcmp (lab, "state")) printf("set_check_button_active > %s\n", lab);
}
void window_header_bar (GtkWindow *window, char *title){
static void window_header_bar (GtkWindow *window, char *title){
GtkWidget *header_bar = GTK_WIDGET (gtk_header_bar_new ());
gtk_header_bar_set_title_widget (GTK_HEADER_BAR (header_bar), gtk_label_new (title));
gtk_window_set_titlebar (window, header_bar);
@ -200,7 +207,6 @@ void window_header_bar (GtkWindow *window, char *title){
GtkButton *btt_XOR_EXEC_EDIT = GTK_BUTTON (gtk_toggle_button_new ());
gtk_button_set_icon_name (btt_XOR_EXEC_EDIT, "system-run-symbolic");
gtk_button_set_icon_name (btt_XOR_EXEC_EDIT, "process-stop-symbolic");
gtk_button_set_icon_name (btt_XOR_EXEC_EDIT, "power-profile-balanced-rtl-symbolic");
g_signal_connect (btt_XOR_EXEC_EDIT, "clicked", G_CALLBACK (on_toggle_EXEC_EDIT), no_local_data);
@ -261,7 +267,7 @@ GtkWidget *get_window_child_STATE() {
return GTK_WIDGET (page_box);
}
GtkWidget *get_window_child_RULES(){
GtkWidget *get_window_child_RULES() {
if (0) printf("widgets.get_window_child_RULES (line 246)\n");
GtkPaned *H_tree_vs_selected = GTK_PANED (gtk_paned_new (GTK_ORIENTATION_HORIZONTAL));
// GtkWidget *arbre_des_règles = gtk_frame_new ("Arbre des règles");
@ -273,7 +279,7 @@ GtkWidget *get_window_child_RULES(){
return GTK_WIDGET (H_tree_vs_selected);
}
GtkWidget *get_window_child_DATA (){
GtkWidget *get_window_child_DATA () {
if (0) printf("widgets.get_window_child_DATA (line 279)\n");
GtkBox *data_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 32));

View File

@ -29,6 +29,10 @@
#include "../include/widgets.h"
// https://blog.gtk.org/2020/09/08/on-list-models/ < TODO
// https://docs.gtk.org/gtk4/visual_index.html < widgets gallery
//------------------------------------------------------------------------------
GtkWidget *get_image_ALL_SPACE(){
@ -419,6 +423,8 @@ void icons_for_fun (GtkHeaderBar *header_bar) // https://iconduck.com/sets/a
GtkButton *power_low = GTK_BUTTON (gtk_button_new ());
gtk_button_set_icon_name (power_low, "power-profile-power-saver-symbolic");
gtk_header_bar_pack_end (header_bar, GTK_WIDGET (power_low));
// gtk_button_set_icon_name (btt_XOR_EXEC_EDIT, "process-stop-symbolic");
}
void let_us_create_a_complex_useless_and_expensive_tree (struct TreeNode_t *tree_root) {