Merge lp:~simar/clicompanion/fix-738260 into lp:clicompanion

Proposed by Gursimran singh
Status: Merged
Merged at revision: 78
Proposed branch: lp:~simar/clicompanion/fix-738260
Merge into: lp:clicompanion
Diff against target: 89 lines (+12/-42) (has conflicts)
2 files modified
clicompanionlib/controller.py (+0/-42)
clicompanionlib/view.py (+12/-0)
Text conflict in clicompanionlib/view.py
To merge this branch: bzr merge lp:~simar/clicompanion/fix-738260
Reviewer Review Type Date Requested Status
Duane Hinnen Approve
Review via email: mp+55731@code.launchpad.net

Description of the change

There was a built in functionality of drap and drop in pygtk treeview widget. So I removed all the drag and drop code and used that functionality. It fits nicely.

        self.treeview.set_reorderable(True)

To post a comment you must log in.
Revision history for this message
Duane Hinnen (duanedesign) wrote :

I do not know how you figured this out, but great job. This is a much much better solution for adding drag and drop. 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-29 17:31:11 +0000
+++ clicompanionlib/controller.py 2011-03-31 11:15:53 +0000
@@ -641,45 +641,3 @@
641 ## not work.641 ## not work.
642 dialog.destroy()642 dialog.destroy()
643 643
644
645 ## drag and drop
646 def drag_data_get_data(self, treeview, context, selection, target_id,
647 etime):
648 treeselection = treeview.get_selection()
649 model, iter = treeselection.get_selected()
650 data = model.get(iter, 0,1,2)
651
652
653 selection.set(selection.target, 8, str(data))
654 ## drag and drop
655 def drag_data_received_data(self, treeview, context, x, y, selection,
656 info, etime):
657 model = treeview.get_model()
658 data_selection = selection.data
659 data = str(data_selection).split(',')
660 print data[0][2:-1]
661 print data[1][2:-1]
662 print data[2][2:-2]
663 drop_info = treeview.get_dest_row_at_pos(x, y)
664 if drop_info:
665 path, position = drop_info
666 iter = model.get_iter(path)
667 if (position == gtk.TREE_VIEW_DROP_BEFORE
668 or position == gtk.TREE_VIEW_DROP_INTO_OR_BEFORE):
669 model.set(iter, 0, data[0][2:-1],1, data[1][2:-1],2, data[2][2:-2])
670 else:
671 model.set(iter, 0, data[0][2:-1],1, data[1][2:-1],2, data[2][2:-2])
672 else:
673 model.append([data])
674 if context.action == gtk.gdk.ACTION_MOVE:
675 context.finish(True, True, etime)
676 return
677
678
679
680
681
682
683
684
685
686644
=== modified file 'clicompanionlib/view.py'
--- clicompanionlib/view.py 2011-03-29 17:31:11 +0000
+++ clicompanionlib/view.py 2011-03-31 11:15:53 +0000
@@ -255,9 +255,16 @@
255 255
256 ''' set treeview model and put treeview in the scrolled window256 ''' set treeview model and put treeview in the scrolled window
257 and the scrolled window in the expander. '''257 and the scrolled window in the expander. '''
258<<<<<<< TREE
258 self.treeview.set_model(self.liststore)259 self.treeview.set_model(self.liststore)
259 self.scrolledwindow.add(self.treeview)260 self.scrolledwindow.add(self.treeview)
260 self.expander.add(self.scrolledwindow)261 self.expander.add(self.scrolledwindow)
262=======
263 treeview.set_model(self.liststore)
264 treeview.set_reorderable(True)
265 scrolledwindow.add(treeview)
266 expander.add(scrolledwindow)
267>>>>>>> MERGE-SOURCE
261 #self.window.show_all()268 #self.window.show_all()
262269
263 ## instantiate tabs270 ## instantiate tabs
@@ -299,6 +306,7 @@
299 ## double-click306 ## double-click
300 self.treeview.connect("button-press-event", treeview_clicked)307 self.treeview.connect("button-press-event", treeview_clicked)
301 #press enter to run command308 #press enter to run command
309<<<<<<< TREE
302 self.treeview.connect("key-press-event", treeview_button)310 self.treeview.connect("key-press-event", treeview_button)
303 311
304 ##drag and drop312 ##drag and drop
@@ -307,6 +315,10 @@
307 self.treeview.connect("drag_data_get", actions.drag_data_get_data)315 self.treeview.connect("drag_data_get", actions.drag_data_get_data)
308 self.treeview.connect("drag_data_received", actions.drag_data_received_data)316 self.treeview.connect("drag_data_received", actions.drag_data_received_data)
309 317
318=======
319 treeview.connect("key-press-event", treeview_button)
320
321>>>>>>> MERGE-SOURCE
310 global menu_search_hbox322 global menu_search_hbox
311 323
312 ## The search section324 ## The search section

Subscribers

People subscribed via source and target branches