예제 #1
0
파일: mgtk-mlton.c 프로젝트: mgtk/mgtk
EXTERNML GValue* mgtk_g_value_set_int (int i){
  GValue* res = create_GValue(G_TYPE_INT);
  g_value_set_int(res, i);
  return res;
}
예제 #2
0
static void
gimp_transform_options_get_property (GObject    *object,
                                     guint       property_id,
                                     GValue     *value,
                                     GParamSpec *pspec)
{
  GimpTransformOptions *options = GIMP_TRANSFORM_OPTIONS (object);

  switch (property_id)
    {
    case PROP_TYPE:
      g_value_set_enum (value, options->type);
      break;
    case PROP_DIRECTION:
      g_value_set_enum (value, options->direction);
      break;
    case PROP_INTERPOLATION:
      g_value_set_enum (value, options->interpolation);
      break;
    case PROP_CLIP:
      g_value_set_enum (value, options->clip);
      break;
    case PROP_SHOW_PREVIEW:
      g_value_set_boolean (value, options->show_preview);
      break;
    case PROP_PREVIEW_OPACITY:
      g_value_set_double (value, options->preview_opacity);
      break;
    case PROP_GRID_TYPE:
      g_value_set_enum (value, options->grid_type);
      break;
    case PROP_GRID_SIZE:
      g_value_set_int (value, options->grid_size);
      break;
    case PROP_CONSTRAIN_MOVE:
      g_value_set_boolean (value, options->constrain_move);
      break;
    case PROP_CONSTRAIN_SCALE:
      g_value_set_boolean (value, options->constrain_scale);
      break;
    case PROP_CONSTRAIN_ROTATE:
      g_value_set_boolean (value, options->constrain_rotate);
      break;
    case PROP_CONSTRAIN_SHEAR:
      g_value_set_boolean (value, options->constrain_shear);
      break;
    case PROP_CONSTRAIN_PERSPECTIVE:
      g_value_set_boolean (value, options->constrain_perspective);
      break;
    case PROP_FROMPIVOT_SCALE:
      g_value_set_boolean (value, options->frompivot_scale);
      break;
    case PROP_FROMPIVOT_SHEAR:
      g_value_set_boolean (value, options->frompivot_shear);
      break;
    case PROP_FROMPIVOT_PERSPECTIVE:
      g_value_set_boolean (value, options->frompivot_perspective);
      break;
    case PROP_CORNERSNAP:
      g_value_set_boolean (value, options->cornersnap);
      break;
    case PROP_FIXEDPIVOT:
      g_value_set_boolean (value, options->fixedpivot);
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
      break;
    }
}
예제 #3
0
GstStructure *payloadInfoToStructure(const PPayloadInfo &info, const QString &media)
{
	GstStructure *out = gst_structure_empty_new("application/x-rtp");

	{
		GValue gv;
		memset(&gv, 0, sizeof(GValue));
		g_value_init(&gv, G_TYPE_STRING);
		g_value_set_string(&gv, media.toLatin1().data());
		gst_structure_set_value(out, "media", &gv);
	}

	// payload id field required
	if(info.id == -1)
	{
		gst_structure_free(out);
		return 0;
	}

	{
		GValue gv;
		memset(&gv, 0, sizeof(GValue));
		g_value_init(&gv, G_TYPE_INT);
		g_value_set_int(&gv, info.id);
		gst_structure_set_value(out, "payload", &gv);
	}

	// name required for payload values 96 or greater
	if(info.id >= 96 && info.name.isEmpty())
	{
		gst_structure_free(out);
		return 0;
	}

	{
		GValue gv;
		memset(&gv, 0, sizeof(GValue));
		g_value_init(&gv, G_TYPE_STRING);
		g_value_set_string(&gv, info.name.toLatin1().data());
		gst_structure_set_value(out, "encoding-name", &gv);
	}

	if(info.clockrate != -1)
	{
		GValue gv;
		memset(&gv, 0, sizeof(GValue));
		g_value_init(&gv, G_TYPE_INT);
		g_value_set_int(&gv, info.clockrate);
		gst_structure_set_value(out, "clock-rate", &gv);
	}

	if(info.channels != -1)
	{
		GValue gv;
		memset(&gv, 0, sizeof(GValue));
		g_value_init(&gv, G_TYPE_STRING);
		g_value_set_string(&gv, QString::number(info.channels).toLatin1().data());
		gst_structure_set_value(out, "encoding-params", &gv);
	}

	foreach(const PPayloadInfo::Parameter &i, info.parameters)
	{
		QString value = i.value;

		// FIXME: is there a better way to detect when we should do this conversion?
		if(i.name == "configuration" && (info.name.toUpper() == "THEORA" || info.name.toUpper() == "VORBIS"))
		{
			QByteArray config = hexDecode(value);
			if(config.isEmpty())
			{
				gst_structure_free(out);
				return 0;
			}

			value = QString::fromLatin1(config.toBase64());
		}

		GValue gv;
		memset(&gv, 0, sizeof(GValue));
		g_value_init(&gv, G_TYPE_STRING);
		g_value_set_string(&gv, value.toLatin1().data());
		gst_structure_set_value(out, i.name.toLatin1().data(), &gv);
	}

	return out;
}
예제 #4
0
static void
itl_prayer_get_property (GObject      *object,
                         guint         prop_id,
                         GValue *value,
                         GParamSpec   *pspec)
{
  ItlPrayer *prayer= ITL_PRAYER(object);

  switch (prop_id)
    {
    /* Location properties */
    case PROP_DEGREE_LONG:
      g_value_set_double (value, (gdouble) prayer->priv->loc.degreeLong);
      break;
    case PROP_DEGREE_LAT:
      g_value_set_double (value, (gdouble) prayer->priv->loc.degreeLat);
      break;
    case PROP_GMT_DIFF:
      g_value_set_double (value, (gdouble) prayer->priv->loc.gmtDiff);
      break;
    case PROP_DST:
      g_value_set_boolean (value, (gboolean) prayer->priv->loc.dst);
      break;
    case PROP_SEA_LEVEL:
      g_value_set_double (value, (gdouble) prayer->priv->loc.seaLevel);
      break;
    case PROP_PRESSURE:
      g_value_set_double (value, (gdouble) prayer->priv->loc.pressure);
      break;
    case PROP_TEMPERATURE:
      g_value_set_double (value, (gdouble) prayer->priv->loc.temperature);
      break;
    /* Method properties */
    case PROP_METHOD:
      g_value_set_enum (value, (gint) prayer->priv->method.method);
      break;
    case PROP_FAJR_ANG:
      g_value_set_double (value, (gdouble) prayer->priv->method.fajrAng);
      break;
    case PROP_ISHAA_ANG:
      g_value_set_double (value, (gdouble) prayer->priv->method.ishaaAng);
      break;
    case PROP_IMSAAK_ANG:
      g_value_set_double (value, (gdouble) prayer->priv->method.imsaakAng);
      break;
    case PROP_FAJR_INV:
      g_value_set_int (value, (gint) prayer->priv->method.fajrInv);
      break;
    case PROP_ISHAA_INV:
      g_value_set_int (value, (gint) prayer->priv->method.ishaaInv);
      break;
    case PROP_IMSAAK_INV:
      g_value_set_int (value, (gint) prayer->priv->method.imsaakInv);
      break;
    case PROP_ROUND:
      g_value_set_enum (value, (gint) prayer->priv->method.round);
      break;
    case PROP_MATHHAB:
      g_value_set_enum (value, (gint) prayer->priv->method.mathhab);
      break;
    case PROP_NEAREST_LAT:
      g_value_set_double (value, (gdouble) prayer->priv->method.nearestLat);
      break;
    case PROP_EXTREME:
      g_value_set_enum (value, (gint) prayer->priv->method.extreme);
      break;
    case PROP_EXTREME_LAT:
      g_value_set_double (value, (gdouble) prayer->priv->method.extremeLat);
      break;
    case PROP_OFFSET:
      g_value_set_boolean (value, (gboolean) prayer->priv->method.offset);
      break;
    case PROP_FAJR_OFFSET:
      g_value_set_double (value, (gdouble) prayer->priv->method.offList[0]);
      break;
    case PROP_SHUROOQ_OFFSET:
      g_value_set_double (value, (gdouble) prayer->priv->method.offList[1]);
      break;
    case PROP_DHUHR_OFFSET:
      g_value_set_double (value, (gdouble) prayer->priv->method.offList[2]);
      break;
    case PROP_ASR_OFFSET:
      g_value_set_double (value, (gdouble) prayer->priv->method.offList[3]);
      break;
    case PROP_MAGHRIB_OFFSET:
      g_value_set_double (value, (gdouble) prayer->priv->method.offList[4]);
      break;
    case PROP_ISHA_OFFSET:
      g_value_set_double (value, (gdouble) prayer->priv->method.offList[5]);
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
  }
}
예제 #5
0
static gboolean
gst_lfo_control_source_bind (GstControlSource * source, GParamSpec * pspec)
{
  GType type, base;
  GstLFOControlSource *self = GST_LFO_CONTROL_SOURCE (source);
  gboolean ret = TRUE;

  /* get the fundamental base type */
  self->priv->type = base = type = G_PARAM_SPEC_VALUE_TYPE (pspec);
  while ((type = g_type_parent (type)))
    base = type;

  self->priv->base = base;
  /* restore type */
  type = self->priv->type;

  switch (base) {
    case G_TYPE_INT:{
      GParamSpecInt *tpspec = G_PARAM_SPEC_INT (pspec);

      g_value_init (&self->priv->minimum_value, type);
      g_value_set_int (&self->priv->minimum_value, tpspec->minimum);
      g_value_init (&self->priv->maximum_value, type);
      g_value_set_int (&self->priv->maximum_value, tpspec->maximum);

      if (!G_IS_VALUE (&self->priv->amplitude)) {
        g_value_init (&self->priv->amplitude, type);
        g_value_set_int (&self->priv->amplitude, 0);
      }

      if (!G_IS_VALUE (&self->priv->offset)) {
        g_value_init (&self->priv->offset, type);
        g_value_set_int (&self->priv->offset, tpspec->default_value);
      }
      break;
    }
    case G_TYPE_UINT:{
      GParamSpecUInt *tpspec = G_PARAM_SPEC_UINT (pspec);

      g_value_init (&self->priv->minimum_value, type);
      g_value_set_uint (&self->priv->minimum_value, tpspec->minimum);
      g_value_init (&self->priv->maximum_value, type);
      g_value_set_uint (&self->priv->maximum_value, tpspec->maximum);

      if (!G_IS_VALUE (&self->priv->amplitude)) {
        g_value_init (&self->priv->amplitude, type);
        g_value_set_uint (&self->priv->amplitude, 0);
      }

      if (!G_IS_VALUE (&self->priv->offset)) {
        g_value_init (&self->priv->offset, type);
        g_value_set_uint (&self->priv->offset, tpspec->default_value);
      }
      break;
    }
    case G_TYPE_LONG:{
      GParamSpecLong *tpspec = G_PARAM_SPEC_LONG (pspec);

      g_value_init (&self->priv->minimum_value, type);
      g_value_set_long (&self->priv->minimum_value, tpspec->minimum);
      g_value_init (&self->priv->maximum_value, type);
      g_value_set_long (&self->priv->maximum_value, tpspec->maximum);
      if (!G_IS_VALUE (&self->priv->amplitude)) {
        g_value_init (&self->priv->amplitude, type);
        g_value_set_long (&self->priv->amplitude, 0);
      }

      if (!G_IS_VALUE (&self->priv->offset)) {
        g_value_init (&self->priv->offset, type);
        g_value_set_long (&self->priv->offset, tpspec->default_value);
      }
      break;
    }
    case G_TYPE_ULONG:{
      GParamSpecULong *tpspec = G_PARAM_SPEC_ULONG (pspec);

      g_value_init (&self->priv->minimum_value, type);
      g_value_set_ulong (&self->priv->minimum_value, tpspec->minimum);
      g_value_init (&self->priv->maximum_value, type);
      g_value_set_ulong (&self->priv->maximum_value, tpspec->maximum);
      if (!G_IS_VALUE (&self->priv->amplitude)) {
        g_value_init (&self->priv->amplitude, type);
        g_value_set_ulong (&self->priv->amplitude, 0);
      }

      if (!G_IS_VALUE (&self->priv->offset)) {
        g_value_init (&self->priv->offset, type);
        g_value_set_ulong (&self->priv->offset, tpspec->default_value);
      }
      break;
    }
    case G_TYPE_INT64:{
      GParamSpecInt64 *tpspec = G_PARAM_SPEC_INT64 (pspec);

      g_value_init (&self->priv->minimum_value, type);
      g_value_set_int64 (&self->priv->minimum_value, tpspec->minimum);
      g_value_init (&self->priv->maximum_value, type);
      g_value_set_int64 (&self->priv->maximum_value, tpspec->maximum);
      if (!G_IS_VALUE (&self->priv->amplitude)) {
        g_value_init (&self->priv->amplitude, type);
        g_value_set_int64 (&self->priv->amplitude, 0);
      }

      if (!G_IS_VALUE (&self->priv->offset)) {
        g_value_init (&self->priv->offset, type);
        g_value_set_int64 (&self->priv->offset, tpspec->default_value);
      }
      break;
    }
    case G_TYPE_UINT64:{
      GParamSpecUInt64 *tpspec = G_PARAM_SPEC_UINT64 (pspec);

      g_value_init (&self->priv->minimum_value, type);
      g_value_set_uint64 (&self->priv->minimum_value, tpspec->minimum);
      g_value_init (&self->priv->maximum_value, type);
      g_value_set_uint64 (&self->priv->maximum_value, tpspec->maximum);
      if (!G_IS_VALUE (&self->priv->amplitude)) {
        g_value_init (&self->priv->amplitude, type);
        g_value_set_uint64 (&self->priv->amplitude, 0);
      }

      if (!G_IS_VALUE (&self->priv->offset)) {
        g_value_init (&self->priv->offset, type);
        g_value_set_uint64 (&self->priv->offset, tpspec->default_value);
      }
      break;
    }
    case G_TYPE_FLOAT:{
      GParamSpecFloat *tpspec = G_PARAM_SPEC_FLOAT (pspec);

      g_value_init (&self->priv->minimum_value, type);
      g_value_set_float (&self->priv->minimum_value, tpspec->minimum);
      g_value_init (&self->priv->maximum_value, type);
      g_value_set_float (&self->priv->maximum_value, tpspec->maximum);
      if (!G_IS_VALUE (&self->priv->amplitude)) {
        g_value_init (&self->priv->amplitude, type);
        g_value_set_float (&self->priv->amplitude, 0.0);
      }

      if (!G_IS_VALUE (&self->priv->offset)) {
        g_value_init (&self->priv->offset, type);
        g_value_set_float (&self->priv->offset, tpspec->default_value);
      }
      break;
    }
    case G_TYPE_DOUBLE:{
      GParamSpecDouble *tpspec = G_PARAM_SPEC_DOUBLE (pspec);

      g_value_init (&self->priv->minimum_value, type);
      g_value_set_double (&self->priv->minimum_value, tpspec->minimum);
      g_value_init (&self->priv->maximum_value, type);
      g_value_set_double (&self->priv->maximum_value, tpspec->maximum);
      if (!G_IS_VALUE (&self->priv->amplitude)) {
        g_value_init (&self->priv->amplitude, type);
        g_value_set_float (&self->priv->amplitude, 0.0);
      }

      if (!G_IS_VALUE (&self->priv->offset)) {
        g_value_init (&self->priv->offset, type);
        g_value_set_float (&self->priv->offset, tpspec->default_value);
      }
      break;
    }
    default:
      GST_WARNING ("incomplete implementation for paramspec type '%s'",
          G_PARAM_SPEC_TYPE_NAME (pspec));
      ret = FALSE;
      break;
  }

  if (ret) {
    GValue amp = { 0, }
    , off = {
    0,};

    /* This should never fail unless the user already set amplitude or offset
     * with an incompatible type before _bind () */
    if (!g_value_type_transformable (G_VALUE_TYPE (&self->priv->amplitude),
            base)
        || !g_value_type_transformable (G_VALUE_TYPE (&self->priv->offset),
            base)) {
      GST_WARNING ("incompatible types for amplitude or offset");
      gst_lfo_control_source_reset (self);
      return FALSE;
    }

    /* Generate copies and transform to the correct type */
    g_value_init (&amp, base);
    g_value_transform (&self->priv->amplitude, &amp);
    g_value_init (&off, base);
    g_value_transform (&self->priv->offset, &off);

    ret = gst_lfo_control_source_set_waveform (self, self->priv->waveform);

    g_value_unset (&self->priv->amplitude);
    g_value_init (&self->priv->amplitude, self->priv->base);
    g_value_transform (&amp, &self->priv->amplitude);

    g_value_unset (&self->priv->offset);
    g_value_init (&self->priv->offset, self->priv->base);
    g_value_transform (&off, &self->priv->offset);

    g_value_unset (&amp);
    g_value_unset (&off);
  }

  if (!ret)
    gst_lfo_control_source_reset (self);

  return ret;
}
static GdaRow *
fetch_next_sqlite_row (GdaSqliteRecordset *model, gboolean do_store, GError **error)
{
	int rc;
	SqliteConnectionData *cdata;
	GdaSqlitePStmt *ps;
	GdaRow *prow = NULL;

	cdata = (SqliteConnectionData*) gda_connection_internal_get_provider_data_error 
		(gda_data_select_get_connection ((GdaDataSelect*) model), error);
	if (!cdata)
		return NULL;
	ps = GDA_SQLITE_PSTMT (GDA_DATA_SELECT (model)->prep_stmt);

	virt_cnc_set_working_obj (gda_data_select_get_connection ((GdaDataSelect*) model), model);

	if (model->priv->empty_forced)
		rc = SQLITE_DONE;
	else		
		rc = SQLITE3_CALL (sqlite3_step) (ps->sqlite_stmt);
	switch (rc) {
	case  SQLITE_ROW: {
		gint col, real_col;
		prow = gda_row_new (_GDA_PSTMT (ps)->ncols);
		for (col = 0; col < _GDA_PSTMT (ps)->ncols; col++) {
			GValue *value;
			GType type = _GDA_PSTMT (ps)->types [col];
						GError *may_error;
			real_col = col + ps->nb_rowid_columns;

			if (type == GDA_TYPE_NULL) {
				type = fuzzy_get_gtype (cdata, ps, col);
				if (type == GDA_TYPE_BLOB) {
					/* extra check: make sure we have a rowid for this blob, or fallback to binary */
					if (ps->rowid_hash) {
						gint oidcol = 0;
						const char *ctable;
						ctable = SQLITE3_CALL (sqlite3_column_name) (ps->sqlite_stmt, real_col);
						if (ctable)
							oidcol = GPOINTER_TO_INT (g_hash_table_lookup (ps->rowid_hash,
												       ctable));
						if (oidcol == 0) {
							ctable = SQLITE3_CALL (sqlite3_column_table_name) (ps->sqlite_stmt, real_col);
							if (ctable)
								oidcol = GPOINTER_TO_INT (g_hash_table_lookup (ps->rowid_hash, 
													       ctable));
						}
						if (oidcol == 0)
							type = GDA_TYPE_BINARY;
					}
					else
						type = GDA_TYPE_BINARY;
				}
				if (type != GDA_TYPE_NULL) {
					GdaColumn *column;
					
					_GDA_PSTMT (ps)->types [col] = type;
					column = gda_data_model_describe_column (GDA_DATA_MODEL (model), col);
					gda_column_set_g_type (column, type);
					column = (GdaColumn *) g_slist_nth_data (_GDA_PSTMT (ps)->tmpl_columns, col);
					gda_column_set_g_type (column, type);
				}
			}
			
			/* fill GValue */
			value = gda_row_get_value (prow, col);

			may_error = (GError*) SQLITE3_CALL (sqlite3_column_blob) (ps->sqlite_stmt, real_col);
			if (may_error && g_hash_table_lookup (error_blobs_hash, may_error)) {
				/*g_print ("Row invalidated: [%s]\n", may_error->message);*/
				gda_row_invalidate_value_e (prow, value, may_error);
				g_hash_table_remove (error_blobs_hash, may_error);
			}
			else if (SQLITE3_CALL (sqlite3_column_text) (ps->sqlite_stmt, real_col) == NULL) {
				/* we have a NULL value */
				gda_value_set_null (value);
			}
			else {
				gda_value_reset_with_type (value, type);
				
				if (type == GDA_TYPE_NULL)
					;
				else if (type == G_TYPE_INT) {
					gint64 i;
					i = SQLITE3_CALL (sqlite3_column_int64) (ps->sqlite_stmt, real_col);
					if ((i > G_MAXINT) || (i < G_MININT)) {
						GError *lerror = NULL;
						g_set_error (&lerror, GDA_SERVER_PROVIDER_ERROR,
							     GDA_SERVER_PROVIDER_DATA_ERROR,
							     "%s", _("Integer value is too big"));
						gda_row_invalidate_value_e (prow, value, lerror);
					}
					else
						g_value_set_int (value, (gint) i);
				}
				else if (type == G_TYPE_UINT) {
					guint64 i;
					i = (gint64) SQLITE3_CALL (sqlite3_column_int64) (ps->sqlite_stmt, real_col);
					if (i > G_MAXUINT) {
						GError *lerror = NULL;
						g_set_error (&lerror, GDA_SERVER_PROVIDER_ERROR,
							     GDA_SERVER_PROVIDER_DATA_ERROR,
							     "%s", _("Integer value is too big"));
						gda_row_invalidate_value_e (prow, value, lerror);
					}
					else
						g_value_set_uint (value, (gint) i);
				}
				else if (type == G_TYPE_INT64)
					g_value_set_int64 (value, SQLITE3_CALL (sqlite3_column_int64) (ps->sqlite_stmt, real_col));
				else if (type == G_TYPE_UINT64)
					g_value_set_uint64 (value, (guint64) SQLITE3_CALL (sqlite3_column_int64) (ps->sqlite_stmt,
												   real_col));
				else if (type == G_TYPE_DOUBLE)
					g_value_set_double (value, SQLITE3_CALL (sqlite3_column_double) (ps->sqlite_stmt,
											  real_col));
				else if (type == G_TYPE_STRING)
					g_value_set_string (value, (gchar *) SQLITE3_CALL (sqlite3_column_text) (ps->sqlite_stmt,
												  real_col));
				else if (type == GDA_TYPE_BINARY) {
					GdaBinary *bin;
					
					bin = g_new0 (GdaBinary, 1);
					bin->binary_length = SQLITE3_CALL (sqlite3_column_bytes) (ps->sqlite_stmt, real_col);
					if (bin->binary_length > 0) {
						bin->data = g_new (guchar, bin->binary_length);
						memcpy (bin->data, SQLITE3_CALL (sqlite3_column_blob) (ps->sqlite_stmt, /* Flawfinder: ignore */
												       real_col),
							bin->binary_length);
					}
					else
						bin->binary_length = 0;
					gda_value_take_binary (value, bin);
				}
				else if (type == GDA_TYPE_BLOB) {
					GdaBlobOp *bop = NULL;
					gint oidcol = 0;

					if (ps->rowid_hash) {
						const char *ctable;
						ctable = SQLITE3_CALL (sqlite3_column_name) (ps->sqlite_stmt, real_col);
						if (ctable)
							oidcol = GPOINTER_TO_INT (g_hash_table_lookup (ps->rowid_hash,
												       ctable));
						if (oidcol == 0) {
							ctable = SQLITE3_CALL (sqlite3_column_table_name) (ps->sqlite_stmt, real_col);
							if (ctable)
								oidcol = GPOINTER_TO_INT (g_hash_table_lookup (ps->rowid_hash, 
													       ctable));
						}
					}
					if (oidcol != 0) {
						gint64 rowid;
						rowid = SQLITE3_CALL (sqlite3_column_int64) (ps->sqlite_stmt, oidcol - 1); /* remove 1
													       because it was added in the first place */
						bop = _gda_sqlite_blob_op_new (cdata,
									       SQLITE3_CALL (sqlite3_column_database_name) (ps->sqlite_stmt, 
													    real_col),
									       SQLITE3_CALL (sqlite3_column_table_name) (ps->sqlite_stmt,
													 real_col),
									       SQLITE3_CALL (sqlite3_column_origin_name) (ps->sqlite_stmt,
													  real_col),
									      rowid);
					}
					if (!bop) {
						GError *lerror = NULL;
						g_set_error (&lerror, GDA_SERVER_PROVIDER_ERROR,
							     GDA_SERVER_PROVIDER_DATA_ERROR,
							     "%s", _("Unable to open BLOB"));
						gda_row_invalidate_value_e (prow, value, lerror);
					}
					else {
						GdaBlob *blob;
						blob = g_new0 (GdaBlob, 1);
						gda_blob_set_op (blob, bop);
						g_object_unref (bop);
						gda_value_take_blob (value, blob);
					}
				}
				else if (type == G_TYPE_BOOLEAN)
					g_value_set_boolean (value, SQLITE3_CALL (sqlite3_column_int) (ps->sqlite_stmt, real_col) == 0 ? FALSE : TRUE);
				else if (type == G_TYPE_DATE) {
					GDate date;
					if (!gda_parse_iso8601_date (&date, 
								     (gchar *) SQLITE3_CALL (sqlite3_column_text) (ps->sqlite_stmt, 
												    real_col))) {
						GError *lerror = NULL;
						g_set_error (&lerror, GDA_SERVER_PROVIDER_ERROR,
							     GDA_SERVER_PROVIDER_DATA_ERROR,
							     _("Invalid date '%s' (date format should be YYYY-MM-DD)"), 
							     (gchar *) SQLITE3_CALL (sqlite3_column_text) (ps->sqlite_stmt, real_col));
						gda_row_invalidate_value_e (prow, value, lerror);
					}
					else
						g_value_set_boxed (value, &date);
				}
				else if (type == GDA_TYPE_TIME) {
					GdaTime timegda;
					if (!gda_parse_iso8601_time (&timegda, 
								     (gchar *) SQLITE3_CALL (sqlite3_column_text) (ps->sqlite_stmt, 
												    real_col))) {
						GError *lerror = NULL;
						g_set_error (&lerror, GDA_SERVER_PROVIDER_ERROR,
							     GDA_SERVER_PROVIDER_DATA_ERROR,
							     _("Invalid time '%s' (time format should be HH:MM:SS[.ms])"), 
							     (gchar *) SQLITE3_CALL (sqlite3_column_text) (ps->sqlite_stmt, real_col));
						gda_row_invalidate_value_e (prow, value, lerror);
					}
					else
						gda_value_set_time (value, &timegda);
				}
				else if (type == GDA_TYPE_TIMESTAMP) {
					GdaTimestamp timestamp;
					if (!gda_parse_iso8601_timestamp (&timestamp, 
									  (gchar *) SQLITE3_CALL (sqlite3_column_text) (ps->sqlite_stmt,
													 real_col))) {
						GError *lerror = NULL;
						g_set_error (&lerror, GDA_SERVER_PROVIDER_ERROR,
							     GDA_SERVER_PROVIDER_DATA_ERROR,
							     _("Invalid timestamp '%s' (format should be YYYY-MM-DD HH:MM:SS[.ms])"), 
							     (gchar *) SQLITE3_CALL (sqlite3_column_text) (ps->sqlite_stmt, real_col));
						gda_row_invalidate_value_e (prow, value, lerror);
					}
					else
						gda_value_set_timestamp (value, &timestamp);
				}
				else if (type == G_TYPE_CHAR) {
					gint64 i;
					i = (gint64) SQLITE3_CALL (sqlite3_column_int64) (ps->sqlite_stmt, real_col);
					if ((i > G_MAXINT8) || (i < G_MININT8)) {
						GError *lerror = NULL;
						g_set_error (&lerror, GDA_SERVER_PROVIDER_ERROR,
							     GDA_SERVER_PROVIDER_DATA_ERROR,
							     "%s", _("Integer value is too big"));
						gda_row_invalidate_value_e (prow, value, lerror);
					}
					else
#if GLIB_CHECK_VERSION(2,31,7)
						g_value_set_schar (value, (gchar) i);
#else
						g_value_set_char (value, (gchar) i);
#endif
				}
				else if (type == G_TYPE_UCHAR) {
					gint64 i;
					i = (gint64) SQLITE3_CALL (sqlite3_column_int64) (ps->sqlite_stmt, real_col);
					if ((i > G_MAXUINT8) || (i < 0)) {
						GError *lerror = NULL;
						g_set_error (&lerror, GDA_SERVER_PROVIDER_ERROR,
							     GDA_SERVER_PROVIDER_DATA_ERROR,
							     "%s", _("Integer value is too big"));
						gda_row_invalidate_value_e (prow, value, lerror);
					}
					else
						g_value_set_uchar (value, (guchar) i);
				}
				else if (type == GDA_TYPE_SHORT) {
					gint64 i;
					i = (gint64) SQLITE3_CALL (sqlite3_column_int64) (ps->sqlite_stmt, real_col);
					if ((i > G_MAXSHORT) || (i < G_MINSHORT)) {
						GError *lerror = NULL;
						g_set_error (&lerror, GDA_SERVER_PROVIDER_ERROR,
							     GDA_SERVER_PROVIDER_DATA_ERROR,
							     "%s", _("Integer value is too big"));
						gda_row_invalidate_value_e (prow, value, lerror);
					}
					else
						gda_value_set_short (value, (guchar) i);
				}
				else if (type == GDA_TYPE_USHORT) {
					gint64 i;
					i = (gint64) SQLITE3_CALL (sqlite3_column_int64) (ps->sqlite_stmt, real_col);
					if ((i > G_MAXUSHORT) || (i < 0)) {
						GError *lerror = NULL;
						g_set_error (&lerror, GDA_SERVER_PROVIDER_ERROR,
							     GDA_SERVER_PROVIDER_DATA_ERROR,
							     "%s", _("Integer value is too big"));
						gda_row_invalidate_value_e (prow, value, lerror);
					}
					else
						gda_value_set_ushort (value, (guchar) i);
				}
				else {
					GError *lerror = NULL;
					g_set_error (&lerror, GDA_SERVER_PROVIDER_ERROR,
						     GDA_SERVER_PROVIDER_DATA_ERROR,
						     "Unhandled type '%s' in SQLite recordset",
						     gda_g_type_to_string (_GDA_PSTMT (ps)->types [col]));
					gda_row_invalidate_value_e (prow, value, lerror);
				}
			}
		}
		
		if (do_store) {
			/* insert row */
			gda_data_select_take_row (GDA_DATA_SELECT (model), prow, model->priv->next_row_num);
		}
		model->priv->next_row_num ++;
		break;
	}
	case SQLITE_BUSY:
		/* nothing to do */
		break;
	case SQLITE_DONE:
		GDA_DATA_SELECT (model)->advertized_nrows = model->priv->next_row_num;
		SQLITE3_CALL (sqlite3_reset) (ps->sqlite_stmt);
		break;
	case SQLITE_READONLY:
	case SQLITE_MISUSE:
		g_set_error (error, GDA_SERVER_PROVIDER_ERROR,
			     GDA_SERVER_PROVIDER_INTERNAL_ERROR, 
			      "%s", _("SQLite provider fatal internal error"));
		break;
	case SQLITE_ERROR:
	default: {
		GError *lerror = NULL;
		SQLITE3_CALL (sqlite3_reset) (ps->sqlite_stmt);
		if (rc == SQLITE_IOERR_TRUNCATE)
			g_set_error (&lerror, GDA_DATA_MODEL_ERROR,
				     GDA_DATA_MODEL_TRUNCATED_ERROR, "%s", _("Truncated data"));
		else
			g_set_error (&lerror, GDA_SERVER_PROVIDER_ERROR,
				     GDA_SERVER_PROVIDER_INTERNAL_ERROR, 
				     "%s", SQLITE3_CALL (sqlite3_errmsg) (cdata->connection));
		gda_data_select_add_exception (GDA_DATA_SELECT (model), lerror);
		if (rc == SQLITE_ERROR)
			g_propagate_error (error, g_error_copy (lerror));
		GDA_DATA_SELECT (model)->advertized_nrows = model->priv->next_row_num;
		break;
	}
	}

	virt_cnc_set_working_obj (gda_data_select_get_connection ((GdaDataSelect*) model), NULL);

	return prow;
}
예제 #7
0
파일: gdbusutils.c 프로젝트: 183amir/glib
/**
 * g_dbus_gvariant_to_gvalue:
 * @value: A #GVariant.
 * @out_gvalue: (out): Return location pointing to a zero-filled (uninitialized) #GValue.
 *
 * Converts a #GVariant to a #GValue. If @value is floating, it is consumed.
 *
 * The rules specified in the g_dbus_gvalue_to_gvariant() function are
 * used - this function is essentially its reverse form.
 *
 * The conversion never fails - a valid #GValue is always returned in
 * @out_gvalue.
 *
 * Since: 2.30
 */
