void gui2_init() { if(root == 0) root = (menubar_t*)malloc(sizeof(menubar_t)); menubar_create(root); }
MessageView *messageview_create_with_new_window(void) { MessageView *msgview; GtkWidget *window; GtkWidget *window_vbox; GtkWidget *body_vbox; GtkWidget *vspacer; GtkWidget *menubar; GtkItemFactory *ifactory; GtkWidget *statusbar; guint n_menu_entries; window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(window), _("Message View - Sylpheed")); gtk_window_set_wmclass(GTK_WINDOW(window), "message_view", "Sylpheed"); gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE); gtk_widget_set_size_request(window, prefs_common.msgwin_width, prefs_common.msgwin_height); msgview = messageview_create(); window_vbox = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(window), window_vbox); g_signal_connect(G_OBJECT(window), "size_allocate", G_CALLBACK(messageview_size_allocate_cb), msgview); g_signal_connect(G_OBJECT(window), "delete_event", G_CALLBACK(messageview_delete_cb), msgview); g_signal_connect(G_OBJECT(window), "key_press_event", G_CALLBACK(key_pressed), msgview); MANAGE_WINDOW_SIGNALS_CONNECT(window); n_menu_entries = sizeof(msgview_entries) / sizeof (msgview_entries[0]); menubar = menubar_create(window, msgview_entries, n_menu_entries, "<MessageView>", msgview); #if 0 menu_factory_copy_rc("<Main>", "<MessageView>"); #endif gtk_box_pack_start(GTK_BOX(window_vbox), menubar, FALSE, TRUE, 0); vspacer = gtk_vbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(window_vbox), vspacer, FALSE, TRUE, BORDER_WIDTH); body_vbox = gtk_vbox_new(FALSE, BORDER_WIDTH); gtk_box_pack_start(GTK_BOX(window_vbox), body_vbox, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(body_vbox), GTK_WIDGET_PTR(msgview), TRUE, TRUE, 0); gtk_widget_grab_focus(msgview->textview->text); statusbar = gtk_statusbar_new(); gtk_box_pack_end(GTK_BOX(body_vbox), statusbar, FALSE, FALSE, 0); msgview->statusbar = statusbar; msgview->statusbar_cid = gtk_statusbar_get_context_id (GTK_STATUSBAR(statusbar), "Message View"); msgview->new_window = TRUE; msgview->window = window; msgview->window_vbox = window_vbox; msgview->body_vbox = body_vbox; msgview->menubar = menubar; msgview->menu_locked = FALSE; msgview->visible = TRUE; gtk_widget_show_all(window); messageview_init(msgview); messageview_set_encoding_menu(msgview); ifactory = gtk_item_factory_from_widget(menubar); #ifndef G_OS_WIN32 action_update_msgview_menu(ifactory, msgview); #endif messageview_list = g_list_append(messageview_list, msgview); return msgview; }
static LRESULT CALLBACK menubar_proc(HWND win, UINT msg, WPARAM wp, LPARAM lp) { menubar_t* mb = (menubar_t*) GetWindowLongPtr(win, extra_offset); switch(msg) { case MC_MBM_REFRESH: lp = (LPARAM)mb->menu; /* no break */ case MC_MBM_SETMENU: return (menubar_set_menu(mb, (HMENU)lp, (msg == MC_MBM_REFRESH)) == 0 ? TRUE : FALSE); case TB_SETPARENT: case CCM_SETNOTIFYWINDOW: { HWND old = mb->notify_win; mb->notify_win = (wp ? (HWND) wp : GetAncestor(win, GA_PARENT)); return (LRESULT) old; } case WM_COMMAND: MENUBAR_TRACE("menubar_proc(WM_COMMAND): code=%d; wid=%d; control=%p", (int)HIWORD(wp), (int)LOWORD(wp), (HWND)lp); if(lp == 0 && HIWORD(wp) == 0) /* msg came from the menu */ return MC_SEND(mb->notify_win, msg, wp, lp); break; case WM_NOTIFY: { NMHDR* hdr = (NMHDR*) lp; if(hdr->hwndFrom == win) return menubar_notify(mb, hdr); break; } case WM_ENTERMENULOOP: case WM_EXITMENULOOP: case WM_CONTEXTMENU: case WM_INITMENU: case WM_INITMENUPOPUP: case WM_UNINITMENUPOPUP: case WM_MENUSELECT: case WM_MENUCHAR: case WM_MENURBUTTONUP: case WM_MENUCOMMAND: case WM_MENUDRAG: case WM_MENUGETOBJECT: case WM_MEASUREITEM: case WM_DRAWITEM: return MC_SEND(mb->notify_win, msg, wp, lp); case WM_KEYDOWN: case WM_SYSKEYDOWN: if(menubar_key_down(mb, wp, lp)) return 0; break; case WM_GETDLGCODE: return MENUBAR_SENDMSG(win, msg, wp, lp) | DLGC_WANTALLKEYS | DLGC_WANTARROWS; case WM_NCCREATE: if(MC_ERR(MENUBAR_SENDMSG(win, msg, wp, lp) == FALSE)) { MC_TRACE_ERR("menubar_proc: MENUBAR_SENDMSG(WM_NCCREATE) failed"); return FALSE; } mb = menubar_nccreate(win, (CREATESTRUCT*) lp); if(MC_ERR(mb == NULL)) return FALSE; SetWindowLongPtr(win, extra_offset, (LONG_PTR)mb); return TRUE; case WM_SETFOCUS: MENUBAR_TRACE("menubar_proc(WM_SETFOCUS): old focus %p", (HWND) wp); if(win != (HWND) wp) mb->old_focus = (HWND) wp; active_menubar = mb; break; case WM_KILLFOCUS: MENUBAR_TRACE("menubar_proc: WM_KILLFOCUS"); mb->old_focus = NULL; MENUBAR_SENDMSG(mb->win, TB_SETHOTITEM, -1, 0); menubar_update_ui_state(mb, FALSE); active_menubar = NULL; break; case WM_CREATE: return menubar_create(mb, (CREATESTRUCT*) lp); case WM_DESTROY: menubar_destroy(mb); break; case WM_NCDESTROY: if(mb) { menubar_ncdestroy(mb); mb = NULL; } break; /* Disable those standard toolbar messages, which modify contents of * the toolbar, as it is our internal responsibility to set it * according to the menu. */ case TB_ADDBITMAP: case TB_ADDSTRING: MC_TRACE("menubar_proc: Suppressing message TB_xxxx (%d)", msg); SetLastError(ERROR_CALL_NOT_IMPLEMENTED); return -1; case TB_ADDBUTTONS: case TB_BUTTONSTRUCTSIZE: case TB_CHANGEBITMAP: case TB_DELETEBUTTON: case TB_ENABLEBUTTON: case TB_HIDEBUTTON: case TB_INDETERMINATE: case TB_INSERTBUTTON: case TB_LOADIMAGES: case TB_MARKBUTTON: case TB_MOVEBUTTON: case TB_PRESSBUTTON: case TB_REPLACEBITMAP: case TB_SAVERESTORE: case TB_SETANCHORHIGHLIGHT: case TB_SETBITMAPSIZE: case TB_SETBOUNDINGSIZE: case TB_SETCMDID: case TB_SETDISABLEDIMAGELIST: case TB_SETHOTIMAGELIST: case TB_SETIMAGELIST: case TB_SETINSERTMARK: case TB_SETPRESSEDIMAGELIST: case TB_SETSTATE: MC_TRACE("menubar_proc: Suppressing message TB_xxxx (%d)", msg); SetLastError(ERROR_CALL_NOT_IMPLEMENTED); return 0; /* FALSE == NULL == 0 */ case TB_CUSTOMIZE: /* Actually we suppress TB_CUSTOMIZE as the message above (i.e. * not passing it into the original proc), but we also misuse * is for our internal purpose of showing the popup menu. */ menubar_perform_dropdown(mb); return 0; } return MENUBAR_SENDMSG(win, msg, wp, lp); }