[glade] GtkLabel: Integrate the "lines" property nicely



commit 249d09ee312d2cdb99edf210555344bc2a083b8b
Author: Tristan Van Berkom <tristan vanberkom codethink co uk>
Date:   Fri Jan 29 12:44:38 2016 +0100

    GtkLabel: Integrate the "lines" property nicely
    
    This property is only relevant when ellipsizing and
    word wrapping are enabled, make it insensitive when
    not relevant and place it beside the wrap-mode property.

 plugins/gtk+/glade-gtk-label.c     |   28 ++++++-
 plugins/gtk+/glade-label-editor.ui |  181 ++++++++++++++++++------------------
 plugins/gtk+/gtk+.xml.in           |    4 +-
 3 files changed, 122 insertions(+), 91 deletions(-)
---
diff --git a/plugins/gtk+/glade-gtk-label.c b/plugins/gtk+/glade-gtk-label.c
index 6f3d316..56fb0a8 100644
--- a/plugins/gtk+/glade-gtk-label.c
+++ b/plugins/gtk+/glade-gtk-label.c
@@ -239,6 +239,25 @@ glade_gtk_label_set_content_mode (GObject * object, const GValue * value)
 }
 
 static void
+glade_gtk_label_update_lines_sensitivity (GObject * object)
+{
+  GladeWidget *glabel;
+  PangoEllipsizeMode ellipsize_mode;
+  gint wrap_mode;
+
+  glabel = glade_widget_get_from_gobject (object);
+
+  glade_widget_property_get (glabel, "label-wrap-mode", &wrap_mode);
+  glade_widget_property_get (glabel, "ellipsize", &ellipsize_mode);
+
+  if (wrap_mode == GLADE_LABEL_WRAP_MODE && ellipsize_mode != PANGO_ELLIPSIZE_NONE)
+    glade_widget_property_set_sensitive (glabel, "lines", TRUE, NULL);
+  else
+    glade_widget_property_set_sensitive (glabel, "lines", FALSE,
+                                         _("This property only applies if ellispize and wrapping are 
enabled"));
+}
+
+static void
 glade_gtk_label_set_wrap_mode (GObject * object, const GValue * value)
 {
   GladeLabelWrapMode mode = g_value_get_int (value);
@@ -256,6 +275,8 @@ glade_gtk_label_set_wrap_mode (GObject * object, const GValue * value)
                                          NULL);
   else if (mode == GLADE_LABEL_WRAP_MODE)
     glade_widget_property_set_sensitive (glabel, "wrap-mode", TRUE, NULL);
+
+  glade_gtk_label_update_lines_sensitivity (object);
 }
 
 static void
@@ -290,7 +311,12 @@ glade_gtk_label_set_property (GladeWidgetAdaptor * adaptor,
   else if (!strcmp (id, "use-underline"))
     glade_gtk_label_set_use_underline (object, value);
   else
-    GWA_GET_CLASS (GTK_TYPE_WIDGET)->set_property (adaptor, object, id, value);
+    {
+      if (!strcmp (id, "ellipsize"))
+       glade_gtk_label_update_lines_sensitivity (object);
+
+      GWA_GET_CLASS (GTK_TYPE_WIDGET)->set_property (adaptor, object, id, value);
+    }
 }
 
 static void
diff --git a/plugins/gtk+/glade-label-editor.ui b/plugins/gtk+/glade-label-editor.ui
index 4c90064..0a8ca5d 100644
--- a/plugins/gtk+/glade-label-editor.ui
+++ b/plugins/gtk+/glade-label-editor.ui
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.16.0 
+<!-- Generated with glade 3.19.0 
 
 libgladegtk - Glade UI Designer Gtk+ support plugin
 Copyright (C) 2013 Tristan Van Berkom <tvb gnome org>
@@ -44,7 +44,6 @@ Author: Tristan Van Berkom <tvb gnome org>
             <property name="left_attach">0</property>
             <property name="top_attach">0</property>
             <property name="width">6</property>
-            <property name="height">1</property>
           </packing>
         </child>
         <child>
@@ -62,7 +61,6 @@ Author: Tristan Van Berkom <tvb gnome org>
             <property name="left_attach">0</property>
             <property name="top_attach">1</property>
             <property name="width">6</property>
-            <property name="height">1</property>
           </packing>
         </child>
         <child>
@@ -76,8 +74,6 @@ Author: Tristan Van Berkom <tvb gnome org>
           <packing>
             <property name="left_attach">0</property>
             <property name="top_attach">2</property>
-            <property name="width">1</property>
-            <property name="height">1</property>
           </packing>
         </child>
         <child>
@@ -91,7 +87,6 @@ Author: Tristan Van Berkom <tvb gnome org>
             <property name="left_attach">1</property>
             <property name="top_attach">2</property>
             <property name="width">5</property>
-            <property name="height">1</property>
           </packing>
         </child>
         <child>
@@ -116,8 +111,6 @@ Author: Tristan Van Berkom <tvb gnome org>
           <packing>
             <property name="left_attach">0</property>
             <property name="top_attach">3</property>
-            <property name="width">1</property>
-            <property name="height">1</property>
           </packing>
         </child>
         <child>
@@ -131,7 +124,6 @@ Author: Tristan Van Berkom <tvb gnome org>
             <property name="left_attach">1</property>
             <property name="top_attach">3</property>
             <property name="width">5</property>
-            <property name="height">1</property>
           </packing>
         </child>
         <child>
@@ -158,7 +150,6 @@ Author: Tristan Van Berkom <tvb gnome org>
             <property name="left_attach">0</property>
             <property name="top_attach">4</property>
             <property name="width">2</property>
-            <property name="height">1</property>
           </packing>
         </child>
         <child>
@@ -185,7 +176,6 @@ Author: Tristan Van Berkom <tvb gnome org>
             <property name="left_attach">0</property>
             <property name="top_attach">5</property>
             <property name="width">2</property>
-            <property name="height">1</property>
           </packing>
         </child>
         <child>
@@ -199,7 +189,6 @@ Author: Tristan Van Berkom <tvb gnome org>
             <property name="left_attach">2</property>
             <property name="top_attach">5</property>
             <property name="width">4</property>
-            <property name="height">1</property>
           </packing>
         </child>
         <child>
@@ -217,7 +206,6 @@ Author: Tristan Van Berkom <tvb gnome org>
             <property name="left_attach">0</property>
             <property name="top_attach">9</property>
             <property name="width">6</property>
-            <property name="height">1</property>
           </packing>
         </child>
         <child>
@@ -237,7 +225,6 @@ Author: Tristan Van Berkom <tvb gnome org>
             <property name="left_attach">0</property>
             <property name="top_attach">6</property>
             <property name="width">6</property>
-            <property name="height">1</property>
           </packing>
         </child>
         <child>
@@ -253,7 +240,6 @@ Author: Tristan Van Berkom <tvb gnome org>
             <property name="left_attach">0</property>
             <property name="top_attach">7</property>
             <property name="width">2</property>
-            <property name="height">1</property>
           </packing>
         </child>
         <child>
@@ -268,7 +254,6 @@ Author: Tristan Van Berkom <tvb gnome org>
             <property name="left_attach">2</property>
             <property name="top_attach">7</property>
             <property name="width">4</property>
-            <property name="height">1</property>
           </packing>
         </child>
         <child>
@@ -284,7 +269,6 @@ Author: Tristan Van Berkom <tvb gnome org>
             <property name="left_attach">0</property>
             <property name="top_attach">8</property>
             <property name="width">2</property>
-            <property name="height">1</property>
           </packing>
         </child>
         <child>
@@ -298,7 +282,6 @@ Author: Tristan Van Berkom <tvb gnome org>
             <property name="left_attach">2</property>
             <property name="top_attach">8</property>
             <property name="width">4</property>
-            <property name="height">1</property>
           </packing>
         </child>
         <child>
@@ -312,8 +295,6 @@ Author: Tristan Van Berkom <tvb gnome org>
           <packing>
             <property name="left_attach">0</property>
             <property name="top_attach">10</property>
-            <property name="width">1</property>
-            <property name="height">1</property>
           </packing>
         </child>
         <child>
@@ -326,8 +307,6 @@ Author: Tristan Van Berkom <tvb gnome org>
           <packing>
             <property name="left_attach">1</property>
             <property name="top_attach">10</property>
-            <property name="width">1</property>
-            <property name="height">1</property>
           </packing>
         </child>
         <child>
@@ -341,8 +320,6 @@ Author: Tristan Van Berkom <tvb gnome org>
           <packing>
             <property name="left_attach">2</property>
             <property name="top_attach">10</property>
-            <property name="width">1</property>
-            <property name="height">1</property>
           </packing>
         </child>
         <child>
@@ -355,8 +332,6 @@ Author: Tristan Van Berkom <tvb gnome org>
           <packing>
             <property name="left_attach">3</property>
             <property name="top_attach">10</property>
-            <property name="width">1</property>
-            <property name="height">1</property>
           </packing>
         </child>
         <child>
@@ -370,8 +345,6 @@ Author: Tristan Van Berkom <tvb gnome org>
           <packing>
             <property name="left_attach">0</property>
             <property name="top_attach">11</property>
-            <property name="width">1</property>
-            <property name="height">1</property>
           </packing>
         </child>
         <child>
@@ -384,8 +357,6 @@ Author: Tristan Van Berkom <tvb gnome org>
           <packing>
             <property name="left_attach">1</property>
             <property name="top_attach">11</property>
-            <property name="width">1</property>
-            <property name="height">1</property>
           </packing>
         </child>
         <child>
@@ -409,9 +380,8 @@ Author: Tristan Van Berkom <tvb gnome org>
           </object>
           <packing>
             <property name="left_attach">0</property>
-            <property name="top_attach">12</property>
-            <property name="width">3</property>
-            <property name="height">1</property>
+            <property name="top_attach">13</property>
+            <property name="width">2</property>
           </packing>
         </child>
         <child>
@@ -437,37 +407,8 @@ Author: Tristan Van Berkom <tvb gnome org>
           </object>
           <packing>
             <property name="left_attach">0</property>
-            <property name="top_attach">13</property>
-            <property name="width">3</property>
-            <property name="height">1</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkRadioButton" id="wrap_mode_radio">
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="receives_default">False</property>
-            <property name="margin_left">12</property>
-            <property name="hexpand">False</property>
-            <property name="xalign">0</property>
-            <property name="active">True</property>
-            <property name="draw_indicator">True</property>
-            <property name="group">single_radio</property>
-            <signal name="toggled" handler="wrap_mode_toggled" swapped="no"/>
-            <child>
-              <object class="GladePropertyLabel" id="wrap_mode_label">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="property_name">wrap-mode</property>
-                <property name="custom_text" translatable="yes">Automatically wrap</property>
-              </object>
-            </child>
-          </object>
-          <packing>
-            <property name="left_attach">0</property>
             <property name="top_attach">14</property>
-            <property name="width">2</property>
-            <property name="height">1</property>
+            <property name="width">3</property>
           </packing>
         </child>
         <child>
@@ -483,9 +424,8 @@ Author: Tristan Van Berkom <tvb gnome org>
           </object>
           <packing>
             <property name="left_attach">0</property>
-            <property name="top_attach">15</property>
+            <property name="top_attach">16</property>
             <property name="width">6</property>
-            <property name="height">1</property>
           </packing>
         </child>
         <child>
@@ -497,9 +437,8 @@ Author: Tristan Van Berkom <tvb gnome org>
           </object>
           <packing>
             <property name="left_attach">2</property>
-            <property name="top_attach">16</property>
+            <property name="top_attach">17</property>
             <property name="width">2</property>
-            <property name="height">1</property>
           </packing>
         </child>
         <child>
@@ -511,23 +450,8 @@ Author: Tristan Van Berkom <tvb gnome org>
           </object>
           <packing>
             <property name="left_attach">2</property>
-            <property name="top_attach">17</property>
-            <property name="width">2</property>
-            <property name="height">1</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GladePropertyShell" id="wrap_mode_editor">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="hexpand">False</property>
-            <property name="property_name">wrap-mode</property>
-          </object>
-          <packing>
-            <property name="left_attach">2</property>
-            <property name="top_attach">14</property>
+            <property name="top_attach">18</property>
             <property name="width">2</property>
-            <property name="height">1</property>
           </packing>
         </child>
         <child>
@@ -539,9 +463,8 @@ Author: Tristan Van Berkom <tvb gnome org>
           </object>
           <packing>
             <property name="left_attach">0</property>
-            <property name="top_attach">18</property>
+            <property name="top_attach">19</property>
             <property name="width">6</property>
-            <property name="height">1</property>
           </packing>
         </child>
         <child>
@@ -553,9 +476,8 @@ Author: Tristan Van Berkom <tvb gnome org>
           </object>
           <packing>
             <property name="left_attach">0</property>
-            <property name="top_attach">16</property>
+            <property name="top_attach">17</property>
             <property name="width">2</property>
-            <property name="height">1</property>
           </packing>
         </child>
         <child>
@@ -567,12 +489,91 @@ Author: Tristan Van Berkom <tvb gnome org>
           </object>
           <packing>
             <property name="left_attach">0</property>
-            <property name="top_attach">17</property>
+            <property name="top_attach">18</property>
             <property name="width">2</property>
-            <property name="height">1</property>
           </packing>
         </child>
         <child>
+          <object class="GtkRadioButton" id="wrap_mode_radio">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="receives_default">False</property>
+            <property name="margin_left">12</property>
+            <property name="hexpand">False</property>
+            <property name="xalign">0</property>
+            <property name="active">True</property>
+            <property name="draw_indicator">True</property>
+            <property name="group">single_radio</property>
+            <signal name="toggled" handler="wrap_mode_toggled" swapped="no"/>
+            <child>
+              <object class="GladePropertyLabel" id="wrap_mode_label">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="property_name">wrap-mode</property>
+                <property name="custom_text" translatable="yes">Automatically wrap</property>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="left_attach">0</property>
+            <property name="top_attach">12</property>
+            <property name="width">2</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GladePropertyShell" id="wrap_mode_editor">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="hexpand">False</property>
+            <property name="property_name">wrap-mode</property>
+          </object>
+          <packing>
+            <property name="left_attach">2</property>
+            <property name="top_attach">12</property>
+            <property name="width">2</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GladePropertyShell" id="lines_editor">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="hexpand">False</property>
+            <property name="property_name">lines</property>
+          </object>
+          <packing>
+            <property name="left_attach">3</property>
+            <property name="top_attach">13</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GladePropertyLabel" id="lines_label">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="halign">end</property>
+            <property name="property_name">lines</property>
+            <property name="custom_text" translatable="yes">Lines</property>
+          </object>
+          <packing>
+            <property name="left_attach">2</property>
+            <property name="top_attach">13</property>
+          </packing>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
           <placeholder/>
         </child>
         <child>
@@ -669,6 +670,8 @@ Author: Tristan Van Berkom <tvb gnome org>
       <editor id="width_editor"/>
       <editor id="max_width_editor"/>
       <editor id="wrap_mode_editor"/>
+      <editor id="lines_label"/>
+      <editor id="lines_editor"/>
       <editor id="misc_editor"/>
       <editor id="width_label"/>
       <editor id="max_width_label"/>
diff --git a/plugins/gtk+/gtk+.xml.in b/plugins/gtk+/gtk+.xml.in
index ac3734b..838accb 100644
--- a/plugins/gtk+/gtk+.xml.in
+++ b/plugins/gtk+/gtk+.xml.in
@@ -1423,7 +1423,9 @@
           <property id="max-width-chars" custom-layout="True"/>
           <property id="width-chars" custom-layout="True"/>
           <property id="wrap" custom-layout="True"/>
-               
+
+         <!-- Shove it in there ! -->
+         <property id="lines" since="3.10" custom-layout="True"/>
           <property id="selectable" ignore="True" custom-layout="True"/>
           <property id="justify" custom-layout="True">
             <displayable-values>


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