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
=== modified file 'clicompanionlib/controller.py'
--- clicompanionlib/controller.py 2011-03-18 15:46:30 +0000
+++ clicompanionlib/controller.py 2011-03-20 12:29:23 +0000
@@ -163,7 +163,7 @@
163 l = str(text1+":"+text2+":"+text3)163 l = str(text1+":"+text2+":"+text3)
164 #ls = l.split(':',2)164 #ls = l.split(':',2)
165 ## update view.CMNDS variable165 ## update view.CMNDS variable
166 filteredcommandplus = text1, text2166 filteredcommandplus = text1, text2, text3
167 view.CMNDS.append(filteredcommandplus)167 view.CMNDS.append(filteredcommandplus)
168 ## update the command list on screen168 ## update the command list on screen
169 liststore.append([text1,text2,text3])169 liststore.append([text1,text2,text3])
@@ -176,9 +176,21 @@
176176
177 ## This the edit function177 ## This the edit function
178 def edit_command(self, widget , liststore):178 def edit_command(self, widget , liststore):
179179
180 row_int = int(view.ROW[0][0])180 row_int_x = int(view.ROW[0][0])
181181 row_int = 0
182 ## TODO: Not implemented with filted yet
183 if view.FILTER == 1:
184 with open(CHEATSHEET, "r") as cheatfile:
185 cheatlines = cheatfile.readlines()
186 for i in range(len(cheatlines)):
187 if view.CMNDS[row_int_x][0] in cheatlines[i] and view.CMNDS[row_int_x][1] in cheatlines[i] :
188 row_int = i
189 cheatfile.close()
190 else:
191 row_int = row_int_x
192
193
182 row_obj1 = view.MainWindow.liststore[row_int][0]194 row_obj1 = view.MainWindow.liststore[row_int][0]
183 text1 = "".join(row_obj1)195 text1 = "".join(row_obj1)
184196
@@ -250,7 +262,7 @@
250 l = str(text1+":"+text2+":"+text3)262 l = str(text1+":"+text2+":"+text3)
251 #ls = l.split(':',2)263 #ls = l.split(':',2)
252 ## update view.CMNDS variable264 ## update view.CMNDS variable
253 filteredcommandplus = text1, text2265 filteredcommandplus = text1, text2, text3
254 view.CMNDS.append(filteredcommandplus)266 view.CMNDS.append(filteredcommandplus)
255 ## update the command list on screen267 ## update the command list on screen
256 liststore.append([text1,text2,text3])268 liststore.append([text1,text2,text3])
@@ -262,9 +274,21 @@
262274
263 ## Remove command from command file and GUI275 ## Remove command from command file and GUI
264 def remove_command(self, widget, liststore):276 def remove_command(self, widget, liststore):
277
278 row_int_x = int(view.ROW[0][0])
279 row_int = 0
280 ## TODO: Not implemented with filted yet
281 if view.FILTER == 1:
282 with open(CHEATSHEET, "r") as cheatfile:
283 cheatlines = cheatfile.readlines()
284 for i in range(len(cheatlines)):
285 if view.CMNDS[row_int_x][0] in cheatlines[i] and view.CMNDS[row_int_x][1] in cheatlines[i]:
286 row_int = i
287 cheatfile.close()
288 else:
289 row_int = row_int_x
265290
266 row_int = int(view.ROW[0][0]) #convert pathlist into something usable 291 del view.CMNDS[row_int_x]
267 del view.CMNDS[row_int]
268 del liststore[row_int]292 del liststore[row_int]
269293
270 ## open command file and delete line so the change is persistent294 ## open command file and delete line so the change is persistent
@@ -285,6 +309,10 @@
285 Pretty straight-forward.309 Pretty straight-forward.
286 """310 """
287 search_term = widget.get_text().lower()311 search_term = widget.get_text().lower()
312 if search_term == "":
313 view.FILTER = 0
314 else:
315 view.FILTER = 1
288 316
289 ## Create a TreeModelFilter object which provides auxiliary functions for317 ## Create a TreeModelFilter object which provides auxiliary functions for
290 ## filtering data.318 ## filtering data.
@@ -303,6 +331,11 @@
303 ## Python raises a TypeError if row data doesn't exist. Catch331 ## Python raises a TypeError if row data doesn't exist. Catch
304 ## that and fail silently.332 ## that and fail silently.
305 pass333 pass
334 except AttributeError:
335 ## Python raises a AttributeError if row data was modified . Catch
336 ## that and fail silently.
337 pass
338
306339
307 modelfilter.set_visible_func(search, search_term)340 modelfilter.set_visible_func(search, search_term)
308 treeview.set_model(modelfilter)341 treeview.set_model(modelfilter)
@@ -312,13 +345,14 @@
312 view.CMNDS = []345 view.CMNDS = []
313 for line in modelfilter:346 for line in modelfilter:
314 linelist = line347 linelist = line
315 filteredcommandplus = linelist[0], linelist[1]348 filteredcommandplus = linelist[0], linelist[1], linelist[2]
316 view.CMNDS.append(filteredcommandplus)349 view.CMNDS.append(filteredcommandplus)
317350
318351
319352
320 ## send the command to the terminal353 ## send the command to the terminal
321 def run_command(self, widget, notebook, liststore):354 def run_command(self, widget, notebook, liststore):
355
322 text = ""356 text = ""
323 row_int = int(view.ROW[0][0]) ## removes everything but number from [5,]357 row_int = int(view.ROW[0][0]) ## removes everything but number from [5,]
324358
@@ -369,7 +403,21 @@
369 403
370 ## open the man page for selected command404 ## open the man page for selected command
371 def man_page(self, widget, notebook):405 def man_page(self, widget, notebook):
372 row_int = int(view.ROW[0][0]) # removes everything but number from EX: [5,]406 try:
407 row_int = int(view.ROW[0][0]) # removes everything but number from EX: [5,]
408 except IndexError:
409 ## When user not choose row, when is in filter mode
410 dialog = gtk.MessageDialog(
411 None,
412 gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
413 gtk.MESSAGE_QUESTION,
414 gtk.BUTTONS_OK,
415 None)
416 dialog.set_markup('You must choose row to view help')
417 dialog.show_all()
418 dialog.run()
419 dialog.destroy()
420 return
373 cmnd = view.CMNDS[row_int][0] #CMNDS is where commands are store421 cmnd = view.CMNDS[row_int][0] #CMNDS is where commands are store
374 splitcommand = self._filter_sudo_from(cmnd.split(" "))422 splitcommand = self._filter_sudo_from(cmnd.split(" "))
375 ## get current notebook tab to use in function423 ## get current notebook tab to use in function
@@ -423,7 +471,34 @@
423 471
424 ## Help --> About and Help --> Help menus472 ## Help --> About and Help --> Help menus
425 def about_event(self, widget, data=None):473 def about_event(self, widget, data=None):
426 pass474 # Create AboutDialog object
475 dialog = gtk.AboutDialog()
476
477 # Add the application name to the dialog
478 dialog.set_name('CLI Companion ')
479
480 # Set the application version
481 dialog.set_version('1.0')
482
483 # Pass a list of authors. This is then connected to the 'Credits'
484 # button. When clicked the buttons opens a new window showing
485 # each author on their own line.
486 dialog.set_authors(['Duane Hinnen', 'Kenny Meyer', 'Marcos Vanetta'])
487
488 # Add a short comment about the application, this appears below the application
489 # name in the dialog
490 dialog.set_comments('This is a CLI Companion program.')
491
492 # Add license information, this is connected to the 'License' button
493 # and is displayed in a new window.
494 dialog.set_license('Distributed under the GNU license. You can see it at <http://www.gnu.org/licenses/>.')
495
496 # Show the dialog
497 dialog.run()
498
499 # The destroy method must be called otherwise the 'Close' button will
500 # not work.
501 dialog.destroy()
427 def help_event(self, widget, data=None):502 def help_event(self, widget, data=None):
428 webbrowser.open("http://okiebuntu.homelinux.com/okwiki/clicompanion")503 webbrowser.open("http://okiebuntu.homelinux.com/okwiki/clicompanion")
429 504
430505
=== modified file 'clicompanionlib/view.py'
--- clicompanionlib/view.py 2011-03-18 15:46:30 +0000
+++ clicompanionlib/view.py 2011-03-20 12:29:23 +0000
@@ -51,9 +51,17 @@
51CONFIGFILE = os.path.expanduser("~/.config/clicompanion/config")51CONFIGFILE = os.path.expanduser("~/.config/clicompanion/config")
52CHEATSHEET = os.path.expanduser("~/.clicompanion2")52CHEATSHEET = os.path.expanduser("~/.clicompanion2")
53CONFIG_ORIG = "/etc/clicompanion.d/clicompanion2.config"53CONFIG_ORIG = "/etc/clicompanion.d/clicompanion2.config"
54CMNDS = [] ## will hold the commands. Actually the first two columns54
55## Changed two->three columns
56CMNDS = [] ## will hold the commands. Actually the first three columns
55ROW = '1' ## holds the currently selected row57ROW = '1' ## holds the currently selected row
5658TARGETS = [
59 ('MY_TREE_MODEL_ROW', gtk.TARGET_SAME_WIDGET, 0),
60 ('text/plain', 0, 1),
61 ('TEXT', 0, 2),
62 ('STRING', 0, 3),
63 ]
64FILTER = 0
5765
5866
59class MainWindow():67class MainWindow():
@@ -75,7 +83,7 @@
75 ## add bug data from .clicompanion --> bugdata --> to the liststore83 ## add bug data from .clicompanion --> bugdata --> to the liststore
76 for line in bugdata.splitlines():84 for line in bugdata.splitlines():
77 l = line.split(':',2)85 l = line.split(':',2)
78 commandplus = l[0], l[1]86 commandplus = l[0], l[1], l[2]
79 CMNDS.append(commandplus)87 CMNDS.append(commandplus)
80 self.liststore.append([l[0],l[1],l[2]])88 self.liststore.append([l[0],l[1],l[2]])
8189

Subscribers

People subscribed via source and target branches