当前位置: 首页>>代码示例>>Python>>正文


Python GdkX11.x11_get_default_xdisplay方法代码示例

本文整理汇总了Python中gi.repository.GdkX11.x11_get_default_xdisplay方法的典型用法代码示例。如果您正苦于以下问题:Python GdkX11.x11_get_default_xdisplay方法的具体用法?Python GdkX11.x11_get_default_xdisplay怎么用?Python GdkX11.x11_get_default_xdisplay使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gi.repository.GdkX11的用法示例。


在下文中一共展示了GdkX11.x11_get_default_xdisplay方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: make_hole

# 需要导入模块: from gi.repository import GdkX11 [as 别名]
# 或者: from gi.repository.GdkX11 import x11_get_default_xdisplay [as 别名]
	def make_hole(self, border_width):
		"""
		Uses shape extension to create hole in window...
		Area needs only border, rest should be transparent.
		"""
		width, height = self.size
		dpy = X.Display(hash(GdkX11.x11_get_default_xdisplay()))		# I have no idea why this works...
		wid = X.XID(self.get_window().get_xid())
		
		mask = X.create_pixmap(dpy, wid, width, height, 1)
		xgcv = X.c_void_p()
		gc = X.create_gc(dpy, mask, 0, xgcv)
		
		X.set_foreground(dpy, gc, 1)
		X.fill_rectangle(dpy, mask, gc, 0, 0, width, height)
		
		X.set_foreground(dpy, gc, 0)
		X.fill_rectangle(dpy, mask, gc, border_width, border_width,
			width - 2 * border_width, height - 2 * border_width)
		
		SHAPE_BOUNDING = 0
		SHAPE_SET = 0
		X.shape_combine_mask(dpy, wid, SHAPE_BOUNDING, 0, 0, mask, SHAPE_SET)
		
		X.free_gc(dpy, gc)
		X.free_pixmap(dpy, mask)
开发者ID:alwaysLearnin,项目名称:sc-controller,代码行数:28,代码来源:area.py

示例2: make_window_clicktrough

# 需要导入模块: from gi.repository import GdkX11 [as 别名]
# 或者: from gi.repository.GdkX11 import x11_get_default_xdisplay [as 别名]
	def make_window_clicktrough(self):
		dpy = X.Display(hash(GdkX11.x11_get_default_xdisplay()))		# I have no idea why this works...
		win = X.XID(self.get_window().get_xid())
		reg = X.create_region(dpy, None, 0)
		X.set_window_shape_region (dpy, win, X.SHAPE_BOUNDING, 0, 0, 0)
		X.set_window_shape_region (dpy, win, X.SHAPE_INPUT, 0, 0, reg)
		X.destroy_region (dpy, reg)
开发者ID:TotalCaesar659,项目名称:sc-controller,代码行数:9,代码来源:__init__.py

示例3: __fill_layouts_dict

# 需要导入模块: from gi.repository import GdkX11 [as 别名]
# 或者: from gi.repository.GdkX11 import x11_get_default_xdisplay [as 别名]
def __fill_layouts_dict():
    """assemble dictionary of layout codes to corresponding layout name
    
    """
    _xkl_engine = Xkl.Engine.get_instance(GdkX11.x11_get_default_xdisplay())
    _xkl_registry = Xkl.ConfigRegistry.get_instance(_xkl_engine)
    _xkl_registry.load(False)

    layouts_dict = {}

    def variant_iter(registry, variant, layout):
        code = '%s/%s' % (xkl_strip(layout.name),
                          xkl_strip(variant.name))
        description = '%s - %s' % (xkl_strip(layout.description),
                                   xkl_strip(variant.description))
        if code not in layouts_dict:
            layouts_dict[code] = description

    def layout_iter(registry, layout, _):
        code = xkl_strip(layout.name)
        description = xkl_strip(layout.description)
        if code not in layouts_dict:
            layouts_dict[code] = description
        _xkl_registry.foreach_layout_variant(code, variant_iter, layout)

    _xkl_registry.foreach_layout(layout_iter, None)
    return layouts_dict
