[meld] Add a new editable list widget, replacing old preference list



commit 65238163f6453d8f99d43fcd8a5f78544d17e4c4
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Sun Jan 9 08:09:53 2011 +1000

    Add a new editable list widget, replacing old preference list
    
    This commit adds a new editable list widget, adapted from:
      http://live.gnome.org/UsabilityProject/HIG3/EditableLists
    This widget is used in the preferences dialog in place of the old
    ListWidget, which has been removed.
    
    data/ui/EditableList.ui: New UI file, adapted from the HIG pattern
    data/ui/preferences.ui: Remove old list widget
    meld/ui/listwidget.py: Basic implementation of some common list logic,
                           taken from the existing ListWidget code
    meld/preferences.py: Create new FilterList derived from ListWidget

 data/ui/EditableList.ui |  233 +++++++++++++++++++++++++++++++
 data/ui/preferences.ui  |  354 +++++++++++++++++++++-------------------------
 meld/preferences.py     |  119 +++++------------
 meld/ui/listwidget.py   |   66 +++++++++
 4 files changed, 493 insertions(+), 279 deletions(-)
---
diff --git a/data/ui/EditableList.ui b/data/ui/EditableList.ui
new file mode 100644
index 0000000..36557af
--- /dev/null
+++ b/data/ui/EditableList.ui
@@ -0,0 +1,233 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <requires lib="gtk+" version="2.16"/>
+  <!-- interface-naming-policy project-wide -->
+  <object class="GtkListStore" id="EditableListStore">
+    <columns>
+      <!-- column-name Name -->
+      <column type="gchararray"/>
+      <!-- column-name Active -->
+      <column type="gboolean"/>
+      <!-- column-name Pattern -->
+      <column type="gchararray"/>
+    </columns>
+    <signal name="row-inserted" handler="_update_sensitivity" swapped="no"/>
+    <signal name="rows-reordered" handler="_update_sensitivity" swapped="no"/>
+  </object>
+  <object class="GtkWindow" id="EditableListWindow">
+    <property name="can_focus">False</property>
+    <property name="title" translatable="yes">Editable List</property>
+    <child>
+      <object class="GtkAlignment" id="list_alignment">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="top_padding">8</property>
+        <property name="bottom_padding">8</property>
+        <property name="left_padding">8</property>
+        <property name="right_padding">8</property>
+        <child>
+          <object class="GtkVBox" id="list_vbox">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <child>
+              <object class="GtkScrolledWindow" id="scrolledwindow1">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="hscrollbar_policy">automatic</property>
+                <property name="vscrollbar_policy">automatic</property>
+                <property name="shadow_type">in</property>
+                <child>
+                  <object class="GtkTreeView" id="EditableList">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="model">EditableListStore</property>
+                    <property name="headers_clickable">False</property>
+                    <property name="reorderable">True</property>
+                    <property name="search_column">0</property>
+                    <property name="show_expanders">False</property>
+                    <property name="rubber_banding">True</property>
+                    <child>
+                      <object class="GtkTreeViewColumn" id="treeviewcolumn1">
+                        <property name="title">Name</property>
+                        <child>
+                          <object class="GtkCellRendererText" id="cellrenderertext1">
+                            <property name="editable">True</property>
+                            <signal name="edited" handler="on_name_edited" swapped="no"/>
+                          </object>
+                          <attributes>
+                            <attribute name="text">0</attribute>
+                          </attributes>
+                        </child>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkTreeViewColumn" id="treeviewcolumn2">
+                        <property name="title" translatable="yes">Active</property>
+                        <child>
+                          <object class="GtkCellRendererToggle" id="cellrenderertoggle1">
+                            <signal name="toggled" handler="on_cellrenderertoggle_toggled" swapped="no"/>
+                          </object>
+                          <attributes>
+                            <attribute name="active">1</attribute>
+                          </attributes>
+                        </child>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkTreeViewColumn" id="treeviewcolumn3">
+                        <property name="title" translatable="yes">Pattern</property>
+                        <child>
+                          <object class="GtkCellRendererText" id="cellrenderertext2">
+                            <property name="editable">True</property>
+                            <signal name="edited" handler="on_pattern_edited" swapped="no"/>
+                          </object>
+                          <attributes>
+                            <attribute name="text">2</attribute>
+                          </attributes>
+                        </child>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">True</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkToolbar" id="list_toolbar">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="toolbar_style">icons</property>
+                <property name="show_arrow">False</property>
+                <property name="icon_size">1</property>
+                <property name="icon_size_set">True</property>
+                <child>
+                  <object class="GtkToolButton" id="add">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="tooltip_text" translatable="yes">Add new filter</property>
+                    <property name="use_action_appearance">False</property>
+                    <property name="label" translatable="yes">_Add</property>
+                    <property name="use_underline">True</property>
+                    <property name="icon_name">list-add</property>
+                    <signal name="clicked" handler="on_add_clicked" swapped="no"/>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="homogeneous">True</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkToolButton" id="remove">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="tooltip_text" translatable="yes">Remove selected filter</property>
+                    <property name="use_action_appearance">False</property>
+                    <property name="label" translatable="yes">_Remove</property>
+                    <property name="use_underline">True</property>
+                    <property name="icon_name">list-remove</property>
+                    <signal name="clicked" handler="on_remove_clicked" swapped="no"/>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="homogeneous">True</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkSeparatorToolItem" id="dup_edit_sep">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="homogeneous">True</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkToolButton" id="dup">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="tooltip_text" translatable="yes">Duplicate selected filter</property>
+                    <property name="use_action_appearance">False</property>
+                    <property name="label" translatable="yes">Du_plicate</property>
+                    <property name="use_underline">True</property>
+                    <property name="icon_name">edit-copy</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="homogeneous">True</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkToolButton" id="edit">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="tooltip_text" translatable="yes">Edit selected filter</property>
+                    <property name="use_action_appearance">False</property>
+                    <property name="label" translatable="yes">_Edit</property>
+                    <property name="use_underline">True</property>
+                    <property name="icon_name">gtk-edit</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="homogeneous">True</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkSeparatorToolItem" id="up_down_sep">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="homogeneous">True</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkToolButton" id="move_up">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="tooltip_text" translatable="yes">Move item up</property>
+                    <property name="use_action_appearance">False</property>
+                    <property name="label" translatable="yes">Move _Up</property>
+                    <property name="use_underline">True</property>
+                    <property name="icon_name">go-up</property>
+                    <signal name="clicked" handler="on_move_up_clicked" swapped="no"/>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="homogeneous">True</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkToolButton" id="move_down">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="tooltip_text" translatable="yes">Move item down</property>
+                    <property name="use_action_appearance">False</property>
+                    <property name="label" translatable="yes">Move _Down</property>
+                    <property name="use_underline">True</property>
+                    <property name="icon_name">go-down</property>
+                    <signal name="clicked" handler="on_move_down_clicked" swapped="no"/>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="homogeneous">True</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+        </child>
+      </object>
+    </child>
+  </object>
+</interface>
diff --git a/data/ui/preferences.ui b/data/ui/preferences.ui
index c689bf6..20b386c 100644
--- a/data/ui/preferences.ui
+++ b/data/ui/preferences.ui
@@ -1,42 +1,91 @@
-<?xml version="1.0"?>
+<?xml version="1.0" encoding="UTF-8"?>
 <interface>
