Exemple #1
0
        def prepare_window_osx(window):
            def quit_launcher(*args):
                gtk.main_quit()

            osxapp = gtk_osxapplication.OSXApplication()
            icon = get_icon("xpra.png")
            if icon:
                osxapp.set_dock_icon_pixbuf(icon)
            #menu:
            menu = gtk.MenuBar()

            # Quit (will be hidden - see below)
            quit_item = gtk.MenuItem("Quit")
            quit_item.connect("activate", quit_launcher)
            menu.add(quit_item)

            # Add to the application menu:
            item = gtk.MenuItem("About")
            item.show()
            item.connect("activate", about)
            item.show()

            #now set the dock/main menu
            menu.show_all()
            quit_item.hide()
            menu.hide()
            # We need to add it to a widget (otherwise it just does not work)
            window.vbox.add(menu)
            osxapp.set_menu_bar(menu)
            osxapp.insert_app_menu_item(item, 0)
            osxapp.ready()
Exemple #2
0
    def _pre_launcher_init(self):
        if platform.system() == 'Darwin':
            import gtk_osxapplication
            self._osx_app = gtk_osxapplication.OSXApplication()
            self._osx_app.connect('NSApplicationBlockTermination',
                                  self._on_osx__block_termination)
            self._osx_app.set_use_quartz_accelerators(True)

        self._app_settings = api.user_settings.get('app-ui', {})
        self.main_vbox = Gtk.VBox()
Exemple #3
0
def Application():
	if sys.platform == "darwin":
		try:
			# This worked with the first runtime that we built.
			import gtk_osxapplication
			return gtk_osxapplication.OSXApplication()
		except ImportError:
			# This works with the second. We can find no explanation of the name change.
			import gtkosx_application
			return gtkosx_application.Application()
	else:
		return None
Exemple #4
0
    def _pre_launcher_init(self):
        if platform.system() == 'Darwin':
            import gtk_osxapplication
            self._osx_app = gtk_osxapplication.OSXApplication()
            self._osx_app.connect('NSApplicationBlockTermination',
                                  self._on_osx__block_termination)
            self._osx_app.set_use_quartz_accelerators(True)
        api.user_settings.migrate()
        self._app_settings = api.user_settings.get('app-ui', {})
        self._create_shared_actions()
        if self.options.debug:
            self.add_debug_ui()

        self.main_vbox = gtk.VBox()
Exemple #5
0
    def setup_macdock(self):
        log.debug("setup_macdock()")
        self.macapp = None
        try:
            import gtk_osxapplication  #@UnresolvedImport
            self.macapp = gtk_osxapplication.OSXApplication()
            if self.icon_filename:
                log.debug("setup_macdock() loading icon from %s",
                          self.icon_filename)
                pixbuf = gtk.gdk.pixbuf_new_from_file(self.icon_filename)
                self.macapp.set_dock_icon_pixbuf(pixbuf)
            #setup the menu:
            self.menu_bar = gtk.MenuBar()
            # We need to add it to a widget (otherwise it just does not work)
            self.hidden_window = gtk.Window()
            self.hidden_window.add(self.menu_bar)
            self.quit_menu_item = gtk.MenuItem("Quit")
            self.quit_menu_item.connect("activate", self.quit)
            self.menu_bar.add(self.quit_menu_item)
            self.menu_bar.show_all()
            self.macapp.set_menu_bar(self.menu_bar)
            self.quit_menu_item.hide()

            self._menu_item_pos = 0

            def add_item(item):
                self.macapp.insert_app_menu_item(item, self._menu_item_pos)
                self._menu_item_pos += 1

            add_item(self.make_aboutmenuitem())
            add_item(self.make_sessioninfomenuitem())
            add_item(self.make_bellmenuitem())
            add_item(self.make_cursorsmenuitem())
            add_item(self.make_notificationsmenuitem())
            add_item(self.make_encodingsmenuitem())
            if not self.client.readonly:
                add_item(self.make_layoutsmenuitem())
            add_item(self.make_qualitysubmenu())
            #add_item(self.make_compressionmenu())
            add_item(self.make_refreshmenuitem())
            add_item(self.make_raisewindowsmenuitem())
            add_item(gtk.SeparatorMenuItem())

            #dock menu
            self.dock_menu = gtk.Menu()
            self.disconnect_dock_item = gtk.MenuItem("Disconnect")
            self.disconnect_dock_item.connect("activate", self.quit)
            self.dock_menu.add(self.disconnect_dock_item)
            self.dock_menu.show_all()
            self.macapp.set_dock_menu(self.dock_menu)

            self.macapp.connect("NSApplicationBlockTermination", self.quit)

            def active(*args):
                log.debug("active()")

            def inactive(*args):
                log.debug("inactive()")

            self.macapp.connect("NSApplicationDidBecomeActive", active)
            self.macapp.connect("NSApplicationWillResignActive", inactive)

            def dock_ready(*args):
                log.debug("dock_ready()")
                self.macapp.ready()

            self.client.connect("handshake-complete", dock_ready)
        except Exception, e:
            log.error("failed to create dock: %s", e)
Exemple #6
0
class GtkUI(object):
    def __init__(self, args):
        self.daemon_bps = (0, 0, 0)
        # Setup signals
        try:
            import gnome.ui
            import gnome
            self.gnome_prog = gnome.init("Deluge", deluge.common.get_version())
            self.gnome_client = gnome.ui.master_client()

            def on_die(*args):
                reactor.stop()

            self.gnome_client.connect("die", on_die)
            log.debug("GNOME session 'die' handler registered!")
        except Exception, e:
            log.warning(
                "Unable to register a 'die' handler with the GNOME session manager: %s",
                e)

        if deluge.common.windows_check():
            from win32api import SetConsoleCtrlHandler
            from win32con import CTRL_CLOSE_EVENT
            from win32con import CTRL_SHUTDOWN_EVENT

            def win_handler(ctrl_type):
                log.debug("ctrl_type: %s", ctrl_type)
                if ctrl_type in (CTRL_CLOSE_EVENT, CTRL_SHUTDOWN_EVENT):
                    reactor.stop()
                    return 1

            SetConsoleCtrlHandler(win_handler)

        if deluge.common.osx_check() and gtk.gdk.WINDOWING == "quartz":
            import gtk_osxapplication
            self.osxapp = gtk_osxapplication.OSXApplication()

            def on_die(*args):
                reactor.stop()

            self.osxapp.connect("NSApplicationWillTerminate", on_die)

        # Set process name again to fix gtk issue
        setproctitle(getproctitle())

        # Attempt to register a magnet URI handler with gconf, but do not overwrite
        # if already set by another program.
        common.associate_magnet_links(False)

        # Make sure gtkui.conf has at least the defaults set
        self.config = deluge.configmanager.ConfigManager(
            "gtkui.conf", DEFAULT_PREFS)

        # We need to check on exit if it was started in classic mode to ensure we
        # shutdown the daemon.
        self.started_in_classic = self.config["classic_mode"]

        # Start the IPC Interface before anything else.. Just in case we are
        # already running.
        self.queuedtorrents = QueuedTorrents()
        self.ipcinterface = IPCInterface(args)

        # Initialize gdk threading
        gtk.gdk.threads_init()
        gobject.threads_init()

        # We make sure that the UI components start once we get a core URI
        client.set_disconnect_callback(self.__on_disconnect)

        self.trackericons = TrackerIcons()
        self.sessionproxy = SessionProxy()
        # Initialize various components of the gtkui
        self.mainwindow = MainWindow()
        self.menubar = MenuBar()
        self.toolbar = ToolBar()
        self.torrentview = TorrentView()
        self.torrentdetails = TorrentDetails()
        self.sidebar = SideBar()
        self.filtertreeview = FilterTreeView()
        self.preferences = Preferences()
        self.systemtray = SystemTray()
        self.statusbar = StatusBar()
        self.addtorrentdialog = AddTorrentDialog()

        if deluge.common.osx_check() and gtk.gdk.WINDOWING == "quartz":

            def nsapp_open_file(osxapp, filename):
                # Will be raised at app launch (python opening main script)
                if filename.endswith('Deluge-bin'):
                    return True
                from deluge.ui.gtkui.ipcinterface import process_args
                process_args([filename])

            self.osxapp.connect("NSApplicationOpenFile", nsapp_open_file)
            from menubar_osx import menubar_osx
            menubar_osx(self, self.osxapp)
            self.osxapp.ready()

        # Initalize the plugins
        self.plugins = PluginManager()

        # Show the connection manager
        self.connectionmanager = ConnectionManager()

        from twisted.internet.task import LoopingCall
        rpc_stats = LoopingCall(self.print_rpc_stats)
        rpc_stats.start(10)

        reactor.callWhenRunning(self._on_reactor_start)
        # Start the gtk main loop
        gtk.gdk.threads_enter()
        reactor.run()
        self.shutdown()
        gtk.gdk.threads_leave()
Exemple #7
0
        def prepare_window_osx(window):
            def quit_launcher(*args):
                gtk.main_quit()

            osxapp = gtk_osxapplication.OSXApplication()
            icon = get_icon("xpra.png")
            if icon:
                osxapp.set_dock_icon_pixbuf(icon)
            #menu:
            menu = gtk.MenuBar()

            # Quit (will be hidden - see below)
            quit_item = gtk.MenuItem("Quit")
            quit_item.connect("activate", quit_launcher)
            menu.add(quit_item)

            # Add to the application menu:
            item = gtk.MenuItem("About")
            item.show()
            global about_dialog
            about_dialog = None

            def about(*args):
                import webbrowser
                global about_dialog, GPL2
                if about_dialog:
                    about_dialog.show()
                    about_dialog.present()
                    return
                dialog = gtk.AboutDialog()

                def on_website_hook(dialog, web, *args):
                    ''' called when the website item is selected '''
                    webbrowser.open(SITE_URL)

                def on_email_hook(dialog, mail, *args):
                    webbrowser.open(
                        "mailto://[email protected]")

                gtk.about_dialog_set_url_hook(on_website_hook)
                gtk.about_dialog_set_email_hook(on_email_hook)
                dialog.set_name("Xpra")
                from xpra import __version__
                dialog.set_version(__version__)
                dialog.set_copyright('Copyright (c) 2012, Nagafix Ltd')
                dialog.set_authors(
                    ('Antoine Martin <*****@*****.**>', ''))
                dialog.set_license(str(GPL2))
                dialog.set_website(SITE_URL)
                dialog.set_website_label(SITE_DOMAIN)
                dialog.set_logo(get_icon("xpra.png"))
                dialog.set_program_name(APPLICATION_NAME)

                def response(*args):
                    dialog.destroy()
                    global about_dialog
                    about_dialog = None

                dialog.connect("response", response)
                about_dialog = dialog
                dialog.show()

            item.connect("activate", about)
            item.show()

            #now set the dock/main menu
            menu.show_all()
            quit_item.hide()
            menu.hide()
            # We need to add it to a widget (otherwise it just does not work)
            window.vbox.add(menu)
            osxapp.set_menu_bar(menu)
            osxapp.insert_app_menu_item(item, 0)
            osxapp.ready()