开发者ID:bankonme,项目名称:tails-greeter,代码行数:29,代码来源:language.py

示例4: update_labels

# 需要导入模块: from gi.repository import GdkX11 [as 别名]
# 或者: from gi.repository.GdkX11 import x11_get_default_xdisplay [as 别名]
	def update_labels(self):
		""" Updates keyboard labels based on active X keymap """
		labels = {}
		# Get current layout group
		dpy = X.Display(hash(GdkX11.x11_get_default_xdisplay()))		# Still no idea why...
		group = X.get_xkb_state(dpy).group
		# Get state of shift/alt/ctrl key
		mt = Gdk.ModifierType(self.keymap.get_modifier_state())
		for a in self.background.areas:
			# Iterate over all translatable keys...
			if hasattr(Keys, a.name) and getattr(Keys, a.name) in KEY_TO_GDK:
				# Try to convert GKD key to keycode
				gdkkey = KEY_TO_GDK[getattr(Keys, a.name)]
				found, entries = self.keymap.get_entries_for_keyval(gdkkey)
				
				if gdkkey == Gdk.KEY_equal:
					# Special case, GDK reports nonsense here
					entries = [ [ e for e in entries if e.level == 0 ][-1] ]
				
				if not found: continue
				for k in sorted(entries, key=lambda a : a.level):
					# Try to convert keycode to label
					code = Gdk.keyval_to_unicode(
						self.keymap.translate_keyboard_state(k.keycode, mt, group)
						.keyval)
					if code != 0:
						labels[a.name] = unichr(code)
						break
		
		self.background.set_labels(labels)
开发者ID:TotalCaesar659,项目名称:sc-controller,代码行数:32,代码来源:keyboard.py

示例5: __init__

# 需要导入模块: from gi.repository import GdkX11 [as 别名]
# 或者: from gi.repository.GdkX11 import x11_get_default_xdisplay [as 别名]
	def __init__(self, cls="osd-menu"):
		OSDWindow.__init__(self, cls)
		self.daemon = None
		self.config = None
		self.feedback = None
		self.controller = None
		self.xdisplay = X.Display(hash(GdkX11.x11_get_default_xdisplay()))	# Magic
		
		cursor = os.path.join(get_share_path(), "images", 'menu-cursor.svg')
		self.cursor = Gtk.Image.new_from_file(cursor)
		self.cursor.set_name("osd-menu-cursor")
		
		self.parent = self.create_parent()
		self.f = Gtk.Fixed()
		self.f.add(self.parent)
		self.add(self.f)
		
		self._submenu = None
		self._scon = StickController()
		self._scon.connect("direction", self.on_stick_direction)
		self._is_submenu = False
		self._selected = None
		self._menuid = None
		self._use_cursor = False
		self._eh_ids = []
		self._control_with = STICK
		self._control_with_dpad = False
		self._confirm_with = 'A'
		self._cancel_with = 'B'
开发者ID:kozec,项目名称:sc-controller,代码行数:31,代码来源:menu.py

示例6: __init__

