コード例 #1
0
ファイル: dispatcher.py プロジェクト: sinhote/Galicaster
    def add_new_signal(self, name, *args):
        parameters = ()
        for element in args:
            parameters = parameters + (GObject.TYPE_PYOBJECT,)

        if not self.is_signal(name):
            GObject.signal_new(name, self, GObject.SignalFlags.RUN_LAST, None, parameters)
コード例 #2
0
ファイル: notebook.py プロジェクト: Dziuperduperman/guake
    def __init__(self, *args, **kwargs):
        Gtk.Notebook.__init__(self, *args, **kwargs)
        self.last_terminal_focused = None

        self.set_name("notebook-teminals")
        self.set_tab_pos(Gtk.PositionType.BOTTOM)
        self.set_property("show-tabs", True)
        self.set_property("enable-popup", False)
        self.set_property("scrollable", True)
        self.set_property("show-border", False)
        self.set_property("visible", True)
        self.set_property("has-focus", True)
        self.set_property("can-focus", True)
        self.set_property("is-focus", True)
        self.set_property("expand", True)

        if GObject.signal_lookup('terminal-spawned', TerminalNotebook) == 0:
            GObject.signal_new('terminal-spawned', TerminalNotebook,
                               GObject.SIGNAL_RUN_LAST, GObject.TYPE_NONE,
                               (GObject.TYPE_PYOBJECT, GObject.TYPE_INT))
            GObject.signal_new('page-deleted', TerminalNotebook,
                               GObject.SIGNAL_RUN_LAST, GObject.TYPE_NONE, ())

        self.scroll_callback = NotebookScrollCallback(self)
        self.add_events(Gdk.EventMask.SCROLL_MASK)
        self.connect('scroll-event', self.scroll_callback.on_scroll)
        self.connect("button-press-event", self.on_button_press, None)

        self.new_page_button = Gtk.Button(image=Gtk.Image.new_from_icon_name(
            "tab-new", Gtk.IconSize.MENU),
                                          visible=True)
        self.new_page_button.connect("clicked", self.on_new_tab)
        self.set_action_widget(self.new_page_button, Gtk.PackType.END)
コード例 #3
0
 def __init__(
     self, window, notebook_parent, workspaces_enabled, terminal_spawned_cb, page_deleted_cb,
 ):
     GObject.Object.__init__(self)
     if not GObject.signal_lookup("notebook-created", self):
         GObject.signal_new(
             "notebook-created",
             self,
             GObject.SIGNAL_RUN_LAST,
             GObject.TYPE_NONE,
             (GObject.TYPE_PYOBJECT, GObject.TYPE_INT),
         )
     self.current_notebook = 0
     self.notebooks = {}
     self.window = window
     self.notebook_parent = notebook_parent
     self.terminal_spawned_cb = terminal_spawned_cb
     self.page_deleted_cb = page_deleted_cb
     if workspaces_enabled and gdk_is_x11_display(Gdk.Display.get_default()):
         # NOTE: Wnck didn't support non-X11 display backend, so we need to check if the display
         #       is X11 or not, if not, it will not able to enable workspace-specific-tab-sets
         #
         # TODO: Is there anyway to support this in non-X11 display backend?
         self.screen = Wnck.Screen.get_default()
         self.screen.connect("active-workspace-changed", self.__workspace_changed_cb)
コード例 #4
0
    def initialize(self):
        # Install "KB Updated" signal
        GObject.signal_new('kb-updated', KB4Basico,
                           GObject.SignalFlags.RUN_LAST, None, ())

        # Get KB4IT version
        self.log.debug("Basico is using %s" % KB4IT().get_version())

        # Clean KB4IT temporary folder
        shutil.rmtree(LPATH['TMP'])
        os.makedirs(LPATH['TMP'])
        self.log.debug("KB4IT temporary directory recreated")

        # Check settings / Initialize
        source_path = self.get_config_value('source_dir')
        if source_path is None:
            self.set_config_value('source_dir', LPATH['DOC_SOURCE'])

        target_path = self.get_config_value('target_dir')
        if target_path is None:
            self.set_config_value('target_dir', LPATH['DOC_TARGET'])

        force = self.get_config_value('force')
        if force is None:
            self.set_config_value('force', False)

        # Start listening to requests
        self.queue = queue.Queue()
        self.th = threading.Thread(name='update', target=self.update_kb)
        self.th.setDaemon(True)
        self.th.start()
        self.log.debug("KB Basico Manager started")
コード例 #5
0
ファイル: main_window.py プロジェクト: acmo0/meteo
    def __init__(self, application):
        self.layout_path = ""
        with open("/usr/local/lib/meteo/var.cfg", 'r') as f:
            self.layout_path = f.read().split('\n')[2].replace(" ", "")
        print(self.layout_path)
        self.last = 0
        self.application = application
        self.builder = Gtk.Builder()
        self.builder.add_from_file(self.layout_path + "main.glade")
        self.main_window = self.builder.get_object("main_window")
        self.logo = self.builder.get_object("logo")
        self.img_path = ""
        with open('/usr/local/lib/meteo/var.cfg', 'r') as f:
            self.img_path = f.read().split('\n')[3].replace(" ", "")
        self.logo.set_from_file(self.img_path + "logov2.png")
        self.main_window.set_default_icon_from_file(self.img_path +
                                                    "main_logo.png")
        self.year_layout = self.builder.get_object("year_layout")
        self.year_label = self.builder.get_object("year_label")
        self.menu1 = self.builder.get_object("menubar1")
        self.menu2 = self.builder.get_object("menubar2")
        self.year_layout.set_visible(True)
        self.builder.connect_signals(self)
        self.year_layout.set_visible(False)

        GObject.signal_new('on_reponse', self.main_window,
                           GObject.SIGNAL_RUN_LAST, GObject.TYPE_PYOBJECT,
                           (GObject.TYPE_PYOBJECT, ))
        self.main_window.connect('on_reponse', self.on_reponse)
        #GObject.signal_new('on_month_window_destroy', self.main_window, GObject.SIGNAL_RUN_LAST, GObject.TYPE_PYOBJECT, (GObject.TYPE_PYOBJECT,))
        #self.main_window.connect("on_month_window_destroy", self.on_month_window_destroy)
        self.main_window.set_application(self.application)
        self.main_window.set_title('Météo')
        self.main_window.maximize()
        self.main_window.show()
コード例 #6
0
ファイル: gdm3setup.py プロジェクト: jpfeiffer/gdm3setup
	def __init__(self,parent_window):
		Gtk.Button.__init__(self)
		self.autologin=False
		self.username=""
		self.timed=False
		self.time=30
		self.box=Gtk.HBox(False,0)
		self.add(self.box)
		self.label_state=Gtk.Label(_("Disabled"))
		self.label_state.set_no_show_all(True)
		self.label_state.show()
		self.box.pack_start(self.label_state,True,True,2)
		self.label_user=Gtk.Label("USER")
		self.label_user.set_no_show_all(True)
		self.box.pack_start(self.label_user,False,False,2)
		self.label_time=Gtk.Label("TIME")
		self.label_time.set_no_show_all(True)
		self.box.pack_end(self.label_time,False,False,2)
		self.Separator = Gtk.Separator.new(Gtk.Orientation.VERTICAL)
		self.Separator.set_no_show_all(True)
		self.box.pack_end(self.Separator,False,False,2)
		self.connect("clicked",self._clicked)
		self.window = AutoLoginWindow(parent_window)
		self.window.connect("changed",self._changed)

		GObject.signal_new("changed", AutologinButton, GObject.SIGNAL_RUN_FIRST,GObject.TYPE_NONE, ())
コード例 #7
0
ファイル: gdm3setup.py プロジェクト: jpfeiffer/gdm3setup
    def __init__(self, parent_window):
        Gtk.Button.__init__(self)
        self.autologin = False
        self.username = ""
        self.timed = False
        self.time = 30
        self.box = Gtk.HBox(False, 0)
        self.add(self.box)
        self.label_state = Gtk.Label(_("Disabled"))
        self.label_state.set_no_show_all(True)
        self.label_state.show()
        self.box.pack_start(self.label_state, True, True, 2)
        self.label_user = Gtk.Label("USER")
        self.label_user.set_no_show_all(True)
        self.box.pack_start(self.label_user, False, False, 2)
        self.label_time = Gtk.Label("TIME")
        self.label_time.set_no_show_all(True)
        self.box.pack_end(self.label_time, False, False, 2)
        self.Separator = Gtk.Separator.new(Gtk.Orientation.VERTICAL)
        self.Separator.set_no_show_all(True)
        self.box.pack_end(self.Separator, False, False, 2)
        self.connect("clicked", self._clicked)
        self.window = AutoLoginWindow(parent_window)
        self.window.connect("changed", self._changed)

        GObject.signal_new("changed", AutologinButton,
                           GObject.SIGNAL_RUN_FIRST, GObject.TYPE_NONE, ())
コード例 #8
0
ファイル: lotto.py プロジェクト: wglas85/lotto
 def __init__(self, lotto=None, tipps=None, file=None):
     
     self.file = file
     
     self.config = ConfigParser()
     self.config.read(os.path.expanduser("~/.local/share/lotto/preferences.ini"))
     if tipps == None:
         tipps = self.config.getint("tipps", "tipps")
     if lotto == None:
         self.lotto = Lotto([Tipp() for i in range(tipps)])  # @UnusedVariable
     else:
         self.lotto = lotto
         
     Gtk.Notebook.__init__(self)
     self.set_scrollable(True)
     
     GObject.type_register(LottoWidget)
     GObject.signal_new("reaload",LottoWidget,GObject.SIGNAL_RUN_FIRST,
                GObject.TYPE_NONE, [])
     
     self.tippwidgets = []
     for i in range(self.lotto.get_n_tipps()):
         self.tippwidgets.append(TippWidget(self.lotto.get_nth_tipp(i)))
         self.append_page(child=self.tippwidgets[i],tab_label=Gtk.Label(label="tipp %s"%(i+1)))
     self.set_buttons()
コード例 #9
0
    def add_new_signal(self, name, *args):
        parameters = ()
        for element in args:
            parameters = parameters + (GObject.TYPE_PYOBJECT,)

        if not self.is_signal(name):
            GObject.signal_new(name, self, GObject.SignalFlags.RUN_LAST, None, parameters)
コード例 #10
0
ファイル: notebook.py プロジェクト: 0x29a/guake
    def __init__(self, guake, *args, **kwargs):
        Gtk.Notebook.__init__(self, *args, **kwargs)
        self.guake = guake
        self.last_terminal_focused = None

        self.set_name("notebook-teminals")
        self.set_tab_pos(Gtk.PositionType.BOTTOM)
        self.set_property("show-tabs", True)
        self.set_property("enable-popup", False)
        self.set_property("scrollable", True)
        self.set_property("show-border", False)
        self.set_property("visible", True)
        self.set_property("has-focus", True)
        self.set_property("can-focus", True)
        self.set_property("is-focus", True)
        self.set_property("expand", True)

        GObject.signal_new('terminal-spawned', self, GObject.SIGNAL_RUN_LAST,
                           GObject.TYPE_NONE,
                           (GObject.TYPE_PYOBJECT, GObject.TYPE_INT))
        GObject.signal_new('page-deleted', self, GObject.SIGNAL_RUN_LAST,
                           GObject.TYPE_NONE, ())

        self.scroll_callback = NotebookScrollCallback(self)
        self.add_events(Gdk.EventMask.SCROLL_MASK)
        self.connect('scroll-event', self.scroll_callback.on_scroll)
コード例 #11
0
    def __init__(self, lotto=None, tipps=None, file=None):

        self.file = file

        self.config = ConfigParser()
        self.config.read(
            os.path.expanduser("~/.local/share/lotto/preferences.ini"))
        if tipps == None:
            tipps = self.config.getint("tipps", "tipps")
        if lotto == None:
            self.lotto = Lotto([Tipp()
                                for i in range(tipps)])  # @UnusedVariable
        else:
            self.lotto = lotto

        Gtk.Notebook.__init__(self)
        self.set_scrollable(True)

        GObject.type_register(LottoWidget)
        GObject.signal_new("reaload", LottoWidget, GObject.SIGNAL_RUN_FIRST,
                           GObject.TYPE_NONE, [])

        self.tippwidgets = []
        for i in range(self.lotto.get_n_tipps()):
            self.tippwidgets.append(TippWidget(self.lotto.get_nth_tipp(i)))
            self.append_page(child=self.tippwidgets[i],
                             tab_label=Gtk.Label(label="tipp %s" % (i + 1)))
        self.set_buttons()
コード例 #12
0
    def __init__(self):
        super(BookmarkUtils, self).__init__()
        GObject.signal_new("bookmark_clicked", BookmarkUtils, GObject.SIGNAL_RUN_LAST, GObject.TYPE_NONE, (object,))

        self.menu1 = Gtk.Menu()
        self.menu2 = Gtk.Menu()
        self.menubar = None
コード例 #13
0
    def __init__(self):
        super().__init__()

        self._icon_contexts = []
        self._icon_size = 32
        self._filter_term = ""
        self._use_regex = False
        self._selected_icon = None

        # Register a custom icon_selected signal for once dialog closes.
        GObject.type_register(IconChooserButton)
        GObject.signal_new("icon-selected", IconChooserButton,
                           GObject.SIGNAL_RUN_FIRST, GObject.TYPE_NONE,
                           [GObject.TYPE_STRING])

        # Widgets go here
        self._icon = Gtk.Image.new_from_icon_name("gtk-search",
                                                  Gtk.IconSize.MENU)
        self._icon.set_margin_left(2)

        open_icon = Gtk.Image.new_from_icon_name("document-open-symbolic",
                                                 Gtk.IconSize.MENU)
        self._label = Gtk.Label("(Choose An Icon)")
        self._label.set_hexpand(True)
        self._label.set_halign(Gtk.Align.START)
        self._label.set_ellipsize(Pango.EllipsizeMode.END)

        box = Gtk.Box()
        box.set_spacing(4)
        box.pack_start(self._icon, False, False, 0)
        box.pack_start(self._label, False, True, 0)
        box.pack_start(open_icon, False, False, 2)

        self.add(box)
        self.connect("clicked", self._show_dialog)
コード例 #14
0
  def __init__(self):
      
      super(UPnPDeviceManager, self).__init__()
      GObject.threads_init()

      GObject.signal_new("device-available", UPnPDeviceManager, 
                         GObject.SIGNAL_RUN_LAST, 
                         GObject.TYPE_BOOLEAN, (GObject.TYPE_PYOBJECT,))

      GObject.signal_new("device-unavailable", UPnPDeviceManager, 
                         GObject.SIGNAL_RUN_LAST, 
                         GObject.TYPE_BOOLEAN, (GObject.TYPE_PYOBJECT,))

      atexit.register(self.cleanup_files)

      self.contexts = []
      self.cps = []
      self.devices = []
      self.sources = []
      self.renderers = []
      self.device_services = {}
      self.introspections = {}
      self.created_files = []

      # Get a default maincontext
      self.main_ctx = GLib.main_context_default() 
        
      # Use the built in GUPnP Network Manager to listen on 
      # all interfaces
      self.ctx_mgr = GUPnP.ContextManager.new(self.main_ctx, 0)
      self.ctx_mgr.connect("context_available", self.new_ctx)

      self.new_ctx(self.ctx_mgr, GUPnP.Context(interface="eth0"))
