I am trying to get a basic notebook going with gtk
- From: "ken guess" <triorieel hotmail com>
- To: gtk-devel-list gnome org
- Subject: I am trying to get a basic notebook going with gtk
- Date: Mon, 09 May 2005 20:54:35 -0400
To try and udnerstand things better, ive tried creating a simple program for
a notebook. As far as I can tell it should be working, but I see only an
empty window.
[I can only hope Im doing this mailing list correctly]
My code:
#include <cstdlib>
#include <iostream>
#include <gtk/gtk.h>
#include <stdlib.h>
using namespace std;
static gboolean delete_event(GtkWidget *widget, GdkEvent *event,gpointer
data )
{
/* If you return FALSE in the "delete_event" signal handler,
* GTK will emit the "destroy" signal. Returning TRUE means
* you don't want the window to be destroyed.
* This is useful for popping up 'are you sure you want to quit?'
* type dialogs. */
g_print ("delete event occurred\n");
/* Change TRUE to FALSE and the main window will be destroyed with
* a "delete_event". */
return FALSE;
}
/* Another callback */
static void destroy( GtkWidget *widget,
gpointer data )
{
gtk_main_quit ();
}
int main(int argc, char *argv[] )
{
/* GtkWidget is the storage type for widgets */
GtkWidget *window;
GtkWidget *label;
GtkWidget *notebook;
GtkWidget *frame;
gtk_init (&argc, &argv);
//Window Stuff
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
// gtk_window_fullscreen(GTK_WINDOW(window));
g_signal_connect (G_OBJECT (window), "delete_event", G_CALLBACK
(delete_event), NULL);
g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (destroy),
NULL);
gtk_container_set_border_width (GTK_CONTAINER (window), 10);
//gtk_container_add (GTK_CONTAINER (window), button1);
notebook = gtk_notebook_new();
gtk_notebook_set_tab_pos (GTK_NOTEBOOK (notebook), GTK_POS_TOP);
gtk_widget_show(notebook);
frame = gtk_frame_new("frame");
gtk_widget_set_size_request (frame, 100, 75);
gtk_widget_show(frame);
label = gtk_label_new("label");
gtk_container_add (GTK_CONTAINER (frame), label);
gtk_widget_show(label);
label = gtk_label_new ("added");
gtk_notebook_append_page(GTK_NOTEBOOK(notebook),frame, label);
frame = gtk_frame_new("frame2");
gtk_widget_set_size_request (frame, 100, 75);
gtk_widget_show(frame);
label = gtk_label_new("label2");
gtk_container_add (GTK_CONTAINER (frame), label);
gtk_widget_show(label);
label = gtk_label_new ("added2");
gtk_notebook_append_page(GTK_NOTEBOOK(notebook),frame, label);
gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), 1);
gtk_widget_show (window);
gtk_main ();
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]