Creating GTK Widget Using Expander

2019-04-17 03:38发布

I am trying to create GTK Widget like shows in following Images

alt text

Is it possible to create it in GTK+ under C, I tried using GtkExpander but it is not working out ...

Can any one Help....

标签: gtk
2条回答
Explosion°爆炸
2楼-- · 2019-04-17 04:10

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.

查看更多
一夜七次
3楼-- · 2019-04-17 04:22

If what you want is to duplicate the look, then there are two very inefficient solutions to the problem:

  1. Write your own GTK theme engine (see Murrine or Clearlooks).
  2. 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.

查看更多
登录 后发表回答