Пример #1
0
 def show(self, *a):
     OSDWindow.show(self, *a)
     self.profile.load(find_profile(".scc-osd.keyboard")).compress()
     self.mapper = SlaveMapper(self.profile, keyboard=b"SCC OSD Keyboard")
     self.mapper.set_special_actions_handler(self)
     self.set_cursor_position(0, 0, self.cursors[LEFT], self.limits[LEFT])
     self.set_cursor_position(0, 0, self.cursors[RIGHT], self.limits[RIGHT])
Пример #2
0
 def quit(self, code=-1):
     self.daemon.unlock_all()
     for x in self._eh_ids:
         self.daemon.disconnect(x)
     self._eh_ids = []
     del self.mapper
     OSDWindow.quit(self, code)
Пример #3
0
	def quit(self, code=-1):
		self.daemon.unlock_all()
		for x in self._eh_ids:
			self.daemon.disconnect(x)
		self._eh_ids = []
		del self.keyboard
		OSDWindow.quit(self, code)
Пример #4
0
    def __init__(self, cls="osd-menu"):
        OSDWindow.__init__(self, cls)
        self.daemon = None
        self.config = 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._confirm_with = 'A'
        self._cancel_with = 'B'
Пример #5
0
	def _add_arguments(self):
		OSDWindow._add_arguments(self)
		self.argparser.add_argument('image', type=str, nargs="?",
			default = self.bdisplay, help="keyboard image to use")
		self.argparser.add_argument('--cancel-with', type=str,
			metavar="button", default='B',
			help="button used to close display (default: B)")
Пример #6
0
	def __init__(self):
		OSDWindow.__init__(self, "osd-message")
		
		self.timeout = OSDAction.DEFAULT_TIMEOUT
		self.size = OSDAction.DEFAULT_SIZE
		self.text = "text"
		self._timeout_id = None
Пример #7
0
	def show(self, *a):
		OSDWindow.show(self, *a)
		self.profile.load(find_profile(".scc-osd.keyboard")).compress()
		self.mapper = SlaveMapper(self.profile, keyboard=b"SCC OSD Keyboard")
		self.mapper.set_special_actions_handler(self)
		self.set_cursor_position(0, 0, self.cursors[LEFT], self.limits[LEFT])
		self.set_cursor_position(0, 0, self.cursors[RIGHT], self.limits[RIGHT])
Пример #8
0
    def __init__(self):
        OSDWindow.__init__(self, "osd-message")

        self.timeout = OSDAction.DEFAULT_TIMEOUT
        self.size = OSDAction.DEFAULT_SIZE
        self.text = "text"
        self._timeout_id = None
Пример #9
0
	def _add_arguments(self):
		OSDWindow._add_arguments(self)
		self.argparser.add_argument('--control-with', '-c', type=str,
			metavar="option", default=STICK, choices=(LEFT, RIGHT, STICK),
			help="which pad or stick should be used to navigate menu (default: %s)" % (STICK,))
		self.argparser.add_argument('--confirm-with', type=str,
			metavar="button", default='A',
			help="button used to confirm choice (default: A)")
		self.argparser.add_argument('--cancel-with', type=str,
			metavar="button", default='B',
			help="button used to cancel menu (default: B)")
		self.argparser.add_argument('--confirm-with-release', action='store_true',
			help="confirm choice with button release instead of button press")
		self.argparser.add_argument('--cancel-with-release', action='store_true',
			help="cancel menu with button release instead of button press")
		self.argparser.add_argument('--use-cursor', '-u', action='store_true',
			help="display and use cursor")
		self.argparser.add_argument('--size', type=int,
			help="sets prefered width or height")
		self.argparser.add_argument('--feedback-amplitude', type=int,
			help="enables and sets power of feedback effect generated when active menu option is changed")
		self.argparser.add_argument('--from-profile', '-p', type=str,
			metavar="profile_file menu_name",
			help="load menu items from profile file")
		self.argparser.add_argument('--from-file', '-f', type=str,
			metavar="filename",
			help="load menu items from json file")
		self.argparser.add_argument('--print-items', action='store_true',
			help="prints menu items to stdout")
		self.argparser.add_argument('items', type=str, nargs='*', metavar='id title',
			help="Menu items")
Пример #10
0
	def quit(self, code=-2):
		if not self._is_submenu:
			self.daemon.unlock_all()
			for x in self._eh_ids:
				self.daemon.disconnect(x)
			self._eh_ids = []
		OSDWindow.quit(self, code)
