What can I use instead of gtk_container_set_focus_chain()? - gtk

The gtk_container_set_focus_chain() function deprecated since GTK 3.24. What can I use instead of?

The link you provided indicates:
Deprecated since: 3.24
For overriding focus behavior, use the GtkWidgetClass::focus signal.
which, of course, is almost fully undocumented (sigh). I have checked the demos and saw nothing related to this, sadly.
From this migration from GTK3 to GTK4 guide:
In GTK 4, any widget can have children (and GtkContainer is gone).
There is new API to navigate the widget tree, for use in widget
implementations: gtk_widget_get_first_child(),
gtk_widget_get_last_child(), gtk_widget_get_next_sibling(),
gtk_widget_get_prev_sibling().
This could be a good place to start.

Related

How to do default styling in swift 3

What's the best way to perform simple default styling?
I'm not interested in styling every single UI element in the interface builder and the UIAppearance proxy seems to be very limited. I am looking for solutions to default styling UI elements with low coupling.
note that i am using swift 3 / xcode 8
UIAppearance is the default styling mechanism in UIKit. It doesn't seem very limited to me, yet it indeed has some downsides. You should give it a try if you haven't yet.
If you're interested in a non-UIAppearance-based approach, it's possible to craft even more powerful custom styling mechanism. For example, I've been able to attach and compose styles in the following manner:
final class CaptionLabel: UILabel, CaptionFontStyle, MultilineLabelStyle
See Style.swift and RootStyle.swift in the StyleSheet library for implementation details (it's really simple and there is an example project as well).

What is LeftNav in material-ui?

I keep seeing references to a component called "LeftNav" in the material-ui react library (example: Material UI - Open LeftNav / Drawer on AppBar click), but I can't find anything about it in the documentation. What is it? How does it differ from Drawer? Why is it apparently undocumented, despite being hugely popular (at least judging by the number of questions I see about how to use it)? What is its toggle() method for, and is there a similar method for Drawer (the documentation suggests not, but for all I would know by reading the documentation there was no such component as LeftNav at all, so I don't think the documentation can really be trusted here)?
<LeftNav/> is the same as <Drawer/>. The name was changed from "LeftNav" to "Drawer" with the release of material-UI version 0.15. Take a look at the change log here and you will see this.

Use what instead of Deprecated GTK CList?

I'm just learning GTK (I'm using C) and I see from https://developer.gnome.org/gtk2/2.24/GtkCList.html#GtkCList-struct that "GtkCList is deprecated and should not be used in newly-written code", but I can't seem to find what should be used instead. Can someone point me in the right direction?
On top of that same page, you have a "description" section where you may read:
GtkCList has been deprecated since GTK+ 2.0 and should not be used in
newly written code. Use GtkTreeView instead.
There's a navigation bar on top which easily allows you to access specific sections of the documentation of the class.

GWT use of interface instead of widget

in a définition of a widget, what is a better practice, and why, use the widget himself or the type "higher", example, it's a better practice to do
1) Button myButton;
or
2) Hastext myButton; (and set a button later)
thanks for your answer.
It is usually a good idea to use "higher" types or interfaces. By doing this properly you can hide implementation details. The code that uses an object looks at it as the one of a higher type and it is not important what is actually hiding behind it. This is good because you can easily change an implementation of the object without breaking anything.
For example when defining a panel in an application you should use Panel class instead of its implementation e.g. HorizontalPanel or VerticalPanel.:
Panel myPanel;
Then you can create a proper implementation of it, e.g HorizontalPanel:
myPanel = new HorizontalPanel();
If you then later decide to change myPanel to be VerticalPanel you will not have to change anything in the code that uses myPanel. Everything will work just fine.
However you must remember that you will be only able to use methods available in Panel class. Additional methods defined in e.g. HorizontalPanel will not be accessible. And this is actually what you should remember when choosing the type of your widgets. Your widgets should be of types which provide methods which you want to use.
In your example using HasText instead of Button isn't probably a good idea because HasText has only methods for setting and getting a text and you probably also want to have access to addClickHandler method available in Button and a few more.
So to summarize it is good to use "higher types" but they should not be "too high" to be useful.
The answer to that lies in the Model-View-Presenter pattern, that was introduced in last years Google IO presentation by Ray Ryan. There's also an official tutorial/docs - part 1 and part 2. There are also a number of questions here on SO that cover that topic :)
And a quick answer to your question (that will make more sense once you get familiar with MVP): use interfaces in the Presenter and their implementations in the View :) That way your Presenter stays oblivious to the underlying implementation/Widget you actually used (was it a Button? Or a Label? It doesn't matter, they both implement HasText).

Get gtk widget name

I'm writing a GTK-Theme that is pretty dark. It works with most programs but some toolbars look pretty strange (in Bluefish and NetBeans for example).
Now I need to get the name of the toolbar widget to write a workaround.
You could use Parasite, although I never used it so I cannot say how it works. Alternatively, you can use the ever working good old way.
Do Bluefish and NetBeans even use Gtk? Not sure what you would in that case, otherwise here is a list of widgets: http://live.gnome.org/GnomeArt/Tutorials/GtkThemes.