WIP: clean & comment
This commit is contained in:
parent
8aad4e1d54
commit
20537e68e2
|
@ -124,5 +124,6 @@ void ui_toggle_sidebar ();
|
||||||
|
|
||||||
void print_test_in_tree_dot_c(void);
|
void print_test_in_tree_dot_c(void);
|
||||||
|
|
||||||
GtkWidget *create_my_list_model(GtkBox *runlib_objects);
|
GtkWidget *create_my_tree_model(GtkBox *runlib_objects);
|
||||||
GtkWidget *create_a_button(GtkBox *runlib_objects);
|
GtkWidget *create_my_button_test(GtkBox *runlib_objects);
|
||||||
|
GtkWidget *create_my_list_view_test(GtkBox *runlib_objects);
|
||||||
|
|
|
@ -0,0 +1,98 @@
|
||||||
|
/*
|
||||||
|
* Gem-graph OpenGL experiments
|
||||||
|
*
|
||||||
|
* Desc: User interface functions
|
||||||
|
*
|
||||||
|
* Copyright (C) 2023 Jean Sirmai <jean@a-lec.org>
|
||||||
|
*
|
||||||
|
* This file is part of Gem-graph.
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <gtk-4.0/gtk/gtk.h>
|
||||||
|
#include <glib-2.0/glib.h>
|
||||||
|
|
||||||
|
#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
|
||||||
|
};
|
||||||
|
|
||||||
|
GtkWidget *create_my_list_view_test(GtkBox *runlib_objects)
|
||||||
|
{
|
||||||
|
GtkListStore* model;
|
||||||
|
GtkWidget* view;
|
||||||
|
GtkTreeViewColumn* column;
|
||||||
|
GtkWidget* window;
|
||||||
|
|
||||||
|
/* 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);
|
||||||
|
|
||||||
|
/* VIEW */
|
||||||
|
view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model));
|
||||||
|
g_object_unref(model);
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
gtk_box_append(runlib_objects, view);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,7 @@ static GListStore *create_node_recursive (GListStore *model,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
GtkWidget *create_my_list_model(GtkBox *runlib_objects)
|
GtkWidget *create_my_tree_model(GtkBox *runlib_objects)
|
||||||
{
|
{
|
||||||
GListStore *my_list_model = NULL;
|
GListStore *my_list_model = NULL;
|
||||||
GtkWidget *my_tree_box = NULL;
|
GtkWidget *my_tree_box = NULL;
|
||||||
|
@ -122,8 +122,7 @@ GtkWidget *create_my_list_model(GtkBox *runlib_objects)
|
||||||
return my_tree_view;
|
return my_tree_view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
static gint xxx(GtkBox *runlib_objects);
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
print_hello (GtkWidget *widget,
|
print_hello (GtkWidget *widget,
|
||||||
|
@ -134,7 +133,7 @@ print_hello (GtkWidget *widget,
|
||||||
printf("From 'tree.c', > button clicked (n = %d)\n", nb);
|
printf("From 'tree.c', > button clicked (n = %d)\n", nb);
|
||||||
}
|
}
|
||||||
|
|
||||||
GtkWidget *create_a_button(GtkBox *runlib_objects)
|
GtkWidget *create_my_button_test(GtkBox *runlib_objects)
|
||||||
{
|
{
|
||||||
GtkWidget *button;
|
GtkWidget *button;
|
||||||
const char *text = "Hello ! I'm the new button. Click me !";
|
const char *text = "Hello ! I'm the new button. Click me !";
|
||||||
|
@ -145,76 +144,7 @@ GtkWidget *create_a_button(GtkBox *runlib_objects)
|
||||||
|
|
||||||
g_signal_connect (button, "clicked", G_CALLBACK (print_hello), NULL);
|
g_signal_connect (button, "clicked", G_CALLBACK (print_hello), NULL);
|
||||||
|
|
||||||
xxx(runlib_objects);
|
|
||||||
|
|
||||||
return button;
|
return button;
|
||||||
}
|
}
|
||||||
|
|
||||||
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 gint xxx(GtkBox *runlib_objects)
|
|
||||||
{
|
|
||||||
GtkListStore* model;
|
|
||||||
GtkWidget* view;
|
|
||||||
GtkTreeViewColumn* column;
|
|
||||||
GtkWidget* window;
|
|
||||||
|
|
||||||
/* 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);
|
|
||||||
|
|
||||||
/* VIEW */
|
|
||||||
view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model));
|
|
||||||
g_object_unref(model);
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
gtk_box_append(runlib_objects, view);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// guix shell -m manifest.scm make clean && clear && time make run
|
// guix shell -m manifest.scm make clean && clear && time make run
|
||||||
|
|
|
@ -50,6 +50,7 @@ float rotation_angles[N_AXIS] = { 0.0 }; // Rotation angles on each axis
|
||||||
GtkWidget *gl_area = NULL;
|
GtkWidget *gl_area = NULL;
|
||||||
GtkWidget *my_tree = NULL;
|
GtkWidget *my_tree = NULL;
|
||||||
GtkWidget *my_button = NULL;
|
GtkWidget *my_button = NULL;
|
||||||
|
GtkWidget *my_list = NULL;
|
||||||
|
|
||||||
GemGraphClientWindow *window;
|
GemGraphClientWindow *window;
|
||||||
|
|
||||||
|
@ -121,7 +122,7 @@ static void gem_graph_client_window_init(GemGraphClientWindow *self)
|
||||||
//XXX TEMP ui_setup_glarea(window->run_glarea, window->run_controls);
|
//XXX TEMP ui_setup_glarea(window->run_glarea, window->run_controls);
|
||||||
//
|
//
|
||||||
printf("--------------------------------------------------------------------------------------\n\
|
printf("--------------------------------------------------------------------------------------\n\
|
||||||
from : gem_graph_client_window_init(GemGraphClientWindow *self) in window.c (line 123)\n\
|
from : gem_graph_client_window_init(GemGraphClientWindow *self) in window.c (line 124)\n\
|
||||||
> widgets examples in user/jean/01/GTK4/tree (learning)/The_Gnome_way/demos/gtk-demo <\n\
|
> widgets examples in user/jean/01/GTK4/tree (learning)/The_Gnome_way/demos/gtk-demo <\n\
|
||||||
--------------------------------------------------------------------------------------\n");
|
--------------------------------------------------------------------------------------\n");
|
||||||
|
|
||||||
|
@ -149,8 +150,9 @@ void ui_set_stack(const char *mode)
|
||||||
break;
|
break;
|
||||||
case 'r':
|
case 'r':
|
||||||
gtk_menu_button_set_icon_name(window->main_button_mode, "system-run-symbolic");
|
gtk_menu_button_set_icon_name(window->main_button_mode, "system-run-symbolic");
|
||||||
if (! my_tree) my_tree = create_my_list_model(window->runlib_objects);
|
if (! my_tree) my_tree = create_my_tree_model(window->runlib_objects); // in tree.c
|
||||||
if (! my_button) my_button = create_a_button(window->runlib_objects);
|
if (! my_button) my_button = create_my_button_test(window->runlib_objects); // in tree.c
|
||||||
|
if (! my_list) my_list = create_my_list_view_test(window->runlib_objects); // in "bac-a-sable.c"
|
||||||
break;
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
gtk_menu_button_set_icon_name(window->main_button_mode, "x-office-presentation-symbolic");
|
gtk_menu_button_set_icon_name(window->main_button_mode, "x-office-presentation-symbolic");
|
||||||
|
|
Loading…
Reference in New Issue