Пример #11
0
	def quit(self, code=-2):
		if self.get_controller():
			self.get_controller().unlock_all()
		for source, eid in self._eh_ids:
			source.disconnect(eid)
		self._eh_ids = []
		OSDWindow.quit(self, code)
Пример #12
0
 def _add_arguments(self):
     OSDWindow._add_arguments(self)
     self.argparser.add_argument('--confirm-with',
                                 type=str,
                                 metavar="button",
                                 default=DEFAULT,
                                 help="button used to confirm choice")
     self.argparser.add_argument('--cancel-with',
                                 type=str,
                                 metavar="button",
                                 default=DEFAULT,
                                 help="button used to cancel dialog")
     self.argparser.add_argument(
         '--feedback-amplitude',
         type=int,
         help=
         "enables and sets power of feedback effect generated when active menu option is changed"
     )
     self.argparser.add_argument('--text',
                                 type=str,
                                 metavar='text',
                                 help="Dialog text")
     self.argparser.add_argument('items',
                                 type=str,
                                 nargs='*',
                                 metavar='id text',
                                 help="Dialog buttons")
Пример #13
0
	def show(self):
		OSDWindow.show(self)

		from ctypes import byref

		pb = self.b.get_pixbuf()
		win = X.XID(self.get_window().get_xid())
		
		pixmap = X.create_pixmap(self.xdisplay, win,
			pb.get_width(), pb.get_height(), 1)
		width = pb.get_width()
		height = pb.get_height()
		self.f.move(self.cursor, int(width / 2), int(height / 2))
		
		gc = X.create_gc(self.xdisplay, pixmap, 0, None)
		X.set_foreground(self.xdisplay, gc, 0)
		X.fill_rectangle(self.xdisplay, pixmap, gc, 0, 0, pb.get_width(), pb.get_height())
		X.set_foreground(self.xdisplay, gc, 1)
		X.set_background(self.xdisplay, gc, 1)
		
		r = int(pb.get_width() * 0.985)
		x = (pb.get_width() - r) / 2
		
		X.fill_arc(self.xdisplay, pixmap, gc,
			x, x, r, r, 0, 360*64)
		
		X.flush_gc(self.xdisplay, gc)
		X.flush(self.xdisplay)
		
		X.shape_combine_mask(self.xdisplay, win, X.SHAPE_BOUNDING, 0, 0, pixmap, X.SHAPE_SET)
		
		X.flush(self.xdisplay)
Пример #14
0
 def _add_arguments(self):
     OSDWindow._add_arguments(self)
     self.argparser.add_argument(
         '--cancel-with',
         type=str,
         metavar="button",
         default='START',
         help="button used to cancel menu (default: START)")
     self.argparser.add_argument(
         '--timeout',
         type=int,
         default=5,
         help="how many seconds before menu is automatically canceled")
     self.argparser.add_argument(
         '--cancel-with-release',
         action='store_true',
         help="cancel menu with button release instead of button press")
     self.argparser.add_argument('--from-profile',
                                 '-p',
                                 type=str,
                                 metavar="profile_file menu_name",
                                 help="load menu items from profile file")
     self.argparser.add_argument('--from-file',
                                 '-f',
                                 type=str,
                                 metavar="filename",
                                 help="load menu items from json file")
     self.argparser.add_argument('--print-items',
                                 action='store_true',
                                 help="prints menu items to stdout")
     self.argparser.add_argument('items',
                                 type=str,
                                 nargs='*',
                                 metavar='id title',
                                 help="Menu items")
Пример #15
0
    def show(self):
        self.main_area = Gtk.Fixed()
        self.background = SVGWidget(self,
                                    os.path.join(self.imagepath, self.IMAGE))
        self.lpadTest = Gtk.Image.new_from_file(
            os.path.join(self.imagepath, "inputdisplay-cursor.svg"))
        self.rpadTest = Gtk.Image.new_from_file(
            os.path.join(self.imagepath, "inputdisplay-cursor.svg"))
        self.stickTest = Gtk.Image.new_from_file(
            os.path.join(self.imagepath, "inputdisplay-cursor.svg"))

        self.main_area.set_property("margin-left", 10)
        self.main_area.set_property("margin-right", 10)
        self.main_area.set_property("margin-top", 10)
        self.main_area.set_property("margin-bottom", 10)

        self.main_area.put(self.background, 0, 0)
        self.main_area.put(self.lpadTest, 40, 40)
        self.main_area.put(self.rpadTest, 290, 90)
        self.main_area.put(self.stickTest, 150, 40)

        self.add(self.main_area)

        OSDWindow.show(self)
        self.lpadTest.hide()
        self.rpadTest.hide()
        self.stickTest.hide()
