From: <kr_...@us...> - 2003-04-02 19:12:19
|
Update of /cvsroot/htoolkit/port/src/cbits/GTK In directory sc8-pr-cvs1:/tmp/cvs-serv10416/src/cbits/GTK Modified Files: Frame.c Menu.c Log Message: Fix the MDI menu Index: Frame.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/GTK/Frame.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Frame.c 30 Mar 2003 18:49:07 -0000 1.4 --- Frame.c 2 Apr 2003 19:12:10 -0000 1.5 *************** *** 8,11 **** --- 8,12 ---- GtkWidget *gFrameWidget = NULL; GtkWidget *gClientWidget = NULL; + GtkWidget *gMenuBar = NULL; static void frame_close_page_handler(GtkWidget *client) *************** *** 188,192 **** void createMDIFrame() { ! GtkWidget *menuBar, *box; GtkWidget *notebook_menu, *menu_item, *pages_menu; GtkAccelGroup *accel_group; --- 189,193 ---- void createMDIFrame() { ! GtkWidget *box; GtkWidget *notebook_menu, *menu_item, *pages_menu; GtkAccelGroup *accel_group; *************** *** 213,218 **** /* Create the menubar. */ ! menuBar = gtk_menu_bar_new(); ! gtk_box_pack_start(GTK_BOX(box), menuBar, FALSE, FALSE, 0); /* Create client(notebook) */ --- 214,219 ---- /* Create the menubar. */ ! gMenuBar = gtk_menu_bar_new(); ! gtk_box_pack_start(GTK_BOX(box), gMenuBar, FALSE, FALSE, 0); /* Create client(notebook) */ *************** *** 236,240 **** gtk_widget_show_all(menu_item); ! gtk_menu_bar_insert(GTK_MENU_BAR(menuBar), menu_item, 0); notebook_menu = gtk_menu_new(); --- 237,241 ---- gtk_widget_show_all(menu_item); ! gtk_menu_bar_insert(GTK_MENU_BAR(gMenuBar), menu_item, 0); notebook_menu = gtk_menu_new(); Index: Menu.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/GTK/Menu.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Menu.c 1 Apr 2003 23:54:20 -0000 1.5 --- Menu.c 2 Apr 2003 19:12:11 -0000 1.6 *************** *** 1,118 **** ! #include "Menu.h" ! #include "Window.h" ! #include "Internals.h" ! #include "Handlers_stub.h" ! ! GtkWidget *gMenuBar = NULL; ! ! static MenuHandle getMenu(MenuHandle parent) ! { ! if (!parent) ! { ! if (!gMenuBar) ! { ! gMenuBar = gtk_menu_bar_new(); ! gtk_box_pack_start(GTK_BOX(GTK_BIN(gFrameWidget)->child), gMenuBar, FALSE, TRUE, 0); ! gtk_widget_show(gMenuBar); ! } ! ! parent = gMenuBar; ! } ! ! return parent; ! }; ! ! MenuHandle osAddMenu(MenuHandle parent, char *title) ! { ! gchar *szText = toMnemonicString(title); ! GtkWidget *menuItem = gtk_menu_item_new_with_mnemonic(szText); ! GtkWidget *popUpMenu = gtk_menu_new(); ! gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuItem), popUpMenu); ! rfree(szText); ! ! gtk_menu_shell_append(GTK_MENU_SHELL(getMenu(parent)), menuItem); ! gtk_widget_show(menuItem); ! return popUpMenu; ! }; ! ! MenuHandle osAddMenuItem(MenuHandle parent, int nKeyCode, unsigned int mods, char *title) ! { ! gchar *szText = toMnemonicString(title); ! GtkWidget *menuItem = gtk_menu_item_new_with_mnemonic(szText); ! rfree(szText); ! ! gtk_signal_connect (GTK_OBJECT(menuItem), "activate", ! GTK_SIGNAL_FUNC(handleMenuCommand), ! NULL); ! ! gtk_menu_shell_append(GTK_MENU_SHELL(getMenu(parent)), menuItem); ! gtk_widget_show(menuItem); ! return menuItem; ! }; ! ! static int in_handler_flag = 0; ! ! static void handleCheckMenuCommand(GtkMenuItem *menuitem) ! { ! if (!in_handler_flag) ! { ! in_handler_flag++; ! gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), !(GTK_CHECK_MENU_ITEM(menuitem)->active)); ! handleMenuCommand(menuitem) ; ! in_handler_flag--; ! } ! } ! ! MenuHandle osAddMenuCheckItem(MenuHandle parent, int nKeyCode, unsigned int mods, char *title) ! { ! gchar *szText = toMnemonicString(title); ! GtkWidget *menuItem = gtk_check_menu_item_new_with_mnemonic(szText); ! rfree(szText); ! ! gtk_signal_connect (GTK_OBJECT(menuItem), "activate", ! GTK_SIGNAL_FUNC(handleCheckMenuCommand), ! NULL); ! ! gtk_menu_shell_append(GTK_MENU_SHELL(getMenu(parent)), menuItem); ! gtk_widget_show(menuItem); ! return menuItem; ! }; ! ! void osAddMenuSeparatorItem(MenuHandle parent) ! { ! GtkWidget *item = gtk_separator_menu_item_new(); ! gtk_menu_shell_append(GTK_MENU_SHELL(getMenu(parent)), item); ! gtk_widget_show(item); ! } ! ! void osSetMenuItemEnabled(MenuHandle parent, MenuHandle item, BOOL bState) ! { ! gtk_widget_set_sensitive(item,bState); ! }; ! ! BOOL osGetMenuItemEnabled(MenuHandle parent, MenuHandle item) ! { ! return GTK_WIDGET_SENSITIVE(item); ! }; ! ! void osSetMenuItemChecked(MenuHandle parent, MenuHandle item, BOOL bState) ! { ! in_handler_flag++; ! gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(item), bState); ! in_handler_flag--; ! }; ! ! BOOL osGetMenuItemChecked(MenuHandle parent, MenuHandle item) ! { ! return gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(item)); ! }; ! ! void osDrawMenuBar(WindowHandle window) ! { ! /* TODO: nothing yet */ ! } ! ! void osSetMenuItemLabel(MenuHandle menu, MenuHandle item, int nKeyCode, unsigned int mods, char* title ) ! { ! /* TODO: nothing yet */ ! } --- 1,123 ---- ! #include "Menu.h" ! #include "Window.h" ! #include "Internals.h" ! #include "Handlers_stub.h" ! ! ! static MenuHandle getMenu(MenuHandle parent) ! { ! if (!parent) ! { ! if (!gMenuBar) ! { ! gMenuBar = gtk_menu_bar_new(); ! gtk_box_pack_start(GTK_BOX(GTK_BIN(gFrameWidget)->child), gMenuBar, FALSE, TRUE, 0); ! gtk_widget_show(gMenuBar); ! } ! ! parent = gMenuBar; ! } ! ! return parent; ! }; ! ! MenuHandle osAddMenu(MenuHandle parent, char *title) ! { ! GtkMenuShell *menu_shell; ! gchar *szText = toMnemonicString(title); ! GtkWidget *menuItem = gtk_menu_item_new_with_mnemonic(szText); ! GtkWidget *popUpMenu = gtk_menu_new(); ! gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuItem), popUpMenu); ! rfree(szText); ! ! menu_shell = GTK_MENU_SHELL(getMenu(parent)); ! ! if (gDocumentInterface == 1) ! gtk_menu_shell_append(menu_shell, menuItem); ! else ! gtk_menu_shell_insert(menu_shell, menuItem, g_list_length(menu_shell->children)-1); ! gtk_widget_show(menuItem); ! return popUpMenu; ! }; ! ! MenuHandle osAddMenuItem(MenuHandle parent, int nKeyCode, unsigned int mods, char *title) ! { ! gchar *szText = toMnemonicString(title); ! GtkWidget *menuItem = gtk_menu_item_new_with_mnemonic(szText); ! rfree(szText); ! ! gtk_signal_connect (GTK_OBJECT(menuItem), "activate", ! GTK_SIGNAL_FUNC(handleMenuCommand), ! NULL); ! ! gtk_menu_shell_append(GTK_MENU_SHELL(getMenu(parent)), menuItem); ! gtk_widget_show(menuItem); ! return menuItem; ! }; ! ! static int in_handler_flag = 0; ! ! static void handleCheckMenuCommand(GtkMenuItem *menuitem) ! { ! if (!in_handler_flag) ! { ! in_handler_flag++; ! gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), !(GTK_CHECK_MENU_ITEM(menuitem)->active)); ! handleMenuCommand(menuitem) ; ! in_handler_flag--; ! } ! } ! ! MenuHandle osAddMenuCheckItem(MenuHandle parent, int nKeyCode, unsigned int mods, char *title) ! { ! gchar *szText = toMnemonicString(title); ! GtkWidget *menuItem = gtk_check_menu_item_new_with_mnemonic(szText); ! rfree(szText); ! ! gtk_signal_connect (GTK_OBJECT(menuItem), "activate", ! GTK_SIGNAL_FUNC(handleCheckMenuCommand), ! NULL); ! ! gtk_menu_shell_append(GTK_MENU_SHELL(getMenu(parent)), menuItem); ! gtk_widget_show(menuItem); ! return menuItem; ! }; ! ! void osAddMenuSeparatorItem(MenuHandle parent) ! { ! GtkWidget *item = gtk_separator_menu_item_new(); ! gtk_menu_shell_append(GTK_MENU_SHELL(getMenu(parent)), item); ! gtk_widget_show(item); ! } ! ! void osSetMenuItemEnabled(MenuHandle parent, MenuHandle item, BOOL bState) ! { ! gtk_widget_set_sensitive(item,bState); ! }; ! ! BOOL osGetMenuItemEnabled(MenuHandle parent, MenuHandle item) ! { ! return GTK_WIDGET_SENSITIVE(item); ! }; ! ! void osSetMenuItemChecked(MenuHandle parent, MenuHandle item, BOOL bState) ! { ! in_handler_flag++; ! gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(item), bState); ! in_handler_flag--; ! }; ! ! BOOL osGetMenuItemChecked(MenuHandle parent, MenuHandle item) ! { ! return gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(item)); ! }; ! ! void osDrawMenuBar(WindowHandle window) ! { ! /* TODO: nothing yet */ ! } ! ! void osSetMenuItemLabel(MenuHandle menu, MenuHandle item, int nKeyCode, unsigned int mods, char* title ) ! { ! /* TODO: nothing yet */ ! } |