[gnome-control-center] user-accounts: Move non-shared function



commit ffa54acdb91cf5bc4c138370978c08a87bcb128f
Author: Robert Ancell <robert ancell canonical com>
Date:   Fri Nov 9 09:40:06 2018 +1300

    user-accounts: Move non-shared function
    
    The set_user_icon_data function is only use in CcAvatarChooser

 panels/user-accounts/cc-avatar-chooser.c | 43 +++++++++++++++++++++++++++++++-
 panels/user-accounts/um-utils.c          | 43 --------------------------------
 panels/user-accounts/um-utils.h          |  4 ---
 3 files changed, 42 insertions(+), 48 deletions(-)
---
diff --git a/panels/user-accounts/cc-avatar-chooser.c b/panels/user-accounts/cc-avatar-chooser.c
index f837d0309..7b568ce6e 100644
--- a/panels/user-accounts/cc-avatar-chooser.c
+++ b/panels/user-accounts/cc-avatar-chooser.c
@@ -22,8 +22,10 @@
 
 #include <stdlib.h>
 
+#include <gio/gunixoutputstream.h>
 #include <glib.h>
 #include <glib/gi18n.h>
+#include <glib/gstdio.h>
 #include <gtk/gtk.h>
 #include <act/act.h>
 #define GNOME_DESKTOP_USE_UNSTABLE_API
@@ -37,7 +39,6 @@
 
 #include "cc-avatar-chooser.h"
 #include "cc-crop-area.h"
-#include "um-utils.h"
 
 #define ROW_SPAN 5
 #define AVATAR_PIXEL_SIZE 80
@@ -64,6 +65,46 @@ struct _CcAvatarChooser {
 
 G_DEFINE_TYPE (CcAvatarChooser, cc_avatar_chooser, GTK_TYPE_POPOVER)
 
+static void
+set_user_icon_data (ActUser   *user,
+                    GdkPixbuf *pixbuf)
+{
+        gchar *path;
+        gint fd;
+        GOutputStream *stream;
+        GError *error;
+
+        path = g_build_filename (g_get_tmp_dir (), "gnome-control-center-user-icon-XXXXXX", NULL);
+        fd = g_mkstemp (path);
+
+        if (fd == -1) {
+                g_warning ("failed to create temporary file for image data");
+                g_free (path);
+                return;
+        }
+
+        stream = g_unix_output_stream_new (fd, TRUE);
+
+        error = NULL;
+        if (!gdk_pixbuf_save_to_stream (pixbuf, stream, "png", NULL, &error, NULL)) {
+                g_warning ("failed to save image: %s", error->message);
+                g_error_free (error);
+                g_object_unref (stream);
+                return;
+        }
+
+        g_object_unref (stream);
+
+        act_user_set_icon_file (user, path);
+
+        /* if we ever make the dbus call async, the g_remove call needs
+         * to wait for its completion
+         */
+        g_remove (path);
+
+        g_free (path);
+}
+
 static void
 crop_dialog_response (GtkWidget       *dialog,
                       gint             response_id,
diff --git a/panels/user-accounts/um-utils.c b/panels/user-accounts/um-utils.c
index db963e2e2..e34272327 100644
--- a/panels/user-accounts/um-utils.c
+++ b/panels/user-accounts/um-utils.c
@@ -29,9 +29,7 @@
 #include <pwd.h>
 
 #include <gio/gio.h>
-#include <gio/gunixoutputstream.h>
 #include <glib/gi18n.h>
-#include <glib/gstdio.h>
 
 #include "um-utils.h"
 
@@ -664,44 +662,3 @@ generate_username_choices (const gchar  *name,
         g_string_free (item3, TRUE);
         g_string_free (item4, TRUE);
 }
-
-void
-set_user_icon_data (ActUser   *user,
-                    GdkPixbuf *pixbuf)
-{
-        gchar *path;
-        gint fd;
-        GOutputStream *stream;
-        GError *error;
-
-        path = g_build_filename (g_get_tmp_dir (), "gnome-control-center-user-icon-XXXXXX", NULL);
-        fd = g_mkstemp (path);
-
-        if (fd == -1) {
-                g_warning ("failed to create temporary file for image data");
-                g_free (path);
-                return;
-        }
-
-        stream = g_unix_output_stream_new (fd, TRUE);
-
-        error = NULL;
-        if (!gdk_pixbuf_save_to_stream (pixbuf, stream, "png", NULL, &error, NULL)) {
-                g_warning ("failed to save image: %s", error->message);
-                g_error_free (error);
-                g_object_unref (stream);
-                return;
-        }
-
-        g_object_unref (stream);
-
-        act_user_set_icon_file (user, path);
-
-        /* if we ever make the dbus call async, the g_remove call needs
-         * to wait for its completion
-         */
-        g_remove (path);
-
-        g_free (path);
-}
-
diff --git a/panels/user-accounts/um-utils.h b/panels/user-accounts/um-utils.h
index 93b599bb5..9a963d9ef 100644
--- a/panels/user-accounts/um-utils.h
+++ b/panels/user-accounts/um-utils.h
@@ -21,7 +21,6 @@
 #pragma once
 
 #include <gtk/gtk.h>
-#include <act/act.h>
 
 G_BEGIN_DECLS
 
@@ -45,7 +44,4 @@ gboolean is_valid_username                (const gchar     *name,
 void     generate_username_choices        (const gchar     *name,
                                            GtkListStore    *store);
 
-void     set_user_icon_data               (ActUser         *user,
-                                           GdkPixbuf       *pixbuf);
-
 G_END_DECLS


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