+  <!-- interface-requires gtk+ 2.8 -->
+  <!-- interface-naming-policy toplevel-contextual -->
   <object class="GtkAdjustment" id="adjustment1">
-    <property name="upper">8</property>
     <property name="lower">1</property>
-    <property name="page_increment">10</property>
-    <property name="step_increment">1</property>
-    <property name="page_size">0</property>
+    <property name="upper">8</property>
     <property name="value">4</property>
+    <property name="step_increment">1</property>
+    <property name="page_increment">10</property>
   </object>
-  <!-- interface-requires gtk+ 2.8 -->
-  <!-- interface-naming-policy toplevel-contextual -->
   <object class="GtkDialog" id="preferencesdialog">
-    <property name="visible">False</property>
+    <property name="can_focus">False</property>
     <property name="border_width">5</property>
     <property name="title" translatable="yes">Meld Preferences</property>
     <property name="type_hint">dialog</property>
     <property name="has_separator">False</property>
-    <signal handler="on_response" name="response"/>
+    <signal name="response" handler="on_response" swapped="no"/>
     <child internal-child="vbox">
       <object class="GtkVBox" id="dialog-vbox4">
         <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <child internal-child="action_area">
+          <object class="GtkHButtonBox" id="dialog-action_area4">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="layout_style">end</property>
+            <child>
+              <object class="GtkButton" id="helpbutton1">
+                <property name="label">gtk-help</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="receives_default">False</property>
+                <property name="use_action_appearance">False</property>
+                <property name="use_stock">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="closebutton1">
+                <property name="label">gtk-close</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="receives_default">False</property>
+                <property name="use_action_appearance">False</property>
+                <property name="use_stock">True</property>
+                <accelerator key="Escape" signal="clicked"/>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="pack_type">end</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
         <child>
           <object class="GtkNotebook" id="notebook">
             <property name="visible">True</property>
+            <property name="can_focus">False</property>
             <property name="border_width">5</property>
             <property name="show_border">False</property>
             <child>
               <object class="GtkVBox" id="editor_tab">
                 <property name="visible">True</property>
+                <property name="can_focus">False</property>
                 <property name="border_width">12</property>
                 <property name="spacing">12</property>
                 <child>
                   <object class="GtkVBox" id="vbox20">
                     <property name="visible">True</property>
+                    <property name="can_focus">False</property>
                     <property name="spacing">6</property>
                     <child>
                       <object class="GtkLabel" id="label32">
                         <property name="visible">True</property>
+                        <property name="can_focus">False</property>
                         <property name="xalign">0</property>
                         <property name="label" translatable="yes">Font</property>
                         <property name="use_markup">True</property>
@@ -53,9 +102,11 @@
                     <child>
                       <object class="GtkHBox" id="hbox15">
                         <property name="visible">True</property>
+                        <property name="can_focus">False</property>
                         <child>
                           <object class="GtkLabel" id="label33">
                             <property name="visible">True</property>
+                            <property name="can_focus">False</property>
                           </object>
                           <packing>
                             <property name="expand">False</property>
@@ -67,6 +118,7 @@
                         <child>
                           <object class="GtkVBox" id="vbox10">
                             <property name="visible">True</property>
+                            <property name="can_focus">False</property>
                             <property name="spacing">6</property>
                             <child>
                               <object class="GtkCheckButton" id="checkbutton_default_font">
@@ -74,23 +126,27 @@
                                 <property name="visible">True</property>
                                 <property name="can_focus">True</property>
                                 <property name="receives_default">False</property>
