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 Dec 20, 2014 2:26 pm

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: [SOLVED] Different looking Toolbar
PostPosted: Thu Aug 07, 2014 5:35 pm 
Offline

Joined: Thu Aug 07, 2014 2:57 pm
Posts: 2
Hello guys,
I have a quite simple question. I tried to add a toolbar to one of my projects, but I couldn't get the look I want.

For example;
Image

In this image..
Left window belongs to 'gedit'. And Right window belongs to my application.
As you can see, the toolbar of gedit looks different than my toolbar.
By the different, I mean the shadowy look, and when you hover the buttons, they don't get a 3D border.
How can I achive this kind of look. I couldn't find any options.

I'm using C++ with GTK 3 by the way.


Last edited by EraOzgur on Tue Aug 12, 2014 2:09 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Different looking Toolbar
PostPosted: Sat Aug 09, 2014 5:39 am 
Offline
Never Seen the Sunlight

Joined: Mon Apr 28, 2008 5:52 am
Posts: 799
Location: UK
Hello,

You do not say which version of 'gedit' you are comparing with as it is going through rapid modification with every release. The latest releases do not have tool bars.

I have not looked at the sources for gedit, but I expect that it is using CSS to change the properties/Styling of the tool bar.

In your documentation you will need to look at Styling and at the CSSProvider. If you are using gtkmm also look at the C documentation for the relevent section as not everything gets copied over from the C documents.

_________________
E.


Top
 Profile  
 
 Post subject: Re: Different looking Toolbar
PostPosted: Sat Aug 09, 2014 7:05 am 
Offline
Familiar Face

Joined: Mon Mar 31, 2014 9:59 pm
Posts: 16
In Python I use this code to style the toolbar (Works on Ubuntu). I think it should work on all distros and grab the native style:

toolbar = Gtk.Toolbar()
context = self.toolbar.get_style_context()
context.add_class(Gtk.STYLE_CLASS_PRIMARY_TOOLBAR)

_________________
I am learning to develop GTK+ (GTK 3.10) programs written in Python 3.4.0, designed with Glade 3.16.1, with plots using Matplotlib 1.4. I program and test using Ubuntu 14.04 (64bit) and Gedit. (http://gtk3-matplotlib-cookbook.readthedocs.org)


Top
 Profile  
 
 Post subject: Re: Different looking Toolbar
PostPosted: Tue Aug 12, 2014 2:08 am 
Offline

Joined: Thu Aug 07, 2014 2:57 pm
Posts: 2
Thank you so much!
The Python code you provided helped a lot.
I wrote a C++ equivalent of it and, voila!

If someone cares, here is the two lines of code to change the style:
Code:
   Glib::RefPtr<Gtk::StyleContext> contextRef = toolbar.get_style_context();
   contextRef->add_class(GTK_STYLE_CLASS_PRIMARY_TOOLBAR);


Also, It does not matter which version of gedit have this style of toolbar, because almost every application on my computer have this style of toolbar, not specific to gedit. Thank you so much again.

And result:
Image


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


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