Exemple #1
0
 def on_create(self, widget, data=None):
     name = self.name.get_text()
     manager = FogAppManager()
     existing = manager.get_by_name(name)
     if existing:
         confirm = ConfirmDialog('Fogger', _('There\'s an app for that!'),
                     _('A fog app already exists by that name. '\
                       'Would you like to replace it with a new one?'),
                     existing.icon, self, _('Replace'))
         response = confirm.run()
         confirm.destroy()
         if response != Gtk.ResponseType.YES:
             self.name.grab_focus()
             return
     self.set_loading_url(True)
     self.error_message.hide()
     thread = threading.Thread(target=self.verify_url)
     thread.daemon = True
     thread.start()
Exemple #2
0
 def on_create(self, widget, data=None):
     name = self.name.get_text()
     manager = FogAppManager()
     existing = manager.get_by_name(name)
     if existing:
         confirm = ConfirmDialog('Fogger', _('There\'s an app for that!'),
                     _('A fog app already exists by that name. '\
                       'Would you like to replace it with a new one?'),
                     existing.icon, self, _('Replace'))
         response = confirm.run()
         confirm.destroy()
         if response != Gtk.ResponseType.YES:
             self.name.grab_focus()
             return
     self.set_loading_url(True)
     self.error_message.hide()
     thread = threading.Thread(target=self.verify_url)
     thread.daemon = True
     thread.start()
Exemple #3
0
def main():
    options, args = parse_options()
    option_selected = False
    if options.list:
        option_selected = True
        manager = FogAppManager()
        apps = manager.get_all()
        for app in apps:
            print '\033[1m%s\033[0m' % app.name, '\t', app.uuid, '\n'

    if options.remove:
        option_selected = True
        manager = FogAppManager()
        app = manager.get(options.remove)
        if app:
            app.remove()
            print 'Removed app %s (%s)' % (app.name, app.uuid)

    if options.remove_all:
        option_selected = True
        manager = FogAppManager()
        for app in manager.get_all():
            app.remove()
            print 'Removed app %s (%s)' % (app.name, app.uuid)

    if options.clean:
        import os
        option_selected = True
        manager = FogAppManager()
        apps = [app.desktop_file for app in  manager.get_all()]
        all_apps = [app for app in Gio.AppInfo.get_all() if 'fogapp' in app.get_keywords()]
        for app in all_apps:
            if not app.props.filename in apps:
                try:
                    os.remove(app.props.filename)
                except:
                    print 'Could not delete file %s' % app.props.filename
                else:
                    print 'Cleaned stale file: %s' % app.props.filename

    if option_selected:
        return

    # Run the application.
    if len(args) > 0:
        def activate_application(application):
            try:
                window.present()
            except NameError:
                pass

        gapp_name = 'net.launchpad.fogger%s' % args[0]
        g_app = Gtk.Application.new(gapp_name, Gio.ApplicationFlags.FLAGS_NONE)
        g_app.connect('activate', activate_application)
        g_app.run(args)
        if g_app.get_is_remote():
            return
        manager = FogAppManager()
        app = manager.get(args[0]) or manager.get_by_name(args[0])
        if app:
            app.run()
            window = app.window
            Gtk.main()
    else:
        window = FoggerWindow.FoggerWindow()
        window.show()
        Gtk.main()