diff --git a/issues/issue-21bc9efec48c9dec4b4470aed5bedc144abc7f65.yaml b/issues/issue-21bc9efec48c9dec4b4470aed5bedc144abc7f65.yaml index 4f2e624..359c596 100644 --- a/issues/issue-21bc9efec48c9dec4b4470aed5bedc144abc7f65.yaml +++ b/issues/issue-21bc9efec48c9dec4b4470aed5bedc144abc7f65.yaml @@ -5,8 +5,8 @@ type: :feature component: pygtk release: 1.0.0 reporter: Julio Biason -status: :unstarted -disposition: +status: :closed +disposition: :fixed creation_time: 2009-12-21 10:38:11.287314 Z references: [] @@ -16,3 +16,7 @@ log_events: - Julio Biason - created - "" +- - 2009-12-25 18:59:09.219716 Z + - Julio Biason + - closed with disposition fixed + - "" diff --git a/issues/issue-de26ded9beb48644ce9c18e6cd531333a723b812.yaml b/issues/issue-de26ded9beb48644ce9c18e6cd531333a723b812.yaml index b93702a..0d4a2bb 100644 --- a/issues/issue-de26ded9beb48644ce9c18e6cd531333a723b812.yaml +++ b/issues/issue-de26ded9beb48644ce9c18e6cd531333a723b812.yaml @@ -5,8 +5,8 @@ type: :feature component: network release: 1.0.0 reporter: Julio Biason -status: :unstarted -disposition: +status: :closed +disposition: :fixed creation_time: 2009-12-22 12:36:09.292341 Z references: - pygtk-12 @@ -20,3 +20,7 @@ log_events: - Julio Biason - added reference 1 - "" +- - 2009-12-25 18:58:40.275798 Z + - Julio Biason + - closed with disposition fixed + - "" diff --git a/mitterlib/network/__init__.py b/mitterlib/network/__init__.py index 7f54d1e..77fb5d1 100644 --- a/mitterlib/network/__init__.py +++ b/mitterlib/network/__init__.py @@ -170,6 +170,10 @@ class Networks(object): results.append(self.networks[shortcut].update(status, reply_to)) return results + def reply_prefix(self, message): + """Return the prefix to be used in the reply for that message.""" + return self.networks[message.network].reply_prefix(message) + def repost(self, message): """Repost a message in the user's timeline. The network used is the same in the message.""" @@ -193,6 +197,8 @@ class Networks(object): def message(self, message_id, network): """Return a single NetworkData object for a specified message.""" + # TODO: This should probably be named parent() and receive a + # NetworkData. Still returns a single NetworkData object. if not network in self.networks: raise NetworksNoSuchNetworkError(network) @@ -200,9 +206,9 @@ class Networks(object): data.network = network return data - def reply_prefix(self, message): - """Return the prefix to be used in the reply for that message.""" - return self.networks[message.network].reply_prefix(message) + def link(self, message): + """Returns a link directly to the message.""" + return self.networks[message.network].link(message) def replies(self, network=None): """Return a list of NetworkData objects for the replies for the user @@ -214,11 +220,6 @@ class Networks(object): result.append(message) return result - def inbox(self, network=None): - """Return a list of NetworkData objects for the direct messages/inbox - of the user.""" - return [] - def available_requests(self, network=None): """Return a dictionary with the available requests the user can make to each network before getting capped.""" diff --git a/mitterlib/network/networkbase.py b/mitterlib/network/networkbase.py index afbc89a..67d450e 100644 --- a/mitterlib/network/networkbase.py +++ b/mitterlib/network/networkbase.py @@ -248,6 +248,12 @@ class NetworkBase(object): message.""" return None + def link(self, message): + """Returns a link (as string) to the message in the network site. If + the network doesn't provide a link directly to the message, None shall + be returned. *message* is a :class:`NetworkData` object.""" + return None + def replies(self): """Return a list of :class:`NetworkData` objects for the replies for the user messages.""" diff --git a/mitterlib/network/twitter.py b/mitterlib/network/twitter.py index 505a618..b80a014 100644 --- a/mitterlib/network/twitter.py +++ b/mitterlib/network/twitter.py @@ -352,6 +352,11 @@ class Connection(NetworkBase): response = self._request('/statuses/show/%d.json' % (message_id)) return TwitterNetworkData(response) + def link(self, message): + """Return a link directly to the message.""" + return 'http://twitter.com/%s/status/%s' % (message.username, + message.id) + def reply_prefix(self, message): """Returns the prefix needed for a reply.""" return '@' + message.username + ' ' diff --git a/mitterlib/ui/ui_pygtk.py b/mitterlib/ui/ui_pygtk.py index 57138a8..9d62e39 100644 --- a/mitterlib/ui/ui_pygtk.py +++ b/mitterlib/ui/ui_pygtk.py @@ -664,22 +664,26 @@ class Interface(object): iter = widget.get_model().get_iter(path) message = widget.get_model().get_value(iter, 0) - popup = gtk.Menu() + items = [] + link = self._connection.link(message) + if link: + network = self._connection.name(message.network) + items.append(('Open on %s' % (network), link)) 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 + items.append((title, url)) + + if len(items) == 0: + return + + popup = gtk.Menu() + for url in items: + (title, url) = url item = gtk.MenuItem(title) item.connect('activate', self._open_url, url) popup.append(item)