def Xenter(self): assert self.depth >= 0 verify_main_thread() Gdk.error_trap_push() if XPRA_LOG_SYNC: log("X11trap.enter at level %i", self.depth) self.depth += 1
def Xenter(self): assert self.depth >= 0 verify_main_thread() Gdk.error_trap_push() if XPRA_LOG_SYNC: log("X11trap.enter at level %i", self.depth) if LOG_NESTED_XTRAP and self.depth > 0: for x in traceback.extract_stack(): log("%s", x) self.depth += 1
def GetScreenNums(): screens = [] nScreens = max(GetDefaultScreenNum(), GetCurrentScreenNum()) + 1 display = Gdk.Display.get_default() if GTK_VERSION >= (3, 10, 0): Gdk.error_trap_push() try: import Xlib.display xdisplay = Xlib.display.Display(display.get_name()) nScreens = xdisplay.screen_count() except: pass Gdk.error_trap_pop_ignored() else: nScreens = display.get_n_screens() for s in range(nScreens): screens.append(s) return screens
def main(): """ creates a HAL component. parsees a glade XML file with Gtk.builder or libglade calls gladevcp.makepins with the specified XML file to create pins and register callbacks. main window must be called "window1" """ global gladevcp_debug (progdir, progname) = os.path.split(sys.argv[0]) usage = "usage: %prog [options] myfile.ui" parser = OptionParser(usage=usage) parser.disable_interspersed_args() parser.add_options(options) (opts, args) = parser.parse_args() if not args: parser.print_help() sys.exit(1) gladevcp_debug = debug = opts.debug xmlname = args[0] #if there was no component name specified use the xml file name if opts.component is None: opts.component = os.path.splitext(os.path.basename(xmlname))[0] #try loading as a libglade project try: builder = Gtk.Builder() builder.add_from_file(xmlname) except: try: # try loading as a Gtk.builder project dbg("**** GLADE VCP INFO: Not a builder project, trying to load as a lib glade project") builder = Gtk.glade.XML(xmlname) builder = GladeBuilder(builder) except Exception as e: print("**** GLADE VCP ERROR: With xml file: %s : %s" % (xmlname,e), file=sys.stderr) sys.exit(0) window = builder.get_object("window1") window.set_title(opts.component) try: halcomp = hal.component(opts.component) except: print("*** GLADE VCP ERROR: Asking for a HAL component using a name that already exists.", file=sys.stderr) sys.exit(0) panel = gladevcp.makepins.GladePanel( halcomp, xmlname, builder, None) # at this point, any glade HL widgets and their pins are set up. handlers, mod, obj = load_handlers(opts.usermod,halcomp,builder,opts.useropts) # so widgets can call handler functions - give them refeence to the handler object panel.set_handler(obj) builder.connect_signals(handlers) # This option puts the gladevcp panel into a plug and pushed the plug's # X window id number to standard output - so it can be reparented exterally # it also forwards events to qtvcp if opts.push_XID: if not opts.debug: # supress warnings when x window closes warnings.filterwarnings("ignore") # block X errors since Gdk error handling silently exits the # program without even the atexit handler given a chance Gdk.error_trap_push() forward = os.environ.get('QTVCP_FORWARD_EVENTS_TO', None) if forward: xembed.keyboard_forward(window, forward) # This option reparents gladevcp in a given X window id. # it also forwards keyboard events from gladevcp to AXIS if opts.parent: if not opts.debug: # supress warnings when x window closes warnings.filterwarnings("ignore") # block X errors since Gdk error handling silently exits the # program without even the atexit handler given a chance Gdk.error_trap_push() window = xembed.reparent(window, opts.parent) forward = os.environ.get('AXIS_FORWARD_EVENTS_TO', None) if forward: xembed.keyboard_forward(window, forward) window.connect("destroy", on_window_destroy) window.show() # for window resize and or position options if "+" in opts.geometry: try: j = opts.geometry.partition("+") pos = j[2].partition("+") window.move( int(pos[0]), int(pos[2]) ) except: print("**** GLADE VCP ERROR: With window position data", file=sys.stderr) parser.print_usage() sys.exit(1) if "x" in opts.geometry: try: if "+" in opts.geometry: j = opts.geometry.partition("+") t = j[0].partition("x") else: t = window_geometry.partition("x") window.resize( int(t[0]), int(t[2]) ) except: print("**** GLADE VCP ERROR: With window resize data", file=sys.stderr) parser.print_usage() sys.exit(1) if opts.gtk_rc: dbg( "**** GLADE VCP INFO: %s reading gtkrc file '%s'" %(opts.component,opts.gtk_rc)) Gtk.rc_add_default_file(opts.gtk_rc) Gtk.rc_parse(opts.gtk_rc) if opts.theme: dbg("**** GLADE VCP INFO: Switching %s to '%s' theme" %(opts.component,opts.theme)) settings = Gtk.Settings.get_default() settings.set_string_property("gtk-theme-name", opts.theme, "") # This needs to be done after geometry moves so on dual screens the window maxumizes to the actual used screen size. if opts.maximum: window.window.maximize() if opts.always_above_flag: window.set_keep_above(True) if opts.halfile: if opts.halfile[-4:] == ".tcl": cmd = ["haltcl", opts.halfile] else: cmd = ["halcmd", "-f", opts.halfile] res = subprocess.call(cmd, stdout=sys.stdout, stderr=sys.stderr) if res: print("'%s' exited with %d" %(' '.join(cmd), res), file=sys.stderr) sys.exit(res) # User components are set up so report that we are ready halcomp.ready() GSTAT.forced_update() # push the XWindow id number to standard out if opts.push_XID or opts.parent: w_id = window.get_property('window').get_xid() print(w_id, file=sys.stdout) sys.stdout.flush() if signal_func in handlers: dbg("Register callback '%s' for SIGINT and SIGTERM" %(signal_func)) signal.signal(signal.SIGTERM, handlers[signal_func]) signal.signal(signal.SIGINT, handlers[signal_func]) try: Gtk.main() except KeyboardInterrupt: sys.exit(0) finally: halcomp.exit() if opts.parent or opts.push_XID: Gdk.flush() error = Gdk.error_trap_pop() if error and opts.debug: print("**** GLADE VCP ERROR: X Protocol Error: %s" % str(error), file=sys.stderr)