From d5bd093912a0b0b679fb98b2665a8097dc0d661c Mon Sep 17 00:00:00 2001 From: Simon Schampijer Date: Thu, 13 Sep 2007 09:52:54 +0000 Subject: Added the buttons for hide/show tray --- diff --git a/NEWS b/NEWS index de2f856..4fd86f7 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,5 @@ +* Added the buttons for hide/show tray (erikos) + 51 * #3339 Add some mime types web-activity can handle (marco) diff --git a/icons/tray-hide.svg b/icons/tray-hide.svg new file mode 100644 index 0000000..4f30fa8 --- /dev/null +++ b/icons/tray-hide.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/icons/tray-show.svg b/icons/tray-show.svg new file mode 100644 index 0000000..0361b23 --- /dev/null +++ b/icons/tray-show.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/webactivity.py b/webactivity.py index b613c0c..99e0f4b 100755 --- a/webactivity.py +++ b/webactivity.py @@ -89,8 +89,10 @@ class WebActivity(activity.Activity): self._tray = HTray() self.session_history = sessionhistory.get_instance() self.session_history.connect('session-link-changed', self._session_history_changed_cb) - self.toolbar._add_link.connect('clicked', self._share_link_button_cb) - self.tray_isvisible = False + self.toolbar.connect('add-link', self._link_add_button_cb) + self.toolbar.connect('show-tray', self._tray_show_cb) + self.toolbar.connect('hide-tray', self._tray_hide_cb) + self.tray_isvisible = True self._browser.connect("notify::title", self._title_changed_cb) @@ -302,10 +304,20 @@ class WebActivity(activity.Activity): finally: f.close() - def _share_link_button_cb(self, button): + def _link_add_button_cb(self, button): _logger.debug('button: Add link: %s.' % self.current) self._add_link() - + + def _tray_show_cb(self, button): + if self.tray_isvisible == False: + self._tray.show() + self.tray_isvisible = True + + def _tray_hide_cb(self, button): + if self.tray_isvisible == True: + self._tray.hide() + self.tray_isvisible = False + def key_press_cb(self, widget, event): if event.state & gtk.gdk.CONTROL_MASK: if gtk.gdk.keyval_name(event.keyval) == "l": @@ -359,7 +371,9 @@ class WebActivity(activity.Activity): item.connect('remove_link', self._link_removed_cb) self._tray.add_item(item, index) # use index to add to the tray item.show() - self.tray_isvisible = True + if self.tray_isvisible == False: + self._tray.show() + self.tray_isvisible = True def _link_removed_cb(self, button, hash): ''' remove a link from tray and delete it in the model ''' diff --git a/webtoolbar.py b/webtoolbar.py index 3623808..6aab4bd 100755 --- a/webtoolbar.py +++ b/webtoolbar.py @@ -32,6 +32,20 @@ import progresslistener import filepicker class WebToolbar(gtk.Toolbar): + __gtype_name__ = 'WebToolbar' + + __gsignals__ = { + 'add-link': (gobject.SIGNAL_RUN_FIRST, + gobject.TYPE_NONE, + ([])), + 'show-tray': (gobject.SIGNAL_RUN_FIRST, + gobject.TYPE_NONE, + ([])), + 'hide-tray': (gobject.SIGNAL_RUN_FIRST, + gobject.TYPE_NONE, + ([])) + } + def __init__(self, browser): gtk.Toolbar.__init__(self) @@ -67,10 +81,23 @@ class WebToolbar(gtk.Toolbar): self.insert(entry_item, -1) entry_item.show() - self._add_link = ToolButton('add-link') - self._add_link.set_tooltip(_('Add Link')) - self.insert(self._add_link, -1) - self._add_link.show() + self._link_add = ToolButton('add-link') + self._link_add.set_tooltip(_('Add Link')) + self._link_add.connect('clicked', self._link_add_clicked_cb) + self.insert(self._link_add, -1) + self._link_add.show() + + self._tray_show = ToolButton('tray-show') + self._tray_show.set_tooltip(_('Show Tray')) + self._tray_show.connect('clicked', self._tray_show_clicked_cb) + self.insert(self._tray_show, -1) + self._tray_show.show() + + self._tray_hide = ToolButton('tray-hide') + self._tray_hide.set_tooltip(_('Hide Tray')) + self._tray_hide.connect('clicked', self._tray_hide_clicked_cb) + self.insert(self._tray_hide, -1) + self._tray_hide.show() progress_listener = progresslistener.get_instance() progress_listener.connect('location-changed', self._location_changed_cb) @@ -189,3 +216,11 @@ class WebToolbar(gtk.Toolbar): def _history_item_activated_cb(self, menu_item, index): self._browser.web_navigation.gotoIndex(index) + def _link_add_clicked_cb(self, button): + self.emit('add-link') + + def _tray_show_clicked_cb(self, button): + self.emit('show-tray') + + def _tray_hide_clicked_cb(self, button): + self.emit('hide-tray') -- cgit v0.9.1