[meld] Use two checkboxes for wrapping options instead of OptionMenu



commit 75d39907e217a5c7dd483a29ed6666eddbd06d26
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Sat Oct 10 18:19:56 2009 +1000

    Use two checkboxes for wrapping options instead of OptionMenu
    
    Taking inspiration from gEdit, this commit uses two checkboxes instead
    of an OptionMenu to provide line wrapping options. This allows for
    clearer labeling of the options. Also, OptionMenu is deprecated.

 data/ui/preferences.glade |   54 +++++++++++++++++++++++---------------------
 meld/preferences.py       |   21 +++++++++++++++--
 2 files changed, 46 insertions(+), 29 deletions(-)
---
diff --git a/data/ui/preferences.glade b/data/ui/preferences.glade
index 5965d41..5a6143c 100644
--- a/data/ui/preferences.glade
+++ b/data/ui/preferences.glade
@@ -139,7 +139,7 @@
                       <widget class="GtkLabel" id="label34">
                         <property name="visible">True</property>
                         <property name="xalign">0</property>
-                        <property name="label" translatable="yes">&lt;b&gt;Misc&lt;/b&gt;</property>
+                        <property name="label" translatable="yes">&lt;b&gt;Display&lt;/b&gt;</property>
                         <property name="use_markup">True</property>
                       </widget>
                       <packing>
@@ -219,37 +219,39 @@
                               </packing>
                             </child>
                             <child>
-                              <widget class="GtkHBox" id="hbox38">
+                              <widget class="GtkCheckButton" id="checkbutton_wrap_text">
+                                <property name="label" translatable="yes">Enable text _wrapping</property>
                                 <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="use_underline">True</property>
+                                <property name="draw_indicator">True</property>
+                                <signal name="toggled" handler="on_checkbutton_wrap_text_toggled"/>
+                              </widget>
+                              <packing>
+                                <property name="position">3</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <widget class="GtkAlignment" id="alignment1">
+                                <property name="visible">True</property>
+                                <property name="left_padding">18</property>
                                 <child>
-                                  <widget class="GtkLabel" id="label85">
-                                    <property name="visible">True</property>
-                                    <property name="label" translatable="yes">Line Wrapping </property>
-                                  </widget>
-                                  <packing>
-                                    <property name="expand">False</property>
-                                    <property name="fill">False</property>
-                                    <property name="position">0</property>
-                                  </packing>
-                                </child>
-                                <child>
-                                  <widget class="GtkOptionMenu" id="option_wrap_lines">
+                                  <widget class="GtkCheckButton" id="checkbutton_split_words">
+                                    <property name="label" translatable="yes">Do not _split words over two lines</property>
                                     <property name="visible">True</property>
+                                    <property name="sensitive">False</property>
                                     <property name="can_focus">True</property>
                                     <property name="receives_default">False</property>
-                                    <signal name="changed" handler="on_option_wrap_lines_changed"/>
+                                    <property name="use_underline">True</property>
+                                    <property name="active">True</property>
+                                    <property name="draw_indicator">True</property>
+                                    <signal name="toggled" handler="on_checkbutton_wrap_text_toggled"/>
                                   </widget>
-                                  <packing>
-                                    <property name="expand">False</property>
-                                    <property name="fill">False</property>
-                                    <property name="position">1</property>
-                                  </packing>
                                 </child>
                               </widget>
                               <packing>
-                                <property name="expand">False</property>
-                                <property name="fill">False</property>
-                                <property name="position">2</property>
+                                <property name="position">3</property>
                               </packing>
                             </child>
                             <child>
@@ -265,7 +267,7 @@
                               <packing>
                                 <property name="expand">False</property>
                                 <property name="fill">False</property>
-                                <property name="position">3</property>
+                                <property name="position">4</property>
                               </packing>
                             </child>
                             <child>
@@ -281,7 +283,7 @@
                               <packing>
                                 <property name="expand">False</property>
                                 <property name="fill">False</property>
-                                <property name="position">4</property>
+                                <property name="position">5</property>
                               </packing>
                             </child>
                             <child>
@@ -297,7 +299,7 @@
                               <packing>
                                 <property name="expand">False</property>
                                 <property name="fill">False</property>
-                                <property name="position">5</property>
+                                <property name="position">6</property>
                               </packing>
                             </child>
                           </widget>
diff --git a/meld/preferences.py b/meld/preferences.py
index 0ae4a00..296f278 100644
--- a/meld/preferences.py
+++ b/meld/preferences.py
@@ -145,7 +145,12 @@ class PreferencesDialog(gnomeglade.Component):
                 self.checkbutton_spaces_instead_of_tabs.set_tooltip_text(no_sourceview_text)
                 self.checkbutton_show_line_numbers.set_tooltip_text(no_sourceview_text)
                 self.checkbutton_use_syntax_highlighting.set_tooltip_text(no_sourceview_text)
-        self.option_wrap_lines.set_history( self.prefs.edit_wrap_lines )
+        # TODO: This doesn't restore the state of character wrapping when word
+        # wrapping is disabled, but this is hard with our existing gconf keys
+        if self.prefs.edit_wrap_lines != gtk.WRAP_NONE:
+            if self.prefs.edit_wrap_lines == gtk.WRAP_CHAR:
+                self.checkbutton_split_words.set_active(False)
+            self.checkbutton_wrap_text.set_active(True)
         self.checkbutton_supply_newline.set_active( self.prefs.supply_newline )
         self.editor_command[ self.editor_radio_values.get(self.prefs.edit_command_type, "internal") ].set_active(1)
         self.gnome_default_editor_label.set_text( "(%s)" % " ".join(self.prefs.get_gnome_editor_command([])) )
@@ -176,8 +181,18 @@ class PreferencesDialog(gnomeglade.Component):
         self.prefs.tab_size = int(spin.get_value())
     def on_checkbutton_spaces_instead_of_tabs_toggled(self, check):
         self.prefs.spaces_instead_of_tabs = check.get_active()
-    def on_option_wrap_lines_changed(self, option):
-        self.prefs.edit_wrap_lines = option.get_history()
+
+    def on_checkbutton_wrap_text_toggled(self, button):
+        if not self.checkbutton_wrap_text.get_active():
+            self.prefs.edit_wrap_lines = 0
+            self.checkbutton_split_words.set_sensitive(False)
+        else:
+            self.checkbutton_split_words.set_sensitive(True)
+            if self.checkbutton_split_words.get_active():
+                self.prefs.edit_wrap_lines = 2
+            else:
+                self.prefs.edit_wrap_lines = 1
+
     def on_checkbutton_supply_newline_toggled(self, check):
         self.prefs.supply_newline = check.get_active()
     def on_checkbutton_show_line_numbers_toggled(self, check):



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