diff options
author | Vivien Kraus <vivien@planete-kraus.eu> | 2023-03-13 20:06:11 +0100 |
---|---|---|
committer | Vivien Kraus <vivien@planete-kraus.eu> | 2023-03-13 21:14:10 +0100 |
commit | c3af2a1b3c86bf1070b60f16c6caed2d13763ac5 (patch) | |
tree | 4f435ec045e6972725370ed3a059e71d5728de37 /src | |
parent | 1c031b6fa198b5732f7cb39b54c2fb1d70673c4c (diff) |
Show the About page when passed -V (--version).
Diffstat (limited to 'src')
-rw-r--r-- | src/adwaita/disfluid-about.c | 60 | ||||
-rw-r--r-- | src/adwaita/disfluid-application.c | 64 |
2 files changed, 90 insertions, 34 deletions
diff --git a/src/adwaita/disfluid-about.c b/src/adwaita/disfluid-about.c index 028b762..ccc55f8 100644 --- a/src/adwaita/disfluid-about.c +++ b/src/adwaita/disfluid-about.c @@ -97,22 +97,48 @@ disfluid_adw_show_about (GtkApplication * app) char **designers = enumerate_credits (disfluid_author_is_designer); char **artists = enumerate_credits (disfluid_author_is_artist); char **documenters = enumerate_credits (disfluid_author_is_documenter); - adw_show_about_window (gtk_application_get_active_window (app), - "application-name", _("Experiences"), - "application-icon", disfluid_adw_application_id (), - "version", disfluid_version (), - "copyright", _("Copyright © 2023 Vivien Kraus"), - "developer-name", developer, - "website", disfluid_website (), - "developers", developers, - "designers", designers, - "artists", artists, - "documenters", documenters, - "translator-credits", - disfluid_translation_credits (), "license-type", - GTK_LICENSE_AGPL_3_0, - "release-notes", disfluid_whats_new (), - "release-notes-version", disfluid_major_version (), - NULL); + AdwAboutWindow *window = + (AdwAboutWindow *) g_object_new (ADW_TYPE_ABOUT_WINDOW, + "application-name", _("Experiences"), + "application-icon", + disfluid_adw_application_id (), + "version", disfluid_version (), + "copyright", + _("Copyright © 2023 Vivien Kraus"), + "developer-name", developer, + "website", disfluid_website (), + "developers", developers, + "designers", designers, + "artists", artists, + "documenters", documenters, + "translator-credits", + disfluid_translation_credits (), + "license-type", GTK_LICENSE_AGPL_3_0, + "release-notes", disfluid_whats_new (), + "release-notes-version", + disfluid_major_version (), + NULL); + gtk_window_set_application (GTK_WINDOW (window), app); + gtk_window_present (GTK_WINDOW (window)); free (developer); + for (size_t i = 0; developers[i] != NULL; i++) + { + free (developers[i]); + } + free (developers); + for (size_t i = 0; designers[i] != NULL; i++) + { + free (designers[i]); + } + free (designers); + for (size_t i = 0; artists[i] != NULL; i++) + { + free (artists[i]); + } + free (artists); + for (size_t i = 0; documenters[i] != NULL; i++) + { + free (documenters[i]); + } + free (documenters); } diff --git a/src/adwaita/disfluid-application.c b/src/adwaita/disfluid-application.c index 08af0c8..471bfae 100644 --- a/src/adwaita/disfluid-application.c +++ b/src/adwaita/disfluid-application.c @@ -23,6 +23,7 @@ struct _DisfluidAdwApplication { AdwApplication parent_instance; + gboolean only_show_version; }; struct _DisfluidAdwApplicationClass @@ -41,27 +42,61 @@ disfluid_adw_application_class_init (DisfluidAdwApplicationClass * klass) } static void -disfluid_adw_application_init (DisfluidAdwApplication * self) +launch_about_window (GSimpleAction * action, GVariant * parameter, + gpointer user_data) { - (void) self; - /* Perform default initialization of self. */ + (void) action; + (void) parameter; + DisfluidAdwApplication *self = user_data; + disfluid_adw_show_about (GTK_APPLICATION (self)); } static void -activated (GtkApplication * app) +disfluid_adw_application_init (DisfluidAdwApplication * self) { - GtkWidget *window = disfluid_adw_window_new (app); - gtk_window_present (GTK_WINDOW (window)); + (void) self; + /* Perform default initialization of self. */ + self->only_show_version = false; + g_application_set_flags (G_APPLICATION (self), + g_application_get_flags (G_APPLICATION (self)) | + G_APPLICATION_HANDLES_OPEN); + static GActionEntry app_actions[] = { + {.name = "about",.activate = launch_about_window} + }; + g_action_map_add_action_entries (G_ACTION_MAP (self), app_actions, + G_N_ELEMENTS (app_actions), self); + GOptionEntry app_options[] = { + { + .long_name = N_("version"), + .short_name = 'V', + .flags = G_OPTION_FLAG_NONE, + .arg = G_OPTION_ARG_NONE, + .arg_data = &(self->only_show_version), + .description = N_("Show the program version.")}, + {0} + }; + for (size_t i = 0; i < sizeof (app_options) / sizeof (app_options[0]); i++) + { + app_options[i].long_name = dgettext (PACKAGE, app_options[i].long_name); + app_options[i].description = + dgettext (PACKAGE, app_options[i].description); + } + g_application_add_main_option_entries (G_APPLICATION (self), app_options); } static void -launch_about_window (GSimpleAction * action, GVariant * parameter, - gpointer user_data) +activated (GtkApplication * app) { - (void) action; - (void) parameter; - DisfluidAdwApplication *self = user_data; - disfluid_adw_show_about (GTK_APPLICATION (self)); + DisfluidAdwApplication *self = DISFLUID_ADW_APPLICATION (app); + if (self->only_show_version) + { + launch_about_window (NULL, NULL, app); + } + else + { + GtkWidget *window = disfluid_adw_window_new (app); + gtk_window_present (GTK_WINDOW (window)); + } } DisfluidAdwApplication * @@ -73,11 +108,6 @@ disfluid_adw_application_new (void) "application-id", disfluid_adw_application_id (), NULL); - static GActionEntry app_actions[] = { - {.name = "about",.activate = launch_about_window} - }; - g_action_map_add_action_entries (G_ACTION_MAP (self), app_actions, - G_N_ELEMENTS (app_actions), self); g_signal_connect (self, "activate", G_CALLBACK (activated), NULL); return self; } |