1
0
mirror of https://gitlab.cvh-server.de/skrause/flashcards.git synced 2025-12-12 06:41:38 +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

@@ -2,7 +2,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: flashcards\n" "Project-Id-Version: flashcards\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-02-18 18:53+0100\n" "POT-Creation-Date: 2025-02-19 16:20+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -11,21 +11,50 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
#: resources/ui/window.blp:5 resources/ui/window.blp:63 #: resources/ui/window.blp:5 resources/ui/window.blp:59
#: resources/ui/window.blp:75 resources/li.sopht.Flashcards.desktop.in:3 #: resources/ui/window.blp:72 resources/li.sopht.Flashcards.desktop.in:3
#: resources/li.sopht.Flashcards.metainfo.xml.in:7 #: resources/li.sopht.Flashcards.metainfo.xml.in:7
msgid "Flashcards" msgid "Flashcards"
msgstr "Karteikarten" msgstr "Karteikarten"
#: resources/ui/window.blp:19 #: resources/ui/window.blp:20
msgid "Categories" msgid "Categories"
msgstr "Kategorien" msgstr "Kategorien"
#: resources/ui/window.blp:88 #: resources/ui/window.blp:29
msgid "Create category"
msgstr "Erstelle eine neue Kategorie"
#: resources/ui/window.blp:35
msgid "Delete category"
msgstr "Kategorie löschen"
#: resources/ui/window.blp:41
msgid "Menu"
msgstr "Menü"
#: resources/ui/window.blp:68
#, fuzzy
msgid "Delete flashcard"
msgstr "Über Karteikarten"
#: resources/ui/window.blp:80
msgid "Select a category" msgid "Select a category"
msgstr "Wähle eine Kategorie" msgstr "Wähle eine Kategorie"
#: resources/ui/window.blp:106 #: resources/ui/window.blp:120
msgid "Easy"
msgstr "Einfach"
#: resources/ui/window.blp:125
msgid "Medium"
msgstr "Mittel"
#: resources/ui/window.blp:130
msgid "Hard"
msgstr "Schwer"
#: resources/ui/window.blp:147
msgid "About Flashcards" msgid "About Flashcards"
msgstr "Über Karteikarten" msgstr "Über Karteikarten"
@@ -57,6 +86,6 @@ msgstr "Lerne Kategorien mit Karteikarten!"
msgid "No description" msgid "No description"
msgstr "" msgstr ""
#: resources/li.sopht.Flashcards.metainfo.xml.in:33 #: resources/li.sopht.Flashcards.metainfo.xml.in:44
msgid "A caption" msgid "A caption"
msgstr "" msgstr ""

View File

@@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: flashcards\n" "Project-Id-Version: flashcards\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-02-18 18:53+0100\n" "POT-Creation-Date: 2025-02-19 16:20+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -17,21 +17,49 @@ msgstr ""
"Content-Type: text/plain; charset=CHARSET\n" "Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
#: resources/ui/window.blp:5 resources/ui/window.blp:63 #: resources/ui/window.blp:5 resources/ui/window.blp:59
#: resources/ui/window.blp:75 resources/li.sopht.Flashcards.desktop.in:3 #: resources/ui/window.blp:72 resources/li.sopht.Flashcards.desktop.in:3
#: resources/li.sopht.Flashcards.metainfo.xml.in:7 #: resources/li.sopht.Flashcards.metainfo.xml.in:7
msgid "Flashcards" msgid "Flashcards"
msgstr "" msgstr ""
#: resources/ui/window.blp:19 #: resources/ui/window.blp:20
msgid "Categories" msgid "Categories"
msgstr "" msgstr ""
#: resources/ui/window.blp:88 #: resources/ui/window.blp:29
msgid "Create category"
msgstr ""
#: resources/ui/window.blp:35
msgid "Delete category"
msgstr ""
#: resources/ui/window.blp:41
msgid "Menu"
msgstr ""
#: resources/ui/window.blp:68
msgid "Delete flashcard"
msgstr ""
#: resources/ui/window.blp:80
msgid "Select a category" msgid "Select a category"
msgstr "" msgstr ""
#: resources/ui/window.blp:106 #: resources/ui/window.blp:120
msgid "Easy"
msgstr ""
#: resources/ui/window.blp:125
msgid "Medium"
msgstr ""
#: resources/ui/window.blp:130
msgid "Hard"
msgstr ""
#: resources/ui/window.blp:147
msgid "About Flashcards" msgid "About Flashcards"
msgstr "" msgstr ""
@@ -63,6 +91,6 @@ msgstr ""
msgid "No description" msgid "No description"
msgstr "" msgstr ""
#: resources/li.sopht.Flashcards.metainfo.xml.in:33 #: resources/li.sopht.Flashcards.metainfo.xml.in:44
msgid "A caption" msgid "A caption"
msgstr "" msgstr ""

