Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GraphView] Add drag and drop function [gramps51] #232

Open
wants to merge 15 commits into
base: maintenance/gramps51
Choose a base branch
from

Conversation

vantu5z
Copy link
Contributor

@vantu5z vantu5z commented Sep 23, 2019

fix 11093

I get as base PedigreeView, but we have difference:
PedigreeView have Gtk.Widgets and native drag&drop.
But GraphView use GooCanvas so we have to use workarounds to setup drag&drop.

Features:

  • drag person or family to clipboard
  • popup menu with availible actions on drop to nodes
    • at family node
      • drop person(s) adds them as children to family
      • drop 1 person add as spouse to family as mother or father (depen on gender)
    • at person node
      • drop 1 person adds relation (reference)
      • drop 1 person add as parent to existing family
      • drop 1 or 2 persons create family parents
    • drop family???
    • drop events???
    • drop tags??? we can't drag them?
  • drag persons from search/bookmark widget

Needs to be tested on each of the OS's

  • Linux
    • gtk++ : 3.24.34, pygobject : 3.42.1
    • gtk 3.12, pygobject : 3.12.0
  • Apple MacOS Package
  • Microsoft Windows AIO Installer

@vantu5z vantu5z changed the title [GraphView] Add drag and drop function [GraphView] Add drag and drop function [gramps51] Sep 23, 2019
@Mattkmmr
Copy link
Member

@vantu5z: Drag&drop does not work for me. Dragging works, symbol is shown, but the dropping to the clipboard fails.

@vantu5z
Copy link
Contributor Author

vantu5z commented Sep 24, 2019

Matt, can you provide more info?
OS, program versions, exception with it fails.
Is it works with text fields?

@Mattkmmr
Copy link
Member

Windows 10
Gramps 5.1.1
GTK+ 3.18.9

There aren't any exception raised. What do you mean with the text fields?

@vantu5z
Copy link
Contributor Author

vantu5z commented Sep 24, 2019

You can drop to text entry fields (where you can type) and other apps like notepad.

@Mattkmmr
Copy link
Member

No drag & drop to text fields is also not working.

@vantu5z
Copy link
Contributor Author

vantu5z commented Sep 24, 2019

Matt, can you test this:
In function "cb_drag_data_get" change "id(self)" to "id(self.get_widget())" or "id(widget)"

@sam-m888

This comment has been minimized.

@sam-m888
Copy link
Member

In function "cb_drag_data_get" change "id(self)" to "id(self.get_widget())" or "id(widget)"

Neither work on Windows AIO 64bit or 32 bit Gramps 5.1.1 on Win 10 (1903) 64bit

@PQYPLZXHGF
Copy link

PQYPLZXHGF commented Sep 25, 2019

Works but with a big catch, the drag works as per normal but for the drop you need to press the "Enter" Key (, which nobody would normally do with drag & drop) or else the drag icon stays on the screen unless you press Escape to cancel

test

On Windows 10 Home 64bit / Gramps 5.1.1

@vantu5z
Copy link
Contributor Author

vantu5z commented Sep 25, 2019

@PQYPLZXHGF can you test this on Windows:

  • in function motion_notify_event in call drag_widget.drag_begin_with_coordinates change parameter event to None
  • in call drag_widget.drag_begin_with_coordinates change parameter Gdk.ModifierType.BUTTON1_MASK to Gdk.KEY_Pointer_Button1 or Gdk.EventMask.BUTTON1_MOTION_MASK
  • try to change event window befor call drag_widget.drag_begin_with_coordinates, like this :
    event.window = drag_widget.get_window()

@vantu5z
Copy link
Contributor Author

vantu5z commented Sep 26, 2019

Now it should work in Windows.
I setup VirtualBox for testing. But it should be tested on real machines.
Mouse button param in drag_begin_with_coordinates should be 1 (as left mouse)

@sam-m888
Copy link
Member

Now it should work in Windows.

Confirming new changes work on Windows.

@jralls Do you have time to test on MacOS please?

@jralls
Copy link
Member

jralls commented Sep 27, 2019

