Re: learning gtk.. using sams examples :)
- From: cesar <ciriso ave128 retena es>
- To: mdew <rpbrown xtra co nz>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: learning gtk.. using sams examples :)
- Date: Wed, 19 Sep 2001 14:00:13 +0100
Hi ( Sorry for my abominable english )
I have download source code
In the chapter 6 there are :
antioco:~/devel/GTK/gtk/chapter6$ ls -la
total 28
-rw-r--r-- 1 kaesar kaesar 3212 Feb 28 2000 6callbacks.c
-rw-r--r-- 1 kaesar kaesar 6599 Feb 28 2000 acc.c
-rw-r--r-- 1 kaesar kaesar 6760 Feb 28 2000 cascade.c
-rw-r--r-- 1 kaesar kaesar 4421 Feb 28 2000 itemfac.c
The callbacks are in 6callbacks.c so ...
gcc -g -o base0 6callbacks.c itemfac.c `gtk-config --libs --cflags`
gcc -g -o base1 6callbacks.c cascade.c `gtk-config --libs --cflags`
gcc -g -o base2 6callbacks.c acc.c `gtk-config --libs --cflags`
...works fine.
Regards.
César.
mdew wrote:
I was sampling some of the sams learn gtk+ in 21 days... and when compiling a few programs... i got this
error... Running Debian Sid (gtk+ 1.2.10, glib 1.2.10)
$ gcc itemfac.c -Wall -o base `gtk-config --libs --cflags`
/tmp/ccB5KkZJ.o: In function `main':
/tmp/ccB5KkZJ.o(.text+0x338): undefined reference to `dialog_delete_handler'
/tmp/ccB5KkZJ.o(.text+0x386): undefined reference to `delete_event_handler'
/tmp/ccB5KkZJ.o(.text+0x3d4): undefined reference to `print_and_quit'
/tmp/ccB5KkZJ.o(.text+0x50a): undefined reference to `line_plot'
/tmp/ccB5KkZJ.o(.rodata+0x98): undefined reference to `print_and_quit'
collect2: ld returned 1 exit status
#include <gtk/gtk.h>
#define NO_PADDING 0
#define NO_SPACING 0
/* Callbacks */
void line_plot( GtkMenuItem *was_clicked, GtkWidget *where_to_draw );
void print_and_quit( GtkButton *was_clicked, gpointer user_data );
gboolean delete_event_handler( GtkWidget *widget, GdkEvent *event,
gpointer user_data );
gboolean dialog_delete_handler( GtkWidget *widget, GdkEvent *event,
gpointer user_data );
int main( int argc, char *argv[] )
{
GtkWidget *top_widget;
GtkWidget *vbox, *menu_bar;
GtkWidget *plot_area;
GtkWidget *about_dialog, *about_label, *about_ok;
GtkAccelGroup *accel_group, *accel_about;
GtkItemFactory *ifac;
GtkItemFactoryEntry items[] = { { "/File", NULL, NULL, 0, "<Branch>" },
{ "/File/_Exit", "<Ctrl>Q", print_and_quit, 0, "<Item>" },
{ "/Plot", NULL, NULL, 0, "<Item>" },
{ "/Help", NULL, NULL, 0, "<Branch>" },
{ "/Help/What's This?", NULL, NULL, 0, "<Item>" },
{ "/Help/Separator", NULL, NULL, 0, "<Separator>" },
{ "/Help/About my program", NULL, NULL, 0, "<Item>" }};
/* 1. Initialize the environment */
gtk_init( &argc, &argv );
/* 2a. Create widgets */
top_widget = gtk_window_new( GTK_WINDOW_TOPLEVEL );
vbox = gtk_vbox_new( FALSE, NO_SPACING );
/* Create the Work Area */
plot_area = gtk_drawing_area_new();
/* Set up the accelerator group */
accel_group = gtk_accel_group_new();
gtk_accel_group_attach( accel_group, GTK_OBJECT( top_widget ) );
/* Create the item factory */
ifac = gtk_item_factory_new( GTK_TYPE_MENU_BAR, "<main>", accel_group );
/* Instantiate the item factory entries */
gtk_item_factory_create_items( ifac, sizeof(items)/sizeof(items[0]),
items, NULL );
menu_bar = gtk_item_factory_get_widget( ifac, "<main>" );
/* Create pop-up dialog */
about_dialog = gtk_dialog_new();
accel_about = gtk_accel_group_new();
gtk_accel_group_attach( accel_about, GTK_OBJECT( about_dialog ) );
about_label = gtk_label_new( "This is a simple plotting program\n"
"It currently accepts no outside data, \n"
"though this feature will be available in a future release.\n" "Author:
You\n Version 0.0.1\n" );
about_ok = gtk_button_new_with_label( "OK" );
/* Put the label in vbox, and the button in action_area */
gtk_box_pack_start( GTK_BOX( GTK_DIALOG(about_dialog)->vbox), about_label,
FALSE, FALSE, NO_PADDING );
gtk_box_pack_start( GTK_BOX(GTK_DIALOG(about_dialog)->action_area), about_ok, FALSE, FALSE,
NO_PADDING );
gtk_widget_show( about_label );
gtk_widget_show( about_ok );
gtk_signal_connect_object( GTK_OBJECT( about_ok ), "clicked",
GTK_SIGNAL_FUNC( gtk_widget_hide ), GTK_OBJECT( about_dialog ) );
/* 2b. Set Attributes */
gtk_window_set_title( GTK_WINDOW( top_widget ), "Item Factory" );
gtk_drawing_area_size( GTK_DRAWING_AREA(plot_area), 300, 200 );
/* 3. Registering Callback routines */
gtk_signal_connect( GTK_OBJECT( about_dialog ), "delete_event",
GTK_SIGNAL_FUNC(dialog_delete_handler), NULL );
gtk_signal_connect( GTK_OBJECT( top_widget ), "delete_event",
GTK_SIGNAL_FUNC(delete_event_handler), NULL );
gtk_signal_connect( GTK_OBJECT( top_widget ), "destroy",
GTK_SIGNAL_FUNC(print_and_quit), NULL );
gtk_signal_connect_object(
GTK_OBJECT( gtk_item_factory_get_widget( ifac, "/Help/About my program" ) ),
"activate", GTK_SIGNAL_FUNC( gtk_widget_show ),
GTK_OBJECT( about_dialog ) );
gtk_signal_connect( GTK_OBJECT( gtk_item_factory_get_widget( ifac, "/Plot" ) ),
"activate", line_plot, plot_area );
/* 4. Defining the Instance Hierarchy */
gtk_container_add( GTK_CONTAINER( top_widget ), vbox );
gtk_box_pack_start( GTK_BOX(vbox), menu_bar, FALSE, FALSE, NO_PADDING);
gtk_box_pack_start( GTK_BOX(vbox), plot_area, FALSE, FALSE, NO_PADDING );
/* 5. Showing the Widgets */
gtk_widget_show_all( top_widget );
/* 6. Processing Loop */
gtk_main();
g_print( "Bye!\n");
return 0;
}
--
id: 9DF3262C
key fingerprint: B556 04DA CFD9 78DD 9215 A970 8196 FB6D 9DF3 262C
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]