+                                <property name="use_action_appearance">False</property>
                                 <property name="use_underline">True</property>
                                 <property name="active">True</property>
                                 <property name="draw_indicator">True</property>
-                                <signal handler="on_checkbutton_default_font_toggled" name="toggled"/>
+                                <signal name="toggled" handler="on_checkbutton_default_font_toggled" swapped="no"/>
                               </object>
                               <packing>
                                 <property name="expand">False</property>
+                                <property name="fill">True</property>
                                 <property name="position">0</property>
                               </packing>
                             </child>
                             <child>
                               <object class="GtkHBox" id="hbox5">
                                 <property name="visible">True</property>
+                                <property name="can_focus">False</property>
                                 <property name="spacing">6</property>
                                 <child>
                                   <object class="GtkLabel" id="label1">
                                     <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
                                     <property name="xalign">0</property>
                                     <property name="label" translatable="yes">_Editor font:</property>
                                     <property name="use_underline">True</property>
@@ -98,6 +154,7 @@
                                   </object>
                                   <packing>
                                     <property name="expand">False</property>
+                                    <property name="fill">True</property>
                                     <property name="position">0</property>
                                   </packing>
                                 </child>
@@ -106,42 +163,54 @@
                                     <property name="visible">True</property>
                                     <property name="can_focus">True</property>
                                     <property name="receives_default">False</property>
+                                    <property name="use_action_appearance">False</property>
                                     <property name="font_name">Monospace 12</property>
                                     <property name="use_font">True</property>
-                                    <signal handler="on_fontpicker_font_set" name="font_set"/>
+                                    <signal name="font-set" handler="on_fontpicker_font_set" swapped="no"/>
                                   </object>
                                   <packing>
+                                    <property name="expand">True</property>
+                                    <property name="fill">True</property>
                                     <property name="position">1</property>
                                   </packing>
                                 </child>
                               </object>
                               <packing>
+                                <property name="expand">True</property>
+                                <property name="fill">True</property>
                                 <property name="position">1</property>
                               </packing>
                             </child>
                           </object>
                           <packing>
+                            <property name="expand">True</property>
+                            <property name="fill">True</property>
                             <property name="position">1</property>
                           </packing>
                         </child>
                       </object>
                       <packing>
+                        <property name="expand">True</property>
+                        <property name="fill">True</property>
                         <property name="position">1</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="GtkVBox" id="vbox22">
                     <property name="visible">True</property>
+                    <property name="can_focus">False</property>
                     <property name="spacing">6</property>
                     <child>
                       <object class="GtkLabel" id="label34">
                         <property name="visible">True</property>
+                        <property name="can_focus">False</property>
                         <property name="xalign">0</property>
                         <property name="label" translatable="yes">Display</property>
                         <property name="use_markup">True</property>
@@ -158,9 +227,11 @@
                     <child>
                       <object class="GtkHBox" id="hbox17">
                         <property name="visible">True</property>
+                        <property name="can_focus">False</property>
                         <child>
                           <object class="GtkLabel" id="label35">
                             <property name="visible">True</property>
+                            <property name="can_focus">False</property>
                             <property name="xpad">12</property>
                           </object>
                           <packing>
@@ -172,14 +243,17 @@
                         <child>
                           <object class="GtkVBox" id="vbox23">
                             <property name="visible">True</property>
+                            <property name="can_focus">False</property>
                             <property name="spacing">6</property>
                             <child>
                               <object class="GtkHBox" id="hbox3">
                                 <property name="visible">True</property>
+                                <property name="can_focus">False</property>
                                 <property name="spacing">6</property>
                                 <child>
                                   <object class="GtkLabel" id="label16">
                                     <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
                                     <property name="xalign">0</property>
                                     <property name="label" translatable="yes">_Tab width:</property>
                                     <property name="use_underline">True</property>
@@ -197,7 +271,7 @@
                                     <property name="can_focus">True</property>
                                     <property name="adjustment">adjustment1</property>
                                     <property name="climb_rate">1</property>
-                                    <signal handler="on_spinbutton_tabsize_changed" name="changed"/>
+                                    <signal name="changed" handler="on_spinbutton_tabsize_changed" swapped="no"/>
                                   </object>
                                   <packing>
                                     <property name="expand">False</property>
@@ -218,9 +292,10 @@
                                 <property name="visible">True</property>
                                 <property name="can_focus">True</property>
                                 <property name="receives_default">False</property>
+                                <property name="use_action_appearance">False</property>
                                 <property name="use_underline">True</property>
                                 <property name="draw_indicator">True</property>
-                                <signal handler="on_checkbutton_spaces_instead_of_tabs_toggled" name="toggled"/>
+                                <signal name="toggled" handler="on_checkbutton_spaces_instead_of_tabs_toggled" swapped="no"/>
                               </object>
                               <packing>
                                 <property name="expand">False</property>
@@ -234,17 +309,21 @@
                                 <property name="visible">True</property>
                                 <property name="can_focus">True</property>
                                 <property name="receives_default">False</property>
+                                <property name="use_action_appearance">False</property>
                                 <property name="use_underline">True</property>
                                 <property name="draw_indicator">True</property>
-                                <signal handler="on_checkbutton_wrap_text_toggled" name="toggled"/>
+                                <signal name="toggled" handler="on_checkbutton_wrap_text_toggled" swapped="no"/>
                               </object>
                               <packing>
