OSDN Git Service

Add filterbar.
authorAiwota Programmer <aiwotaprog@tetteke.tk>
Wed, 6 Sep 2006 22:56:36 +0000 (07:56 +0900)
committerAiwota Programmer <aiwotaprog@tetteke.tk>
Wed, 6 Sep 2006 22:56:36 +0000 (07:56 +0900)
src/FukuiNoNamari/board_window.py
src/data/board_window.glade

index f1132bf..1647a9a 100644 (file)
@@ -79,6 +79,8 @@ class WinWrap(winwrapbase.WinWrapBase, board_data.BoardData):
         self.toolbar = self.widget_tree.get_widget("toolbar")
         self.toolbar.unset_style()
         self.statusbar = self.widget_tree.get_widget("appbar")
         self.toolbar = self.widget_tree.get_widget("toolbar")
         self.toolbar.unset_style()
         self.statusbar = self.widget_tree.get_widget("appbar")
+        self.filterbar = self.widget_tree.get_widget("bonobodockitem_filterbar")
+        self.entry_filterbar = self.widget_tree.get_widget("entry_filterbar")
 
         renderer = gtk.CellRendererText()
 
 
         renderer = gtk.CellRendererText()
 
@@ -119,6 +121,10 @@ class WinWrap(winwrapbase.WinWrapBase, board_data.BoardData):
                   "on_statusbar_activate": self.on_statusbar_activate,
                   "on_board_window_delete_event":
                   self.on_board_window_delete_event,
                   "on_statusbar_activate": self.on_statusbar_activate,
                   "on_board_window_delete_event":
                   self.on_board_window_delete_event,
+                  "on_entry_filterbar_activate": self.on_entry_filterbar_activate,
+                  "on_filter_activate": self.on_filter_activate,
+                  "on_toolbutton_filterbar_close_clicked":
+                  self.on_toolbutton_filterbar_close_clicked,
                   "on_popup_menu_open_activate": self.on_open_thread}
         self.widget_tree.signal_autoconnect(sigdic)
 
                   "on_popup_menu_open_activate": self.on_open_thread}
         self.widget_tree.signal_autoconnect(sigdic)
 
@@ -149,6 +155,32 @@ class WinWrap(winwrapbase.WinWrapBase, board_data.BoardData):
         else:
             self.statusbar.show()
 
         else:
             self.statusbar.show()
 
+    def on_filter_activate(self, widget):
+        self.filterbar.show()
+        self.entry_filterbar.grab_focus()
+
+    def on_entry_filterbar_activate(self, widget):
+        text = widget.get_text()
+
+        def func(model, item):
+            try:
+                item["title"].index(text)
+            except ValueError:
+                return False
+            else:
+                return True
+
+        model = self.treeview.get_model()
+        if model:
+            if text:
+                model.set_filter_func(func)
+            else:
+                model.set_filter_func(None)
+            model.refilter()
+
+    def on_toolbutton_filterbar_close_clicked(self, widget):
+        self.filterbar.hide()
+
     def updated_thread_highlight(self, column, cell, model, iter):
 
         def is_updated_thread():
     def updated_thread_highlight(self, column, cell, model, iter):
 
         def is_updated_thread():
@@ -340,6 +372,7 @@ class WinWrap(winwrapbase.WinWrapBase, board_data.BoardData):
                 window_width, window_height = self.window.get_size()
                 toolbar_visible = self.toolbar.parent.get_property("visible")
                 statusbar_visible = self.statusbar.get_property("visible")
                 window_width, window_height = self.window.get_size()
                 toolbar_visible = self.toolbar.parent.get_property("visible")
                 statusbar_visible = self.statusbar.get_property("visible")
+                filterbar_visible = self.filterbar.get_property("visible")
 
                 columns = self.treeview.get_columns()
                 order = ""
 
                 columns = self.treeview.get_columns()
                 order = ""
@@ -368,6 +401,7 @@ class WinWrap(winwrapbase.WinWrapBase, board_data.BoardData):
                 f.write("window_height=" + str(window_height) + "\n")
                 f.write("toolbar_visible=" + str(toolbar_visible) + "\n")
                 f.write("statusbar_visible=" + str(statusbar_visible) + "\n")
                 f.write("window_height=" + str(window_height) + "\n")
                 f.write("toolbar_visible=" + str(toolbar_visible) + "\n")
                 f.write("statusbar_visible=" + str(statusbar_visible) + "\n")