コード例 #15
0
    def __init__(self, parent, englabel=None, userdict={}, 
                    timeout=10):
        """
        The PTK engine class for embedding in gtk3 (pyGObject) applications. 
        To use create an instance of this or a subclass. 
        It uses the parent object for signals. 
        engine.disconnect() should also be called before the application exits.
        
        Important. 
        It uses the a the gtk mainloop to post/bind events and starts a 
        communications thread, therefore gtk.gdk.threads_init() must be called 
        before the main loop is started!

            GObject.threads_init() 
            Gtk.main()

        Signals to use:
        'engine_disconnect' -  sent went the engine disconnects.

        Methods/attributes you might want to overload:
        _get_welcome()  - Returns a string welcome message.
        self.eng_prompts - these are the prompts used by the controlling console.
        """
        self.parent = parent
        
        #add the engine disconnect signal
        if GObject.signal_lookup("engine_disconnect", self.parent) == 0:
            GObject.signal_new("engine_disconnect", self.parent, 
                               GObject.SIGNAL_RUN_FIRST, GObject.TYPE_NONE,())
        Engine.__init__(self, englabel, userdict, timeout)
コード例 #16
0
    def addConfigOption(
        cls,
        attrname,
        type_=None,
        section=None,
        key=None,
        environment=None,
        default=None,
        notify=False,
    ):
        """Adds a configuration option.

        This function should be called during module initialization, before
        the config file is actually read. By default, only options registered
        beforehand will be loaded.

        If you want to add configuration options after initialization,
        use the `readSettingSectionFromFile` method to force reading later on.

        Args:
            attrname (str): The attribute of this class for accessing the option.
            type_ (Optional[type]): The type of the attribute. Unnecessary if a
                `default` value is specified.
            section (Optional[str]): The section of the config file under which
                this option is saved. This section must have been added with
                addConfigSection(). Not necessary if `key` is not given.
            key (Optional[str]): The key under which this option is to be saved.
                By default the option will not be saved.
            notify (Optional[bool]): Whether this attribute should emit
                signals when modified. By default signals are not emitted.
        """
        if section and section not in cls.options:
            raise ConfigError("You must add the section `%s` first" % section)
        if key and not section:
            raise ConfigError("You must specify a section for key `%s`" % key)
        if section and key in cls.options[section]:
            raise ConfigError("Key `%s` is already in use" % key)
        if hasattr(cls, attrname):
            raise ConfigError("Attribute `%s` is already in use" % attrname)
        if environment and environment in cls.environment:
            raise ConfigError("Env var `%s` is already in use" % environment)
        if not type_ and default is None:
            raise ConfigError("Attribute `%s` must have a type or a default" %
                              attrname)
        if not type_:
            type_ = type(default)
        if notify:
            notification = Notification(attrname)
            setattr(cls, attrname, notification)
            setattr(cls, "_" + attrname, default)
            if notification.signame not in GObject.signal_list_names(cls):
                GObject.signal_new(notification.signame, cls,
                                   GObject.SignalFlags.RUN_LAST, None, ())
        else:
            setattr(cls, attrname, default)
        if section and key:
            cls.options[section][attrname] = type_, key, environment
        cls.environment.add(environment)
        cls.defaults[attrname] = default
コード例 #17
0
ファイル: settings.py プロジェクト: brion/pitivi
    def addConfigOption(cls, attrname, type_=None, section=None, key=None,
                        environment=None, default=None, notify=False,):
        """
        Add a configuration option.

        This function should be called during module initialization, before
        the config file is actually read. By default, only options registered
        beforehand will be loaded.
        See mainwindow.py and medialibrary.py for examples of usage.

        If you want to add configuration options after initialization,
        use the readSettingSectionFromFile method to force reading later on.
        See tabsmanager.py for an example of such a scenario.

        @param attrname: the attribute of this class which represents the option
        @type attrname: C{str}
        @param type_: type of the attribute. Unnecessary if default is given.
        @type type_: a builtin or class
        @param section: The section of the config file under which this option is
        saved. This section must have been added with addConfigSection(). Not
        necessary if key is not given.
        @param key: the key under which this option is to be saved. Can be none if
        this option should not be saved.
        @type key: C{str}
        @param notify: whether or not this attribute should emit notification
        signals when modified (default is False).
        @type notify: C{boolean}
        """
        if section and section not in cls.options:
            raise ConfigError("You must add the section \"%s\" first." % section)
        if key and not section:
            raise ConfigError("You must specify a section for key \"%s\"" % key)
        if section and key in cls.options[section]:
            raise ConfigError("Option \"%s\" is already in use.")
        if hasattr(cls, attrname):
            raise ConfigError("Settings attribute \"%s\" is already in use.")
        if environment and environment in cls.environment:
            raise ConfigError("Settings environment varaible \"%s\" is"
                "already in use.")
        if not type_ and default is None:
            raise ConfigError("Settings attribute \"%s\" has must have a"
                " type or a default." % attrname)
        if not type_:
            type_ = type(default)
        if notify:
            notification = Notification(attrname)
            setattr(cls, attrname, notification)
            setattr(cls, "_" + attrname, default)
            GObject.signal_new(notification.signame,
                               cls,
                               GObject.SIGNAL_RUN_LAST,
                               None,
                               ())
        else:
            setattr(cls, attrname, default)
        if section and key:
            cls.options[section][attrname] = type_, key, environment
        cls.environment.add(environment)
        cls.defaults[attrname] = default
コード例 #18
0
ファイル: callbacks.py プロジェクト: t00m/Basico
 def initialize(self):
     # Be aware about when the whole gui is started
     GObject.signal_new('gui-started', Callback,
                        GObject.SignalFlags.RUN_LAST, None, ())
     self.connect('gui-started', self.gui_started)
     self.th = threading.Thread(name='startup', target=self.on_startup)
     self.th.setDaemon(True)
     self.th.start()
コード例 #19
0
 def initialize(self):
     '''
     Setup AppLogic Service
     '''
     GObject.signal_new('sap-download-complete', SAP,
                        GObject.SignalFlags.RUN_LAST, None, ())
     self.__fix_collections()
     self.connect_signals()
コード例 #20
0
ファイル: settings.py プロジェクト: dz0ny/pitivi
    def addConfigOption(cls, attrname, type_=None, section=None, key=None,
                        environment=None, default=None, notify=False,):
        """Adds a configuration option.

        This function should be called during module initialization, before
        the config file is actually read. By default, only options registered
        beforehand will be loaded.

        If you want to add configuration options after initialization,
        use the `readSettingSectionFromFile` method to force reading later on.

        Args:
            attrname (str): The attribute of this class for accessing the option.
            type_ (Optional[type]): The type of the attribute. Unnecessary if a
                `default` value is specified.
            section (Optional[str]): The section of the config file under which
                this option is saved. This section must have been added with
                addConfigSection(). Not necessary if `key` is not given.
            key (Optional[str]): The key under which this option is to be saved.
                By default the option will not be saved.
            notify (Optional[bool]): Whether this attribute should emit
                signals when modified. By default signals are not emitted.
        """
        if section and section not in cls.options:
            raise ConfigError(
                "You must add the section \"%s\" first." % section)
        if key and not section:
            raise ConfigError(
                "You must specify a section for key \"%s\"" % key)
        if section and key in cls.options[section]:
            raise ConfigError("Option \"%s\" is already in use.")
        if hasattr(cls, attrname):
            raise ConfigError("Settings attribute \"%s\" is already in use.")
        if environment and environment in cls.environment:
            raise ConfigError("Settings environment varaible \"%s\" is"
                              "already in use.")
        if not type_ and default is None:
            raise ConfigError("Settings attribute \"%s\" has must have a"
                              " type or a default." % attrname)
        if not type_:
            type_ = type(default)
        if notify:
            notification = Notification(attrname)
            setattr(cls, attrname, notification)
            setattr(cls, "_" + attrname, default)
            GObject.signal_new(notification.signame,
                               cls,
                               GObject.SIGNAL_RUN_LAST,
                               None,
                               ())
        else:
            setattr(cls, attrname, default)
        if section and key:
            cls.options[section][attrname] = type_, key, environment
        cls.environment.add(environment)
        cls.defaults[attrname] = default
