[glabels/vala] Additional text object cleanup.



commit e5e2a4ca22e174a1760134babc3eb746c5e3b6f8
Author: Jim Evins <evins snaught com>
Date:   Sat Jul 28 21:10:38 2012 -0400

    Additional text object cleanup.

 data/ui/object_editor.ui       |  463 +++++++++++++++++++++++++---------------
 glabels/label_object_text.vala |   66 +++++-
 glabels/object_editor.vala     |    2 +-
 glabels/view.vala              |    9 +-
 4 files changed, 361 insertions(+), 179 deletions(-)
---
diff --git a/data/ui/object_editor.ui b/data/ui/object_editor.ui
index 69302c5..508d504 100644
--- a/data/ui/object_editor.ui
+++ b/data/ui/object_editor.ui
@@ -104,28 +104,84 @@
               <object class="GtkBox" id="text_page_box">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="valign">start</property>
                 <property name="hexpand">True</property>
                 <property name="border_width">6</property>
                 <property name="orientation">vertical</property>
                 <property name="spacing">12</property>
                 <child>
-                  <object class="GtkFrame" id="frame9">
+                  <object class="GtkFrame" id="frame5">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
                     <property name="label_xalign">0</property>
                     <property name="shadow_type">none</property>
                     <child>
-                      <object class="GtkAlignment" id="alignment10">
+                      <object class="GtkAlignment" id="alignment5">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
                         <property name="left_padding">12</property>
                         <child>
-                          <object class="GtkBox" id="box2">
+                          <object class="GtkGrid" id="grid5">
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
-                            <property name="orientation">vertical</property>
-                            <property name="spacing">6</property>
+                            <property name="border_width">3</property>
+                            <property name="row_spacing">6</property>
+                            <property name="column_spacing">9</property>
+                            <child>
+                              <object class="GtkLabel" id="label14">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="halign">start</property>
+                                <property name="label" translatable="yes">Family:</property>
+                              </object>
+                              <packing>
+                                <property name="left_attach">0</property>
+                                <property name="top_attach">0</property>
+                                <property name="width">1</property>
+                                <property name="height">1</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkLabel" id="label11">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="halign">start</property>
+                                <property name="label" translatable="yes">Size:</property>
+                              </object>
+                              <packing>
+                                <property name="left_attach">0</property>
+                                <property name="top_attach">1</property>
+                                <property name="width">1</property>
+                                <property name="height">1</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkLabel" id="label15">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="halign">start</property>
+                                <property name="label" translatable="yes">Style:</property>
+                              </object>
+                              <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>
+                              <object class="GtkLabel" id="label16">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="halign">start</property>
+                                <property name="label" translatable="yes">Color:</property>
+                              </object>
+                              <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>
                               <object class="GtkBox" id="box3">
                                 <property name="visible">True</property>
@@ -146,6 +202,19 @@
                                     <property name="position">0</property>
                                   </packing>
                                 </child>
+                              </object>
+                              <packing>
+                                <property name="left_attach">1</property>
+                                <property name="top_attach">0</property>
+                                <property name="width">1</property>
+                                <property name="height">1</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkBox" id="box10">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="spacing">3</property>
                                 <child>
                                   <object class="GtkSpinButton" id="text_font_size_spin">
                                     <property name="visible">True</property>
@@ -153,6 +222,7 @@
                                     <property name="has_tooltip">True</property>
                                     <property name="tooltip_markup" translatable="yes">Font size</property>
                                     <property name="tooltip_text" translatable="yes">Font size</property>
+                                    <property name="halign">start</property>
                                     <property name="invisible_char">â</property>
                                     <property name="invisible_char_set">True</property>
                                     <property name="progress_pulse_step">0.5</property>
@@ -162,15 +232,16 @@
                                   </object>
                                   <packing>
                                     <property name="expand">False</property>
