[gedit] snippets: add custom css styling for manager



commit 9b04c3b34e314c57d9304dd25b4b713270fdfa82
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Wed Feb 19 15:12:06 2014 +0100

    snippets: add custom css styling for manager

 plugins/snippets/snippets/appactivatable.py |   37 ++++++++++++++++++++++++++-
 plugins/snippets/snippets/snippets.ui       |    9 ++++++
 2 files changed, 45 insertions(+), 1 deletions(-)
---
diff --git a/plugins/snippets/snippets/appactivatable.py b/plugins/snippets/snippets/appactivatable.py
index 418d4c2..e4b29bd 100644
--- a/plugins/snippets/snippets/appactivatable.py
+++ b/plugins/snippets/snippets/appactivatable.py
@@ -20,7 +20,7 @@ import os
 import shutil
 import gettext
 
-from gi.repository import Gedit, Gtk, GObject, Gio, GLib
+from gi.repository import Gedit, Gtk, Gdk, GObject, Gio, GLib
 import platform
 
 from .library import Library
@@ -46,6 +46,39 @@ class AppActivatable(GObject.Object, Gedit.AppActivatable):
 
                 library.set_dirs(snippetsdir, self.system_dirs())
 
+                self.css = Gtk.CssProvider()
+                self.css.load_from_data("""
+.gedit-snippet-manager-paned {
+  border-style: solid;
+  border-color: @borders;
+}
+.gedit-snippet-manager-paned:dir(ltr) {
+  border-width: 0 1px 0 0;
+}
+
+.gedit-snippet-manager-paned:dir(rtl) {
+  border-width: 0 0 0 1px;
+}
+
+.gedit-snippet-manager-view {
+  border-width: 0 0 1px 0;
+}
+
+.gedit-snippet-manager-treeview {
+  border-top-width: 0;
+}
+
+.gedit-snippet-manager-treeview:dir(ltr) {
+  border-left-width: 0;
+}
+
+.gedit-snippet-manager-treeview:dir(rtl) {
+  border-right-width: 0;
+}
+""".encode('utf-8'))
+                Gtk.StyleContext.add_provider_for_screen(Gdk.Screen.get_default(),
+                                                         self.css, 600)
+
                 action = Gio.SimpleAction(name="snippets")
                 action.connect('activate', self.on_action_snippets_activate)
                 self.app.add_action(action)
@@ -57,6 +90,8 @@ class AppActivatable(GObject.Object, Gedit.AppActivatable):
         def do_deactivate(self):
                 self.app.remove_action("snippets")
                 self.menu = None
+                Gtk.StyleContext.remove_for_screen(Gdk.Screen.get_default(),
+                                                   self.css)
 
         def system_dirs(self):
                 if platform.system() != 'Windows':
diff --git a/plugins/snippets/snippets/snippets.ui b/plugins/snippets/snippets/snippets.ui
index 74b3be2..7d4e833 100644
--- a/plugins/snippets/snippets/snippets.ui
+++ b/plugins/snippets/snippets/snippets.ui
@@ -72,6 +72,9 @@
         <property name="visible">True</property>
         <property name="can_focus">True</property>
         <property name="position">275</property>
+        <style>
+          <class name="gedit-snippet-manager-paned"/>
+        </style>
         <child>
           <object class="GtkBox" id="box2">
             <property name="visible">True</property>
@@ -83,6 +86,9 @@
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="shadow_type">in</property>
+                <style>
+                  <class name="gedit-snippet-manager-treeview"/>
+                </style>
                 <child>
                   <object class="GtkTreeView" id="tree_view_snippets">
                     <property name="visible">True</property>
@@ -202,6 +208,9 @@
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="shadow_type">in</property>
+                <style>
+                  <class name="gedit-snippet-manager-view"/>
+                </style>
                 <child>
                   <object class="GeditView" id="source_view_snippet">
                     <property name="buffer">source_buffer</property>


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