Merge lp:~dcaro/clicompanion/fix-913436 into lp:clicompanion

Proposed by David Caro
Status: Merged
Approved by: Marek Bardoński
Approved revision: no longer in the source branch.
Merged at revision: 103
Proposed branch: lp:~dcaro/clicompanion/fix-913436
Merge into: lp:clicompanion
Diff against target: 192 lines (+32/-78)
3 files modified
clicompanionlib/config.py (+4/-0)
clicompanionlib/tabs.py (+12/-0)
clicompanionlib/view.py (+16/-78)
To merge this branch: bzr merge lp:~dcaro/clicompanion/fix-913436
Reviewer Review Type Date Requested Status
Marek Bardoński Approve
Review via email: mp+87873@code.launchpad.net

Description of the change

Just added the two shorcuts to the list of shorcuts.

To post a comment you must log in.
Revision history for this message
Marek Bardoński (bdfhjk) wrote :

Work fine.

I'm curious why did You deleted some lines regarding drag'n'drop, but it stil work.

Could You, David, look at a bug which I discovered testing d'n'd:

"""
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/plugins/LocalCommandList.py", line 356, in drag_data_received_event
    self.cmnds.drag_n_drop(orig, dest, before=True)
  File "/usr/local/lib/python2.7/dist-packages/plugins/LocalCommandList.py", line 599, in drag_n_drop
    i2 = self.commands.index(cmd2)
ValueError: ['dpkg -l ?', 'package', 'Find version of a package'] is not in list
/usr/local/lib/python2.7/dist-packages/clicompanionlib/view.py:524: GtkWarning: IA__gtk_tree_drag_dest_drag_data_received: assertion `iface->drag_data_received != NULL' failed
  gtk.main()

"""

I will occur when You drop command over the list.

review: Approve
Revision history for this message
David Caro (dcaro) wrote :

The lines deleted for the drag and drop where moved before to another module (from view to LocalCommandList), so they were not needed anymore there.

The bug should be fixed now,

lp:~dcaro/clicompanion/fix-913436 updated
104. By David Caro "<email address hidden>"

