[gnome-control-center] user-accounts: use a GResource for GtkBuilder UI definition and icons
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] user-accounts: use a GResource for GtkBuilder UI definition and icons
- Date: Mon, 7 Jan 2013 10:06:20 +0000 (UTC)
commit eb573a72e58d98dca2ed72dc78c9a0f74c5824cd
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Fri Jan 4 18:04:03 2013 +0100
user-accounts: use a GResource for GtkBuilder UI definition and icons
https://bugzilla.gnome.org/show_bug.cgi?id=691132
panels/user-accounts/Makefile.am | 20 +++++++++++++-------
panels/user-accounts/data/Makefile.am | 13 ++-----------
panels/user-accounts/data/icons/Makefile.am | 18 ------------------
panels/user-accounts/um-account-dialog.c | 8 +++-----
panels/user-accounts/um-fingerprint-dialog.c | 20 +++++++-------------
panels/user-accounts/um-password-dialog.c | 8 +++-----
panels/user-accounts/um-user-panel.c | 11 +++++------
panels/user-accounts/user-accounts.gresource.xml | 22 ++++++++++++++++++++++
8 files changed, 55 insertions(+), 65 deletions(-)
---
diff --git a/panels/user-accounts/Makefile.am b/panels/user-accounts/Makefile.am
index c6f3630..9debce4 100644
--- a/panels/user-accounts/Makefile.am
+++ b/panels/user-accounts/Makefile.am
@@ -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 = \
diff --git a/panels/user-accounts/data/Makefile.am b/panels/user-accounts/data/Makefile.am
index d03d14b..ac08ad3 100644
--- a/panels/user-accounts/data/Makefile.am
+++ b/panels/user-accounts/data/Makefile.am
@@ -1,12 +1,4 @@
-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 \
diff --git a/panels/user-accounts/um-account-dialog.c b/panels/user-accounts/um-account-dialog.c
index 5fc63d2..88dff99 100644
--- a/panels/user-accounts/um-account-dialog.c
+++ b/panels/user-accounts/um-account-dialog.c
@@ -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;
diff --git a/panels/user-accounts/um-fingerprint-dialog.c b/panels/user-accounts/um-fingerprint-dialog.c
index ab18c1b..da4f2df 100644
--- a/panels/user-accounts/um-fingerprint-dialog.c
+++ b/panels/user-accounts/um-fingerprint-dialog.c
@@ -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;
diff --git a/panels/user-accounts/um-password-dialog.c b/panels/user-accounts/um-password-dialog.c
index 94f6411..655bfc6 100644
--- a/panels/user-accounts/um-password-dialog.c
+++ b/panels/user-accounts/um-password-dialog.c
@@ -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;
diff --git a/panels/user-accounts/um-user-panel.c b/panels/user-accounts/um-user-panel.c
index 4515b11..7b4fa61 100644
--- a/panels/user-accounts/um-user-panel.c
+++ b/panels/user-accounts/um-user-panel.c
@@ -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;
diff --git a/panels/user-accounts/user-accounts.gresource.xml b/panels/user-accounts/user-accounts.gresource.xml
new file mode 100644
index 0000000..f80689b
--- /dev/null
+++ b/panels/user-accounts/user-accounts.gresource.xml
@@ -0,0 +1,22 @@
+<?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>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]