WIP: https://github.com/ToshioCP/Gtk4-tutorial/blob/main/gfm/sec17.md what is 'startup' for ?
This commit is contained in:
parent
eddcb68911
commit
f4e023a236
|
@ -56,6 +56,7 @@
|
||||||
* which is in "topbar.c" (last one) (see widget.h)
|
* which is in "topbar.c" (last one) (see widget.h)
|
||||||
*/
|
*/
|
||||||
void on_windows_activation (GtkApplication *app);
|
void on_windows_activation (GtkApplication *app);
|
||||||
|
void on_windows_startup (GtkApplication *app);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ void *widget_get_text_window();
|
||||||
// - widget / topbar / polytext.c
|
// - widget / topbar / polytext.c
|
||||||
// (after gtk_application_window_new (app) x 3)
|
// (after gtk_application_window_new (app) x 3)
|
||||||
|
|
||||||
void widget_design_main_window (GtkWindow *main_window);
|
void widget_design_main_window (GtkWindow *main_window, GtkApplication *app);
|
||||||
void widget_design_dialog_window (GtkWindow *main_window, GtkWindow *dialog_window);
|
void widget_design_dialog_window (GtkWindow *main_window, GtkWindow *dialog_window);
|
||||||
void widget_design_text_window (GtkWindow *main_window, GtkWindow *text_window);
|
void widget_design_text_window (GtkWindow *main_window, GtkWindow *text_window);
|
||||||
|
|
||||||
|
@ -93,13 +93,13 @@ void *widget_get_btt_data(); // {return btt_DATA;}
|
||||||
// - widget / topbar / right.c
|
// - widget / topbar / right.c
|
||||||
|
|
||||||
void window_design_topbar_left (GtkWidget *header_bar);
|
void window_design_topbar_left (GtkWidget *header_bar);
|
||||||
void window_design_topbar_right (GtkWidget *header_bar);
|
void window_design_topbar_right (GtkWidget *header_bar, GtkApplication *app);
|
||||||
|
|
||||||
|
|
||||||
// called in signal.c / fsm_get_state_rules_data()
|
// called in signal.c / fsm_get_state_rules_data()
|
||||||
// defined in widget / synth / dispatch.c
|
// defined in widget / synth / dispatch.c
|
||||||
// - widget / state / dispatch.c
|
// - widget / state / dispatch.c
|
||||||
// - widget / rules / dispatch.c
|
// - widgetvoid on_windows_activation (GtkApplication *app) / rules / dispatch.c
|
||||||
// - widget / data / dispatch.c
|
// - widget / data / dispatch.c
|
||||||
// - widget / measure / dispatch.c
|
// - widget / measure / dispatch.c
|
||||||
|
|
||||||
|
|
|
@ -121,22 +121,22 @@ void fsm_msg (int choice, int value, char *string, int sub_automaton)
|
||||||
switch (sub_automaton) { // sub_automaton 0 is EXEC_EDIT and
|
switch (sub_automaton) { // sub_automaton 0 is EXEC_EDIT and
|
||||||
// sub_automaton 1 is STATE_RULES_DATA
|
// sub_automaton 1 is STATE_RULES_DATA
|
||||||
// sub_automaton 2 is MEASURE
|
// sub_automaton 2 is MEASURE
|
||||||
case (0) : printf ("fsm/dispatch.message |\
|
case (0) : printf ("fsm/dispatch (message) |\
|
||||||
switch %5s x %5s > %5s x %5s\n",
|
switch %5s x %5s > %5s x %5s\n",
|
||||||
tab_0 [choice_EXEC_EDIT], tab_1 [choice_STATE_RULES_DATA],
|
tab_0 [choice_EXEC_EDIT], tab_1 [choice_STATE_RULES_DATA],
|
||||||
tab_0 [choice], tab_1 [choice_STATE_RULES_DATA]);
|
tab_0 [choice], tab_1 [choice_STATE_RULES_DATA]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case (1) : printf ("fsm/dispatch.message |\
|
case (1) : printf ("fsm/dispatch (message) |\
|
||||||
switch %5s x %5s > %5s x %5s\n",
|
switch %5s x %5s > %5s x %5s\n",
|
||||||
tab_0 [choice_EXEC_EDIT], tab_1 [choice_STATE_RULES_DATA],
|
tab_0 [choice_EXEC_EDIT], tab_1 [choice_STATE_RULES_DATA],
|
||||||
tab_0 [choice_EXEC_EDIT], tab_1 [choice]);
|
tab_0 [choice_EXEC_EDIT], tab_1 [choice]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case (2) : printf ("fsm/dispatch.message | %s\n", string);
|
case (2) : printf ("fsm/dispatch (message) | %s\n", string);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case (3) : printf ("fsm/dispatch.message | %2d\n", choice);
|
case (3) : printf ("fsm/dispatch (message) | %2d\n", choice);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -132,7 +132,7 @@ void fsm_add_displayable (char *displayable_name)
|
||||||
/* P R E F E R E N C E S */
|
/* P R E F E R E N C E S */
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
void fsm_preferences_init () {printf("src/fsm/prefer.c\
|
void fsm_preferences_init () {printf("fsm/prefer.c |\
|
||||||
| src/fsm/prefer.c fsm_preferences_init()\n");}
|
src/fsm/prefer.c fsm_preferences_init()\n");}
|
||||||
void fsm_displayable_list_init () {printf("src/fsm/prefer.c\
|
void fsm_displayable_list_init () {printf("fsm/prefer.c |\
|
||||||
| src/fsm/prefer.c fsm_displayable_list_init()\n");}
|
src/fsm/prefer.c fsm_displayable_list_init()\n");}
|
||||||
|
|
15
src/main.c
15
src/main.c
|
@ -135,23 +135,24 @@
|
||||||
|
|
||||||
int main (int argc, char **argv)
|
int main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
int status;
|
|
||||||
|
|
||||||
GtkApplication *app = gtk_application_new ("org.gem-graph", G_APPLICATION_DEFAULT_FLAGS);
|
|
||||||
|
|
||||||
fsm_init (); // fsm = finite state machine (see : src/fsm/dispatch.c)
|
fsm_init (); // fsm = finite state machine (see : src/fsm/dispatch.c)
|
||||||
|
|
||||||
|
GtkApplication *app = gtk_application_new ("org.gem-graph", G_APPLICATION_DEFAULT_FLAGS);
|
||||||
|
g_signal_connect (app, "startup", G_CALLBACK (on_windows_startup), NULL);
|
||||||
g_signal_connect (app, "activate", G_CALLBACK (on_windows_activation), NULL);
|
g_signal_connect (app, "activate", G_CALLBACK (on_windows_activation), NULL);
|
||||||
// on_windows_activation <> see: src/widget/dispatch.c (NOT src/signal.c)
|
// ! WARNING ! 'on_windows_activation()'
|
||||||
|
// and 'on_windows_startup()' are in: src/widget/dispatch.c
|
||||||
status = g_application_run (G_APPLICATION (app), argc, argv);
|
// NOT in: src/signal.c
|
||||||
|
|
||||||
|
int status = g_application_run (G_APPLICATION (app), argc, argv);
|
||||||
g_object_unref (app);
|
g_object_unref (app);
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// GTK itself does not support event sounds, << A GREAT WAY TO DEBUG ! TODO
|
// GTK itself does not support event sounds, << A GREAT WAY TO DEBUG ! TODO
|
||||||
// you have to use a loadable module like the one that comes with libcanberra.
|
// you have to use a loadable module like the one that comes with libcanberra.
|
||||||
|
|
||||||
|
|
|
@ -57,8 +57,21 @@ void *widget_get_main_window() { return main_window; }
|
||||||
void *widget_get_dialog_window() { return dialog_window; }
|
void *widget_get_dialog_window() { return dialog_window; }
|
||||||
void *widget_get_text_window() { return text_window; }
|
void *widget_get_text_window() { return text_window; }
|
||||||
|
|
||||||
|
static void action_b (GSimpleAction *action,
|
||||||
|
GVariant *parameter,
|
||||||
|
GApplication *application) {printf ("action_b() in widget/dispatch.c\n");}
|
||||||
|
|
||||||
|
void on_windows_startup (GtkApplication *app)
|
||||||
|
{
|
||||||
|
printf ("widget/dispatch.c |\
|
||||||
|
on_windows_startup() is in: widget/dispatch.c NOT in: src/signal.c\n");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void on_windows_activation (GtkApplication *app)
|
void on_windows_activation (GtkApplication *app)
|
||||||
{
|
{
|
||||||
|
printf ("widget/dispatch.c |\
|
||||||
|
on_windows_activation() is in: widget/dispatch.c NOT in: src/signal.c\n");
|
||||||
// g_application_activate (G_APPLICATION (app)); < how ? > in main.c is
|
// g_application_activate (G_APPLICATION (app)); < how ? > in main.c is
|
||||||
// g_signal_connect (app, "activate", G_CALLBACK (on_windows_activation), NULL);
|
// g_signal_connect (app, "activate", G_CALLBACK (on_windows_activation), NULL);
|
||||||
|
|
||||||
|
@ -66,9 +79,15 @@ void on_windows_activation (GtkApplication *app)
|
||||||
dialog_window = GTK_WINDOW (gtk_application_window_new (app));
|
dialog_window = GTK_WINDOW (gtk_application_window_new (app));
|
||||||
text_window = GTK_WINDOW (gtk_application_window_new (app));
|
text_window = GTK_WINDOW (gtk_application_window_new (app));
|
||||||
|
|
||||||
widget_design_main_window (main_window); // def: widget/topbar/dispatch
|
widget_design_main_window (main_window, app); // def: widget/topbar/dispatch
|
||||||
widget_design_dialog_window (main_window, dialog_window);
|
widget_design_dialog_window (main_window, dialog_window);
|
||||||
widget_design_text_window (main_window, text_window);
|
widget_design_text_window (main_window, text_window);
|
||||||
|
|
||||||
|
//https://github.com/ToshioCP/Gtk4-tutorial/blob/main/gfm/sec17.md
|
||||||
|
GtkApplication *app2 = GTK_APPLICATION (app);
|
||||||
|
GSimpleAction *act_b = g_simple_action_new ("do_b", NULL);
|
||||||
|
g_action_map_add_action (G_ACTION_MAP (app), G_ACTION (act_b));
|
||||||
|
g_signal_connect (act_b, "activate", G_CALLBACK (action_b), app2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
|
@ -89,7 +89,6 @@ static void *get_btt_rule_identity()
|
||||||
GtkWidget *label_C = GTK_WIDGET (gtk_label_new("date")); gtk_list_box_append (GTK_LIST_BOX (list_box), label_C);
|
GtkWidget *label_C = GTK_WIDGET (gtk_label_new("date")); gtk_list_box_append (GTK_LIST_BOX (list_box), label_C);
|
||||||
GtkWidget *label_D = GTK_WIDGET (gtk_label_new("author")); gtk_list_box_append (GTK_LIST_BOX (list_box), label_D);
|
GtkWidget *label_D = GTK_WIDGET (gtk_label_new("author")); gtk_list_box_append (GTK_LIST_BOX (list_box), label_D);
|
||||||
GtkWidget *label_E = GTK_WIDGET (gtk_label_new("status, activity")); gtk_list_box_append (GTK_LIST_BOX (list_box), label_E);
|
GtkWidget *label_E = GTK_WIDGET (gtk_label_new("status, activity")); gtk_list_box_append (GTK_LIST_BOX (list_box), label_E);
|
||||||
GtkWidget *label_F = GTK_WIDGET (gtk_label_new("links to other rules")); gtk_list_box_append (GTK_LIST_BOX (list_box), label_F);
|
|
||||||
|
|
||||||
GtkWidget *pop = gtk_popover_new ();
|
GtkWidget *pop = gtk_popover_new ();
|
||||||
gtk_popover_set_child (GTK_POPOVER (pop), list_box);
|
gtk_popover_set_child (GTK_POPOVER (pop), list_box);
|
||||||
|
@ -120,6 +119,13 @@ void *widget_get_selected_rule_texts()
|
||||||
gtk_box_append (conditions_actions_names_box, GTK_WIDGET (get_btt_conditions_list ()));
|
gtk_box_append (conditions_actions_names_box, GTK_WIDGET (get_btt_conditions_list ()));
|
||||||
gtk_box_append (conditions_actions_names_box, GTK_WIDGET (get_btt_assign_list()));
|
gtk_box_append (conditions_actions_names_box, GTK_WIDGET (get_btt_assign_list()));
|
||||||
gtk_box_append (conditions_actions_names_box, GTK_WIDGET (get_btt_rule_identity()));
|
gtk_box_append (conditions_actions_names_box, GTK_WIDGET (get_btt_rule_identity()));
|
||||||
|
|
||||||
return GTK_WIDGET (conditions_actions_names_box);
|
return GTK_WIDGET (conditions_actions_names_box);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://juliagtk.github.io/Gtk4.jl/stable/manual/listtreeview/
|
||||||
|
//
|
||||||
|
// https://github.com/ToshioCP/Gtk4-tutorial/blob/main/gfm/sec17.md
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -41,11 +41,11 @@
|
||||||
|
|
||||||
static GtkWidget *window_topbar (GtkWindow *window);
|
static GtkWidget *window_topbar (GtkWindow *window);
|
||||||
|
|
||||||
void widget_design_main_window (GtkWindow *main_window)
|
void widget_design_main_window (GtkWindow *main_window, GtkApplication *app)
|
||||||
{
|
{
|
||||||
GtkWidget *topbar = window_topbar (main_window);
|
GtkWidget *topbar = window_topbar (main_window);
|
||||||
window_design_topbar_left (topbar);
|
window_design_topbar_left (topbar);
|
||||||
window_design_topbar_right (topbar);
|
window_design_topbar_right (topbar, app);
|
||||||
|
|
||||||
gtk_window_present (GTK_WINDOW (main_window));
|
gtk_window_present (GTK_WINDOW (main_window));
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,10 +36,10 @@
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
/* M A I N W I N D O W T O P B A R ( R I G H T ) */
|
/* M A I N W I N D O W T O P B A R ( R I G H T ) */
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
static void action_a (GSimpleAction *action, GVariant *parameter, gpointer app) {puts("menu item A clicked.\n");}
|
||||||
static void connect(GApplication *app, gpointer *data) { puts("Connect menu item clicked.\n"); }
|
static void connect(GApplication *app, gpointer *data) { puts("Connect menu item clicked.\n"); }
|
||||||
|
|
||||||
void window_design_topbar_right (GtkWidget *header_bar)
|
void window_design_topbar_right (GtkWidget *header_bar, GtkApplication *app)
|
||||||
{
|
{
|
||||||
gpointer no_local_data = NULL;
|
gpointer no_local_data = NULL;
|
||||||
|
|
||||||
|
@ -93,11 +93,16 @@ void window_design_topbar_right (GtkWidget *header_bar)
|
||||||
g_signal_connect(act_connect, "activate", G_CALLBACK(connect), NULL);
|
g_signal_connect(act_connect, "activate", G_CALLBACK(connect), NULL);
|
||||||
|
|
||||||
|
|
||||||
|
GSimpleAction *act_a = g_simple_action_new ("do_a", NULL);
|
||||||
|
g_action_map_add_action (G_ACTION_MAP (app), G_ACTION (act_a));
|
||||||
|
g_signal_connect (act_a, "activate", G_CALLBACK (action_a), app);
|
||||||
|
// GMenuItem *menu_item_do_a = g_menu_item_new ("do_a", "app.do_a");
|
||||||
|
|
||||||
// gtk_menu_button_popup (open_menu); gtk_menu_button_popdown (open_menu);
|
// gtk_menu_button_popup (open_menu); gtk_menu_button_popdown (open_menu);
|
||||||
// gtk_menu_item_activate (label_C);
|
// gtk_menu_item_activate (label_C);
|
||||||
// g_action_map_add_action(G_ACTION_MAP(app), G_ACTION(act_connect));
|
// g_action_map_add_action(G_ACTION_MAP(app), G_ACTION(act_connect));
|
||||||
// GMenuItem *label_E = g_menu_item_new("connect", "app.connect");
|
// GMenuItem *label_E = g_menu_item_new("connect", "app.do_a");
|
||||||
// gtk_list_box_append (GTK_LIST_BOX (list_box), GTK_WIDGET (label_E));
|
// gtk_list_box_append (GTK_LIST_BOX (list_box), GTK_WIDGET (menu_item_do_a));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue