WIP: new actions
This commit is contained in:
parent
4a29b20acb
commit
555478c783
58
include/ui.h
58
include/ui.h
|
@ -56,3 +56,61 @@ GemGraphClientApplication *gem_graph_client_application_new(const char *applicat
|
|||
GApplicationFlags flags);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
//
|
||||
// Actions
|
||||
//
|
||||
void on_about_action(GSimpleAction *action,
|
||||
GVariant *parameter,
|
||||
gpointer user_data);
|
||||
|
||||
void on_quit_action(GSimpleAction *action,
|
||||
GVariant *parameter,
|
||||
gpointer user_data);
|
||||
|
||||
void on_preferences_action(GSimpleAction *action,
|
||||
GVariant *parameter,
|
||||
gpointer user_data);
|
||||
|
||||
void on_togglesidebar_action(GSimpleAction *action,
|
||||
GVariant *parameter,
|
||||
gpointer user_data);
|
||||
|
||||
void on_editmode_action(GSimpleAction *action,
|
||||
GVariant *parameter,
|
||||
gpointer user_data);
|
||||
|
||||
void on_runmode_action(GSimpleAction *action,
|
||||
GVariant *parameter,
|
||||
gpointer user_data);
|
||||
|
||||
void on_presentmode_action(GSimpleAction *action,
|
||||
GVariant *parameter,
|
||||
gpointer user_data);
|
||||
|
||||
void on_openfile_action(GSimpleAction *action,
|
||||
GVariant *parameter,
|
||||
gpointer user_data);
|
||||
|
||||
void on_closefile_action(GSimpleAction *action,
|
||||
GVariant *parameter,
|
||||
gpointer user_data);
|
||||
|
||||
void on_savefile_action(GSimpleAction *action,
|
||||
GVariant *parameter,
|
||||
gpointer user_data);
|
||||
|
||||
|
||||
static const GActionEntry app_actions[] = {
|
||||
{ "quit", on_quit_action },
|
||||
{ "about", on_about_action },
|
||||
{ "preferences", on_preferences_action },
|
||||
{ "togglesidebar", on_togglesidebar_action },
|
||||
{ "editmode", on_editmode_action },
|
||||
{ "runmode", on_runmode_action },
|
||||
{ "presentmode", on_presentmode_action },
|
||||
{ "openfile", on_openfile_action },
|
||||
{ "closefile", on_closefile_action },
|
||||
{ "savefile", on_savefile_action },
|
||||
};
|
||||
|
|
|
@ -69,54 +69,19 @@ static void gem_graph_client_application_class_init(
|
|||
app_class->activate = gem_graph_client_application_activate;
|
||||
}
|
||||
|
||||
static void
|
||||
gem_graph_client_application_about_action (GSimpleAction *action,
|
||||
GVariant *parameter,
|
||||
gpointer user_data)
|
||||
{
|
||||
static const char *authors[] = { "Adrien Bourmault <neox@a-lec.org>",
|
||||
"Jean Sirmai <jean@a-lec.org>",
|
||||
NULL};
|
||||
GemGraphClientApplication *self = user_data;
|
||||
GtkWindow *window = NULL;
|
||||
|
||||
g_assert (GEM_GRAPH_CLIENT_IS_APPLICATION(self));
|
||||
|
||||
window = gtk_application_get_active_window(GTK_APPLICATION (self));
|
||||
|
||||
gtk_show_about_dialog(window,
|
||||
"program-name", "Gem-graph",
|
||||
"logo-icon-name", "application-x-executable",
|
||||
"authors", authors,
|
||||
"version", "0.1.0",
|
||||
"copyright", "Copyright © 2022 Libre en Communs",
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void gem_graph_client_application_quit_action (GSimpleAction *action,
|
||||
GVariant *parameter,
|
||||
gpointer user_data)
|
||||
{
|
||||
GemGraphClientApplication *self = user_data;
|
||||
|
||||
g_assert(GEM_GRAPH_CLIENT_IS_APPLICATION(self));
|
||||
|
||||
g_application_quit(G_APPLICATION(self));
|
||||
}
|
||||
|
||||
static const GActionEntry app_actions[] = {
|
||||
{ "quit", gem_graph_client_application_quit_action },
|
||||
{ "about", gem_graph_client_application_about_action },
|
||||
};
|
||||
|
||||
static void gem_graph_client_application_init(GemGraphClientApplication *self)
|
||||
{
|
||||
g_action_map_add_action_entries(G_ACTION_MAP(self),
|
||||
g_action_map_add_action_entries(G_ACTION_MAP(self),
|
||||
app_actions,
|
||||
G_N_ELEMENTS(app_actions),
|
||||
self);
|
||||
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.quit",
|
||||
(const char *[]) { "<primary>q", NULL });
|
||||
|
||||
}
|
||||
|
||||
|
||||
// XXX changer tous les noms
|
||||
|
|
|
@ -9,6 +9,9 @@
|
|||
<property name="default-width">1080</property>
|
||||
<property name="icon-name">application-x-executable</property>
|
||||
<property name="title">GemGraph 0.1.0</property>
|
||||
<style>
|
||||
<class name="devel"/>
|
||||
</style>
|
||||
<child type="titlebar">
|
||||
<object class="GtkHeaderBar" id="main_titlebar">
|
||||
<child type="end">
|
||||
|
|
|
@ -247,5 +247,5 @@ static void gem_graph_client_window_class_init(GemGraphClientWindowClass *klass)
|
|||
|
||||
static void gem_graph_client_window_init(GemGraphClientWindow *self)
|
||||
{
|
||||
gtk_widget_init_template(GTK_WIDGET (self));
|
||||
gtk_widget_init_template(GTK_WIDGET(self));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue