Exemplo n.º 1
0
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);
    }
}
Exemplo n.º 2
0
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);
    }

}
Exemplo n.º 3
0
Arquivo: xqf-ui.c Projeto: IR4T4/xqf
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);
}
Exemplo n.º 4
0
Arquivo: xqf-ui.c Projeto: IR4T4/xqf
static int progress_bar_timeout_callback (GtkWidget *pbar) {
	gfloat new_val;
	GtkAdjustment *adj;

	adj = GTK_PROGRESS (pbar)->adjustment;

	new_val = adj->value + 1;
	if (new_val > adj->upper)
		new_val = adj->lower;

	gtk_progress_set_value (GTK_PROGRESS (pbar), new_val);

	return TRUE;
}
Exemplo n.º 5
0
/* Controls the alignment of the text within the progress bar area. */
int
clip_GTK_PROGRESSSETTEXTALIGNMENT(ClipMachine * cm)
{
	C_widget *cprg = _fetch_cw_arg(cm);
	gfloat x_align = _clip_parnd(cm,2);
	gfloat y_align = _clip_parnd(cm,2);
        CHECKCWID(cprg,GTK_IS_PROGRESS);
	CHECKOPT(2,NUMERIC_t); CHECKOPT(3,NUMERIC_t);
        if (_clip_parinfo(cm,2)==UNDEF_t) x_align = GTK_PROGRESS(cprg->widget)->x_align;
        if (_clip_parinfo(cm,3)==UNDEF_t) y_align = GTK_PROGRESS(cprg->widget)->y_align;
        gtk_progress_set_text_alignment(GTK_PROGRESS(cprg->widget), x_align, y_align);
	return 0;
err:
	return 1;
}
Exemplo n.º 6
0
Arquivo: xqf-ui.c Projeto: IR4T4/xqf
void progress_bar_start (GtkWidget *pbar, int activity_mode) {
	struct pbarinfo *info;

	progress_bar_reset (pbar);

	if (activity_mode) {
		info = gtk_object_get_user_data (GTK_OBJECT (pbar));
		info->activity_mode = TRUE;
		info->timeout_id = gtk_timeout_add (100, (GtkFunction) progress_bar_timeout_callback, pbar);
		gtk_progress_set_activity_mode (GTK_PROGRESS (pbar), TRUE);
	}
	else {
		gtk_progress_set_show_text (GTK_PROGRESS (pbar), TRUE);
	}
}
Exemplo n.º 7
0
Arquivo: xqf-ui.c Projeto: IR4T4/xqf
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);
}
Exemplo n.º 8
0
gint timeout_command (gpointer data)
{
  datastruct * ds = (datastruct * )data;
  char * strbuf=NULL;
  int time_current=time_max-(time(NULL)-start_time);

  gtk_progress_configure(GTK_PROGRESS(ds->progress),
			 (float)time_current / (float)time_max * 100.0,
			 0.0, 100);
  asprintf (&strbuf, "%i:%.2i",
	    time_current / 60,
	    time_current % 60);

  gtk_label_set_text (GTK_LABEL(ds->text), strbuf);
  free (strbuf);

  if (time_current < timeout[current_timeout].threshold)
    {
      system(timeout[current_timeout].command);
      current_timeout++;
      if (!timeout[current_timeout].command)
	exit (1);
    }

  return 1;
}
Exemplo n.º 9
0
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;
	}
}
Exemplo n.º 11
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;
        }
    }
}
Exemplo n.º 12
0
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;
}
Exemplo n.º 13
0
int my_progress_func(GtkWidget *Bar, int t, int d)
{
/*  printf("%d / %d (%g %%)\n", d, t, d*100.0/t);*/
  gdk_threads_enter();
  gtk_progress_set_value(GTK_PROGRESS(Bar), d*100.0/t);
  gdk_threads_leave();
  return 0;
}
Exemplo n.º 14
0
void
finish_operation(FormatDialog* dialog)
{
	dialog->ops_left = 0;
	gtk_progress_set_value(GTK_PROGRESS(dialog->progress_bar), 0.0);
	gtk_progress_bar_set_text(dialog->progress_bar, "");

	update_dialog(dialog);
}
Exemplo n.º 15
0
void
CreateItems(datastruct * ds, GtkWidget *vbox)
{
  ds->progress = gtk_progress_bar_new();
  gtk_progress_bar_set_bar_style(GTK_PROGRESS_BAR (ds->progress), GTK_PROGRESS_CONTINUOUS);
  gtk_progress_set_format_string(GTK_PROGRESS(ds->progress), "%v%%");
  gtk_progress_set_show_text(GTK_PROGRESS(ds->progress), TRUE);
  gtk_box_pack_start(GTK_BOX(vbox), ds->progress, TRUE, TRUE, FALSE);
  gtk_widget_show(ds->progress);

  ds->text = gtk_label_new("time");
  gtk_box_pack_start(GTK_BOX(vbox), ds->text,
		     TRUE,
		     TRUE,
		     FALSE);
  gtk_widget_show(ds->text);
  return ;
}
Exemplo n.º 16
0
static GtkWidget *
progressbar_new(GladeXML *xml, GladeWidgetInfo *info)
{
	GtkWidget *ret = gtk_progress_bar_new();
	GList *tmp;
	gfloat value = 0, lower = 0, upper = 100;
	gfloat xalign = 0.5, yalign = 0.5;

	for (tmp = info->attributes; tmp; tmp = tmp->next) {
		GladeAttribute *attr = tmp->data;

		if (!strcmp(attr->name, "value"))
			value = g_strtod(attr->value, NULL);
		else if (!strcmp(attr->name, "lower"))
			lower = g_strtod(attr->value, NULL);
		else if (!strcmp(attr->name, "upper"))
			upper = g_strtod(attr->value, NULL);
		else if (!strcmp(attr->name, "activity_mode"))
			gtk_progress_set_activity_mode(GTK_PROGRESS(ret),
						       attr->value[0]=='T');
		else if (!strcmp(attr->name, "bar_style"))
			gtk_progress_bar_set_bar_style(GTK_PROGRESS_BAR(ret),
			    glade_enum_from_string(GTK_TYPE_PROGRESS_BAR_STYLE,
						   attr->value));
		else if (!strcmp(attr->name, "orientation"))
			gtk_progress_bar_set_orientation(GTK_PROGRESS_BAR(ret),
			    glade_enum_from_string(
			      GTK_TYPE_PROGRESS_BAR_ORIENTATION, attr->value));
		else if (!strcmp(attr->name, "show_text"))
			gtk_progress_set_show_text(GTK_PROGRESS(ret),
						   attr->value[0] == 'T');
		else if (!strcmp(attr->name, "text_xalign"))
			xalign = g_strtod(attr->value, NULL);
		else if (!strcmp(attr->name, "text_yalign"))
			yalign = g_strtod(attr->value, NULL);
		else if (!strcmp(attr->name, "format"))
			gtk_progress_set_format_string(GTK_PROGRESS(ret),
						       attr->value);
	}
	gtk_progress_configure(GTK_PROGRESS(ret), value, lower, upper);
	gtk_progress_set_text_alignment(GTK_PROGRESS(ret), xalign, yalign);
	return ret;
}
Exemplo n.º 17
0
/* Returns the current progress as a percentage. */
int
clip_GTK_PROGRESSGETCURRENTPERCENTAGE(ClipMachine * cm)
{
	C_widget *cprg = _fetch_cw_arg(cm);
        CHECKCWID(cprg,GTK_IS_PROGRESS);
        _clip_retnd(cm,gtk_progress_get_current_percentage(GTK_PROGRESS(cprg->widget)));
	return 0;
err:
	return 1;
}
Exemplo n.º 18
0
/* Returns the current progress complete value. */
int
clip_GTK_PROGRESSGETVALUE(ClipMachine * cm)
{
	C_widget    *cprg = _fetch_cw_arg(cm);
        CHECKCWID(cprg,GTK_IS_PROGRESS);
        _clip_retnd(cm,gtk_progress_get_value(GTK_PROGRESS(cprg->widget)));
	return 0;
err:
	return 1;
}
Exemplo n.º 19
0
void create_scene_detection_window()
{
	GtkWidget *vbox, *button;

	scene_detection_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	vbox = gtk_vbox_new(FALSE, 5);

	gtk_window_set_title (GTK_WINDOW(scene_detection_window),
		"Linux Video Studio - Scene detection");
	gtk_container_set_border_width (GTK_CONTAINER (scene_detection_window), 20);

	scene_detection_status_label = gtk_label_new(" ");
	gtk_box_pack_start (GTK_BOX (vbox), scene_detection_status_label,
		FALSE,FALSE, 10);
	gtk_widget_show (scene_detection_status_label);

	scene_detection_bar = gtk_progress_bar_new();
	gtk_box_pack_start (GTK_BOX (vbox), scene_detection_bar,
		FALSE, FALSE, 0);
	gtk_progress_bar_set_orientation(GTK_PROGRESS_BAR(scene_detection_bar),
		GTK_PROGRESS_LEFT_TO_RIGHT);
	gtk_progress_bar_set_bar_style(GTK_PROGRESS_BAR(scene_detection_bar),
		GTK_PROGRESS_CONTINUOUS);
	gtk_progress_set_show_text(GTK_PROGRESS(scene_detection_bar), 1);
	gtk_progress_set_format_string(GTK_PROGRESS(scene_detection_bar), "%p\%");
	gtk_widget_show(scene_detection_bar);

	button = gtk_button_new();
	gtk_signal_connect(GTK_OBJECT(button), "clicked",
		(GtkSignalFunc)stop_scene_detection_process, NULL);
	scene_detection_button_label = gtk_label_new(" Cancel ");
	gtk_container_add (GTK_CONTAINER (button), scene_detection_button_label);
	gtk_widget_show(scene_detection_button_label);
	gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
	gtk_widget_show(button);

	gtk_container_add (GTK_CONTAINER (scene_detection_window), vbox);
	gtk_widget_show(vbox);

	gtk_grab_add(scene_detection_window);
	gtk_widget_show(scene_detection_window);
}
Exemplo n.º 20
0
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);
}
Exemplo n.º 21
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);
}
Exemplo n.º 22
0
int
clip_GTK_PROGRESSGETADJUSTMENT(ClipMachine * cm)
{
	C_widget *cprg = _fetch_cw_arg(cm);
	C_widget *cadj;
	CHECKCWID(cprg,GTK_IS_PROGRESS);
	cadj = _get_cwidget(cm,GTK_WIDGET(GTK_PROGRESS(cprg->widget)->adjustment));
	if (cadj) _clip_mclone(cm,RETPTR(cm),&cadj->obj);
	return 0;
err:
	return 1;
}
Exemplo n.º 23
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;
}
Exemplo n.º 24
0
/* Sets the value within the GtkProgress to an absolute value. The value must
* be within the valid range of values for the underlying GtkAdjustment. */
int
clip_GTK_PROGRESSSETVALUE(ClipMachine * cm)
{
	C_widget    *cprg = _fetch_cw_arg(cm);
	gfloat      value = _clip_parnd(cm,2);
        CHECKCWID(cprg,GTK_IS_PROGRESS);
	CHECKOPT(2,NUMERIC_t);
        gtk_progress_set_value(GTK_PROGRESS(cprg->widget), value);
	return 0;
err:
	return 1;
}
Exemplo n.º 25
0
/* Returns the progress as a percentage calculated
 * from the supplied absolute progress value. */
