GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Tue Sep 23, 2014 12:16 am

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: I'm tryin to setup gtk_seperator_new() inside a fixed frame
PostPosted: Sun Jan 19, 2014 8:16 am 
Offline
Familiar Face

Joined: Fri Jan 10, 2014 2:29 pm
Posts: 21
I'm tryin to setup gtk_seperator_new() inside a fixed frame i.e gtk_fixed_new(); but it is showing only a blank screen

Code:
#include <gtk/gtk.h>
int main( int argc, char *argv[])
{

  GtkWidget *window;
  GtkWidget *frame;
  GtkWidget *hseparator;



gtk_init(&argc, &argv);

  window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_window_set_default_size(GTK_WINDOW(window), 230, 150);
  gtk_window_set_title(GTK_WINDOW(window), "title");


  hseparator = gtk_separator_new( GTK_ORIENTATION_HORIZONTAL);
  frame = gtk_fixed_new();
  gtk_container_add(GTK_CONTAINER(window),frame);
gtk_fixed_put(GTK_FIXED(frame),hseparator,100,30);

  gtk_widget_show_all(window);

  gtk_main();

  return 0;
}


Top
 Profile  
 
 Post subject: Re: I'm tryin to setup gtk_seperator_new() inside a fixed fr
PostPosted: Mon Jan 20, 2014 7:09 am 
Offline
Never Seen the Sunlight

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

Your problem is with using the layout widget GtkFixed. It is recommended not to use GtkFixed for many reasons and this is one reason why you may get problems; see https://developer.gnome.org/gtk3/stable/GtkFixed.html

What is happening is that GtkFixed does not give any layout hints such as sizing. GtkSeperator is expecting a size hint from the widget it is placed into. Therefore the size it will use is 0 x 0 and you will get nothing displayed.

It is better to use a different layout widget such as GtkGrid instead.

_________________
E.


Top
 Profile  
 
 Post subject: Re: I'm tryin to setup gtk_seperator_new() inside a fixed fr
PostPosted: Mon Jan 20, 2014 4:41 pm 
Offline
Familiar Face

Joined: Fri Jan 10, 2014 2:29 pm
Posts: 21
Oh I See that's the problem


Top
 Profile  
 
 Post subject: Re: I'm tryin to setup gtk_seperator_new() inside a fixed fr
PostPosted: Tue Jan 21, 2014 1:06 pm 
Offline
Familiar Face

Joined: Fri Jan 10, 2014 2:29 pm
Posts: 21
@errol I tried it with GRID but still there is no horizontal separator bar here is my code

Code:
#include <gtk/gtk.h>
int main( int argc, char *argv[])
{

  GtkWidget *window;
  GtkWidget *hseparator;
  GtkWidget *grid;



gtk_init(&argc, &argv);


  window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_window_set_default_size(GTK_WINDOW(window), 230, 150);
  gtk_window_set_title(GTK_WINDOW(window), "title");

grid = gtk_grid_new();
  gtk_container_add(GTK_CONTAINER(window),grid);


  hseparator = gtk_separator_new( GTK_ORIENTATION_HORIZONTAL);
  gtk_grid_attach(GTK_GRID(grid),hseparator,2,2,2,2);

  gtk_widget_show_all(window);

  gtk_main();

  return 0;
}


Top
 Profile  
 
 Post subject: Re: I'm tryin to setup gtk_seperator_new() inside a fixed fr
PostPosted: Tue Jan 21, 2014 1:52 pm 
Offline
Familiar Face

Joined: Fri Jan 10, 2014 2:29 pm
Posts: 21
It's Working It's Working ! as line was too thin so i was not able to notice it its working all fine in GRID


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: 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