Skip to content

Commit 1e531cb

Browse files
Carlos Garcia Camposraveit65
authored andcommitted
Move custom css to a file compiled as a gresource
origin commit: https://git.gnome.org/browse/evince/commit/shell?h=gnome-3-6&id=65fa4ff
1 parent c7fcfa1 commit 1e531cb

File tree

4 files changed

+38
-1
lines changed

4 files changed

+38
-1
lines changed

shell/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ atrild_LDADD= \
153153
endif
154154

155155
EXTRA_DIST = \
156+
atril.css \
156157
atril-ui.xml \
157158
atril-toolbar.xml \
158159
atril.gresource.xml \

shell/atril.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#ev-fullscreen-toolbar {
2+
3+
}

shell/atril.gresource.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<gresource prefix="/org/mate/atril/shell">
2020
<file alias="ui/atril.xml" compressed="true" preprocess="xml-stripblanks">atril-ui.xml</file>
2121
<file alias="ui/toolbar.xml" compressed="true" preprocess="xml-stripblanks">atril-toolbar.xml</file>
22+
<file alias="ui/atril.css" compressed="true">atril.css</file>
2223
</gresource>
2324
</gresources>
2425

shell/ev-window.c

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4231,7 +4231,7 @@ ev_window_run_fullscreen (EvWindow *window)
42314231
"/FullscreenToolbar");
42324232

42334233
gtk_widget_set_name (window->priv->fullscreen_toolbar,
4234-
"atril-fullscreen-toolbar");
4234+
"ev-fullscreen-toolbar");
42354235
gtk_toolbar_set_style (GTK_TOOLBAR (window->priv->fullscreen_toolbar),
42364236
GTK_TOOLBAR_BOTH_HORIZ);
42374237
fullscreen_toolbar_setup_item_properties (window->priv->ui_manager);
@@ -7647,11 +7647,33 @@ handle_sync_view_cb (EvAtrilWindow *object,
76477647
}
76487648
#endif /* ENABLE_DBUS */
76497649

7650+
static gboolean
7651+
_gtk_css_provider_load_from_resource (GtkCssProvider *provider,
7652+
const char *resource_path,
7653+
GError **error)
7654+
{
7655+
GBytes *data;
7656+
gboolean retval;
7657+
7658+
data = g_resources_lookup_data (resource_path, 0, error);
7659+
if (!data)
7660+
return FALSE;
7661+
7662+
retval = gtk_css_provider_load_from_data (provider,
7663+
g_bytes_get_data (data, NULL),
7664+
g_bytes_get_size (data),
7665+
error);
7666+
g_bytes_unref (data);
7667+
7668+
return retval;
7669+
}
7670+
76507671
static void
76517672
ev_window_init (EvWindow *ev_window)
76527673
{
76537674
GtkActionGroup *action_group;
76547675
GtkAccelGroup *accel_group;
7676+
GtkCssProvider *css_provider;
76557677
GError *error = NULL;
76567678
GtkWidget *sidebar_widget;
76577679
GtkWidget *menuitem;
@@ -7758,6 +7780,16 @@ ev_window_init (EvWindow *ev_window)
77587780
&error);
77597781
g_assert_no_error (error);
77607782

7783+
css_provider = gtk_css_provider_new ();
7784+
_gtk_css_provider_load_from_resource (css_provider,
7785+
"/org/mate/atril/shell/ui/atril.css",
7786+
&error);
7787+
g_assert_no_error (error);
7788+
gtk_style_context_add_provider_for_screen (gtk_widget_get_screen (GTK_WIDGET (ev_window)),
7789+
GTK_STYLE_PROVIDER (css_provider),
7790+
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
7791+
g_object_unref (css_provider);
7792+
77617793
ev_window->priv->recent_manager = gtk_recent_manager_get_default ();
77627794
ev_window->priv->recent_action_group = NULL;
77637795
ev_window->priv->recent_ui_id = 0;

0 commit comments

Comments
 (0)