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


Python repository.GdkX11类代码示例

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


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

示例1: __fill_layouts_dict

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,代码行数:27,代码来源:language.py

示例2: update_labels

	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,代码行数:30,代码来源:keyboard.py

示例3: make_window_clicktrough

	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,代码行数:7,代码来源:__init__.py

示例4: button_press

    def button_press(self, terminal, event):
        """Handles the button press event in the terminal widget. If
        any match string is caught, another aplication is open to
        handle the matched resource uri.
        """
        self.matched_value = ''
        matched_string = self.match_check(
            int(event.x / self.get_char_width()),
            int(event.y / self.get_char_height()))
        value, tag = matched_string

        if event.button == 1 \
                and event.get_state() & Gdk.ModifierType.CONTROL_MASK \
                and value:
            if TERMINAL_MATCH_TAGS[tag] == 'schema':
                # value here should not be changed, it is right and
                # ready to be used.
                pass
            elif TERMINAL_MATCH_TAGS[tag] == 'http':
                value = 'http://%s' % value
            elif TERMINAL_MATCH_TAGS[tag] == 'email':
                value = 'mailto:%s' % value

            Gtk.show_uri(self.get_screen(), value,
                         GdkX11.x11_get_server_time(self.get_window()))
        elif event.button == 3 and matched_string:
            self.matched_value = matched_string[0]
开发者ID:lambdalisue,项目名称:guake,代码行数:27,代码来源:terminal3.py

示例5: getXTime

    def getXTime(self):
        try:
            time = GdkX11.x11_get_server_time(self.get_window())
        except:
            time = 0

        return time
开发者ID:Frenzie,项目名称:nimbler,代码行数:7,代码来源:nimbler.py

示例6: make_hole

	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,代码行数:26,代码来源:area.py

示例7: __init__

	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,代码行数:29,代码来源:menu.py

示例8: main

def main():
    #atom = Gdk.Atom.intern("CLIPBOARD", False)
    #clippy = Gtk.Clipboard.get(selection=atom)
    clippy = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
    result, targets = clippy.wait_for_targets()
    for target in targets:
        print target, GdkX11.x11_xatom_to_atom(target).name()
    print(targets)
开发者ID:godiard,项目名称:many-tests,代码行数:8,代码来源:atom_test.py

示例9: __map_event_cb

 def __map_event_cb(self, window, event):
     # have to make the desktop window active
     # since metacity doesn't make it on startup
     timestamp = event.get_time()
     x11_window = self.get_window()
     if not timestamp:
         timestamp = GdkX11.x11_get_server_time(x11_window)
     x11_window.focus(timestamp)
开发者ID:W3SS,项目名称:sugar,代码行数:8,代码来源:homewindow.py

示例10: get_server_time

def get_server_time(widget):
    try:
        return GdkX11.x11_get_server_time(widget.get_window())
    except (TypeError, AttributeError):
        # Issue: https://github.com/Guake/guake/issues/1071
        # Wayland does not seem to like `x11_get_server_time`.
        # Use local timestamp instead
        return get_local_timestamp()
开发者ID:meridius,项目名称:guake,代码行数:8,代码来源:utils.py

示例11: main

def main(argv):

    # No arg list, pass out help
    if len(argv) == 0:
        printHelp()
        sys.exit(2)

    buff = 20

    try:
        opts, args = getopt.getopt(argv,"hudlrb:v")
    except getopt.GetoptError as err:
        printHelp()
        sys.exit(2)

    direction = ""
    verbose = False

    for opt, arg in opts:
        if opt == "-h":
            printHelp()
            sys.exit()
        elif opt == "-u":
            direction = "UP"
        elif opt == "-d":
            direction = "DOWN"
        elif opt == "-l":
            direction = "LEFT"
        elif opt == "-r":
            direction = "RIGHT"
        elif opt == "-b":
            buff = int(arg)
        elif opt == "-v":
            verbose = True

    # Grab window list and geo
    Gtk.init([])  # necessary if not using a Gtk.main() loop
    screen = Wnck.Screen.get_default()
    screen.force_update()  # recommended per Wnck documentation

    window_list = screen.get_windows()
    active_window = screen.get_active_window()

    workspace_id = screen.get_active_workspace().get_number()

    if len(window_list) > 0:
        window = findWindow( direction, window_list, workspace_id, active_window, buff, verbose )
    else:
        print( "Empty window list!" )
        sys.exit(2)

    if window != None:
        now = GdkX11.x11_get_server_time(Gdk.get_default_root_window())
        window.activate(now)

    window = None
    screen = None
    Wnck.shutdown()
开发者ID:allora,项目名称:awmtools,代码行数:58,代码来源:taskswitcher_wnck.py

示例12: setup

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,代码行数:56,代码来源:keyboard.py

示例13: __init__

    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,代码行数:56,代码来源:keyboard.py

示例14: __init__

 def __init__(self):
     """
         Init dbus objects
     """
     # Just to make pep8/flake8 happy
     GdkX11.x11_get_default_root_xwindow()
     # Dbus interface to disable screenlock
     bus = dbus.SessionBus()
     self._sm = None
     self._cookie = None
     self._flags = []
     try:
         bus_object = bus.get_object('org.gnome.SessionManager',
                                     '/org/gnome/SessionManager')
         self._sm = dbus.Interface(bus_object,
                                   'org.gnome.SessionManager')
     except:
         self._sm = None
     Lp().player.connect('status-changed', self._on_status_changed)
开发者ID:Nikhil-z,项目名称:lollypop,代码行数:19,代码来源:inhibitor.py

示例15: move_mouse

    def move_mouse(self, window, hide_cursor):
        GdkX11.x11_grab_server()

        old_window = self.mouse_grab_window

        if old_window:
            self.release_mouse()

        res = self.grab_mouse(window, hide_cursor)
        if not res:
            time.sleep(1)
            res = self.grab_mouse(window, hide_cursor)

        if not res and old_window:
            self.grab_mouse(old_window)

        GdkX11.x11_ungrab_server()

        return res
开发者ID:Fantu,项目名称:cinnamon-screensaver,代码行数:19,代码来源:grabHelper.py


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