Exemple #1
0
def dialog_from_fault(f, error_text=None, additional_text=None,
                      parent=None, post_dialog_thunk=None):
    if not f:
        return

    if error_text:
        text = error_text + ": " + f.faultString
    else:
        text = f.faultString

    if additional_text:
        text = text + "\n\n" + additional_text
    
    text = text + "\n\n" + "(fault %d)" % f.faultCode

    dialog = gtk.MessageDialog(parent, 0, gtk.MESSAGE_WARNING,
                               gtk.BUTTONS_OK,
                               text)
    dialog.set_title("") # Gnome HIG says no titles on these sorts of dialogs

    def idle_cb(d, thunk):
        gtk.threads_enter()
        d.show()
        d.run()
        d.destroy()
        if thunk:
            thunk()
        gtk.threads_leave()

    # Always run the dialog in the main thread.
    gtk.idle_add(idle_cb, dialog, post_dialog_thunk)
Exemple #2
0
        def get_id_thread():
            if not input_id:
                new_id = None
                return
            else:
                new_id = input_id
                old_id = computer.id
                computer.id = new_id if new_id != "" else None
                if not new_id:
                    gtk.idle_add(self.show_computer, computer)
                    return
                try:
                    self.mainwindow.alert_plugins('on-set-id', computer,
                                                  input_id)
                except CallbackFailed:
                    computer.id = old_id
                    gobject.idle_add(self.show_get_id, computer)
                    return

            gobject.idle_add(self.__update_computer, computer)
            gobject.idle_add(self.show_computer, computer)

            if computer.id in [
                    c.id for c in filter(lambda c: c != computer,
                                         self.group.computers)
            ]:

                @idle_add_decorator
                def show_error():
                    computer.id = old_id
                    self.show_error("The ID %s is already in use!" % new_id)
                    self.show_computer(computer)
                    return

                show_error()
Exemple #3
0
 def handleSwipe(self, data):
     NuimoDelegate.handleSwipe(self, data)
     self.app.hadnuimoaction = True
     if data == 1:
         gtk.idle_add(app.next)
     else:
         gtk.idle_add(app.previous)
 def disable(self):
     if self.callback_id is not None:
         self.video_sink.disconnect(self.callback_id)
         self.callback_id = None
         self._enabled = False
         self.emit('video-disabled')
     gtk.idle_add(self.on_frame_update, None, None)
    def assistant_prepared(self, assistant, *args):
        if assistant.get_current_page() not in (4, 5):
            self.width, self.height = self.widget.size_request()

        if assistant.get_current_page() not in (0, 4):
            print self.width, self.height
            self.widget.resize(self.width, self.height)

        print 'Page %s prepared.' % assistant.get_current_page()
        if assistant.get_current_page() == 3:
            channels_str = self.selected_channels()
            start_channel = int(re.match(r'Channels (?P<start_channel>\d+)-\d+',
                                         channels_str).group('start_channel'))
            self.measurements_label.set_label('Reading measurements (this '
                                              'might take a few minutes)...')
            gtk.idle_add(self.read_measurements, start_channel)
        elif assistant.get_current_page() == 4:
            self.widget.resize(600, 700)
            normalized_measurements = (self.readings['measured capacitance']
                                       / self.readings['expected capacitance'])
            self.figure.clf()
            axis = self.figure.add_subplot(111)
            axis.bar(normalized_measurements.index - 0.3,
                     normalized_measurements, width=0.6, edgecolor='none',
                     facecolor='limegreen')
            axis.set_xlim(left=self.test_loads.index.min() - 0.5,
                          right=self.test_loads.index.max() + 0.5)
            axis.set_xlabel('channel')
            axis.set_ylabel(r'$\frac{C_{\tt{measured}}}{C_{\tt{expected}}}$',
                            fontsize=28)
Exemple #6
0
    def assistant_prepared(self, assistant, *args):
        if assistant.get_current_page() not in (4, 5):
            self.width, self.height = self.widget.size_request()

        if assistant.get_current_page() not in (0, 4):
            print self.width, self.height
            self.widget.resize(self.width, self.height)

        print 'Page %s prepared.' % assistant.get_current_page()
        if assistant.get_current_page() == 3:
            channels_str = self.selected_channels()
            start_channel = int(
                re.match(r'Channels (?P<start_channel>\d+)-\d+',
                         channels_str).group('start_channel'))
            self.measurements_label.set_label('Reading measurements (this '
                                              'might take a few minutes)...')
            gtk.idle_add(self.read_measurements, start_channel)
        elif assistant.get_current_page() == 4:
            self.widget.resize(600, 700)
            normalized_measurements = (self.readings['measured capacitance'] /
                                       self.readings['expected capacitance'])
            self.figure.clf()
            axis = self.figure.add_subplot(111)
            axis.bar(normalized_measurements.index - 0.3,
                     normalized_measurements,
                     width=0.6,
                     edgecolor='none',
                     facecolor='limegreen')
            axis.set_xlim(left=self.test_loads.index.min() - 0.5,
                          right=self.test_loads.index.max() + 0.5)
            axis.set_xlabel('channel')
            axis.set_ylabel(r'$\frac{C_{\tt{measured}}}{C_{\tt{expected}}}$',
                            fontsize=28)
    def assistant_prepared(self, assistant, *args):
        if assistant.get_current_page() not in (4, 5):
            self.width, self.height = self.widget.size_request()

        if assistant.get_current_page() not in (0, 4):
            print self.width, self.height
            self.widget.resize(self.width, self.height)

        print 'Page %s prepared.' % assistant.get_current_page()
        if assistant.get_current_page() < 3:
            self.widget.set_page_complete(self.box1, False)

        if assistant.get_current_page() == 3:
            settings = dict([(f, self.form_view.form.fields[f].proxy
                              .get_widget_value())
                             for f in ('start_frequency', 'number_of_steps',
                                       'end_frequency', 'RMS_voltage')])
            start_frequency = np.array(settings['start_frequency'])
            end_frequency = np.array(settings['end_frequency'])
            number_of_steps = np.array(settings['number_of_steps'])
            frequencies = np.floor(np.logspace(np.log10(start_frequency),
                                               np.log10(end_frequency),
                                               number_of_steps))
            self.measurements_label.set_label('Reading measurements (this '
                                              'might take a few minutes)...')
            gtk.idle_add(self.read_measurements, settings['RMS_voltage'],
                         frequencies)
        elif assistant.get_current_page() == 4:
            self.widget.resize(600, 700)
            self.fit_feedback_params()
            display(self.fitted_params)
            fitted_readings = self.impedance_readings.copy()
            apply_calibration(fitted_readings, self.fitted_params,
                              self.calibration)
            plot_stat_summary(fitted_readings, fig=self.figure)
Exemple #8
0
 def get_id_thread():
     if not input_id:
         new_id = None
         return
     else:
         new_id = input_id
         old_id = computer.id
         computer.id = new_id if new_id != "" else None
         if not new_id:
             gtk.idle_add(self.show_computer, computer)
             return
         try:
             self.mainwindow.alert_plugins('on-set-id', computer, input_id)
         except CallbackFailed:
             computer.id = old_id
             gobject.idle_add(self.show_get_id, computer)
             return
     
     gobject.idle_add(self.__update_computer, computer)
     gobject.idle_add(self.show_computer, computer)
     
     if computer.id in [c.id for c in filter(lambda c: c != computer, self.group.computers)]:
         @idle_add_decorator
         def show_error():
             computer.id = old_id
             self.show_error("The ID %s is already in use!" % new_id)
             self.show_computer(computer)
             return
         show_error()
Exemple #9
0
    def set_electrode_states(self, electrode_states, save=True):
        '''
        Set the state of multiple electrodes.

        Args:

            electrode_states (pandas.Series) : State of electrodes, indexed by
                electrode identifier (e.g., `"electrode001"`).
            save (bool) : Trigger save request for protocol step.

        Returns:

            (dict) : States of modified channels and electrodes, as well as the
                total area of all actuated electrodes.
        '''
        app = get_app()

        result = self.get_state(electrode_states)

        # Set the state of DMF device channels.
        self.electrode_states = (result['electrode_states']
                                 .combine_first(self.electrode_states))

        if save:
            def notify(step_number):
                emit_signal('on_step_options_changed', [self.name,
                                                        step_number],
                            interface=IPlugin)
            gtk.idle_add(notify, app.protocol.current_step_number)

        result['actuated_area'] = self.get_actuated_area(self.electrode_states)
        return result
 def on_treeview_layers__cursor_changed(self, treeview):
     # As a workaround for an apparent race condition, use `idle_add`
     # callback here to give the tree view selection instance to update.
     #
     # *N.B.*, Without doing this, sometimes the previously selected row is
     # still returned by `get_selected()`/`get_selected_rows()`.
     gtk.idle_add(self.set_scale_alpha_from_selection)
Exemple #11
0
def dialog_from_fault(f,
                      error_text=None,
                      additional_text=None,
                      parent=None,
                      post_dialog_thunk=None):
    if not f:
        return

    if error_text:
        text = error_text + ": " + f.faultString
    else:
        text = f.faultString

    if additional_text:
        text = text + "\n\n" + additional_text

    text = text + "\n\n" + "(fault %d)" % f.faultCode

    dialog = gtk.MessageDialog(parent, 0, gtk.MESSAGE_WARNING, gtk.BUTTONS_OK,
                               text)
    dialog.set_title("")  # Gnome HIG says no titles on these sorts of dialogs

    def idle_cb(d, thunk):
        gtk.threads_enter()
        d.show()
        d.run()
        d.destroy()
        if thunk:
            thunk()
        gtk.threads_leave()

    # Always run the dialog in the main thread.
    gtk.idle_add(idle_cb, dialog, post_dialog_thunk)
    def __init__(self, install_packages=[], remove_packages=[],
                 verify=0, transaction_type=rcd_util.PACKAGE_TYPE_PACKAGE):
        gobject.GObject.__init__(self)
        red_component.Component.__init__(self)

        self.server = rcd_util.get_server_proxy()

        self.install_packages = install_packages
        self.remove_packages = remove_packages
        self.verify = verify

        self.dep_install = []
        self.dep_remove = []
        self.dep_error = None

        self.__worker = None
        self.__worker_handler_id = 0

        self.transaction_type = transaction_type

        # Call get_deps in an idle so that we are fully initialized
        # before we being our computation.  (In particular, the
        # parent isn't properly set on the component at this point.)
        if transaction_type == rcd_util.PACKAGE_TYPE_PATCH:
            gtk.idle_add(lambda comp: comp.emit("got-results"), self)
        else:
            gtk.idle_add(lambda comp: comp.get_deps(), self)
def askOpenFolderGtk(title, initialDir):
    if hasGtk:
        fls = []
        def run_dlg():
            chooser = gtk.FileChooserDialog(title,
                                        None, gtk.FILE_CHOOSER_ACTION_SAVE,
                                        (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
                                        gtk.STOCK_OPEN, gtk.RESPONSE_OK))

            chooser.set_default_response(gtk.RESPONSE_OK)
            chooser.set_current_folder(initialDir)
            chooser.set_current_name("world")
            chooser.set_action(gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER)

            response = chooser.run()
            if response == gtk.RESPONSE_OK:
                fls.append(chooser.get_filename()) # Returns the folder path if gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER is the action
            else:
                fls.append(None)
            chooser.destroy()
            gtk.main_quit()

        gtk.idle_add(run_dlg)
        gtk.main()
        return fls[0]
    else:
        print "You currently need gtk to use an Open Folder Dialog!"
Exemple #14
0
def askOpenFolderGtk(title, initialDir):
    if hasGtk:
        fls = []

        def run_dlg():
            chooser = gtk.FileChooserDialog(
                title, None, gtk.FILE_CHOOSER_ACTION_SAVE,
                (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN,
                 gtk.RESPONSE_OK))

            chooser.set_default_response(gtk.RESPONSE_OK)
            chooser.set_current_folder(initialDir)
            chooser.set_current_name("world")
            chooser.set_action(gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER)

            response = chooser.run()
            if response == gtk.RESPONSE_OK:
                fls.append(
                    chooser.get_filename()
                )  # Returns the folder path if gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER is the action
            else:
                fls.append(None)
            chooser.destroy()
            gtk.main_quit()

        gtk.idle_add(run_dlg)
        gtk.main()
        return fls[0]
    else:
        print "You currently need gtk to use an Open Folder Dialog!"
Exemple #15
0
    def set_electrode_states(self, electrode_states, save=True):
        '''
        Set the state of multiple electrodes.

        Args:

            electrode_states (pandas.Series) : State of electrodes, indexed by
                electrode identifier (e.g., `"electrode001"`).
            save (bool) : Trigger save request for protocol step.

        Returns:

            (dict) : States of modified channels and electrodes, as well as the
                total area of all actuated electrodes.
        '''
        app = get_app()

        result = self.get_state(electrode_states)

        # Set the state of DMF device channels.
        self.electrode_states = (result['electrode_states'].combine_first(
            self.electrode_states))

        if save:

            def notify(step_number):
                emit_signal('on_step_options_changed',
                            [self.name, step_number],
                            interface=IPlugin)

            gtk.idle_add(notify, app.protocol.current_step_number)

        result['actuated_area'] = self.get_actuated_area(self.electrode_states)
        return result
 def _c(tv, item):
     # check it is None now
     self.assertEqual(tv.selected, None)
     def _i():
         # but is getting set in idle
         self.assertEqual(tv.selected, item)
     gtk.idle_add(_i)
Exemple #17
0
 def _initialize_gtk_browser(self):
     '''Sets various event-handlers for browser and window objects.'''
     self.window = gtk.Window()
     self.vbox = gtk.VBox()
     self.scroller = gtk.ScrolledWindow()
     self.browser = webkit.WebView()
     self.browser.connect('title-changed', self._on_gtk_title_changed)
     self.vbox.pack_start(self.scroller)
     self._initialize_gtk_progress_bar().scroller.add(self.browser)
     self.browser.open(self._url)
     self.window.connect('delete_event', self.trigger_stop)
     self.window.add(self.vbox)
     self.window.set_title(self.default_title)
     self.window.resize(
         width=self.width_in_pixel, height=self.height_in_pixel)
     if self.fullscreen:
         self.window.fullscreen()
     if self.no_window_decoration:
         self.window.set_decorated(False)
     self.window.show_all()
     gtk.idle_add(self._check_for_gtk_closing_flag)
     # Alternative more low-level implementation.
     # while True:
     #     gtk.main_iteration(block=False)
     #     if gtk.events_pending() and self._gtk_close:
     #         break
     gtk.main()
     return self
Exemple #18
0
 def execute_command(self, start, end):
     self.buffer.begin_user_action()
     command = self.buffer.get_text(start, end, True)
     if command.startswith('%'):
         command = command[1:]
         command = command.strip()
         pipe = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)
         output = pipe.communicate()[0]
         output = '\n' + output
         self.buffer.insert(end, output, len(output))
         def insert_prompt(widget):
             widget.insert_at_cursor(u'% ', 2)
         gtk.idle_add(insert_prompt, self.buffer)
     elif command.startswith('|'):
         command = command[1:]
         command = '%s < %s' % (
             command, self.filename
         )
         self.buffer.delete(start, end)
         self.save_to_disk()
         pipe = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)
         output = pipe.communicate()[0]
         self.buffer.set_text(output)
     elif command.startswith('cd '):
         dirname = command[3:]
         if os.path.isdir(dirname):
             os.chdir(dirname)
             #self.set_window_title(-1, self)
         self.buffer.set_text('')
     else:
         pipe = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)
         output = pipe.communicate()[0]
         self.buffer.delete(start, end)
         self.buffer.insert(start, output, len(output))
     self.buffer.end_user_action()
Exemple #19
0
 def on_routes_set(self, df_routes):
     if not self.canvas_slave.df_routes.equals(df_routes):
         self.canvas_slave.df_routes = df_routes
         self.canvas_slave.set_surface('routes',
                                       self.canvas_slave.render_routes())
         self.canvas_slave.cairo_surface = flatten_surfaces(
             self.canvas_slave.df_surfaces)
         gtk.idle_add(self.canvas_slave.draw)
Exemple #20
0
 def cb_multi_view_controlbar_clicked_close(self, view, toolbar, name):
     if self.confirm_multi_view_controlbar_clicked_close(view):
         def closed():
             view.remove()
             self.cb_multi_view_closed(view)
             del self.__views[view.unique_id]
             #view.destroy()
         gtk.idle_add(closed)
Exemple #21
0
def idle_add(callable, *args):
    """A wrapper around gtk.idle_add which wraps the callback in
    threads_enter/threads_leave if required"""
    try:
        _throwback()
        gobject.idle_add(idle_wrapper, callable, *args)
    except AttributeError:
        gtk.idle_add(idle_wrapper, callable, *args)
Exemple #22
0
 def possibly_indent_new_block(self, start, end):
     text = self.buffer.get_text(start, end, True)
     if (text.endswith((':', '{', '(', '[')) or
         text.startswith(('*   ', '-   '))):
         # Allow the keystroke, but queue an insert of four spaces
         def insert_four_spaces(widget):
             widget.insert_at_cursor(u'    ', 4)
         gtk.idle_add(insert_four_spaces, self.buffer)
Exemple #23
0
def idle_add(callable, *args):
    """A wrapper around gtk.idle_add which wraps the callback in
    threads_enter/threads_leave if required"""
    try:
        _throwback()
        gobject.idle_add(idle_wrapper, callable, *args)
    except AttributeError:
        gtk.idle_add(idle_wrapper, callable, *args)
Exemple #24
0
 def on_routes_set(self, df_routes):
     if not self.canvas_slave.df_routes.equals(df_routes):
         self.canvas_slave.df_routes = df_routes
         self.canvas_slave.set_surface('routes',
                                       self.canvas_slave.render_routes())
         self.canvas_slave.cairo_surface = flatten_surfaces(self
                                                            .canvas_slave
                                                            .df_surfaces)
         gtk.idle_add(self.canvas_slave.draw)
Exemple #25
0
        def _c(tv, item):
            # check it is None now
            self.assertEqual(tv.selected, None)

            def _i():
                # but is getting set in idle
                self.assertEqual(tv.selected, item)

            gtk.idle_add(_i)
Exemple #26
0
 def on_electrode_states_set(self, states):
     if not (self.canvas_slave.electrode_states.equals(
             states['electrode_states'])):
         self.canvas_slave.electrode_states = states['electrode_states']
         self.canvas_slave.set_surface(
             'actuated_shapes', self.canvas_slave.render_actuated_shapes())
         self.canvas_slave.cairo_surface = flatten_surfaces(
             self.canvas_slave.df_surfaces)
         gtk.idle_add(self.canvas_slave.draw)
Exemple #27
0
 def async_update(self, start, schema, paths, context):
   gtk.idle_add(self.statusbar.push, context, "Parsing schema")
   self.__set_treestore(start[0])
   gtk.idle_add(self.statusbar.push, context, "Schema parsed... finding usage")
   self.__set_useage(schemausage.find_unusedset(schema, paths))
   gtk.idle_add(self.statusbar.push, context, "Usage found")
   self.__floodfill(self.treestore.get_iter_root())
   gtk.idle_add(self.statusbar.push, context, "")
   gtk.idle_add(self.treeview.set_model, self.treestore)
 def set_shape(self, width, height):
     logger.debug('[set_shape]: Set drawing area shape to %sx%s', width,
                  height)
     self.shape = width, height
     # Set new target size for scaled frames from video sink.
     self.video_sink.shape = width, height
     self.update_transforms()
     if not self._enabled:
         gtk.idle_add(self.on_frame_update, None, None)
Exemple #29
0
 def set_shape(self, width, height):
     logger.debug('[set_shape]: Set drawing area shape to %sx%s', width,
                  height)
     self.shape = width, height
     # Set new target size for scaled frames from video sink.
     self.video_sink.shape = width, height
     self.update_transforms()
     if not self._enabled:
         gtk.idle_add(self.on_frame_update, None, None)
Exemple #30
0
    def replace_from_channel(self, channel, downloading=None, \
            include_description=False, generate_thumbnails=False, \
            treeview=None):
        """
        Add episode from the given channel to this model.
        Downloading should be a callback.
        include_description should be a boolean value (True if description
        is to be added to the episode row, or False if not)
        """

        # Remove old episodes in the list store
        self.clear()

        if treeview is not None:
            util.idle_add(treeview.queue_draw)

        self._all_episodes_view = getattr(channel, 'ALL_EPISODES_PROXY', False)

        # Avoid gPodder bug 1291
        if channel is None:
            episodes = []
        else:
            episodes = channel.get_all_episodes()

        if not isinstance(episodes, list):
            episodes = list(episodes)
        count = len(episodes)

        for position, episode in enumerate(episodes):
            iter = self.append((episode.url, \
                    episode.title, \
                    self._format_filesize(episode), \
                    episode, \
                    None, \
                    episode.cute_pubdate(), \
                    '', \
                    '', \
                    True, \
                    True, \
                    True, \
                    episode.length, \
                    episode.pubDate, \
                    episode.get_play_info_string(), \
                    episode.total_time and not episode.current_position, \
                    episode.total_time and episode.current_position, \
                    episode.is_locked))

            self.update_by_iter(iter, downloading, include_description, \
                    generate_thumbnails, reload_from_db=False)

        self._on_filter_changed(self.has_episodes())
        log("updated model")

        def hello():
            log("idle again")

        gtk.idle_add(hello)
Exemple #31
0
 def on_canvas_slave__routes_set(self, slave, df_routes):
     '''
     .. versionadded:: 0.11.3
     '''
     self.canvas_slave.set_surface('routes',
                                   self.canvas_slave.render_routes())
     self.canvas_slave.cairo_surface = flatten_surfaces(self.canvas_slave
                                                        .df_surfaces)
     gtk.idle_add(self.canvas_slave.draw)
Exemple #32
0
 def switch_page(self, book, gpointer, page):
     """
     Focus chatbox when page changed
     """
     pagenum = notebook.find_page(self.notebook, self.addview)
     if page == pagenum: # if switching to addition tab switch back
         current = self.notebook.get_current_page()
         gtk.idle_add(self.notebook.set_current_page, current)
     gtk.idle_add(self.chatbox.grab_focus) # grab focus after page change
Exemple #33
0
    def on_stop_all(self):
        """Stops running tasks"""
        self.indicator.set_idle()

        def timer():
            for task in self.database.get_tasks():
                if "start" in task:
                    self.database.stop_task(task.id())

        gtk.idle_add(timer)
Exemple #34
0
    def __init__ (self):
        # Init widget
        liststore = gtk.ListStore(str)
        gtk.ComboBox.__init__ (self, liststore)
        cell = gtk.CellRendererText()
        self.pack_start(cell, True)
        self.add_attribute(cell, 'text', 0)
        self.set_row_separator_func (self.__is_separator, None)

        gtk.idle_add (self.__populate)
Exemple #35
0
    def show_all(self):
        super(TaskDialog, self).show_all()

        def present():
            self.present()
            self.window.focus()
            self.grab_focus()
            self.description.grab_focus()

        gtk.idle_add(present)
Exemple #36
0
 def cmd_load_session(self, session_filename):
     f = open(session_filename, 'r')
     for line in f:
         filename = line.strip()
         def _o(filename):
             self.call('open_file', filename=filename, quiet=True)
         gtk.idle_add(_o, filename)
     lines = f.readlines()
     f.close()
     return lines
Exemple #37
0
    def cb_multi_view_controlbar_clicked_close(self, view, toolbar, name):
        if self.confirm_multi_view_controlbar_clicked_close(view):

            def closed():
                view.remove()
                self.cb_multi_view_closed(view)
                del self.__views[view.unique_id]
                #view.destroy()

            gtk.idle_add(closed)
Exemple #38
0
 def async_update(self, start, schema, paths, context):
     gtk.idle_add(self.statusbar.push, context, "Parsing schema")
     self.__set_treestore(start[0])
     gtk.idle_add(self.statusbar.push, context,
                  "Schema parsed... finding usage")
     self.__set_useage(schemausage.find_unusedset(schema, paths))
     gtk.idle_add(self.statusbar.push, context, "Usage found")
     self.__floodfill(self.treestore.get_iter_root())
     gtk.idle_add(self.statusbar.push, context, "")
     gtk.idle_add(self.treeview.set_model, self.treestore)
Exemple #39
0
 def activate(self, active=None):
     prev = self.active
     if active is None:
         self.active = not self.active
     else:
         self.active = active
     if (not prev) and self.active:
         #~ self.error("Starting The Tube clipboard player")
         gtk.idle_add(self.reset_clipboard)
         gtk.timeout_add(500, self.check_clipboard)
Exemple #40
0
    def replace_from_channel(self, channel, downloading=None, \
            include_description=False, generate_thumbnails=False, \
            treeview=None):
        """
        Add episode from the given channel to this model.
        Downloading should be a callback.
        include_description should be a boolean value (True if description
        is to be added to the episode row, or False if not)
        """

        # Remove old episodes in the list store
        self.clear()

        if treeview is not None:
            util.idle_add(treeview.queue_draw)

        self._all_episodes_view = getattr(channel, 'ALL_EPISODES_PROXY', False)

        # Avoid gPodder bug 1291
        if channel is None:
            episodes = []
        else:
            episodes = channel.get_all_episodes()

        if not isinstance(episodes, list):
            episodes = list(episodes)
        count = len(episodes)

        for position, episode in enumerate(episodes):
            iter = self.append((episode.url, \
                    episode.title, \
                    self._format_filesize(episode), \
                    episode, \
                    None, \
                    episode.cute_pubdate(), \
                    '', \
                    '', \
                    True, \
                    True, \
                    True, \
                    episode.length, \
                    episode.pubDate, \
                    episode.get_play_info_string(), \
                    episode.total_time and not episode.current_position, \
                    episode.total_time and episode.current_position, \
                    episode.is_locked))

            self.update_by_iter(iter, downloading, include_description, \
                    generate_thumbnails, reload_from_db=False)

        self._on_filter_changed(self.has_episodes())
        log("updated model")
        def hello():
        	log("idle again")
        gtk.idle_add(hello)
 def check_dirty(self):
     if self._dirty_size is not None:
         width, height = self._dirty_size
         self.set_shape(width, height)
         transform_update_required = True
     else:
         transform_update_required = False
     result = super(DmfDeviceCanvas, self).check_dirty()
     if transform_update_required:
         gtk.idle_add(self.update_transforms)
     return result
Exemple #42
0
    def auto_loop(self):
        sleep = 18
        if len(sys.argv) > 2:
            sleep = float(sys.argv[2])

        while True:
            time.sleep(sleep)
            if self.hadnuimoaction == False:
                gtk.idle_add(self.next)
            else:
                self.hadnuimoaction = False
Exemple #43
0
 def _bind_pluginviews(self):
     for service in self.boss.services:
         if service.plugin_view_type is not None:
             if service.NAME in ['buffermanager', 'projectmanager',
                                 'filemanager']:
                 self.contentview.append_page(service.plugin_view)
             else:
                 self.pluginview.append_page(service.plugin_view)
     def _s():
         self.contentview.notebook.set_current_page(0)
     gtk.idle_add(_s)
Exemple #44
0
 def on_electrode_states_set(self, states):
     if not (self.canvas_slave.electrode_states
             .equals(states['electrode_states'])):
         self.canvas_slave.electrode_states = states['electrode_states']
         self.canvas_slave.set_surface('actuated_shapes',
                                       self.canvas_slave
                                       .render_actuated_shapes())
         self.canvas_slave.cairo_surface = flatten_surfaces(self
                                                            .canvas_slave
                                                            .df_surfaces)
         gtk.idle_add(self.canvas_slave.draw)
Exemple #45
0
 def _bind_views(self):
     self._cm = ContentManager()
     self.contentview = self._cm.create_book('content')
     self.contentview.set_tab_pos(gtk.POS_RIGHT)
     self.bookview = self._cm.create_book('view')
     self.editorview = self._cm.create_book('edit')
     self.editorview.set_show_tabs(False)
     self.pluginview = self._cm.create_book('plugin')
     def _s():
         self.contentview.set_current_page(0)
     gtk.idle_add(_s)
Exemple #46
0
 def check_dirty(self):
     if self._dirty_size is not None:
         width, height = self._dirty_size
         self.set_shape(width, height)
         transform_update_required = True
     else:
         transform_update_required = False
     result = super(DmfDeviceCanvas, self).check_dirty()
     if transform_update_required:
         gtk.idle_add(self.update_transforms)
     return result
Exemple #47
0
    def show_all(self):
        super(Search, self).show_all()
        self.present()
        self.pmenu.show_all()

        def present():
            self.present()
            self.window.focus()
            self.grab_focus()
            self.query_ctl.grab_focus()

        gtk.idle_add(present)
Exemple #48
0
 def insert_number(self, entry, text, length, position, real=False):
     position = entry.get_position()
     allowed = string.digits + "." if real else string.digits
     func = self.insert_float if real else self.insert_number
     result = ''.join([c for c in text if c in allowed])
     if result != '':
         entry.handler_block_by_func(func)
         entry.insert_text(result, position)
         entry.handler_unblock_by_func(func)
         new_pos = position + len(result)
         gtk.idle_add(entry.set_position, new_pos)
     entry.stop_emission("insert_text")
Exemple #49
0
    def do_changed(self):
        operator, args = self.__pending_changes.pop()
        if operator:
            self.busy(1)
            apply(operator, (self, ) + args)

            self.set_list(self.get_all())
            self.set_sort_magic(self.__sort_fn, self.__reverse_sort)
            self.set_filter_magic(self.__filter_fn)
            gtk.idle_add(lambda x: x.busy(0), self)

        return (operator, args)
Exemple #50
0
 def on_electrode_states_updated(self, states):
     updated_electrode_states = \
         states['electrode_states'].combine_first(self.canvas_slave
                                                  .electrode_states)
     if not (self.canvas_slave.electrode_states.equals(
             updated_electrode_states)):
         self.canvas_slave.electrode_states = updated_electrode_states
         self.canvas_slave.set_surface(
             'actuated_shapes', self.canvas_slave.render_actuated_shapes())
         self.canvas_slave.cairo_surface = flatten_surfaces(
             self.canvas_slave.df_surfaces)
         gtk.idle_add(self.canvas_slave.draw)
 def on_widget__configure_event(self, widget, event):
     '''
     Handle resize of Cairo drawing area.
     '''
     # Set new target size for scaled frames from video sink.
     width, height = event.width, event.height
     self.shape = width, height
     self.video_sink.shape = width, height
     self.reset_canvas_corners()
     self.update_transforms()
     if not self._enabled:
         gtk.idle_add(self.on_frame_update, None, None)
Exemple #52
0
    def _bind_views(self):
        self._cm = ContentManager()
        self.contentview = self._cm.create_book('content')
        self.contentview.set_tab_pos(gtk.POS_RIGHT)
        self.bookview = self._cm.create_book('view')
        self.editorview = self._cm.create_book('edit')
        self.editorview.set_show_tabs(False)
        self.pluginview = self._cm.create_book('plugin')

        def _s():
            self.contentview.set_current_page(0)

        gtk.idle_add(_s)
    def run(self):
        self.lock.acquire()

        p = self.fetch_package()

        # emit the signal in the main thread.
        def emit_ready_cb(th, p):
            th.emit("ready", p)
            return 0

        gtk.idle_add(emit_ready_cb, self, p)

        self.lock.release()
Exemple #54
0
 def run(self):
     'For each iteration of the main loop, take some work from the queue.'
     while not self.shutdown:
         try:
             (function, arguments, callback, data) = queue.get(True, 0.01)
         except Empty:
             continue
         
         function(*arguments)
         
         cb_arguments = list(arguments)
         cb_arguments.append(data)
         gtk.idle_add(callback, *cb_arguments)
Exemple #55
0
def show_xvfb():
    """
    Print the pending figures only then quit, no screen draw
    """
    for manager in Gcf.get_all_fig_managers():
        manager.canvas.set_do_plot(False)
        manager.window.show()

    gtk.idle_add(_quit_after_print_xvfb)
    if gtk.pygtk_version > (2, 3, 90):
        gtk.main()
    else:
        gtk.mainloop()