-                                    <property name="fill">True</property>
-                                    <property name="position">1</property>
+                                    <property name="fill">False</property>
+                                    <property name="position">0</property>
                                   </packing>
                                 </child>
                               </object>
                               <packing>
-                                <property name="expand">False</property>
-                                <property name="fill">True</property>
-                                <property name="position">0</property>
+                                <property name="left_attach">1</property>
+                                <property name="top_attach">1</property>
+                                <property name="width">1</property>
+                                <property name="height">1</property>
                               </packing>
                             </child>
                             <child>
@@ -223,7 +294,7 @@
                                   <packing>
                                     <property name="expand">False</property>
                                     <property name="fill">True</property>
-                                    <property name="position">1</property>
+                                    <property name="position">2</property>
                                   </packing>
                                 </child>
                                 <child>
@@ -247,9 +318,22 @@
                                   <packing>
                                     <property name="expand">False</property>
                                     <property name="fill">True</property>
-                                    <property name="position">2</property>
+                                    <property name="position">3</property>
                                   </packing>
                                 </child>
+                              </object>
+                              <packing>
+                                <property name="left_attach">1</property>
+                                <property name="top_attach">2</property>
+                                <property name="width">1</property>
+                                <property name="height">1</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkBox" id="box11">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="spacing">3</property>
                                 <child>
                                   <object class="GtkBox" id="text_color_box">
                                     <property name="visible">True</property>
@@ -262,14 +346,15 @@
                                   <packing>
                                     <property name="expand">False</property>
                                     <property name="fill">True</property>
-                                    <property name="position">3</property>
+                                    <property name="position">0</property>
                                   </packing>
                                 </child>
                               </object>
                               <packing>
-                                <property name="expand">False</property>
-                                <property name="fill">True</property>
-                                <property name="position">1</property>
+                                <property name="left_attach">1</property>
+                                <property name="top_attach">3</property>
+                                <property name="width">1</property>
+                                <property name="height">1</property>
                               </packing>
                             </child>
                           </object>
@@ -277,10 +362,10 @@
                       </object>
                     </child>
                     <child type="label">
-                      <object class="GtkLabel" id="label13">
+                      <object class="GtkLabel" id="label19">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="label" translatable="yes">&lt;b&gt;Font/Appearance&lt;/b&gt;</property>
+                        <property name="label" translatable="yes">&lt;b&gt;Font&lt;/b&gt;</property>
                         <property name="use_markup">True</property>
                       </object>
                     </child>
@@ -292,234 +377,272 @@
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkFrame" id="frame6">
+                  <object class="GtkFrame" id="frame7">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
                     <property name="label_xalign">0</property>
                     <property name="shadow_type">none</property>
                     <child>
-                      <object class="GtkAlignment" id="alignment7">
+                      <object class="GtkAlignment" id="alignment8">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
                         <property name="left_padding">12</property>
                         <child>
-                          <object class="GtkBox" id="box4">
+                          <object class="GtkGrid" id="grid6">
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
-                            <property name="spacing">12</property>
+                            <property name="border_width">3</property>
+                            <property name="row_spacing">6</property>
+                            <property name="column_spacing">9</property>
+                            <child>
+                              <object class="GtkLabel" id="label17">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="halign">start</property>
+                                <property name="label" translatable="yes">Alignment:</property>
+                              </object>
+                              <packing>
+                                <property name="left_attach">0</property>
+                                <property name="top_attach">0</property>
+                                <property name="width">1</property>
+                                <property name="height">1</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkLabel" id="label9">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="halign">start</property>
+                                <property name="label" translatable="yes">Line spacing:</property>
+                              </object>
+                              <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>
                               <object class="GtkBox" id="box5">
                                 <property name="visible">True</property>
                                 <property name="can_focus">False</property>
-                                <property name="spacing">3</property>
+                                <property name="spacing">12</property>
                                 <child>