# 需要导入模块: from gi.repository import GdkX11 [as 别名]
# 或者: from gi.repository.GdkX11 import x11_get_default_xdisplay [as 别名]
    def __init__(self):
        # pylint: disable-msg=E0611
        from gi.repository import GdkX11

        #initialize Xkl-related stuff
        display = GdkX11.x11_get_default_xdisplay()
        self._engine = Xkl.Engine.get_instance(display)

        self._rec = Xkl.ConfigRec()
        if not self._rec.get_from_server(self._engine):
            raise XklWrapperError("Failed to get configuration from server")

        #X is probably initialized to the 'us' layout without any variant and
        #since we want to add layouts with variants we need the layouts and
        #variants lists to have the same length. Add "" padding to variants.
        #See docstring of the add_layout method for details.
        diff = len(self._rec.layouts) - len(self._rec.variants)
        if diff > 0 and flags.can_touch_runtime_system("activate layouts"):
            self._rec.set_variants(self._rec.variants + (diff * [""]))
            if not self._rec.activate(self._engine):
                # failed to activate layouts given e.g. by a kickstart (may be
                # invalid)
                lay_var_str = ",".join(map(_join_layout_variant,
                                           self._rec.layouts,
                                           self._rec.variants))
                log.error("Failed to activate layouts: '%s', "
                          "falling back to default 'us'" % lay_var_str)
                self._rec.set_layouts(["us"])
                self._rec.set_variants([""])

                if not self._rec.activate(self._engine):
                    # failed to activate even the default "us" layout, something
                    # is really wrong
                    raise XklWrapperError("Failed to initialize layouts")

        #needed also for Gkbd.KeyboardDrawingDialog
        self.configreg = Xkl.ConfigRegistry.get_instance(self._engine)
        self.configreg.load(False)

        self._language_keyboard_variants = dict()
        self._country_keyboard_variants = dict()
        self._switching_options = list()

        #we want to display layouts as 'language (description)'
        self.name_to_show_str = dict()

        #we want to display layout switching options as e.g. "Alt + Shift" not
        #as "grp:alt_shift_toggle"
        self.switch_to_show_str = dict()

        #this might take quite a long time
        self.configreg.foreach_language(self._get_language_variants, None)
        self.configreg.foreach_country(self._get_country_variants, None)

        #'grp' means that we want layout (group) switching options
        self.configreg.foreach_option('grp', self._get_switch_option, None)
开发者ID:cs2c-zhangchao,项目名称:nkwin1.0-anaconda,代码行数:58,代码来源:keyboard.py

示例7: setup

# 需要导入模块: from gi.repository import GdkX11 [as 别名]
# 或者: from gi.repository.GdkX11 import x11_get_default_xdisplay [as 别名]
def setup():
    if not _USE_XKL:
        return

    gconf_client = GConf.Client.get_default()
    have_config = False

    try:
        display = GdkX11.x11_get_default_xdisplay()
        if display is not None:
            engine = Xkl.Engine.get_instance(display)
        else:
            logging.debug('setup_keyboard_cb: Could not get default display.')
            return

        configrec = Xkl.ConfigRec()
        configrec.get_from_server(engine)

        # FIXME, gconf_client_get_list not introspectable #681433
        layouts_from_gconf = gconf_client.get(
            '/desktop/sugar/peripherals/keyboard/layouts')
        layouts_list = []
        variants_list = []
        if layouts_from_gconf:
            for gval in layouts_from_gconf.get_list():
                layout = gval.get_string()
                layouts_list.append(layout.split('(')[0])
                variants_list.append(layout.split('(')[1][:-1])

            if layouts_list and variants_list:
                have_config = True
                configrec.set_layouts(layouts_list)
                configrec.set_variants(variants_list)

        model = gconf_client.get_string(\
            '/desktop/sugar/peripherals/keyboard/model')
        if model:
            have_config = True
            configrec.set_model(model)

        options = []
        # FIXME, gconf_client_get_list not introspectable #681433
        options_from_gconf = gconf_client.get(\
            '/desktop/sugar/peripherals/keyboard/options')
        if options_from_gconf:
            for gval in options_from_gconf.get_list():
                option = gval.get_string()
                options.append(option)
            if options:
                have_config = True
                configrec.set_options(options)

        if have_config:
            configrec.activate(engine)
    except Exception:
        logging.exception('Error during keyboard configuration')
开发者ID:ajaygarg84,项目名称:sugar,代码行数:58,代码来源:keyboard.py

示例8: generate

# 需要导入模块: from gi.repository import GdkX11 [as 别名]
# 或者: from gi.repository.GdkX11 import x11_get_default_xdisplay [as 别名]
	def generate(self, menuhandler):
		rv = []
		dpy = X.Display(hash(GdkX11.x11_get_default_xdisplay()))	# Magic
		root = X.get_default_root_window(dpy)
		
		count, wlist = X.get_window_prop(dpy, root, "_NET_CLIENT_LIST", 1024)
		skip_taskbar = X.intern_atom(dpy, "_NET_WM_STATE_SKIP_TASKBAR", True)
		wlist = cast(wlist, POINTER(X.XID))[0:count]
		for win in wlist:
			if not skip_taskbar in X.get_wm_state(dpy, win):
				title = X.get_window_title(dpy, win)[0:self.MAX_LENGHT]
				menuitem = MenuItem(str(win), title)
				menuitem.callback = WindowListMenuGenerator.callback
				rv.append(menuitem)
		return rv
开发者ID:kozec,项目名称:sc-controller,代码行数:17,代码来源:menu_generators.py

示例9: __init__

# 需要导入模块: from gi.repository import GdkX11 [as 别名]
# 或者: from gi.repository.GdkX11 import x11_get_default_xdisplay [as 别名]
    def __init__(self):
        #initialize Xkl-related stuff
        display = GdkX11.x11_get_default_xdisplay()
        self._engine = Xkl.Engine.get_instance(display)

        self._rec = Xkl.ConfigRec()
        if not self._rec.get_from_server(self._engine):
            raise XklWrapperError("Failed to get configuration from server")

        #X is probably initialized to the 'us' layout without any variant and
        #since we want to add layouts with variants we need the layouts and
        #variants lists to have the same length. Add "" padding to variants.
        #See docstring of the add_layout method for details.
        diff = len(self._rec.layouts) - len(self._rec.variants)
        if diff > 0 and flags.can_touch_runtime_system("activate layouts"):
            self._rec.set_variants(self._rec.variants + (diff * [""]))
            if not self._rec.activate(self._engine):
                # failed to activate layouts given e.g. by a kickstart (may be
                # invalid)
                lay_var_str = ",".join(map(join_layout_variant,
                                           self._rec.layouts,
                                           self._rec.variants))
                log.error("Failed to activate layouts: '%s', "
                          "falling back to default %s", lay_var_str, DEFAULT_KEYBOARD)
                self._rec.set_layouts([DEFAULT_KEYBOARD])
                self._rec.set_variants([""])

                if not self._rec.activate(self._engine):
                    # failed to activate even the default layout, something is
                    # really wrong
                    raise XklWrapperError("Failed to initialize layouts")

        #needed also for Gkbd.KeyboardDrawingDialog
        self.configreg = Xkl.ConfigRegistry.get_instance(self._engine)
        self.configreg.load(False)

        self._layout_infos = dict()
        self._layout_infos_lock = threading.RLock()
        self._switch_opt_infos = dict()
        self._switch_opt_infos_lock = threading.RLock()

        #this might take quite a long time
        self.configreg.foreach_language(self._get_language_variants, None)
        self.configreg.foreach_country(self._get_country_variants, None)

        #'grp' means that we want layout (group) switching options
        self.configreg.foreach_option('grp', self._get_switch_option, None)
开发者ID:nandakishore1006,项目名称:anaconda,代码行数:49,代码来源:xkl_wrapper.py

示例10: __init__

# 需要导入模块: from gi.repository import GdkX11 [as 别名]
# 或者: from gi.repository.GdkX11 import x11_get_default_xdisplay [as 别名]
    def __init__(self, model, alerts):
        SectionView.__init__(self)

        self._model = model

        self._kmodel = None
        self._selected_kmodel = None

        self._klayouts = []
        self._selected_klayouts = []

        self._group_switch_option = None
        self._selected_group_switch_option = None

        self.set_border_width(style.DEFAULT_SPACING * 2)
        self.set_spacing(style.DEFAULT_SPACING)

        self._layout_table = Gtk.Table(rows=4, columns=2, homogeneous=False)

        _build_ISO_639_dictionary()

        self._keyboard_manager = model.KeyboardManager(
            GdkX11.x11_get_default_xdisplay())

        self._layout_combo_list = []
        self._layout_addremovebox_list = []

        scrollwindow = Gtk.ScrolledWindow()
        scrollwindow.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
        self.pack_start(scrollwindow, True, True, 0)
        scrollwindow.show()

        self._vbox = Gtk.VBox()
        scrollwindow.add_with_viewport(self._vbox)

        self.__kmodel_sid = None
        self.__layout_sid = None
        self.__group_switch_sid = None

        self._setup_kmodel()
        self._setup_layouts()
        self._setup_group_switch_option()

        self._vbox.show()
开发者ID:AbrahmAB,项目名称:sugar,代码行数:46,代码来源:view.py

示例11: __init__

# 需要导入模块: from gi.repository import GdkX11 [as 别名]
# 或者: from gi.repository.GdkX11 import x11_get_default_xdisplay [as 别名]
	def __init__(self, cls="osd-menu"):
		self._buttons = None
		self._string = ""
		
		OSDWindow.__init__(self, cls)
		self.daemon = None
		self.config = None
		self.feedback = None
		self.controller = None
		self.xdisplay = X.Display(hash(GdkX11.x11_get_default_xdisplay()))	# Magic
		
		self.create_parent()
		self.create_app_list()
		self.create_buttons()
		
		cursor = os.path.join(get_share_path(), "images", 'menu-cursor.svg')
		self.cursors = [ Gtk.Image.new_from_file(cursor), Gtk.Image.new_from_file(cursor) ]
		for c in self.cursors:
			c.set_name("osd-menu-cursor")
			c.selected = None
			self.f.add(c)
		self.f.show_all()
		
		self._scon = StickController()
		self._scon.connect("direction", self.on_stick_direction)
		self._selected = None
		self._menuid = None
		self._eh_ids = []
		self._confirm_with = 'A'
		self._cancel_with = 'B'
		
		if Launcher._app_db is None:
			Launcher._app_db = []
			for x in Launcher.BUTTONS:
				for c in x:
					Launcher.CHAR_TO_NUMBER[c] = x[0]
			
			for x in Gio.AppInfo.get_all():
				try:
					Launcher._app_db.append(( Launcher.name_to_keys(x), x ))
				except UnicodeDecodeError:
					# Just fuck them...
					pass
开发者ID:kozec,项目名称:sc-controller,代码行数:45,代码来源:launcher.py

示例12: setup

# 需要导入模块: from gi.repository import GdkX11 [as 别名]
# 或者: from gi.repository.GdkX11 import x11_get_default_xdisplay [as 别名]
def setup():
    settings = Gio.Settings('org.sugarlabs.peripherals.keyboard')
    have_config = False

    try:
        display = GdkX11.x11_get_default_xdisplay()
        if display is not None:
            engine = Xkl.Engine.get_instance(display)
        else:
            logging.debug('setup_keyboard_cb: Could not get default display.')
            return

        configrec = Xkl.ConfigRec()
        configrec.get_from_server(engine)

        layouts = settings.get_strv('layouts')
        layouts_list = []
        variants_list = []
        if layouts:
            for layout in layouts:
                layouts_list.append(layout.split('(')[0])
                variants_list.append(layout.split('(')[1][:-1])

            if layouts_list and variants_list:
                have_config = True
                configrec.set_layouts(layouts_list)
                configrec.set_variants(variants_list)

        model = settings.get_string('model')
        if model:
            have_config = True
            configrec.set_model(model)

        options = settings.get_strv('options')
        if options:
            have_config = True
            configrec.set_options(options)

        if have_config:
            configrec.activate(engine)
    except Exception:
        logging.exception('Error during keyboard configuration')
开发者ID:AbrahmAB,项目名称:sugar-prototype,代码行数:44,代码来源:keyboard.py

示例13: __init__

# 需要导入模块: from gi.repository import GdkX11 [as 别名]
# 或者: from gi.repository.GdkX11 import x11_get_default_xdisplay [as 别名]
	def __init__(self, cls="osd-menu"):
		self._buttons = None
		self._text = None
		
		OSDWindow.__init__(self, cls)
		self.daemon = None
		self.config = None
		self.feedback = None
		self.controller = None
		self.xdisplay = X.Display(hash(GdkX11.x11_get_default_xdisplay()))	# Magic
		
		self.parent = self.create_parent()
		self.f = Gtk.Fixed()
		self.f.add(self.parent)
		self.add(self.f)
		
		self._scon = StickController()
		self._scon.connect("direction", self.on_stick_direction)
		self._selected = None
		self._eh_ids = []
