def __init__(self, wid): self.wid = wid self.gdk = gtk.gdk.window_foreign_new_for_display( state.gtk_display, self.wid) self.name = ewmh.get_wm_name(self.wid).reply() self.geom = self.get_geometry() self.desk = ewmh.get_wm_desktop(self.wid).reply() self.invis = gtk.Invisible() self.gdk.set_events(gtk.gdk.PROPERTY_CHANGE_MASK | gtk.gdk.STRUCTURE_MASK) self.gdk.set_user_data(self.invis) self.invis.connect('property_notify_event', self.cb_prop_change) # This is interesting; look for configure events on the decor window if state.wmname.lower() == 'openbox': pid = window.get_parent_window(self.wid) pgdk = gtk.gdk.window_foreign_new_for_display( state.gtk_display, pid) pinvis = gtk.Invisible() pgdk.set_events(gtk.gdk.STRUCTURE_MASK) pgdk.set_user_data(pinvis) pinvis.connect('configure_event', self.cb_configure) else: self.invis.connect('configure_event', self.cb_configure) self.update_state()
def block_keyboard_mouse(self): if not self.__grabwindow: self.__grabwindow = gtk.Invisible() self.__grabwindow.show() self.__grabwindow.realize() self.__block_mouse() gobject.idle_add(gtk.gdk.keyboard_grab,self.__grabwindow.window,True)
def text_color(): "color as triple or None" settings = gtk.settings_get_default() s = gtk.rc_get_style_by_paths(settings, "kupfer.*", None, None) if not s: e = gtk.Invisible() e.realize() s = e.style c = s.fg[gtk.STATE_NORMAL] return (1.0*c.red/0xffff, 1.0*c.green/0xffff, 1.0*c.blue/0xffff)
def _setMsgLevel(self, titer, messages): icon = None if messages: messages = sorted(messages, cmp=lambda x, y: x.level - y.level) level = messages[0].level st = _stock_icons.get(level, gtk.STOCK_MISSING_IMAGE) w = gtk.Invisible() icon = w.render_icon(st, gtk.ICON_SIZE_MENU) self._model.set(titer, COL_MSG, icon)
def run_neat(self, *args): #Create a gtkInvisible dialog to block until up2date is complete i = gtk.Invisible() i.grab_add() #Run rhn_register so they can register with RHN pid = start_process("/usr/bin/system-config-network") # get the x window id xid = None round = 0 # keep trying for 3 seconds while xid is None and round < 3: rc, out = commands.getstatusoutput('xwininfo -name' \ ' "Network Configuration" -int') pattern = re.compile("xwininfo:\sWindow\sid:\s(?P<xid>\d+)\s.*") for line in out.splitlines(): m = pattern.match(line) if m: xid = long(m.group("xid")) round += 1 time.sleep(1) # if we have the xid, embed the window if xid is not None: network_dlg = gtk.gdk.window_foreign_new(xid) self.parent.win.realize() network_dlg.set_transient_for(self.parent.win.window) network_dlg.set_modal_hint(True) # XXX if we keep the main window fullscreen, # and use alt+tab, the network window is gone forever self.parent.win.unfullscreen() flag = None while not flag: while gtk.events_pending(): gtk.main_iteration_do() child_pid, status = os.waitpid(pid, os.WNOHANG) if child_pid == pid: flag = 1 else: time.sleep(0.1) # make the main window fullscreen again self.parent.win.fullscreen() i.grab_remove() self.updateLabels()
def _create_invisible(self, x, y, width, height, delay): invisible = gtk.Invisible() if delay >= 0: invisible.connect('enter-notify-event', self._enter_notify_cb, delay) invisible.connect('leave-notify-event', self._leave_notify_cb) invisible.drag_dest_set(0, [], 0) invisible.connect('drag_motion', self._drag_motion_cb) invisible.connect('drag_leave', self._drag_leave_cb) invisible.realize() # pylint: disable=E1101 invisible.window.set_events(gtk.gdk.POINTER_MOTION_MASK | gtk.gdk.ENTER_NOTIFY_MASK | gtk.gdk.LEAVE_NOTIFY_MASK) invisible.window.move_resize(x, y, width, height) return invisible
def _runAuthconfig(self, *args): self.nisFlag = 1 # Create a gtkInvisible to block until authconfig is done. i = gtk.Invisible() i.grab_add() pid = start_process("/usr/bin/authconfig-gtk", "--firstboot") while True: while gtk.events_pending(): gtk.main_iteration_do() child_pid, status = os.waitpid(pid, os.WNOHANG) if child_pid == pid: break else: time.sleep(0.1) i.grab_remove()
def run_neat(self, *args): #Create a gtkInvisible dialog to block until up2date is complete i = gtk.Invisible() i.grab_add() #Run rhn_register so they can register with RHN pid = start_process("/usr/bin/system-config-network") flag = None while not flag: while gtk.events_pending(): gtk.main_iteration_do() child_pid, status = os.waitpid(pid, os.WNOHANG) if child_pid == pid: flag = 1 else: time.sleep(0.1) i.grab_remove() self.updateLabels()
def format_color_string(Color): return "%s %s %s" % (Color.red / 256, Color.green / 256, Color.blue / 256) def print_hex_color(Color): return "#" + hex(Color.red / 256)[2:] + hex(Color.green / 256)[2:] + hex( Color.blue / 256)[2:] def format_color_key(key, Color): return "\"%s\"=\"%s\" (%s)\n" % (key, format_color_string(Color), print_hex_color(Color)) invisible1 = gtk.Invisible() style1 = invisible1.style button1 = gtk.Button() buttonstyle = button1.style scroll1 = gtk.VScrollbar() scrollbarstyle = scroll1.style menu1 = gtk.Menu() menuitem1 = gtk.MenuItem() menu1.add(menuitem1) menustyle = menuitem1.style format = "" format += format_color_key('Scrollbar', scrollbarstyle.bg[gtk.STATE_NORMAL])
wmname = ewmh.get_wm_name(childw).reply() print '%s window manager is running...' % wmname sys.stdout.flush() if not wmrunning: time.sleep(1) import config from keymousebind import keybinds xinerama = xpybutil.conn(xinerama.key) gtk_display = gtk.gdk.display_get_default() gtk_screen = gtk_display.get_default_screen() gtk_root = gtk_screen.get_root_window() gtk_rootwin = gtk.Invisible() gtk_root.set_user_data(gtk_rootwin) gtk_root.set_events(gtk.gdk.PROPERTY_CHANGE_MASK | gtk.gdk.KEY_PRESS_MASK) # Initial setup if config.desktops: ewmh.set_desktop_names_checked(config.desktops).check() ewmh.set_desktop_layout_checked(ewmh.Orientation.Horz, len(config.desktops), 1, ewmh.StartingCorner.TopLeft).check() ewmh.request_number_of_desktops_checked(len(config.desktops)).check() # Is this a horizontal or vertical pager? if config.width > config.height: orient = 'H'
def autorun(self, *args): def getCDDev(): drives = kudzu.probe(kudzu.CLASS_CDROM, kudzu.BUS_UNSPEC, kudzu.PROBE_ALL) return map (lambda d: d.device, drives) #Create a gtkInvisible widget to block until the autorun is complete i = gtk.Invisible () i.grab_add () dev = None mounted = False while not mounted: for device in getCDDev(): if device is None: continue try: subprocess.call(["mount", "-o", "ro", "/dev/%s" % device, "/mnt"]) dev = device break except: continue if dev is None: dlg = gtk.MessageDialog(None, 0, gtk.MESSAGE_ERROR, gtk.BUTTONS_NONE, (_("A CD-ROM has not been detected. Please insert " "a CD-ROM in the drive and click \"OK\" to continue."))) dlg.set_position(gtk.WIN_POS_CENTER) dlg.set_modal(True) cancelButton = dlg.add_button('gtk-cancel', 0) okButton = dlg.add_button('gtk-ok', 1) rc = dlg.run() dlg.destroy() if rc == 0: #Be sure to remove the focus grab if we have to return here. #Otherwise, the user is stuck i.grab_remove () return else: mounted = True if os.access("/mnt/autorun", os.R_OK): #If there's an autorun file on the cd, run it pid = start_process("/mnt/autorun") flag = None while not flag: while gtk.events_pending(): gtk.main_iteration_do() child_pid, status = os.waitpid(pid, os.WNOHANG) if child_pid == pid: flag = 1 else: time.sleep(0.1) else: #There's no autorun on the disc, so complain dlg = gtk.MessageDialog(None, 0, gtk.MESSAGE_ERROR, gtk.BUTTONS_NONE, (_("The autorun program cannot be found on the CD. " "Click \"OK\" to continue."))) dlg.set_position(gtk.WIN_POS_CENTER) dlg.set_modal(True) okButton = dlg.add_button('gtk-ok', 0) rc = dlg.run() dlg.destroy() if rc == 0: #Be sure to remove the focus grab if we have to return here. #Otherwise, the user is stuck i.grab_remove () #I think system-config-packages will do a umount, but just in case it doesn't... try: subprocess.call(["umount", "/mnt"]) except: #Yep, system-config-packages has already umounted the disc, so fall through and go on pass #Remove the focus grab of the gtkInvisible widget i.grab_remove ()