diff options
-rw-r--r-- | NEWS | 1 | ||||
-rwxr-xr-x | fetchmailconf | 118 |
2 files changed, 111 insertions, 8 deletions
@@ -6,6 +6,7 @@ fetchmail-4.7.5 (): * Fix prefix problem with internationalized version. * Attempted fix for Harry McGavran's VPATH bug. * Progress messages now go to stdout. Errors still go to stderr +* Fetchmailconf can now launch fetchmail with a point-and-click interface. There are 249 people on fetchmail-friends and 334 on fetchmail-announce. diff --git a/fetchmailconf b/fetchmailconf index e0493d8d..a1440383 100755 --- a/fetchmailconf +++ b/fetchmailconf @@ -1327,16 +1327,14 @@ class UserEdit(Frame, MyWidget): # (but not both at once; it disappears when one is selected). # -class MainWindow(Frame): - def __init__(self, outfile, master=None): +class Configurator(Frame): + def __init__(self, outfile, master, parent): Frame.__init__(self, master) self.outfile = outfile - self.master.title('fetchmail configurator main'); - self.master.iconname('fetchmail configurator main'); + self.parent = parent + self.master.title('fetchmail configurator'); + self.master.iconname('fetchmail configurator'); Pack.config(self) - Label(self, - text='Fetchmailconf ' + version, - bd=2).pack(side=TOP, pady=10) self.keepalive = [] # Use this to anchor the PhotoImage object make_icon_window(self, fetchmail_gif) @@ -1356,9 +1354,11 @@ including multiple-site or multidrop connections. fg='blue', command=self.expert).pack() Message(self, text=""" -Or you can just select `Quit' to leave the configurator now. +Or you can just select `Quit' to leave the configurator now and +return to the main panel. """, width=600).pack(side=TOP) Button(self, text='Quit', fg='blue', command=self.leave).pack() + self.parent.configuration_active = 1 def novice(self): self.destroy() @@ -1369,6 +1369,108 @@ Or you can just select `Quit' to leave the configurator now. ConfigurationEdit(Fetchmailrc, self.outfile).edit('expert') def leave(self): + self.parent.configuration_active = 0 + Widget.destroy(self.master) + +# Run a command an a scrolling text widget, displaying its output + +class RunWindow(Frame): + def __init__(self, command, master, parent): + Frame.__init__(self, master) + self.master = master + self.master.title('fetchmail run window'); + self.master.iconname('fetchmail run window'); + Pack.config(self) + Label(self, + text="Running "+command, + bd=2).pack(side=TOP, pady=10) + self.keepalive = [] # Use this to anchor the PhotoImage object + make_icon_window(self, fetchmail_gif) + + # This is a scrolling text window + textframe = Frame(self) + scroll = Scrollbar(textframe) + self.textwidget = Text(textframe, setgrid=TRUE) + textframe.pack(side=TOP, expand=YES, fill=BOTH) + self.textwidget.config(yscrollcommand=scroll.set, relief=SUNKEN) + self.textwidget.pack(side=LEFT, expand=YES, fill=BOTH) + scroll.config(command=self.textwidget.yview, relief=SUNKEN) + scroll.pack(side=RIGHT, fill=BOTH) + textframe.pack(side=TOP) + + Button(self, text='Quit', fg='blue', command=self.leave).pack() + + self.update() # Draw widget before executing fetchmail + + child_stdout = os.popen(command + " 2>&1", "r") + while 1: + ch = child_stdout.read(1) + if not ch: + break + self.textwidget.insert(END, ch) + self.textwidget.insert(END, "Done.") + self.textwidget.see(END); + + def leave(self): + Widget.destroy(self.master) + +# Here's where we choose either configuration or launching + +class MainWindow(Frame): + def __init__(self, outfile, master=None): + Frame.__init__(self, master) + self.outfile = outfile + self.configuration_active = 0 + self.master.title('fetchmail launcher'); + self.master.iconname('fetchmail launcher'); + Pack.config(self) + Label(self, + text='Fetchmailconf ' + version, + bd=2).pack(side=TOP, pady=10) + self.keepalive = [] # Use this to anchor the PhotoImage object + make_icon_window(self, fetchmail_gif) + self.debug = 0 + + Message(self, text=""" +Use `Configure fetchmail' to tell fetchmail about the remote +servers it should poll (the host name, your username there, +whether to use POP or IMAP, and so forth). +""", width=600).pack(side=TOP) + self.configbutton = Button(self, text='Configure fetchmail', + fg='blue', command=self.configure).pack() + + Message(self, text=""" +Use `Test fetchmail' to run fetchmail with debugging enabled. +This is a good way to test out a new configuration. +""", width=600).pack(side=TOP) + self.configbutton = Button(self, text='Test fetchmail', + fg='blue', command=self.test).pack() + + Message(self, text=""" +Use `Run fetchmail' to run fetchmail in foreground. +Progress messages will be shown, but not debug messages. +""", width=600).pack(side=TOP) + self.configbutton = Button(self, text='Run fetchmail', + fg='blue', command=self.run).pack() + + Message(self, text=""" +Or you can just select `Quit' to leave the launcher now and +return to the main panel. +""", width=600).pack(side=TOP) + Button(self, text='Quit', fg='blue', command=self.leave).pack() + + def configure(self): + # FIXME: We really want to disable the button temporarily + if not self.configuration_active: + Configurator(self.outfile, Toplevel(), self) + + def test(self): + RunWindow("fetchmail -d0 -v", Toplevel(), self) + + def run(self): + RunWindow("fetchmail -d0", Toplevel(), self) + + def leave(self): self.quit() # Functions for turning a dictionary into an instantiated object tree. |