Merge lp:~julien-spautz/cable/regex into lp:cable

Proposed by Julien Spautz
Status: Merged
Merge reported by: Eduard Gotwig
Merged at revision: not available
Proposed branch: lp:~julien-spautz/cable/regex
Merge into: lp:cable
Diff against target: 57 lines (+13/-7)
1 file modified
src/Widgets/ChatDisplay.vala (+13/-7)
To merge this branch: bzr merge lp:~julien-spautz/cable/regex
Reviewer Review Type Date Requested Status
Cable Developers Pending
Review via email: mp+174630@code.launchpad.net

Description of the change

Fix ping markup and url markup mess.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Widgets/ChatDisplay.vala'
2--- src/Widgets/ChatDisplay.vala 2013-07-14 14:47:42 +0000
3+++ src/Widgets/ChatDisplay.vala 2013-07-14 20:18:25 +0000
4@@ -10,7 +10,7 @@
5 but WITHOUT ANY WARRANTY; without even the implied warranty of
6 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
7 Lesser General Public License for more details.
8-
9+
10 You should have received a copy of the GNU Lesser General
11 Public License along with this library; if not, write to the
12 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
13@@ -18,10 +18,10 @@
14 ***/
15
16 public class Cable.Widgets.ChatDisplay : Gtk.EventBox {
17-
18+
19 private Gtk.Grid main_grid;
20 private int line = 0;
21-
22+
23 public ChatDisplay () {
24 this.get_style_context ().add_class (Granite.StyleClass.CONTENT_VIEW);
25 main_grid = new Gtk.Grid ();
26@@ -32,14 +32,20 @@
27 expand = true;
28 this.add (main_grid);
29 }
30-
31- public void add_message (string user, string message) {
32+
33+ public void add_message (string user, string msg) {
34+
35+ var regex = /((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[.!\/\\w]*))?)/;
36+ var message = regex.replace (msg, -1, 0, "<a href=\"\\1\">\\1</a>");
37+
38 var user_label = new Gtk.Label ("");
39 user_label.set_markup (user);
40 user_label.set_alignment (1, 0);
41 user_label.width_request = 80;
42 user_label.ellipsize = Pango.EllipsizeMode.END;
43 var message_label = new Granite.Widgets.WrapLabel ("");
44+ message_label.use_markup = true;
45+ debug (message);
46 message_label.set_markup (message);
47 message_label.hexpand = true;
48 main_grid.attach (user_label, 0, line, 1, 1);
49@@ -48,6 +54,6 @@
50 message_label.show ();
51 line++;
52 }
53-
54-
55+
56+
57 }

Subscribers

People subscribed via source and target branches

to all changes: