def set_default_youtube_video_rate(self,widget=None): active = self.youtube_video_rate.get_active() qn = 0 ## if there s only one quality available, read it... if active == -1: if len(self.quality_list) == 1: self.youtube_video_rate.set_active(0) for frate in self.quality_list: try: rate = frate.split('|')[0] codec = frate.split('|')[1] h = int(rate.split('x')[0]) dh = int(self.youtube_max_res.split('x')[0]) if h > dh: qn += 1 continue else: if codec == 'mp4' and '%s|webm' % rate in str(self.quality_list): #qn += 1 continue self.youtube_video_rate.set_active(qn) except: continue active = self.youtube_video_rate.get_active() else: if self.quality_list: active = self.youtube_video_rate.get_active() gobject.idle_add(self.gui.quality_box.show)
def Connect(self): if not self.engine: self.bus = dbus.SessionBus() proxy = self.bus.get_object("org.synce.SyncEngine", "/org/synce/SyncEngine") self.engine = dbus.Interface(proxy, "org.synce.SyncEngine") self.engine.connect_to_signal("Synchronized", lambda: gobject.idle_add(self._OnSynchronized)) self.engine.connect_to_signal("PrefillComplete", lambda: gobject.idle_add(self._OnPrefillComplete))
def on_name_change(self, treeview): """ Called when the user selects a movie or a show from the 'name list'. """ selected_text = self.get_selected_name() self.file_model.clear() if self.get_mode() == MODE_SHOWS: self.seassons_model.clear() seassons = self.pycavane.seasson_by_show(selected_text) for i in range(1, len(seassons) + 1): # Here we're assuming that the server has the # seassons 1 to length(seassons) that could not be true. TODO #self.seassons_model.append([i]) gobject.idle_add(append_item_to_store, self.seassons_model, [i]) else: self.file_model.clear() theme = gtk.icon_theme_get_default() file_icon = theme.load_icon(gtk.STOCK_FILE, 48, 0) letter = selected_text for movie in self.pycavane.get_movies(letter): #self.file_model.append([file_icon, movie[1]]) gobject.idle_add(append_item_to_store, self.file_model, (file_icon, movie[1]))
def popup(self, t=0): parent_window = self._panel_button.get_toplevel() self.set_transient_for(parent_window) self.hide_on_leave = False self.hide_on_release = False child = self.get_child() if child is None or child is not self.content_widget: if child is not None: self.remove(child) p = self._panel_button child = self.content_widget while p is not None: if "Glade" in p.get_name(): label = "In Glade: cannot show this widget." if self.content_widget is None: label += "\n\nPanel Widget is not set.\n" label += "Please set it to a top-level widget." child = gtk.Label(label) break p = p.get_parent() self.add(child) self.show_all() def deferred_grab(): if not self.establish_grab(t): self.popdown() gobject.idle_add(deferred_grab)
def on_tab_switch(self, notebook, page, page_num, data=None): """Do the real work for a tab switch""" tabs_last_active_term = data['tabs_last_active_term'] if tabs_last_active_term: term = self.terminator.find_terminal_by_uuid(tabs_last_active_term.urn) gobject.idle_add(term.ensure_visible_and_focussed) return True
def update_gui(self, line): """Update the GUI viewer.""" try: line.decode('utf-8') except UnicodeDecodeError as exc: if self.has_warned_corrupt: return False self.has_warned_corrupt = True dialog = warning_dialog("Problem reading file:\n %s: %s" % (type(exc).__name__, exc)) gobject.idle_add(dialog.warn) return False for word, setting in self.TAGS.items(): rec, colour = setting if rec.match(line): if word not in self.tags: self.tags[word] = self.logbuffer.create_tag( None, foreground=colour) self.logbuffer.insert_with_tags( self.logbuffer.get_end_iter(), line, self.tags[word]) break else: self.logbuffer.insert(self.logbuffer.get_end_iter(), line) self.logview.scroll_to_iter(self.logbuffer.get_end_iter(), 0) return False
def on_seasson_change(self, combo): """ Called when the 'seasson' combobox changes value. This will only be fired if the 'mode' combobox is setted to 'Shows'. """ # Precondition if self.get_mode() != MODE_SHOWS: return seasson = combobox_get_active_text(combo) show = self.get_selected_name() if not seasson: return self.file_model.clear() theme = gtk.icon_theme_get_default() file_icon = theme.load_icon(gtk.STOCK_FILE, 48, 0) seasson = "Temporada " + seasson # Hopfully temporary fix for episode in self.pycavane.episodes_by_season(show, seasson): episode_name = "%.2d - %s" % (int(episode[1]), episode[2]) #self.file_model.append([file_icon, episode_name]) gobject.idle_add(append_item_to_store, self.file_model, (file_icon, episode_name))
def do_notify(self, summary, body, icon_file = None): if (icon_file == None or not os.path.isfile(icon_file)): icon_file = utils.get_ui_object(os.path.join('image','ic64_hotot.png')); icon_file = 'file://' + icon_file title = _("Hotot Notification") text = summary + '\n' + body gobject.idle_add(gtknotification.gtknotification, title, text, icon_file)
def update_file_info(self, file): if file.get_uri_scheme() != 'file': return filename = urllib.unquote(file.get_uri()[7:]) parts = filename.split('.') if len(parts) < 2: return if str.lower(parts[-1]) not in _accepted_extensions: return d = discoverer.Discoverer(filename) self._cv = threading.Condition() self._complete = False d.connect('discovered', on_discovered, self, os.stat(sys.argv[1]).st_size) gobject.idle_add(d.discover) _needed += 1 if _needed == 1: main_loop.run() self._cv.acquire() self._cv.wait() while not self._complete: self._cv.wait() self._cv.release() file.add_string_attribute('duration', self._duration) file.add_string_attribute('byte rate', self._byte_rate) if self._width: file.add_string_attribute('resolution', '{}x{}'.format(self._width, self._height))
def _check_recd_request(self, recd): #todo: add category for "not active activity, so go ahead and delete" if recd.downloadedFromBuddy: logger.debug('_meshCheckOnRecdRequest: recdRequesting.downloadedFromBuddy') if recd.meshReqCallbackId: gobject.source_remove(recd.meshReqCallbackId) recd.meshReqCallbackId = 0 return False if recd.deleted: logger.debug('_meshCheckOnRecdRequest: recdRequesting.deleted') if recd.meshReqCallbackId: gobject.source_remove(recd.meshReqCallbackId) recd.meshReqCallbackId = 0 return False if recd.meshDownloadingProgress: logger.debug('_meshCheckOnRecdRequest: recdRequesting.meshDownloadingProgress') #we've received some bits since last we checked, so keep waiting... they'll all get here eventually! recd.meshDownloadingProgress = False return True else: logger.debug('_meshCheckOnRecdRequest: ! recdRequesting.meshDownloadingProgress') #that buddy we asked info from isn't responding; next buddy! #self.meshNextRoundRobinBuddy( recdRequesting ) gobject.idle_add(self._next_round_robin_buddy, recd) return False
def _executeExploit(self, expl, vuln): '''Exploits a vulnerability. This raises a text dialog that informs how the exploit is going until it finishes. This method is going to: a) Create the TextDialog b) spawn a thread to launch the exploit process c) spawn a thread to read from the output manager queue b and c both write messages to the TextDialog. @param expl: the exploit to use @param vuln: the vulnerability to exploit ''' dlg = entries.TextDialog("Exploit!") # Start the generator that writes the messages from output manager console_task = helpers.write_console_messages(dlg) gobject.idle_add(console_task.next) # Start the generator that launches the exploit exploit_task = self._launch_exploit(dlg, expl, vuln) gobject.idle_add(exploit_task.next) return
def _focus(self, server_source, wid, modifiers): log("_focus(%s, %s, %s) has_focus=%s", server_source, wid, modifiers, self._has_focus) if self._has_focus==wid: #nothing to do! return had_focus = self._id_to_window.get(self._has_focus) def reset_focus(): log("reset_focus() %s / %s had focus", self._has_focus, had_focus) self._clear_keys_pressed() # FIXME: kind of a hack: self._has_focus = 0 self._wm.get_property("toplevel").reset_x_focus() if wid == 0: #wid==0 means root window return reset_focus() window = self._id_to_window.get(wid) if not window: #not found! (go back to root) return reset_focus() if window.is_OR(): log.warn("focus(..) cannot focus OR window: %s", window) return log("focus(%s, %s, %s) giving focus to %s", server_source, wid, modifiers, window) #using idle_add seems to prevent some focus races: gobject.idle_add(window.give_client_focus) if server_source and modifiers is not None: server_source.make_keymask_match(modifiers) self._has_focus = wid
def sleep_within_loop(duration): main_loop = gobject.MainLoop() gobject.timeout_add(duration * 1000, main_loop.quit) # NOTE: I am not sure why, but I need add this # dumb thing to run _process method of LibLarch gobject.idle_add(lambda: True) main_loop.run()
def geotag_selection(self,job,item,continue_cb,lat,lon): if item.selected: if item.thumb: from picty import imagemanip pb=imagemanip.scale_pixbuf(item.thumb,40) imagemanip.set_coords(item,lat,lon) gobject.idle_add(self.osm.add_image,lat,lon,pb)
def log_activate(self): textbuffer_err = self.w_log_errors_textview.get_buffer() textbuffer_info = self.w_log_info_textview.get_buffer() if self.is_normal_logging_setup: textbuffer_err.set_text(_("Loading ...")) textbuffer_info.set_text(_("Loading ...")) else: textbuffer_err.set_text("") textbuffer_info.set_text("") textiter = textbuffer_err.get_end_iter() textbuffer_err.insert_with_tags_by_name(textiter, _("Unable to setup log:\n"), "bold") textbuffer_err.insert(textiter, _("All errors and warnings will be logged to stderr")) textiter = textbuffer_info.get_end_iter() textbuffer_info.insert_with_tags_by_name(textiter, _("Unable to setup log:\n"), "bold") textbuffer_info.insert(textiter, _("All info messages will be logged to stdout")) self.w_log_close_button.grab_focus() self.w_view_log_dialog.show() if self.is_normal_logging_setup: gobject.idle_add(self.__load_err_view_log) gobject.idle_add(self.__load_info_view_log)
def _populateGroups(self, groups, defaultpix = None): grps = map(lambda x: self.ayum.comps.return_group(x), filter(lambda x: self.ayum.comps.has_group(x), groups)) grps.sort(ui_comps_sort) for grp in grps: if not self.ayum._groupHasPackages(grp): continue s = "<span size=\"large\" weight=\"bold\">%s</span>" % xmltrans(grp.name, grp.translated_name) fn = "/usr/share/pixmaps/comps/%s.png" % grp.groupid if os.access(fn, os.R_OK): pix = self._get_pix(fn) elif defaultpix: pix = defaultpix else: pix = None self.groupstore.append(None, [self.ayum.isGroupInstalled(grp),s,grp,pix]) tree = self.xml.get_widget("groupList") gobject.idle_add(lambda x: x.flags() & gtk.REALIZED and x.scroll_to_point(0, 0), tree) self.xml.get_widget("optionalLabel").set_text("") self.xml.get_widget("detailsButton").set_sensitive(False) # select the first group i = self.groupstore.get_iter_first() if i is not None: sel = self.xml.get_widget("groupList").get_selection() sel.select_iter(i)
def load_music_tree(self): self.perspective.hide_add_button() if not FCache().cache_music_tree_beans[0] and len(FCache().cache_music_tree_beans) == 1: self.perspective.show_add_button() self.tree.is_empty = True if FCache().tab_names[0]: self.tabhelper.label.set_label(FCache().tab_names[0] + " ") else: tabs = len(FCache().cache_music_tree_beans) self.tree.simple_append_all(FCache().cache_music_tree_beans[tabs - 1]) self.tabhelper.label.set_label(FCache().tab_names[tabs - 1] + " ") for tab in xrange(tabs - 2, -1, -1): tree = NavigationTreeControl(self) tree.simple_append_all(FCache().cache_music_tree_beans[tab]) self.tabhelper._append_tab(FCache().tab_names[tab], navig_tree=tree) if not FCache().cache_music_tree_beans[tab]: tree.is_empty = True self.perspective.show_add_button() logging.info("Tree loaded from cache") if FC().update_tree_on_start: def cycle(): for n in xrange(len(FCache().music_paths)): tab_child = self.tabhelper.get_nth_page(n) tree = tab_child.get_child() self.update_music_tree(tree, n) gobject.idle_add(cycle)
def refresh( self, limit = 20, network = True ): print 'Refreshing' tweets = [ tweet_as_tag_list( tweet ) for tweet in self.tweets( limit = limit, network = network ) ] buf = self.make_buffer() count = 0 point = buf.get_end_iter() images = [] for tweet, tag_list in tweets: if count > 0: buf.insert_tag_list( point, [ ('\n\n', 'separator') ] ) url, filename = tweet_image_filename( tweet ) if not os.path.exists( filename ): dirname = os.path.dirname( filename ) if not os.path.exists( dirname ): os.mkdir( dirname ) urllib.urlretrieve( url, filename ) mark = buf.create_mark( None, point, True ) img = res.get_usericon( filename, tweet ) img.mark = mark images.append( img ) buf.insert_tag_list( point, tag_list ) count += 1 gobject.idle_add( self.update, buf, images )
def create_HUD(self, new_hand_id, table, table_name, max, poker_game, stat_dict, cards): def idle_func(): gtk.gdk.threads_enter() try: newlabel = gtk.Label("%s - %s" % (table.site, table_name)) self.vb.add(newlabel) newlabel.show() self.main_window.resize_children() self.hud_dict[table_name].tablehudlabel = newlabel self.hud_dict[table_name].create(new_hand_id, self.config, stat_dict, cards) for m in self.hud_dict[table_name].aux_windows: m.create() m.update_gui(new_hand_id) self.hud_dict[table_name].update(new_hand_id, self.config) self.hud_dict[table_name].reposition_windows() return False finally: gtk.gdk.threads_leave() self.hud_dict[table_name] = Hud.Hud(self, table, max, poker_game, self.config, self.db_connection) self.hud_dict[table_name].table_name = table_name self.hud_dict[table_name].stat_dict = stat_dict self.hud_dict[table_name].cards = cards [aw.update_data(new_hand_id, self.db_connection) for aw in self.hud_dict[table_name].aux_windows] gobject.idle_add(idle_func)
def relayout(self): self._in_relayout = True x, y, max_h = 0, 0, 0 current_row = [] pw, ph = self._size def fixup_row(widgets, x, y, max_h): residue = (pw - x) x = int(residue/2) for widget in widgets: cw, ch = widget.size_request() self.move(widget, x, y+max(0, int((max_h-ch)/2))) x += cw + 10 for child in self.get_children(): w, h = child.size_request() if x + w > pw: fixup_row(current_row, x, y, max_h) y += max_h + 10 max_h, x = 0, 0 current_row = [] self.move(child, x, y) x += w + 10 max_h = max(max_h, h) current_row.append(child) fixup_row(current_row, x, y, max_h) self.set_size(pw, y+max_h) def unrelayout(): self._in_relayout = False return False gobject.idle_add(unrelayout)
def run(self): """Start Nex""" splash = Splash(self.appath) splash.show_all() gobject.timeout_add(1000, splash.hide) # 5*1000 miliseconds gobject.idle_add(self.setup_app) gtk.main()
def write(self, text, tag = None): buffer = self.view.get_buffer() if tag is None: buffer.insert(buffer.get_end_iter(), text) else: buffer.insert_with_tags(buffer.get_end_iter(), text, tag) gobject.idle_add(self.scroll_to_end)
def __delete_activate_be(self): not_deleted = [] not_default = None not_renamed = {} # The while gtk.events_pending(): # gtk.main_iteration(False) # Is not working if we are calling libbe, so it is required # To have sleep in few places in this function # Remove for row in self.be_list: if row[BE_MARKED]: time.sleep(0.1) result = self.__destroy_be(row[BE_NAME]) if result != 0: not_deleted.append(row[BE_NAME]) # Rename for row in self.be_list: if row[BE_NAME] != row[BE_ORIG_NAME]: time.sleep(0.1) result = self.__rename_be(row[BE_ORIG_NAME], row[BE_NAME]) if result != 0: not_renamed[row[BE_ORIG_NAME]] = row[BE_NAME] # Set active for row in self.be_list: if row[BE_ACTIVE_DEFAULT] == True and row[BE_ID] != \ self.initial_default: time.sleep(0.1) result = self.__set_default_be(row[BE_NAME]) if result != 0: not_default = row[BE_NAME] if len(not_deleted) == 0 and not_default == None \ and len(not_renamed) == 0: self.progress_stop_thread = True else: self.progress_stop_thread = True msg = "" if not_default: msg += _("<b>Couldn't change Active " "Boot Environment to:</b>\n") + not_default if len(not_deleted) > 0: if not_default: msg += "\n\n" msg += _("<b>Couldn't delete Boot " "Environments:</b>\n") for row in not_deleted: msg += row + "\n" if len(not_renamed) > 0: if not_default or len(not_deleted): msg += "\n" msg += _("<b>Couldn't rename Boot " "Environments:</b>\n") for orig in not_renamed: msg += _("%(src)s <b>to</b> " "%(targ)s\n") % \ {"src": orig, "targ": not_renamed.get(orig)} gobject.idle_add(self.__error_occurred, msg) return gobject.idle_add(self.__on_cancel_be_clicked, None)
def deferred_set_rough_geometry_hints(self): # no parameters are used in set_rough_geometry_hints, so we can # use the set_rough_geometry_hints if self.pending_set_rough_geometry_hint == True: return self.pending_set_rough_geometry_hint = True gobject.idle_add(self.do_deferred_set_rough_geometry_hints)
def show(self): if not self.widget.parent: self.parent_widget.add(self.widget) else: self.widget.reparent(self.parent_widget) self.parent_widget.child_set_property(self.widget, 'position', self.PARENT_VBOX_POSITION) self.parent_widget.child_set_property(self.widget, 'expand', True) self.widget.show() def calculate_width(): txt = self.widget.widgets['txt_features'] expander = txt.parent.parent width_col1 = self.widget.widgets['buttons']['open'].parent.get_allocation().width maxwidth = 1.8 * width_col1 screenwidth = self.widget.get_allocation().width # Preliminary width is the whole_screen - width_col1 - 30 # The "50" above is just to make sure we don't go under the # vertical scroll bar (if it is showing). width = screenwidth - width_col1 - 50 if width > maxwidth: width = int(maxwidth) txt.set_size_request(width, -1) idle_add(calculate_width)
def mainloop(self,sys_exit=0,banner=None): self._banner = banner if self.gtk.pygtk_version >= (2,4,0): import gobject gobject.idle_add(self.on_timer) else: self.gtk.idle_add(self.on_timer) if sys.platform != 'win32': try: if self.gtk.gtk_version[0] >= 2: self.gtk.gdk.threads_init() except AttributeError: pass except RuntimeError: error('Your pyGTK likely has not been compiled with ' 'threading support.\n' 'The exception printout is below.\n' 'You can either rebuild pyGTK with threads, or ' 'try using \n' 'matplotlib with a different backend (like Tk or WX).\n' 'Note that matplotlib will most likely not work in its ' 'current state!') self.IP.InteractiveTB() self.start() self.gtk.gdk.threads_enter() self.gtk_mainloop() self.gtk.gdk.threads_leave() self.join()
def run(self, floppy, havemenu, fullscreen, embed): accelgroup = None # create menu? if havemenu: # this would steal keys from embedded Hatari if not embed: accelgroup = gtk.AccelGroup() for action in self.actions.list_actions(): action.set_accel_group(accelgroup) menu = self._get_menu() else: menu = None # create toolbars toolbars = { "left":None, "right":None, "top":None, "bottom":None} for side in ("left", "right"): if side in self.toolbars: toolbars[side] = self._get_container(self.toolbars[side], False) for side in ("top", "bottom"): if side in self.toolbars: toolbars[side] = self._get_container(self.toolbars[side], True) self.callbacks.create_ui(accelgroup, menu, toolbars, fullscreen, embed) self.help.set_mainwin(self.callbacks.mainwin) self.callbacks.set_floppy(floppy) # ugly, Hatari socket window ID can be gotten only # after Socket window is realized by gtk_main() gobject.idle_add(self.callbacks.run) gtk.main()
def draw_image(self, at_bottom=False, scroll=False): """Draw the current pages and update the titlebar and statusbar. """ if not self._waiting_for_redraw: # Don't stack up redraws. self._waiting_for_redraw = True gobject.idle_add(self._draw_image, at_bottom, scroll, priority=gobject.PRIORITY_HIGH_IDLE)
def on_get_pixbuf_completed(self, entry, pixbuf, uri, tooltip_image, tooltip_text): # Set the pixbuf for the entry returned from the art db if rb.entry_equal(entry, self.current_entry): self.current_pixbuf = pixbuf if tooltip_image is None: pb = None elif tooltip_image.startswith("/"): pb = GdkPixbuf.Pixbuf.new_from_file(tooltip_image) else: f = rb.find_plugin_file (self, tooltip_image) pb = GdkPixbuf.Pixbuf.new_from_file(f) self.art_widget.set (entry, pixbuf, uri, pb, tooltip_text, False) if pixbuf: # This might be from a playing-changed signal, # in which case consumers won't be ready yet. def idle_emit_art(): shell = self.object db = shell.props.db db.emit_entry_extra_metadata_notify (entry, "rb:coverArt", pixbuf) if uri: self.emitting_uri_notify = True db.emit_entry_extra_metadata_notify (entry, "rb:coverArt-uri", uri) self.emitting_uri_notify = False return False gobject.idle_add(idle_emit_art)
def deactivateFullscreen(self): ## Deactivates the fullscreen. # Hide all the widgets, before we unfullscreen. for x in lists.hiddenFSWidgets: self.wTree.get_object(x).hide() # Unfullscreen the window when we're idle (stops weird dimensions). gobject.idle_add(self.mainWindow.unfullscreen)
def __check_cb(self, manager, unloaded_plugin_data): from gobject import idle_add idle_add(self.__check, unloaded_plugin_data) return False
def idler_add(self, func): gobject.idle_add(func)
def koniec(self, ID="none"): print "KOOOOOONIEC!" gobject.idle_add(gtk.main_quit) self.stopThread()
def _thread(): result = function(*args, **kwargs) gobject.idle_add(task_return, result)
def start(self): assert self.__idleId is None if self.__once: self.__idleId = gobject.idle_add(self._on_once) else: self.__idleId = gobject.idle_add(self.__func)
def new_function(*args, **kwargs): def async_function(): func(*args, **kwargs) return False gobject.idle_add(async_function)
def __process_timeout(self, filtered_data): from gobject import idle_add idle_add(self.__process, filtered_data) return False
def __g_progressdialog_progress_pulse(self): while not self.stop_progress_bouncing: gobject.idle_add(self.w_progressbar.pulse) time.sleep(0.1) self.stopped_bouncing_progress = True gobject.idle_add(self.w_progress_dialog.hide)
def add_callback(self, name): data = self.get_data()[self._WORKGROUP] data.append(name) self.rebuild() gobject.idle_add(self.tree.scroll_to_cell, (self._WORKGROUP, len(data) - 1))
def __quit_cb(self, *args): from gobject import idle_add idle_add(self.__destroy) return False
def __read_cb(self, *args): from gobject import idle_add idle_add(self.__read, priority=9999) return False
def __start_bouncing_progress(self): self.stop_progress_bouncing = False self.stopped_bouncing_progress = False gobject.idle_add(self.w_progress_dialog.show) Thread(target=self.__g_progressdialog_progress_pulse).start()
def update_thread_broken(self, event): tid = event.m_tid def _u(tid): self.threads.broken_thread(tid) gobject.idle_add(_u, tid)
def receiveIR(self, code): if self.settingsManager: if code == self.settingsManager.remote_playpause: gobject.idle_add(self.cb_dict['playpause'], None) if code == self.settingsManager.remote_switch_fullscreen: gobject.idle_add(self.cb_dict['fullscreen'], None) if code == self.settingsManager.remote_stop: gobject.idle_add(self.cb_dict['stop'], None) if code == self.settingsManager.remote_volumeup: gobject.idle_add(self.cb_dict['setVolume'], None, None, 0.1) if code == self.settingsManager.remote_volumedown: gobject.idle_add(self.cb_dict['setVolume'], None, None, -0.1) if code == self.settingsManager.remote_mute: gobject.idle_add(self.cb_dict['mute']) if code == self.settingsManager.remote_quit: gobject.idle_add(self.cb_dict['quit'], None) if code == self.settingsManager.remote_nextchannel: gobject.idle_add(self.cb_dict['nextChannel']) if code == self.settingsManager.remote_prevchannel: gobject.idle_add(self.cb_dict['prevChannel']) if code == self.settingsManager.remote_info: gobject.idle_add(self.cb_dict['showEPG']) if code == self.settingsManager.remote_up: gobject.idle_add(self.cb_dict['remoteUP']) if code == self.settingsManager.remote_down: gobject.idle_add(self.cb_dict['remoteDOWN']) if code == self.settingsManager.remote_ok: gobject.idle_add(self.cb_dict['remoteOK']) if code == self.settingsManager.remote_sleep: gobject.idle_add(self.cb_dict['remoteSLEEP'])
def update_namespace(self, event): def _u(): self.locals.update_namespace() self.globals.update_namespace() gobject.idle_add(_u)
def update_list(self): if self._do_update_hid is None: self._do_update_hid = gobject.idle_add(self._do_update_list)
def update_frame(self, event): index = event.m_frame_index def _u(index): self.stack.select_frame(index) gobject.idle_add(_u, index) self.update_source(-index - 1)
def update_threads(self, event): current_thread = event.m_current_thread threads_list = event.m_thread_list def _u(threads_list, current_thread): self.threads.update_threads(threads_list, current_thread) gobject.idle_add(_u, threads_list, current_thread)
def __init__(self, connection): window = gtk.Window(gtk.WINDOW_TOPLEVEL) window.connect("delete_event", self.close_application) window.set_border_width(10) window.set_property("resizable", False) window.set_property("allow_grow", True) window.set_geometry_hints(min_width=self.XSIZE, min_height=self.YSIZE, max_width=self.XSIZE, max_height=self.YSIZE) self.window = window labels_and_ranges = [("start.x", (-10, 10, 0, 0.01)), ("start.y", (-10, 10, 0, 0.01)), ("start.z", (-10, 10, 0, 0.01)), ("angle.x", (-200, 200, 0, 0.01)), ("angle.y", (-200, 200, 0, 0.01)), ("angle.z", (-200, 200, 0, 0.01)), ("scale", (-10, 10, 0.1, 0.0001)), ("distance", (-100, 100, 10, 0.01)), ("dirvec.x", (-10, 10, 0, 0.01)), ("dirvec.y", (-10, 10, 0, 0.01)), ("dirvec.z", (-10, 10, 0, 0.01)), ("steps", (0, 50000, 500, 1)), ("bisect", (0, 100, 10, 1))] # Create a table table = gtk.Table(len(labels_and_ranges) + 1 + 3 + 3 * 20, 2, True) window.add(table) for (i, (label_txt, (r_low, r_high, r_def, step_inc))) in enumerate(labels_and_ranges): page_size = 0.1 adj = gtk.Adjustment(r_def, r_low, r_high, step_inc, (r_high - r_low) / 3000.0) scale = gtk.HScale(adj) adj.connect("value_changed", self.update_value, label_txt) label = gtk.Label() label.set_text(label_txt) table.attach(label, 0, 1, i, i + 1, gtk.SHRINK | gtk.FILL, gtk.FILL, 0, 0) table.attach(scale, 1, 2, i, i + 1, gtk.EXPAND | gtk.SHRINK | gtk.FILL, gtk.FILL, 0, 0) label.show() scale.show() # Combo for surfaces pos = len(labels_and_ranges) + 2 combobox = gtk.combo_box_new_text() slist = surfaces.get() for el in slist: combobox.append_text(el) combobox.connect('changed', self.surface_combobox_changed) combobox.set_active(4) combobox.show() table.attach(combobox, 0, 2, pos - 2, pos - 1, gtk.EXPAND | gtk.SHRINK | gtk.FILL, gtk.FILL, 0, 0) print pos # text boxes for arbitrary surface for i in range(3): pos += 1 print pos text = gtk.Entry(max=300) text.set_text( "+1 0 -128 0 +2688 0 -21504 0 +84480 0 -180224 0 +212992 0 -131072 0 +32768 0 0" ) text.set_editable(True) text.show() text.param = "arb_poly." + ["x", "y", "z"][i] table.attach(text, 0, 2, pos - 2, pos - 1, gtk.EXPAND | gtk.SHRINK | gtk.FILL, gtk.FILL, 0, 0) # setup callback text.connect("activate", self.arb_poly_entry_activate, text) # screenshot button pos += 1 screenshot = gtk.Button("screenshot!") screenshot.connect("clicked", self.do_screenshot) table.attach(screenshot, 0, 1, pos - 2, pos - 1, 0, 0, 0) screenshot.show() # show table.show() window.show() import gobject gobject.idle_add(self.on_idle) window.move(1030, 50)
def update_source(self, index): def _u(index): si =StackItem(index, *self._last_stack['stack'][index]) self.source_goto(si.filename, si.linenumber) gobject.idle_add(_u, index)
(self.func, str(self.args), str(self.kwargs))) DBG(self.desc) result = func(*self.args, **self.kwargs) except errors.InvalidMemoryLocation, e: result = e except Exception, e: LOG.error("Exception running RadioJob: %s" % e) log_exception() LOG.error("Job Args: %s" % str(self.args)) LOG.error("Job KWArgs: %s" % str(self.kwargs)) LOG.error("Job Called from:%s%s" % (os.linesep, "".join(self.tb[:-1]))) result = e if self.cb: gobject.idle_add(self.cb, result, *self.cb_args) def execute(self, radio): if not self.target: self.target = radio try: func = getattr(self.target, self.func) except AttributeError, e: LOG.error("No such radio function `%s' in %s" % (self.func, self.target)) return self._execute(self.target, func)
def __create_on_idle(self, _data): from gobject import idle_add, PRIORITY_LOW self.__timer1 = idle_add(self.__create, _data, priority=PRIORITY_LOW) return False
def switch_btn(status): gobject.idle_add(indicator.switch_btn, status)
def _status(self, msg): jobs = 0 for i in dict(self.__queue): jobs += len(self.__queue[i]) gobject.idle_add(self.emit, "status", "[%i] %s" % (jobs, msg))
def agregar_items(self, elementos): self.get_toplevel().set_sensitive(False) self.permitir_select = False gobject.idle_add(self.__ejecutar_agregar_elemento, elementos)
def cal_getter(): # get cal data in thread, write it in main loop data = self.fetch_calendar() gobject.idle_add(self.update, data)
def _change_mode(self, reload_cache=True): """ Display mode changing helper. This method uses the value in self._mode to switch to a new display mode. It is responsible for hiding/showing widgets and setting the UI up correctly. :param reload_cache: Defines whether to reload the cache or not. """ self._parent.window_main.set_sensitive(False) if self._mode in [self.MODE.DOWNLOAD_LIST, self.MODE.DOWNLOAD_PKG]: self._current_items = {} self._store_map = {} LOG.debug('Changing to download mode.') self._expander.set_label(_('Show progress of individual files')) self._show_widgets('expander', 'treeview', 'progressbar', 'summary', 'status', 'window') self._hide_widgets('terminal') self._treeview.columns_autosize() if self._terminal.is_ancestor(self._scrolled): self._scrolled.remove(self._terminal) if not self._treeview.is_ancestor(self._scrolled): self._scrolled.add(self._treeview) elif self._mode == self.MODE.INSTALL: self._current_items = {} self._store_map = {} self._expander.set_label(_('Show terminal')) self._summary.set_markup('<b>%s</b>' % _('Installing updates')) LOG.debug('Changing to install mode') self._show_widgets('expander', 'terminal', 'progressbar', 'summary', 'status', 'window') self._hide_widgets('treeview') if self._treeview.is_ancestor(self._scrolled): self._scrolled.remove(self._treeview) if not self._terminal.is_ancestor(self._scrolled): self._scrolled.add(self._terminal) self._cancel_button.set_sensitive(False) elif self._mode == self.MODE.INSTALL_FINISHED: self._current_items = {} self._store_map = {} self._expander.set_label(_('Show terminal')) LOG.debug('Changing to install finished mode.') self._show_widgets('expander', 'terminal', 'progressbar', 'summary', 'status', 'window') self._hide_widgets('treeview', 'progressbar') self._cancel_button.set_sensitive(True) elif self._mode == self.MODE.HIDDEN: self._current_items = {} self._store_map = {} LOG.debug('Changing to hidden mode.') self._hide_widgets('treeview', 'progressbar', 'terminal', 'expander', 'progressbar', 'summary', 'status', 'window') if self._terminal.is_ancestor(self._scrolled): self._scrolled.remove(self._terminal) if not self._treeview.is_ancestor(self._scrolled): self._scrolled.add(self._treeview) self._parent.window_main.set_sensitive(True) self._store.clear() # Schedule cache reloading, so the main window's treeview # gets updated. def reload_cache_helper(): self._parent._application.reload_cache() return False if reload_cache: gobject.idle_add(reload_cache_helper) else: LOG.debug('Unknown mode: %d', self._mode)
def update_status(msg): gobject.idle_add(indicator.update_status, msg)
def cache_update(self, progress): def update_func(): self._progressbar.set_fraction(float(progress) / 100.0) gobject.idle_add(update_func)
self.error = False self.exception = None def start(self): try: self.res = getattr(rpc, self.method)(*self.args) except Exception, exception: self.error = True self.res = False self.exception = exception else: if not self.res: self.error = True if self.callback: # Post to GTK queue to be run by the main thread gobject.idle_add(self.process) return True def run(self, process_exception_p=True, callback=None): self.process_exception_p = process_exception_p self.callback = callback if callback: # Parent is only useful if it is asynchronous # otherwise the cursor is not updated. self.parent = get_toplevel_window() if self.parent.get_window(): watch = gtk.gdk.Cursor(gtk.gdk.WATCH) self.parent.get_window().set_cursor(watch) thread.start_new_thread(self.start, ()) return