Beispiel #1
0
 def carga_modelo(self):
     if self.obj != None:
         self.modelo.clear()
         if self.get_all:
             func =self.obj.select_all
         else:
             func = self.obj.select_criterial
         #dlg = dlgBarraProgreso()
         #dlg.set_progreso(0)
         s = muestra_splash("Cargando")
         while gtk.events_pending():
                 gtk.mainiteration(False)
         r = func(self.obj)
         
         #max=len(r)
         #cont=1
         for i in [(eval("i.get_desc_%s()"%(self.obj.table)),eval("i.get_cod_%s()"%(self.obj.table))) for i in r]:
             #cod =i[1]
             self.modelo.append(i)
             #Barra Progreso
             #dlg.set_progreso(cont / float(max))
             while gtk.events_pending():
                 gtk.mainiteration(False)
             #cont = cont +1
         #if len(self.modelo)==1 :
             #self.set_cod(cod)
         s.destroy()
Beispiel #2
0
    def startpan_cb(self, *args):
        if self.playing == 1:
            print 'already panning- left click to stop'
            return

        for view in self.app.view_manager.view_list:
            if view.title == args[1]:
                self.app.view_manager.set_active_view(view)
                self.view = view.viewarea
                self.viewwin = view

        xmin, ymin, xmax, ymax = self.view.get_extents()
        xwidth = xmax - xmin
        ywidth = ymax - ymin
        self.id = self.viewwin.connect('button-release-event', self.stoppan_cb)
        self.playing = 1

        self.xmin, self.ymin, self.xwidth, self.ywidth = xmin, ymin, xwidth, ywidth

        self.set_speed(0.01)
        self.view.fit_extents(self.centers[0][0], self.centers[0][1],
                              xwidth / 8, ywidth / 8)

        while self.playing == 1:
            self.view.set_translation(self.centers[self.idx][0],
                                      self.centers[self.idx][1])
            self.idx = self.idx + 1
            if self.idx > len(self.centers) - 1:
                self.idx = 0

            while gtk.events_pending():
                gtk.mainiteration()
Beispiel #3
0
 def bufferInsert(widget, event, *args):
     end = widget.get_iter_at_mark(widget.get_insert())
     start = end.copy()
     start.backward_chars(args[1])
     widget.apply_tag(green, start, end)
     view.queue_draw()
     gtk.mainiteration()
    def __initIcons(self):
        if self.icons_loaded:
            return
        i = 0
        self.buttons = []
        self.err_msg=[] # added 4/25/2003, be quiet about image problems, but report errors later, Erica Andrews
        first_butt = None
        picturelist = self.getPictureList()
        size = len(picturelist)
        self.progressbar.set_fraction(0.0)
        self.progressbar.set_text(_("Loading")+" "+str(size)+" "+_("images...please wait.") )
        buttongroup = self.__addButton(None, "-", "-", None, None)
        if picturelist:
            for name, val in picturelist:
                i = i + 1
                self.progressbar.set_fraction(float(i)/size)
                while gtk.events_pending():
                    gtk.mainiteration()
                if len(val) == 3:
                    filename, pix, mask = val
                elif type(val) == type(""):
                    filename, pix, mask = val, None, None
                else:
                    filename, pix, mask = val[0], None, None
#DJM                try:
                self.__addButton(buttongroup, name, filename, pix, mask)
#DJM                except:
#DJM                    pass
        self.icons_loaded = 1
        self.__fillTable()
        self.__setSelectedIcon(None)
        self.progressbar.set_fraction(0.0)
        del picturelist
        if len(self.err_msg)>0:
            msg_warn("IceMe", _("There were some errors.")+"\n"+"\n".join(self.err_msg))
Beispiel #5
0
    def startpan_cb(self, *args):
        if self.playing == 1:
            print 'already panning- left click to stop'
            return

        for view in self.app.view_manager.view_list:
            if view.title == args[1]:
                self.app.view_manager.set_active_view(view)
                self.view = view.viewarea
                self.viewwin = view

        xmin,ymin,xmax,ymax = self.view.get_extents()
        xwidth = xmax-xmin
        ywidth = ymax-ymin
        self.id=self.viewwin.connect('button-release-event',self.stoppan_cb)
        self.playing = 1

        self.xmin,self.ymin,self.xwidth,self.ywidth=xmin,ymin,xwidth,ywidth

        self.set_speed(0.01)       
        self.view.fit_extents(self.centers[0][0],self.centers[0][1],
                              xwidth/8,ywidth/8)

        while self.playing == 1:
            self.view.set_translation(self.centers[self.idx][0],
                                      self.centers[self.idx][1])
            self.idx = self.idx+1
            if self.idx > len(self.centers)-1:
                self.idx = 0

            while gtk.events_pending():
                gtk.mainiteration()
Beispiel #6
0
    def executar(self, widget=None):
        '''Executa o código abaixo'''

        # Carrega a classe 'BarraProgresso'
        barra = minhabarra.BarraProgresso()
        barra.texto = "Começando o Processo..."

        # Muda a variável registro da classe 'BarraProgresso'
        barra.registro = 0

        # Muda a variável total_registro da classe 'BarraProgresso'
        barra.total_registro = 15000

        # Desenha os widgets da classe 'BarraProgresso'
        barra.desenhar()

        # Loop ilustrativo, mas poderia ser uma lista de clientes
        for i in range(barra.total_registro):

            # Depuração do código
            print "Estou no for imprimindo %s\n" % i

            # Mostra mais informação ao usuário
            barra.texto = "Estou Processando o Cliente '%05d'" % barra.registro

            # Muda novamente a variavel registro, ou melhor, acrescenta +1 na variável
            barra.registro += 1

            # Pausa o processo e espera a execução do "Timer"
            gtk.mainiteration()
Beispiel #7
0
    def layGrid(self, w, h):

        for i in range(self.MAP_X):
            for j in range(self.MAP_Y):
                gtk.mainiteration()
                self.engine.simTick()
                # vertical road
                if ((i + 4) % w == 0):
                    self.doTool(i, j, 'Road')
                    if ((j + 1) % h in [1, h - 1]) and \
                            j not in [0, self.MAP_Y -1]:
                        self.doTool(i, j, 'Wire')
                # horizontal roads
                elif ((j + 1) % h == 0):
                    self.doTool(i, j, 'Road')
                    if ((i + 4) % w in [1, w - 1]) and \
                            i not in [0, self.MAP_X - 1]:
                        self.doTool(i, j, 'Wire')
                # random zones
                elif ((i + 2 - (i + 4) // w) % 3) ==0 and \
                     ((j + 2 - (j + 1) // h) % 3) ==0:

                    tool_i = random.randint(0, 3 - 1)
                    self.doTool(i, j,
                                ['Residential', 'Commercial',
                                 'Industrial'][tool_i])
    def _doChoose(self, found, entry):
        # arma un liststore
        self._store = gtk.ListStore(
            gobject.TYPE_PYOBJECT,
            *[gobject.TYPE_STRING for i in self._entries])
        # set sort if needed
        if self._sortcol is not None:
            self._store.set_sort_column_id(*self._sortcol)
        # set model
        self._treeview.set_model(self._store)
        # build ui
        self._dia.set_parent_window(self.getWindow()._obj.window)
        self._response = None
        self._dia_ok_button.set_sensitive(False)
        self._dia.show_all()
        gtk.gdk.set_xcursor(self._dia.window, "left_ptr_watch")

        finder = entry.getFinder()
        entries = self._entries
        tot = found[0]
        got = 0
        n = 0
        self._progress.set_fraction(0)
        self._treeview.set_enable_search(False)
        self._treeview.set_headers_clickable(False)
        # fill the grid
        while tot > got and self._response is None:
            gtk.mainiteration()
            chunk = finder.fetchSlice(found, n)
            n += 1
            got += len(chunk)
            if not self._response:
                for i in chunk:
                    self._store.append(
                        [i] + [f.getFinder().getter(i) for f in entries])
                    gtk.mainiteration()
            self._progress.set_fraction(1.0 * got / tot)
        self._treeview.set_headers_clickable(True)
        self._treeview.set_enable_search(True)
        self._dia.window.set_cursor(None)

        rv = self._response or self._dia.run()
        self._dia.hide_all()
        sortcol = self._store.get_sort_column_id()
        if sortcol[0] >= 0:
            self._sortcol = sortcol
        else:
            self._sortcol = None
        self._store = None
        if rv == gtk.RESPONSE_OK:
            m, i = self._treeview.get_selection().get_selected()
            self.foundOne(m.get_value(i, 0))
Beispiel #9
0
def do_test(wclass):
    # watch two maildirs
    w = wclass()
    sdir = DirWatcher("sdir")
    w.addSource(sdir)
    ddir = DirWatcher("ddir")
    w.addDest(ddir)
    print "running"
    w.start()
    while 1:
        gtk.mainiteration()
    w.stop()
    print "finished"
Beispiel #10
0
 def doIteration(self, delay):
     log.msg(channel='system', event='iteration', reactor=self)
     if gtk.events_pending():
         gtk.mainiteration(0)
         return
     if delay == 0:
         return # shouldn't delay, so just return
     self.doIterationTimer = gtk.timeout_add(int(delay * 1000),
                                             self.doIterationTimeout)
     gtk.mainiteration(1) # block
     if self.doIterationTimer:
         gtk.timeout_remove(self.doIterationTimer)
         self.doIterationTimer = None
Beispiel #11
0
def test1():
    class MaildirTest(MaildirGtk):
        def messageReceived(self, filename):
            print "changed:", filename
    m = MaildirTest("ddir")
    print "watching ddir/new/"
    m.start()
    #gtk.main()
    # to allow the python-side signal handler to run, we must surface from
    # gtk (which blocks on the C-side) every once in a while.
    while 1:
        gtk.mainiteration() # this will block until there is something to do
    m.stop()
    print "done"
    def _doChoose(self, found, entry):
        # arma un liststore
        self._store = gtk.ListStore(gobject.TYPE_PYOBJECT, *[gobject.TYPE_STRING for i in self._entries])
        # set sort if needed
        if self._sortcol is not None:
            self._store.set_sort_column_id(*self._sortcol)
        # set model
        self._treeview.set_model(self._store)
        # build ui
        self._dia.set_parent_window(self.getWindow()._obj.window)
        self._response = None
        self._dia_ok_button.set_sensitive(False)
        self._dia.show_all()
        gtk.gdk.set_xcursor(self._dia.window, "left_ptr_watch")

        finder = entry.getFinder()
        entries = self._entries
        tot = found[0]
        got = 0
        n = 0
        self._progress.set_fraction(0)
        self._treeview.set_enable_search(False)
        self._treeview.set_headers_clickable(False)
        # fill the grid
        while tot > got and self._response is None:
            gtk.mainiteration()
            chunk = finder.fetchSlice(found, n)
            n += 1
            got += len(chunk)
            if not self._response:
                for i in chunk:
                    self._store.append([i] + [f.getFinder().getter(i) for f in entries])
                    gtk.mainiteration()
            self._progress.set_fraction(1.0 * got / tot)
        self._treeview.set_headers_clickable(True)
        self._treeview.set_enable_search(True)
        self._dia.window.set_cursor(None)

        rv = self._response or self._dia.run()
        self._dia.hide_all()
        sortcol = self._store.get_sort_column_id()
        if sortcol[0] >= 0:
            self._sortcol = sortcol
        else:
            self._sortcol = None
        self._store = None
        if rv == gtk.RESPONSE_OK:
            m, i = self._treeview.get_selection().get_selected()
            self.foundOne(m.get_value(i, 0))
Beispiel #13
0
def main_loop(sleep,action):
    ts = 0

    while True:
        # ensure UI stays reactive
        while gtk.events_pending():
            gtk.mainiteration()

        # schedule update
        if time.time() > ts + sleep:
            action()
            ts = time.time()

        # prevent full-load loop 
        time.sleep(0.1)
Beispiel #14
0
def main():
    try:
        f = open("watcher.pickle", "r")
        w = cPickle.load(f)
        f.close()
    except:
        print "unable to load pickle"
        w = makeWatcher()
    print "running"
    w.start()
    while not w.gui.done:
        gtk.mainiteration()
    print "done"
    w.stop()
    # save pickle of seen messages
    f = open("watcher.pickle", "w")
    cPickle.dump(w, f, 1)
    f.close()
Beispiel #15
0
    def process(self,time=0.1):
        while gtk.events_pending(): gtk.mainiteration()
        jabber.Client.process(self,time)

        if self.sleeper:
            state_pres = None
            self.sleeper.poll()
            state = self.sleeper.getState()
            if state != self.sleeper_state:
                if state == sleepy.STATE_WOKEN:
                    state_pres = jabber.Presence(type='available')
                    state_pres.setStatus('online')
                    state_pres.setShow('')
                if state == sleepy.STATE_SLEEPING:
                    state_pres = jabber.Presence(type='available')
                    state_pres.setStatus('away')
                    state_pres.setShow('Away from computer')
                if state_pres: self.send(state_pres)
            self.sleeper_state = state
Beispiel #16
0
    def process(self, time=0.1):
        while gtk.events_pending():
            gtk.mainiteration()
        jabber.Client.process(self, time)

        if self.sleeper:
            state_pres = None
            self.sleeper.poll()
            state = self.sleeper.getState()
            if state != self.sleeper_state:
                if state == sleepy.STATE_WOKEN:
                    state_pres = jabber.Presence(type='available')
                    state_pres.setStatus('online')
                    state_pres.setShow('')
                if state == sleepy.STATE_SLEEPING:
                    state_pres = jabber.Presence(type='available')
                    state_pres.setStatus('away')
                    state_pres.setShow('Away from computer')
                if state_pres: self.send(state_pres)
            self.sleeper_state = state
Beispiel #17
0
def gui_ino_upload(widget, ino_file=None):
    """
    Uploads selected .ino file to the Arduino PulseBox

    ARGS:
    ino_file: the .ino file to upload.
        Defaults to None. If a valid filename is not explicitly given,
        the .ino file will be taken from the GTK filechooser
    """
    if ino_file is None:
        ino_file = filechooserIno.get_filename()
    # the file doesn't have to bee set even in the filechooser, check again
    if ino_file is not None:
        # start the upload thread, keep updating the GTK interface
        print "gonna start the thread now, k?"
        UPLOAD = uploadThread(ino_file)
        UPLOAD.start()
        while UPLOAD.isAlive():
            gtk.mainiteration()
        UPLOAD.join()
Beispiel #18
0
 def doIteration(self, delay):
     # flush some pending events, return if there was something to do
     # don't use the usual "while gtk.events_pending(): mainiteration()"
     # idiom because lots of IO (in particular test_tcp's
     # ProperlyCloseFilesTestCase) can keep us from ever exiting.
     if gtk.events_pending():
         gtk.mainiteration(0)
         return
     # nothing to do, must delay
     if delay == 0:
         return # shouldn't delay, so just return
     self.doIterationTimer = gtk.timeout_add(delay * 1000,
                                             self.doIterationTimeout)
     # This will either wake up from IO or from a timeout.
     gtk.mainiteration(1) # block
     # note: with the .simulate timer below, delays > 0.1 will always be
     # woken up by the .simulate timer
     if self.doIterationTimer:
         # if woken by IO, need to cancel the timer
         gtk.timeout_remove(self.doIterationTimer)
         self.doIterationTimer = None
Beispiel #19
0
 def doIteration(self, delay):
     # flush some pending events, return if there was something to do
     # don't use the usual "while gtk.events_pending(): mainiteration()"
     # idiom because lots of IO (in particular test_tcp's
     # ProperlyCloseFilesTestCase) can keep us from ever exiting.
     log.msg(channel='system', event='iteration', reactor=self)
     if gtk.events_pending():
         gtk.mainiteration(0)
         return
     # nothing to do, must delay
     if delay == 0:
         return  # shouldn't delay, so just return
     self.doIterationTimer = gtk.timeout_add(int(delay * 1000),
                                             self.doIterationTimeout)
     # This will either wake up from IO or from a timeout.
     gtk.mainiteration(1)  # block
     # note: with the .simulate timer below, delays > 0.1 will always be
     # woken up by the .simulate timer
     if self.doIterationTimer:
         # if woken by IO, need to cancel the timer
         gtk.timeout_remove(self.doIterationTimer)
         self.doIterationTimer = None
Beispiel #20
0
def run_nonblocking(function, *args):
    """
      Runs the given function in a new thread while the main thread waits in
      a nonblocking way, i.e. runs the GTK mainloop.
      If the given function throws an exception, that exception is rethrown by
      this function so that it doesn't get lost.
    """

    def worker(function, event, retval, *args):

        success = False
        try:
            ret = function(*args)
            success = True
        except:
            ret = sys.exc_value
            success = False

        retval[0] = (success, ret)
        event.set()


    retval = [None]
    event = threading.Event()
    t = threading.Thread(target = worker,
                         args = [function, event, retval] + list(args))
    t.start()

    while (not event.isSet()):
        gtk.threads_enter()
        gtk.mainiteration()
        gtk.threads_leave()
    success, ret = retval[0]

    if (not success):
        raise ret
    else:
        return ret
Beispiel #21
0
def burn(paths, progress):
    def cb(fd, cond):
        data = os.read(fd, 80)
        print data,
        if data.find('extents') >= 0:
            progress.set_fraction(1.0)
            progress.set_text('100%')
            return gtk.TRUE
        elif data.find('read/written') >= 0:
            progress.set_text('Finishing...')
        try:
            perc = int(data.split('.')[0])
            progress.set_fraction(perc/100.0)
            progress.set_text('%d%%' % (perc,))
        except (ValueError):
            pass
    command = burn_command(paths)
    print command
    pipe = popen2.Popen4(command)
    gtk.input_add(pipe.fromchild, gtk.gdk.INPUT_READ, cb)
    while pipe.poll() < 0:
        gtk.mainiteration()
    return pipe.poll()
 def __initIcons(self):
     if self.icons_loaded:
         return
     i = 0
     self.buttons = []
     first_butt = None
     picturelist = self.getPictureList()
     size = len(picturelist)
     #DJM        self.progressbar.configure(0, 0, size - 1)
     self.progressbar.set_fraction(0.0)
     self.progressbar.set_text(
         _("Loading") + " " + str(size) + " " + _("images...please wait."))
     buttongroup = self.__addButton(None, "-", "-", None, None)
     if picturelist:
         for name, val in picturelist:
             i = i + 1
             self.progressbar.set_fraction(float(i) / size)
             #DJMself.progressbar.set_value(i)
             while gtk.events_pending():
                 gtk.mainiteration()
             if len(val) == 3:
                 filename, pix, mask = val
             elif type(val) == type(""):
                 filename, pix, mask = val, None, None
             else:
                 filename, pix, mask = val[0], None, None
             try:
                 self.__addButton(buttongroup, name, filename, pix, mask)
             except:
                 pass
     self.icons_loaded = 1
     self.__fillTable()
     #self.__setSelectedIcon(None) # commented out by Erica Andrews
     #DJMself.progressbar.set_value(0)
     self.progressbar.set_fraction(0.0)
     del picturelist
Beispiel #23
0
def creacatalogo (widget):
	global rai,homedir
	htm = open (homedir+'ubuntuwintv.html','w')
	barra = progressbar(trad("creazionecatalogo"))
	x = 1
	tutti = len(rai)
	htm.write('<html><head>'+trad("catalogocanalirai")+'</head><body>')
	htm.write('<p><strong>'+trad("canalivisibilicon")+' <a href="http://ubuntuwin.altervista.org">UBUNTUWIN TV</a>. '+trad("loghirai")+'</strong></p>')
	for menuItem in rai:
			htm.write('<p style="font-weight: bold; font-size: 12px">'+menuItem[1]+'</p>')
			htm.write('<p>'+menuItem[3]+'</p>')
			if menuItem[3].find("http")!=-1:
				htm.write('<p><img src="'+menuItem[3]+'"></p>')
			else:
				htm.write('<p><img height="150px;" border="1" src="http://www.rai.it/'+menuItem[4]+'"></p>')
			while gtk.events_pending():
				gtk.mainiteration(False)
			barra.pbar.set_fraction(float(x)/float(tutti))
			barra.window.show_all()
			x = x + 1
	htm.write('</body></html')
	htm.close()
	barra.window.hide_all()
	webbrowser.open(homedir+'ubuntuwintv.html')
Beispiel #24
0
def burn(paths, progress):
    def cb(fd, cond):
        data = os.read(fd, 80)
        print data,
        if data.find('extents') >= 0:
            progress.set_fraction(1.0)
            progress.set_text('100%')
            return gtk.TRUE
        elif data.find('read/written') >= 0:
            progress.set_text('Finishing...')
        try:
            perc = int(data.split('.')[0])
            progress.set_fraction(perc / 100.0)
            progress.set_text('%d%%' % (perc, ))
        except (ValueError):
            pass

    command = burn_command(paths)
    print command
    pipe = popen2.Popen4(command)
    gtk.input_add(pipe.fromchild, gtk.gdk.INPUT_READ, cb)
    while pipe.poll() < 0:
        gtk.mainiteration()
    return pipe.poll()
Beispiel #25
0
# 
# This program is distributed under the GNU General
# Public License (open source).
#
# Ported to PyGTK-2 by: David Moore ([email protected]) - June 2003
#
#######################################

import icewmcp_common,gtk,ICEWMCP_BugReport
icewmcp_common.setSplash(icewmcp_common.getLocaleDir)
icewmcp_common.showSplash(0)
icewmcp_common.IS_STATIC_BINARY="yes"
ICEWMCP_BugReport.IS_STATIC_BINARY="yes"
icewmcp_common.NOSPLASH=1  # disable splash window from icepref_td
while gtk.events_pending():
        gtk.mainiteration()

import os,sys,IceWMCP,IceWMCPWinOptions,IceWMCPMouse,IceWMCPKeyboard,IceWMCPWallpaper,IceMe,phrozenclock,icepref,pyspool,icesound,icepref_td,IceWMCP.IconSelection,IceWMCP_gtk.PCCard

global HW_SUPPORT
try:
        import IceWMCPSystem
        HW_SUPPORT=1
except:
        HW_SUPPORT=0


if __name__== "__main__" :
        mods = ( "IceWMCP.py",
             "IceWMCPWinOptions.py",
             "IceMe.py",
 def render(self, mode='human'):
     gtk.mainiteration()
Beispiel #27
0
app = gviewapp.GViewApp()
gview.app = app
app.subscribe("quit", gtk.mainquit)
app.show_layerdlg()
app.new_view(None)
app.do_auto_imports()

view = gview.app.view_manager.get_active_view()
view.connect("key-press-event", key_press_cb)

gview.file_list = []
gview.file_list_ds = [None, None, None]
gview.file_cur = 0

# Command line parser
i = 1
while i < len(sys.argv):
    arg = sys.argv[i]
    gview.file_list.append(arg)
    i = i + 1

update_view()

gview.request_clean = 0
while 1:
    gtk.mainiteration()

    if gview.request_clean == 1:
        clean_old_layer()
Beispiel #28
0
 def _destroy_win(self, *args):
     import gtk
     self._win.unrealize()
     while gtk.events_pending(): gtk.mainiteration()
     gtk.mainquit()
Beispiel #29
0
def gtkExecWithCaptureStatus(command,
                             argv,
                             searchPath=0,
                             root='/',
                             stdin=0,
                             catchfd=1,
                             closefd=-1):
    import gtk
    if not os.access(root + command, os.X_OK):
        raise RuntimeError, command + " can not be run"

    (read, write) = os.pipe()

    childpid = os.fork()
    if (not childpid):
        if (root and root != '/'): os.chroot(root)
        if isinstance(catchfd, tuple):
            for fd in catchfd:
                os.dup2(write, fd)
        else:
            os.dup2(write, catchfd)
        os.close(write)
        os.close(read)

        if closefd != -1:
            os.close(closefd)

        if stdin:
            os.dup2(stdin, 0)
            os.close(stdin)

        if (searchPath):
            os.execvp(command, argv)
        else:
            os.execv(command, argv)

        sys.exit(1)

    os.close(write)

    rc = ""
    s = "1"
    while (s):
        try:
            (fdin, fdout, fderr) = select.select([read], [], [], 0.1)
        except:
            fdin = []
            pass

        while gtk.events_pending():
            gtk.mainiteration()
        if len(fdin):
            s = os.read(read, 1000)
            rc = rc + s

    os.close(read)

    status = None

    try:
        (pid, status) = os.waitpid(childpid, 0)
    except OSError, (errno, msg):
        print __name__, "waitpid:", msg
Beispiel #30
0
    def __init__(self, title=None, cwd=None, dialog_type=FILE_OPEN, filter=None, app=None, multiselect=0):
        gtk.GtkWindow.__init__(self)

        if dialog_type >= FILE_OPEN and dialog_type <= DIRECTORY_SELECT:
            self.dialog_type = dialog_type
        else:
            self.dialog_type = FILE_OPEN

        self.filter = None #current filter
        self.filters = {} #active filter objects
        self.filter_keys = [] #ordered list of the names of the filters
        
        self.file_selection = []
        
        self.multiselect = multiselect
                
        self.set_border_width(5)
        self.set_policy(as=gtk.FALSE, ag=gtk.FALSE, autos=gtk.TRUE)
        self.drives = None

        if title == None:
            if dialog_type == FILE_OPEN:
                title = nls.get('filedlg-title-open-file', 'Open File ...')
            elif dialog_type == FILE_SAVE:
                title = nls.get('filedlg-title-save-file', 'Save File ...')
            elif dialog_type == DIRECTORY_SELECT:
                title = nls.get('filedlg-title-select-directory', 'Select Directory ...')
        self.set_title(title)

        #setup the current working directory
        if cwd is None or not os.path.exists(cwd):
            cwd = gview.get_preference('working-directory')
            if cwd is None:
                cwd = os.getcwd()
        self.cwd = cwd
        
        #widgets
        vbox = gtk.GtkVBox(spacing=5)
        if dialog_type == FILE_OPEN or dialog_type == DIRECTORY_SELECT:
            lbl = gtk.GtkLabel(nls.get('filedlg-label-open-from', 'Open From:'))
        elif dialog_type == FILE_SAVE:
            lbl = gtk.GtkLabel(nls.get('filedlg-label-save-in', 'Save In:'))
        self.opt_menu = gtk.GtkOptionMenu()
        self.opt_menu.set_menu(gtk.GtkMenu())
        hbox = gtk.GtkHBox()
        hbox.pack_start(lbl, expand=gtk.FALSE)
        hbox.pack_start(self.opt_menu)
        vbox.pack_start(hbox, expand = gtk.FALSE)

        self.list_directory = gtk.GtkCList()
        scr_directories = gtk.GtkScrolledWindow()
        scr_directories.add(self.list_directory)
        self.list_directory.connect('button-press-event', self.directory_selected_cb)

        if dialog_type == DIRECTORY_SELECT:
            self.list_files = None
            vbox.pack_start(scr_directories)
        else:
            self.list_files = gtk.GtkCList()
            if self.multiselect:
                self.list_files.set_selection_mode( gtk.SELECTION_EXTENDED )
            scr_files = gtk.GtkScrolledWindow()
            scr_files.add(self.list_files)
            self.list_files.connect('button-press-event', self.file_clicked_cb)
            self.list_files.connect('select-row', self.file_selected_cb )
            self.list_files.connect('unselect-row', self.file_unselected_cb )
            pane = gtk.GtkHPaned()
            scr_directories.set_usize(100, -1)
            scr_files.set_usize(100, -1)
            pane.add1(scr_directories)
            pane.add2(scr_files)
            pane.set_position(200)
            vbox.pack_start(pane)

        widget = None
        if dialog_type == FILE_SAVE:
            self.txt_filename = gtk.GtkEntry()
            widget = self.txt_filename            
        
        elif dialog_type == FILE_OPEN:
            combo = gtk.GtkCombo()
            combo.set_value_in_list(gtk.FALSE, gtk.FALSE)
            combo.disable_activate()
            if app is not None:
                rfl = app.get_rfl()
                rfl.insert(0, '')
                combo.set_popdown_strings( rfl )
            self.txt_filename = combo.entry
            widget = combo
            
        if widget is not None:
            table = gtk.GtkTable(rows=2, cols=2)
            lbl = gtk.GtkLabel(nls.get('filedlg-label-file-name', 'File Name:'))
            self.txt_filename.connect('focus-out-event', self.map_path_cb)
            self.txt_filename.connect('key-press-event', self.map_path_cb)

            table.attach(lbl, 0, 1, 0, 1)
            table.attach(widget, 1, 2, 0, 1)
            lbl = gtk.GtkLabel(nls.get('filedlg-label-filter-extension', 'Filter extension:'))
            self.cmb_filter = pguCombo()
            self.set_filter(filter)
            self.cmb_filter.entry.connect('changed', self.filter_cb)
            table.attach(lbl, 0, 1, 1, 2)
            table.attach(self.cmb_filter, 1, 2, 1, 2)
            vbox.pack_start(table, expand=gtk.FALSE)

        if dialog_type == FILE_SAVE:
            self.ok_button = gtk.GtkButton(nls.get('filedlg-button-ok', 'OK'))
        elif dialog_type == FILE_OPEN:
            self.ok_button = gtk.GtkButton(nls.get('filedlg-button-open', 'Open'))
        elif dialog_type == DIRECTORY_SELECT:
            self.ok_button = gtk.GtkButton(nls.get('filedlg-button-ok', 'OK'))

        self.cancel_button = gtk.GtkButton(nls.get('filedlg-button-cancel', 'Cancel'))

        self.ok_button.connect('clicked', self.remove_grab)
        self.ok_button.connect('clicked', self.update_cwd)
        self.cancel_button.connect('clicked', self.remove_grab)
        btn_box = gtk.GtkHButtonBox()
        btn_box.pack_start(self.ok_button)
        btn_box.pack_start(self.cancel_button)
        vbox.pack_start(btn_box, expand=gtk.FALSE)

        self.add(vbox)
        self.show_all()
        
        #make modal
        gtk.grab_add(self)


        self.ok_button.set_flags(gtk.CAN_DEFAULT)
        self.ok_button.grab_default()

        self.set_usize(400, 400)
        self.menu_update = gtk.FALSE

        while gtk.events_pending():
            gtk.mainiteration(FALSE)

        self.refresh_directory()
        self.connect('delete-event', self.quit)
        self.ok_button.connect('clicked', self.quit)
        self.cancel_button.connect('clicked', self.quit)
        self.publish('quit')
        
        self.add_events(gtk.GDK.KEY_PRESS_MASK)
        self.connect('key-press-event', self.key_press_cb)

        self.result = 'cancel'
Beispiel #31
0
    def __init__(self):
        self.sleeper = None
        self.sleeper_state = None
        self.gui = None
        not_connected = 1
        while not_connected:

            login_dia = Logon_dialog(None)
            while (login_dia.done is None):
                while gtk.events_pending():
                    gtk.mainiteration()
            login_dia.close()

            server = login_dia.server

            jabber.Client.__init__(self, host=server, debug=0)
            try:
                self.connect()
            except:
                msg_dia = Msg_dialog(None, "Couldnt connect to " + server)
                while (msg_dia.done is None):
                    while gtk.events_pending():
                        gtk.mainiteration()
                msg_dia.close()
                sys.exit(0)
            else:
                print "connected!"

            if (login_dia.done == 2):
                new_acc_dia = New_ac_dialog(None, self)
                while (new_acc_dia.done is None):
                    self.process()
                new_acc_dia.close()
                username = new_acc_dia.username
                password = new_acc_dia.password

            else:
                username = login_dia.username
                password = login_dia.password
            resource = 'pygtkjab'

            print "logging in"
            if self.auth(username, password, resource):
                not_connected = 0
            else:
                msg_dia = Msg_dialog(None, self.lastErr)
                while (msg_dia.done is None):
                    while gtk.events_pending():
                        gtk.mainiteration()
                msg_dia.close()
                #print "eek -> ", self.lastErr, self.lastErrCode
                sys.exit(1)

        self.loggedin_jid = jabber.JID(node=username,
                                       domain=server,
                                       resource=resource)
        self.presence_details = ['available', None]

        Known[server] = {'xpm': 'something'}

        ## Build the roster Tab ##
        self.roster = []
        r = self.requestRoster()
        self.gui = mainWindow("jabber app", jabberObj=self)
        self.gui.getTab(0)._cb = self.addChatTabViaRoster
        self.sendInitPresence()
        self._unsub_lock = 0  ## hack to fix unsubscribe wierdo bug
        self._pres_queue = []
        self.sleeper = sleepy.Sleepy()
Beispiel #32
0
	def wait(self):
		while gtk.events_pending():
			gtk.mainiteration(0)
Beispiel #33
0
    def __init__(self):
        self.sleeper = None
        self.sleeper_state = None
        self.gui = None
        not_connected = 1
        while not_connected:

            login_dia = Logon_dialog(None)
            while (login_dia.done is None):
                while gtk.events_pending(): gtk.mainiteration()
            login_dia.close()

            server   = login_dia.server

            jabber.Client.__init__(self,host=server,debug=0)
            try:
                self.connect()
            except:
                msg_dia = Msg_dialog(None, "Couldnt connect to "+server)
                while (msg_dia.done is None):
                    while gtk.events_pending(): gtk.mainiteration()
                msg_dia.close()
                sys.exit(0)
            else:
                print "connected!"

            if (login_dia.done == 2):
                new_acc_dia = New_ac_dialog(None, self)
                while (new_acc_dia.done is None):
                    self.process()
                new_acc_dia.close()
                username = new_acc_dia.username
                password = new_acc_dia.password

            else:
                username = login_dia.username
                password = login_dia.password
            resource = 'pygtkjab'

                
            print "logging in"
            if self.auth(username,password,resource):
                not_connected = 0
            else:
                msg_dia = Msg_dialog(None, self.lastErr)
                while (msg_dia.done is None):
                    while gtk.events_pending(): gtk.mainiteration()
                msg_dia.close()
                #print "eek -> ", self.lastErr, self.lastErrCode
                sys.exit(1)

        self.loggedin_jid     = jabber.JID( node = username, domain = server,
                                        resource = resource );
        self.presence_details = [ 'available', None ]
        
        Known[server] = { 'xpm':'something' }
        
        ## Build the roster Tab ##
        self.roster = []
        r = self.requestRoster()
        self.gui = mainWindow("jabber app",jabberObj=self)
        self.gui.getTab(0)._cb = self.addChatTabViaRoster;
        self.sendInitPresence()                                  
        self._unsub_lock = 0 ## hack to fix unsubscribe wierdo bug
        self._pres_queue  = []
        self.sleeper = sleepy.Sleepy()
Beispiel #34
0
 def refresh(self):
     import gtk
     while gtk.events_pending():
         gtk.mainiteration()