2008-01-09 Raphael Ackermann <raphael.ackermann@gmail.com> * src/ObjectSelector/_FilterFrameBase.py: indentation and tabs/spaces fix
svn: r9763
This commit is contained in:
parent
b7c7952058
commit
87e152e0b7
@ -1,3 +1,6 @@
|
||||
2008-01-09 Raphael Ackermann <raphael.ackermann@gmail.com>
|
||||
* src/ObjectSelector/_FilterFrameBase.py: indentation and tabs/spaces fix
|
||||
|
||||
2008-01-09 Raphael Ackermann <raphael.ackermann@gmail.com>
|
||||
* src/ViewManager.py: delete unneded method import_pkg
|
||||
* src/ArgHandler.py: fix import CompressionError instead of CompressError
|
||||
|
@ -41,18 +41,18 @@ class FilterFrameBase(gtk.Frame):
|
||||
__default_border_width = 5
|
||||
|
||||
def __init__(self,filter_spec=None,label="Filter"):
|
||||
gtk.Frame.__init__(self,label)
|
||||
gtk.Frame.__init__(self,label)
|
||||
|
||||
|
||||
self._checkboxes = []
|
||||
self._active_widgets = []
|
||||
self._active_widgets = []
|
||||
|
||||
self._current_row = 0
|
||||
self._current_row = 0
|
||||
|
||||
self._filter_spec = filter_spec
|
||||
|
||||
box = gtk.EventBox()
|
||||
align = gtk.Alignment()
|
||||
align = gtk.Alignment()
|
||||
|
||||
# table layout
|
||||
|
||||
@ -86,7 +86,7 @@ class FilterFrameBase(gtk.Frame):
|
||||
outer_box.set_border_width(self.__class__.__default_border_width/2)
|
||||
outer_box.set_spacing(self.__class__.__default_border_width/2)
|
||||
|
||||
align.add(outer_box)
|
||||
align.add(outer_box)
|
||||
align.set_padding(self.__class__.__default_border_width,
|
||||
self.__class__.__default_border_width,
|
||||
self.__class__.__default_border_width,
|
||||
@ -94,12 +94,12 @@ class FilterFrameBase(gtk.Frame):
|
||||
|
||||
|
||||
box.add(align)
|
||||
self.add(box)
|
||||
self.add(box)
|
||||
|
||||
|
||||
def _reset_widgets(self):
|
||||
for widget in self._active_widgets:
|
||||
widget.set_sensitive(False)
|
||||
for widget in self._active_widgets:
|
||||
widget.set_sensitive(False)
|
||||
for check in self._checkboxes:
|
||||
check.set_active(False)
|
||||
|
||||
@ -108,130 +108,139 @@ class FilterFrameBase(gtk.Frame):
|
||||
self.emit('clear-filter')
|
||||
|
||||
def make_text_widget(self,widget_label):
|
||||
"""create a text edit widget with a label and check box."""
|
||||
|
||||
check_col=self._check_col
|
||||
label_col=self._label_col
|
||||
control_col=self._control_col
|
||||
|
||||
check = gtk.CheckButton()
|
||||
self._checkboxes.append(check)
|
||||
|
||||
label = gtk.Label(widget_label)
|
||||
label.set_alignment(xalign=0,yalign=0.5)
|
||||
|
||||
edit = gtk.Entry()
|
||||
self._active_widgets.append(edit)
|
||||
|
||||
check.connect('toggled',lambda b: edit.set_sensitive(check.get_active()))
|
||||
|
||||
self._table.attach(check,check_col,check_col+1,
|
||||
self._current_row,self._current_row+1,xoptions=False,yoptions=False)
|
||||
self._table.attach(label,label_col,label_col+1,
|
||||
self._current_row,self._current_row+1,xoptions=gtk.FILL,yoptions=False)
|
||||
self._table.attach(edit,control_col,control_col+1,
|
||||
self._current_row,self._current_row+1,xoptions=gtk.EXPAND|gtk.FILL,yoptions=False)
|
||||
self._current_row += 1
|
||||
|
||||
return(check,label,edit)
|
||||
"""create a text edit widget with a label and check box."""
|
||||
|
||||
check_col=self._check_col
|
||||
label_col=self._label_col
|
||||
control_col=self._control_col
|
||||
|
||||
check = gtk.CheckButton()
|
||||
self._checkboxes.append(check)
|
||||
|
||||
label = gtk.Label(widget_label)
|
||||
label.set_alignment(xalign=0,yalign=0.5)
|
||||
|
||||
edit = gtk.Entry()
|
||||
self._active_widgets.append(edit)
|
||||
|
||||
check.connect('toggled',lambda b: edit.set_sensitive(check.get_active()))
|
||||
|
||||
self._table.attach(check,check_col,check_col+1, self._current_row,
|
||||
self._current_row+1,xoptions=False,yoptions=False)
|
||||
self._table.attach(label,label_col,label_col+1, self._current_row,
|
||||
self._current_row+1,xoptions=gtk.FILL,
|
||||
yoptions=False)
|
||||
self._table.attach(edit,control_col,control_col+1, self._current_row,
|
||||
self._current_row+1,xoptions=gtk.EXPAND|gtk.FILL,
|
||||
yoptions=False)
|
||||
self._current_row += 1
|
||||
|
||||
return(check,label,edit)
|
||||
|
||||
def make_combo_widget(self,widget_label,list_model):
|
||||
"""create a combo widget with a label and check box."""
|
||||
check_col=self._check_col
|
||||
label_col=self._label_col
|
||||
control_col=self._control_col
|
||||
|
||||
check = gtk.CheckButton()
|
||||
self._checkboxes.append(check)
|
||||
|
||||
label = gtk.Label(widget_label)
|
||||
label.set_alignment(xalign=0,yalign=0.5)
|
||||
|
||||
combo = gtk.ComboBox(list_model)
|
||||
self._active_widgets.append(combo)
|
||||
|
||||
label_cell = gtk.CellRendererText()
|
||||
|
||||
combo.pack_start(label_cell, True)
|
||||
combo.add_attribute(label_cell, 'text', 0)
|
||||
combo.set_active(2)
|
||||
|
||||
check.connect('toggled',lambda b: combo.set_sensitive(check.get_active()))
|
||||
|
||||
|
||||
self._table.attach(check,check_col,check_col+1,
|
||||
self._current_row,self._current_row+1,xoptions=False,yoptions=False)
|
||||
self._table.attach(label,label_col,label_col+1,
|
||||
self._current_row,self._current_row+1,xoptions=gtk.FILL,yoptions=False)
|
||||
self._table.attach(combo,control_col,control_col+1,
|
||||
self._current_row,self._current_row+1,xoptions=gtk.EXPAND|gtk.FILL,yoptions=False)
|
||||
self._current_row += 1
|
||||
|
||||
return (check,label,combo)
|
||||
"""create a combo widget with a label and check box."""
|
||||
check_col=self._check_col
|
||||
label_col=self._label_col
|
||||
control_col=self._control_col
|
||||
|
||||
check = gtk.CheckButton()
|
||||
self._checkboxes.append(check)
|
||||
|
||||
label = gtk.Label(widget_label)
|
||||
label.set_alignment(xalign=0,yalign=0.5)
|
||||
|
||||
combo = gtk.ComboBox(list_model)
|
||||
self._active_widgets.append(combo)
|
||||
|
||||
label_cell = gtk.CellRendererText()
|
||||
|
||||
combo.pack_start(label_cell, True)
|
||||
combo.add_attribute(label_cell, 'text', 0)
|
||||
combo.set_active(2)
|
||||
|
||||
check.connect('toggled',lambda b: combo.set_sensitive(check.get_active()))
|
||||
|
||||
self._table.attach(check,check_col,check_col+1,
|
||||
self._current_row,self._current_row+1,
|
||||
xoptions=False,yoptions=False)
|
||||
self._table.attach(label,label_col,label_col+1, self._current_row,
|
||||
self._current_row+1,xoptions=gtk.FILL,
|
||||
yoptions=False)
|
||||
self._table.attach(combo,control_col,control_col+1, self._current_row,
|
||||
self._current_row+1,xoptions=gtk.EXPAND|gtk.FILL,
|
||||
yoptions=False)
|
||||
self._current_row += 1
|
||||
|
||||
return (check,label,combo)
|
||||
|
||||
def make_year_widget(self,widget_label):
|
||||
"""Create a widget with a year edit entry, a before and after check box.
|
||||
Including a check box to enable and disable all the widgets."""
|
||||
check_col=self._check_col
|
||||
label_col=self._label_col
|
||||
control_col=self._control_col
|
||||
|
||||
check = gtk.CheckButton()
|
||||
check.set_alignment(xalign=0,yalign=0)
|
||||
self._checkboxes.append(check)
|
||||
|
||||
label = gtk.Label(widget_label)
|
||||
label.set_alignment(xalign=0,yalign=0)
|
||||
|
||||
edit = IntEdit()
|
||||
self._active_widgets.append(edit)
|
||||
|
||||
before = gtk.RadioButton(group=None,label="Before")
|
||||
self._active_widgets.append(before)
|
||||
|
||||
after = gtk.RadioButton(before,"After")
|
||||
self._active_widgets.append(after)
|
||||
before.set_active(True)
|
||||
|
||||
unknown = gtk.CheckButton("Include Unknown")
|
||||
self._active_widgets.append(unknown)
|
||||
unknown.set_active(False)
|
||||
|
||||
check.connect('toggled',lambda b: edit.set_sensitive(check.get_active()))
|
||||
check.connect('toggled',lambda b: before.set_sensitive(check.get_active()))
|
||||
check.connect('toggled',lambda b: after.set_sensitive(check.get_active()))
|
||||
#check.connect('toggled',lambda b: unknown.set_sensitive(check.get_active()))
|
||||
|
||||
inner_box = gtk.HBox()
|
||||
inner_box.pack_start(before)
|
||||
inner_box.pack_start(after)
|
||||
|
||||
|
||||
self._table.attach(check,check_col,check_col+1,
|
||||
self._current_row,self._current_row+1,xoptions=False,yoptions=False)
|
||||
self._table.attach(label,label_col,label_col+1,
|
||||
self._current_row,self._current_row+1,xoptions=gtk.FILL,yoptions=False)
|
||||
self._table.attach(edit,control_col,control_col+1,
|
||||
self._current_row,self._current_row+1,xoptions=gtk.EXPAND|gtk.FILL,yoptions=False)
|
||||
|
||||
self._current_row +=1
|
||||
self._table.attach(inner_box,control_col,control_col+1,
|
||||
self._current_row,self._current_row+1,xoptions=gtk.EXPAND|gtk.FILL,yoptions=False)
|
||||
|
||||
self._current_row +=1
|
||||
self._table.attach(unknown,control_col,control_col+1,
|
||||
self._current_row,self._current_row+1,xoptions=gtk.EXPAND|gtk.FILL,yoptions=False)
|
||||
self._current_row +=1
|
||||
|
||||
return (check, edit, before, after, unknown)
|
||||
"""Create a widget with a year edit entry, a before and after check box.
|
||||
Including a check box to enable and disable all the widgets."""
|
||||
check_col=self._check_col
|
||||
label_col=self._label_col
|
||||
control_col=self._control_col
|
||||
|
||||
check = gtk.CheckButton()
|
||||
check.set_alignment(xalign=0,yalign=0)
|
||||
self._checkboxes.append(check)
|
||||
|
||||
label = gtk.Label(widget_label)
|
||||
label.set_alignment(xalign=0,yalign=0)
|
||||
|
||||
edit = IntEdit()
|
||||
self._active_widgets.append(edit)
|
||||
|
||||
before = gtk.RadioButton(group=None,label="Before")
|
||||
self._active_widgets.append(before)
|
||||
|
||||
after = gtk.RadioButton(before,"After")
|
||||
self._active_widgets.append(after)
|
||||
before.set_active(True)
|
||||
|
||||
unknown = gtk.CheckButton("Include Unknown")
|
||||
self._active_widgets.append(unknown)
|
||||
unknown.set_active(False)
|
||||
|
||||
check.connect('toggled',lambda b: edit.set_sensitive(check.get_active()))
|
||||
check.connect('toggled',lambda b: before.set_sensitive(check.get_active()))
|
||||
check.connect('toggled',lambda b: after.set_sensitive(check.get_active()))
|
||||
#check.connect('toggled',lambda b: unknown.set_sensitive(check.get_active()))
|
||||
|
||||
inner_box = gtk.HBox()
|
||||
inner_box.pack_start(before)
|
||||
inner_box.pack_start(after)
|
||||
|
||||
|
||||
self._table.attach(check,check_col,check_col+1, self._current_row,
|
||||
self._current_row+1,xoptions=False,yoptions=False)
|
||||
self._table.attach(label,label_col,label_col+1, self._current_row,
|
||||
self._current_row+1,xoptions=gtk.FILL,
|
||||
yoptions=False)
|
||||
self._table.attach(edit,control_col,control_col+1, self._current_row,
|
||||
self._current_row+1,xoptions=gtk.EXPAND|gtk.FILL,
|
||||
yoptions=False)
|
||||
|
||||
self._current_row +=1
|
||||
self._table.attach(inner_box,control_col,control_col+1,
|
||||
self._current_row,self._current_row+1,
|
||||
xoptions=gtk.EXPAND|gtk.FILL,yoptions=False)
|
||||
|
||||
self._current_row +=1
|
||||
self._table.attach(unknown,control_col,control_col+1,
|
||||
self._current_row,self._current_row+1,
|
||||
xoptions=gtk.EXPAND|gtk.FILL,yoptions=False)
|
||||
self._current_row +=1
|
||||
|
||||
return (check, edit, before, after, unknown)
|
||||
|
||||
|
||||
def on_apply(self,button):
|
||||
"""Build a GenericFilter object from the settings in the filter controls and
|
||||
emit a 'apply-filter' signal with the GenericFilter object as the parameter."""
|
||||
|
||||
"""Build a GenericFilter object from the settings in the filter
|
||||
controls and emit a 'apply-filter' signal with the GenericFilter object
|
||||
as the parameter."""
|
||||
|
||||
raise NotImplementedError("subclass of FilterFrameBase must implement on_apply")
|
||||
|
||||
|
||||
if gtk.pygtk_version < (2,8,0):
|
||||
gobject.type_register(FilterFrameBase)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user