static GtkWidget * AddMenuCheckItem(GtkWidget *window1, const char * immagine_xpm, GtkWidget* Menu,const char* label, gboolean state, int Number) { GtkWidget * Label = NULL; GtkWidget * Pixmap = NULL; GtkWidget * hbox = NULL; GtkWidget * Item = NULL; GdkPixmap *PixmapIcon = NULL; GdkColor transparent; GdkBitmap *MaskIcon = NULL; PixmapIcon = gdk_pixmap_create_from_xpm_d (window1->window, &MaskIcon, &transparent,(gchar **)immagine_xpm ); Pixmap = gtk_pixmap_new (PixmapIcon, MaskIcon); gdk_pixmap_unref (PixmapIcon); Item=gtk_check_menu_item_new(); Label = gtk_label_new (label); hbox = gtk_hbox_new (FALSE, 8); gtk_box_pack_start (GTK_BOX (hbox), Pixmap, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (hbox), Label, FALSE, FALSE, 0); gtk_container_add (GTK_CONTAINER (Item), hbox); gtk_menu_append( GTK_MENU( Menu ),Item ); gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(Item),state); gtk_signal_connect_object( GTK_OBJECT(Item),"activate", GTK_SIGNAL_FUNC(ActivateMenuItem),(gpointer)Number ); gtk_menu_item_right_justify (GTK_MENU_ITEM (Item)); gtk_widget_show_all(Item); return Item; }
int clip_GTK_MENUITEMRIGHTJUSTIFY(ClipMachine * ClipMachineMemory) { C_widget *citm = _fetch_cw_arg(ClipMachineMemory); CHECKCWID(citm, GTK_IS_ITEM); gtk_menu_item_right_justify(GTK_MENU_ITEM(citm->widget)); return 0; err: return 1; }
TWindowMenu::TWindowMenu (void) : ejecutar("Run Genetic A."), paso("Run one step"), exit("Exit"), inicial("Init Pop."), prefs("Preferences"), about("About"), file_menu(), file_item("Genetic A."), prefs_menu(), prefs_item("Parameters"), help_menu(), help_item("Help") { // Put all menus on bar prepend(file_item); append(prefs_item); gtk_menu_item_right_justify( help_item.gtkobj() ); append(help_item); // set up game menu file_menu.append(ejecutar); //ejecutar.show(); file_menu.append(paso); //paso.show(); file_menu.append(exit); exit.show(); file_item.set_submenu(file_menu); file_item.show(); //prefs menu prefs_menu.append(inicial); inicial.show(); prefs_menu.append(prefs); //prefs.show(); prefs_item.set_submenu(prefs_menu); prefs_item.show(); // Help help_menu.append(about); about.show(); help_item.set_submenu(help_menu); help_item.show(); }
struct menu * gui_gtk_menu_new(struct container *co, GtkWidget **widget) { struct menu *this=g_new0(struct menu, 1); this->gui=g_new0(struct menu_gui,1); this->gui->co=co; GtkWidget *menu,*item,*menu2,*item2,*menu3,*clock; menu=gtk_menu_bar_new(); item=gtk_menu_item_new_with_label("Goto"); gtk_menu_bar_append(GTK_MENU_BAR(menu), item); { menu2=gtk_menu_new(); item2=gtk_menu_item_new_with_label("Abensberg"); gtk_menu_append (GTK_MENU(menu2), item2); gtk_signal_connect_object(GTK_OBJECT(item2), "activate", GTK_SIGNAL_FUNC (menu_goto_abensberg), this); item2=gtk_menu_item_new_with_label("Regensburg"); gtk_menu_append (GTK_MENU(menu2), item2); gtk_signal_connect_object(GTK_OBJECT(item2), "activate", GTK_SIGNAL_FUNC (menu_goto_regensburg), this); item2=gtk_menu_item_new_with_label("Problem"); gtk_menu_append (GTK_MENU(menu2), item2); gtk_signal_connect_object(GTK_OBJECT(item2), "activate", GTK_SIGNAL_FUNC (menu_goto_problem), this); } gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), menu2); item=gtk_menu_item_new_with_label("Window"); gtk_menu_bar_append(GTK_MENU_BAR(menu), item); { menu2=gtk_menu_new(); item2=gtk_menu_item_new_with_label("Clone"); gtk_menu_append (GTK_MENU(menu2), item2); gtk_signal_connect_object(GTK_OBJECT(item2), "activate", GTK_SIGNAL_FUNC (menu_window_clone), this); item2=gtk_menu_item_new_with_label("Command"); gtk_menu_append (GTK_MENU(menu2), item2); gtk_signal_connect_object(GTK_OBJECT(item2), "activate", GTK_SIGNAL_FUNC (menu_window_command), this); item2=gtk_menu_item_new_with_label("Visible Blocks"); gtk_menu_append (GTK_MENU(menu2), item2); gtk_signal_connect_object(GTK_OBJECT(item2), "activate", GTK_SIGNAL_FUNC (menu_window_visible_blocks), co); item2=gtk_menu_item_new_with_label("Visible Towns"); gtk_menu_append (GTK_MENU(menu2), item2); gtk_signal_connect_object(GTK_OBJECT(item2), "activate", GTK_SIGNAL_FUNC (menu_window_visible_towns), co); item2=gtk_menu_item_new_with_label("Visible Polys"); gtk_menu_append (GTK_MENU(menu2), item2); gtk_signal_connect_object(GTK_OBJECT(item2), "activate", GTK_SIGNAL_FUNC (menu_window_visible_polys), co); item2=gtk_menu_item_new_with_label("Visible Streets"); gtk_menu_append (GTK_MENU(menu2), item2); gtk_signal_connect_object(GTK_OBJECT(item2), "activate", GTK_SIGNAL_FUNC (menu_window_visible_streets), co); menu_item(this, menu2, "Visible Points", menu_window_visible_points); item2=gtk_menu_item_new_with_label("Exit"); gtk_menu_append (GTK_MENU(menu2), item2); gtk_signal_connect_object(GTK_OBJECT(item2), "activate", GTK_SIGNAL_FUNC (exit), this); } gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), menu2); item=gtk_menu_item_new_with_label("Map"); gtk_menu_bar_append(GTK_MENU_BAR(menu), item); { menu2=gtk_menu_new(); item2=gtk_menu_item_new_with_label("Compare"); gtk_menu_append (GTK_MENU(menu2), item2); gtk_signal_connect_object(GTK_OBJECT(item2), "activate", GTK_SIGNAL_FUNC (menu_map_compare), this); item2=gtk_menu_item_new_with_label("Distances"); gtk_menu_append (GTK_MENU(menu2), item2); gtk_signal_connect_object(GTK_OBJECT(item2), "activate", GTK_SIGNAL_FUNC (menu_map_distances), this); } gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), menu2); item=gtk_menu_item_new_with_label("Route"); gtk_menu_bar_append(GTK_MENU_BAR(menu), item); { menu2=gtk_menu_new(); item2=gtk_menu_item_new_with_label("Start"); gtk_menu_append (GTK_MENU(menu2), item2); gtk_signal_connect_object(GTK_OBJECT(item2), "activate", GTK_SIGNAL_FUNC (route_start), co); item2=gtk_menu_item_new_with_label("Trace"); gtk_menu_append (GTK_MENU(menu2), item2); gtk_signal_connect_object(GTK_OBJECT(item2), "activate", GTK_SIGNAL_FUNC (route_trace), co); item2=gtk_menu_item_new_with_label("Update"); gtk_menu_append (GTK_MENU(menu2), item2); gtk_signal_connect_object(GTK_OBJECT(item2), "activate", GTK_SIGNAL_FUNC (menu_route_update), this); } gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), menu2); item=gtk_menu_item_new_with_label("Destinations"); gtk_menu_bar_append(GTK_MENU_BAR(menu), item); menu2=gtk_menu_new(); item2=gtk_menu_item_new_with_label("Last Destinations"); gtk_menu_append (GTK_MENU(menu2), item2); menu3=gtk_menu_new(); gtk_menu_item_set_submenu(GTK_MENU_ITEM(item2), menu3); item2=gtk_menu_item_new_with_label("Address"); gtk_menu_append (GTK_MENU(menu2), item2); { FILE *file; char buffer[8192]; double lat,lng,lat_deg,lng_deg; char lat_c,lng_c; struct destination *dest; int pos,len; char *utf8,*text,*tok,*label; GList *list; file=fopen("locations.txt","r"); while (fgets(buffer,8192,file)) { dest=malloc(sizeof(*dest)); dest->co=co; len=strlen(buffer)-1; while (len >= 0 && buffer[len] == '\n') { buffer[len]='\0'; } sscanf(buffer,"%lf %c %lf %c %n",&lat, &lat_c, &lng, &lng_c, &pos); lat_deg=floor(lat/100); lat-=lat_deg*100; lat_deg+=lat/60; lng_deg=floor(lng/100); lng-=lng_deg*100; lng_deg+=lng/60; transform_mercator(&lng_deg, &lat_deg, &dest->pos); text=buffer+pos; dest->text=strdup(text); item2=NULL; menu3=menu2; while ((tok=strtok(text,"/"))) { list=NULL; if (item2) { menu3=gtk_menu_new(); gtk_menu_item_set_submenu(GTK_MENU_ITEM(item2), menu3); } list=gtk_container_get_children(GTK_CONTAINER(menu3)); while (list) { item2=GTK_WIDGET(list->data); gtk_label_get(GTK_LABEL(gtk_bin_get_child(GTK_BIN(item2))),&label); if (!strcmp(label, tok)) { menu3=gtk_menu_item_get_submenu(GTK_MENU_ITEM(item2)); break; } list=list->next; } item2=NULL; if (! list) { utf8=g_locale_to_utf8(tok,-1,NULL,NULL,NULL); item2=gtk_menu_item_new_with_label(utf8); gtk_menu_append (GTK_MENU(menu3), item2); g_free(utf8); } text=NULL; } gtk_signal_connect(GTK_OBJECT(item2), "activate", GTK_SIGNAL_FUNC (menu_destination_selected), dest); } } gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), menu2); item=gtk_menu_item_new(); clock=gtk_label_new(NULL); gtk_menu_item_right_justify(GTK_MENU_ITEM(item)); gtk_container_add(GTK_CONTAINER(item), clock); gtk_menu_bar_append(GTK_MENU_BAR(menu), item); menu_clock_update(clock); *widget=menu; return this; }
int main(int argc, char *argv[] ) { int i; char track_text[4]; gtk_init (&argc, &argv); id3win=gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(id3win),"MP3info - An ID3 tag editor"); gtk_window_set_policy (GTK_WINDOW(id3win), FALSE,FALSE,FALSE); gtk_widget_set_usize(id3win,450,360); gtk_container_border_width(GTK_CONTAINER(id3win),5); gtk_signal_connect(GTK_OBJECT(id3win), "delete_event", (GtkSignalFunc) gtk_exit, NULL); id3win_frame_global=gtk_vbox_new(FALSE,5); /* rmcc was here */ id3win_menu_bar = gtk_menu_bar_new(); gtk_widget_show(id3win_menu_bar); gtk_box_pack_start(GTK_BOX(id3win_frame_global), id3win_menu_bar, FALSE, TRUE, 1); id3win_menu_file = gtk_menu_item_new_with_label("File"); gtk_widget_show(id3win_menu_file); gtk_container_add(GTK_CONTAINER(id3win_menu_bar), id3win_menu_file); id3win_menu_fcont = gtk_menu_new(); gtk_menu_item_set_submenu(GTK_MENU_ITEM(id3win_menu_file), id3win_menu_fcont); id3win_menu_open = gtk_menu_item_new_with_label("Open New "); gtk_widget_show(id3win_menu_open); gtk_container_add(GTK_CONTAINER(id3win_menu_fcont), id3win_menu_open); gtk_signal_connect(GTK_OBJECT(id3win_menu_open), "activate", GTK_SIGNAL_FUNC(open_mp3_file), NULL); id3win_menu_info = gtk_menu_item_new_with_label("Info "); gtk_widget_show(id3win_menu_info); gtk_container_add(GTK_CONTAINER(id3win_menu_fcont), id3win_menu_info); gtk_signal_connect(GTK_OBJECT(id3win_menu_info), "activate", GTK_SIGNAL_FUNC(create_techinfo_win), NULL); id3win_menu_help = gtk_menu_item_new_with_label(" Help"); gtk_widget_show(id3win_menu_help); gtk_container_add(GTK_CONTAINER(id3win_menu_bar), id3win_menu_help); gtk_menu_item_right_justify(GTK_MENU_ITEM(id3win_menu_help)); id3win_menu_hcont = gtk_menu_new(); gtk_menu_item_set_submenu(GTK_MENU_ITEM(id3win_menu_help), id3win_menu_hcont); id3win_menu_about = gtk_menu_item_new_with_label("About "); gtk_widget_show(id3win_menu_about); gtk_container_add(GTK_CONTAINER(id3win_menu_hcont), id3win_menu_about); gtk_signal_connect(GTK_OBJECT(id3win_menu_about), "activate", GTK_SIGNAL_FUNC(about_mp3info), NULL); /* rmcc has left the building */ id3win_frame_title=gtk_frame_new("Title"); gtk_container_border_width(GTK_CONTAINER(id3win_frame_title),5); id3win_text_title=gtk_entry_new_with_max_length(30); gtk_container_add(GTK_CONTAINER(id3win_frame_title),id3win_text_title); gtk_box_pack_start(GTK_BOX(id3win_frame_global),id3win_frame_title,TRUE,TRUE,0); id3win_frame_artist=gtk_frame_new("Artist"); gtk_container_border_width(GTK_CONTAINER(id3win_frame_artist),5); id3win_text_artist=gtk_entry_new_with_max_length(30); gtk_container_add(GTK_CONTAINER(id3win_frame_artist),id3win_text_artist); gtk_box_pack_start(GTK_BOX(id3win_frame_global),id3win_frame_artist,TRUE,TRUE,0); id3win_frame_albyear=gtk_hbox_new(FALSE,30); id3win_frame_album=gtk_frame_new("Album"); gtk_container_border_width(GTK_CONTAINER(id3win_frame_album),5); id3win_text_album=gtk_entry_new_with_max_length(30); gtk_container_add(GTK_CONTAINER(id3win_frame_album),id3win_text_album); gtk_box_pack_start(GTK_BOX(id3win_frame_albyear),id3win_frame_album,TRUE,TRUE,0); id3win_frame_year=gtk_frame_new("Year"); gtk_widget_set_usize(id3win_frame_year,2,0); gtk_container_border_width(GTK_CONTAINER(id3win_frame_year),5); id3win_text_year=gtk_entry_new_with_max_length(4); gtk_container_add(GTK_CONTAINER(id3win_frame_year),id3win_text_year); gtk_box_pack_start(GTK_BOX(id3win_frame_albyear),id3win_frame_year,TRUE,TRUE,0); gtk_box_pack_start(GTK_BOX(id3win_frame_global),id3win_frame_albyear,TRUE,TRUE,0); id3win_frame_comtrack=gtk_hbox_new(FALSE,30); id3win_frame_comment=gtk_frame_new("Comment"); gtk_container_border_width(GTK_CONTAINER(id3win_frame_comment),5); id3win_text_comment=gtk_entry_new_with_max_length(30); gtk_container_add(GTK_CONTAINER(id3win_frame_comment),id3win_text_comment); gtk_box_pack_start(GTK_BOX(id3win_frame_comtrack),id3win_frame_comment,TRUE,TRUE,0); id3win_frame_track=gtk_frame_new("Track"); gtk_widget_set_usize(id3win_frame_track,2,0); gtk_container_border_width(GTK_CONTAINER(id3win_frame_track),5); id3win_text_track=gtk_entry_new_with_max_length(3); gtk_container_add(GTK_CONTAINER(id3win_frame_track),id3win_text_track); gtk_box_pack_start(GTK_BOX(id3win_frame_comtrack),id3win_frame_track,TRUE,TRUE,0); gtk_box_pack_start(GTK_BOX(id3win_frame_global),id3win_frame_comtrack,TRUE,TRUE,0); id3win_frame_genre=gtk_frame_new("Genre"); gtk_container_border_width(GTK_CONTAINER(id3win_frame_genre),5); id3win_combo_genre=gtk_combo_new(); for(i=0;i<MAXGENRE+2;i++) { genrelist = g_list_append(genrelist, typegenre[galphagenreindex[i]]); } gtk_combo_set_popdown_strings(GTK_COMBO(id3win_combo_genre),genrelist); gtk_container_add(GTK_CONTAINER(id3win_frame_genre),id3win_combo_genre); gtk_box_pack_start(GTK_BOX(id3win_frame_global),id3win_frame_genre,TRUE,TRUE,0); id3win_frame_buttons=gtk_hbox_new(TRUE,30); id3win_ok_button=gtk_button_new_with_label("OK"); gtk_box_pack_start(GTK_BOX(id3win_frame_buttons),id3win_ok_button,TRUE,TRUE,0); if(read_only) { gtk_widget_set_sensitive (id3win_text_title, FALSE); gtk_widget_set_sensitive (id3win_text_artist, FALSE); gtk_widget_set_sensitive (id3win_text_album, FALSE); gtk_widget_set_sensitive (id3win_text_year, FALSE); gtk_widget_set_sensitive (id3win_text_comment, FALSE); gtk_widget_set_sensitive (id3win_text_track, FALSE); gtk_widget_set_sensitive (id3win_combo_genre, FALSE); } else { id3win_cancel_button=gtk_button_new_with_label("Cancel"); gtk_box_pack_start(GTK_BOX(id3win_frame_buttons),id3win_cancel_button,TRUE,TRUE,0); gtk_signal_connect (GTK_OBJECT (id3win_cancel_button), "clicked", GTK_SIGNAL_FUNC (gtk_exit), NULL); } gtk_widget_set_usize(id3win_frame_buttons,30,20); gtk_box_pack_start(GTK_BOX(id3win_frame_global),id3win_frame_buttons,TRUE,TRUE,0); gtk_container_add(GTK_CONTAINER(id3win),id3win_frame_global); gtk_signal_connect (GTK_OBJECT (id3win_ok_button), "clicked", GTK_SIGNAL_FUNC (exit_save), NULL); gtk_widget_show_all(id3win); memset(&mp3,0,sizeof(mp3info)); if(argc==2) { if (! load_mp3(argv[1])) { exit(0); } gtk_entry_set_text(GTK_ENTRY(id3win_text_title),mp3.id3.title); gtk_entry_set_text(GTK_ENTRY(id3win_text_artist),mp3.id3.artist); gtk_entry_set_text(GTK_ENTRY(id3win_text_album),mp3.id3.album); gtk_entry_set_text(GTK_ENTRY(id3win_text_year),mp3.id3.year); gtk_entry_set_text(GTK_ENTRY(id3win_text_comment),mp3.id3.comment); if(mp3.id3.track[0] > 0) sprintf(track_text,"%d",(int)mp3.id3.track[0]); else track_text[0]=0; gtk_entry_set_text(GTK_ENTRY(id3win_text_track),track_text); gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(id3win_combo_genre)->entry), gtext_genre(mp3.id3.genre[0])); } else { open_mp3_file(); } gtk_main(); return(0); }
/* Constructs the main program window. The specified mode will be the one * initially selected in the Vis menu */ void window_init( FsvMode fsv_mode ) { GtkWidget *main_window_w; GtkWidget *main_vbox_w; GtkWidget *menu_bar_w; GtkWidget *menu_w; GtkWidget *menu_item_w; GtkWidget *hpaned_w; GtkWidget *vpaned_w; GtkWidget *left_vbox_w; GtkWidget *right_vbox_w; GtkWidget *hbox_w; GtkWidget *button_w; GtkWidget *frame_w; GtkWidget *dir_ctree_w; GtkWidget *file_clist_w; GtkWidget *gl_area_w; GtkWidget *x_scrollbar_w; GtkWidget *y_scrollbar_w; int window_width, window_height; /* Main window widget */ main_window_w = gtk_window_new( GTK_WINDOW_TOPLEVEL ); gtk_window_set_title( GTK_WINDOW(main_window_w), "fsv" ); gtk_window_set_wmclass( GTK_WINDOW(main_window_w), "main", "fsv" ); gtk_window_set_policy( GTK_WINDOW(main_window_w), TRUE, TRUE, TRUE ); window_width = 3 * gdk_screen_width( ) / 4; window_height = 2584 * window_width / 4181; gtk_widget_set_usize( main_window_w, window_width, window_height ); gtk_signal_connect( GTK_OBJECT(main_window_w), "delete_event", GTK_SIGNAL_FUNC(gtk_main_quit), NULL ); gtk_quit_add_destroy( 1, GTK_OBJECT(main_window_w) ); /* Main vertical box widget */ main_vbox_w = gui_vbox_add( main_window_w, 0 ); /* Build menu bar */ /* Menu bar widget */ menu_bar_w = gtk_menu_bar_new( ); gtk_box_pack_start( GTK_BOX(main_vbox_w), menu_bar_w, FALSE, FALSE, 0 ); gtk_widget_show( menu_bar_w ); /* File menu */ menu_w = gui_menu_add( menu_bar_w, _("File") ); /* File menu items */ menu_item_w = gui_menu_item_add( menu_w, _("Change root..."), on_file_change_root_activate, NULL ); gui_keybind( menu_item_w, _("^N") ); G_LIST_APPEND(sw_widget_list, menu_item_w); #if 0 gui_menu_item_add( menu_w, _("Save settings"), on_file_save_settings_activate, NULL ); #endif gui_separator_add( menu_w ); menu_item_w = gui_menu_item_add( menu_w, _("Exit"), on_file_exit_activate, NULL ); gui_keybind( menu_item_w, _("^Q") ); /* Vis menu */ menu_w = gui_menu_add( menu_bar_w, _("Vis") ); /* Vis menu items */ gui_radio_menu_begin( fsv_mode -1 ); #if 0 /* DiscV mode needs more work */ gui_radio_menu_item_add( menu_w, _("DiscV"), on_vis_discv_activate, NULL ); /* Note: don't forget to remove the "-1" three lines up */ #endif gui_radio_menu_item_add( menu_w, _("MapV"), on_vis_mapv_activate, NULL ); gui_radio_menu_item_add( menu_w, _("TreeV"), on_vis_treev_activate, NULL ); /* Color menu */ menu_w = gui_menu_add( menu_bar_w, _("Colors") ); /* Color menu items */ gui_radio_menu_begin( 0 ); menu_item_w = gui_radio_menu_item_add( menu_w, _("By node type"), on_color_by_nodetype_activate, NULL ); G_LIST_APPEND(sw_widget_list, menu_item_w); color_by_nodetype_rmenu_item_w = menu_item_w; menu_item_w = gui_radio_menu_item_add( menu_w, _("By timestamp"), on_color_by_timestamp_activate, NULL ); G_LIST_APPEND(sw_widget_list, menu_item_w); color_by_timestamp_rmenu_item_w = menu_item_w; menu_item_w = gui_radio_menu_item_add( menu_w, _("By wildcards"), on_color_by_wildcards_activate, NULL ); G_LIST_APPEND(sw_widget_list, menu_item_w); color_by_wpattern_rmenu_item_w = menu_item_w; gui_separator_add( menu_w ); gui_menu_item_add( menu_w, _("Setup..."), on_color_setup_activate, NULL ); #ifdef DEBUG /* Debug menu */ menu_w = gui_menu_add( menu_bar_w, "Debug" ); /* Debug menu items */ gui_menu_item_add( menu_w, "Memory totals", debug_show_mem_totals, NULL ); gui_menu_item_add( menu_w, "Memory summary", debug_show_mem_summary, NULL ); gui_menu_item_add( menu_w, "Memory stats", debug_show_mem_stats, NULL ); gui_separator_add( menu_w ); gui_menu_item_add( menu_w, "GLib memory profile", g_mem_profile, NULL ); gui_menu_item_add( menu_w, "GMemChunk info", g_mem_chunk_info, NULL ); #endif /* Help menu (right-justified) */ menu_w = gui_menu_add( menu_bar_w, _("Help") ); gtk_menu_item_right_justify( GTK_MENU_ITEM(GTK_MENU(menu_w)->parent_menu_item) ); /* Help menu items */ gui_menu_item_add( menu_w, _("Contents..."), on_help_contents_activate, NULL ); gui_separator_add( menu_w ); gui_menu_item_add( menu_w, _("About fsv..."), on_help_about_fsv_activate, NULL ); /* Done with the menu bar */ /* Main horizontal paned widget */ hpaned_w = gui_hpaned_add( main_vbox_w, window_width / 5 ); /* Vertical box for everything in the left pane */ left_vbox_w = gtk_vbox_new( FALSE, 0 ); gtk_paned_add1( GTK_PANED(hpaned_w), left_vbox_w ); gtk_widget_show( left_vbox_w ); /* Horizontal box for toolbar buttons */ hbox_w = gui_hbox_add( left_vbox_w, 2 ); /* "back" button */ button_w = gui_button_add( hbox_w, NULL, on_back_button_clicked, NULL ); gui_pixmap_xpm_add( button_w, back_xpm ); G_LIST_APPEND(sw_widget_list, button_w); /* "cd /" button */ button_w = gui_button_add( hbox_w, NULL, on_cd_root_button_clicked, NULL ); gui_pixmap_xpm_add( button_w, cd_root_xpm ); G_LIST_APPEND(sw_widget_list, button_w); /* "cd .." button */ button_w = gui_button_add( hbox_w, NULL, on_cd_up_button_clicked, NULL ); gui_pixmap_xpm_add( button_w, cd_up_xpm ); G_LIST_APPEND(sw_widget_list, button_w); /* "bird's-eye view" toggle button */ button_w = gui_toggle_button_add( hbox_w, NULL, FALSE, on_birdseye_view_togglebutton_toggled, NULL ); gui_pixmap_xpm_add( button_w, birdseye_view_xpm ); G_LIST_APPEND(sw_widget_list, button_w); birdseye_view_tbutton_w = button_w; /* Frame to encase the directory tree / file list */ frame_w = gui_frame_add( left_vbox_w, NULL ); /* Vertical paned widget for directory tree / file list */ vpaned_w = gui_vpaned_add( frame_w, window_height / 3 ); /* Directory tree goes in top pane */ dir_ctree_w = gui_ctree_add( NULL ); gtk_paned_add1( GTK_PANED(vpaned_w), dir_ctree_w->parent ); gtk_widget_show( dir_ctree_w->parent ); /* File list goes in bottom pane */ file_clist_w = gui_clist_add( NULL, 3, NULL ); gtk_paned_add2( GTK_PANED(vpaned_w), file_clist_w->parent ); gtk_widget_show( file_clist_w->parent ); /* Left statusbar */ left_statusbar_w = gui_statusbar_add( left_vbox_w ); /* Vertical box for everything in the right pane */ right_vbox_w = gtk_vbox_new( FALSE, 0 ); gtk_paned_add2( GTK_PANED(hpaned_w), right_vbox_w ); gtk_widget_show( right_vbox_w ); /* Horizontal box for viewport and y-scrollbar */ hbox_w = gui_hbox_add( right_vbox_w, 0 ); gui_widget_packing( hbox_w, EXPAND, FILL, AT_START ); /* Main viewport (OpenGL area widget) */ gl_area_w = gui_gl_area_add( hbox_w ); gtk_signal_connect( GTK_OBJECT(gl_area_w), "event", GTK_SIGNAL_FUNC(viewport_cb), NULL ); /* y-scrollbar */ y_scrollbar_w = gui_vscrollbar_add( hbox_w, NULL ); G_LIST_APPEND(sw_widget_list, y_scrollbar_w); /* x-scrollbar */ x_scrollbar_w = gui_hscrollbar_add( right_vbox_w, NULL ); G_LIST_APPEND(sw_widget_list, x_scrollbar_w); /* Right statusbar */ right_statusbar_w = gui_statusbar_add( right_vbox_w ); /* Bind program icon to main window */ gui_window_icon_xpm( main_window_w, fsv_icon_xpm ); /* Attach keybindings */ gui_keybind( main_window_w, NULL ); /* Send out the widgets to their respective modules */ dialog_pass_main_window_widget( main_window_w ); dirtree_pass_widget( dir_ctree_w ); filelist_pass_widget( file_clist_w ); camera_pass_scrollbar_widgets( x_scrollbar_w, y_scrollbar_w ); /* Showtime! */ gtk_widget_show( main_window_w ); }
void do_menu (GtkWidget * vbox) { GtkWidget *menu_bar, *menu, *smenu; GtkWidget *mi; GtkWidget *handlebox; menu_bar = gtk_menu_bar_new (); menu = gtk_menu_item_new_with_label (_("File")); gtk_widget_show (menu); smenu = gtk_menu_new (); gtk_widget_show (smenu); gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu), smenu); mi = gtk_menu_item_new_with_label (_("C-Wizard")); gtk_signal_connect (GTK_OBJECT (mi), "activate", GTK_SIGNAL_FUNC (clist), NULL); gtk_widget_show (mi); gtk_menu_append (GTK_MENU (smenu), mi); mi = gtk_menu_item_new_with_label (_("Connect")); gtk_signal_connect (GTK_OBJECT (mi), "activate", GTK_SIGNAL_FUNC (cbox), NULL); gtk_widget_show (mi); gtk_menu_append (GTK_MENU (smenu), mi); mi = gtk_menu_item_new_with_label (_("Disconnect")); gtk_signal_connect (GTK_OBJECT (mi), "activate", GTK_SIGNAL_FUNC (disconnect), NULL); gtk_widget_show (mi); gtk_menu_append (GTK_MENU (smenu), mi); mi = gtk_menu_item_new (); gtk_widget_show (mi); gtk_menu_append (GTK_MENU (smenu), mi); /* mi = gtk_menu_item_new_with_label (_("Preferences...")); gtk_signal_connect (GTK_OBJECT (mi), "activate", GTK_SIGNAL_FUNC (show_config), NULL); gtk_widget_show (mi); gtk_menu_append (GTK_MENU (smenu), mi); */ mi = gtk_menu_item_new (); gtk_widget_show (mi); gtk_menu_append (GTK_MENU (smenu), mi); mi = gtk_menu_item_new_with_label (_("Exit")); gtk_signal_connect (GTK_OBJECT (mi), "activate", GTK_SIGNAL_FUNC (bmud_exit), NULL); gtk_widget_show (mi); gtk_menu_append (GTK_MENU (smenu), mi); gtk_menu_bar_append (GTK_MENU_BAR (menu_bar), menu); menu = gtk_menu_item_new_with_label (_("Tools")); gtk_widget_show (menu); smenu = gtk_menu_new (); gtk_widget_show (smenu); gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu), smenu); mi = gtk_menu_item_new_with_label (_("Equip")); gtk_signal_connect (GTK_OBJECT (mi), "activate", GTK_SIGNAL_FUNC (NULL), NULL); gtk_widget_set_sensitive (GTK_WIDGET (mi), FALSE); gtk_widget_show (mi); gtk_menu_append (GTK_MENU (smenu), mi); mi = gtk_menu_item_new_with_label (_("Map")); gtk_signal_connect (GTK_OBJECT (mi), "activate", GTK_SIGNAL_FUNC (NULL), NULL); gtk_widget_set_sensitive (GTK_WIDGET (mi), FALSE); gtk_widget_show (mi); gtk_menu_append (GTK_MENU (smenu), mi); gtk_menu_bar_append (GTK_MENU_BAR (menu_bar), menu); menu = gtk_menu_item_new_with_label (_("Help")); gtk_widget_show (menu); gtk_menu_item_right_justify (GTK_MENU_ITEM (menu)); smenu = gtk_menu_new (); gtk_widget_show (smenu); gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu), smenu); mi = gtk_menu_item_new_with_label (_("About")); gtk_signal_connect (GTK_OBJECT (mi), "activate", GTK_SIGNAL_FUNC (do_about), NULL); gtk_widget_show (mi); gtk_menu_append (GTK_MENU (smenu), mi); mi = gtk_menu_item_new_with_label (_("Manual")); /* I d'no about this one */ /* gtk_signal_connect(GTK_OBJECT(mi),"activate",GTK_SIGNAL_FUNC(gtk_main_quit),NULL); */ gtk_widget_show (mi); gtk_menu_append (GTK_MENU (smenu), mi); gtk_menu_bar_append (GTK_MENU_BAR (menu_bar), menu); gtk_widget_show (menu_bar); handlebox = gtk_handle_box_new (); gtk_widget_show (handlebox); gtk_container_add (GTK_CONTAINER (handlebox), menu_bar); gtk_box_pack_start (GTK_BOX (vbox), handlebox, FALSE, FALSE, 0); return; }
GtkWidget * create_term_menu(ZvtTerm *term, gchar *command) { GtkWidget *menu_bar; GtkWidget *menu; GtkWidget *menu_item; GtkWidget *vide_menu; GtkWidget *tools_menu; GtkWidget *term_label; GdkColor color = TAB_COLOR; GtkStyle *defstyle; GtkStyle *style = gtk_style_new(); menu_bar = gtk_menu_bar_new(); defstyle = gtk_widget_get_default_style(); style = gtk_style_copy(defstyle); style->fg[0] = color; menu = gtk_menu_new(); gtk_signal_connect(GTK_OBJECT(menu), "key_press_event", GTK_SIGNAL_FUNC(menu_key_cb), NULL); gtk_object_set_data(GTK_OBJECT(term), "menu_bar", menu_bar); /* The terminal is running vi */ if(GPOINTER_TO_INT(gtk_object_get_user_data(GTK_OBJECT(term)))) { add_menu_item(menu, "Open File in Buffer", create_fileselector, GUINT_TO_POINTER(0)); if(strcmp(cfg.vi_clone, "vi")) add_menu_item (menu, "Split Buffer & Open File", create_fileselector, GUINT_TO_POINTER(1)); if(!strcmp(cfg.vi_clone, "vim")) add_menu_item (menu, "VSplit Buffer & Open File", create_fileselector, GUINT_TO_POINTER(2)); add_menu_separator (menu); } add_menu_item(menu, "Open File in New Term", create_fileselector, GUINT_TO_POINTER(3)); add_menu_separator (menu); add_menu_item(menu, "New Shell", split_zterm, NULL); add_menu_separator(menu); add_menu_item(menu, "List Pages", create_page_menu, NULL); add_menu_separator(menu); add_menu_item(menu, "Detach Term", detach_term, term); add_menu_separator(menu); add_menu_item (menu, "Cancel", NULL, NULL); vide_menu = add_submenu (menu_bar, "_Vide", menu); gtk_object_set_data(GTK_OBJECT(term), "vide_menu", vide_menu); menu = gtk_menu_new(); gtk_signal_connect(GTK_OBJECT(menu), "key_press_event", GTK_SIGNAL_FUNC(menu_key_cb), NULL); add_menu_item(menu, "Look up word", lookup_word, term); add_menu_separator(menu); /* add_menu_item(menu, "Compare file to..", compare_file, term); add_menu_separator(menu); */ /* I don't know how to visually select text in nvi and vile if((!strcmp("vim", cfg.vi_clone) | (!strcmp("elvis", cfg.vi_clone)))) { add_menu_item(menu, "Copy", copy_text, term); add_menu_separator(menu); add_menu_item(menu, "Paste", paste_text, term); add_menu_separator(menu); } */ add_menu_item(menu, "Cancel", NULL, NULL); tools_menu = add_submenu(menu_bar, "_Tools", menu); gtk_object_set_data(GTK_OBJECT(term), "tools_menu", tools_menu); /* label for filename on menubar */ menu = gtk_menu_new(); menu_item = gtk_menu_item_new(); term_label = gtk_widget_new(GTK_TYPE_LABEL, "GtkWidget::visible", TRUE, "GtkWidget::parent", menu_item, "GtkMisc::xalign", 0, 0, NULL); gtk_label_set_text(GTK_LABEL(term_label), command); gtk_widget_set_style(GTK_WIDGET(term_label), style); gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_item), menu); gtk_menu_bar_append(GTK_MENU_BAR(menu_bar), menu_item); gtk_menu_item_right_justify(GTK_MENU_ITEM(menu_item)); gtk_widget_show(menu_item); gtk_object_set_data(GTK_OBJECT(term), "term_label", term_label); return menu_bar; }
GtkWidget * create_main_menu_bar (void) { GtkWidget *main_menu_bar; GtkWidget *menu; GtkWidget *filter_menu; GtkWidget *menu_item; main_menu_bar = gtk_menu_bar_new (); menu = gtk_menu_new(); gtk_signal_connect(GTK_OBJECT(menu), "key_press_event", GTK_SIGNAL_FUNC(bookmark_key_cb), NULL); add_menu_item(menu, "Cancel ", NULL, NULL); add_menu_separator (menu); add_menu_item (menu, "Become Root", root_cb, NULL); add_menu_separator (menu); add_menu_item (menu, "Open Trash", open_trash_cb, NULL); add_menu_item (menu, "Empty Trash", empty_trash_cb, NULL); add_menu_separator (menu); add_menu_item (menu, "Quit Alt Q", quit_cb, NULL); app.vide_menu_item = add_submenu (main_menu_bar, "_Vide", menu); app.bookmark_menu = gtk_menu_new (); gtk_signal_connect (GTK_OBJECT (app.bookmark_menu), "key_press_event", GTK_SIGNAL_FUNC (bookmark_key_cb), NULL); add_menu_item (app.bookmark_menu, "Edit Bookmarks", edit_bookmarks_cb, NULL); add_menu_separator (app.bookmark_menu); app.bookmark_menu_item = add_submenu (main_menu_bar, "_Bookmarks", app.bookmark_menu); menu = gtk_menu_new (); gtk_signal_connect (GTK_OBJECT (menu), "key_press_event", GTK_SIGNAL_FUNC (bookmark_key_cb), NULL); add_menu_item(menu, "Show Dot Files", show_hidden_cb, NULL); add_menu_separator (menu); filter_menu = gtk_menu_new(); gtk_signal_connect(GTK_OBJECT(filter_menu), "key_press_event", GTK_SIGNAL_FUNC(bookmark_key_cb), NULL); add_menu_item(filter_menu, "File Name Filter", filename_cb, NULL); add_menu_separator(filter_menu); add_menu_item(filter_menu, "Date Filter", date_filter_cb, NULL); add_menu_separator(filter_menu); add_menu_item(filter_menu, "Size Filter", size_filter_cb, NULL); menu_item = add_menu_item(menu, "Set Filters", NULL, NULL); gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_item), filter_menu); add_menu_separator(menu); add_menu_item(menu, "Remove Filters", remove_filters_cb, NULL); add_menu_separator(menu); add_menu_item (menu, "Configure", create_config_dialog, NULL); add_menu_separator(menu); add_menu_item(menu, "Cancel ", NULL, NULL); app.options_menu_item = add_submenu (main_menu_bar, "_Options", menu); /* menu = gtk_menu_new(); gtk_signal_connect(GTK_OBJECT(menu), "key_press_event", GTK_SIGNAL_FUNC(bookmark_key_cb), NULL); add_menu_item(menu, "Open Project", NULL, NULL); add_menu_item(menu, "New Project", NULL, NULL); add_menu_item(menu, "Import Project", NULL, NULL); add_menu_separator(menu); add_menu_item(menu, "Close Project", NULL, NULL); app.tools_menu_item = add_submenu(main_menu_bar, "_Tools", menu); */ menu = gtk_menu_new (); gtk_signal_connect (GTK_OBJECT (menu), "key_press_event", GTK_SIGNAL_FUNC (bookmark_key_cb), NULL); add_menu_item(menu, "Using Vide :h", help_cb, NULL); add_menu_separator(menu); add_menu_item(menu, "Cancel ", NULL, NULL); app.help_menu_item = add_submenu (main_menu_bar, "_Help", menu); gtk_menu_item_right_justify (GTK_MENU_ITEM (app.help_menu_item)); return main_menu_bar; }
void create_main_window (const char *tag, int instance_count) { GtkWidget *vbox1; GtkWidget *menubar1; GtkWidget *file1; GtkWidget *file1_menu; GtkWidget *menu_save; GtkWidget *menu_patchlist; GtkWidget *separator1; GtkWidget *menu_quit; GtkWidget *help1; GtkWidget *help1_menu; GtkWidget *menu_about; GtkWidget *scrolledwindow1; GtkWidget *viewport1; GtkAccelGroup *accel_group; GdkPixbuf *icon; if ((icon = gtk_icon_theme_load_icon(gtk_icon_theme_get_default(), "ghostess", 32, 0, NULL)) != NULL) { gtk_window_set_default_icon(icon); g_object_unref(icon); } accel_group = gtk_accel_group_new (); main_window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_object_set_data (GTK_OBJECT (main_window), "main_window", main_window); gtk_window_set_title (GTK_WINDOW (main_window), tag); /* gtk_widget_realize(main_window); // window must be realized for create_logo_pixmap() */ vbox1 = gtk_vbox_new (FALSE, 0); gtk_widget_ref (vbox1); gtk_object_set_data_full (GTK_OBJECT (main_window), "vbox1", vbox1, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (vbox1); gtk_container_add (GTK_CONTAINER (main_window), vbox1); menubar1 = gtk_menu_bar_new (); gtk_widget_ref (menubar1); gtk_object_set_data_full (GTK_OBJECT (main_window), "menubar1", menubar1, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (menubar1); gtk_box_pack_start (GTK_BOX (vbox1), menubar1, FALSE, FALSE, 0); file1 = gtk_menu_item_new_with_label ("File"); gtk_widget_ref (file1); gtk_object_set_data_full (GTK_OBJECT (main_window), "file1", file1, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (file1); gtk_container_add (GTK_CONTAINER (menubar1), file1); file1_menu = gtk_menu_new (); gtk_widget_ref (file1_menu); gtk_object_set_data_full (GTK_OBJECT (main_window), "file1_menu", file1_menu, (GtkDestroyNotify) gtk_widget_unref); gtk_menu_item_set_submenu (GTK_MENU_ITEM (file1), file1_menu); menu_save = gtk_menu_item_new_with_label ("Save Configuration..."); gtk_widget_ref (menu_save); gtk_object_set_data_full (GTK_OBJECT (main_window), "menu_save", menu_save, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (menu_save); gtk_container_add (GTK_CONTAINER (file1_menu), menu_save); gtk_widget_add_accelerator (menu_save, "activate", accel_group, GDK_S, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE); menu_patchlist = gtk_menu_item_new_with_label ("Patchlist Export for Freewheeling..."); gtk_widget_ref (menu_patchlist); gtk_object_set_data_full (GTK_OBJECT (main_window), "menu_patchlist", menu_patchlist, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (menu_patchlist); gtk_container_add (GTK_CONTAINER (file1_menu), menu_patchlist); gtk_widget_add_accelerator (menu_patchlist, "activate", accel_group, GDK_P, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE); separator1 = gtk_menu_item_new (); gtk_widget_ref (separator1); gtk_object_set_data_full (GTK_OBJECT (main_window), "separator1", separator1, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (separator1); gtk_container_add (GTK_CONTAINER (file1_menu), separator1); gtk_widget_set_sensitive (separator1, FALSE); menu_quit = gtk_menu_item_new_with_label ("Quit"); gtk_widget_ref (menu_quit); gtk_object_set_data_full (GTK_OBJECT (main_window), "menu_quit", menu_quit, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (menu_quit); gtk_container_add (GTK_CONTAINER (file1_menu), menu_quit); gtk_widget_add_accelerator (menu_quit, "activate", accel_group, GDK_Q, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE); help1 = gtk_menu_item_new_with_label ("About"); gtk_widget_ref (help1); gtk_object_set_data_full (GTK_OBJECT (main_window), "help1", help1, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (help1); gtk_container_add (GTK_CONTAINER (menubar1), help1); gtk_menu_item_right_justify (GTK_MENU_ITEM (help1)); help1_menu = gtk_menu_new (); gtk_widget_ref (help1_menu); gtk_object_set_data_full (GTK_OBJECT (main_window), "help1_menu", help1_menu, (GtkDestroyNotify) gtk_widget_unref); gtk_menu_item_set_submenu (GTK_MENU_ITEM (help1), help1_menu); menu_about = gtk_menu_item_new_with_label ("About ghostess"); gtk_widget_ref (menu_about); gtk_object_set_data_full (GTK_OBJECT (main_window), "menu_about", menu_about, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (menu_about); gtk_container_add (GTK_CONTAINER (help1_menu), menu_about); plugin_hbox = gtk_hbox_new (FALSE, 0); gtk_widget_ref (plugin_hbox); gtk_object_set_data_full (GTK_OBJECT (main_window), "plugin_hbox", plugin_hbox, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (plugin_hbox); if (instance_count > 5) { scrolledwindow1 = gtk_scrolled_window_new (NULL, NULL); gtk_widget_ref (scrolledwindow1); gtk_object_set_data_full (GTK_OBJECT (main_window), "scrolledwindow1", scrolledwindow1, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (scrolledwindow1); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow1), GTK_POLICY_AUTOMATIC, GTK_POLICY_NEVER); gtk_range_set_update_policy (GTK_RANGE (GTK_SCROLLED_WINDOW (scrolledwindow1)->vscrollbar), GTK_POLICY_AUTOMATIC); gtk_box_pack_start (GTK_BOX (vbox1), scrolledwindow1, TRUE, TRUE, 0); gtk_widget_set_size_request(GTK_WIDGET(scrolledwindow1), 400, -1); viewport1 = gtk_viewport_new (NULL, NULL); gtk_widget_ref (viewport1); gtk_object_set_data_full (GTK_OBJECT (main_window), "viewport1", viewport1, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (viewport1); gtk_container_add (GTK_CONTAINER (scrolledwindow1), viewport1); gtk_container_add (GTK_CONTAINER (viewport1), plugin_hbox); } else { gtk_box_pack_start (GTK_BOX (vbox1), plugin_hbox, TRUE, TRUE, 0); } gtk_signal_connect(GTK_OBJECT(main_window), "destroy", GTK_SIGNAL_FUNC(gtk_main_quit), NULL); gtk_signal_connect (GTK_OBJECT (main_window), "delete_event", (GtkSignalFunc)on_delete_event_wrapper, (gpointer)on_menu_quit_activate); gtk_signal_connect (GTK_OBJECT (menu_save), "activate", GTK_SIGNAL_FUNC (on_menu_save_activate), NULL); gtk_signal_connect (GTK_OBJECT (menu_patchlist), "activate", GTK_SIGNAL_FUNC (on_menu_patchlist_activate), NULL); gtk_signal_connect (GTK_OBJECT (menu_quit), "activate", GTK_SIGNAL_FUNC (on_menu_quit_activate), NULL); gtk_signal_connect (GTK_OBJECT (menu_about), "activate", GTK_SIGNAL_FUNC (on_menu_about_activate), NULL); gtk_window_add_accel_group (GTK_WINDOW (main_window), accel_group); }