示例#1
0
static void
x264_update_int(signal_user_data_t *ud, const gchar *name, const gchar *val)
{
    gint ival;

    if (val == NULL) return;
    ival = g_strtod (val, NULL);
    ghb_settings_set_int(ud->x264_priv, name, ival);
}
示例#2
0
static void
x264_update_double(signal_user_data_t *ud, const gchar *name, const gchar *val)
{
    gdouble dval;

    if (val == NULL) return;
    dval = g_strtod (val, NULL);
    ghb_settings_set_double(ud->x264_priv, name, dval);
}
示例#3
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;
}
示例#4
0
static void
xform_string_int64(const GValue *sval, GValue *ival)
{
	gchar *end;
	const gchar *str = g_value_get_string(sval);
	gint64 val = g_strtod(str, &end);
	if (*end)
		val = (guint64)(~0L)>>1;
	g_value_set_int64(ival, val);
}
示例#5
0
static void
x264_update_int_setting(signal_user_data_t *ud, const gchar *name, const gchar *val)
{
    gint ival;

    if (val == NULL) return;
    ival = g_strtod (val, NULL);
    ghb_dict_set(ud->x264_priv, name, ghb_int_value_new(ival));
    ghb_check_dependency(ud, NULL, name);
}
static real
_parse_real (xmlNodePtr node, const char *attrib)
{
  xmlChar *str = xmlGetProp(node, (const xmlChar *)attrib);
  real val = 0;
  if (str) {
    val = g_strtod ((gchar *)str, NULL);
    xmlFree(str);
  }
  return val;
}
示例#7
0
static float
convert_pos (gchar *pos, int digits)
{
	gchar whole[10];
	gchar *fraction;
	gint i;
	float t1, t2;
	
	if (!pos || strlen(pos) < 4 || digits > 9) return 0.0;
	
	for (i = 0; i < digits + 1; i++) whole[i] = pos[i];
	whole[i] = '\0';
	fraction = pos + digits + 1;

	t1 = g_strtod (whole, NULL);
	t2 = g_strtod (fraction, NULL);

	if (t1 >= 0.0) return t1 + t2/pow (10.0, strlen(fraction));
	else return t1 - t2/pow (10.0, strlen(fraction));
}
示例#8
0
static gboolean world_file_read_line ( FILE *ff, gdouble *value, gboolean use_value )
{
  gboolean answer = TRUE; // Success
  gchar buffer[1024];
  if ( !fgets ( buffer, 1024, ff ) ) {
    answer = FALSE;
  }
  if ( answer && use_value )
      *value = g_strtod ( buffer, NULL );

  return answer;
}
示例#9
0
文件: dem.c 项目: idaohang/viking-1
static gboolean get_double_and_continue ( gchar **buffer, gdouble *tmp, gboolean warn )
{
  gchar *endptr;
  *tmp = g_strtod(*buffer, &endptr);
  if ( endptr == NULL|| endptr == *buffer ) {
    if ( warn )
      g_warning(_("Invalid DEM"));
    return FALSE;
  }
  *buffer=endptr;
  return TRUE;
}
示例#10
0
static GArray *
_parse_bezpoints (xmlNodePtr node, const char *attrib)
{
  xmlChar *str = xmlGetProp(node, (const xmlChar *)attrib);
  GArray *arr = NULL;
  
  if (str) {
    GArray *arr = g_array_new(FALSE, TRUE, sizeof(BezPoint));
    gint i;
    gchar **split = g_strsplit ((gchar *)str, " ", -1);
    gchar *val, *ep = NULL;
    for (i = 0, val = split[i]; split[i] != NULL; ++i)
      /* count them */;
    g_array_set_size (arr, i);
    for (i = 0, val = split[i]; split[i] != 0; ++i) {
      BezPoint *pt = &g_array_index(arr, BezPoint, i);
      pt->type = val[0] == 'M' ? BEZ_MOVE_TO : (val[0] == 'L' ? BEZ_LINE_TO : BEZ_CURVE_TO);
      ep = (gchar *)str + 1;
      
      pt->p1.x = ep ? g_strtod (ep, &ep) : 0;
      pt->p1.y = ep ? ++ep, g_strtod (ep, &ep) : 0;
      pt->p2.x = ep ? ++ep, g_strtod (ep, &ep) : 0;
      pt->p2.y = ep ? ++ep, g_strtod (ep, &ep) : 0;
      pt->p3.x = ep ? ++ep, g_strtod (ep, &ep) : 0;
      pt->p3.y = ep ? ++ep, g_strtod (ep, &ep) : 0;
    }    
    g_strfreev(split);
    xmlFree(str);
  }
  return arr;
}
示例#11
0
int logarithmic_input_value(gpointer obj, gpointer nv)
{
    GtkEntry *entry = GTK_ENTRY(obj);
    double *new_val = static_cast<double*>(nv);
    gchar *err = NULL;
    *new_val = g_strtod(gtk_entry_get_text(entry), &err);
    if (*err)
        return GTK_INPUT_ERROR;
    else {
        *new_val = log10(*new_val);
        return TRUE;
    }
}
示例#12
0
文件: gimpeevl.c 项目: LebedevRI/gimp
static void
gimp_eevl_lex (GimpEevl *eva)
{
  const gchar *s;

  gimp_eevl_move_past_whitespace (eva);
  s = eva->string;
  eva->start_of_current_token = s;

  if (! s || s[0] == '\0')
    {
      /* We're all done */
      eva->current_token.type = GIMP_EEVL_TOKEN_END;
    }
  else if (s[0] == '+' || s[0] == '-')
    {
      /* Snatch these before the g_strtod() does, otherwise they might
       * be used in a numeric conversion.
       */
      gimp_eevl_lex_accept_count (eva, 1, s[0]);
    }
  else
    {
      /* Attempt to parse a numeric value */
      gchar  *endptr = NULL;
      gdouble value      = g_strtod (s, &endptr);

      if (endptr && endptr != s)
        {
          /* A numeric could be parsed, use it */
          eva->current_token.value.fl = value;

          gimp_eevl_lex_accept_to (eva, endptr, GIMP_EEVL_TOKEN_NUM);
        }
      else if (gimp_eevl_unit_identifier_start (s[0]))
        {
          /* Unit identifier */
          eva->current_token.value.c    = s;
          eva->current_token.value.size = gimp_eevl_unit_identifier_size (s, 0);

          gimp_eevl_lex_accept_count (eva,
                                      eva->current_token.value.size,
                                      GIMP_EEVL_TOKEN_IDENTIFIER);
        }
      else
        {
          /* Everything else is a single character token */
          gimp_eevl_lex_accept_count (eva, 1, s[0]);
        }
    }
}
示例#13
0
文件: conf.c 项目: dimkr/beaver
gint		get_int_conf(gchar *key)
{
  t_conf	conf;
  gint		ret_val;

  if (get_conf(key, &conf))
    {
      free_conf(&conf);
      return (0);
    }
  ret_val = (gint) g_strtod(conf.line, NULL);
  free_conf(&conf);
  return (ret_val);
}
示例#14
0
文件: util.c 项目: vifino/dwb
/* util_char_to_arg(char *value, DwbType type)    return: Arg*{{{*/
Arg *
util_char_to_arg(char *value, DwbType type) 
{
    errno = 0;
    Arg *ret = util_arg_new();
    if (type == BOOLEAN && !value)  
        ret->b = false;
    else if (value || type == CHAR) 
    {
        if (value) {
            g_strstrip(value);
            if (strlen(value) == 0) 
            {
                if (type == CHAR) 
                    return ret;
                g_free(ret);
                return NULL;
            }
        }
        if (type == BOOLEAN) 
        {
            if(value == NULL || !g_ascii_strcasecmp(value, "false") || !g_strcmp0(value, "0")) 
                ret->b = false;
            else 
                ret->b = true;
        }
        else if (type == INTEGER) 
        {
            long n = strtol(value, NULL, 10);
            if (n != LONG_MAX &&  n != LONG_MIN && !errno ) 
                ret->i = n;
        }
        else if (type == DOUBLE) 
        {
            char *end = NULL;
            double d = g_strtod(value, &end);
            if (! *end) 
                ret->d = d;
        }
        else if (type == CHAR) 
            ret->p = !value || (value && !g_strcmp0(value, "null")) ? NULL : g_strdup(value);
        else if (type == COLOR_CHAR) 
        {
            int length = strlen(value);
            if (value[0] == '#' && (length == 4 || length == 7) && util_is_hex(&value[1])) 
                ret->p = g_strdup(value);
        }
    }
    return ret;
}/*}}}*/
示例#15
0
文件: gtans.c 项目: GNOME/gcompris
gdouble tanreadfloat(FILE *fhd, int *lres)
{
  gdouble pouet;
  char buf[100];

  pouet = 1;
  if (*lres==1){
    *lres = fscanf(fhd, "%99s",buf);
    pouet=g_strtod(buf,NULL);
  }

  return pouet;

}
示例#16
0
gdouble convert_dms_to_dec(const gchar *dms)
{
	gdouble d = 0.0; /* Degree */
	gdouble m = 0.0; /* Minutes */
	gdouble s = 0.0; /* Seconds */
	gint neg = FALSE;
	gdouble result;
	
	if (dms != NULL) {
		int nbFloat = 0;
		const gchar *ptr, *endptr;

		// Compute the sign
		// It is negative if:
		// - the '-' sign occurs
		// - it is a west longitude or south latitude
		if (strpbrk (dms, "-wWsS") != NULL)
		    neg = TRUE;

		// Peek the différent components
		endptr = dms;
		do {
			gdouble value;
			ptr = strpbrk (endptr, "0123456789,.");
			if (ptr != NULL) {
			  value = g_strtod((const gchar *)ptr, (gchar **)&endptr);
      			nbFloat++;
      		switch(nbFloat) {
      			case 1:
      				d = value;
      				break;
      			case 2:
      				m = value;
      				break;
      			case 3:
      				s = value;
      				break;
      		}
			}
		} while (ptr != NULL && endptr != NULL);
	}
	
	// Compute the result
	result = d + m/60 + s/3600;
	
	if (neg) result = - result;
	
	return result;
}
示例#17
0
/**
 * rpt_common_get_translation:
 * @xnode: an #xmlNode.
 *
 * Returns: an #RptTranslation struct that represent the object's rotation
 * specified on @xnode.
 */
RptTranslation
*rpt_common_get_translation (xmlNode *xnode)
{
	gchar *prop;
	RptTranslation *translation = NULL;

	gdouble x;
	gdouble y;

	/* TODO try the first level of children */
	if (xmlStrcmp (xnode->name, "translation") == 0)
		{
			x = 0.0;
			y = 0.0;

			prop = xmlGetProp (xnode, "x");
			if (prop != NULL)
				{
					translation = rpt_common_rpttranslation_new ();
					translation->x = g_strtod (prop, NULL);
					xmlFree (prop);
				}
			prop = xmlGetProp (xnode, "y");
			if (prop != NULL)
				{
					if (translation == NULL)
						{
							translation = rpt_common_rpttranslation_new ();
						}
					translation->y = g_strtod (prop, NULL);
					xmlFree (prop);
				}
		}

	return translation;
}
示例#18
0
void
brasero_song_props_get_properties (BraseroSongProps *self,
				   gchar **artist,
				   gchar **title,
				   gchar **composer,
				   gint *isrc,
				   gint64 *start,
				   gint64 *end,
				   gint64 *gap)
{
	if (artist) {
		if (self->priv->artist_set)
			*artist = brasero_song_props_get_entry_value (GTK_ENTRY (self->priv->artist));
		else
			*artist = NULL;
	}

	if (title) {
		if (self->priv->title_set)
			*title = brasero_song_props_get_entry_value (GTK_ENTRY (self->priv->title));
		else
			*title = NULL;
	}

	if (composer) {
		if (self->priv->composer_set)
			*composer = brasero_song_props_get_entry_value (GTK_ENTRY (self->priv->composer));
		else
			*composer = NULL;
	}

	if (isrc) {
		const gchar *string;

		string = brasero_song_props_get_entry_value (GTK_ENTRY (self->priv->isrc));
		if (string)
			*isrc = (gint) g_strtod (string, NULL);
		else
			*isrc = 0;
	}

	if (start)
		*start = brasero_time_button_get_value (BRASERO_TIME_BUTTON (self->priv->start));
	if (end)
		*end = brasero_time_button_get_value (BRASERO_TIME_BUTTON (self->priv->end));
	if (gap)
		*gap = gtk_spin_button_get_value (GTK_SPIN_BUTTON (self->priv->gap)) * GST_SECOND;
}
示例#19
0
static gboolean world_file_read_line ( gchar *buffer, gint size, FILE *f, GtkWidget *widget, gboolean use_value )
{
  if (!fgets ( buffer, 1024, f ))
  {
    a_dialog_error_msg ( VIK_GTK_WINDOW_FROM_WIDGET(widget), _("Unexpected end of file reading World file.") );
    g_free ( buffer );
    fclose ( f );
    f = NULL;
    return FALSE;
  }
  if ( use_value )
  {
    gdouble val = g_strtod ( buffer, NULL );
    gtk_spin_button_set_value ( GTK_SPIN_BUTTON(widget), val > 0 ? val : -val );
  }
  return TRUE;
}
示例#20
0
static gdouble 
get_bar_data (Netinfo *netinfo, PingGraphBarData *bar_data, int ntodisplay,
	      gint rangemin, gint rangemax)
{
	gint i, index;
	GtkTreeModel *results;
	GtkTreeIter node;
	gboolean nodeavailable;
	gint seqnumber;
	gchar *srtt_str;
	gdouble max;

	for (i = 0; i<ntodisplay; i++) {
		bar_data[i].value = 0;
		bar_data[i].valid = FALSE;
	}
	
	results = gtk_tree_view_get_model (GTK_TREE_VIEW (netinfo->output));

	if (results != NULL) {
		nodeavailable = gtk_tree_model_get_iter_first (results, &node);
		while (nodeavailable) {
			gtk_tree_model_get (results, &node, 
					    ICMP_SEQ_COLUMN, &seqnumber, -1);
			index = seqnumber - rangemin - 1;
			if (seqnumber > rangemin) {
				gtk_tree_model_get (results, &node, 
						    SRTT_COLUMN, &srtt_str, 
						    -1);
				bar_data[index].value = g_strtod (srtt_str, 
								  NULL);
				g_free (srtt_str);
				bar_data[index].valid = TRUE;
			}
			nodeavailable = gtk_tree_model_iter_next (results, &node);
		}

	}

	max = 0.0;
	for (i = 0; i<ntodisplay; i++)
		if (bar_data[i].valid && (bar_data[i].value > max))
			max = bar_data[i].value;

	return max;
}
示例#21
0
/* Initialse VAL to reflect the current status of RD */
static gboolean
set_new_value (GValue *val, const struct recode_dialog *rd)
{
  const gchar *text = NULL;
  struct new_value nv;

  if ( gtk_toggle_button_get_active
       (GTK_TOGGLE_BUTTON (rd->toggle [BUTTON_NEW_VALUE])))
    {
      text = gtk_entry_get_text (GTK_ENTRY (rd->new_value_entry));

      nv.type = NV_NUMERIC;
      if (
	  (! rd->different && rd->input_var_is_string) ||
	  ( rd->different &&
	    gtk_toggle_button_get_active
	       (GTK_TOGGLE_BUTTON (rd->string_button)))
	  )
	{
	  nv.type = NV_STRING;
	}

      if ( nv.type == NV_STRING )
	nv.v.s = g_strdup (text);
      else
	nv.v.v = g_strtod (text, 0);
    }
  else if ( gtk_toggle_button_get_active
	    (GTK_TOGGLE_BUTTON (rd->toggle [BUTTON_NEW_COPY])))
    {
      nv.type = NV_COPY;
    }

  else if ( gtk_toggle_button_get_active
	    (GTK_TOGGLE_BUTTON (rd->toggle [BUTTON_NEW_SYSMIS])))
    {
      nv.type = NV_SYSMIS;
    }
  else
    return FALSE;

  g_value_init (val, new_value_get_type ());
  g_value_set_boxed (val, &nv);

  return TRUE;
}
示例#22
0
/**
 * lgl_xml_get_prop_double:
 * @node:        the libxml2 #xmlNodePtr of the node
 * @property:    the property name
 * @default_val: a default value to return if property not found
 *
 * Return value of property as a double.
 *
 * Returns: the property as a double.
 *
 */
gdouble
lgl_xml_get_prop_double (xmlNodePtr   node,
			 const gchar *property,
			 gdouble      default_val)
{
	gdouble  val;
	xmlChar *string;

	string = xmlGetProp (node, (xmlChar *)property);
	if ( string != NULL ) {
		val = g_strtod ((gchar *)string, NULL);
		xmlFree (string);
		return val;
	}

	return default_val;
}
示例#23
0
static void
as_duration_entry_changed_cb (GtkWidget *widget, gpointer pdata)
{
   GawSndData *snd = (GawSndData *) pdata; 
   UserPrefs *up = snd->ud->up;
   char text[64];
   double val = g_strtod (gtk_entry_get_text (GTK_ENTRY (widget)), NULL );

   if ( val != snd->sparams->duration ) {			  
      snd->sparams->duration = val;
      snd->sparams->numsamples = (unsigned int) val * snd->sparams->rate;
      sprintf( text, "%u",  snd->sparams->numsamples );
      gtk_entry_set_text (GTK_ENTRY (snd->w_size), text);
      msg_dbg(_("duration changed: text = '%s', val =  %0.2f"), text, val );
      up->duration = val;
   }
}
示例#24
0
static void
function_offsets (sqlite3_context *context,
                  int              argc,
                  sqlite3_value   *argv[])
{
	gchar *offsets, **names;
	gint offset_values[4];
	GString *result = NULL;
	gint i = 0;

	if (argc != 2) {
		sqlite3_result_error(context,
		                     "wrong number of arguments to function tracker_offsets()",
		                     -1);
		return;
	}

	offsets = sqlite3_value_text (argv[0]);
	names = (unsigned int *) sqlite3_value_blob (argv[1]);

	while (offsets && *offsets) {
		offset_values[i] = g_strtod (offsets, &offsets);

		/* All 4 values from the quartet have been gathered */
		if (i == 3) {
			if (!result) {
				result = g_string_new ("");
			} else {
				g_string_append_c (result, ',');
			}

			g_string_append_printf (result,
						"%s,%d",
						names[offset_values[0]],
						offset_values[2]);

		}

		i = (i + 1) % 4;
	}

	sqlite3_result_text (context,
			     (result) ? g_string_free (result, FALSE) : NULL,
			     -1, g_free);
}
示例#25
0
/*
 * Conversion from text to digit
 */
static gboolean dialog_entry_text_to_digit(const char *text, guint *value)
{
  gchar *endptr = NULL;
  gboolean status = FALSE;

  g_return_val_if_fail(text != NULL && value != NULL, FALSE);

  status = dialog_entry_digit_sanity_chk(text);
  if (status == FALSE)
  {
    return FALSE;
  }

  *value = (guint)g_strtod(text, &endptr);

  AV_DBG("%s: digit: %d\n", __func__, *value);

  return TRUE;
}
int main (int argc, char **argv)
{
	int times = 10;

	bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR);
	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
	textdomain (GETTEXT_PACKAGE);

	g_thread_init (NULL);
	gtk_init (&argc, &argv);

	if (argc < 2) {
		g_print ("Usage: %s [URI]\n", argv[0]);
		return 1;
	}

	bacon_video_widget_init_backend (NULL, NULL);
#if 0
	create_props (argv[1]);
#endif
	
	if (argc == 3) {
		times = g_strtod (argv[2], NULL);
	}

	for (i = 0; i < times; i++) {
		g_print ("Setting %d\n", i);
#if 0
		totem_properties_view_set_location (TOTEM_PROPERTIES_VIEW (props), argv[1]);
#else
		create_props (argv[1]);
#endif
		g_timeout_add_seconds (4, main_loop_exit, NULL);
		gtk_main ();
#if 1
		destroy_props ();
#endif
	}

//	gtk_main ();

	return 0;
}
示例#27
0
文件: editfast.c 项目: pap71/vergifac
int param0()
{
  int k,i;
  par0.x = -1;  par0.y = -1;
  if ( (k = cherpara( "x=")) != -1)   par0.x = atoi(tabmot[++k].pmot);
  if ( (k = cherpara( "y=")) != -1)   par0.y = atoi(tabmot[++k].pmot);
  if ( par0.x == -1 || par0.y == -1)	{
    gchar *zm = g_strdup_printf ("Fichier Mise en Page\n x= et/ou y= absents ligne '%s'",ze);
    /* sprintf(zm,"Fichier Mise en Page\n x= et/ou y= absents ligne '%s'",ze); */
    messavar(zm);
    g_free (zm);
    return -1;
									  }
if ( (k = cherpara( "siz=")) != -1)
	 par0.siz = g_strtod(tabmot[++k].pmot,NULL);
else par0.siz =6;
if ( (k = cherpara( "pol=")) != -1)	{
    ++k; par0.nupol=0;
    for (i=0; i < nbpol; ++i)	{
      if ( strcmp(tabmot[k].pmot,tabpol[i].pol) == 0) { par0.nupol= i; break;}
 							   }
								  }
else	{
  gchar *zm = g_strdup_printf ("Fichier Mise en Page\n pol= absent ligne '%s'",ze);
    /* sprintf(zm,"Fichier Mise en Page\n pol= absent ligne '%s'",ze); */
  messavar(zm);
  g_free (zm);
  par0.nupol = 0;	// 1er police
		  }
par0.slant = 0;
par0.weight = 0;
if ( (k = cherpara( "slant=")) != -1)	{
    ++k;
    if (strcmp(tabmot[k].pmot,"italic") == 0) par0.slant = 1;
    else if (strcmp(tabmot[k].pmot,"oblique") == 0) par0.slant = 2;
									  }
if ( (k = cherpara( "w=")) != -1)	{
    ++k;
    if (strcmp(tabmot[k].pmot,"bold") == 0) par0.weight = 1;
								  }
  //printf("xx= %d yy= %d zz=%lf\n",par0.x,par0.y,par0.siz);
return 0;
}
示例#28
0
文件: util.c 项目: phako/authorg
static void
_mkisofs_parse_progress (AuthorgSpawnDialog *dialog, gchar *line, gpointer user_data)
{
	gchar *tmp; 
	gdouble fraction = 0.0;
	static gdouble last_fraction = 0.0; 

	fraction = g_strtod (line, NULL) / 100;

	if (fraction > last_fraction && fraction <= 1.0)
	{
		gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (dialog->progress), fraction);
		gtk_progress_bar_set_text (GTK_PROGRESS_BAR (dialog->progress), 
				tmp = g_strdup_printf ("%2.0f%%", fraction * 100));
		last_fraction = fraction;

		g_free (tmp);
	}
}
示例#29
0
gboolean	
_http_response_read_from_stream_real(HttpPackage * package,
				GDataInputStream * data_stream,
				gsize * length,
				GCancellable * cancellable,
				GError ** error)
{
	HttpResponsePrivate
	* priv = http_response_get_instance_private(HTTP_RESPONSE(package));
	gboolean
	done = TRUE;
	gsize
	count = 0,total_count = 0;
	gchar
	* string_response = g_data_input_stream_read_line(data_stream,&total_count,cancellable,error);
	if(string_response)
	{
		static gchar
		version[10];
		static gint
		code = HTTP_RESPONSE_INVALID;
		sscanf(string_response,"%s %d",version,&code);
		int iresponse;
		for(iresponse = 0;iresponse < HTTP_RESPONSE_INVALID;iresponse++)
		{
			if(_http_response_codes[iresponse] == code)
			{
				priv->code = (HttpResponseCode)iresponse;
				break;
			}
		}
		priv->version = g_strtod(version + 5,NULL);
		done = HTTP_PACKAGE_CLASS(http_response_parent_class)->read_from_stream(package,data_stream,&count,cancellable,error);
		total_count += count;
		if(length)
			*length = total_count;
		g_free(string_response);
	}
	else
		done = FALSE;
	return done;
}
示例#30
0
文件: S52utils.c 项目: pcannon67/S52
double   S52_atof(const char *str)
// relacement of stdlib.h atof
{
    if (NULL == str)
        return (1.0/0.0); //nan

    if (0==S52_strlen(str)) {
        //PRINTF("WARNING: zero length string (inf)\n");
        //g_assert(0);
        return (1.0/0.0); //nan
    }


#ifdef S52_USE_GLIB2
    return g_strtod(str, NULL);
#else
    return atof(str);
#endif

}