GTK4_GG_hack/(notes)

264 lines
13 KiB
Plaintext

jean@Project:~/01/Gtk4/Getting_Started_with_GTK [env] $ grep -r "//////////////////////////"
contain.c: (136) gtk_box_append (middle_box, GTK_WIDGET (get_GLArea()));
graph_area.h: (177) static inline GLuint create_shader(const int stack_id, int type, const char *src) {...}
graph_area.h:////////////////////////// shader = glCreateShader(type);
graph_area.h:////////////////////////// glShaderSource(shader, 1, &src, NULL);
graph_area.h:////////////////////////// glCompileShader(shader);
graph_area.h:////////////////////////// glGetShaderiv(shader, GL_COMPILE_STATUS, &status);
graph_area.h:////////////////////////// glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &log_len);
graph_area.h:////////////////////////// glGetShaderInfoLog(shader, log_len, NULL, buffer);
graph_area.h:////////////////////////// glDeleteShader(shader);
graph_area.c:////////////////////////// stack_index[i].stack_id = graphics_init(&error_buffer);
graph_area.c:////////////////////////// if (graphics_shutdown(stack_index[i].stack_id,
graph_area.c:////////////////////////// &error_buffer) == false) {
graph_area.c:////////////////////////// return false;
graph_area.c:////////////////////////// }
graph_area.c:////////////////////////// graphics_draw(stack_index[i].stack_id);
graph_area.c:////////////////////////// graphic_stack[stack_index[i].stack_id].rotation_angles[axis] = value;
graph_area.c:////////////////////////// graphics_shutdown(stack_index[i].stack_id, NULL);
graph_area.c:////////////////////////// g_signal_connect(adj, "value-changed",
graph_area.c:////////////////////////// G_CALLBACK(on_axis_value_change),
graph_area.c:////////////////////////// (gpointer) label);
graph_area.c:////////////////////////// g_signal_connect(GTK_GL_AREA(gl_area),
graph_area.c:////////////////////////// "render",
graph_area.c:////////////////////////// G_CALLBACK(on_glarea_render), NULL);
graph_area.c:////////////////////////// g_signal_connect(gl_area,
graph_area.c:////////////////////////// "realize",
graph_area.c:////////////////////////// G_CALLBACK(on_glarea_realize), NULL);
graph_area.c:////////////////////////// g_signal_connect(gl_area,
graph_area.c:////////////////////////// "unrealize",
graph_area.c:////////////////////////// G_CALLBACK(on_glarea_unrealize), NULL);
graph_stack.c:////////////////////////// glEnable(GL_DEBUG_OUTPUT);
graph_stack.c:////////////////////////// glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
graph_stack.c:////////////////////////// glEnable(GL_MULTISAMPLE);
graph_stack.c:////////////////////////// if (!graphics_init_shaders(cur_id)) return -1;
graph_stack.c:////////////////////////// graphics_init_buffers(cur_id);
graph_stack.c:////////////////////////// glDebugMessageCallback(graphics_debug_callback, NULL);
graph_stack.c:////////////////////////// dimension = model_get_dim();
graph_stack.c:////////////////////////// space_Z = model_get_dim_value("z");
graph_stack.c:////////////////////////// space_Y = model_get_dim_value("y");
graph_stack.c:////////////////////////// space_X = model_get_dim_value("x");
graph_stack.c:////////////////////////// multiplicity = model_get_multiplicity();
graph_stack.c:////////////////////////// g_print("[GRAPH DEBUG] site_multiplicity = %ld\n", multiplicity);
graph_stack.c:////////////////////////// draw_space_ridges_vertex (stack_id, stack->buffer_vertex_size, space_X, space_Y, space_Z);
graph_stack.c:////////////////////////// draw_space_ridges_lines (stack_id);
graph_stack.c:////////////////////////// draw_grids_on_space_faces_vertex (stack_id, space_X, space_Y, space_Z);
graph_stack.c:////////////////////////// draw_grids_on_space_faces_lines (stack_id, stack->buffer_lines_size, space_X, space_Y, space_Z);
graph_stack.c:////////////////////////// assert(model_get_next_state(&state_id));
graph_stack.c:////////////////////////// announced_arrows_nb = model_get_state_arrows_count(state_id);
graph_stack.c:////////////////////////// g_print("[GRAPH DEBUG] announced_arrows_nb is = %ld\n", announced_arrows_nb);
graph_stack.c:////////////////////////// while (model_get_next_arrow(&arrow, &state_id, dimension)) {
graph_stack.c:////////////////////////// g_print("[GRAPH DEBUG] cur arrow has x = %d\n", arrow.x);
graph_stack.c:////////////////////////// stack->arrows_nb =
graph_stack.c:////////////////////////// set_arrow (stack_id, stack->arrows_nb, space_X, space_Y, space_Z,
graph_stack.c:////////////////////////// arrow.load, // load
graph_stack.c:////////////////////////// arrow.site, // site
graph_stack.c:////////////////////////// arrow.x, // x
graph_stack.c:////////////////////////// arrow.y, // y
graph_stack.c:////////////////////////// arrow.z); // z
graph_stack.c:////////////////////////// }
graph_stack.c:////////////////////////// if (stack->arrows_nb != announced_arrows_nb)
graph_stack.c:////////////////////////// g_printerr("ARGH : all the arrows have not been parsed !\n");
init.c.todo:////////////////////////// vertex = create_shader(stack_id, GL_VERTEX_SHADER, vertex_shader);
init.c.todo:////////////////////////// fragment = create_shader(stack_id, GL_FRAGMENT_SHADER, fragment_shader);
--------------------------------------------------------------------------------
https://docs.gtk.org/gtk4/visual_index.html widgets gallery
https://forge.a-lec.org/gem-graph/gem-graph-client/src/branch/devel/Makefile
https://docs.gtk.org/gtk4/class.Widget.html#height-for-width-geometry-management
// GtkSizeRequestMode get_request_mode (GtkWidget* widget);
// gtk_window_set_default_size (GTK_WINDOW (a_box), 30, 400); < TO STUDY
https://docs.gtk.org/gtk4/section-text-widget.html texts
https://docs.gtk.org/gtk4/drag-and-drop.html drag-and-drop
https://docs.gtk.org/gtk4/class.GestureZoom.html GtkGestureZoom
https://docs.gtk.org/gtk4/class.ListView.html
https://blog.gtk.org/2020/09/08/on-list-models/ < TODO
--------------------------------------------------------------------------------
GTK_ORIENTATION_VERTICAL GTK_ORIENTATION_HORIZONTAL
GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT GTK_SIZE_REQUEST_CONSTANT_SIZE
g_signal_connect (button, "clicked", G_CALLBACK (printf("%s\n", text)), text);
g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_window_destroy), window);
--------------------------------------------------------------------------------
GtkBox GtkGrid GtkRevealer GtkStack
GtkOverlay GtkPaned GtkExpander GtkFixed
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_widget_set_halign (box, GTK_ALIGN_FILL);
gtk_widget_set_valign (box, GTK_ALIGN_CENTER); // START CENTER END FILL
gtk_window_set_child (GTK_WINDOW (window), box);
puis, après déclaration du bouton, gtk_box_append (GTK_BOX (box), button);
grid = gtk_grid_new ();
gtk_window_set_child (GTK_WINDOW (window), grid);
button = gtk_button_new_with_label (" I "); n fois
gtk_grid_attach (GTK_GRID (grid), button, 0, 0, 1, 1); n fois
--------------------------------------------------------------------------------
TODO (or NOT TODO)
GtkWidget *get_text_view(){ // WTF ?!& @Grr #~!
// https://docs.gtk.org/gtk4/section-text-widget.html
GtkWidget *my_view = gtk_text_view_new ();
GtkTextTagTable *my_table = gtk_text_tag_table_new ();
GtkTextBuffer *my_buffer = gtk_text_buffer_new (my_table);
gtk_text_buffer_set_text (my_buffer, "Hello, this is some text", -1);
gtk_text_view_set_buffer (GTK_TEXT_VIEW (my_view), my_buffer);
/* Now you might put the view in a container and display it on the
* screen; when the user edits the text, signals on the buffer
* will be emitted, such as "changed", "insert_text", and so on.
*/
return my_view;
}
/*
https://docs.gtk.org/gtk4/class.ApplicationWindow.html
GtkApplication *app = gtk_application_new ("org.gtk.test", 0);
GtkBuilder *builder = gtk_builder_new_from_string (
"<interface>"
" <menu id='menubar'>"
" <submenu>"
" <attribute name='label' translatable='yes'>_Edit</attribute>"
" <item>"
" <attribute name='label' translatable='yes'>_Copy</attribute>"
" <attribute name='action'>win.copy</attribute>"
" </item>"
" <item>"
" <attribute name='label' translatable='yes'>_Paste</attribute>"
" <attribute name='action'>win.paste</attribute>"
" </item>"
" </submenu>"
" </menu>"
"</interface>",
-1);
GMenuModel *menubar = G_MENU_MODEL (gtk_builder_get_object (builder, "menubar"));
gtk_application_set_menubar (GTK_APPLICATION (app), menubar);
g_object_unref (builder);
// ...
GtkWidget *window = gtk_application_window_new (app);
*/
//------------------------------------------------------------------------------
GtkScrolledWindow *get_scrolled_gl_area(){
GtkScrolledWindow *scrolled = GTK_SCROLLED_WINDOW(gtk_scrolled_window_new());
gtk_scrolled_window_set_min_content_width (scrolled, W_IMAGE);
gtk_scrolled_window_set_min_content_height (scrolled, H_IMAGE);
// GtkAdjustment *width = gtk_adjustment_new (600, 300, 1000, 1, 1, 1000);
// GtkAdjustment *height = gtk_adjustment_new (600, 300, 1000, 1, 1, 1000);
// (value, lower, upper, step_increment, page_increment, page_size)
// GtkWidget *GLarea = gtk_gl_area_new();
// gtk_scrolled_window_set_child (scrolled, GLarea);
// https://docs.gtk.org/gtk4/class.GLArea.html
return scrolled;
}
// https://docs.gtk.org/gtk4/getting_started.html (m'aura bien servi, quand même !)
//typedef anytype = {(int)(*fnct) {printf("typedef {(int)(*fnct) {printf("");}");} GtkModelFnct;
/*
essai run-stop, speed et step by step dans une seule box controls
-----------------------------------------------------------------
#include <stdio.h>
#include <gtk-4.0/gtk/gtk.h>
#include "cold.h"
void print_text(GtkWidget *widget, gpointer data) {g_print (data);}
GtkWidget *get_a_space_test_image(){
GtkWidget *image;
image = GTK_WIDGET(get_scrolled_gl_area());
image = gtk_picture_new_for_filename ("/home/jean/01/Gtk4/images/aXoris.png");
image = gtk_picture_new_for_filename ("/home/jean/01/Gtk4/images/gg sketch.png");
image = gtk_picture_new_for_filename ("/home/jean/01/Gtk4/images/E coli.png");
image = gtk_picture_new_for_filename ("/home/jean/01/Gtk4/images/E coli resized.png");
image = gtk_picture_new_for_filename ("/home/jean/01/Gtk4/Getting_Started_with_GTK/E coli by David S. Goodsell (2009).png");
return image;
}
GtkWidget *get_scroll_speed(){
GtkAdjustment *speed_adjust = gtk_adjustment_new (0, 0, 100, 1, 0, 0);
GtkWidget *scroll_speed = gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL, speed_adjust);
return scroll_speed;
}
// TODO cliquer sur "RUN" --> affiche "STOP" (et inversement)
GtkBox *get_RUN_STOP_box(){
GtkBox *RUN_STOP_box = GTK_BOX(gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2)); // spacing = 2
GtkWidget *RUN_Label = GTK_WIDGET (gtk_label_new (NULL)); // "RUN"));
const char *str = " RUN\n STOP";
const char *format = "<span style=\"oblique\">\%s</span>";
char *markup;
markup = g_markup_printf_escaped (format, str);
gtk_label_set_markup (GTK_LABEL (RUN_Label), markup); // Sets the labels text and attributes from markup.
g_free (markup);
gtk_label_set_max_width_chars (GTK_LABEL(RUN_Label), 12);
gtk_label_set_wrap (GTK_LABEL(RUN_Label), TRUE);
gtk_label_set_xalign (GTK_LABEL(RUN_Label), 0.5); // xalign value, between 0 and 1
gtk_label_set_yalign (GTK_LABEL(RUN_Label), 0.5);
gtk_label_set_selectable (GTK_LABEL(RUN_Label), FALSE); // default = FALSE
gtk_label_set_single_line_mode (GTK_LABEL(RUN_Label), TRUE); // default = TRUE
//
gtk_box_append (RUN_STOP_box, RUN_Label);
return RUN_STOP_box;
}
GtkBox *get_STEP_by_STEP_box(){
GtkBox *STEP_by_STEP_box = GTK_BOX(gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0));
GtkWidget *STEP_by_STEP_Label = GTK_WIDGET (gtk_label_new ("ONE\nSTEP"));
gtk_box_append (STEP_by_STEP_box, STEP_by_STEP_Label);
return STEP_by_STEP_box;
}
GtkBox *get_CONTROL_box(){
GtkBox *CONTROL_box = GTK_BOX(gtk_box_new (GTK_ORIENTATION_VERTICAL, 0));
gtk_box_append (CONTROL_box, GTK_WIDGET (get_RUN_STOP_box()));
gtk_box_append (CONTROL_box, GTK_WIDGET (get_scroll_speed()));
gtk_box_append (CONTROL_box, GTK_WIDGET (get_STEP_by_STEP_box()));
return CONTROL_box;
}
*/