Пример #16
0
	def show(self):
		OSDWindow.show(self)

		from ctypes import byref

		pb = self.b.get_pixbuf()
		win = X.XID(self.get_window().get_xid())
		
		pixmap = X.create_pixmap(self.xdisplay, win,
			pb.get_width(), pb.get_height(), 1)
		width = pb.get_width()
		height = pb.get_height()
		self.f.move(self.cursor, int(width / 2), int(height / 2))
		
		gc = X.create_gc(self.xdisplay, pixmap, 0, None)
		X.set_foreground(self.xdisplay, gc, 0)
		X.fill_rectangle(self.xdisplay, pixmap, gc, 0, 0, pb.get_width(), pb.get_height())
		X.set_foreground(self.xdisplay, gc, 1)
		X.set_background(self.xdisplay, gc, 1)
		
		r = int(pb.get_width() * 0.985)
		x = (pb.get_width() - r) / 2
		
		X.fill_arc(self.xdisplay, pixmap, gc,
			x, x, r, r, 0, 360*64)
		
		X.flush_gc(self.xdisplay, gc)
		X.flush(self.xdisplay)
		
		X.shape_combine_mask(self.xdisplay, win, X.SHAPE_BOUNDING, 0, 0, pixmap, X.SHAPE_SET)
		
		X.flush(self.xdisplay)
Пример #17
0
 def quit(self, code=-2):
     if not self._is_submenu:
         self.daemon.unlock_all()
         for x in self._eh_ids:
             self.daemon.disconnect(x)
         self._eh_ids = []
     OSDWindow.quit(self, code)
Пример #18
0
	def _add_arguments(self):
		OSDWindow._add_arguments(self)
		self.argparser.add_argument('--control-with', '-c', type=str,
			metavar="option", default=DEFAULT, choices=(DEFAULT, LEFT, RIGHT, STICK),
			help="which pad or stick should be used to navigate menu")
		self.argparser.add_argument('--confirm-with', type=str,
			metavar="button", default=DEFAULT,
			help="button used to confirm choice")
		self.argparser.add_argument('--cancel-with', type=str,
			metavar="button", default=DEFAULT,
			help="button used to cancel menu")
		self.argparser.add_argument('--confirm-with-release', action='store_true',
			help="confirm choice with button release instead of button press")
		self.argparser.add_argument('--cancel-with-release', action='store_true',
			help="cancel menu with button release instead of button press")
		self.argparser.add_argument('--use-cursor', '-u', action='store_true',
			help="display and use cursor")
		self.argparser.add_argument('--size', type=int,
			help="sets prefered width or height")
		self.argparser.add_argument('--feedback-amplitude', type=int,
			help="enables and sets power of feedback effect generated when active menu option is changed")
		self.argparser.add_argument('--from-profile', '-p', type=str,
			metavar="profile_file menu_name",
			help="load menu items from profile file")
		self.argparser.add_argument('--from-file', '-f', type=str,
			metavar="filename",
			help="load menu items from json file")
		self.argparser.add_argument('--print-items', action='store_true',
			help="prints menu items to stdout")
		self.argparser.add_argument('items', type=str, nargs='*', metavar='id title',
			help="Menu items")
Пример #19
0
 def _add_arguments(self):
     OSDWindow._add_arguments(self)
     self.argparser.add_argument('image',
                                 type=str,
                                 nargs="?",
                                 default=self.kbimage,
                                 help="keyboard image to use")
Пример #20
0
	def _add_arguments(self):
		OSDWindow._add_arguments(self)
		self.argparser.add_argument('-t', type=float, metavar="seconds",
				default=5, help="time before message is hidden (default: 5; 0 means forever)")
		self.argparser.add_argument('-s', type=int, metavar="size",
				default=3, help="font size, in range 1 to 3 (default: 3)")
		self.argparser.add_argument('text', type=str, help="text to display")
Пример #21
0
 def quit(self, code=-1):
     if self.get_controller():
         self.get_controller().unlock_all()
     for source, eid in self._eh_ids:
         source.disconnect(eid)
     self._eh_ids = []
     OSDWindow.quit(self, code)
Пример #22
0
	def _add_arguments(self):
		OSDWindow._add_arguments(self)
		self.argparser.add_argument('--control-with', '-c', type=str,
			metavar="option", default=STICK, choices=(LEFT, RIGHT, STICK),
			help="which pad or stick should be used to navigate menu (default: %s)" % (STICK,))
		self.argparser.add_argument('--confirm-with', type=str,
			metavar="button", default='A',
			help="button used to confirm choice (default: A)")
		self.argparser.add_argument('--cancel-with', type=str,
			metavar="button", default='B',
			help="button used to cancel menu (default: B)")
		self.argparser.add_argument('--confirm-with-release', action='store_true',
			help="confirm choice with button release instead of button press")
		self.argparser.add_argument('--cancel-with-release', action='store_true',
			help="cancel menu with button release instead of button press")
		self.argparser.add_argument('--use-cursor', '-u', action='store_true',
			help="display and use cursor")
		self.argparser.add_argument('--from-profile', '-p', type=str,
			metavar="profile_file menu_name",
			help="load menu items from profile file")
		self.argparser.add_argument('--from-file', '-f', type=str,
			metavar="filename",
			help="load menu items from json file")
		self.argparser.add_argument('--print-items', action='store_true',
			help="prints menu items to stdout")
		self.argparser.add_argument('items', type=str, nargs='*', metavar='id title',
			help="Menu items")
Пример #23
0
	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'
Пример #24
0
    def __init__(self, imagepath="/usr/share/scc/images"):
        OSDWindow.__init__(self, "osd-menu")
        self.daemon = None
        self.config = None
        self.hilights = {self.HILIGHT_COLOR: set(), self.OBSERVE_COLOR: set()}
        self.imagepath = imagepath

        self._eh_ids = []
Пример #25
0
	def __init__(self, imagepath="/usr/share/scc/images"):
		OSDWindow.__init__(self, "osd-menu")
		self.daemon = None
		self.config = None
		self.hilights = { self.HILIGHT_COLOR : set(), self.OBSERVE_COLOR : set() }
		self.imagepath = imagepath
		
		self._eh_ids = []
Пример #26
0
	def show(self, *a):
		if self.background is None:
			self.realize()
			self.background = SVGWidget(self.args.image, init_hilighted=True)
			self.c.add(self.background)
			self.add(self.c)
		
		OSDWindow.show(self, *a)
		self.move(*self.compute_position())
Пример #27
0
	def __init__(self):
		self.exit_code = -1
		self.mainloop = GLib.MainLoop()
		self.config = None
		self._window = None
		self._registered = False
		self._last_profile_change = 0
		self._recent_profiles_undo = None
		OSDWindow._apply_css()
Пример #28
0
	def show(self):
		self.l = Gtk.Label()
		self.l.set_name("osd-label")
		self.l.set_label(self.text)
		
		self.add(self.l)
		
		OSDWindow.show(self)
		GLib.timeout_add_seconds(self.timeout, self.quit)
Пример #29
0
    def show(self):
        self.l = Gtk.Label()
        self.l.set_name("osd-label")
        self.l.set_label(self.text)

        self.add(self.l)

        OSDWindow.show(self)
        GLib.timeout_add_seconds(self.timeout, self.quit)
Пример #30
0
 def _add_arguments(self):
     OSDWindow._add_arguments(self)
     self.argparser.add_argument(
         '-t',
         type=float,
         metavar="seconds",
         default=5,
         help="time before message is hidden (default: 5)")
     self.argparser.add_argument('text', type=str, help="text to display")
Пример #31
0
 def __init__(self):
     self.exit_code = -1
     self.mainloop = GLib.MainLoop()
     self.config = None
     self._window = None
     self._registered = False
     self._last_profile_change = 0
     self._recent_profiles_undo = None
     OSDWindow._apply_css()
Пример #32
0
    def show(self, *a):
        if self.background is None:
            self.realize()
            self.background = SVGWidget(self.args.image, init_hilighted=True)
            self.c.add(self.background)
            self.add(self.c)

        OSDWindow.show(self, *a)
        self.move(*self.compute_position())
Пример #33
0
	def _add_arguments(self):
		OSDWindow._add_arguments(self)
		self.argparser.add_argument('--confirm-with', type=str,
			metavar="button", default=DEFAULT,
			help="button used to confirm choice")
		self.argparser.add_argument('--cancel-with', type=str,
			metavar="button", default=DEFAULT,
			help="button used to cancel dialog")
		self.argparser.add_argument('--feedback-amplitude', type=int,
			help="enables and sets power of feedback effect generated when active menu option is changed")
Пример #34
0
	def _add_arguments(self):
		OSDWindow._add_arguments(self)
		self.argparser.add_argument('--confirm-with', type=str,
			metavar="button", default='A',
			help="button used to confirm choice (default: A)")
		self.argparser.add_argument('--cancel-with', type=str,
			metavar="button", default='B',
			help="button used to cancel menu (default: B)")
		self.argparser.add_argument('--feedback-amplitude', type=int,
			help="enables and sets power of feedback effect generated when active menu option is changed")
Пример #35
0
    def __init__(self, config=None):
        OSDWindow.__init__(self, "osd-gesture")
        self.daemon = None
        self._left_detector = GestureDetector(0, self._on_gesture_finished)
        # self._right_detector = GestureDetector(0, self._on_gesture_finished)
        self._control_with = LEFT
        self._eh_ids = []
        self._gesture = None

        self.setup_widgets()
        self.use_config(config or Config())
Пример #36
0
	def __init__(self, config=None):
		OSDWindow.__init__(self, "osd-gesture")
		self.daemon = None
		self._left_detector  = GestureDetector(0, self._on_gesture_finished)
		# self._right_detector = GestureDetector(0, self._on_gesture_finished)
		self._control_with = LEFT
		self._eh_ids = []
		self._gesture = None
		
		self.setup_widgets()
		self.use_config(config or Config())
Пример #37
0
	def show(self, *a):
		if self.background is None:
			self._create_background()
		OSDWindow.show(self, *a)
		self.load_profile()
		self.mapper = SlaveMapper(self.profile, None,
			keyboard=b"SCC OSD Keyboard", mouse=b"SCC OSD Mouse")
		self.mapper.set_special_actions_handler(self)
		self.set_cursor_position(0, 0, self.cursors[LEFT], self.limits[LEFT])
		self.set_cursor_position(0, 0, self.cursors[RIGHT], self.limits[RIGHT])
		self.set_cursor_position(0, 0, self.cursors[CPAD], self.limits[CPAD])
		self.timer('labels', 0.1, self.update_labels)
Пример #38
0
	def show(self):
		self.l = Gtk.Label()
		self.l.set_name("osd-label-%s" % (self.size, ))
		self.l.set_label(self.text)
		
		self.add(self.l)
		
		if self.size < 2:
			self.set_name("osd-message-1")
		OSDWindow.show(self)
		if self.timeout > 0:
			self._timeout_id = GLib.timeout_add_seconds(self.timeout, self.quit)
Пример #39
0
 def _add_arguments(self):
     OSDWindow._add_arguments(self)
     self.argparser.add_argument(
         '--control-with',
         '-c',
         type=str,
         metavar="option",
         default=LEFT,
         choices=(LEFT, RIGHT),
         help=
         "which pad should be used to generate gesture menu (default: %s)" %
         (LEFT, ))
Пример #40
0
 def _add_arguments(self):
     OSDWindow._add_arguments(self)
     self.argparser.add_argument('--width',
                                 type=int,
                                 metavar="pixels",
                                 default=20,
                                 help="""area width in pixels""")
     self.argparser.add_argument('--height',
                                 type=int,
                                 metavar="pixels",
                                 default=-20,
                                 help="""area height in pixels""")
Пример #41
0
    def show(self):
        self.l = Gtk.Label()
        self.l.set_name("osd-label-%s" % (self.size, ))
        self.l.set_label(self.text)

        self.add(self.l)

        if self.size < 2:
            self.set_name("osd-message-1")
        OSDWindow.show(self)
        if self.timeout > 0:
            self._timeout_id = GLib.timeout_add_seconds(
                self.timeout, self.quit)
Пример #42
0
 def show(self, *a):
     if self.background is None:
         self._create_background()
     OSDWindow.show(self, *a)
     self.load_profile()
     self.mapper = SlaveMapper(self.profile,
                               None,
                               keyboard=b"SCC OSD Keyboard",
                               mouse=b"SCC OSD Mouse")
     self.mapper.set_special_actions_handler(self)
     self.set_cursor_position(0, 0, self.cursors[LEFT], self.limits[LEFT])
     self.set_cursor_position(0, 0, self.cursors[RIGHT], self.limits[RIGHT])
     self.set_cursor_position(0, 0, self.cursors[CPAD], self.limits[CPAD])
     self.timer('labels', 0.1, self.update_labels)
Пример #43
0
	def _check_colorconfig_change(self):
		"""
		Checks if OSD color configuration is changed and re-applies CSS
		if needed.
		"""
		h = sum([ hash(self.config['osd_colors'][x]) for x in self.config['osd_colors'] ])
		h += sum([ hash(self.config['osk_colors'][x]) for x in self.config['osk_colors'] ])
		if self._hash_of_colors != h:
			self._hash_of_colors = h
			OSDWindow._apply_css(self.config)
			if self._window and isinstance(self._window, Keyboard):
				self._window.recolor()
				self._window.update_labels()
				self._window.redraw_background()
Пример #44
0
	def _check_colorconfig_change(self):
		"""
		Checks if OSD color configuration is changed and re-applies CSS
		if needed.
		"""
		h = sum([ hash(self.config['osd_colors'][x]) for x in self.config['osd_colors'] ])
		h += sum([ hash(self.config['osk_colors'][x]) for x in self.config['osk_colors'] ])
		if self._hash_of_colors != h:
			self._hash_of_colors = h
			OSDWindow._apply_css(self.config)
			if self._window and isinstance(self._window, Keyboard):
				self._window.recolor()
				self._window.update_labels()
				self._window.redraw_background()
Пример #45
0
 def _add_arguments(self):
     OSDWindow._add_arguments(self)
     self.argparser.add_argument(
         '-t',
         type=float,
         metavar="seconds",
         default=5,
         help="time before message is hidden (default: 5; 0 means forever)")
     self.argparser.add_argument(
         '-s',
         type=int,
         metavar="size",
         default=3,
         help="font size, in range 1 to 3 (default: 3)")
     self.argparser.add_argument('text', type=str, help="text to display")
Пример #46
0
	def parse_argumets(self, argv):
		if not OSDWindow.parse_argumets(self, argv):
			return False
		self.text = self.args.text
		self.timeout = self.args.t
		self.size = self.args.s
		return True	
Пример #47
0
 def parse_argumets(self, argv):
     if not OSDWindow.parse_argumets(self, argv):
         return False
     self.text = self.args.text
     self.timeout = self.args.t
     self.size = self.args.s
     return True
Пример #48
0
	def parse_argumets(self, argv):
		if not OSDWindow.parse_argumets(self, argv):
			return False
		if not self.config:
			self.config = Config()
		
		try:
			self.items = MenuData.from_args(self.args.items)
			self._menuid = None
		except ValueError:
			print >>sys.stderr, '%s: error: invalid number of arguments' % (sys.argv[0])
			return False
		
		self._text.set_label(self.args.text)
		
		if self.args.feedback_amplitude:
			side = "LEFT"
			self.feedback = side, int(self.args.feedback_amplitude)
		
		# Create buttons that are displayed on screen
		items = self.items.generate(self)
		self.items = []
		for item in items:
			item.widget = self.generate_widget(item)
			if item.widget is not None:
				self.items.append(item)
		self.pack_items(self.parent, self.items)
		if len(self.items) == 0:
			print >>sys.stderr, '%s: error: no items in menu' % (sys.argv[0])
			return False
		
		return True
Пример #49
0
    def parse_argumets(self, argv):
        if not OSDWindow.parse_argumets(self, argv):
            return False
        if not self.config:
            self.config = Config()

        try:
            self.items = MenuData.from_args(self.args.items)
            self._menuid = None
        except ValueError:
            print >> sys.stderr, '%s: error: invalid number of arguments' % (
                sys.argv[0])
            return False

        self._text.set_label(self.args.text)

        if self.args.feedback_amplitude:
            side = "LEFT"
            self.feedback = side, int(self.args.feedback_amplitude)

        # Create buttons that are displayed on screen
        items = self.items.generate(self)
        self.items = []
        for item in items:
            item.widget = self.generate_widget(item)
            if item.widget is not None:
                self.items.append(item)
        self.pack_items(self.parent, self.items)
        if len(self.items) == 0:
            print >> sys.stderr, '%s: error: no items in menu' % (sys.argv[0])
            return False

        return True
