def gtk_main_quit_forever(): # We import gtk inside here, rather than at the top of the file, # because importing gtk has the side-effect of trying to connect to # the X server (and this process may block, may cause us to later be # killed if the X server goes away, etc.), and we don't want to impose # that on every user of wimpiggy.util. from wimpiggy.gobject_compat import import_gtk gtk = import_gtk() gtk.main_quit() # So long as there are more nested main loops, re-register ourselves # to be called again: if gtk.main_level() > 1: return True else: # But when we've just quit the outermost main loop, then # unregister ourselves so that it's possible to start the # main-loop again if desired: return False
# This file is part of Parti. # Copyright (C) 2011 Serviware (Arthur Huillet, <*****@*****.**>) # Copyright (C) 2010-2012 Antoine Martin <*****@*****.**> # Copyright (C) 2008, 2010 Nathaniel Smith <*****@*****.**> # Parti is released under the terms of the GNU GPL v2, or, at your option, any # later version. See the file COPYING for details. #pygtk3 vs pygtk2 (sigh) from wimpiggy.gobject_compat import import_gobject, import_gtk, import_gdk, is_gtk3 gobject = import_gobject() gtk = import_gtk() gdk = import_gdk() if is_gtk3(): def get_root_size(): return gdk.get_default_root_window().get_geometry()[2:] def set_windows_cursor(gtkwindows, new_cursor): pass #window.override_cursor(cursor, None) else: def get_root_size(): return gdk.get_default_root_window().get_size() def set_windows_cursor(gtkwindows, new_cursor): cursor = None if len(new_cursor) > 0: (_, _, w, h, xhot, yhot, serial, pixels) = new_cursor log.debug(
# This file is part of Parti. # Copyright (C) 2011 Serviware (Arthur Huillet, <*****@*****.**>) # Copyright (C) 2010-2012 Antoine Martin <*****@*****.**> # Copyright (C) 2008, 2010 Nathaniel Smith <*****@*****.**> # Parti is released under the terms of the GNU GPL v2, or, at your option, any # later version. See the file COPYING for details. #pygtk3 vs pygtk2 (sigh) from wimpiggy.gobject_compat import import_gobject, import_gtk, import_gdk, is_gtk3 gobject = import_gobject() gtk = import_gtk() gdk = import_gdk() if is_gtk3(): def get_root_size(): return gdk.get_default_root_window().get_geometry()[2:] def set_windows_cursor(gtkwindows, new_cursor): pass #window.override_cursor(cursor, None) else: def get_root_size(): return gdk.get_default_root_window().get_size() def set_windows_cursor(gtkwindows, new_cursor): cursor = None if len(new_cursor)>0: (_, _, w, h, xhot, yhot, serial, pixels) = new_cursor log.debug("new cursor at %s,%s with serial=%s, dimensions: %sx%s, len(pixels)=%s" % (xhot,yhot, serial, w,h, len(pixels))) pixbuf = gdk.pixbuf_new_from_data(pixels, gdk.COLORSPACE_RGB, True, 8, w, h, w * 4) x = max(0, min(xhot, w-1)) y = max(0, min(yhot, h-1)) size = gdk.display_get_default().get_default_cursor_size() if size>0 and (size<w or size<h):