Skip to content

Commit

Permalink
Opening multiple files makes them all attachments of the same note.
Browse files Browse the repository at this point in the history
Now when indicator.py is passed multiple positional command line
arguments, they are all added as attachements to one note rather than
argument parsing problems happening.

The desktop file has been edited (1 character change!) so that when
multiple items are selected in Nautilus (or whatever file manager)
they are passed as a list of positional arguments to everpad
(indicator.py). Combined with the previous change, this means that
selecting multiple objects in the file manager and opening them
with everpad (using the menu shortcut) creates a new note with those
attached. The old behavior was to create a new note for each object
with that object attached. That seems like less useful behavior in
general.

Added docstring to ResourceEdit.add_attach

Added new method to ResourceEdit.add_all_attach for adding a list of
attachments at once.

Made the EverpadService.create_wit_attach method take a list of
strings to match the new signature of Indicator.create

(Note: create_wit_attach looks like it should read create_with_attach
- but this is a public service name, so I wasn't sure that it was a
good idea to change it unilaterally.)

Improved English in "--replace" argument description
  • Loading branch information
Eric Moyer committed Feb 10, 2013
1 parent b56c198 commit e360310
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 11 deletions.
2 changes: 1 addition & 1 deletion data/everpad.desktop
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Name=Everpad
GenericName=Everpad
Comment=Evernote client
Comment[ru]=Клиент для Evernote
Exec=everpad %u
Exec=everpad %U
Terminal=false
Icon=everpad.png
Type=Application
Expand Down
18 changes: 18 additions & 0 deletions everpad/pad/editor/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,12 @@ def add(self):
self.add_attach(name)

def add_attach(self, name):
"""Add name as an attachment and return the attachment as a Resource
name - a string containing a filename or url that will be attached
return: the resource object corresponding to the attached object
"""
dest = os.path.expanduser('~/.everpad/data/%d/' % self.note.id)
try:
os.mkdir(dest)
Expand All @@ -200,3 +206,15 @@ def add_attach(self, name):
self._put(res)
self.on_change()
return res

def add_all_attach(self, names):
"""Adds all the entries in names as attachments
names - sequence of strings - each string is treated as a filename or url
No return value
"""
assert not hasattr(names, "strip"); # Ensure that didn't get
# passed a single string
for name in names:
self.add_attach(name);
20 changes: 10 additions & 10 deletions everpad/pad/indicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def create(self, attach=None, notebook_id=NONE_ID):
)
editor = self.open(note)
if attach:
editor.resource_edit.add_attach(attach)
editor.resource_edit.add_all_attach(attach)

@Slot()
def show_all_notes(self):
Expand Down Expand Up @@ -238,9 +238,9 @@ def open_with_search_term(self, id, search_term):
def create(self):
self.app.indicator.create()

@dbus.service.method("com.everpad.App", in_signature='s', out_signature='')
def create_wit_attach(self, name):
self.app.indicator.create(name)
@dbus.service.method("com.everpad.App", in_signature='as', out_signature='')
def create_wit_attach(self, names):
self.app.indicator.create(names)

@dbus.service.method("com.everpad.App", in_signature='', out_signature='')
def settings(self):
Expand All @@ -258,12 +258,12 @@ def kill(self):
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('attachments', type=str, nargs='*', help='attach files 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('--replace', action='store_true', help='replace already running instance')
parser.add_argument('--version', '-v', action='store_true', help='show version')
args = parser.parse_args(sys.argv[1:])
if args.version:
Expand Down Expand Up @@ -301,8 +301,8 @@ def main():
app.indicator.create()
if args.settings:
app.indicator.show_management()
if args.attach:
app.indicator.create(args.attach)
if args.attachments:
app.indicator.create(args.attachments)
if args.all_notes:
app.indicator.show_all_notes()
app.exec_()
Expand All @@ -314,8 +314,8 @@ def main():
pad.create()
if args.settings:
pad.settings()
if args.attach:
pad.create_wit_attach(args.attach)
if args.attachments:
pad.create_wit_attach(args.attachments)
if args.all_notes or len(sys.argv) <= 1:
pad.all_notes()
sys.exit(0)
Expand Down

0 comments on commit e360310

Please sign in to comment.