Beispiel #1
0
 def preview_switch_active(self, switch, gparam):
     if switch.get_active():
         self.wbwin.set_visible(True)
         self.update_wb()
     else:
         self.wbwin.set_visible(False)
     GLib.timeout_add(1, self._glib_nvim_resize)
    def set_estado(self, widget, valor):

        if valor == "playing":
            self.toolbar.set_estado("detenido")
            GLib.idle_add(self.update_balance_toolbars)

        elif valor == "stoped":
            self.toolbar.set_estado("detenido")
            GLib.idle_add(self.update_balance_toolbars)

        elif valor == "GrabandoAudioVideo":
            self.toolbar.set_estado("grabando")
            GLib.idle_add(self.update_balance_toolbars)

        # FIXME: Solo por JAMediaAudio - JAMediaAudioWidget. por ahora
        elif valor == "GrabandoAudio":
            self.toolbar.set_estado("grabando")
            GLib.idle_add(self.update_balance_toolbars)

        # FIXME: Para JAMediaFotografiaWidget. Pero por ahora no se utiliza
        elif valor == "Fotografiando":
            self.toolbar.set_estado("grabando")
            GLib.idle_add(self.update_balance_toolbars)

        else:
            print "### Estado:", valor
Beispiel #3
0
    def on_start_clicked(self, *args):
        # First, update some widgets to not be usable while discovery happens.
        self._startButton.hide()
        self._cancelButton.set_sensitive(False)
        self._okButton.set_sensitive(False)

        self._conditionNotebook.set_current_page(1)
        self._set_configure_sensitive(False)
        self._initiatorEntry.set_sensitive(False)

        # Now get the node discovery credentials.
        credentials = discoverMap[self._authNotebook.get_current_page()](self.builder)

        discoveredLabelText = _(
            "The following nodes were discovered using the iSCSI initiator "
            "<b>%(initiatorName)s</b> using the target IP address "
            "<b>%(targetAddress)s</b>.  Please select which nodes you "
            "wish to log into:"
        ) % {
            "initiatorName": escape_markup(credentials.initiator),
            "targetAddress": escape_markup(credentials.targetIP),
        }

        discoveredLabel = self.builder.get_object("discoveredLabel")
        discoveredLabel.set_markup(discoveredLabelText)

        bind = self._bindCheckbox.get_active()

        spinner = self.builder.get_object("waitSpinner")
        spinner.start()

        threadMgr.add(
            AnacondaThread(name=constants.THREAD_ISCSI_DISCOVER, target=self._discover, args=(credentials, bind))
        )
        GLib.timeout_add(250, self._check_discover)
Beispiel #4
0
 def do_show(self):
     """
         Init signals, set color and go party mode if nothing is playing
     """
     is_playing = Lp.player.is_playing()
     self._signal1_id = Lp.player.connect("current-changed", self._on_current_changed)
     self._signal2_id = Lp.player.connect("status-changed", self._on_status_changed)
     if is_playing:
         self._change_play_btn_status(self._pause_image, _("Pause"))
         self._on_current_changed(Lp.player)
     else:
         Lp.player.set_party(True)
     if self._timeout1 is None:
         self._timeout1 = GLib.timeout_add(1000, self._update_position)
     Gtk.Window.do_show(self)
     now = datetime.now()
     self._datetime.set_label(now.strftime("%a %d %b, %X")[:-3])
     if self._timeout2 is None:
         second = datetime.now().second
         if 60 - second > 0:
             GLib.timeout_add((60 - second) * 1000, self._update_datetime)
         else:
             self._timeout2 = GLib.timeout_add(60000, self._update_datetime)
     self._update_position()
     self.fullscreen()
     self._next_popover.set_relative_to(self._album)
     if Lp.player.next_track.id != Type.RADIOS:
         self._next_popover.show()
Beispiel #5
0
    def _process(self, data):
        def idle_process(data):
            if not self._stopped:
                self._callback(data)
            return False

        GLib.idle_add(idle_process, data)
Beispiel #6
0
    def __idle(self, song, func, *args, **kwargs):
        def delayed():
            if self._stopped or song is not self._current:
                return
            func(song, *args, **kwargs)

        GLib.idle_add(delayed)
Beispiel #7
0
def _sigchld_handler(num=None, frame=None):
    # Check whether anything in the list of processes being watched has
    # exited. We don't want to call waitpid(-1), since that would break
    # anything else using wait/waitpid (like the subprocess module).
    exited_pids = []
    exit_statuses = []

    for child_pid in _forever_pids:
        try:
            pid_result, status = eintr_retry_call(os.waitpid, child_pid, os.WNOHANG)
        except ChildProcessError:
            continue

        if pid_result:
            proc_name = _forever_pids[child_pid][0]
            exited_pids.append(child_pid)

            # Convert the wait-encoded status to the format used by subprocess
            if os.WIFEXITED(status):
                sub_status = os.WEXITSTATUS(status)
            else:
                # subprocess uses negative return codes to indicate signal exit
                sub_status = -os.WTERMSIG(status)

            exit_statuses.append((proc_name, sub_status))

    for child_pid in exited_pids:
        if _forever_pids[child_pid][1]:
            GLib.source_remove(_forever_pids[child_pid][1])
        del _forever_pids[child_pid]

    if exit_statuses:
        _raise_exit_error(exit_statuses)
Beispiel #8
0
def main():
    GLib.threads_init()
    Clutter.init(sys.argv)

    MainWindow()

    Clutter.main()
def main():
    dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)

    random.seed()

    bus = dbus.SessionBus()

    global manager, settings, agent_manager
    manager = NetworkManager(bus, "/org/freedesktop/NetworkManager")
    settings = Settings(bus, "/org/freedesktop/NetworkManager/Settings")
    agent_manager = AgentManager(bus, "/org/freedesktop/NetworkManager/AgentManager")

    if not bus.request_name("org.freedesktop.NetworkManager"):
        sys.exit(1)

    # Watch stdin; if it closes, assume our parent has crashed, and exit
    io = GLib.IOChannel(0)
    io.add_watch(GLib.IOCondition.HUP, stdin_cb)

    # also quit after inactivity to ensure we don't stick around if the above fails somehow
    GLib.timeout_add_seconds(20, quit_cb, None)

    try:
        mainloop.run()
    except Exception as e:
        pass

    sys.exit(0)
Beispiel #10
0
    def __stop_presentacion(self):

        if self.actualizador:
            GLib.source_remove(self.actualizador)
            self.actualizador = False

        self.toolbar.set_paused()
Beispiel #11
0
    def __run_in_mainloop(self, callable):
        loop = GLib.MainLoop()
        result = []
        exception = []

        def reply_handler(x):
            logging.debug("reply_handler %s" % repr(x))
            loop.quit()
            result.append(x)

        def error_handler(x):
            logging.debug("error_handler %s" % repr(x))
            loop.quit()
            exception.append(x)

        def init():
            logging.debug("Will start top async")
            try:
                async.start_with_callbacks(callable(), reply_handler, error_handler)
            except Exception as e:
                logging.debug("Exception in init %s" % repr(e))
                loop.quit()
                exception.append(e)
            logging.debug("Started top async")
            return False

        GLib.idle_add(init)

        loop.run()

        assert len(result) == 0 or len(exception) == 0
        if len(exception) != 0:
            raise exception[0]
        return result[0]
Beispiel #12
0
    def __init__(self):
        BaseWindow.__init__(self, title="Update Timetable")
        threading.Thread.__init__(self)
        self.set_size_request(100, 0)

        self.timeout_id = None

        rows = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=6)
        row1 = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=6)
        row2 = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=6)
        row3 = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=6)

        rows.add(row1)
        rows.add(row2)
        rows.add(row3)

        self.add(rows)

        self._info_label = Gtk.Label("")
        row1.pack_start(self._info_label, True, True, 0)

        self.progressbar = Gtk.ProgressBar()
        self.progressbar.set_pulse_step(0.01)
        row2.pack_start(self.progressbar, True, True, 0)

        self.ok_button = Gtk.Button("Ok")
        self.ok_button.connect("clicked", self.on_ok_clicked)
        self.ok_button.hide()
        row3.pack_start(self.ok_button, True, True, 1)

        GLib.timeout_add(10, self.handler_timeout)
