I'm reading tutorials on GtkFrame
, I have compile some code examples, but unlike screnhoot of the tutorial, but my program using GtkFrame
don't have a border.
The following code:
#include <gtk/gtk.h>
int main( int argc,
char *argv[] )
{
/* GtkWidget is the storage type for widgets */
GtkWidget *window;
GtkWidget *frame;
GtkWidget *button;
GtkWidget *label;
gint i;
/* Initialise GTK */
gtk_init(&argc, &argv);
/* Create a new window */
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(window), "Frame Example");
/* Here we connect the "destroy" event to a signal handler */
g_signal_connect (G_OBJECT (window), "destroy",
G_CALLBACK (gtk_main_quit), NULL);
gtk_widget_set_size_request(window, 300, 300);
/* Sets the border width of the window. */
gtk_container_set_border_width (GTK_CONTAINER (window), 10);
label = gtk_label_new("foo");
/* Create a Frame */
frame = gtk_frame_new(NULL);
gtk_container_add(GTK_CONTAINER(frame), label);
gtk_widget_set_size_request(frame, 30, 30);
gtk_container_add(GTK_CONTAINER(window), frame);
/* Set the frame's label */
gtk_frame_set_label( GTK_FRAME(frame), "GTK Frame Widget" );
/* Set the style of the frame */
gtk_frame_set_shadow_type( GTK_FRAME(frame), GTK_SHADOW_ETCHED_OUT);
gtk_widget_show(frame);
/* Display the window */
gtk_widget_show (window);
/* Enter the event loop */
gtk_main ();
return(0);
}
/* example-end */
Generate the program:
What am I missing?
This is GTK bug 659926. However, it seems this is mostly due to the fact that the Adwaita theme (default GNOME 3 theme) ignores the frames, so maybe changing the theme (using gnome-tweak-tool, if you want to use a GUI) will do the trick. However I think frames are abused in many GUIs and often lead to ugly interfaces, as they add visual clutter. Less is better.