It sort of works on MacOS. If I control-touch I get a page icon for a drag symbol. Releasing the control key adds a + in a green circle and I can then drag the page icon over to the clipboard window and when I lift my finger from the touchpad it adds the chart's focus person, not the person I dragged. The click-and-drag gesture doesn't work.

Attempting to drop on the name field of the filter gramplet does nothing.

If I don't release the control key the page icon does a fly-back when I lift my finger from the touchpad.

I used the Gramps-5.1.1-1 app bundle with Gtk 3.14.15, copying graphview.py over the latest released one. Unfortunately more recent versions of Gtk are unstable (bugs 9718 and 10434) with Gramps on MacOS though they work fine with C applications.

That said, drag and drop work as expected on the regular chart view: click and drag to the clipboard window drops the dragged person with no extra calisthenics required.

@vantu5z
Copy link
Contributor Author

vantu5z commented Sep 28, 2019

Seems this is touchpad issue.
Do you make tests with mouse?

Test in Linux with touchpad it works. Click-touch-and-drag.
You should start drag before simple click is handled and active person changed.

@sam-m888
Copy link
Member

sam-m888 commented Oct 4, 2019

my old laptop that has ubuntu 14.04 and gtk 3.10.8,

@wroldwiedbwe If you still have this laptop, can you test this PR works for you please?

@vantu5z
Copy link
Contributor Author

vantu5z commented Oct 28, 2019

rebased

@wroldwiedbwe
Copy link

@sam-m888 I only have my old laptop that has ubuntu 14.04 and gtk 3.10.8. , but yes it seems to work well 👍

@prculley
Copy link
Contributor

prculley commented Apr 8, 2020

Been a while, is this still a work in progress?

@vantu5z
Copy link
Contributor Author

vantu5z commented Apr 8, 2020

We have some problems with MacOS and I don't know how to fix this. On Linux and Windows should work fine.

@vantu5z
Copy link
Contributor Author

vantu5z commented Jan 18, 2021

Rebased

@vantu5z
Copy link
Contributor Author

vantu5z commented Jun 7, 2022

@jralls, I change drag-n-drop activation. Please, can you test if it works for you on Mac now?

@vantu5z
Copy link
Contributor Author

vantu5z commented Jun 7, 2022

Example, drop person from clipboard to family node:
изображение

@jralls
Copy link
Member

jralls commented Jun 7, 2022

@vantu5z, tested on 5.1.4.

Well, click-and-drag now works, and the first drag after startup works as expected except that it changes the focus person to the dragged person. Dropping on another person in the chart brings up an "add relationship" dialog and dropping on the clipboard window adds the person to the clipboard. So far so good. Dropping on the name field in the filter gramplet changes the chart as if I'd double-clicked on the person, which isn't what I'd expect.

With the selected person changed by the first drag subsequent drag attempts don't change the selected person and drop the person from the first drag unless I first explicitly change the selected person first by clicking on someone else.

To illustrate, suppose I have a chart with Alice, Barbara, Charles, David, and Edward. Charles is the selected person when I switch to Graph view. I click and drag Alice to the clipboard window; Alice becomes the selected person. I click and drag David to the clipboard and get Alice again. I double click on Barbara to make her the selected person, then try again to drag David to the clipboard. That works, and now David is the selected person. I try to drag Charles and get another instance of David unless I click on someone (could be David) first.

@vantu5z
Copy link
Contributor Author

vantu5z commented Jun 8, 2022

@jralls, it seems you wait alot after click and before move mouse to enable drag.
So when you click (left mouse down) at person node - this activates timer (200 ms) to separate single/double clicks, and if drag is not activated before timer is triggerred then handle single click on person node and make it active person (rebuild graph).
Try to fix this behavior, now drag will be disabled if active person changes (by single click).
Try if this works for you?

@jralls
Copy link
Member

jralls commented Jun 9, 2022

@vantu5z That works better. I see that you came to your senses after your comment and changed click recognition to button-up instead of a (very short in human time) timeout on the button down.

@vantu5z
Copy link
Contributor Author

vantu5z commented Jun 9, 2022

Add drag support from search widget. Now we can find some one and drag it to graph or clipboard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants