Re: [Zim-wiki] faster creation of notes

2009-07-07 Thread Pablo Angulo
Jaap Karssenberg escribió:
> The enhanced key bindings could be implemented in zim relatively
> easily. You might want to have a go hacking this in the pyzim port.
> The template part need a little bit more work as we need  a proper
> place to store templates. But just using a namespace is ok for a
> prototype. (OK, the custom treemodel looks scary, but just adding a
> new page to the index should make it show up in the tree.)
I'm already reading pyzim, trying to get a feeling of it. Maybe trying
to make small changes is a good idea.
>
> Two questions though:
> 1) Can we use different key-bindings ?
Sure, Jaap. No particular reason for choosing those ones.
> 2) Can we keep the templates but not have the double editing step.
>
> Reason is that I feel this will be real confusing behavior if you do
> not expect it. Also you might accidentally have a page of the same
> name as a template and have a conflict.
>
> My suggestion would be to use some syntax like "tempalte: pagename" to
> create a page from a template. E.g. typing "book: Snowcrash" would
> create a page "Snowcrash" using the template "book".
That would be definitely be better.

Other idea is: use Tab instead of Enter for the template, so that Enter
always builds the note with that name, but Tab will load the template
and clear the name, or do nothing if the current word is not a template.
The tab key is commonly associated to snippet expansion.

Regards


___
Mailing list: https://launchpad.net/~zim-wiki
Post to : zim-wiki@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zim-wiki
More help   : https://help.launchpad.net/ListHelp


Re: [Zim-wiki] faster creation of notes

2009-07-07 Thread Jaap Karssenberg

Pablo Angulo wrote:

  Hello:
  In my process of learning python + gtk, I've created a zim mock up to
try out a concept. The idea is to make creation of notes a bit faster,
to achieve mind-map speed, but keeping the current treeview used in zim.
This is how it works:

  * Use arrows to move in the treeview, enter to select a note and
control+space to switch to the editor and back, as usual
  * Use alt+arrows to create notes within the TreeView, using the
editable property of this widget. (alt+left for children, alt+down for
sibling)
  * When there are children of the Template folder, if a new note is
created, you might type the template name and hit enter. Then the text
from the template is copied to the new note, and the cell will become
editable one more time so that you can introduce the real name of this note.
  


Hmm, interesting idea. Indeed it speeds up creation of new nodes and 
makes zim feel more like an outliner - as it should feel. And bonus 
points for attaching a running demo !


The enhanced key bindings could be implemented in zim relatively easily. 
You might want to have a go hacking this in the pyzim port.


The template part need a little bit more work as we need  a proper place 
to store templates. But just using a namespace is ok for a prototype. 
(OK, the custom treemodel looks scary, but just adding a new page to the 
index should make it show up in the tree.)


Two questions though:
1) Can we use different key-bindings ?

Reason for asking is that the Alt + arrow combos are in use for 
navigation already. How about Ctrl + arrow ?


2) Can we keep the templates but not have the double editing step.

Reason is that I feel this will be real confusing behavior if you do not 
expect it. Also you might accidentally have a page of the same name as a 
template and have a conflict.


My suggestion would be to use some syntax like "tempalte: pagename" to 
create a page from a template. E.g. typing "book: Snowcrash" would 
create a page "Snowcrash" using the template "book".


Any comments ?

Regards,

Jaap

___
Mailing list: https://launchpad.net/~zim-wiki
Post to : zim-wiki@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zim-wiki
More help   : https://help.launchpad.net/ListHelp


[Zim-wiki] faster creation of notes

2009-07-07 Thread Pablo Angulo
  Hello:
  In my process of learning python + gtk, I've created a zim mock up to
try out a concept. The idea is to make creation of notes a bit faster,
to achieve mind-map speed, but keeping the current treeview used in zim.
This is how it works:

  * Use arrows to move in the treeview, enter to select a note and
control+space to switch to the editor and back, as usual
  * Use alt+arrows to create notes within the TreeView, using the
editable property of this widget. (alt+left for children, alt+down for
sibling)
  * When there are children of the Template folder, if a new note is
created, you might type the template name and hit enter. Then the text
from the template is copied to the new note, and the cell will become
editable one more time so that you can introduce the real name of this note.

  There are two files attached (unless trimmed by the mail manager, in
which case you can copy and paste the files at the end of the email). It
is run by writing:

python zimmindmap.py

  The other file was generated by glade: it is a gtkbuilder file and it
doesn't need any libraries. It has a mock up menu which is totally
useless, and probably in spanish. The template part should really be
better with autocompletion, and maybe it should use grandchildren of the
Templates folder into, but anyway this is just a mockup.

  Do you like this way of creating notes, and/or using Templates?

Regards

--- zimmindmap.py
---
import sys
import gtk

class ZimMindMap(object):
""" mock up of zim to test an idea """
temptitle = 'Title'
templatechar = '.'
   
def __init__ (self):
""" Class initialiser """
self.notes={}
self.current_note = None
   
self.builder = gtk.Builder()
self.builder.add_from_file("zimmindmap.glade")
   
self.window = self.builder.get_object("mainwindow")
self.noteeditor = self.builder.get_object("noteeditor")
self.noteindex = self.builder.get_object("index")

self.datamodel = gtk.TreeStore(str)

self.cellrender=gtk.CellRendererText() # renderer para la
primera columna
self.title_column = gtk.TreeViewColumn('Notes')
self.title_column.pack_start(self.cellrender,True)
self.title_column.add_attribute(self.cellrender, "text", 0)
self.noteindex.append_column(self.title_column)

uno = self.newnote('Hello1')
dos = self.newnote('Hello2')
self.newnote('Hello11',uno)
self.newnote('Hello12',uno)
self.newnote('Hello21',dos)
self.newnote('Hello22',dos)
templates_iter=self.newnote('Templates')
self.templates_root = self.datamodel.get_path(templates_iter)

self.noteindex.set_model(self.datamodel)
self.builder.connect_signals(self)  

def newnote(self, title, parent=None, texto=None):
it = self.datamodel.append(parent, (title,))
path = self.datamodel.get_path(it)
if not texto:
texto=title
self.notes[path] = texto
return it

def delnote(self, path):
iter=self.datamodel.get_iter(path)
self.datamodel.remove(iter)
del self.notes[path]

def on_mainwindow_destroy(self,widget,data=[]):
gtk.main_quit()

def on_mainwindow_key_release_event(self,widget,data=[]):
if data.keyval==32  and (data.state& gtk.gdk.CONTROL_MASK):  
#Control+space
if self.noteeditor.is_focus():
self.noteindex.grab_focus()
else:
self.noteeditor.grab_focus()
return True
def on_index_key_press_event(self,widget,data=[]):
#65361: left, 65362:up, 65363: right, 65364:down, 65293:Enter,
32:space
if data.keyval==65363:   #right
current_row,current_column=widget.get_cursor()
current_iter=self.datamodel.get_iter(current_row)
widget.expand_row(current_row,False)
if data.state & gtk.gdk.MOD1_MASK:#Alt+Left
new_note_iter=self.newnote(ZimMindMap.temptitle,
parent=current_iter)
new_note_path=self.datamodel.get_path(new_note_iter)
#widget.expand_row(new_note_path,True)  #doesn't work if
current_row only has just this child
widget.expand_row(current_row,True) #not the right
thing, but works
self.cellrender.set_property('editable',True)
   
self.cellrender.connect('edited',self.edited_cell,self.datamodel)
self.noteindex.set_cursor(new_note_path,
focus_column=self.title_column ,start_editing=True)
elif data.keyval==65364 and (data.state&
gtk.gdk.MOD1_MASK):#Alt+down
current_row,current_column=widget.get_cursor()
current_iter=self.datamodel.get_iter(current_row)
parent_iter=self.datamodel.iter_parent(current_iter)
parent_path=self.datamodel.get_path(parent_iter) if
parent_iter else ()
new_note_i