Re: [Deskbar] aligned window patch



This is just ironic:
http://www.google.com/search?q=subclass+gnome.applet.Applet

Well Raphaels old aligned-window patch still applies to cvs and "works"
- to the extent that the window shows up and resizes on async matches :)

I attached the patch since I'm not sure we have it anywhere...

Cheers
Mikkel


On Wed, 2005-10-19 at 09:37 +0200, Mikkel Kamstrup Erlandsen wrote:
> I was fiddling about with the aligned window patch, but I cannot get it
> working anymore. It still applies, but when I run deskbar I get 
> 
> Traceback (most recent call last):
>   File
> "/home/mikkel/Projects/deskbar-applet-devel/deskbar/deskbar-applet",
> line 85, in ?
>     build_window()
>   File
> "/home/mikkel/Projects/deskbar-applet-devel/deskbar/deskbar-applet",
> line 45, in build_window
>     applet = deskbar.applet.DeskbarApplet()
>   File "/home/mikkel/Projects/deskbar-applet-devel/deskbar/applet.py",
> line 13, in __init__
>     gnomeapplet.Applet.__init__(self)
> RuntimeError: cannot subclass gnome.applet.Applet
> 
> 
> But it was working when I tried it out first time - and it *was*
> subclassing gnomeapplet.Applet at that time ...
> 
> What is going on?
> 
> Cheers
> Mikkel
> 
> PS: Please don't tell me it's problems with threading in gtk :)
> 
> _______________________________________________
> deskbar-applet-list mailing list
> deskbar-applet-list gnome org
> http://mail.gnome.org/mailman/listinfo/deskbar-applet-list
> 
Index: deskbar/aligned_window.py
===================================================================
RCS file: deskbar/aligned_window.py
diff -N deskbar/aligned_window.py
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ deskbar/aligned_window.py	16 Oct 2005 22:05:56 -0000
@@ -0,0 +1,93 @@
+#!/usr/bin/python
+import gtk
+import gnomeapplet
+
+class AlignedWindow(gtk.Window):
+
+    def __init__(self, widgetToAlignWith, orient_func):
+        gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)
+        self.set_decorated(False)
+        
+        self.widgetToAlignWith = widgetToAlignWith
+        self.get_orient = orient_func
+
+    def positionWindow(self):
+        # Get our own dimensions & position
+        self.realize()
+        gtk.gdk.flush()
+        ourWidth  = (self.window.get_geometry())[2]
+        ourHeight = (self.window.get_geometry())[3]
+
+        # Skip the taskbar, and the pager, stick and stay on top
+        self.stick()
+        self.set_keep_above(True)
+        self.set_skip_pager_hint(True)
+        self.set_skip_taskbar_hint(True)
+        self.set_type_hint (gtk.gdk.WINDOW_TYPE_HINT_DOCK)
+
+        # Get the dimensions/position of the widgetToAlignWith
+        self.widgetToAlignWith.realize()
+        (x, y) = self.widgetToAlignWith.window.get_origin()
+
+        (w, h) = self.get_size()
+        (w, h) = self.size_request()
+
+        button_w = self.widgetToAlignWith.allocation.width
+        button_h = self.widgetToAlignWith.allocation.height
+
+        screen = self.get_screen()
+
+        found_monitor = False
+        n = screen.get_n_monitors()
+        for i in range(0, n):
+                monitor = screen.get_monitor_geometry(i)
+                if (x >= monitor.x and x <= monitor.x + monitor.width and \
+                    y >= monitor.y and y <= monitor.y + monitor.height):
+                        found_monitor = True
+                        break
+        
+        if not found_monitor:
+                monitor = gtk.gdk.Rectangle(0, 0, screen.get_width(), screen.get_width())
+        
+        orient = self.get_orient()
+        if orient == gnomeapplet.ORIENT_RIGHT:
+                x += button_w
+
+                if ((y + h) > monitor.y + monitor.height):
+                        y -= (y + h) - (monitor.y + monitor.height)
+                
+                if ((y + h) > (monitor.height / 2)):
+                        gravity = gtk.gdk.GRAVITY_SOUTH_WEST
+                else:
+                        gravity = gtk.gdk.GRAVITY_NORTH_WEST
+        elif orient == gnomeapplet.ORIENT_LEFT:
+                x -= w
+
+                if ((y + h) > monitor.y + monitor.height):
+                        y -= (y + h) - (monitor.y + monitor.height)
+                
+                if ((y + h) > (monitor.height / 2)):
+                        gravity = gtk.gdk.GRAVITY_SOUTH_EAST
+                else:
+                        gravity = gtk.gdk.GRAVITY_NORTH_EAST
+        elif orient == gnomeapplet.ORIENT_DOWN:
+                y += button_h
+
+                if ((x + w) > monitor.x + monitor.width):
+                        x -= (x + w) - (monitor.x + monitor.width)
+
+                gravity = gtk.gdk.GRAVITY_NORTH_WEST
+        elif orient == gnomeapplet.ORIENT_UP:
+                y -= h
+
+                if ((x + w) > monitor.x + monitor.width):
+                        x -= (x + w) - (monitor.x + monitor.width)
+
+                gravity = gtk.gdk.GRAVITY_SOUTH_WEST
+        
+        # -"Coordinates locked in captain."
+        # -"Engage."
+        self.move(x, y)
+        self.set_gravity(gravity)
+        self.show()
+
Index: deskbar/applet.py
===================================================================
RCS file: /cvs/gnome/deskbar-applet/deskbar/applet.py,v
retrieving revision 1.24
diff -u -p -r1.24 applet.py
--- deskbar/applet.py	16 Oct 2005 20:57:59 -0000	1.24
+++ deskbar/applet.py	16 Oct 2005 22:05:56 -0000
@@ -7,6 +7,8 @@ import deskbar, deskbar.deskbarentry, de
 from deskbar.module_list import ModuleLoader, ModuleList, ModuleLoader
 from deskbar.preferences import update_modules_priority
 
