void main() { float g,h,gtemp,gtemp2,t,ttemp,ttemp2,dg,dt,s; char i; introduction(); for(i='y';i=='y';) { printf("\n"); printf("\n"); printf("ENTER input G-->"); scanf("%d",&g); printf("\n"); printf("ENTER input H-->"); scanf("%d",&h); printf("\n"); gtemp=g*1.1; gtemp2=g*0.9; dg=gtemp-gtemp2; t=g/(1+(g*h)); ttemp=gtemp/(1+(gtemp*h)); ttemp2=gtemp2/(1+(gtemp2*h)); dt=ttemp-ttemp2; s=(dt*g)/(dg*t); printf("The calculated sensitivity values are.\n\n"); printf(" Delta T = %12e\n\n",dt); printf(" T\n"); printf(" S = %12e\n",s); printf(" G\n\n"); printf("Another calculation (Y/N)\n"); } }
void ManicKnights::run() { // program and reset the FPGA programFpga(); // show the intro screen introduction(); }
void arkanoid::Game::init_screen_settings(){ initscr(); start_color(); init_colors(); cbreak(); noecho(); introduction(); keypad(stdscr, TRUE); srand (time(NULL)); default_max_col = 80; default_max_row = 24; health = 3; level_nr = 0; }
void FormWidgets::populateSubMenu(Wt::WMenu *menu) { menu->addItem("Introduction", introduction())->setPathComponent(""); menu->addItem("Line/Text editor", deferCreate(boost::bind (&FormWidgets::textEditors, this))); menu->addItem("Check boxes", deferCreate(boost::bind (&FormWidgets::checkBox, this))); menu->addItem("Radio buttons", deferCreate(boost::bind (&FormWidgets::radioButton, this))); menu->addItem("Combo box", deferCreate(boost::bind (&FormWidgets::comboBox, this))); menu->addItem("Selection box", deferCreate(boost::bind (&FormWidgets::selectionBox, this))); menu->addItem("Autocomplete", deferCreate(boost::bind (&FormWidgets::autoComplete, this))); menu->addItem("Date entry", deferCreate(boost::bind (&FormWidgets::dateEntry, this))); menu->addItem("In-place edit", deferCreate(boost::bind (&FormWidgets::inPlaceEdit, this))); menu->addItem("Slider", deferCreate(boost::bind (&FormWidgets::slider, this))); menu->addItem("Progress bar", deferCreate(boost::bind (&FormWidgets::progressBar, this))); menu->addItem("File upload", deferCreate(boost::bind (&FormWidgets::fileUpload, this))); menu->addItem("Push button", deferCreate(boost::bind (&FormWidgets::pushButton, this))); menu->addItem("Validation", deferCreate(boost::bind (&FormWidgets::validation, this))); menu->addItem("Integration example", deferCreate(boost::bind (&FormWidgets::example, this))); }
int main() { introduction(); string q=getcommond(); while(q.size()&&q.compare("exit")) { Commond commond=Commond(q); commond.commond_to_array(); execommond(commond); q=getcommond(); } if(q.compare("exit")==0) { cout<<"goodbye"<<endl; system("pause"); } return 0; }
void Home::createHome() { WTemplate *result = new WTemplate(tr("template"), root()); homePage_ = result; WContainerWidget *languagesDiv = new WContainerWidget(); languagesDiv->setId("top_languages"); for (unsigned i = 0; i < languages.size(); ++i) { if (i != 0) new WText("- ", languagesDiv); const Lang& l = languages[i]; new WAnchor(WLink(WLink::InternalPath, l.path_), WString::fromUTF8(l.longDescription_), languagesDiv); } WStackedWidget *contents = new WStackedWidget(); WAnimation fade(WAnimation::Fade, WAnimation::Linear, 250); contents->setTransitionAnimation(fade); contents->setId("main_page"); mainMenu_ = new WMenu(contents, Vertical); mainMenu_->addItem (tr("introduction"), introduction())->setPathComponent(""); mainMenu_->addItem (tr("blog"), deferCreate(boost::bind(&Home::blog, this))); mainMenu_->addItem (tr("features"), wrapView(&Home::features), WMenuItem::PreLoading); mainMenu_->addItem (tr("documentation"), wrapView(&Home::documentation), WMenuItem::PreLoading); mainMenu_->addItem (tr("examples"), examples(), WMenuItem::PreLoading)->setPathComponent("examples/"); mainMenu_->addItem (tr("download"), deferCreate(boost::bind(&Home::download, this)), WMenuItem::PreLoading); mainMenu_->addItem (tr("community"), wrapView(&Home::community), WMenuItem::PreLoading); mainMenu_->addItem (tr("other-language"), wrapView(&Home::otherLanguage), WMenuItem::PreLoading); mainMenu_->itemSelectRendered().connect(this, &Home::updateTitle); mainMenu_->itemSelected().connect(this, &Home::googleAnalyticsLogger); // Make the menu be internal-path aware. mainMenu_->setInternalPathEnabled("/"); sideBarContent_ = new WContainerWidget(); result->bindWidget("languages", languagesDiv); result->bindWidget("menu", mainMenu_); result->bindWidget("contents", contents); result->bindWidget("sidebar", sideBarContent_); }
main (int argc, char *argv[]) { char inFile[80]; char ans; int ans2; int done = 0; int play_again_flag = 1; int seed = 1; printf ("argc = %d\n", argc); if (argc >= 3) { printf ("argv[1] = %s, argv[2] = %s\n", argv[1], argv[2]); if (!strcmp(argv[1], "-i")) strcpy (inFile, argv[2]); printf ("inFile = %s\n", inFile); inFile_fp = fopen (inFile, "r"); if (inFile_fp == NULL) printf ("failed to open input file - %s\n", inFile); else printf ("reading commands from input file - %s\n", inFile); if (argc == 4) { printf ("argv[3] = %s\n", argv[1]); seed = atoi(argv[3]); printf ("using specified random seed = %d\n", seed); } else { printf ("using default random seed = %d\n", seed); } } else if (argc == 2) { printf ("argv[1] = %s\n", argv[1]); seed = atoi(argv[1]); printf ("using specified random seed = %d\n", seed); } else if (argc == 1) { seed = (((int) time(0)) % 100000) + 2; printf ("using generated random seed = %d\n", seed); } srand(seed); initialize(); introduction(); printf ("Do you wish to skip the detailed reports "); printf ("at the end of each year"); ans = getYesNo(); szR = ans; printf ("Do you want to play"); ans = getYesNo(); if (ans == 'Y') { printf ("okay - let's give the wheel a spin\n\n"); play_again_flag = 1; } else { printf ("ok - see ya round\n"); play_again_flag = 0; } while (play_again_flag) { start_new_game(); done = 0; while (!done) { last_years_results(); if (end_of_game_check()) { done = 1; continue; } feed_the_peasants(); if (starvation_and_unrest()) { done = 1; continue; } if (purchase_land() == 0) { if (sell_land()) { done = 1; continue; } } if (war_with_the_king()) { done = 1; continue; } grain_production(); update_land_tables(); crop_yield_and_losses(); if (war()) { done = 1; continue; } population_changes(); if (harvest_grain()) { done = 1; continue; } update_unrest(); } play_again_flag = play_again(); } exit(0); }
BackupAssistant::BackupAssistant(int dummy) : AssistantBase(_("Backup"), _("backup")) // Backup assistant. { gtk_assistant_set_forward_page_func (GTK_ASSISTANT (assistant), GtkAssistantPageFunc (assistant_forward_function), gpointer(this), NULL); g_signal_connect (G_OBJECT (assistant), "apply", G_CALLBACK (on_assistant_apply_signal), gpointer(this)); g_signal_connect (G_OBJECT (assistant), "prepare", G_CALLBACK (on_assistant_prepare_signal), gpointer(this)); introduction (_("A backup helps keep your data safe")); // Configuration and initialization. extern Settings *settings; ustring project = settings->genconfig.project_get(); // Build the GUI for the task selector. vbox_select_type = gtk_vbox_new (FALSE, 0); gtk_widget_show (vbox_select_type); page_number_select_type = gtk_assistant_append_page (GTK_ASSISTANT (assistant), vbox_select_type); gtk_container_set_border_width (GTK_CONTAINER (vbox_select_type), 10); gtk_assistant_set_page_title (GTK_ASSISTANT (assistant), vbox_select_type, _("What would you like to backup?")); gtk_assistant_set_page_type (GTK_ASSISTANT (assistant), vbox_select_type, GTK_ASSISTANT_PAGE_CONTENT); gtk_assistant_set_page_complete (GTK_ASSISTANT (assistant), vbox_select_type, true); GSList *radiobutton_select_type_group = NULL; radiobutton_select_type_bible = gtk_radio_button_new_with_mnemonic (NULL, _("Bible")); gtk_widget_show (radiobutton_select_type_bible); gtk_box_pack_start (GTK_BOX (vbox_select_type), radiobutton_select_type_bible, FALSE, FALSE, 0); gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_select_type_bible), radiobutton_select_type_group); radiobutton_select_type_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_select_type_bible)); radiobutton_select_type_notes = gtk_radio_button_new_with_mnemonic (NULL, _("Notes")); gtk_widget_show (radiobutton_select_type_notes); gtk_box_pack_start (GTK_BOX (vbox_select_type), radiobutton_select_type_notes, FALSE, FALSE, 0); gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_select_type_notes), radiobutton_select_type_group); radiobutton_select_type_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_select_type_notes)); radiobutton_select_type_resource = gtk_radio_button_new_with_mnemonic (NULL, _("Resource")); gtk_widget_show (radiobutton_select_type_resource); gtk_box_pack_start (GTK_BOX (vbox_select_type), radiobutton_select_type_resource, FALSE, FALSE, 0); gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_select_type_resource), radiobutton_select_type_group); radiobutton_select_type_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_select_type_resource)); radiobutton_select_type_everything = gtk_radio_button_new_with_mnemonic (NULL, _("Everything")); gtk_widget_show (radiobutton_select_type_everything); gtk_box_pack_start (GTK_BOX (vbox_select_type), radiobutton_select_type_everything, FALSE, FALSE, 0); gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_select_type_everything), radiobutton_select_type_group); radiobutton_select_type_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_select_type_everything)); Shortcuts shortcuts_select_type (0); shortcuts_select_type.button (radiobutton_select_type_bible); shortcuts_select_type.button (radiobutton_select_type_notes); shortcuts_select_type.button (radiobutton_select_type_resource); shortcuts_select_type.button (radiobutton_select_type_everything); shortcuts_select_type.consider_assistant(); shortcuts_select_type.process(); // Confirm or change Bible. vbox_bible_name = gtk_vbox_new (FALSE, 5); gtk_widget_show (vbox_bible_name); page_number_bible_name = gtk_assistant_append_page (GTK_ASSISTANT (assistant), vbox_bible_name); gtk_container_set_border_width (GTK_CONTAINER (vbox_bible_name), 10); gtk_assistant_set_page_title (GTK_ASSISTANT (assistant), vbox_bible_name, _("Is this the right Bible?")); gtk_assistant_set_page_type (GTK_ASSISTANT (assistant), vbox_bible_name, GTK_ASSISTANT_PAGE_CONTENT); gtk_assistant_set_page_complete (GTK_ASSISTANT (assistant), vbox_bible_name, true); label_bible_name = gtk_label_new (_("Bible name")); gtk_widget_show (label_bible_name); gtk_box_pack_start (GTK_BOX (vbox_bible_name), label_bible_name, FALSE, FALSE, 0); button_bible_name = gtk_button_new (); gtk_widget_show (button_bible_name); gtk_box_pack_start (GTK_BOX (vbox_bible_name), button_bible_name, FALSE, FALSE, 0); g_signal_connect ((gpointer) button_bible_name, "clicked", G_CALLBACK (on_button_bible_name_clicked), gpointer (this)); GtkWidget *alignment1; GtkWidget *hbox1; GtkWidget *image1; GtkWidget *label1; alignment1 = gtk_alignment_new (0.5, 0.5, 0, 0); gtk_widget_show (alignment1); gtk_container_add (GTK_CONTAINER (button_bible_name), alignment1); hbox1 = gtk_hbox_new (FALSE, 2); gtk_widget_show (hbox1); gtk_container_add (GTK_CONTAINER (alignment1), hbox1); image1 = gtk_image_new_from_stock (_("gtk-open"), GTK_ICON_SIZE_BUTTON); gtk_widget_show (image1); gtk_box_pack_start (GTK_BOX (hbox1), image1, FALSE, FALSE, 0); label1 = gtk_label_new_with_mnemonic (_("Choose another one")); gtk_widget_show (label1); gtk_box_pack_start (GTK_BOX (hbox1), label1, FALSE, FALSE, 0); Shortcuts shortcuts_bible_name (0); shortcuts_bible_name.label (label1); shortcuts_bible_name.consider_assistant(); shortcuts_bible_name.process(); // Confirm or change Resource. vbox_resource_name = gtk_vbox_new (FALSE, 5); gtk_widget_show (vbox_resource_name); page_number_resource_name = gtk_assistant_append_page (GTK_ASSISTANT (assistant), vbox_resource_name); gtk_container_set_border_width (GTK_CONTAINER (vbox_resource_name), 10); gtk_assistant_set_page_title (GTK_ASSISTANT (assistant), vbox_resource_name, _("Is this the right Resource?")); gtk_assistant_set_page_type (GTK_ASSISTANT (assistant), vbox_resource_name, GTK_ASSISTANT_PAGE_CONTENT); gtk_assistant_set_page_complete (GTK_ASSISTANT (assistant), vbox_resource_name, true); label_resource_name = gtk_label_new (_("Resource name")); gtk_widget_show (label_resource_name); gtk_box_pack_start (GTK_BOX (vbox_resource_name), label_resource_name, FALSE, FALSE, 0); button_resource_name = gtk_button_new (); gtk_widget_show (button_resource_name); gtk_box_pack_start (GTK_BOX (vbox_resource_name), button_resource_name, FALSE, FALSE, 0); g_signal_connect ((gpointer) button_resource_name, "clicked", G_CALLBACK (on_button_resource_name_clicked), gpointer (this)); alignment1 = gtk_alignment_new (0.5, 0.5, 0, 0); gtk_widget_show (alignment1); gtk_container_add (GTK_CONTAINER (button_resource_name), alignment1); hbox1 = gtk_hbox_new (FALSE, 2); gtk_widget_show (hbox1); gtk_container_add (GTK_CONTAINER (alignment1), hbox1); image1 = gtk_image_new_from_stock ("gtk-open", GTK_ICON_SIZE_BUTTON); gtk_widget_show (image1); gtk_box_pack_start (GTK_BOX (hbox1), image1, FALSE, FALSE, 0); label1 = gtk_label_new_with_mnemonic (_("Choose another one")); gtk_widget_show (label1); gtk_box_pack_start (GTK_BOX (hbox1), label1, FALSE, FALSE, 0); Shortcuts shortcuts_resource_name (0); shortcuts_resource_name.label (label1); shortcuts_resource_name.consider_assistant(); shortcuts_resource_name.process(); // Select file where to save to. vbox_file = gtk_vbox_new (FALSE, 0); gtk_widget_show (vbox_file); page_number_file = gtk_assistant_append_page (GTK_ASSISTANT (assistant), vbox_file); gtk_container_set_border_width (GTK_CONTAINER (vbox_file), 10); gtk_assistant_set_page_title (GTK_ASSISTANT (assistant), vbox_file, _("Where would you like to save it?")); gtk_assistant_set_page_type (GTK_ASSISTANT (assistant), vbox_file, GTK_ASSISTANT_PAGE_CONTENT); gtk_assistant_set_page_complete (GTK_ASSISTANT (assistant), vbox_file, false); button_file = gtk_button_new (); gtk_widget_show (button_file); gtk_box_pack_start (GTK_BOX (vbox_file), button_file, FALSE, FALSE, 0); GtkWidget *alignment2; GtkWidget *hbox2; GtkWidget *image2; alignment2 = gtk_alignment_new (0.5, 0.5, 0, 0); gtk_widget_show (alignment2); gtk_container_add (GTK_CONTAINER (button_file), alignment2); hbox2 = gtk_hbox_new (FALSE, 2); gtk_widget_show (hbox2); gtk_container_add (GTK_CONTAINER (alignment2), hbox2); image2 = gtk_image_new_from_stock ("gtk-open", GTK_ICON_SIZE_BUTTON); gtk_widget_show (image2); gtk_box_pack_start (GTK_BOX (hbox2), image2, FALSE, FALSE, 0); label_file = gtk_label_new_with_mnemonic (""); gtk_widget_show (label_file); gtk_box_pack_start (GTK_BOX (hbox2), label_file, FALSE, FALSE, 0); g_signal_connect ((gpointer) button_file, "clicked", G_CALLBACK (on_button_file_clicked), gpointer(this)); // Build the confirmation stuff. label_confirm = gtk_label_new (_("Backup is about to be made")); gtk_widget_show (label_confirm); page_number_confirm = gtk_assistant_append_page (GTK_ASSISTANT (assistant), label_confirm); gtk_assistant_set_page_title (GTK_ASSISTANT (assistant), label_confirm, _("Backup is about to be made")); gtk_assistant_set_page_type (GTK_ASSISTANT (assistant), label_confirm, GTK_ASSISTANT_PAGE_CONFIRM); gtk_assistant_set_page_complete (GTK_ASSISTANT (assistant), label_confirm, true); label_progress = gtk_label_new (""); gtk_widget_show (label_progress); gtk_assistant_append_page (GTK_ASSISTANT (assistant), label_progress); gtk_assistant_set_page_title (GTK_ASSISTANT (assistant), label_progress, ""); gtk_assistant_set_page_type (GTK_ASSISTANT (assistant), label_progress, GTK_ASSISTANT_PAGE_PROGRESS); gtk_assistant_set_page_complete (GTK_ASSISTANT (assistant), label_progress, true); label_summary = gtk_label_new (_("Backup is done")); gtk_widget_show (label_summary); summary_page_number = gtk_assistant_append_page (GTK_ASSISTANT (assistant), label_summary); gtk_assistant_set_page_title (GTK_ASSISTANT (assistant), label_summary, _("The backup was completed successfully.")); gtk_assistant_set_page_type (GTK_ASSISTANT (assistant), label_summary, GTK_ASSISTANT_PAGE_SUMMARY); gtk_assistant_set_page_complete (GTK_ASSISTANT (assistant), label_summary, true); // Finish building assistant. gtk_widget_show_all (assistant); gtk_assistant_set_current_page (GTK_ASSISTANT (assistant), 0); }
/* Program extracts from Chapter 3 of
ImportAssistant::ImportAssistant(WindowReferences * references_window, WindowStyles * styles_window, WindowCheckKeyterms * check_keyterms_window, WindowsOutpost * windows_outpost) : AssistantBase(_("Import"), _("import")) // Import assistant. { gtk_assistant_set_forward_page_func (GTK_ASSISTANT (assistant), GtkAssistantPageFunc (assistant_forward_function), gpointer(this), NULL); g_signal_connect (G_OBJECT (assistant), "apply", G_CALLBACK (on_assistant_apply_signal), gpointer(this)); g_signal_connect (G_OBJECT (assistant), "prepare", G_CALLBACK (on_assistant_prepare_signal), gpointer(this)); introduction (_("This helps you importing data")); // Configuration and initialization. extern Settings *settings; ustring project = settings->genconfig.project_get(); my_references_window = references_window; my_styles_window = styles_window; my_check_keyterms_window = check_keyterms_window; my_windows_outpost = windows_outpost; import_notes = false; import_keyterms = false; // Build the GUI for the task selector. vbox_select_type = gtk_vbox_new (FALSE, 0); gtk_widget_show (vbox_select_type); page_number_select_type = gtk_assistant_append_page (GTK_ASSISTANT (assistant), vbox_select_type); gtk_container_set_border_width (GTK_CONTAINER (vbox_select_type), 10); gtk_assistant_set_page_title (GTK_ASSISTANT (assistant), vbox_select_type, _("What would you like to import?")); gtk_assistant_set_page_type (GTK_ASSISTANT (assistant), vbox_select_type, GTK_ASSISTANT_PAGE_CONTENT); gtk_assistant_set_page_complete (GTK_ASSISTANT (assistant), vbox_select_type, true); GSList *radiobutton_select_type_group = NULL; radiobutton_select_type_bible = gtk_radio_button_new_with_mnemonic (NULL, _("Bible")); gtk_widget_show (radiobutton_select_type_bible); gtk_box_pack_start (GTK_BOX (vbox_select_type), radiobutton_select_type_bible, FALSE, FALSE, 0); gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_select_type_bible), radiobutton_select_type_group); radiobutton_select_type_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_select_type_bible)); radiobutton_select_type_references = gtk_radio_button_new_with_mnemonic (NULL, _("References")); gtk_widget_show (radiobutton_select_type_references); gtk_box_pack_start (GTK_BOX (vbox_select_type), radiobutton_select_type_references, FALSE, FALSE, 0); gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_select_type_references), radiobutton_select_type_group); radiobutton_select_type_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_select_type_references)); // Importing references only works when the references window shows. gtk_widget_set_sensitive (radiobutton_select_type_references, references_window != NULL); radiobutton_select_type_stylesheet = gtk_radio_button_new_with_mnemonic (NULL, _("Stylesheet")); gtk_widget_show (radiobutton_select_type_stylesheet); gtk_box_pack_start (GTK_BOX (vbox_select_type), radiobutton_select_type_stylesheet, FALSE, FALSE, 0); gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_select_type_stylesheet), radiobutton_select_type_group); radiobutton_select_type_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_select_type_stylesheet)); // Importing styles only works when the styles window shows. gtk_widget_set_sensitive (radiobutton_select_type_stylesheet, my_styles_window != NULL); radiobutton_select_type_notes = gtk_radio_button_new_with_mnemonic (NULL, _("Notes")); gtk_widget_show (radiobutton_select_type_notes); gtk_box_pack_start (GTK_BOX (vbox_select_type), radiobutton_select_type_notes, FALSE, FALSE, 0); gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_select_type_notes), radiobutton_select_type_group); radiobutton_select_type_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_select_type_notes)); radiobutton_select_type_keyterms = gtk_radio_button_new_with_mnemonic (NULL, _("Keyterms")); gtk_widget_show (radiobutton_select_type_keyterms); gtk_box_pack_start (GTK_BOX (vbox_select_type), radiobutton_select_type_keyterms, FALSE, FALSE, 0); gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_select_type_keyterms), radiobutton_select_type_group); radiobutton_select_type_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_select_type_keyterms)); // Importing keyterms only works when the check keyterms window shows. gtk_widget_set_sensitive (radiobutton_select_type_keyterms, my_check_keyterms_window != NULL); Shortcuts shortcuts_select_type (0); shortcuts_select_type.button (radiobutton_select_type_bible); shortcuts_select_type.button (radiobutton_select_type_references); shortcuts_select_type.button (radiobutton_select_type_stylesheet); shortcuts_select_type.button (radiobutton_select_type_notes); shortcuts_select_type.button (radiobutton_select_type_keyterms); shortcuts_select_type.consider_assistant(); shortcuts_select_type.process(); // Confirm or change Bible to import into. vbox_bible_name = gtk_vbox_new (FALSE, 5); gtk_widget_show (vbox_bible_name); page_number_bible_name = gtk_assistant_append_page (GTK_ASSISTANT (assistant), vbox_bible_name); gtk_container_set_border_width (GTK_CONTAINER (vbox_bible_name), 10); gtk_assistant_set_page_title (GTK_ASSISTANT (assistant), vbox_bible_name, _("Is this the right Bible to import into?")); gtk_assistant_set_page_type (GTK_ASSISTANT (assistant), vbox_bible_name, GTK_ASSISTANT_PAGE_CONTENT); gtk_assistant_set_page_complete (GTK_ASSISTANT (assistant), vbox_bible_name, true); label_project_name = gtk_label_new (_("Bible name")); gtk_widget_show (label_project_name); gtk_box_pack_start (GTK_BOX (vbox_bible_name), label_project_name, FALSE, FALSE, 0); button_bible_name = gtk_button_new (); gtk_widget_show (button_bible_name); gtk_box_pack_start (GTK_BOX (vbox_bible_name), button_bible_name, FALSE, FALSE, 0); g_signal_connect ((gpointer) button_bible_name, "clicked", G_CALLBACK (on_button_bible_name_clicked), gpointer (this)); GtkWidget *alignment1; GtkWidget *hbox1; GtkWidget *image1; GtkWidget *label12; alignment1 = gtk_alignment_new (0.5, 0.5, 0, 0); gtk_widget_show (alignment1); gtk_container_add (GTK_CONTAINER (button_bible_name), alignment1); hbox1 = gtk_hbox_new (FALSE, 2); gtk_widget_show (hbox1); gtk_container_add (GTK_CONTAINER (alignment1), hbox1); image1 = gtk_image_new_from_stock ("gtk-open", GTK_ICON_SIZE_BUTTON); gtk_widget_show (image1); gtk_box_pack_start (GTK_BOX (hbox1), image1, FALSE, FALSE, 0); label12 = gtk_label_new_with_mnemonic (_("Choose another one")); gtk_widget_show (label12); gtk_box_pack_start (GTK_BOX (hbox1), label12, FALSE, FALSE, 0); Shortcuts shortcuts_bible_name (0); shortcuts_bible_name.label (label12); shortcuts_bible_name.consider_assistant(); shortcuts_bible_name.process(); // Select what type of Bible data to import. vbox_bible_type = gtk_vbox_new (FALSE, 0); gtk_widget_show (vbox_bible_type); page_number_bible_type = gtk_assistant_append_page (GTK_ASSISTANT (assistant), vbox_bible_type); gtk_container_set_border_width (GTK_CONTAINER (vbox_bible_type), 10); gtk_assistant_set_page_title (GTK_ASSISTANT (assistant), vbox_bible_type, _("What type of data would you like to import?")); gtk_assistant_set_page_type (GTK_ASSISTANT (assistant), vbox_bible_type, GTK_ASSISTANT_PAGE_CONTENT); gtk_assistant_set_page_complete (GTK_ASSISTANT (assistant), vbox_bible_type, true); GSList *radiobutton_bible_type_group = NULL; radiobutton_bible_usfm = gtk_radio_button_new_with_mnemonic (NULL, _("Unified Standard Format Markers (USFM)")); gtk_widget_show (radiobutton_bible_usfm); gtk_box_pack_start (GTK_BOX (vbox_bible_type), radiobutton_bible_usfm, FALSE, FALSE, 0); gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_bible_usfm), radiobutton_bible_type_group); radiobutton_bible_type_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_bible_usfm)); radiobutton_bible_bibleworks = gtk_radio_button_new_with_mnemonic (NULL, _("BibleWorks Exported Database")); gtk_widget_show (radiobutton_bible_bibleworks); gtk_box_pack_start (GTK_BOX (vbox_bible_type), radiobutton_bible_bibleworks, FALSE, FALSE, 0); gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_bible_bibleworks), radiobutton_bible_type_group); radiobutton_bible_type_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_bible_bibleworks)); radiobutton_bible_online_bible = gtk_radio_button_new_with_mnemonic (NULL, _("Online Bible Text")); gtk_widget_show (radiobutton_bible_online_bible); gtk_box_pack_start (GTK_BOX (vbox_bible_type), radiobutton_bible_online_bible, FALSE, FALSE, 0); gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_bible_online_bible), radiobutton_bible_type_group); radiobutton_bible_type_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_bible_online_bible)); radiobutton_bible_raw_text = gtk_radio_button_new_with_mnemonic (NULL, _("Raw Text")); gtk_widget_show (radiobutton_bible_raw_text); gtk_box_pack_start (GTK_BOX (vbox_bible_type), radiobutton_bible_raw_text, FALSE, FALSE, 0); gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_bible_raw_text), radiobutton_bible_type_group); radiobutton_bible_type_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_bible_raw_text)); Shortcuts shortcuts_select_bible_type (0); shortcuts_select_bible_type.button (radiobutton_bible_usfm); shortcuts_select_bible_type.button (radiobutton_bible_bibleworks); shortcuts_select_bible_type.button (radiobutton_bible_online_bible); shortcuts_select_bible_type.button (radiobutton_bible_raw_text); shortcuts_select_bible_type.consider_assistant(); shortcuts_select_bible_type.process(); // Online Bible connection? label_online_bible_running = gtk_label_new (""); gtk_widget_show (label_online_bible_running); page_number_online_bible_running = gtk_assistant_append_page (GTK_ASSISTANT (assistant), label_online_bible_running); gtk_assistant_set_page_title (GTK_ASSISTANT (assistant), label_online_bible_running, _("Connected to the Online Bible?")); gtk_assistant_set_page_type (GTK_ASSISTANT (assistant), label_online_bible_running, GTK_ASSISTANT_PAGE_CONTENT); gtk_assistant_set_page_complete (GTK_ASSISTANT (assistant), label_online_bible_running, false); // In case there's no data in the project, the Online Bible won't get connected. // Therefore connect manually. if (online_bible_is_running ()) { my_windows_outpost->OnlineBibleReferenceGet (); } // Online Bible to import. vbox_online_bible_bible = gtk_vbox_new (FALSE, 0); gtk_widget_show (vbox_online_bible_bible); page_number_online_bible_bible = gtk_assistant_append_page (GTK_ASSISTANT (assistant), vbox_online_bible_bible); gtk_assistant_set_page_title (GTK_ASSISTANT (assistant), vbox_online_bible_bible, _("Which Bible would you like to import?")); gtk_assistant_set_page_type (GTK_ASSISTANT (assistant), vbox_online_bible_bible, GTK_ASSISTANT_PAGE_CONTENT); gtk_assistant_set_page_complete (GTK_ASSISTANT (assistant), vbox_online_bible_bible, false); combobox_online_bible_bible = gtk_combo_box_new_text (); gtk_widget_show (combobox_online_bible_bible); gtk_box_pack_start (GTK_BOX (vbox_online_bible_bible), combobox_online_bible_bible, false, false, 0); g_signal_connect ((gpointer) combobox_online_bible_bible, "changed", G_CALLBACK (on_combobox_online_bible_bible_changed), gpointer (this)); // Select files to import from. vbox_files = gtk_vbox_new (FALSE, 0); gtk_widget_show (vbox_files); page_number_files = gtk_assistant_append_page (GTK_ASSISTANT (assistant), vbox_files); gtk_container_set_border_width (GTK_CONTAINER (vbox_files), 10); gtk_assistant_set_page_title (GTK_ASSISTANT (assistant), vbox_files, _("Which file or files would you like to import?")); gtk_assistant_set_page_type (GTK_ASSISTANT (assistant), vbox_files, GTK_ASSISTANT_PAGE_CONTENT); gtk_assistant_set_page_complete (GTK_ASSISTANT (assistant), vbox_files, false); button_files = gtk_button_new (); gtk_widget_show (button_files); gtk_box_pack_start (GTK_BOX (vbox_files), button_files, FALSE, FALSE, 0); GtkWidget * alignment2 = gtk_alignment_new (0.5, 0.5, 0, 0); gtk_widget_show (alignment2); gtk_container_add (GTK_CONTAINER (button_files), alignment2); GtkWidget * hbox2 = gtk_hbox_new (FALSE, 2); gtk_widget_show (hbox2); gtk_container_add (GTK_CONTAINER (alignment2), hbox2); GtkWidget * image2 = gtk_image_new_from_stock ("gtk-open", GTK_ICON_SIZE_BUTTON); gtk_widget_show (image2); gtk_box_pack_start (GTK_BOX (hbox2), image2, FALSE, FALSE, 0); GtkWidget * label = gtk_label_new_with_mnemonic (_("Select files")); gtk_widget_show (label); gtk_box_pack_start (GTK_BOX (hbox2), label, FALSE, FALSE, 0); g_signal_connect ((gpointer) button_files, "clicked", G_CALLBACK (on_button_files_clicked), gpointer(this)); label_files = gtk_label_new (""); gtk_widget_show (label_files); gtk_box_pack_start (GTK_BOX (vbox_files), label_files, FALSE, FALSE, 0); // Build the confirmation stuff. label_confirm = gtk_label_new (_("Import about to be done")); gtk_widget_show (label_confirm); page_number_confirm = gtk_assistant_append_page (GTK_ASSISTANT (assistant), label_confirm); gtk_assistant_set_page_title (GTK_ASSISTANT (assistant), label_confirm, _("The import is about to be done")); gtk_assistant_set_page_type (GTK_ASSISTANT (assistant), label_confirm, GTK_ASSISTANT_PAGE_CONFIRM); gtk_assistant_set_page_complete (GTK_ASSISTANT (assistant), label_confirm, true); label_progress = gtk_label_new (""); gtk_widget_show (label_progress); gtk_assistant_append_page (GTK_ASSISTANT (assistant), label_progress); gtk_assistant_set_page_title (GTK_ASSISTANT (assistant), label_progress, ""); gtk_assistant_set_page_type (GTK_ASSISTANT (assistant), label_progress, GTK_ASSISTANT_PAGE_PROGRESS); gtk_assistant_set_page_complete (GTK_ASSISTANT (assistant), label_progress, true); label_summary = gtk_label_new (_("Import done")); gtk_widget_show (label_summary); summary_page_number = gtk_assistant_append_page (GTK_ASSISTANT (assistant), label_summary); gtk_assistant_set_page_title (GTK_ASSISTANT (assistant), label_summary, _("Ready")); gtk_assistant_set_page_type (GTK_ASSISTANT (assistant), label_summary, GTK_ASSISTANT_PAGE_SUMMARY); gtk_assistant_set_page_complete (GTK_ASSISTANT (assistant), label_summary, true); // Finish building assistant. gtk_widget_show_all (assistant); gtk_assistant_set_current_page (GTK_ASSISTANT (assistant), 0); }
/* Program extracts from Chapter 13 of
int main() { //CHARACTER const char roleName1[10] = { 'W','a','r','r','i','o','r' }; const char roleName2[10] = { 'M','a','g','e' }; const char roleName3[10] = { 'A','r','c','h','e','r' }; double playerHealth; double playerAttack; double playerMaxHealth; //CHARACTER STATS double playerMinPhysicalResistance; double playerMaxPhysicalResistance; double playerCritChance; double playerMinCritDamage; double playerMaxCritDamage; //BOSS STATS char bossName[10] = { 'S', 'i', 'l', 'v', 'a' }; double bossHealth; double bossAttack; double bossMinPhysicalResistance; double bossMaxPhysicalResistance; double bossCritChance; double bossMinCritDamage; double bossMaxCritDamage; //FUNCTION int renderOpCode = -1; double *renderArgument1 = NULL; double *renderArgument2 = NULL; renderArgument1 = malloc(sizeof(double)); renderArgument2 = malloc(sizeof(double)); introduction(); createPlayerCharacter(getUserInput(3), &playerHealth, &playerMaxHealth, &playerAttack, &playerMinPhysicalResistance, &playerMaxPhysicalResistance, &playerCritChance, &playerMinCritDamage, &playerMaxCritDamage); createBoss( &bossHealth, &bossAttack, &bossMaxPhysicalResistance, &bossMinPhysicalResistance, &bossMaxCritDamage, &bossMinCritDamage, &bossCritChance); while (1 == 1) { while (bossHealth >= 0) { int temp = playerMove(); if (temp == 1) { double amount = calculateDamageAmount( bossMinPhysicalResistance, bossMaxPhysicalResistance, playerMinCritDamage, playerMaxCritDamage, playerCritChance, playerAttack); printf("Player dealt %d to Boss.\n", (int)amount); bossHealth -= amount; printf("Boss heal is %d.\n", (int)bossHealth); } if (temp == 2) { double amount = calculateHealAmount(playerMinPhysicalResistance, playerMaxPhysicalResistance, playerMinCritDamage, playerMaxCritDamage, playerCritChance, playerAttack); printf("Player heal %d to self HP.\n", (int)amount); playerHealth += amount; printf("Player heal is %d.\n", (int)playerHealth); } double amount = calculateDamageAmount(playerMinPhysicalResistance, playerMaxPhysicalResistance, bossMinCritDamage, bossMaxCritDamage, bossCritChance, bossAttack); printf("<----------------------------------------------------------------------------->\n"); printf("Boss dealt %d to Player.\n", (int)amount); playerHealth -= amount; printf("Player heal is %d.\n", (int)playerHealth); printf("<----------------------------------------------------------------------------->\n"); } } return 0; };
RestoreAssistant::RestoreAssistant(GtkWindow *transient_parent) : AssistantBase(_("Restore"), _("restore"), transient_parent) // Restore assistant. { gtk_assistant_set_forward_page_func (GTK_ASSISTANT (assistant), GtkAssistantPageFunc (assistant_forward_function), gpointer(this), NULL); g_signal_connect (G_OBJECT (assistant), "apply", G_CALLBACK (on_assistant_apply_signal), gpointer(this)); g_signal_connect (G_OBJECT (assistant), "prepare", G_CALLBACK (on_assistant_prepare_signal), gpointer(this)); introduction (_("This assists you with restoring a backup")); // Configuration and initialization. extern Settings *settings; ustring project = settings->genconfig.project_get(); // Build the GUI for the task selector. vbox_select_type = gtk_vbox_new (FALSE, 0); gtk_widget_show (vbox_select_type); page_number_select_type = gtk_assistant_append_page (GTK_ASSISTANT (assistant), vbox_select_type); gtk_container_set_border_width (GTK_CONTAINER (vbox_select_type), 10); gtk_assistant_set_page_title (GTK_ASSISTANT (assistant), vbox_select_type, _("What would you like to restore?")); gtk_assistant_set_page_type (GTK_ASSISTANT (assistant), vbox_select_type, GTK_ASSISTANT_PAGE_CONTENT); gtk_assistant_set_page_complete (GTK_ASSISTANT (assistant), vbox_select_type, true); GSList *radiobutton_select_type_group = NULL; radiobutton_select_type_bible = gtk_radio_button_new_with_mnemonic (NULL, _("Bible")); gtk_widget_show (radiobutton_select_type_bible); gtk_box_pack_start (GTK_BOX (vbox_select_type), radiobutton_select_type_bible, FALSE, FALSE, 0); gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_select_type_bible), radiobutton_select_type_group); radiobutton_select_type_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_select_type_bible)); radiobutton_select_type_notes = gtk_radio_button_new_with_mnemonic (NULL, _("Notes")); gtk_widget_show (radiobutton_select_type_notes); gtk_box_pack_start (GTK_BOX (vbox_select_type), radiobutton_select_type_notes, FALSE, FALSE, 0); gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_select_type_notes), radiobutton_select_type_group); radiobutton_select_type_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_select_type_notes)); radiobutton_select_type_resource = gtk_radio_button_new_with_mnemonic (NULL, _("Resource")); gtk_widget_show (radiobutton_select_type_resource); gtk_box_pack_start (GTK_BOX (vbox_select_type), radiobutton_select_type_resource, FALSE, FALSE, 0); gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_select_type_resource), radiobutton_select_type_group); radiobutton_select_type_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_select_type_resource)); radiobutton_select_type_everything = gtk_radio_button_new_with_mnemonic (NULL, _("Everything")); gtk_widget_show (radiobutton_select_type_everything); gtk_box_pack_start (GTK_BOX (vbox_select_type), radiobutton_select_type_everything, FALSE, FALSE, 0); gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_select_type_everything), radiobutton_select_type_group); radiobutton_select_type_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_select_type_everything)); Shortcuts shortcuts_select_type (0); shortcuts_select_type.button (radiobutton_select_type_bible); shortcuts_select_type.button (radiobutton_select_type_notes); shortcuts_select_type.button (radiobutton_select_type_resource); shortcuts_select_type.button (radiobutton_select_type_everything); shortcuts_select_type.consider_assistant(); shortcuts_select_type.process(); // Confirm or change Bible. vbox_bible_name = gtk_vbox_new (FALSE, 5); gtk_widget_show (vbox_bible_name); page_number_bible_name = gtk_assistant_append_page (GTK_ASSISTANT (assistant), vbox_bible_name); gtk_container_set_border_width (GTK_CONTAINER (vbox_bible_name), 10); gtk_assistant_set_page_title (GTK_ASSISTANT (assistant), vbox_bible_name, _("What will be the name of the Bible?")); gtk_assistant_set_page_type (GTK_ASSISTANT (assistant), vbox_bible_name, GTK_ASSISTANT_PAGE_CONTENT); gtk_assistant_set_page_complete (GTK_ASSISTANT (assistant), vbox_bible_name, true); entry_bible_name = gtk_entry_new (); gtk_widget_show (entry_bible_name); gtk_box_pack_start (GTK_BOX (vbox_bible_name), entry_bible_name, FALSE, FALSE, 0); label_bible_name = gtk_label_new (""); gtk_widget_show (label_bible_name); gtk_box_pack_start (GTK_BOX (vbox_bible_name), label_bible_name, FALSE, FALSE, 0); g_signal_connect_after ((gpointer) entry_bible_name, "changed", G_CALLBACK (on_entry_bible_name_changed), gpointer (this)); // Select file. vbox_file = gtk_vbox_new (FALSE, 0); gtk_widget_show (vbox_file); page_number_file = gtk_assistant_append_page (GTK_ASSISTANT (assistant), vbox_file); gtk_container_set_border_width (GTK_CONTAINER (vbox_file), 10); gtk_assistant_set_page_title (GTK_ASSISTANT (assistant), vbox_file, _("What is the file to restore?")); gtk_assistant_set_page_type (GTK_ASSISTANT (assistant), vbox_file, GTK_ASSISTANT_PAGE_CONTENT); gtk_assistant_set_page_complete (GTK_ASSISTANT (assistant), vbox_file, false); button_file = gtk_button_new (); gtk_widget_show (button_file); gtk_box_pack_start (GTK_BOX (vbox_file), button_file, FALSE, FALSE, 0); GtkWidget *alignment2; GtkWidget *hbox2; GtkWidget *image2; alignment2 = gtk_alignment_new (0.5, 0.5, 0, 0); gtk_widget_show (alignment2); gtk_container_add (GTK_CONTAINER (button_file), alignment2); hbox2 = gtk_hbox_new (FALSE, 2); gtk_widget_show (hbox2); gtk_container_add (GTK_CONTAINER (alignment2), hbox2); image2 = gtk_image_new_from_stock ("gtk-open", GTK_ICON_SIZE_BUTTON); gtk_widget_show (image2); gtk_box_pack_start (GTK_BOX (hbox2), image2, FALSE, FALSE, 0); label_file = gtk_label_new_with_mnemonic (""); gtk_widget_show (label_file); gtk_box_pack_start (GTK_BOX (hbox2), label_file, FALSE, FALSE, 0); g_signal_connect ((gpointer) button_file, "clicked", G_CALLBACK (on_button_file_clicked), gpointer(this)); // Build the confirmation stuff. label_confirm = gtk_label_new (_("Restore is about to be done")); gtk_widget_show (label_confirm); page_number_confirm = gtk_assistant_append_page (GTK_ASSISTANT (assistant), label_confirm); gtk_assistant_set_page_title (GTK_ASSISTANT (assistant), label_confirm, _("Restore is about to be done")); gtk_assistant_set_page_type (GTK_ASSISTANT (assistant), label_confirm, GTK_ASSISTANT_PAGE_CONFIRM); gtk_assistant_set_page_complete (GTK_ASSISTANT (assistant), label_confirm, true); label_progress = gtk_label_new (_("Restore is in progress")); gtk_widget_show (label_progress); page_number_progress = gtk_assistant_append_page (GTK_ASSISTANT (assistant), label_progress); gtk_assistant_set_page_title (GTK_ASSISTANT (assistant), label_progress, ""); gtk_assistant_set_page_type (GTK_ASSISTANT (assistant), label_progress, GTK_ASSISTANT_PAGE_PROGRESS); gtk_assistant_set_page_complete (GTK_ASSISTANT (assistant), label_progress, true); label_summary = gtk_label_new (""); gtk_widget_show (label_summary); summary_page_number = gtk_assistant_append_page (GTK_ASSISTANT (assistant), label_summary); gtk_assistant_set_page_title (GTK_ASSISTANT (assistant), label_summary, _("Ready")); gtk_assistant_set_page_type (GTK_ASSISTANT (assistant), label_summary, GTK_ASSISTANT_PAGE_SUMMARY); gtk_assistant_set_page_complete (GTK_ASSISTANT (assistant), label_summary, true); // Finish building assistant. gtk_widget_show_all (assistant); gtk_assistant_set_current_page (GTK_ASSISTANT (assistant), 0); }
RemoteRepositoryAssistant::RemoteRepositoryAssistant(int dummy) : AssistantBase(_("Remote repository setup"), _("menu-preferences/dialog-remote-repository")) // Assistant for managing the remote repository. { // Configuration and initialization. extern Settings *settings; bible = settings->genconfig.project_get(); event_id_entry_repository = 0; persistent_clone_directory = git_testing_directory (_("clone")); write_access_granted = false; ignore_entry_repository_changed = false; gtk_assistant_set_forward_page_func (GTK_ASSISTANT (assistant), GtkAssistantPageFunc (assistant_forward_function), gpointer(this), NULL); g_signal_connect (G_OBJECT (assistant), "apply", G_CALLBACK (on_assistant_apply_signal), gpointer(this)); g_signal_connect (G_OBJECT (assistant), "prepare", G_CALLBACK (on_assistant_prepare_signal), gpointer(this)); introduction (_("Remote repository management for Bible ") + bible + _(" or the project notes")); // Build the GUI for the Bible or notes selector. vbox_bible_notes_selector = gtk_vbox_new (FALSE, 0); gtk_widget_show (vbox_bible_notes_selector); page_number_bible_notes_selector = gtk_assistant_append_page (GTK_ASSISTANT (assistant), vbox_bible_notes_selector); GSList *radiobutton_bible_notes_selector_group = NULL; radiobutton_bible_notes_selector_bible = gtk_radio_button_new_with_mnemonic (NULL, _("B_ible repository")); gtk_widget_show (radiobutton_bible_notes_selector_bible); gtk_box_pack_start (GTK_BOX (vbox_bible_notes_selector), radiobutton_bible_notes_selector_bible, FALSE, FALSE, 0); gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_bible_notes_selector_bible), radiobutton_bible_notes_selector_group); radiobutton_bible_notes_selector_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_bible_notes_selector_bible)); radiobutton_bible_notes_selector_notes = gtk_radio_button_new_with_mnemonic (NULL, _("Project _notes repository")); gtk_widget_show (radiobutton_bible_notes_selector_notes); gtk_box_pack_start (GTK_BOX (vbox_bible_notes_selector), radiobutton_bible_notes_selector_notes, FALSE, FALSE, 0); gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_bible_notes_selector_notes), radiobutton_bible_notes_selector_group); radiobutton_bible_notes_selector_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_bible_notes_selector_notes)); gtk_assistant_set_page_title (GTK_ASSISTANT (assistant), vbox_bible_notes_selector, _("What type of repository would you like to set?")); gtk_assistant_set_page_type (GTK_ASSISTANT (assistant), vbox_bible_notes_selector, GTK_ASSISTANT_PAGE_CONTENT); gtk_assistant_set_page_complete (GTK_ASSISTANT (assistant), vbox_bible_notes_selector, true); // Build the GUI for the setting whether to use a remote repository. checkbutton_use_repository = gtk_check_button_new_with_mnemonic (_("_Use remote repository")); gtk_widget_show (checkbutton_use_repository); page_number_use_repository = gtk_assistant_append_page (GTK_ASSISTANT (assistant), checkbutton_use_repository); gtk_assistant_set_page_title (GTK_ASSISTANT (assistant), checkbutton_use_repository, _("Would you like to use a remote repository?")); gtk_assistant_set_page_type (GTK_ASSISTANT (assistant), checkbutton_use_repository, GTK_ASSISTANT_PAGE_CONTENT); gtk_assistant_set_page_complete (GTK_ASSISTANT (assistant), checkbutton_use_repository, true); // System for trying out git. git_tried_and_okay = false; label_try_git = gtk_label_new (_("The local content tracker has been tested and works fine")); gtk_widget_show (label_try_git); page_number_try_git = gtk_assistant_append_page (GTK_ASSISTANT (assistant), label_try_git); gtk_assistant_set_page_title (GTK_ASSISTANT (assistant), label_try_git, _("Trying out the content tracker")); gtk_assistant_set_page_type (GTK_ASSISTANT (assistant), label_try_git, GTK_ASSISTANT_PAGE_CONTENT); gtk_assistant_set_page_complete (GTK_ASSISTANT (assistant), label_try_git, false); // Build GUI for the repository URL. vbox_repository = gtk_vbox_new (FALSE, 0); gtk_widget_show (vbox_repository); page_number_repository = gtk_assistant_append_page (GTK_ASSISTANT (assistant), vbox_repository); hbox_repository = gtk_hbox_new (FALSE, 3); gtk_widget_show (hbox_repository); gtk_box_pack_start (GTK_BOX (vbox_repository), hbox_repository, TRUE, TRUE, 0); label_repository = gtk_label_new_with_mnemonic (_("_Repository")); gtk_widget_show (label_repository); gtk_box_pack_start (GTK_BOX (hbox_repository), label_repository, FALSE, FALSE, 0); entry_repository = gtk_entry_new (); gtk_widget_show (entry_repository); gtk_box_pack_start (GTK_BOX (hbox_repository), entry_repository, TRUE, TRUE, 0); gtk_entry_set_invisible_char (GTK_ENTRY (entry_repository), 9679); label_repository_accessible = gtk_label_new (""); gtk_widget_show (label_repository_accessible); gtk_box_pack_start (GTK_BOX (vbox_repository), label_repository_accessible, FALSE, FALSE, 0); gtk_misc_set_alignment (GTK_MISC (label_repository_accessible), 0, 0.5); gtk_label_set_mnemonic_widget (GTK_LABEL (label_repository), entry_repository); gtk_assistant_set_page_title (GTK_ASSISTANT (assistant), vbox_repository, _("Enter the location of the remote repository")); gtk_assistant_set_page_type (GTK_ASSISTANT (assistant), vbox_repository, GTK_ASSISTANT_PAGE_CONTENT); gtk_assistant_set_page_complete (GTK_ASSISTANT (assistant), vbox_repository, false); g_signal_connect ((gpointer) entry_repository, "changed", G_CALLBACK (on_entry_repository_changed), gpointer (this)); // GUI for cloning the repository. vbox_clone = gtk_vbox_new (FALSE, 0); gtk_widget_show (vbox_clone); page_number_clone = gtk_assistant_append_page (GTK_ASSISTANT (assistant), vbox_clone); label_clone = gtk_label_new (""); gtk_widget_show (label_clone); gtk_box_pack_start (GTK_BOX (vbox_clone), label_clone, FALSE, FALSE, 0); gtk_misc_set_alignment (GTK_MISC (label_clone), 0, 0.5); button_clone = gtk_button_new (); gtk_widget_show (button_clone); gtk_box_pack_start (GTK_BOX (vbox_clone), button_clone, FALSE, FALSE, 0); GtkWidget *alignment1; GtkWidget *hbox1; GtkWidget *image1; GtkWidget *label1; alignment1 = gtk_alignment_new (0.5, 0.5, 0, 0); gtk_widget_show (alignment1); gtk_container_add (GTK_CONTAINER (button_clone), alignment1); hbox1 = gtk_hbox_new (FALSE, 2); gtk_widget_show (hbox1); gtk_container_add (GTK_CONTAINER (alignment1), hbox1); image1 = gtk_image_new_from_stock ("gtk-copy", GTK_ICON_SIZE_BUTTON); gtk_widget_show (image1); gtk_box_pack_start (GTK_BOX (hbox1), image1, FALSE, FALSE, 0); label1 = gtk_label_new_with_mnemonic (_("C_lone the remote repository")); gtk_widget_show (label1); gtk_box_pack_start (GTK_BOX (hbox1), label1, FALSE, FALSE, 0); gtk_assistant_set_page_title (GTK_ASSISTANT (assistant), vbox_clone, _("Cloning data")); gtk_assistant_set_page_type (GTK_ASSISTANT (assistant), vbox_clone, GTK_ASSISTANT_PAGE_CONTENT); gtk_assistant_set_page_complete (GTK_ASSISTANT (assistant), vbox_clone, false); g_signal_connect ((gpointer) button_clone, "clicked", G_CALLBACK (on_button_clone_clicked), gpointer (this)); // Write tester. label_write_test = gtk_label_new (""); gtk_widget_show (label_write_test); page_number_write_test = gtk_assistant_append_page (GTK_ASSISTANT (assistant), label_write_test); gtk_assistant_set_page_title (GTK_ASSISTANT (assistant), label_write_test, _("Remote repository write test")); gtk_assistant_set_page_type (GTK_ASSISTANT (assistant), label_write_test, GTK_ASSISTANT_PAGE_CONTENT); gtk_assistant_set_page_complete (GTK_ASSISTANT (assistant), label_write_test, false); // GUI for pushing our data into the remote repository. vbox_push = gtk_vbox_new (FALSE, 0); gtk_widget_show (vbox_push); page_number_push = gtk_assistant_append_page (GTK_ASSISTANT (assistant), vbox_push); label_push = gtk_label_new (""); gtk_widget_show (label_push); gtk_box_pack_start (GTK_BOX (vbox_push), label_push, FALSE, FALSE, 0); gtk_misc_set_alignment (GTK_MISC (label_push), 0, 0.5); button_push = gtk_button_new (); gtk_widget_show (button_push); gtk_box_pack_start (GTK_BOX (vbox_push), button_push, FALSE, FALSE, 0); alignment1 = gtk_alignment_new (0.5, 0.5, 0, 0); gtk_widget_show (alignment1); gtk_container_add (GTK_CONTAINER (button_push), alignment1); hbox1 = gtk_hbox_new (FALSE, 2); gtk_widget_show (hbox1); gtk_container_add (GTK_CONTAINER (alignment1), hbox1); image1 = gtk_image_new_from_stock ("gtk-copy", GTK_ICON_SIZE_BUTTON); gtk_widget_show (image1); gtk_box_pack_start (GTK_BOX (hbox1), image1, FALSE, FALSE, 0); label1 = gtk_label_new_with_mnemonic (_("_Push my data to the remote repository")); gtk_widget_show (label1); gtk_box_pack_start (GTK_BOX (hbox1), label1, FALSE, FALSE, 0); gtk_assistant_set_page_title (GTK_ASSISTANT (assistant), vbox_push, _("Would you like to push your data to the repository?")); gtk_assistant_set_page_type (GTK_ASSISTANT (assistant), vbox_push, GTK_ASSISTANT_PAGE_CONTENT); gtk_assistant_set_page_complete (GTK_ASSISTANT (assistant), vbox_push, true); g_signal_connect ((gpointer) button_push, "clicked", G_CALLBACK (on_button_push_clicked), gpointer (this)); // Build the confirmation stuff. label_confirm = gtk_label_new (_("Settings are ready to be applied")); gtk_widget_show (label_confirm); page_number_confirm = gtk_assistant_append_page (GTK_ASSISTANT (assistant), label_confirm); gtk_assistant_set_page_title (GTK_ASSISTANT (assistant), label_confirm, _("Settings are ready to be applied")); gtk_assistant_set_page_type (GTK_ASSISTANT (assistant), label_confirm, GTK_ASSISTANT_PAGE_CONFIRM); gtk_assistant_set_page_complete (GTK_ASSISTANT (assistant), label_confirm, true); label_progress = gtk_label_new (""); gtk_widget_show (label_progress); gtk_assistant_append_page (GTK_ASSISTANT (assistant), label_progress); gtk_assistant_set_page_title (GTK_ASSISTANT (assistant), label_progress, ""); gtk_assistant_set_page_type (GTK_ASSISTANT (assistant), label_progress, GTK_ASSISTANT_PAGE_PROGRESS); gtk_assistant_set_page_complete (GTK_ASSISTANT (assistant), label_progress, true); label_summary = gtk_label_new (_("Settings have been applied")); gtk_widget_show (label_summary); summary_page_number = gtk_assistant_append_page (GTK_ASSISTANT (assistant), label_summary); gtk_assistant_set_page_title (GTK_ASSISTANT (assistant), label_summary, _("Ready")); gtk_assistant_set_page_type (GTK_ASSISTANT (assistant), label_summary, GTK_ASSISTANT_PAGE_SUMMARY); gtk_assistant_set_page_complete (GTK_ASSISTANT (assistant), label_summary, true); // Finish building assistant. gtk_widget_show_all (assistant); gtk_assistant_set_current_page (GTK_ASSISTANT (assistant), 0); }
int main(int, char **) { introduction(); ReaderProviderPtr provider; ReaderUnitPtr readerUnit; ChipPtr chip; std::tie(provider, readerUnit, chip) = pcsc_test_init(); PRINT_TIME("CHip identifier: " << logicalaccess::BufferHelper::getHex(chip->getChipIdentifier())); LLA_ASSERT(chip->getCardType() == "DESFireEV1", "Chip is not an DESFireEV1, but is " + chip->getCardType() + " instead."); auto location_root_node = chip->getRootLocationNode(); auto cmd = std::dynamic_pointer_cast<logicalaccess::DESFireISO7816Commands>( chip->getCommands()); auto cmdev1 = std::dynamic_pointer_cast<logicalaccess::DESFireEV1ISO7816Commands>( chip->getCommands()); LLA_ASSERT(cmd && cmdev1, "Cannot get correct command object from chip."); cmd->selectApplication(0x00); cmd->authenticate(0); cmd->erase(); cmdev1->createApplication(0x521, logicalaccess::DESFireKeySettings::KS_DEFAULT, 3, logicalaccess::DESFireKeyType::DF_KEY_AES, logicalaccess::FIDS_NO_ISO_FID, 0, std::vector<unsigned char>()); cmd->selectApplication(0x521); std::shared_ptr<logicalaccess::DESFireKey> key(new logicalaccess::DESFireKey()); key->setKeyType(logicalaccess::DESFireKeyType::DF_KEY_AES); cmd->authenticate(0, key); LLA_SUBTEST_PASSED("Authenticate"); logicalaccess::DESFireAccessRights ar; ar.readAccess = logicalaccess::TaskAccessRights::AR_KEY2; ar.writeAccess = logicalaccess::TaskAccessRights::AR_KEY1; ar.readAndWriteAccess = logicalaccess::TaskAccessRights::AR_KEY1; ar.changeAccess = logicalaccess::TaskAccessRights::AR_KEY1; cmdev1->createStdDataFile(0x00, logicalaccess::EncryptionMode::CM_ENCRYPT, ar, 4, 0); cmd->authenticate(1, key); std::vector<unsigned char> data = {0x01, 0x02, 0x03, 0x04}, tmp; cmdev1->writeData(0, 0, data, logicalaccess::EncryptionMode::CM_ENCRYPT); cmd->authenticate(2, key); tmp = cmdev1->readData(0, 0, 4, logicalaccess::EncryptionMode::CM_ENCRYPT); LLA_ASSERT(std::equal(data.begin(), data.end(), tmp.begin()), "read and write data are different!"); LLA_SUBTEST_PASSED("WriteRead"); cmd->authenticate(0x00, key); cmd->deleteFile(0x00); cmd->authenticate(0x00, key); std::shared_ptr<logicalaccess::DESFireKey> newkey( new logicalaccess::DESFireKey("00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 03")); cmd->changeKey(0x00, newkey); LLA_SUBTEST_PASSED("ChangeKey"); cmd->selectApplication(0x00); cmd->authenticate(0); cmd->deleteApplication(0x521); auto service = std::dynamic_pointer_cast<logicalaccess::AccessControlCardService>( chip->getService(logicalaccess::CardServiceType::CST_ACCESS_CONTROL)); LLA_ASSERT(service, "Cannot retrieve access control service from chip."); auto location = std::make_shared<logicalaccess::DESFireLocation>(); location->aid = 0x522; location->file = 0; auto ai = std::make_shared<logicalaccess::DESFireAccessInfo>(); auto format = std::make_shared<logicalaccess::Wiegand26Format>(); format->setUid(1000); format->setFacilityCode(67); service->writeFormat(format, location, ai, ai); auto formattmp = std::make_shared<logicalaccess::Wiegand26Format>(); auto rformat = std::dynamic_pointer_cast<logicalaccess::Wiegand26Format>( service->readFormat(formattmp, location, ai)); if (!rformat || rformat->getUid() != 1000 || rformat->getFacilityCode() != 67) THROW_EXCEPTION_WITH_LOG(std::runtime_error, "Bad format"); LLA_SUBTEST_PASSED("ReadFormat"); pcsc_test_shutdown(readerUnit); return EXIT_SUCCESS; }