--- nfo/projects/netfraggle/bin/fraggleViewport.py 2004/08/25 22:53:41 1.7 +++ nfo/projects/netfraggle/bin/fraggleViewport.py 2004/08/27 04:39:06 1.14 @@ -1,55 +1,95 @@ -4#Boa:MDIParent:fraggleViewport +#Boa:MDIParent:fraggleViewport + +# $Id: fraggleViewport.py,v 1.14 2004/08/27 04:39:06 joko Exp $ +# $Log: fraggleViewport.py,v $ +# Revision 1.14 2004/08/27 04:39:06 joko +# cleanup +# +# Revision 1.13 2004/08/27 03:25:44 joko +# added FraggleTaskBarMenu +# +# Revision 1.12 2004/08/27 00:05:22 joko +# fix for icon-path and wxTaskBarIcon-events +# +# Revision 1.11 2004/08/26 23:10:12 xabbu +# xmlrpc class added +# +# Revision 1.10 2004/08/26 18:19:27 joko +# now using FraggleTopicFrame +# +# Revision 1.9 2004/08/26 15:21:13 joko +# renamed namespaces +# added key shortcuts to menu-items +# correct "showAbout" code +# import os from wxPython.wx import * +from wxPython.stc import * +from fraggleConstants import * import fraggleDialogPrefs import fraggleCtlPreferences -from fraggleDialogs import * +import FraggleAboutDialog +import FraggleTopicFrame +import FraggleXMLRPC def create(parent): - return fraggleMainWin(parent) + return fraggleViewport(parent) [wxID_FRAGGLEVIEWPORT] = map(lambda _init_ctrls: wxNewId(), range(1)) [wxID_FRAGGLEVIEWPORTMENU1FPREFS, wxID_FRAGGLEVIEWPORTMENU1ITEMS1, ] = map(lambda _init_coll_menu1_Items: wxNewId(), range(2)) -[wxID_FRAGGLEVIEWPORTMENU2CONT, wxID_FRAGGLEVIEWPORTMENU2ABOUT, +[wxID_FRAGGLEVIEWPORTMENU2ABOUT, wxID_FRAGGLEVIEWPORTMENU2CONT, +] = map(lambda _init_coll_menu2_Items: wxNewId(), range(2)) + +[wxID_FRAGGLEVIEWPORTMENU2ABOUT, wxID_FRAGGLEVIEWPORTMENU2CONT, ] = map(lambda _init_coll_menu2_Items: wxNewId(), range(2)) +[wxID_FRAGGLEVIEWPORTFRAGGLETASKBARMENUITEMSEXIT, + wxID_FRAGGLEVIEWPORTFRAGGLETASKBARMENUITEMSRESTORE, + wxID_FRAGGLEVIEWPORTFRAGGLETASKBARMENUITEMSSYNC, +] = map(lambda _init_coll_FraggleTaskBarMenu_Items: wxNewId(), range(3)) + class fraggleViewport(wxMDIParentFrame): - def _init_coll_menu1_Items(self, parent): + def _init_coll_FraggleTaskBarMenu_Items(self, parent): # generated method, don't edit - - parent.Append(helpString='Configure Netfraggle', - id=wxID_FRAGGLEVIEWPORTMENU1FPREFS, item='Preferences', - kind=wxITEM_NORMAL) - parent.Append(helpString='Exit Netfraggle', - id=wxID_FRAGGLEVIEWPORTMENU1ITEMS1, item='Exit', - kind=wxITEM_NORMAL) - EVT_MENU(self, wxID_FRAGGLEVIEWPORTMENU1FPREFS, self.OnMenu1items0Menu) - EVT_MENU(self, wxID_FRAGGLEVIEWPORTMENU1ITEMS1, self.OnMenu1items1Menu) + parent.Append(helpString='Restore', + id=wxID_FRAGGLEVIEWPORTFRAGGLETASKBARMENUITEMSRESTORE, + item='Restore', kind=wxITEM_NORMAL) + parent.Append(helpString='Sync enabled', + id=wxID_FRAGGLEVIEWPORTFRAGGLETASKBARMENUITEMSSYNC, + item='Sync enabled', kind=wxITEM_CHECK) + parent.Append(helpString='Exit', + id=wxID_FRAGGLEVIEWPORTFRAGGLETASKBARMENUITEMSEXIT, item='Exit', + kind=wxITEM_NORMAL) def _init_coll_menu2_Items(self, parent): # generated method, don't edit - parent.Append(helpString='Documentation', - id=wxID_FRAGGLEVIEWPORTMENU2CONT, item='Contents', + parent.Append(helpString='Contents', id=wxID_FRAGGLEVIEWPORTMENU2CONT, + item='Contents', kind=wxITEM_NORMAL) + parent.Append(helpString='About', id=wxID_FRAGGLEVIEWPORTMENU2ABOUT, + item='About', kind=wxITEM_NORMAL) + + def _init_coll_menu1_Items(self, parent): + # generated method, don't edit + + parent.Append(helpString='Configure Netfraggle', + id=wxID_FRAGGLEVIEWPORTMENU1FPREFS, item='Preferences', kind=wxITEM_NORMAL) - parent.Append(helpString='About Netfraggle', - id=wxID_FRAGGLEVIEWPORTMENU2ABOUT, item='About', + parent.Append(helpString='Exit Netfraggle', + id=wxID_FRAGGLEVIEWPORTMENU1ITEMS1, item='Exit', kind=wxITEM_NORMAL) - - EVT_MENU(self, wxID_FRAGGLEVIEWPORTMENU2CONT, self.OnMenu2items0Menu) - EVT_MENU(self, wxID_FRAGGLEVIEWPORTMENU2ABOUT, self.OnMenu2items1Menu) def _init_coll_menuBar1_Menus(self, parent): # generated method, don't edit - parent.Append(menu=self.menu1, title='File') - parent.Append(menu=self.menu2, title='Help') + parent.Append(menu=self.menu1, title='&File') + parent.Append(menu=self.menu2, title='&Help') def _init_utils(self): # generated method, don't edit @@ -57,22 +97,25 @@ self.menuBar1.SetAutoLayout(1) self.menu1 = wxMenu(title='') - self._init_coll_menu1_Items(self.menu1) self.menu2 = wxMenu(title='') - self._init_coll_menu2_Items(self.menu2) + + self.FraggleTaskBarMenu = wxMenu(title=u'NetFraggle') self._init_coll_menuBar1_Menus(self.menuBar1) + self._init_coll_menu1_Items(self.menu1) + self._init_coll_menu2_Items(self.menu2) + self._init_coll_FraggleTaskBarMenu_Items(self.FraggleTaskBarMenu) def _init_ctrls(self, prnt): # generated method, don't edit wxMDIParentFrame.__init__(self, id=wxID_FRAGGLEVIEWPORT, - name='fraggleViewport', parent=prnt, pos=wxPoint(277, 313), - size=wxSize(683, 307), + name='fraggleViewport', parent=prnt, pos=wxPoint(338, 296), + size=wxSize(435, 296), style=wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL, - title='wxMDIParentFrame1') + title='NetFraggle 0.0.1') self._init_utils() - self.SetClientSize(wxSize(683, 284)) + self.SetClientSize(wxSize(427, 269)) self.SetMenuBar(self.menuBar1) def __init_preferences__(self): @@ -80,84 +123,80 @@ self.dialogPrefs = fraggleDialogPrefs.create(self) self.dialogPrefs.loadConfig() self.dialogPrefs.updateConfig() + + # new as of 2004-08-26: TopicFrame + # new as of 2004-08-27: pass configList to TopicFrame + self.topicFrame = FraggleTopicFrame.create(self, self.preferencesCtl.configList) + self.topicFrame.Move(wxPoint(5, 5)) + + #frame.Show() + #frame.Destroy() + def __init_xmlrpc__(self): + #self.xml_rpc = FraggleXMLRPC.create(self, self.preferencesCtl.configList) + pass + def __init_taskbar_icon__(self): + if os.name == 'posix': + pass + elif os.name == 'nt': + self.tbicon = wxTaskBarIcon() + #icon = wxIcon('mixxx.ico', wxBITMAP_TYPE_ICO) + icon = wxIcon(os.path.join(APPLOCATION, 'mixxx.ico'), wxBITMAP_TYPE_ICO) + self.tbicon.SetIcon(icon, '') + EVT_TASKBAR_LEFT_DCLICK(self.tbicon, self.OnTaskBarLeftDClick) + EVT_TASKBAR_RIGHT_UP(self.tbicon, self.OnTaskBarRightClick) + EVT_MENU(self.tbicon, wxID_FRAGGLEVIEWPORTFRAGGLETASKBARMENUITEMSRESTORE, self.OnTaskBarAppRestore) + EVT_MENU(self.tbicon, wxID_FRAGGLEVIEWPORTFRAGGLETASKBARMENUITEMSEXIT, self.OnTaskBarAppExit) + def __init__(self, parent): self._init_ctrls(parent) self.__init_preferences__() - - def showPrefs(self, event): - """Show preferences screen""" + self.__init_taskbar_icon__() + self.__init_xmlrpc__() + + def OnMenu1items0Menu(self, event): try: self.dialogPrefs.ShowModal() finally: - self.dialogPrefs.Destroy() - #event.Skip() - - def showHelp(self): - """Show help""" - try: - import webbrowser - webbrowser.open("file://"+os.path.join(PEARSLOCATION, "docs/index.html"), 1) - except: - dlg = wxScrolledMessageDialog(parent=self, - caption="Help", - msg="""PEARS - alternative help (see the docs directory in your Pears folder for more elaborate information) - - Pears is a relatively simple three-pane news feed aggregator (RSS/RDF reader). - - The left pane contains the list of feeds. You can add feeds using the Feeds menu. Right-click on a feed to update, single-click to view cached contents. - - The right pane contains a list of the topics available in the feed. Single-click to open the contents of a topic in the viewer window at the bottom. Right-click to toggle read/unread status. - - Everything is cached in Python structures stored as plain text in your Home directory (in a subdirectory called '.pears'). Use the About screen to see exactly where that is on your system. - """) - dlg.ShowModal() - dlg.Destroy() - - def showAbout(self): - """Show about screen""" - dlg = AboutDialog(parent=self, id=-1, title="About Pears") - dlg.ShowModal() - dlg.Destroy() - - def doExit(self): - """Shut down the program""" - self.Close(True) - self.Destroy() - - def OnMenu1items0Menu(self, event): - self.showPrefs(event) - #event.Skip() + self.dialogPrefs.Hide() + event.Skip() def OnMenu1items1Menu(self, event): - self.doExit() + self.Destroy() + event.Skip() + def OnMenu2items0Menu(self, event): - self.showHelp() + try: + self.dialogPrefs.ShowModal() + finally: + pass + event.Skip() def OnMenu2items1Menu(self, event): - self.showAbout() - -class fraggleMainWin(fraggleViewport): - def _init_coll_menu1_Items(self, parent): - - if os.name == 'posix': - super(fraggleMainWin, self)._init_coll_menu1_Items(parent) - elif os.name == 'nt': - parent.Append(wxID_FRAGGLEVIEWPORTMENU1FPREFS, 'Configure Netfraggle', "", wxITEM_NORMAL) - parent.Append(wxID_FRAGGLEVIEWPORTMENU1ITEMS1, 'Exit Netfraggle', "", wxITEM_NORMAL) - - EVT_MENU(self, wxID_FRAGGLEVIEWPORTMENU1FPREFS, self.OnMenu1items0Menu) - EVT_MENU(self, wxID_FRAGGLEVIEWPORTMENU1ITEMS1, self.OnMenu1items1Menu) - - def _init_coll_menu2_Items(self, parent): + """Show about screen""" + dlg = FraggleAboutDialog.create(self) + dlg.ShowModal() + dlg.Destroy() - if os.name == 'posix': - super(fraggleMainWin, self)._init_coll_menu2_Items(parent) - elif os.name == 'nt': - parent.Append(wxID_FRAGGLEVIEWPORTMENU2CONT, 'Contents', "", wxITEM_NORMAL) - parent.Append(wxID_FRAGGLEVIEWPORTMENU2ABOUT, 'About', "", wxITEM_NORMAL) - - EVT_MENU(self, wxID_FRAGGLEVIEWPORTMENU2CONT, self.OnMenu2items0Menu) - EVT_MENU(self, wxID_FRAGGLEVIEWPORTMENU2ABOUT, self.OnMenu2items1Menu) + def OnTaskBarLeftDClick(self, event): + #event.Skip() + #self.SetFocus() + if self.IsIconized(): + self.Restore() + else: + self.Iconize() + + def OnTaskBarRightClick(self, event): + #event.Skip() + self.tbicon.PopupMenu(self.FraggleTaskBarMenu) + + def OnTaskBarAppRestore(self, event): + self.Restore() + #event.Skip() + def OnTaskBarAppExit(self, event): + #event.Skip() + #self.Destroy() + self.Close(True) +