コード例 #21
0
 def __init__(self, *args, **kwargs):
     Gtk.ImageMenuItem.__init__(self, *args, **kwargs)
     GObject.signal_new(
         'value-changed',
         self,
         GObject.SignalFlags.RUN_LAST,
         GObject.TYPE_PYOBJECT,
         (GObject.TYPE_PYOBJECT, ),
     )
     self.attach_slider()
コード例 #22
0
def registerSignals(cls):
	GObject.type_register(cls)
	for name, args in cls.signals:
		GObject.signal_new(
			name,
			cls,
			GObject.SignalFlags.RUN_LAST,
			None,
			args,
		)
	return cls
コード例 #23
0
ファイル: app_gtk3.py プロジェクト: mishurov/applets
 def __init__(self, name, *args, **kwargs):
     self.name = name
     if not self.__class__.signals_created:
         GObject.signal_new('value-changed', self,
                            GObject.SignalFlags.RUN_LAST, GObject.TYPE_NONE,
                            ())
         GObject.signal_new('change-finished', self,
                            GObject.SignalFlags.RUN_LAST, GObject.TYPE_NONE,
                            ())
         self.__class__.signals_created = True
     return super().__init__(*args, **kwargs)
コード例 #24
0
ファイル: volume_tray.py プロジェクト: mishurov/applets
 def __init__(self, *args, **kwargs):
     Gtk.ImageMenuItem.__init__(self, *args, **kwargs)
     GObject.signal_new(
         'value-changed',
         self,
         GObject.SIGNAL_RUN_LAST,
         GObject.TYPE_PYOBJECT,
         (
             GObject.TYPE_PYOBJECT,
         ),
     )
     self.attach_slider()
コード例 #25
0
    def _init_signals(self):
        GObject.signal_new('branch', self._window,
                           GObject.SignalFlags.RUN_FIRST, None,
                           (GObject.TYPE_PYOBJECT, ))

        GObject.signal_new('leaf', self._window, GObject.SignalFlags.RUN_FIRST,
                           None, (GObject.TYPE_PYOBJECT, ))

        self._window.connect('key-press-event', self._on_key_press)
        self._window.connect('branch', self._open_branch)
        self._window.connect('leaf', self._exec_leaf)
        self._window.connect('destroy', Gtk.main_quit)
コード例 #26
0
    def __init__(self):
        self.window = Gtk.Window()

        GObject.signal_new('custom-signal', self.window, GObject.SIGNAL_RUN_LAST, GObject.TYPE_PYOBJECT, (GObject.TYPE_PYOBJECT,))

        self.window.connect('custom-signal', self.custom_signal1_method)

        self.window.emit('custom-signal', 'hello from signal')

        self.window.connect('delete_event', Gtk.main_quit)
        
        self.window.connect('destroy', lambda quit: Gtk.main_quit())

        self.window.show()
コード例 #27
0
ファイル: view.py プロジェクト: TheLokin/Gestor-de-Tareas
 def __init__(self):
     self.window = Gtk.Window()
     self.window.set_title(_('Records of events'))
     self.window.set_position(Gtk.WindowPosition.CENTER)
     box = Gtk.Box()
     self.window.add(box)
     self.notebook = Gtk.Notebook()
     self.notebook.set_scrollable(True)
     self.window.set_focus(self.notebook)
     # List events
     self.list_events = PageListEventsView()
     self.notebook.append_page(self.list_events, Gtk.Label(_('List events')))
     box.pack_start(self.notebook, True, True, 0)
     # Calendar
     self.calendar = PageCalendarView()
     self.notebook.append_page(self.calendar, Gtk.Label(_('Calendar')))
     # Monthly summary
     self.monthly_summary = PageMonthlySummaryView()
     self.notebook.append_page(self.monthly_summary, Gtk.Label(_('Monthly summary')))
     # New event
     self.new_event = NewEventView()
     box.pack_start(self.new_event, True, True, 0)
     # Signals
     GObject.signal_new('try-insert', GObject.Object, GObject.SIGNAL_RUN_FIRST,
                        GObject.TYPE_NONE, (GObject.TYPE_INT,))
     GObject.signal_new('remove-event', GObject.Object, GObject.SIGNAL_RUN_FIRST,
                        GObject.TYPE_NONE, (GObject.TYPE_INT,))
     GObject.signal_new('update-event', GObject.Object, GObject.SIGNAL_RUN_FIRST,
                        GObject.TYPE_NONE, (GObject.TYPE_INT,))
     GObject.signal_new('reload-list', GObject.Object, GObject.SIGNAL_RUN_FIRST,
                        GObject.TYPE_NONE, ())
     self.window.show_all()
コード例 #28
0
ファイル: notebook.py プロジェクト: Dziuperduperman/guake
 def __init__(self, window, notebook_parent, workspaces_enabled,
              terminal_spawned_cb, page_deleted_cb):
     GObject.Object.__init__(self)
     GObject.signal_new('notebook-created', self, GObject.SIGNAL_RUN_LAST,
                        GObject.TYPE_NONE,
                        (GObject.TYPE_PYOBJECT, GObject.TYPE_INT))
     self.current_notebook = 0
     self.notebooks = {}
     self.window = window
     self.notebook_parent = notebook_parent
     self.terminal_spawned_cb = terminal_spawned_cb
     self.page_deleted_cb = page_deleted_cb
     self.screen = Wnck.Screen.get_default()
     if workspaces_enabled:
         self.screen.connect("active-workspace-changed",
                             self.workspace_changed)
コード例 #29
0
def registerSignals(cls):
    GObject.type_register(cls)
    for name, args in cls.signals:
        try:
            GObject.signal_new(
                name,
                cls,
                GObject.SignalFlags.RUN_LAST,
                None,
                args,
            )
        except Exception as e:
            log.error(
                "Failed to create signal %s " % name + "for class %s in %s" %
                (cls.__name__, cls.__module__), )
    return cls
コード例 #30
0
class MainWindow(Gtk.Window):

    GObject.signal_new("interfaceListMsg", GObject.GObject,
                       GObject.SIGNAL_RUN_FIRST, GObject.TYPE_NONE, ())

    def __init__(self, setting):
        Gtk.Window.__init__(self, title='Create AP')
        self.setting = setting
        self._ = self.setting['language'].gettext
        self.initWindow()

        self.setting['runningAp'].registerPage(self.updateStatusPage)
        self.set_default_icon_from_file(self.setting['iconPath'])

    def show(self, page=None):
        self.show_all()
        self.updateStatusPage()
        if page != None:
            Gtk.Notebook.do_change_current_page(
                self.notebook, page - self.notebook.get_current_page())

    def initWindow(self):
        self.connect("destroy", self.on_destroy)
        self.set_border_width(3)
        self.notebook = Gtk.Notebook()
        self.add(self.notebook)

        self.statusPage = StatusPage(self, self.setting)
        self.notebook.append_page(self.statusPage,
                                  Gtk.Label(self._('Running AP')))

        self.editPage = EditPage(self, self.setting)
        self.notebook.append_page(self.editPage, Gtk.Label(self._('New AP')))

        self.createPage = CreatePage(self, self.setting)
        self.notebook.append_page(self.createPage,
                                  Gtk.Label(self._('Create AP')))

        self.settingPage = SettingPage(self, self.setting)
        self.notebook.append_page(self.settingPage,
                                  Gtk.Label(self._('Setting')))

        self.aboutPage = AboutPage(self, self.setting)
        self.notebook.append_page(self.aboutPage, Gtk.Label(self._('About')))

    def updateStatusPage(self, signal=None):
        self.statusPage.updateStatusPage()

    def on_destroy(self, widget):
        self.setting['runningAp'].unregisterPage()
        self.setting['createEditAp'] = None
        self.destroy()

    def changeCurrentPage(self, page):
        Gtk.Notebook.do_change_current_page(self.notebook, page)

    def showFirstPage(self):
        Gtk.Notebook.do_change_current_page(self.notebook,
                                            -self.notebook.get_current_page())
コード例 #31
0
 def register_signals(self, widget):
     """Register gobject signals in a way that avoids multiple inheritance"""
     existing = GObject.signal_list_names(widget)
     for signal in self.signals:
         if signal['name'] in existing:
             dbg('Container:: skipping signal %s for %s, already exists' %
                 (signal['name'], widget))
         else:
             dbg('Container:: registering signal for %s on %s' %
                 (signal['name'], widget))
             try:
                 GObject.signal_new(signal['name'], widget, signal['flags'],
                                    signal['return_type'],
                                    signal['param_types'])
             except RuntimeError:
                 err('Container:: registering signal for %s on %s failed' %
                     (signal['name'], widget))
コード例 #32
0
ファイル: notebook.py プロジェクト: Stibbons/guake
 def __init__(
     self, window, notebook_parent, workspaces_enabled, terminal_spawned_cb, page_deleted_cb
 ):
     GObject.Object.__init__(self)
     GObject.signal_new(
         'notebook-created', self, GObject.SIGNAL_RUN_LAST, GObject.TYPE_NONE,
         (GObject.TYPE_PYOBJECT, GObject.TYPE_INT)
     )
     self.current_notebook = 0
     self.notebooks = {}
     self.window = window
     self.notebook_parent = notebook_parent
     self.terminal_spawned_cb = terminal_spawned_cb
     self.page_deleted_cb = page_deleted_cb
     self.screen = Wnck.Screen.get_default()
     if workspaces_enabled:
         self.screen.connect("active-workspace-changed", self.workspace_changed)
コード例 #33
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        GObject.signal_new("print-this", GObject.TYPE_OBJECT,
                           GObject.SIGNAL_RUN_LAST, GObject.TYPE_BOOLEAN,
                           [GObject.TYPE_STRING])

        self.button = Gtk.Button.new_with_label("Emit signals")
        self.button.connect("clicked", self.emit_signals)

        self.frame = Gtk.Frame.new("Some frame")
        self.frame.add(self.button)
        self.add(self.frame)

        self.connect("print-this", self.got_it)
        self.show_all()
        Gtk.main()
コード例 #34
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        # Add custom signals to detect new word selected
        # GObject.signal_new(signal_name, type, flags, return_type, param_types)
        # param_types is a list example [GObject.TYPE_PYOBJECT, GObject.TYPE_STRING]
        GObject.signal_new("on-new-word-selected", Gtk.ApplicationWindow,
                           GObject.SIGNAL_RUN_LAST, GObject.TYPE_BOOLEAN,
                           [GObject.TYPE_PYOBJECT])
        self.connect("on-new-word-selected", self.on_new_word_selected)

        self.app = self.props.application
        self.lookup_word = self.app.lookup_word

        self.updater_view = UpdaterView()
        self.noword_view = NoWordView()
        self.word_view = WordView()
        self.settings_view = SettingsView(app=self.app)

        self.stack = Gtk.Stack()
        self.stack.props.transition_type = Gtk.StackTransitionType.CROSSFADE
        self.stack.add_named(self.word_view, self.word_view.get_name())
        self.stack.add_named(self.settings_view, self.settings_view.get_name())
        self.stack.add_named(self.noword_view, self.noword_view.get_name())
        self.stack.add_named(self.updater_view, self.updater_view.get_name())

        self.headerbar = self.generate_headerbar()

        # self.props.resizable = False #set this and window will expand and retract based on child
        self.title = "QuickWord"
        self.set_keep_above(True)
        self.get_style_context().add_class("rounded")
        self.set_size_request(
            -1, -1)  #set width to -1 to expand and retract based on content
        self.props.window_position = Gtk.WindowPosition.MOUSE
        self.set_titlebar(self.headerbar)
        self.add(self.stack)

        self.connect("key-press-event", self.on_key_press)

        self.show_all()
        self.on_start_settings()
        # hide all other views to enable window to expand and retract based on content
        self.noword_view.hide()
        self.settings_view.hide()
        self.updater_view.hide()
コード例 #35
0
    def __init__(self, window_parent):

        super().__init__()

        GObject.signal_new('colorlist-changed', self, GObject.SIGNAL_RUN_LAST,
                           GObject.TYPE_NONE, ())

        self.__window_parent = window_parent
        self.__color_selector = Gtk.ColorSelectionDialog(
            "Select a color", window_parent)
        self.__current_colortoolitem = None

        add_button = Gtk.ToolButton.new_from_stock(Gtk.STOCK_ADD)
        add_button.connect("clicked", self.__on_add_button_clicked)
        add_button.set_label(None)
        self.insert(add_button, 0)

        self.reset_colors()
コード例 #36
0
ファイル: container.py プロジェクト: albfan/terminator
 def register_signals(self, widget):
     """Register gobject signals in a way that avoids multiple inheritance"""
     existing = GObject.signal_list_names(widget)
     for signal in self.signals:
         if signal['name'] in existing:
             dbg('Container:: skipping signal %s for %s, already exists' % (
                     signal['name'], widget))
         else:
             dbg('Container:: registering signal for %s on %s' % 
                     (signal['name'], widget))
             try:
                 GObject.signal_new(signal['name'],
                                    widget,
                                    signal['flags'],
                                    signal['return_type'],
                                     signal['param_types'])
             except RuntimeError:
                 err('Container:: registering signal for %s on %s failed' %
                         (signal['name'], widget))
コード例 #37
0
ファイル: window.py プロジェクト: alexr4535/siglo
 def __init__(self, **kwargs):
     self.ble_dfu = None
     self.ota_file = None
     self.manager = None
     self.current_mac = None
     self.asset = None
     self.asset_download_url = None
     self.tag = None
     self.conf = config()
     super().__init__(**kwargs)
     GObject.threads_init()
     self.full_list = get_quick_deploy_list()
     GObject.signal_new(
         "flash-signal",
         self,
         GObject.SIGNAL_RUN_LAST,
         GObject.TYPE_PYOBJECT,
         (GObject.TYPE_PYOBJECT,),
     )