void
g_dbus_gvariant_to_gvalue (GVariant  *value,
                           GValue    *out_gvalue)
{
  const GVariantType *type;
  gchar **array;

  g_return_if_fail (value != NULL);
  g_return_if_fail (out_gvalue != NULL);

  memset (out_gvalue, '\0', sizeof (GValue));

  switch (g_variant_classify (value))
    {
    case G_VARIANT_CLASS_BOOLEAN:
      g_value_init (out_gvalue, G_TYPE_BOOLEAN);
      g_value_set_boolean (out_gvalue, g_variant_get_boolean (value));
      break;

    case G_VARIANT_CLASS_BYTE:
      g_value_init (out_gvalue, G_TYPE_UCHAR);
      g_value_set_uchar (out_gvalue, g_variant_get_byte (value));
      break;

    case G_VARIANT_CLASS_INT16:
      g_value_init (out_gvalue, G_TYPE_INT);
      g_value_set_int (out_gvalue, g_variant_get_int16 (value));
      break;

    case G_VARIANT_CLASS_UINT16:
      g_value_init (out_gvalue, G_TYPE_UINT);
      g_value_set_uint (out_gvalue, g_variant_get_uint16 (value));
      break;

    case G_VARIANT_CLASS_INT32:
      g_value_init (out_gvalue, G_TYPE_INT);
      g_value_set_int (out_gvalue, g_variant_get_int32 (value));
      break;

    case G_VARIANT_CLASS_UINT32:
      g_value_init (out_gvalue, G_TYPE_UINT);
      g_value_set_uint (out_gvalue, g_variant_get_uint32 (value));
      break;

    case G_VARIANT_CLASS_INT64:
      g_value_init (out_gvalue, G_TYPE_INT64);
      g_value_set_int64 (out_gvalue, g_variant_get_int64 (value));
      break;

    case G_VARIANT_CLASS_UINT64:
      g_value_init (out_gvalue, G_TYPE_UINT64);
      g_value_set_uint64 (out_gvalue, g_variant_get_uint64 (value));
      break;

    case G_VARIANT_CLASS_DOUBLE:
      g_value_init (out_gvalue, G_TYPE_DOUBLE);
      g_value_set_double (out_gvalue, g_variant_get_double (value));
      break;

    case G_VARIANT_CLASS_STRING:
      g_value_init (out_gvalue, G_TYPE_STRING);
      g_value_set_string (out_gvalue, g_variant_get_string (value, NULL));
      break;

    case G_VARIANT_CLASS_OBJECT_PATH:
      g_value_init (out_gvalue, G_TYPE_STRING);
      g_value_set_string (out_gvalue, g_variant_get_string (value, NULL));
      break;

    case G_VARIANT_CLASS_SIGNATURE:
      g_value_init (out_gvalue, G_TYPE_STRING);
      g_value_set_string (out_gvalue, g_variant_get_string (value, NULL));
      break;

    case G_VARIANT_CLASS_ARRAY:
      type = g_variant_get_type (value);
      switch (g_variant_type_peek_string (type)[1])
        {
        case G_VARIANT_CLASS_BYTE:
          g_value_init (out_gvalue, G_TYPE_STRING);
          g_value_set_string (out_gvalue, g_variant_get_bytestring (value));
          break;

        case G_VARIANT_CLASS_STRING:
          g_value_init (out_gvalue, G_TYPE_STRV);
          array = g_variant_dup_strv (value, NULL);
          g_value_take_boxed (out_gvalue, array);
          break;

        case G_VARIANT_CLASS_OBJECT_PATH:
          g_value_init (out_gvalue, G_TYPE_STRV);
          array = g_variant_dup_objv (value, NULL);
          g_value_take_boxed (out_gvalue, array);
          break;

        case G_VARIANT_CLASS_ARRAY:
          switch (g_variant_type_peek_string (type)[2])
            {
            case G_VARIANT_CLASS_BYTE:
              g_value_init (out_gvalue, G_TYPE_STRV);
              array = g_variant_dup_bytestring_array (value, NULL);
              g_value_take_boxed (out_gvalue, array);
              break;

            default:
              g_value_init (out_gvalue, G_TYPE_VARIANT);
              g_value_set_variant (out_gvalue, value);
              break;
            }
          break;

        default:
          g_value_init (out_gvalue, G_TYPE_VARIANT);
          g_value_set_variant (out_gvalue, value);
          break;
        }
      break;

    case G_VARIANT_CLASS_HANDLE:
    case G_VARIANT_CLASS_VARIANT:
    case G_VARIANT_CLASS_MAYBE:
    case G_VARIANT_CLASS_TUPLE:
    case G_VARIANT_CLASS_DICT_ENTRY:
      g_value_init (out_gvalue, G_TYPE_VARIANT);
      g_value_set_variant (out_gvalue, value);
      break;
    }
}
예제 #8
0
static GValueArray *
gradients_get_gradient_data_invoker (GimpProcedure      *procedure,
                                     Gimp               *gimp,
                                     GimpContext        *context,
                                     GimpProgress       *progress,
                                     const GValueArray  *args,
                                     GError            **error)
{
  gboolean success = TRUE;
  GValueArray *return_vals;
  const gchar *name;
  gint32 sample_size;
  gboolean reverse;
  gchar *actual_name = NULL;
  gint32 width = 0;
  gdouble *grad_data = NULL;

  name = g_value_get_string (&args->values[0]);
  sample_size = g_value_get_int (&args->values[1]);
  reverse = g_value_get_boolean (&args->values[2]);

  if (success)
    {
      GimpGradient *gradient;

      if (sample_size < 1 || sample_size > 10000)
        sample_size = GIMP_GRADIENT_DEFAULT_SAMPLE_SIZE;

      if (name && strlen (name))
        gradient = gimp_pdb_get_gradient (gimp, name, FALSE, error);
      else
        gradient = gimp_context_get_gradient (context);

      if (gradient)
        {
          GimpGradientSegment *seg = NULL;
          gdouble             *pv;
          gdouble              pos, delta;
          GimpRGB              color;

          pos   = 0.0;
          delta = 1.0 / (sample_size - 1);

          actual_name = g_strdup (gimp_object_get_name (GIMP_OBJECT (gradient)));
          grad_data   = g_new (gdouble, sample_size * 4);
          width       = sample_size * 4;

          pv = grad_data;

          while (sample_size)
            {
              seg = gimp_gradient_get_color_at (gradient, context, seg,
                                                pos, reverse, &color);

              *pv++ = color.r;
              *pv++ = color.g;
              *pv++ = color.b;
              *pv++ = color.a;

              pos += delta;
            }
        }
      else
        success = FALSE;
    }

  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    {
      g_value_take_string (&return_vals->values[1], actual_name);
      g_value_set_int (&return_vals->values[2], width);
      gimp_value_take_floatarray (&return_vals->values[3], grad_data, width);
    }

  return return_vals;
}
예제 #9
0
파일: main.c 프로젝트: bitptr/bytestream
/*
 * Get text and use that to fill in the placeholder.
 */
