Ocaml lablgtk2 custom widget? - gtk

I've been learning Ocaml with lablgtk2 for a while and still searching for a tutorial in which describe a way to create a custom widget (I want to make this widget as a circle filled with color and some text in the center). And this custom widget can be set ~width, ~height, ~label, ~packing,... to another container (as another gtk widgets can).
unfortunately, I found no tutorial about this. I read how to make custom widget in gtk2+ and try to port into Lablgtk2 but still can't help.
Can anyone help me with this issue.
Really appreciate.

I hoped that someone would prove me wrong by answering this question, but here is what I wrote in a comment:
I asked about this to one of the
co-maintainers of lablgtk2, and the
answer is that what you want to do is
not really convenient to do in
lablgtk2 and you would be better of
doing that part in C. Sorry.

Related

Flutter / Dart components visual scheme?

This might be a bit out of the box question, but not being much of an abstract thinker, I find dart syntax unreasonably confusing. Apparently, for example, ThemeData is a widget that is also a class that has a class dark() that has a property that is actually a constructor, that has a class... Pure nonsense.
Does anyone has a link to a nice, clear, schematic, visual explanation of how the components are actually called, how are they connected together etc, so that the person that has more of a visual perception can understand what's going on?
I did some coding in the past, but I'm having hard times getting my head around flutter / dart syntax, as if entire google sat together and said "how we can make it look as confusing as possible? Maybe we can make Color and Colors two different classes? Great! More ideas like that anyone?!"
Any leads to a common sense, not written-by-developer explanation is greatly appreciated.
Widget is a class. So every extension of Widget is also a class.
Each class can have one constructor. There can be "named constructions", so-called factories which are predefined constructors, like ThemeData's dark().
Finally Color is a class that describes a single color. Colors is a class that holds a lot of constants for you to use.
It is not that difficult at the end of the day, but you cannot expect to learn it all at once.

How do you remove a Gdl.DockItem from Gdl.Dock?

I'm using the libgdl in Python using GObject introspection. Does anybody know how to remove a Gdl.DockItem from a Gdl.Dock? I've tried:
dock.remove(dockitem)
and
dock.master.remove(dockitem)
And I've also tried destroying the dockitem and it's child widget. Can't seem to find an example of where this is done.
Figured it out. I was looking for the unbind() method. So, if somebody stumbles upon this, it looks a little like this:
dockitem.unbind()
widget.destroy() # where widget was originally added to dock item

where's the code for Calculator showcase?

Where can I see the code for the calculator? I mean the one with fancy background? By the way, it looks very nice!!
In general, I could not find enough material for custom-made decoration, by searching the documents. Please let me know where I can learn deeper about rendering and widget decoration.
Thanks in advance :)
You can find the source code of the calculator page in the qooxdoo SDK under
qooxdoo/application/showcase/source/class/showcase/page/theme/calc/
There is also a standalone version of the calculator on github. You can find more information about theming in the qooxdoo manual:
Theming
Appearance
Custom Themes
Decorators

Creating GTK Widget Using Expander

I am trying to create GTK Widget like shows in following Images
Is it possible to create it in GTK+ under C,
I tried using GtkExpander but it is not working out ...
Can any one Help....
Stripping the arrow is quite trivial. Just append the following code to you $HOME/.gtkrc-2.0 (or create it if not found):
style "pradeep" {
GtkExpander::expander-size = 0
GtkExpander::expander-spacing = 0
}
widget "*.GtkExpander" style "pradeep"
This is done by customizing the appearance using resource files. You can get the same result programmatically by changing the GtkExpander style properties.
Furthermore, you can connect your own callback to its "activate" signal and switch the background color of the widget whenever is active or not. And a lot more...
Just remember someone loves to have a consistent user interface.
If what you want is to duplicate the look, then there are two very inefficient solutions to the problem:
Write your own GTK theme engine (see Murrine or Clearlooks).
Replace your entire program by a GtkDrawingArea widget and use Cairo to draw exactly the look you want. You'll be on your own then, though, so you'll have to write all your widget placement algorithms, buttons, expanders, menus, and whatnot, from scratch.
GTK isn't really meant for this sort of thing. The whole point of GTK is that you design your user interface with the standard widgets, and they just work with whatever theme, language, or accessibility technologies your users need to use. If you design your own look and there's no way to change it, then someone with color blindness or poor eyesight won't be able to use it. Or the text will get all misaligned if someone uses your application in another language. Or at the very least, maybe someone just likes a black desktop with white lettering, and your application will stick out and look really ugly on that user's computer. If you really need to make it look exactly that way, then probably GTK isn't the right tool for you.

How to use GdkPixBuf?

I want to display a simple GIF image in a VBox using GTK+ from C. I know that I need to use a GdkPixbuf. But as usual there are no example of doing it. Can anyone provide help?
Also: In GTK+ how can we add a PNG image as background to a widget? Can anyone provide an example?
Forgot something to add this:
forgot to tell u that i am using Glade to develop GUI...
And i have created vBox in Glade and in one of the blocks of the vBox i need to display FIG Image....
Sorry of this...
gdk_pixbuf_new_from_file() -- but see unwind's answer for a better way to do it using a GtkImage widget.
You need to set the background pixmap field in the widget's style structure:
GtkRcStyle *newstyle = gtk_widget_get_modifier_style(widget);
newstyle->bg_pixmap_name[GTK_STATE_NORMAL] = g_strdup(pngfilename);
gtk_widget_modify_style(widget, newstyle);
PS. You can often find code examples by doing a Google search for the function you need an example of. The GTK docs usually don't contain examples for every single function, because that would clutter them up, and the documentation of functions like gdk_pixbuf_new_from_file() is usually pretty straightforward. I've noticed you often post this kind of question and I'm wondering if you are looking for the documentation in the right place. For example, are you using the excellent reference tool DevHelp? On the other hand, the GTK documentation is really missing some important information in a few places. If you have some improvements, why not contribute to the documentation?
A vbox in GTK+ is a widget, that displays other widgets as its children, stacking them vertically.
Unsurprisingly, there is a GTK+ widget dedicated to displaying images; it's called GtkImage. You should use the gtk_image_new_from_file() call to create one, passing it your GIF filename, and then just add that to your vbox. There's no need to create the underlying GDK image yourself.