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

Proposed by Carl Groner
Status: Merged
Approved by: Adam Bieńkowski
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 (community) code / testing Approve
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.
Revision history for this message
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
=== modified file 'src/PantheonTerminalWindow.vala'
--- src/PantheonTerminalWindow.vala 2017-01-23 18:01:21 +0000
+++ src/PantheonTerminalWindow.vala 2017-04-14 19:37:43 +0000
@@ -709,7 +709,7 @@
709 }709 }
710710
711 void action_copy () {711 void action_copy () {
712 if (current_terminal.uri != null)712 if (current_terminal.uri != null && ! current_terminal.get_has_selection ())
713 clipboard.set_text (current_terminal.uri,713 clipboard.set_text (current_terminal.uri,
714 current_terminal.uri.length);714 current_terminal.uri.length);
715 else715 else
716716
=== modified file 'src/TerminalWidget.vala'
--- src/TerminalWidget.vala 2016-07-10 16:08:53 +0000
+++ src/TerminalWidget.vala 2017-04-14 19:37:43 +0000
@@ -107,29 +107,34 @@
107107
108 /* Connect to necessary signals */108 /* Connect to necessary signals */
109 button_press_event.connect ((event) => {109 button_press_event.connect ((event) => {
110 uri = get_link ((long) event.x, (long) event.y);110 if (event.button == Gdk.BUTTON_SECONDARY) {
111111 uri = get_link ((long) event.x, (long) event.y);
112 switch (event.button) {112
113 case Gdk.BUTTON_PRIMARY:113 if (uri != null) {
114 if (uri != null) {114 window.main_actions.get_action ("Copy").set_sensitive (true);
115 try {115 }
116 Gtk.show_uri (null, (!) uri, Gtk.get_current_event_time ());116
117 return true;117 menu.select_first (false);
118 } catch (GLib.Error error) {118 menu.popup (null, null, null, event.button, event.time);
119 warning ("Could Not Open link");119
120 }120 return true;
121 }121 }
122122
123 return false;123 return false;
124 case Gdk.BUTTON_SECONDARY:124 });
125 if (uri != null) {125
126 window.main_actions.get_action ("Copy").set_sensitive (true);126 button_release_event.connect ((event) => {
127 }127 if (event.button == Gdk.BUTTON_PRIMARY) {
128128 uri = get_link ((long) event.x, (long) event.y);
129 menu.select_first (false);129
130 menu.popup (null, null, null, event.button, event.time);130 if (uri != null && ! get_has_selection ()) {
131131 try {
132 return true;132 Gtk.show_uri (null, uri, Gtk.get_current_event_time ());
133 return true;
134 } catch (GLib.Error error) {
135 warning ("Could Not Open link");
136 }
137 }
133 }138 }
134139
135 return false;140 return false;

Subscribers

People subscribed via source and target branches