コード例 #38
0
ファイル: ui.py プロジェクト: kurazu/chooser
    def __init__(self, task_queue, pictures):
        super().__init__(type=Gtk.WindowType.TOPLEVEL)
        self.task_queue = task_queue
        self.pictures = pictures

        self.connect("delete-event", Gtk.main_quit)
        self.connect("key-press-event", self.on_keypress)

        self.overlay = Gtk.Overlay()
        self.image = Gtk.Image()
        self.overlay.add(self.image)

        self.star_label = Gtk.Label(self.NOT_FAVOURITE_CHAR)
        self.star_label.set_name('star')

        self.filename_label = Gtk.Label("FILENAME")
        self.filename_label.set_name('filename')

        self.hbox = Gtk.HBox()
        self.hbox.add(self.star_label)
        self.hbox.add(self.filename_label)

        self.hbox.props.valign = Gtk.Align.START
        self.hbox.props.halign = Gtk.Align.START
        self.overlay.add_overlay(self.hbox)

        self.loading_label = Gtk.Label(self.LOADING_TEXT)
        self.loading_label.set_name('loading')
        self.loading_label.props.valign = Gtk.Align.CENTER
        self.loading_label.props.halign = Gtk.Align.CENTER
        self.overlay.add_overlay(self.loading_label)

        self.add(self.overlay)

        self.show_all()
        self.fullscreen()

        GObject.signal_new('picture-loaded', self,
                           GObject.SignalFlags.RUN_LAST, GObject.TYPE_PYOBJECT,
                           (GObject.TYPE_PYOBJECT, ))

        self.connect('picture-loaded', self.on_picture_loaded)
コード例 #39
0
ファイル: cbutil.py プロジェクト: reppkchen/compiz-boxmenu
def set_up():
    GObject.type_register(CommandText)
    GObject.type_register(IconSelector)

    GObject.signal_new("text-changed", CommandText,
                       GObject.SignalFlags.RUN_FIRST, None,
                       (GObject.TYPE_STRING, ))
    GObject.signal_new("mode-changed", CommandText,
                       GObject.SignalFlags.RUN_FIRST, None,
                       (GObject.TYPE_STRING, ))

    GObject.signal_new("image-changed", IconSelector,
                       GObject.SignalFlags.RUN_FIRST, None,
                       (GObject.TYPE_STRING, ))
    GObject.signal_new("text-changed", IconSelector,
                       GObject.SignalFlags.RUN_FIRST, None,
                       (GObject.TYPE_STRING, ))
    GObject.signal_new("mode-changed", IconSelector,
                       GObject.SignalFlags.RUN_FIRST, None,
                       (GObject.TYPE_STRING, ))
コード例 #40
0
ファイル: KbdWindow.py プロジェクト: Dhiru/Inputability-1
    def __init__(self, keyboard_widget, icp):
        self._last_ignore_configure_time = None
        self._last_configures = []
        self._was_visible = False

        Gtk.Window.__init__(self,
                            urgency_hint = False,
                            width_request=self.MINIMUM_SIZE,
                            height_request=self.MINIMUM_SIZE)

        KbdWindowBase.__init__(self, keyboard_widget, icp)

        WindowRectTracker.__init__(self)

        GObject.signal_new("quit-onboard", KbdWindow,
                           GObject.SIGNAL_RUN_LAST,
                           GObject.TYPE_BOOLEAN, ())

        self._auto_position_poll_timer = Timer()

        self.restore_window_rect(startup = True)

        self.connect("map",                     self._on_map_event)
        self.connect("unmap",                   self._on_unmap_event)
        self.connect("delete-event", self._on_delete_event)
        self.connect("configure-event", self._on_configure_event)
        # Connect_after seems broken in Quantal, the callback is never called.
        #self.connect_after("configure-event", self._on_configure_event_after)

        self._osk_util.connect_root_property_notify(["_NET_WORKAREA",
                                                     "_NET_CURRENT_DESKTOP"],
                                                self._on_root_property_notify)

        once = CallOnce(100).enqueue  # call at most once per 100ms

        rect_changed = lambda x: once(self._on_config_rect_changed)
        config.window.position_notify_add(rect_changed)
        config.window.size_notify_add(rect_changed)

        dock_size_changed = lambda x: once(self._on_config_dock_size_changed)
        config.window.dock_size_notify_add(dock_size_changed)
コード例 #41
0
ファイル: KbdWindow.py プロジェクト: vpq98217/Inputability
    def __init__(self, keyboard_widget, icp):
        self._last_ignore_configure_time = None
        self._last_configures = []
        self._was_visible = False

        Gtk.Window.__init__(self,
                            urgency_hint=False,
                            width_request=self.MINIMUM_SIZE,
                            height_request=self.MINIMUM_SIZE)

        KbdWindowBase.__init__(self, keyboard_widget, icp)

        WindowRectTracker.__init__(self)

        GObject.signal_new("quit-onboard", KbdWindow, GObject.SIGNAL_RUN_LAST,
                           GObject.TYPE_BOOLEAN, ())

        self._auto_position_poll_timer = Timer()

        self.restore_window_rect(startup=True)

        self.connect("map", self._on_map_event)
        self.connect("unmap", self._on_unmap_event)
        self.connect("delete-event", self._on_delete_event)
        self.connect("configure-event", self._on_configure_event)
        # Connect_after seems broken in Quantal, the callback is never called.
        #self.connect_after("configure-event", self._on_configure_event_after)

        self._osk_util.connect_root_property_notify(
            ["_NET_WORKAREA", "_NET_CURRENT_DESKTOP"],
            self._on_root_property_notify)

        once = CallOnce(100).enqueue  # call at most once per 100ms

        rect_changed = lambda x: once(self._on_config_rect_changed)
        config.window.position_notify_add(rect_changed)
        config.window.size_notify_add(rect_changed)

        dock_size_changed = lambda x: once(self._on_config_dock_size_changed)
        config.window.dock_size_notify_add(dock_size_changed)
コード例 #42
0
ファイル: main.py プロジェクト: NoIE/bedit
	def __init__(self):
		Gtk.Window.__init__(self, title="带背景的文本编辑器")
		
		GObject.signal_new("changed", BEditDocument, GObject.SIGNAL_RUN_FIRST, GObject.TYPE_NONE, ())	
		
		
		self.grid = Gtk.Grid()
		self.add(self.grid)
		
		#载入历史记录
		self.load_config()
		self.set_default_size(self.sizeWidth, self.sizeHeight)
        
		self.create_notebook()
		self.create_menubar()
		self.create_toolbar()
		self.create_find()
		
		self.on_new()
		self.set_style()
		# 图标来自 http://www.iconlet.com/info/85512_gedit-icon_128x128
		self.set_icon_from_file(sys.path[0]+"/icons/bedit.png")
コード例 #43
0
ファイル: notebook.py プロジェクト: Guake/guake
 def __init__(
     self, window, notebook_parent, workspaces_enabled, terminal_spawned_cb, page_deleted_cb
 ):
     GObject.Object.__init__(self)
     if not GObject.signal_lookup('notebook-created', self):
         GObject.signal_new(
             'notebook-created', self, GObject.SIGNAL_RUN_LAST, GObject.TYPE_NONE,
             (GObject.TYPE_PYOBJECT, GObject.TYPE_INT)
         )
     self.current_notebook = 0
     self.notebooks = {}
     self.window = window
     self.notebook_parent = notebook_parent
     self.terminal_spawned_cb = terminal_spawned_cb
     self.page_deleted_cb = page_deleted_cb
     if workspaces_enabled and gdk_is_x11_display(Gdk.Display.get_default()):
         # NOTE: Wnck didn't support non-X11 display backend, so we need to check if the display
         #       is X11 or not, if not, it will not able to enable workspace-specific-tab-sets
         #
         # TODO: Is there anyway to support this in non-X11 display backend?
         self.screen = Wnck.Screen.get_default()
         self.screen.connect("active-workspace-changed", self.__workspace_changed_cb)
