From c736e15ecdcb18daa98f142227689df0a25f3854 Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Wed, 25 Jan 2023 15:25:24 +0100 Subject: [PATCH] WIP: new actions (2) --- src/ui/actions.c | 149 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100644 src/ui/actions.c diff --git a/src/ui/actions.c b/src/ui/actions.c new file mode 100644 index 0000000..cc6a920 --- /dev/null +++ b/src/ui/actions.c @@ -0,0 +1,149 @@ +/* + * Gem-graph OpenGL experiments + * + * Desc: User interface functions + * + * Copyright (C) 2023 Arthur Menges + * Copyright (C) 2023 Adrien Bourmault + * + * 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 . + */ + +#include "../../include/base.h" +#include "../../include/ui.h" + +void on_about_action(GSimpleAction *action, + GVariant *parameter, + gpointer user_data) +{ + static const char *authors[] = { "Adrien Bourmault ", + "Jean Sirmai ", + 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); +} + +void on_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)); +} + +void on_preferences_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)); +} + +void on_togglesidebar_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)); +} + +void on_editmode_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)); +} + +void on_runmode_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)); +} + +void on_presentmode_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)); +} + +void on_openfile_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)); +} + +void on_closefile_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)); +} + +void on_savefile_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)); +} +