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
1=== modified file 'clicompanionlib/config.py'
2--- clicompanionlib/config.py 2012-01-09 09:17:27 +0000
3+++ clicompanionlib/config.py 2012-01-09 10:51:28 +0000
4@@ -78,6 +78,8 @@
5 'edit_command': 'unused',
6 'add_tab': 'F7',
7 'close_tab': 'unused',
8+ 'next_tab': 'unused',
9+ 'previous_tab': 'unused',
10 'toggle_fullscreen': 'F12',
11 'toggle_maximize': 'F11',
12 'toggle_hide_ui': 'F9',
13@@ -94,6 +96,8 @@
14 'edit_command': 'Edit command',
15 'add_tab': 'Add tab',
16 'close_tab': 'Close tab',
17+ 'next_tab': 'Go to the next tab',
18+ 'previous_tab': 'Go to the previous tab',
19 'toggle_fullscreen': 'Toggle fullscreen',
20 'toggle_maximize': 'Maximize',
21 'toggle_hide_ui': 'Hide UI',
22
23=== modified file 'clicompanionlib/tabs.py'
24--- clicompanionlib/tabs.py 2012-01-08 00:48:43 +0000
25+++ clicompanionlib/tabs.py 2012-01-09 10:51:28 +0000
26@@ -391,6 +391,18 @@
27 if self.get_n_pages() != 1:
28 self.focus()
29
30+ def next_tab(self):
31+ if self.get_current_page() == self.get_n_pages() - 2:
32+ self.set_current_page(0)
33+ else:
34+ self.next_page()
35+
36+ def prev_tab(self):
37+ if self.get_current_page() == 0:
38+ self.set_current_page(self.get_n_pages() - 2)
39+ else:
40+ self.prev_page()
41+
42 def quit_tab(self, tab=None):
43 if not tab:
44 tab = self.get_nth_page(self.get_current_page())
45
46=== modified file 'clicompanionlib/view.py'
47--- clicompanionlib/view.py 2012-01-08 00:48:43 +0000
48+++ clicompanionlib/view.py 2012-01-09 10:51:28 +0000
49@@ -332,20 +332,6 @@
50 self.cmd_notebook.get_command()[0]).run())
51 self.button_box.connect('add_tab',
52 lambda *x: self.term_notebook.add_tab())
53- ## right click menu event capture
54- # Allow enable drag and drop of rows including row move
55-# self.treeview.enable_model_drag_source( gtk.gdk.BUTTON1_MASK,
56-# TARGETS,
57-# gtk.gdk.ACTION_DEFAULT |
58-# gtk.gdk.ACTION_COPY)
59-# self.treeview.enable_model_drag_dest(TARGETS,
60-# gtk.gdk.ACTION_DEFAULT)
61-#
62-# self.treeview.connect ("drag_data_get", self.drag_data_get_event)
63-# self.treeview.connect ("drag_data_received",
64-# self.drag_data_received_event)
65-# self.treeview.connect("drag_drop", self.on_drag_drop )
66-
67 ## show everything
68 self.show_all()
69 ## set the focus on the terminal
70@@ -468,6 +454,12 @@
71 def close_tab(self):
72 self.term_notebook.quit_tab()
73
74+ def next_tab(self):
75+ self.term_notebook.next_tab()
76+
77+ def previous_tab(self):
78+ self.term_notebook.prev_tab()
79+
80 def toggle_hide_ui(self):
81 if self.hiddenui:
82 self.show_ui()
83@@ -478,15 +470,19 @@
84 if self.hiddenui:
85 return
86 dbg('Hide UI')
87+ self.set_border_width(0)
88 self.l_vbox.remove(self.term_notebook)
89 self.remove(self.vpane)
90 self.add(self.term_notebook)
91 self.hiddenui = True
92+ ## set the focus on the terminal
93+ self.term_notebook.focus()
94
95 def show_ui(self):
96 if not self.hiddenui:
97 return
98 dbg('Show UI')
99+ self.set_border_width(5)
100 self.remove(self.term_notebook)
101 btns = self.l_vbox.get_children()[0]
102 self.l_vbox.remove(btns)
103@@ -494,12 +490,16 @@
104 self.l_vbox.pack_start(btns, False, False, 0)
105 self.add(self.vpane)
106 self.hiddenui = False
107+ ## set the focus on the terminal
108+ self.term_notebook.focus()
109
110 def toggle_maximize(self):
111 if not self.maximized:
112 self.maximize()
113 else:
114 self.unmaximize()
115+ ## set the focus on the terminal
116+ self.term_notebook.focus()
117 self.maximized = not self.maximized
118
119 def toggle_fullscreen(self):
120@@ -516,70 +516,8 @@
121 self.unfullscreen()
122 self.set_border_width(5)
123 self.fullscr = not self.fullscr
124-
125- ### TODO: pass these functions to the LocalCommandList class
126- def on_drag_drop(self, treeview, *x):
127- '''
128- Stop the signal when in search mode
129- '''
130- if self.FILTER:
131- treeview.stop_emission('drag_drop')
132-
133- def drag_data_get_event(self, treeview, context, selection, target_id,
134- etime):
135- """
136- Executed on dragging
137- """
138- treeselection = treeview.get_selection()
139- model, iter = treeselection.get_selected()
140- data = model.get(iter, 0, 1, 2)
141- selection.set(selection.target, 8, '\t'.join(data))
142-
143- def drag_data_received_event(self, treeview, context, x, y, selection,
144- info, etime):
145- """
146- Executed when dropping.
147- """
148- global CMNDS
149- ## if we are in a search, do nothing
150- if self.FILTER == 1:
151- return
152- model = treeview.get_model()
153- ## get the destination
154- drop_info = treeview.get_dest_row_at_pos(x, y)
155- if drop_info:
156- path, position = drop_info
157- iter = model.get_iter(path)
158- dest = list(model.get(iter, 0, 1, 2))
159-
160- ## parse all the incoming commands
161- for data in selection.data.split('\n'):
162- # if we got an empty line skip it
163- if not data.replace('\r', ''):
164- continue
165- # format the incoming string
166- orig = data.replace('\r', '').split('\t', 2)
167- orig = [fld.strip() for fld in orig]
168- # fill the empty fields
169- if len(orig) < 3:
170- orig = orig + ('', ) * (3 - len(orig))
171- dbg('Got drop of command %s' % '_\t_'.join(orig))
172-
173- if drop_info:
174- if (position == gtk.TREE_VIEW_DROP_BEFORE
175- or position == gtk.TREE_VIEW_DROP_INTO_OR_BEFORE):
176- dbg('\t to before dest %s' % '_\t_'.join(dest))
177- CMNDS.drag_n_drop(orig, dest, before=True)
178- else:
179- dbg('\t to after dest %s' % '_\t_'.join(dest))
180- CMNDS.drag_n_drop(orig, dest, before=False)
181- else:
182- dbg('\t to the end')
183- CMNDS[len(CMNDS)] = orig
184- if context.action == gtk.gdk.ACTION_MOVE:
185- context.finish(True, True, etime)
186- self.sync_cmnds()
187- CMNDS.save()
188+ ## set the focus on the terminal
189+ self.term_notebook.focus()
190
191 def main(self):
192 try:

Subscribers

People subscribed via source and target branches