1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
|
/*
Copyright (C) 2000 Paul Wilkins
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* status.c by Paul Wilkins 1/2/2000 */
#include <stdio.h>
#include <gtk/gtk.h>
#include <gdk_imlib.h>
#include "globals.h"
#include "status.h"
GtkWidget *mode_display;
GtkWidget *progress_bar;
void toggle_progress_indicator(int onoff){
if(onoff == ST_PERCENT){
gtk_progress_set_format_string(GTK_PROGRESS(progress_bar), "%p%%");
gtk_progress_bar_update(GTK_PROGRESS_BAR(progress_bar), 0.0);
gtk_progress_set_activity_mode(GTK_PROGRESS(progress_bar), FALSE);
gtk_progress_set_show_text(GTK_PROGRESS(progress_bar), TRUE);
} else if(onoff == ST_PROGRESS){
gtk_progress_set_format_string(GTK_PROGRESS(progress_bar), "%p%%");
gtk_progress_bar_update(GTK_PROGRESS_BAR(progress_bar), 0.0);
gtk_progress_set_activity_mode(GTK_PROGRESS(progress_bar), TRUE);
gtk_progress_set_show_text(GTK_PROGRESS(progress_bar), FALSE);
} else if(onoff == ST_READY){
gtk_progress_set_format_string(GTK_PROGRESS(progress_bar), "Ready");
gtk_progress_bar_update(GTK_PROGRESS_BAR(progress_bar), 0.0);
gtk_progress_set_activity_mode(GTK_PROGRESS(progress_bar), FALSE);
gtk_progress_set_show_text(GTK_PROGRESS(progress_bar), TRUE);
} else {
fprintf(stderr, "toggle_progress_indicator: onoff invalid\n");
exit(1);
}
/* force an update NOW */
gtk_widget_draw(GTK_WIDGET(progress_bar), NULL);
gdk_flush();
}
void set_progress_indicator(double val){
static int last_percent = -1;
/* don't bother updating if we haven't changed by al least 1 percent */
if(last_percent == (int)(100.0*val)) return;
last_percent = (int)(100.0*val);
gtk_progress_bar_update(GTK_PROGRESS_BAR(progress_bar), val);
/* force an update NOW */
gtk_widget_draw(GTK_WIDGET(progress_bar), NULL);
gdk_flush();
}
void refresh_mode_display(){
char buf[256];
if(globals.cur_opt.opt_alg == PIX_SIZE){
sprintf(buf, " Size of images: %dx%d",
globals.cur_opt.pixW, globals.cur_opt.pixH);
} else {
sprintf(buf, " Number of Images: %dx%d",
globals.cur_opt.nPixW, globals.cur_opt.nPixH);
}
gtk_label_set(GTK_LABEL(mode_display), buf);
}
GtkWidget *setup_status(GtkWidget *parent){
GtkWidget *hbox;
/* create the hbox that will hold our widgets */
hbox = gtk_hbox_new(FALSE, 0);
gtk_box_pack_end(GTK_BOX(parent), hbox, FALSE, FALSE, 0);
gtk_widget_show(hbox);
/* first is a progressbar */
progress_bar = gtk_progress_bar_new();
/* Set the progress bar format */
gtk_progress_bar_set_bar_style(GTK_PROGRESS_BAR(progress_bar),
GTK_PROGRESS_CONTINUOUS);
gtk_progress_bar_set_orientation(GTK_PROGRESS_BAR(progress_bar),
GTK_PROGRESS_LEFT_TO_RIGHT);
gtk_progress_set_activity_mode(GTK_PROGRESS(progress_bar), FALSE);
gtk_progress_set_show_text(GTK_PROGRESS(progress_bar), TRUE);
toggle_progress_indicator(ST_READY);
gtk_box_pack_start(GTK_BOX(hbox), progress_bar, FALSE, FALSE, 0);
gtk_widget_show(progress_bar);
/* now a label to display stuff */
mode_display = gtk_label_new(" ");
gtk_box_pack_start(GTK_BOX(hbox), mode_display, FALSE, FALSE, 0);
gtk_widget_show(mode_display);
/* set the string */
refresh_mode_display();
return hbox;
}
|