Skip to content

Commit

Permalink
Move custom css to a file compiled as a gresource
Browse files Browse the repository at this point in the history
  • Loading branch information
Carlos Garcia Campos authored and raveit65 committed Mar 22, 2018
1 parent c7fcfa1 commit 1e531cb
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
1 change: 1 addition & 0 deletions shell/Makefile.am
Expand Up @@ -153,6 +153,7 @@ atrild_LDADD= \
endif endif


EXTRA_DIST = \ EXTRA_DIST = \
atril.css \
atril-ui.xml \ atril-ui.xml \
atril-toolbar.xml \ atril-toolbar.xml \
atril.gresource.xml \ atril.gresource.xml \
Expand Down
3 changes: 3 additions & 0 deletions shell/atril.css
@@ -0,0 +1,3 @@
#ev-fullscreen-toolbar {

}
1 change: 1 addition & 0 deletions shell/atril.gresource.xml
Expand Up @@ -19,6 +19,7 @@
<gresource prefix="/org/mate/atril/shell"> <gresource prefix="/org/mate/atril/shell">
<file alias="ui/atril.xml" compressed="true" preprocess="xml-stripblanks">atril-ui.xml</file> <file alias="ui/atril.xml" compressed="true" preprocess="xml-stripblanks">atril-ui.xml</file>
<file alias="ui/toolbar.xml" compressed="true" preprocess="xml-stripblanks">atril-toolbar.xml</file> <file alias="ui/toolbar.xml" compressed="true" preprocess="xml-stripblanks">atril-toolbar.xml</file>
<file alias="ui/atril.css" compressed="true">atril.css</file>
</gresource> </gresource>
</gresources> </gresources>


34 changes: 33 additions & 1 deletion shell/ev-window.c
Expand Up @@ -4231,7 +4231,7 @@ ev_window_run_fullscreen (EvWindow *window)
"/FullscreenToolbar"); "/FullscreenToolbar");


gtk_widget_set_name (window->priv->fullscreen_toolbar, gtk_widget_set_name (window->priv->fullscreen_toolbar,
"atril-fullscreen-toolbar"); "ev-fullscreen-toolbar");
gtk_toolbar_set_style (GTK_TOOLBAR (window->priv->fullscreen_toolbar), gtk_toolbar_set_style (GTK_TOOLBAR (window->priv->fullscreen_toolbar),
GTK_TOOLBAR_BOTH_HORIZ); GTK_TOOLBAR_BOTH_HORIZ);
fullscreen_toolbar_setup_item_properties (window->priv->ui_manager); fullscreen_toolbar_setup_item_properties (window->priv->ui_manager);
Expand Down Expand Up @@ -7647,11 +7647,33 @@ handle_sync_view_cb (EvAtrilWindow *object,
} }
#endif /* ENABLE_DBUS */ #endif /* ENABLE_DBUS */


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 void static void
ev_window_init (EvWindow *ev_window) ev_window_init (EvWindow *ev_window)
{ {
GtkActionGroup *action_group; GtkActionGroup *action_group;
GtkAccelGroup *accel_group; GtkAccelGroup *accel_group;
GtkCssProvider *css_provider;
GError *error = NULL; GError *error = NULL;
GtkWidget *sidebar_widget; GtkWidget *sidebar_widget;
GtkWidget *menuitem; GtkWidget *menuitem;
Expand Down Expand Up @@ -7758,6 +7780,16 @@ ev_window_init (EvWindow *ev_window)
&error); &error);
g_assert_no_error (error); g_assert_no_error (error);


css_provider = gtk_css_provider_new ();
_gtk_css_provider_load_from_resource (css_provider,
"/org/mate/atril/shell/ui/atril.css",
&error);
g_assert_no_error (error);
gtk_style_context_add_provider_for_screen (gtk_widget_get_screen (GTK_WIDGET (ev_window)),
GTK_STYLE_PROVIDER (css_provider),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
g_object_unref (css_provider);

ev_window->priv->recent_manager = gtk_recent_manager_get_default (); ev_window->priv->recent_manager = gtk_recent_manager_get_default ();
ev_window->priv->recent_action_group = NULL; ev_window->priv->recent_action_group = NULL;
ev_window->priv->recent_ui_id = 0; ev_window->priv->recent_ui_id = 0;
Expand Down

0 comments on commit 1e531cb

Please sign in to comment.