Re: [gtk-list] Re: Creating objects in gtk+ ??
- From: Sascha Ziemann <szi aibon ping de>
- To: gtk-list redhat com
- Subject: Re: [gtk-list] Re: Creating objects in gtk+ ??
- Date: Mon, 28 Jul 1997 07:04:30 +0200
Shawn T. Amundson wrote:
> I've been messing around with GTK for a while and still haven't taken
> the time to figure out menus. :-(
First you have to write a funktion for every menu: (the translate
function returns simple strings)
/***********************************************************************
** Create the File-Menu
*/
GtkWidget* create_file_menu (GtkWidget *window)
{
GtkWidget *menu;
GtkWidget *submenu;
GtkWidget *menuitem;
GSList *group;
menu = gtk_menu_new ();
submenu = NULL;
group = NULL;
menuitem = gtk_menu_item_new_with_label(translate("file-new-label"));
gtk_menu_append (GTK_MENU (menu), menuitem);
gtk_widget_show (menuitem);
menuitem = gtk_menu_item_new_with_label(translate("file-open-label"));
gtk_menu_append (GTK_MENU (menu), menuitem);
gtk_widget_show (menuitem);
gtk_menu_line_new(GTK_MENU(menu));
menuitem = gtk_menu_item_new_with_label(translate("file-save-label"));
gtk_menu_append (GTK_MENU (menu), menuitem);
gtk_widget_show (menuitem);
menuitem = gtk_menu_item_new_with_label(translate("file-saveas-label"));
gtk_menu_append (GTK_MENU (menu), menuitem);
gtk_widget_show (menuitem);
menuitem = gtk_menu_item_new_with_label(translate("file-saveall-label"));
gtk_menu_append (GTK_MENU (menu), menuitem);
gtk_widget_show (menuitem);
gtk_menu_line_new(GTK_MENU(menu));
menuitem = gtk_menu_item_new_with_label(translate("file-export-label"));
gtk_menu_append (GTK_MENU (menu), menuitem);
gtk_widget_show (menuitem);
return menu;
}
And in you main window creation function you create a menubar in a box.
/*
** base frame
*/
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_signal_connect (GTK_OBJECT (window), "destroy",
(GtkSignalFunc) destroy_program,
&window);
gtk_widget_set_name (window, "EDINI");
gtk_widget_set_uposition (window, 20, 20);
base_frame_box = gtk_vbox_new (FALSE, 10);
gtk_container_add (GTK_CONTAINER (window), base_frame_box);
gtk_widget_show (base_frame_box);
/*
** the menu bar
*/
menubar = gtk_menu_bar_new ();
gtk_box_pack_start (GTK_BOX (base_frame_box), menubar, FALSE, TRUE, 0);
gtk_widget_show (menubar);
menu = create_file_menu(window);
menuitem = gtk_menu_item_new_with_label(translate("file-menu-label"));
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), menu);
gtk_menu_bar_append (GTK_MENU_BAR (menubar), menuitem);
gtk_widget_show (menuitem);
Was that the problem?
-- bis später...
- Sascha ---<~>=( http://www.ping.de/sites/aibon/ )=<~>---
() Free speech online
/\ http://www.eff.org/BlueRibbon/bluehtml.html
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]