diff options
author | GMT 1999 Tony Gale <gale@gtk.org> | 1999-01-28 10:35:40 +0000 |
---|---|---|
committer | Tony Gale <gale@src.gnome.org> | 1999-01-28 10:35:40 +0000 |
commit | a2dafdfc88dbaaaf67c3971372da4a5b8b63ec2b (patch) | |
tree | b16f8940a58bbe8d25bcf5f3112fbcb3c682952b /examples/menu | |
parent | a70005873773b8b3214b2a54818990db517fbaa9 (diff) | |
download | gtk+-a2dafdfc88dbaaaf67c3971372da4a5b8b63ec2b.tar.gz |
- Replace all uses of deprecated functions. - Replace menufactory example
Thu Jan 28 10:16:28 GMT 1999 Tony Gale <gale@gtk.org>
* docs/gtk_tut.sgml:
- Replace all uses of deprecated functions.
- Replace menufactory example with itemfactory example
from Nick Scott <mendigo@geocities.com>
- Minor bug fixes in the examples.
Diffstat (limited to 'examples/menu')
-rw-r--r-- | examples/menu/Makefile | 14 | ||||
-rw-r--r-- | examples/menu/menufactory.c | 54 | ||||
-rw-r--r-- | examples/menu/menufactory.h | 18 | ||||
-rw-r--r-- | examples/menu/mfmain.c | 48 | ||||
-rw-r--r-- | examples/menu/mfmain.h | 19 |
5 files changed, 4 insertions, 149 deletions
diff --git a/examples/menu/Makefile b/examples/menu/Makefile index b9db74f44f..4b94bb99b9 100644 --- a/examples/menu/Makefile +++ b/examples/menu/Makefile @@ -1,19 +1,13 @@ CC = gcc -all: menu menufactory +all: menu itemfactory menu: menu.c $(CC) `gtk-config --cflags` menu.c -o menu `gtk-config --libs` -menufactory: menufactory.o mfmain.o - $(CC) `gtk-config --libs` menufactory.o mfmain.o -o menufactory - -menufactory.o: menufactory.c mfmain.h - $(CC) `gtk-config --cflags` -c menufactory.c -o menufactory.o - -mfmain.o: mfmain.c mfmain.h menufactory.h - $(CC) `gtk-config --cflags` -c mfmain.c -o mfmain.o +itemfactory: itemfactory.c + $(CC) `gtk-config --cflags` itemfactory.c -o itemfactory `gtk-config --libs` clean: - rm -f *.o menu menufactory + rm -f *.o menu itemfactory diff --git a/examples/menu/menufactory.c b/examples/menu/menufactory.c deleted file mode 100644 index a7f7819594..0000000000 --- a/examples/menu/menufactory.c +++ /dev/null @@ -1,54 +0,0 @@ -/* example-start menu menufactory.c */ - -#include <gtk/gtk.h> -#include <strings.h> - -#include "mfmain.h" - -static void print_hello(GtkWidget *widget, gpointer data); - - -/* this is the GtkMenuEntry structure used to create new menus. The - * first member is the menu definition string. The second, the - * default accelerator key used to access this menu function with - * the keyboard. The third is the callback function to call when - * this menu item is selected (by the accelerator key, or with the - * mouse.) The last member is the data to pass to your callback function. - */ - -static GtkMenuEntry menu_items[] = -{ - {"<Main>/File/New", "<control>N", print_hello, NULL}, - {"<Main>/File/Open", "<control>O", print_hello, NULL}, - {"<Main>/File/Save", "<control>S", print_hello, NULL}, - {"<Main>/File/Save as", NULL, NULL, NULL}, - {"<Main>/File/<separator>", NULL, NULL, NULL}, - {"<Main>/File/Quit", "<control>Q", file_quit_cmd_callback, "OK, I'll quit"}, - {"<Main>/Options/Test", NULL, NULL, NULL} -}; - - -static void -print_hello(GtkWidget *widget, gpointer data) -{ - printf("hello!\n"); -} - -void get_main_menu(GtkWidget *window, GtkWidget ** menubar) -{ - int nmenu_items = sizeof(menu_items) / sizeof(menu_items[0]); - GtkMenuFactory *factory; - GtkMenuFactory *subfactory; - - factory = gtk_menu_factory_new(GTK_MENU_FACTORY_MENU_BAR); - subfactory = gtk_menu_factory_new(GTK_MENU_FACTORY_MENU_BAR); - - gtk_menu_factory_add_subfactory(factory, subfactory, "<Main>"); - gtk_menu_factory_add_entries(factory, menu_items, nmenu_items); - gtk_window_add_accelerator_table(GTK_WINDOW(window), subfactory->table); - - if (menubar) - *menubar = subfactory->widget; -} - -/* example-end */ diff --git a/examples/menu/menufactory.h b/examples/menu/menufactory.h deleted file mode 100644 index acd04684e8..0000000000 --- a/examples/menu/menufactory.h +++ /dev/null @@ -1,18 +0,0 @@ -/* example-start menu menufactory.h */ - -#ifndef __MENUFACTORY_H__ -#define __MENUFACTORY_H__ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -void get_main_menu (GtkWidget *, GtkWidget **menubar); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __MENUFACTORY_H__ */ - -/* example-end */ diff --git a/examples/menu/mfmain.c b/examples/menu/mfmain.c deleted file mode 100644 index 5777632ee9..0000000000 --- a/examples/menu/mfmain.c +++ /dev/null @@ -1,48 +0,0 @@ -/* example-start menu mfmain.c */ - -#include <gtk/gtk.h> - -#include "mfmain.h" -#include "menufactory.h" - -int main(int argc, char *argv[]) -{ - GtkWidget *window; - GtkWidget *main_vbox; - GtkWidget *menubar; - - gtk_init(&argc, &argv); - - window = gtk_window_new(GTK_WINDOW_TOPLEVEL); - gtk_signal_connect(GTK_OBJECT(window), "destroy", - GTK_SIGNAL_FUNC(file_quit_cmd_callback), - "WM destroy"); - gtk_window_set_title(GTK_WINDOW(window), "Menu Factory"); - gtk_widget_set_usize(GTK_WIDGET(window), 300, 200); - - main_vbox = gtk_vbox_new(FALSE, 1); - gtk_container_border_width(GTK_CONTAINER(main_vbox), 1); - gtk_container_add(GTK_CONTAINER(window), main_vbox); - gtk_widget_show(main_vbox); - - get_main_menu(window, &menubar); - gtk_box_pack_start(GTK_BOX(main_vbox), menubar, FALSE, TRUE, 0); - gtk_widget_show(menubar); - - gtk_widget_show(window); - gtk_main(); - - return(0); -} - -/* This is just to demonstrate how callbacks work when using the - * menufactory. Often, people put all the callbacks from the menus - * in a separate file, and then have them call the appropriate functions - * from there. Keeps it more organized. */ -void file_quit_cmd_callback (GtkWidget *widget, gpointer data) -{ - g_print ("%s\n", (char *) data); - gtk_exit(0); -} - -/* example-end */ diff --git a/examples/menu/mfmain.h b/examples/menu/mfmain.h deleted file mode 100644 index 83fc0e3a48..0000000000 --- a/examples/menu/mfmain.h +++ /dev/null @@ -1,19 +0,0 @@ -/* example-start menu mfmain.h */ - -#ifndef __MFMAIN_H__ -#define __MFMAIN_H__ - - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -void file_quit_cmd_callback(GtkWidget *widget, gpointer data); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __MFMAIN_H__ */ - -/* example-end */ |