コード例 #44
0
ファイル: notebook.py プロジェクト: Guake/guake
    def __init__(self, *args, **kwargs):
        Gtk.Notebook.__init__(self, *args, **kwargs)
        self.last_terminal_focused = None

        self.set_name("notebook-teminals")
        self.set_tab_pos(Gtk.PositionType.BOTTOM)
        self.set_property("show-tabs", True)
        self.set_property("enable-popup", False)
        self.set_property("scrollable", True)
        self.set_property("show-border", False)
        self.set_property("visible", True)
        self.set_property("has-focus", True)
        self.set_property("can-focus", True)
        self.set_property("is-focus", True)
        self.set_property("expand", True)

        if GObject.signal_lookup('terminal-spawned', TerminalNotebook) == 0:
            GObject.signal_new(
                'terminal-spawned', TerminalNotebook, GObject.SIGNAL_RUN_LAST, GObject.TYPE_NONE,
                (GObject.TYPE_PYOBJECT, GObject.TYPE_INT)
            )
            GObject.signal_new(
                'page-deleted', TerminalNotebook, GObject.SIGNAL_RUN_LAST, GObject.TYPE_NONE, ()
            )

        self.scroll_callback = NotebookScrollCallback(self)
        self.add_events(Gdk.EventMask.SCROLL_MASK)
        self.connect('scroll-event', self.scroll_callback.on_scroll)
        self.notebook_on_button_press_id = self.connect(
            "button-press-event", self.on_button_press, None
        )

        self.new_page_button = Gtk.Button(
            image=Gtk.Image.new_from_icon_name("tab-new", Gtk.IconSize.MENU), visible=True
        )
        self.new_page_button.connect("clicked", self.on_new_tab)
        self.set_action_widget(self.new_page_button, Gtk.PackType.END)
コード例 #45
0
ファイル: html_parser.py プロジェクト: Kronos3/HTML_PARSER
	def __init__ ( self, _dir="gui", start_type="input" ):
		self.dir = DIR
		GObject.type_register ( configitem.ConfigItem )
		GObject.type_register ( configfile.ConfigFile )
		GObject.signal_new ( "new_config", configitem.ConfigItem, GObject.SIGNAL_RUN_FIRST, GObject.TYPE_NONE, ( configitem.ConfigItem, ) )
		GObject.signal_new ( "remove_item", configitem.ConfigItem, GObject.SIGNAL_RUN_FIRST, GObject.TYPE_NONE, ( configfile.ConfigFile, ) )
		GObject.signal_new ( "remove_config", configfile.ConfigFile, GObject.SIGNAL_RUN_FIRST, GObject.TYPE_NONE, ( configfile.ConfigFile, ) )
		self.project = project.Project ( _dir, start_type, main_handlers, self.dir )
		self.project.load_config ( self.project.files, "parser.cfg" )
		self.config = "parser.cfg"
コード例 #46
0
ファイル: test_signal.py プロジェクト: ceibal-tatu/pygobject
 def test_illegals(self):
     self.assertRaises(TypeError, lambda: GObject.signal_new('test',
                                                             None,
                                                             0,
                                                             None,
                                                             (GObject.TYPE_LONG,)))
コード例 #47
0
            self.m_timeout = GObject.timeout_add(DELAY2, self.on_down_timeout)

    def down(self):
        self.m_value -= 1
        self.g_entry.set_text(mpd.int_to_user_octave_notename(self.m_value))
        self.emit('value-changed', self.m_value)

    def get_value(self):
        return self.m_value

    def set_value(self, val):
        self.m_value = val
        self.g_entry.set_text(mpd.int_to_user_octave_notename(val))

GObject.signal_new('value-changed', NotenameSpinButton,
                   GObject.SignalFlags.RUN_FIRST,
                   None,
                   (GObject.TYPE_PYOBJECT,))


class NotenameRangeController(object):

    def __init__(self, spin_low, spin_high, lowest_value, highest_value):
        self.g_spin_low = spin_low
        self.g_spin_low.connect('value-changed', self.on_low_changed)
        self.g_spin_high = spin_high
        self.g_spin_high.connect('value-changed', self.on_high_changed)
        self.m_lowest_value = mpd.notename_to_int(lowest_value)
        self.m_highest_value = mpd.notename_to_int(highest_value)

    def on_low_changed(self, widget, v):
        if widget.get_value() > self.g_spin_high.get_value():
コード例 #48
0
            if self.is_an_error:
                break
            self.next_event.wait()
            self.next_event.clear()
            if self.is_an_error:
                break
            self.next_event.wait(delay_time / 1000.0)
            if self.is_an_error:
                break
            self.next_event.clear()
        self.emit('sequence_finished')

    @staticmethod
    def get_function_group(sbrick_configuration, group):
        for gp in sbrick_configuration["functions"]:
            if group == gp["group"]:
                return gp
        return None

    @staticmethod
    def get_function_in_group(group, function):
        for f in group["functions"]:
            if function == f["label"]:
                return f
        return None


GObject.type_register(SBrickSequencePlayer)
GObject.signal_new("sequence_finished", SBrickSequencePlayer, GObject.SignalFlags.RUN_LAST, GObject.TYPE_NONE, ())
コード例 #49
0
ファイル: __init__.py プロジェクト: Richard-Ni/bareftp
from gi.repository import GObject
from lib.stdoutwrapper import StdOutWrapper
from lib.xferpool import Xfer

GObject.signal_new('log-event', StdOutWrapper, GObject.SIGNAL_RUN_LAST, GObject.TYPE_NONE, (object,))
GObject.signal_new('xfer-event', Xfer, GObject.SIGNAL_RUN_LAST, GObject.TYPE_NONE, ())
GObject.signal_new('xfer-finished', Xfer, GObject.SIGNAL_RUN_LAST, GObject.TYPE_NONE, (object,int,))
コード例 #50
0
ファイル: sidebar.py プロジェクト: Jessewb786/Silaty
			self.iconstack.set_visible_child_name('active')
		else:
			self.iconstack.set_visible_child_name('inactive')
		self._state = value	

	def on_icon_pressed(self, widget, data):
		parent = self.get_parent()
		for i in range(0, parent.childlength):
			if i == self.position:
				parent.get_child(i).state = SideBarButtonState.ON
				parent.get_child(i).emit("sidebar-button-pressed")
			else:
				parent.get_child(i).state = SideBarButtonState.OFF

	def set_image_from_file(self, iconpath):
		try:
			pixbuf = GdkPixbuf.Pixbuf.new_from_file(iconpath)
			icon = Gtk.Image.new_from_pixbuf(pixbuf)
		except GLib.GError:
			icon = Gtk.Image.new_from_stock(Gtk.STOCK_MISSING_IMAGE, 22)
		return icon

class SideBarButtonState(object):
	ON, OFF = True, False

GObject.type_register(SideBarButton)
GObject.signal_new("sidebar-button-pressed", SideBarButton, GObject.SIGNAL_RUN_FIRST, GObject.TYPE_NONE, ())

GObject.type_register(SideBar)
GObject.signal_new("window-shown", SideBar, GObject.SIGNAL_RUN_FIRST, GObject.TYPE_NONE, ())
GObject.signal_new("stack-changed", SideBar, GObject.SIGNAL_RUN_FIRST, GObject.TYPE_NONE, [GObject.TYPE_STRING])
コード例 #51
0
ファイル: image_event_box.py プロジェクト: jonnywei/wallpaper
#!/usr/bin/python

from gi.repository import Gtk, Gdk, GdkPixbuf, GLib, Gio, GObject,Notify

class ImageEventBox(Gtk.EventBox):
    
    def __init__(self):
        super(ImageEventBox,self).__init__()



