GNOME Bugzilla – Bug 643379
Glade drag and drop support for Vala
Last modified: 2011-03-07 23:57:28 UTC
I'm attaching an initial version of the glade drag and drop for Vala. Right now, it is only correct if one drops outside of any class/namespace, fixing those would need bracket matching as I have no way to find where a class/namespace ends from libvala (this will follow in a separate patch). (I'm attaching trivial unrelated patches to bugs because I don't know what to do with them)
Created attachment 182012 [details] [review] language-support-vala: don't assert a Document is always an Editor this is obviously false for a glade document.
Created attachment 182013 [details] [review] libanjuta: use IAnjutaIterable instead of GObject in signals
Created attachment 182014 [details] [review] language-support-vala: initial support for glade drag and drop (currently, dragging inside a class will produce wrong results)
Created attachment 182015 [details] [review] fix typo in the AUTHORS file it was causing the about dialog to be too wide
Comment on attachment 182014 [details] [review] language-support-vala: initial support for glade drag and drop First thanks a lot for working on this for vala! Not sure if I see this correctly but I guess dropping inside a class is the most common case for vala or is this wrong. In that case I would rather default to an in-class handler (and model our project-wizard generated code like this) instead of using out-of-class callbacks.
(In reply to comment #5) > (From update of attachment 182014 [details] [review]) > First thanks a lot for working on this for vala! > > Not sure if I see this correctly but I guess dropping inside a class is the > most common case for vala or is this wrong. In that case I would rather default > to an in-class handler (and model our project-wizard generated code like this) > instead of using out-of-class callbacks. Well, it is. The problem is that I have no way to know whether a drop is inside a class or not, I have the same problem as bug 643139, I don't have a way to detect the end-of-scope for classes/namespaces. I do have some code that works with a hacked libvala, but I don't think my changes would make it to vala, so I'm going to try finding the start of the scope from the current position. In short, I want to support both, but started with this one because it is easier.
OK, well, basically I think it would be better to think the other way round which means we default to create callbacks inside classes. I did the same in python. I hope Marco will succeed with the scope detection though.
Created attachment 182283 [details] [review] language-support-vala: support dropping from glade inside a class This should also fix a bug and locate more accurately where the user is currently typing -- This is the next step: drag and drop now works more or less correctly if you drop inside a class or namespace. However, indentation doesn't work yet. How am I supposed to get an a reference to the indenter plugin? anjuta_shell_get_object("IAnjutaIndenter") returns null here. Am I doing something wrong? and btw, I'm attaching only additions to the previous patch. But if you prefer to commit everything as one patch, that's also fine.
Review of attachment 182283 [details] [review]: See my inline comment below. Otherwise it looks fine. Thanks for working on this! ::: plugins/language-support-vala/locator.vala @@ +26,2 @@ // XXX : assumes that line length < 1000 + location = line * 1000 + column; Why are you messing around with a FIXME like this. It is quite likely that a file has more than 1000 lines. Why is this necessary at all? @@ +33,3 @@ + bool update_location (Vala.Symbol s) { + var begin = s.source_reference.first_line * 1000 + s.source_reference.first_column; + var end = s.source_reference.last_line * 1000 + s.source_reference.last_column; Same here: Just use two variables, one for the line and one for the column. Maybe define a location object like this (sorry, I am not so used to vala): struct Location { public int line; public int location; }
(In reply to comment #9) > Review of attachment 182283 [details] [review]: > > See my inline comment below. Otherwise it looks fine. Thanks for working on > this! > > ::: plugins/language-support-vala/locator.vala > @@ +26,2 @@ > // XXX : assumes that line length < 1000 > + location = line * 1000 + column; > > Why are you messing around with a FIXME like this. It is quite likely that a > file has more than 1000 lines. Why is this necessary at all? It's more a NOTE than a FIXME. And the problem isn't with files that have more than 1000 lines but with lines that have more than 1000 characters (which aren't common, if they even exist). Nevertheless, you're right, I'd better change this since I'm touching it at all. > > @@ +33,3 @@ > + bool update_location (Vala.Symbol s) { > + var begin = s.source_reference.first_line * 1000 + > s.source_reference.first_column; > + var end = s.source_reference.last_line * 1000 + > s.source_reference.last_column; > > Same here: Just use two variables, one for the line and one for the column. > Maybe define a location object like this (sorry, I am not so used to vala): > > struct Location > { > public int line; > public int location; > } Yes, that would be fine. I'll try to do it. And how about the indenter? anjuta_shell_get_object returns null, what could be wrong with this?
> And how about the indenter? anjuta_shell_get_object returns null, what could be > wrong with this? I need to add the IAnjutaIndeter interface to the .plugin.in file of language-support-cpp-java (and -python). Thanks for the reminder!
Created attachment 182775 [details] [review] language-support-vala: support dropping from glade inside a class This should also fix a bug and locate more accurately where the user is currently typing
Created attachment 182776 [details] [review] language-support-vala: indent code inserted from glade dnd Also add IAnjutaIndenter to the .plugin files of l-s-cpp-java and l-s-python
Thanks for your patches, I applied them to master.