And the patch
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 17 Oct 2005 16:13:07 -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 17 Oct 2005 16:13:07 -0000 @@ -7,10 +7,11 @@ import deskbar, deskbar.deskbarentry, de from deskbar.module_list import ModuleLoader, ModuleList, ModuleLoader from deskbar.preferences import update_modules_priority -class DeskbarApplet: - def __init__(self, applet): - self.applet = applet - +class DeskbarApplet(gnomeapplet.Applet): + def __init__(self): + gnomeapplet.Applet.__init__(self) + + def init(self): self._inited_modules = 0 self._loaded_modules = 0 @@ -23,13 +24,13 @@ 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 = deskbar.deskbarentry.DeskbarEntry(self, 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.keybinder = deskbar.applet_keybinder.AppletKeybinder(self) # Set and retreive entry width from gconf @@ -42,15 +43,15 @@ class DeskbarApplet: self.config_expand = False deskbar.GCONF_CLIENT.notify_add(deskbar.GCONF_EXPAND, lambda x, y, z, a: self.on_config_expand(z.value)) - self.applet.set_flags(gtk.CAN_FOCUS) - self.applet.add(self.entry) - self.applet.connect("button-press-event", self.on_applet_button_press) - self.applet.connect('destroy', lambda x: self.keybinder.unbind()) - self.applet.setup_menu_from_file ( + self.set_flags(gtk.CAN_FOCUS) + self.add(self.entry) + self.connect("button-press-event", self.on_applet_button_press) + self.connect('destroy', lambda x: self.keybinder.unbind()) + self.setup_menu_from_file ( None, os.path.join(deskbar.SHARED_DATA_DIR, "Deskbar_Applet.xml"), None, [("About", self.on_about), ("Prefs", self.on_preferences)]) - self.applet.show_all() + self.show_all() self.sync_applet_size() self.entry.get_entry().grab_focus() @@ -73,9 +74,9 @@ class DeskbarApplet: def sync_applet_size(self): if self.config_expand: - self.applet.set_applet_flags(gnomeapplet.EXPAND_MINOR | gnomeapplet.EXPAND_MAJOR) + self.set_applet_flags(gnomeapplet.EXPAND_MINOR | gnomeapplet.EXPAND_MAJOR) else: - self.applet.set_applet_flags(0) + self.set_applet_flags(0) # Set the new size of the entry self.entry.get_entry().set_width_chars(self.config_width) @@ -112,7 +113,7 @@ class DeskbarApplet: try: # GNOME 2.12 - self.applet.request_focus(long(event.time)) + self.request_focus(long(event.time)) except AttributeError: pass @@ -131,7 +132,7 @@ class DeskbarApplet: return False if event.button == 3: - self.applet.emit("button-press-event", event) + self.emit("button-press-event", event) return True elif event.button == 1: self.build_history_menu(event) @@ -142,7 +143,7 @@ class DeskbarApplet: def on_entry_button_press(self, widget, event): try: # GNOME 2.12 - self.applet.request_focus(long(event.time)) + self.request_focus(long(event.time)) except AttributeError: pass @@ -193,3 +194,5 @@ class DeskbarApplet: menu.show_all() menu.popup(None, None, None, event.button, event.time) + +gobject.type_register(DeskbarApplet) Index: deskbar/deskbar-applet =================================================================== RCS file: /cvs/gnome/deskbar-applet/deskbar/deskbar-applet,v retrieving revision 1.10 diff -u -p -r1.10 deskbar-applet --- deskbar/deskbar-applet 16 Oct 2005 20:57:59 -0000 1.10 +++ deskbar/deskbar-applet 17 Oct 2005 16:13:07 -0000 @@ -5,7 +5,6 @@ import gtk gtk.threads_init() - import gnomeapplet import getopt, sys @@ -23,11 +22,11 @@ else: print "Running installed deskbar, using normal PYTHONPATH" # Now the path is set, import our applet -import deskbar.applet +import deskbar, deskbar.applet +import gettext -def applet_factory(applet, iid): - deskbar.applet.DeskbarApplet(applet) - return True +gettext.bindtextdomain('deskbar-applet', join(deskbar.DATA_DIR, "locale")) +gettext.textdomain('deskbar-applet') # Return a standalone window that holds the applet def build_window(): @@ -36,8 +35,8 @@ def build_window(): app.connect("destroy", gtk.main_quit) app.set_property('resizable', False) - applet = gnomeapplet.Applet() - applet_factory(applet, None) + applet = deskbar.applet.DeskbarApplet() + applet.init() applet.reparent(app) app.show_all() @@ -79,9 +78,13 @@ if __name__ == "__main__": build_window() gtk.main() else: + def applet_factory(applet, iid): + applet.init() + return True + gnomeapplet.bonobo_factory( "OAFIID:Deskbar_Applet_Factory", - gnomeapplet.Applet.__gtype__, + deskbar.applet.DeskbarApplet.__gtype__, "deskbar-applet", "0", applet_factory) 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 17 Oct 2005 16:13:07 -0000 @@ -6,6 +6,7 @@ import gtk, gobject import deskbar, deskbar.iconentry from deskbar.module_list import ModuleList from deskbar.handler import * +import aligned_window # The liststore columns HANDLER_PRIO_COL = 0 @@ -27,7 +28,7 @@ MOVE_UP = -1 MOVE_DOWN = +1 class DeskbarEntry(deskbar.iconentry.IconEntry): - def __init__(self, module_list): + def __init__(self, applet, module_list): deskbar.iconentry.IconEntry.__init__(self) # Set up the Handlers @@ -67,33 +68,37 @@ class DeskbarEntry(deskbar.iconentry.Ico self._completion_model.set_sort_func(SORT_BY_HANDLER_MATCH_ACTION, self._on_sort_matches) # Create the completion model - completion = gtk.EntryCompletion() - try: - # PyGTK >= 2.8 - completion.set_popup_set_width(False) - completion.set_property("text-column", ACTION_COL) - except AttributeError: - pass - - try: - # PyGTK >= 2.4 - completion.set_match_func(lambda x, y, z: True) - completion.set_model(self._completion_model) - except AttributeError: - pass - - completion.connect("match-selected", self._on_completion_selected) - entry.set_completion(completion) + self.completion_view = gtk.TreeView(self._completion_model) + self.completion_view.set_property('enable-search', False) + self.completion_view.set_property('headers-visible', False) + self.completion_view.set_property('rules-hint', True) + self.completion_view.connect("row-activated", self._on_completion_selected) - # Paint it accordingly + # Paint it renderer = gtk.CellRendererPixbuf() - completion.pack_start(renderer) - completion.add_attribute(renderer, "pixbuf", ICON_COL) + 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) + + self.completion_view.append_column(column_icon) + self.completion_view.append_column(column_description) + + self.dropdown = aligned_window.AlignedWindow(self, applet.get_orient) + + scroll = gtk.ScrolledWindow() + scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_NEVER) + scroll.set_property("hscrollbar-policy", gtk.POLICY_NEVER) + scroll.set_property("vscrollbar-policy", gtk.POLICY_AUTOMATIC) + scroll.set_property('shadow-type', gtk.SHADOW_IN) + scroll.set_property('window-placement', gtk.CORNER_TOP_LEFT) + scroll.add(self.completion_view) + scroll.show_all() + + self.dropdown.add(scroll) - renderer = gtk.CellRendererText() - completion.pack_start(renderer) - completion.add_attribute(renderer, "markup", ACTION_COL) - def get_evbox(self): return self._evbox @@ -126,8 +131,8 @@ class DeskbarEntry(deskbar.iconentry.Ico else: return 0 - def _on_completion_selected(self, completion, model, iterator): - match = model[iterator][MATCH_COL] + def _on_completion_selected(self, treeview, path, column): + match = model[treeview.get_model().get_iter(path)][MATCH_COL] text = self.get_entry().get_text().strip() # Do the action, match will be either a regular selected manually match @@ -235,6 +240,10 @@ class DeskbarEntry(deskbar.iconentry.Ico self._append_matches (result) else: self._append_matches (matches) + + self.get_entry().grab_focus() + self.dropdown.show() + self.get_entry().grab_focus() def _append_matches (self, matches): """
Attachment:
signature.asc
Description: This is a digitally signed message part