+                f.write("filterbar_visible=" + str(filterbar_visible) + "\n")
 
                 f.close()
         except:
 
                 f.close()
         except:
@@ -379,16 +413,17 @@ class WinWrap(winwrapbase.WinWrapBase, board_data.BoardData):
             window_width = 600
             toolbar_visible = True
             statusbar_visible = True
             window_width = 600
             toolbar_visible = True
             statusbar_visible = True
+            filterbar_visible = False
 
             try:
                 key_base = config.gconf_app_key_base() + "/board_states"
                 gconf_client = gconf.client_get_default()
                 width = gconf_client.get_int(key_base + "/window_width")
                 height = gconf_client.get_int(key_base + "/window_height")
 
             try:
                 key_base = config.gconf_app_key_base() + "/board_states"
                 gconf_client = gconf.client_get_default()
                 width = gconf_client.get_int(key_base + "/window_width")
                 height = gconf_client.get_int(key_base + "/window_height")
-                toolbar_visible = gconf_client.get_bool(
-                    key_base + "/toolbar")
-                statusbar_visible = gconf_client.get_bool(
-                    key_base + "/statusbar")
+                toolbar_visible = gconf_client.get_bool(key_base + "/toolbar")
+                statusbar_visible = gconf_client.get_bool(key_base + "/statusbar")
+                filterbar_visible = gconf_client.get_bool(key_base + "/filterbar")
+
                 if width != 0:
                     window_width = width
                 if height != 0:
                 if width != 0:
                     window_width = width
                 if height != 0:
@@ -453,6 +488,9 @@ class WinWrap(winwrapbase.WinWrapBase, board_data.BoardData):
                     elif line.startswith("statusbar_visible="):
                         sbar = line[len("statusbar_visible="):].rstrip("\n")
                         statusbar_visible = sbar == "True"
                     elif line.startswith("statusbar_visible="):
                         sbar = line[len("statusbar_visible="):].rstrip("\n")
                         statusbar_visible = sbar == "True"
+                    elif line.startswith("filterbar_visible="):
+                        fbar = line[len("filterbar_visible="):].rstrip("\n")
+                        filterbar_visible = fbar == "True"
 
                 self.treeview.get_model().sort(
                     sort_column_name, True, sort_reverse)
 
                 self.treeview.get_model().sort(
                     sort_column_name, True, sort_reverse)
@@ -463,5 +501,7 @@ class WinWrap(winwrapbase.WinWrapBase, board_data.BoardData):
                 gobject.idle_add(self.toolbar.parent.hide)
             if not statusbar_visible:
                 gobject.idle_add(self.statusbar.hide)
                 gobject.idle_add(self.toolbar.parent.hide)
             if not statusbar_visible:
                 gobject.idle_add(self.statusbar.hide)
+            if not filterbar_visible:
+                gobject.idle_add(self.filterbar.hide)
         except:
             traceback.print_exc()
         except:
             traceback.print_exc()
index 0e40819..44931b8 100644 (file)
                <widget class="GtkMenuItem" id="edit1">
                  <property name="visible">True</property>
                  <property name="stock_item">GNOMEUIINFO_MENU_EDIT_TREE</property>
                <widget class="GtkMenuItem" id="edit1">
                  <property name="visible">True</property>
                  <property name="stock_item">GNOMEUIINFO_MENU_EDIT_TREE</property>
+
+                 <child>
+                   <widget class="GtkMenu" id="edit1_menu">
+
+                     <child>
+                       <widget class="GtkMenuItem" id="filter">
+                         <property name="visible">True</property>
+                         <property name="label" translatable="yes">Filter</property>
+                         <property name="use_underline">True</property>
+                         <signal name="activate" handler="on_filter_activate" last_modification_time="Wed, 06 Sep 2006 21:41:17 GMT"/>
+                         <accelerator key="F" modifiers="GDK_CONTROL_MASK" signal="activate"/>
+                       </widget>
+                     </child>
+                   </widget>
+                 </child>
                </widget>
              </child>
 
                </widget>
              </child>
 
       </child>
 
       <child>
       </child>
 
       <child>
