Beispiel #1
0
 def __init__(self, db, extent, method_name):
     gtk.VBox.__init__(self)
     self._db = db
     self._extent = extent
     method = extent.q[method_name]
     query = self._query = method()
     # Criteria form.
     expander_label = gtk.HBox()
     image_label = icon.small_image(self, db, 'q.%s' % method_name)
     text_label = gtk.Label(label(method))
     expander_label.pack_start(image_label, expand=False, padding=6)
     expander_label.pack_start(text_label, expand=False)
     image_label = icon.small_image(self, extent)
     text_label = gtk.Label(u'<b>%s</b>' % label(extent))
     text_label.props.use_markup = True
     expander_label.pack_start(image_label, expand=False, padding=6)
     expander_label.pack_start(text_label, expand=False)
     expander = gtk.Expander()
     expander.props.label_widget = expander_label
     self.pack_start(expander, expand=False)
     vbox = gtk.VBox()
     expander.add(vbox)
     criteria = self._criteria = query_widget(db, query)
     vbox.pack_start(criteria, expand=False)
     # Update button.
     box = gtk.HBox()
     vbox.pack_start(box, expand=False)
     refresh = gtk.Button(stock=gtk.STOCK_REFRESH)
     refresh.connect('clicked', self.on_refresh_clicked)
     box.pack_end(refresh, expand=False)
     # Results table.
     scroller = gtk.ScrolledWindow()
     scroller.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
     self.pack_start(scroller, expand=True)
     results = self._results = Results(db, query)
     scroller.add_with_viewport(results)
     self.show_all()
     criteria.update_ui()
     results.rerun()
Beispiel #2
0
 def rerun(self):
     """Re-run the query and update results."""
     db = self._db
     # Destroy existing results.
     class_expander = self._class_expander
     while class_expander:
         class_, expander = class_expander.pop()
         expander.destroy()
     # Re-run query.
     results = self._query()
     class_results = {}
     for result in results:
         L = class_results.setdefault(result.__class__, [])
         L.append(result)
     # Create expanders and listviews.
     if not class_results:
         no_results = gtk.Label('No results found.')
         self.pack_start(no_results, expand=False)
         class_expander.append((None, no_results))
     for class_, results in class_results.iteritems():
         extent = class_._extent
         expander_label = gtk.HBox()
         # Label for extent.
         extent_image = icon.small_image(self, extent)
         count = len(results)
         if count != 1:
             extent_label = gtk.Label(
                 u'%i %s found:' % (count, plural(extent)))
         else:
             extent_label = gtk.Label(
                 u'%i %s found:' % (count, label(extent)))
         expander_label.pack_start(extent_image, expand=False, padding=6)
         expander_label.pack_start(extent_label, expand=False, padding=6)
         expander = gtk.Expander()
         expander.props.label_widget = expander_label
         expander.props.expanded = True
         self.pack_start(expander, expand=True)
         listview = ResultsListView(class_, results)
         expander.add(listview)
         class_expander.append((class_, expander))
     self.show_all()
Beispiel #3
0
 def __init__(self, db):
     gtk.VBox.__init__(self)
     self._db = db
     ##         exp_ext = self._expander_extent = {}
     ##         ext_exp = self._extent_expander = {}
     for extent in db.extents():
         expander = gtk.Expander()
         extent_label = plural(extent)
         iset = icon.iconset(self, extent)
         image_label = icon.small_image(self, extent)
         ##             text_label = gtk.Label(u'<b>%s</b>' % extent_label)
         ##             text_label.props.use_markup = True
         text_label = gtk.Label(extent_label)
         label_widget = gtk.HBox()
         label_widget.pack_start(image_label, expand=False, padding=6)
         label_widget.pack_start(text_label, expand=False)
         expander.props.label_widget = label_widget
         self.pack_start(expander)
         # Children of expander.
         hbox = gtk.HBox()
         expander.add(hbox)
         # Padding on left.
         padding = gtk.VBox()
         padding.props.width_request = 20
         hbox.pack_start(padding, expand=False)
         # Buttons.
         buttons = gtk.VBox()
         hbox.add(buttons)
         # Query buttons.
         q = extent.q
         for q_name in q:
             q_method = q[q_name]
             ##                 q_label = label(q_method)
             q_label = gtk.Label(label(q_method))
             q_button = gtk.Button()
             ##                 q_button.props.label = q_label
             ##                 q_button.props.image = icon.small_image(
             ##                     self, db, 'q.%s' % q_name)
             q_image = icon.small_image(self, db, "q.%s" % q_name)
             q_hbox = gtk.HBox(spacing=2)
             q_hbox.pack_start(q_image, expand=False)
             q_hbox.pack_start(q_label, expand=False, padding=1)
             q_button.add(q_hbox)
             ##                 q_button.props.relief = gtk.RELIEF_NONE
             q_button.props.xalign = 0.0
             q_button.connect("clicked", self.on_q_button_clicked, extent, q_name)
             buttons.add(q_button)
         # Transaction buttons.
         t = extent.t
         for t_name in t:
             t_method = t[t_name]
             t_label = label(t_method)
             t_button = gtk.Button()
             t_button.props.label = t_label
             t_button.props.image = icon.small_image(self, db, "t.%s" % t_name)
             ##                 t_button.props.relief = gtk.RELIEF_NONE
             t_button.props.xalign = 0.0
             t_button.connect("clicked", self.on_t_button_clicked, extent, t_name)
             buttons.add(t_button)
         # Padding on bottom.
         padding = gtk.VBox()
         padding.props.height_request = 11
         buttons.add(padding)
     self.show_all()