Beispiel #13
0
    def __init__(self, figure):
        if _debug:
            print("FigureCanvasGTK3.%s" % fn_name())
        FigureCanvasBase.__init__(self, figure)
        GObject.GObject.__init__(self)

        self._idle_draw_id = 0
        self._need_redraw = True
        self._lastCursor = None

        self.connect("scroll_event", self.scroll_event)
        self.connect("button_press_event", self.button_press_event)
        self.connect("button_release_event", self.button_release_event)
        self.connect("configure_event", self.configure_event)
        self.connect("draw", self.on_draw_event)
        self.connect("key_press_event", self.key_press_event)
        self.connect("key_release_event", self.key_release_event)
        self.connect("motion_notify_event", self.motion_notify_event)
        self.connect("leave_notify_event", self.leave_notify_event)
        self.connect("enter_notify_event", self.enter_notify_event)
        self.connect("size_allocate", self.size_allocate)

        self.set_events(self.__class__.event_mask)

        self.set_double_buffered(True)
        self.set_can_focus(True)
        self._renderer_init()
        default_context = GLib.main_context_get_thread_default() or GLib.main_context_default()
Beispiel #14
0
def run():
    utils.setproctitle("redshift-gtk")

    # Internationalisation
    gettext.bindtextdomain("redshift", defs.LOCALEDIR)
    gettext.textdomain("redshift")

    # Create redshift child process controller
    c = RedshiftController(sys.argv[1:])

    def terminate_child(data=None):
        c.terminate_child()
        return False

    # Install signal handlers
    GLib.unix_signal_add(GLib.PRIORITY_DEFAULT, signal.SIGTERM, terminate_child, None)
    GLib.unix_signal_add(GLib.PRIORITY_DEFAULT, signal.SIGINT, terminate_child, None)

    try:
        # Create status icon
        s = RedshiftStatusIcon(c)

        # Run main loop
        Gtk.main()
    except:
        c.kill_child()
        raise
 def do_install(self):
     podir = os.path.join(os.getcwd(), "po")
     done_one = False
     for root, subFolders, files in os.walk(podir, topdown=False):
         for file in files:
             parts = os.path.splitext(file)
             if parts[1] == ".po":
                 this_locale_dir = os.path.join(locale_inst, parts[0], "LC_MESSAGES")
                 GLib.mkdir_with_parents(this_locale_dir, 0755)
                 # print "/usr/bin/msgfmt -c %s -o %s" % (os.path.join(root, file), os.path.join(this_locale_dir, '%s.mo' % self.get_uuid()))
                 subprocess.call(
                     [
                         "msgfmt",
                         "-c",
                         os.path.join(root, file),
                         "-o",
                         os.path.join(this_locale_dir, "%s.mo" % self.get_uuid()),
                     ]
                 )
                 done_one = True
     if done_one:
         print "Install complete for domain: %s" % self.get_uuid()
     else:
         print "Nothing installed"
     quit()
