user-accounts: Move non-shared function
The set_user_icon_data function is only use in CcAvatarChooser
This commit is contained in:
parent
60ffc24c30
commit
ffa54acdb9
3 changed files with 42 additions and 48 deletions
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue