After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 643379 - Glade drag and drop support for Vala
Glade drag and drop support for Vala
Status: RESOLVED FIXED
Product: anjuta
Classification: Applications
Component: plugins: language-support-vala
git master
Other Linux
: Normal normal
: ---
Assigned To: Abderrahim Kitouni
Anjuta maintainers
Depends on:
Blocks:
 
 
Reported: 2011-02-26 20:16 UTC by Abderrahim Kitouni
Modified: 2011-03-07 23:57 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
language-support-vala: don't assert a Document is always an Editor (1.11 KB, patch)
2011-02-26 20:24 UTC, Abderrahim Kitouni
committed Details | Review
libanjuta: use IAnjutaIterable instead of GObject in signals (2.55 KB, patch)
2011-02-26 20:25 UTC, Abderrahim Kitouni
committed Details | Review
language-support-vala: initial support for glade drag and drop (3.81 KB, patch)
2011-02-26 20:29 UTC, Abderrahim Kitouni
reviewed Details | Review
fix typo in the AUTHORS file (787 bytes, patch)
2011-02-26 20:32 UTC, Abderrahim Kitouni
committed Details | Review
language-support-vala: support dropping from glade inside a class (8.66 KB, patch)
2011-03-02 18:27 UTC, Abderrahim Kitouni
reviewed Details | Review
language-support-vala: support dropping from glade inside a class (9.28 KB, patch)
2011-03-07 21:48 UTC, Abderrahim Kitouni
none Details | Review
language-support-vala: indent code inserted from glade dnd (9.74 KB, patch)
2011-03-07 21:50 UTC, Abderrahim Kitouni
none Details | Review

Description Abderrahim Kitouni 2011-02-26 20:16:46 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)
Comment 1 Abderrahim Kitouni 2011-02-26 20:24:06 UTC
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.
Comment 2 Abderrahim Kitouni 2011-02-26 20:25:53 UTC
Created attachment 182013 [details] [review]
libanjuta: use IAnjutaIterable instead of GObject in signals
Comment 3 Abderrahim Kitouni 2011-02-26 20:29:46 UTC
Created attachment 182014 [details] [review]
language-support-vala: initial support for glade drag and drop

(currently, dragging inside a class will produce wrong results)
Comment 4 Abderrahim Kitouni 2011-02-26 20:32:11 UTC
Created attachment 182015 [details] [review]
fix typo in the AUTHORS file

it was causing the about dialog to be too wide
Comment 5 Johannes Schmid 2011-02-27 21:47:10 UTC
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.
Comment 6 Abderrahim Kitouni 2011-02-28 20:35:50 UTC
(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.
Comment 7 Johannes Schmid 2011-02-28 21:36:31 UTC
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.
Comment 8 Abderrahim Kitouni 2011-03-02 18:27:17 UTC
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.
Comment 9 Johannes Schmid 2011-03-02 18:40:00 UTC
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;
}
Comment 10 Abderrahim Kitouni 2011-03-07 12:54:14 UTC
(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?
Comment 11 Johannes Schmid 2011-03-07 13:33:44 UTC
> 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!
Comment 12 Abderrahim Kitouni 2011-03-07 21:48:57 UTC
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
Comment 13 Abderrahim Kitouni 2011-03-07 21:50:46 UTC
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
Comment 14 Johannes Schmid 2011-03-07 23:57:28 UTC
Thanks for your patches, I applied them to master.