/* Updates the first progress bar */ int _etk_test_progress_bar_update(void *data) { Etk_Widget *pbar; double fraction; char text[32]; pbar = data; fraction = etk_progress_bar_fraction_get(ETK_PROGRESS_BAR(pbar)); fraction += 0.01; if (fraction > 1.0) fraction = 0.0; snprintf(text, sizeof(text), "%d%% done", (int)(fraction * 100.0)); etk_progress_bar_text_set(ETK_PROGRESS_BAR(pbar), text); etk_progress_bar_fraction_set(ETK_PROGRESS_BAR(pbar), fraction); return 1; }
/** * @brief Set the progress bar to elapsed_time/total_time * @param elapsed_time The time elapsed * @param total_time The lenght of the song * @param gui A Emphasis_Gui */ void emphasis_player_progress_set(Emphasis_Player_Gui *player, float elapsed_time, int total_time) { char *time; etk_progress_bar_fraction_set(ETK_PROGRESS_BAR(player->full.progress), (elapsed_time / total_time)); etk_progress_bar_fraction_set(ETK_PROGRESS_BAR(player->small.progress), (elapsed_time / total_time)); asprintf(&time, "%d:%02d / %d:%02d", (int) elapsed_time / 60, (int) elapsed_time % 60, total_time / 60, total_time % 60); etk_label_set(ETK_LABEL(player->full.time) , time); // etk_label_set(ETK_LABEL(player->small.time), time); etk_progress_bar_text_set(ETK_PROGRESS_BAR(player->small.progress), time); free(time); }
int _ex_file_download_progress_cb(void *data, const char *file, long int dltotal, long int dlnow, long int ultotal, long int ulnow) { double fraction; char text[42]; static long int last; static double t_last; long int diff; double t_diff; double kbytes; static double total_kbytes; if (dlnow == 0 || dltotal == 0) return 0; if (!total_kbytes) total_kbytes = (double) ((((double)dltotal) / 1024)); if (last) { diff = dlnow - last; t_diff = ecore_time_get() - t_last; kbytes = (double) ((((double) diff) / 1024)); fraction = (double) ((double) dlnow) / ((double) dltotal); etk_progress_bar_fraction_set(ETK_PROGRESS_BAR(progressbar), fraction); snprintf(text, sizeof(text), "%d%% done at %.0f kb/s (%.0f of %.0f kb)", (int) (fraction * 100.0), kbytes / t_diff, kbytes, total_kbytes); etk_progress_bar_text_set(ETK_PROGRESS_BAR(progressbar), text); } t_last = ecore_time_get(); last = dlnow; return 0; }
void _ex_file_download_dialog(char *url, char *file) { char string[PATH_MAX + 16]; snprintf(string, sizeof(string), "Downloading %s", url); dialog = etk_message_dialog_new(ETK_MESSAGE_DIALOG_INFO, ETK_MESSAGE_DIALOG_CANCEL, string); etk_signal_connect("response", ETK_OBJECT(dialog), ETK_CALLBACK(_ex_file_download_dialog_response), file); etk_container_border_width_set(ETK_CONTAINER(dialog), 4); etk_window_title_set(ETK_WINDOW(dialog), _("Exhibit - Download progress")); progressbar = etk_progress_bar_new(); etk_progress_bar_text_set(ETK_PROGRESS_BAR(progressbar), "0% done"); etk_dialog_pack_in_main_area(ETK_DIALOG(dialog), progressbar, ETK_BOX_END, ETK_BOX_EXPAND_FILL, 2); etk_widget_show_all(dialog); }