static void dlarea_level_button_clicked(GtkWidget *widget, gpointer data) { log_debug("dlarea_level_button_clicked"); char *levels_mark = (char *)data; int levels = levels_mark[0] - '0'; if (! dl_area_choosed || ! AREA_BIG_ENOUGH()) { warn_dialog("Download area is not specified!"); return; } log_debug("guess network connecting..."); if (! guess_network_is_connecting(TRUE)) { if (! confirm_dialog("Seems no network connection,\ncontinue?")) return; } GdkRectangle rect; if (! gdk_rectangle_intersect(&dlarea, &g_view.fglayer.visible, &rect)) { warn_dialog("The selected area contains no map tiles."); return; } map_repo_t *repo = g_view.fglayer.repo; int zoom = repo->zoom; point_t tl = {rect.x + g_view.fglayer.tl_pixel.x, rect.y + g_view.fglayer.tl_pixel.y}; point_t br = {tl.x + rect.width, tl.y + rect.height}; coord_t tl_wgs84 = tilepixel_to_wgs84(tl, zoom, repo); coord_t br_wgs84 = tilepixel_to_wgs84(br, zoom, repo); /* try download... */ tile_batch_download(levels, tl_wgs84, br_wgs84); }
void on_logout_now(GtkWidget *widget, gpointer data) { if(confirm_dialog(values.action_logout) == TRUE) { gui_notification(_("Current session will be terminated !"), NOTIFICATION_TYPE_IMPORTANT, NOTIFICATION_ICON_TIME); action_run(values.action_logout); } }
void on_reboot_now(GtkWidget *widget, gpointer data) { if(confirm_dialog(values.action_restart) == TRUE) { gui_notification(_("Computer is going to reboot now !"), NOTIFICATION_TYPE_IMPORTANT, NOTIFICATION_ICON_TIME); action_run(values.action_restart); } }
static void sys_power_off() { int ret = confirm_dialog("确认关机吗?"); if (ret == 0) { close_config_db(); power_off(); exit(0); } }
int main(int argc, char *argv[]) { GtkStatusIcon *statusicon; DBusGConnection *conn; DBusGProxy *adapter, *device; GError *error = NULL; bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR); bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); textdomain(GETTEXT_PACKAGE); gtk_init(&argc, &argv); gtk_window_set_default_icon_name("bluetooth"); conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error); if (error != NULL) { g_printerr("Connecting to system bus failed: %s\n", error->message); g_error_free(error); return 1; } set_icon (TRUE); statusicon = init_notification(); g_signal_connect(statusicon, "activate", G_CALLBACK(activate_callback), NULL); setup_agents(); adapter = dbus_g_proxy_new_for_name(conn, "org.bluez", "/hci0", "org.bluez.Adapter"); device = dbus_g_proxy_new_from_proxy(adapter, "/hci0/dev_11_22_33_44_55_66", "org.bluez.Device"); //display_dialog(adapter, device, "Test (00:11:22:33:44:55)", "123456", 0, NULL); pin_dialog(adapter, device, "Test", "'Test' (00:11:22:33:44:55)", FALSE, NULL); confirm_dialog(adapter, device, "Test", "'Test' (00:11:22:33:44:55)", "123456", NULL); auth_dialog(adapter, device, "Test", "'Test' (00:11:22:33:44:55)", "UUID", NULL); gtk_main(); g_object_unref(device); g_object_unref(adapter); cleanup_notification(); cleanup_agents(); dbus_g_connection_unref(conn); return 0; }
/** * preferences->update local cache */ void on_pref_button_update_cache_clicked(GtkButton *button, gpointer data) { gint result; result = confirm_dialog(main_window, _("Update will delete all the old cache! Really want to update?"), _("Attention!")); if (result == GTK_RESPONSE_YES) weather_window_update_cache(WEATHER_WINDOW(main_window)); }
static void sys_cfg_clear_transdtl() { int ret = confirm_dialog("确认清空流水?"); if (ret != 0) return; ret = trans_clear_dtl(); if (!ret) { disp_msg("清空流水成功", 10); } else { disp_msg("清空流水失败\n 请联系管理员", 10); } }
static void delete_button_clicked(GtkWidget *widget, gpointer data) { GtkTreeIter iter; char *file = get_selected_file(&iter); if (file) { char buf[64]; snprintf(buf, sizeof(buf), "Delete file:\n\n%s", file); if (confirm_dialog(buf)) { gtk_list_store_remove (filelist_store, &iter); char buf[256]; char *path = get_full_path(buf, sizeof(buf), file); unlink(path); } } else { info_dialog("Delete: no file selected!"); } }
void GameList::DeleteFile() { ModalMessageBox confirm_dialog(this); confirm_dialog.setIcon(QMessageBox::Warning); confirm_dialog.setWindowTitle(tr("Confirm")); confirm_dialog.setText(tr("Are you sure you want to delete this file?")); confirm_dialog.setInformativeText(tr("This cannot be undone!")); confirm_dialog.setStandardButtons(QMessageBox::Yes | QMessageBox::Cancel); if (confirm_dialog.exec() == QMessageBox::Yes) { for (const auto& game : GetSelectedGames()) { bool deletion_successful = false; while (!deletion_successful) { deletion_successful = File::Delete(game->GetFilePath()); if (deletion_successful) { m_model->RemoveGame(game->GetFilePath()); } else { ModalMessageBox error_dialog(this); error_dialog.setIcon(QMessageBox::Critical); error_dialog.setWindowTitle(tr("Failure")); error_dialog.setText(tr("Failed to delete the selected file.")); error_dialog.setInformativeText(tr("Check whether you have the permissions required to " "delete the file or whether it's still in use.")); error_dialog.setStandardButtons(QMessageBox::Retry | QMessageBox::Abort); if (error_dialog.exec() == QMessageBox::Abort) break; } } if (!deletion_successful) break; // Something is wrong, so we should abort the whole thing } } }
static void oper_logout() { if (p16pos.login_flag == 1) { int ret; ret = confirm_dialog("确定签出操作员?"); if (ret < 0) return; p16pos.login_flag = 0; p16pos.operid = 0; p16pos.authcode = 0; p16pos.batchno = 0; disp_msg("操作员签出成功", 6); } else { disp_msg("不需要签出", 5); } }
static void delete_button_clicked(GtkWidget *widget, gpointer data) { char buf[256]; if (! selected_file) { info_dialog("no file was selected!"); return; } snprintf(buf, sizeof(buf), "Delete file:\n\n%s", selected_file); if (confirm_dialog(buf)) { gtk_list_store_remove (filelist_store, &selected_iter); get_full_path(buf, sizeof(buf), selected_file); unlink(buf); gtk_widget_set_sensitive(view_button, FALSE); gtk_widget_set_sensitive(delete_button, FALSE); } }
static void cancel_batch_button_clicked(GtkCellRenderer *cell, gchar *path_str, gpointer data) { GtkTreeIter iter; batch_dl_t *batch; GtkTreeModel *treemodel = gtk_tree_view_get_model (GTK_TREE_VIEW(batchlist_treeview)); GtkTreePath *path = gtk_tree_path_new_from_string (path_str); gtk_tree_model_get_iter (treemodel, &iter, path); gtk_tree_model_get (treemodel, &iter, COL_BL_BATCH, &batch, -1); gtk_tree_path_free (path); if (batch->state != BATCH_DL_STATE_FINISHED) { if (! confirm_dialog("cancel this batch download?")) return; } download_cancel_batch(batch); gtk_list_store_remove (batchlist_store, &iter); }
static gboolean confirm_request (DBusGMethodInvocation *context, DBusGProxy *device, guint pin, gpointer user_data) { DBusGProxy *adapter = user_data; char *name, *long_name, *line, *text; name = device_get_name (device, &long_name); if (name == NULL) return FALSE; text = g_strdup_printf("%d", pin); confirm_dialog(adapter, device, name, long_name, text, context); g_free(text); g_free (long_name); /* translators: this is a popup telling you a particular device * has asked for pairing */ line = g_strdup_printf(_("Pairing confirmation for '%s'"), name); g_free(name); /* translators: * This message is for Bluetooth 2.1 support, when the * action is clicked in the notification popup, the user * will get to check whether the PIN matches the one * showing on the Bluetooth device */ if (notification_supports_actions () != FALSE) show_notification(_("Bluetooth device"), line, _("Verify PIN"), 0, G_CALLBACK(notification_closed)); else present_notification_dialogs (); g_free(line); return TRUE; }
void GameList::DeleteFile() { const auto game = GetSelectedGame(); QMessageBox confirm_dialog(this); confirm_dialog.setIcon(QMessageBox::Warning); confirm_dialog.setText(tr("Are you sure you want to delete this file?")); confirm_dialog.setInformativeText(tr("You won't be able to undo this!")); confirm_dialog.setStandardButtons(QMessageBox::Yes | QMessageBox::Cancel); if (confirm_dialog.exec() == QMessageBox::Yes) { bool deletion_successful = false; while (!deletion_successful) { deletion_successful = File::Delete(game.toStdString()); if (deletion_successful) { m_model->RemoveGame(game); } else { QMessageBox error_dialog(this); error_dialog.setIcon(QMessageBox::Critical); error_dialog.setText(tr("Failed to delete the selected file.")); error_dialog.setInformativeText(tr("Check whether you have the permissions required to " "delete the file or whether it's still in use.")); error_dialog.setStandardButtons(QMessageBox::Retry | QMessageBox::Abort); if (error_dialog.exec() == QMessageBox::Abort) break; } } } }
/* --- TITLE SCREEN --- */ void title(void) { random_timer.init(true); walking = true; st_pause_ticks_init(); GameSession session(datadir + "/levels/misc/menu.stl", 0, ST_GL_DEMO_GAME); clearscreen(0, 0, 0); updatescreen(); /* Load images: */ bkg_title = new Surface(datadir + "/images/title/background.jpg", IGNORE_ALPHA); logo = new Surface(datadir + "/images/title/logo.png", USE_ALPHA); img_choose_subset = new Surface(datadir + "/images/status/choose-level-subset.png", USE_ALPHA); /* Generating contrib maps by only using a string_list */ // Since there isn't any world dir or anything, add a hardcoded entry for Bonus Island string_list_init(&worldmap_list); string_list_type files = dfiles("levels/worldmaps/", ".stwm", "couldn't list worldmaps"); for(int i = 0; i < files.num_items; ++i) { if(strcmp(files.item[i], "world1.stwm") == 0) continue; string_list_add_item(&worldmap_list, files.item[i]); } string_list_free(&files); /* --- Main title loop: --- */ frame = 0; /* Draw the title background: */ bkg_title->draw_bg(); update_time = st_get_ticks(); random_timer.start(rand() % 2000 + 2000); Menu::set_current(main_menu); while (Menu::current()) { // if we spent to much time on a menu entry if( (update_time - last_update_time) > 1000) update_time = last_update_time = st_get_ticks(); // Calculate the movement-factor double frame_ratio = ((double)(update_time-last_update_time))/((double)FRAME_RATE); if(frame_ratio > 1.5) /* Quick hack to correct the unprecise CPU clocks a little bit. */ frame_ratio = 1.5 + (frame_ratio - 1.5) * 0.85; /* Lower the frame_ratio that Tux doesn't jump to hectically throught the demo. */ frame_ratio /= 2; SDL_Event event; while (SDL_PollEvent(&event)) { if (Menu::current()) { Menu::current()->event(event); } // FIXME: QUIT signal should be handled more generic, not locally if (event.type == SDL_QUIT) Menu::set_current(0); } /* Draw the background: */ draw_demo(&session, frame_ratio); if (Menu::current() == main_menu) logo->draw( 160, 30); white_small_text->draw(" SuperTux " VERSION "\n" "Copyright (c) 2003 SuperTux Devel Team\n" "This game comes with ABSOLUTELY NO WARRANTY. This is free software, and you\n" "are welcome to redistribute it under certain conditions; see the file COPYING\n" "for details.\n", 0, 420, 0); /* Don't draw menu, if quit is true */ Menu* menu = Menu::current(); if(menu) { menu->draw(); menu->action(); if(menu == main_menu) { MusicManager* music_manager; MusicRef menu_song; switch (main_menu->check()) { case MNID_STARTGAME: // Start Game, ie. goto the slots menu update_load_save_game_menu(load_game_menu); break; case MNID_CONTRIB: // Contrib Menu puts("Entering contrib menu"); generate_contrib_menu(); break; case MNID_LEVELEDITOR: leveleditor(); Menu::set_current(main_menu); break; case MNID_CREDITS: music_manager = new MusicManager(); menu_song = music_manager->load_music(datadir + "/music/credits.ogg"); music_manager->halt_music(); music_manager->play_music(menu_song,0); display_text_file("CREDITS", bkg_title, SCROLL_SPEED_CREDITS); music_manager->halt_music(); menu_song = music_manager->load_music(datadir + "/music/theme.mod"); music_manager->play_music(menu_song); Menu::set_current(main_menu); break; case MNID_QUITMAINMENU: Menu::set_current(0); break; } } else if(menu == options_menu) { process_options_menu(); } else if(menu == load_game_menu) { if(event.key.keysym.sym == SDLK_DELETE) { int slot = menu->get_active_item_id(); char str[1024]; sprintf(str,"Are you sure you want to delete slot %d?", slot); draw_background(); if(confirm_dialog(str)) { sprintf(str,"%s/slot%d.stsg", st_save_dir, slot); printf("Removing: %s\n",str); remove(str); } update_load_save_game_menu(load_game_menu); update_time = st_get_ticks(); Menu::set_current(main_menu); } else if (process_load_game_menu()) { // FIXME: shouldn't be needed if GameSession doesn't relay on global variables // reset tux scroll_x = 0; //titletux.level_begin(); update_time = st_get_ticks(); } } else if(menu == contrib_menu) { check_contrib_menu(); } else if (menu == contrib_subset_menu) { check_contrib_subset_menu(); } } mouse_cursor->draw(); flipscreen(); /* Set the time of the last update and the time of the current update */ last_update_time = update_time; update_time = st_get_ticks(); /* Pause: */ frame++; SDL_Delay(25); } /* Free surfaces: */ free_contrib_menu(); string_list_free(&worldmap_list); delete bkg_title; delete logo; delete img_choose_subset; }
static gboolean replay_read_records() { gboolean ret = TRUE; FILE *fp = fopen(replay_file_path, "r"); if (! fp) { warn_dialog("Unable to open track file"); return FALSE; } /* head */ U4 end_time, record_count; fscanf(fp, TRACK_HEAD_LABEL_1"%u\n", &replay_start_time); fscanf(fp, TRACK_HEAD_LABEL_2"%u\n", &end_time); fscanf(fp, TRACK_HEAD_LABEL_3"%u\n", &record_count); /* auto split at each GPS week start, see track_add() */ if (record_count > 3600 * 24 * 7) { if (! confirm_dialog("Too many records, " "risk of out of memory\n\ncontinue?")) { ret = FALSE; goto END; } } replay_records = (trackpoint_t*)calloc(record_count, sizeof(trackpoint_t)); if (! replay_records) { warn_dialog("Track replay: failed to allocate memory"); ret = FALSE; goto END; } int i, n; for (i=0; i < record_count; i++) { n = fscanf(fp, "%lf\t%lf\t%u\n", &replay_records[i].wgs84.lat, &replay_records[i].wgs84.lon, &replay_records[i].time_offset); if (n == EOF) break; else if (n != 3) { warn_dialog("Read track file failed"); replay_free_data(); ret = FALSE; goto END; } } if (i == 0) { ret = FALSE; goto END; } total_records = i; time_span = replay_records[total_records - 1].time_offset; END: fclose(fp); return ret; }
/** * <topleft> and <botright>: tile pixel */ static void tile_batch_download(int levels, coord_t tl_wgs84, coord_t br_wgs84) { map_repo_t *repo = g_view.fglayer.repo; int zoom = repo->zoom; if (zoom + levels > repo->max_zoom) levels = repo->max_zoom - zoom; batch_dl_t *batch = (batch_dl_t*)malloc(sizeof(batch_dl_t)); if (! batch) { warn_dialog("batch download:\n\nunable to allocate memory!"); return; } batch->repo = repo; batch->min_zoom = zoom + 1; batch->max_zoom = zoom + levels; batch->tl_wgs84 = tl_wgs84; batch->br_wgs84 = br_wgs84; /* prepare */ int exists_size = batch_download_prepare(batch); if (exists_size < 0) { warn_dialog("batch download:\nallocate memory failed!"); return; } float size_est; /* MB */ if (batch->num_in_range == batch->num_dl_total) size_est = batch->num_dl_total * 0.01; // estimate else { int average_size = exists_size / (batch->num_in_range - batch->num_dl_total); size_est = 1.0 * average_size * batch->num_dl_total / (1024 * 1024); } char buf[128]; if (batch->num_dl_total == 0) { snprintf(buf, sizeof(buf), "total %d tiles, already on disk.", batch->num_in_range); info_dialog(buf); return; } /* Assume each download takes 1 second */ int seconds = (int)ceil((1 + 1000.0 / DL_SLEEP_MS) * batch->num_dl_total / TILE_DL_THREADS_LIMIT); int h = seconds / 3600; int remains = seconds - h * 3600; int m = remains / 60; int s = remains - m * 60; snprintf(buf, sizeof(buf), "tiles: %d of %d, disk space: ~%.2fMB, time: > %d:%d:%d", batch->num_dl_total, batch->num_in_range, size_est, h, m, s); if (! confirm_dialog(buf)) { free(batch); return; } /* batch download */ log_info("batch download: map=%s, zoom=%d, +levels=%d", repo->name, zoom, levels); log_info("%s", buf); batch_download(batch); }
void title_loop() { // if we spent to much time on a menu entry if( (update_time - last_update_time) > 1000) update_time = last_update_time = st_get_ticks(); // Calculate the movement-factor double frame_ratio = ((double)(update_time-last_update_time))/((double)FRAME_RATE); if(frame_ratio > 1.5) /* Quick hack to correct the unprecise CPU clocks a little bit. */ frame_ratio = 1.5 + (frame_ratio - 1.5) * 0.85; /* Lower the frame_ratio that Tux doesn't jump to hectically throught the demo. */ frame_ratio /= 2; //printf("pxx: frame ratio: %f\n", frame_ratio); SDL_Event event; while (SDL_PollEvent(&event)) { if (Menu::current()) { Menu::current()->event(event); } // FIXME: QUIT signal should be handled more generic, not locally if (event.type == SDL_QUIT) Menu::set_current(0); } /* Draw the background: */ draw_demo(title_session, frame_ratio); if (Menu::current() == main_menu) logo->draw( 160, 30); white_small_text->draw(" SuperTux " VERSION "\n" "Copyright (c) 2003 SuperTux Devel Team\n" "This game comes with ABSOLUTELY NO WARRANTY. This is free software, and you\n" "are welcome to redistribute it under certain conditions; see the file COPYING\n" "for details.\n", 0, 420, 0); /* Don't draw menu, if quit is true */ Menu* menu = Menu::current(); if(menu) { menu->draw(); menu->action(); if(menu == main_menu) { MusicManager* music_manager; MusicRef menu_song; switch (main_menu->check()) { case MNID_STARTGAME: // Start Game, ie. goto the slots menu update_load_save_game_menu(load_game_menu); break; case MNID_CONTRIB: // Contrib Menu puts("Entering contrib menu"); generate_contrib_menu(); break; case MNID_LEVELEDITOR: leveleditor(); Menu::set_current(main_menu); break; case MNID_CREDITS: music_manager = new MusicManager(); menu_song = music_manager->load_music(datadir + "/music/credits.ogg"); //music_manager->halt_music(); music_manager->play_music(menu_song,0); display_text_file("CREDITS", bkg_title, SCROLL_SPEED_CREDITS); // music_manager->halt_music(); // menu_song = music_manager->load_music(datadir + "/music/theme.ogg"); // music_manager->play_music(menu_song); // Menu::set_current(main_menu); break; case MNID_QUITMAINMENU: Menu::set_current(0); break; } } else if(menu == options_menu) { process_options_menu(); } else if(menu == load_game_menu) { if(event.key.keysym.sym == SDLK_DELETE) { int slot = menu->get_active_item_id(); char str[1024]; sprintf(str,"Are you sure you want to delete slot %d?", slot); draw_background(); if(confirm_dialog(str)) { sprintf(str,"%s/slot%d.stsg", st_save_dir, slot); printf("Removing: %s\n",str); remove(str); } update_load_save_game_menu(load_game_menu); update_time = st_get_ticks(); Menu::set_current(main_menu); } else if (process_load_game_menu()) { // // FIXME: shouldn't be needed if GameSession doesn't relay on global variables // // reset tux // scroll_x = 0; // //titletux.level_begin(); // update_time = st_get_ticks(); } } else if(menu == contrib_menu) { check_contrib_menu(); } else if (menu == contrib_subset_menu) { check_contrib_subset_menu(); } } mouse_cursor->draw(); flipscreen(); /* Set the time of the last update and the time of the current update */ last_update_time = update_time; update_time = st_get_ticks(); /* Pause: */ frame++; //SDL_Delay(25); //printf("pxx: title loop finish\n"); }