+                                <property name="expand">True</property>
+                                <property name="fill">True</property>
                                 <property name="position">3</property>
                               </packing>
                             </child>
                             <child>
                               <object class="GtkAlignment" id="alignment1">
                                 <property name="visible">True</property>
+                                <property name="can_focus">False</property>
                                 <property name="left_padding">18</property>
                                 <child>
                                   <object class="GtkCheckButton" id="checkbutton_split_words">
@@ -253,14 +332,17 @@
                                     <property name="sensitive">False</property>
                                     <property name="can_focus">True</property>
                                     <property name="receives_default">False</property>
+                                    <property name="use_action_appearance">False</property>
                                     <property name="use_underline">True</property>
                                     <property name="active">True</property>
                                     <property name="draw_indicator">True</property>
-                                    <signal handler="on_checkbutton_wrap_text_toggled" name="toggled"/>
+                                    <signal name="toggled" handler="on_checkbutton_wrap_text_toggled" swapped="no"/>
                                   </object>
                                 </child>
                               </object>
                               <packing>
+                                <property name="expand">True</property>
+                                <property name="fill">True</property>
                                 <property name="position">3</property>
                               </packing>
                             </child>
@@ -270,9 +352,10 @@
                                 <property name="visible">True</property>
                                 <property name="can_focus">True</property>
                                 <property name="receives_default">False</property>
+                                <property name="use_action_appearance">False</property>
                                 <property name="use_underline">True</property>
                                 <property name="draw_indicator">True</property>
-                                <signal handler="on_checkbutton_show_line_numbers_toggled" name="toggled"/>
+                                <signal name="toggled" handler="on_checkbutton_show_line_numbers_toggled" swapped="no"/>
                               </object>
                               <packing>
                                 <property name="expand">False</property>
@@ -286,9 +369,10 @@
                                 <property name="visible">True</property>
                                 <property name="can_focus">True</property>
                                 <property name="receives_default">False</property>
+                                <property name="use_action_appearance">False</property>
                                 <property name="use_underline">True</property>
                                 <property name="draw_indicator">True</property>
-                                <signal handler="on_checkbutton_show_whitespace_toggled" name="toggled"/>
+                                <signal name="toggled" handler="on_checkbutton_show_whitespace_toggled" swapped="no"/>
                               </object>
                               <packing>
                                 <property name="expand">False</property>
@@ -302,9 +386,10 @@
                                 <property name="visible">True</property>
                                 <property name="can_focus">True</property>
                                 <property name="receives_default">False</property>
+                                <property name="use_action_appearance">False</property>
                                 <property name="use_underline">True</property>
                                 <property name="draw_indicator">True</property>
-                                <signal handler="on_checkbutton_use_syntax_highlighting_toggled" name="toggled"/>
+                                <signal name="toggled" handler="on_checkbutton_use_syntax_highlighting_toggled" swapped="no"/>
                               </object>
                               <packing>
                                 <property name="expand">False</property>
@@ -315,28 +400,33 @@
                           </object>
                           <packing>
                             <property name="expand">False</property>
+                            <property name="fill">True</property>
                             <property name="position">1</property>
                           </packing>
                         </child>
                       </object>
                       <packing>
                         <property name="expand">False</property>
+                        <property name="fill">True</property>
                         <property name="position">1</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="GtkVBox" id="vbox42">
                     <property name="visible">True</property>
+                    <property name="can_focus">False</property>
                     <property name="spacing">6</property>
                     <child>
                       <object class="GtkLabel" id="label69">
                         <property name="visible">True</property>
+                        <property name="can_focus">False</property>
                         <property name="xalign">0</property>
                         <property name="label" translatable="yes">External editor</property>
                         <property name="use_markup">True</property>
@@ -353,9 +443,11 @@
                     <child>
                       <object class="GtkHBox" id="hbox34">
                         <property name="visible">True</property>
+                        <property name="can_focus">False</property>
                         <child>
                           <object class="GtkLabel" id="label70">
                             <property name="visible">True</property>
+                            <property name="can_focus">False</property>
                             <property name="xpad">12</property>
                           </object>
                           <packing>
@@ -367,6 +459,7 @@
                         <child>
                           <object class="GtkVBox" id="vbox43">
                             <property name="visible">True</property>
+                            <property name="can_focus">False</property>
                             <property name="spacing">6</property>
                             <child>
                               <object class="GtkCheckButton" id="system_editor_checkbutton">
@@ -374,21 +467,26 @@
                                 <property name="visible">True</property>
                                 <property name="can_focus">True</property>
                                 <property name="receives_default">False</property>
+                                <property name="use_action_appearance">False</property>
                                 <property name="use_underline">True</property>
                                 <property name="draw_indicator">True</property>
-                                <signal handler="on_system_editor_checkbutton_toggled" name="toggled"/>
+                                <signal name="toggled" handler="on_system_editor_checkbutton_toggled" swapped="no"/>
                               </object>
                               <packing>
+                                <property name="expand">True</property>
+                                <property name="fill">True</property>
                                 <property name="position">0</property>
                               </packing>
                             </child>
                             <child>
                               <object class="GtkHBox" id="hbox35">
                                 <property name="visible">True</property>
+                                <property name="can_focus">False</property>
                                 <property name="spacing">6</property>
                                 <child>
                                   <object class="GtkLabel" id="label2">
                                     <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
                                     <property name="xalign">0</property>
                                     <property name="label" translatable="yes">Edito_r command:</property>
                                     <property name="use_underline">True</property>
