GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Sat Nov 22, 2014 4:42 pm

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Remove (reset) the style of a GTK+ Window
PostPosted: Tue Mar 13, 2012 4:26 am 
Offline
Familiar Face

Joined: Fri Mar 09, 2012 3:08 am
Posts: 5
I made a simple application with a window and some buttons on it.
Attachment:
main.c.gz [1.26 KiB]
Downloaded 59 times
On my Debian Linux the button looks nice, but if compiled and ran on Windows 7, it is very simple (and "ugly").

I want to use my own code for drawing the buttons. To do that, I connected a signal to the expose event.
In the event callback function, I draw a decorated rectangle and then call the "child" expose event:
Code:
// Calling the expose event of the button's child (in my case, label)
(*GTK_WIDGET_GET_CLASS(GTK_BIN(widget)->child)->expose_event)(GTK_BIN(widget)->child, event);
This works the same as this:
Code:
// Calling the expose event of a "container" class
(*GTK_WIDGET_CLASS(GTK_BIN_GET_CLASS(widget->parent))->expose_event)(widget, event);

Everything works, but there is a small difference:
On Linux, when the button is pressed down (when you hold the mouse button), the label moves to the left and bottom by 1px.
On Windows it stays still.
How can I make it consistent?

My idea was to turn off (remove) the theme (style). I think it would make the Linux version look like Windows version (with poor button syle), and the label would stay still in both systems.


Top
 Profile  
 
 Post subject: Re: Remove (reset) the style of a GTK+ Window
PostPosted: Tue Mar 13, 2012 7:58 pm 
Offline
Familiar Face

Joined: Fri Mar 09, 2012 3:08 am
Posts: 5
Just found a solution.
Code:
GtkWidget *window, *button1, *button2;
//...
GtkStyle *style = gtk_widget_get_default_style();
//...
gtk_widget_set_style(window, style);
gtk_widget_set_style(button1, style);
gtk_widget_set_style(button2, style);

But you need to call "gtk_widget_set_style" for each widget.
Is there a way to do it once for all widgets? Something like:
Code:
gtk_widget_set_style_all(window, style);


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot], Yahoo [Bot] and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group