Beispiel #16
0
    def _build_ui(self):
        """Builds the UI from ``brusheditor.glade``"""
        ui_dir = os.path.dirname(os.path.abspath(__file__))
        ui_path = os.path.join(ui_dir, self._UI_DEFINITION_FILE)
        ui_fp = open(ui_path, "r")
        ui_xml = ui_fp.read()
        ui_fp.close()
        self._builder.add_from_string(ui_xml)
        self._populate_inputs(ui_xml)
        self._populate_settings_treestore()
        self._builder.connect_signals(self)
        for inp in brushsettings.inputs:
            grid = self._builder.get_object("by%s_curve_grid" % inp.name)
            GLib.idle_add(grid.hide)
            curve = self._builder.get_object("by%s_curve" % inp.name)

            def _curve_changed_cb(curve, i=inp):
                self._update_brush_from_input_widgets(i)

            curve.changed_cb = _curve_changed_cb
            btn = self._builder.get_object("by%s_reset_button" % inp.name)
            btn.connect("clicked", self.input_adj_reset_button_clicked_cb, inp)
        # Certain actions must be coordinated via a real app instance
        if not self.app:
            action_buttons = [
                "clone_button",
                "rename_button",
                "edit_icon_button",
                "delete_button",
                "live_update_checkbutton",
                "save_button",
            ]
            for b_name in action_buttons:
                w = self._builder.get_object(b_name)
                w.set_sensitive(False)
    def enabled(self):
        if not self.running:
            wm = WatchManager()
            self.event_handler = LibraryEvent(app.library)

            # Choose event types to watch for
            # FIXME: watch for IN_CREATE or for some reason folder copies
            # are missed,  --nickb
            FLAGS = ["IN_DELETE", "IN_CLOSE_WRITE", "IN_MOVED_FROM", "IN_MOVED_TO", "IN_CREATE"]  # 'IN_MODIFY',
            mask = reduce(lambda x, s: x | EventsCodes.ALL_FLAGS[s], FLAGS, 0)

            if self.USE_THREADS:
                print_d("Using threaded notifier")
                self.notifier = ThreadedNotifier(wm, self.event_handler)
                # Daemonize to ensure thread dies on exit
                self.notifier.daemon = True
                self.notifier.start()
            else:
                self.notifier = Notifier(wm, self.event_handler, timeout=100)
                GLib.timeout_add(1000, self.unthreaded_callback)

            for path in get_scan_dirs():
                print_d("Watching directory %s for %s" % (path, FLAGS))
                # See https://github.com/seb-m/pyinotify/wiki/
                # Frequently-Asked-Questions
                wm.add_watch(path, mask, rec=True, auto_add=True)

            self.running = True
Beispiel #18
0
        def _on_disk_error(widget, song_path, eror=None):
            def on_disk_error():
                logger.warn("Playlist.on_disk_error: %s, %s" % (song_path, error))
                self.stop_caching_daemon()
                Widgets.filesystem_error(self.app.window, song_path)

            GLib.idle_add(on_disk_error)
Beispiel #19
0
    def do_search(self, keyword):
        """
            Actually performs the search in a separate thread
        """
        lists = self.search(keyword)

        GLib.idle_add(self.search_done, keyword, lists)
Beispiel #20
0
        def _on_network_error(widget, song_link, error=None):
            def on_network_error():
                logger.warn("Playlist.on_network_error: %s, %s" % (song_link, error))
                self.stop_caching_daemon()
                Widgets.network_error(self.app.window, _("Failed to cache song"))

            GLib.idle_add(on_network_error)
Beispiel #21
0
def unwatchAllProcesses():
    """Clear the watched process list."""
    global _forever_pids
    for child_pid in _forever_pids:
        if _forever_pids[child_pid][1]:
            GLib.source_remove(_forever_pids[child_pid][1])
    _forever_pids = {}
Beispiel #22
0
    def _load_plugin_pages(self):
        self._clear_children(self.plug_root)
        plugin_pages = []
        plugin_manager = self.main.exaile.plugins

        for name in plugin_manager.enabled_plugins:
            plugin = plugin_manager.enabled_plugins[name]
            if hasattr(plugin, "get_preferences_pane"):
                try:
                    plugin_pages.append(plugin.get_preferences_pane())
                except Exception:
                    logger.exception("Error loading preferences pane")

        plugin_pages.sort(key=lambda x: common.strxfrm(x.name))

        for page in plugin_pages:
            icon = self.default_icon

            if hasattr(page, "icon"):
                if isinstance(page.icon, GdkPixbuf.Pixbuf):
                    icon = page.icon
                else:
                    icon = icons.MANAGER.pixbuf_from_icon_name(page.icon, Gtk.IconSize.MENU)

            self.model.append(self.plug_root, [page, page.name, icon])

        GLib.idle_add(self.tree.expand_row, self.model.get_path(self.plug_root), False)
