コード例 #1
0
ファイル: recorder.py プロジェクト: rcaferraz/kiwi
    def __init__(self, filename):
        """
        Create a new Recorder object.
        :param filename: name of the script
        """
        WidgetIntrospecter.__init__(self)
        self.register_event_handler()
        self.connect('window-removed', self.window_removed)

        self._filename = filename
        self._events = []
        self._listened_objects = []
        self._event_types = self._configure_event_types()
        self._args = None

        # This is sort of a hack, but there are no other realiable ways
        # of actually having something executed after the application
        # is finished
        atexit.register(self.save)

        # Register a hook that is called before normal delete-events
        # because if it's connected using a normal callback it will not
        # be called if the application returns True in it's signal handler.
        if add_emission_hook:
            add_emission_hook(gtk.Window, 'delete-event',
                              self._emission_window__delete_event)
コード例 #2
0
    def __init__(self, text, parent=None, title=None):
        gobject.GObject.__init__(self)
        self.rc = None

        # this seems to be wordwrapping text passed to
        # it, which is making for ugly error messages
        self.dialog = gtk.MessageDialog(parent, 0, self.STYLE, self.BUTTONS)

        if title:
            self.dialog.set_title(title)

        # escape product strings see rh bz#633438
        self.dialog.set_markup(text)

        self.dialog.set_default_response(0)

        self.dialog.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
        self.dialog.show_all()
        self.dialog.set_icon_name('subscription-manager')

        self.dialog.set_modal(True)
        #this seems spurious, but without it, a ref to this obj gets "lost"
        gobject.add_emission_hook(self, 'response', self.noop_hook)

        self.dialog.connect("response", self._on_response_event)
コード例 #3
0
    def __init__(self, text, parent=None, title=None):
        gobject.GObject.__init__(self)
        self.rc = None

        # this seems to be wordwrapping text passed to
        # it, which is making for ugly error messages
        self.dialog = gtk.MessageDialog(parent, 0, self.STYLE, self.BUTTONS)

        if title:
            self.dialog.set_title(title)

        # escape product strings see rh bz#633438
        self.dialog.set_markup(text)

        self.dialog.set_default_response(0)

        self.dialog.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
        self.dialog.show_all()
        self.dialog.set_icon_name('subscription-manager')

        self.dialog.set_modal(True)
        #this seems spurious, but without it, a ref to this obj gets "lost"
        gobject.add_emission_hook(self, 'response', self.noop_hook)

        self.dialog.connect("response", self._on_response_event)
コード例 #4
0
 def testAdd(self):
     self.hook = True
     e = E()
     e.connect('signal', self._callback)
     gobject.add_emission_hook(E, "signal", self._emission_hook)
     e.emit('signal')
     self.assertEqual(e.status, 3)
コード例 #5
0
ファイル: recorder.py プロジェクト: RENATOZANETTI9/kiwi
    def __init__(self, filename):
        """
        Create a new Recorder object.
        :param filename: name of the script
        """
        WidgetIntrospecter.__init__(self)
        self.register_event_handler()
        self.connect('window-removed', self.window_removed)

        self._filename = filename
        self._events = []
        self._listened_objects = []
        self._event_types = self._configure_event_types()
        self._args = None

        # This is sort of a hack, but there are no other realiable ways
        # of actually having something executed after the application
        # is finished
        atexit.register(self.save)

        # Register a hook that is called before normal delete-events
        # because if it's connected using a normal callback it will not
        # be called if the application returns True in it's signal handler.
        if add_emission_hook:
            add_emission_hook(gtk.Window, 'delete-event',
                              self._emission_window__delete_event)
コード例 #6
0
    def __init__(self, text, parent=None, title=None):
        gobject.GObject.__init__(self)
        self.rc = None

        # this seems to be wordwrapping text passed to
        # it, which is making for ugly error messages
        self.dialog = gtk.MessageDialog(parent, 0, self.STYLE, self.BUTTONS)

        if title:
            self.dialog.set_title(title)

        # escape product strings see rh bz#633438
        self.dialog.set_markup(text)

        # If translations contain bad markup (perhaps from bad text encoding)
        # that doesn't render, just show the message including the markup.
        # See rhbz #865702
        if self.dialog.label.get_text() == '':
            self.dialog.label.set_use_markup(False)

        self.dialog.set_default_response(0)

        self.dialog.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
        self.dialog.show_all()
        self.dialog.set_icon_name('subscription-manager')

        self.dialog.set_modal(True)
        #this seems spurious, but without it, a ref to this obj gets "lost"
        gobject.add_emission_hook(self, 'response', self.noop_hook)

        self.dialog.connect("response", self._on_response_event)
コード例 #7
0
ファイル: test_signal.py プロジェクト: NikolenkoAV2020/Selena
 def testAdd(self):
     self.hook = True
     e = E()
     e.connect('signal', self._callback)
     gobject.add_emission_hook(E, "signal", self._emission_hook)
     e.emit('signal')
     self.assertEqual(e.status, 3)
コード例 #8
0
    def connect_signals(self):
        # Install DBus handlers
        dbg('CliSnipsMenu :: Connecting to Session Bus')
        self.bus = dbus.SessionBus()
        clisnips_service = self.bus.get_object(BUS_NAME, BUS_PATH)
        self.clisnips = dbus.Interface(clisnips_service, BUS_NAME)
        self.bus.add_signal_receiver(self.on_insert_snippet,
                                     dbus_interface=BUS_NAME,
                                     signal_name='InsertSnippet')

        # Connect terminal focus signal
        self.handlers['focus'] = gobject.add_emission_hook(
            Terminal, 'focus-in', self.on_terminal_focus_in)
        self.handlers["keypress"] = gobject.add_emission_hook(
            vte.Terminal, 'key-press-event', self.on_terminal_key_pressed)
コード例 #9
0
ファイル: test_signal.py プロジェクト: NikolenkoAV2020/Selena
 def testRemove(self):
     self.hook = False
     e = E()
     e.connect('signal', self._callback)
     hook_id = gobject.add_emission_hook(E, "signal", self._emission_hook)
     gobject.remove_emission_hook(E, "signal", hook_id)
     e.emit('signal')
     self.assertEqual(e.status, 3)
コード例 #10
0
 def testRemove(self):
     self.hook = False
     e = E()
     e.connect('signal', self._callback)
     hook_id = gobject.add_emission_hook(E, "signal", self._emission_hook)
     gobject.remove_emission_hook(E, "signal", hook_id)
     e.emit('signal')
     self.assertEqual(e.status, 3)
コード例 #11
0
 def testCallbackReturnFalse(self):
     self.hook = False
     obj = F()
     def _emission_hook(obj):
         obj.status += 1
         return False
     hook_id = gobject.add_emission_hook(obj, "signal", _emission_hook)
     obj.emit('signal')
     obj.emit('signal')
     self.assertEqual(obj.status, 3)
コード例 #12
0
ファイル: clisnips_plugin.py プロジェクト: ju1ius/clisnips
    def connect_signals(self):
        # Install DBus handlers
        dbg('CliSnipsMenu :: Connecting to Session Bus')
        self.bus = dbus.SessionBus()
        clisnips_service = self.bus.get_object(BUS_NAME, BUS_PATH)
        self.clisnips = dbus.Interface(clisnips_service, BUS_NAME)
        self.bus.add_signal_receiver(self.on_insert_snippet,
                                     dbus_interface=BUS_NAME,
                                     signal_name='InsertSnippet')

        # Connect terminal focus signal
        self.handlers['focus'] = gobject.add_emission_hook(
            Terminal,
            'focus-in',
            self.on_terminal_focus_in
        )
        self.handlers["keypress"] = gobject.add_emission_hook(
            vte.Terminal,
            'key-press-event',
            self.on_terminal_key_pressed
        )
コード例 #13
0
ファイル: test_signal.py プロジェクト: NikolenkoAV2020/Selena
    def testCallbackReturnFalse(self):
        self.hook = False
        obj = F()

        def _emission_hook(obj):
            obj.status += 1
            return False

        hook_id = gobject.add_emission_hook(obj, "signal", _emission_hook)
        obj.emit('signal')
        obj.emit('signal')
        self.assertEqual(obj.status, 3)
コード例 #14
0
    def connect_button_press_events_for_hiding(self):
        self._button_press_emission_hook_id = gobject.add_emission_hook(
            self._popup_owner_widget, "button-press-event",
            self._on_emission_hook_button_press_event)

        toplevel = utils_.get_toplevel_window(self._popup_owner_widget)
        if toplevel is not None:
            toplevel.get_group().add_window(self._popup_to_hide)
            # Button presses on the window decoration cannot be intercepted via the
            # `"button-press-event"` emission hooks, hence this workaround.
            self._toplevel_configure_event_id = toplevel.connect(
                "configure-event", self._on_toplevel_configure_event)
            self._toplevel_position = toplevel.get_position()
コード例 #15
0
 def connect_button_press_events_for_hiding(self):
   self._button_press_emission_hook_id = gobject.add_emission_hook(
     self._popup_owner_widget,
     "button-press-event",
     self._on_emission_hook_button_press_event)
   
   toplevel = utils_.get_toplevel_window(self._popup_owner_widget)
   if toplevel is not None:
     toplevel.get_group().add_window(self._popup_to_hide)
     # Button presses on the window decoration cannot be intercepted via the
     # `"button-press-event"` emission hooks, hence this workaround.
     self._toplevel_configure_event_id = toplevel.connect(
       "configure-event", self._on_toplevel_configure_event)
     self._toplevel_position = toplevel.get_position()
コード例 #16
0
 def _show_popup(self):
   if not self._is_popup_shown() and len(self._file_formats_filtered) > 0:
     self._update_popup_position()
     
     self._button_press_emission_hook_id = gobject.add_emission_hook(
       self, "button-press-event", self._on_button_press_emission_hook)
     
     toplevel_window = self.get_toplevel()
     if isinstance(toplevel_window, gtk.Window):
       toplevel_window.get_group().add_window(self._popup)
       # As soon as the user starts dragging or resizing the window, hide the
       # popup. Button presses on the window decoration cannot be intercepted
       # via "button-press-event" emission hooks, hence this workaround.
       self._toplevel_configure_event_id = toplevel_window.connect("configure-event",
                                                                   self._on_toplevel_configure_event)
     
     self._popup.set_screen(self.get_screen())
     
     self._popup.show()
     
     if self._show_popup_first_time:
       self._last_assigned_text = self.get_text()
       self._show_popup_first_time = False
コード例 #17
0
    def show(self):
        if not self.is_shown() and len(self._rows_filtered) > 0:
            self._button_press_emission_hook_id = gobject.add_emission_hook(
                self._entry, "button-press-event",
                self._on_emission_hook_button_press_event)

            toplevel_window = self._entry.get_toplevel()
            if isinstance(toplevel_window, gtk.Window):
                toplevel_window.get_group().add_window(self._popup)
                # As soon as the user starts dragging or resizing the window, hide the
                # popup. Button presses on the window decoration cannot be intercepted
                # via "button-press-event" emission hooks, hence this workaround.
                self._toplevel_configure_event_id = toplevel_window.connect(
                    "configure-event", self._on_toplevel_configure_event)

            self._popup.set_screen(self._entry.get_screen())

            self._popup.show()

            self._update_position()

            if self._show_popup_first_time:
                self.save_last_value()
                self._show_popup_first_time = False
コード例 #18
0
ファイル: bus.py プロジェクト: jldupont/dbus_lastfm
 def add_emission_hook(cls, name, callback):
     gobject.add_emission_hook(cls._signals, name, callback)
コード例 #19
0
ファイル: blamainwindow.py プロジェクト: nkoep/blaplay
    def __init__(self):
        super(BlaMainWindow, self).__init__(gtk.WINDOW_TOPLEVEL)
        self.set_resizable(True)
        self.connect("delete_event", self.__delete_event)
        self.enable_tracking(is_main_window=True)

        # Set up the fullscreen window.
        self.__fullscreen_window = gtk.Window()
        def map_(window):
            pass
        self.__fullscreen_window.connect("map", map_)
        self.__fullscreen_window.set_modal(True)
        self.__fullscreen_window.set_transient_for(self)
        self.__fullscreen_window.connect_object(
            "window_state_event", BlaMainWindow.__window_state_event, self)
        def key_press_event(window, event):
            if blagui.is_accel(event, "Escape"):
                window.child.emit("toggle_fullscreen")
            elif blagui.is_accel(event, "space"):
                player.play_pause()
            elif blagui.is_accel(event, "<Ctrl>Q"):
                blaplay.shutdown()
        self.__fullscreen_window.connect_object(
            "key_press_event", key_press_event, self.__fullscreen_window)
        # Realize the fullscreen window. If we don't do this here and reparent
        # the drawingarea to it later that in turn will get unrealized again,
        # causing bad X window errors.
        self.__fullscreen_window.realize()

        # Install a global mouse hook. If connected callbacks don't consume the
        # event by returning True this hook gets called for every widget in the
        # hierarchy that re-emits the event. We therefore cache the event's
        # timestamp to detect and ignore signal re-emissions.
        def button_press_hook(receiver, event):
            event_time = event.get_time()
            if event_time != self.__previous_event_time:
                self.__previous_event_time = event_time
                if event.button == 8:
                    player.previous()
                elif event.button == 9:
                    player.next()
            # This behaves like gobject.{timeout|idle}_add: if the callback
            # doesn't return True it's only called once. It does NOT prevent
            # signal callbacks from executing.
            return True
        self.__previous_event_time = -1
        gobject.add_emission_hook(self, "button_press_event",
                                  button_press_hook)

        # Main menu
        ui_manager = blaplay.bla.ui_manager
        self.add_accel_group(ui_manager.get_accel_group())

        actions = [
            # Menus and submenus
            ("File", None, "_File"),
            ("Edit", None, "_Edit"),
            ("Select", None, "S_elect"),
            ("Selection", None, "Se_lection"),
            ("NewPlaylistFrom", None, "_New playlist from"),
            ("PlayOrder", None, "_Order"),
            ("View", None, "_View"),
            ("Help", None, "_Help"),

            # Menu items
            ("OpenPlaylist", None, "Open playlist...", None, "",
             self.__open_playlist),
            ("AddFiles", None, "Add _files...", None, "",
             lambda *x: self.__add_tracks()),
            ("AddDirectories", None, "_Add directories...", None, "",
             lambda *x: self.__add_tracks(files=False)),
            ("SavePlaylist", None, "_Save playlist...", None, "",
             self.__save_playlist),
            ("Quit", gtk.STOCK_QUIT, "_Quit", "<Ctrl>Q", "",
             lambda *x: blaplay.shutdown()),
            ("Preferences", None, "Pre_ferences...", None, "", BlaPreferences),
            ("About", None, "_About...", None, "", BlaAbout)
        ]
        ui_manager.add_actions(actions)

        toggle_actions = [
            ("Statusbar", None, "St_atusbar", None, "",
             self.__toggle_statusbar, blacfg.getboolean("general",
                                                        "statusbar")),
            ("Visualization", None, "Visualization", None, "",
             self.__toggle_visualization,
             blacfg.getboolean("general", "show.visualization"))
        ]
        ui_manager.add_toggle_actions(toggle_actions)

        radio_actions = [
            ("OrderNormal", None, "_Normal", None, "", blaconst.ORDER_NORMAL),
            ("OrderRepeat", None, "_Repeat", None, "", blaconst.ORDER_REPEAT),
            ("OrderShuffle", None, "_Shuffle", None, "",
             blaconst.ORDER_SHUFFLE)
        ]
        # TODO: Emit "order_changed" signal in the on_change handler instead
        #       and let interested widgets handle this instead.
        ui_manager.add_radio_actions(
            radio_actions, value=blacfg.getint("general", "play.order"),
            on_change=BlaStatusbar.set_order)

        # This is the topmost box that holds all the other components.
        self.add(gtk.VBox())

        # Create instances of the main parts of the GUI.
        self.__toolbar = BlaToolbar()
        self.__browsers = BlaBrowsers()
        self.__visualization = BlaVisualization()
        self.__view = BlaView()
        self.__statusbar = BlaStatusbar()

        # Group browsers and visualization widget.
        self.__vbox_left = gtk.VBox(spacing=blaconst.WIDGET_SPACING)
        self.__vbox_left.pack_start(self.__browsers, expand=True)
        self.__vbox_left.pack_start(self.__visualization, expand=False)
        self.__vbox_left.show()

        # Pack the browser + view-widget into a gtk.HPane instance.
        hpane = gtk.HPaned()
        hpane.pack1(self.__vbox_left, resize=False, shrink=False)
        hpane.pack2(self.__view, resize=True, shrink=True)
        hpane.show()

        # Restore pane positions.
        def notify(pane, propspec, key):
            blacfg.set("general", key, str(pane.get_position()))
        for pane, side in [(hpane, "left"), (self.__view, "right")]:
            key = "pane.pos.%s" % side
            try:
                pane.set_position(blacfg.getint("general", key))
            except TypeError:
                pass
            pane.connect("notify", notify, key)

        # Create a vbox hpane and the statusbar. This allows for setting a
        # border around those items which excludes the menubar and the toolbar.
        vbox = gtk.VBox(spacing=blaconst.BORDER_PADDING)
        vbox.set_border_width(blaconst.BORDER_PADDING)
        vbox.pack_start(hpane)
        vbox.pack_start(self.__statusbar, expand=False)
        vbox.show()

        self.child.pack_start(ui_manager.get_widget("/Menu"), expand=False)
        self.child.pack_start(self.__toolbar, expand=False)
        self.child.pack_start(vbox)
        self.child.show()

        self.__tray = BlaTray()

        def update_title(*args):
            self.__update_title()
        player.connect("state_changed", update_title)
        library.connect("library_updated", update_title)
        self.__update_title()
コード例 #20
0
ファイル: bus.py プロジェクト: jldupont/rb_synclastfm
 def add_emission_hook(cls, name, callback):
     gobject.add_emission_hook(cls._signals, name, callback) #@UndefinedVariable