uint8_t
fill_in_flags(char **cmd, uint8_t flags)
{
	uint8_t		 ret = 0;
	const char	*text = NULL;
	GtkWidget	*dialog, *box, *entry, *label = NULL;
	GtkEntryBuffer	*buf;
	GValue		 g_9 = G_VALUE_INIT;

	g_value_init(&g_9, G_TYPE_INT);
	g_value_set_int(&g_9, 3);

	dialog = gtk_dialog_new_with_buttons(
	    "Command options",
	    GTK_WINDOW(window),
	     GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
	     "_Close", GTK_RESPONSE_CLOSE,
	     "_Run", GTK_RESPONSE_OK,
	     NULL);
	box = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
	entry = gtk_entry_new();

	gtk_widget_set_size_request(dialog, 300, 20);
	g_object_set_property(G_OBJECT(box), "margin", &g_9);
	gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE);
	gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK);

	if (flags & SINGLE_FILE_PLACEHOLDER)
		label = gtk_label_new("File name");

	if (flags & SINGLE_URL_PLACEHOLDER)
		label = gtk_label_new("URI");

	if (flags & MULTI_FILE_PLACEHOLDER)
		label = gtk_label_new("Files");

	if (flags & MULTI_URL_PLACEHOLDER)
		label = gtk_label_new("URIs");

	if (label) {
		gtk_box_pack_start(GTK_BOX(box), label, /* expand */ 0,
		    /* fill */ 1, /* padding */ 3);
		gtk_box_pack_start(GTK_BOX(box), entry, /* expand */ 1,
		    /* fill */ 1, /* padding */ 3);
	}

	gtk_widget_show_all(box);

	switch (gtk_dialog_run(GTK_DIALOG(dialog))) {
	case GTK_RESPONSE_OK:
		buf = gtk_entry_get_buffer(GTK_ENTRY(entry));
		text = gtk_entry_buffer_get_text(buf);

		if ((*cmd = fill_in_command(*cmd, text, flags)) == NULL) {
			warnx("fill_in_command failed");
			break;
		}

		ret = 1;

		break;
	case GTK_RESPONSE_CLOSE:
	case GTK_RESPONSE_NONE:
	case GTK_RESPONSE_DELETE_EVENT:
		break;
	default:
		warnx("unknown result from gtk_dialog_run");
		break;
	}

	gtk_widget_destroy(dialog);

	return ret;
}
예제 #10
0
/* Syncs a value from GConf to an object property */
static void
prop_binding_sync_pref_to_prop (PropBinding *binding,
                                GConfValue *pref_value)
{
	GValue src_value, value;

        /* Make sure we don't enter an infinite synchronizing loop */
	g_signal_handler_block (binding->object, binding->prop_notify_id);

	memset (&src_value, 0, sizeof (GValue));

        /* First, convert GConfValue to GValue */
	switch (pref_value->type) {
	case GCONF_VALUE_STRING:
		g_value_init (&src_value, G_TYPE_STRING);
		g_value_set_string (&src_value,
				    gconf_value_get_string (pref_value));
		break;
	case GCONF_VALUE_INT:
		g_value_init (&src_value, G_TYPE_INT);
		g_value_set_int (&src_value,
				 gconf_value_get_int (pref_value));
		break;
	case GCONF_VALUE_BOOL:
		g_value_init (&src_value, G_TYPE_BOOLEAN);
		g_value_set_boolean (&src_value,
				     gconf_value_get_bool (pref_value));
		break;
	case GCONF_VALUE_FLOAT:
		g_value_init (&src_value, G_TYPE_FLOAT);
		g_value_set_float (&src_value,
				   gconf_value_get_float (pref_value));
		break;
	default:
                g_warning ("prop_binding_sync_pref_to_prop: Unhandled value "
                           "type '%d'.\n", pref_value->type);

		return;
	}

        /* Then convert to the type expected by the object, if necessary */
	memset (&value, 0, sizeof (GValue));
	g_value_init (&value,
		      G_PARAM_SPEC_VALUE_TYPE (binding->prop));

	if (src_value.g_type != value.g_type) {
		if (!g_value_transform (&src_value, &value)) {
                        g_warning ("prop_binding_sync_pref_to_prop: Failed to "
                                   "transform a \"%s\" to a \"%s\".",
				   g_type_name (src_value.g_type),
				   g_type_name (value.g_type));

			goto done;
		}

		g_object_set_property (binding->object,
				       binding->prop->name, &value);
	} else {
		g_object_set_property (binding->object,
				       binding->prop->name, &src_value);
	}

done:
	g_value_unset (&src_value);
	g_value_unset (&value);

	g_signal_handler_unblock (binding->object, binding->prop_notify_id);
}
예제 #11
0
static void
gimp_core_config_get_property (GObject    *object,
                               guint       property_id,
                               GValue     *value,
                               GParamSpec *pspec)
{
  GimpCoreConfig *core_config = GIMP_CORE_CONFIG (object);

  switch (property_id)
    {
    case PROP_LANGUAGE:
      g_value_set_string (value, core_config->language);
      break;
    case PROP_INTERPOLATION_TYPE:
      g_value_set_enum (value, core_config->interpolation_type);
      break;
    case PROP_DEFAULT_THRESHOLD:
      g_value_set_int (value, core_config->default_threshold);
      break;
    case PROP_PLUG_IN_PATH:
      g_value_set_string (value, core_config->plug_in_path);
      break;
    case PROP_MODULE_PATH:
      g_value_set_string (value, core_config->module_path);
      break;
    case PROP_INTERPRETER_PATH:
      g_value_set_string (value, core_config->interpreter_path);
      break;
    case PROP_ENVIRON_PATH:
      g_value_set_string (value, core_config->environ_path);
      break;
    case PROP_BRUSH_PATH:
      g_value_set_string (value, core_config->brush_path);
      break;
    case PROP_BRUSH_PATH_WRITABLE:
      g_value_set_string (value, core_config->brush_path_writable);
      break;
    case PROP_DYNAMICS_PATH:
      g_value_set_string (value, core_config->dynamics_path);
      break;
    case PROP_DYNAMICS_PATH_WRITABLE:
      g_value_set_string (value, core_config->dynamics_path_writable);
      break;
    case PROP_MYPAINT_BRUSH_PATH:
      g_value_set_string (value, core_config->mypaint_brush_path);
      break;
    case PROP_MYPAINT_BRUSH_PATH_WRITABLE:
      g_value_set_string (value, core_config->mypaint_brush_path_writable);
      break;
    case PROP_PATTERN_PATH:
      g_value_set_string (value, core_config->pattern_path);
      break;
    case PROP_PATTERN_PATH_WRITABLE:
      g_value_set_string (value, core_config->pattern_path_writable);
      break;
    case PROP_PALETTE_PATH:
      g_value_set_string (value, core_config->palette_path);
      break;
    case PROP_PALETTE_PATH_WRITABLE:
      g_value_set_string (value, core_config->palette_path_writable);
      break;
    case PROP_GRADIENT_PATH:
      g_value_set_string (value, core_config->gradient_path);
      break;
    case PROP_GRADIENT_PATH_WRITABLE:
      g_value_set_string (value, core_config->gradient_path_writable);
      break;
    case PROP_TOOL_PRESET_PATH:
      g_value_set_string (value, core_config->tool_preset_path);
      break;
    case PROP_TOOL_PRESET_PATH_WRITABLE:
      g_value_set_string (value, core_config->tool_preset_path_writable);
      break;
    case PROP_FONT_PATH:
      g_value_set_string (value, core_config->font_path);
      break;
    case PROP_FONT_PATH_WRITABLE:
      g_value_set_string (value, core_config->font_path_writable);
      break;
    case PROP_DEFAULT_BRUSH:
      g_value_set_string (value, core_config->default_brush);
      break;
    case PROP_DEFAULT_DYNAMICS:
      g_value_set_string (value, core_config->default_dynamics);
      break;
    case PROP_DEFAULT_MYPAINT_BRUSH:
      g_value_set_string (value, core_config->default_mypaint_brush);
      break;
    case PROP_DEFAULT_PATTERN:
      g_value_set_string (value, core_config->default_pattern);
      break;
    case PROP_DEFAULT_PALETTE:
      g_value_set_string (value, core_config->default_palette);
      break;
    case PROP_DEFAULT_GRADIENT:
      g_value_set_string (value, core_config->default_gradient);
      break;
    case PROP_DEFAULT_TOOL_PRESET:
      g_value_set_string (value, core_config->default_tool_preset);
      break;
    case PROP_DEFAULT_FONT:
      g_value_set_string (value, core_config->default_font);
      break;
    case PROP_GLOBAL_BRUSH:
      g_value_set_boolean (value, core_config->global_brush);
      break;
    case PROP_GLOBAL_DYNAMICS:
      g_value_set_boolean (value, core_config->global_dynamics);
      break;
    case PROP_GLOBAL_PATTERN:
      g_value_set_boolean (value, core_config->global_pattern);
      break;
    case PROP_GLOBAL_PALETTE:
      g_value_set_boolean (value, core_config->global_palette);
      break;
    case PROP_GLOBAL_GRADIENT:
      g_value_set_boolean (value, core_config->global_gradient);
      break;
    case PROP_GLOBAL_FONT:
      g_value_set_boolean (value, core_config->global_font);
      break;
    case PROP_DEFAULT_IMAGE:
      g_value_set_object (value, core_config->default_image);
      break;
    case PROP_DEFAULT_GRID:
      g_value_set_object (value, core_config->default_grid);
      break;
    case PROP_FILTER_HISTORY_SIZE:
      g_value_set_int (value, core_config->filter_history_size);
      break;
    case PROP_UNDO_LEVELS:
      g_value_set_int (value, core_config->levels_of_undo);
      break;
    case PROP_UNDO_SIZE:
      g_value_set_uint64 (value, core_config->undo_size);
      break;
    case PROP_UNDO_PREVIEW_SIZE:
      g_value_set_enum (value, core_config->undo_preview_size);
      break;
    case PROP_PLUGINRC_PATH:
      g_value_set_string (value, core_config->plug_in_rc_path);
      break;
    case PROP_LAYER_PREVIEWS:
      g_value_set_boolean (value, core_config->layer_previews);
      break;
    case PROP_LAYER_PREVIEW_SIZE:
      g_value_set_enum (value, core_config->layer_preview_size);
      break;
    case PROP_THUMBNAIL_SIZE:
      g_value_set_enum (value, core_config->thumbnail_size);
      break;
    case PROP_THUMBNAIL_FILESIZE_LIMIT:
      g_value_set_uint64 (value, core_config->thumbnail_filesize_limit);
      break;
    case PROP_COLOR_MANAGEMENT:
      g_value_set_object (value, core_config->color_management);
      break;
    case PROP_COLOR_PROFILE_POLICY:
      g_value_set_enum (value, core_config->color_profile_policy);
      break;
    case PROP_SAVE_DOCUMENT_HISTORY:
      g_value_set_boolean (value, core_config->save_document_history);
      break;
    case PROP_QUICK_MASK_COLOR:
      gimp_value_set_rgb (value, &core_config->quick_mask_color);
      break;

    case PROP_INSTALL_COLORMAP:
    case PROP_MIN_COLORS:
      /*  ignored  */
      break;

    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
      break;
    }
}
예제 #12
0
void
_foo_tree_data_list_node_to_value (FooTreeDataList *list,
				   GType            type,
				   GValue          *value)
{
  g_value_init (value, type);

  switch (get_fundamental_type (type))
    {
    case G_TYPE_BOOLEAN:
      g_value_set_boolean (value, (gboolean) list->data.v_int);
      break;
    case G_TYPE_CHAR:
      g_value_set_char (value, (gchar) list->data.v_char);
      break;
    case G_TYPE_UCHAR:
      g_value_set_uchar (value, (guchar) list->data.v_uchar);
      break;
    case G_TYPE_INT:
      g_value_set_int (value, (gint) list->data.v_int);
      break;
    case G_TYPE_UINT:
      g_value_set_uint (value, (guint) list->data.v_uint);
      break;
    case G_TYPE_LONG:
      g_value_set_long (value, list->data.v_long);
      break;
    case G_TYPE_ULONG:
      g_value_set_ulong (value, list->data.v_ulong);
      break;
    case G_TYPE_INT64:
      g_value_set_int64 (value, list->data.v_int64);
      break;
    case G_TYPE_UINT64:
      g_value_set_uint64 (value, list->data.v_uint64);
      break;
    case G_TYPE_ENUM:
      g_value_set_enum (value, list->data.v_int);
      break;
    case G_TYPE_FLAGS:
      g_value_set_flags (value, list->data.v_uint);
      break;
    case G_TYPE_FLOAT:
      g_value_set_float (value, (gfloat) list->data.v_float);
      break;
    case G_TYPE_DOUBLE:
      g_value_set_double (value, (gdouble) list->data.v_double);
      break;
    case G_TYPE_STRING:
      g_value_set_string (value, (gchar *) list->data.v_pointer);
      break;
    case G_TYPE_POINTER:
      g_value_set_pointer (value, (gpointer) list->data.v_pointer);
      break;
    case G_TYPE_BOXED:
      g_value_set_boxed (value, (gpointer) list->data.v_pointer);
      break;
    case G_TYPE_OBJECT:
      g_value_set_object (value, (GObject *) list->data.v_pointer);
      break;
    default:
      g_warning ("%s: Unsupported type (%s) retrieved.", G_STRLOC, g_type_name (value->g_type));
      break;
    }
}
예제 #13
0
파일: gsktypes.c 프로젝트: davebenson/gsk
static void
param_fd_set_default (GParamSpec *pspec,
		      GValue     *value)
{ 
  g_value_set_int (value, -1);
}
예제 #14
0
static void
gimp_pdb_context_get_property (GObject    *object,
                               guint       property_id,
                               GValue     *value,
                               GParamSpec *pspec)
{
  GimpPDBContext *options = GIMP_PDB_CONTEXT (object);

  switch (property_id)
    {
    case PROP_ANTIALIAS:
      g_value_set_boolean (value, options->antialias);
      break;

    case PROP_FEATHER:
      g_value_set_boolean (value, options->feather);
      break;

    case PROP_FEATHER_RADIUS_X:
      g_value_set_double (value, options->feather_radius_x);
      break;

    case PROP_FEATHER_RADIUS_Y:
      g_value_set_double (value, options->feather_radius_y);
      break;

    case PROP_SAMPLE_MERGED:
      g_value_set_boolean (value, options->sample_merged);
      break;

    case PROP_SAMPLE_CRITERION:
      g_value_set_enum (value, options->sample_criterion);
      break;

    case PROP_SAMPLE_THRESHOLD:
      g_value_set_double (value, options->sample_threshold);
      break;

    case PROP_SAMPLE_TRANSPARENT:
      g_value_set_boolean (value, options->sample_transparent);
      break;

    case PROP_INTERPOLATION:
      g_value_set_enum (value, options->interpolation);
      break;

    case PROP_TRANSFORM_DIRECTION:
      g_value_set_enum (value, options->transform_direction);
      break;

    case PROP_TRANSFORM_RESIZE:
      g_value_set_enum (value, options->transform_resize);
      break;

    case PROP_TRANSFORM_RECURSION:
      g_value_set_int (value, options->transform_recursion);
      break;

    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
      break;
    }
}
예제 #15
0
static gboolean gst_tcamwhitebalance_get_tcam_property (TcamProp* prop,
                                                        gchar* name,
                                                        GValue* value,
                                                        GValue* min,
                                                        GValue* max,
                                                        GValue* def,
                                                        GValue* step,
                                                        GValue* type,
                                                        GValue* flags,
                                                        GValue* category,
                                                        GValue* group)
{
    GstTcamWhitebalance* self = GST_TCAMWHITEBALANCE(prop);

    flags = nullptr;

    if (strcmp(name, "whitebalance-red") == 0)
    {
        if (value)
        {
            g_value_init(value, G_TYPE_INT);
            g_value_set_int(value, self->red);
        }
        if (min)
        {
            g_value_init(min, G_TYPE_INT);
            g_value_set_int(min, 0);
        }
        if (max)
        {
            g_value_init(max, G_TYPE_INT);
            g_value_set_int(max, 255);
        }
        if (def)
        {
            g_value_init(def, G_TYPE_INT);
            g_value_set_int(def, 64);
        }
        if (step)
        {
            g_value_init(step, G_TYPE_INT);
            g_value_set_int(step, 1);
        }
        if (flags)
        {
            g_value_init(flags, G_TYPE_INT);
            g_value_set_int(flags, 0);
        }
        if (type)
        {
            g_value_init(type, G_TYPE_STRING);
            g_value_set_string(type,gst_tcamwhitebalance_get_property_type(prop, name));
        }
        if (category)
        {
            g_value_init(category, G_TYPE_STRING);
            g_value_set_string(category, "Color");
        }
        if (group)
        {
            g_value_init(group, G_TYPE_STRING);
            g_value_set_string(group, "Whitebalance");
        }

        return TRUE;
    }
    else if (strcmp(name, "whitebalance-green") == 0)
    {
        if (value)
        {
            g_value_init(value, G_TYPE_INT);
            g_value_set_int(value, self->green);
        }
        if (min)
        {
            g_value_init(min, G_TYPE_INT);
            g_value_set_int(min, 0);
        }
        if (max)
        {
            g_value_init(max, G_TYPE_INT);
            g_value_set_int(max, 255);
        }
        if (def)
        {
            g_value_init(def, G_TYPE_INT);
            g_value_set_int(def, 64);
        }
        if (step)
        {
            g_value_init(step, G_TYPE_INT);
            g_value_set_int(step, 1);
        }
        if (flags)
        {
            g_value_init(flags, G_TYPE_INT);
            g_value_set_int(flags, 0);
        }
        if (type)
        {
            g_value_init(type, G_TYPE_STRING);
            g_value_set_string(type,gst_tcamwhitebalance_get_property_type(prop, name));
        }
        if (category)
        {
            g_value_init(category, G_TYPE_STRING);
            g_value_set_string(category, "Color");
        }
        if (group)
        {
            g_value_init(group, G_TYPE_STRING);
            g_value_set_string(group, "Whitebalance");
        }
        return TRUE;
    }
    else if (strcmp(name, "whitebalance-blue") == 0)
    {
        if (value)
        {
            g_value_init(value, G_TYPE_INT);
            g_value_set_int(value, self->blue);
        }
        if (min)
        {
            g_value_init(min, G_TYPE_INT);
            g_value_set_int(min, 0);
        }
        if (max)
        {
            g_value_init(max, G_TYPE_INT);
            g_value_set_int(max, 255);
        }
        if (def)
        {
            g_value_init(def, G_TYPE_INT);
            g_value_set_int(def, 64);
        }
        if (step)
        {
            g_value_init(step, G_TYPE_INT);
            g_value_set_int(step, 1);
        }
        if (flags)
        {
            g_value_init(flags, G_TYPE_INT);
            g_value_set_int(flags, 0);
        }
        if (type)
        {
            g_value_init(type, G_TYPE_STRING);
            g_value_set_string(type,gst_tcamwhitebalance_get_property_type(prop, name));
        }
        if (category)
        {
            g_value_init(category, G_TYPE_STRING);
            g_value_set_string(category, "Color");
        }
        if (group)
        {
            g_value_init(group, G_TYPE_STRING);
            g_value_set_string(group, "Whitebalance");
        }
        return TRUE;
    }
    else if (strcmp(name, "whitebalance-auto") == 0)
    {
        if (value)
        {
            g_value_init(value, G_TYPE_BOOLEAN);
            g_value_set_boolean(value, self->auto_enabled);
        }
        if (min)
        {
            g_value_init(min, G_TYPE_BOOLEAN);
            g_value_set_boolean(min, FALSE);
        }
        if (max)
        {
            g_value_init(max, G_TYPE_BOOLEAN);
            g_value_set_boolean(max, TRUE);
        }
        if (def)
        {
            g_value_init(def, G_TYPE_BOOLEAN);
            g_value_set_boolean(def, TRUE);
        }
        if (step)
        {
            g_value_init(step, G_TYPE_INT);
            g_value_set_int(step, 1);
        }
        if (flags)
        {
            g_value_init(flags, G_TYPE_INT);
            g_value_set_int(flags, 0);
        }
        if (type)
        {
            g_value_init(type, G_TYPE_STRING);
            g_value_set_string(type,gst_tcamwhitebalance_get_property_type(prop, name));
        }
        if (category)
        {
            g_value_init(category, G_TYPE_STRING);
            g_value_set_string(category, "Color");
        }
        if (group)
        {
            g_value_init(group, G_TYPE_STRING);
            g_value_set_string(group, "Whitebalance");
        }
        return TRUE;
    }
    else if (strcmp(name, "camera-whitebalance") == 0)
    {
        if (value)
        {
            g_value_init(value, G_TYPE_BOOLEAN);
            g_value_set_boolean(value, self->auto_enabled);
        }
        if (min)
        {
            g_value_init(min, G_TYPE_BOOLEAN);
            g_value_set_boolean(min, FALSE);
        }
        if (max)
        {
            g_value_init(max, G_TYPE_BOOLEAN);
            g_value_set_boolean(max, TRUE);
        }
        if (def)
        {
            g_value_init(def, G_TYPE_BOOLEAN);
            g_value_set_boolean(def, FALSE);
        }
        if (step)
        {
            g_value_init(step, G_TYPE_INT);
            g_value_set_int(step, 1);
        }
        if (flags)
        {
            g_value_init(flags, G_TYPE_INT);
            g_value_set_int(flags, 0);
        }
        if (type)
        {
            g_value_init(type, G_TYPE_STRING);
            g_value_set_string(type,gst_tcamwhitebalance_get_property_type(prop, name));
        }
        if (category)
        {
            g_value_init(category, G_TYPE_STRING);
            g_value_set_string(category, "Color");
        }
        if (group)
        {
            g_value_init(group, G_TYPE_STRING);
            g_value_set_string(group, "Whitebalance");
        }        return TRUE;
    }
    else if (strcmp(name, "whitebalance-module-enabled") == 0)
    {
        if (value)
        {
            g_value_init(value, G_TYPE_BOOLEAN);
            g_value_set_boolean(value, self->auto_enabled);
        }
        if (min)
        {
            g_value_init(min, G_TYPE_BOOLEAN);
            g_value_set_boolean(min, FALSE);
        }
        if (max)
        {
            g_value_init(max, G_TYPE_BOOLEAN);
            g_value_set_boolean(max, TRUE);
        }
        if (def)
        {
            g_value_init(def, G_TYPE_BOOLEAN);
            g_value_set_boolean(def, TRUE);
        }
        if (step)
        {
            g_value_init(step, G_TYPE_INT);
            g_value_set_int(step, 1);
        }
        if (flags)
        {
            g_value_init(flags, G_TYPE_INT);
            g_value_set_int(flags, 0);
        }
        if (type)
        {
            g_value_init(type, G_TYPE_STRING);
            g_value_set_string(type,gst_tcamwhitebalance_get_property_type(prop, name));
        }
        if (category)
        {
            g_value_init(category, G_TYPE_STRING);
            g_value_set_string(category, "Color");
        }
        if (group)
        {
            g_value_init(group, G_TYPE_STRING);
            g_value_set_string(group, "Whitebalance");
        }
        return TRUE;
    }
    else
    {
        return FALSE;
    }
}
예제 #16
0
파일: main.c 프로젝트: bitptr/bytestream
/*
 * A program runner.
 */
int
main(int argc, char *argv[])
{
	int		 ch;
	GtkWidget	*box, *label, *apps_tree, *scrollable;
	GValue		 g_9 = G_VALUE_INIT;
	GtkBindingSet	*binding_set;
	struct state	*st;

	st = init_state();

	while ((ch = getopt(argc, argv, "")) != -1)
		usage();
	argc -= optind;
	argv += optind;

	gtk_init(&argc, &argv);

	if (argc > 1)
		usage();

	if (argc == 1) {
		st->name = strdup(argv[0]);
		run_app(st);
		return 0;
	}

	g_value_init(&g_9, G_TYPE_INT);
	g_value_set_int(&g_9, 9);

	window = gtk_dialog_new_with_buttons(
	    "bytestream",
	    NULL,
	    0,
	    "_Close", GTK_RESPONSE_CLOSE,
	    "_Run", GTK_RESPONSE_OK,
	    NULL);
	box = gtk_dialog_get_content_area(GTK_DIALOG(window));
	label = gtk_label_new("Select program.");
	scrollable = gtk_scrolled_window_new(NULL, NULL);
	if ((apps_tree = apps_tree_new()) == NULL)
		return 1;

	gtk_widget_set_size_request(window, 400, 300);
	g_object_set_property(G_OBJECT(box), "margin", &g_9);

	gtk_container_add(GTK_CONTAINER(scrollable), apps_tree);
	gtk_box_pack_start(GTK_BOX(box), label, /* expand */ 0, /* fill */ 1,
	    /* padding */ 3);
	gtk_box_pack_start(GTK_BOX(box), scrollable, /* expand */ 1,
	    /* fill */ 1, /* padding */ 3);

	g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL);
	g_signal_connect(window, "response", G_CALLBACK(handle_response), apps_tree);
	g_signal_connect(window, "key-press-event", G_CALLBACK(key_pressed), st);
	g_signal_connect(apps_tree, "row-activated", G_CALLBACK(app_selected), st);

	binding_set = gtk_binding_set_by_class(G_OBJECT_GET_CLASS(apps_tree));
	gtk_binding_entry_add_signal(
	    binding_set, GDK_KEY_Return, GDK_SHIFT_MASK, "select-cursor-row",
	    1, G_TYPE_BOOLEAN, TRUE);
	gtk_binding_entry_add_signal(
	    binding_set, GDK_KEY_ISO_Enter, GDK_SHIFT_MASK, "select-cursor-row",
	    1, G_TYPE_BOOLEAN, TRUE);
	gtk_binding_entry_add_signal(
	    binding_set, GDK_KEY_KP_Enter, GDK_SHIFT_MASK, "select-cursor-row",
	    1, G_TYPE_BOOLEAN, TRUE);

	gtk_widget_show_all(window);

	gtk_main();

	free_state(st);
	return 0;
}
예제 #17
0
static void
add_gvalue_owner_to_slist( const GncSqlBackend* be, QofIdTypeConst obj_name,
                           const gpointer pObject, const GncSqlColumnTableEntry* table_row, GSList** pList )
{
    GValue* subfield_value;
    GncOwner* owner;
    gchar* buf;
    const GncGUID* guid;
    gchar guid_buf[GUID_ENCODING_LENGTH+1];
    GncOwnerType type;
    QofInstance* inst = NULL;
    OwnerGetterFunc getter;

    g_return_if_fail( be != NULL );
    g_return_if_fail( obj_name != NULL );
    g_return_if_fail( pObject != NULL );
    g_return_if_fail( table_row != NULL );

    getter = (OwnerGetterFunc)gnc_sql_get_getter( obj_name, table_row );
    owner = (*getter)( pObject );

    if ( owner != NULL )
    {
        buf = g_strdup_printf( "%s_type", table_row->col_name );
        subfield_value = g_new0( GValue, 1 );
        g_value_init( subfield_value, G_TYPE_INT );
        type = gncOwnerGetType( owner );
        g_value_set_int( subfield_value, type );
        (*pList) = g_slist_append( (*pList), subfield_value );
        g_free( buf );

        buf = g_strdup_printf( "%s_guid", table_row->col_name );
        subfield_value = g_new0( GValue, 1 );
        switch ( type )
        {
        case GNC_OWNER_CUSTOMER:
            inst = QOF_INSTANCE(gncOwnerGetCustomer( owner ));
            break;

        case GNC_OWNER_JOB:
            inst = QOF_INSTANCE(gncOwnerGetJob( owner ));
            break;

        case GNC_OWNER_VENDOR:
            inst = QOF_INSTANCE(gncOwnerGetVendor( owner ));
            break;

        case GNC_OWNER_EMPLOYEE:
            inst = QOF_INSTANCE(gncOwnerGetEmployee( owner ));
            break;

        default:
            PWARN("Invalid owner type: %d\n", type );
        }
        g_value_init( subfield_value, G_TYPE_STRING );
        if ( inst != NULL )
        {
            guid = qof_instance_get_guid( inst );
            if ( guid != NULL )
            {
                (void)guid_to_string_buff( guid, guid_buf );
                g_value_take_string( subfield_value, g_strdup_printf( "%s", guid_buf ) );
            }
        }
        (*pList) = g_slist_append( (*pList), subfield_value );
        g_free( buf );
    }
    else
    {
        subfield_value = g_new0( GValue, 1 );
        g_value_init( subfield_value, G_TYPE_STRING );
        g_value_set_string( subfield_value, "NULL" );
        (*pList) = g_slist_append( (*pList), subfield_value );
        subfield_value = g_new0( GValue, 1 );
        g_value_init( subfield_value, G_TYPE_STRING );
        g_value_set_string( subfield_value, "NULL" );
        (*pList) = g_slist_append( (*pList), subfield_value );
    }
}
예제 #18
0
static void
gst_raw_audio_parse_get_property (GObject * object, guint prop_id,
    GValue * value, GParamSpec * pspec)
{
  GstRawAudioParse *raw_audio_parse = GST_RAW_AUDIO_PARSE (object);

  switch (prop_id) {
    case PROP_FORMAT:
      GST_RAW_BASE_PARSE_CONFIG_MUTEX_LOCK (object);
      g_value_set_enum (value, raw_audio_parse->properties_config.format);
      GST_RAW_BASE_PARSE_CONFIG_MUTEX_UNLOCK (object);
      break;

    case PROP_PCM_FORMAT:
      GST_RAW_BASE_PARSE_CONFIG_MUTEX_LOCK (object);
      g_value_set_enum (value, raw_audio_parse->properties_config.pcm_format);
      GST_RAW_BASE_PARSE_CONFIG_MUTEX_UNLOCK (object);
      break;

    case PROP_SAMPLE_RATE:
      GST_RAW_BASE_PARSE_CONFIG_MUTEX_LOCK (object);
      g_value_set_int (value, raw_audio_parse->properties_config.sample_rate);
      GST_RAW_BASE_PARSE_CONFIG_MUTEX_UNLOCK (object);
      break;

    case PROP_NUM_CHANNELS:
      GST_RAW_BASE_PARSE_CONFIG_MUTEX_LOCK (object);
      g_value_set_int (value, raw_audio_parse->properties_config.num_channels);
      GST_RAW_BASE_PARSE_CONFIG_MUTEX_UNLOCK (object);
      break;

    case PROP_INTERLEAVED:
      GST_RAW_BASE_PARSE_CONFIG_MUTEX_LOCK (object);
      g_value_set_boolean (value,
          raw_audio_parse->properties_config.interleaved);
      GST_RAW_BASE_PARSE_CONFIG_MUTEX_UNLOCK (object);
      break;

    case PROP_CHANNEL_POSITIONS:
    {
      GstRawAudioParseConfig *config;
      GValueArray *valarray;

      GST_RAW_BASE_PARSE_CONFIG_MUTEX_LOCK (object);

      valarray = NULL;
      config = &(raw_audio_parse->properties_config);

      /* Copy channel positions into the valuearray */
      if (config->num_channels > 0) {
        guint i;
        GValue val = G_VALUE_INIT;
        g_assert (config->channel_positions);

        g_value_init (&val, GST_TYPE_AUDIO_CHANNEL_POSITION);
        valarray = g_value_array_new (config->num_channels);

        for (i = 0; i < config->num_channels; ++i) {
          g_value_set_enum (&val, config->channel_positions[i]);
          g_value_array_insert (valarray, i, &val);
        }

        g_value_unset (&val);
      }

      GST_RAW_BASE_PARSE_CONFIG_MUTEX_UNLOCK (object);

      /* Pass on ownership to the value array,
       * since we don't need it anymore */
      g_value_take_boxed (value, valarray);

      break;
    }

    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
  }
}
예제 #19
0
static void
get_g_value_from_java_number (JNIEnv *jniEnv, jobject jnumber, GValue *value)
{
  jclass classByte = (*jniEnv)->FindClass(jniEnv, "java/lang/Byte");
  jclass classDouble = (*jniEnv)->FindClass(jniEnv, "java/lang/Double");
  jclass classFloat = (*jniEnv)->FindClass(jniEnv, "java/lang/Float");
  jclass classInteger = (*jniEnv)->FindClass(jniEnv, "java/lang/Integer");
  jclass classLong = (*jniEnv)->FindClass(jniEnv, "java/lang/Long");
  jclass classShort = (*jniEnv)->FindClass(jniEnv, "java/lang/Short");

  jmethodID jmid;

  if ((*jniEnv)->IsInstanceOf(jniEnv, jnumber, classByte))
  {
    jmid = (*jniEnv)->GetMethodID(jniEnv, classByte, "byteValue", "()B");
    g_value_init(value, G_TYPE_CHAR);
    g_value_set_schar(value,
                      (gchar)(*jniEnv)->CallByteMethod(jniEnv, jnumber, jmid));

    return;
  }

  if ((*jniEnv)->IsInstanceOf(jniEnv, jnumber, classDouble))
  {
    jmid = (*jniEnv)->GetMethodID(jniEnv, classDouble, "doubleValue", "()D");
    g_value_init(value, G_TYPE_DOUBLE);
    g_value_set_double(value,
                       (gdouble)(*jniEnv)->CallDoubleMethod(jniEnv, jnumber, jmid));

    return;
  }

  if ((*jniEnv)->IsInstanceOf(jniEnv, jnumber, classFloat))
  {
    jmid = (*jniEnv)->GetMethodID(jniEnv, classFloat, "floatValue", "()F");
    g_value_init(value, G_TYPE_FLOAT);
    g_value_set_float(value,
                      (gfloat)(*jniEnv)->CallFloatMethod(jniEnv, jnumber, jmid));

    return;
  }

  if ((*jniEnv)->IsInstanceOf(jniEnv, jnumber, classInteger)
    || (*jniEnv)->IsInstanceOf(jniEnv, jnumber, classShort))
    {
    jmid = (*jniEnv)->GetMethodID(jniEnv, classInteger, "intValue", "()I");
    g_value_init(value, G_TYPE_INT);
    g_value_set_int(value,
                    (gint)(*jniEnv)->CallIntMethod(jniEnv, jnumber, jmid));

    return;
  }

  if ((*jniEnv)->IsInstanceOf(jniEnv, jnumber, classLong)) {
    jmid = (*jniEnv)->GetMethodID(jniEnv, classLong, "longValue", "()J");
    g_value_init(value, G_TYPE_INT64);
    g_value_set_int64(value,
                      (gint64)(*jniEnv)->CallLongMethod(jniEnv, jnumber, jmid));

    return;
  }
}
예제 #20
0
/**
 * shell_perf_log_replay:
 * @perf_log: a #ShellPerfLog
 * @replay_function: (scope call): function to call for each event in the log
 * @user_data: data to pass to @replay_function
 *
 * Replays the log by calling the given function for each event
 * in the log.
 */
void
shell_perf_log_replay (ShellPerfLog            *perf_log,
                       ShellPerfReplayFunction  replay_function,
                       gpointer                 user_data)
{
  gint64 event_time = perf_log->start_time;
  GList *iter;

  for (iter = perf_log->blocks->head; iter; iter = iter->next)
    {
      ShellPerfBlock *block = iter->data;
      guint32 pos = 0;

      while (pos < block->bytes)
        {
          ShellPerfEvent *event;
          guint16 id;
          guint32 time_delta;
          GValue arg = { 0, };

          memcpy (&time_delta, block->buffer + pos, sizeof (guint32));
          pos += sizeof (guint32);
          memcpy (&id, block->buffer + pos, sizeof (guint16));
          pos += sizeof (guint16);

          if (id == EVENT_SET_TIME)
            {
              /* Internal, we don't include in the replay */
              memcpy (&event_time, block->buffer + pos, sizeof (gint64));
              pos += sizeof (gint64);
              continue;
            }
          else
            {
              event_time += time_delta;
            }

          event = g_ptr_array_index (perf_log->events, id);

          if (strcmp (event->signature, "") == 0)
            {
              /* We need to pass something, so pass an empty string */
              g_value_init (&arg, G_TYPE_STRING);
            }
          else if (strcmp (event->signature, "i") == 0)
            {
              gint32 l;

              memcpy (&l, block->buffer + pos, sizeof (gint32));
              pos += sizeof (gint32);

              g_value_init (&arg, G_TYPE_INT);
              g_value_set_int (&arg, l);
            }
          else if (strcmp (event->signature, "x") == 0)
            {
              gint64 l;

              memcpy (&l, block->buffer + pos, sizeof (gint64));
              pos += sizeof (gint64);

              g_value_init (&arg, G_TYPE_INT64);
              g_value_set_int64 (&arg, l);
            }
          else if (strcmp (event->signature, "s") == 0)
            {
              g_value_init (&arg, G_TYPE_STRING);
              g_value_set_string (&arg, (char *)block->buffer + pos);
              pos += strlen ((char *)(block->buffer + pos)) + 1;
            }

          replay_function (event_time, event->name, event->signature, &arg, user_data);
          g_value_unset (&arg);
        }
    }
}
예제 #21
0
static void
gimp_operation_tool_color_picked (GimpImageMapTool  *im_tool,
                                  gpointer           identifier,
                                  gdouble            x,
                                  gdouble            y,
                                  const Babl        *sample_format,
                                  const GimpRGB     *color)
{
    GimpOperationTool  *tool = GIMP_OPERATION_TOOL (im_tool);
    gchar             **pspecs;

    pspecs = g_strsplit (identifier, ":", 2);

    if (pspecs[1])
    {
        GimpImageMapOptions *options      = GIMP_IMAGE_MAP_TOOL_GET_OPTIONS (tool);
        GimpDrawable        *drawable     = GIMP_TOOL (im_tool)->drawable;
        GObjectClass        *object_class = G_OBJECT_GET_CLASS (tool->config);
        GParamSpec          *pspec_x;
        GParamSpec          *pspec_y;
        gint                 width        = 1;
        gint                 height       = 1;

        if (drawable)
        {
            gint off_x, off_y;

            gimp_item_get_offset (GIMP_ITEM (drawable), &off_x, &off_y);

            x -= off_x;
            y -= off_y;

            switch (options->region)
            {
            case GIMP_IMAGE_MAP_REGION_SELECTION:
                if (gimp_item_mask_intersect (GIMP_ITEM (drawable),
                                              &off_x, &off_y, &width, &height))
                {
                    x -= off_x;
                    y -= off_y;
                }
                break;

            case GIMP_IMAGE_MAP_REGION_DRAWABLE:
                width  = gimp_item_get_width  (GIMP_ITEM (drawable));
                height = gimp_item_get_height (GIMP_ITEM (drawable));
                break;
            }
        }

        pspec_x = g_object_class_find_property (object_class, pspecs[0]);
        pspec_y = g_object_class_find_property (object_class, pspecs[1]);

        if (pspec_x && pspec_y &&
                G_PARAM_SPEC_TYPE (pspec_x) == G_PARAM_SPEC_TYPE (pspec_y))
        {
            GValue value_x = G_VALUE_INIT;
            GValue value_y = G_VALUE_INIT;

            g_value_init (&value_x, G_PARAM_SPEC_VALUE_TYPE (pspec_x));
            g_value_init (&value_y, G_PARAM_SPEC_VALUE_TYPE (pspec_y));

#define HAS_KEY(p,k,v) gimp_gegl_param_spec_has_key (p, k, v)

            if (HAS_KEY (pspec_x, "unit", "relative-coordinate") &&
                    HAS_KEY (pspec_y, "unit", "relative-coordinate"))
            {
                x /= (gdouble) width;
                y /= (gdouble) height;
            }

            if (G_IS_PARAM_SPEC_INT (pspec_x))
            {
                g_value_set_int (&value_x, x);
                g_value_set_int (&value_y, y);

                g_param_value_validate (pspec_x, &value_x);
                g_param_value_validate (pspec_y, &value_y);

                g_object_set (tool->config,
                              pspecs[0], g_value_get_int (&value_x),
                              pspecs[1], g_value_get_int (&value_y),
                              NULL);
            }
            else if (G_IS_PARAM_SPEC_DOUBLE (pspec_x))
            {
                g_value_set_double (&value_x, x);
                g_value_set_double (&value_y, y);

                g_param_value_validate (pspec_x, &value_x);
                g_param_value_validate (pspec_y, &value_y);

                g_object_set (tool->config,
                              pspecs[0], g_value_get_double (&value_x),
                              pspecs[1], g_value_get_double (&value_y),
                              NULL);
            }
            else
            {
                g_warning ("%s: unhandled param spec of type %s",
                           G_STRFUNC, G_PARAM_SPEC_TYPE_NAME (pspec_x));
            }

            g_value_unset (&value_x);
            g_value_unset (&value_y);
        }
    }
    else
    {
        g_object_set (tool->config,
                      pspecs[0], color,
                      NULL);
    }

    g_strfreev (pspecs);
}
static void
transform_string_to_int (const GValue *src,
                         GValue       *dst)
{
  g_value_set_int (dst, (gint) strtol (g_value_get_string (src), NULL, 10));
}
예제 #23
0
gint
pygi_set_property_value_real (PyGObject *instance,
                              const gchar *attr_name,
                              PyObject *py_value)
{
    GType g_type;
    GIPropertyInfo *property_info = NULL;
    char *property_name = g_strdup (attr_name);
    GITypeInfo *type_info = NULL;
    GITypeTag type_tag;
    GITransfer transfer;
    GValue value = { 0, };
    GIArgument arg = { 0, };
    GParamSpec *pspec = NULL;
    gint ret_value = -1;

    canonicalize_key (property_name);

    g_type = pyg_type_from_object ((PyObject *)instance);
    property_info = _pygi_lookup_property_from_g_type (g_type, property_name);

    if (property_info == NULL)
        goto out;

    pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (instance->obj),
                                          attr_name);
    if (pspec == NULL)
        goto out;

    if (! (pspec->flags & G_PARAM_WRITABLE))
        goto out;

    type_info = g_property_info_get_type (property_info);
    transfer = g_property_info_get_ownership_transfer (property_info);
    arg = _pygi_argument_from_object (py_value, type_info, transfer);

    if (PyErr_Occurred())
        goto out;

    g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec));

    // FIXME: Lots of types still unhandled
    type_tag = g_type_info_get_tag (type_info);
    switch (type_tag) {
        case GI_TYPE_TAG_INTERFACE:
        {
            GIBaseInfo *info;
            GIInfoType info_type;
            GType type;

            info = g_type_info_get_interface (type_info);
            type = g_registered_type_info_get_g_type (info);
            info_type = g_base_info_get_type (info);

            g_base_info_unref (info);

            switch (info_type) {
                case GI_INFO_TYPE_ENUM:
                    g_value_set_enum (&value, arg.v_int32);
                    break;
                case GI_INFO_TYPE_INTERFACE:
                case GI_INFO_TYPE_OBJECT:
                    g_value_set_object (&value, arg.v_pointer);
                    break;
                case GI_INFO_TYPE_BOXED:
                case GI_INFO_TYPE_STRUCT:
                case GI_INFO_TYPE_UNION:
                    if (g_type_is_a (type, G_TYPE_BOXED)) {
                        g_value_set_boxed (&value, arg.v_pointer);
                    } else {
                        PyErr_Format (PyExc_NotImplementedError,
                                      "Setting properties of type '%s' is not implemented",
                                      g_type_name (type));
                    }
                    break;
                default:
                    PyErr_Format (PyExc_NotImplementedError,
                                  "Setting properties of type '%s' is not implemented",
                                  g_type_name (type));
                    goto out;
            }
            break;
        }
        case GI_TYPE_TAG_BOOLEAN:
            g_value_set_boolean (&value, arg.v_boolean);
            break;
        case GI_TYPE_TAG_INT8:
            g_value_set_schar (&value, arg.v_int8);
            break;
        case GI_TYPE_TAG_INT16:
        case GI_TYPE_TAG_INT32:
            if (G_VALUE_HOLDS_LONG (&value))
                g_value_set_long (&value, arg.v_long);
            else
                g_value_set_int (&value, arg.v_int);
            break;
        case GI_TYPE_TAG_INT64:
            if (G_VALUE_HOLDS_LONG (&value))
                g_value_set_long (&value, arg.v_long);
            else
                g_value_set_int64 (&value, arg.v_int64);
            break;
        case GI_TYPE_TAG_UINT8:
            g_value_set_uchar (&value, arg.v_uint8);
            break;
        case GI_TYPE_TAG_UINT16:
        case GI_TYPE_TAG_UINT32:
            if (G_VALUE_HOLDS_ULONG (&value))
                g_value_set_ulong (&value, arg.v_ulong);
            else
                g_value_set_uint (&value, arg.v_uint);
            break;
        case GI_TYPE_TAG_UINT64:
            if (G_VALUE_HOLDS_ULONG (&value))
                g_value_set_ulong (&value, arg.v_ulong);
            else
                g_value_set_uint64 (&value, arg.v_uint64);
            break;
        case GI_TYPE_TAG_FLOAT:
            g_value_set_float (&value, arg.v_float);
            break;
        case GI_TYPE_TAG_DOUBLE:
            g_value_set_double (&value, arg.v_double);
            break;
        case GI_TYPE_TAG_GTYPE:
            g_value_set_gtype (&value, arg.v_size);
            break;
        case GI_TYPE_TAG_UTF8:
        case GI_TYPE_TAG_FILENAME:
            g_value_set_string (&value, arg.v_string);
            break;
        case GI_TYPE_TAG_GHASH:
            g_value_set_boxed (&value, arg.v_pointer);
            break;
        case GI_TYPE_TAG_GLIST:
            g_value_set_pointer (&value, arg.v_pointer);
            break;
        case GI_TYPE_TAG_ARRAY:
        {
            GArray *arg_items = (GArray*) arg.v_pointer;
            gchar** strings;
            int i;

            if (arg_items == NULL)
                goto out;

            strings = g_new0 (char*, arg_items->len);
            for (i = 0; i < arg_items->len; ++i) {
                strings[i] = g_array_index (arg_items, GIArgument, i).v_string;
            }
            g_array_free (arg_items, TRUE);
            g_value_set_boxed (&value, strings);
            break;
        }
        default:
            PyErr_Format (PyExc_NotImplementedError,
                          "Setting properties of type %s is not implemented",
                          g_type_tag_to_string (g_type_info_get_tag (type_info)));
            goto out;
    }

    g_object_set_property (instance->obj, attr_name, &value);

    ret_value = 0;