开发者ID:kozec,项目名称:sc-controller,代码行数:22,代码来源:dialog.py

示例14: __init__

# 需要导入模块: from gi.repository import GdkX11 [as 别名]
# 或者: from gi.repository.GdkX11 import x11_get_default_xdisplay [as 别名]
	def __init__(self, config=None):
		self.kbimage = os.path.join(get_config_path(), 'keyboard.svg')
		if not os.path.exists(self.kbimage):
			# Prefer image in ~/.config/scc, but load default one as fallback
			self.kbimage = os.path.join(get_share_path(), "images", 'keyboard.svg')
		
		TimerManager.__init__(self)
		OSDWindow.__init__(self, "osd-keyboard")
		self.daemon = None
		self.mapper = None
		self.keymap = Gdk.Keymap.get_default()
		self.keymap.connect('state-changed', self.on_keymap_state_changed)
		Action.register_all(sys.modules['scc.osd.osk_actions'], prefix="OSK")
		self.profile = Profile(TalkingActionParser())
		self.config = config or Config()
		self.dpy = X.Display(hash(GdkX11.x11_get_default_xdisplay()))
		self.group = None
		self.limits = {}
		self.background = None
		
		cursor = os.path.join(get_share_path(), "images", 'menu-cursor.svg')
		self.cursors = {}
		self.cursors[LEFT] = Gtk.Image.new_from_file(cursor)
		self.cursors[LEFT].set_name("osd-keyboard-cursor")
		self.cursors[RIGHT] = Gtk.Image.new_from_file(cursor)
		self.cursors[RIGHT].set_name("osd-keyboard-cursor")
		self.cursors[CPAD] = Gtk.Image.new_from_file(cursor)
		self.cursors[CPAD].set_name("osd-keyboard-cursor")
		
		self._eh_ids = []
		self._controller = None
		self._stick = 0, 0
		self._hovers = { self.cursors[LEFT]: None, self.cursors[RIGHT]: None }
		self._pressed = { self.cursors[LEFT]: None, self.cursors[RIGHT]: None }
		self._pressed_areas = {}
		
		self.c = Gtk.Box()
		self.c.set_name("osd-keyboard-container")
		
		self.f = Gtk.Fixed()
开发者ID:kozec,项目名称:sc-controller,代码行数:42,代码来源:keyboard.py

示例15: __init__

# 需要导入模块: from gi.repository import GdkX11 [as 别名]
# 或者: from gi.repository.GdkX11 import x11_get_default_xdisplay [as 别名]
    def __init__(self, usermanager_loaded_cb=None, locale_selected_cb=None):
        self._usermanager_loaded_cb = usermanager_loaded_cb
        self._locale_selected_cb = locale_selected_cb

        self.__act_user = None
        self.__actusermanager_loadedid = None

        self._xkl_engine = Xkl.Engine.get_instance(GdkX11.x11_get_default_xdisplay())
        self._xkl_registry = Xkl.ConfigRegistry.get_instance(self._xkl_engine)
        self._xkl_registry.load(False)
        self._xkl_record = Xkl.ConfigRec()
        self._xkl_record.get_from_server(self._xkl_engine)

        self._system_locales_list = _langcodes
        self._system_locales_dict = self.__fill_locales_dict(self._system_locales_list)

        self._language = 'en'
        self._locale = 'en_US'
        self._layout = 'us'
        self._variant = ''

        actusermanager = AccountsService.UserManager.get_default()
        self.__actusermanager_loadedid = actusermanager.connect(
            "notify::is-loaded",  self.__on_usermanager_loaded)
开发者ID:bankonme,项目名称:tails-greeter,代码行数:26,代码来源:language.py


注:本文中的gi.repository.GdkX11.x11_get_default_xdisplay方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。