@@ -396,6 +494,7 @@
                                   </object>
                                   <packing>
                                     <property name="expand">False</property>
+                                    <property name="fill">True</property>
                                     <property name="position">0</property>
                                   </packing>
                                 </child>
@@ -403,11 +502,12 @@
                                   <object class="GtkEntry" id="custom_edit_command_entry">
                                     <property name="visible">True</property>
                                     <property name="can_focus">True</property>
-                                    <property name="invisible_char">*</property>
-                                    <signal handler="on_custom_edit_command_entry_activate" name="focus_out_event"/>
-                                    <signal handler="on_custom_edit_command_entry_activate" name="activate"/>
+                                    <signal name="focus-out-event" handler="on_custom_edit_command_entry_activate" swapped="no"/>
+                                    <signal name="activate" handler="on_custom_edit_command_entry_activate" swapped="no"/>
                                   </object>
                                   <packing>
+                                    <property name="expand">True</property>
+                                    <property name="fill">True</property>
                                     <property name="position">1</property>
                                   </packing>
                                 </child>
@@ -420,17 +520,22 @@
                             </child>
                           </object>
                           <packing>
+                            <property name="expand">True</property>
+                            <property name="fill">True</property>
                             <property name="position">1</property>
                           </packing>
                         </child>
                       </object>
                       <packing>
                         <property name="expand">False</property>
+                        <property name="fill">True</property>
                         <property name="position">1</property>
                       </packing>
                     </child>
                   </object>
                   <packing>
+                    <property name="expand">True</property>
+                    <property name="fill">True</property>
                     <property name="position">2</property>
                   </packing>
                 </child>
@@ -439,6 +544,7 @@
             <child type="tab">
               <object class="GtkLabel" id="editor_label">
                 <property name="visible">True</property>
+                <property name="can_focus">False</property>
                 <property name="label" translatable="yes">Editor</property>
               </object>
               <packing>
@@ -448,11 +554,13 @@
             <child>
               <object class="GtkVBox" id="file_filters_tab">
                 <property name="visible">True</property>
+                <property name="can_focus">False</property>
                 <property name="border_width">12</property>
                 <property name="spacing">12</property>
                 <child>
                   <object class="GtkLabel" id="label86">
                     <property name="visible">True</property>
+                    <property name="can_focus">False</property>
                     <property name="xalign">0</property>
                     <property name="label" translatable="yes">When performing directory comparisons, you may filter out files and directories by name. Each pattern is a list of shell style wildcards separated by spaces.</property>
                     <property name="wrap">True</property>
@@ -466,15 +574,17 @@
                 <child>
                   <object class="GtkHBox" id="hbox40">
                     <property name="visible">True</property>
+                    <property name="can_focus">False</property>
                     <child>
                       <object class="GtkCheckButton" id="checkbutton_ignore_symlinks">
                         <property name="label" translatable="yes">Ignore symbolic links</property>
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="receives_default">False</property>
+                        <property name="use_action_appearance">False</property>
                         <property name="use_underline">True</property>
                         <property name="draw_indicator">True</property>
-                        <signal handler="on_checkbutton_ignore_symlinks_toggled" name="toggled"/>
+                        <signal name="toggled" handler="on_checkbutton_ignore_symlinks_toggled" swapped="no"/>
                       </object>
                       <packing>
                         <property name="expand">False</property>
@@ -501,6 +611,7 @@
             <child type="tab">
               <object class="GtkLabel" id="filters_label">
                 <property name="visible">True</property>
+                <property name="can_focus">False</property>
                 <property name="label" translatable="yes">File Filters</property>
               </object>
               <packing>
@@ -511,11 +622,13 @@
             <child>
               <object class="GtkVBox" id="text_filters_tab">
                 <property name="visible">True</property>
+                <property name="can_focus">False</property>
                 <property name="border_width">12</property>
                 <property name="spacing">12</property>
                 <child>
                   <object class="GtkLabel" id="label87">
                     <property name="visible">True</property>
+                    <property name="can_focus">False</property>
                     <property name="xalign">0</property>
                     <property name="label" translatable="yes">When performing file comparisons, you may ignore certain types of changes. Each pattern here is a python regular expression which replaces matching text with the empty string before comparison is performed. If the expression contains groups, only the groups are replaced. See the user manual for more details.</property>
                     <property name="use_markup">True</property>
@@ -531,15 +644,17 @@
                 <child>
                   <object class="GtkHBox" id="hbox39">
                     <property name="visible">True</property>
+                    <property name="can_focus">False</property>
                     <child>
                       <object class="GtkCheckButton" id="checkbutton_ignore_blank_lines">
                         <property name="label" translatable="yes">Ignore changes which insert or delete blank lines</property>
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="receives_default">False</property>
+                        <property name="use_action_appearance">False</property>
                         <property name="use_underline">True</property>
                         <property name="draw_indicator">True</property>
-                        <signal handler="on_checkbutton_ignore_blank_lines_toggled" name="toggled"/>
+                        <signal name="toggled" handler="on_checkbutton_ignore_blank_lines_toggled" swapped="no"/>
                       </object>
                       <packing>
                         <property name="expand">False</property>
@@ -558,10 +673,14 @@
                   <placeholder/>
                 </child>
               </object>
+              <packing>
+                <property name="position">2</property>
+              </packing>
             </child>
             <child type="tab">
               <object class="GtkLabel" id="regex_label">
                 <property name="visible">True</property>
