Created
November 10, 2014 15:47
-
-
Save mattiasb/4a8865b622664e82c895 to your computer and use it in GitHub Desktop.
Templates discussion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mattiasb Is it possible to put your own custom classes inside | |
gtkbuilder ui-files? Or do you need to do work on the | |
gtkbuilder side for that to work? | |
baedert you mean custom widgets? | |
mattiasb And if it works: does it also work for, say, gjs? | |
mattiasb baedert: ah, yeah exactly | |
xjuan mattiasb, yes you can | |
xjuan what I do not remember is if you need to have your | |
class referenced or not | |
mattiasb What I'm after is to have a main-window.ui file be a | |
template for my custom window widget (inheriting from | |
GtkWindow) and then let that ui file use some other | |
templated custom widgets inside them etc. | |
mattiasb xjuan: that sounds encouraging. | |
xjuan mattiasb, yeah as long as you have a properly named | |
_get_type() function it should work automatically | |
mattiasb xjuan: cool, I need to experiment with this a bit. | |
xjuan I do not know how javascript bindings works | |
xjuan I mean, does the binding create a new derived GObject | |
class when you define your JavaScript class? | |
xjuan I know that python binding does | |
xjuan but I never used gjs | |
mattiasb xjuan: I have no idea. :/ | |
xjuan mattiasb, so when you make your custom widget derive | |
from GtkWindow for example | |
xjuan newType.prototype = Object.create (parent.prototype); | |
xjuan newType.prototype.constructor = newType; | |
xjuan I assume you do something like that ^^ | |
xjuan or perhaps there is a special gjs function to derive | |
from a Gtk class | |
xjuan so I wonder if g_type_get_from_name("newType") returns | |
a new GType :) | |
mattiasb xjuan: yeah there's some special class-stuff there. | |
Basically it looks like this: | |
https://git.gnome.org/browse/gnome-maps/tree/src/notification.js#n29 | |
xjuan mattiasb, looks nice | |
mattiasb but so yeah what I need to do is check whether the | |
gtypes get registerred somewhere? | |
mattiasb ..that or just try it out and see if it fails :) | |
xjuan yeah just try to create a widget using GtkBuilder | |
mattiasb and if it doesn't work I know where to start and fix it :) | |
mattiasb thanks a lot! | |
xjuan if it does not work, try creating an instance manually | |
before using GtkBuilder |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment