GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Sun Nov 23, 2014 5:18 pm

All times are UTC




Post new topic Reply to topic  [ 22 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: remove GTK notebook border
PostPosted: Fri Sep 30, 2011 9:09 am 
Offline
GTK+ Geek

Joined: Sat Sep 03, 2011 6:36 pm
Posts: 94
ok so when i add a notebook inside a vbox there is a white line at the left and the right and t he bottom so how do i get rid of that?


Top
 Profile  
 
 Post subject: Re: remove GTK notebook border
PostPosted: Fri Sep 30, 2011 5:29 pm 
Offline
GTK+ Guru

Joined: Fri Mar 25, 2011 5:16 pm
Posts: 177
Location: USA
Post a minimal working example, there's too many variables. Are you displaying the tabs or hiding them? Are the tabs at the top or another location? ect.


Top
 Profile  
 
 Post subject: Re: remove GTK notebook border
PostPosted: Fri Sep 30, 2011 7:16 pm 
Offline
GTK+ Geek

Joined: Sat Sep 03, 2011 6:36 pm
Posts: 94
zerohour wrote:
Post a minimal working example, there's too many variables. Are you displaying the tabs or hiding them? Are the tabs at the top or another location? ect.


correct,the reason i do that is because i dont like ready copy-pasting codes and i prefer to write the code myself :P

Code:


#include <gtk/gtk.h>

static void destroy(GtkWidget *widget, gpointer data) {
gtk_main_quit();
}

static GtkWidget*
create_menubar(void) {
GtkWidget *menubar = gtk_menu_bar_new();

return menubar;
}

static GtkWidget*
create_notebook(void) {
GtkWidget *notebook = gtk_notebook_new();
gtk_notebook_set_scrollable(notebook, TRUE);

gtk_notebook_set_tab_pos (GTK_NOTEBOOK (notebook), GTK_POS_TOP);


GtkWidget *scrolled = gtk_scrolled_window_new(NULL, NULL);
gtk_notebook_append_page(notebook, scrolled, NULL);

return notebook;
}
static GtkWidget*

create_statusbar() {

      GtkWidget *statusbar = gtk_statusbar_new();
   

   return statusbar;

}

static GtkWidget*

      create_window() {

         GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);

         gtk_window_set_default_size(GTK_WINDOW(window), 400, 400);

         gtk_window_set_title(GTK_WINDOW(window), "Testy");

         

         g_signal_connect(window, "destroy", G_CALLBACK(destroy), window);


         return window;

      }

int main(int argc, char *argv[]) {

      GtkWidget *vbox;

      gtk_init(&argc, &argv);



      GtkWidget *window = create_window();



      vbox = gtk_vbox_new(FALSE, 0);

      gtk_box_pack_start(GTK_BOX(vbox), create_menubar(), FALSE, FALSE, 0);

      gtk_box_pack_start(GTK_BOX(vbox), create_notebook(), TRUE, TRUE, 0);

      gtk_box_pack_start(GTK_BOX(vbox), create_statusbar(), FALSE, FALSE, 0);



      gtk_container_add(window, vbox);



      gtk_widget_show_all(window);


      gtk_main();



      return 0;
}


you can see at the top where the tab is rounded,there is a small margin between the content and the notebook,which creates that white line at both left,right,botom and top :/


Top
 Profile  
 
 Post subject: Re: remove GTK notebook border
PostPosted: Sat Oct 01, 2011 5:46 pm 
Offline
GTK+ Guru

Joined: Fri Mar 25, 2011 5:16 pm
Posts: 177
Location: USA
Are you trying to created notebooks dynamically? Does this compile for you? It doesn't for me even under Gtk2: gcc -Wall -o test1 `pkg-config --cflags --libs gtk+-2.0` test1.c
Code:
test1.c: In function ‘create_notebook’:
test1.c:17:1: warning: passing argument 1 of ‘gtk_notebook_set_scrollable’ from incompatible pointer type
/usr/include/gtk-2.0/gtk/gtknotebook.h:241:10: note: expected ‘struct GtkNotebook *’ but argument is of type ‘struct GtkWidget *’
test1.c:23:1: warning: passing argument 1 of ‘gtk_notebook_append_page’ from incompatible pointer type
/usr/include/gtk-2.0/gtk/gtknotebook.h:153:6: note: expected ‘struct GtkNotebook *’ but argument is of type ‘struct GtkWidget *’
test1.c: In function ‘main’:
test1.c:82:7: warning: passing argument 1 of ‘gtk_container_add’ from incompatible pointer type
/usr/include/gtk-2.0/gtk/gtkcontainer.h:111:9: note: expected ‘struct GtkContainer *’ but argument is of type ‘struct GtkWidget *’

