From 5c57c205af2e2bc88269e1cb2f3b8b1a3f2f75f4 Mon Sep 17 00:00:00 2001 From: erich koslovsky Date: Sun, 19 Aug 2007 19:04:45 +0000 Subject: Added button for adding a link. Added the star icon as a button to add a link. Otherwise you can use ctrl-l to add a link and ctrl-r to remove the currently selected link. --- diff --git a/icons/add-link.svg b/icons/add-link.svg new file mode 100644 index 0000000..b84d3ef --- /dev/null +++ b/icons/add-link.svg @@ -0,0 +1,13 @@ + + + + + + +]> + + + diff --git a/stock-buddy-link.svg b/icons/buddy-link.svg index 7e79838..7e79838 100644 --- a/stock-buddy-link.svg +++ b/icons/buddy-link.svg diff --git a/linkbutton.py b/linkbutton.py index 84c0adb..1f5ac99 100644 --- a/linkbutton.py +++ b/linkbutton.py @@ -40,7 +40,7 @@ class LinkButton(gtk.RadioToolButton): pixbuf = loader.get_pixbuf() del loader - xo_buddy = os.path.join(os.path.dirname(__file__), "stock-buddy-link.svg") + xo_buddy = os.path.join(os.path.dirname(__file__), "icons/buddy-link.svg") pixbuf_xo = self._read_xo_icon(xo_buddy, fill, stroke) width = pixbuf_xo.get_width() diff --git a/webactivity.py b/webactivity.py index c7a1457..5db55f3 100755 --- a/webactivity.py +++ b/webactivity.py @@ -75,9 +75,9 @@ class WebActivity(activity.Activity): toolbox = activity.ActivityToolbox(self) activity_toolbar = toolbox.get_activity_toolbar() - toolbar = WebToolbar(self._browser) - toolbox.add_toolbar(_('Browse'), toolbar) - toolbar.show() + self.toolbar = WebToolbar(self._browser) + toolbox.add_toolbar(_('Browse'), self.toolbar) + self.toolbar.show() self.set_toolbox(toolbox) toolbox.show() @@ -87,6 +87,7 @@ class WebActivity(activity.Activity): self.linkbar.connect('link-rm', self._link_rm_cb) 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._add_link_button_cb) self._browser.connect("notify::title", self._title_changed_cb) self.model = Model(os.path.dirname(__file__)) @@ -303,21 +304,14 @@ class WebActivity(activity.Activity): def _link_rm_cb(self, linkbar, index): self.model.links[index]['deleted'] = 1 self.model.links[index]['thumb'] = '' - + + def _add_link_button_cb(self, button): + self._add_link() + def key_press_cb(self, widget, event): if event.state & gtk.gdk.CONTROL_MASK: if gtk.gdk.keyval_name(event.keyval) == "l": - buffer = self._get_screenshot() - _logger.debug('keyboard: Add link: %s.' % self.current) - self.model.links.append( {'hash':sha.new(self.current).hexdigest(), 'url':self.current, 'title':self.webtitle, - 'thumb':buffer, 'owner':self.owner.props.nick, 'color':self.owner.props.color, 'deleted':0} ) - - self.linkbar._add_link(self.current, buffer, self.owner.props.color, self.webtitle, self.owner.props.nick, - len(self.model.links)-1) - if self.messenger is not None: - import base64 - self.messenger._add_link(self.current, self.webtitle, self.owner.props.color, - self.owner.props.nick, base64.b64encode(buffer)) + self._add_link() return True elif gtk.gdk.keyval_name(event.keyval) == "r": _logger.debug('keyboard: Remove link: %s.' % self.current) @@ -327,7 +321,19 @@ class WebActivity(activity.Activity): return True return False - + def _add_link(self): + buffer = self._get_screenshot() + _logger.debug('keyboard: Add link: %s.' % self.current) + self.model.links.append( {'hash':sha.new(self.current).hexdigest(), 'url':self.current, 'title':self.webtitle, + 'thumb':buffer, 'owner':self.owner.props.nick, 'color':self.owner.props.color, 'deleted':0} ) + + self.linkbar._add_link(self.current, buffer, self.owner.props.color, self.webtitle, self.owner.props.nick, + len(self.model.links)-1) + if self.messenger is not None: + import base64 + self.messenger._add_link(self.current, self.webtitle, self.owner.props.color, + self.owner.props.nick, base64.b64encode(buffer)) + def _pixbuf_save_cb(self, buf, data): data[0] += buf return True diff --git a/webtoolbar.py b/webtoolbar.py index a330d70..6735a9c 100755 --- a/webtoolbar.py +++ b/webtoolbar.py @@ -67,6 +67,11 @@ 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() + progress_listener = progresslistener.get_instance() progress_listener.connect('location-changed', self._location_changed_cb) progress_listener.connect('loading-start', self._loading_start_cb) -- cgit v0.9.1