out:
    g_free (property_name);
    if (property_info != NULL)
        g_base_info_unref (property_info);
    if (type_info != NULL)
        g_base_info_unref (type_info);

    return ret_value;
}
예제 #24
0
/* Note that g_value_set_object() refs the object, as does
 * g_object_get(). But g_object_get() only unrefs once when it disgorges
 * the object, leaving an unbalanced ref, which leaks. So instead of
 * using g_value_set_object(), use g_value_take_object() which doesn't
 * ref the object when used in get_property().
 */
static void
gnc_schedxaction_get_property (GObject         *object,
                               guint            prop_id,
                               GValue          *value,
                               GParamSpec      *pspec)
{
    SchedXaction *sx;

    g_return_if_fail(GNC_IS_SCHEDXACTION(object));

    sx = GNC_SCHEDXACTION(object);
    switch (prop_id)
    {
    case PROP_NAME:
        g_value_set_string(value, sx->name);
        break;
    case PROP_ENABLED:
        g_value_set_boolean(value, sx->enabled);
        break;
    case PROP_NUM_OCCURANCE:
        g_value_set_int(value, sx->num_occurances_total);
        break;
    case PROP_REM_OCCURANCE:
        g_value_set_int(value, sx->num_occurances_remain);
        break;
    case PROP_AUTO_CREATE:
        g_value_set_boolean(value, sx->autoCreateOption);
        break;
    case PROP_AUTO_CREATE_NOTIFY:
        g_value_set_boolean(value, sx->autoCreateNotify);
        break;
    case PROP_ADVANCE_CREATION_DAYS:
        g_value_set_int(value, sx->advanceCreateDays);
        break;
    case PROP_ADVANCE_REMINDER_DAYS:
        g_value_set_int(value, sx->advanceRemindDays);
        break;
    case PROP_START_DATE:
        g_value_set_boxed(value, &sx->start_date);
        break;
    case PROP_END_DATE:
        /* g_value_set_boxed raises a critical error if sx->end_date
         * is invalid */
        if (g_date_valid (&sx->end_date))
            g_value_set_boxed(value, &sx->end_date);
        break;
    case PROP_LAST_OCCURANCE_DATE:
     /* g_value_set_boxed raises a critical error if sx->last_date
         * is invalid */
        if (g_date_valid (&sx->last_date))
            g_value_set_boxed(value, &sx->last_date);
        break;
    case PROP_INSTANCE_COUNT:
        g_value_set_int(value, sx->instance_num);
        break;
    case PROP_TEMPLATE_ACCOUNT:
        g_value_take_object(value, sx->template_acct);
        break;
    default:
        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
        break;
    }
}
static void
gst_video_parse_get_property (GObject * object, guint prop_id, GValue * value,
    GParamSpec * pspec)
{
  GstVideoParse *vp = GST_VIDEO_PARSE (object);

  switch (prop_id) {
    case PROP_FORMAT:{
      GstVideoFormat format;
      g_object_get (G_OBJECT (vp->rawvideoparse), "format", &format, NULL);
      g_value_set_enum (value, format);
      break;
    }

    case PROP_WIDTH:{
      gint width;
      g_object_get (G_OBJECT (vp->rawvideoparse), "width", &width, NULL);
      g_value_set_int (value, width);
      break;
    }

    case PROP_HEIGHT:{
      gint height;
      g_object_get (G_OBJECT (vp->rawvideoparse), "height", &height, NULL);
      g_value_set_int (value, height);
      break;
    }

    case PROP_FRAMERATE:{
      gint fps_n, fps_d;
      g_object_get (G_OBJECT (vp->rawvideoparse), "framerate", &fps_n, &fps_d,
          NULL);
      gst_value_set_fraction (value, fps_n, fps_d);
      break;
    }

    case PROP_PAR:{
      gint par_n, par_d;
      g_object_get (G_OBJECT (vp->rawvideoparse), "pixel-aspect-ratio", &par_n,
          &par_d, NULL);
      gst_value_set_fraction (value, par_n, par_d);
      break;
    }

    case PROP_INTERLACED:{
      gboolean interlaced;
      g_object_get (G_OBJECT (vp->rawvideoparse), "interlaced", &interlaced,
          NULL);
      g_value_set_boolean (value, interlaced);
      break;
    }

    case PROP_TOP_FIELD_FIRST:{
      gboolean top_field_first;
      g_object_get (G_OBJECT (vp->rawvideoparse), "top-field-first",
          &top_field_first, NULL);
      g_value_set_boolean (value, top_field_first);
      break;
    }

    case PROP_STRIDES:{
      GValueArray *array;
      g_object_get (G_OBJECT (vp->rawvideoparse), "plane-strides", &array,
          NULL);
      g_value_take_string (value,
          gst_video_parse_int_valarray_to_string (array));
      break;
    }

    case PROP_OFFSETS:{
      GValueArray *array;
      g_object_get (G_OBJECT (vp->rawvideoparse), "plane-offsets", &array,
          NULL);
      g_value_take_string (value,
          gst_video_parse_int_valarray_to_string (array));
      break;
    }

    case PROP_FRAMESIZE:{
      guint frame_stride;
      g_object_get (G_OBJECT (vp->rawvideoparse), "frame-stride", &frame_stride,
          NULL);
      g_value_set_uint (value, frame_stride);
      break;
    }

    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
  }
}
static gboolean
gst_video_crop_transform_dimension_value (const GValue * src_val,
    gint delta, GValue * dest_val, GstPadDirection direction, gboolean dynamic)
{
  gboolean ret = TRUE;

  if (G_VALUE_HOLDS_INT (src_val)) {
    gint ival = g_value_get_int (src_val);
    ival = gst_video_crop_transform_dimension (ival, delta);

    if (dynamic) {
      if (direction == GST_PAD_SRC) {
        if (ival == G_MAXINT) {
          g_value_init (dest_val, G_TYPE_INT);
          g_value_set_int (dest_val, ival);
        } else {
          g_value_init (dest_val, GST_TYPE_INT_RANGE);
          gst_value_set_int_range (dest_val, ival, G_MAXINT);
        }
      } else {
        if (ival == 1) {
          g_value_init (dest_val, G_TYPE_INT);
          g_value_set_int (dest_val, ival);
        } else {
          g_value_init (dest_val, GST_TYPE_INT_RANGE);
          gst_value_set_int_range (dest_val, 1, ival);
        }
      }
    } else {
      g_value_init (dest_val, G_TYPE_INT);
      g_value_set_int (dest_val, ival);
    }
  } else if (GST_VALUE_HOLDS_INT_RANGE (src_val)) {
    gint min = gst_value_get_int_range_min (src_val);
    gint max = gst_value_get_int_range_max (src_val);

    min = gst_video_crop_transform_dimension (min, delta);
    max = gst_video_crop_transform_dimension (max, delta);

    if (dynamic) {
      if (direction == GST_PAD_SRC)
        max = G_MAXINT;
      else
        min = 1;
    }

    if (min == max) {
      g_value_init (dest_val, G_TYPE_INT);
      g_value_set_int (dest_val, min);
    } else {
      g_value_init (dest_val, GST_TYPE_INT_RANGE);
      gst_value_set_int_range (dest_val, min, max);
    }
  } else if (GST_VALUE_HOLDS_LIST (src_val)) {
    gint i;

    g_value_init (dest_val, GST_TYPE_LIST);

    for (i = 0; i < gst_value_list_get_size (src_val); ++i) {
      const GValue *list_val;
      GValue newval = { 0, };

      list_val = gst_value_list_get_value (src_val, i);
      if (gst_video_crop_transform_dimension_value (list_val, delta, &newval,
              direction, dynamic))
        gst_value_list_append_value (dest_val, &newval);
      g_value_unset (&newval);
    }

    if (gst_value_list_get_size (dest_val) == 0) {
      g_value_unset (dest_val);
      ret = FALSE;
    }
  } else {
    ret = FALSE;
  }

  return ret;
}
예제 #27
0
/*
 * "Adds" app window to the set of managed windows.
 * Actually, no data structures involved. The only thing we do is save app state
 * and register ourselves us listeners.
 * Note: User's callback is called
 */
