|
|
|
@ -27,6 +27,7 @@ import threading
|
|
|
|
|
import Queue |
|
|
|
|
import re |
|
|
|
|
import urllib2 |
|
|
|
|
import webbrowser |
|
|
|
|
|
|
|
|
|
from mitterlib.ui.helpers.image_helpers import find_image |
|
|
|
|
from mitterlib import htmlize |
|
|
|
@ -271,9 +272,8 @@ class Interface(object):
|
|
|
|
|
self._grid.set_resize_mode(gtk.RESIZE_IMMEDIATE) |
|
|
|
|
self._grid.connect('cursor-changed', self._message_selected) |
|
|
|
|
#self._grid.connect('row-activated', self.open_post) |
|
|
|
|
#self.grid.connect('button-press-event', self.click_post) |
|
|
|
|
#self.grid.connect('popup-menu', |
|
|
|
|
# lambda view: self.show_post_popup(view, None)) |
|
|
|
|
self._grid.connect('button-press-event', self._click_message) |
|
|
|
|
self._grid.connect('popup-menu', self._message_popup) # Menu button |
|
|
|
|
|
|
|
|
|
scrolled_window = gtk.ScrolledWindow() |
|
|
|
|
scrolled_window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS) |
|
|
|
@ -632,6 +632,38 @@ class Interface(object):
|
|
|
|
|
self._reply_label.set_text('') |
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
def _url_popup(self, path, event): |
|
|
|
|
"""Builds the popup with URLs in the cell pointed by *path*. Requires |
|
|
|
|
the *event* that the widget received.""" |
|
|
|
|
iter = self._grid.get_model().get_iter(path) |
|
|
|
|
message = self._grid.get_model().get_value(iter, 0) |
|
|
|
|
|
|
|
|
|
popup = gtk.Menu() |
|
|
|
|
|
|
|
|
|
urls = URL_RE.findall(message.message) |
|
|
|
|
if len(urls) == 0: |
|
|
|
|
item = gtk.MenuItem('No URLs in message.') |
|
|
|
|
item.set_property('sensitive', False) |
|
|
|
|
popup.append(item) |
|
|
|
|
popup.show_all() |
|
|
|
|
popup.popup(None, None, None, event.button, event.time) |
|
|
|
|
return True |
|
|
|
|
|
|
|
|
|
for url in urls: |
|
|
|
|
if len(url) > 20: |
|
|
|
|
title = url[:20] + '...' |
|
|
|
|
else: |
|
|
|
|
title = url |
|
|
|
|
item = gtk.MenuItem(title) |
|
|
|
|
item.connect('activate', self._open_url, url) |
|
|
|
|
popup.append(item) |
|
|
|
|
|
|
|
|
|
popup.show_all() |
|
|
|
|
popup.popup(None, None, None, event.button, event.time) |
|
|
|
|
|
|
|
|
|
return True |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ------------------------------------------------------------ |
|
|
|
|
# Widget callback functions |
|
|
|
|
# ------------------------------------------------------------ |
|
|
|
@ -791,7 +823,7 @@ class Interface(object):
|
|
|
|
|
|
|
|
|
|
def _repost_message(self, widget, user_data=None): |
|
|
|
|
"""Repost someone else's message on your timeline.""" |
|
|
|
|
(model, iter)= self._grid.get_selection().get_selected() |
|
|
|
|
(model, iter) = self._grid.get_selection().get_selected() |
|
|
|
|
message = model.get_value(iter, 0) |
|
|
|
|
self._update_statusbar('Reposting %s message...' % |
|
|
|
|
(message.username)) |
|
|
|
@ -885,6 +917,35 @@ class Interface(object):
|
|
|
|
|
|
|
|
|
|
return True |
|
|
|
|
|
|
|
|
|
def _click_message(self, widget, event, user_data=None): |
|
|
|
|
"""Check the click on the message and, if it's a right click, call the |
|
|
|
|
_message_popup function to show the popup.""" |
|
|
|
|
if event.button != 3: |
|
|
|
|
# not right click |
|
|
|
|
return False |
|
|
|
|
|
|
|
|
|
path = self._grid.get_path_at_pos(event.x, event.y) |
|
|
|
|
if not path: |
|
|
|
|
return False |
|
|
|
|
|
|
|
|
|
(path, _, _, _) = path |
|
|
|
|
return self._url_popup(path, event) |
|
|
|
|
return True |
|
|
|
|
|
|
|
|
|
def _message_popup(self, widget, event, user_data=None): |
|
|
|
|
"""Builds the popup with the URLs in the message.""" |
|
|
|
|
_log.debug('Popup') |
|
|
|
|
(path, _) = self._grid.get_cursor() |
|
|
|
|
if not path: |
|
|
|
|
return True |
|
|
|
|
|
|
|
|
|
return self._url_popup(path, event) |
|
|
|
|
|
|
|
|
|
def _open_url(self, widget, user_data=None): |
|
|
|
|
"""Opens an URL (used mostly from popup menu items.)""" |
|
|
|
|
webbrowser.open_new_tab(user_data) |
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
# ------------------------------------------------------------ |
|
|
|
|
# Network related functions |
|
|
|
|
# ------------------------------------------------------------ |
|
|
|
|