Esempio n. 1
0
def main():
    signal.signal(signal.SIGINT, signal.SIG_DFL)
    parser = argparse.ArgumentParser()
    parser.add_argument('attach', type=str, nargs='?', help='attach file to new note')
    parser.add_argument('--open', type=int, help='open note')
    parser.add_argument('--create', action='store_true', help='create new note')
    parser.add_argument('--all-notes', action='store_true', help='show all notes window')
    parser.add_argument('--settings', action='store_true', help='settings and management')
    parser.add_argument('--replace', action='store_true', help='replace already runned')
    parser.add_argument('--version', '-v', action='store_true', help='show version')
    args = parser.parse_args(sys.argv[1:])
    if args.version:
        print_version()
    if args.replace:
        try:
            pad = get_pad()
            pad.kill()
        except dbus.exceptions.DBusException:
            pass
    fp = open('/tmp/everpad-%s.lock' % getpass.getuser(), 'w')
    try:
        fcntl.lockf(fp, fcntl.LOCK_EX | fcntl.LOCK_NB)
        app = PadApp(sys.argv)
        app.setApplicationName('everpad')
        dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
        session_bus = dbus.SessionBus()
        app.provider = get_provider(session_bus)
        app.provider.connect_to_signal(
            'sync_state_changed',
            app.on_sync_state_changed,
            dbus_interface="com.everpad.provider",
        )
        app.launcher = get_launcher('application://everpad.desktop', session_bus, '/')
        bus = dbus.service.BusName("com.everpad.App", session_bus)
        service = EverpadService(app, session_bus, '/EverpadService')
        if args.open:
            app.indicator.open(args.open)
        if args.create:
            app.indicator.create()
        if args.settings:
            app.indicator.show_management()
        if args.attach:
            app.indicator.create(args.attach)
        if args.all_notes:
            app.indicator.show_all_notes()
        app.exec_()
    except IOError:
        pad = get_pad()
        if args.open:
            pad.open(args.open)
        if args.create:
            pad.create()
        if args.settings:
            pad.settings()
        if args.attach:
            pad.create_wit_attach(args.attach)
        if args.all_notes:
            pad.all_notes()
        sys.exit(0)
Esempio n. 2
0
def main():
    signal.signal(signal.SIGINT, signal.SIG_DFL)
    parser = argparse.ArgumentParser()
    parser.add_argument("attach", type=str, nargs="?", help="attach file to new note")
    parser.add_argument("--open", type=int, help="open note")
    parser.add_argument("--create", action="store_true", help="create new note")
    parser.add_argument("--all-notes", action="store_true", help="show all notes window")
    parser.add_argument("--settings", action="store_true", help="settings and management")
    parser.add_argument("--replace", action="store_true", help="replace already runned")
    parser.add_argument("--version", "-v", action="store_true", help="show version")
    args = parser.parse_args(sys.argv[1:])
    if args.version:
        print_version()
    if args.replace:
        try:
            pad = get_pad()
            pad.kill()
        except dbus.exceptions.DBusException:
            pass
    fp = open("/tmp/everpad-%s.lock" % getpass.getuser(), "w")
    try:
        fcntl.lockf(fp, fcntl.LOCK_EX | fcntl.LOCK_NB)
        app = PadApp(sys.argv)
        app.setApplicationName("everpad")
        dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
        session_bus = dbus.SessionBus()
        app.provider = get_provider(session_bus)
        app.provider.connect_to_signal(
            "sync_state_changed", app.on_sync_state_changed, dbus_interface="com.everpad.provider"
        )
        app.provider.connect_to_signal("data_changed", app.on_data_changed, dbus_interface="com.everpad.provider")
        app.launcher = get_launcher("application://everpad.desktop", session_bus, "/")
        bus = dbus.service.BusName("com.everpad.App", session_bus)
        service = EverpadService(session_bus, "/EverpadService")
        if args.open:
            app.indicator.open(args.open)
        if args.create:
            app.indicator.create()
        if args.settings:
            app.indicator.show_management()
        if args.attach:
            app.indicator.create(args.attach)
        if args.all_notes:
            app.indicator.show_all_notes()
        app.exec_()
    except IOError:
        pad = get_pad()
        if args.open:
            pad.open(args.open)
        if args.create:
            pad.create()
        if args.settings:
            pad.settings()
        if args.attach:
            pad.create_wit_attach(args.attach)
        if args.all_notes:
            pad.all_notes()
        sys.exit(0)
Esempio n. 3
0
 def run(self, context, match):
     data = match.data().toInt()[0]
     pad = get_pad()
     if data == CREATE:
         pad.create()
     elif data == SETTINGS:
         pad.settings()
     else:
         pad.open(data)
 def do_activate(self, result, metadata, id):
     obj = json.loads(result.uri)
     everpad = get_pad()
     everpad.open_with_search_term(int(obj['id']), obj.get('search', ''))
     return Unity.ActivationResponse(handled=Unity.HandledType.HIDE_DASH, goto_uri=None)
Esempio n. 5
0
 def handle_uri(self, scope, uri):
     obj = json.loads(uri)
     get_pad().open_with_search_term(int(obj['id']), obj.get('search', ''))
     return self.hide_dash_response()
Esempio n. 6
0
 def handle_uri(self, scope, uri):
     obj = json.loads(uri)
     get_pad().open_with_search_term(int(obj['id']), obj.get('search', ''))
     return self.hide_dash_response()
Esempio n. 7
0
 def handle_uri(self, scope, id):
     get_pad().open(int(id))
     return self.hide_dash_response()