I've created a custom Gtk Widget with a template, and I want to use it on other Gtk Builder file.
What I've done:
Wrote a .ui file with <template class="G3JAMinScenes" parent="GtkBox">
Wrote widget source code (.c/.h)
when I create it with g3jamin_scenes_new the widget works as expected, the problem is that I want to add it as child of a window using Gtk Builder, so I wrote:
...
<child>
<object class="G3JAMinScenes" parent="GtkBox" id="scnes">
</object>
</child>
...
but it throws an error when I try to run:
Gtk-CRITICAL **: Error building template class 'G3JAMinAppWindow' for an instance of type 'G3JAMinAppWindow': Invalid object type `G3JAMinScenes'
I haven't been able to find any official answer to this in any documentation. I went digging through the GTK+ source and found a few things though.
When GtkBuilder sees a type it doesn't know about yet, it tries to obtain a function that returns the relevantGType. It will try a couple of heuristics to determine what function to call. If you are using one of the G_DEFINE_TYPE family of macros, it will generate the necessary mywidget_get_type style function that is needed. If you are doing something weird, you can also specify the function in the type-func attribute for the object in your ui file.
But, for simple programs that probably isn't going to work (at least on Linux) because the compiler probably isn't going to export the function in the dynamic symbol table, and so GtkBuilder won't be able to find it. So you are left with a few options.
Call mywidget_get_type() somewhere early in your application. This will register the type in the GObject type system and GtkBuilder will be able to find it. I am using a subclass of GtkApplication, so I'm calling it in my myapp_class_init. This feels a little bit like a hack, but I settled on this solution because it seems like it should be portable to every situation.
If you are using GCC, link the final executable with -rdynamic. This will put all symbols in the dynamic symbol table so the magic described above will allow GtkBuilder to find it.
Build your widget in a shared library. I haven't tried this one, but I believe it should work for the same reason that -rdynamic works.
Related
I need to get the list of all defined widgets in a nlogo script in headless mode. I basically need to the targeted variables and the default values. But I just find private methods in the API to achieve this (https://github.com/NetLogo/NetLogo/blob/5.x/src/main/org/nlogo/headless/HeadlessModelOpener.scala#L136-L234). Is there a public method from the API to achieve this ?
Thanks
Mike Horn solved this by parsing through the .nlogo file in his NetTango project. If you're okay with that, take a look at his Model.java load() method, and initSlider(), initSwitch(), and initPlot() methods. I don't remember the exact relative line location of default value for the other widget types, but if you open a .nlogo file in a text editor, you should be able to figure it out.
Correct me if I am wrong, but it appears that CoffeeScript does not compile/join code (each class has its own file) in the correct order.
If I have these classes in the following files:
Button.coffee
class Button extends UIComponent
UIComponent.coffee
class UIComponpent
When I compile these classes (using the --join flag), it outputs the classes in the incorrect order (i.e. putting Button ahead of UIComponent). So when the referenced .js file is used on a web page, it throws the "Cannot read property 'prototype' of undefined" error
Is this an issue that anyone else experiences? If so, is the standard use of CoffeeScript to not use classes? I'm just confused on why this doesn't appear to be a standard implementation? Perhaps I am using CoffeeScript incorrectly.
CoffeeScript isn't responsible for your dependency management.
You could use something like require.js to define your dependencies, then use CoffeeScript to compile your JavaScript files separately, and then use the r.js optimiser to minify and concatenate your compiled JS.
Is there a way to find complete class info of an object in Lazarus. F1 doesn't work.
For example, I want to know the methods, events and properties of TSQLQuery. More specifically, I'm trying to find what constants I can use with the state property.
The docs I've found so far aren't really much help in this context.
I've also tried the menu that says 'object browser' but it simply points to the properites window.
TSQLQuery and its unit sqldb is not documented.
The state property however is from the base tdataset ancestor of sqlquery, and that IS documented.
Try typing TDatasetstate or tdataset and press F1
The best documentation is the source code. After you dropped a TSQLQuery on the form CTRL-click on the identifier "TSQLQuery" in the source editor. Lazarus will open the corresponding source file at the position where TSQLQuery is declared. Scroll down to the public methods or published properties to see everything you need. Identifiers usually are self-explanatory - the chm file often does not contain more info. And the source is always up-to-date.
You can do the same with any identifier. Depending on the Lazarus version you may land in the implementation part of the unit. In this case, just press SHIFT-CTRL Up/Down to go to the interface.
Does anybody know how to create his own models and controllers in Orchard-based projects? I have an empty project and a pack of screenshots for pages, but I don't know with what to begin. If it is possible, please show an example.
Thanks.
You should start off at the documentation page. There is an 'Extending Orchard' section which walks you through how to create a module, with data access, content parts, and content fields.
Use the command line to generate the module using the code generation module
Documentation here
Then install the Code Generation Extensions from Piotr and follow the instructions on his blog. http://www.szmyd.com.pl/blog/generating-orchard-content-parts-via-command-line
Module adds an Orchard command-line command “codegen part”. It’s
syntax is as follows:
codegen part [/Properties:]
For example:
codegen part Modules.Shop ProductPart /Properties: Name:string,
Price:int
Properties is an optional parameter, so if you’d like to create an
empty part you can just write
codegen part Modules.Shop ProductPart
The command creates a handler, driver, model, record, display and
editor shapes and updates the Placement.info file with default
Content:before placement for your part shape. If you provide
/Properties parameter, the model, record and editor shapes will be
filled with appropriate code accordingly.
I'm trying to work through groovy's Implementing Local AST Transformations tutorial, but whenever I clean my project I get this error in each file that has the #WithLogging annotation in it:
Groovy:Could not find class for Transformation Processor AC.LoggingASTTransformation declared by AC.WithLogging
So you have a package named "AC" that contains both "WithLogging.groovy" and "LoggingASTTransformation.groovy" classes? Does it also contain any classes that implement the "WithLogging" interface?
If so, I'd suggest you move the class(es) that use your annotation to a location outside of the annotation defining package (the default will suffice, for diagnostic purposes) - Order of compilation matters with transformations. See this post on the groovy users mailing list for more on that.
Also try changing the annotation from #WithLogging to #AC.WithLogging.
As far as cleaning with Eclipse is concerned, I had a similar issue and found that I had to make a trivial modification after a clean to any file that contained my annotation. IE, add a space somewhere. Then save the file. This should rebuild everything properly.