[geary] Remove GTK+ 3.14 check when setting widget CSS, modernise it a bit.



commit 8491cd50bc2ae25d4affb7f702fc2b309915a510
Author: Michael James Gratton <mike vee net>
Date:   Fri May 20 14:44:11 2016 +1000

    Remove GTK+ 3.14 check when setting widget CSS, modernise it a bit.
    
    Bug 764812
    
    * src/client/components/main-window.vala (MainWindow::set_styling): Merge
      CSS blocks. Fix Gtk.Frame styling rules for Gtk3.20, making them also
      apply to the frame's border node instead of the frame node. Remove
      redundant rules. Add a prefix for CSS class names so to avoid name
      collisions.
    
    * src/client/composer/composer-box.vala (ComposerBox::ComposerBox): Add a
      CSS class to the composer box, add prefix to the full-pane class.
    
    * ui/composer.glade: Add a class to the composer's frame so that can be
      styled.

 src/client/components/main-window.vala |   60 +++++++++++++------------------
 src/client/composer/composer-box.vala  |    6 ++-
 ui/composer.glade                      |    8 +++-
 3 files changed, 35 insertions(+), 39 deletions(-)
---
diff --git a/src/client/components/main-window.vala b/src/client/components/main-window.vala
index a26fdce..8871309 100644
--- a/src/client/components/main-window.vala
+++ b/src/client/components/main-window.vala
@@ -152,27 +152,34 @@ public class MainWindow : Gtk.ApplicationWindow {
         Gtk.CssProvider provider = new Gtk.CssProvider();
         Gtk.StyleContext.add_provider_for_screen(Gdk.Display.get_default().get_default_screen(),
             provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
-        // Gtk < 3.14: No borders along top or left side of window
         string css = """
-            .folder-frame {
-                border-left-width: 0px;
-                border-top-width: 0px;
+            .geary-folder-frame, /* GTK < 3.20 */
+            .geary-folder-frame > border {
+                border-left-width: 0;
+                border-top-width: 0;
+                border-right-width: 0;
             }
-            .sidebar-pane-separator.horizontal .conversation-frame {
-                border-top-width: 0px;
-                border-bottom-width: 0px;
+            .geary-conversation-frame, /* GTK < 3.20 */
+            .geary-conversation-frame > border {
+                border-left-width: 0;
+                border-top-width: 0;
+                border-right-width: 0;
             }
-            .sidebar-pane-separator.vertical .conversation-frame {
-                border-left-width: 0px;
+            /* For 3-pane mode only */
+            .geary-sidebar-pane-separator.vertical .conversation-frame, /* GTK < 3.20 */
+            .geary-sidebar-pane-separator.vertical .conversation-frame > border {
+                border-bottom-width: 0;
             }
-            ComposerBox {
-                border-left-width: 0px;
-                border-right-width: 0px;
-                border-bottom-width: 0px;
+
+            .geary-composer-box > border {
+                border-width: 0px;
             }
-            ComposerBox.full-pane {
-                border-top-width: 0px;
+            .geary-composer-body > border {
+                border-left-width: 0;
+                border-right-width: 0;
+                border-bottom-width: 0;
             }
+
             ComposerEmbed GtkHeaderBar,
             ComposerBox GtkHeaderBar,
             GtkBox.vertical GtkHeaderBar {
@@ -187,23 +194,6 @@ public class MainWindow : Gtk.ApplicationWindow {
                 border-top-left-radius: 0px;
             }
         """;
-        
-        if(Gtk.MAJOR_VERSION > 3 || Gtk.MAJOR_VERSION == 3 && Gtk.MINOR_VERSION >= 14) {
-            // Gtk >= 3.14: Borders only along status bar
-            css += """
-                  .folder-frame {
-                      border-right-width: 0px;
-                  }
-                  .sidebar-pane-separator.vertical .folder-frame {
-                      border-bottom-width: 0px;
-                  }
-                  .conversation-frame {
-                      border-top-width: 0px;
-                      border-left-width: 0px;
-                      border-right-width: 0px;
-                  }
-            """;
-        }
 
         try {
             provider.load_from_data(css, -1);
@@ -222,7 +212,7 @@ public class MainWindow : Gtk.ApplicationWindow {
         folder_list_scrolled.add(folder_list);
         Gtk.Frame folder_frame = new Gtk.Frame(null);
         folder_frame.shadow_type = Gtk.ShadowType.IN;
-        folder_frame.get_style_context ().add_class ("folder-frame");
+        folder_frame.get_style_context ().add_class("geary-folder-frame");
         folder_frame.add(folder_list_scrolled);
         folder_box = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
         folder_box.pack_start(folder_frame, true, true);
@@ -234,7 +224,7 @@ public class MainWindow : Gtk.ApplicationWindow {
         conversation_list_scrolled.add(conversation_list_view);
         Gtk.Frame conversation_frame = new Gtk.Frame(null);
         conversation_frame.shadow_type = Gtk.ShadowType.IN;
-        conversation_frame.get_style_context ().add_class ("conversation-frame");
+        conversation_frame.get_style_context ().add_class("geary-conversation-frame");
         conversation_frame.add(conversation_list_scrolled);
         conversation_box = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
         conversation_box.pack_start(conversation_frame, true, true);
@@ -245,7 +235,7 @@ public class MainWindow : Gtk.ApplicationWindow {
         spinner.set_size_request(STATUS_BAR_HEIGHT - 2, -1);
         status_bar.add(spinner);
         
-        folder_paned.get_style_context().add_class("sidebar-pane-separator");
+        folder_paned.get_style_context().add_class("geary-sidebar-pane-separator");
         
         Gtk.Frame viewer_frame = new Gtk.Frame(null);
         viewer_frame.shadow_type = Gtk.ShadowType.NONE;
diff --git a/src/client/composer/composer-box.vala b/src/client/composer/composer-box.vala
index 3e7f03b..dd6344e 100644
--- a/src/client/composer/composer-box.vala
+++ b/src/client/composer/composer-box.vala
@@ -22,6 +22,8 @@ public class ComposerBox : Gtk.Frame, ComposerContainer {
         composer.editor.focus_out_event.connect(on_focus_out);
         show();
         
+        get_style_context().add_class("geary-composer-box");
+
         if (composer.state == ComposerWidget.ComposerState.NEW) {
             ConversationListView conversation_list_view = ((MainWindow) GearyApplication.
                 instance.controller.main_window).conversation_list_view;
@@ -31,7 +33,7 @@ public class ComposerBox : Gtk.Frame, ComposerContainer {
             composer.free_header();
             GearyApplication.instance.controller.main_window.main_toolbar.set_conversation_header(
                 composer.header);
-            get_style_context().add_class("full-pane");
+            get_style_context().add_class("geary-full-pane");
         }
     }
     
@@ -71,7 +73,7 @@ public class ComposerBox : Gtk.Frame, ComposerContainer {
     public void vanish() {
         hide();
         parent.hide();
-        if (get_style_context().has_class("full-pane"))
+        if (get_style_context().has_class("geary-full-pane"))
             GearyApplication.instance.controller.main_window.main_toolbar.remove_conversation_header(
                 composer.header);
         
diff --git a/ui/composer.glade b/ui/composer.glade
index 7e730c0..8414995 100644
--- a/ui/composer.glade
+++ b/ui/composer.glade
@@ -1,6 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.20.0 -->
 <interface>
-  <!-- interface-requires gtk+ 3.0 -->
+  <requires lib="gtk+" version="3.14"/>
   <object class="GtkActionGroup" id="compose actions">
     <child>
       <object class="GtkAction" id="undo">
@@ -594,7 +595,7 @@
       </packing>
     </child>
     <child>
-      <object class="GtkFrame" id="frame1">
+      <object class="GtkFrame">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
         <property name="label_xalign">0</property>
@@ -611,6 +612,9 @@
         <child type="label_item">
           <placeholder/>
         </child>
+        <style>
+          <class name="geary-composer-body"/>
+        </style>
       </object>
       <packing>
         <property name="expand">True</property>


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