[almanah] resources: Added the CSS as a resource
- From: Álvaro Peña <alvaropg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [almanah] resources: Added the CSS as a resource
- Date: Sun, 15 Feb 2015 17:52:20 +0000 (UTC)
commit 187e5e6eaa6c26288aa9b24af95c5e64bc7e1296
Author: Álvaro Peña <alvaropg gmail com>
Date: Sat Feb 14 18:14:52 2015 +0100
resources: Added the CSS as a resource
https://bugzilla.gnome.org/show_bug.cgi?id=743086
data/Makefile.am | 3 +--
src/almanah.gresource.xml | 1 +
src/application.c | 26 ++++++++++++++++----------
{data => src/css}/almanah.css | 0
src/interface.c | 9 ---------
src/interface.h | 1 -
6 files changed, 18 insertions(+), 22 deletions(-)
---
diff --git a/data/Makefile.am b/data/Makefile.am
index ab1f924..76b6579 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -26,8 +26,7 @@ update-icon-cache:
uidir = $(datadir)/almanah
ui_DATA = \
- almanah.ui \
- almanah.css
+ almanah.ui
EXTRA_DIST += $(ui_DATA)
diff --git a/src/almanah.gresource.xml b/src/almanah.gresource.xml
index a422afa..d4239d7 100644
--- a/src/almanah.gresource.xml
+++ b/src/almanah.gresource.xml
@@ -2,5 +2,6 @@
<gresources>
<gresource prefix="/org/gnome/Almanah">
<file preprocess="xml-stripblanks">gtk/menus.ui</file>
+ <file>css/almanah.css</file>
</gresource>
</gresources>
diff --git a/src/application.c b/src/application.c
index b977389..cf8b4c8 100644
--- a/src/application.c
+++ b/src/application.c
@@ -52,6 +52,9 @@ static void action_print_cb (GSimpleAction *action, GVariant *parameter, gpointe
static void action_about_cb (GSimpleAction *action, GVariant *parameter, gpointer user_data);
static void action_quit_cb (GSimpleAction *action, GVariant *parameter, gpointer user_data);
+/* Some callbacks */
+void almanah_application_style_provider_parsing_error_cb (GtkCssProvider *provider, GtkCssSection *section,
GError *error, gpointer user_data);
+
struct _AlmanahApplicationPrivate {
gboolean debug;
@@ -227,7 +230,6 @@ startup (GApplication *application)
gchar *db_filename;
GError *error = NULL;
GtkCssProvider *style_provider;
- gchar *css_path;
/* Chain up. */
G_APPLICATION_CLASS (almanah_application_parent_class)->startup (application);
@@ -275,16 +277,11 @@ startup (GApplication *application)
/* Application actions */
g_action_map_add_action_entries (G_ACTION_MAP (application), app_entries, G_N_ELEMENTS (app_entries),
application);
- css_path = g_build_filename (almanah_get_css_path (), "almanah.css", NULL);
+ /* Application CSS styles */
style_provider = gtk_css_provider_new ();
- if (!gtk_css_provider_load_from_path (style_provider, css_path, NULL)) {
- /* Error loading the CSS */
- g_warning (_("Couldn't load the CSS file '%s'. The interface might not be styled correctly"),
css_path);
- g_error_free (error);
- } else {
- gtk_style_context_add_provider_for_screen (gdk_screen_get_default (), GTK_STYLE_PROVIDER
(style_provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
- }
- g_free (css_path);
+ g_signal_connect (G_OBJECT (style_provider), "parsing-error", G_CALLBACK
(almanah_application_style_provider_parsing_error_cb), NULL);
+ gtk_css_provider_load_from_resource (style_provider, "/org/gnome/Almanah/css/almanah.css");
+ gtk_style_context_add_provider_for_screen (gdk_screen_get_default (), GTK_STYLE_PROVIDER
(style_provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
g_object_unref (style_provider);
/* Shortcuts */
@@ -582,6 +579,15 @@ action_quit_cb (GSimpleAction *action, GVariant *parameter, gpointer user_data)
gtk_widget_destroy (GTK_WIDGET (main_window));
}
+void
+almanah_application_style_provider_parsing_error_cb (__attribute__ ((unused)) GtkCssProvider *provider,
+ __attribute__ ((unused)) GtkCssSection *section,
+ GError *error,
+ __attribute__ ((unused)) gpointer user_data)
+{
+ g_warning (_("Couldn't load the CSS resources. The interface might not be styled correctly: %s"),
error->message);
+}
+
AlmanahApplication *
almanah_application_new (void)
{
diff --git a/data/almanah.css b/src/css/almanah.css
similarity index 100%
rename from data/almanah.css
rename to src/css/almanah.css
diff --git a/src/interface.c b/src/interface.c
index ea93784..cd302b0 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -43,15 +43,6 @@ almanah_get_interface_app_menu_filename (void)
return PACKAGE_DATA_DIR"/almanah/almanah-app-menu.ui";
}
-const gchar *
-almanah_get_css_path (void)
-{
- if (g_file_test ("./data", G_FILE_TEST_IS_DIR) == TRUE)
- return "./data";
- else
- return PACKAGE_DATA_DIR"/almanah";
-}
-
void
almanah_interface_create_text_tags (GtkTextBuffer *text_buffer, gboolean connect_events)
{
diff --git a/src/interface.h b/src/interface.h
index e4e4f6f..6591b5d 100644
--- a/src/interface.h
+++ b/src/interface.h
@@ -26,7 +26,6 @@ G_BEGIN_DECLS
const gchar *almanah_get_interface_filename (void);
const gchar *almanah_get_interface_app_menu_filename (void);
-const gchar *almanah_get_css_path (void);
void almanah_interface_create_text_tags (GtkTextBuffer *text_buffer, gboolean connect_events);
void almanah_calendar_month_changed_cb (GtkCalendar *calendar, gpointer user_data);
gboolean almanah_run_on_screen (GdkScreen *screen, const gchar *command_line, GError **error);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]