deskbar-applet r2081 - in trunk: . deskbar deskbar/ui po
- From: sebp svn gnome org
- To: svn-commits-list gnome org
- Subject: deskbar-applet r2081 - in trunk: . deskbar deskbar/ui po
- Date: Tue, 8 Apr 2008 14:52:26 +0100 (BST)
Author: sebp
Date: Tue Apr 8 14:52:26 2008
New Revision: 2081
URL: http://svn.gnome.org/viewvc/deskbar-applet?rev=2081&view=rev
Log:
Removed DeskbarTray.py and added DeskbarApplet.py that represents the Deskbar icon when used as applet.
The size of the icon is no longer based on applet's size hint, but the allocation width and height. (fixes bug #526536 partly)
Added:
trunk/deskbar/ui/DeskbarApplet.py
Removed:
trunk/deskbar/ui/DeskbarTray.py
Modified:
trunk/ChangeLog
trunk/deskbar/deskbar-applet.py
trunk/deskbar/ui/AbstractCuemiacDeskbarIcon.py
trunk/deskbar/ui/Makefile.am
trunk/po/POTFILES.in
Modified: trunk/deskbar/deskbar-applet.py
==============================================================================
--- trunk/deskbar/deskbar-applet.py (original)
+++ trunk/deskbar/deskbar-applet.py Tue Apr 8 14:52:26 2008
@@ -18,7 +18,6 @@
app.connect("destroy", gtk.main_quit)
applet = gnomeapplet.Applet()
- applet.set_flags(applet.flags() | gnomeapplet.EXPAND_MINOR)
applet.get_orient = lambda: gnomeapplet.ORIENT_DOWN
applet_factory(applet, None)
applet.reparent(app)
@@ -29,10 +28,10 @@
def applet_factory(applet, iid):
logging.info ('Starting Deskbar instance: %s %s', applet, iid)
- tray = DeskbarTray(applet)
- applet.add(tray)
- applet.show_all()
+ app = DeskbarApplet(applet)
+ app.show_all()
+
return True
def check_deskbar_path ():
@@ -96,7 +95,7 @@
gtk.gdk.threads_leave()
elif options.window:
import gnome
- from deskbar.ui.DeskbarTray import DeskbarTray
+ from deskbar.ui.DeskbarApplet import DeskbarApplet
gnome.init(deskbar.defs.PACKAGE, deskbar.defs.VERSION)
build_window()
@@ -104,11 +103,11 @@
gtk.main()
gtk.gdk.threads_leave()
else:
- from deskbar.ui.DeskbarTray import DeskbarTray
-
+ from deskbar.ui.DeskbarApplet import DeskbarApplet
+
gnomeapplet.bonobo_factory(
"OAFIID:Deskbar_Applet_Factory",
- gnomeapplet.Applet.__gtype__,
+ DeskbarApplet.__gtype__,
deskbar.defs.PACKAGE,
deskbar.defs.VERSION,
applet_factory)
Modified: trunk/deskbar/ui/AbstractCuemiacDeskbarIcon.py
==============================================================================
--- trunk/deskbar/ui/AbstractCuemiacDeskbarIcon.py (original)
+++ trunk/deskbar/ui/AbstractCuemiacDeskbarIcon.py Tue Apr 8 14:52:26 2008
@@ -23,7 +23,8 @@
self._show_toggle(self, time)
def create_button_ui(self):
- self._view = CuemiacAlignedView(self._controller, self._core, self.image, self.applet)
+ self._view = CuemiacAlignedView(self._controller, self._core,
+ self.get_reference_widget(), self.get_applet())
self._active_view = deskbar.BUTTON_UI_NAME
def create_window_ui(self):
@@ -91,3 +92,15 @@
Setup popup menu
"""
raise NotImplementedError
+
+ def get_reference_widget(self):
+ """
+ Required by CuemiacAlignedView
+ """
+ raise NotImplementedError
+
+ def get_applet(self):
+ """
+ Required by CuemiacAlignedView
+ """
+ raise NotImplementedError
Added: trunk/deskbar/ui/DeskbarApplet.py
==============================================================================
--- (empty file)
+++ trunk/deskbar/ui/DeskbarApplet.py Tue Apr 8 14:52:26 2008
@@ -0,0 +1,114 @@
+import gnomeapplet
+import gtk
+import deskbar
+import os.path
+import gobject
+from deskbar.ui.AbstractCuemiacDeskbarIcon import AbstractCuemiacDeskbarIcon
+from gettext import gettext as _
+
+class DeskbarApplet (gnomeapplet.Applet, AbstractCuemiacDeskbarIcon):
+
+ def __init__(self, applet):
+ gnomeapplet.Applet.__init__(self)
+ AbstractCuemiacDeskbarIcon.__init__(self)
+
+ self.applet = applet
+
+ self.handler_size_allocate_id = self.applet.connect ("size-allocate", self.on_allocate)
+ self.applet.set_applet_flags (gnomeapplet.EXPAND_MINOR)
+ self.applet.set_background_widget(self)
+
+ self.tray = gtk.EventBox()
+ self.tray.set_visible_window(False)
+ self.tray.set_sensitive(False)
+ self.tray.connect('button-press-event', self.on_button_press)
+ self.applet.add(self.tray)
+ self.tray.show()
+
+ self.tooltips = gtk.Tooltips()
+ self.tooltips.set_tip(self.tray, _("Show search entry"))
+
+ self.image = gtk.Image ()
+ self.tray.add(self.image)
+ self.image.show()
+
+ self.setup_menu()
+ self._setup_mvc()
+
+ self._set_image(self.applet.get_size())
+
+ self.applet.show_all()
+
+ def get_image_filename_and_size(self, size):
+ """
+ Choose correct icon and calculate its size
+ """
+ image_name = "deskbar-applet-panel"
+ if self.applet.get_orient() in [gnomeapplet.ORIENT_UP, gnomeapplet.ORIENT_DOWN]:
+ image_name += "-h"
+ else:
+ image_name += "-v"
+
+ if size > 31 and self._has_svg_support():
+ image_name += ".svg"
+ s = size - 12
+ else:
+ image_name += ".png"
+ s = -1 # Don't resize image
+
+ return os.path.join(deskbar.ART_DATA_DIR, image_name), s
+
+ def on_allocate(self, applet, alloc):
+ if self.applet.get_orient () in [gnomeapplet.ORIENT_UP, gnomeapplet.ORIENT_DOWN]:
+ size_alloc = alloc.height
+ else:
+ size_alloc = alloc.width
+
+ self._set_image(size_alloc)
+
+ def _set_image(self, size_alloc):
+ """
+ @param size_alloc: The space that's available in pixels
+ """
+ filename, size = self.get_image_filename_and_size(size_alloc)
+
+ if self.applet.get_orient() in [gnomeapplet.ORIENT_DOWN, gnomeapplet.ORIENT_UP]:
+ pixbuf = gtk.gdk.pixbuf_new_from_file_at_size (filename, -1, size)
+ else:
+ pixbuf = gtk.gdk.pixbuf_new_from_file_at_size (filename, size, -1)
+
+ self.applet.handler_block(self.handler_size_allocate_id)
+ self.image.set_from_pixbuf (pixbuf)
+ self.tray.set_size_request (size_alloc, size_alloc)
+ # If we unblock immediately we get an infinite loop
+ gobject.timeout_add(100, self.unblock_allocate)
+
+ def unblock_allocate(self):
+ self.applet.handler_unblock (self.handler_size_allocate_id)
+ return False
+
+ def on_button_press(self, widget, event):
+ if event.button == 1: # left mouse button
+ self.set_active (not self.get_active(), event.time)
+ return True
+
+ def get_reference_widget(self):
+ return self.image
+
+ def get_applet(self):
+ return self.applet
+
+ def on_loaded(self, sender):
+ AbstractCuemiacDeskbarIcon.on_loaded (self, sender)
+ self.tray.set_sensitive(True)
+
+ def setup_menu(self):
+ self.applet.setup_menu_from_file (
+ deskbar.SHARED_DATA_DIR, "Deskbar_Applet.xml",
+ None, [
+ ("About", lambda a,b: self._controller.on_show_about(a)),
+ ("Prefs", lambda a,b: self._controller.on_show_preferences(a)),
+ ("Clear", lambda a,b: self._controller.on_clear_history(a),),
+ ("Help", lambda a,b: self._controller.on_show_help(a),)
+ ])
+
\ No newline at end of file
Modified: trunk/deskbar/ui/Makefile.am
==============================================================================
--- trunk/deskbar/ui/Makefile.am (original)
+++ trunk/deskbar/ui/Makefile.am Tue Apr 8 14:52:26 2008
@@ -8,5 +8,5 @@
CuemiacWindowController.py \
CuemiacWindowView.py \
CuemiacAlignedView.py \
- DeskbarStatusIcon.py \
- DeskbarTray.py
+ DeskbarApplet.py \
+ DeskbarStatusIcon.py
Modified: trunk/po/POTFILES.in
==============================================================================
--- trunk/po/POTFILES.in (original)
+++ trunk/po/POTFILES.in Tue Apr 8 14:52:26 2008
@@ -42,8 +42,8 @@
deskbar/ui/cuemiac/CuemiacItems.py
deskbar/ui/CuemiacAlignedView.py
deskbar/ui/CuemiacWindowView.py
+deskbar/ui/DeskbarApplet.py
deskbar/ui/DeskbarStatusIcon.py
-deskbar/ui/DeskbarTray.py
deskbar/ui/preferences/AccelEntry.py
deskbar/ui/preferences/DeskbarPreferences.py
deskbar/ui/preferences/ErrorDialog.py
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]