fixed error when dropping text from another program

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'clicompanionlib/config.py'
--- clicompanionlib/config.py 2012-01-09 09:17:27 +0000
+++ clicompanionlib/config.py 2012-01-09 10:51:28 +0000
@@ -78,6 +78,8 @@
78 'edit_command': 'unused',78 'edit_command': 'unused',
79 'add_tab': 'F7',79 'add_tab': 'F7',
80 'close_tab': 'unused',80 'close_tab': 'unused',
81 'next_tab': 'unused',
82 'previous_tab': 'unused',
81 'toggle_fullscreen': 'F12',83 'toggle_fullscreen': 'F12',
82 'toggle_maximize': 'F11',84 'toggle_maximize': 'F11',
83 'toggle_hide_ui': 'F9',85 'toggle_hide_ui': 'F9',
@@ -94,6 +96,8 @@
94 'edit_command': 'Edit command',96 'edit_command': 'Edit command',
95 'add_tab': 'Add tab',97 'add_tab': 'Add tab',
96 'close_tab': 'Close tab',98 'close_tab': 'Close tab',
99 'next_tab': 'Go to the next tab',
100 'previous_tab': 'Go to the previous tab',
97 'toggle_fullscreen': 'Toggle fullscreen',101 'toggle_fullscreen': 'Toggle fullscreen',
98 'toggle_maximize': 'Maximize',102 'toggle_maximize': 'Maximize',
99 'toggle_hide_ui': 'Hide UI',103 'toggle_hide_ui': 'Hide UI',
100104
=== modified file 'clicompanionlib/tabs.py'
--- clicompanionlib/tabs.py 2012-01-08 00:48:43 +0000
+++ clicompanionlib/tabs.py 2012-01-09 10:51:28 +0000
@@ -391,6 +391,18 @@
391 if self.get_n_pages() != 1:391 if self.get_n_pages() != 1:
392 self.focus()392 self.focus()
393393
394 def next_tab(self):
395 if self.get_current_page() == self.get_n_pages() - 2:
396 self.set_current_page(0)
397 else:
398 self.next_page()
399
400 def prev_tab(self):
401 if self.get_current_page() == 0:
402 self.set_current_page(self.get_n_pages() - 2)
403 else:
404 self.prev_page()
405
394 def quit_tab(self, tab=None):406 def quit_tab(self, tab=None):
395 if not tab:407 if not tab:
396 tab = self.get_nth_page(self.get_current_page())408 tab = self.get_nth_page(self.get_current_page())
397409
=== modified file 'clicompanionlib/view.py'
--- clicompanionlib/view.py 2012-01-08 00:48:43 +0000
+++ clicompanionlib/view.py 2012-01-09 10:51:28 +0000
@@ -332,20 +332,6 @@
332 self.cmd_notebook.get_command()[0]).run())332 self.cmd_notebook.get_command()[0]).run())
333 self.button_box.connect('add_tab',333 self.button_box.connect('add_tab',
334 lambda *x: self.term_notebook.add_tab())334 lambda *x: self.term_notebook.add_tab())
335 ## right click menu event capture
336 # Allow enable drag and drop of rows including row move
337# self.treeview.enable_model_drag_source( gtk.gdk.BUTTON1_MASK,
338# TARGETS,
339# gtk.gdk.ACTION_DEFAULT |
340# gtk.gdk.ACTION_COPY)
341# self.treeview.enable_model_drag_dest(TARGETS,
342# gtk.gdk.ACTION_DEFAULT)
343#
344# self.treeview.connect ("drag_data_get", self.drag_data_get_event)
345# self.treeview.connect ("drag_data_received",
346# self.drag_data_received_event)
347# self.treeview.connect("drag_drop", self.on_drag_drop )
348
349 ## show everything335 ## show everything
350 self.show_all()336 self.show_all()
351 ## set the focus on the terminal337 ## set the focus on the terminal
@@ -468,6 +454,12 @@
468 def close_tab(self):454 def close_tab(self):
469 self.term_notebook.quit_tab()455 self.term_notebook.quit_tab()
470456
457 def next_tab(self):
458 self.term_notebook.next_tab()
459
460 def previous_tab(self):
461 self.term_notebook.prev_tab()
462
471 def toggle_hide_ui(self):463 def toggle_hide_ui(self):
472 if self.hiddenui:464 if self.hiddenui:
473 self.show_ui()465 self.show_ui()
@@ -478,15 +470,19 @@
478 if self.hiddenui:470 if self.hiddenui:
479 return471 return
480 dbg('Hide UI')472 dbg('Hide UI')
473 self.set_border_width(0)
481 self.l_vbox.remove(self.term_notebook)474 self.l_vbox.remove(self.term_notebook)
482 self.remove(self.vpane)475 self.remove(self.vpane)
483 self.add(self.term_notebook)476 self.add(self.term_notebook)
484 self.hiddenui = True477 self.hiddenui = True
478 ## set the focus on the terminal
479 self.term_notebook.focus()
485480
486 def show_ui(self):481 def show_ui(self):
487 if not self.hiddenui:482 if not self.hiddenui:
488 return483 return
489 dbg('Show UI')484 dbg('Show UI')
485 self.set_border_width(5)
490 self.remove(self.term_notebook)486 self.remove(self.term_notebook)
491 btns = self.l_vbox.get_children()[0]487 btns = self.l_vbox.get_children()[0]
492 self.l_vbox.remove(btns)488 self.l_vbox.remove(btns)
@@ -494,12 +490,16 @@
494 self.l_vbox.pack_start(btns, False, False, 0)490 self.l_vbox.pack_start(btns, False, False, 0)
495 self.add(self.vpane)491 self.add(self.vpane)
496 self.hiddenui = False492 self.hiddenui = False
493 ## set the focus on the terminal
494 self.term_notebook.focus()
497495
498 def toggle_maximize(self):496 def toggle_maximize(self):
499 if not self.maximized:497 if not self.maximized:
500 self.maximize()498 self.maximize()
501 else:499 else:
502 self.unmaximize()500 self.unmaximize()
501 ## set the focus on the terminal
502 self.term_notebook.focus()
503 self.maximized = not self.maximized503 self.maximized = not self.maximized
504504
505 def toggle_fullscreen(self):505 def toggle_fullscreen(self):
@@ -516,70 +516,8 @@
516 self.unfullscreen()516 self.unfullscreen()
517 self.set_border_width(5)517 self.set_border_width(5)
518 self.fullscr = not self.fullscr518 self.fullscr = not self.fullscr
519519 ## set the focus on the terminal
520 ### TODO: pass these functions to the LocalCommandList class520 self.term_notebook.focus()
521 def on_drag_drop(self, treeview, *x):
522 '''
523 Stop the signal when in search mode
524 '''
525 if self.FILTER:
526 treeview.stop_emission('drag_drop')
527
528 def drag_data_get_event(self, treeview, context, selection, target_id,
529 etime):
530 """
531 Executed on dragging
532 """
533 treeselection = treeview.get_selection()
534 model, iter = treeselection.get_selected()
535 data = model.get(iter, 0, 1, 2)
536 selection.set(selection.target, 8, '\t'.join(data))
537
538 def drag_data_received_event(self, treeview, context, x, y, selection,
539 info, etime):
540 """
541 Executed when dropping.
542 """
543 global CMNDS
544 ## if we are in a search, do nothing
545 if self.FILTER == 1:
546 return
547 model = treeview.get_model()
548 ## get the destination
549 drop_info = treeview.get_dest_row_at_pos(x, y)
550 if drop_info:
551 path, position = drop_info
552 iter = model.get_iter(path)
553 dest = list(model.get(iter, 0, 1, 2))
554
555 ## parse all the incoming commands
556 for data in selection.data.split('\n'):
557 # if we got an empty line skip it
558 if not data.replace('\r', ''):
559 continue
560 # format the incoming string
561 orig = data.replace('\r', '').split('\t', 2)
562 orig = [fld.strip() for fld in orig]
563 # fill the empty fields
564 if len(orig) < 3:
565 orig = orig + ('', ) * (3 - len(orig))
566 dbg('Got drop of command %s' % '_\t_'.join(orig))
567
568 if drop_info:
569 if (position == gtk.TREE_VIEW_DROP_BEFORE
570 or position == gtk.TREE_VIEW_DROP_INTO_OR_BEFORE):
571 dbg('\t to before dest %s' % '_\t_'.join(dest))
572 CMNDS.drag_n_drop(orig, dest, before=True)
573 else:
574 dbg('\t to after dest %s' % '_\t_'.join(dest))
575 CMNDS.drag_n_drop(orig, dest, before=False)
576 else:
577 dbg('\t to the end')
578 CMNDS[len(CMNDS)] = orig
579 if context.action == gtk.gdk.ACTION_MOVE:
580 context.finish(True, True, etime)
581 self.sync_cmnds()
582 CMNDS.save()
583521
584 def main(self):522 def main(self):
585 try:523 try:

Subscribers

People subscribed via source and target branches