Beispiel #23
0
    def _updatePositionCb(self, unused_pipeline, position):
        """
        Unlike other progression indicator callbacks, this one occurs every time
        the pipeline emits a position changed signal, which is *very* often.
        This should only be used for a smooth progressbar/percentage, not text.
        """
        self.current_position = position
        if not self.progress or not position:
            return

        length = self.app.project_manager.current_project.timeline.props.duration
        fraction = float(min(position, length)) / float(length)
        self.progress.updatePosition(fraction)

        # In order to have enough averaging, only display the ETA after 5s
        timediff = time.time() - self._time_started
        if not self._timeEstimateTimer:
            if timediff < 6:
                self.progress.progressbar.set_text(_("Estimating..."))
            else:
                self._timeEstimateTimer = GLib.timeout_add_seconds(3, self._updateTimeEstimateCb)

        # Filesize is trickier and needs more time to be meaningful:
        if not self._filesizeEstimateTimer and (fraction > 0.33 or timediff > 180):
            self._filesizeEstimateTimer = GLib.timeout_add_seconds(5, self._updateFilesizeEstimateCb)
Beispiel #24
0
    def stop(self):
        if self.timeout:
            GLib.source_remove(self.timeout)
            self.timeout = None

        self.player.set_state(Gst.State.NULL)
        self.emit("playing-changed")
Beispiel #25
0
    def create_palette(self):
        primary_text = GLib.markup_escape_text(self._model.bundle.get_name())
        secondary_text = GLib.markup_escape_text(self._model.get_name())
        palette_icon = Icon(
            file=self._model.bundle.get_icon(), pixel_size=style.STANDARD_ICON_SIZE, xo_color=self._model.get_color()
        )
        palette = Palette(None, primary_text=primary_text, secondary_text=secondary_text, icon=palette_icon)

        private = self._model.props.private
        joined = get_owner_instance() in self._model.props.buddies

        menu_box = PaletteMenuBox()

        if joined:
            item = PaletteMenuItem(_("Resume"))
            icon = Icon(pixel_size=style.SMALL_ICON_SIZE, icon_name="activity-start")
            item.set_image(icon)
            item.connect("activate", self.__palette_item_clicked_cb)
            menu_box.append_item(item)
        elif not private:
            item = PaletteMenuItem(_("Join"))
            icon = Icon(pixel_size=style.SMALL_ICON_SIZE, icon_name="activity-start")
            item.set_image(icon)
            item.connect("activate", self.__palette_item_clicked_cb)
            menu_box.append_item(item)

        palette.set_content(menu_box)
        menu_box.show_all()

        self.connect_to_palette_pop_events(palette)
        return palette
Beispiel #26
0
 def _on_progress_scale_event(self, scale, data):
     self._lastState = self.player.get_state(1)[1]
     self.player.set_state(Gst.State.PAUSED)
     if self.timeout:
         GLib.source_remove(self.timeout)
         self.timeout = None
     return False
    def set_accion(self, widget, senial):
        """
        Cuando se hace click en fotografiar o
        en configurar filmacion.
        """

        if senial == "fotografiar":
            if self.jamediawebcam.estado != "Fotografiando":
                self.jamediawebcam.fotografiar()

            else:
                # Solo puede estar en estado Fotografiando
                # si hay ráfagas en proceso.
                self.jamediawebcam.stop_rafagas()

        elif senial == "configurar":
            if self.box_config.get_visible():
                self.box_config.hide()

            else:
                self.box_config.show()
                GLib.idle_add(self.update_balance_toolbars)

        elif senial == "Reset":
            self.reset()
Beispiel #28
0
 def populate(self):
     """
         Populate view
     """
     if Lp.player.get_queue():
         self._clear_btn.set_sensitive(True)
     GLib.idle_add(self._add_items, list(Lp.player.get_queue()))
Beispiel #29
0
 def _on_self_unmap(self, widget):
     """
         Kill thread
         @param widget as Gtk.Widget
     """
     self._thread = False
     GLib.idle_add(self.destroy)
    def initialise(self, plugin):
        """
          one off initialisation call

          :param plugin is the plugin reference
        """

        self.plugin = plugin
        self.shell = plugin.shell

        self.find = plugin.find

        # finally - complete the headerbar setup after the database has fully
        # loaded because
        # rhythmbox has everything initiated at this point.

        self.startup_completed = False
        # self.shell.props.db.connect('load-complete', self.on_load_complete)

        # fire event anyway - scenario is when plugin is first activated post
        # rhythmbox having started
        def delayed(*args):
            if self.shell.props.selected_page:
                self.startup_completed = True
                self.on_startup()
                return False
            else:
                return True

        GLib.timeout_add(100, delayed)