aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandre Mazari <scaroo@gmail.com>2011-07-30 12:57:51 +0800
committerDiego Escalante Urrelo <descalante@igalia.com>2011-07-30 13:10:17 +0800
commitd6f43136341159cccde9f707f2a493c109ec4e85 (patch)
treef9cd5ac4c6b6ffdd08f3404e90236c8b13c609a1
parentf4c6a2f079f5b24c067f2b656a8a4f808ec4533c (diff)
downloadgsoc2013-epiphany-d6f43136341159cccde9f707f2a493c109ec4e85.tar
gsoc2013-epiphany-d6f43136341159cccde9f707f2a493c109ec4e85.tar.gz
gsoc2013-epiphany-d6f43136341159cccde9f707f2a493c109ec4e85.tar.bz2
gsoc2013-epiphany-d6f43136341159cccde9f707f2a493c109ec4e85.tar.lz
gsoc2013-epiphany-d6f43136341159cccde9f707f2a493c109ec4e85.tar.xz
gsoc2013-epiphany-d6f43136341159cccde9f707f2a493c109ec4e85.tar.zst
gsoc2013-epiphany-d6f43136341159cccde9f707f2a493c109ec4e85.zip
e-window: use a css file for widget styling
Replace local styling (used for the tab close button and embed's status frame) by a global css sheet loaded at window construction. This allows tweaking style properties without rebuilding. The css file is installed in $(pkgdatadir)/epiphany.css. Signed-off-by: Diego Escalante Urrelo <descalante@igalia.com> Bug #644805
-rw-r--r--data/ui/Makefile.am7
-rw-r--r--data/ui/epiphany.css16
-rw-r--r--embed/ephy-embed.c15
-rw-r--r--src/ephy-notebook.c18
-rw-r--r--src/ephy-window.c23
5 files changed, 45 insertions, 34 deletions
diff --git a/data/ui/Makefile.am b/data/ui/Makefile.am
index 4fd9a45f2..7ffa3b1cb 100644
--- a/data/ui/Makefile.am
+++ b/data/ui/Makefile.am
@@ -7,4 +7,9 @@ xml_DATA = \
epiphany-toolbar.xml \
epiphany-history-window-ui.xml
-EXTRA_DIST = $(xml_DATA)
+cssdir = $(pkgdatadir)
+css_DATA = epiphany.css
+
+EXTRA_DIST = \
+ $(xml_DATA) \
+ $(css_DATA)
diff --git a/data/ui/epiphany.css b/data/ui/epiphany.css
new file mode 100644
index 000000000..867d31045
--- /dev/null
+++ b/data/ui/epiphany.css
@@ -0,0 +1,16 @@
+#ephy-status-frame {
+ border-style: solid;
+ border-width: 1;
+ padding: 4;
+}
+
+#ephy-tab-close-button {
+ -GtkButton-default-border: 0;
+ -GtkButton-default-outside-border: 0;
+ -GtkButton-inner-border: 0;
+ -GtkWidget-focus-padding: 0;
+ -GtkWidget-focus-line-width: 0;
+ margin: 0;
+ padding: 0;
+}
+
diff --git a/embed/ephy-embed.c b/embed/ephy-embed.c
index d5a63a5a3..623c659e8 100644
--- a/embed/ephy-embed.c
+++ b/embed/ephy-embed.c
@@ -497,9 +497,6 @@ ephy_embed_constructed (GObject *object)
GtkWidget *overlay;
EphyOverlayEscapingChild *escaping_child;
GtkWidget *frame;
- GtkCssProvider *provider;
- GtkStyleContext *context;
- GError *error = NULL;
/* Skeleton */
web_view = WEBKIT_WEB_VIEW (ephy_web_view_new ());
@@ -510,18 +507,6 @@ ephy_embed_constructed (GObject *object)
priv->statusbar_label = gtk_label_new (NULL);
frame = gtk_frame_new (NULL);
gtk_widget_set_name (frame, "ephy-status-frame");
- provider = gtk_css_provider_new ();
- gtk_css_provider_load_from_data (provider,
- "#ephy-status-frame { border-style: solid; border-width: 1; padding: 4; }",
- -1, &error);
- if (error == NULL) {
- context = gtk_widget_get_style_context (frame);
- gtk_style_context_add_provider (context, GTK_STYLE_PROVIDER (provider),
- GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
- } else
- g_error_free (error);
-
- g_object_unref (provider);
gtk_widget_show (frame);
diff --git a/src/ephy-notebook.c b/src/ephy-notebook.c
index 3d2e365bc..d5cc41372 100644
--- a/src/ephy-notebook.c
+++ b/src/ephy-notebook.c
@@ -581,7 +581,6 @@ build_tab_label (EphyNotebook *nb, EphyEmbed *embed)
{
GtkWidget *hbox, *label, *close_button, *image, *spinner, *icon;
EphyWebView *view;
- GtkCssProvider *provider;
/* set hbox spacing and label padding (see below) so that there's an
* equal amount of space around the label */
@@ -615,23 +614,6 @@ build_tab_label (EphyNotebook *nb, EphyEmbed *embed)
gtk_widget_set_name (close_button, "ephy-tab-close-button");
- provider = gtk_css_provider_new ();
- gtk_css_provider_load_from_data (provider,
- "#ephy-tab-close-button {"
- " -GtkButton-default-border: 0;"
- " -GtkButton-default-outside-border: 0;"
- " -GtkButton-inner-border: 0;"
- " -GtkWidget-focus-padding: 0;"
- " -GtkWidget-focus-line-width: 0;"
- " margin: 0;"
- " padding: 0; }",
- -1, NULL);
-
- gtk_style_context_add_provider (gtk_widget_get_style_context (close_button),
- GTK_STYLE_PROVIDER (provider),
- GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
- g_object_unref (provider);
-
image = gtk_image_new_from_stock (GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU);
gtk_widget_set_tooltip_text (close_button, _("Close tab"));
g_signal_connect (close_button, "clicked",
diff --git a/src/ephy-window.c b/src/ephy-window.c
index f5ee4b2a9..f8cedf9be 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -3683,6 +3683,8 @@ ephy_window_constructor (GType type,
guint settings_connection;
GSList *proxies;
GtkWidget *proxy;
+ GtkCssProvider *css_provider;
+ GFile *css_file;
object = G_OBJECT_CLASS (ephy_window_parent_class)->constructor
(type, n_construct_properties, construct_params);
@@ -3779,6 +3781,27 @@ ephy_window_constructor (GType type,
}
#endif
+ /* Attach the CSS provider to the window */
+ css_file = g_file_new_for_path (ephy_file ("epiphany.css"));
+ css_provider = gtk_css_provider_new ();
+ gtk_css_provider_load_from_file (css_provider,
+ css_file,
+ &error);
+ if (error == NULL)
+ {
+ gtk_style_context_add_provider_for_screen (gtk_widget_get_screen (GTK_WIDGET (window)),
+ GTK_STYLE_PROVIDER (css_provider),
+ GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+ }
+ else
+ {
+ g_warning ("Could not attach css style: %s", error->message);
+ g_error_free (error);
+ }
+
+ g_object_unref (css_provider);
+ g_object_unref (css_file);
+
/* Initialize the menus */
priv->tabs_menu = ephy_tabs_menu_new (window);
priv->enc_menu = ephy_encoding_menu_new (window);