From 81d2e8d92e1f51fc63ba7ea80548bae3f73314a3 Mon Sep 17 00:00:00 2001 From: Sophie Krause Date: Mon, 17 Feb 2025 17:46:00 +0100 Subject: [PATCH] remove en, update ui, some minor changes --- meson.build | 132 +++++++++++++++---------------- po/LINGUAS | 3 +- po/de.po | 27 +++---- po/en.po | 39 --------- po/flashcards.pot | 18 +++-- resources/ui/create-category.blp | 5 +- resources/ui/window.blp | 80 ++++++++++--------- src/create-category.c | 2 +- src/flashcardsappwin.c | 23 +++++- 9 files changed, 154 insertions(+), 175 deletions(-) delete mode 100644 po/en.po diff --git a/meson.build b/meson.build index 42d743e..d53e1b0 100644 --- a/meson.build +++ b/meson.build @@ -1,7 +1,7 @@ project('flashcards', 'c', version: '1.0.0', meson_version: '>= 1.0.0', - default_options: [ 'warning_level=2', 'werror=false', 'c_std=gnu23', ], + default_options: ['warning_level=2', 'c_std=gnu23'], ) flashcards_deps = [ @@ -26,71 +26,71 @@ config_h.set_quoted('LOCALEDIR', get_option('prefix') / get_option('localedir')) configure_file(output: 'config.h', configuration: config_h) add_project_arguments(['-I' + meson.project_build_root()], language: 'c') -project_c_args = [] -test_c_args = [ - '-Wcast-align', - '-Wdeclaration-after-statement', - '-Werror=address', - '-Werror=array-bounds', - '-Werror=empty-body', - '-Werror=implicit', - '-Werror=implicit-function-declaration', - '-Werror=incompatible-pointer-types', - '-Werror=init-self', - '-Werror=int-conversion', - '-Werror=int-to-pointer-cast', - '-Werror=main', - '-Werror=misleading-indentation', - '-Werror=missing-braces', - '-Werror=missing-include-dirs', - '-Werror=nonnull', - '-Werror=overflow', - '-Werror=parenthesis', - '-Werror=pointer-arith', - '-Werror=pointer-to-int-cast', - '-Werror=redundant-decls', - '-Werror=return-type', - '-Werror=sequence-point', - '-Werror=shadow', - '-Werror=strict-prototypes', - '-Werror=trigraphs', - '-Werror=undef', - '-Werror=write-strings', - '-Wformat-nonliteral', - '-Wignored-qualifiers', - '-Wimplicit-function-declaration', - '-Wlogical-op', - '-Wmissing-declarations', - '-Wmissing-format-attribute', - '-Wmissing-include-dirs', - '-Wmissing-noreturn', - '-Wnested-externs', - '-Wno-cast-function-type', - '-Wno-dangling-pointer', - '-Wno-missing-field-initializers', - '-Wno-sign-compare', - '-Wno-unused-parameter', - '-Wold-style-definition', - '-Wpointer-arith', - '-Wredundant-decls', - '-Wstrict-prototypes', - '-Wswitch-default', - '-Wswitch-enum', - '-Wundef', - '-Wuninitialized', - '-Wunused', - '-fno-strict-aliasing', - ['-Werror=format-security', '-Werror=format=2'], -] -if get_option('buildtype') != 'plain' - test_c_args += '-fstack-protector-strong' -endif -foreach arg: test_c_args - if cc.has_multi_arguments(arg) - project_c_args += arg - endif -endforeach -add_project_arguments(project_c_args, language: 'c') +# project_c_args = [] +# test_c_args = [ +# '-Wcast-align', +# '-Wdeclaration-after-statement', +# '-Werror=address', +# '-Werror=array-bounds', +# '-Werror=empty-body', +# '-Werror=implicit', +# '-Werror=implicit-function-declaration', +# '-Werror=incompatible-pointer-types', +# '-Werror=init-self', +# '-Werror=int-conversion', +# '-Werror=int-to-pointer-cast', +# '-Werror=main', +# '-Werror=misleading-indentation', +# '-Werror=missing-braces', +# '-Werror=missing-include-dirs', +# '-Werror=nonnull', +# '-Werror=overflow', +# '-Werror=parenthesis', +# '-Werror=pointer-arith', +# '-Werror=pointer-to-int-cast', +# '-Werror=redundant-decls', +# '-Werror=return-type', +# '-Werror=sequence-point', +# '-Werror=shadow', +# '-Werror=strict-prototypes', +# '-Werror=trigraphs', +# '-Werror=undef', +# '-Werror=write-strings', +# '-Wformat-nonliteral', +# '-Wignored-qualifiers', +# '-Wimplicit-function-declaration', +# '-Wlogical-op', +# '-Wmissing-declarations', +# '-Wmissing-format-attribute', +# '-Wmissing-include-dirs', +# '-Wmissing-noreturn', +# '-Wnested-externs', +# '-Wno-cast-function-type', +# '-Wno-dangling-pointer', +# '-Wno-missing-field-initializers', +# '-Wno-sign-compare', +# '-Wno-unused-parameter', +# '-Wold-style-definition', +# '-Wpointer-arith', +# '-Wredundant-decls', +# '-Wstrict-prototypes', +# '-Wswitch-default', +# '-Wswitch-enum', +# '-Wundef', +# '-Wuninitialized', +# '-Wunused', +# '-fno-strict-aliasing', +# ['-Werror=format-security', '-Werror=format=2'], +# ] +# if get_option('buildtype') != 'plain' +# test_c_args += '-fstack-protector-strong' +# endif +# foreach arg: test_c_args +# if cc.has_multi_arguments(arg) +# project_c_args += arg +# endif +# endforeach +# add_project_arguments(project_c_args, language: 'c') executable('flashcards', sourcefiles, diff --git a/po/LINGUAS b/po/LINGUAS index 150b83b..7673daa 100644 --- a/po/LINGUAS +++ b/po/LINGUAS @@ -1,2 +1 @@ -en -de \ No newline at end of file +de diff --git a/po/de.po b/po/de.po index 8458249..7ab37d9 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-05 18:52+0100\n" +"POT-Creation-Date: 2025-02-17 16:10+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -11,7 +11,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -#: resources/ui/window.blp:5 resources/ui/window.blp:54 src/flashcardsapp.c:42 +#: resources/ui/window.blp:5 resources/ui/window.blp:59 src/flashcardsapp.c:42 msgid "Flashcards" msgstr "Karteikarten" @@ -19,25 +19,22 @@ msgstr "Karteikarten" msgid "Categories" msgstr "Kategorien" -#: resources/ui/window.blp:96 +#: resources/ui/window.blp:102 msgid "About Flashcards" msgstr "Über Karteikarten" -#: resources/ui/create-category.blp:9 -#, fuzzy +#: resources/ui/create-category.blp:5 +msgid "Create a new category" +msgstr "Erstelle eine neue Kategorie" + +#: resources/ui/create-category.blp:8 msgid "Cancel" msgstr "Abbrechen" -#: resources/ui/create-category.blp:10 +#: resources/ui/create-category.blp:9 msgid "Add" msgstr "Hinzufügen" -#: src/flashcardsapp.c:45 -msgid "translator-credits" -msgstr "Übersetzer-Credits" - -#~ msgid "Topics" -#~ msgstr "Themen" - -#~ msgid "_Replace" -#~ msgstr "Ersetzen" +#: resources/ui/create-category.blp:14 +msgid "Category title" +msgstr "Kategorie-Titel" diff --git a/po/en.po b/po/en.po deleted file mode 100644 index 6d42445..0000000 --- a/po/en.po +++ /dev/null @@ -1,39 +0,0 @@ -msgid "" -msgstr "" -"Project-Id-Version: flashcards\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-02-05 18:52+0100\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" -"Language: \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" - -#: resources/ui/window.blp:5 resources/ui/window.blp:54 src/flashcardsapp.c:42 -msgid "Flashcards" -msgstr "Flashcards" - -#: resources/ui/window.blp:17 -msgid "Categories" -msgstr "" - -#: resources/ui/window.blp:96 -msgid "About Flashcards" -msgstr "About Flashcards" - -#: resources/ui/create-category.blp:9 -msgid "Cancel" -msgstr "" - -#: resources/ui/create-category.blp:10 -msgid "Add" -msgstr "" - -#: src/flashcardsapp.c:45 -msgid "translator-credits" -msgstr "" - -#~ msgid "Topics" -#~ msgstr "Topics" diff --git a/po/flashcards.pot b/po/flashcards.pot index 7009f4f..9d15057 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-05 18:52+0100\n" +"POT-Creation-Date: 2025-02-17 16:10+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -17,7 +17,7 @@ msgstr "" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" -#: resources/ui/window.blp:5 resources/ui/window.blp:54 src/flashcardsapp.c:42 +#: resources/ui/window.blp:5 resources/ui/window.blp:59 src/flashcardsapp.c:42 msgid "Flashcards" msgstr "" @@ -25,18 +25,22 @@ msgstr "" msgid "Categories" msgstr "" -#: resources/ui/window.blp:96 +#: resources/ui/window.blp:102 msgid "About Flashcards" msgstr "" -#: resources/ui/create-category.blp:9 +#: resources/ui/create-category.blp:5 +msgid "Create a new category" +msgstr "" + +#: resources/ui/create-category.blp:8 msgid "Cancel" msgstr "" -#: resources/ui/create-category.blp:10 +#: resources/ui/create-category.blp:9 msgid "Add" msgstr "" -#: src/flashcardsapp.c:45 -msgid "translator-credits" +#: resources/ui/create-category.blp:14 +msgid "Category title" msgstr "" diff --git a/resources/ui/create-category.blp b/resources/ui/create-category.blp index c1f6675..5a711be 100644 --- a/resources/ui/create-category.blp +++ b/resources/ui/create-category.blp @@ -2,8 +2,7 @@ using Gtk 4.0; using Adw 1; template $FlashcardsCreateCategoryDialog : Adw.AlertDialog { - heading: "Create a new category"; - default-response: "add"; + heading: _("Create a new category"); close-response: "cancel"; responses [ cancel: _("Cancel"), @@ -12,7 +11,7 @@ template $FlashcardsCreateCategoryDialog : Adw.AlertDialog { response => $on_response(); Adw.EntryRow entry { - title: "Category name"; + title: _("Category title"); styles [ "card", ] diff --git a/resources/ui/window.blp b/resources/ui/window.blp index 87c81f7..f74d818 100644 --- a/resources/ui/window.blp +++ b/resources/ui/window.blp @@ -16,47 +16,16 @@ template $FlashcardsAppWindow : Adw.ApplicationWindow { Adw.NavigationPage sidebar { title: _("Categories"); - Box { - orientation: vertical; - hexpand: true; + Adw.ToolbarView { width-request: 360; + [top] Adw.HeaderBar { - [end] + [start] Gtk.Button { icon-name: "list-add-symbolic"; clicked => $on_add_category(); } - } - - Adw.Clamp { - hexpand: true; - - ListBox topics { - hexpand: true; - selection-mode: single; - margin-top: 12; - margin-bottom: 12; - margin-start: 12; - margin-end: 12; - row-selected => $on_category_selected(); - - styles [ - "boxed-list", - ] - } - } - } - } - - [content] - Adw.NavigationPage content { - title: _("Flashcards"); - Box { - orientation: vertical; - hexpand: true; - - Adw.HeaderBar { [end] Gtk.MenuButton { icon-name: "open-menu-symbolic"; @@ -64,9 +33,44 @@ template $FlashcardsAppWindow : Adw.ApplicationWindow { } } - Adw.Clamp { - hexpand: true; - + content: ScrolledWindow { + 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", + ] + } + }; + } + } + + [content] + Adw.NavigationPage content { + title: _("Flashcards"); + + Adw.ToolbarView { + [top] + Adw.HeaderBar { + [start] + Gtk.Button { + icon-name: "user-trash-symbolic"; + clicked => $on_delete_category(); + } + [title] + Adw.WindowTitle title { + title: _("Flashcards"); + subtitle: _("Test"); + } + } + + content: Adw.Clamp { Adw.Bin { margin-top: 12; margin-bottom: 12; @@ -85,7 +89,7 @@ template $FlashcardsAppWindow : Adw.ApplicationWindow { label: "Wie viel Grad hat ein Kreis?"; }; } - } + }; } } } diff --git a/src/create-category.c b/src/create-category.c index 787fac5..06f4a84 100644 --- a/src/create-category.c +++ b/src/create-category.c @@ -23,7 +23,7 @@ flashcards_create_category_dialog_init(FlashcardsCreateCategoryDialog *self) } static void -on_response(AdwAlertDialog *dialog, +on_response(__attribute__((unused)) AdwAlertDialog *dialog, gchar *response, gpointer user_data) { diff --git a/src/flashcardsappwin.c b/src/flashcardsappwin.c index e642bf9..9d2bd0f 100644 --- a/src/flashcardsappwin.c +++ b/src/flashcardsappwin.c @@ -17,6 +17,7 @@ struct _FlashcardsAppWindow GArray *categories; + AdwWindowTitle *title; AdwNavigationSplitView *split_view; AdwNavigationPage *sidebar; AdwNavigationPage *content; @@ -29,7 +30,7 @@ struct _FlashcardsAppWindow G_DEFINE_TYPE(FlashcardsAppWindow, flashcards_app_window, ADW_TYPE_APPLICATION_WINDOW); static void -on_category_selected(GtkListBox *box, GtkListBoxRow *row, gpointer user_data) +on_category_selected(__attribute__((unused)) GtkListBox *box, GtkListBoxRow *row, gpointer user_data) { FlashcardsAppWindow *win; int id; @@ -38,16 +39,19 @@ on_category_selected(GtkListBox *box, GtkListBoxRow *row, gpointer user_data) { return; } - printf("Test\n"); win = user_data; 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)); printf("%d\n", id); + + char test[2]; + sprintf(test, "%d", id); + adw_window_title_set_subtitle(ADW_WINDOW_TITLE(win->title), test); } static void -on_add_category(GtkButton *self, +on_add_category(__attribute__((unused)) GtkButton *self, gpointer user_data) { FlashcardsCreateCategoryDialog *dialog; @@ -56,6 +60,15 @@ on_add_category(GtkButton *self, adw_dialog_present(ADW_DIALOG(dialog), GTK_WIDGET(user_data)); } +static void +on_delete_category(__attribute__((unused)) GtkButton *self, + gpointer user_data) +{ + FlashcardsAppWindow *win = user_data; + + printf("Delete category\n"); +} + void flashcards_app_window_test(FlashcardsAppWindow *win, const gchar *test) { GtkWidget *child; @@ -81,7 +94,7 @@ flashcards_app_window_init(FlashcardsAppWindow *win) categories = win->categories; - for (int i = 0; i < categories->len; i++) + for (guint i = 0; i < categories->len; i++) { GtkWidget *child; category c; @@ -101,6 +114,7 @@ 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_bind_template_child(GTK_WIDGET_CLASS(class), FlashcardsAppWindow, title); gtk_widget_class_bind_template_child(GTK_WIDGET_CLASS(class), FlashcardsAppWindow, split_view); gtk_widget_class_bind_template_child(GTK_WIDGET_CLASS(class), FlashcardsAppWindow, sidebar); gtk_widget_class_bind_template_child(GTK_WIDGET_CLASS(class), FlashcardsAppWindow, content); @@ -109,6 +123,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); } FlashcardsAppWindow *