void progress_change_cb (GtkMozEmbed *embed, gint cur, gint max, TestGtkBrowser *browser) { g_print("progress_change_cb cur %d max %d\n", cur, max); // avoid those pesky divide by zero errors if (max < 1) { gtk_progress_set_activity_mode(GTK_PROGRESS(browser->progressBar), FALSE); browser->loadPercent = 0; browser->bytesLoaded = cur; browser->maxBytesLoaded = 0; update_status_bar_text(browser); } else { browser->bytesLoaded = cur; browser->maxBytesLoaded = max; if (cur > max) browser->loadPercent = 100; else browser->loadPercent = (cur * 100) / max; update_status_bar_text(browser); gtk_progress_set_percentage(GTK_PROGRESS(browser->progressBar), browser->loadPercent / 100.0); } }
/* * UpdateProgress * * Update the progress window to reflect the state * of the file that is being loaded. * * pos - how much of the file has been loaded. * len - length of the file * (pos / len) = % file has been loaded. */ void UpdateProgress (long pos, long len) { gfloat pvalue; int pct; /* --- Prevent divide by zero errors --- */ if (len > 0) { /* --- Calculate the percentage --- */ pvalue = (gfloat) pos / (gfloat) len; pct = pvalue * 100; if (pdata->nLastPct != pct) { /* --- Update the displayed value --- */ gtk_progress_set_percentage (GTK_PROGRESS (pdata->progressbar), pvalue); /* --- Repaint any windows - like the progress bar --- */ while (gtk_events_pending ()) { gtk_main_iteration (); } pdata->nLastPct = pct; } } }
static void progress_cb (GtkMozEmbed *embed, gint cur, gint max, WebBrowserObject *browser) { if (max < 1) { gtk_progress_set_activity_mode(GTK_PROGRESS(browser->progressBar), FALSE); browser->loadPercent = 0; browser->bytesLoaded = cur; browser->maxBytesLoaded = 0; browser->SetStatus(0); } else { browser->bytesLoaded = cur; browser->maxBytesLoaded = max; if (cur > max) { browser->loadPercent = 100; } else { browser->loadPercent = (cur * 100) / max; } char msg[256]; if (browser->loadPercent) { snprintf(msg, sizeof(msg), "%d%% complete, %d bytes of %d loaded", browser->loadPercent, browser->bytesLoaded, browser->maxBytesLoaded); browser->SetStatus(msg); } else if (browser->bytesLoaded) { snprintf(msg, sizeof(msg), "%d bytes loaded", browser->bytesLoaded); browser->SetStatus(msg); } gtk_progress_set_percentage(GTK_PROGRESS(browser->progressBar), browser->loadPercent / 100.0); } }
void progress_bar_set_percentage (GtkWidget *pbar, float percentage) { struct pbarinfo *info; info = gtk_object_get_user_data (GTK_OBJECT (pbar)); if (!info->activity_mode) gtk_progress_set_percentage (GTK_PROGRESS (pbar), percentage); }
void diaElemBar::setMe(void *dialog, void *opaque,uint32_t line) { GtkWidget *widget; GtkWidget *label; GtkWidget *bar; label = gtk_label_new_with_mnemonic (paramTitle); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_widget_show(label); gtk_table_attach (GTK_TABLE (opaque), label, 0, 1, line, line+1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); bar = gtk_progress_bar_new (); gtk_widget_show (bar); gfloat p; p=per; p=p/100.; gtk_progress_set_percentage(GTK_PROGRESS(bar),p); gtk_table_attach (GTK_TABLE (opaque), bar, 1, 2, line, line+1, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (0), 0, 0); }
static void on_transfer_item_finish (C2TransferItem *ti, C2TransferList *tl) { GtkWidget *progress; GSList *list; if (GTK_TOGGLE_BUTTON (tl->close)->active && g_slist_length (tl->list) == 1) gtk_timeout_add (2500, (GtkFunction) on_last_finish_timeout, tl); else tl->list = g_slist_remove (tl->list, ti); progress = ti->progress_byte; gtk_widget_hide (progress); progress = ti->progress_mail; gtk_progress_set_percentage (GTK_PROGRESS (progress), 1.0); gtk_widget_set_sensitive (ti->cancel_button, FALSE); if (!g_slist_length (tl->list)) { gtk_signal_emit (GTK_OBJECT (tl), signals[FINISH]); tl->finished = 1; } }
static gint scan_match(gpointer first) { static int scan = 0; int stop; carmen_point_t pos, cpos; carmen_laser_laser_message laserscan; g_mutex_lock(laserscans_mutex); stop = !scan_matching; g_mutex_unlock(laserscans_mutex); if (stop) return FALSE; if ((long)first) { if (scan != 0) vascocore_reset(); scan = scan_range_min; } while (scan_mask[scan] == 0 && scan <= scan_range_max) scan++; if (scan > scan_range_max) { g_idle_add(end_scan_matching, 0); return FALSE; } laserscan.config = scan_list[scan].config; laserscan.num_readings = scan_list[scan].num_readings; laserscan.range = scan_list[scan].range; laserscan.timestamp = 0.0; laserscan.host = (char *)calloc(1, sizeof(char)); pos.x = scan_list[scan].laser_pose.x; pos.y = scan_list[scan].laser_pose.y; pos.theta = scan_list[scan].laser_pose.theta; cpos = vascocore_scan_match(laserscan, pos); scan_list[scan].laser_pose = cpos; /* scan_list[scan].x = cpos.x; */ /* scan_list[scan].y = cpos.y; */ /* scan_list[scan].theta = cpos.theta; */ scan++; gtk_progress_set_percentage(GTK_PROGRESS(progress_bar), (scan - scan_range_min) / (double) (scan_range_max - scan_range_min + 1)); while (gtk_events_pending()) gtk_main_iteration_do(0); if ((long)first) { g_idle_add(scan_match, 0); return FALSE; } return TRUE; }
static void net_stop_cb (GtkMozEmbed *embed, WebBrowserObject *browser) { browser->FireEvent("OnStop"); gtk_widget_set_sensitive(browser->stopButton, FALSE); gtk_widget_set_sensitive(browser->reloadButton, TRUE); gtk_progress_set_percentage(GTK_PROGRESS(browser->progressBar), 0); browser->loadPercent = 0; browser->bytesLoaded = 0; browser->maxBytesLoaded = 0; browser->SetStatus(0); }
void load_finished_cb (GtkMozEmbed *embed, TestGtkBrowser *browser) { g_print("load_finished_cb\n"); gtk_widget_set_sensitive(browser->stopButton, FALSE); gtk_widget_set_sensitive(browser->reloadButton, TRUE); browser->loadPercent = 0; browser->bytesLoaded = 0; browser->maxBytesLoaded = 0; update_status_bar_text(browser); gtk_progress_set_percentage(GTK_PROGRESS(browser->progressBar), 0); }
/* Sets the current percentage completion for the GtkProgress. */ int clip_GTK_PROGRESSSETPERCENTAGE(ClipMachine * cm) { C_widget *cprg = _fetch_cw_arg(cm); gfloat percentage = _clip_parnd(cm,2); CHECKCWID(cprg,GTK_IS_PROGRESS); CHECKOPT(2,NUMERIC_t); gtk_progress_set_percentage(GTK_PROGRESS(cprg->widget), percentage); return 0; err: return 1; }
uint8_t DIA_working::update(uint32_t percent) { GtkWidget *dialog; uint32_t elapsed; char b[300]; UI_purge(); if(!_priv) return 1; dialog=(GtkWidget *)_priv; if(!percent) return 0; if(percent==lastper) return 0; aprintf("DIA_working::update(%lu) called\n", percent); elapsed=_clock.getElapsedMS(); if(!elapsed) return 0; lastper=percent; // // 100/totalMS=percent/elapsed // totalM=100*elapsed/percent double f; f=100.; f*=elapsed; f/=percent; f-=elapsed; f/=1000; uint32_t sectogo=(uint32_t)floor(f); int mm,ss; mm=sectogo/60; ss=sectogo%60; sprintf(b, " %d m %d s left", mm,ss); aprintf("DIA_working::update(%lu): new time left: %s\n" "\tf=%f sectogo=%lu\n", percent,b,f,sectogo); gtk_label_set_text(GTK_LABEL(lookup_widget(dialog,"label_time")), b); double p; p=percent; p=p/100.; gtk_progress_set_percentage(GTK_PROGRESS(lookup_widget(dialog,"progressbar1")),(gfloat)p); UI_purge(); return 0; }
void progress_bar_reset (GtkWidget *pbar) { struct pbarinfo *info; info = gtk_object_get_user_data (GTK_OBJECT (pbar)); if (info->activity_mode) { gtk_timeout_remove (info->timeout_id); info->activity_mode = FALSE; } gtk_progress_set_activity_mode (GTK_PROGRESS (pbar), FALSE); gtk_progress_set_show_text (GTK_PROGRESS (pbar), FALSE); gtk_progress_set_percentage (GTK_PROGRESS (pbar), 0.0); }
void UpdateProgress(int pos, int len) { gfloat pvalue; int pct; if(len > 0) { pvalue=(gfloat)pos / (gfloat)len; pct=pvalue * 100; if(pdata->nLastPct != pct) { gtk_progress_set_percentage (GTK_PROGRESS (pdata->progressbar),pvalue); while(gtk_events_pending()) { gtk_main_iteration(); } pdata->nLastPct=pct; } } }
uint8_t DIA_progressIndexing::update(uint32_t done,uint32_t total, uint32_t nbImage, uint32_t hh, uint32_t mm, uint32_t ss) { char string[512]; double f; UI_purge(); sprintf(string,"%02d:%02d:%02d",hh,mm,ss); gtk_label_set_text(GTK_LABEL(WID(labelTime)),string); sprintf(string,"%0lu",nbImage); gtk_label_set_text(GTK_LABEL(WID(labelNbImage)),string); f=done; f/=total; gtk_progress_set_percentage(GTK_PROGRESS(WID(progressbar1)),(gfloat)f); return 1; }
static gint end_scan_matching(gpointer data) { long cancelled = (long) data; g_mutex_lock(laserscans_mutex); scan_matching = 0; g_mutex_unlock(laserscans_mutex); gtk_progress_set_percentage(GTK_PROGRESS(progress_bar), 0.0); if (!cancelled) { laser_scans_update(); status_print("Scan matching...complete", "scanmatch"); } else { laser_scans_restore(); status_print("Scan matching...cancelled", "scanmatch"); } return FALSE; }
uint8_t DIA_progressIndexing::update(uint32_t done,uint32_t total, uint32_t nbImage, uint32_t hh, uint32_t mm, uint32_t ss) { uint32_t tim; #define GUI_UPDATE_RATE 1000 tim=clock.getElapsedMS(); if(tim>_nextUpdate) { char string[256]; double f; uint32_t tom,zhh,zmm,zss; _nextUpdate=tim+GUI_UPDATE_RATE; sprintf(string,"%02d:%02d:%02d",hh,mm,ss); gtk_label_set_text(GTK_LABEL(WID(labelTime)),string); sprintf(string,"%0lu",nbImage); gtk_label_set_text(GTK_LABEL(WID(labelNbImage)),string); f=done; f/=total; gtk_progress_set_percentage(GTK_PROGRESS(WID(progressbar1)),(gfloat)f); /* compute ETL */ // Do a simple relation between % and time // Elapsed time =total time*percent if(f<0.01) return 1; f=tim/f; // Tom is total time tom=(uint32_t)floor(f); if(tim>tom) return 1; tom=tom-tim; ms2time(tom,&zhh,&zmm,&zss); sprintf(string,"%02d:%02d:%02d",zhh,zmm,zss); gtk_label_set_text(GTK_LABEL(WID(label6)),string); UI_purge(); } return 1; }
gint gw_progress_bar_box_set_percentage ( GtkWindow *w, gfloat percentage) { GtkProgress *progress_bar = NULL; gint result = -1; #ifdef GW_DEBUG_GUI_COMPONENT g_print ( "*** GW - %s (%d) :: %s()\n", __FILE__, __LINE__, __PRETTY_FUNCTION__); #endif if ( w != NULL ) { if ( (progress_bar = gw_progress_bar_box_get_progress_bar ( w)) != NULL ) { gtk_progress_set_percentage ( progress_bar, percentage); result = 0; } } return result; }
gboolean progress_timer(gpointer data) { //TOFIX optimize, show only if hidden, hide only if visible if(g_bMsgBox){ //hide progress dialog while waiting soem message box to finish gtk_widget_hide(g_wndProgressDlg); } else { //ensure progress dialog is visible and pulse the progress if(g_wndProgressDlg) gtk_widget_show(g_wndProgressDlg); if(g_progress1){ if(ProgressDlg::m_nTotalSize > 0) //TOFIX what if two loads at te same time ? not static!?? { gtk_progress_set_percentage(GTK_PROGRESS(g_progress1), ((double)ProgressDlg::m_nCurrentSize)/ProgressDlg::m_nTotalSize); } else gtk_progress_bar_pulse(GTK_PROGRESS_BAR(g_progress1)); } } return TRUE; }
void * check_pop_main (Account *account) { char *buf = NULL, *buf2, *buf3; C2ResolveNode *resolve; int sock; int timedout = FALSE; struct sockaddr_in server; int messages = 0, bytes = 0, downloaded_bytes = 0, i = 0, password_errors = 3; GList *download[DOWNLOAD_LIST_LAST], *uidl_search = NULL, *top_search = NULL; GList *list; gboolean supports_uidl = FALSE; mid_t mid; FILE *index; FILE *mail; Message message; char *mailbox; Mailbox *mbox; GString *strmsg; char *header[HEADER_LAST]; gboolean reading_header = TRUE; gboolean with_attachs = FALSE; char *content_type; char *row[8]; GtkStyle *style, *style2; gboolean clisted = FALSE; g_return_val_if_fail (account, NULL); g_return_val_if_fail (account->type == C2_ACCOUNT_POP, NULL); download[DOWNLOAD_LIST_TOTAL] = NULL; download[DOWNLOAD_LIST_UIDL] = NULL; download[DOWNLOAD_LIST_TOP] = NULL; resolve = c2_resolve (account->protocol.pop.host, &buf); if (buf) { gdk_threads_enter (); window_checking_report (C2_CHECK_ERR, account->acc_name, buf); gdk_threads_leave (); return NULL; } sock = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP); if (sock < 0) { gdk_threads_enter (); window_checking_report (C2_CHECK_ERR, account->acc_name, _("Failed to create socket")); gdk_threads_leave (); return NULL; } server.sin_family = AF_INET; server.sin_port = htons (account->protocol.pop.host_port); server.sin_addr.s_addr= inet_addr (resolve->ip); if (connect (sock, (struct sockaddr *)&server, sizeof (server)) < 0) { buf = g_strerror (errno); gdk_threads_enter (); window_checking_report (C2_CHECK_ERR, account->acc_name, buf); gdk_threads_leave (); return NULL; } /* Guten Morgen, Herr Server! */ buf = sock_read (sock, &timedout); if (pop_check_answer (buf, account, timedout) < 0) { if (timedout) goto run_for_your_life; goto bye_bye_server; } c2_free (buf); /* Log In */ gdk_threads_enter (); gtk_progress_set_format_string (GTK_PROGRESS (window_checking->mail_progress), _("Logging in...")); gdk_threads_leave (); retry_login: if (sock_printf (sock, "USER %s\r\n", account->protocol.pop.usr_name) < 0) { buf = g_strerror (errno); gdk_threads_enter (); window_checking_report (C2_CHECK_ERR, account->acc_name, buf); gdk_threads_leave (); goto bye_bye_server; } buf = sock_read (sock, &timedout); if (pop_check_answer (buf, account, timedout) < 0) { if (timedout) goto run_for_your_life; goto bye_bye_server; } c2_free (buf); if (sock_printf (sock, "PASS %s\r\n", account->protocol.pop.pass) < 0) { buf = g_strerror (errno); gdk_threads_enter (); window_checking_report (C2_CHECK_ERR, account->acc_name, buf); gdk_threads_leave (); goto bye_bye_server; } buf = sock_read (sock, &timedout); if (strnne (buf, "+OK", 3)) { if (--password_errors < 0) { if (pop_check_answer (buf, account, timedout) < 0) { if (timedout) goto run_for_your_life; goto bye_bye_server; } } gdk_threads_enter (); if (!gui_ask_password (account)) { gdk_threads_leave (); if (pop_check_answer (buf, account, timedout) < 0) { if (timedout) goto run_for_your_life; goto bye_bye_server; } } else { gdk_threads_leave (); goto retry_login; } } c2_free (buf); /* STAT */ gdk_threads_enter (); gtk_progress_set_format_string (GTK_PROGRESS (window_checking->mail_progress), _("Checking for number of mails in server...")); gdk_threads_leave (); if (sock_printf (sock, "STAT\r\n") < 0) { buf = g_strerror (errno); gdk_threads_enter (); window_checking_report (C2_CHECK_ERR, account->acc_name, buf); gdk_threads_leave (); goto bye_bye_server; } buf = sock_read (sock, &timedout); if (pop_check_answer (buf, account, timedout) < 0) { if (timedout) goto run_for_your_life; goto bye_bye_server; } sscanf (buf, "+OK %d ", &messages); c2_free (buf); if (!messages) { gdk_threads_enter (); gtk_progress_set_format_string (GTK_PROGRESS (window_checking->mail_progress), _("No messages in server")); window_checking_report (C2_CHECK_OK, account->acc_name, _("No messages to download")); gdk_threads_leave (); clisted = TRUE; goto bye_bye_server; } else if (messages != 1) buf = g_strdup_printf (_("%d messages in server"), messages); else buf = g_strdup_printf (_("1 message in server")); gdk_threads_enter (); gtk_progress_set_format_string (GTK_PROGRESS (window_checking->mail_progress), buf); gdk_threads_leave (); c2_free (buf); /* UIDL */ if (!account->keep_copy) { dont_use_uidl: /* Without UIDL*/ for (i = 1; i <= messages; i++) { buf = g_strdup_printf ("%d", i); download[DOWNLOAD_LIST_UIDL] = g_list_append (download[DOWNLOAD_LIST_UIDL], (gpointer) buf); } } else { /* With UIDL */ if (sock_printf (sock, "UIDL\r\n") < 0) { buf = g_strerror (errno); gdk_threads_enter (); window_checking_report (C2_CHECK_ERR, account->acc_name, buf); gdk_threads_leave (); goto bye_bye_server; } for (i = 0;; i++) { buf = sock_read (sock, &timedout); if (!i && strnne (buf, "+OK", 3)) { /* UIDL is optional for POP servers, * so I won't complain if server doesn't like it */ buf2 = g_strdup_printf (_("The POP server of the account %s doesn't support UIDL."), account->acc_name); gdk_threads_enter (); gnome_appbar_set_status (GNOME_APPBAR (WMain->appbar), buf2); gdk_threads_leave (); supports_uidl = FALSE; goto dont_use_uidl; } supports_uidl = TRUE; if (!i) continue; if (streq (buf, ".\r\n")) break; buf2 = str_get_word (1, buf, ' '); buf3 = str_strip (buf2, '\r'); buf2 = str_strip (buf3, '\n'); if (!uidl_check (buf2, account->acc_name)) { download[DOWNLOAD_LIST_UIDL] = g_list_append (download[DOWNLOAD_LIST_UIDL], buf); } } } /* TOP */ if (!config->message_bigger) { /* Without TOP */ dont_use_list: dont_use_top: for (i = 1; i <= messages; i++) download[DOWNLOAD_LIST_TOP] = g_list_append (download[DOWNLOAD_LIST_TOP], (gpointer) i); } else { /* With TOP */ char *subject, *from, *date, *kbytes; if (sock_printf (sock, "LIST\r\n") < 0) { buf = g_strerror (errno); gdk_threads_enter (); window_checking_report (C2_CHECK_ERR, account->acc_name, buf); gdk_threads_leave (); goto bye_bye_server; } for (i = 0;; i++) { buf = sock_read (sock, &timedout); if (!i && strnne (buf, "+OK", 3)) { buf2 = g_strdup_printf (_("The POP server of the account %s doesn't support LIST."), account->acc_name); gdk_threads_enter (); gnome_appbar_set_status (GNOME_APPBAR (WMain->appbar), buf2); gdk_threads_leave (); goto dont_use_list; } if (!i) continue; if (streq (buf, ".\r\n")) break; buf2 = str_get_word (1, buf, ' '); str_strip (buf2, '\r'); str_strip (buf2, '\n'); download[DOWNLOAD_LIST_TOP] = g_list_append (download[DOWNLOAD_LIST_TOP], buf); c2_free (buf2); } for (list = download[DOWNLOAD_LIST_TOP]; list; list = list->next) { if (sock_printf (sock, "TOP %d 0\r\n", atoi (CHAR (list->data))) < 0) { buf = g_strerror (errno); gdk_threads_enter (); window_checking_report (C2_CHECK_ERR, account->acc_name, buf); gdk_threads_leave (); goto bye_bye_server; } strmsg = g_string_new (NULL); for (i = 0;; i++) { buf = sock_read (sock, &timedout); if (!i && strnne (buf, "+OK", 3)) { buf2 = g_strdup_printf (_("The POP server of the account %s doesn't support TOP."), account->acc_name); gdk_threads_enter (); gnome_appbar_set_status (GNOME_APPBAR (WMain->appbar), buf2); gdk_threads_leave (); goto dont_use_top; } if (!i) continue; if (streq (buf, ".\r\n")) break; g_string_append (strmsg, buf); c2_free (buf); } subject = message_get_header_field (NULL, strmsg->str, "\nSubject:"); from = message_get_header_field (NULL, strmsg->str, "From:"); date = message_get_header_field (NULL, strmsg->str, "\nDate:"); kbytes = str_get_word (1, CHAR (list->data), ' '); str_strip (kbytes, '\r');str_strip (kbytes, '\n'); gdk_threads_enter (); if ((atoi (kbytes) >= config->message_bigger*1024) && (!gui_message_big_new (from, subject, date, account->acc_name, kbytes))) { gdk_threads_leave (); c2_free (list->data); list->data = NULL; download[DOWNLOAD_LIST_TOP] = g_list_remove_link (download[DOWNLOAD_LIST_TOP], list); } else gdk_threads_leave (); } } /* Learn messages to download */ if (!account->keep_copy && !config->message_bigger) { /* !UIDL AND !TOP */ download[DOWNLOAD_LIST_TOTAL] = download[DOWNLOAD_LIST_UIDL]; } else if (account->keep_copy && !config->message_bigger) { /* UIDL AND !TOP */ for (list = download[DOWNLOAD_LIST_UIDL]; list; list = list->next) { download[DOWNLOAD_LIST_TOTAL] = g_list_append (download[DOWNLOAD_LIST_TOTAL], str_get_word (0, CHAR (list->data), ' ')); } } else if (!account->keep_copy && config->message_bigger) { /* !UIDL AND TOP */ download[DOWNLOAD_LIST_TOTAL] = download[DOWNLOAD_LIST_TOP]; } else if (account->keep_copy && config->message_bigger) { /* UIDL AND TOP */ for (uidl_search = download[DOWNLOAD_LIST_UIDL]; !uidl_search; uidl_search = uidl_search->next) { for (top_search = download[DOWNLOAD_LIST_TOP]; !top_search; top_search = top_search->next) { printf ("%d %d\n", (int) uidl_search->data, (int) top_search->data); /* TODO */ } } } messages = g_list_length (download[DOWNLOAD_LIST_TOTAL]); gdk_threads_enter (); gtk_progress_configure (GTK_PROGRESS (window_checking->mail_progress), 0, 0, messages); gtk_progress_set_format_string (GTK_PROGRESS (window_checking->mail_progress), _("%p%% downloaded (%v of %u messages)")); gdk_threads_leave (); strmsg = g_string_new (NULL); message.message = message.header = NULL; for (list = download[DOWNLOAD_LIST_TOTAL]; list; list = list->next) { buf = str_get_word (0, CHAR (list->data), ' '); i = atoi (buf); c2_free (buf); /* Ask for the mail */ if (sock_printf (sock, "RETR %d\r\n", i) < 0) { buf = g_strerror (errno); gdk_threads_enter (); window_checking_report (C2_CHECK_ERR, account->acc_name, buf); gdk_threads_leave (); goto bye_bye_server; } /* Read the first line */ buf = sock_read (sock, &timedout); if (pop_check_answer (buf, account, timedout) < 0) { if (timedout) goto run_for_your_life; goto bye_bye_server; } /* Learn bytes in the messages */ sscanf (buf, "+OK %d octets\r\n", &bytes); if (bytes) { gdk_threads_enter (); gtk_progress_configure (GTK_PROGRESS (window_checking->bytes_progress), 0, 0, bytes); gtk_widget_show (window_checking->bytes_progress); gdk_threads_leave (); } else { gdk_threads_enter (); gtk_widget_hide (window_checking->bytes_progress); gdk_threads_leave (); } c2_free (buf); /* Get the mail */ reading_header = TRUE; for (;;) { buf = sock_read (sock, &timedout); if (bytes) { downloaded_bytes += strlen (buf); gdk_threads_enter (); gtk_progress_set_value (GTK_PROGRESS (window_checking->bytes_progress), downloaded_bytes); gdk_threads_leave (); } if (streq (buf, ".\r\n")) { message.message = g_strdup (strmsg->str); g_string_assign (strmsg, ""); str_strip (message.message, '\r'); break; } if (reading_header && strlen (buf) > 2) { char *buf2; buf2 = decode_8bit (buf); c2_free (buf); buf = buf2; } if (reading_header && strlen (buf) == 2) { /* Still reading header and is an empty line */ buf2 = g_strdup_printf ("X-CronosII-Account: %s\r\n", account->acc_name); g_string_append (strmsg, buf2); c2_free (buf2); reading_header = FALSE; } g_string_append (strmsg, buf); } gtk_progress_set_percentage (GTK_PROGRESS (window_checking->bytes_progress), 1); /* Write to the mail file */ mailbox = account->mailbox->name; #if USE_PLUGINS c2_dynamic_module_signal_emit (C2_DYNAMIC_MODULE_MESSAGE_DOWNLOAD_POP, &message, &mailbox, NULL, NULL, NULL); #endif mbox = search_mailbox_name (config->mailbox_head, mailbox); if (!mbox) { /* Mailbox couldn't be found, going with the default */ mbox = account->mailbox; } mid = c2_mailbox_get_next_mid (mbox); buf = c2_mailbox_mail_path (mailbox, mid); if ((mail = fopen (buf, "w")) == NULL) { gdk_threads_enter (); window_checking_report (C2_CHECK_ERR, account->acc_name, _("Error opening the file where to store the new mail")); cronos_error (errno, _("Opening the mail file"), ERROR_WARNING); gdk_threads_leave (); c2_free (buf); continue; } c2_free (buf); fprintf (mail, "%s", message.message); fclose (mail); /* Write to the index file */ buf = c2_mailbox_index_path (mailbox); if ((index = fopen (buf, "a")) == NULL) { gdk_threads_enter (); window_checking_report (C2_CHECK_ERR, account->acc_name, _("Error opening the main DB file to store the new mail")); cronos_error (errno, _("Opening the main DB file"), ERROR_WARNING); gdk_threads_leave (); c2_free (buf); goto bye_bye_server; } header[HEADER_SUBJECT] = message_get_header_field (&message, NULL, "\nSubject:"); header[HEADER_FROM] = message_get_header_field (&message, NULL, "\nFrom:"); header[HEADER_DATE] = message_get_header_field (&message, NULL, "\nDate:"); content_type = message_get_header_field (&message, NULL, "\nContent-Type:"); with_attachs = FALSE; /* if (content_type) { message_mime_parse_content_type (content_type, &type, &subtype, ¶meter); if (streq (type, "multipart")) { GList *s; MimeHash *mime; message_mime_parse (&message, NULL); for (s = message.mime; s != NULL; s = s->next) { mime = MIMEHASH (s->data); if (!mime) continue; if (strneq (mime->disposition, "attachment", 10)) with_attachs = TRUE; } } }*/ if (!header[HEADER_SUBJECT]) header[HEADER_SUBJECT] = ""; if (!header[HEADER_FROM]) header[HEADER_FROM] = ""; if (!header[HEADER_DATE]) header[HEADER_DATE] = ""; fprintf (index, "N\r\r%s\r%s\r%s\r%s\r%s\r%d\n", with_attachs ? "1" : "", header[HEADER_SUBJECT], header[HEADER_FROM], header[HEADER_DATE], account->acc_name, mid); fclose (index); c2_free (message.message); c2_free (message.header); message.message = message.header = NULL; if (!account->keep_copy) { /* Delete the message */ if (sock_printf (sock, "DELE %d\r\n", i) < 0) { buf = g_strerror (errno); gdk_threads_enter (); window_checking_report (C2_CHECK_ERR, account->acc_name, buf); gdk_threads_leave (); goto bye_bye_server; } buf = sock_read (sock, &timedout); if (pop_check_answer (buf, account, timedout) < 0) { if (timedout) goto run_for_your_life; goto bye_bye_server; } } if (streq (selected_mbox, mailbox)) { row[0] = ""; row[1] = ""; row[2] = ""; row[3] = header[HEADER_SUBJECT]; row[4] = header[HEADER_FROM]; row[5] = header[HEADER_DATE]; row[6] = account->acc_name; row[7] = g_strdup_printf ("%d", mid); gdk_threads_enter (); gtk_clist_freeze (GTK_CLIST (WMain->clist)); gtk_clist_append (GTK_CLIST (WMain->clist), row); style = gtk_widget_get_style (WMain->clist); style2 = gtk_style_copy (style); style2->font = font_unread; gtk_clist_set_row_style (GTK_CLIST (WMain->clist), GTK_CLIST (WMain->clist)->rows-1, style2); gtk_clist_set_pixmap (GTK_CLIST (WMain->clist), GTK_CLIST (WMain->clist)->rows-1, 0, pixmap_unread, mask_unread); if (with_attachs) gtk_clist_set_pixmap (GTK_CLIST (WMain->clist), GTK_CLIST (WMain->clist)->rows-1, 2, pixmap_attach, mask_attach); new_messages++; gtk_clist_thaw (GTK_CLIST (WMain->clist)); gtk_clist_set_row_data (GTK_CLIST (WMain->clist), GTK_CLIST (WMain->clist)->rows-1, (gpointer) "N"); update_wm_title (); gtk_progress_set_value (GTK_PROGRESS (window_checking->mail_progress), i); gdk_threads_leave (); clisted = TRUE; } gdk_threads_enter (); gtk_progress_set_value (GTK_PROGRESS (window_checking->mail_progress), gtk_progress_get_value (GTK_PROGRESS (window_checking->mail_progress))+1); gdk_threads_leave (); } if (supports_uidl) { GList *llist; for (llist = download[DOWNLOAD_LIST_UIDL]; llist != NULL; llist = llist->next) { char *uidl; uidl = CHAR (llist->data); buf2 = str_get_word (1, uidl, ' '); buf3 = str_strip (buf2, '\r'); buf2 = str_strip (buf3, '\n'); if (buf2) { uidl_register (buf2, account->acc_name); } } } if (messages != 1) buf = g_strdup_printf (_("%d messages downloaded."), messages); else buf = g_strdup_printf (_("1 message downloaded.")); gdk_threads_enter (); gtk_progress_configure (GTK_PROGRESS (window_checking->mail_progress), messages, 0, messages); gtk_progress_set_format_string (GTK_PROGRESS (window_checking->mail_progress), buf); window_checking_report (C2_CHECK_OK, account->acc_name, buf); gdk_threads_leave (); bye_bye_server: if (sock_printf (sock, "QUIT\r\n") < 0) { buf = g_strerror (errno); } buf = sock_read (sock, &timedout); if (pop_check_answer (buf, account, timedout) < 0) { if (timedout) goto run_for_your_life; } run_for_your_life: close (sock); return NULL; }
void DIA_encoding::setFrame(uint32_t nb,uint32_t total) { uint32_t tim; assert(dialog); sprintf(string,"%lu/%lu",nb,total); gtk_label_set_text(GTK_LABEL(WID(label_frame)),string); // // nb/total=timestart/totaltime -> total time =timestart*total/nb // // if(nb==0) // restart ? { clock.reset(); _lastTime=clock.getElapsedMS();; _lastFrame=0; _fps_average=0; UI_purge(); return; } tim=clock.getElapsedMS();; // printf("%lu / %lu\n",tim,_lastTime); if(_lastTime > tim) return; if( tim-_lastTime < 1000) return ; // refresh every 3 seconds if(tim) { double d; uint32_t fps; // compute fps uint32_t deltaFrame, deltaTime; deltaTime=tim-_lastTime; deltaFrame=nb-_lastFrame; if(deltaTime>500) { d=deltaTime; d=1/d; d*=deltaFrame; d*=1000.; fps=(uint32_t)floor(d); sprintf(string,"%lu",fps); gtk_label_set_text(GTK_LABEL(WID(label_fps)),string); } uint32_t sectogo,secdone; uint32_t hh,mm,ss; secdone = tim; d = secdone; d /= nb; d*=total; d -= secdone; _lastTime=tim; tim=(uint32_t)floor(d); ms2time(tim,&hh,&mm,&ss); sprintf(string,"%02d:%02d:%02d",hh,mm,ss); gtk_label_set_text(GTK_LABEL(WID(label_eta)),string); } // update progress bar float f=nb; f=f/total; gtk_progress_set_percentage(GTK_PROGRESS(WID(progressbar1)),(gfloat)f); _lastFrame=nb; UI_purge(); }
int op_progress (void *data) { int reporttype; int reportpipe; int actionpipe; panel *p; int readresult; int pd; GtkWidget *progress_path_label; GtkWindow *progress_dialog; GtkProgress *progress_bar; gtk_param_unpack (data, "iipppp", &reportpipe, &actionpipe, &p, &progress_path_label, &progress_dialog, &progress_bar); pd = (int) reportpipe; while ( (readresult = read(pd, &reporttype, sizeof(int))) > 0) { if (readresult > 0) { if (reporttype == 0) { /* Operation completed */ free (data); wait (NULL); panel_selectnone (p); panel_refresh (p->next, 1); panel_refresh (p, 1); gtk_widget_destroy (GTK_WIDGET(progress_dialog)); panel_enable (p->next); panel_enable (p); p->operation_busy = 0; p->next->operation_busy = 0; return (0); } else if (reporttype == 1) { /* Operation progress report */ int percent; char *path; op_progress_readprogress (pd, &percent, &path); gtk_label_set_text(GTK_LABEL(progress_path_label), path); gtk_entry_set_text (GTK_ENTRY(p->info), path); gtk_progress_set_percentage (GTK_PROGRESS(progress_bar), (double)(percent)/100); free (path); } else if (reporttype == 2) { /* Error */ int errornr; int action = 0; char *path; op_progress_readerror (pd, &errornr, &path); dialog_report_error ("Error operating on\n", path, strerror (errornr), &action); write (actionpipe, &action, sizeof(int)); free (path); } } } return (1); }
GtkWidget *create_dialog1 (uint32_t max, float *value) { GtkWidget *dialog1; GtkWidget *dialog_vbox1; GtkWidget *table1; GtkWidget *label1; GtkWidget *label2; GtkWidget *progressbar1; GtkWidget *progressbar2; GtkWidget *dialog_action_area1; GtkWidget *okbutton1; dialog1 = gtk_dialog_new (); gtk_window_set_title (GTK_WINDOW (dialog1), "Bitrate Histogram"); dialog_vbox1 = GTK_DIALOG (dialog1)->vbox; gtk_widget_show (dialog_vbox1); table1 = gtk_table_new (20, 2, FALSE); gtk_widget_show (table1); gtk_box_pack_start (GTK_BOX (dialog_vbox1), table1, TRUE, TRUE, 0); /*----*/ char string[200]; float p; for(int j=0; j<20; j++) { sprintf(string,"%05d kbps :",(max*j)/20); label1 = gtk_label_new (string); gtk_widget_show (label1); gtk_table_attach (GTK_TABLE (table1), label1, 0, 1, 20-j-1, 20-j, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_label_set_justify (GTK_LABEL (label1), GTK_JUSTIFY_LEFT); gtk_misc_set_alignment (GTK_MISC (label1), 0, 0.5); gtk_widget_set_usize(label1,100,-1); progressbar1 = gtk_progress_bar_new (); gtk_widget_show (progressbar1); gtk_table_attach (GTK_TABLE (table1), progressbar1, 1, 2, 20-j-1, 20-j, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); p=value[j]; p=p/100.; gtk_progress_set_percentage(GTK_PROGRESS(progressbar1),(gfloat)p); } dialog_action_area1 = GTK_DIALOG (dialog1)->action_area; gtk_widget_show (dialog_action_area1); gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area1), GTK_BUTTONBOX_END); okbutton1 = gtk_button_new_from_stock ("gtk-ok"); gtk_widget_show (okbutton1); gtk_dialog_add_action_widget (GTK_DIALOG (dialog1), okbutton1, GTK_RESPONSE_OK); GTK_WIDGET_SET_FLAGS (okbutton1, GTK_CAN_DEFAULT); /* Store pointers to all widgets, for use by lookup_widget(). */ GLADE_HOOKUP_OBJECT_NO_REF (dialog1, dialog1, "dialog1"); GLADE_HOOKUP_OBJECT_NO_REF (dialog1, dialog_vbox1, "dialog_vbox1"); GLADE_HOOKUP_OBJECT (dialog1, table1, "table1"); GLADE_HOOKUP_OBJECT_NO_REF (dialog1, dialog_action_area1, "dialog_action_area1"); GLADE_HOOKUP_OBJECT (dialog1, okbutton1, "okbutton1"); return dialog1; }
void DIA_encoding::updateUI(void) { uint32_t tim; ADM_assert(dialog); // // nb/total=timestart/totaltime -> total time =timestart*total/nb // // if(!_lastnb) return; tim=clock.getElapsedMS(); if(_lastTime > tim) return; if( tim < _nextUpdate) return ; _nextUpdate = tim+GUI_UPDATE_RATE; sprintf(string,"%lu",_lastnb); gtk_label_set_text(GTK_LABEL(WID(label_frame)),string); sprintf(string,"%lu",_total); gtk_label_set_text(GTK_LABEL(WID(label_totalframe)),string); // Average bitrate on the last second uint32_t sum=0,aquant=0,gsum; for(int i=0;i<_roundup;i++) { sum+=_bitrate[i].size; aquant+=_bitrate[i].quant; } aquant/=_roundup; sum=(sum*8)/1000; // Now compute global average bitrate float whole=_videoSize,second; second=_lastnb; second/=_fps1000; second*=1000; whole/=second; whole/=1000; whole*=8; gsum=(uint32_t)whole; setBitrate(sum,gsum); setQuantIn(aquant); // compute fps uint32_t deltaFrame, deltaTime; deltaTime=tim-_lastTime; deltaFrame=_lastnb-_lastFrame; _fps_average =(float)( deltaFrame*1000.0F / deltaTime ); sprintf(string,"%.2f",_fps_average); gtk_label_set_text(GTK_LABEL(WID(label_fps)),string); uint32_t hh,mm,ss; double framesLeft=(_total-_lastnb); ms2time(tim,&hh,&mm,&ss); sprintf(string,"%02d:%02d:%02d",hh,mm,ss); gtk_label_set_text(GTK_LABEL(WID(label_elapsed)),string); gtk_label_set_text(GTK_LABEL(WID(label_eta)), ms2timedisplay((uint32_t) floor(0.5 + deltaTime * framesLeft / deltaFrame))); // Check if we should move on to the next sample period if (tim >= _nextSampleStartTime + ETA_SAMPLE_PERIOD ) { _lastTime=_nextSampleStartTime; _lastFrame=_nextSampleStartFrame; _nextSampleStartTime=tim; _nextSampleStartFrame=0; } else if (tim >= _nextSampleStartTime && _nextSampleStartFrame == 0 ) { // Store current point for use later as the next sample period. // _nextSampleStartTime=tim; _nextSampleStartFrame=_lastnb; } // update progress bar float f=_lastnb; f=f/_total; if(tray) tray->setPercent((int)(f*100.)); gtk_progress_set_percentage(GTK_PROGRESS(WID(progressbar1)),(gfloat)f); sprintf(string,QT_TR_NOOP("%d%%"),(int)(100*f)); if(isQuiet()) printf("[Encoding]%s\n",string); gtk_progress_bar_set_text (GTK_PROGRESS_BAR(WID(progressbar1)), string); _totalSize=_audioSize+_videoSize; setSize(_totalSize>>20); setAudioSizeIn((_audioSize>>20)); setVideoSizeIn((_videoSize>>20)); UI_purge(); }
void perform_uninstall_slot(GtkWidget* w, gpointer data) { GtkWidget *notebook; GtkWidget *progress; GtkWidget *widget; GList *list, *poopy, *clist; GtkWidget *button; component_list *component; size_t size, total; char text[1024]; const char *message; /* Set through environment to hide questions, and assume Yes */ int show_messages; const char *env; show_messages = 1; env = getenv("SETUP_NO_PROMPT"); if ( env && atoi(env) ) show_messages = 0; /* First switch to the next notebook page */ notebook = glade_xml_get_widget(uninstall_glade, "uninstall_notebook"); gtk_notebook_set_page(GTK_NOTEBOOK(notebook), 1); widget = glade_xml_get_widget(uninstall_glade, "finished_button"); if ( widget ) { gtk_button_set_sensitive(widget, FALSE); } /* Now uninstall all the selected components */ progress = glade_xml_get_widget(uninstall_glade, "uninstall_progress"); size = 0; total = calculate_recovered_space(); widget = glade_xml_get_widget(uninstall_glade, "uninstall_vbox"); list = gtk_container_children(GTK_CONTAINER(widget)); while ( list && ! uninstall_cancelled ) { widget = GTK_WIDGET(list->data); poopy = gtk_container_children(GTK_CONTAINER(widget)); widget = GTK_WIDGET(poopy->data); /* First do the addon components */ clist = gtk_container_children(GTK_CONTAINER(widget)); while ( clist && ! uninstall_cancelled ) { button = GTK_WIDGET(clist->data); if ( gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)) ) { component = gtk_object_get_data(GTK_OBJECT(button), "data"); if ( loki_isdefault_component(component->component) ) { clist = clist->next; continue; } /* Put up the status */ snprintf(text, sizeof(text), "%s: %s", component->info->description, loki_getname_component(component->component)); set_status_text(text); /* See if the user wants to cancel the uninstall */ while( gtk_events_pending() ) { gtk_main_iteration(); } /* Display an optional message to the user */ message = loki_getmessage_component(component->component); if (show_messages && message && !display_message(message, BUTTON_OK|BUTTON_ABORT) ) { clist = clist->next; uninstall_cancelled = 1; break; } /* Remove the component */ if ( ! uninstall_component(component->component, component->info) ) { uninstall_cancelled = 2; snprintf(text, sizeof(text), _("Uninstallation of component %s has failed!\n" "The whole uninstallation may be incomplete.\n"), loki_getname_component(component->component)); display_message(text, BUTTON_ABORT); break; } /* Update the progress bar */ if ( total && progress ) { size += component->size/1024; gtk_progress_set_percentage(GTK_PROGRESS(progress), (float)size/total); } gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), FALSE); /* See if the user wants to cancel the uninstall */ while( gtk_events_pending() ) { gtk_main_iteration(); } } clist = clist->next; } /* Now do the primary components */ clist = gtk_container_children(GTK_CONTAINER(widget)); while ( clist && ! uninstall_cancelled ) { button = GTK_WIDGET(clist->data); if ( gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)) ) { component = gtk_object_get_data(GTK_OBJECT(button), "data"); if ( ! loki_isdefault_component(component->component) ) { clist = clist->next; continue; } /* Put up the status */ strncpy(text, component->info->description, sizeof(text)); set_status_text(text); /* See if the user wants to cancel the uninstall */ while( gtk_events_pending() ) { gtk_main_iteration(); } /* Display an optional message to the user */ message = loki_getmessage_component(component->component); if ( message && !display_message(message, BUTTON_OK|BUTTON_ABORT) ) { clist = clist->next; uninstall_cancelled = 1; break; } /* Remove the component */ if ( ! perform_uninstall(component->product, component->info, 0) ) { uninstall_cancelled = 2; snprintf(text, sizeof(text), _("Uninstallation of product %s has failed!\n" "Aborting the rest of the uninstallation.\n"), component->info->description); display_message(text, BUTTON_ABORT); break; } remove_product(component->product); /* Update the progress bar */ if ( total && progress ) { size += component->size/1024; gtk_progress_set_percentage(GTK_PROGRESS(progress), (float)size/total); } /* See if the user wants to cancel the uninstall */ while( gtk_events_pending() ) { gtk_main_iteration(); } break; } clist = clist->next; } list = list->next; } switch ( uninstall_cancelled ) { case 1: set_status_text(_("Uninstall cancelled")); break; case 2: set_status_text(_("Uninstall aborted")); break; default: set_status_text(_("Uninstall complete")); gtk_progress_set_percentage(GTK_PROGRESS(progress), 1.0f); break; } widget = glade_xml_get_widget(uninstall_glade, "cancel_button"); if ( widget ) { gtk_button_set_sensitive(widget, FALSE); } widget = glade_xml_get_widget(uninstall_glade, "finished_button"); if ( widget ) { gtk_button_set_sensitive(widget, TRUE); } }
void DIA_encoding::setFrame(uint32_t nb,uint32_t total) { uint32_t tim; #define ETA_SAMPLE_PERIOD 60000 //Use last n millis to calculate ETA #define GUI_UPDATE_RATE 500 static uint32_t _lastnb=0; ADM_assert(dialog); // // nb/total=timestart/totaltime -> total time =timestart*total/nb // // if(nb < _lastnb || _lastnb == 0) // restart ? { _lastnb = nb; clock.reset(); _lastTime=clock.getElapsedMS(); _lastFrame=0; _fps_average=0; _nextUpdate = _lastTime + GUI_UPDATE_RATE; _nextSampleStartTime=_lastTime + ETA_SAMPLE_PERIOD; _nextSampleStartFrame=0; if(tray) tray->setPercent(0); UI_purge(); return; } _lastnb = nb; tim=clock.getElapsedMS(); // printf("%lu / %lu\n",tim,_lastTime); if(_lastTime > tim) return; if( tim < _nextUpdate) return ; _nextUpdate = tim+GUI_UPDATE_RATE; sprintf(string,"%lu/%lu",nb,total); gtk_label_set_text(GTK_LABEL(WID(label_frame)),string); // compute fps uint32_t deltaFrame, deltaTime; deltaTime=tim-_lastTime; deltaFrame=nb-_lastFrame; sprintf(string,"%lu",(uint32_t)( deltaFrame*1000.0 / deltaTime )); gtk_label_set_text(GTK_LABEL(WID(label_fps)),string); uint32_t hh,mm,ss; double framesLeft=(total-nb); ms2time((uint32_t)floor(0.5+deltaTime*framesLeft/deltaFrame),&hh,&mm,&ss); sprintf(string,"%02d:%02d:%02d",hh,mm,ss); gtk_label_set_text(GTK_LABEL(WID(label_eta)),string); // Check if we should move on to the next sample period if (tim >= _nextSampleStartTime + ETA_SAMPLE_PERIOD ) { _lastTime=_nextSampleStartTime; _lastFrame=_nextSampleStartFrame; _nextSampleStartTime=tim; _nextSampleStartFrame=0; } else if (tim >= _nextSampleStartTime && _nextSampleStartFrame == 0 ) { // Store current point for use later as the next sample period. // _nextSampleStartTime=tim; _nextSampleStartFrame=nb; } // update progress bar float f=nb; f=f/total; if(tray) tray->setPercent((int)(f*100.)); gtk_progress_set_percentage(GTK_PROGRESS(WID(progressbar1)),(gfloat)f); sprintf(string,"Done : %02d%%",(int)(100*f)); if(isQuiet()) printf("[Encoding]%s\n",string); gtk_progress_bar_set_text (GTK_PROGRESS_BAR(WID(progressbar1)), string); UI_purge(); }
void GUI_encoderSetFrame(uint32_t nb,uint32_t total) { uint32_t tim; static char str[100]; //float ratio; //uint32_t mm,ss; if(window) { sprintf(str,"%08lu / %08lu ",nb,total); gtk_label_set_text(GTK_LABEL(label_frame),str); if(nb==0) // restart ? { timestart=getTime(0); lastTime=timestart; lastFrame=0; fps_average=0; } tim=getTime(1)-timestart; // // nb/total=timestart/totaltime -> total time =timestart*total/nb // // if(nb&&tim) { //--- uint32_t sectogo,secdone; double d; // float f; int mm,ss; secdone = getTime(1) - timestart;; d = secdone; d /= nb; d*=total; d -= secdone; // d is in ms, divide by 1000 to get seconds sectogo = (uint32_t) floor(d / 1000.); mm=sectogo/60; ss=sectogo%60; sprintf(str,"%03u m %02u s left ",mm,ss); gtk_label_set_text(GTK_LABEL(label_eta),str); } // update progress bar float f=nb; f=f/total; gtk_progress_set_percentage(GTK_PROGRESS(progressbar1),(gfloat)f); /* Compute FPS */ if(getTime(1)>(lastTime+1000)) // one second has elapsed { /* fps = 1000* delta frame / delta ms */ double fps; double framepersec; fps=getTime(1)-lastTime; if(fps) { framepersec=(nb-lastFrame); framepersec/=fps; framepersec*=1000.; if(lastTime==0) { fps_average=(uint32_t)floor(framepersec); } fps_average=fps_average*9+(uint32_t)floor(framepersec); fps_average=(fps_average+4)/10; // printf("\n fps= %02.2f",fps); sprintf(str," %02ld ",fps_average); gtk_label_set_text(GTK_LABEL(label_fps),str); lastTime=getTime(1); lastFrame=nb; } } while (gtk_events_pending()) { gtk_main_iteration(); } } }