From 2144bc655beb4f51403b3b971f2a6d501e6227da Mon Sep 17 00:00:00 2001 From: Sophie Krause Date: Wed, 19 Feb 2025 16:21:45 +0100 Subject: [PATCH] update ui --- po/de.po | 43 +++++++++++++++++++---- po/flashcards.pot | 42 ++++++++++++++++++---- resources/ui/window.blp | 77 +++++++++++++++++++++++++++++++---------- src/flashcardsapp.c | 9 ----- src/flashcardsappwin.c | 57 +++++++++++++++--------------- 5 files changed, 157 insertions(+), 71 deletions(-) diff --git a/po/de.po b/po/de.po index b542584..b1282d8 100644 --- a/po/de.po +++ b/po/de.po @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: flashcards\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" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -11,21 +11,50 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -#: resources/ui/window.blp:5 resources/ui/window.blp:63 -#: resources/ui/window.blp:75 resources/li.sopht.Flashcards.desktop.in:3 +#: resources/ui/window.blp:5 resources/ui/window.blp:59 +#: resources/ui/window.blp:72 resources/li.sopht.Flashcards.desktop.in:3 #: resources/li.sopht.Flashcards.metainfo.xml.in:7 msgid "Flashcards" msgstr "Karteikarten" -#: resources/ui/window.blp:19 +#: resources/ui/window.blp:20 msgid "Categories" 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" 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" msgstr "Über Karteikarten" @@ -57,6 +86,6 @@ msgstr "Lerne Kategorien mit Karteikarten!" msgid "No description" msgstr "" -#: resources/li.sopht.Flashcards.metainfo.xml.in:33 +#: resources/li.sopht.Flashcards.metainfo.xml.in:44 msgid "A caption" msgstr "" diff --git a/po/flashcards.pot b/po/flashcards.pot index a753f19..f0a7e19 100644 --- a/po/flashcards.pot +++ b/po/flashcards.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: flashcards\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" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -17,21 +17,49 @@ msgstr "" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" -#: resources/ui/window.blp:5 resources/ui/window.blp:63 -#: resources/ui/window.blp:75 resources/li.sopht.Flashcards.desktop.in:3 +#: resources/ui/window.blp:5 resources/ui/window.blp:59 +#: resources/ui/window.blp:72 resources/li.sopht.Flashcards.desktop.in:3 #: resources/li.sopht.Flashcards.metainfo.xml.in:7 msgid "Flashcards" msgstr "" -#: resources/ui/window.blp:19 +#: resources/ui/window.blp:20 msgid "Categories" 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" 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" msgstr "" @@ -63,6 +91,6 @@ msgstr "" msgid "No description" msgstr "" -#: resources/li.sopht.Flashcards.metainfo.xml.in:33 +#: resources/li.sopht.Flashcards.metainfo.xml.in:44 msgid "A caption" msgstr "" diff --git a/resources/ui/window.blp b/resources/ui/window.blp index e7b51ab..48fe40c 100644 --- a/resources/ui/window.blp +++ b/resources/ui/window.blp @@ -5,9 +5,10 @@ template $FlashcardsAppWindow : Adw.ApplicationWindow { title: _("Flashcards"); default-width: 1200; default-height: 600; + show => $on_flashcards_app_window_show(); Adw.Breakpoint { - condition ( "max-width: 600sp" ) + condition ( "max-width: 600" ) setters { split_view.collapsed: true; } @@ -19,24 +20,25 @@ template $FlashcardsAppWindow : Adw.ApplicationWindow { title: _("Categories"); Adw.ToolbarView { - width-request: 360; - [top] Adw.HeaderBar { [start] Gtk.Button { icon-name: "list-add-symbolic"; clicked => $on_add_category(); + tooltip-text: _("Create category"); } [start] Gtk.Button { icon-name: "user-trash-symbolic"; clicked => $on_delete_category(); + tooltip-text: _("Delete category"); } [end] Gtk.MenuButton { icon-name: "open-menu-symbolic"; menu-model: primary_menu; + tooltip-text: _("Menu"); } } @@ -44,15 +46,9 @@ template $FlashcardsAppWindow : Adw.ApplicationWindow { ListBox topics { valign: start; selection-mode: single; - margin-top: 12; - margin-bottom: 12; - margin-start: 12; - margin-end: 12; - row-selected => $on_category_selected(); - - styles [ - "boxed-list", - ] + activate-on-single-click: true; + row-activated => $on_category_selected(); + styles ["navigation-sidebar"] } }; } @@ -69,6 +65,7 @@ template $FlashcardsAppWindow : Adw.ApplicationWindow { Gtk.Button { icon-name: "user-trash-symbolic"; clicked => $on_delete_category(); + tooltip-text: _("Delete flashcard"); } [title] Adw.WindowTitle title { @@ -80,18 +77,62 @@ template $FlashcardsAppWindow : Adw.ApplicationWindow { content: Adw.ViewStack main_view { Adw.ViewStackPage { child: Adw.StatusPage placeholder { - margin-top: 12; - margin-bottom: 12; - margin-start: 12; - margin-end: 12; - title: _("Select a category"); icon-name: "edit-find-symbolic"; }; } 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; + } + } + } + } }; } }; diff --git a/src/flashcardsapp.c b/src/flashcardsapp.c index bf30c8a..21a723f 100644 --- a/src/flashcardsapp.c +++ b/src/flashcardsapp.c @@ -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)); } diff --git a/src/flashcardsappwin.c b/src/flashcardsappwin.c index 5e3be33..4e6ff2a 100644 --- a/src/flashcardsappwin.c +++ b/src/flashcardsappwin.c @@ -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 *