Gtk Button Theming 'suggested-action' and 'destructive-action'
Posted
#1
(In Topic #1087)
Regular

Posted
Guru

In Gambas, how do I define a button to be themed as 'destructive-action' or 'suggested-action'? They should be of different color.
The best way is to make your own bespoke button. Run this code in a new Graphical Application.
Code (gambas)
- .Center
- .Y = 250
- .Height = 75
- .Width = 300
- .Height = 56
- .Width = 100
- .Arrangement = Arrange.Vertical
- .Background = Color.Yellow
- .Border = Border.Raised
- .Foreground = Color.Red
- .Alignment = Align.Center
- .Text = "Destructive-action!!"
- PanelButton.Border = Border.Sunken
- PanelButton.Border = Border.Raised
Posted
Regular

Posted
Regular

Forgive me, but :? I do not quite understand what you want to achieve.JumpyVB said
In Gambas, how do I define a button to be themed as 'destructive-action' or 'suggested-action'? They should be of different color.
Europaeus sum !
<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Posted
Regular

PS: I'm using Linux Mint and SebastJava/mint-yz-theme here.
PSS: Maybe this could be achieved in QT as well as in Gtk. I can change my app to using QT. I know you vuott are using QT if I remember correctly from an earlier post.
Posted
Guru

btnSaveAs.Default = True
btnExit.Cancel = True
Posted
Regular

BruceSteers said
You can set a buttons Cancel or Default Boolean properties.
btnSaveAs.Default = True
btnExit.Cancel = True
I tried default and cancel but they don't change the appearance - At least on my setup.
I will post a new question about theming QT apps.
Posted
Guru

You have to code it yourself if you want it guaranteed.
Posted
Regular

BruceSteers said
It's down to the theme config.
How should I theme config for a Gambas app?
There seems to be something odd with naming convention of gtk ui elements in Gambas. Here's a screenshot showcasing my image viewer prototype made in Gambas as a GTK+3 Application. For example Gtk Inspector reveals that the proggressbar is called GtkFixed - Which makes it impossible to be themed? I would have expected it to be called GtkProggressBar and have the name ProgressBar1 shown aswell - As compared to gtk3-widget-factory on the right side on the screenshot. Is it possible that proggressbar is not a native gtk component in Gambas?
Posted
Guru

Personally i think it would be easier to just make your own buttons like cogier first suggested.
I'd probably do something like this….
Save this code in my projects .src folder as Form.class
Code (gambas)
- ' Gambas class file
- SetButtonColors
- SetButtonColors
- b = c
That will make ALL your programs windows buttons (including modal windows like Message.class) show a hint of green if Default or a hint of red if Cancel.
of course you can change the color to your own liking
PS. you need to explicitly use Me.Show in your startup forms Form_Open() method as it does not seem to run Show() itself.
Posted
Regular

Okay, I'll have a go with this. I will need to wrap this in to a custom control to keep the source code of FMain ungluttered. Let's leave out the label for now to make things more simple. So far I have created a "NiceButton.class":cogier said
The best way is to make your own bespoke button.
Code (gambas)
- ' Gambas class file
I have this in a new Graphical application with a single VBox on the FMain to populate my buttons (or a single button now for starters):
Posted
Posted
Regular

Exactly what I needed. Thank you very much.cogier said
Have a look at ColButton that's on the farm and here.
1 guest and 0 members have just viewed this.




