1
0
mirror of https://gitlab.cvh-server.de/skrause/flashcards.git synced 2026-04-30 21:47:05 +00:00

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

This commit is contained in:
2026-03-06 15:48:07 +01:00
parent d5c11782d5
commit f3e20967b8
31 changed files with 767 additions and 183 deletions

56
src/create-category.c Normal file
View File

@@ -0,0 +1,56 @@
#include <gtk/gtk.h>
#include <adwaita.h>
#include <glib/gi18n.h>
#include "create-category.h"
struct _FlashcardsCreateCategoryDialog
{
AdwAlertDialog parent;
GtkEditable *entry;
FlashcardsAppWindow *win;
};
G_DEFINE_TYPE(FlashcardsCreateCategoryDialog, flashcards_create_category_dialog, ADW_TYPE_ALERT_DIALOG);
static void
flashcards_create_category_dialog_init(FlashcardsCreateCategoryDialog *self)
{
gtk_widget_init_template(GTK_WIDGET(self));
}
static void
on_response(AdwAlertDialog *dialog,
gchar *response,
gpointer user_data)
{
FlashcardsCreateCategoryDialog *self = FLASHCARDS_CREATE_CATEGORY_DIALOG(user_data);
const gchar *category = gtk_editable_get_text(self->entry);
if (strcmp(response, "add") == 0 && strlen(category) > 0)
{
flashcards_app_window_test(self->win, category);
}
}
static void
flashcards_create_category_dialog_class_init(FlashcardsCreateCategoryDialogClass *class)
{
gtk_widget_class_set_template_from_resource(GTK_WIDGET_CLASS(class), "/li/sopht/flashcards/create-category.ui");
gtk_widget_class_bind_template_child(GTK_WIDGET_CLASS(class), FlashcardsCreateCategoryDialog, entry);
gtk_widget_class_bind_template_callback(GTK_WIDGET_CLASS(class), on_response);
}
FlashcardsCreateCategoryDialog *
flashcards_create_category_dialog_new(FlashcardsAppWindow *win)
{
FlashcardsCreateCategoryDialog *self = g_object_new(FLASHCARDS_CREATE_CATEGORY_DIALOG_TYPE, NULL);
self->win = win;
return self;
}