[gedit/wip/redesign2] Load custom css file



commit 8e37355bd775d19b3644fc8b4766f24fb2b32470
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Fri Jan 3 09:56:43 2014 +0100

    Load custom css file

 gedit/Makefile.am         |    3 ++-
 gedit/gedit-app.c         |   20 +++++++++++++++++++-
 gedit/gedit-style.css     |    9 +++++++++
 gedit/gedit.gresource.xml |    1 +
 4 files changed, 31 insertions(+), 2 deletions(-)
---
diff --git a/gedit/Makefile.am b/gedit/Makefile.am
index dbf8bd7..bdc15a4 100644
--- a/gedit/Makefile.am
+++ b/gedit/Makefile.am
@@ -269,7 +269,8 @@ EXTRA_DIST =                                \
        gedit-status-menu-button.ui     \
        gedit-view-frame.ui             \
        gedit-highlight-mode-dialog.ui  \
-       gedit-window.ui
+       gedit-window.ui                 \
+       gedit-style.css
 
 CLEANFILES = $(BUILT_SOURCES) $(BUILT_SOURCES_PRIVATE)
 
diff --git a/gedit/gedit-app.c b/gedit/gedit-app.c
index b09a009..34fb787 100644
--- a/gedit/gedit-app.c
+++ b/gedit/gedit-app.c
@@ -415,6 +415,9 @@ gedit_app_startup (GApplication *application)
        const gchar *cache_dir;
        gchar *metadata_filename;
 #endif
+       GError *error = NULL;
+       GFile *css_file;
+       GtkCssProvider *provider;
 
        G_APPLICATION_CLASS (gedit_app_parent_class)->startup (application);
 
@@ -465,7 +468,6 @@ gedit_app_startup (GApplication *application)
        {
                GtkBuilder *builder;
                GAction *action;
-               GError *error = NULL;
 
                g_action_map_add_action_entries (G_ACTION_MAP (app),
                                                 app_entries,
@@ -549,6 +551,22 @@ gedit_app_startup (GApplication *application)
                                         "<Control><Alt>Page_Down",
                                         "win.next_document", NULL);
 
+       /* Load custom css */
+       error = NULL;
+       css_file = g_file_new_for_uri ("resource:///org/gnome/gedit/ui/gedit-style.css");
+       provider = gtk_css_provider_new ();
+       if (gtk_css_provider_load_from_file (provider, css_file, &error))
+       {
+               gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
+                                                          GTK_STYLE_PROVIDER (provider),
+                                                          GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+       }
+       else
+       {
+               g_warning ("Could not load css provider: %s", error->message);
+               g_error_free (error);
+       }
+
        /*
         * We use the default gtksourceview style scheme manager so that plugins
         * can obtain it easily without a gedit specific api, but we need to
diff --git a/gedit/gedit-style.css b/gedit/gedit-style.css
new file mode 100644
index 0000000..ffb8b09
--- /dev/null
+++ b/gedit/gedit-style.css
@@ -0,0 +1,9 @@
+.gedit-titlebar-left:dir(ltr),
+.gedit-titlebar-right:dir(rtl) {
+    border-top-right-radius: 0;
+}
+
+.gedit-titlebar-right:dir(ltr),
+.gedit-titlebar-left:dir(rtl) {
+    border-top-left-radius: 0;
+}
diff --git a/gedit/gedit.gresource.xml b/gedit/gedit.gresource.xml
index 722d1e4..b340e66 100644
--- a/gedit/gedit.gresource.xml
+++ b/gedit/gedit.gresource.xml
@@ -14,5 +14,6 @@
     <file preprocess="xml-stripblanks">gedit-view-frame.ui</file>
     <file preprocess="xml-stripblanks">gedit-highlight-mode-dialog.ui</file>
     <file preprocess="xml-stripblanks">gedit-window.ui</file>
+    <file>gedit-style.css</file>
   </gresource>
 </gresources>


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