For instance the prototype for gtk_notebook_set_scrollable is:
Code:
void gtk_notebook_set_scrollable  (GtkNotebook *notebook,   gboolean scrollable);

So line# 17 is corrected with:
Code:
gtk_notebook_set_scrollable(GTK_NOTEBOOK(notebook), TRUE);


Top
 Profile  
 
 Post subject: Re: remove GTK notebook border
PostPosted: Sat Oct 01, 2011 6:54 pm 
Offline
GTK+ Geek

Joined: Sat Sep 03, 2011 6:36 pm
Posts: 94
yes it compiles to me (:


Top
 Profile  
 
 Post subject: Re: remove GTK notebook border
PostPosted: Sun Oct 02, 2011 6:36 pm 
Offline
GTK+ Guru

Joined: Fri Mar 25, 2011 5:16 pm
Posts: 177
Location: USA
1) What is your O.S. ?
2) What version of GTK are you using?
3) Are you trying to create a notebook and/or window as the program is running?
I ask this because you normally don't add functions outside main to quit the program or create these widgets.
4) You say the program complies for you, do you see a "FILE" menu ? I don't because you haven't packed anything in it. Just like if you want to see a notebook, it's not enough to create it, you must pack something in it.
This works for me and there's no white lines. Of course there's no large content in the notebook to allow the scroll bars to actually work.
Code:
/*  Compile with:
*  gcc -Wall -o testy `pkg-config --cflags --libs gtk+-2.0` testy.c
*/
#include <gtk/gtk.h>

static void destroy(GtkWidget *widget, gpointer data) {
gtk_main_quit();
}

static GtkWidget*
create_menubar(void) {
  GtkWidget *menubar = gtk_menu_bar_new();
  GtkWidget *filemenu = gtk_menu_new();
  GtkWidget *file = gtk_menu_item_new_with_label("File");
  GtkWidget *quit = gtk_menu_item_new_with_label("Quit");
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(file), filemenu);
  gtk_menu_shell_append(GTK_MENU_SHELL(filemenu), quit);
  gtk_menu_shell_append(GTK_MENU_SHELL(menubar), file);
  g_signal_connect(G_OBJECT(quit), "activate", G_CALLBACK(gtk_main_quit), NULL);
   return menubar;
}

static GtkWidget*
create_notebook(void) {
   GtkWidget *notebook = gtk_notebook_new();
   gtk_notebook_set_scrollable(GTK_NOTEBOOK(notebook), TRUE);
   gtk_notebook_set_tab_pos (GTK_NOTEBOOK (notebook), GTK_POS_TOP);
   GtkWidget *scrolled = gtk_scrolled_window_new(NULL, NULL);
   gtk_notebook_append_page(GTK_NOTEBOOK(notebook), scrolled, NULL);
   return notebook;
}

static GtkWidget*
create_statusbar() {
      GtkWidget *statusbar = gtk_statusbar_new();
   return statusbar;
}

static GtkWidget*
      create_window() {
         GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
         gtk_window_set_default_size(GTK_WINDOW(window), 400, 400);
         gtk_window_set_title(GTK_WINDOW(window), "Testy");
         g_signal_connect(window, "destroy", G_CALLBACK(destroy), window);
         return window;
      }

int main(int argc, char *argv[]) {

      GtkWidget *vbox;

      gtk_init(&argc, &argv);

      GtkWidget *window = create_window();

      vbox = gtk_vbox_new(FALSE, 0);

      gtk_box_pack_start(GTK_BOX(vbox), create_menubar(), FALSE, FALSE, 0);
      gtk_box_pack_start(GTK_BOX(vbox), create_notebook(), TRUE, TRUE, 0);
      gtk_box_pack_start(GTK_BOX(vbox), create_statusbar(), FALSE, FALSE, 0);
      gtk_container_add(GTK_CONTAINER(window), vbox);

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


Top
 Profile  
 
 Post subject: Re: remove GTK notebook border
PostPosted: Sun Oct 02, 2011 7:37 pm 
Offline
GTK+ Geek

Joined: Sat Sep 03, 2011 6:36 pm
Posts: 94
i didnt pack anything inside the menubar on purpose,because it doesnt effect my question whatsoever.You can still see that at the left and the right there is a small thick black border which is the notebook's border.thats what im asking to remove (:


Top
 Profile  
 
 Post subject: Re: remove GTK notebook border
PostPosted: Sun Oct 02, 2011 7:58 pm 
Offline
GTK+ Guru

Joined: Fri Mar 25, 2011 5:16 pm
Posts: 177
Location: USA
I can't help very much if your not willing to answer my questions. The only other thing I can think of is, In the create_notebook() function add:
Code:
gtk_container_set_border_width (GTK_CONTAINER(notebook),0);


Top
 Profile  
 
 Post subject: Re: remove GTK notebook border
PostPosted: Sun Oct 02, 2011 8:15 pm 
Offline
GTK+ Geek

Joined: Sat Sep 03, 2011 6:36 pm
Posts: 94
i can still see the border.

1)ubuntu natty
2)GTK + 2.24
3)i only want to box a notebook inside a vbox
4)no i do not because i didnt add one on purpose


Top
 Profile  
 
 Post subject: Re: remove GTK notebook border
PostPosted: Mon Oct 03, 2011 12:01 am 
Offline
GTK+ Guru

Joined: Fri Mar 25, 2011 5:16 pm
Posts: 177
Location: USA
Ok I'll give it one more shot, I don't see a white line. If you do, are you running any downloaded Ubuntu themes? Perhaps it's your theme overriding things? I'm running signed in as: Ubuntu classic (no effects)
Code:
/*  Compile with:
*  gcc -Wall -o test4 `pkg-config --cflags --libs gtk+-3.0` test4.c
*/
#include <gtk/gtk.h>

int main( int argc, char *argv[])
{
  GtkWidget *window;
  GtkWidget *vbox, *vbox2,  *vbox3;
  GtkWidget *menubar, *filemenu, *file, *quit;
  GtkWidget *notebook, *tab1_label,  *tab2_label;
  GtkWidget *statusbar;
  GtkWidget *scrolled, *viewport;

  gtk_init(&argc, &argv);

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

/*----- menubar ---------------*/
   menubar = gtk_menu_bar_new();
  gtk_widget_set_margin_bottom (GTK_WIDGET(menubar),0);
  gtk_widget_set_margin_top (GTK_WIDGET(menubar),0);
  filemenu = gtk_menu_new();
  file = gtk_menu_item_new_with_label ("File");
  quit = gtk_menu_item_new_with_label ("Quit");
  gtk_menu_item_set_submenu (GTK_MENU_ITEM(file), filemenu);
  gtk_menu_shell_append (GTK_MENU_SHELL(filemenu), quit);
  gtk_menu_shell_append (GTK_MENU_SHELL(menubar), file);

/*----- main vbox ---------------*/
  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL,0);
  gtk_container_set_border_width (GTK_CONTAINER(vbox),0);
  gtk_container_add (GTK_CONTAINER(window),vbox);
  gtk_box_pack_start (GTK_BOX(vbox),menubar,FALSE,TRUE,0);

/*----- notebook page 1 ---------------*/
  notebook = gtk_notebook_new ();
  gtk_widget_set_margin_bottom (GTK_WIDGET(notebook),0);
  gtk_widget_set_margin_top (GTK_WIDGET(notebook),0);
  gtk_container_set_border_width (GTK_CONTAINER(notebook),0);
   gtk_notebook_set_scrollable(GTK_NOTEBOOK(notebook), TRUE);
  gtk_notebook_set_tab_pos (GTK_NOTEBOOK (notebook), GTK_POS_TOP);
  vbox2 = gtk_vbox_new (FALSE,0);
  gtk_container_add (GTK_CONTAINER(notebook),vbox2);
  gtk_box_pack_start (GTK_BOX(vbox),notebook,TRUE,TRUE,0);

/*----- scrollable window ---------------*/
   scrolled = gtk_scrolled_window_new(NULL, NULL);
  viewport = gtk_viewport_new(NULL,NULL);
  gtk_container_add (GTK_CONTAINER(scrolled),viewport);

/*----- vbtnbox for scrollable window ---------------*/
  GtkWidget *vbtnbox = gtk_vbutton_box_new ();
  gtk_button_box_set_layout (GTK_BUTTON_BOX(vbtnbox),GTK_BUTTONBOX_START);
  gtk_box_set_spacing (GTK_BOX(vbtnbox),300);
  GtkWidget *btn1 = gtk_button_new ();
  GtkWidget *btn2 = gtk_button_new ();
  gtk_container_add (GTK_CONTAINER(vbtnbox),btn1);
  gtk_container_add (GTK_CONTAINER(vbtnbox),btn2);
  gtk_container_add (GTK_CONTAINER(viewport),vbtnbox);
  gtk_container_add (GTK_CONTAINER(vbox2),scrolled);

  /*----- notebook page 2 ---------------*/
  vbox3 = gtk_vbox_new (FALSE,0);
  tab2_label = gtk_label_new ("Really long notebook second page tab to cause scrolling");
  gtk_notebook_insert_page (GTK_NOTEBOOK(notebook), GTK_WIDGET(vbox3), GTK_WIDGET(tab2_label), -1);

  /*----- status bar ---------------*/
  statusbar = gtk_statusbar_new();
  gtk_box_pack_start (GTK_BOX(vbox),
            GTK_WIDGET(statusbar),
            FALSE,
            TRUE,
            0);

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


Attachments:
Screenshot.png
Screenshot.png [ 15.68 KiB | Viewed 500 times ]
Top
 Profile  
 
 Post subject: Re: remove GTK notebook border
PostPosted: Mon Oct 03, 2011 7:03 am 
Offline
GTK+ Geek

Joined: Sat Sep 03, 2011 6:36 pm
Posts: 94
at the image you can see the border of the notebook between the window and the content of it :) to me its white thats what i want to remove


Top
 Profile  
 
 Post subject: Re: remove GTK notebook border
PostPosted: Sat Oct 22, 2011 11:19 am 
Offline
GTK+ Geek

Joined: Sat Sep 03, 2011 6:36 pm
Posts: 94
any suggestions?i still want to remove the border of the appended page.


Top
 Profile  
 
 Post subject: Re: remove GTK notebook border
PostPosted: Thu Oct 27, 2011 3:28 am 
Offline
Never Seen the Sunlight

Joined: Thu Mar 24, 2011 2:10 pm
Posts: 328
Location: Sydney, Australia
As I have said earlier, look into the .css styling. I have modified zerohour's file below (note also the different compile instructions). My system is Ubuntu 11.10 which uses unico so you may want to try to figure out what different commands would do the same thing. I based it around what was set by the gtk-widgets.css file in usr/share/themes/ambiance/gtk-3.0/. Of course one of the main reasons for using gtk is to be able to write platform independent code... but I've said enough about all that already...
Oh and by the way it would help a lot if you were to include screenshots and indicate what exactly you want changed (I really don't see the white line you're talking about on my system either unless you mean the padding between the notebook and the surrounding window which I was able to get rid of).

Code:
/*  Compile with:
*  gcc `pkg-config --cflags gtk+-3.0` -o test4 test4.c `pkg-config --libs gtk+-3.0`
*/
#include <gtk/gtk.h>

int main( int argc, char *argv[])
{
  GdkDisplay *display;
  GdkScreen *screen;
  GtkCssProvider *provider;
  GtkWidget *window;
  GtkWidget *vbox, *vbox2,  *vbox3;
  GtkWidget *menubar, *filemenu, *file, *quit;
  GtkWidget *notebook, *tab1_label,  *tab2_label;
  GtkWidget *statusbar;
  GtkWidget *scrolled, *viewport;

  gtk_init(&argc, &argv);

  provider = gtk_css_provider_new ();
  display = gdk_display_get_default ();
  screen = gdk_display_get_default_screen (display);
  gtk_style_context_add_provider_for_screen (screen, GTK_STYLE_PROVIDER(provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
  gtk_css_provider_load_from_data (GTK_CSS_PROVIDER (provider),
                                 " .notebook {\n"
                                 "   background-color: shade (@bg_color, 1.02);\n"
                                 "   background-image: none;\n"
                                 "   border-radius: 0;\n"
                                 "   padding: 3;\n"
                                 "   -unico-inner-stroke-color: shade (@bg_color, 1.02);\n"
                                 "   -unico-border-gradient: none;\n"
                                 "   -unico-inner-stroke-gradient: none;\n"
                                 "   -unico-inner-stroke-width: 0;\n"
                                 "   -unico-outer-stroke-gradient: none;\n"
                                 "   -unico-outer-stroke-width: 0;\n"
                                 "}\n", -1, NULL);
  g_object_unref (provider);
  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
etc.


Top
 Profile  
 
 Post subject: Re: remove GTK notebook border
PostPosted: Thu Oct 27, 2011 3:35 am 
Offline
Never Seen the Sunlight

Joined: Thu Mar 24, 2011 2:10 pm
Posts: 328
Location: Sydney, Australia
forgot to attach the resultant image:
Attachment:
Screenshot.png
Screenshot.png [ 40.35 KiB | Viewed 424 times ]


Top
 Profile  
 
 Post subject: Re: remove GTK notebook border
PostPosted: Thu Oct 27, 2011 2:04 pm 
Offline
GTK+ Geek

Joined: Sat Sep 03, 2011 6:36 pm
Posts: 94
thanks a lot,but as i compile i get the error GtkCssProvider undeclared as well as for the GTK_STYLE_PROVIDER_PRIORITY


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 22 posts ]  Go to page 1, 2  Next

All times are UTC


Who is online

Users browsing this forum: Google [Bot] 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