Commit eb573a72 authored by Cosimo Cecchi's avatar Cosimo Cecchi Committed by Bastien Nocera
Browse files

user-accounts: use a GResource for GtkBuilder UI definition and icons

https://bugzilla.gnome.org/show_bug.cgi?id=691132
parent ce1e2edd
......@@ -7,9 +7,6 @@ NULL =
noinst_LTLIBRARIES = libuser-accounts.la
AM_CPPFLAGS = \
-DDATADIR=\""$(datadir)"\" \
-DUIDIR=\""$(pkgdatadir)/ui/user-accounts"\" \
-DLIBLOCALEDIR=\""$(prefix)/lib/locale"\" \
-DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
-DUM_PIXMAP_DIR=\""$(pkgdatadir)/pixmaps"\" \
-DHAVE_LIBPWQUALITY \
......@@ -23,8 +20,10 @@ AM_CPPFLAGS += $(CHEESE_CFLAGS)
endif
BUILT_SOURCES = \
um-realm-generated.c \
um-realm-generated.h
um-realm-generated.c \
um-realm-generated.h \
um-resources.c \
um-resources.h
libuser_accounts_la_SOURCES = \
um-account-type.h \
......@@ -75,6 +74,12 @@ um-realm-generated.c: $(srcdir)/data/org.freedesktop.realmd.xml
--c-generate-object-manager $<
um-realm-generated.h: um-realm-generated.c
resource_files = $(shell glib-compile-resources --generate-dependencies $(srcdir)/user-accounts.gresource.xml)
um-resources.c: user-accounts.gresource.xml $(resource_files)
$(AM_V_GEN) glib-compile-resources --target=$@ --sourcedir=$(srcdir) --generate-source --c-name um $<
um-resources.h: user-accounts.gresource.xml $(resource_files)
$(AM_V_GEN) glib-compile-resources --target=$@ --sourcedir=$(srcdir) --generate-header --c-name um $<
noinst_PROGRAMS = frob-account-dialog
frob_account_dialog_SOURCES = \
......@@ -91,8 +96,7 @@ frob_account_dialog_LDADD = \
$(libuser_accounts_la_LIBADD)
frob_account_dialog_CFLAGS = \
$(AM_CFLAGS) \
-DUIDIR=\""$(pkgdatadir)/ui/user-accounts"\"
$(AM_CFLAGS)
polkitdir = $(datadir)/polkit-1/actions
polkit_in_files = org.gnome.controlcenter.user-accounts.policy.in
......@@ -102,6 +106,8 @@ polkit_DATA = $(polkit_in_files:.policy.in=.policy)
EXTRA_DIST = \
$(polkit_in_files) \
$(resource_files) \
user-accounts.gresource.xml \
$(NULL)
CLEANFILES = \
......
SUBDIRS = faces icons
uidir = $(pkgdatadir)/ui/user-accounts
ui_DATA = \
account-dialog.ui \
password-dialog.ui \
photo-dialog.ui \
user-accounts-dialog.ui \
account-fingerprint.ui
SUBDIRS = faces
@INTLTOOL_DESKTOP_RULE@
......@@ -16,8 +8,7 @@ desktop_DATA = $(Desktop_in_files:.desktop.in=.desktop)
EXTRA_DIST = \
gnome-user-accounts-panel.desktop.in.in \
org.freedesktop.realmd.xml \
$(ui_DATA)
org.freedesktop.realmd.xml
CLEANFILES = \
gnome-user-accounts-panel.desktop \
......
pixmapsdir = $(pkgdatadir)/pixmaps
pixmaps_DATA = \
left-index-finger.png \
left-middle-finger.png \
left-little-finger.png \
left-ring-finger.png \
left-thumb.png \
print_error.png \
print_ok.png \
right-index-finger.png \
right-middle-finger.png \
right-little-finger.png \
right-ring-finger.png \
right-thumb.png
EXTRA_DIST = $(pixmaps_DATA)
-include $(top_srcdir)/git.mk
......@@ -1023,7 +1023,6 @@ um_account_dialog_init (UmAccountDialog *self)
{
GtkBuilder *builder;
GtkWidget *widget;
const gchar *filename;
GError *error = NULL;
GtkDialog *dialog;
GtkWidget *content;
......@@ -1032,10 +1031,9 @@ um_account_dialog_init (UmAccountDialog *self)
builder = gtk_builder_new ();
filename = UIDIR "/account-dialog.ui";
if (!g_file_test (filename, G_FILE_TEST_EXISTS))
filename = "data/account-dialog.ui";
if (!gtk_builder_add_from_file (builder, filename, &error)) {
if (!gtk_builder_add_from_resource (builder,
"/org/gnome/control-center/user-accounts/account-dialog.ui",
&error)) {
g_error ("%s", error->message);
g_error_free (error);
return;
......
......@@ -446,8 +446,8 @@ enroll_result (EnrollData *data, const char *result, gboolean done)
data->num_stages_done++;
name = g_strdup_printf ("image%d", data->num_stages_done);
path = g_build_filename (UM_PIXMAP_DIR, "print_ok.png", NULL);
gtk_image_set_from_file (GTK_IMAGE (WID (name)), path);
path = g_strdup_printf ("/org/gnome/control-center/user-accounts/print_ok.png");
gtk_image_set_from_resource (GTK_IMAGE (WID (name)), path);
g_free (name);
g_free (path);
}
......@@ -577,16 +577,12 @@ assistant_prepare (GtkAssistant *ass, GtkWidget *page, EnrollData *data)
}
/* And set the right image */
{
char *filename;
filename = g_strdup_printf ("%s.png", data->finger);
path = g_build_filename (UM_PIXMAP_DIR, filename, NULL);
g_free (filename);
path = g_strdup_printf ("/org/gnome/control-center/user-accounts/%s.png", data->finger);
}
for (i = 1; i <= data->num_enroll_stages; i++) {
char *name;
name = g_strdup_printf ("image%d", i);
gtk_image_set_from_file (GTK_IMAGE (WID (name)), path);
gtk_image_set_from_resource (GTK_IMAGE (WID (name)), path);
g_free (name);
}
g_free (path);
......@@ -634,7 +630,6 @@ enroll_fingerprints (GtkWindow *parent,
GtkBuilder *dialog;
EnrollData *data;
GtkWidget *ass;
const char *filename;
char *msg;
GVariant *result;
GError *error = NULL;
......@@ -692,10 +687,9 @@ enroll_fingerprints (GtkWindow *parent,
}
dialog = gtk_builder_new ();
filename = UIDIR "/account-fingerprint.ui";
if (!g_file_test (filename, G_FILE_TEST_EXISTS))
filename = "data/account-fingerprint.ui";
if (!gtk_builder_add_from_file (dialog, filename, &error)) {
if (!gtk_builder_add_from_resource (dialog,
"/org/gnome/control-center/account-fingerprint.ui",
&error)) {
g_error ("%s", error->message);
g_error_free (error);
return;
......
......@@ -510,7 +510,6 @@ um_password_dialog_new (void)
{
GtkBuilder *builder;
GError *error;
const gchar *filename;
UmPasswordDialog *um;
GtkWidget *widget;
const char *old_label;
......@@ -520,10 +519,9 @@ um_password_dialog_new (void)
builder = gtk_builder_new ();
error = NULL;
filename = UIDIR "/password-dialog.ui";
if (!g_file_test (filename, G_FILE_TEST_EXISTS))
filename = "data/password-dialog.ui";
if (!gtk_builder_add_from_file (builder, filename, &error)) {
if (!gtk_builder_add_from_resource (builder,
"/org/gnome/control-center/user-accounts/password-dialog.ui",
&error)) {
g_error ("%s", error->message);
g_error_free (error);
return NULL;
......
......@@ -49,6 +49,7 @@
#include "um-photo-dialog.h"
#include "um-fingerprint-dialog.h"
#include "um-utils.h"
#include "um-resources.h"
#include "cc-common-language.h"
......@@ -1308,11 +1309,11 @@ cc_user_panel_init (CcUserPanel *self)
CcUserPanelPrivate *d;
GError *error;
volatile GType type G_GNUC_UNUSED;
const gchar *filename;
GtkWidget *button;
GtkStyleContext *context;
d = self->priv = UM_USER_PANEL_PRIVATE (self);
g_resources_register (um_get_resource ());
/* register types that the builder might need */
type = um_editable_button_get_type ();
......@@ -1324,12 +1325,10 @@ cc_user_panel_init (CcUserPanel *self)
d->builder = gtk_builder_new ();
d->um = act_user_manager_get_default ();
filename = UIDIR "/user-accounts-dialog.ui";
if (!g_file_test (filename, G_FILE_TEST_EXISTS)) {
filename = "data/user-accounts-dialog.ui";
}
error = NULL;
if (!gtk_builder_add_from_file (d->builder, filename, &error)) {
if (!gtk_builder_add_from_resource (d->builder,
"/org/gnome/control-center/user-accounts/user-accounts-dialog.ui",
&error)) {
g_error ("%s", error->message);
g_error_free (error);
return;
......
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/org/gnome/control-center/user-accounts">
<file alias="account-dialog.ui" preprocess="xml-stripblanks">data/account-dialog.ui</file>
<file alias="account-fingerprint.ui" preprocess="xml-stripblanks">data/account-fingerprint.ui</file>
<file alias="password-dialog.ui" preprocess="xml-stripblanks">data/password-dialog.ui</file>
<file alias="photo-dialog.ui" preprocess="xml-stripblanks">data/photo-dialog.ui</file>
<file alias="user-accounts-dialog.ui" preprocess="xml-stripblanks">data/user-accounts-dialog.ui</file>
<file alias="left-index-finger.png">data/icons/left-index-finger.png</file>
<file alias="left-middle-finger.png">data/icons/left-middle-finger.png</file>
<file alias="left-little-finger.png">data/icons/left-little-finger.png</file>
<file alias="left-ring-finger.png">data/icons/left-ring-finger.png</file>
<file alias="left-thumb.png">data/icons/left-thumb.png</file>
<file alias="print_error.png">data/icons/print_error.png</file>
<file alias="print_ok.png">data/icons/print_ok.png</file>
<file alias="right-index-finger.png">data/icons/right-index-finger.png</file>
<file alias="right-middle-finger.png">data/icons/right-middle-finger.png</file>
<file alias="right-little-finger.png">data/icons/right-little-finger.png</file>
<file alias="right-ring-finger.png">data/icons/right-ring-finger.png</file>
<file alias="right-thumb.png">data/icons/right-thumb.png</file>
</gresource>
</gresources>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment