[evince] previewer: Add CSS file for EvView styling



commit 48110cb41681d8babe94cc8ee3fb26a533d16671
Author: Carlos Garcia Campos <cgarcia igalia com>
Date:   Mon Aug 4 12:50:41 2014 +0200

    previewer: Add CSS file for EvView styling
    
    EvView CSS used to be shared in adwaita theme, but now that adwaita has
    been merged into GTK+ and app specific CSS has been removed, we need to
    add the EvView CSS to all of its users.

 {shell => data}/thumbnail-frame.png |  Bin 832 -> 832 bytes
 previewer/Makefile.am               |    4 ++--
 previewer/ev-previewer-window.c     |   32 ++++++++++++++++++++++++++++++++
 previewer/evince-previewer.css      |   19 +++++++++++++++++++
 previewer/previewer.gresource.xml   |    2 ++
 shell/Makefile.am                   |    4 ++--
 6 files changed, 57 insertions(+), 4 deletions(-)
---
diff --git a/previewer/Makefile.am b/previewer/Makefile.am
index 1558cb9..e2ddca4 100644
--- a/previewer/Makefile.am
+++ b/previewer/Makefile.am
@@ -36,8 +36,8 @@ evince_previewer_LDADD = \
        $(top_builddir)/libmisc/libevmisc.la            \
        $(PREVIEWER_LIBS)
 
-ev-previewer-resources.c: previewer.gresource.xml Makefile $(shell $(GLIB_COMPILE_RESOURCES) 
--generate-dependencies --sourcedir $(srcdir) $(srcdir)/previewer.gresource.xml)
-       $(AM_V_GEN) XMLLINT=$(XMLLINT) $(GLIB_COMPILE_RESOURCES) --target $@ --sourcedir $(srcdir) 
--generate-source --c-name ev_previewer $<
+ev-previewer-resources.c: previewer.gresource.xml Makefile $(shell $(GLIB_COMPILE_RESOURCES) 
--generate-dependencies --sourcedir=$(srcdir) --sourcedir=$(top_builddir)/data 
$(srcdir)/previewer.gresource.xml)
+       $(AM_V_GEN) XMLLINT=$(XMLLINT) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) 
--sourcedir=$(top_builddir)/data --generate-source --c-name ev_previewer $<
 
 EXTRA_DIST = \
        previewer.gresource.xml \
diff --git a/previewer/ev-previewer-window.c b/previewer/ev-previewer-window.c
index 0a90309..dd34f25 100644
--- a/previewer/ev-previewer-window.c
+++ b/previewer/ev-previewer-window.c
@@ -473,6 +473,27 @@ ev_previewer_window_set_property (GObject      *object,
        }
 }
 
+static gboolean
+_gtk_css_provider_load_from_resource (GtkCssProvider *provider,
+                                      const char     *resource_path,
+                                      GError        **error)
+{
+        GBytes  *data;
+        gboolean retval;
+
+        data = g_resources_lookup_data (resource_path, 0, error);
+        if (!data)
+                return FALSE;
+
+        retval = gtk_css_provider_load_from_data (provider,
+                                                  g_bytes_get_data (data, NULL),
+                                                  g_bytes_get_size (data),
+                                                  error);
+        g_bytes_unref (data);
+
+        return retval;
+}
+
 static GObject *
 ev_previewer_window_constructor (GType                  type,
                                 guint                  n_construct_properties,
@@ -485,6 +506,7 @@ ev_previewer_window_constructor (GType                  type,
        GtkAction         *action;
        GError            *error = NULL;
        gdouble            dpi;
+        GtkCssProvider    *css_provider;
 
        object = G_OBJECT_CLASS (ev_previewer_window_parent_class)->constructor (type,
                                                                                 n_construct_properties,
@@ -529,6 +551,16 @@ ev_previewer_window_constructor (GType                  type,
                                      window);
        gtk_action_group_set_sensitive (window->accels_group, FALSE);
 
+        css_provider = gtk_css_provider_new ();
+        _gtk_css_provider_load_from_resource (css_provider,
+                                              "/org/gnome/evince/previewer/ui/evince-previewer.css",
+                                              &error);
+        g_assert_no_error (error);
+        gtk_style_context_add_provider_for_screen (gtk_widget_get_screen (GTK_WIDGET (window)),
+                                                   GTK_STYLE_PROVIDER (css_provider),
+                                                   GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+        g_object_unref (css_provider);
+
        window->ui_manager = gtk_ui_manager_new ();
        gtk_ui_manager_insert_action_group (window->ui_manager,
                                            window->action_group, 0);
diff --git a/previewer/evince-previewer.css b/previewer/evince-previewer.css
new file mode 100644
index 0000000..44c3801
--- /dev/null
+++ b/previewer/evince-previewer.css
@@ -0,0 +1,19 @@
+.content-view.document-page {
+    border-style: solid;
+    border-width: 3px 3px 6px 4px;
+    border-image: url("resource:///org/gnome/evince/previewer/ui/thumbnail-frame.png") 3 3 6 4;
+    background-color: @theme_bg_color;
+}
+
+EvView {
+    background-color: @theme_bg_color;
+}
+
+EvView:selected {
+    background-color: @theme_selected_bg_color;
+}
+
+EvView.document-page {
+    background-color: white;
+    padding: 0;
+}
diff --git a/previewer/previewer.gresource.xml b/previewer/previewer.gresource.xml
index 010c6bf..2d8e7fa 100644
--- a/previewer/previewer.gresource.xml
+++ b/previewer/previewer.gresource.xml
@@ -18,5 +18,7 @@
 <gresources>
   <gresource prefix="/org/gnome/evince/previewer">
     <file alias="ui/previewer.xml" compressed="true" preprocess="xml-stripblanks">previewer-ui.xml</file>
+    <file alias="ui/evince-previewer.css" compressed="true">evince-previewer.css</file>
+    <file alias="ui/thumbnail-frame.png" compressed="true">thumbnail-frame.png</file>
   </gresource>
 </gresources>
diff --git a/shell/Makefile.am b/shell/Makefile.am
index abdae6b..45a69c0 100644
--- a/shell/Makefile.am
+++ b/shell/Makefile.am
@@ -175,8 +175,8 @@ EXTRA_DIST = \
        ev-daemon-gdbus.xml \
        thumbnail-frame.png
 
-ev-resources.c: evince.gresource.xml Makefile $(shell $(GLIB_COMPILE_RESOURCES) --generate-dependencies 
--sourcedir $(srcdir) $(srcdir)/evince.gresource.xml)
-       $(AM_V_GEN) XMLLINT=$(XMLLINT) $(GLIB_COMPILE_RESOURCES) --target $@ --sourcedir $(srcdir) 
--generate-source --c-name ev $<
+ev-resources.c: evince.gresource.xml Makefile $(shell $(GLIB_COMPILE_RESOURCES) --generate-dependencies 
--sourcedir=$(srcdir) --sourcedir=$(top_builddir)/data $(srcdir)/evince.gresource.xml)
+       $(AM_V_GEN) XMLLINT=$(XMLLINT) $(GLIB_COMPILE_RESOURCES) --target $@ --sourcedir=$(srcdir) 
--sourcedir=$(top_builddir)/data --generate-source --c-name ev $<
 
 ev-gdbus-generated.c ev-gdbus-generated.h: ev-gdbus.xml Makefile
        $(AM_V_GEN) $(GDBUS_CODEGEN) \


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