Compare commits
No commits in common. "fadd5f256fe2bf70bc48657fc46ae578116732fe" and "8cbf759e0bb98afd043c601bf3b5c089f939076e" have entirely different histories.
fadd5f256f
...
8cbf759e0b
|
@ -128,5 +128,3 @@ GtkWidget *create_my_deprec_tree_model(GtkBox *runlib_objects);
|
|||
GtkWidget *create_my_button_test(GtkBox *runlib_objects);
|
||||
GtkWidget *create_my_list_view_test(GtkBox *runlib_objects);
|
||||
GtkWidget *create_my_editable_cells (GtkBox *my_box);
|
||||
|
||||
void hello_it_s_me();
|
||||
|
|
|
@ -58,8 +58,6 @@
|
|||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
hello_it_s_me(); // in bac-à-sable
|
||||
|
||||
g_autoptr(GemGraphClientApplication) app = NULL;
|
||||
int res;
|
||||
|
||||
|
@ -69,4 +67,3 @@ int main(int argc, char **argv)
|
|||
res = g_application_run(G_APPLICATION(app), argc, argv);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,38 +28,71 @@
|
|||
#include "../../include/base.h"
|
||||
#include "../../include/ui.h"
|
||||
|
||||
enum {
|
||||
FILE_NAME,
|
||||
FILE_OFFSET,
|
||||
FILE_SIZE,
|
||||
FILE_DESCRIPTION, /* Not used by the view, maybe used elsewhere */
|
||||
COLOR, /* Just to show how the model can affect the view */
|
||||
N_COLUMNS
|
||||
};
|
||||
|
||||
static void on_button_action (GtkWidget *widget, gpointer data) { g_print ("Hello, it's me ! (again)\n");}
|
||||
|
||||
static void on_destroy (GtkWidget *widget, gpointer data) { exit(0);}
|
||||
|
||||
void hello_it_s_me()
|
||||
GtkWidget *create_my_list_view_test(GtkBox *runlib_objects)
|
||||
{
|
||||
GtkWidget *my_window;
|
||||
GtkWidget *my_box;
|
||||
GtkWidget *my_button;
|
||||
char *my_title = "Hello, it's me !";
|
||||
char *my_button_title = "And I'm the button.";
|
||||
GtkListStore* model;
|
||||
GtkWidget* view;
|
||||
GtkTreeViewColumn* column;
|
||||
GtkWidget* window;
|
||||
|
||||
gtk_init();
|
||||
my_window = gtk_window_new ();
|
||||
/* MODEL */
|
||||
model = gtk_list_store_new(N_COLUMNS,
|
||||
G_TYPE_STRING, /* FILE_NAME */
|
||||
G_TYPE_UINT, /* FILE_OFFSET */
|
||||
G_TYPE_UINT, /* FILE_SIZE */
|
||||
G_TYPE_STRING, /* FILE_DESCRIPTION */
|
||||
G_TYPE_STRING /* COLOR */
|
||||
);
|
||||
gtk_list_store_insert_with_values(model, NULL, -1,
|
||||
FILE_NAME, "test name",
|
||||
FILE_OFFSET, 0,
|
||||
FILE_SIZE, 10,
|
||||
-1);
|
||||
gtk_list_store_insert_with_values(model, NULL, -1,
|
||||
FILE_NAME, "Dummy",
|
||||
FILE_OFFSET, 123,
|
||||
COLOR, "black",
|
||||
-1);
|
||||
gtk_list_store_insert_with_values(model, NULL, -1,
|
||||
FILE_NAME, "another name",
|
||||
COLOR, "blue",
|
||||
-1);
|
||||
|
||||
g_signal_connect(G_OBJECT (my_window), "on_destroy::", G_CALLBACK(on_destroy), NULL);
|
||||
/* VIEW */
|
||||
view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model));
|
||||
g_object_unref(model);
|
||||
|
||||
gtk_window_set_title (GTK_WINDOW(my_window), my_title);
|
||||
gtk_window_set_default_size (GTK_WINDOW(my_window), 200, 34);
|
||||
column = gtk_tree_view_column_new_with_attributes("Name",
|
||||
gtk_cell_renderer_text_new(),
|
||||
"text", FILE_NAME,
|
||||
"background", COLOR,
|
||||
NULL);
|
||||
gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);
|
||||
|
||||
my_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
||||
column = gtk_tree_view_column_new_with_attributes("Offset",
|
||||
gtk_cell_renderer_spin_new(),
|
||||
"text", FILE_OFFSET,
|
||||
NULL);
|
||||
gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);
|
||||
|
||||
my_button = gtk_button_new_with_label (my_button_title);
|
||||
column = gtk_tree_view_column_new_with_attributes("Size",
|
||||
gtk_cell_renderer_text_new(),
|
||||
"text", FILE_SIZE,
|
||||
NULL);
|
||||
gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);
|
||||
|
||||
g_signal_connect(G_OBJECT (my_button), "on_button_action::", G_CALLBACK(on_button_action), NULL);
|
||||
gtk_box_append(GTK_BOX(my_box), GTK_WIDGET(my_button));
|
||||
// gtk_widget_show (my_button);
|
||||
gtk_box_append(runlib_objects, view);
|
||||
|
||||
gtk_window_set_child(GTK_WINDOW(my_window), GTK_WIDGET(my_box));
|
||||
gtk_widget_show (my_window);
|
||||
|
||||
printf("A little window is created in bac-a-sable with title : %s\n", my_title);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -28,9 +28,6 @@
|
|||
#include "../../include/base.h"
|
||||
#include "../../include/ui.h"
|
||||
|
||||
// TODO use GTK_DEBUG
|
||||
GTK_DEBUG;
|
||||
|
||||
enum
|
||||
{
|
||||
STRING_COLUMN,
|
||||
|
@ -45,6 +42,13 @@ struct _TreeItem
|
|||
TreeItem *children;
|
||||
};
|
||||
|
||||
void // https://docs.gtk.org/gtk4/method.StringList.take.html
|
||||
gtk_string_list_take (
|
||||
GtkStringList* self,
|
||||
char* string
|
||||
)
|
||||
{}
|
||||
|
||||
// tree data
|
||||
static TreeItem E[] = {NULL}, F[] = {NULL}, G[] = {NULL}, H[] = {NULL};
|
||||
static TreeItem I[] = {NULL}, K[] = {NULL}, N[] = {NULL}, M[] = {NULL};
|
||||
|
@ -55,15 +59,32 @@ 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
|
||||
|
||||
void gtk_string_list_take (GtkStringList* self, char* string){}
|
||||
|
||||
static void bind_listitem_cb_complex (GtkListItemFactory *factory,
|
||||
static void
|
||||
setup_listitem_cb (GtkListItemFactory *factory,
|
||||
GtkListItem *list_item)
|
||||
{
|
||||
GtkWidget *label = gtk_label_new ("");
|
||||
gtk_list_item_set_child (list_item, label);
|
||||
|
||||
|
||||
//factory = gtk_signal_list_item_factory_new ();
|
||||
//GListModel my_model = NULL;
|
||||
//view = gtk_list_view_new (model, factory);
|
||||
|
||||
//g_signal_connect (factory, "setup", setup_listitem_cb, NULL);
|
||||
//g_signal_connect (factory, "bind", bind_listitem_cb, NULL);
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
bind_listitem_cb_complex (GtkListItemFactory *factory,
|
||||
GtkListItem *list_item)
|
||||
{
|
||||
GtkWidget *label;
|
||||
TreeItem *obj;
|
||||
|
||||
label = gtk_list_item_get_child (list_item);
|
||||
label = gtk_list_item_get_child (list_ite
|
||||
obj = gtk_list_item_get_item (list_item);
|
||||
gtk_label_set_label (GTK_LABEL (label),
|
||||
my_object_get_string (obj));
|
||||
|
@ -72,8 +93,9 @@ static void bind_listitem_cb_complex (GtkListItemFactory *factory,
|
|||
static GtkWidget *my_tree_view;
|
||||
static GListModel *my_Glist_model = NULL;
|
||||
|
||||
|
||||
// erreur: un élément de l'initialisation n'est pas une constante
|
||||
// model = create_application_list (); g_list_model_get_item_type()
|
||||
//model = create_application_list ();
|
||||
|
||||
|
||||
typedef struct _GtkListView GtkListView;
|
||||
|
@ -109,10 +131,10 @@ static void setup_listitem_cb (GtkListItemFactory *my_factory,
|
|||
GtkLabel *my_label,
|
||||
GtkImage *my_image)
|
||||
{
|
||||
// If not provided : GtkWidget *my_label = gtk_label_new ("");
|
||||
//GtkWidget *my_label = gtk_label_new ("");
|
||||
gtk_list_item_set_child (my_list_item, my_label);
|
||||
|
||||
// If not provided : GtkWidget *my_image = gtk_image_new ();
|
||||
//GtkWidget *my_image = gtk_image_new ();
|
||||
gtk_image_set_icon_size (GTK_IMAGE (my_image), GTK_ICON_SIZE_LARGE);
|
||||
gtk_list_item_set_child (my_list_item, my_image);
|
||||
}
|
||||
|
@ -139,15 +161,13 @@ static void activate_cb (GtkListView *list,
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Parameters : self : the GtkSignalListItemFactory,
|
||||
// listitem : the GtkListItem to bind,
|
||||
// user_data : the user data set when the signal handler was connected.
|
||||
// Flags: Run First
|
||||
static void any_user_function (GtkSignalListItemFactory *self, GtkListItem *listitem, gpointer user_data) {
|
||||
// my_factory = gtk_signal_list_item_factory_new ();
|
||||
g_signal_connect (my_factory, "setup", setup_listitem_cb, NULL);
|
||||
g_signal_connect (my_factory, "bind", bind_listitem_cb, NULL);
|
||||
}
|
||||
static void any_user_function (GtkSignalListItemFactory *self, GtkListItem *listitem, gpointer user_data) {}
|
||||
|
||||
// user_function can be : setup, bind, unbind or teardown
|
||||
//
|
||||
|
@ -164,7 +184,6 @@ static void any_user_function (GtkSignalListItemFactory *self, GtkListItem *list
|
|||
// If your “bind” handler connects to signals on the item or does other things that require cleanup,
|
||||
// you can use the “unbind” signal to do that cleanup. The “setup” signal has a similar counterpart called “teardown”.
|
||||
|
||||
|
||||
static GListModel *create_settings_model (gpointer item,
|
||||
gpointer unused)
|
||||
{
|
||||
|
@ -238,27 +257,23 @@ user_function (GListModel *list,
|
|||
//------------------------------------------------------------------------------
|
||||
|
||||
// guix shell -m manifest.scm make clean && clear && time make run
|
||||
// GOBJECT_DEBUG=instance_count Gio Gnome input output
|
||||
|
||||
// https://docs.gtk.org/gtk4/
|
||||
// https://docs.gtk.org/gtk4/question_index.html
|
||||
// https://docs.gtk.org/gtk4/running.html
|
||||
//
|
||||
// Gio Gnome input output
|
||||
// https://docs.gtk.org/gtk4/section-list-widget.html
|
||||
// https://gnome.pages.gitlab.gnome.org/libsoup/gio/GListModel.html
|
||||
// https://blog.gtk.org/2020/09/05/a-primer-on-gtklistview/ <<< Factory mechanism
|
||||
// https://docs.gtk.org/gtk4/class.ListItemFactory.html <<<
|
||||
<<<<<<< HEAD
|
||||
// https://www.typeerror.org/docs/gtk~4.0/gtksignallistitemfactory
|
||||
// https://developer-old.gnome.org/gtk4/stable/GtkListView.html <<< copy that !
|
||||
=======
|
||||
>>>>>>> afc2bd0 (WIP: GtkTreeListModel *gtk_tree_list_model_new(...){} < how to ?)
|
||||
// https://docs.gtk.org/gtk4/class.ListItem.html
|
||||
// https://docs.gtk.org/gtk4/ctor.TreeListModel.new.html ***
|
||||
// https://blog.gtk.org/2020/06/08/more-on-lists-in-gtk-4/ ***
|
||||
// https://gitlab.gnome.org/GNOME/gtk/-/blob/main/demos/gtk-demo/listview_settings.c GtkBuilder *builder; (line 216)
|
||||
// https://discourse.gnome.org/t/how-can-i-get-the-expanded-collapsed-items-in-the-new-gtktreelistmodel-implementation/16824
|
||||
<<<<<<< HEAD
|
||||
// https://developer-old.gnome.org/gtk4/stable/GtkSignalListItemFactory.html
|
||||
// https://docs.gtk.org/gtk4/method.StringList.take.html
|
||||
|
||||
// https://developer-old.gnome.org/gtk4/stable/gtk-running.html
|
||||
|
||||
// https://fr.wikibooks.org/wiki/Programmation_GTK // mars 2022
|
||||
// https://fr.wikibooks.org/wiki/Programmation_GTK/Bonjour_tout_le_monde
|
||||
=======
|
||||
>>>>>>> afc2bd0 (WIP: GtkTreeListModel *gtk_tree_list_model_new(...){} < how to ?)
|
||||
|
|
Loading…
Reference in New Issue