WIP: I wish a functionnal upper left toggle [RUN/ÉDIT] button
This commit is contained in:
parent
52053f917c
commit
6e6f9f0e99
|
@ -167,6 +167,7 @@ void ui_set_stack(int mode);
|
|||
void ui_send_internal_notification(const char *message);
|
||||
void ui_close_internal_notification(void);
|
||||
void ui_toggle_sidebar();
|
||||
void ui_toggle_run_edit(int mode);
|
||||
|
||||
//
|
||||
// Graphical stuff
|
||||
|
|
|
@ -113,6 +113,7 @@ static void gem_graph_client_application_init(GemGraphClientApplication *self)
|
|||
ui_disable_action("runmode");
|
||||
ui_disable_action("presentmode");
|
||||
ui_disable_action("togglesidebar");
|
||||
ui_disable_action("toggle_run_edit");
|
||||
}
|
||||
|
||||
void ui_send_notification(const char *message)
|
||||
|
|
|
@ -89,6 +89,19 @@ void on_togglesidebar_action(GSimpleAction *action,
|
|||
ui_toggle_sidebar();
|
||||
}
|
||||
|
||||
void on_toggle_run_stop_action(GSimpleAction *action,
|
||||
GVariant *parameter,
|
||||
gpointer user_data)
|
||||
{
|
||||
GemGraphClientApplication *self = user_data;
|
||||
|
||||
g_assert(GEM_GRAPH_CLIENT_IS_APPLICATION(self));
|
||||
|
||||
// Switch on the first letter of the mode, because switch is soooo simple :)
|
||||
if (EDIT_MODE) ui_toggle_run_edit (RUN_MODE);
|
||||
else if (RUN_MODE) ui_toggle_run_edit (EDIT_MODE);
|
||||
}
|
||||
|
||||
void on_editmode_action(GSimpleAction *action,
|
||||
GVariant *parameter,
|
||||
gpointer user_data)
|
||||
|
@ -166,6 +179,7 @@ void on_closefile_action(GSimpleAction *action,
|
|||
ui_disable_action("editmode");
|
||||
ui_disable_action("presentmode");
|
||||
ui_disable_action("togglesidebar");
|
||||
ui_disable_action("toggle_run_edit");
|
||||
ui_set_stack(HOME_MODE);
|
||||
}
|
||||
|
||||
|
@ -362,6 +376,7 @@ void ui_model_loading(GObject *source_object,
|
|||
ui_enable_action("editmode");
|
||||
ui_enable_action("presentmode");
|
||||
ui_enable_action("togglesidebar");
|
||||
ui_enable_action("toggle_run_edit");
|
||||
ui_set_stack(RUN_MODE);
|
||||
|
||||
g_free(basenamestr);
|
||||
|
@ -397,6 +412,7 @@ void ui_debug_model_loading (GtkWindow *self, const char *file)
|
|||
ui_enable_action("editmode");
|
||||
ui_enable_action("presentmode");
|
||||
ui_enable_action("togglesidebar");
|
||||
ui_enable_action("toggle_run_edit");
|
||||
ui_set_stack(RUN_MODE);
|
||||
ui_toggle_sidebar();
|
||||
}
|
||||
|
|
|
@ -19,6 +19,20 @@
|
|||
<property name="menu-model">main_menu</property>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<!-- On to us a child is born ... -->
|
||||
<child>
|
||||
<object class="GtkToggleButton" id="main_button_run_edit">
|
||||
<property name="icon-name">system-run-symbolic</property>
|
||||
<property name="tooltip-text" translatable="yes">Run mode</property>
|
||||
<property name="action-name">app.toggle_run_edit</property>
|
||||
<!-- applications should be compiled with the -Wl,--export-dynamic argument inside their compiler flags -->
|
||||
<!-- and linked against gmodule-export-2.0 -->
|
||||
<!-- https://docs.gtk.org/gtk4/class.Builder.html -->
|
||||
<!--signal name="clicked" handler="ui_toggle_run_edit" on_toggle_run_stop_action /-->
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<child type="start">
|
||||
<object class="GtkMenuButton" id="main_button_mode">
|
||||
<property name="always-show-arrow">True</property>
|
||||
|
@ -33,10 +47,6 @@
|
|||
<property name="icon-name">sidebar-show-symbolic</property>
|
||||
<property name="tooltip-text" translatable="yes">Display/hide sidebar</property>
|
||||
<property name="action-name">app.togglesidebar</property>
|
||||
<!-- applications should be compiled with the -Wl,--export-dynamic argument inside their compiler flags -->
|
||||
<!-- and linked against gmodule-export-2.0 -->
|
||||
<!-- https://docs.gtk.org/gtk4/class.Builder.html -->
|
||||
<!--signal name="clicked" handler="ui_toggle_sidebar" /-->
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
|
|
|
@ -45,6 +45,7 @@ struct _GemGraphClientWindow
|
|||
GtkStack *side_stack;
|
||||
GtkPaned *main_paned;
|
||||
GtkMenuButton *main_button_mode;
|
||||
GtkToggleButton *main_button_run_stop;
|
||||
GtkToggleButton *main_button_sidebar;
|
||||
GtkRevealer *toast_revealer;
|
||||
GtkToggleButton *toast_close_button;
|
||||
|
@ -83,6 +84,7 @@ static void gem_graph_client_window_class_init(GemGraphClientWindowClass *klass)
|
|||
gtk_widget_class_bind_template_child(widget_class, GemGraphClientWindow, main_stack);
|
||||
gtk_widget_class_bind_template_child(widget_class, GemGraphClientWindow, side_stack);
|
||||
gtk_widget_class_bind_template_child(widget_class, GemGraphClientWindow, main_paned);
|
||||
gtk_widget_class_bind_template_child(widget_class, GemGraphClientWindow, main_button_run_stop);
|
||||
gtk_widget_class_bind_template_child(widget_class, GemGraphClientWindow, main_button_mode);
|
||||
gtk_widget_class_bind_template_child(widget_class, GemGraphClientWindow, main_button_sidebar);
|
||||
gtk_widget_class_bind_template_child(widget_class, GemGraphClientWindow, toast_revealer);
|
||||
|
@ -194,3 +196,33 @@ void ui_toggle_sidebar(void)
|
|||
gtk_paned_set_position(window->main_paned, 400);
|
||||
}
|
||||
}
|
||||
void ui_toggle_run_edit(int mode)
|
||||
{
|
||||
if (window->main_stack == NULL) {
|
||||
g_printerr("Can't find self->main_stack !\n");
|
||||
return;
|
||||
}
|
||||
if (window->side_stack == NULL) {
|
||||
g_printerr("Can't find self->side_stack !\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// Switch on the first letter of the mode, because switch is soooo simple :)
|
||||
switch(mode) {
|
||||
case EDIT_MODE:
|
||||
// gtk_stack_set_visible_child_full(window->main_stack, "edition", GTK_STACK_TRANSITION_TYPE_CROSSFADE);
|
||||
gtk_stack_set_visible_child_full(window->side_stack, "edition", GTK_STACK_TRANSITION_TYPE_CROSSFADE);
|
||||
gtk_menu_button_set_icon_name(window->main_button_run_stop, "document-edit-symbolic");
|
||||
ui_setup_glarea(EDIT_MODE, GTK_WIDGET(window->edition_glarea_box));
|
||||
break;
|
||||
case RUN_MODE:
|
||||
// gtk_stack_set_visible_child_full(window->main_stack, "run", GTK_STACK_TRANSITION_TYPE_CROSSFADE);
|
||||
gtk_stack_set_visible_child_full(window->side_stack, "run", GTK_STACK_TRANSITION_TYPE_CROSSFADE);
|
||||
gtk_menu_button_set_icon_name(window->main_button_run_stop, "system-run-symbolic");
|
||||
ui_setup_glarea(RUN_MODE, GTK_WIDGET(window->run_glarea_box));
|
||||
ui_create_tree (GTK_WIDGET (window->run_conditions_tree_box));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue