本文整理汇总了C++中GTK_MENU_BAR函数的典型用法代码示例。如果您正苦于以下问题:C++ GTK_MENU_BAR函数的具体用法?C++ GTK_MENU_BAR怎么用?C++ GTK_MENU_BAR使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GTK_MENU_BAR函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: gtk_menu_bar_append
GtkWidget *createMenu()
{
//建立菜单条并把第一级菜单项放入
GtkWidget *menubar=gtk_menu_bar_new();//建立菜单条
GtkWidget *menuitem[2];
menuitem[0]=gtk_menu_item_new_with_label("文件");//建立菜单项
gtk_menu_bar_append(GTK_MENU_BAR(menubar),menuitem[0]);//把菜单项加入到菜单条中
menuitem[1]=gtk_menu_item_new_with_label("帮助");
gtk_menu_bar_append(GTK_MENU_BAR(menubar),menuitem[1]);
GtkWidget *menu[2];
//建立menuitem[0]的子菜单
menu[0]=gtk_menu_new();//建立菜单
GtkWidget *menuitem0_0=gtk_menu_item_new_with_label("退出");
gtk_menu_shell_append(GTK_MENU_SHELL(menu[0]),menuitem0_0);//把菜单项加入到菜单中
gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem[0]),menu[0]);//最后把菜单menu1粘到菜单项menuitem1上
//如法炮制menuitem[1]的子菜单
menu[1]=gtk_menu_new();
GtkWidget *menuitem1_0=gtk_menu_item_new_with_label("关于");
gtk_menu_shell_append(GTK_MENU_SHELL(menu[1]),menuitem1_0);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem[1]),menu[1]);
//连接信号和函数
gtk_signal_connect(GTK_OBJECT(menuitem0_0),"activate",GTK_SIGNAL_FUNC(gtk_main_quit),NULL);
gtk_signal_connect(GTK_OBJECT(menuitem1_0),"activate",GTK_SIGNAL_FUNC(about_system),NULL);
return menubar;
}
示例2: make_menus
void make_menus(GtkWidget *box)
{
GtkWidget *menu, *menu_bar, *root_menu, *menu_items;
/* FILE menu */
menu = gtk_menu_new ();
menu_items = gtk_menu_item_new_with_label ("Open");
gtk_menu_append (GTK_MENU (menu), menu_items);
gtk_signal_connect_object (GTK_OBJECT (menu_items), "activate",
GTK_SIGNAL_FUNC(open_func), NULL);
gtk_widget_show(menu_items);
menu_items = gtk_menu_item_new_with_label ("Exit");
gtk_menu_append (GTK_MENU (menu), menu_items);
gtk_signal_connect_object (GTK_OBJECT (menu_items), "activate",
GTK_SIGNAL_FUNC(exit_func), NULL);
gtk_widget_show(menu_items);
root_menu = gtk_menu_item_new_with_label ("File");
gtk_widget_show (root_menu);
gtk_menu_item_set_submenu (GTK_MENU_ITEM (root_menu), menu);
menu_bar = gtk_menu_bar_new ();
gtk_box_pack_start (GTK_BOX (box), menu_bar, FALSE, FALSE, 0);
gtk_widget_show (menu_bar);
gtk_menu_bar_append (GTK_MENU_BAR (menu_bar), root_menu);
/* OPTIONS menu */
menu = gtk_menu_new ();
menu_items = gtk_menu_item_new_with_label ("Options");
gtk_menu_append (GTK_MENU (menu), menu_items);
gtk_signal_connect_object (GTK_OBJECT (menu_items), "activate",
GTK_SIGNAL_FUNC(open_options_window), NULL);
gtk_widget_show(menu_items);
// root_menu = gtk_menu_item_new_with_label ("Options");
// gtk_widget_show (root_menu);
root_menu = gtk_menu_item_new_with_label ("Options");
gtk_widget_show (root_menu);
gtk_menu_item_set_submenu (GTK_MENU_ITEM (root_menu), menu);
gtk_menu_bar_append (GTK_MENU_BAR (menu_bar), root_menu);
/* HELP menu */
menu = gtk_menu_new ();
menu_items = gtk_menu_item_new_with_label ("About");
gtk_menu_append (GTK_MENU (menu), menu_items);
gtk_signal_connect_object (GTK_OBJECT (menu_items), "activate",
GTK_SIGNAL_FUNC(open_about_menu), NULL);
gtk_widget_show(menu_items);
menu_items = gtk_menu_item_new_with_label ("Help");
gtk_menu_append (GTK_MENU (menu), menu_items);
gtk_signal_connect_object (GTK_OBJECT (menu_items), "activate",
GTK_SIGNAL_FUNC(open_help_menu), NULL);
gtk_widget_show(menu_items);
root_menu = gtk_menu_item_new_with_label ("Help");
gtk_widget_show (root_menu);
//gtk_menu_item_right_justify(GTK_MENU_ITEM(root_menu)); //(for later)
gtk_menu_item_set_submenu (GTK_MENU_ITEM (root_menu), menu);
gtk_menu_bar_append (GTK_MENU_BAR (menu_bar), root_menu);
}
示例3: CreateMainWindow
void CreateMainWindow(GtkWidget **m_oWindow, GtkWidget **m_oMenuBar, GtkWidget **m_oFileItem, GtkWidget **m_oDSPItem)
{
// Main Window
gtk_window_set_title(GTK_WINDOW(m_oWindow), "Benchmark Suite");
gtk_window_set_default_size(GTK_WINDOW(m_oWindow), 290, 200);
gtk_window_set_position(GTK_WINDOW(m_oWindow), GTK_WIN_POS_CENTER);
gtk_container_set_border_width(GTK_CONTAINER(m_oWindow), 5);
gtk_menu_bar_append(GTK_MENU_BAR(m_oMenuBar), m_oFileItem);
gtk_menu_bar_append(GTK_MENU_BAR(m_oMenuBar), m_oDSPItem);
}
示例4: build_menus
void build_menus( GtkWidget* window )
{
GtkWidget* menu_bar;
GtkWidget* file_menu;
GtkWidget* file_item;
GtkWidget* file_open;
GtkWidget* file_quit;
menu_bar = gtk_menu_bar_new( );
file_menu = gtk_menu_new( );
file_open = gtk_menu_item_new_with_label( "Open" );
gtk_signal_connect_object( GTK_OBJECT( file_open ), "activate",
GTK_SIGNAL_FUNC( show_open_dialog ), NULL );
gtk_menu_append( GTK_MENU( file_menu ), file_open );
gtk_widget_show( file_open );
file_quit = gtk_menu_item_new_with_label( "Quit" );
gtk_signal_connect_object( GTK_OBJECT( file_quit ), "activate",
GTK_SIGNAL_FUNC( query_quit ), NULL );
gtk_menu_append( GTK_MENU( file_menu ), file_quit );
gtk_widget_show( file_quit );
file_item = gtk_menu_item_new_with_label( "File" );
gtk_menu_item_set_submenu( GTK_MENU_ITEM( file_item ), file_menu );
gtk_widget_show( file_item );
gtk_menu_bar_append( GTK_MENU_BAR( menu_bar ), file_item );
gtk_container_add( GTK_CONTAINER( window ), menu_bar );
gtk_widget_show( menu_bar );
}
示例5: gtk_image_menu_item_get_preferred_height
static void
gtk_image_menu_item_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural)
{
GtkImageMenuItem *image_menu_item = GTK_IMAGE_MENU_ITEM (widget);
GtkImageMenuItemPrivate *priv = image_menu_item->priv;
gint child_height = 0;
GtkPackDirection pack_dir;
GtkWidget *parent;
parent = gtk_widget_get_parent (widget);
if (GTK_IS_MENU_BAR (parent))
pack_dir = gtk_menu_bar_get_child_pack_direction (GTK_MENU_BAR (parent));
else
pack_dir = GTK_PACK_DIRECTION_LTR;
if (priv->image && gtk_widget_get_visible (priv->image))
{
GtkRequisition child_requisition;
gtk_widget_get_preferred_size (priv->image, &child_requisition, NULL);
child_height = child_requisition.height;
}
GTK_WIDGET_CLASS (gtk_image_menu_item_parent_class)->get_preferred_height (widget, minimum, natural);
if (pack_dir == GTK_PACK_DIRECTION_RTL || pack_dir == GTK_PACK_DIRECTION_LTR)
{
*minimum = MAX (*minimum, child_height);
*natural = MAX (*natural, child_height);
}
}
示例6: menu_new
GtkMenuBar* menu_new(gpointer userData)
{
GtkWidget* pMenuBar = NULL;
GtkWidget* pMenuFile = NULL;
GtkWidget* pMenuItemFile = NULL;
pMenuBar = gtk_menu_bar_new();
pMenuFile = gtk_menu_new();
pMenuItemFile = gtk_menu_item_new_with_mnemonic("_File");
menu_item_new(GTK_MENU(pMenuFile), "_New", G_CALLBACK(map_editor_new_file), userData);
menu_item_new(GTK_MENU(pMenuFile), "_Open", G_CALLBACK(map_editor_open_file), userData);
menu_item_new(GTK_MENU(pMenuFile), "_Save", G_CALLBACK(map_editor_save), userData);
menu_item_new(GTK_MENU(pMenuFile), "Save _As", G_CALLBACK(map_editor_save_as), userData);
menu_item_new(GTK_MENU(pMenuFile), "_Close", G_CALLBACK(map_editor_close), userData);
menu_item_new(GTK_MENU(pMenuFile), "_Quit", G_CALLBACK(map_editor_quit), userData);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(pMenuItemFile), pMenuFile);
gtk_menu_shell_append(GTK_MENU_SHELL(pMenuBar), pMenuItemFile);
pMenuFile = gtk_menu_new();
pMenuItemFile = gtk_menu_item_new_with_mnemonic("_?");
menu_item_new(GTK_MENU(pMenuFile), "_Help", G_CALLBACK(NULL), userData);
menu_item_new(GTK_MENU(pMenuFile), "_About", G_CALLBACK(NULL), userData);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(pMenuItemFile), pMenuFile);
gtk_menu_shell_append(GTK_MENU_SHELL(pMenuBar), pMenuItemFile);
return GTK_MENU_BAR(pMenuBar);
}
示例7: malloc
/**
* Generate menubar menus.
*
* Generate the main menu structure and attach it to a menubar widget.
*/
struct nsgtk_bar_submenu *nsgtk_menu_bar_create(GtkMenuShell *menubar, GtkAccelGroup *group)
{
;
struct nsgtk_bar_submenu *nmenu;
nmenu = malloc(sizeof(struct nsgtk_bar_submenu));
if (nmenu == NULL) {
warn_user(messages_get("NoMemory"), 0);
return NULL;
}
nmenu->bar_menu = GTK_MENU_BAR(menubar);
nmenu->file_submenu = nsgtk_menu_file_submenu(group);
ATTACH_PARENT(menubar, gtkFile, nmenu->file_submenu->file, group);
nmenu->edit_submenu = nsgtk_menu_edit_submenu(group);
ATTACH_PARENT(menubar, gtkEdit, nmenu->edit_submenu->edit, group);
nmenu->view_submenu = nsgtk_menu_view_submenu(group);
ATTACH_PARENT(menubar, gtkView, nmenu->view_submenu->view, group);
nmenu->nav_submenu = nsgtk_menu_nav_submenu(group);
ATTACH_PARENT(menubar, gtkNavigate, nmenu->nav_submenu->nav, group);
nmenu->help_submenu = nsgtk_menu_help_submenu(group);
ATTACH_PARENT(menubar, gtkHelp, nmenu->help_submenu->help, group);
return nmenu;
}
示例8: gtk_image_menu_item_get_preferred_width
static void
gtk_image_menu_item_get_preferred_width (GtkWidget *widget,
gint *minimum,
gint *natural)
{
GtkImageMenuItem *image_menu_item = GTK_IMAGE_MENU_ITEM (widget);
GtkImageMenuItemPrivate *priv = image_menu_item->priv;
GtkPackDirection pack_dir;
GtkWidget *parent;
parent = gtk_widget_get_parent (widget);
if (GTK_IS_MENU_BAR (parent))
pack_dir = gtk_menu_bar_get_child_pack_direction (GTK_MENU_BAR (parent));
else
pack_dir = GTK_PACK_DIRECTION_LTR;
GTK_WIDGET_CLASS (gtk_image_menu_item_parent_class)->get_preferred_width (widget, minimum, natural);
if ((pack_dir == GTK_PACK_DIRECTION_TTB || pack_dir == GTK_PACK_DIRECTION_BTT) &&
priv->image &&
gtk_widget_get_visible (priv->image))
{
gint child_minimum, child_natural;
gtk_widget_get_preferred_width (priv->image, &child_minimum, &child_natural);
*minimum = MAX (*minimum, child_minimum);
*natural = MAX (*natural, child_natural);
}
}
示例9: gnoclMenuBarCmd
int gnoclMenuBarCmd( ClientData data, Tcl_Interp *interp,
int objc, Tcl_Obj * const objv[] )
{
int ret;
GtkMenuBar *menuBar;
if( gnoclParseOptions( interp, objc, objv, menuBarOptions )
!= TCL_OK )
{
gnoclClearOptions( menuBarOptions );
return TCL_ERROR;
}
menuBar = GTK_MENU_BAR( gtk_menu_bar_new( ) );
gtk_widget_show( GTK_WIDGET( menuBar ) );
ret = gnoclSetOptions( interp, menuBarOptions, G_OBJECT( menuBar ), -1 );
if( ret == TCL_OK )
ret = configure( interp, menuBar, menuBarOptions );
gnoclClearOptions( menuBarOptions );
if( ret != TCL_OK )
{
gtk_widget_destroy( GTK_WIDGET( menuBar ) );
return TCL_ERROR;
}
return gnoclRegisterWidget( interp, GTK_WIDGET( menuBar ), menuBarFunc );
}
示例10: create_toolbox
/**
* Create toolbox component for distributed user interface
*/
void
create_toolbox ()
{
GtkWidget *window;
GtkWidget *main_vbox;
GtkWidget *wrapbox;
GtkWidget *menubar;
GtkAccelGroup *accel_group;
#ifdef HAVE_GNOME
window = gnome_app_new ("Dia", _("Diagram Editor"));
#else
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_object_ref(window);
gtk_window_set_title (GTK_WINDOW (window), "Dia v" VERSION);
#endif
gtk_window_set_role (GTK_WINDOW (window), "toolbox_window");
gtk_window_set_default_size(GTK_WINDOW(window), 146, 349);
app_set_icon (GTK_WINDOW (window));
g_signal_connect (G_OBJECT (window), "delete_event",
G_CALLBACK (toolbox_delete), window);
g_signal_connect (G_OBJECT (window), "destroy",
G_CALLBACK (toolbox_destroy), window);
main_vbox = gtk_vbox_new (FALSE, 1);
gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 1);
#ifdef HAVE_GNOME
gnome_app_set_contents(GNOME_APP(window), main_vbox);
#else
gtk_container_add (GTK_CONTAINER (window), main_vbox);
#endif
wrapbox = toolbox_create();
gtk_box_pack_end (GTK_BOX (main_vbox), wrapbox, TRUE, TRUE, 0);
g_signal_connect (G_OBJECT (wrapbox), "drag_data_received",
G_CALLBACK (dia_dnd_file_drag_data_received),
NULL); /* userdata == NULL here intentionally */
gtk_widget_show (main_vbox);
/* menus -- initialised afterwards, because initing the display menus
* uses the tool buttons*/
menus_get_toolbox_menubar(&menubar, &accel_group);
gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
#ifdef HAVE_GNOME
gnome_app_set_menus(GNOME_APP(window), GTK_MENU_BAR(menubar));
#else
# ifdef HAVE_MAC_INTEGRATION
_create_mac_integration ();
# else
gtk_box_pack_start (GTK_BOX (main_vbox), menubar, FALSE, TRUE, 0);
gtk_widget_show (menubar);
# endif
#endif
persistence_register_window(GTK_WINDOW(window));
toolbox_shell = window;
}
示例11: matenu_menu_bar_real_forall_internal
static void matenu_menu_bar_real_forall_internal (GtkContainer* base, gboolean include_internals, GtkCallback callback, void* callback_target) {
MatenuMenuBar * self;
self = (MatenuMenuBar*) base;
if (include_internals) {
callback ((GtkWidget*) self->priv->_overflown_arrow, callback_target);
}
GTK_CONTAINER_CLASS (matenu_menu_bar_parent_class)->forall ((GtkContainer*) GTK_MENU_BAR (self), include_internals, callback, callback_target);
}
示例12: panel_menu_bar_object_update_orientation
static void
panel_menu_bar_object_update_orientation (PanelMenuBarObject *menubar)
{
GtkPackDirection pack_direction;
double text_angle;
float text_xalign;
float text_yalign;
GList *children, *l;
pack_direction = GTK_PACK_DIRECTION_LTR;
text_angle = 0.0;
text_xalign = 0.0;
text_yalign = 0.5;
switch (menubar->priv->orientation) {
case PANEL_ORIENTATION_TOP:
case PANEL_ORIENTATION_BOTTOM:
break;
case PANEL_ORIENTATION_LEFT:
pack_direction = GTK_PACK_DIRECTION_BTT;
text_angle = 90.0;
text_xalign = 0.5;
text_yalign = 0.0;
break;
case PANEL_ORIENTATION_RIGHT:
pack_direction = GTK_PACK_DIRECTION_TTB;
text_angle = 270.0;
text_xalign = 0.5;
text_yalign = 0.0;
break;
default:
g_assert_not_reached ();
break;
}
gtk_menu_bar_set_pack_direction (GTK_MENU_BAR (menubar), pack_direction);
gtk_menu_bar_set_child_pack_direction (GTK_MENU_BAR (menubar), pack_direction);
children = gtk_container_get_children (GTK_CONTAINER (menubar));
for (l = children; l != NULL; l = l->next)
set_item_text_angle_and_alignment (GTK_WIDGET (l->data),
text_angle,
text_xalign,
text_yalign);
g_list_free (children);
}
示例13: matenu_menu_bar_real_dispose
static void matenu_menu_bar_real_dispose (GObject* base) {
MatenuMenuBar * self;
self = (MatenuMenuBar*) base;
if (!self->priv->disposed) {
self->priv->disposed = TRUE;
gtk_menu_shell_remove_all (self);
}
G_OBJECT_CLASS (matenu_menu_bar_parent_class)->dispose ((GObject*) GTK_MENU_BAR (self));
}
示例14: matenu_menu_bar_real_insert
static void matenu_menu_bar_real_insert (GtkMenuShell* base, GtkWidget* child, gint position) {
MatenuMenuBar * self;
self = (MatenuMenuBar*) base;
g_return_if_fail (child != NULL);
GTK_MENU_SHELL_CLASS (matenu_menu_bar_parent_class)->insert ((GtkMenuShell*) GTK_MENU_BAR (self), child, position);
if (MATENU_IS_MENU_ITEM (child)) {
GtkWidget* _tmp0_;
matenu_menu_item_set_gravity ((_tmp0_ = child, MATENU_IS_MENU_ITEM (_tmp0_) ? ((MatenuMenuItem*) _tmp0_) : NULL), matenu_menu_bar_get_gravity (self));
}
}
示例15: menuBarFunc
static int menuBarFunc( ClientData data, Tcl_Interp *interp,
int objc, Tcl_Obj * const objv[] )
{
static const char *cmds[] = { "delete", "configure",
"add", "addBegin", "addEnd", NULL };
enum cmdIdx { DeleteIdx, ConfigureIdx, AddIdx, BeginIdx, EndIdx };
GtkMenuBar *menuBar = GTK_MENU_BAR( data );
int idx;
if( objc < 2 )
{
Tcl_WrongNumArgs( interp, 1, objv, "command" );
return TCL_ERROR;
}
if( Tcl_GetIndexFromObj( interp, objv[1], cmds, "command",
TCL_EXACT, &idx ) != TCL_OK )
return TCL_ERROR;
switch( idx )
{
case DeleteIdx:
return gnoclDelete( interp, GTK_WIDGET( menuBar ), objc, objv );
case ConfigureIdx:
{
int ret = TCL_ERROR;
if( gnoclParseAndSetOptions( interp, objc - 1, objv + 1,
menuBarOptions, G_OBJECT( menuBar ) ) == TCL_OK )
{
ret = configure( interp, menuBar, menuBarOptions );
}
gnoclClearOptions( menuBarOptions );
return ret;
}
break;
case AddIdx:
case BeginIdx:
case EndIdx:
{
if( objc != 3 )
{
Tcl_WrongNumArgs( interp, 2, objv, "widget-list" );
return TCL_ERROR;
}
return gnoclMenuShellAddChildren( interp,
GTK_MENU_SHELL( menuBar ), objv[2], idx != EndIdx );
}
}
return TCL_OK;
}