+                <property name="can_focus">False</property>
                 <property name="label" translatable="yes">Text Filters</property>
               </object>
               <packing>
@@ -572,15 +691,18 @@
             <child>
               <object class="GtkVBox" id="encoding_tab">
                 <property name="visible">True</property>
+                <property name="can_focus">False</property>
                 <property name="border_width">12</property>
                 <property name="spacing">12</property>
                 <child>
                   <object class="GtkVBox" id="vbox39">
                     <property name="visible">True</property>
+                    <property name="can_focus">False</property>
                     <property name="spacing">6</property>
                     <child>
                       <object class="GtkLabel" id="label52">
                         <property name="visible">True</property>
+                        <property name="can_focus">False</property>
                         <property name="xalign">0</property>
                         <property name="label" translatable="yes">Loading</property>
                         <property name="use_markup">True</property>
@@ -597,9 +719,11 @@
                     <child>
                       <object class="GtkHBox" id="hbox29">
                         <property name="visible">True</property>
+                        <property name="can_focus">False</property>
                         <child>
                           <object class="GtkLabel" id="label53">
                             <property name="visible">True</property>
+                            <property name="can_focus">False</property>
                             <property name="xpad">12</property>
                           </object>
                           <packing>
@@ -611,12 +735,15 @@
                         <child>
                           <object class="GtkVBox" id="vbox40">
                             <property name="visible">True</property>
+                            <property name="can_focus">False</property>
                             <child>
                               <object class="GtkVBox" id="vbox41">
                                 <property name="visible">True</property>
+                                <property name="can_focus">False</property>
                                 <child>
                                   <object class="GtkLabel" id="label55">
                                     <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
                                     <property name="xalign">0</property>
                                     <property name="xpad">4</property>
                                     <property name="ypad">4</property>
@@ -632,10 +759,9 @@
                                   <object class="GtkEntry" id="entry_text_codecs">
                                     <property name="visible">True</property>
                                     <property name="can_focus">True</property>
-                                    <property name="invisible_char">*</property>
                                     <property name="text">utf8 iso8859</property>
-                                    <signal handler="on_entry_text_codecs_activate" name="focus_out_event"/>
-                                    <signal handler="on_entry_text_codecs_activate" name="activate"/>
+                                    <signal name="focus-out-event" handler="on_entry_text_codecs_activate" swapped="no"/>
+                                    <signal name="activate" handler="on_entry_text_codecs_activate" swapped="no"/>
                                   </object>
                                   <packing>
                                     <property name="expand">False</property>
@@ -653,26 +779,33 @@
                           </object>
                           <packing>
                             <property name="expand">False</property>
+                            <property name="fill">True</property>
                             <property name="position">1</property>
                           </packing>
                         </child>
                       </object>
                       <packing>
                         <property name="expand">False</property>
+                        <property name="fill">True</property>
                         <property name="position">1</property>
                       </packing>
                     </child>
                   </object>
                   <packing>
                     <property name="expand">False</property>
+                    <property name="fill">True</property>
                     <property name="position">0</property>
                   </packing>
                 </child>
               </object>
+              <packing>
+                <property name="position">3</property>
+              </packing>
             </child>
             <child type="tab">
               <object class="GtkLabel" id="encoding_label">
                 <property name="visible">True</property>
+                <property name="can_focus">False</property>
                 <property name="label" translatable="yes">Encoding</property>
               </object>
               <packing>
@@ -682,46 +815,11 @@
             </child>
           </object>
           <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
             <property name="position">1</property>
           </packing>
         </child>
-        <child internal-child="action_area">
-          <object class="GtkHButtonBox" id="dialog-action_area4">
-            <property name="visible">True</property>
-            <property name="layout_style">end</property>
-            <child>
-              <object class="GtkButton" id="helpbutton1">
-                <property name="label">gtk-help</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="receives_default">False</property>
-                <property name="use_stock">True</property>
-              </object>
-              <packing>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkButton" id="closebutton1">
-                <property name="label">gtk-close</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="receives_default">False</property>
-                <property name="use_stock">True</property>
-                <accelerator key="Escape" signal="clicked"/>
-              </object>
-              <packing>
-                <property name="position">1</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="pack_type">end</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
       </object>
     </child>
     <action-widgets>
@@ -729,132 +827,4 @@
       <action-widget response="-7">closebutton1</action-widget>
     </action-widgets>
   </object>
