WIP: cleaning ...
This commit is contained in:
parent
7a46ec1b42
commit
993ce2fc73
|
@ -12,3 +12,4 @@
|
|||
#include <assert.h>
|
||||
|
||||
GtkScrolledWindow *get_user_rules_tree ();
|
||||
void let_us_create_a_complex_useless_and_expensive_tree (struct TreeNode_t *tree_root);
|
||||
|
|
|
@ -104,21 +104,11 @@ static void gem_graph_client_application_init(GemGraphClientApplication *self)
|
|||
self);
|
||||
|
||||
// Setup shortcuts
|
||||
gtk_application_set_accels_for_action(GTK_APPLICATION(self),
|
||||
"app.quit",
|
||||
(const char *[]) { "<primary>q", NULL });
|
||||
gtk_application_set_accels_for_action(GTK_APPLICATION(self),
|
||||
"app.editmode",
|
||||
(const char *[]) { "<primary>e", NULL });
|
||||
gtk_application_set_accels_for_action(GTK_APPLICATION(self),
|
||||
"app.runmode",
|
||||
(const char *[]) { "<primary>r", NULL });
|
||||
gtk_application_set_accels_for_action(GTK_APPLICATION(self),
|
||||
"app.presentmode",
|
||||
(const char *[]) { "<primary>p", NULL });
|
||||
gtk_application_set_accels_for_action(GTK_APPLICATION(self),
|
||||
"app.savefile",
|
||||
(const char *[]) { "<primary>s", NULL });
|
||||
gtk_application_set_accels_for_action(GTK_APPLICATION(self), "app.quit", (const char *[]) { "<primary>q", NULL });
|
||||
gtk_application_set_accels_for_action(GTK_APPLICATION(self), "app.editmode", (const char *[]) { "<primary>e", NULL });
|
||||
gtk_application_set_accels_for_action(GTK_APPLICATION(self), "app.runmode", (const char *[]) { "<primary>r", NULL });
|
||||
gtk_application_set_accels_for_action(GTK_APPLICATION(self), "app.presentmode", (const char *[]) { "<primary>p", NULL });
|
||||
gtk_application_set_accels_for_action(GTK_APPLICATION(self), "app.savefile", (const char *[]) { "<primary>s", NULL });
|
||||
|
||||
application = self;
|
||||
|
||||
|
@ -136,17 +126,12 @@ static void gem_graph_client_application_init(GemGraphClientApplication *self)
|
|||
void ui_send_notification(const char *message)
|
||||
{
|
||||
g_print("NOTIFICATION: %s\n", message);
|
||||
|
||||
g_application_send_notification(G_APPLICATION(application),
|
||||
"notification",
|
||||
g_notification_new(message)
|
||||
);
|
||||
g_application_send_notification(G_APPLICATION(application), "notification", g_notification_new(message));
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
static void gem_graph_client_application_class_init(
|
||||
GemGraphClientApplicationClass *klass)
|
||||
static void gem_graph_client_application_class_init (GemGraphClientApplicationClass *klass)
|
||||
{
|
||||
GApplicationClass *app_class = G_APPLICATION_CLASS(klass);
|
||||
|
||||
|
|
97
src/ui/hot.c
97
src/ui/hot.c
|
@ -20,35 +20,60 @@ static struct TreeNode_t *create_user_tree_node (const gchar* text){
|
|||
return node;
|
||||
}
|
||||
|
||||
static void create_a_complex_useless_and_expensive_tree (struct TreeNode_t *tree_root){
|
||||
/* struct TreeNode_t *move_random = create_user_tree_node("move random"); add_child_node(tree_root, move_random);
|
||||
struct TreeNode_t *move_determ = create_user_tree_node("move determ"); add_child_node(tree_root, move_determ);
|
||||
struct TreeNode_t *transport = create_user_tree_node("transport"); add_child_node(tree_root, transport);*/
|
||||
struct TreeNode_t *transform = create_user_tree_node("transform"); add_child_node(tree_root, transform);
|
||||
struct TreeNode_t *regulate = create_user_tree_node("regulate"); add_child_node(tree_root, regulate);
|
||||
/* struct TreeNode_t *isole = create_user_tree_node("isolated object"); add_child_node(move_random, isole);
|
||||
struct TreeNode_t *relie = create_user_tree_node("part of object"); add_child_node(move_random, relie);
|
||||
struct TreeNode_t *no_payload = create_user_tree_node("free"); add_child_node(transport, no_payload);
|
||||
struct TreeNode_t *charged = create_user_tree_node("charged"); add_child_node(transport, charged);
|
||||
struct TreeNode_t *spontaneous = create_user_tree_node("spontaneous"); add_child_node(transform, spontaneous);*/
|
||||
struct TreeNode_t *catalysed = create_user_tree_node("catalysed"); add_child_node(transform, catalysed);
|
||||
/* struct TreeNode_t *isole_1D = create_user_tree_node("isolated object move 1D"); add_child_node(isole, isole_1D);
|
||||
struct TreeNode_t *isole_2D = create_user_tree_node("isolated object move 2D"); add_child_node(isole, isole_2D);
|
||||
struct TreeNode_t *isole_3D = create_user_tree_node("isolated object move 3D"); add_child_node(isole, isole_3D);
|
||||
struct TreeNode_t *translat_2D = create_user_tree_node("translation"); add_child_node(isole_2D, translat_2D);
|
||||
struct TreeNode_t *rotat_2D = create_user_tree_node("rotation"); add_child_node(isole_2D, rotat_2D);
|
||||
struct TreeNode_t *rotat_X_2D = create_user_tree_node("rotation axe X"); add_child_node(rotat_2D, rotat_X_2D);
|
||||
struct TreeNode_t *rotat_Y_2D = create_user_tree_node("rotation axe Y"); add_child_node(rotat_2D, rotat_Y_2D);
|
||||
struct TreeNode_t *translat_3D = create_user_tree_node("translation"); add_child_node(isole_3D, translat_3D);
|
||||
struct TreeNode_t *rotat_3D = create_user_tree_node("rotation"); add_child_node(isole_3D, rotat_3D);
|
||||
struct TreeNode_t *rotat_X_3D = create_user_tree_node("rotation axe X"); add_child_node(rotat_3D, rotat_X_3D);
|
||||
struct TreeNode_t *rotat_Y_3D = create_user_tree_node("rotation axe Y"); add_child_node(rotat_3D, rotat_Y_3D);
|
||||
struct TreeNode_t *rotat_Z_3D = create_user_tree_node("rotation axe Z"); add_child_node(rotat_3D, rotat_Z_3D);
|
||||
struct TreeNode_t *control = create_user_tree_node("negative feedback (control)"); add_child_node(regulate, control);
|
||||
struct TreeNode_t *enhance = create_user_tree_node("positive feedback (enhance)"); add_child_node(regulate, enhance);*/
|
||||
struct TreeNode_t *n_importe = create_user_tree_node("n'importe"); add_child_node(catalysed, n_importe);
|
||||
struct TreeNode_t *quoi = create_user_tree_node("quoi"); add_child_node(n_importe, quoi);
|
||||
struct TreeNode_t *ma_qué = create_user_tree_node("ma_qué"); add_child_node(quoi, ma_qué);
|
||||
static struct TreeNode_t *create_tree_node (const gchar* text)
|
||||
{
|
||||
struct TreeNode_t *node = g_malloc0 (sizeof(struct TreeNode_t));
|
||||
node->text = g_strdup(text);
|
||||
node->child = NULL;
|
||||
return node;
|
||||
}
|
||||
|
||||
// Function to add a child node to a parent node
|
||||
static void add_child_node (struct TreeNode_t *parent, struct TreeNode_t *child)
|
||||
{
|
||||
struct TreeNode_t *cur;
|
||||
|
||||
if (parent->child) {
|
||||
cur = parent->child;
|
||||
while (cur && cur->next) {
|
||||
cur = cur->next;
|
||||
}
|
||||
cur->next = child;
|
||||
} else {
|
||||
parent->child = child;
|
||||
}
|
||||
}
|
||||
|
||||
void let_us_create_a_complex_useless_and_expensive_tree (struct TreeNode_t *tree_root){
|
||||
struct TreeNode_t *a = create_tree_node("We, the people");add_child_node(tree_root, a);
|
||||
struct TreeNode_t *b = create_tree_node("in Order to"); add_child_node(tree_root, b);
|
||||
struct TreeNode_t *c = create_tree_node("do establish"); add_child_node(tree_root, c);
|
||||
struct TreeNode_t *aa = create_tree_node("aware of"); add_child_node(a, aa);
|
||||
struct TreeNode_t *aaa = create_tree_node("our rights"); add_child_node(aa, aaa);
|
||||
struct TreeNode_t *aab = create_tree_node("our duties"); add_child_node(aa, aab);
|
||||
struct TreeNode_t *aaaa = create_tree_node("read"); add_child_node(aaa, aaaa);
|
||||
struct TreeNode_t *aaab = create_tree_node("write"); add_child_node(aaa, aaab);
|
||||
struct TreeNode_t *aaac = create_tree_node("copy"); add_child_node(aaa, aaac);
|
||||
struct TreeNode_t *aaad = create_tree_node("edit"); add_child_node(aaa, aaad);
|
||||
struct TreeNode_t *aaaba= create_tree_node("code"); add_child_node(aaab, aaaba);
|
||||
struct TreeNode_t *aaabb= create_tree_node("language"); add_child_node(aaab, aaabb);
|
||||
struct TreeNode_t *aaabc= create_tree_node("any art..."); add_child_node(aaab, aaabc);
|
||||
struct TreeNode_t *aaadb= create_tree_node("publish"); add_child_node(aaac, aaadb);
|
||||
struct TreeNode_t *aaada= create_tree_node("create"); add_child_node(aaad, aaada);
|
||||
struct TreeNode_t *aaba = create_tree_node("learn"); add_child_node(aab, aaba);
|
||||
struct TreeNode_t *aabb = create_tree_node("help"); add_child_node(aab, aabb);
|
||||
struct TreeNode_t *ba = create_tree_node("promote"); add_child_node(b, ba);
|
||||
struct TreeNode_t *bb = create_tree_node("individual"); add_child_node(b, bb);
|
||||
struct TreeNode_t *bc = create_tree_node("and common"); add_child_node(b, bc);
|
||||
struct TreeNode_t *bca = create_tree_node("education"); add_child_node(bc, bca);
|
||||
struct TreeNode_t *bcb = create_tree_node("mutual"); add_child_node(bc, bcb);
|
||||
struct TreeNode_t *bcc = create_tree_node("support"); add_child_node(bc, bcc);
|
||||
struct TreeNode_t *bcd = create_tree_node("health"); add_child_node(bc, bcd);
|
||||
struct TreeNode_t *bcda = create_tree_node("mental"); add_child_node(bcd, bcda);
|
||||
struct TreeNode_t *bcdb = create_tree_node("physical"); add_child_node(bcd, bcdb);
|
||||
struct TreeNode_t *ca = create_tree_node("free"); add_child_node(c, ca);
|
||||
struct TreeNode_t *cb = create_tree_node("code"); add_child_node(c, cb);
|
||||
struct TreeNode_t *cc = create_tree_node("access"); add_child_node(c, cc);
|
||||
}
|
||||
|
||||
void on_user_tree_expander_toggled(GtkExpander *expander, gpointer user_data)
|
||||
|
@ -111,17 +136,9 @@ GListModel* get_user_tree_model (GObject *item, gpointer root){
|
|||
return get_user_tree_model_child (cur);
|
||||
}
|
||||
|
||||
static void add_child_node (struct TreeNode_t *parent, struct TreeNode_t *child){
|
||||
if (parent->child) {
|
||||
struct TreeNode_t *cur = parent->child;
|
||||
while (cur && cur->next) {cur = cur->next;}
|
||||
cur->next = child;
|
||||
} else parent->child = child;
|
||||
}
|
||||
|
||||
GtkScrolledWindow *get_user_rules_tree (){
|
||||
struct TreeNode_t *tree_root = create_user_tree_node("root");
|
||||
create_a_complex_useless_and_expensive_tree (tree_root);
|
||||
struct TreeNode_t *tree_root = create_user_tree_node("Declaration");
|
||||
let_us_create_a_complex_useless_and_expensive_tree (tree_root);
|
||||
|
||||
GtkStringList *model = gtk_string_list_new(NULL);
|
||||
gtk_string_list_append (model, tree_root->text);
|
||||
|
@ -132,7 +149,7 @@ GtkScrolledWindow *get_user_rules_tree (){
|
|||
GtkTreeListModel *tree_model = gtk_tree_list_model_new(
|
||||
G_LIST_MODEL (model),
|
||||
FALSE, // Passthrough - False in actual usage with dynamic children retrieval
|
||||
TRUE, // FALSE, // autoexpand
|
||||
FALSE, // TRUE, // FALSE, // autoexpand
|
||||
(GtkTreeListModelCreateModelFunc) &get_user_tree_model,
|
||||
tree_root,
|
||||
NULL // (GDestroyNotify) free_user_tree_node
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
|
||||
#include "../../include/base.h"
|
||||
#include "../../include/ui.h"
|
||||
#include "../../include/hot.h"
|
||||
|
||||
// Simplified TreeNode structure for demonstration purposes
|
||||
struct TreeNode_t
|
||||
|
@ -194,8 +195,11 @@ void ui_create_tree (GtkWidget *target_widget)
|
|||
GtkWidget *list_view;
|
||||
GtkScrolledWindow *scrolled_window;
|
||||
|
||||
struct TreeNode_t *tree_root = create_tree_node ("Declaration");
|
||||
create_experimental_tree (tree_root);
|
||||
struct TreeNode_t *tree_root = create_tree_node("Declaration");
|
||||
let_us_create_a_complex_useless_and_expensive_tree (tree_root);
|
||||
// struct TreeNode_t *tree_root = create_tree_node ("Declaration");
|
||||
// create_experimental_tree (tree_root);
|
||||
// get_user_rules_tree (tree_root);
|
||||
|
||||
model = gtk_string_list_new(NULL);
|
||||
gtk_string_list_append(model, tree_root->text);
|
||||
|
|
Loading…
Reference in New Issue