1
0
mirror of https://gitlab.cvh-server.de/skrause/flashcards.git synced 2025-12-12 07:51:38 +01:00

replace deprecated classes, update code, fix errors, add missing stuff

This commit is contained in:
2025-02-05 20:52:07 +01:00
parent 81e353b449
commit b4d8f9d096
31 changed files with 767 additions and 183 deletions

View File

@@ -1,6 +1,8 @@
#include <gtk/gtk.h>
#include <adwaita.h>
#include <glib/gi18n.h>
#include "flashcardsapp.h"
#include "flashcardsappwin.h"
@@ -13,9 +15,56 @@ struct _FlashcardsApp
G_DEFINE_TYPE(FlashcardsApp, flashcards_app, ADW_TYPE_APPLICATION);
static void
flashcards_app_quit_action(GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
FlashcardsApp *self = user_data;
g_assert(FLASHCARDS_IS_APP(self));
g_application_quit(G_APPLICATION(self));
}
static void
flashcards_app_about_action(GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
static const char *developers[] = {"Sophie Krause", NULL};
FlashcardsApp *self = user_data;
GtkWindow *window = NULL;
g_assert(FLASHCARDS_IS_APP(self));
window = gtk_application_get_active_window(GTK_APPLICATION(self));
adw_show_about_dialog(GTK_WIDGET(window),
"application-name", _("Flashcards"),
"application-icon", "li.sopht.Flashcards",
"developer-name", "Sophie Krause",
"translator-credits", "Sophie Krause",
"version", "1.0.0",
"developers", developers,
"copyright", "© 2025 Sophie Krause",
"license-type", GTK_LICENSE_MIT_X11,
NULL);
}
static const GActionEntry app_actions[] = {
{"quit", flashcards_app_quit_action},
{"about", flashcards_app_about_action},
};
static void
flashcards_app_init(FlashcardsApp *app)
{
g_action_map_add_action_entries(G_ACTION_MAP(app),
app_actions,
G_N_ELEMENTS(app_actions),
app);
gtk_application_set_accels_for_action(GTK_APPLICATION(app),
"app.quit",
(const char *[]){"<primary>q", NULL});
}
static void
@@ -59,7 +108,7 @@ FlashcardsApp *
flashcards_app_new(void)
{
return g_object_new(FLASHCARDS_APP_TYPE,
"application-id", "li.sopht.flashcards",
"flags", G_APPLICATION_HANDLES_OPEN,
"application-id", "li.sopht.Flashcards",
"flags", G_APPLICATION_DEFAULT_FLAGS,
NULL);
}