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

update ui

This commit is contained in:
2025-02-19 16:21:45 +01:00
parent 48848f55a3
commit 2144bc655b
5 changed files with 157 additions and 71 deletions

View File

@@ -40,15 +40,6 @@ flashcards_app_about(
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",
"version", "1.0.0",
"issue-url", "https://gitlab.cvh-server.de/skrause/flashcards/-/issues",
"copyright", "© 2025 Sophie Krause",
"license-type", GTK_LICENSE_MIT_X11,
NULL);*/
dialog = adw_about_dialog_new_from_appdata("/li/sopht/flashcards/appdata", NULL);
adw_dialog_present(dialog, GTK_WIDGET(window));
}

View File

@@ -33,8 +33,7 @@ struct _FlashcardsAppWindow
G_DEFINE_TYPE(FlashcardsAppWindow, flashcards_app_window, ADW_TYPE_APPLICATION_WINDOW);
static void
on_category_selected(__attribute__((unused)) GtkListBox *box, GtkListBoxRow *row, gpointer user_data)
static void on_category_selected(__attribute__((unused)) GtkListBox *box, GtkListBoxRow *row, gpointer user_data)
{
FlashcardsAppWindow *win;
int id;
@@ -42,20 +41,9 @@ on_category_selected(__attribute__((unused)) GtkListBox *box, GtkListBoxRow *row
win = user_data;
if (!win->started)
{
win->started = true;
gtk_list_box_unselect_all(win->topics);
return;
}
if (row == NULL)
{
return;
}
adw_navigation_split_view_set_show_content(ADW_NAVIGATION_SPLIT_VIEW(win->split_view), TRUE);
id = gtk_list_box_row_get_index(gtk_list_box_get_selected_row(win->topics));
id = gtk_list_box_row_get_index(row);
printf("%d\n", id);
c = g_array_index(win->categories, category, id);
@@ -64,9 +52,8 @@ on_category_selected(__attribute__((unused)) GtkListBox *box, GtkListBoxRow *row
adw_view_stack_set_visible_child(win->main_view, win->flashcard);
}
static void
on_add_category(__attribute__((unused)) GtkButton *self,
gpointer user_data)
static void on_add_category(__attribute__((unused)) GtkButton *self,
gpointer user_data)
{
FlashcardsCreateCategoryDialog *dialog;
@@ -74,9 +61,8 @@ on_add_category(__attribute__((unused)) GtkButton *self,
adw_dialog_present(ADW_DIALOG(dialog), GTK_WIDGET(user_data));
}
static void
on_delete_category(__attribute__((unused)) GtkButton *self,
gpointer user_data)
static void on_delete_category(__attribute__((unused)) GtkButton *self,
gpointer user_data)
{
FlashcardsAppWindow *win;
@@ -87,8 +73,7 @@ on_delete_category(__attribute__((unused)) GtkButton *self,
adw_view_stack_set_visible_child(win->main_view, win->placeholder);
}
static void
load_categories(FlashcardsAppWindow *win)
static void load_categories(FlashcardsAppWindow *win)
{
GArray *categories;
@@ -100,13 +85,17 @@ load_categories(FlashcardsAppWindow *win)
for (guint i = 0; i < categories->len; i++)
{
GtkWidget *child;
GtkWidget *label;
category c;
c = g_array_index(categories, category, i);
printf("%d: %s\n", c.id, c.name);
child = adw_action_row_new();
adw_preferences_row_set_title(ADW_PREFERENCES_ROW(child), c.name);
child = gtk_list_box_row_new();
label = gtk_label_new(c.name);
gtk_label_set_ellipsize(GTK_LABEL(label), PANGO_ELLIPSIZE_MIDDLE);
gtk_widget_set_tooltip_text(label, c.name);
gtk_list_box_row_set_child(GTK_LIST_BOX_ROW(child), label);
gtk_list_box_append(win->topics, child);
}
@@ -120,17 +109,24 @@ void flashcards_app_window_test(FlashcardsAppWindow *win, const gchar *test)
load_categories(win);
}
static void
flashcards_app_window_init(FlashcardsAppWindow *win)
static void on_flashcards_app_window_show(GtkWidget *self,
gpointer user_data)
{
gtk_widget_init_template(GTK_WIDGET(win));
FlashcardsAppWindow *win;
win = user_data;
printf("Show\n");
win->db = database_connect(g_get_user_data_dir());
load_categories(win);
gtk_list_box_unselect_all(win->topics);
}
static void
flashcards_app_window_class_init(FlashcardsAppWindowClass *class)
static void flashcards_app_window_init(FlashcardsAppWindow *win)
{
gtk_widget_init_template(GTK_WIDGET(win));
win->db = database_connect(g_get_user_data_dir());
}
static void flashcards_app_window_class_init(FlashcardsAppWindowClass *class)
{
gtk_widget_class_set_template_from_resource(GTK_WIDGET_CLASS(class), "/li/sopht/flashcards/window.ui");
@@ -149,6 +145,7 @@ flashcards_app_window_class_init(FlashcardsAppWindowClass *class)
gtk_widget_class_bind_template_callback(GTK_WIDGET_CLASS(class), on_category_selected);
gtk_widget_class_bind_template_callback(GTK_WIDGET_CLASS(class), on_add_category);
gtk_widget_class_bind_template_callback(GTK_WIDGET_CLASS(class), on_delete_category);
gtk_widget_class_bind_template_callback(GTK_WIDGET_CLASS(class), on_flashcards_app_window_show);
}
FlashcardsAppWindow *