Merge lp:~c.groner/pantheon-terminal/fix-1169255 into lp:~elementary-apps/pantheon-terminal/trunk

Proposed by Carl Groner on 2017-04-14
Status: Merged
Approved by: Adam Bieńkowski on 2017-04-20
Approved revision: 954
Merged at revision: 954
Proposed branch: lp:~c.groner/pantheon-terminal/fix-1169255
Merge into: lp:~elementary-apps/pantheon-terminal/trunk
Diff against target: 74 lines (+29/-24)
2 files modified
src/PantheonTerminalWindow.vala (+1/-1)
src/TerminalWidget.vala (+28/-23)
To merge this branch: bzr merge lp:~c.groner/pantheon-terminal/fix-1169255
Reviewer Review Type Date Requested Status
Adam Bieńkowski code / testing 2017-04-14 Approve on 2017-04-20
Review via email: mp+322591@code.launchpad.net

Commit message

* Fix links not being selectable for copying.

Description of the change

Allow selection of all or part of a link for copying & pasting.

The current default behavior will instantly open the link, not allowing a link/url to be selected for copying (as noted in bug 1169255). My proposed solution opens the link on the mouse release event only if a selection was not made.

To post a comment you must log in.
Adam Bieńkowski (donadigo) wrote :

It looks good. Thanks for your contribution!

review: Approve (code / testing)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/PantheonTerminalWindow.vala'
2--- src/PantheonTerminalWindow.vala 2017-01-23 18:01:21 +0000
3+++ src/PantheonTerminalWindow.vala 2017-04-14 19:37:43 +0000
4@@ -709,7 +709,7 @@
5 }
6
7 void action_copy () {
8- if (current_terminal.uri != null)
9+ if (current_terminal.uri != null && ! current_terminal.get_has_selection ())
10 clipboard.set_text (current_terminal.uri,
11 current_terminal.uri.length);
12 else
13
14=== modified file 'src/TerminalWidget.vala'
15--- src/TerminalWidget.vala 2016-07-10 16:08:53 +0000
16+++ src/TerminalWidget.vala 2017-04-14 19:37:43 +0000
17@@ -107,29 +107,34 @@
18
19 /* Connect to necessary signals */
20 button_press_event.connect ((event) => {
21- uri = get_link ((long) event.x, (long) event.y);
22-
23- switch (event.button) {
24- case Gdk.BUTTON_PRIMARY:
25- if (uri != null) {
26- try {
27- Gtk.show_uri (null, (!) uri, Gtk.get_current_event_time ());
28- return true;
29- } catch (GLib.Error error) {
30- warning ("Could Not Open link");
31- }
32- }
33-
34- return false;
35- case Gdk.BUTTON_SECONDARY:
36- if (uri != null) {
37- window.main_actions.get_action ("Copy").set_sensitive (true);
38- }
39-
40- menu.select_first (false);
41- menu.popup (null, null, null, event.button, event.time);
42-
43- return true;
44+ if (event.button == Gdk.BUTTON_SECONDARY) {
45+ uri = get_link ((long) event.x, (long) event.y);
46+
47+ if (uri != null) {
48+ window.main_actions.get_action ("Copy").set_sensitive (true);
49+ }
50+
51+ menu.select_first (false);
52+ menu.popup (null, null, null, event.button, event.time);
53+
54+ return true;
55+ }
56+
57+ return false;
58+ });
59+
60+ button_release_event.connect ((event) => {
61+ if (event.button == Gdk.BUTTON_PRIMARY) {
62+ uri = get_link ((long) event.x, (long) event.y);
63+
64+ if (uri != null && ! get_has_selection ()) {
65+ try {
66+ Gtk.show_uri (null, uri, Gtk.get_current_event_time ());
67+ return true;
68+ } catch (GLib.Error error) {
69+ warning ("Could Not Open link");
70+ }
71+ }
72 }
73
74 return false;

Subscribers

People subscribed via source and target branches