[gnome-software/wip/ubuntu-3-22: 14/28] Do not hardcode the application name



commit 698865f56e5180112fb37854ff6e11ee121828bb
Author: Richard Hughes <richard hughsie com>
Date:   Thu Dec 15 15:53:07 2016 +0000

    Do not hardcode the application name
    
    Various downstream distros rename 'GNOME Software' to different things, for
    various reasons.
    
    Allow the application name to be changed by patching the .desktop file in one
    place rather than having to patch various places in the source file.

 src/gs-application.c |   12 +++++++-----
 src/gs-main.c        |    4 ++++
 src/gs-shell.c       |    4 ++--
 3 files changed, 13 insertions(+), 7 deletions(-)
---
diff --git a/src/gs-application.c b/src/gs-application.c
index e66042d..c079d38 100644
--- a/src/gs-application.c
+++ b/src/gs-application.c
@@ -371,6 +371,7 @@ about_activated (GSimpleAction *action,
        };
        const gchar *copyright = "Copyright \xc2\xa9 2016 Richard Hughes, Matthias Clasen";
        GtkAboutDialog *dialog;
+       g_autofree gchar *title = NULL;
 
        gs_application_initialize_ui (app);
 
@@ -381,12 +382,13 @@ about_activated (GSimpleAction *action,
        gtk_about_dialog_set_logo_icon_name (dialog, "org.gnome.Software");
        gtk_about_dialog_set_translator_credits (dialog, _("translator-credits"));
        gtk_about_dialog_set_version (dialog, VERSION);
+       gtk_about_dialog_set_program_name (dialog, g_get_application_name ());
 
-       /* TRANSLATORS: this is the title of the about window */
-       gtk_window_set_title (GTK_WINDOW (dialog), _("About Software"));
-
-       /* TRANSLATORS: this is the application name */
-       gtk_about_dialog_set_program_name (dialog, _("Software"));
+       /* TRANSLATORS: this is the title of the about window, e.g.
+        * 'About Software' or 'About Application Installer' where the %s is
+        * the application name chosen by the distro */
+       title = g_strdup_printf (_("About %s"), g_get_application_name ());
+       gtk_window_set_title (GTK_WINDOW (dialog), title);
 
        /* TRANSLATORS: well, we seem to think so, anyway */
        gtk_about_dialog_set_comments (dialog, _("A nice way to manage the "
diff --git a/src/gs-main.c b/src/gs-main.c
index 156b284..c39e8ba 100644
--- a/src/gs-main.c
+++ b/src/gs-main.c
@@ -25,6 +25,7 @@
 #include <appstream-glib.h>
 #include <glib/gi18n.h>
 #include <gio/gio.h>
+#include <gio/gdesktopappinfo.h>
 #include <gtk/gtk.h>
 #include <locale.h>
 
@@ -35,6 +36,7 @@ int
 main (int argc, char **argv)
 {
        int status = 0;
+       g_autoptr(GDesktopAppInfo) appinfo = NULL;
        g_autoptr(GsApplication) application = NULL;
        g_autoptr(GsDebug) debug = gs_debug_new ();
        g_autoptr(AsProfile) profile = NULL;
@@ -52,6 +54,8 @@ main (int argc, char **argv)
 
        /* redirect logs */
        application = gs_application_new ();
+       appinfo = g_desktop_app_info_new ("org.gnome.Software.desktop");
+       g_set_application_name (g_app_info_get_name (G_APP_INFO (appinfo)));
        status = g_application_run (G_APPLICATION (application), argc, argv);
        return status;
 }
diff --git a/src/gs-shell.c b/src/gs-shell.c
index 88e701c..61d58bd 100644
--- a/src/gs-shell.c
+++ b/src/gs-shell.c
@@ -268,9 +268,9 @@ gs_shell_change_mode (GsShell *shell,
 
        context = gtk_widget_get_style_context (GTK_WIDGET (gtk_builder_get_object (priv->builder, 
"header")));
        gtk_style_context_remove_class (context, "selection-mode");
+
        /* set the window title back to default */
-       /* TRANSLATORS: this is the main window title */
-       gtk_window_set_title (priv->main_window, _("Software"));
+       gtk_window_set_title (priv->main_window, g_get_application_name ());
 
        /* update main buttons according to mode */
        priv->ignore_primary_buttons = TRUE;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]