void
xkl_engine_add_toplevel_window(XklEngine * engine, Window toplevel_win,
			       Window parent,
			       gboolean ignore_existing_state,
			       XklState * init_state)
{
	XklState state = *init_state;
	gint default_group_to_use = -1;
	GValue params[3];
	GValue rv;
	guint signal_id;

	if (toplevel_win == xkl_engine_priv(engine, root_window))
		xkl_debug(150, "??? root app win ???\n");

	xkl_debug(150,
		  "Trying to add window " WINID_FORMAT
		  "/%s with group %d\n", toplevel_win,
		  xkl_get_debug_window_title(engine, toplevel_win),
		  init_state->group);

	if (!ignore_existing_state) {
		gboolean have_state =
		    xkl_engine_get_toplevel_window_state(engine,
							 toplevel_win,
							 &state);

		if (have_state) {
			xkl_debug(150,
				  "The window " WINID_FORMAT
				  " does not require to be added, it already has the xklavier state \n",
				  toplevel_win);
			return;
		}
	}
	memset(params, 0, sizeof(params));
	g_value_init(params, XKL_TYPE_ENGINE);
	g_value_set_object(params, engine);
	g_value_init(params + 1, G_TYPE_LONG);
	g_value_set_long(params + 1, toplevel_win);
	g_value_init(params + 2, G_TYPE_LONG);
	g_value_set_long(params + 2, parent);

	memset(&rv, 0, sizeof(rv));
	g_value_init(&rv, G_TYPE_INT);
	g_value_set_int(&rv, default_group_to_use);

	signal_id =
	    g_signal_lookup("new-toplevel-window", xkl_engine_get_type());
	g_signal_emitv(params, signal_id, 0, &rv);
	default_group_to_use = g_value_get_int(&rv);
        
	if (default_group_to_use == -1) {
		Window transient_for = 0;
		if (XGetTransientForHint(xkl_engine_get_display(engine), toplevel_win, &transient_for)) {
			if (transient_for) {
				XklState trans_state;
				gboolean have_state =
					xkl_engine_get_toplevel_window_state(engine,
							 transient_for,
							 &trans_state);
				if (have_state) {
					default_group_to_use = trans_state.group;
				}
			}
		}
	}

	if (default_group_to_use == -1)
		default_group_to_use =
		    xkl_engine_priv(engine, default_group);

	if (default_group_to_use != -1)
		state.group = default_group_to_use;

	xkl_engine_save_toplevel_window_state(engine, toplevel_win,
					      &state);
	xkl_engine_select_input_merging(engine, toplevel_win,
					FocusChangeMask |
					PropertyChangeMask);

	if (default_group_to_use != -1) {
		if (xkl_engine_priv(engine, curr_toplvl_win) ==
		    toplevel_win) {
			if ((xkl_engine_priv(engine, secondary_groups_mask)
			     & (1 << default_group_to_use)) != 0)
				xkl_engine_allow_one_switch_to_secondary_group
				    (engine);
			xkl_engine_lock_group(engine,
					      default_group_to_use);
		}
	}

	if (parent == (Window) NULL)
		parent =
		    xkl_engine_get_registered_parent(engine, toplevel_win);

	xkl_debug(150, "done\n");
}
예제 #28
0
static void
virt_viewer_file_get_property(GObject* object, guint property_id,
                        GValue* value, GParamSpec* pspec)
{
    VirtViewerFile *self = VIRT_VIEWER_FILE(object);

    switch (property_id) {
    case PROP_TYPE:
        g_value_take_string(value, virt_viewer_file_get_file_type(self));
        break;
    case PROP_HOST:
        g_value_take_string(value, virt_viewer_file_get_host(self));
        break;
    case PROP_PORT:
        g_value_set_int(value, virt_viewer_file_get_port(self));
        break;
    case PROP_TLS_PORT:
        g_value_set_int(value, virt_viewer_file_get_tls_port(self));
        break;
    case PROP_USERNAME:
        g_value_take_string(value, virt_viewer_file_get_username(self));
        break;
    case PROP_PASSWORD:
        g_value_take_string(value, virt_viewer_file_get_password(self));
        break;
    case PROP_DISABLE_CHANNELS:
        g_value_take_boxed(value, virt_viewer_file_get_disable_channels(self, NULL));
        break;
    case PROP_TLS_CIPHERS:
        g_value_take_string(value, virt_viewer_file_get_tls_ciphers(self));
        break;
    case PROP_CA:
        g_value_take_string(value, virt_viewer_file_get_ca(self));
        break;
    case PROP_HOST_SUBJECT:
        g_value_take_string(value, virt_viewer_file_get_host_subject(self));
        break;
    case PROP_FULLSCREEN:
        g_value_set_int(value, virt_viewer_file_get_fullscreen(self));
        break;
    case PROP_TITLE:
        g_value_take_string(value, virt_viewer_file_get_title(self));
        break;
    case PROP_TOGGLE_FULLSCREEN:
        g_value_take_string(value, virt_viewer_file_get_toggle_fullscreen(self));
        break;
    case PROP_RELEASE_CURSOR:
        g_value_take_string(value, virt_viewer_file_get_release_cursor(self));
        break;
    case PROP_SECURE_ATTENTION:
        g_value_take_string(value, virt_viewer_file_get_secure_attention(self));
        break;
    case PROP_ENABLE_SMARTCARD:
        g_value_set_int(value, virt_viewer_file_get_enable_smartcard(self));
        break;
    case PROP_ENABLE_USBREDIR:
        g_value_set_int(value, virt_viewer_file_get_enable_usbredir(self));
        break;
    case PROP_COLOR_DEPTH:
        g_value_set_int(value, virt_viewer_file_get_color_depth(self));
        break;
    case PROP_DISABLE_EFFECTS:
        g_value_take_boxed(value, virt_viewer_file_get_disable_effects(self, NULL));
        break;
    case PROP_ENABLE_USB_AUTOSHARE:
        g_value_set_int(value, virt_viewer_file_get_enable_usb_autoshare(self));
        break;
    case PROP_USB_FILTER:
        g_value_take_string(value, virt_viewer_file_get_usb_filter(self));
        break;
    case PROP_PROXY:
        g_value_take_string(value, virt_viewer_file_get_proxy(self));
        break;
    case PROP_VERSION:
        g_value_take_string(value, virt_viewer_file_get_version(self));
        break;
    case PROP_VERSIONS:
        g_value_take_boxed(value, virt_viewer_file_get_versions(self));
        break;
    case PROP_VERSION_URL:
        g_value_take_string(value, virt_viewer_file_get_version_url(self));
        break;
    case PROP_SECURE_CHANNELS:
        g_value_take_boxed(value, virt_viewer_file_get_secure_channels(self, NULL));
        break;
    case PROP_DELETE_THIS_FILE:
        g_value_set_int(value, virt_viewer_file_get_delete_this_file(self));
        break;
    case PROP_OVIRT_ADMIN:
        g_value_set_int(value, virt_viewer_file_get_ovirt_admin(self));
        break;
    case PROP_OVIRT_HOST:
        g_value_take_string(value, virt_viewer_file_get_ovirt_host(self));
        break;
    case PROP_OVIRT_VM_GUID:
        g_value_take_string(value, virt_viewer_file_get_ovirt_vm_guid(self));
        break;
    case PROP_OVIRT_JSESSIONID:
        g_value_take_string(value, virt_viewer_file_get_ovirt_jsessionid(self));
        break;
    case PROP_OVIRT_SSO_TOKEN:
        g_value_take_string(value, virt_viewer_file_get_ovirt_sso_token(self));
        break;
    case PROP_OVIRT_CA:
        g_value_take_string(value, virt_viewer_file_get_ovirt_ca(self));
        break;
    default:
        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
        break;
    }
}
예제 #29
0
static void
gimp_operation_tool_color_picked (GimpFilterTool  *filter_tool,
                                  gpointer         identifier,
                                  gdouble          x,
                                  gdouble          y,
                                  const Babl      *sample_format,
                                  const GimpRGB   *color)
{
  gchar **pspecs = g_strsplit (identifier, ":", 2);

  if (pspecs[1])
    {
      GObjectClass  *object_class = G_OBJECT_GET_CLASS (filter_tool->config);
      GParamSpec    *pspec_x;
      GParamSpec    *pspec_y;
      gint           off_x, off_y;
      GeglRectangle  area;

      gimp_filter_tool_get_drawable_area (filter_tool, &off_x, &off_y, &area);

      x -= off_x + area.x;
      y -= off_y + area.y;

      pspec_x = g_object_class_find_property (object_class, pspecs[0]);
      pspec_y = g_object_class_find_property (object_class, pspecs[1]);

      if (pspec_x && pspec_y &&
          G_PARAM_SPEC_TYPE (pspec_x) == G_PARAM_SPEC_TYPE (pspec_y))
        {
          GValue value_x = G_VALUE_INIT;
          GValue value_y = G_VALUE_INIT;

          g_value_init (&value_x, G_PARAM_SPEC_VALUE_TYPE (pspec_x));
          g_value_init (&value_y, G_PARAM_SPEC_VALUE_TYPE (pspec_y));

#define HAS_KEY(p,k,v) gimp_gegl_param_spec_has_key (p, k, v)

          if (HAS_KEY (pspec_x, "unit", "relative-coordinate") &&
              HAS_KEY (pspec_y, "unit", "relative-coordinate"))
            {
              x /= (gdouble) area.width;
              y /= (gdouble) area.height;
            }

          if (G_IS_PARAM_SPEC_INT (pspec_x))
            {
              g_value_set_int (&value_x, x);
              g_value_set_int (&value_y, y);

              g_param_value_validate (pspec_x, &value_x);
              g_param_value_validate (pspec_y, &value_y);

              g_object_set (filter_tool->config,
                            pspecs[0], g_value_get_int (&value_x),
                            pspecs[1], g_value_get_int (&value_y),
                            NULL);
            }
          else if (G_IS_PARAM_SPEC_DOUBLE (pspec_x))
            {
              g_value_set_double (&value_x, x);
              g_value_set_double (&value_y, y);

              g_param_value_validate (pspec_x, &value_x);
              g_param_value_validate (pspec_y, &value_y);

              g_object_set (filter_tool->config,
                            pspecs[0], g_value_get_double (&value_x),
                            pspecs[1], g_value_get_double (&value_y),
                            NULL);
            }
          else
            {
              g_warning ("%s: unhandled param spec of type %s",
                         G_STRFUNC, G_PARAM_SPEC_TYPE_NAME (pspec_x));
            }

          g_value_unset (&value_x);
          g_value_unset (&value_y);
        }
    }
  else
    {
      g_object_set (filter_tool->config,
                    pspecs[0], color,
                    NULL);
    }

  g_strfreev (pspecs);
}
예제 #30
0
static GstStructure *gst_avdtp_sink_parse_mpeg_caps(
			GstAvdtpSink *self, mpeg_capabilities_t *mpeg)
{
	GstStructure *structure;
	GValue *value;
	GValue *list;
	gboolean valid_layer = FALSE;
	gboolean mono, stereo;

	if (!mpeg)
		return NULL;

	GST_LOG_OBJECT(self, "parsing mpeg caps");

	structure = gst_structure_empty_new("audio/mpeg");
	value = g_new0(GValue, 1);
	g_value_init(value, G_TYPE_INT);

	list = g_value_init(g_new0(GValue, 1), GST_TYPE_LIST);
	g_value_set_int(value, 1);
	gst_value_list_prepend_value(list, value);
	g_value_set_int(value, 2);
	gst_value_list_prepend_value(list, value);
	gst_structure_set_value(structure, "mpegversion", list);
	g_free(list);

	/* layer */
	GST_LOG_OBJECT(self, "setting mpeg layer");
	list = g_value_init(g_new0(GValue, 1), GST_TYPE_LIST);
	if (mpeg->layer & BT_MPEG_LAYER_1) {
		g_value_set_int(value, 1);
		gst_value_list_prepend_value(list, value);
		valid_layer = TRUE;
	}
	if (mpeg->layer & BT_MPEG_LAYER_2) {
		g_value_set_int(value, 2);
		gst_value_list_prepend_value(list, value);
		valid_layer = TRUE;
	}
	if (mpeg->layer & BT_MPEG_LAYER_3) {
		g_value_set_int(value, 3);
		gst_value_list_prepend_value(list, value);
		valid_layer = TRUE;
	}
	if (list) {
		gst_structure_set_value(structure, "layer", list);
		g_free(list);
		list = NULL;
	}

	if (!valid_layer) {
		gst_structure_free(structure);
		g_free(value);
		return NULL;
	}

	/* rate */
	GST_LOG_OBJECT(self, "setting mpeg rate");
	list = g_value_init(g_new0(GValue, 1), GST_TYPE_LIST);
	if (mpeg->frequency & BT_MPEG_SAMPLING_FREQ_48000) {
		g_value_set_int(value, 48000);
		gst_value_list_prepend_value(list, value);
	}
	if (mpeg->frequency & BT_MPEG_SAMPLING_FREQ_44100) {
		g_value_set_int(value, 44100);
		gst_value_list_prepend_value(list, value);
	}
	if (mpeg->frequency & BT_MPEG_SAMPLING_FREQ_32000) {
		g_value_set_int(value, 32000);
		gst_value_list_prepend_value(list, value);
	}
	if (mpeg->frequency & BT_MPEG_SAMPLING_FREQ_24000) {
		g_value_set_int(value, 24000);
		gst_value_list_prepend_value(list, value);
	}
	if (mpeg->frequency & BT_MPEG_SAMPLING_FREQ_22050) {
		g_value_set_int(value, 22050);
		gst_value_list_prepend_value(list, value);
	}
	if (mpeg->frequency & BT_MPEG_SAMPLING_FREQ_16000) {
		g_value_set_int(value, 16000);
		gst_value_list_prepend_value(list, value);
	}
	g_value_unset(value);
	if (list) {
		gst_structure_set_value(structure, "rate", list);
		g_free(list);
		list = NULL;
	}

	/* channels */
	GST_LOG_OBJECT(self, "setting mpeg channels");
	mono = FALSE;
	stereo = FALSE;
	if (mpeg->channel_mode & BT_A2DP_CHANNEL_MODE_MONO)
		mono = TRUE;
	if ((mpeg->channel_mode & BT_A2DP_CHANNEL_MODE_STEREO) ||
			(mpeg->channel_mode &
			BT_A2DP_CHANNEL_MODE_DUAL_CHANNEL) ||
			(mpeg->channel_mode &
			BT_A2DP_CHANNEL_MODE_JOINT_STEREO))
		stereo = TRUE;

	if (mono && stereo) {
		g_value_init(value, GST_TYPE_INT_RANGE);
		gst_value_set_int_range(value, 1, 2);
	} else {
		g_value_init(value, G_TYPE_INT);
		if (mono)
			g_value_set_int(value, 1);
		else if (stereo)
			g_value_set_int(value, 2);
		else {
			GST_ERROR_OBJECT(self,
				"Unexpected number of channels");
			g_value_set_int(value, 0);
		}
	}
	gst_structure_set_value(structure, "channels", value);
	g_free(value);

	return structure;
}