-                                  <object class="GtkToggleButton" id="text_halign_left_toggle">
-                                    <property name="use_action_appearance">False</property>
+                                  <object class="GtkBox" id="box6">
                                     <property name="visible">True</property>
-                                    <property name="can_focus">True</property>
-                                    <property name="receives_default">True</property>
-                                    <property name="use_action_appearance">False</property>
+                                    <property name="can_focus">False</property>
+                                    <property name="spacing">3</property>
                                     <child>
-                                      <object class="GtkImage" id="image4">
+                                      <object class="GtkToggleButton" id="text_halign_left_toggle">
+                                        <property name="use_action_appearance">False</property>
                                         <property name="visible">True</property>
-                                        <property name="can_focus">False</property>
-                                        <property name="stock">gtk-justify-left</property>
+                                        <property name="can_focus">True</property>
+                                        <property name="receives_default">True</property>
+                                        <property name="use_action_appearance">False</property>
+                                        <child>
+                                          <object class="GtkImage" id="image4">
+                                            <property name="visible">True</property>
+                                            <property name="can_focus">False</property>
+                                            <property name="stock">gtk-justify-left</property>
+                                          </object>
+                                        </child>
                                       </object>
+                                      <packing>
+                                        <property name="expand">False</property>
+                                        <property name="fill">True</property>
+                                        <property name="position">0</property>
+                                      </packing>
                                     </child>
-                                  </object>
-                                  <packing>
-                                    <property name="expand">False</property>
-                                    <property name="fill">True</property>
-                                    <property name="position">0</property>
-                                  </packing>
-                                </child>
-                                <child>
-                                  <object class="GtkToggleButton" id="text_halign_center_toggle">
-                                    <property name="use_action_appearance">False</property>
-                                    <property name="visible">True</property>
-                                    <property name="can_focus">True</property>
-                                    <property name="receives_default">True</property>
-                                    <property name="use_action_appearance">False</property>
                                     <child>
-                                      <object class="GtkImage" id="image5">
+                                      <object class="GtkToggleButton" id="text_halign_center_toggle">
+                                        <property name="use_action_appearance">False</property>
                                         <property name="visible">True</property>
-                                        <property name="can_focus">False</property>
-                                        <property name="stock">gtk-justify-center</property>
+                                        <property name="can_focus">True</property>
+                                        <property name="receives_default">True</property>
+                                        <property name="use_action_appearance">False</property>
+                                        <child>
+                                          <object class="GtkImage" id="image5">
+                                            <property name="visible">True</property>
+                                            <property name="can_focus">False</property>
+                                            <property name="stock">gtk-justify-center</property>
+                                          </object>
+                                        </child>
                                       </object>
+                                      <packing>
+                                        <property name="expand">False</property>
+                                        <property name="fill">True</property>
+                                        <property name="position">2</property>
+                                      </packing>
                                     </child>
-                                  </object>
-                                  <packing>
-                                    <property name="expand">False</property>
-                                    <property name="fill">True</property>
-                                    <property name="position">1</property>
-                                  </packing>
-                                </child>
-                                <child>
-                                  <object class="GtkToggleButton" id="text_halign_right_toggle">
-                                    <property name="use_action_appearance">False</property>
-                                    <property name="visible">True</property>
-                                    <property name="can_focus">True</property>
-                                    <property name="receives_default">True</property>
-                                    <property name="use_action_appearance">False</property>
                                     <child>
-                                      <object class="GtkImage" id="image6">
+                                      <object class="GtkToggleButton" id="text_halign_right_toggle">
+                                        <property name="use_action_appearance">False</property>
                                         <property name="visible">True</property>
-                                        <property name="can_focus">False</property>
-                                        <property name="stock">gtk-justify-right</property>
+                                        <property name="can_focus">True</property>
+                                        <property name="receives_default">True</property>
+                                        <property name="use_action_appearance">False</property>
+                                        <child>
+                                          <object class="GtkImage" id="image6">
+                                            <property name="visible">True</property>
+                                            <property name="can_focus">False</property>
+                                            <property name="stock">gtk-justify-right</property>
+                                          </object>
+                                        </child>
                                       </object>
+                                      <packing>
+                                        <property name="expand">False</property>
+                                        <property name="fill">True</property>
+                                        <property name="position">3</property>
+                                      </packing>
                                     </child>
                                   </object>
                                   <packing>
                                     <property name="expand">False</property>
                                     <property name="fill">True</property>
-                                    <property name="position">2</property>
+                                    <property name="position">0</property>
                                   </packing>
                                 </child>
                               </object>
                               <packing>
-                                <property name="expand">False</property>
-                                <property name="fill">True</property>
-                                <property name="position">0</property>
+                                <property name="left_attach">1</property>
+                                <property name="top_attach">0</property>
+                                <property name="width">1</property>
+                                <property name="height">1</property>
                               </packing>
                             </child>
                             <child>
-                              <object class="GtkBox" id="box6">
+                              <object class="GtkBox" id="box13">
                                 <property name="visible">True</property>
                                 <property name="can_focus">False</property>
-                                <property name="spacing">3</property>
+                                <property name="spacing">12</property>
                                 <child>
-                                  <object class="GtkToggleButton" id="text_valign_top_toggle">
-                                    <property name="use_action_appearance">False</property>
+                                  <object class="GtkBox" id="box15">
                                     <property name="visible">True</property>
-                                    <property name="can_focus">True</property>
-                                    <property name="receives_default">True</property>
-                                    <property name="use_action_appearance">False</property>
+                                    <property name="can_focus">False</property>
+                                    <property name="spacing">3</property>
                                     <child>
-                                      <object class="GtkImage" id="image7">
+                                      <object class="GtkToggleButton" id="text_valign_top_toggle1">
+                                        <property name="use_action_appearance">False</property>
                                         <property name="visible">True</property>
-                                        <property name="can_focus">False</property>
-                                        <property name="icon_name">glabels-align-text-top</property>
+                                        <property name="can_focus">True</property>
+                                        <property name="receives_default">True</property>
+                                        <property name="use_action_appearance">False</property>
+                                        <child>
+                                          <object class="GtkImage" id="image13">
+                                            <property name="visible">True</property>
+                                            <property name="can_focus">False</property>
+                                            <property name="icon_name">glabels-align-text-top</property>
+                                          </object>
+                                        </child>
                                       </object>
+                                      <packing>
+                                        <property name="expand">False</property>
+                                        <property name="fill">True</property>
+                                        <property name="position">0</property>
+                                      </packing>
                                     </child>
-                                  </object>
-                                  <packing>
-                                    <property name="expand">False</property>
-                                    <property name="fill">True</property>
-                                    <property name="position">0</property>
-                                  </packing>
-                                </child>
-                                <child>
-                                  <object class="GtkToggleButton" id="text_valign_middle_toggle">
-                                    <property name="use_action_appearance">False</property>
-                                    <property name="visible">True</property>
-                                    <property name="can_focus">True</property>
-                                    <property name="receives_default">True</property>
-                                    <property name="use_action_appearance">False</property>
                                     <child>
-                                      <object class="GtkImage" id="image8">
+                                      <object class="GtkToggleButton" id="text_valign_middle_toggle1">
+                                        <property name="use_action_appearance">False</property>
                                         <property name="visible">True</property>
-                                        <property name="can_focus">False</property>
-                                        <property name="icon_name">glabels-align-text-middle</property>
+                                        <property name="can_focus">True</property>
+                                        <property name="receives_default">True</property>
+                                        <property name="use_action_appearance">False</property>
+                                        <child>
+                                          <object class="GtkImage" id="image14">
+                                            <property name="visible">True</property>
+                                            <property name="can_focus">False</property>
+                                            <property name="icon_name">glabels-align-text-middle</property>
+                                          </object>
+                                        </child>
                                       </object>
