Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Schampijer <simon@schampijer.de>2007-09-16 14:32:26 (GMT)
committer Simon Schampijer <simon@schampijer.de>2007-09-16 14:32:26 (GMT)
commit90990c178837d2d31f63df8a9209f49b03cc8ed3 (patch)
tree47eb5a727c158e620818a11c32ae7a404a84fd70
parent5c31ae6ef9d3d6cf631bc224bd8516a21cca6f04 (diff)
* Make hide/show of the treay one button #3475
-rw-r--r--NEWS2
-rw-r--r--icons/tray-empty.svg3
-rwxr-xr-xwebactivity.py58
-rwxr-xr-xwebtoolbar.py48
4 files changed, 61 insertions, 50 deletions
diff --git a/NEWS b/NEWS
index d2f405f..5527ccd 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,5 @@
+* Make hide/show of the treay one button #3475 (erikos)
+
52
* Fix for when participant leaves (erikos)
diff --git a/icons/tray-empty.svg b/icons/tray-empty.svg
new file mode 100644
index 0000000..5980eec
--- /dev/null
+++ b/icons/tray-empty.svg
@@ -0,0 +1,3 @@
+<?xml version="1.0" ?><!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'>
+<svg enable-background="new 0 0 55.125 55" height="55px" version="1.1" viewBox="0 0 55.125 55" width="55.125px" x="0px" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" y="0px">
+</svg>
diff --git a/webactivity.py b/webactivity.py
index 99e0f4b..50ae081 100755
--- a/webactivity.py
+++ b/webactivity.py
@@ -90,9 +90,9 @@ class WebActivity(activity.Activity):
self.session_history = sessionhistory.get_instance()
self.session_history.connect('session-link-changed', self._session_history_changed_cb)
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.toolbar.connect('visibility-tray', self._tray_visibility_cb)
+ self._tray_isvisible = False
+ self._tray_numelems = 0
self._browser.connect("notify::title", self._title_changed_cb)
@@ -279,7 +279,8 @@ class WebActivity(activity.Activity):
_logger.debug('read: url=%s title=%s d=%s' % (link['url'],
link['title'],
link['color']))
- self._add_link_totray(link['url'], base64.b64decode(link['thumb']),
+ self._add_link_totray(link['url'],
+ base64.b64decode(link['thumb']),
link['color'], link['title'],
link['owner'], -1, link['hash'])
self._browser.set_session(self.model.data['history'])
@@ -307,16 +308,6 @@ class WebActivity(activity.Activity):
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:
@@ -325,8 +316,8 @@ class WebActivity(activity.Activity):
self._add_link()
return True
elif gtk.gdk.keyval_name(event.keyval) == "v":
- _logger.debug('keyboard: Toggle visibility of tray')
- self._toggle_visibility_tray()
+ # toggle visibility of tray
+ self._tray_visibility()
return True
elif gtk.gdk.keyval_name(event.keyval) == "u":
_logger.debug('keyboard: Show source of the current page')
@@ -343,7 +334,8 @@ class WebActivity(activity.Activity):
''' take screenshot and add link info to the model '''
for link in self.model.data['shared_links']:
if link['hash'] == sha.new(self.current).hexdigest():
- _logger.debug('_add_link: link exist already')
+ _logger.debug('_add_link: link exist already a=%s b=%s' %(
+ link['hash'], sha.new(self.current).hexdigest()))
return
buffer = self._get_screenshot()
timestamp = time.time()
@@ -371,26 +363,38 @@ 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()
- if self.tray_isvisible == False:
+ self._tray_numelems+=1
+ if self._tray_isvisible == False:
self._tray.show()
- self.tray_isvisible = True
-
+ self._tray_isvisible = True
+ self.toolbar.tray_set_hide()
+
def _link_removed_cb(self, button, hash):
''' remove a link from tray and delete it in the model '''
self.model.remove_link(hash)
self._tray.remove_item(button)
+ self._tray_numelems-=1
+ if self._tray_numelems == 0:
+ self.toolbar.tray_set_empty()
+ self._tray_isvisible = False
def _link_clicked_cb(self, button, url):
''' an item of the link tray has been clicked '''
self._browser.load_uri(url)
- def _toggle_visibility_tray(self):
- if self.tray_isvisible is True:
- self.tray_isvisible = False
- self._tray.hide()
- else:
- self.tray_isvisible = True
- self._tray.show()
+ def _tray_visibility_cb(self, toolbar):
+ self._tray_visibility()
+
+ def _tray_visibility(self):
+ if self._tray_numelems > 0:
+ if self._tray_isvisible is False:
+ self.toolbar.tray_set_hide()
+ self._tray.show()
+ self._tray_isvisible = True
+ else:
+ self.toolbar.tray_set_show()
+ self._tray.hide()
+ self._tray_isvisible = False
def _show_source(self):
self._browser.get_source()
diff --git a/webtoolbar.py b/webtoolbar.py
index 6aab4bd..098ac4d 100755
--- a/webtoolbar.py
+++ b/webtoolbar.py
@@ -38,12 +38,9 @@ class WebToolbar(gtk.Toolbar):
'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,
- ([]))
+ 'visibility-tray': (gobject.SIGNAL_RUN_FIRST,
+ gobject.TYPE_NONE,
+ ([]))
}
def __init__(self, browser):
@@ -87,18 +84,12 @@ class WebToolbar(gtk.Toolbar):
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()
-
+ self._tray_vis = ToolButton()
+ self._tray_vis.connect('clicked', self._tray_vis_clicked_cb)
+ self.insert(self._tray_vis, -1)
+ self.tray_set_empty()
+ self._tray_vis.show()
+
progress_listener = progresslistener.get_instance()
progress_listener.connect('location-changed', self._location_changed_cb)
progress_listener.connect('loading-start', self._loading_start_cb)
@@ -219,8 +210,19 @@ class WebToolbar(gtk.Toolbar):
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')
+ def tray_set_empty(self):
+ self._tray_vis.set_icon('tray-empty')
+ self._tray_vis.set_sensitive(False)
+
+ def tray_set_show(self):
+ self._tray_vis.set_icon('tray-show')
+ self._tray_vis.set_tooltip(_('Show Tray'))
+ self._tray_vis.set_sensitive(True)
+
+ def tray_set_hide(self):
+ self._tray_vis.set_icon('tray-hide')
+ self._tray_vis.set_tooltip(_('Hide Tray'))
+ self._tray_vis.set_sensitive(True)
+
+ def _tray_vis_clicked_cb(self, button):
+ self.emit('visibility-tray')