Commits

Ikey Doherty committed e1ae25d

Detect hyperlinks and show hand icon where appropriate

  • Participants
  • Parent commits a536e07

Comments (0)

Files changed (1)

File src/pages/summary/summary.vala

    private Gtk.TextBuffer buffer;
    TextIter iter;
 
+   private Gdk.Cursor saved_cursor;
+
    static construct {
 
 	message ("SummaryPage init");
 	display.pack_start (inst_label, false, false, 20);
 
 	textview = new Gtk.TextView ();
+	textview.realize.connect ( () => { 
+		unowned Gdk.Window win = textview.get_window (Gtk.TextWindowType.TEXT);
+		saved_cursor = win.get_cursor ();
+	} );
+	textview.motion_notify_event.connect ( (w,e) => {
+		int x;
+		int y;
+		w.window.at_pointer (out x, out y);
+		Gtk.TextIter tmp;
+		textview.get_iter_at_location (out tmp, x, y);
+		var tags = tmp.get_tags ();
+		foreach (unowned Gtk.TextTag tag in tags) {
+			if (tag.name == "hyperlink") {
+				unowned Gdk.Window win = textview.get_window (Gtk.TextWindowType.TEXT);
+				win.set_cursor (new Gdk.Cursor (Gdk.CursorType.HAND2));
+				return false;
+			}
+		}
+		unowned Gdk.Window win = textview.get_window (Gtk.TextWindowType.TEXT);
+		win.set_cursor (saved_cursor);
+		return false;
+	} );
 	textview.editable = false;
 	var scrolls = new Gtk.ScrolledWindow (null,null);
 	scrolls.vscrollbar_policy = PolicyType.AUTOMATIC;