+                                      <packing>
+                                        <property name="expand">False</property>
+                                        <property name="fill">True</property>
+                                        <property name="position">2</property>
+                                      </packing>
+                                    </child>
+                                    <child>
+                                      <object class="GtkToggleButton" id="text_valign_bottom_toggle1">
+                                        <property name="use_action_appearance">False</property>
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">True</property>
+                                        <property name="receives_default">True</property>
+                                        <property name="use_action_appearance">False</property>
+                                        <child>
+                                          <object class="GtkImage" id="image15">
+                                            <property name="visible">True</property>
+                                            <property name="can_focus">False</property>
+                                            <property name="icon_name">glabels-align-text-bottom</property>
+                                          </object>
+                                        </child>
+                                      </object>
+                                      <packing>
+                                        <property name="expand">False</property>
+                                        <property name="fill">True</property>
+                                        <property name="position">3</property>
+                                      </packing>
                                     </child>
                                   </object>
                                   <packing>
                                     <property name="expand">False</property>
                                     <property name="fill">True</property>
-                                    <property name="position">1</property>
+                                    <property name="position">0</property>
                                   </packing>
                                 </child>
+                              </object>
+                              <packing>
+                                <property name="left_attach">1</property>
+                                <property name="top_attach">1</property>
+                                <property name="width">1</property>
+                                <property name="height">1</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkBox" id="box7">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="spacing">3</property>
                                 <child>
-                                  <object class="GtkToggleButton" id="text_valign_bottom_toggle">
-                                    <property name="use_action_appearance">False</property>
+                                  <object class="GtkSpinButton" id="text_line_spacing_spin">
                                     <property name="visible">True</property>
                                     <property name="can_focus">True</property>
-                                    <property name="receives_default">True</property>
-                                    <property name="use_action_appearance">False</property>
-                                    <child>
-                                      <object class="GtkImage" id="image9">
-                                        <property name="visible">True</property>
-                                        <property name="can_focus">False</property>
-                                        <property name="icon_name">glabels-align-text-bottom</property>
-                                      </object>
-                                    </child>
+                                    <property name="has_tooltip">True</property>
+                                    <property name="tooltip_markup" translatable="yes">Line spacing</property>
+                                    <property name="tooltip_text" translatable="yes">Line spacing</property>
+                                    <property name="invisible_char">â</property>
+                                    <property name="invisible_char_set">True</property>
+                                    <property name="progress_pulse_step">0.10000000149011612</property>
+                                    <property name="adjustment">line_spacing_adjustment</property>
+                                    <property name="digits">1</property>
+                                    <property name="numeric">True</property>
                                   </object>
                                   <packing>
                                     <property name="expand">False</property>
                                     <property name="fill">True</property>
-                                    <property name="position">2</property>
+                                    <property name="position">0</property>
                                   </packing>
                                 </child>
                               </object>
                               <packing>
-                                <property name="expand">False</property>
-                                <property name="fill">True</property>
-                                <property name="position">1</property>
+                                <property name="left_attach">1</property>
+                                <property name="top_attach">2</property>
+                                <property name="width">1</property>
+                                <property name="height">1</property>
                               </packing>
                             </child>
-                          </object>
-                        </child>
-                      </object>
-                    </child>
-                    <child type="label">
-                      <object class="GtkLabel" id="label10">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="label" translatable="yes">&lt;b&gt;Alignment&lt;/b&gt;</property>
-                        <property name="use_markup">True</property>
-                      </object>
-                    </child>
-                  </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">True</property>
-                    <property name="position">1</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkFrame" id="frame7">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="label_xalign">0</property>
-                    <property name="shadow_type">none</property>
-                    <child>
-                      <object class="GtkAlignment" id="alignment8">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="left_padding">12</property>
-                        <child>
-                          <object class="GtkBox" id="box7">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
                             <child>
-                              <object class="GtkSpinButton" id="text_line_spacing_spin">
-                                <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="has_tooltip">True</property>
-                                <property name="tooltip_markup" translatable="yes">Font size</property>
-                                <property name="tooltip_text" translatable="yes">Line spacing</property>
-                                <property name="invisible_char">â</property>
-                                <property name="invisible_char_set">True</property>
-                                <property name="progress_pulse_step">0.10000000149011612</property>
-                                <property name="adjustment">line_spacing_adjustment</property>
-                                <property name="digits">1</property>
-                                <property name="numeric">True</property>
-                              </object>
-                              <packing>
-                                <property name="expand">False</property>
-                                <property name="fill">True</property>
-                                <property name="position">0</property>
-                              </packing>
+                              <placeholder/>
                             </child>
                           </object>
                         </child>
                       </object>
                     </child>
                     <child type="label">
-                      <object class="GtkLabel" id="label11">
+                      <object class="GtkLabel" id="label20">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="label" translatable="yes">&lt;b&gt;Line spacing&lt;/b&gt;</property>
+                        <property name="label" translatable="yes">&lt;b&gt;Layout&lt;/b&gt;</property>
                         <property name="use_markup">True</property>
                       </object>
                     </child>
@@ -527,7 +650,7 @@
                   <packing>
                     <property name="expand">False</property>
                     <property name="fill">True</property>
-                    <property name="position">3</property>
+                    <property name="position">1</property>
                   </packing>
                 </child>
                 <child>
@@ -546,6 +669,7 @@
                           <object class="GtkBox" id="box8">
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
+                            <property name="border_width">3</property>
                             <property name="orientation">vertical</property>
                             <property name="spacing">6</property>
                             <child>
@@ -615,7 +739,7 @@
                   <packing>
                     <property name="expand">True</property>
                     <property name="fill">True</property>
-                    <property name="position">4</property>
+                    <property name="position">3</property>
                   </packing>
                 </child>
               </object>
@@ -1429,6 +1553,7 @@
   <object class="GtkSizeGroup" id="page_sizegroup">
     <property name="mode">both</property>
     <widgets>
+      <widget name="text_page_box"/>
       <widget name="line_fill_page_box"/>
       <widget name="pos_size_page_box"/>
       <widget name="shadow_page_box"/>
diff --git a/glabels/label_object_text.vala b/glabels/label_object_text.vala
index 4cb0146..a746021 100644
--- a/glabels/label_object_text.vala
+++ b/glabels/label_object_text.vala
@@ -35,6 +35,8 @@ namespace glabels
 		private const double SELECTION_SLOP_PIXELS = 4.0;
 		private const double TEXT_MARGIN = 3.0;
 
+		private const Color  EMPTY_TEXT_COLOR = { 0.5, 0.5, 0.5, 0.5 };
+
 		public bool auto_shrink { get; set; default = false; }
 
 
@@ -78,14 +80,21 @@ namespace glabels
 
 		public override void draw_object( Cairo.Context cr, bool in_editor, MergeRecord? record )
 		{
-			Color text_color = text_color_node.expand( record );
-
-			if ( in_editor && text_color_node.field_flag )
+			if ( in_editor && (buffer.get_char_count() == 0) )
 			{
-				text_color = Color.from_rgba( 0, 0, 0, 0.5 );
+				draw_empty_text( cr );
 			}
+			else
+			{
+				Color text_color = text_color_node.expand( record );
+
+				if ( in_editor && text_color_node.field_flag )
+				{
+					text_color = Color.from_rgba( 0, 0, 0, 0.5 );
+				}
 
-			draw_text_real( cr, in_editor, record, text_color );
+				draw_text_real( cr, in_editor, record, text_color );
+			}
 		}
 
 
@@ -104,9 +113,18 @@ namespace glabels
 		}
 
 
+		private void draw_empty_text( Cairo.Context cr )
+		{
+			set_empty_text_path( cr );
+
+			cr.set_source_rgba( EMPTY_TEXT_COLOR.r, EMPTY_TEXT_COLOR.g, EMPTY_TEXT_COLOR.b, EMPTY_TEXT_COLOR.a );
+			cr.fill();
+		}
+
+
 		private void draw_text_real( Cairo.Context cr, bool in_editor, MergeRecord? record, Color color )
 		{
-			set_text_path( cr, in_editor, record);
+			set_text_path( cr, in_editor, record );
 
 			cr.set_source_rgba( color.r, color.g, color.b, color.a );
 			cr.fill();
@@ -118,7 +136,14 @@ namespace glabels
 			if ( (x >= 0) && (x <= w) && (y >=0) && (y <= h) )
 			{
 				cr.new_path();
-				set_text_path( cr, true, null);
+				if ( buffer.get_char_count() == 0 )
+				{
+					set_empty_text_path( cr );
+				}
+				else
+				{
+					set_text_path( cr, true, null);
+				}
 				if ( cr.in_fill( x, y ) )
 				{
 					return true;
@@ -201,6 +226,33 @@ namespace glabels
 		}
 
 
+		private void set_empty_text_path( Cairo.Context cr )
+		{
+			cr.save();
+
+			Pango.Layout layout = Pango.cairo_create_layout( cr );
+
+			Cairo.FontOptions font_options = new Cairo.FontOptions();
+			font_options.set_hint_metrics( Cairo.HintMetrics.OFF );
+			Pango.Context context = layout.get_context();
+			Pango.cairo_context_set_font_options( context, font_options );
+
+			Pango.FontDescription desc = new Pango.FontDescription();
+			desc.set_family( "Sans" );
+			desc.set_weight( Pango.Weight.NORMAL );
+			desc.set_size( (int)(12 * FONT_SCALE * Pango.SCALE) );
+			desc.set_style( Pango.Style.NORMAL );
+			layout.set_font_description( desc );
+
+			layout.set_text( _("Text"), -1 );
+
+			cr.move_to( TEXT_MARGIN, 0 );
+			Pango.cairo_layout_path( cr, layout );
+
+			cr.restore();
+		}
+
+
 		private double auto_shrink_font_size( Cairo.Context cr,
 		                                      string        family,
 		                                      double        size,
diff --git a/glabels/object_editor.vala b/glabels/object_editor.vala
index f9faccc..060878d 100644
--- a/glabels/object_editor.vala
+++ b/glabels/object_editor.vala
@@ -314,7 +314,7 @@ namespace glabels
 
 				if ( object is LabelObjectText  )
 				{
-					title_image.set_from_icon_name( "glabels-box", Gtk.IconSize.LARGE_TOOLBAR );
+					title_image.set_from_icon_name( "glabels-text", Gtk.IconSize.LARGE_TOOLBAR );
 					title_label.set_text( "<b>%s</b>".printf( _("Text object properties") ) );
 
 					text_page_box.show_all();
diff --git a/glabels/view.vala b/glabels/view.vala
index c4505ef..c01e5a8 100644
--- a/glabels/view.vala
+++ b/glabels/view.vala
@@ -1008,6 +1008,9 @@ namespace glabels
 						create_object.set_size( 0, 0 );
 						model.label.add_object( create_object );
 
+						model.label.unselect_all();
+						model.label.select_object( create_object );
+
 						create_x0 = x;
 						create_y0 = y;
 
@@ -1098,8 +1101,10 @@ namespace glabels
 					Gdk.Cursor cursor = new Gdk.Cursor( Gdk.CursorType.LEFT_PTR );
 					window.set_cursor( cursor );
 
-					model.label.unselect_all();
-					model.label.select_object( create_object );
+					if ( (create_object.w < 2) && (create_object.h < 2) )
+					{
+						create_object.set_size( 72, 72 );
+					}
 
 					in_object_create_mode = false;
 					state = State.IDLE;



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