Skip to content

Instantly share code, notes, and snippets.

@cosmo0920
Created September 24, 2011 06:25
Show Gist options
  • Save cosmo0920/1239036 to your computer and use it in GitHub Desktop.
Save cosmo0920/1239036 to your computer and use it in GitHub Desktop.
def tag_user_id_link(body)
tag = body.buffer.create_tag('_user_id_link',
'foreground' => 'blue',
"underline" => Pango::UNDERLINE_SINGLE)
tag.signal_connect('event'){ |this, textview, event, iter|
result = false
if(event.is_a?(Gdk::EventButton)) and
(event.event_type == Gdk::Event::BUTTON_RELEASE) and
not(textview.buffer.selection_bounds[2])
if (event.button == 1)
#'http://twitter.com/'+user[:idname]->'http://twitter.com/#!/'+user[:idname]へ変更
Gtk::openurl('http://twitter.com/#!/'+user[:idname]) end
elsif(event.is_a?(Gdk::EventMotion))
body.set_cursor(textview, Gdk::Cursor::HAND2) end
result }
tag end }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment