Merge lp:~voldyman/pantheon-terminal/fixed-1028594 into lp:~elementary-apps/pantheon-terminal/trunk

Proposed by Akshay Shekher
Status: Merged
Merged at revision: 276
Proposed branch: lp:~voldyman/pantheon-terminal/fixed-1028594
Merge into: lp:~elementary-apps/pantheon-terminal/trunk
Diff against target: 81 lines (+42/-5)
2 files modified
src/PantheonTerminalWindow.vala (+1/-1)
src/TerminalWidget.vala (+41/-4)
To merge this branch: bzr merge lp:~voldyman/pantheon-terminal/fixed-1028594
Reviewer Review Type Date Requested Status
Victor Martinez (community) Approve
Review via email: mp+117115@code.launchpad.net

Description of the change

Added support for link clicking

To post a comment you must log in.
Revision history for this message
Victor Martinez (victored) wrote :

Your fix works perfectly here Akshay.

It'd be better if you used "else if" in line 31, and Gtk.BUTTON_PRIMARY instead of "1", but these are negligible issues.

review: Approve
Revision history for this message
Victor Martinez (victored) wrote :

Correction: Gdk.BUTTON_PRIMARY

274. By Akshay Shekher

Using SwitchCase Instead of multiple if's

275. By Akshay Shekher

Using Gdk.BUTTON_PRIMARY/SECONDARY

Revision history for this message
David Gomes (davidgomes) wrote :

Empty newlines 48 and 76 should be removed, also:

private extern string? vte_terminal_match_check (Vte.Terminal terminal,

 long col, long row,

 out int tag);

Lines 10, 11, 12 should look like that, an alignment to the passed
arguments is necessary.

Other than that, looks fine. Fix that and it's ready for trunk.

--
David Gomes

Revision history for this message
Akshay Shekher (voldyman) wrote :

Match_check does not work for valac<0.17.2

On 28-Jul-2012, at 7:19 PM, David Gomes <email address hidden> wrote:

> Empty newlines 48 and 76 should be removed, also:
>
> private extern string? vte_terminal_match_check (Vte.Terminal terminal,
>
> long col, long row,
>
> out int tag);
>
> Lines 10, 11, 12 should look like that, an alignment to the passed
> arguments is necessary.
>
> Other than that, looks fine. Fix that and it's ready for trunk.
>
> --
> David Gomes
>
> --
> https://code.launchpad.net/~voldyman/pantheon-terminal/fixed-1028594/+merge/117115
> You are the owner of lp:~voldyman/pantheon-terminal/fixed-1028594.

Revision history for this message
Rico Tzschichholz (ricotz) wrote :

Use "#if !VALA_0_18" to guard your custom bindings to only use them when they are needed

276. By Akshay Shekher

vte_terminal_match_check and using this.match_check

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 2012-07-26 13:37:17 +0000
3+++ src/PantheonTerminalWindow.vala 2012-07-29 05:49:21 +0000
4@@ -160,7 +160,7 @@
5 add (notebook);
6 this.key_press_event.connect ((e) => {
7 switch (e.keyval){
8- case 49: //ctrl+[1-8]
9+ case 49: //alt+[1-8]
10 case 50:
11 case 51:
12 case 52:
13
14=== modified file 'src/TerminalWidget.vala'
15--- src/TerminalWidget.vala 2012-07-26 13:37:17 +0000
16+++ src/TerminalWidget.vala 2012-07-29 05:49:21 +0000
17@@ -37,9 +37,22 @@
18 menu.show_all ();
19
20 button_press_event.connect ((event) => {
21- if (event.button == 3) {
22- menu.select_first (false);
23- menu.popup (null, null, null, event.button, event.time);
24+ switch (event.button) {
25+ case Gdk.BUTTON_PRIMARY:
26+ string? uri = get_link ((long)event.x, (long)event.y);
27+ if (uri != null) {
28+ try {
29+ Gtk.show_uri (null, (!)uri, Gtk.get_current_event_time());
30+ return true;
31+ } catch (GLib.Error error) {
32+ warning ("Could Not Open link");
33+ }
34+ }
35+ return false;
36+ case Gdk.BUTTON_SECONDARY :
37+ menu.select_first (false);
38+ menu.popup (null, null, null, event.button, event.time);
39+ return true;
40 }
41 return false;
42 });
43@@ -56,6 +69,9 @@
44 Gtk.TargetEntry target = {"text/uri-list",0,0};
45 Gtk.drag_dest_set (this, Gtk.DestDefaults.ALL,{target},Gdk.DragAction.COPY);
46
47+ /*Make Links Clickable */
48+ this.clickable("""(https?|ftps?)://\S+""");
49+
50 }
51
52 void on_child_exited () { }
53@@ -105,6 +121,27 @@
54 return (int) (this.get_char_height()) * row_count;
55 }
56
57+ private void clickable (string str) {
58+ try {
59+ var regex = new GLib.Regex (str);
60+ int id = this.match_add_gregex (regex, 0);
61+
62+ this.match_set_cursor_type (id, Gdk.CursorType.HAND2);
63+ } catch (GLib.RegexError error) {
64+ warning (error.message);
65+ }
66+ }
67+
68+ private string? get_link (long x, long y) {
69+ long col = x / this.get_char_width ();
70+ long row = y / this.get_char_height ();
71+ int tag;
72+
73+ // Vte.Terminal.match_check need a non-null tag instead of what is
74+ // written in the doc
75+ // (see: https://bugzilla.gnome.org/show_bug.cgi?id=676886)
76+ return this.match_check(col, row, out tag);
77+
78+ }
79 }
80-
81 }

Subscribers

People subscribed via source and target branches