View previous topic :: View next topic |
Author |
Message |
hauptmech
Joined: 14 Jan 2007 Posts: 20 Location: Wellington, NZ
|
Posted: Fri Jan 19, 2007 10:08 pm Post subject: Questions about signals |
|
|
Ant,
As I'm working through the gtk tutorial the only thing about duit that gives me pause is translating the signals connect code.
the DerivedWidget.addOnEvent(delegate(DerivedWidget) dlg) implementation seems to restrict me to callbacks that pass DerivedWidget.
Did you have ideas for a more flexible implementation?
What about adding Signals methods to ObjectGTK?
Code: |
public class ObjectGtk : ObjectG
{
uint connectData(char[] detailedSignal, GCallback cHandler, void* data, GClosureNotify destroyData, GConnectFlags connectFlags)
{
return g_signal_connect_data(this.getStruct(), Str.toStringz(detailedSignal), cHandler, data, destroyData, connectFlags);
}
//etc...
} |
also... Why is getStruct() private? _________________ -hauptmech |
|
Back to top |
|
|
kaarna
Joined: 03 Apr 2006 Posts: 92 Location: Finland
|
Posted: Sat Jan 20, 2007 5:59 pm Post subject: |
|
|
I been thinking that getStruct() should be public, because that way it would be possible to do stuff with GTK+ functions, in cases where the Duit API isn't covering the thing that the programmer wants to achieve.
(And that's the way it is in Gtkmm (the C++ bindings for GTK+). They have a public method that returns the gobject for every class, and it's named gobj().) |
|
Back to top |
|
|
Ant
Joined: 06 Mar 2004 Posts: 306 Location: Canada
|
Posted: Sun Jan 21, 2007 11:24 pm Post subject: |
|
|
satelliittipupu wrote: | I been thinking that getStruct() should be public... |
You too? you guys maybe right.
I saw some cases where it might be useful but my idea was to request some additions to the gtk API...
The problem I see is portability (of course) as we don't have a C compiler as gtkmm has (is).
Any one on my side?
Also I don't look at other bindings because of the posibility of releasing Duit on a different license (please note: rapidly diminishing possibility).
Ant |
|
Back to top |
|
|
kaarna
Joined: 03 Apr 2006 Posts: 92 Location: Finland
|
Posted: Mon Jan 22, 2007 6:47 am Post subject: |
|
|
I've just noticed that there are public methods e.g. in Button.d called getButtonStruct() which returns a GtkButton*. So those are enough for me. I don't need getStruct() to be public. I don't really have an opinion, as I don't know all the stuff that this would effect.
I got Cairo Patterns working with getPatternStruct(), but I had a little less luck with Cairo Matrix, as there was no Matrix.create() that would wrap cairo_matrix_create(). |
|
Back to top |
|
|
kaarna
Joined: 03 Apr 2006 Posts: 92 Location: Finland
|
Posted: Mon Jan 22, 2007 6:59 am Post subject: |
|
|
And regarding the original issue with the way signals are being handled:
There was just a quick note by somebody here regarding the signals:
http://www.flickr.com/photos/michaeldominic/329290303/
And here's a direct quote:
"Yeah, I'm going to try getting DUI (T) working. Though, after a very quick look around, I'm not 100? happy with the way signals/events are being boud."
So, I think that Duit would benefit very much, if it's signals would be better. Again, I'm no expert in the matter, and haven't had that many problems with Duit's signals, but it is a bit restricting to have to have certain kind of arguments in functions that one wishes to use as signal callbacks. I don't know how such a system should be made, but I've heard there are some implementations of signal/slot systems in D. And maybe it would be wise to use one of those existing implementations? |
|
Back to top |
|
|
Ant
Joined: 06 Mar 2004 Posts: 306 Location: Canada
|
Posted: Mon Jan 22, 2007 12:33 pm Post subject: |
|
|
satelliittipupu wrote: | So, I think that Duit would benefit very much, if it's signals would be better. |
Ok, something has to be done.
But I might need help to figure out what to do.
Ant |
|
Back to top |
|
|
kaarna
Joined: 03 Apr 2006 Posts: 92 Location: Finland
|
Posted: Sat Jan 27, 2007 4:54 pm Post subject: |
|
|
I remembered that once there was an announcement about signal/slot being added to Phobos. And then I searched for it and here's a great page with links concerning the issue:
http://www.digitalmars.com/d/phobos/std_signals.html
I'm not sure if the Phobos implementation is optimal or not, and it propably would be wise to wait and see what Tango has to offer on this front (if anything). But if somebody wants to study the issue, then that seems to be a great collection of links... |
|
Back to top |
|
|
Ant
Joined: 06 Mar 2004 Posts: 306 Location: Canada
|
Posted: Sat Jan 27, 2007 6:01 pm Post subject: |
|
|
satelliittipupu wrote: | I remembered that once there was an announcement about signal/slot being added to Phobos. And then I searched for it and here's a great page with links concerning the issue:
http://www.digitalmars.com/d/phobos/std_signals.html
I'm not sure if the Phobos implementation is optimal or not, and it propably would be wise to wait and see what Tango has to offer on this front (if anything). But if somebody wants to study the issue, then that seems to be a great collection of links... |
The problem is that the signal can only be connect to an object, not a method
(or something like that, I looked at it at the time)
I figured it will not be an improvement in simplicity or expressiveness
(even if the signal could be connected to a method - but I would take another look at it if it was to change).
But...
What is missing in the signal handelling?
What direction should we take?
For the use I give Duit the current status is suficient...
Ant |
|
Back to top |
|
|
kaarna
Joined: 03 Apr 2006 Posts: 92 Location: Finland
|
Posted: Sun Jan 28, 2007 4:24 am Post subject: |
|
|
Ant wrote: |
For the use I give Duit the current status is suficient...
Ant |
You are right about that. It's very usable as it is now. I don't think this issue is the number one issue for Duit yet. |
|
Back to top |
|
|
Ant
Joined: 06 Mar 2004 Posts: 306 Location: Canada
|
Posted: Sun Jan 28, 2007 10:30 pm Post subject: Re: Questions about signals |
|
|
hauptmech wrote: | As I'm working through the gtk tutorial the only thing about duit that gives me pause is translating the signals connect code.
...
Did you have ideas for a more flexible implementation?
|
I reviewed the GObject signals.
I see what you mean.
Duit just ignores the wrapping of the signals and make a simple binding of the functions.
That's prety unusable.
Something can be done, suggestions are welcome but at least now I have an idea of where to go.
This is not my top priority - let me know if it should be,
Ant |
|
Back to top |
|
|
hauptmech
Joined: 14 Jan 2007 Posts: 20 Location: Wellington, NZ
|
Posted: Sun Jan 28, 2007 10:55 pm Post subject: |
|
|
The bindings are in place. Each D wrapper object points to a gtk object... So you can make anything you need to happen work if you drop down to the bindings level...
I would say anything fancy with the D wrapper and signals can wait. The person that needs some intricate functionality out of duit probably knows enough to suggest an implementation.
I *would* like to see the Signals macros all bound so I can follow along with the tutorial... I suppose I will get around to it since I'm the only one that wants it at the moment. _________________ -hauptmech |
|
Back to top |
|
|
Lutger
Joined: 25 May 2006 Posts: 91
|
Posted: Fri Feb 09, 2007 6:36 am Post subject: |
|
|
Hi, I'm new to duit (and linux too), but already quite impressed.
At the moment I don't have much time and I need to learn about gtk more to have any input, but maybe the signal slot library I wrote could be of some use? It is less limited than the one in phobos (functions, functors, return values, etc. are supported).
Anyway it is not my intention to spam here , but take a look if you want:
http://lutger.ifastnet.com/sslot/signal.html
http://lutger.ifastnet.com/ |
|
Back to top |
|
|
pmfp
Joined: 25 May 2004 Posts: 7 Location: Sweden
|
Posted: Mon Apr 16, 2007 3:40 pm Post subject: |
|
|
Ant, I think you're doing a great work. GtkD is much farther along than the initial impression, proved by the test app included. Just need to rename the Forums and Project name too.
I think it would be a good idea to look at how others have made bindings in the past and learn from their mistakes. Take anything that's useful. Gtk-sharp is a good example. Whatever you decide upon, keep D's capabilities in mind.
A gtk-sharp example with signals...
Code: | using System;
using Gtk;
public class GtkHelloWorld {
public static void Main() {
Application.Init();
Window win = new Window("Event handler test");
win.Resize(200, 200);
// One way to add a signal handler.
win.DeleteEvent += OnDeleteEvent;
Button my_button = new Button("Geuten heute alle leute!");
// Another way to add a signal handler.
my_button.Clicked += new EventHandler(OnButtonClickedEvent);
win.Add(my_button);
win.ShowAll();
Application.Run();
}
private void OnButtonClickedEvent(object sender, EventArgs args) {
sender.Label = "Good morning!";
}
private void OnDeleteEvent(object sender, DeleteEventArgs args) {
Application.Quit();
}
} |
|
|
Back to top |
|
|
sclytrack
Joined: 14 Jul 2006 Posts: 14
|
Posted: Tue Apr 17, 2007 6:33 am Post subject: Duit on a different license (please note: rapidly diminishin |
|
|
Also I don't look at other bindings because of the posibility of releasing Duit on a different license (please note: rapidly diminishing possibility).
Apparently one can not inherit from classes from a shared library (I think). Shared libraries
must expose plain functions to the end application.
Code: |
MyClass getMyClass();
|
Now most likely the first window in an application is called MainWindow. That would be something like class MainWindow:GtkWindow (I haven't used gtkD yet). This doesn't work. (for me at least, disclaimer) The linker is totally separated from the compiler.
Commercial closed source developers will have a hard time using it.
This inheritance is possible with C# with something called assemblies, works out of the box, I don't know how (disclaimer).
Maybe it will be possible in the future for D. I see the following line in the DDL project as one of their possible future objectives.
Quote: |
Seamless class interop between dynamic libraries (runtime dynamic inheritance for example)
|
Please don't shoot me for any mistakes made in this post, but if you do ...
make it a headshot.
Please keep possibility open, beg beg beg _________________ AMD Athlon 1800+
Debian Etch 4.0 (stable)
Geforce 2 MX
Please no comments about me passing a 4x4 matrix by value. |
|
Back to top |
|
|
|