View File

@@ -5,9 +5,10 @@ template $FlashcardsAppWindow : Adw.ApplicationWindow {
title: _("Flashcards"); title: _("Flashcards");
default-width: 1200; default-width: 1200;
default-height: 600; default-height: 600;
show => $on_flashcards_app_window_show();
Adw.Breakpoint { Adw.Breakpoint {
condition ( "max-width: 600sp" ) condition ( "max-width: 600" )
setters { setters {
split_view.collapsed: true; split_view.collapsed: true;
} }
@@ -19,24 +20,25 @@ template $FlashcardsAppWindow : Adw.ApplicationWindow {
title: _("Categories"); title: _("Categories");
Adw.ToolbarView { Adw.ToolbarView {
width-request: 360;
[top] [top]
Adw.HeaderBar { Adw.HeaderBar {
[start] [start]
Gtk.Button { Gtk.Button {
icon-name: "list-add-symbolic"; icon-name: "list-add-symbolic";
clicked => $on_add_category(); clicked => $on_add_category();
tooltip-text: _("Create category");
} }
[start] [start]
Gtk.Button { Gtk.Button {
icon-name: "user-trash-symbolic"; icon-name: "user-trash-symbolic";
clicked => $on_delete_category(); clicked => $on_delete_category();
tooltip-text: _("Delete category");
} }
[end] [end]
Gtk.MenuButton { Gtk.MenuButton {
icon-name: "open-menu-symbolic"; icon-name: "open-menu-symbolic";
menu-model: primary_menu; menu-model: primary_menu;
tooltip-text: _("Menu");
} }
} }
@@ -44,15 +46,9 @@ template $FlashcardsAppWindow : Adw.ApplicationWindow {
ListBox topics { ListBox topics {
valign: start; valign: start;
selection-mode: single; selection-mode: single;
margin-top: 12; activate-on-single-click: true;
margin-bottom: 12; row-activated => $on_category_selected();
margin-start: 12; styles ["navigation-sidebar"]
margin-end: 12;
row-selected => $on_category_selected();
styles [
"boxed-list",
]
} }
}; };
} }
@@ -69,6 +65,7 @@ template $FlashcardsAppWindow : Adw.ApplicationWindow {
Gtk.Button { Gtk.Button {
icon-name: "user-trash-symbolic"; icon-name: "user-trash-symbolic";
clicked => $on_delete_category(); clicked => $on_delete_category();
tooltip-text: _("Delete flashcard");
} }
[title] [title]
Adw.WindowTitle title { Adw.WindowTitle title {
@@ -80,18 +77,62 @@ template $FlashcardsAppWindow : Adw.ApplicationWindow {
content: Adw.ViewStack main_view { content: Adw.ViewStack main_view {
Adw.ViewStackPage { Adw.ViewStackPage {
child: Adw.StatusPage placeholder { child: Adw.StatusPage placeholder {
margin-top: 12;
margin-bottom: 12;
margin-start: 12;
margin-end: 12;
title: _("Select a category"); title: _("Select a category");
icon-name: "edit-find-symbolic"; icon-name: "edit-find-symbolic";
}; };
} }
Adw.ViewStackPage { Adw.ViewStackPage {
child: Adw.Bin flashcard { child: Adw.Clamp flashcard {
maximum-size: 800;
Box {
orientation: vertical;
spacing: 24;
margin-top: 12;
margin-bottom: 12;
margin-start: 12;
margin-end: 12;
Box {
styles ["card", "activatable"]
halign: center;
Label {
styles ["title-4"]
margin-top: 24;
margin-bottom: 24;
margin-start: 48;
margin-end: 48;
hexpand: true;
justify: center;
label: "Wie viele Bäume sind in einem Wald?";
wrap: true;
wrap-mode: word_char;
}
}
Adw.Clamp {
maximum-size: 600;
Box {
styles ["linked"]
Button {
styles ["pill"]
label: _("Easy");
hexpand: true;
}
Button {
styles ["pill"]
label: _("Medium");
hexpand: true;
}
Button {
styles ["pill"]
label: _("Hard");
hexpand: true;
}
}
}
}
}; };
} }
}; };

View File

@@ -40,15 +40,6 @@ flashcards_app_about(
window = gtk_application_get_active_window(GTK_APPLICATION(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",
"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); dialog = adw_about_dialog_new_from_appdata("/li/sopht/flashcards/appdata", NULL);
adw_dialog_present(dialog, GTK_WIDGET(window)); 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); G_DEFINE_TYPE(FlashcardsAppWindow, flashcards_app_window, ADW_TYPE_APPLICATION_WINDOW);
static void static void on_category_selected(__attribute__((unused)) GtkListBox *box, GtkListBoxRow *row, gpointer user_data)
on_category_selected(__attribute__((unused)) GtkListBox *box, GtkListBoxRow *row, gpointer user_data)
{ {
FlashcardsAppWindow *win; FlashcardsAppWindow *win;
int id; int id;
@@ -42,20 +41,9 @@ on_category_selected(__attribute__((unused)) GtkListBox *box, GtkListBoxRow *row
win = user_data; 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); 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); printf("%d\n", id);
c = g_array_index(win->categories, category, 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); adw_view_stack_set_visible_child(win->main_view, win->flashcard);
} }
static void static void on_add_category(__attribute__((unused)) GtkButton *self,
on_add_category(__attribute__((unused)) GtkButton *self, gpointer user_data)
gpointer user_data)
{ {
FlashcardsCreateCategoryDialog *dialog; FlashcardsCreateCategoryDialog *dialog;
@@ -74,9 +61,8 @@ on_add_category(__attribute__((unused)) GtkButton *self,
adw_dialog_present(ADW_DIALOG(dialog), GTK_WIDGET(user_data)); adw_dialog_present(ADW_DIALOG(dialog), GTK_WIDGET(user_data));
} }
static void static void on_delete_category(__attribute__((unused)) GtkButton *self,
on_delete_category(__attribute__((unused)) GtkButton *self, gpointer user_data)
gpointer user_data)
{ {
FlashcardsAppWindow *win; FlashcardsAppWindow *win;
@@ -87,8 +73,7 @@ on_delete_category(__attribute__((unused)) GtkButton *self,
adw_view_stack_set_visible_child(win->main_view, win->placeholder); adw_view_stack_set_visible_child(win->main_view, win->placeholder);
} }
static void static void load_categories(FlashcardsAppWindow *win)
load_categories(FlashcardsAppWindow *win)
{ {
GArray *categories; GArray *categories;
@@ -100,13 +85,17 @@ load_categories(FlashcardsAppWindow *win)
for (guint i = 0; i < categories->len; i++) for (guint i = 0; i < categories->len; i++)
{ {
GtkWidget *child; GtkWidget *child;
GtkWidget *label;
category c; category c;
c = g_array_index(categories, category, i); c = g_array_index(categories, category, i);
printf("%d: %s\n", c.id, c.name); printf("%d: %s\n", c.id, c.name);
child = adw_action_row_new(); child = gtk_list_box_row_new();
adw_preferences_row_set_title(ADW_PREFERENCES_ROW(child), c.name); 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); gtk_list_box_append(win->topics, child);
} }
@@ -120,17 +109,24 @@ void flashcards_app_window_test(FlashcardsAppWindow *win, const gchar *test)
load_categories(win); load_categories(win);
} }
static void static void on_flashcards_app_window_show(GtkWidget *self,
flashcards_app_window_init(FlashcardsAppWindow *win) 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); load_categories(win);
gtk_list_box_unselect_all(win->topics);
} }
static void static void flashcards_app_window_init(FlashcardsAppWindow *win)
flashcards_app_window_class_init(FlashcardsAppWindowClass *class) {
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"); 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_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_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_delete_category);
gtk_widget_class_bind_template_callback(GTK_WIDGET_CLASS(class), on_flashcards_app_window_show);
} }
FlashcardsAppWindow * FlashcardsAppWindow *