-  <object class="GtkWindow" id="listwidgetcontainer">
-    <property name="visible">True</property>
-    <property name="title" translatable="yes">window1</property>
-    <child>
-      <object class="GtkTable" id="listwidget">
-        <property name="visible">True</property>
-        <property name="n_rows">3</property>
-        <property name="n_columns">2</property>
-        <child>
-          <object class="GtkButton" id="items_revert">
-            <property name="label">gtk-revert-to-saved</property>
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="receives_default">False</property>
-            <property name="use_stock">True</property>
-            <signal handler="on_items_revert_clicked" name="clicked"/>
-          </object>
-          <packing>
-            <property name="left_attach">1</property>
-            <property name="right_attach">2</property>
-            <property name="top_attach">2</property>
-            <property name="bottom_attach">3</property>
-            <property name="x_options">GTK_FILL</property>
-            <property name="y_options"/>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkVButtonBox" id="vbuttonbox2">
-            <property name="visible">True</property>
-            <child>
-              <object class="GtkButton" id="item_up">
-                <property name="label">gtk-go-up</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="receives_default">False</property>
-                <property name="use_stock">True</property>
-                <signal handler="on_item_up_clicked" name="clicked"/>
-              </object>
-              <packing>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkButton" id="item_down">
-                <property name="label">gtk-go-down</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="receives_default">False</property>
-                <property name="use_stock">True</property>
-                <signal handler="on_item_down_clicked" name="clicked"/>
-              </object>
-              <packing>
-                <property name="position">1</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="left_attach">1</property>
-            <property name="right_attach">2</property>
-            <property name="top_attach">1</property>
-            <property name="bottom_attach">2</property>
-            <property name="x_options"/>
-            <property name="y_options"/>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkVButtonBox" id="vbuttonbox1">
-            <property name="visible">True</property>
-            <child>
-              <object class="GtkButton" id="item_new">
-                <property name="label">gtk-new</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="receives_default">False</property>
-                <property name="use_stock">True</property>
-                <signal handler="on_item_new_clicked" name="clicked"/>
-              </object>
-              <packing>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkButton" id="item_delete">
-                <property name="label">gtk-delete</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="receives_default">False</property>
-                <property name="use_stock">True</property>
-                <signal handler="on_item_delete_clicked" name="clicked"/>
-              </object>
-              <packing>
-                <property name="position">1</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="left_attach">1</property>
-            <property name="right_attach">2</property>
-            <property name="x_options"/>
-            <property name="y_options"/>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkScrolledWindow" id="scrolledwindow">
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="shadow_type">in</property>
-            <child>
-              <object class="GtkTreeView" id="treeview">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="reorderable">True</property>
-              </object>
-            </child>
-          </object>
-          <packing>
-            <property name="bottom_attach">3</property>
-            <property name="x_padding">12</property>
-            <property name="y_padding">12</property>
-          </packing>
-        </child>
-      </object>
-    </child>
-  </object>
 </interface>
diff --git a/meld/preferences.py b/meld/preferences.py
index 292fb20..1ac80fc 100644
--- a/meld/preferences.py
+++ b/meld/preferences.py
@@ -20,6 +20,7 @@ from gettext import gettext as _
 import gtk
 
 from ui import gnomeglade
+from ui import listwidget
 import misc
 import paths
 from util import prefs
@@ -28,93 +29,38 @@ import vc
 from util.sourceviewer import srcviewer
 
 
-class ListWidget(gnomeglade.Component):
-    def __init__(self, columns, prefs, key):
-        gnomeglade.Component.__init__(self, paths.ui_dir("preferences.ui"), "listwidget")
+class FilterList(listwidget.ListWidget):
+
+    def __init__(self, prefs, key):
+        listwidget.ListWidget.__init__(self, [_("label"), 0, _("pattern")])
         self.prefs = prefs
         self.key = key
-        self.treeview.set_model( gtk.ListStore( *[c[1] for c in columns] ) )
-        view = self.treeview
-        def addTextCol(label, colnum):
-            model = view.get_model()
-            rentext = gtk.CellRendererText()
-            rentext.props.editable = 1
-            def change_text(ren, path, text):
-                model[path][colnum] = text
-                self._update_filter_string()
-            rentext.connect("edited", change_text)
-            column = gtk.TreeViewColumn(label, rentext, text=colnum)
-            view.append_column(column)
-        def addToggleCol(label, colnum):
-            model = view.get_model()
-            rentoggle = gtk.CellRendererToggle()
-            def change_toggle(ren, path):
-                model[path][colnum] = not ren.get_active()
-                self._update_filter_string()
-            rentoggle.connect("toggled", change_toggle)
-            column = gtk.TreeViewColumn(label, rentoggle, active=colnum)
-            view.append_column(column)
-        for c,i in zip( columns, range(len(columns))):
-            if c[1] == type(""):
-                addTextCol(c[0], i)
-            elif c[1] == type(0):
-                addToggleCol( c[0], 1)
-        view.get_selection().connect('changed', self._update_sensitivity)
-        view.get_model().connect('row-inserted', self._update_sensitivity)
-        view.get_model().connect('rows-reordered', self._update_sensitivity)
+
+        for filtstring in getattr(self.prefs, self.key).split("\n"):
+            filt = misc.ListItem(filtstring)
+            self.model.append([filt.name, filt.active, filt.value])
+
+        for signal in ('row-changed', 'row-deleted', 'row-inserted',
+                       'rows-reordered'):
+            self.model.connect(signal, self._update_filter_string)
+
         self._update_sensitivity()
