Skip to content

Commit

Permalink
Use the application name in the print notification (flatpak#304)
Browse files Browse the repository at this point in the history
When printing with an flatpak application, the notification
telling that it prints says "Document from %s" where %s is the
app desktop file id (i.e. will print "Document from
org.gnome.Evince" with evince).

This is not very clear what this name is in the notification,
particularly with a third-party app, for example
com.github.my_beautiful_github_name.app_name.

So this changes %s to the actual translated application name,
looking in the corresponding desktop file entry.
  • Loading branch information
Vanadiae authored May 28, 2020
1 parent 82e474e commit 68c044c
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/print.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <gio/gunixfdlist.h>
#include <gio/gunixinputstream.h>
#include <gio/gunixoutputstream.h>
#include <gio/gdesktopappinfo.h>

#include "xdg-desktop-portal-dbus.h"

Expand Down Expand Up @@ -259,8 +260,27 @@ print_file (int fd,
g_autoptr(GUnixInputStream) istream = NULL;
g_autoptr(GUnixOutputStream) ostream = NULL;
int fd2;
g_autofree char *app_desktop_fullname = NULL;
g_autoptr (GDesktopAppInfo) app_info = NULL;
// ensures the app_name won't be NULL even if the app_id.desktop file doesn't exist
g_autofree char *app_name = g_strdup (app_id);

title = g_strdup_printf ("Document from %s", app_id);
if (!g_str_has_suffix (app_id, ".desktop"))
{
app_desktop_fullname = g_strconcat (app_id, ".desktop", NULL);
}
else
{
app_desktop_fullname = g_strdup (app_id);
}

app_info = g_desktop_app_info_new (app_desktop_fullname);
if (app_info)
{
app_name = g_desktop_app_info_get_locale_string (app_info, "Name");
}

title = g_strdup_printf ("Document from %s", app_name);

if (!preview)
job = gtk_print_job_new (title, printer, settings, page_setup);
Expand Down

0 comments on commit 68c044c

Please sign in to comment.