GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Fri Oct 31, 2014 4:26 pm

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: New fancy Gtk3-look for the GtkNotebook widget [SOLVED]
PostPosted: Mon Jan 16, 2012 10:45 pm 
Offline
Familiar Face

Joined: Mon Jan 16, 2012 9:26 pm
Posts: 5
Hello, friends.

How is it possible to activate the new fancy Gtk 3.x look for the GtkNotebook widget (in C)? Does it need a special style to be changed?

2.x:
Image

3.x:
Image


------------


So, while posing this question I found the answer. There's no need to do anything to enable the new look for the widget - it happens automatically, just compile the project using Gtk+-3.0 libs instead of Gtk+-2.0 ones.

I'm using Code::Blocks. All I needed was:
1. Install the libraries. In Debian, "apt-get install libgtk-3-0 libgtk-3-common libgtk-3-dev"
2. Enable them in the Code::Blocks settings. Either using this method or, if the settings are stored inside the project file, just open it (*.cbp) and replace all references to "gtk+-2.0" with "gtk+-3.0". Plain "nano" is good enough.


Top
 Profile  
 
 Post subject: Re: New fancy Gtk3-look for the GtkNotebook widget [SOLVED]
PostPosted: Mon Jan 16, 2012 11:46 pm 
Offline
GTK+ Guru

Joined: Fri Mar 25, 2011 5:16 pm
Posts: 177
Location: USA
I don't use CodeBlocks or any other IDE. I compile from the command line but only your interface in CodeBlocks will change. The look for GtkNoteBook in your own compiled applications will not be different for Gtk-3x versus Gtk-2x unless you apply styling to it using CSS.
By default GtkNoteBook looks the same for gtk-2x and for all three versions of gtk+3x
http://developer.gnome.org/gtk/2.24/GtkNotebook.html
http://developer.gnome.org/gtk3/3.0/GtkNotebook.html
http://developer.gnome.org/gtk3/3.1/GtkNotebook.html
http://developer.gnome.org/gtk3/3.2/GtkNotebook.html

I posted an example of styling a GtkNoteBook with CSS in the tutorials section.
http://www.gtkforums.com/viewtopic.php?f=3&t=988&p=72092&hilit=GtkNoteBook+css#p72092


Top
 Profile  
 
 Post subject: Re: New fancy Gtk3-look for the GtkNotebook widget [SOLVED]
PostPosted: Tue Jan 17, 2012 8:40 pm 
Offline
Familiar Face

Joined: Mon Jan 16, 2012 9:26 pm
Posts: 5
Thanks for the tips, I'll use styles as an option, that's a nice feature.

I wonder why they don't change the GtkNotebook screenshot on developer.gnome.org. It looks like this only on default GTK2 theme but it looks other way on default GTK3 one.

Code::Blocks is used just for convenience, you don't have a visual UI editor there. Same way, I like to generate UI from the code, somehow it looks as a better approach.


Top
 Profile  
 
 Post subject: Re: New fancy Gtk3-look for the GtkNotebook widget [SOLVED]
PostPosted: Tue Jan 17, 2012 9:12 pm 
Offline
GTK+ Guru

Joined: Fri Mar 25, 2011 5:16 pm
Posts: 177
Location: USA
No, notebooks in GTK2 and GTK3 look the same by default. This is a screen grab of the default notebook using gtk3.
Attachment:
notebook1.png
notebook1.png [ 81.94 KiB | Viewed 1042 times ]

Code:
/*  Compile with:   gcc -Wall -o notebasic `pkg-config --cflags --libs gtk+-3.0` notebasic.c   */

#include <gtk/gtk.h>

int main( int argc, char *argv[])
{
  GtkWidget *window;
  GtkWidget *vbox;
  GtkWidget *vbox2;
  GtkWidget *tab1_label;
  GtkWidget *tab2_label;
  GtkWidget *notebook;
 
  gtk_init(&argc, &argv);

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_default_size(GTK_WINDOW(window), 150, 120);
  tab1_label = gtk_label_new ("tab 1");
  g_signal_connect (GTK_WIDGET (window), "destroy",
                        G_CALLBACK (gtk_main_quit), NULL);

/*----- NOTEBOOK PAGE 1 ---------------*/
  notebook = gtk_notebook_new ();
  gtk_widget_set_name (GTK_WIDGET(notebook), "notebook");
  gtk_notebook_set_tab_pos (GTK_NOTEBOOK (notebook), GTK_POS_TOP);
  tab1_label = gtk_label_new ("First page");

  gtk_widget_set_name (GTK_WIDGET(tab1_label), "first_tab");

  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL,0);
  gtk_container_add(GTK_CONTAINER(notebook),vbox);

  gtk_notebook_set_tab_label (GTK_NOTEBOOK(notebook), GTK_WIDGET(vbox), GTK_WIDGET(tab1_label));
  gtk_container_add(GTK_CONTAINER(window),notebook);

  /*----- NOTEBOOK PAGE 2 ---------------*/
  vbox2 = gtk_vbox_new (FALSE,0);
  tab2_label = gtk_label_new ("Second page");
  gtk_widget_set_name (GTK_WIDGET(tab2_label), "second tab");
  gtk_notebook_insert_page (GTK_NOTEBOOK(notebook), GTK_WIDGET(vbox2), GTK_WIDGET(tab2_label), -1);

  gtk_widget_show_all(window);
  gtk_main();
  return 0;
}


Top
 Profile  
 
 Post subject: Re: New fancy Gtk3-look for the GtkNotebook widget [SOLVED]
PostPosted: Wed Jan 18, 2012 4:03 am 
Offline
Familiar Face

Joined: Mon Jan 16, 2012 9:26 pm
Posts: 5
It seems Ubuntu is shipped with different from Debian default GTK3 theme. Still it's prettier than it was. Ok, I got the point, program should be tested on several distributions using different themes.


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 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