-        self._update_filter_model()
-
-    def _update_sensitivity(self, *args):
-        (model, it, path) = self._get_selected()
-        if not it:
-            self.item_delete.set_sensitive(False)
-            self.item_up.set_sensitive(False)
-            self.item_down.set_sensitive(False)
-        else:
-            self.item_delete.set_sensitive(True)
-            self.item_up.set_sensitive(path > 0)
-            self.item_down.set_sensitive(path < len(model) - 1)
-
-    def on_item_new_clicked(self, button):
-        model = self.treeview.get_model()
-        model.append([_("label"), 0, _("pattern")])
-        self._update_filter_string()
-    def _get_selected(self):
-        (model, it) = self.treeview.get_selection().get_selected()
-        if it:
-            path = model.get_path(it)[0]
-        else:
-            path = None
-        return (model, it, path)
-    def on_item_delete_clicked(self, button):
-        (model, it, path) = self._get_selected()
-        model.remove(it)
-        self._update_filter_string()
-    def on_item_up_clicked(self, button):
-        (model, it, path) = self._get_selected()
-        model.swap(it, model.get_iter(path - 1))
-        self._update_filter_string()
-    def on_item_down_clicked(self, button):
-        (model, it, path) = self._get_selected()
-        model.swap(it, model.get_iter(path + 1))
-        self._update_filter_string()
-    def on_items_revert_clicked(self, button):
-        setattr( self.prefs, self.key, self.prefs.get_default(self.key) )
-        self._update_filter_model()
-    def _update_filter_string(self):
-        model = self.treeview.get_model()
+
+    def on_name_edited(self, ren, path, text):
+        self.model[path][0] = text
+
+    def on_cellrenderertoggle_toggled(self, ren, path):
+        self.model[path][1] = not ren.get_active()
+
+    def on_pattern_edited(self, ren, path, text):
+        self.model[path][2] = text
+
+    def _update_filter_string(self, *args):
         pref = []
-        for row in model:
-            pref.append("%s\t%s\t%s" % (row[0], row[1], row[2]))
-        setattr( self.prefs, self.key, "\n".join(pref) )
-    def _update_filter_model(self):
-        model = self.treeview.get_model()
-        model.clear()
-        for filtstring in getattr( self.prefs, self.key).split("\n"):
-            filt = misc.ListItem(filtstring)
-            model.append([filt.name, filt.active, filt.value])
-   
+        for row in self.model:
+            pref.append("%s\t%s\t%s" % (row[0], 1 if row[1] else 0, row[2]))
+        setattr(self.prefs, self.key, "\n".join(pref))
+
 
 class PreferencesDialog(gnomeglade.Component):
 
@@ -164,13 +110,12 @@ class PreferencesDialog(gnomeglade.Component):
         self.custom_edit_command_entry.set_text( " ".join(self.prefs.get_custom_editor_command([])) )
 
         # file filters
-        cols = [ (_("Name"), type("")), (_("Active"), type(0)), (_("Pattern"), type("")) ]
-        self.filefilter = ListWidget( cols, self.prefs, "filters")
+        self.filefilter = FilterList(self.prefs, "filters")
         self.file_filters_tab.pack_start(self.filefilter.widget)
         self.checkbutton_ignore_symlinks.set_active( self.prefs.ignore_symlinks)
+
         # text filters
-        cols = [ (_("Name"), type("")), (_("Active"), type(0)), (_("Regex"), type("")) ]
-        self.textfilter = ListWidget( cols, self.prefs, "regexes")
+        self.textfilter = FilterList(self.prefs, "regexes")
         self.text_filters_tab.pack_start(self.textfilter.widget)
         self.checkbutton_ignore_blank_lines.set_active( self.prefs.ignore_blank_lines )
         # encoding
diff --git a/meld/ui/listwidget.py b/meld/ui/listwidget.py
new file mode 100644
index 0000000..9395ca6
--- /dev/null
+++ b/meld/ui/listwidget.py
@@ -0,0 +1,66 @@
+### Copyright (C) 2002-2009 Stephen Kennedy <stevek gnome org>
+### Copyright (C) 2010-2011 Kai Willadsen <kai willadsen gmail com>
+
+### This program is free software; you can redistribute it and/or modify
+### it under the terms of the GNU General Public License as published by
+### the Free Software Foundation; either version 2 of the License, or
+### (at your option) any later version.
+
+### This program is distributed in the hope that it will be useful,
+### but WITHOUT ANY WARRANTY; without even the implied warranty of
+### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+### GNU General Public License for more details.
+
+### You should have received a copy of the GNU General Public License
+### along with this program; if not, write to the Free Software
+### Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+
+import gnomeglade
+from meld import paths
+
+
+class ListWidget(gnomeglade.Component):
+
+    def __init__(self, new_row_data=None):
+        gnomeglade.Component.__init__(self, paths.ui_dir("EditableList.ui"),
+                                      "list_alignment", ["EditableListStore"])
+        self.new_row_data = new_row_data
+        self.model = self.EditableList.get_model()
+        selection = self.EditableList.get_selection()
+        selection.connect("changed", self._update_sensitivity)
+
+    def _update_sensitivity(self, *args):
+        (model, it, path) = self._get_selected()
+        if not it:
+            self.remove.set_sensitive(False)
+            self.move_up.set_sensitive(False)
+            self.move_down.set_sensitive(False)
+        else:
+            self.remove.set_sensitive(True)
+            self.move_up.set_sensitive(path > 0)
+            self.move_down.set_sensitive(path < len(model) - 1)
+
+    def _get_selected(self):
+        (model, it) = self.EditableList.get_selection().get_selected()
+        if it:
+            path = model.get_path(it)[0]
+        else:
+            path = None
+        return (model, it, path)
+
+    def on_add_clicked(self, button):
+        self.model.append(self.new_row_data)
+
+    def on_remove_clicked(self, button):
+        (model, it, path) = self._get_selected()
+        self.model.remove(it)
+
+    def on_move_up_clicked(self, button):
+        (model, it, path) = self._get_selected()
+        model.swap(it, model.get_iter(path - 1))
+
+    def on_move_down_clicked(self, button):
+        (model, it, path) = self._get_selected()
+        model.swap(it, model.get_iter(path + 1))
+



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