+import aligned_window
+
 class DeskbarApplet:
 	def __init__(self, applet):
 		self.applet = applet
@@ -23,13 +25,16 @@ class DeskbarApplet:
 		self.loader.connect ("module-initialized", self.module_list.module_toggled_cb)
 		self.loader.connect ("module-initialized", self.on_module_initialized)
 		self.loader.connect ("module-stopped", self.module_list.module_toggled_cb)
-		
+				
 		self.entry = deskbar.deskbarentry.DeskbarEntry(self.module_list)
 		self.entry.get_evbox().connect("button-press-event", self.on_icon_button_press)
 		self.entry.get_entry().connect("button-press-event", self.on_entry_button_press)
 		self.loader.connect ("module-initialized", self.entry._connect_if_async)
 		self.on_applet_sensivity_update(False)
-
+		
+		self.dropdown = aligned_window.AlignedWindow(self.entry, self.applet.get_orient)
+		self.entry.add_to_dropdown(self.dropdown)
+		
 		self.keybinder = deskbar.applet_keybinder.AppletKeybinder(self)
 
 		# Set and retreive entry width from gconf
Index: deskbar/deskbarentry.py
===================================================================
RCS file: /cvs/gnome/deskbar-applet/deskbar/deskbarentry.py,v
retrieving revision 1.17
diff -u -p -r1.17 deskbarentry.py
--- deskbar/deskbarentry.py	16 Oct 2005 20:57:59 -0000	1.17
+++ deskbar/deskbarentry.py	16 Oct 2005 22:05:56 -0000
@@ -94,6 +94,24 @@ class DeskbarEntry(deskbar.iconentry.Ico
 		completion.pack_start(renderer)
 		completion.add_attribute(renderer, "markup", ACTION_COL)
 	
+	def add_to_dropdown(self, dropdown):
+		tv = gtk.TreeView(self._completion_model)
+		tv.show()
+		dropdown.add(tv)
+		
+		renderer = gtk.CellRendererPixbuf()
+		column_icon = gtk.TreeViewColumn ("Icon", renderer)
+		column_icon.set_attributes (renderer, pixbuf=ICON_COL)
+		
+		renderer = gtk.CellRendererText ()
+		column_description = gtk.TreeViewColumn ("Description", renderer)
+		column_description.set_attributes (renderer, markup=ACTION_COL)
+		
+		tv.append_column(column_icon)
+		tv.append_column(column_description)
+				
+		self.dropdown = dropdown
+		
 	def get_evbox(self):
 		return self._evbox
 	
@@ -235,6 +253,8 @@ class DeskbarEntry(deskbar.iconentry.Ico
 			self._append_matches (result)
 		else:
 			self._append_matches (matches)
+		
+		self.dropdown.show()
 	
 	def _append_matches (self, matches):
 		"""


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]