Merge lp:~bdfhjk/clicompanion/fix-738264 into lp:clicompanion

Proposed by Marek Bardoński
Status: Merged
Approved by: Duane Hinnen
Approved revision: 70
Merged at revision: 69
Proposed branch: lp:~bdfhjk/clicompanion/fix-738264
Merge into: lp:clicompanion
Diff against target: 200 lines (+96/-13)
2 files modified
clicompanionlib/controller.py (+85/-10)
clicompanionlib/view.py (+11/-3)
To merge this branch: bzr merge lp:~bdfhjk/clicompanion/fix-738264
Reviewer Review Type Date Requested Status
Duane Hinnen Approve
Review via email: mp+54122@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Duane Hinnen (duanedesign) wrote :

This great. Looks good.
This has been bugging me for awhile now. No pun intended. Glad it is fixed.
good work!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'clicompanionlib/controller.py'
2--- clicompanionlib/controller.py 2011-03-18 15:46:30 +0000
3+++ clicompanionlib/controller.py 2011-03-20 12:29:23 +0000
4@@ -163,7 +163,7 @@
5 l = str(text1+":"+text2+":"+text3)
6 #ls = l.split(':',2)
7 ## update view.CMNDS variable
8- filteredcommandplus = text1, text2
9+ filteredcommandplus = text1, text2, text3
10 view.CMNDS.append(filteredcommandplus)
11 ## update the command list on screen
12 liststore.append([text1,text2,text3])
13@@ -176,9 +176,21 @@
14
15 ## This the edit function
16 def edit_command(self, widget , liststore):
17-
18- row_int = int(view.ROW[0][0])
19-
20+
21+ row_int_x = int(view.ROW[0][0])
22+ row_int = 0
23+ ## TODO: Not implemented with filted yet
24+ if view.FILTER == 1:
25+ with open(CHEATSHEET, "r") as cheatfile:
26+ cheatlines = cheatfile.readlines()
27+ for i in range(len(cheatlines)):
28+ if view.CMNDS[row_int_x][0] in cheatlines[i] and view.CMNDS[row_int_x][1] in cheatlines[i] :
29+ row_int = i
30+ cheatfile.close()
31+ else:
32+ row_int = row_int_x
33+
34+
35 row_obj1 = view.MainWindow.liststore[row_int][0]
36 text1 = "".join(row_obj1)
37
38@@ -250,7 +262,7 @@
39 l = str(text1+":"+text2+":"+text3)
40 #ls = l.split(':',2)
41 ## update view.CMNDS variable
42- filteredcommandplus = text1, text2
43+ filteredcommandplus = text1, text2, text3
44 view.CMNDS.append(filteredcommandplus)
45 ## update the command list on screen
46 liststore.append([text1,text2,text3])
47@@ -262,9 +274,21 @@
48
49 ## Remove command from command file and GUI
50 def remove_command(self, widget, liststore):
51+
52+ row_int_x = int(view.ROW[0][0])
53+ row_int = 0
54+ ## TODO: Not implemented with filted yet
55+ if view.FILTER == 1:
56+ with open(CHEATSHEET, "r") as cheatfile:
57+ cheatlines = cheatfile.readlines()
58+ for i in range(len(cheatlines)):
59+ if view.CMNDS[row_int_x][0] in cheatlines[i] and view.CMNDS[row_int_x][1] in cheatlines[i]:
60+ row_int = i
61+ cheatfile.close()
62+ else:
63+ row_int = row_int_x
64
65- row_int = int(view.ROW[0][0]) #convert pathlist into something usable
66- del view.CMNDS[row_int]
67+ del view.CMNDS[row_int_x]
68 del liststore[row_int]
69
70 ## open command file and delete line so the change is persistent
71@@ -285,6 +309,10 @@
72 Pretty straight-forward.
73 """
74 search_term = widget.get_text().lower()
75+ if search_term == "":
76+ view.FILTER = 0
77+ else:
78+ view.FILTER = 1
79
80 ## Create a TreeModelFilter object which provides auxiliary functions for
81 ## filtering data.
82@@ -303,6 +331,11 @@
83 ## Python raises a TypeError if row data doesn't exist. Catch
84 ## that and fail silently.
85 pass
86+ except AttributeError:
87+ ## Python raises a AttributeError if row data was modified . Catch
88+ ## that and fail silently.
89+ pass
90+
91
92 modelfilter.set_visible_func(search, search_term)
93 treeview.set_model(modelfilter)
94@@ -312,13 +345,14 @@
95 view.CMNDS = []
96 for line in modelfilter:
97 linelist = line
98- filteredcommandplus = linelist[0], linelist[1]
99+ filteredcommandplus = linelist[0], linelist[1], linelist[2]
100 view.CMNDS.append(filteredcommandplus)
101
102
103
104 ## send the command to the terminal
105 def run_command(self, widget, notebook, liststore):
106+
107 text = ""
108 row_int = int(view.ROW[0][0]) ## removes everything but number from [5,]
109
110@@ -369,7 +403,21 @@
111
112 ## open the man page for selected command
113 def man_page(self, widget, notebook):
114- row_int = int(view.ROW[0][0]) # removes everything but number from EX: [5,]
115+ try:
116+ row_int = int(view.ROW[0][0]) # removes everything but number from EX: [5,]
117+ except IndexError:
118+ ## When user not choose row, when is in filter mode
119+ dialog = gtk.MessageDialog(
120+ None,
121+ gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
122+ gtk.MESSAGE_QUESTION,
123+ gtk.BUTTONS_OK,
124+ None)
125+ dialog.set_markup('You must choose row to view help')
126+ dialog.show_all()
127+ dialog.run()
128+ dialog.destroy()
129+ return
130 cmnd = view.CMNDS[row_int][0] #CMNDS is where commands are store
131 splitcommand = self._filter_sudo_from(cmnd.split(" "))
132 ## get current notebook tab to use in function
133@@ -423,7 +471,34 @@
134
135 ## Help --> About and Help --> Help menus
136 def about_event(self, widget, data=None):
137- pass
138+ # Create AboutDialog object
139+ dialog = gtk.AboutDialog()
140+
141+ # Add the application name to the dialog
142+ dialog.set_name('CLI Companion ')
143+
144+ # Set the application version
145+ dialog.set_version('1.0')
146+
147+ # Pass a list of authors. This is then connected to the 'Credits'
148+ # button. When clicked the buttons opens a new window showing
149+ # each author on their own line.
150+ dialog.set_authors(['Duane Hinnen', 'Kenny Meyer', 'Marcos Vanetta'])
151+
152+ # Add a short comment about the application, this appears below the application
153+ # name in the dialog
154+ dialog.set_comments('This is a CLI Companion program.')
155+
156+ # Add license information, this is connected to the 'License' button
157+ # and is displayed in a new window.
158+ dialog.set_license('Distributed under the GNU license. You can see it at <http://www.gnu.org/licenses/>.')
159+
160+ # Show the dialog
161+ dialog.run()
162+
163+ # The destroy method must be called otherwise the 'Close' button will
164+ # not work.
165+ dialog.destroy()
166 def help_event(self, widget, data=None):
167 webbrowser.open("http://okiebuntu.homelinux.com/okwiki/clicompanion")
168
169
170=== modified file 'clicompanionlib/view.py'
171--- clicompanionlib/view.py 2011-03-18 15:46:30 +0000
172+++ clicompanionlib/view.py 2011-03-20 12:29:23 +0000
173@@ -51,9 +51,17 @@
174 CONFIGFILE = os.path.expanduser("~/.config/clicompanion/config")
175 CHEATSHEET = os.path.expanduser("~/.clicompanion2")
176 CONFIG_ORIG = "/etc/clicompanion.d/clicompanion2.config"
177-CMNDS = [] ## will hold the commands. Actually the first two columns
178+
179+## Changed two->three columns
180+CMNDS = [] ## will hold the commands. Actually the first three columns
181 ROW = '1' ## holds the currently selected row
182-
183+TARGETS = [
184+ ('MY_TREE_MODEL_ROW', gtk.TARGET_SAME_WIDGET, 0),
185+ ('text/plain', 0, 1),
186+ ('TEXT', 0, 2),
187+ ('STRING', 0, 3),
188+ ]
189+FILTER = 0
190
191
192 class MainWindow():
193@@ -75,7 +83,7 @@
194 ## add bug data from .clicompanion --> bugdata --> to the liststore
195 for line in bugdata.splitlines():
196 l = line.split(':',2)
197- commandplus = l[0], l[1]
198+ commandplus = l[0], l[1], l[2]
199 CMNDS.append(commandplus)
200 self.liststore.append([l[0],l[1],l[2]])
201

Subscribers

People subscribed via source and target branches