Added close buttons to notebook
[findit] / src / files / search.py
index 4868f90..24e423b 100755 (executable)
@@ -6,7 +6,7 @@ from os import walk
 from os.path import join, abspath, normcase, isdir, getsize
 from heapq import nlargest
 
-from misc import size_hum_read, _
+from misc import size_hum_read, _, NotebookWCloseBtns
 from config import config
 
 OUTTYPES = [
@@ -116,9 +116,9 @@ class Gtk_Presentation(object):
         import gtk
         global gtk  # for show_current_status()
 
-        self.nb = gtk.Notebook()
-        self.nb.set_scrollable(True)
-        self.nb.set_border_width(2)
+        self.nb = NotebookWCloseBtns()
+        self.nb.notebook.set_scrollable(True)
+        self.nb.notebook.set_border_width(2)
 
         #====================
         # Notebook
@@ -189,7 +189,8 @@ class Gtk_Presentation(object):
         cr_vbox.pack_start(hbox2, False, False, 0)
         cr_vbox.pack_start(hbox3, False, False, 0)
         cr_vbox.pack_end(hbox4, False, False, 0)
-        self.nb.append_page(cr_vbox, gtk.Label(_('Criteria')))
+
+        self.nb.new_tab(cr_vbox, _('Criteria'), noclose=True)
 
         #====================
         # Others
@@ -200,7 +201,7 @@ class Gtk_Presentation(object):
         self.context_id = self.statusbar.get_context_id('Current walked file')
 
         self.vbox = gtk.VBox()
-        self.vbox.pack_start(self.nb, True, True, 0)
+        self.vbox.pack_start(self.nb.notebook, True, True, 0)
         self.vbox.pack_end(self.statusbar, False, False, 0)
 
 #        self.show_out_toplevel(config['outtype'], [(1, 'path', 'bytesize')])
@@ -254,14 +255,12 @@ class Gtk_Presentation(object):
         self.statusbar.push(self.context_id, current_path)
         gtk.main_iteration()
 
-    def _new_page(self, child, label):
+    def _new_page(self, child, title):
         """Create new notebook page with search output."""
-        self.nb.append_page(child, gtk.Label(label))
-        #self.nb.set_current_page(-1)
-        #child.grab_focus()
-
-    def _close_page(self):
-        pass
+        pages = self.nb.notebook.get_n_pages()
+        self.nb.new_tab(child, title)
+        child.show_all()
+        self.nb.notebook.set_current_page(pages)
 
     def run(self):
         pass
@@ -274,7 +273,6 @@ class Gtk_Presentation(object):
         self.out_toplevel = out_submodule.Gtk_Presentation(results).toplevel
 
         self._new_page(self.out_toplevel, outtype['label'])
-        self.out_toplevel.show_all()
 ###        out_submodule.Gtk_Presentation().show_results(results)
 
 #==============================================================================