int
clip_GTK_PROGRESSGETPERCENTAGEFROMVALUE(ClipMachine * cm)
{
	C_widget *cprg = _fetch_cw_arg(cm);
	gfloat   value = _clip_parnd(cm,2);
        CHECKCWID(cprg,GTK_IS_PROGRESS);
	CHECKOPT(2,NUMERIC_t);
        _clip_retnd(cm,gtk_progress_get_percentage_from_value(GTK_PROGRESS(cprg->widget),value));
	return 0;
err:
	return 1;
}
Exemplo n.º 26
0
/* Controls whether progress text is shown. */
int
clip_GTK_PROGRESSSETSHOWTEXT(ClipMachine * cm)
{
	C_widget *cprg = _fetch_cw_arg(cm);
	gint      show = BOOL_OPTION(cm,2,TRUE);
        CHECKCWID(cprg,GTK_IS_PROGRESS);
	CHECKOPT(2,LOGICAL_t);
        gtk_progress_set_show_text(GTK_PROGRESS(cprg->widget), show);
	return 0;
err:
	return 1;
}
Exemplo n.º 27
0
Arquivo: curlgtk.c Projeto: 2px/curl
int my_progress_func(GtkWidget *bar,
                     double t, /* dltotal */
                     double d, /* dlnow */
                     double ultotal,
                     double ulnow)
{
/*  printf("%d / %d (%g %%)\n", d, t, d*100.0/t);*/
  gdk_threads_enter();
  gtk_progress_set_value(GTK_PROGRESS(bar), d*100.0/t);
  gdk_threads_leave();
  return 0;
}
Exemplo n.º 28
0
/* Associates a GtkAdjustment with the GtkProgress. A GtkAdjustment is used
 * to represent the upper and lower bounds and the step interval of the
 * underlying value for which progress is shown. */
int
clip_GTK_PROGRESSSETADJUSTMENT(ClipMachine * cm)
{
	C_widget *cprg = _fetch_cw_arg(cm);
	C_widget *cadj = _fetch_cwidget(cm,_clip_spar(cm,2));
        CHECKCWID(cprg,GTK_IS_PROGRESS);
        CHECKOPT2(2,MAP_t,NUMERIC_t); CHECKCWID(cadj,GTK_IS_ADJUSTMENT);
        gtk_progress_set_adjustment(GTK_PROGRESS(cprg->widget),GTK_ADJUSTMENT(cadj->widget));
	return 0;
err:
	return 1;
}
Exemplo n.º 29
0
/* A GtkProgress can be in one of two different modes: percentage mode (the default)
 * and activity mode. In activity mode, the progress is simply indicated as activity
 * rather than as a percentage complete. */
int
clip_GTK_PROGRESSSETACTIVITYMODE(ClipMachine * cm)
{
	C_widget      *cprg = _fetch_cw_arg(cm);
	guint activity_mode = _clip_parl(cm,2);
        CHECKCWID(cprg,GTK_IS_PROGRESS);
	CHECKOPT(2,LOGICAL_t);
        if (_clip_parinfo(cm,2)==UNDEF_t) activity_mode = TRUE;
        gtk_progress_set_activity_mode(GTK_PROGRESS(cprg->widget), activity_mode);
	return 0;
err:
	return 1;
}
Exemplo n.º 30
0
static	void
GetProgressBar(
	GtkWidget				*widget,
	_ProgressBar			*data)
{
ENTER_FUNC;
#ifdef LIBGTK_3_0_0
	data->value = gtk_panda_progress_bar_get_value(GTK_PANDA_PROGRESS_BAR(widget));
#else
	data->value = gtk_progress_get_value(GTK_PROGRESS(widget));
#endif
LEAVE_FUNC;
}