gnome-initial-setup/gnome-initial-setup-3.28.0-fix-legacy-faces-missing-icon.patch

201 lines
7.8 KiB
Diff

From 55f148cb0e09009bc0bfc2e12b58fa3577bc900c Mon Sep 17 00:00:00 2001
From: Ondrej Holy <oholy@redhat.com>
Date: Mon, 9 Apr 2018 09:07:32 +0200
Subject: [PATCH 1/3] account: Use GIO API for face images handling
Users panel in gnome-control-center switched to GIO API for face images
handling. Let's do the similar changes here also as a preparation for
filtering out legacy face images.
https://bugzilla.gnome.org/show_bug.cgi?id=795086
---
.../pages/account/um-photo-dialog.c | 45 ++++++++++---------
1 file changed, 23 insertions(+), 22 deletions(-)
diff --git a/gnome-initial-setup/pages/account/um-photo-dialog.c b/gnome-initial-setup/pages/account/um-photo-dialog.c
index b63ed78..8b23974 100644
--- a/gnome-initial-setup/pages/account/um-photo-dialog.c
+++ b/gnome-initial-setup/pages/account/um-photo-dialog.c
@@ -145,15 +145,12 @@ stock_icon_selected (GtkMenuItem *menuitem,
static GtkWidget *
menu_item_for_filename (UmPhotoDialog *um,
- const char *filename)
+ GFile *file)
{
GtkWidget *image, *menuitem;
- GFile *file;
GIcon *icon;
- file = g_file_new_for_path (filename);
icon = g_file_icon_new (file);
- g_object_unref (file);
image = gtk_image_new_from_gicon (icon, GTK_ICON_SIZE_DIALOG);
g_object_unref (icon);
@@ -161,8 +158,9 @@ menu_item_for_filename (UmPhotoDialog *um,
gtk_container_add (GTK_CONTAINER (menuitem), image);
gtk_widget_show_all (menuitem);
- g_object_set_data_full (G_OBJECT (menuitem), "filename",
- g_strdup (filename), (GDestroyNotify) g_free);
+ g_object_set_data_full (G_OBJECT (menuitem),
+ "filename", g_file_get_path (file),
+ (GDestroyNotify) g_free);
g_signal_connect (G_OBJECT (menuitem), "activate",
G_CALLBACK (stock_icon_selected), um);
@@ -176,8 +174,6 @@ setup_photo_popup (UmPhotoDialog *um)
guint x, y;
const gchar * const * dirs;
guint i;
- GDir *dir;
- const char *face;
gboolean none_item_shown;
gboolean added_faces;
@@ -189,25 +185,32 @@ setup_photo_popup (UmPhotoDialog *um)
dirs = g_get_system_data_dirs ();
for (i = 0; dirs[i] != NULL; i++) {
- char *path;
+ g_autoptr(GFileEnumerator) enumerator = NULL;
+ g_autoptr(GFile) dir = NULL;
+ g_autofree gchar *path = NULL;
+ gpointer infoptr;
path = g_build_filename (dirs[i], "pixmaps", "faces", NULL);
- dir = g_dir_open (path, 0, NULL);
- if (dir == NULL) {
- g_free (path);
+ dir = g_file_new_for_path (path);
+
+ enumerator = g_file_enumerate_children (dir,
+ G_FILE_ATTRIBUTE_STANDARD_NAME ","
+ G_FILE_ATTRIBUTE_STANDARD_TYPE ","
+ G_FILE_ATTRIBUTE_STANDARD_IS_SYMLINK ","
+ G_FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET,
+ G_FILE_QUERY_INFO_NONE,
+ NULL, NULL);
+ if (enumerator == NULL)
continue;
- }
- while ((face = g_dir_read_name (dir)) != NULL) {
- char *filename;
+ while ((infoptr = g_file_enumerator_next_file (enumerator, NULL, NULL)) != NULL) {
+ g_autoptr (GFileInfo) info = infoptr;
+ g_autoptr (GFile) face_file = NULL;
added_faces = TRUE;
- filename = g_build_filename (path, face, NULL);
- menuitem = menu_item_for_filename (um, filename);
- g_free (filename);
- if (menuitem == NULL)
- continue;
+ face_file = g_file_get_child (dir, g_file_info_get_name (info));
+ menuitem = menu_item_for_filename (um, face_file);
gtk_menu_attach (GTK_MENU (menu), GTK_WIDGET (menuitem),
x, x + 1, y, y + 1);
@@ -219,8 +222,6 @@ setup_photo_popup (UmPhotoDialog *um)
x = 0;
}
}
- g_dir_close (dir);
- g_free (path);
if (added_faces)
break;
--
2.33.1
From 0441acd191fb89b40d30484e2966ddd48a196f12 Mon Sep 17 00:00:00 2001
From: Ondrej Holy <oholy@redhat.com>
Date: Mon, 9 Apr 2018 09:10:45 +0200
Subject: [PATCH 2/3] account: Do not show legacy face images
Legacy face images should not be shown in avatar chooser, so let's filter
all symlinks to the legacy files out.
https://bugzilla.gnome.org/show_bug.cgi?id=795086
---
gnome-initial-setup/pages/account/um-photo-dialog.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/gnome-initial-setup/pages/account/um-photo-dialog.c b/gnome-initial-setup/pages/account/um-photo-dialog.c
index 8b23974..0769209 100644
--- a/gnome-initial-setup/pages/account/um-photo-dialog.c
+++ b/gnome-initial-setup/pages/account/um-photo-dialog.c
@@ -170,6 +170,8 @@ menu_item_for_filename (UmPhotoDialog *um,
static void
setup_photo_popup (UmPhotoDialog *um)
{
+ GFileType type;
+ const gchar *target;
GtkWidget *menu, *menuitem, *image;
guint x, y;
const gchar * const * dirs;
@@ -209,6 +211,14 @@ setup_photo_popup (UmPhotoDialog *um)
added_faces = TRUE;
+ type = g_file_info_get_file_type (info);
+ if (type != G_FILE_TYPE_REGULAR && type != G_FILE_TYPE_SYMBOLIC_LINK)
+ continue;
+
+ target = g_file_info_get_symlink_target (info);
+ if (target != NULL && g_str_has_prefix (target , "legacy/"))
+ continue;
+
face_file = g_file_get_child (dir, g_file_info_get_name (info));
menuitem = menu_item_for_filename (um, face_file);
--
2.33.1
From 6a7fcaf82b3dc913313f328501ec085b5bfb5d0f Mon Sep 17 00:00:00 2001
From: Ondrej Holy <oholy@redhat.com>
Date: Mon, 9 Apr 2018 09:37:46 +0200
Subject: [PATCH 3/3] account: Make face images bigger
The new set of face images doesn't contain the same number of images,
so let's change parameters of avatar chooser in the same way as it was
done in gnome-control-center.
Now we present 72x72 faces in a 4x4 grid.
https://bugzilla.gnome.org/show_bug.cgi?id=795086
---
gnome-initial-setup/pages/account/um-photo-dialog.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/gnome-initial-setup/pages/account/um-photo-dialog.c b/gnome-initial-setup/pages/account/um-photo-dialog.c
index 0769209..ac89d30 100644
--- a/gnome-initial-setup/pages/account/um-photo-dialog.c
+++ b/gnome-initial-setup/pages/account/um-photo-dialog.c
@@ -37,7 +37,8 @@
#include "um-photo-dialog.h"
#include "um-utils.h"
-#define ROW_SPAN 6
+#define ROW_SPAN 5
+#define AVATAR_PIXEL_SIZE 72
struct _UmPhotoDialog {
GtkWidget *photo_popup;
@@ -152,6 +153,7 @@ menu_item_for_filename (UmPhotoDialog *um,
icon = g_file_icon_new (file);
image = gtk_image_new_from_gicon (icon, GTK_ICON_SIZE_DIALOG);
+ gtk_image_set_pixel_size (GTK_IMAGE (image), AVATAR_PIXEL_SIZE);
g_object_unref (icon);
menuitem = gtk_menu_item_new ();
--
2.33.1