GObject.type_register(ImageEventBox)
#GObject.signal_new('image-load-complete', ImageEventBox, GObject.SIGNAL_RUN_FIRST | GObject.SIGNAL_ACTION,
#                   GObject.TYPE_NONE, (GObject.TYPE_STRING, ))
GObject.signal_new('image-load-init', ImageEventBox, GObject.SIGNAL_RUN_FIRST | GObject.SIGNAL_ACTION,
                    GObject.TYPE_NONE, (GObject.TYPE_STRING, GObject.TYPE_OBJECT,GObject.TYPE_STRING, ))

        
        
コード例 #52
0
        self.emit("color-added")

    def get_selected_color(self):
        """Return the selected state of a particular color"""
        if self.selected_col is None:
            return None
        else:
            return self.selected_col.color

    def set_selected_color(self, col):
        """Defines the selected state of a displayed color,
        enables clear button when a color is selected"""
        self.unselect_color()
        if self.has_color(col):
            self.buttons_lookup[col].set_selected(True)
            self.selected_col = self.buttons_lookup[col]
        self.clear_button.set_sensitive(True)

    def unselect_color(self):
        """Deselect all colors"""
        if self.selected_col is not None:
            self.selected_col.set_selected(False)
            self.selected_col = None
        self.clear_button.set_sensitive(False)

GObject.type_register(SimpleColorSelector)
GObject.signal_new("color-changed", SimpleColorSelector,
                   GObject.SIGNAL_RUN_FIRST, GObject.TYPE_NONE, ())
GObject.signal_new("color-added", SimpleColorSelector,
                   GObject.SIGNAL_RUN_FIRST, GObject.TYPE_NONE, ())
コード例 #53
0
    def __init__(self):
        super(AuthWebKitScrolledWindow, self).__init__()
        self.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
       
        url = self._get_auth_url()

        w = WebKit.WebView.new()
        w.set_vexpand(True)
        w.load_uri(url)
        w.connect("document-load-finished", self._get_document_cb)

        self.add(w)
        self.show_all()

    def _get_document_cb(self, w, e):
        url = w.get_property('uri')
        re_token = re.compile(self.RE_TOKEN)

        if url.startswith(self.LOGIN_URL):
            self.emit("login-started", None)
        elif re_token.search(url):
            self.emit("token-acquired", url)
        elif url.startswith(self.ERROR_URL):
            self.emit("error-occurred", None)

for signal in ["login-started", "token-acquired", "error-occurred"]:
    GObject.signal_new(signal, AuthWebKitScrolledWindow,
                       GObject.SignalFlags.RUN_LAST, None,
                       (GObject.TYPE_PYOBJECT,))
コード例 #54
0
    # noinspection PyUnusedLocal
    def on_sbrick_channel_stop(self, sbrick, channel):
        self.current_sbrick_channels[channel].stopped()

    def show_channels(self):
        children = self.channelBox.get_children()
        for child in children:
            self.channelBox.remove(child)

        for channelNumber in range(4):
            channel_box = None
            sb = self.sbrick_configuration["channelConfiguration"][channelNumber]
            cc = sb["type"]
            if cc == 'motor':
                channel_box = SBrickMotorChannelBox(channelNumber, sb)
            elif cc == 'servo':
                channel_box = SBrickServoChannelBox(channelNumber, sb)
            self.channelBox.pack_start(channel_box, False, False, 0)
            self.current_sbrick_channels.append(channel_box)

        self.channelBox.show_all()


GObject.type_register(SBrickBox)
GObject.signal_new("sbrick_connected", SBrickBox, GObject.SignalFlags.RUN_LAST, GObject.TYPE_NONE, ())
GObject.signal_new("sbrick_disconnected", SBrickBox, GObject.SignalFlags.RUN_LAST, GObject.TYPE_NONE, ())
GObject.signal_new("show_message", SBrickBox, GObject.SignalFlags.RUN_LAST,
                   GObject.TYPE_NONE, [GObject.TYPE_STRING,
                                       GObject.TYPE_STRING,
                                       GObject.TYPE_STRING])
コード例 #55
0
ファイル: home.py プロジェクト: Jessewb786/Silaty
		self.pack_start(self.prayerlabel, True, True, 0)

		self.timelabel = Gtk.Label(label=prayertime, halign=Gtk.Align.END, margin_bottom=6, margin_top=6, margin_right=12, margin_left=12)
		self.timelabel.set_use_markup(True)

		if state == True:
			self.timelabel.set_markup("<span color=\"#55c1ec\">"+prayertime+"</span>")
		else:
			self.timelabel.set_label(prayertime)

		self.pack_end(self.timelabel, True, True, 0)

	@property
	def time(self):
		return self._time
	@time.setter
	def time(self, value):
		self._time = value

	@property
	def name(self):
		return self._name

	@name.setter
	def name(self, value):
		self._name = value

GObject.type_register(Home)
GObject.signal_new("prayers-updated", Home, GObject.SIGNAL_RUN_FIRST, GObject.TYPE_NONE, [GObject.TYPE_STRING])
コード例 #56
0
ファイル: spanselector.py プロジェクト: jelmer/bzr-gtk
        spin.connect("show", lambda w: w.grab_focus())

        label = Gtk.Label(label="Days")

        entry.pack_start(spin, False, False, True, 0)
        entry.pack_start(label, False, False, True, 0)

        return entry


"""The "span-changed" signal is emitted when a new span has been selected or
entered.

Callback signature: def callback(SpanSelector, span, [user_param, ...])
"""
GObject.signal_new("span-changed", SpanSelector,
                   GObject.SignalFlags.RUN_LAST,
                   None,
                   (GObject.TYPE_FLOAT,))

"""The "custom-span-added" signal is emitted after a custom span has been
added, but before it has been selected.

Callback signature: def callback(SpanSelector, span, [user_param, ...])
"""
GObject.signal_new("custom-span-added", SpanSelector,
                   GObject.SignalFlags.RUN_LAST,
                   None,
                   (GObject.TYPE_FLOAT,))

コード例 #57
0
ファイル: gstreamer.py プロジェクト: ankrap/foobnix
            if struct.has_field("taglist"):
                taglist = struct.get_value("taglist")
                title = taglist.get_string("title")[1]
                if not title:
                    title = ""
                title = correct_encoding(title)
                text = title

                if taglist.get_string('artist')[0]:
                    artist = taglist.get_string('artist')[1]
                    artist = correct_encoding(artist)
                    text = artist + " - " + text
                if not text:
                    text = self.bean.path
                if self._is_remote() and taglist.get_string("audio-codec")[0]:
                    text = text + " || " + taglist.get_string("audio-codec")[1]
                if self._is_remote() and taglist.get_uint('bitrate')[0]:
                    text = text + " || " + str(taglist.get_uint('bitrate')[1] / 1000) + _("kbps")
                    self.emit('bitrate-changed', taglist.get_uint('bitrate')[1])

                self.notify_title(text)

        elif type == Gst.MessageType.EOS:
            self.error_counter = 0
            logging.info("MESSAGE_EOS")
            self.notify_eos()

GObject.signal_new("title-changed", GStreamerEngine, GObject.SIGNAL_RUN_LAST, None, (object, str,))
GObject.signal_new("bitrate-changed", GStreamerEngine, GObject.SIGNAL_RUN_LAST, None, (int,))
GObject.signal_new("eos-signal", GStreamerEngine, GObject.SIGNAL_RUN_LAST, None, ())
コード例 #58
0
ファイル: editor.py プロジェクト: reusee/my-editor-ng
 def new_signal(self, name, arg_types):
     GObject.signal_new(name, Editor, GObject.SIGNAL_RUN_FIRST, None, arg_types)