Replies: 2 comments 3 replies
-
|
Don't you only need to use the fully qualified names when there is a conflict? I don't think you need to do that for ApplicationWindow. Only for the Application ones, and then you could use an alias when you import them. The alternative that I know of is to add a prefix or postfix to the class name, so that it doesn't conflict. But this becomes quite complicated, as we add new libraries, since we can't foresee what will conflict. For example, Adwaita has an Application as well. I think the way giD is doing this now, is the best way. Those who want a shorter name to use in their application can just import it as an alias. Example: import gio.application : AppGio = Application;
import gtk.application : AppGtk = Application;
import adw.application : AppAdw = Application;Then just use them as |
Beta Was this translation helpful? Give feedback.
-
|
I manually added public imports and the aliases to test it out. I also cheated and used the import std.stdio;
import gio.types; // ApplicationFlags
import gtk.label; // Label
import gtk.application_window;
import gtk.box;
import gtk.types; // Orientation
import adw.application; // Application
int main() {
auto app = new ApplicationAdw("org.lekic.gid-examples.adw1.Mini", ApplicationFlags.DefaultFlags);
app.connectActivate((ApplicationGio appArg) {
auto label = new Label("Hello World!");
auto box = new Box(Orientation.Vertical, 4);
box.append(label);
auto window = new ApplicationWindow(app);
window.setTitle("Hello");
window.setDefaultSize(200, 200);
window.setChild(box);
window.present();
});
return app.run();
} |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
So in parallel with my new Adwaits PR I worked on a tiny example to show at least how to create and run Adwaits application.
The code above is more less the same what they have in this document: https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1.6/initialization.html
What I want to discuss here is if we can avoid explicitly using all those fully qualified names.
If I have to do that for a small application like this, imagine how frustrating it would be for something serious
(I know, I am migrating my DIDE application to gid:gtk3 and I had the same set of issues there too).
connactActivate takes gio.application.Application so I have to explicitly put that in the signature.
ApplicationWindow (gtk.application_window.ApplicationWindow) takes gtk.application.Application so I have to cast the gio.application.Application there...
I wanted to make as small application that is as close to the example from Adwaita as possible, and it turned out to be uglier than the C code they have there! :)
So, can we do something about this?
Beta Was this translation helpful? Give feedback.
All reactions