当前位置: 技术问答>linux和unix
linux c 菜单列表编辑怎么做(就是可以通过光标进行选择,请指点)
来源: 互联网 发布时间:2016-01-14
本文导语: linux c 菜单列表编辑怎么做(就是可以通过光标进行选择,请指点) | 我给你写一个用GTK的 #include void command1_cb(){ g_print("new is pressedn"); } void command2_cb(){ g_print("open is pressedn"); } void save_as()...
linux c 菜单列表编辑怎么做(就是可以通过光标进行选择,请指点)
|
我给你写一个用GTK的
#include
void command1_cb(){
g_print("new is pressedn");
}
void command2_cb(){
g_print("open is pressedn");
}
void save_as(){
g_print("save as pressedn");
}
/**/
static GnomeUIInfo save_menu[]={
{ GNOME_APP_UI_ITEM, N_("Save as"),N_("Save as"),save_as,NULL,NULL,0,0,'s',GDK_CONTROL_MASK,NULL},
GNOMEUIINFO_END
};
static GnomeUIInfo file_menu[]={
{ GNOME_APP_UI_ITEM, N_("New"), N_("Create a new file"),command1_cb,NULL,NULL,0,0,'a',GDK_CONTROL_MASK,NULL},
{ GNOME_APP_UI_ITEM, N_("Open"), N_("Open a file"),command2_cb,NULL,NULL,0,0,'o',GDK_CONTROL_MASK,NULL},
GNOMEUIINFO_SUBTREE(("Save"),save_menu),
/**/
GNOMEUIINFO_END
};
static GnomeUIInfo main_menu[] =
{
GNOMEUIINFO_SUBTREE(N_("_File"),file_menu),
//GNOMEUIINFO_SUBTREE(N_("_Edit"),NULL),
{GNOME_APP_UI_ITEM, ("_Edit"), N_("Edit a file"),command2_cb,NULL,NULL,0,0,0,GDK_CONTROL_MASK,NULL},
{GNOME_APP_UI_ITEM, ("_View"), N_("View a file"),command2_cb,NULL,NULL,0,0,0,GDK_CONTROL_MASK,NULL},
//GNOMEUIINFO_SUBTREE(N_("_View"),NULL),
GNOMEUIINFO_END
};
int main(int argc, char *argv[])
{
GtkWidget *window;
gnome_init("","",argc,argv);
window = gnome_app_new("gnomeapp",NULL);
//window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_signal_connect(GTK_OBJECT(window),"destroy",
GTK_SIGNAL_FUNC(gtk_main_quit),NULL);
gtk_window_set_default_size((GtkWindow *)window,400,300);
gtk_window_set_position(GTK_WINDOW (window),GTK_WIN_POS_CENTER);
gtk_widget_show(window);
gnome_app_create_menus(GNOME_APP(window), main_menu);
gtk_main();
return(0);
}
#include
void command1_cb(){
g_print("new is pressedn");
}
void command2_cb(){
g_print("open is pressedn");
}
void save_as(){
g_print("save as pressedn");
}
/**/
static GnomeUIInfo save_menu[]={
{ GNOME_APP_UI_ITEM, N_("Save as"),N_("Save as"),save_as,NULL,NULL,0,0,'s',GDK_CONTROL_MASK,NULL},
GNOMEUIINFO_END
};
static GnomeUIInfo file_menu[]={
{ GNOME_APP_UI_ITEM, N_("New"), N_("Create a new file"),command1_cb,NULL,NULL,0,0,'a',GDK_CONTROL_MASK,NULL},
{ GNOME_APP_UI_ITEM, N_("Open"), N_("Open a file"),command2_cb,NULL,NULL,0,0,'o',GDK_CONTROL_MASK,NULL},
GNOMEUIINFO_SUBTREE(("Save"),save_menu),
/**/
GNOMEUIINFO_END
};
static GnomeUIInfo main_menu[] =
{
GNOMEUIINFO_SUBTREE(N_("_File"),file_menu),
//GNOMEUIINFO_SUBTREE(N_("_Edit"),NULL),
{GNOME_APP_UI_ITEM, ("_Edit"), N_("Edit a file"),command2_cb,NULL,NULL,0,0,0,GDK_CONTROL_MASK,NULL},
{GNOME_APP_UI_ITEM, ("_View"), N_("View a file"),command2_cb,NULL,NULL,0,0,0,GDK_CONTROL_MASK,NULL},
//GNOMEUIINFO_SUBTREE(N_("_View"),NULL),
GNOMEUIINFO_END
};
int main(int argc, char *argv[])
{
GtkWidget *window;
gnome_init("","",argc,argv);
window = gnome_app_new("gnomeapp",NULL);
//window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_signal_connect(GTK_OBJECT(window),"destroy",
GTK_SIGNAL_FUNC(gtk_main_quit),NULL);
gtk_window_set_default_size((GtkWindow *)window,400,300);
gtk_window_set_position(GTK_WINDOW (window),GTK_WIN_POS_CENTER);
gtk_widget_show(window);
gnome_app_create_menus(GNOME_APP(window), main_menu);
gtk_main();
return(0);
}
|
你做个图形得了加个GTK包 全部都可搞定
|
如果是图形界面,有qt、gtk等
如果是控制台的图形界面,有sgvlib等!
如果是控制台的图形界面,有sgvlib等!
|
SVGAlib
|
QT吧
很容易上手
很容易上手