def update_interface(self): """periodically update interface when asked""" if self.graphic: if not self.count % 10: while gtk.events_pending(): gtk.main_iteration_do(False) self.count += 1 % 10
def rotate(self, widget, clockwise): """Rotate children in this window""" self.set_pos_by_ratio = True maker = Factory() # collect all paned children in breadth-first order paned = [] child = self.get_child() # If our child is a Notebook, reset to work from its visible child if maker.isinstance(child, 'Notebook'): pagenum = child.get_current_page() child = child.get_nth_page(pagenum) if maker.isinstance(child, 'Paned'): paned.append(child) for p in paned: for child in p.get_children(): if child not in paned and maker.isinstance(child, 'Paned'): paned.append(child) # then propagate the rotation for p in paned: p.rotate(widget, clockwise) self.show_all() widget.grab_focus() while gtk.events_pending(): gtk.main_iteration_do(False) self.set_pos_by_ratio = False
def add_simfiles(self, paths): simfile_paths = [] for path in paths: simfile_paths.extend(utils.find_simfiles(path)) simfile_list = self.glade.get_object('simfiles') for path in simfile_paths: # Don't re-add simfiles that were already added already_added = False for existing_simfile in simfile_list: if path == existing_simfile[-1]: already_added = True break if already_added: break # Get metadata from the simfiles (without creating Simfile objects) metadata = {'TITLE': None, 'ARTIST': None, 'CREDIT': None} metadata_missing = len(metadata) with codecs.open(path, 'r', encoding='utf-8') as msdfile: for param in MSDParser(msdfile): if param[0].upper() in metadata: metadata[param[0].upper()] = ':'.join(param[1:]) metadata_missing -= 1 if not metadata_missing: break # We're probably not going to find any useful # parameters once we're down to the charts elif param[0].upper() == 'NOTES': break simfile_list.append([metadata['TITLE'], metadata['ARTIST'], metadata['CREDIT'], path]) while gtk.events_pending(): gtk.main_iteration_do(False)
def displayHourglass ( self ): gtkwindow = self['MEMainWindow'] gdkwindow = gtkwindow.window cursor = gtk.gdk.Cursor( gtk.gdk.WATCH ) gdkwindow.set_cursor( cursor ) while gtk.events_pending(): gtk.main_iteration_do()
def resetCursor ( self ): gtkwindow = self['MEMainWindow'] gdkwindow = gtkwindow.window cursor = gtk.gdk.Cursor( gtk.gdk.TOP_LEFT_ARROW ) gdkwindow.set_cursor( cursor ) while gtk.events_pending(): gtk.main_iteration_do()
def preview(widget, other=None): if not os.path.isfile('/lib/plymouth/renderers/x11.so'): msg_error( _("In order to be able to preview plymouth themes, you have to install plymouth-x11!" )) return output = os.popen('update-alternatives --display default.plymouth' ).read().strip() m = re.search(_('default.plymouth - (manual|auto) mode'), output) if m == None: ns.window.get_widget("window3").show() return mode = m.group(1) if mode == _('auto'): ns.window.get_widget("window3").hide() while gtk.events_pending(): gtk.main_iteration_do() os.system("plymouth-preview") ns.window.get_widget("window3").show() else: model, treeiter = ns.window.get_widget( "treeview1").get_selection().get_selected() if treeiter == None: msg_error(_("Please, select a theme!")) return theme = model.get(treeiter, 1)[0] ns.window.get_widget("window3").hide() while gtk.events_pending(): gtk.main_iteration_do() output = os.popen( 'update-alternatives --display default.plymouth').read( ).strip() m = re.search(_('default.plymouth - (manual|auto) mode'), output) if m == None: ns.window.get_widget("window3").show() return mode = m.group(1) m = re.search(_('link\s*currently\s*points\s*to\s*(.*)'), output) if m == None: ns.window.get_widget("window3").show() return link = m.group(1) os.system('update-alternatives --set default.plymouth "%s"' % theme) os.system("plymouth-preview") ns.window.get_widget("window3").show() if mode == _('auto'): os.system('update-alternatives --auto default.plymouth') else: os.system( 'update-alternatives --set default.plymouth "%s"' % link)
def open_clicked(self, widget, event=None, data=None): mrz1 = self.main_window_xml.get_widget("mrz_entry1").get_text() mrz2 = self.main_window_xml.get_widget("mrz_entry2").get_text() mrz = [e.strip().upper().replace(";","<") for e in mrz1, mrz2] self.clear_display() self.main_window_xml.get_widget("mrz_entry1").set_text(mrz[0]) self.main_window_xml.get_widget("mrz_entry2").set_text(mrz[1]) while gtk.events_pending(): gtk.main_iteration_do(block=False) if self.card_factory: try: card_object = self.card_factory.connect() card = cards.new_card_object(card_object) cards.generic_card.DEBUG = False print >>sys.stderr, "Using %s" % card.DRIVER_NAME p = cards.passport_application.Passport.from_card(card, mrz) self.set_passport(p) except KeyboardInterrupt,SystemExit: raise except: import traceback
def r_start(self, *args): try: self.glosR except AttributeError: if not self.r_load(): return False #if len(self.glosR)==0: # log.error('Input glossary has no word! Be sure to click "Load" before "Start", or just click "Apply" instead.') # return oPath = self.entry_r_o.get_text() if not oPath: log.critical('Output file path is empty!');return self.progress(0.0, 'Starting....') self.pref_rev_update_var() self.pref['savePath']=oPath while gtk.events_pending(): gtk.main_iteration_do(False) self.rWords = self.glosR.takeOutputWords() self.assert_quit=True #revTh = thread.start_new_thread(self.glosR.reverseDic, (self.rWords, self.pref)) self.xml.get_widget('image_r_d').set_from_stock('gtk-media-pause', 'button') self.xml.get_widget('label_r_d').set_text('Stop') self.entry_r_i.set_editable(False) self.entry_r_o.set_editable(False) self.xml.get_widget('button_r_i').set_sensitive(False) self.xml.get_widget('button_r_load').set_sensitive(False) self.xml.get_widget('button_r_o').set_sensitive(False) self.xml.get_widget('vbox_options').set_sensitive(False) log.info('Number of input words:', len(self.rWords)) log.info('Reversing glossary...') self.glosR.reverseDic(self.rWords, self.pref) while True:## FIXME #while not self.reverseStop: while gtk.events_pending(): gtk.main_iteration_do(False)
def r_load(self, *args): iPath = self.entry_r_i.get_text() formatD = self.combobox_r_i.get_active_text() if not iPath: log.critical('Input file path is empty!') return False if not formatD: log.critical('Input format is empty!') return False log.info('Reading from %s, please wait...'%formatD) format = Glossary.descFormat[formatD] self.glosR = Glossary(ui=self) while gtk.events_pending(): gtk.main_iteration_do(False) t0 = time.time() self.glosR.read(iPath, format=format) log.debug('time left = %3f seconds'%(time.time()-t0)) for x in self.glos.info: log.info('%s="%s"'%(x[0], x[1])) #self.glosR.faEdit() self.glosR.uiEdit() #self.riFormat = format #self.riPath = iPath log.info('reading %s file: "%s" done.\n%d words found.'%( formatD, iPath, len(self.glosR), )) self.assert_quit = False return True
def convert_clicked(self, *args): #if self.assert_quit: # log.error('Can not convert glossary, because another operation is running. '+\ # 'Please open a new PyGlossary window, or wait until that operation be completed.') # return False if len(self.glos)==0: log.error('Input glossary has no word! Be sure to click "Load" before "Convert", '+\ 'or just click "Apply" instead.') return False oPath = self.entry_o.get_text() if not oPath: log.critical('Output file path is empty!');return formatD = self.combobox_o.get_active_text() if not formatD: log.critical('Output format is empty!');return log.info('Converting to %s, please wait...'%formatD) while gtk.events_pending(): gtk.main_iteration_do(False) self.assert_quit=True format = Glossary.descFormat[formatD] t0=time.time() if format=='Omnidic': dicIndex=self.xml.get_widget('spinbutton_omnidic_o').get_value_as_int() self.glos.writeOmnidic(oPath, dicIndex=dicIndex) elif format=='Babylon': encoding = self.xml.get_widget('comboentry_enc').get_active_text() self.glos.writeBabylon(oPath, encoding=encoding) else: self.glos.write(oPath, format=format) #self.oFormat = format self.oPath = oPath log.info('writing %s file: "%s" done.'%(format, oPath)) log.debug('time left = %3f seconds'%(time.time()-t0)) self.assert_quit=False return True
def _close(self, close_provider=False): """Run tasks for "closing" the currently opened file(s).""" if self.file_loaded or self.file_loading: if close_provider: self._file_provider = None self.update_last_read_page() if self.archive_type is not None: self._extractor.close() self._window.imagehandler.cleanup() self.file_loaded = False self.file_loading = False self.archive_type = None self._current_file = None self._base_path = None self._stop_waiting = True self._comment_files = [] self._name_table.clear() self.file_closed() # Catch up on UI events, so we don't leave idle callbacks. while gtk.events_pending(): gtk.main_iteration_do(False) tools.garbage_collect() if self._tmp_dir is not None: self.thread_delete(self._tmp_dir) self._tmp_dir = None
def editor_open(self, *args): step = 1000 fcd = FileChooserDialog(self, action='open') fcd.run() if not self.path: return self.editor_path = self.path self.fcd_dir = os.path.dirname(self.path) self.path = '' text = open(self.editor_path).read() self.path = '' t_table = gtk.TextTagTable() tag = gtk.TextTag('output') t_table.add(tag) self.editor_buffer = gtk.TextBuffer(t_table) self.textview_edit.set_buffer(self.editor_buffer) self.assert_quit = True size=len(text) if size < step: self.editor_buffer.set_text(text) else: self.editor_buffer.set_text(text[:step]) while gtk.events_pending(): gtk.main_iteration_do(False) i = step while i < size-step: self.editor_buffer.insert(self.editor_buffer.get_end_iter(), text[i:i+step]) i += step while gtk.events_pending(): gtk.main_iteration_do(False) self.editor_buffer.insert(self.editor_buffer.get_end_iter(), text[i:])
def refresh_gui(self,delay=0.0001,wait=0.0001): time.sleep(delay) while gtk.events_pending(): gtk.main_iteration_do(block=False) time.sleep(wait)
def startGUI(self): time.sleep(0.5) gtk.main_iteration_do() time.sleep(0.5) while self.running: # gtk.main() #probably not launched before. Launching gtk.main gtk.main()
def save(self, widget=None): self.window.set_cursor(gdk.Cursor(gdk.WATCH)) while gtk.events_pending(): gtk.main_iteration_do(False) path = self.fcw.get_filename() if path in (None, ''): return print 'Exporting to html file "%s"'%path i = self.combo.get_active() months = [] module = core.modules[core.primaryMode] if i==0: s = getCurrentMonthStatus() months = [s] title = '%s %s'%(core.getMonthName(core.primaryMode, s.month, s.year), _(s.year)) elif i==1: for i in xrange(1, 13): months.append(getMonthStatus(ui.cell.year, i)) title = '%s %s'%(_('Calendar'), _(ui.cell.year)) elif i==2: (y0, m0) = self.ymBox0.get_value() (y1, m1) = self.ymBox1.get_value() for ym in xrange(y0*12+m0-1, y1*12+m1): (y, m) = divmod(ym, 12) m += 1 months.append(getMonthStatus(y, m)) title = _('Calendar') exportToHtml(path, months, title) self.window.set_cursor(gdk.Cursor(gdk.LEFT_PTR)) self.hide()
def run(self): self.salir = False time_inicio = time.time() while not self.salir and ((time.time()-time_inicio) < self.MAX_SEGS_LOADING): gtk.main_iteration_do(False) self.destroy()
def response(widget, response_id): if response_id != gtk.RESPONSE_APPLY: gtk.main_quit() else: i=0 n=1000 progress = dialog.get_data("progress") progress.set_text("Calculating....") progress.grab_add() while True: sleep(0.005) progress.set_fraction(i/(n - 1.0)) i += 1 print i while gtk.events_pending(): gtk.main_iteration_do(False) if i == 500: break progress.set_fraction(0.0) progress.set_text("") progress.grab_remove()
def flush(self): rv = self.cout.getvalue() if rv: self.write(rv) self.cout.truncate(0) while gtk.events_pending(): gtk.main_iteration_do(False)
def clear_database(self, widget): """ Czyści bazę danych i usuwa wszystkie pobrane obrazki """ self.lblInfo.set_text('Usuwanie...') while gtk.events_pending(): gtk.main_iteration_do(True) self.database.connect() for file in self.database.get_images(): try: os.remove(file[1]) except OSError: pass self.database.clear_database() self.database.disconnect() self.refreshImagesTableAndShowThem() self.refreshImagesCount() self.refreshPages() md = gtk.MessageDialog( self, gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_INFO, gtk.BUTTONS_CLOSE, "Wszystkie grafiki zostały usunięte!") md.run() md.destroy() self.lblInfo.set_text('') self.refreshPages()
def startGUI(self): time.sleep(0.5) gtk.main_iteration_do() time.sleep(0.5) while self.running: #gtk.main() #probably not launched before. Launching gtk.main gtk.main()
def run(self, run_next_task=True): # play modem sound? if self.common.settings['modem_sound']: def play_modem_sound(): try: import pygame pygame.mixer.init() sound = pygame.mixer.Sound(self.common.paths['modem_sound']) sound.play() time.sleep(10) except ImportError: md = gtk.MessageDialog(None, gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_WARNING, gtk.BUTTONS_CLOSE, _("The python-pygame package is missing, the modem sound is unavailable.")) md.set_position(gtk.WIN_POS_CENTER) md.run() md.destroy() t = threading.Thread(target=play_modem_sound) t.start() # hide the TBL window (#151) if hasattr(self, 'window'): self.window.hide() while gtk.events_pending(): gtk.main_iteration_do(True) # run Tor Browser subprocess.call([self.common.paths['tbb']['start']], cwd=self.common.paths['tbb']['dir_tbb']) if run_next_task: self.run_task()
def convert(self): if not self.BGL.open(): print 'Error in Reading bgl file !\n' return False self.BGL.ReadBglHeader() dbname = os.path.splitext(self.bglFileName)[0] dbname = os.path.split(dbname)[1] ### Converting while True: data = self.BGL.readWord() # Error or EOF if data == False : break elif data == None or data[0] == '' or data[1] == '': continue else: if self.SDB.insert(data[0],data[1]) == True: self.progress.pulse() self.counter+=1 print self.counter buff = " %d Words added." % (self.counter) self.bar.push(0,buff) while gtk.events_pending(): gtk.main_iteration_do(False) self.BGL.close() print '\nOk! %d word converted from %s to %s !\n'%(self.counter, self.bglFileName, self.SDB.sqlFile)
def clock(): for i in range(256): if i%4!=255%4: continue self.adjm.set_value(currentValue * 1/(math.expm1(1))*math.expm1((255-i)/256.0)) while gtk.events_pending(): gtk.main_iteration_do(False) time.sleep(10/1000.0)
def dlProgress(count, blockSize, totalSize): global updating_step1 percent = int(count * blockSize * 100 / totalSize) total = str(round(totalSize / 1024 / 1024.0 * 10) / 10.0) updating_step1.set_text("1. " + _("Downloading") + " (%s Мб)... %d%%" % (total, percent)) # перерисовка окна while gtk.events_pending(): gtk.main_iteration_do(True)
def refresh_gui(delay=0): """ Emulates GTK applicaiton main loop event handler in synchronous way """ while gtk.events_pending(): gtk.main_iteration_do(block=False) time.sleep(delay)
def update_progress(self, percent, what): self.p.set_text(what) if percent: self.p.set_fraction(percent / 100.0) else: self.p.set_fraction(0) while gtk.events_pending(): gtk.main_iteration_do(block=False)
def load_image(self, image_path): if image_path: pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(image_path, self.get_size()[0] - 50, self.get_size()[1] - 50) self.image.set_from_pixbuf(pixbuf) while gtk.events_pending(): gtk.main_iteration_do(True) else: logger.debug("Splash screen image path is None")
def usleep(msec): got_clock = time.clock() + float(msec) / 1000 #print got_clock while True: if time.clock() > got_clock: break gtk.main_iteration_do(False)
def update_progress(self, percent, what): self.p.set_text(what) if percent: self.p.set_fraction(percent/100.0) else: self.p.set_fraction(0) while gtk.events_pending(): gtk.main_iteration_do(block=False)
def set_text(self, text): self.label.set_text(text) # include this to give more time to watch # import time # time.sleep(1) while gtk.events_pending(): gtk.main_iteration_do(True) return
def progress(self, rat, text=None): (stderr, sys.stderr) = (sys.stderr, sys.__stderr__) if not text: text = '%%%d%s'%(rat*100, self.ptext) self.progressbar.update(rat) self.progressbar.set_text(text) while gtk.events_pending(): gtk.main_iteration_do(False) sys.stderr = stderr
def clock(): for i in range(0, 256): if i%5!=255%5: continue i = i+currentValue-currentValue/255.0*i self.adjm.set_value(1/(math.expm1(1))*math.expm1((i)/255.0)) while gtk.events_pending(): gtk.main_iteration_do(False) time.sleep(10/1000.0)
def IniReadFile(self, Path): #Avvia come un nuovo Thread la funzione ReadFile() while gtk.events_pending(): gtk.main_iteration_do() Reader = ReadFile(Path) Reader.start()
def _pack_archive(self, archive_path): """Create a new archive with the chosen files.""" self.set_sensitive(False) self._window.set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH)) while gtk.events_pending(): gtk.main_iteration_do(False) image_files = self._image_area.get_file_listing() comment_files = self._comment_area.get_file_listing() try: fd, tmp_path = tempfile.mkstemp( suffix='.%s' % os.path.basename(archive_path), prefix='tmp.', dir=os.path.dirname(archive_path)) # Close open tempfile handle (writing is handled by the packer) os.close(fd) fail = False except: fail = True if not fail: packer = archive_packer.Packer(image_files, comment_files, tmp_path, os.path.splitext(os.path.basename(archive_path))[0]) packer.pack() packing_success = packer.wait() if packing_success: # Preserve permissions if currently edited files come from an archive if (self._window.filehandler.archive_type is not None and os.path.exists(self._window.filehandler.get_path_to_base())): mode = os.stat(self._window.filehandler.get_path_to_base()).st_mode else: mode = os.stat(tmp_path).st_mode # Remove existing file (Win32 fails on rename otherwise) if os.path.exists(archive_path): os.unlink(archive_path) os.rename(tmp_path, archive_path) os.chmod(archive_path, mode) _close_dialog() else: fail = True self._window.set_cursor(None) if fail: dialog = message_dialog.MessageDialog(self._window, 0, gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE) dialog.set_text( _("The new archive could not be saved!"), _("The original files have not been removed.")) dialog.run() self.set_sensitive(True)
def close(self): ''' Things to do before the plugin closes. ''' # don't close the plugin until we have finished writing while True: if not self.write_in_progress: break gtk.main_iteration_do(True)
def repairDatabaseNow(self, sender): msg = _("Please wait...") self.msgbox = gtk.MessageDialog(self.window, gtk.DIALOG_MODAL, gtk.MESSAGE_INFO, gtk.BUTTONS_NONE, msg) self.msgbox.set_title(_("Repairing database")) self.msgbox.show_all() while gtk.events_pending(): gtk.main_iteration_do(False) gobject.timeout_add(1000, self.repairDbFunc)
def on_button_release(self, widget, event): """Handle button presses on a Pane""" if event.button == 1: if self.last_balance_time > (time.time() - 1): # Dumb loop still needed, or some terms get squished on a Super rebalance for i in range(3): while gtk.events_pending(): gtk.main_iteration_do(False) self.do_redistribute(*self.last_balance_args) return False
def change_page(self, widget): """ Jeśli zmienimy wyświetlaną stronę, odświeżamy listę obrazków """ if self.refresh_all == True and self.cmbPages.get_active_text() != None: self.lblInfo.set_text("Wczytywanie...") while gtk.events_pending(): gtk.main_iteration_do(True) self.refreshImagesTableAndShowThem() self.lblInfo.set_text("")
def emit(self, record): try: msg = self.format(record) fs = "%s\n" self.tbf.insert(self.tbf.get_end_iter(), fs % msg) self.tv.scroll_mark_onscreen(self.tbf.get_insert()) while gtk.events_pending(): gtk.main_iteration_do(False) except: self.handleError(record)
def split_axis(self, widget, vertical=True, cwd=None, sibling=None, widgetfirst=True): """Split the axis of a terminal inside us""" dbg('called for widget: %s' % widget) order = None page_num = self.page_num(widget) if page_num == -1: err('Notebook::split_axis: %s not found in Notebook' % widget) return label = self.get_tab_label(widget) self.remove(widget) maker = Factory() if vertical: container = maker.make('vpaned') else: container = maker.make('hpaned') self.get_toplevel().set_pos_by_ratio = True if not sibling: sibling = maker.make('terminal') sibling.set_cwd(cwd) sibling.spawn_child() if widget.group and self.config['split_to_group']: sibling.set_group(None, widget.group) if self.config['always_split_with_profile']: sibling.force_set_profile(None, widget.get_profile()) self.insert_page(container, None, page_num) self.set_tab_reorderable(container, True) self.set_tab_label(container, label) self.show_all() order = [widget, sibling] if widgetfirst is False: order.reverse() for terminal in order: container.add(terminal) self.set_current_page(page_num) self.show_all() while gtk.events_pending(): gtk.main_iteration_do(False) self.get_toplevel().set_pos_by_ratio = False gobject.idle_add(terminal.ensure_visible_and_focussed)
def pref_rev_update_gui(self): self.xml.get_widget('checkb_mw').set_active(self.pref['matchWord']) for i in xrange(len(self.showRelItems)): if self.showRelItems[i]==self.pref['showRel']: self.combobox_sr.set_active(i) self.xml.get_widget('spinbutton_autosave').set_value(self.pref['autoSaveStep']) self.xml.get_widget('spinbutton_minrel').set_value(self.pref['minRel']*100.0) self.xml.get_widget('spinbutton_maxnum').set_value(self.pref['maxNum']) self.xml.get_widget('checkb_defs').set_active(self.pref['includeDefs']) while gtk.events_pending(): gtk.main_iteration_do(False)
def run(self, run_next_task=True): # don't run if it isn't at least the minimum version if not self.check_min_version(): message = _( "The version of Tor Browser you have installed is earlier than it should be, which could be a sign of an attack!" ) print message md = gtk.MessageDialog(None, gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_WARNING, gtk.BUTTONS_CLOSE, _(message)) md.set_position(gtk.WIN_POS_CENTER) md.run() md.destroy() return # play modem sound? if self.common.settings['modem_sound']: def play_modem_sound(): try: import pygame pygame.mixer.init() sound = pygame.mixer.Sound( self.common.paths['modem_sound']) sound.play() time.sleep(10) except ImportError: md = gtk.MessageDialog( None, gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_WARNING, gtk.BUTTONS_CLOSE, _("The python-pygame package is missing, the modem sound is unavailable." )) md.set_position(gtk.WIN_POS_CENTER) md.run() md.destroy() t = threading.Thread(target=play_modem_sound) t.start() # hide the TBL window (#151) if hasattr(self, 'window'): self.window.hide() while gtk.events_pending(): gtk.main_iteration_do(True) # run Tor Browser subprocess.call([self.common.paths['tbb']['start']], cwd=self.common.paths['tbb']['dir_tbb']) if run_next_task: self.run_task()
def main(onexit=None): try: while go: guilock.acquire() gtk.main_iteration_do(False) skipsleep = gtk.events_pending() guilock.release() if not skipsleep: time.sleep(0.01) finally: if onexit != None: onexit()
def run_neat(self, *args): #Create a gtkInvisible dialog to block until up2date is complete i = gtk.Invisible() i.grab_add() #Run rhn_register so they can register with RHN pid = start_process("/usr/bin/system-config-network") # get the x window id xid = None round = 0 # keep trying for 3 seconds while xid is None and round < 3: rc, out = commands.getstatusoutput('xwininfo -name' \ ' "Network Configuration" -int') pattern = re.compile("xwininfo:\sWindow\sid:\s(?P<xid>\d+)\s.*") for line in out.splitlines(): m = pattern.match(line) if m: xid = long(m.group("xid")) round += 1 time.sleep(1) # if we have the xid, embed the window if xid is not None: network_dlg = gtk.gdk.window_foreign_new(xid) self.parent.win.realize() network_dlg.set_transient_for(self.parent.win.window) network_dlg.set_modal_hint(True) # XXX if we keep the main window fullscreen, # and use alt+tab, the network window is gone forever self.parent.win.unfullscreen() flag = None while not flag: while gtk.events_pending(): gtk.main_iteration_do() child_pid, status = os.waitpid(pid, os.WNOHANG) if child_pid == pid: flag = 1 else: time.sleep(0.1) # make the main window fullscreen again self.parent.win.fullscreen() i.grab_remove() self.updateLabels()
def on_entry1_changed(self, widget): #self.window1.get_widget("window1").get_window().set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH)) while gtk.events_pending(): gtk.main_iteration_do() video_url = self.window1.get_widget("entry1").get_text() self.downloader = None if not video_url: self.window1.get_widget("label2").hide() self.window1.get_widget("button1").set_sensitive(False) else: for plugin in viget.available: d = plugin(video_url) if d.detect(): self.downloader = d break if self.downloader: self.downloader.get_title() self.window1.get_widget("label2").set_text(self.downloader.website) self.window1.get_widget("label2").show() self.window1.get_widget("button1").set_sensitive(True) self.window1.get_widget("entry1").hide() self.window1.get_widget("hbox2").show() self.window1.get_widget( "label5").set_text(self.downloader.title if self.downloader. title else _('Unknown Title')) formats = [] if self.downloader.get_video_url(): for row in self.downloader.video_urls: formats.append(row[0]) self.combobox_populate(self.window1.get_widget("combobox1"), formats, 0) self.downloader.get_subtitles() if self.downloader.subs: self.window1.get_widget("checkbutton1").show() self.window1.get_widget("checkbutton1").set_active(True) else: self.window1.get_widget("checkbutton1").hide() self.window1.get_widget("checkbutton1").set_active(False) else: self.combobox_populate(self.window1.get_widget("combobox1"), [], 0) if video_url: self.window1.get_widget("label2").set_markup( '<span color="red">' + _('Invalid URL!') + '</span>') self.window1.get_widget("label2").show() self.window1.get_widget("button1").set_sensitive(False) self.window1.get_widget("checkbutton1").hide()
def on_button10_clicked(self, widget): dialog = gtk.FileChooserDialog( title=_("Select image..."), action=gtk.FILE_CHOOSER_ACTION_OPEN, buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN, gtk.RESPONSE_OK)) dialog.set_default_response(gtk.RESPONSE_OK) dialog.set_current_folder(self.working_dir) response = dialog.run() if response == gtk.RESPONSE_OK: now = datetime.datetime.now() filename = dialog.get_filename() self.working_dir = os.path.dirname(filename) name, ext = os.path.splitext(filename) grub_bg = "/etc/remastersys/grub" + ext shutil.copy(filename, grub_bg) dialog.destroy() grub = open('/etc/default/grub').read() m = re.search('(#?)GRUB_BACKGROUND=.*', grub) if m != None: grub.replace(m.group(0), 'GRUB_BACKGROUND="%s"' % grub_bg) else: grub += '\nGRUB_BACKGROUND="%s"' % grub_bg f = open('/etc/default/grub', 'w+') f.write(grub) f.close() msg_info( _("%(filename)s has been copied to %(grub_bg)s and is the default background for grub. Click OK to update grub with the new settings so you can see your picture on the next boot." ) % ({ 'filename': filename, 'grub_bg': grub_bg })) self.window1.get_widget("label17").hide() self.window1.get_widget("progressbar1").show() process = subprocess.Popen(['update-grub'], stdout=subprocess.PIPE, stderr=None) while process.poll() == None: while gtk.events_pending(): gtk.main_iteration_do() time.sleep(.1) self.window1.get_widget("progressbar1").pulse() process.wait() self.window1.get_widget("progressbar1").hide() self.window1.get_widget("label17").show() msg_info(_("GRUB has been updated.")) else: dialog.destroy()