class PLaunchStatusIcon(gtk.StatusIcon): '''Plaunch statusIcon, It show always in system tray. ''' def __init__(self): gtk.StatusIcon.__init__(self) menu = ''' <ui> <menubar name="PLaunch"> <menu action="Menu"> <menuitem action="Show"/> <menuitem action="Config"/> <menuitem action="About"/> <menuitem action="Exit"/> </menu> </menubar> </ui> ''' actions = [ ('Menu', None, 'Menu'), ('Show', gtk.STOCK_EXECUTE, '_Show...', None, None, self.on_activate), ('Config', gtk.STOCK_EDIT, '_Shortcuts...', None, None, self.on_edit_shortcut), ('About', gtk.STOCK_ABOUT, '_About...', None, None, self.on_about), ('Exit', gtk.STOCK_CLOSE, '_Exit...', None, None, self.on_exit_event)] ag = gtk.ActionGroup('Actions') ag.add_actions(actions) self.manager = gtk.UIManager() self.manager.insert_action_group(ag, 0) self.manager.add_ui_from_string(menu) self.menu = self.manager.get_widget('/PLaunch/Menu/About').props.parent self.set_from_file(ICON) self.set_tooltip('PLaunch is running here') self.set_visible(True) self.connect('activate', self.on_activate) self.connect('popup-menu', self.on_popup_menu) self.maindialog = MainDialog() def on_popup_menu(self, status, button, time): self.menu.popup(None, None, None, button, time) def on_activate(self, data): self.maindialog.open_main() def on_edit_shortcut(self, widget): ShortCutsEditer() def on_about(self, widget): xml = glade.XML(GLADE) about = xml.get_widget('aboutplaunch') about.run() about.destroy() def on_exit_event(self, widget, data=None): gtk.main_quit() return False
def do_init(self, license=None): # We ignore the license, not needed in the player import MMurl, windowinterface opts, files = self.tmpopts, self.tmpfiles del self.tmpopts del self.tmpfiles self._tracing = 0 self.nocontrol = 0 # For player compatability self._closing = 0 self._mm_callbacks = {} self.tops = [] self.last_location = '' try: import mm, posix, fcntl except ImportError: pass else: pipe_r, pipe_w = posix.pipe() mm.setsyncfd(pipe_w) self._mmfd = pipe_r windowinterface.select_setcallback( pipe_r, self._mmcallback, (posix.read, fcntl.fcntl, fcntl)) self.commandlist = [ OPEN(callback=(self.open_callback, ())), OPENFILE(callback=(self.openfile_callback, ())), OPEN_RECENT(callback=self.open_recent_callback), # Dynamic cascade # RELOAD(callback = (self.reload_callback, ())), PREFERENCES(callback=(self.preferences_callback, ())), CHECKVERSION(callback=(self.checkversion_callback, ())), EXIT(callback=(self.close_callback, ())), CHOOSESKIN(callback=(self.skin_callback, ())), ## CHOOSECOMPONENTS(callback = (self.components_callback, ())), ] import settings if hasattr(windowinterface, 'is_embedded') and windowinterface.is_embedded(): settings.factory_defaults() if settings.get('debug'): self.commandlist = self.commandlist + [ TRACE(callback=(self.trace_callback, ())), DEBUG(callback=(self.debug_callback, ())), CRASH(callback=(self.crash_callback, ())), ] MainDialog.__init__(self, 'GRiNS') # first open all files for file in files: self.openURL_callback(MMurl.guessurl(file), 0) if not files and settings.get('skin'): self.openURL_callback('data:application/smil,<smil/>', 0, 0, 0) self._update_recent(None) # then play them if not hasattr(windowinterface, 'is_embedded') or not windowinterface.is_embedded(): for top in self.tops: top.player.playsubtree(top.root)
def __init__(self): gtk.StatusIcon.__init__(self) menu = ''' <ui> <menubar name="PLaunch"> <menu action="Menu"> <menuitem action="Show"/> <menuitem action="Config"/> <menuitem action="About"/> <menuitem action="Exit"/> </menu> </menubar> </ui> ''' actions = [ ('Menu', None, 'Menu'), ('Show', gtk.STOCK_EXECUTE, '_Show...', None, None, self.on_activate), ('Config', gtk.STOCK_EDIT, '_Shortcuts...', None, None, self.on_edit_shortcut), ('About', gtk.STOCK_ABOUT, '_About...', None, None, self.on_about), ('Exit', gtk.STOCK_CLOSE, '_Exit...', None, None, self.on_exit_event)] ag = gtk.ActionGroup('Actions') ag.add_actions(actions) self.manager = gtk.UIManager() self.manager.insert_action_group(ag, 0) self.manager.add_ui_from_string(menu) self.menu = self.manager.get_widget('/PLaunch/Menu/About').props.parent self.set_from_file(ICON) self.set_tooltip('PLaunch is running here') self.set_visible(True) self.connect('activate', self.on_activate) self.connect('popup-menu', self.on_popup_menu) self.maindialog = MainDialog()
def do_init(self, license=None): # We ignore the license, not needed in the player import MMurl, windowinterface self._tracing = 0 self.nocontrol = 0 # For player compatability self._closing = 0 self.tops = [] self.last_location = '' self.commandlist = [ OPEN(callback=(self.open_callback, ())), OPENFILE(callback=(self.openfile_callback, ())), EXIT(callback=(self.close_callback, ())), ] if not hasattr(features, 'trial') or not features.trial: self.commandlist.append( CHOOSESKIN(callback=(self.skin_callback, ()))) import settings MainDialog.__init__(self, 'GRiNS') if settings.get('skin'): self.openURL_callback(EMPTYDOC, askskin=0)
from PyQt5 import QtWidgets from MainDialog import MainDialog app = QtWidgets.QApplication([]) dialog = MainDialog() dialog.show() app.exec_()
def do_init(self, license): opts, files = self.tmpopts, self.tmpfiles del self.tmpopts del self.tmpfiles ## del self.tmplicensedialog import MMurl import windowinterface if features.lightweight and len(files) > 1: windowinterface.showmessage( 'Cannot open multiple files in this product.') files = files[:1] self._license = license ## if not self._license.have('save'): ## windowinterface.showmessage( ## 'This is a demo version.\n'+ ## 'You will not be able to save your changes.', ## title='CMIFed license') self._tracing = 0 self.tops = [] self._mm_callbacks = {} self.last_location = '' self._untitled_counter = 1 self.template_info = None try: import mm, posix, fcntl except ImportError: pass else: pipe_r, pipe_w = posix.pipe() mm.setsyncfd(pipe_w) self._mmfd = pipe_r windowinterface.select_setcallback( pipe_r, self._mmcallback, (posix.read, fcntl.fcntl, fcntl.F_SETFL, posix.O_NDELAY)) self.commandlist = [ EXIT(callback=(self.close_callback, ())), NEW_DOCUMENT(callback=(self.new_callback, ())), OPEN(callback=(self.open_callback, ())), OPENFILE(callback=(self.openfile_callback, ())), OPEN_RECENT(callback=self.open_recent_callback), # Dynamic cascade PREFERENCES(callback=(self.preferences_callback, ())), CHECKVERSION(callback=(self.checkversion_callback, ())), ] import settings if self._license.have('preregistered'): settings.set('registered', 'preregistered') if not self._license.is_evaluation_license() and \ settings.get('registered') != 'preregistered': self.commandlist.append( REGISTER(callback=(self.register_callback, ()))) import Help if hasattr(Help, 'hashelp') and Help.hashelp(): self.commandlist.append(HELP(callback=(self.help_callback, ()))) if __debug__: if settings.get('debug'): self.commandlist = self.commandlist + [ TRACE(callback=(self.trace_callback, ())), DEBUG(callback=(self.debug_callback, ())), CRASH(callback=(self.crash_callback, ())), ] if self.splash is not None: self.splash.unsplash() self.splash = None MainDialog.__init__(self, 'CMIFed', (not not files)) for file in files: self.openURL_callback(MMurl.guessurl(file)) self._update_recent(None) if ENABLE_FNORB_SUPPORT: import CORBA.services self.corba_services = CORBA.services.services(sys.argv) if settings.get('registered') == 'notyet' and \ not self._license.is_evaluation_license(): answer = windowinterface.RegisterDialog() astr = ['yes', 'no', 'notyet'][answer] settings.set('registered', astr) settings.save() if astr == 'yes': self.register_callback()