aboutsummaryrefslogtreecommitdiffstats
path: root/misc
diff options
context:
space:
mode:
authorChris Ball <cjb@laptop.org>2009-07-23 17:49:13 -0400
committerChris Ball <cjb@laptop.org>2009-07-23 17:49:13 -0400
commit6a639574fa95e50f82fa3052e5524b961295a7ab (patch)
treeb498654ed1dcbdbba94605292c280c883c5e9faa /misc
parent5e249abfee7273c79640c4211607a6b4bf7b374c (diff)
parentcaf0111d9c571ac268c235880e6d18fa512e9efa (diff)
downloadbugseverywhere-6a639574fa95e50f82fa3052e5524b961295a7ab.tar.gz
Merge large rework from W. Trevor King.
Diffstat (limited to 'misc')
-rw-r--r--misc/completion/be.bash39
-rwxr-xr-xmisc/gui/beg12
-rw-r--r--misc/gui/table.py97
-rwxr-xr-xmisc/gui/wxbe87
4 files changed, 39 insertions, 196 deletions
diff --git a/misc/completion/be.bash b/misc/completion/be.bash
new file mode 100644
index 0000000..834bf25
--- /dev/null
+++ b/misc/completion/be.bash
@@ -0,0 +1,39 @@
+#!/bin/bash
+# Bash completion script for be (Bugs Everywhere)
+#
+# System wide installation:
+# Copy this file to /etc/bash_completion/be
+# Per-user installation:
+# Copy this file to ~/.be-completion.sh and source it in your .bashrc:
+# source ~/.be-completion.sh
+#
+# For a good intro to Bash completion, see Steve Kemp's article
+# "An introduction to bash completion: part 2"
+# http://www.debian-administration.org/articles/317
+
+# Requires:
+# be [X Y Z] --complete
+# to print a list of available completions at that point
+_be()
+{
+ local cur prev opts
+ COMPREPLY=()
+ cur="${COMP_WORDS[COMP_CWORD]}"
+ prev="${COMP_WORDS[COMP_CWORD-1]}"
+
+ if [ $COMP_CWORD -eq 1 ]; then
+ # no command yet, show all commands
+ COMPREPLY=( $( compgen -W "$(be --complete)" -- $cur ) )
+ else
+ # remove the first word (should be "be") for security reasons
+ unset COMP_WORDS[0]
+ # remove the current word and all later words, because they
+ # are not needed for completion.
+ for i in `seq $COMP_CWORD ${#COMP_WORDS[@]}`; do
+ unset COMP_WORDS[$i];
+ done
+ COMPREPLY=( $( compgen -W "$(be "${COMP_WORDS[@]}" --complete $cur)" -- $cur ) )
+ fi
+}
+
+complete -F _be be
diff --git a/misc/gui/beg b/misc/gui/beg
deleted file mode 100755
index 55e537d..0000000
--- a/misc/gui/beg
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/usr/bin/env python
-import table
-from Tkinter import *
-from libbe import bugdir
-
-tk = Tk()
-Label(tk, text="Bug list").pack()
-mlb = table.MultiListbox(tk, (('Severity', 4), ('Creator', 8), ('Summary', 40)))
-for bug in [b for b in bugdir.tree_root(".").list() if b.active]:
- mlb.insert(END, (bug.severity, bug.creator, bug.summary))
-mlb.pack(expand=YES,fill=BOTH)
-tk.mainloop()
diff --git a/misc/gui/table.py b/misc/gui/table.py
deleted file mode 100644
index 2865f28..0000000
--- a/misc/gui/table.py
+++ /dev/null
@@ -1,97 +0,0 @@
-from Tkinter import *
-
-class MultiListbox(Frame):
- def __init__(self, master, lists):
- Frame.__init__(self, master)
- self.lists = []
- for l,w in lists:
- frame = Frame(self); frame.pack(side=LEFT, expand=YES, fill=BOTH)
- Label(frame, text=l, borderwidth=1, relief=RAISED).pack(fill=X)
- lb = Listbox(frame, width=w, borderwidth=0, selectborderwidth=0,
- relief=FLAT, exportselection=FALSE)
- lb.pack(expand=YES, fill=BOTH)
- self.lists.append(lb)
- lb.bind('<B1-Motion>', lambda e, s=self: s._select(e.y))
- lb.bind('<Button-1>', lambda e, s=self: s._select(e.y))
- lb.bind('<Leave>', lambda e: 'break')
- lb.bind('<B2-Motion>', lambda e, s=self: s._b2motion(e.x, e.y))
- lb.bind('<Button-2>', lambda e, s=self: s._button2(e.x, e.y))
- frame = Frame(self); frame.pack(side=LEFT, fill=Y)
- Label(frame, borderwidth=1, relief=RAISED).pack(fill=X)
- sb = Scrollbar(frame, orient=VERTICAL, command=self._scroll)
- sb.pack(expand=YES, fill=Y)
- self.lists[0]['yscrollcommand']=sb.set
-
- def _select(self, y):
- row = self.lists[0].nearest(y)
- self.selection_clear(0, END)
- self.selection_set(row)
- return 'break'
-
- def _button2(self, x, y):
- for l in self.lists: l.scan_mark(x, y)
- return 'break'
-
- def _b2motion(self, x, y):
- for l in self.lists: l.scan_dragto(x, y)
- return 'break'
-
- def _scroll(self, *args):
- for l in self.lists:
- apply(l.yview, args)
-
- def curselection(self):
- return self.lists[0].curselection()
-
- def delete(self, first, last=None):
- for l in self.lists:
- l.delete(first, last)
-
- def get(self, first, last=None):
- result = []
- for l in self.lists:
- result.append(l.get(first,last))
- if last: return apply(map, [None] + result)
- return result
-
- def index(self, index):
- self.lists[0].index(index)
-
- def insert(self, index, *elements):
- for e in elements:
- i = 0
- for l in self.lists:
- l.insert(index, e[i])
- i = i + 1
-
- def size(self):
- return self.lists[0].size()
-
- def see(self, index):
- for l in self.lists:
- l.see(index)
-
- def selection_anchor(self, index):
- for l in self.lists:
- l.selection_anchor(index)
-
- def selection_clear(self, first, last=None):
- for l in self.lists:
- l.selection_clear(first, last)
-
- def selection_includes(self, index):
- return self.lists[0].selection_includes(index)
-
- def selection_set(self, first, last=None):
- for l in self.lists:
- l.selection_set(first, last)
-
-if __name__ == '__main__':
- tk = Tk()
- Label(tk, text='MultiListbox').pack()
- mlb = MultiListbox(tk, (('Subject', 40), ('Sender', 20), ('Date', 10)))
- for i in range(1000):
- mlb.insert(END, ('Important Message: %d' % i, 'John Doe', '10/10/%04d' % (1900+i)))
- mlb.pack(expand=YES,fill=BOTH)
- tk.mainloop()
-
diff --git a/misc/gui/wxbe b/misc/gui/wxbe
deleted file mode 100755
index e71ae0c..0000000
--- a/misc/gui/wxbe
+++ /dev/null
@@ -1,87 +0,0 @@
-#!/usr/bin/env python
-import wx
-from wx.lib.mixins.listctrl import ListCtrlAutoWidthMixin
-import sys, os.path
-from libbe import bugdir, names
-from libbe.bug import cmp_status, cmp_severity, cmp_time, cmp_full
-
-class MyApp(wx.App):
- def OnInit(self):
- frame = BugListFrame(None, title="Bug List")
- frame.Show(True)
- self.SetTopWindow(frame)
- return True
-
-class BugListFrame(wx.Frame):
- def __init__(self, *args, **kwargs):
- wx.Frame.__init__(self, *args, **kwargs)
- bugs = BugList(self)
-
- # Widgets to display/sort/edit will go in this panel
- # for now it is just a placeholder
- panel = wx.Panel(self)
- panel.SetBackgroundColour("RED")
-
- vbox = wx.BoxSizer(wx.VERTICAL)
- vbox.Add(panel, 0, wx.EXPAND)
- vbox.Add(bugs, 1, wx.EXPAND)
-
- self.SetAutoLayout(True)
- self.SetSizer(vbox)
- self.Layout()
-
-class BugList(wx.ListCtrl, ListCtrlAutoWidthMixin):
- def __init__(self, parent):
- wx.ListCtrl.__init__(self, parent,
- style=wx.LC_REPORT)
- ListCtrlAutoWidthMixin.__init__(self)
-
- self.bugdir = bugdir.tree_root(".")
- self.buglist = list(self.bugdir.list())
- self.buglist.sort()
- self.columns = ("id", "status", "severity", "summary")
-
- dataIndex = 0
- for x in range(len(self.columns)):
- self.InsertColumn(x, self.columns[x].capitalize())
- self.SetColumnWidth(x, wx.LIST_AUTOSIZE_USEHEADER)
- for bug in [b for b in self.buglist if b.active]:
- name = names.unique_name(bug, self.buglist)
- id = self.InsertStringItem(self.GetItemCount(), name)
- self.SetStringItem(id, 1, bug.status)
- self.SetStringItem(id, 2, bug.severity)
- self.SetStringItem(id, 3, bug.summary)
- self.SetItemData(id, dataIndex) # set keys for each line
- dataIndex += 1
- self.EnsureVisible(id)
- for x in range(len(self.columns)):
- self.SetColumnWidth(x, wx.LIST_AUTOSIZE)
- conts_width = self.GetColumnWidth(x)
- self.SetColumnWidth(x, wx.LIST_AUTOSIZE_USEHEADER)
- if conts_width > self.GetColumnWidth(x):
- self.SetColumnWidth(x, conts_width)
-
- self.Bind(wx.EVT_LIST_COL_CLICK, self.OnColumnClick)
- self.bugcmp_fn = cmp_full
- # For reasons I don't understant, sorting is broken...
- #self.SortItems(self.Sorter)
- #self.Refresh()
- def Sorter(self, key1, key2):
- """Get bug info from the keys and pass to self.bugcmp_fn"""
- bug1 = self.buglist[key1-1]
- bug2 = self.buglist[key2-1]
- # Another way of getting bug information
- #bug1uuid = self.GetItem(key1, 0).GetText()
- #bug2uuid = self.GetItem(key2, 0).GetText()
- #print bug1uuid, bug2uuid
- #bug1 = self.bugdir.get_bug(bug1uuid)
- #bug2 = self.bugdir.get_bug(bug1uuid)
- print self.bugcmp_fn(bug1,bug2)
- return self.bugcmp_fn(bug1,bug2)
- def OnColumnClick(self, event):
- """Resort bug list depending on which column was clicked"""
- print "TODO: sort by column %d" % event.Column
- # change self.bugcmp_fn and resort, but I can't get it working
-
-app = MyApp()
-app.MainLoop()