Пример #50
0
    def parse_argumets(self, argv):
        if not OSDWindow.parse_argumets(self, argv):
            print "failed to parse args"
            return False
        if not self.parse_menu():
            print "failed to parse menu"
            return False
        if not self.config:
            self.config = Config()

        self._cancel_with = self.args.cancel_with
        self._timeout = self.args.timeout

        # Create buttons that are displayed on screen
        items = self.items.generate(self)
        self.items = []
        self._button_index = 0
        for item in items:
            item.widget = self.generate_widget(item)
            if item.widget is not None:
                self.items.append(item)
        self.pack_items(self.parent, self.items)
        if len(self.items) == 0:
            print >> sys.stderr, '%s: error: no items in menu' % (sys.argv[0])
            return False

        return True
Пример #51
0
	def parse_argumets(self, argv):
		if not OSDWindow.parse_argumets(self, argv):
			return False
		if not self.parse_menu():
			return False
		if not self.config:
			self.config = Config()
		
		# Parse simpler arguments
		self._size = self.args.size
		
		# Create buttons that are displayed on screen
		items = self.items.generate(self)
		self.items = []
		for item in items:
			item.widget = self.generate_widget(item)
			if item.widget is not None:
				self.items.append(item)
		self.pack_items(self.parent, self.items)
		if len(self.items) == 0:
			print >>sys.stderr, '%s: error: no items in menu' % (sys.argv[0])
			return False
		
		if self.args.print_items:
			max_id_len = max(*[ len(x.id) for x in self.items ])
			row_format ="{:>%s}:\t{}" % (max_id_len,)
			for item in self.items:
				print row_format.format(item.id, item.label)
		return True
Пример #52
0
	def parse_argumets(self, argv):
		if not OSDWindow.parse_argumets(self, argv):
			print "failed to parse args"
			return False
		if not self.parse_menu():
			print "failed to parse menu"
			return False
		if not self.config:
			self.config = Config()
		
		self._cancel_with = self.args.cancel_with
		self._timeout = self.args.timeout
		
		# Create buttons that are displayed on screen
		items = self.items.generate(self)
		self.items = []
		self._button_index = 0
		for item in items:
			item.widget = self.generate_widget(item)
			if item.widget is not None:
				self.items.append(item)
		self.pack_items(self.parent, self.items)
		if len(self.items) == 0:
			print >>sys.stderr, '%s: error: no items in menu' % (sys.argv[0])
			return False
		
		return True
Пример #53
0
    def parse_argumets(self, argv):
        if not OSDWindow.parse_argumets(self, argv):
            return False
        if not self.parse_menu():
            return False
        if not self.config:
            self.config = Config()

        # Parse simpler arguments
        self._size = self.args.size

        # Create buttons that are displayed on screen
        items = self.items.generate(self)
        self.items = []
        for item in items:
            item.widget = self.generate_widget(item)
            if item.widget is not None:
                self.items.append(item)
        self.pack_items(self.parent, self.items)
        if len(self.items) == 0:
            print >> sys.stderr, '%s: error: no items in menu' % (sys.argv[0])
            return False

        if self.args.print_items:
            max_id_len = max(*[len(x.id) for x in self.items])
            row_format = "{:>%s}:\t{}" % (max_id_len, )
            for item in self.items:
                print row_format.format(item.id, item.label)
        return True
Пример #54
0
	def parse_argumets(self, argv):
		if not OSDWindow.parse_argumets(self, argv):
			return False
		self.position = (self.position[0] - self.BORDER_WIDTH,
			self.position[1] - self.BORDER_WIDTH)
		self.size = (self.args.width + 2 * self.BORDER_WIDTH,
			self.args.height + 2 * self.BORDER_WIDTH)
		return True
Пример #55
0
	def __init__(self, config=None):
		self.bdisplay = os.path.join(get_config_path(), 'binding-display.svg')
		if not os.path.exists(self.bdisplay):
			# Prefer image in ~/.config/scc, but load default one as fallback
			self.bdisplay = os.path.join(get_share_path(), "images", 'binding-display.svg')
		
		OSDWindow.__init__(self, "osd-keyboard")
		self.daemon = None
		self.config = config or Config()
		self.group = None
		self.limits = {}
		self.background = None
		
		self._eh_ids = []
		self._stick = 0, 0
		
		self.c = Gtk.Box()
		self.c.set_name("osd-keyboard-container")