+       <widget class="BonoboDockItem" id="bonobodockitem_filterbar">
+         <property name="visible">True</property>
+         <property name="shadow_type">GTK_SHADOW_OUT</property>
+
+         <child>
+           <widget class="GtkHBox" id="hbox1">
+             <property name="visible">True</property>
+             <property name="homogeneous">False</property>
+             <property name="spacing">0</property>
+
+             <child>
+               <widget class="GtkToolbar" id="toolbar2">
+                 <property name="visible">True</property>
+                 <property name="orientation">GTK_ORIENTATION_HORIZONTAL</property>
+                 <property name="toolbar_style">GTK_TOOLBAR_ICONS</property>
+                 <property name="tooltips">True</property>
+                 <property name="show_arrow">False</property>
+
+                 <child>
+                   <widget class="GtkToolButton" id="toolbutton_filterbar_close">
+                     <property name="visible">True</property>
+                     <property name="stock_id">gtk-close</property>
+                     <property name="visible_horizontal">True</property>
+                     <property name="visible_vertical">True</property>
+                     <property name="is_important">False</property>
+                     <signal name="clicked" handler="on_toolbutton_filterbar_close_clicked" last_modification_time="Wed, 06 Sep 2006 21:30:04 GMT"/>
+                   </widget>
+                   <packing>
+                     <property name="expand">False</property>
+                     <property name="homogeneous">False</property>
+                   </packing>
+                 </child>
+               </widget>
+               <packing>
+                 <property name="padding">0</property>
+                 <property name="expand">False</property>
+                 <property name="fill">False</property>
+               </packing>
+             </child>
+
+             <child>
+               <widget class="GtkLabel" id="label1">
+                 <property name="visible">True</property>
+                 <property name="label" translatable="yes">Filter:</property>
+                 <property name="use_underline">False</property>
+                 <property name="use_markup">False</property>
+                 <property name="justify">GTK_JUSTIFY_LEFT</property>
+                 <property name="wrap">False</property>
+                 <property name="selectable">False</property>
+                 <property name="xalign">0.5</property>
+                 <property name="yalign">0.5</property>
+                 <property name="xpad">0</property>
+                 <property name="ypad">0</property>
+               </widget>
+               <packing>
+                 <property name="padding">0</property>
+                 <property name="expand">False</property>
+                 <property name="fill">False</property>
+               </packing>
+             </child>
+
+             <child>
+               <widget class="GtkEntry" id="entry_filterbar">
+                 <property name="visible">True</property>
+                 <property name="can_focus">True</property>
+                 <property name="editable">True</property>
+                 <property name="visibility">True</property>
+                 <property name="max_length">0</property>
+                 <property name="text" translatable="yes"></property>
+                 <property name="has_frame">True</property>
+                 <property name="invisible_char">*</property>
+                 <property name="activates_default">False</property>
+                 <signal name="activate" handler="on_entry_filterbar_activate" last_modification_time="Wed, 06 Sep 2006 21:30:21 GMT"/>
+               </widget>
+               <packing>
+                 <property name="padding">0</property>
+                 <property name="expand">True</property>
+                 <property name="fill">True</property>
+               </packing>
+             </child>
+           </widget>
+         </child>
+       </widget>
+       <packing>
+         <property name="placement">BONOBO_DOCK_BOTTOM</property>
+         <property name="band">0</property>
+         <property name="position">0</property>
+         <property name="offset">0</property>
+         <property name="behavior">BONOBO_DOCK_ITEM_BEH_EXCLUSIVE|BONOBO_DOCK_ITEM_BEH_LOCKED</property>
+       </packing>
+      </child>
+
+      <child>
        <widget class="GtkScrolledWindow" id="scrolledwindow1">
          <property name="visible">True</property>
          <property name="can_focus">True</property>
        <widget class="GtkScrolledWindow" id="scrolledwindow1">
          <property name="visible">True</property>
          <property name="can_focus">True</property>