Пример #56
0
	def parse_argumets(self, argv):
		if not OSDWindow.parse_argumets(self, argv):
			return False
		if not self.config:
			self.config = Config()
		if self.args.from_profile:
			try:
				self._menuid = self.args.items[0]
				self.items = MenuData.from_profile(self.args.from_profile, self._menuid)
			except IOError:
				print >>sys.stderr, '%s: error: profile file not found' % (sys.argv[0])
				return False
			except ValueError:
				print >>sys.stderr, '%s: error: menu not found' % (sys.argv[0])
				return False
		elif self.args.from_file:
			#try:
			data = json.loads(open(self.args.from_file, "r").read())
			self._menuid = self.args.from_file
			self.items = MenuData.from_json_data(data)
			#except:
			#	print >>sys.stderr, '%s: error: failed to load menu file' % (sys.argv[0])
			#	return False
		else:
			try:
				self.items = MenuData.from_args(self.args.items)
				self._menuid = None
			except ValueError:
				print >>sys.stderr, '%s: error: invalid number of arguments' % (sys.argv[0])
				return False
		
		# Parse simpler arguments
		self._control_with = self.args.control_with
		self._confirm_with = self.args.confirm_with
		self._cancel_with = self.args.cancel_with
		
		print "_control_with", self._control_with
		
		if self.args.use_cursor:
			self.enable_cursor()
		
		# Create buttons that are displayed on screen
		self.items = self.items.generate(self)
		for item in self.items:
			item.widget = self.generate_widget(item)
		self.pack_items(self.parent, self.items)
		if len(self.items) == 0:
			print >>sys.stderr, '%s: error: no items in menu' % (sys.argv[0])
			return False
		
		if self.args.print_items:
			max_id_len = max(*[ len(x.id) for x in self.items ])
			row_format ="{:>%s}:\t{}" % (max_id_len,)
			for item in self.items:
				print row_format.format(item.id, item.label)
		return True
Пример #57
0
	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 f**k them...
					pass
Пример #58
0
	def __init__(self):
		OSDWindow.__init__(self, "osd-keyboard")
		TimerManager.__init__(self)
		self.daemon = None
		self.keyboard = None
		self.keymap = Gdk.Keymap.get_default()
		self.keymap.connect('state-changed', self.on_state_changed)
		
		
		kbimage = os.path.join(get_config_path(), 'keyboard.svg')
		if not os.path.exists(kbimage):
			# Prefer image in ~/.config/scc, but load default one as fallback
			kbimage = os.path.join(get_share_path(), "images", 'keyboard.svg')
		self.background = SVGWidget(self, kbimage)
		
		self.limit_left  = self.background.get_rect_area(self.background.get_element("LIMIT_LEFT"))
		self.limit_right = self.background.get_rect_area(self.background.get_element("LIMIT_RIGHT"))
		
		cursor = os.path.join(get_share_path(), "images", 'menu-cursor.svg')
		self.cursor_left = Gtk.Image.new_from_file(cursor)
		self.cursor_left.set_name("osd-keyboard-cursor")
		self.cursor_right = Gtk.Image.new_from_file(cursor)
		self.cursor_right.set_name("osd-keyboard-cursor")
		
		self._eh_ids = []
		self._stick = 0, 0
		self._hovers = { self.cursor_left : None, self.cursor_right : None }
		self._pressed = { self.cursor_left : None, self.cursor_right : None }
		
		self.c = Gtk.Box()
		self.c.set_name("osd-keyboard-container")
		
		self.f = Gtk.Fixed()
		self.f.add(self.background)
		self.f.add(self.cursor_left)
		self.f.add(self.cursor_right)
		self.c.add(self.f)
		self.add(self.c)
		
		self.set_cursor_position(0, 0, self.cursor_left, self.limit_left)
		self.set_cursor_position(0, 0, self.cursor_right, self.limit_right)
		
		self.timer('labels', 0.1, self.update_labels)
Пример #59
0
	def parse_argumets(self, argv):
		if not OSDWindow.parse_argumets(self, argv):
			return False
		if not self.config:
			self.use_config(Config())
		
		# Parse simpler arguments
		self._control_with = self.args.control_with
		
		return True