示例#1
0
文件: json.c 项目: GNOME/gegl
static GParamSpec *
copy_param_spec(GParamSpec *in, const gchar *name) {

  const gchar * blurb = g_param_spec_get_blurb(in);
  GParamSpec *out = NULL;

  GParamFlags flags = G_PARAM_READWRITE;

  // TODO: handle more things
  if (G_IS_PARAM_SPEC_FLOAT(in)) {
    GParamSpecFloat *f = G_PARAM_SPEC_FLOAT(in);
    out = g_param_spec_double(name, name, blurb, f->minimum, f->maximum, f->default_value, flags);
  } else if (G_IS_PARAM_SPEC_DOUBLE(in)) {
    GParamSpecDouble *d = G_PARAM_SPEC_DOUBLE(in);
    out = g_param_spec_double(name, name, blurb, d->minimum, d->maximum, d->default_value, flags);
  } else if (G_IS_PARAM_SPEC_INT(in)) {
    GParamSpecInt *i = G_PARAM_SPEC_INT(in);
    out = g_param_spec_int(name, name, blurb, i->minimum, i->maximum, i->default_value, flags);
  } else if (G_IS_PARAM_SPEC_UINT(in)) {
    GParamSpecUInt *u = G_PARAM_SPEC_UINT(in);
    out = g_param_spec_int(name, name, blurb, u->minimum, u->maximum, u->default_value, flags);
  } else if (G_IS_PARAM_SPEC_LONG(in)) {
    GParamSpecLong *l = G_PARAM_SPEC_LONG(in);
    out = g_param_spec_int(name, name, blurb, l->minimum, l->maximum, l->default_value, flags);
  } else if (GEGL_IS_PARAM_SPEC_COLOR(in)) {
    GeglColor *default_value = gegl_param_spec_color_get_default(in);
    out = gegl_param_spec_color(name, name, blurb, default_value, flags);
  } else {
    g_critical("json: Unknown param spec type for property %s", g_param_spec_get_nick(in));
  }
  return out;
}
示例#2
0
static void *
vips_operation_class_usage_arg( VipsObjectClass *object_class, 
	GParamSpec *pspec, VipsArgumentClass *argument_class,
	VipsBuf *buf, VipsOperationClassUsage *usage )
{
	/* Only show construct args ... others are internal.
	 */
	if( usage->required == 
		((argument_class->flags & VIPS_ARGUMENT_REQUIRED) != 0) &&
		(argument_class->flags & VIPS_ARGUMENT_CONSTRUCT) &&
		!(argument_class->flags & VIPS_ARGUMENT_DEPRECATED) ) { 
		if( usage->message && usage->n == 0 ) 
			vips_buf_appendf( buf, "%s\n", usage->message );

		if( usage->oftype ) {
			vips_buf_appendf( buf, "   %-12s - %s, %s %s\n",
				g_param_spec_get_name( pspec ), 
				g_param_spec_get_blurb( pspec ), 
				(argument_class->flags & VIPS_ARGUMENT_INPUT) ?
					_( "input" ) : _( "output" ),
				g_type_name( 
					G_PARAM_SPEC_VALUE_TYPE( pspec ) ) );
		}
		else {
			if( usage->n > 0 )
				vips_buf_appends( buf, " " );
			vips_buf_appends( buf, g_param_spec_get_name( pspec ) );
		}

		usage->n += 1;
	}

	return( NULL );
}
示例#3
0
static GObject*
base_object_constructor  (GType                  type,
			  guint                  n_construct_properties,
			  GObjectConstructParam *construct_properties)
{
  /* The constructor is the one place where a GParamSpecOverride is visible
   * to the outside world, so we do a bunch of checks here
   */
  GValue value1 = { 0, };
  GValue value2 = { 0, };
  GParamSpec *pspec;

  g_assert (n_construct_properties == 1);

  pspec = construct_properties->pspec;

  /* Check we got the param spec we expected
   */
  g_assert (G_IS_PARAM_SPEC_OVERRIDE (pspec));
  g_assert (pspec->param_id == BASE_PROP1);
  g_assert (strcmp (g_param_spec_get_name (pspec), "prop1") == 0);
  g_assert (g_param_spec_get_redirect_target (pspec) == iface_spec1);

  /* Test redirection of the nick and blurb to the redirect target
   */
  g_assert (strcmp (g_param_spec_get_nick (pspec), "Prop1") == 0);
  g_assert (strcmp (g_param_spec_get_blurb (pspec), "Property 1") == 0);

  /* Test forwarding of the various GParamSpec methods to the redirect target
   */
  g_value_init (&value1, G_TYPE_INT);
  g_value_init (&value2, G_TYPE_INT);
  
  g_param_value_set_default (pspec, &value1);
  g_assert (g_value_get_int (&value1) == 42);

  g_value_reset (&value1);
  g_value_set_int (&value1, 0x10000);
  g_assert (g_param_value_validate (pspec, &value1));
  g_assert (g_value_get_int (&value1) == 0xFFFF);
  g_assert (!g_param_value_validate (pspec, &value1));
  
  g_value_reset (&value1);
  g_value_set_int (&value1, 1);
  g_value_set_int (&value2, 2);
  g_assert (g_param_values_cmp (pspec, &value1, &value2) < 0);
  g_assert (g_param_values_cmp (pspec, &value2, &value1) > 0);
  
  g_value_unset (&value1);
  g_value_unset (&value2);

  return base_parent_class->constructor (type,
					 n_construct_properties,
					 construct_properties);
}
示例#4
0
static gboolean
gst_egueb_demux_install_property (GObjectClass * klass, GObjectClass * from,
    guint id, const gchar *name)
{
  GParamSpec *pspec;
  GParamSpec *npspec;

  pspec = g_object_class_find_property(from, name);
  if (!pspec) return FALSE;

  npspec = g_param_spec_internal (G_PARAM_SPEC_TYPE (pspec), pspec->name,
      g_param_spec_get_nick (pspec), g_param_spec_get_blurb (pspec), pspec->flags);
  g_object_class_install_property (klass, id, npspec);
  return TRUE;
}
示例#5
0
static void
param_item_seq_popup_editor (GtkWidget *widget,
                             GxkParam  *param)
{
  SfiProxy proxy = bst_param_get_proxy (param);
  if (proxy)
    {
      BsePropertyCandidates *pc = bse_item_get_property_candidates (proxy, param->pspec->name);
      SfiSeq *seq = g_value_get_boxed (&param->value);
      BseItemSeq *iseq = bse_item_seq_from_seq (seq);
      bst_item_seq_dialog_popup (widget, proxy,
                                 pc->label, pc->tooltip, pc->items,
                                 g_param_spec_get_nick (param->pspec), g_param_spec_get_blurb (param->pspec), iseq,
                                 param_item_seq_changed,
                                 param, NULL);
      bse_item_seq_free (iseq);
    }
}
示例#6
0
文件: gimp-utils.c 项目: Natella/gimp
gint64
gimp_g_param_spec_get_memsize (GParamSpec *pspec)
{
  gint64 memsize = 0;

  if (! pspec)
    return 0;

  if (! (pspec->flags & G_PARAM_STATIC_NAME))
    memsize += gimp_string_get_memsize (g_param_spec_get_name (pspec));

  if (! (pspec->flags & G_PARAM_STATIC_NICK))
    memsize += gimp_string_get_memsize (g_param_spec_get_nick (pspec));

  if (! (pspec->flags & G_PARAM_STATIC_BLURB))
    memsize += gimp_string_get_memsize (g_param_spec_get_blurb (pspec));

  return memsize + gimp_g_type_instance_get_memsize ((GTypeInstance *) pspec);
}
示例#7
0
static void
test_param_spec_char (void)
{
  GParamSpec *pspec;
  GValue value = { 0, };
  gboolean modified;
 
  pspec = g_param_spec_char ("char", "nick", "blurb",
			     20, 40, 30, G_PARAM_READWRITE);

  //g_param_spec_ref_force_floating(pspec);			     
  //g_assert(g_param_spec_is_floating(pspec)); 			     
  g_param_spec_ref_sink(pspec);

  g_assert (strcmp (g_param_spec_get_name (pspec), "char") == 0);
  g_assert (strcmp (g_param_spec_get_nick (pspec), "nick") == 0);
  g_assert (strcmp (g_param_spec_get_blurb (pspec), "blurb") == 0);

  g_value_init (&value, G_TYPE_CHAR);
  g_value_set_char (&value, 30);

  g_assert (g_param_value_defaults (pspec, &value));
  
  g_value_set_char (&value, 0);
  modified = g_param_value_validate (pspec, &value);
  g_assert (modified && g_value_get_char (&value) == 20);

  g_value_set_char (&value, 20);
  modified = g_param_value_validate (pspec, &value);
  g_assert (!modified && g_value_get_char (&value) == 20);

  g_value_set_char (&value, 40);
  modified = g_param_value_validate (pspec, &value);
  g_assert (!modified && g_value_get_char (&value) == 40);

  g_value_set_char (&value, 60);
  modified = g_param_value_validate (pspec, &value);
  g_assert (modified && g_value_get_char (&value) == 40);

  g_param_spec_unref (pspec);
}
示例#8
0
文件: main.c 项目: TigerWFH/webkit
static GOptionEntry* getOptionEntriesFromWebKitSettings(WebKitSettings *webSettings)
{
    GParamSpec **propertySpecs;
    GOptionEntry *optionEntries;
    guint numProperties, numEntries, i;

    propertySpecs = g_object_class_list_properties(G_OBJECT_GET_CLASS(webSettings), &numProperties);
    if (!propertySpecs)
        return NULL;

    optionEntries = g_new0(GOptionEntry, numProperties + 1);
    numEntries = 0;
    for (i = 0; i < numProperties; i++) {
        GParamSpec *param = propertySpecs[i];

        /* Fill in structures only for writable and not construct-only properties. */
        if (!param || !(param->flags & G_PARAM_WRITABLE) || (param->flags & G_PARAM_CONSTRUCT_ONLY))
            continue;

        GType gParamType = G_PARAM_SPEC_VALUE_TYPE(param);
        if (!isValidParameterType(gParamType))
            continue;

        GOptionEntry *optionEntry = &optionEntries[numEntries++];
        optionEntry->long_name = g_param_spec_get_name(param);

        /* There is no easy way to figure our short name for generated option entries.
           optionEntry.short_name=*/
        /* For bool arguments "enable" type make option argument not required. */
        if (gParamType == G_TYPE_BOOLEAN && (strstr(optionEntry->long_name, "enable")))
            optionEntry->flags = G_OPTION_FLAG_OPTIONAL_ARG;
        optionEntry->arg = G_OPTION_ARG_CALLBACK;
        optionEntry->arg_data = parseOptionEntryCallback;
        optionEntry->description = g_param_spec_get_blurb(param);
        optionEntry->arg_description = g_type_name(gParamType);
    }
    g_free(propertySpecs);

    return optionEntries;
}
示例#9
0
文件: gen-doc.c 项目: miq/libuca
static void
print_property_descriptions (GParamSpec **pspecs, guint n_props)
{
    g_print ("<h2>Details</h2><dl>");

    for (guint i = 0; i < n_props; i++) {
        GParamSpec *pspec = pspecs[i];
        const gchar *name = g_param_spec_get_name (pspec);

        g_print ("<dt id=\"%s\"><a href=\"#toc\">%s</a></dt>\n", name, name);
        g_print ("<dd>");
        g_print ("<pre><code class=\"prop-type\">\"%s\" : %s : %s</code></pre>\n",
                 name,
                 g_type_name (pspec->value_type),
                 get_flags_description (pspec));
        g_print ("<p>%s</p>\n", g_param_spec_get_blurb (pspec));
        print_value_info (pspec);
        g_print ("</dd>");
    }

    g_print ("</dl>");
}
示例#10
0
static gchar *
dump_describe_param (GParamSpec *param_spec)
{
  const gchar *blurb  = g_param_spec_get_blurb (param_spec);
  const gchar *values = NULL;

  if (!blurb)
    {
      g_warning ("FIXME: Property '%s' has no blurb.", param_spec->name);

      blurb = g_strdup_printf ("The %s property has no description.",
                               param_spec->name);
    }

  if (GIMP_IS_PARAM_SPEC_RGB (param_spec))
    {
      if (gimp_param_spec_rgb_has_alpha (param_spec))
        values =
          "The color is specified in the form (color-rgba red green blue "
          "alpha) with channel values as floats in the range of 0.0 to 1.0.";
      else
        values =
          "The color is specified in the form (color-rgb red green blue) "
          "with channel values as floats in the range of 0.0 to 1.0.";
    }
  else if (GIMP_IS_PARAM_SPEC_MEMSIZE (param_spec))
    {
      values =
        "The integer size can contain a suffix of 'B', 'K', 'M' or 'G' which "
        "makes GIMP interpret the size as being specified in bytes, kilobytes, "
        "megabytes or gigabytes. If no suffix is specified the size defaults "
        "to being specified in kilobytes.";
    }
  else if (GIMP_IS_PARAM_SPEC_CONFIG_PATH (param_spec))
    {
      switch (gimp_param_spec_config_path_type (param_spec))
        {
        case GIMP_CONFIG_PATH_FILE:
          values = "This is a single filename.";
          break;

        case GIMP_CONFIG_PATH_FILE_LIST:
          switch (G_SEARCHPATH_SEPARATOR)
            {
            case ':':
              values = "This is a colon-separated list of files.";
              break;
            case ';':
              values = "This is a semicolon-separated list of files.";
              break;
            default:
              g_warning ("unhandled G_SEARCHPATH_SEPARATOR value");
              break;
            }
          break;

        case GIMP_CONFIG_PATH_DIR:
          values = "This is a single folder.";
          break;

        case GIMP_CONFIG_PATH_DIR_LIST:
          switch (G_SEARCHPATH_SEPARATOR)
            {
            case ':':
              values = "This is a colon-separated list of folders to search.";
              break;
            case ';':
              values = "This is a semicolon-separated list of folders to search.";
              break;
            default:
              g_warning ("unhandled G_SEARCHPATH_SEPARATOR value");
              break;
            }
          break;
        }
    }
  else if (GIMP_IS_PARAM_SPEC_UNIT (param_spec))
    {
      values =
        "The unit can be one inches, millimeters, points or picas plus "
        "those in your user units database.";
    }
  else if (g_type_is_a (param_spec->value_type, GIMP_TYPE_CONFIG))
    {
      values = "This is a parameter list.";
    }
  else
    {
      switch (G_TYPE_FUNDAMENTAL (param_spec->value_type))
        {
        case G_TYPE_BOOLEAN:
          values = "Possible values are yes and no.";
          break;
        case G_TYPE_INT:
        case G_TYPE_UINT:
        case G_TYPE_LONG:
        case G_TYPE_ULONG:
          values = "This is an integer value.";
          break;
        case G_TYPE_FLOAT:
        case G_TYPE_DOUBLE:
          values = "This is a float value.";
          break;
        case G_TYPE_STRING:
          /* eek */
          if (strcmp (g_param_spec_get_name (param_spec), "image-title-format")
              &&
              strcmp (g_param_spec_get_name (param_spec), "image-status-format"))
            {
              values = "This is a string value.";
            }
          else
            {
              values = display_format_description;
            }
          break;
        case G_TYPE_ENUM:
          {
            GEnumClass *enum_class;
            GEnumValue *enum_value;
            GString    *str;
            gint        i;

            enum_class = g_type_class_peek (param_spec->value_type);

            str = g_string_new (blurb);

            g_string_append (str, "  Possible values are ");

            for (i = 0, enum_value = enum_class->values;
                 i < enum_class->n_values;
                 i++, enum_value++)
              {
                g_string_append (str, enum_value->value_nick);

                switch (enum_class->n_values - i)
                  {
                  case 1:
                    g_string_append_c (str, '.');
                    break;
                  case 2:
                    g_string_append (str, " and ");
                    break;
                  default:
                    g_string_append (str, ", ");
                    break;
                  }
              }

            return g_string_free (str, FALSE);
          }
          break;
        default:
          break;
        }
    }

  if (!values)
    g_warning ("FIXME: Can't tell anything about a %s.",
               g_type_name (param_spec->value_type));

  if (strcmp (blurb, "") == 0)
    return g_strdup_printf ("%s", values);
  else
    return g_strdup_printf ("%s  %s", blurb, values);
}
示例#11
0
文件: adg-adim.c 项目: bert/adg
static void
adg_adim_class_init(AdgADimClass *klass)
{
    GObjectClass *gobject_class;
    AdgEntityClass *entity_class;
    AdgDimClass *dim_class;
    GParamSpec *param, *old_param;

    gobject_class = (GObjectClass *) klass;
    entity_class = (AdgEntityClass *) klass;
    dim_class = (AdgDimClass *) klass;

    g_type_class_add_private(klass, sizeof(AdgADimPrivate));

    gobject_class->dispose = _adg_dispose;
    gobject_class->get_property = _adg_get_property;
    gobject_class->set_property = _adg_set_property;

    entity_class->global_changed = _adg_global_changed;
    entity_class->local_changed = _adg_local_changed;
    entity_class->invalidate = _adg_invalidate;
    entity_class->arrange = _adg_arrange;
    entity_class->render = _adg_render;

    dim_class->default_value = _adg_default_value;

    /* Override #AdgDim:value to append a degree symbol
     * to the default set value template string */
    old_param = g_object_class_find_property(gobject_class, "value");
    param = g_param_spec_string(old_param->name,
                                g_param_spec_get_nick(old_param),
                                g_param_spec_get_blurb(old_param),
                                "<>" ADG_UTF8_DEGREE,
                                old_param->flags);
    g_object_class_install_property(gobject_class, PROP_VALUE, param);

    param = g_param_spec_boxed("org1",
                               P_("First Origin"),
                               P_("Where the first line comes from: this point is used toghether with \"ref1\" to align the first extension line"),
                               ADG_TYPE_POINT,
                               G_PARAM_READWRITE);
    g_object_class_install_property(gobject_class, PROP_ORG1, param);

    param = g_param_spec_boxed("org2",
                               P_("Second Origin"),
                               P_("Where the second line comes from: this point is used toghether with \"ref2\" to align the second extension line"),
                               ADG_TYPE_POINT,
                               G_PARAM_READWRITE);
    g_object_class_install_property(gobject_class, PROP_ORG2, param);

    param = g_param_spec_boolean("has-extension1",
                                 P_("Has First Extension Line flag"),
                                 P_("Show (TRUE) or hide (FALSE) the first extension line"),
                                 TRUE, G_PARAM_READWRITE);
    g_object_class_install_property(gobject_class, PROP_HAS_EXTENSION1, param);

    param = g_param_spec_boolean("has-extension2",
                                 P_("Has Second Extension Line flag"),
                                 P_("Show (TRUE) or hide (FALSE) the second extension line"),
                                 TRUE, G_PARAM_READWRITE);
    g_object_class_install_property(gobject_class, PROP_HAS_EXTENSION2, param);
}
示例#12
0
// make json formated description
void Property::make_description() {
  if (nullptr == property_) {
    g_warning("%s: cannot make description from a nullptr property",
              __PRETTY_FUNCTION__);
    return;
  }
  GValue value = G_VALUE_INIT;
  g_value_init(&value, property_->value_type);

  g_object_get_property(object_, property_->name, &value);
  json_description_->reset();
  json_description_->begin_object();
  // long name
  json_description_->add_string_member("name", long_name_.c_str());
  // name
  json_description_->add_string_member("id", name_.c_str());
  // nickname
  // json_description_->add_string_member ("nickname", g_param_spec_get_nick (property_));

  // short description
  json_description_->add_string_member("description",
                                       g_param_spec_get_blurb(property_));
  json_description_->add_string_member("parent",
                                       get_category().c_str());
  json_description_->add_int_member("order",
                                    get_position_weight());
  // name
  // json_description_->add_string_member ("internal name", g_param_spec_get_name (property_));
  if (property_->flags &G_PARAM_WRITABLE)
    json_description_->add_string_member("writable", "true");
  else
    json_description_->add_string_member("writable", "false");
  switch (G_VALUE_TYPE(&value)) {
    case G_TYPE_STRING:
      {
        const char *string_val = g_value_get_string(&value);
        json_description_->add_string_member("type", "string");
        if (string_val == nullptr)
          json_description_->add_string_member("default value", "");
        else
          json_description_->add_string_member("default value", string_val);
        break;
      }
    case G_TYPE_BOOLEAN:
      {
        gboolean bool_val = g_value_get_boolean(&value);
        json_description_->add_string_member("type", "boolean");
        if (bool_val)
          json_description_->add_string_member("default value", "true");
        else
          json_description_->add_string_member("default value", "false");
        break;
      }
    case G_TYPE_ULONG:
      {
        GParamSpecULong *pulong = G_PARAM_SPEC_ULONG(property_);

        json_description_->add_string_member("type", "ulong");
        gchar *min = g_strdup_printf("%lu", pulong->minimum);
        gchar *max = g_strdup_printf("%lu", pulong->maximum);
        gchar *default_value =
            g_strdup_printf("%lu", g_value_get_ulong(&value));
        json_description_->add_string_member("minimum", min);
        json_description_->add_string_member("maximum", max);
        json_description_->add_string_member("default value", default_value);
        g_free(min);
        g_free(max);
        g_free(default_value);
        break;
      }
    case G_TYPE_LONG:
      {
        GParamSpecLong *plong = G_PARAM_SPEC_LONG(property_);
        gchar *min = g_strdup_printf("%ld", plong->minimum);
        gchar *max = g_strdup_printf("%ld", plong->maximum);
        gchar *default_value =
            g_strdup_printf("%ld", g_value_get_ulong(&value));
        json_description_->add_string_member("type", "long");
        json_description_->add_string_member("minimum", min);
        json_description_->add_string_member("maximum", max);
        json_description_->add_string_member("default value", default_value);
        g_free(min);
        g_free(max);
        g_free(default_value);
        break;
      }
    case G_TYPE_UINT:
      {
        GParamSpecUInt *puint = G_PARAM_SPEC_UINT(property_);
        gchar *min = g_strdup_printf("%u", puint->minimum);
        gchar *max = g_strdup_printf("%u", puint->maximum);
        gchar *default_value =
            g_strdup_printf("%u", g_value_get_uint(&value));
        json_description_->add_string_member("type", "uint");
        json_description_->add_string_member("minimum", min);
        json_description_->add_string_member("maximum", max);
        json_description_->add_string_member("default value", default_value);
        g_free(min);
        g_free(max);
        g_free(default_value);
        break;
      }
    case G_TYPE_INT:
      {
        GParamSpecInt *pint = G_PARAM_SPEC_INT(property_);
        gchar *min = g_strdup_printf("%d", pint->minimum);
        gchar *max = g_strdup_printf("%d", pint->maximum);
        gchar *default_value = g_strdup_printf("%d", g_value_get_int(&value));
        json_description_->add_string_member("type", "int");
        json_description_->add_string_member("minimum", min);
        json_description_->add_string_member("maximum", max);
        json_description_->add_string_member("default value", default_value);
        g_free(min);
        g_free(max);
        g_free(default_value);
        break;
      }
    case G_TYPE_UINT64:
      {
        GParamSpecUInt64 *puint64 = G_PARAM_SPEC_UINT64(property_);
        gchar *min = g_strdup_printf("%" G_GUINT64_FORMAT, puint64->minimum);
        gchar *max = g_strdup_printf("%" G_GUINT64_FORMAT, puint64->maximum);
        gchar *default_value = g_strdup_printf("%" G_GUINT64_FORMAT,
                                               g_value_get_uint64(&value));
        json_description_->add_string_member("type", "uint64");
        json_description_->add_string_member("minimum", min);
        json_description_->add_string_member("maximum", max);
        json_description_->add_string_member("default value", default_value);
        g_free(min);
        g_free(max);
        g_free(default_value);
        break;
      }
    case G_TYPE_INT64:
      {
        GParamSpecInt64 *pint64 = G_PARAM_SPEC_INT64(property_);
        gchar *min = g_strdup_printf("%" G_GINT64_FORMAT, pint64->minimum);
        gchar *max = g_strdup_printf("%" G_GINT64_FORMAT, pint64->maximum);
        gchar *default_value =
            g_strdup_printf("%" G_GINT64_FORMAT, g_value_get_int64(&value));
        json_description_->add_string_member("type", "int64");
        json_description_->add_string_member("minimum", min);
        json_description_->add_string_member("maximum", max);
        json_description_->add_string_member("default value", default_value);
        g_free(min);
        g_free(max);
        g_free(default_value);
        break;
      }
    case G_TYPE_FLOAT:
      {
        GParamSpecFloat *pfloat = G_PARAM_SPEC_FLOAT(property_);
        gchar *min = g_strdup_printf("%.7g", pfloat->minimum);
        gchar *max = g_strdup_printf("%.7g", pfloat->maximum);
        gchar *default_value =
            g_strdup_printf("%.7g", g_value_get_float(&value));
        json_description_->add_string_member("type", "float");
        json_description_->add_string_member("minimum", min);
        json_description_->add_string_member("maximum", max);
        json_description_->add_string_member("default value", default_value);
        g_free(min);
        g_free(max);
        g_free(default_value);
        break;
      }
    case G_TYPE_DOUBLE:
      {
        GParamSpecDouble *pdouble = G_PARAM_SPEC_DOUBLE(property_);
        gchar *min = g_strdup_printf("%.7g", pdouble->minimum);
        gchar *max = g_strdup_printf("%.7g", pdouble->maximum);
        gchar *default_value =
            g_strdup_printf("%.7g", g_value_get_double(&value));
        json_description_->add_string_member("type", "double");
        json_description_->add_string_member("minimum", min);
        json_description_->add_string_member("maximum", max);
        json_description_->add_string_member("default value", default_value);
        g_free(min);
        g_free(max);
        g_free(default_value);
        break;
      }
    default:
      if (property_->value_type == GST_TYPE_CAPS) {
        const GstCaps *caps = gst_value_get_caps(&value);
        json_description_->add_string_member("type", "caps");
        if (!caps)
          json_description_->add_string_member("default value", "");
        else
          json_description_->add_string_member("default value",
                                               gst_caps_to_string(caps));
      } else if (G_IS_PARAM_SPEC_ENUM(property_)) {
        GEnumValue *values;
        guint j = 0;
        gint enum_value;
        const gchar *value_nick = "";
        const gchar *value_name = "";
        json_description_->add_string_member("type", "enum");
        values =
            G_ENUM_CLASS(g_type_class_ref(property_->value_type))->values;
        enum_value = g_value_get_enum(&value);
        while (values[j].value_name) {
          if (values[j].value == enum_value) {
            value_nick = values[j].value_nick;
            value_name = values[j].value_name;
          }
          j++;
        }

        json_description_->set_member_name("default value");
        json_description_->begin_object();
        gchar *value = g_strdup_printf("%d", enum_value);
        json_description_->add_string_member("value", value);
        g_free(value);
        json_description_->add_string_member("nick", value_nick);
        json_description_->add_string_member("name", value_name);
        json_description_->end_object();

        // g_debug ("Enum \"%s\" Default: %d, \"%s\" \"%s\"",
        //  g_type_name (G_VALUE_TYPE (&value)),
        //  enum_value,
        //  value_nick,
        //  value_name);

        j = 0;

        json_description_->set_member_name("values");
        json_description_->begin_array();
        while (values[j].value_name) {
          json_description_->begin_object();
          json_description_->add_string_member("name", values[j].value_name);
          json_description_->add_string_member("nick", values[j].value_nick);
          gchar *values_value = g_strdup_printf("%d", values[j].value);
          json_description_->add_string_member("value", values_value);
          g_free(values_value);
          json_description_->end_object();
          j++;
        }
        json_description_->end_array();

        /* g_type_class_unref (ec); */
      } else if (G_IS_PARAM_SPEC_FLAGS(property_)) {
        g_debug("warning: param spec flags not handled");
        // GParamSpecFlags *pflags = G_PARAM_SPEC_FLAGS (property_);
        // GFlagsValue *vals;
        // gchar *cur;

        // vals = pflags->flags_class->values;

        // cur = flags_to_string (vals, g_value_get_flags (&value));

        // g_debug ("%-23.23s Flags \"%s\" Default: 0x%08x, \"%s\"", "",
        //    g_type_name (G_VALUE_TYPE (&value)),
        //    g_value_get_flags (&value), cur);

        // while (vals[0].value_name) {
        //   g_debug ("");
        //   if (_name)
        //     g_debug ("%s", _name);
        //   g_debug ("%-23.23s    (0x%08x): %-16s - %s", "",
        //      vals[0].value, vals[0].value_nick, vals[0].value_name);
        //   ++vals;
        // }

        // g_free (cur);
      } else if (G_IS_PARAM_SPEC_OBJECT(property_)) {
        g_debug("warning: param spec object not handled");
        // g_debug ("%-23.23s Object of type \"%s\"", "",
        //  g_type_name (property_->value_type));
      } else if (G_IS_PARAM_SPEC_BOXED(property_)) {
        g_debug("warning: param spec boxed not handled");
        // g_debug ("%-23.23s Boxed pointer of type \"%s\"", "",
        //  g_type_name (property_->value_type));
      } else if (G_IS_PARAM_SPEC_POINTER(property_)) {
        g_debug("warning: param spec pointer not handled");
        // if (property_->value_type != G_TYPE_POINTER) {
        //   g_debug ("%-23.23s Pointer of type \"%s\".", "",
        //    g_type_name (property_->value_type));
        // } else if (property_->value_type == G_TYPE_VALUE_ARRAY) {
        // GParamSpecValueArray *pvarray = G_PARAM_SPEC_VALUE_ARRAY (property_);
        // g_debug ("warning: array not handled");
        // if (pvarray->element_spec) {
        //   g_debug ("%-23.23s Array of GValues of type \"%s\"", "",
        //    g_type_name (pvarray->element_spec->value_type));
        // } else {
        //   g_debug ("%-23.23s Array of GValues", "");
        // }
      } else if (GST_IS_PARAM_SPEC_FRACTION(property_)) {
        GstParamSpecFraction *pfraction = GST_PARAM_SPEC_FRACTION(property_);
        json_description_->add_string_member("type", "fraction");
        gchar *minnum = g_strdup_printf("%d", pfraction->min_num);
        gchar *minden = g_strdup_printf("%d", pfraction->min_den);
        gchar *maxnum = g_strdup_printf("%d", pfraction->max_num);
        gchar *maxden = g_strdup_printf("%d", pfraction->max_den);
        gchar *defaultnum = g_strdup_printf("%d",
                                            gst_value_get_fraction_numerator
                                            (&value));
        gchar *defaultden = g_strdup_printf("%d",
                                            gst_value_get_fraction_denominator
                                            (&value));
        json_description_->add_string_member("minimum numerator", minnum);
        json_description_->add_string_member("maximum numerator", minden);
        json_description_->add_string_member("minimum denominator", maxnum);
        json_description_->add_string_member("maximum denominator", maxden);
        json_description_->add_string_member("default numerator", defaultnum);
        json_description_->add_string_member("default denominator",
                                             defaultden);
        g_free(minnum);
        g_free(minden);
        g_free(maxnum);
        g_free(maxden);
        g_free(defaultnum);
        g_free(defaultden);
        // g_debug ("Range: %d/%d - %d/%d Default: %d/%d ",
        //  pfraction->min_num, pfraction->min_den,
        //  pfraction->max_num, pfraction->max_den,
        //  gst_value_get_fraction_numerator (&value),
        //  gst_value_get_fraction_denominator (&value));
      } else {
        g_warning("warning: unknown type");
        // g_debug ("%-23.23s Unknown type %ld \"%s\"", "", property_->value_type,
        //  g_type_name (property_->value_type));
      }
      break;
  }
  g_value_reset(&value);
  json_description_->end_object();
}
示例#13
0
static void
dvb_base_bin_class_init (DvbBaseBinClass * klass)
{
  GObjectClass *gobject_class;
  GstElementClass *element_class;
  GstBinClass *bin_class;
  DvbBaseBinClass *dvbbasebin_class;
  GstElementFactory *dvbsrc_factory;
  GObjectClass *dvbsrc_class;
  typedef struct
  {
    guint prop_id;
    const gchar *prop_name;
  } ProxyedProperty;
  ProxyedProperty *walk;
  ProxyedProperty proxyed_properties[] = {
    {PROP_ADAPTER, "adapter"},
    {PROP_FRONTEND, "frontend"},
    {PROP_DISEQC_SRC, "diseqc-source"},
    {PROP_FREQUENCY, "frequency"},
    {PROP_POLARITY, "polarity"},
    {PROP_SYMBOL_RATE, "symbol-rate"},
#ifndef GST_REMOVE_DEPRECATED
    {PROP_BANDWIDTH, "bandwidth"},
#endif
    {PROP_CODE_RATE_HP, "code-rate-hp"},
    {PROP_CODE_RATE_LP, "code-rate-lp"},
    {PROP_GUARD, "guard"},
    {PROP_MODULATION, "modulation"},
    {PROP_TRANS_MODE, "trans-mode"},
    {PROP_HIERARCHY, "hierarchy"},
    {PROP_INVERSION, "inversion"},
    {PROP_STATS_REPORTING_INTERVAL, "stats-reporting-interval"},
    {PROP_TUNING_TIMEOUT, "tuning-timeout"},
    {PROP_DELSYS, "delsys"},
    {PROP_PILOT, "pilot"},
    {PROP_ROLLOFF, "rolloff"},
    {PROP_STREAM_ID, "stream-id"},
    {PROP_BANDWIDTH_HZ, "bandwidth-hz"},
    {PROP_ISDBT_LAYER_ENABLED, "isdbt-layer-enabled"},
    {PROP_ISDBT_PARTIAL_RECEPTION, "isdbt-partial-reception"},
    {PROP_ISDBT_SOUND_BROADCASTING, "isdbt-sound-broadcasting"},
    {PROP_ISDBT_SB_SUBCHANNEL_ID, "isdbt-sb-subchannel-id"},
    {PROP_ISDBT_SB_SEGMENT_IDX, "isdbt-sb-segment-idx"},
    {PROP_ISDBT_SB_SEGMENT_COUNT, "isdbt-sb-segment-count"},
    {PROP_ISDBT_LAYERA_FEC, "isdbt-layera-fec"},
    {PROP_ISDBT_LAYERA_MODULATION, "isdbt-layera-modulation"},
    {PROP_ISDBT_LAYERA_SEGMENT_COUNT, "isdbt-layera-segment-count"},
    {PROP_ISDBT_LAYERA_TIME_INTERLEAVING, "isdbt-layera-time-interleaving"},
    {PROP_ISDBT_LAYERB_FEC, "isdbt-layerb-fec"},
    {PROP_ISDBT_LAYERB_MODULATION, "isdbt-layerb-modulation"},
    {PROP_ISDBT_LAYERB_SEGMENT_COUNT, "isdbt-layerb-segment-count"},
    {PROP_ISDBT_LAYERB_TIME_INTERLEAVING, "isdbt-layerb-time-interleaving"},
    {PROP_ISDBT_LAYERC_FEC, "isdbt-layerc-fec"},
    {PROP_ISDBT_LAYERC_MODULATION, "isdbt-layerc-modulation"},
    {PROP_ISDBT_LAYERC_SEGMENT_COUNT, "isdbt-layerc-segment-count"},
    {PROP_ISDBT_LAYERC_TIME_INTERLEAVING, "isdbt-layerc-time-interleaving"},
    {PROP_LNB_SLOF, "lnb-slof"},
    {PROP_LNB_LOF1, "lnb-lof1"},
    {PROP_LNB_LOF2, "lnb-lof2"},
    {PROP_INTERLEAVING, "interleaving"},
    {0, NULL}
  };

  bin_class = GST_BIN_CLASS (klass);
  bin_class->handle_message = dvb_base_bin_handle_message;

  element_class = GST_ELEMENT_CLASS (klass);

  element_class->change_state = dvb_base_bin_change_state;
  element_class->request_new_pad = dvb_base_bin_request_new_pad;
  element_class->release_pad = dvb_base_bin_release_pad;

  gst_element_class_add_pad_template (element_class,
      gst_static_pad_template_get (&program_template));
  gst_element_class_add_pad_template (element_class,
      gst_static_pad_template_get (&src_template));

  gst_element_class_set_static_metadata (element_class, "DVB bin",
      "Source/Bin/Video",
      "Access descramble and split DVB streams",
      "Alessandro Decina <*****@*****.**>\n"
      "Reynaldo H. Verdejo Pinochet <*****@*****.**>");

  gobject_class = G_OBJECT_CLASS (klass);
  gobject_class->set_property = dvb_base_bin_set_property;
  gobject_class->get_property = dvb_base_bin_get_property;
  gobject_class->dispose = dvb_base_bin_dispose;
  gobject_class->finalize = dvb_base_bin_finalize;

  dvbbasebin_class = (DvbBaseBinClass *) klass;
  dvbbasebin_class->do_tune = dvb_base_bin_do_tune;

  /* install dvbsrc properties */
  dvbsrc_factory = gst_element_factory_find ("dvbsrc");
  dvbsrc_class =
      g_type_class_ref (gst_element_factory_get_element_type (dvbsrc_factory));
  walk = proxyed_properties;
  while (walk->prop_name != NULL) {
    GParamSpec *pspec;
    GParamSpec *our_pspec;

    pspec = g_object_class_find_property (dvbsrc_class, walk->prop_name);
    if (pspec != NULL) {
      GType param_type = G_PARAM_SPEC_TYPE (pspec);

      if (param_type == G_TYPE_PARAM_INT) {
        GParamSpecInt *src_pspec = G_PARAM_SPEC_INT (pspec);

        our_pspec = g_param_spec_int (g_param_spec_get_name (pspec),
            g_param_spec_get_nick (pspec), g_param_spec_get_blurb (pspec),
            src_pspec->minimum, src_pspec->maximum, src_pspec->default_value,
            pspec->flags);
      } else if (param_type == G_TYPE_PARAM_UINT) {
        GParamSpecUInt *src_pspec = G_PARAM_SPEC_UINT (pspec);

        our_pspec = g_param_spec_uint (g_param_spec_get_name (pspec),
            g_param_spec_get_nick (pspec), g_param_spec_get_blurb (pspec),
            src_pspec->minimum, src_pspec->maximum, src_pspec->default_value,
            pspec->flags);
      } else if (param_type == G_TYPE_PARAM_UINT64) {
        GParamSpecUInt64 *src_pspec = G_PARAM_SPEC_UINT64 (pspec);

        our_pspec = g_param_spec_uint64 (g_param_spec_get_name (pspec),
            g_param_spec_get_nick (pspec), g_param_spec_get_blurb (pspec),
            src_pspec->minimum, src_pspec->maximum, src_pspec->default_value,
            pspec->flags);
      } else if (param_type == G_TYPE_PARAM_STRING) {
        GParamSpecString *src_pspec = G_PARAM_SPEC_STRING (pspec);

        our_pspec = g_param_spec_string (g_param_spec_get_name (pspec),
            g_param_spec_get_nick (pspec), g_param_spec_get_blurb (pspec),
            src_pspec->default_value, pspec->flags);
      } else if (param_type == G_TYPE_PARAM_ENUM) {
        GParamSpecEnum *src_pspec = G_PARAM_SPEC_ENUM (pspec);

        our_pspec = g_param_spec_enum (g_param_spec_get_name (pspec),
            g_param_spec_get_nick (pspec), g_param_spec_get_blurb (pspec),
            pspec->value_type, src_pspec->default_value, pspec->flags);
      } else {
        GST_ERROR ("Unsupported property type %s for property %s",
            g_type_name (param_type), g_param_spec_get_name (pspec));
        ++walk;
        continue;
      }

      g_object_class_install_property (gobject_class, walk->prop_id, our_pspec);
    } else {
      g_warning ("dvbsrc has no property named %s", walk->prop_name);
    }
    ++walk;
  }
  g_type_class_unref (dvbsrc_class);

  g_object_class_install_property (gobject_class, PROP_PROGRAM_NUMBERS,
      g_param_spec_string ("program-numbers",
          "Program Numbers",
          "Colon separated list of programs", "", G_PARAM_READWRITE));
  /**
   * DvbBaseBin::tuning-start:
   * @dvbbasebin: the element on which the signal is emitted
   *
   * Signal emited when the element first attempts to tune the
   * frontend tunner to a given frequency.
   */
  dvb_base_bin_signals[SIGNAL_TUNING_START] =
      g_signal_new ("tuning-start", G_TYPE_FROM_CLASS (klass),
      G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE, 0);
  /**
   * DvbBaseBin::tuning-done:
   * @dvbbasebin: the element on which the signal is emitted
   *
   * Signal emited when the tunner has successfully got a lock on a signal.
   */
  dvb_base_bin_signals[SIGNAL_TUNING_DONE] =
      g_signal_new ("tuning-done", G_TYPE_FROM_CLASS (klass),
      G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE, 0);
  /**
   * DvbBaseBin::tuning-fail:
   * @dvbbasebin: the element on which the signal is emitted
   *
   * Signal emited when the tunner failed to get a lock on the
   * signal.
   */
  dvb_base_bin_signals[SIGNAL_TUNING_FAIL] =
      g_signal_new ("tuning-fail", G_TYPE_FROM_CLASS (klass),
      G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE, 0);

  /**
   * DvbBaseBin::tune:
   * @dvbbasesink: the element on which the signal is emitted
   *
   * Signal emited from the application to the element, instructing it
   * to tune.
   */
  dvb_base_bin_signals[SIGNAL_TUNE] =
      g_signal_new ("tune", G_TYPE_FROM_CLASS (klass),
      G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
      G_STRUCT_OFFSET (DvbBaseBinClass, do_tune),
      NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}
示例#14
0
static void
print_element_properties (GstElement * element, gint pfx)
{
  GParamSpec **property_specs;
  guint num_properties;
  gint i;
  gboolean readable;

  property_specs = g_object_class_list_properties
      (G_OBJECT_GET_CLASS (element), &num_properties);

  PUT_START_TAG (pfx, "element-properties");

  for (i = 0; i < num_properties; i++) {
    GValue value = { 0, };
    GParamSpec *param = property_specs[i];

    readable = FALSE;

    g_value_init (&value, param->value_type);
    if (param->flags & G_PARAM_READABLE) {
      g_object_get_property (G_OBJECT (element), param->name, &value);
      readable = TRUE;
    }
    PUT_START_TAG (pfx + 1, "element-property");
    PUT_ESCAPED (pfx + 2, "name", g_param_spec_get_name (param));
    PUT_ESCAPED (pfx + 2, "type", g_type_name (param->value_type));
    PUT_ESCAPED (pfx + 2, "nick", g_param_spec_get_nick (param));
    PUT_ESCAPED (pfx + 2, "blurb", g_param_spec_get_blurb (param));
    if (readable) {
      PUT_ESCAPED (pfx + 2, "flags", "RW");
    } else {
      PUT_ESCAPED (pfx + 2, "flags", "W");
    }

    switch (G_VALUE_TYPE (&value)) {
      case G_TYPE_STRING:
        PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value));
        break;
      case G_TYPE_BOOLEAN:
        PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value));
        break;
      case G_TYPE_ULONG:
      {
        GParamSpecULong *pulong = G_PARAM_SPEC_ULONG (param);

        PUT_STRING (pfx + 2, "<range min=\"%lu\" max=\"%lu\"/>",
            pulong->minimum, pulong->maximum);
        PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value));
        break;
      }
      case G_TYPE_LONG:
      {
        GParamSpecLong *plong = G_PARAM_SPEC_LONG (param);

        PUT_STRING (pfx + 2, "<range min=\"%ld\" max=\"%ld\"/>",
            plong->minimum, plong->maximum);
        PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value));
        break;
      }
      case G_TYPE_UINT:
      {
        GParamSpecUInt *puint = G_PARAM_SPEC_UINT (param);

        PUT_STRING (pfx + 2, "<range min=\"%u\" max=\"%u\"/>",
            puint->minimum, puint->maximum);
        PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value));
        break;
      }
      case G_TYPE_INT:
      {
        GParamSpecInt *pint = G_PARAM_SPEC_INT (param);

        PUT_STRING (pfx + 2, "<range min=\"%d\" max=\"%d\"/>",
            pint->minimum, pint->maximum);
        PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value));
        break;
      }
      case G_TYPE_UINT64:
      {
        GParamSpecUInt64 *puint64 = G_PARAM_SPEC_UINT64 (param);

        PUT_STRING (pfx + 2,
            "<range min=\"%" G_GUINT64_FORMAT "\" max=\"%" G_GUINT64_FORMAT
            "\"/>", puint64->minimum, puint64->maximum);
        PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value));
        break;
      }
      case G_TYPE_INT64:
      {
        GParamSpecInt64 *pint64 = G_PARAM_SPEC_INT64 (param);

        PUT_STRING (pfx + 2,
            "<range min=\"%" G_GINT64_FORMAT "\" max=\"%" G_GINT64_FORMAT
            "\"/>", pint64->minimum, pint64->maximum);
        PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value));
        break;
      }
      case G_TYPE_FLOAT:
      {
        GParamSpecFloat *pfloat = G_PARAM_SPEC_FLOAT (param);

        PUT_STRING (pfx + 2, "<range min=\"%f\" max=\"%f\"/>",
            pfloat->minimum, pfloat->maximum);
        PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value));
        break;
      }
      case G_TYPE_DOUBLE:
      {
        GParamSpecDouble *pdouble = G_PARAM_SPEC_DOUBLE (param);

        PUT_STRING (pfx + 2, "<range min=\"%g\" max=\"%g\"/>",
            pdouble->minimum, pdouble->maximum);
        PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value));
        break;
      }
      default:
        if (param->value_type == GST_TYPE_CAPS) {
          GstCaps *caps = g_value_peek_pointer (&value);

          if (!caps)
            PUT_ESCAPED (pfx + 2, "default", "NULL");
          else {
            print_caps (caps, 2);
          }
        } else if (G_IS_PARAM_SPEC_ENUM (param)) {
          GEnumValue *values;
          guint j = 0;
          gint enum_value;

          values = G_ENUM_CLASS (g_type_class_ref (param->value_type))->values;
          enum_value = g_value_get_enum (&value);

          while (values[j].value_name) {
            if (values[j].value == enum_value)
              break;
            j++;
          }
          PUT_STRING (pfx + 2, "<default>%d</default>", values[j].value);

          PUT_START_TAG (pfx + 2, "enum-values");
          j = 0;
          while (values[j].value_name) {
            PUT_STRING (pfx + 3, "<value value=\"%d\" nick=\"%s\"/>",
                values[j].value, values[j].value_nick);
            j++;
          }
          PUT_END_TAG (pfx + 2, "enum-values");
        } else if (G_IS_PARAM_SPEC_FLAGS (param)) {
          GFlagsValue *values;
          guint j = 0;
          gint flags_value;

          values = G_FLAGS_CLASS (g_type_class_ref (param->value_type))->values;
          flags_value = g_value_get_flags (&value);

          PUT_STRING (pfx + 2, "<default>%d</default>", flags_value);

          PUT_START_TAG (pfx + 2, "flags");
          j = 0;
          while (values[j].value_name) {
            PUT_STRING (pfx + 3, "<flag value=\"%d\" nick=\"%s\"/>",
                values[j].value, values[j].value_nick);
            j++;
          }
          PUT_END_TAG (pfx + 2, "flags");
        } else if (G_IS_PARAM_SPEC_OBJECT (param)) {
          PUT_ESCAPED (pfx + 2, "object-type", g_type_name (param->value_type));
        }
        break;
    }

    PUT_END_TAG (pfx + 1, "element-property");
  }
  PUT_END_TAG (pfx, "element-properties");
  g_free (property_specs);
}
static void
impl_constructed (GObject *object)
{
    RBObjectPropertyEditor *editor;
    GObjectClass *klass;
    int i;
    int row;

    RB_CHAIN_GOBJECT_METHOD (rb_object_property_editor_parent_class, constructed, object);

    editor = RB_OBJECT_PROPERTY_EDITOR (object);
    klass = G_OBJECT_GET_CLASS (editor->priv->object);

    editor->priv->notify_id = g_signal_connect (editor->priv->object, "notify", G_CALLBACK (notify_cb), editor);

    row = 0;
    for (i = 0; editor->priv->properties[i] != NULL; i++) {
        GParamSpec *pspec;
        GtkWidget *label;
        GtkWidget *control;
        GType prop_type;

        pspec = g_object_class_find_property (klass, editor->priv->properties[i]);
        if (pspec == NULL) {
            g_warning ("couldn't find property %s on object %s",
                       editor->priv->properties[i],
                       G_OBJECT_CLASS_NAME (klass));
            continue;
        }

        prop_type = G_PARAM_SPEC_TYPE (pspec);
        if (prop_type == G_TYPE_PARAM_BOOLEAN) {
            control = create_boolean_editor (editor, editor->priv->properties[i], pspec);
        } else if (prop_type == G_TYPE_PARAM_ENUM) {
            control = create_enum_editor (editor, editor->priv->properties[i], pspec);
        } else if (prop_type == G_TYPE_PARAM_INT) {
            control = create_int_editor (editor, editor->priv->properties[i], pspec);
        } else if (prop_type == G_TYPE_PARAM_FLOAT) {
            control = create_float_editor (editor, editor->priv->properties[i], pspec);
        } else if (prop_type == G_TYPE_PARAM_DOUBLE) {
            control = create_double_editor (editor, editor->priv->properties[i], pspec);
        } else {
            /* can't do this */
            g_warning ("don't know how to edit %s", g_type_name (prop_type));
            continue;
        }
        g_signal_connect (control, "focus-out-event", G_CALLBACK (focus_out_cb), editor);
        gtk_widget_set_hexpand (control, TRUE);

        label = gtk_label_new (g_param_spec_get_nick (pspec));
        gtk_widget_set_tooltip_text (label, g_param_spec_get_blurb (pspec));

        gtk_grid_attach (GTK_GRID (editor),
                         label,
                         0, row, 1, 1);
        gtk_grid_attach (GTK_GRID (editor),
                         control,
                         1, row, 1, 1);

        row++;
    }
}
示例#16
0
GParamSpec *
gimp_param_spec_duplicate (GParamSpec *pspec)
{
  GParamSpec  *copy = NULL;
  GParamFlags  flags;

  g_return_val_if_fail (pspec != NULL, NULL);

  flags = pspec->flags | GIMP_CONFIG_PARAM_SERIALIZE;

  if (G_IS_PARAM_SPEC_STRING (pspec))
    {
      GParamSpecString *spec = G_PARAM_SPEC_STRING (pspec);

      if (GEGL_IS_PARAM_SPEC_FILE_PATH (pspec))
        {
          copy = gimp_param_spec_config_path (pspec->name,
                                              g_param_spec_get_nick (pspec),
                                              g_param_spec_get_blurb (pspec),
                                              GIMP_CONFIG_PATH_FILE,
                                              spec->default_value,
                                              flags);
        }
      else
        {
          static GQuark multiline_quark = 0;

          if (! multiline_quark)
            multiline_quark = g_quark_from_static_string ("multiline");

          copy = g_param_spec_string (pspec->name,
                                      g_param_spec_get_nick (pspec),
                                      g_param_spec_get_blurb (pspec),
                                      spec->default_value,
                                      flags);

          if (GEGL_IS_PARAM_SPEC_MULTILINE (pspec))
            {
              g_param_spec_set_qdata (copy, multiline_quark,
                                      GINT_TO_POINTER (TRUE));
            }
        }
    }
  else if (G_IS_PARAM_SPEC_BOOLEAN (pspec))
    {
      GParamSpecBoolean *spec = G_PARAM_SPEC_BOOLEAN (pspec);

      copy = g_param_spec_boolean (pspec->name,
                                   g_param_spec_get_nick (pspec),
                                   g_param_spec_get_blurb (pspec),
                                   spec->default_value,
                                   flags);
    }
  else if (G_IS_PARAM_SPEC_ENUM (pspec))
    {
      GParamSpecEnum *spec = G_PARAM_SPEC_ENUM (pspec);

      copy = g_param_spec_enum (pspec->name,
                                g_param_spec_get_nick (pspec),
                                g_param_spec_get_blurb (pspec),
                                G_TYPE_FROM_CLASS (spec->enum_class),
                                spec->default_value,
                                flags);
    }
  else if (GEGL_IS_PARAM_SPEC_DOUBLE (pspec))
    {
      GeglParamSpecDouble *gspec = GEGL_PARAM_SPEC_DOUBLE (pspec);
      GParamSpecDouble    *spec = G_PARAM_SPEC_DOUBLE (pspec);

      copy = gegl_param_spec_double (pspec->name,
                                     g_param_spec_get_nick (pspec),
                                     g_param_spec_get_blurb (pspec),
                                     spec->minimum,
                                     spec->maximum,
                                     spec->default_value,
                                     gspec->ui_minimum,
                                     gspec->ui_maximum,
                                     gspec->ui_gamma,
                                     flags);
    }
  else if (G_IS_PARAM_SPEC_DOUBLE (pspec))
    {
      GParamSpecDouble *spec = G_PARAM_SPEC_DOUBLE (pspec);

      copy = g_param_spec_double (pspec->name,
                                  g_param_spec_get_nick (pspec),
                                  g_param_spec_get_blurb (pspec),
                                  spec->minimum,
                                  spec->maximum,
                                  spec->default_value,
                                  flags);
    }
  else if (G_IS_PARAM_SPEC_FLOAT (pspec))
    {
      GParamSpecFloat *spec = G_PARAM_SPEC_FLOAT (pspec);

      copy = g_param_spec_float (pspec->name,
                                 g_param_spec_get_nick (pspec),
                                 g_param_spec_get_blurb (pspec),
                                 spec->minimum,
                                 spec->maximum,
                                 spec->default_value,
                                 flags);
    }
  else if (GEGL_IS_PARAM_SPEC_INT (pspec))
    {
      GeglParamSpecInt *gspec = GEGL_PARAM_SPEC_INT (pspec);
      GParamSpecInt    *spec  = G_PARAM_SPEC_INT (pspec);

      copy = gegl_param_spec_int (pspec->name,
                                  g_param_spec_get_nick (pspec),
                                  g_param_spec_get_blurb (pspec),
                                  spec->minimum,
                                  spec->maximum,
                                  spec->default_value,
                                  gspec->ui_minimum,
                                  gspec->ui_maximum,
                                  gspec->ui_gamma,
                                  flags);
    }
  else if (GEGL_IS_PARAM_SPEC_SEED (pspec))
    {
      copy = gegl_param_spec_seed (pspec->name,
                                   g_param_spec_get_nick (pspec),
                                   g_param_spec_get_blurb (pspec),
                                   pspec->flags |
                                   GIMP_CONFIG_PARAM_SERIALIZE);
    }
  else if (G_IS_PARAM_SPEC_INT (pspec))
    {
      GParamSpecInt *spec = G_PARAM_SPEC_INT (pspec);

      copy = g_param_spec_int (pspec->name,
                               g_param_spec_get_nick (pspec),
                               g_param_spec_get_blurb (pspec),
                               spec->minimum,
                               spec->maximum,
                               spec->default_value,
                               flags);
    }
  else if (G_IS_PARAM_SPEC_UINT (pspec))
    {
      GParamSpecUInt *spec = G_PARAM_SPEC_UINT (pspec);

      copy = g_param_spec_uint (pspec->name,
                                g_param_spec_get_nick (pspec),
                                g_param_spec_get_blurb (pspec),
                                spec->minimum,
                                spec->maximum,
                                spec->default_value,
                                flags);
    }
  else if (GIMP_IS_PARAM_SPEC_RGB (pspec))
    {
      GValue  value = G_VALUE_INIT;
      GimpRGB color;

      g_value_init (&value, GIMP_TYPE_RGB);
      g_param_value_set_default (pspec, &value);
      gimp_value_get_rgb (&value, &color);
      g_value_unset (&value);

      copy = gimp_param_spec_rgb (pspec->name,
                                  g_param_spec_get_nick (pspec),
                                  g_param_spec_get_blurb (pspec),
                                  gimp_param_spec_rgb_has_alpha (pspec),
                                  &color,
                                  flags);
    }
  else if (GEGL_IS_PARAM_SPEC_COLOR (pspec))
    {
      GeglColor *gegl_color;
      GimpRGB    gimp_color;
      gdouble    r = 0.0;
      gdouble    g = 0.0;
      gdouble    b = 0.0;
      gdouble    a = 1.0;
      GValue     value = { 0, };

      g_value_init (&value, GEGL_TYPE_COLOR);
      g_param_value_set_default (pspec, &value);

      gegl_color = g_value_get_object (&value);
      if (gegl_color)
        gegl_color_get_rgba (gegl_color, &r, &g, &b, &a);

      gimp_rgba_set (&gimp_color, r, g, b, a);

      g_value_unset (&value);

      copy = gimp_param_spec_rgb (pspec->name,
                                  g_param_spec_get_nick (pspec),
                                  g_param_spec_get_blurb (pspec),
                                  TRUE,
                                  &gimp_color,
                                  flags);
    }
  else if (G_IS_PARAM_SPEC_OBJECT (pspec) ||
           G_IS_PARAM_SPEC_POINTER (pspec))
    {
      /*  silently ignore object properties  */
    }
  else
    {
      g_warning ("%s: not supported: %s (%s)\n", G_STRFUNC,
                 g_type_name (G_TYPE_FROM_INSTANCE (pspec)), pspec->name);
    }

  if (copy)
    {
      GQuark      quark = g_quark_from_static_string ("gegl-property-keys");
      GHashTable *keys  = g_param_spec_get_qdata (pspec, quark);

      if (keys)
        g_param_spec_set_qdata (copy, quark, g_hash_table_ref (keys));
    }

  return copy;
}
示例#17
0
文件: prop-editor.c 项目: 3v1n0/gtk
static GtkWidget *
property_editor (GObject                *object,
                 GParamSpec             *spec,
                 GtkInspectorPropEditor *editor)
{
  GtkWidget *prop_edit;
  GtkAdjustment *adj;
  gchar *msg;
  GType type = G_PARAM_SPEC_TYPE (spec);

  if (type == G_TYPE_PARAM_INT)
    {
      adj = gtk_adjustment_new (G_PARAM_SPEC_INT (spec)->default_value,
                                G_PARAM_SPEC_INT (spec)->minimum,
                                G_PARAM_SPEC_INT (spec)->maximum,
                                1,
                                MAX ((G_PARAM_SPEC_INT (spec)->maximum - G_PARAM_SPEC_INT (spec)->minimum) / 10, 1),
                                0.0);

      prop_edit = gtk_spin_button_new (adj, 1.0, 0);

      g_object_connect_property (object, spec, G_CALLBACK (int_changed), adj, G_OBJECT (adj)); 

      connect_controller (G_OBJECT (adj), "value_changed",
                          object, spec, G_CALLBACK (int_modified));
    }
  else if (type == G_TYPE_PARAM_UINT)
    {
      adj = gtk_adjustment_new (G_PARAM_SPEC_UINT (spec)->default_value,
                                G_PARAM_SPEC_UINT (spec)->minimum,
                                G_PARAM_SPEC_UINT (spec)->maximum,
                                1,
                                MAX ((G_PARAM_SPEC_UINT (spec)->maximum - G_PARAM_SPEC_UINT (spec)->minimum) / 10, 1),
                                0.0);

      prop_edit = gtk_spin_button_new (adj, 1.0, 0);

      g_object_connect_property (object, spec,
                                 G_CALLBACK (uint_changed),
                                 adj, G_OBJECT (adj));

      connect_controller (G_OBJECT (adj), "value_changed",
                          object, spec, G_CALLBACK (uint_modified));
    }
  else if (type == G_TYPE_PARAM_FLOAT)
    {
      adj = gtk_adjustment_new (G_PARAM_SPEC_FLOAT (spec)->default_value,
                                G_PARAM_SPEC_FLOAT (spec)->minimum,
                                G_PARAM_SPEC_FLOAT (spec)->maximum,
                                0.1,
                                MAX ((G_PARAM_SPEC_FLOAT (spec)->maximum - G_PARAM_SPEC_FLOAT (spec)->minimum) / 10, 0.1),
                                0.0);

      prop_edit = gtk_spin_button_new (adj, 0.1, 2);

      g_object_connect_property (object, spec,
                                 G_CALLBACK (float_changed),
                                 adj, G_OBJECT (adj));

      connect_controller (G_OBJECT (adj), "value_changed",
                          object, spec, G_CALLBACK (float_modified));
    }
  else if (type == G_TYPE_PARAM_DOUBLE)
    {
      adj = gtk_adjustment_new (G_PARAM_SPEC_DOUBLE (spec)->default_value,
                                G_PARAM_SPEC_DOUBLE (spec)->minimum,
                                G_PARAM_SPEC_DOUBLE (spec)->maximum,
                                0.1,
                                MAX ((G_PARAM_SPEC_DOUBLE (spec)->maximum - G_PARAM_SPEC_DOUBLE (spec)->minimum) / 10, 0.1),
                                0.0);

      prop_edit = gtk_spin_button_new (adj, 0.1, 2);

      g_object_connect_property (object, spec,
                                 G_CALLBACK (double_changed),
                                 adj, G_OBJECT (adj));

      connect_controller (G_OBJECT (adj), "value_changed",
                          object, spec, G_CALLBACK (double_modified));
    }
  else if (type == G_TYPE_PARAM_STRING)
    {
      prop_edit = gtk_entry_new ();

      g_object_connect_property (object, spec,
                                 G_CALLBACK (string_changed),
                                 prop_edit, G_OBJECT (prop_edit));

      connect_controller (G_OBJECT (prop_edit), "changed",
                          object, spec, G_CALLBACK (string_modified));
    }
  else if (type == G_TYPE_PARAM_BOOLEAN)
    {
      prop_edit = gtk_toggle_button_new_with_label ("");

      g_object_connect_property (object, spec,
                                 G_CALLBACK (bool_changed),
                                 prop_edit, G_OBJECT (prop_edit));

      connect_controller (G_OBJECT (prop_edit), "toggled",
                          object, spec, G_CALLBACK (bool_modified));
    }
  else if (type == G_TYPE_PARAM_ENUM)
    {
      {
        GtkWidget *box;
        GEnumClass *eclass;
        GtkWidget *first;
        gint j;

        prop_edit = gtk_scrolled_window_new (NULL, NULL);
        g_object_set (prop_edit,
                      "expand", TRUE,
                      "hscrollbar-policy", GTK_POLICY_NEVER,
                      "vscrollbar-policy", GTK_POLICY_NEVER,
                      NULL);
        box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
        gtk_widget_show (box);
        gtk_container_add (GTK_CONTAINER (prop_edit), box);

        eclass = G_ENUM_CLASS (g_type_class_ref (spec->value_type));

        j = 0;
        first = NULL;
        while (j < eclass->n_values)
          {
            GtkWidget *b;

            b = gtk_radio_button_new_with_label_from_widget ((GtkRadioButton*)first, eclass->values[j].value_name);
            if (first == NULL)
              first = b;
            g_object_set_data (G_OBJECT (b), "index", GINT_TO_POINTER (j));
            gtk_widget_show (b);
            gtk_box_pack_start (GTK_BOX (box), b, FALSE, FALSE, 0);
            connect_controller (G_OBJECT (b), "toggled",
                                object, spec, G_CALLBACK (enum_modified));
            ++j;
          }

        if (j >= 10)
          g_object_set (prop_edit, "vscrollbar-policy", GTK_POLICY_AUTOMATIC, NULL);

        g_type_class_unref (eclass);

        g_object_connect_property (object, spec,
                                   G_CALLBACK (enum_changed),
                                   prop_edit, G_OBJECT (prop_edit));
      }
    }
  else if (type == G_TYPE_PARAM_FLAGS)
    {
      {
        GtkWidget *box;
        GFlagsClass *fclass;
        gint j;

        prop_edit = gtk_scrolled_window_new (NULL, NULL);
        g_object_set (prop_edit,
                      "expand", TRUE,
                      "hscrollbar-policy", GTK_POLICY_NEVER,
                      "vscrollbar-policy", GTK_POLICY_NEVER,
                      NULL);
        box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
        gtk_widget_show (box);
        gtk_container_add (GTK_CONTAINER (prop_edit), box);

        fclass = G_FLAGS_CLASS (g_type_class_ref (spec->value_type));

        for (j = 0; j < fclass->n_values; j++)
          {
            GtkWidget *b;

            b = gtk_check_button_new_with_label (fclass->values[j].value_name);
            g_object_set_data (G_OBJECT (b), "index", GINT_TO_POINTER (j));
            gtk_widget_show (b);
            gtk_box_pack_start (GTK_BOX (box), b, FALSE, FALSE, 0);
            connect_controller (G_OBJECT (b), "toggled",
                                object, spec, G_CALLBACK (flags_modified));
          }

        if (j >= 10)
          g_object_set (prop_edit, "vscrollbar-policy", GTK_POLICY_AUTOMATIC, NULL);

        g_type_class_unref (fclass);

        g_object_connect_property (object, spec,
                                   G_CALLBACK (flags_changed),
                                   prop_edit, G_OBJECT (prop_edit));
      }
    }
  else if (type == G_TYPE_PARAM_UNICHAR)
    {
      prop_edit = gtk_entry_new ();
      gtk_entry_set_max_length (GTK_ENTRY (prop_edit), 1);

      g_object_connect_property (object, spec,
                                 G_CALLBACK (unichar_changed),
                                 prop_edit, G_OBJECT (prop_edit));

      connect_controller (G_OBJECT (prop_edit), "changed",
                          object, spec, G_CALLBACK (unichar_modified));
    }
  else if (type == G_TYPE_PARAM_POINTER)
    {
      prop_edit = gtk_label_new ("");

      g_object_connect_property (object, spec,
                                 G_CALLBACK (pointer_changed),
                                 prop_edit, G_OBJECT (prop_edit));
    }
  else if (type == G_TYPE_PARAM_OBJECT)
    {
      GtkWidget *label, *button;

      prop_edit = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);

      label = gtk_label_new ("");
      button = gtk_button_new_with_label (_("Properties"));
      g_signal_connect_swapped (button, "clicked",
                                G_CALLBACK (object_properties),
                                editor);
      gtk_container_add (GTK_CONTAINER (prop_edit), label);
      gtk_container_add (GTK_CONTAINER (prop_edit), button);
      gtk_widget_show (label);
      gtk_widget_show (button);

      g_object_connect_property (object, spec,
                                 G_CALLBACK (object_changed),
                                 prop_edit, G_OBJECT (label));
    }
  else if (type == G_TYPE_PARAM_BOXED &&
           G_PARAM_SPEC_VALUE_TYPE (spec) == GDK_TYPE_RGBA)
    {
      prop_edit = gtk_color_chooser_widget_new ();
      gtk_color_chooser_set_use_alpha (GTK_COLOR_CHOOSER (prop_edit), TRUE);

      g_object_connect_property (object, spec,
                                 G_CALLBACK (rgba_changed),
                                 prop_edit, G_OBJECT (prop_edit));

      connect_controller (G_OBJECT (prop_edit), "notify::rgba",
                          object, spec, G_CALLBACK (rgba_modified));
    }
  else if (type == G_TYPE_PARAM_BOXED &&
           G_PARAM_SPEC_VALUE_TYPE (spec) == g_type_from_name ("GdkColor"))
    {
      prop_edit = gtk_color_chooser_widget_new ();
      gtk_color_chooser_set_use_alpha (GTK_COLOR_CHOOSER (prop_edit), FALSE);

      g_object_connect_property (object, spec,
                                 G_CALLBACK (color_changed),
                                 prop_edit, G_OBJECT (prop_edit));

      connect_controller (G_OBJECT (prop_edit), "notify::rgba",
                          object, spec, G_CALLBACK (color_modified));
    }
  else if (type == G_TYPE_PARAM_BOXED &&
           G_PARAM_SPEC_VALUE_TYPE (spec) == PANGO_TYPE_FONT_DESCRIPTION)
    {
      prop_edit = gtk_font_chooser_widget_new ();

      g_object_connect_property (object, spec,
                                 G_CALLBACK (font_changed),
                                 prop_edit, G_OBJECT (prop_edit));

      connect_controller (G_OBJECT (prop_edit), "notify::font-desc",
                          object, spec, G_CALLBACK (font_modified));
    }
  else
    {
      msg = g_strdup_printf (_("Uneditable property type: %s"),
                             g_type_name (G_PARAM_SPEC_TYPE (spec)));
      prop_edit = gtk_label_new (msg);
      g_free (msg);
      gtk_widget_set_halign (prop_edit, GTK_ALIGN_START);
      gtk_widget_set_valign (prop_edit, GTK_ALIGN_CENTER);
    }

  if (g_param_spec_get_blurb (spec))
    gtk_widget_set_tooltip_text (prop_edit, g_param_spec_get_blurb (spec));

  notify_property (object, spec);

  return prop_edit;
}
示例#18
0
static void test_xml_parser(void) {
    GError *error = NULL; ZCloudStorePlugin *pl;

    load_xml("<zcloud-module basename=\"disk\">"
        "<store-plugin prefix=\"disk\"></store-plugin>"
        "</zcloud-module>", &error);
    gerror_is_clear(&error, "XML: single plugin in a simple module");
    ok(NULL != zcloud_get_store_plugin_by_prefix("disk"), "plugin found");

    load_xml("<zcloud-module foo=\"bar\" basename=\"myext\">"
        "<store-plugin prefix=\"myext\"></store-plugin>"
        "</zcloud-module>", &error);
    gerror_is_set(&error, "*'zcloud-module' attribute 'foo' not recognized",
                G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE, "bogus zcloud-module attribute");

    load_xml("<zcloud-module basename=\"myext\">"
        "<store-plugin foo=\"bar\" prefix=\"myext\"></store-plugin>"
        "</zcloud-module>", &error);
    gerror_is_set(&error, "*'store-plugin' attribute 'foo' not recognized",
                G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE, "bogus store-plugin attribute");

    load_xml("<zcloud-module>"
        "<store-plugin prefix=\"myext\"></store-plugin>"
        "</zcloud-module>", &error);
    gerror_is_set(&error, "*'zcloud-module' attribute 'basename' is required",
                G_MARKUP_ERROR_INVALID_CONTENT, "missing basename attribute");

    load_xml("<zcloud-module basename=\"foo\">"
        "<store-plugin></store-plugin>"
        "</zcloud-module>", &error);
    gerror_is_set(&error, "*'store-plugin' attribute 'prefix' is required",
                G_MARKUP_ERROR_INVALID_CONTENT, "missing prefix attribute");

    load_xml("<zcloud-module basename=\"myext\">"
        "random text"
        "</zcloud-module>", &error);
    gerror_is_set(&error, "*unexpected text",
            G_MARKUP_ERROR_INVALID_CONTENT, "unexpected text");

    load_xml("<zcloud-module basename=\"myext\">"
        "<blink>hi mom</blink>"
        "</zcloud-module>", &error);
    gerror_is_set(&error, "*element 'blink' not recognized",
            G_MARKUP_ERROR_UNKNOWN_ELEMENT, "bogus element");

    load_xml("<store-plugin></store-plugin>", &error);
    gerror_is_set(&error, "*element 'store-plugin' must appear in a 'zcloud-module' element",
            G_MARKUP_ERROR_INVALID_CONTENT, "store-plugin with no module");

    load_xml("<zcloud-module basename=\"myext\">"
        "<zcloud-module>", &error);
    gerror_is_set(&error, "*element 'zcloud-module' cannot be nested",
            G_MARKUP_ERROR_INVALID_CONTENT, "nested zcloud-module");

    load_xml("<zcloud-module basename=\"myext\">"
        "<store-plugin prefix=\"myext\">"
        "<store-plugin prefix=\"myext\">", &error);
    gerror_is_set(&error, "*element 'store-plugin' cannot be nested",
            G_MARKUP_ERROR_INVALID_CONTENT, "nested store-plugin");

    load_xml("<zcloud-module basename=\"myext\">"
        "<store-plugin prefix=\"myext\">"
        "<store-plugin prefix=\"myext\">", &error);
    gerror_is_set(&error, "*element 'store-plugin' cannot be nested",
            G_MARKUP_ERROR_INVALID_CONTENT, "nested store-plugin");

    load_xml("<parameter name=\"foo\" type=\"string\" blurb=\"bar\" />",
         &error);
    gerror_is_set(&error, "*element 'parameter' must appear in a 'store-plugin' element",
            G_MARKUP_ERROR_INVALID_CONTENT, "property with no module");

    load_xml("<zcloud-module basename=\"myext\"><store-plugin prefix=\"foo\">"
        "<parameter type=\"string\" blurb=\"bar\" />", &error);
    gerror_is_set(&error, "*'parameter' attribute 'name' is required",
                G_MARKUP_ERROR_INVALID_CONTENT, "missing name attribute");

    load_xml("<zcloud-module basename=\"myext\"><store-plugin prefix=\"foo\">"
        "<parameter name=\"foo\" blurb=\"bar\" />", &error);
    gerror_is_set(&error, "*'parameter' attribute 'type' is required",
                G_MARKUP_ERROR_INVALID_CONTENT, "missing type attribute");

    load_xml("<zcloud-module basename=\"myext\"><store-plugin prefix=\"foo\">"
        "<parameter name=\"foo\" type=\"string\" />", &error);
    gerror_is_set(&error, "*'parameter' attribute 'blurb' is required",
                G_MARKUP_ERROR_INVALID_CONTENT, "missing blurb attribute");

    load_xml("<zcloud-module basename=\"myext\"><store-plugin prefix=\"foo\">"
        "<parameter name=\"foo\" hype=\"string\" />", &error);
    gerror_is_set(&error, "*'parameter' attribute 'hype' not recognized",
                G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE, "bad property attribute");

    load_xml("<zcloud-module basename=\"myext\"><store-plugin prefix=\"foo\">"
        "<parameter name=\"foo\" type=\"rectangle\" blurb=\"bar\"/>", &error);
    gerror_is_set(&error, "*invalid parameter type 'rectangle'",
                G_MARKUP_ERROR_INVALID_CONTENT, "bad parameter type");

    load_xml("<zcloud-module basename=\"myext\"><store-plugin prefix=\"foo\">"
        "<parameter name=\"1foo\" type=\"string\" blurb=\"bar\"/>", &error);
    gerror_is_set(&error, "*invalid parameter name '1foo'",
                G_MARKUP_ERROR_INVALID_CONTENT, "bad parameter name (starts with number)");

    load_xml("<zcloud-module basename=\"myext\"><store-plugin prefix=\"foo\">"
        "<parameter name=\"f_o_o\" type=\"string\" blurb=\"bar\"/>", &error);
    gerror_is_set(&error, "*invalid parameter name 'f_o_o'",
                G_MARKUP_ERROR_INVALID_CONTENT, "bad parameter name (non-alphanumeric)");

    load_xml("<zcloud-module basename=\"mod\">"
        "<store-plugin prefix=\"withprop\">"
        " <parameter name=\"ver-bose\" type=\"string\" blurb=\"lots to say\" />"
        "</store-plugin>"
        "</zcloud-module>", &error);
    gerror_is_clear(&error, "no error loading a plugin with a property with dashes in its name");

    load_xml("<zcloud-module basename=\"myext\"><store-plugin prefix=\"foo\">"
        "<parameter name=\"foo\" type=\"sTrInG\" blurb=\"bar\">"
        "<foo>"
        "</parameter>", &error);
    gerror_is_set(&error, "*'parameter' element must be empty",
                G_MARKUP_ERROR_INVALID_CONTENT, "non-empty property");

    load_xml("<zcloud-module basename=\"myext\"><store-plugin prefix=\"foo\">"
        "<parameter name=\"foo\" type=\"string\" blurb=\"bar\" />"
        "<parameter name=\"foo\" type=\"string\" blurb=\"bar\" />", &error);
    gerror_is_set(&error, "*duplicate parameter name 'foo'",
                G_MARKUP_ERROR_INVALID_CONTENT, "duplicate property");

    load_xml("<zcloud-module basename=\"myext\">"
        "<store-plugin prefix=\"myext1\"></store-plugin>"
        "<store-plugin prefix=\"myext2\"></store-plugin>"
        "</zcloud-module>", &error);
    gerror_is_clear(&error, "no error loading a module with two store plugins");
    ok(NULL != zcloud_get_store_plugin_by_prefix("myext1"), "one of two plugins exists");
    ok(NULL != zcloud_get_store_plugin_by_prefix("myext2"), ".. as does the other");

    load_xml("<zcloud-module basename=\"myext\">"
        "<store-plugin prefix=\"dupe\"></store-plugin>"
        "<store-plugin prefix=\"dupe\"></store-plugin>"
        "</zcloud-module>", &error);
    gerror_is_set(&error, "*store plugin prefix 'dupe' is already defined",
            G_MARKUP_ERROR_INVALID_CONTENT, "duplicate prefixes generate an error");

    load_xml("<zcloud-module basename=\"myext1\">"
        "<store-plugin prefix=\"one\"></store-plugin>"
        "</zcloud-module><zcloud-module basename=\"myext2\">"
        "<store-plugin prefix=\"two\"></store-plugin>"
        "</zcloud-module>", &error);
    gerror_is_clear(&error, "no error loading two modules");

    pl = zcloud_get_store_plugin_by_prefix("one");
    ok(pl != NULL, "prefix one exists");
    ok(0 == strcmp(pl->module->basename, "myext1"),
        "..and has the right module name");

    pl = zcloud_get_store_plugin_by_prefix("two");
    ok(pl != NULL, "prefix two exists");
    ok(0 == strcmp(pl->module->basename, "myext2"),
        "..and has the right module name");

    load_xml("<zcloud-module basename=\"mod\">"
        "<store-plugin prefix=\"withprop\">"
        " <parameter name=\"verbose\" type=\"string\" blurb=\"talkative; wordy\" />"
        "</store-plugin>"
        "</zcloud-module>", &error);
    gerror_is_clear(&error, "no error loading a plugin with a property without a nick");
    pl = zcloud_get_store_plugin_by_prefix("withprop");
    is_string(get_paramspec(pl, 0)->name, "verbose",
            "..name is set correctly");
    is_string(g_param_spec_get_blurb(get_paramspec(pl, 0)), "talkative; wordy",
            "..blurb is set correctly");
    is_int(get_paramspec(pl, 0)->value_type, G_TYPE_STRING,
            "..type is set correctly");
    is_string(g_param_spec_get_nick(get_paramspec(pl, 0)), "verbose",
            "..and the nick defaults correctly");

    load_xml("<zcloud-module basename=\"mod\">"
        "<store-plugin prefix=\"withprop\">"
        " <parameter name=\"verbose\" type=\"string\" nick=\"loud\" blurb=\"talkative; wordy\" />"
        "</store-plugin>"
        "</zcloud-module>", &error);
    gerror_is_clear(&error, "no error loading a plugin with a property with a nick");
    pl = zcloud_get_store_plugin_by_prefix("withprop");
    is_string(g_param_spec_get_nick(get_paramspec(pl, 0)), "loud",
            "..and the nick defaults correctly");

    load_xml("<zcloud-module basename=\"foo\">"
        "<store-plugin prefix=\"one\"></store-plugin>"
        "</zcloud-module><zcloud-module basename=\"foo\">"
        "<store-plugin prefix=\"another\"></store-plugin>"
        "</zcloud-module>", &error);
    gerror_is_set(&error, "*zcloud-module with basename 'foo' is already defined",
            G_MARKUP_ERROR_INVALID_CONTENT,
            "two extensions with the same basename generate an error");

    load_xml("<zcloud-module basename=\"myext\">"
    "<store-plugin prefix=\"one\"></store-plugin>"
    "<store-plugin prefix=\"two\"></store-plugin>"
    "</zcloud-module>", &error);
    gerror_is_clear(&error, "no error loading two plugins");

    {
        GSList *iter, *all;
        gboolean seen_one = FALSE, seen_two = FALSE;

        /* evaluate all of the fields in the structs to make sure they're set
         * correctly */
        all = zcloud_get_all_store_plugins();
        for (iter = all; iter; iter = iter->next) {
            pl = (ZCloudStorePlugin *)iter->data;

            if (0 == strcmp(pl->prefix, "one"))
                seen_one = TRUE;
            if (0 == strcmp(pl->prefix, "two"))
                seen_two = TRUE;

            is_string(pl->module->basename, "myext",
                "module basename is correct");
            is_string(pl->module->xml_path, "(string)",
                "module xml_path is correct");
            ok(pl->module->module_path != NULL,
                "module module_path is non-NULL");
        }

        ok(g_slist_length(all) == 2 && seen_one && seen_two,
            "saw the correct two plugins");
    }
}
示例#19
0
gboolean
plug_in_rc_write (GSList  *plug_in_defs,
                  GFile   *file,
                  GError **error)
{
  GimpConfigWriter *writer;
  GEnumClass       *enum_class;
  GSList           *list;

  writer = gimp_config_writer_new_gfile (file,
                                         FALSE,
                                         "GIMP pluginrc\n\n"
                                         "This file can safely be removed and "
                                         "will be automatically regenerated by "
                                         "querying the installed plugins.",
                                         error);
  if (!writer)
    return FALSE;

  enum_class = g_type_class_ref (GIMP_TYPE_ICON_TYPE);

  gimp_config_writer_open (writer, "protocol-version");
  gimp_config_writer_printf (writer, "%d", GIMP_PROTOCOL_VERSION);
  gimp_config_writer_close (writer);

  gimp_config_writer_open (writer, "file-version");
  gimp_config_writer_printf (writer, "%d", PLUG_IN_RC_FILE_VERSION);
  gimp_config_writer_close (writer);

  gimp_config_writer_linefeed (writer);

  for (list = plug_in_defs; list; list = list->next)
    {
      GimpPlugInDef *plug_in_def = list->data;

      if (plug_in_def->procedures)
        {
          GSList *list2;
          gchar  *path;
          gchar  *utf8;

          path = g_file_get_path (plug_in_def->file);
          utf8 = g_filename_to_utf8 (path, -1, NULL, NULL, NULL);
          g_free (path);

          if (! utf8)
            continue;

          gimp_config_writer_open (writer, "plug-in-def");
          gimp_config_writer_string (writer, utf8);
          gimp_config_writer_printf (writer, "%"G_GINT64_FORMAT,
                                     plug_in_def->mtime);

          g_free (utf8);

          for (list2 = plug_in_def->procedures; list2; list2 = list2->next)
            {
              GimpPlugInProcedure *proc      = list2->data;
              GimpProcedure       *procedure = GIMP_PROCEDURE (proc);
              GEnumValue          *enum_value;
              GList               *list3;
              gint                 i;

              if (proc->installed_during_init)
                continue;

              gimp_config_writer_open (writer, "proc-def");
              gimp_config_writer_printf (writer, "\"%s\" %d",
                                         procedure->original_name,
                                         procedure->proc_type);
              gimp_config_writer_linefeed (writer);
              gimp_config_writer_string (writer, procedure->blurb);
              gimp_config_writer_linefeed (writer);
              gimp_config_writer_string (writer, procedure->help);
              gimp_config_writer_linefeed (writer);
              gimp_config_writer_string (writer, procedure->author);
              gimp_config_writer_linefeed (writer);
              gimp_config_writer_string (writer, procedure->copyright);
              gimp_config_writer_linefeed (writer);
              gimp_config_writer_string (writer, procedure->date);
              gimp_config_writer_linefeed (writer);
              gimp_config_writer_string (writer, proc->menu_label);
              gimp_config_writer_linefeed (writer);

              gimp_config_writer_printf (writer, "%d",
                                         g_list_length (proc->menu_paths));
              for (list3 = proc->menu_paths; list3; list3 = list3->next)
                {
                  gimp_config_writer_open (writer, "menu-path");
                  gimp_config_writer_string (writer, list3->data);
                  gimp_config_writer_close (writer);
                }

              gimp_config_writer_open (writer, "icon");
              enum_value = g_enum_get_value (enum_class, proc->icon_type);
              gimp_config_writer_identifier (writer, enum_value->value_nick);
              gimp_config_writer_printf (writer, "%d",
                                         proc->icon_data_length);

              switch (proc->icon_type)
                {
                case GIMP_ICON_TYPE_ICON_NAME:
                case GIMP_ICON_TYPE_IMAGE_FILE:
                  gimp_config_writer_string (writer, (gchar *) proc->icon_data);
                  break;

                case GIMP_ICON_TYPE_INLINE_PIXBUF:
                  gimp_config_writer_data (writer, proc->icon_data_length,
                                           proc->icon_data);
                  break;
                }

              gimp_config_writer_close (writer);

              if (proc->file_proc)
                {
                  gimp_config_writer_open (writer,
                                           proc->image_types ?
                                           "save-proc" : "load-proc");

                  if (proc->extensions && *proc->extensions)
                    {
                      gimp_config_writer_open (writer, "extension");
                      gimp_config_writer_string (writer, proc->extensions);
                      gimp_config_writer_close (writer);
                    }

                  if (proc->prefixes && *proc->prefixes)
                    {
                      gimp_config_writer_open (writer, "prefix");
                      gimp_config_writer_string (writer, proc->prefixes);
                      gimp_config_writer_close (writer);
                    }

                  if (proc->magics && *proc->magics)
                    {
                      gimp_config_writer_open (writer, "magic");
                      gimp_config_writer_string (writer, proc->magics);
                      gimp_config_writer_close (writer);
                    }

                  if (proc->mime_type)
                    {
                      gimp_config_writer_open (writer, "mime-type");
                      gimp_config_writer_string (writer, proc->mime_type);
                      gimp_config_writer_close (writer);
                    }

                  if (proc->handles_uri)
                    {
                      gimp_config_writer_open (writer, "handles-uri");
                      gimp_config_writer_close (writer);
                    }

                  if (proc->thumb_loader)
                    {
                      gimp_config_writer_open (writer, "thumb-loader");
                      gimp_config_writer_string (writer, proc->thumb_loader);
                      gimp_config_writer_close (writer);
                    }

                  gimp_config_writer_close (writer);
                }

              gimp_config_writer_linefeed (writer);

              gimp_config_writer_string (writer, proc->image_types);
              gimp_config_writer_linefeed (writer);

              gimp_config_writer_printf (writer, "%d %d",
                                         procedure->num_args,
                                         procedure->num_values);

              for (i = 0; i < procedure->num_args; i++)
                {
                  GParamSpec *pspec = procedure->args[i];

                  gimp_config_writer_open (writer, "proc-arg");
                  gimp_config_writer_printf (writer, "%d",
                                             gimp_pdb_compat_arg_type_from_gtype (G_PARAM_SPEC_VALUE_TYPE (pspec)));

                  gimp_config_writer_string (writer,
                                             g_param_spec_get_name (pspec));
                  gimp_config_writer_string (writer,
                                             g_param_spec_get_blurb (pspec));

                  gimp_config_writer_close (writer);
                }

              for (i = 0; i < procedure->num_values; i++)
                {
                  GParamSpec *pspec = procedure->values[i];

                  gimp_config_writer_open (writer, "proc-arg");
                  gimp_config_writer_printf (writer, "%d",
                                             gimp_pdb_compat_arg_type_from_gtype (G_PARAM_SPEC_VALUE_TYPE (pspec)));

                  gimp_config_writer_string (writer,
                                             g_param_spec_get_name (pspec));
                  gimp_config_writer_string (writer,
                                             g_param_spec_get_blurb (pspec));

                  gimp_config_writer_close (writer);
                }

              gimp_config_writer_close (writer);
            }

          if (plug_in_def->locale_domain_name)
            {
              gimp_config_writer_open (writer, "locale-def");
              gimp_config_writer_string (writer,
                                         plug_in_def->locale_domain_name);

              if (plug_in_def->locale_domain_path)
                gimp_config_writer_string (writer,
                                           plug_in_def->locale_domain_path);

              gimp_config_writer_close (writer);
            }

          if (plug_in_def->help_domain_name)
            {
              gimp_config_writer_open (writer, "help-def");
              gimp_config_writer_string (writer,
                                         plug_in_def->help_domain_name);

              if (plug_in_def->help_domain_uri)
                gimp_config_writer_string (writer,
                                           plug_in_def->help_domain_uri);

             gimp_config_writer_close (writer);
            }

          if (plug_in_def->has_init)
            {
              gimp_config_writer_open (writer, "has-init");
              gimp_config_writer_close (writer);
            }

          gimp_config_writer_close (writer);
        }
    }

  g_type_class_unref (enum_class);

  return gimp_config_writer_finish (writer, "end of pluginrc", error);
}
示例#20
0
static void
print_element_properties_info (GstElement * element)
{
  GParamSpec **property_specs;
  guint num_properties, i;
  gboolean readable;
  gboolean first_flag;

  property_specs = g_object_class_list_properties
      (G_OBJECT_GET_CLASS (element), &num_properties);
  n_print ("\n");
  n_print ("Element Properties:\n");

  for (i = 0; i < num_properties; i++) {
    GValue value = { 0, };
    GParamSpec *param = property_specs[i];

    readable = FALSE;

    g_value_init (&value, param->value_type);

    n_print ("  %-20s: %s\n", g_param_spec_get_name (param),
        g_param_spec_get_blurb (param));

    first_flag = TRUE;
    n_print ("%-23.23s flags: ", "");
    if (param->flags & G_PARAM_READABLE) {
      g_object_get_property (G_OBJECT (element), param->name, &value);
      readable = TRUE;
      if (!first_flag)
        g_print (", ");
      else
        first_flag = FALSE;
      g_print (_("readable"));
    }
    if (param->flags & G_PARAM_WRITABLE) {
      if (!first_flag)
        g_print (", ");
      else
        first_flag = FALSE;
      g_print (_("writable"));
    }
    if (param->flags & GST_PARAM_CONTROLLABLE) {
      if (!first_flag)
        g_print (", ");
      else
        first_flag = FALSE;
      g_print (_("controllable"));
    }
    n_print ("\n");

    switch (G_VALUE_TYPE (&value)) {
      case G_TYPE_STRING:
      {
        GParamSpecString *pstring = G_PARAM_SPEC_STRING (param);

        n_print ("%-23.23s String. ", "");

        if (pstring->default_value == NULL)
          g_print ("Default: null ");
        else
          g_print ("Default: \"%s\" ", pstring->default_value);

        if (readable) {
          const char *string_val = g_value_get_string (&value);

          if (string_val == NULL)
            g_print ("Current: null");
          else
            g_print ("Current: \"%s\"", string_val);
        }
        break;
      }
      case G_TYPE_BOOLEAN:
      {
        GParamSpecBoolean *pboolean = G_PARAM_SPEC_BOOLEAN (param);

        n_print ("%-23.23s Boolean. ", "");
        g_print ("Default: %s ", (pboolean->default_value ? "true" : "false"));
        if (readable)
          g_print ("Current: %s",
              (g_value_get_boolean (&value) ? "true" : "false"));
        break;
      }
      case G_TYPE_ULONG:
      {
        GParamSpecULong *pulong = G_PARAM_SPEC_ULONG (param);

        n_print ("%-23.23s Unsigned Long. ", "");
        g_print ("Range: %lu - %lu Default: %lu ",
            pulong->minimum, pulong->maximum, pulong->default_value);
        if (readable)
          g_print ("Current: %lu", g_value_get_ulong (&value));
        break;
      }
      case G_TYPE_LONG:
      {
        GParamSpecLong *plong = G_PARAM_SPEC_LONG (param);

        n_print ("%-23.23s Long. ", "");
        g_print ("Range: %ld - %ld Default: %ld ",
            plong->minimum, plong->maximum, plong->default_value);
        if (readable)
          g_print ("Current: %ld", g_value_get_long (&value));
        break;
      }
      case G_TYPE_UINT:
      {
        GParamSpecUInt *puint = G_PARAM_SPEC_UINT (param);

        n_print ("%-23.23s Unsigned Integer. ", "");
        g_print ("Range: %u - %u Default: %u ",
            puint->minimum, puint->maximum, puint->default_value);
        if (readable)
          g_print ("Current: %u", g_value_get_uint (&value));
        break;
      }
      case G_TYPE_INT:
      {
        GParamSpecInt *pint = G_PARAM_SPEC_INT (param);

        n_print ("%-23.23s Integer. ", "");
        g_print ("Range: %d - %d Default: %d ",
            pint->minimum, pint->maximum, pint->default_value);
        if (readable)
          g_print ("Current: %d", g_value_get_int (&value));
        break;
      }
      case G_TYPE_UINT64:
      {
        GParamSpecUInt64 *puint64 = G_PARAM_SPEC_UINT64 (param);

        n_print ("%-23.23s Unsigned Integer64. ", "");
        g_print ("Range: %" G_GUINT64_FORMAT " - %" G_GUINT64_FORMAT
            " Default: %" G_GUINT64_FORMAT " ",
            puint64->minimum, puint64->maximum, puint64->default_value);
        if (readable)
          g_print ("Current: %" G_GUINT64_FORMAT, g_value_get_uint64 (&value));
        break;
      }
      case G_TYPE_INT64:
      {
        GParamSpecInt64 *pint64 = G_PARAM_SPEC_INT64 (param);

        n_print ("%-23.23s Integer64. ", "");
        g_print ("Range: %" G_GINT64_FORMAT " - %" G_GINT64_FORMAT
            " Default: %" G_GINT64_FORMAT " ",
            pint64->minimum, pint64->maximum, pint64->default_value);
        if (readable)
          g_print ("Current: %" G_GINT64_FORMAT, g_value_get_int64 (&value));
        break;
      }
      case G_TYPE_FLOAT:
      {
        GParamSpecFloat *pfloat = G_PARAM_SPEC_FLOAT (param);

        n_print ("%-23.23s Float. ", "");
        g_print ("Range: %15.7g - %15.7g Default: %15.7g ",
            pfloat->minimum, pfloat->maximum, pfloat->default_value);
        if (readable)
          g_print ("Current: %15.7g", g_value_get_float (&value));
        break;
      }
      case G_TYPE_DOUBLE:
      {
        GParamSpecDouble *pdouble = G_PARAM_SPEC_DOUBLE (param);

        n_print ("%-23.23s Double. ", "");
        g_print ("Range: %15.7g - %15.7g Default: %15.7g ",
            pdouble->minimum, pdouble->maximum, pdouble->default_value);
        if (readable)
          g_print ("Current: %15.7g", g_value_get_double (&value));
        break;
      }
      default:
        if (param->value_type == GST_TYPE_CAPS) {
          const GstCaps *caps = gst_value_get_caps (&value);

          if (!caps)
            n_print ("%-23.23s Caps (NULL)", "");
          else {
            print_caps (caps, "                           ");
          }
        } else if (G_IS_PARAM_SPEC_ENUM (param)) {
          GParamSpecEnum *penum = G_PARAM_SPEC_ENUM (param);
          GEnumValue *values;
          guint j = 0;
          gint enum_value;
          const gchar *def_val_nick = "", *cur_val_nick = "";

          values = G_ENUM_CLASS (g_type_class_ref (param->value_type))->values;
          enum_value = g_value_get_enum (&value);

          while (values[j].value_name) {
            if (values[j].value == enum_value)
              cur_val_nick = values[j].value_nick;
            if (values[j].value == penum->default_value)
              def_val_nick = values[j].value_nick;
            j++;
          }

          n_print
              ("%-23.23s Enum \"%s\" Default: %d, \"%s\" Current: %d, \"%s\"",
              "", g_type_name (G_VALUE_TYPE (&value)), penum->default_value,
              def_val_nick, enum_value, cur_val_nick);

          j = 0;
          while (values[j].value_name) {
            g_print ("\n");
            if (_name)
              g_print ("%s", _name);
            g_print ("%-23.23s    (%d): %-16s - %s", "",
                values[j].value, values[j].value_nick, values[j].value_name);
            j++;
          }
          /* g_type_class_unref (ec); */
        } else if (G_IS_PARAM_SPEC_FLAGS (param)) {
          GParamSpecFlags *pflags = G_PARAM_SPEC_FLAGS (param);
          GFlagsValue *values;
          guint j = 0;
          gint flags_value;
          GString *cur_flags = NULL, *def_flags = NULL;

          values = G_FLAGS_CLASS (g_type_class_ref (param->value_type))->values;
          flags_value = g_value_get_flags (&value);

          while (values[j].value_name) {
            if (values[j].value & flags_value) {
              if (cur_flags) {
                g_string_append_printf (cur_flags, " | %s",
                    values[j].value_nick);
              } else {
                cur_flags = g_string_new (values[j].value_nick);
              }
            }
            if (values[j].value & pflags->default_value) {
              if (def_flags) {
                g_string_append_printf (def_flags, " | %s",
                    values[j].value_nick);
              } else {
                def_flags = g_string_new (values[j].value_nick);
              }
            }
            j++;
          }

          n_print
              ("%-23.23s Flags \"%s\" Default: 0x%08x, \"%s\" Current: 0x%08x, \"%s\"",
              "", g_type_name (G_VALUE_TYPE (&value)), pflags->default_value,
              (def_flags ? def_flags->str : "(none)"), flags_value,
              (cur_flags ? cur_flags->str : "(none)"));

          j = 0;
          while (values[j].value_name) {
            g_print ("\n");
            if (_name)
              g_print ("%s", _name);
            g_print ("%-23.23s    (0x%08x): %-16s - %s", "",
                values[j].value, values[j].value_nick, values[j].value_name);
            j++;
          }

          if (cur_flags)
            g_string_free (cur_flags, TRUE);
          if (def_flags)
            g_string_free (def_flags, TRUE);
        } else if (G_IS_PARAM_SPEC_OBJECT (param)) {
          n_print ("%-23.23s Object of type \"%s\"", "",
              g_type_name (param->value_type));
        } else if (G_IS_PARAM_SPEC_BOXED (param)) {
          n_print ("%-23.23s Boxed pointer of type \"%s\"", "",
              g_type_name (param->value_type));
        } else if (G_IS_PARAM_SPEC_POINTER (param)) {
          if (param->value_type != G_TYPE_POINTER) {
            n_print ("%-23.23s Pointer of type \"%s\".", "",
                g_type_name (param->value_type));
          } else {
            n_print ("%-23.23s Pointer.", "");
          }
        } else if (param->value_type == G_TYPE_VALUE_ARRAY) {
          GParamSpecValueArray *pvarray = G_PARAM_SPEC_VALUE_ARRAY (param);

          if (pvarray->element_spec) {
            n_print ("%-23.23s Array of GValues of type \"%s\"", "",
                g_type_name (pvarray->element_spec->value_type));
          } else {
            n_print ("%-23.23s Array of GValues", "");
          }
        } else if (GST_IS_PARAM_SPEC_FRACTION (param)) {
          GstParamSpecFraction *pfraction = GST_PARAM_SPEC_FRACTION (param);

          n_print ("%-23.23s Fraction. ", "");

          g_print ("Range: %d/%d - %d/%d Default: %d/%d ",
              pfraction->min_num, pfraction->min_den,
              pfraction->max_num, pfraction->max_den,
              pfraction->def_num, pfraction->def_den);
          if (readable)
            g_print ("Current: %d/%d",
                gst_value_get_fraction_numerator (&value),
                gst_value_get_fraction_denominator (&value));

        } else if (GST_IS_PARAM_SPEC_MINI_OBJECT (param)) {
          n_print ("%-23.23s MiniObject of type \"%s\"", "",
              g_type_name (param->value_type));
        } else {
          n_print ("%-23.23s Unknown type %ld \"%s\"", "", param->value_type,
              g_type_name (param->value_type));
        }
        break;
    }
    if (!readable)
      g_print (" Write only\n");
    else
      g_print ("\n");

    g_value_reset (&value);
  }
  if (num_properties == 0)
    n_print ("  none\n");

  g_free (property_specs);
}
示例#21
0
static void
dvb_base_bin_class_init (DvbBaseBinClass * klass)
{
  GObjectClass *gobject_class;
  GstElementClass *element_class;
  GstBinClass *bin_class;
  GstElementFactory *dvbsrc_factory;
  GObjectClass *dvbsrc_class;
  typedef struct
  {
    guint prop_id;
    const gchar *prop_name;
  } ProxyedProperty;
  ProxyedProperty *walk;
  ProxyedProperty proxyed_properties[] = {
    {PROP_ADAPTER, "adapter"},
    {PROP_FRONTEND, "frontend"},
    {PROP_DISEQC_SRC, "diseqc-source"},
    {PROP_FREQUENCY, "frequency"},
    {PROP_POLARITY, "polarity"},
    {PROP_SYMBOL_RATE, "symbol-rate"},
    {PROP_BANDWIDTH, "bandwidth"},
    {PROP_CODE_RATE_HP, "code-rate-hp"},
    {PROP_CODE_RATE_LP, "code-rate-lp"},
    {PROP_GUARD, "guard"},
    {PROP_MODULATION, "modulation"},
    {PROP_TRANS_MODE, "trans-mode"},
    {PROP_HIERARCHY, "hierarchy"},
    {PROP_INVERSION, "inversion"},
    {PROP_STATS_REPORTING_INTERVAL, "stats-reporting-interval"},
    {0, NULL}
  };

  bin_class = GST_BIN_CLASS (klass);
  bin_class->handle_message = dvb_base_bin_handle_message;

  element_class = GST_ELEMENT_CLASS (klass);
  element_class->change_state = dvb_base_bin_change_state;

  gobject_class = G_OBJECT_CLASS (klass);
  gobject_class->set_property = dvb_base_bin_set_property;
  gobject_class->get_property = dvb_base_bin_get_property;
  gobject_class->dispose = dvb_base_bin_dispose;
  gobject_class->finalize = dvb_base_bin_finalize;

  /* install dvbsrc properties */
  dvbsrc_factory = gst_element_factory_find ("dvbsrc");
  dvbsrc_class = g_type_class_ref (dvbsrc_factory->type);
  walk = proxyed_properties;
  while (walk->prop_name != NULL) {
    GParamSpec *pspec;
    GParamSpec *our_pspec;

    pspec = g_object_class_find_property (dvbsrc_class, walk->prop_name);
    if (pspec != NULL) {
      GType param_type = G_PARAM_SPEC_TYPE (pspec);

      if (param_type == G_TYPE_PARAM_INT) {
        GParamSpecInt *src_pspec = G_PARAM_SPEC_INT (pspec);

        our_pspec = g_param_spec_int (g_param_spec_get_name (pspec),
            g_param_spec_get_nick (pspec), g_param_spec_get_blurb (pspec),
            src_pspec->minimum, src_pspec->maximum, src_pspec->default_value,
            pspec->flags);
      } else if (param_type == G_TYPE_PARAM_UINT) {
        GParamSpecUInt *src_pspec = G_PARAM_SPEC_UINT (pspec);

        our_pspec = g_param_spec_uint (g_param_spec_get_name (pspec),
            g_param_spec_get_nick (pspec), g_param_spec_get_blurb (pspec),
            src_pspec->minimum, src_pspec->maximum, src_pspec->default_value,
            pspec->flags);
      } else if (param_type == G_TYPE_PARAM_STRING) {
        GParamSpecString *src_pspec = G_PARAM_SPEC_STRING (pspec);

        our_pspec = g_param_spec_string (g_param_spec_get_name (pspec),
            g_param_spec_get_nick (pspec), g_param_spec_get_blurb (pspec),
            src_pspec->default_value, pspec->flags);
      } else if (param_type == G_TYPE_PARAM_ENUM) {
        GParamSpecEnum *src_pspec = G_PARAM_SPEC_ENUM (pspec);

        our_pspec = g_param_spec_enum (g_param_spec_get_name (pspec),
            g_param_spec_get_nick (pspec), g_param_spec_get_blurb (pspec),
            pspec->value_type, src_pspec->default_value, pspec->flags);
      } else {
        GST_ERROR ("Unsupported property type %d for property %s",
            param_type, g_param_spec_get_name (pspec));
        ++walk;
        continue;
      }

      g_object_class_install_property (gobject_class, walk->prop_id, our_pspec);
    } else {
      g_warning ("dvbsrc has no property named %s", walk->prop_name);
    }
    ++walk;
  }
  g_type_class_unref (dvbsrc_class);

  g_object_class_install_property (gobject_class, PROP_PROGRAM_NUMBERS,
      g_param_spec_string ("program-numbers",
          "Program Numbers",
          "Colon separated list of programs", "", G_PARAM_READWRITE));
}
示例#22
0
std::string
get_property_with_node_name(
  GParamSpec* pParamSpec, const std::string& strObjectName, const std::string& strNodeName)
{
  std::string strResult;

  // Name and type:
  const std::string strName = g_param_spec_get_name(pParamSpec);
  const std::string strTypeName = G_PARAM_SPEC_TYPE_NAME(pParamSpec);

  const gchar* pchBlurb = g_param_spec_get_blurb(pParamSpec);
  std::string strDocs = (pchBlurb) ? pchBlurb : "";
  // Quick hack to get rid of nested double quotes:
  std::replace(strDocs.begin(), strDocs.end(), '"', '\'');

  strResult += "(" + strNodeName + " " + strName + "\n";
  strResult += "  (of-object \"" + strObjectName + "\")\n";
  strResult += "  (prop-type \"" + strTypeName + "\")\n";
  strResult += "  (docs \"" + strDocs + "\")\n";

  // Flags:
  GParamFlags flags = pParamSpec->flags;
  bool bReadable = (flags & G_PARAM_READABLE) == G_PARAM_READABLE;
  bool bWritable = (flags & G_PARAM_WRITABLE) == G_PARAM_WRITABLE;
  bool bConstructOnly = (flags & G_PARAM_CONSTRUCT_ONLY) == G_PARAM_CONSTRUCT_ONLY;
  bool bDeprecated = (flags & G_PARAM_DEPRECATED) == G_PARAM_DEPRECATED;

  //#t and #f aren't documented, but I guess that it's correct based on the example in the .defs
  // spec.
  const std::string strTrue = "#t";
  const std::string strFalse = "#f";

  strResult += "  (readable " + (bReadable ? strTrue : strFalse) + ")\n";
  strResult += "  (writable " + (bWritable ? strTrue : strFalse) + ")\n";
  strResult += "  (construct-only " + (bConstructOnly ? strTrue : strFalse) + ")\n";
  if (bDeprecated)
    strResult += "  (deprecated #t)\n"; // Default: not deprecated

  // Default value:
  const GValue* defValue = g_param_spec_get_default_value(pParamSpec);
  std::string defString;
  bool defValueExists = false;
  if (G_VALUE_HOLDS_STRING(defValue))
  {
    defValueExists = true;
    const char* defCString = g_value_get_string(defValue);
    if (defCString)
    {
      // Replace newlines with \n.
      // A string default value can contain newline characters.
      // gmmproc removes all newlines when it reads .defs files.
      defString = std::regex_replace(defCString, std::regex("\n"), "\\n");
    }
    else
      defString = ""; // A NULL string pointer becomes an empty string.
  }
  else if (G_VALUE_HOLDS_FLOAT(defValue) || G_VALUE_HOLDS_DOUBLE(defValue))
  {
    // g_value_transform() can transform a floating point value to a terrible
    // string, especially if the value is huge.
    defValueExists = true;
    const double defDouble = G_VALUE_HOLDS_FLOAT(defValue) ?
      g_value_get_float(defValue) : g_value_get_double(defValue);
    std::ostringstream defStringStream;
    defStringStream << defDouble;
    defString = defStringStream.str();
  }
  else
  {
    GValue defStringValue = G_VALUE_INIT;
    g_value_init(&defStringValue, G_TYPE_STRING);

    if (g_value_transform(defValue, &defStringValue))
    {
      const char* defCString = g_value_get_string(&defStringValue);
      if (defCString)
      {
        defValueExists = true;
        defString = defCString;
      }
    }
    g_value_unset(&defStringValue);
  }

  if (defValueExists)
    strResult += "  (default-value \"" + defString + "\")\n";

  strResult += ")\n\n"; // close (strNodeName

  return strResult;
}
示例#23
0
static void
list_properties (GType    type,
                 gint     indent,
                 gboolean html)
{
  GParamSpec **self;
  GParamSpec **parent;
  guint n_self;
  guint n_parent;
  gint prop_no;

  if (!type)
    return;

  self = g_object_class_list_properties (
            G_OBJECT_CLASS (g_type_class_ref (type)),
            &n_self);
  parent = g_object_class_list_properties (
            /*G_OBJECT_CLASS (g_type_class_peek_parent (g_type_class_ref (type))),*/
            G_OBJECT_CLASS (g_type_class_ref (GEGL_TYPE_OPERATION)),
            &n_parent);

  for (prop_no=0;prop_no<n_self;prop_no++)
    {
      gint parent_no;
      gboolean found=FALSE;
      for (parent_no=0;parent_no<n_parent;parent_no++)
        if (self[prop_no]==parent[parent_no])
          found=TRUE;
      /* only print properties if we are an addition compared to
       * GeglOperation
       */
      if (!found)
        {
          const gchar *type_name = g_type_name (G_OBJECT_TYPE (self[prop_no]));

          type_name = strstr (type_name, "Param");
          type_name+=5;

          g_print("<tr><td colspan='1'>&nbsp;&nbsp;</td><td colspan='1' class='prop_type' valign='top'>%s<br/><span style='font-style:normal;text-align:right;float:right;padding-right:1em;'>", type_name);

          if (g_type_is_a (G_PARAM_SPEC_VALUE_TYPE (self[prop_no]), G_TYPE_DOUBLE))
            {

            g_print ("%2.2f", G_PARAM_SPEC_DOUBLE (self[prop_no])->default_value);

            {
            gdouble min = G_PARAM_SPEC_DOUBLE (self[prop_no])->minimum;
            gdouble max = G_PARAM_SPEC_DOUBLE (self[prop_no])->maximum;
            g_print ("<br/>");
            if (min<-10000000)
              g_print ("-inf ");
            else
              g_print ("%2.2f", min);
            
            g_print ("-");

            if (max>10000000)
              g_print (" +inf");
            else
              g_print ("%2.2f", max);
            }

            }
          else if (g_type_is_a (G_PARAM_SPEC_VALUE_TYPE (self[prop_no]), G_TYPE_INT))
            {
              g_print ("%i", G_PARAM_SPEC_INT (self[prop_no])->default_value);

            {
            gint min = G_PARAM_SPEC_INT (self[prop_no])->minimum;
            gint max = G_PARAM_SPEC_INT (self[prop_no])->maximum;
            g_print ("<br/>");
            if (min<-10000000)
              g_print ("-inf ");
            else
              g_print ("%i", min);
            
            g_print ("-");

            if (max>10000000)
              g_print (" +inf");
            else
              g_print ("%i", max);
            }

            }
          else if (g_type_is_a (G_PARAM_SPEC_VALUE_TYPE (self[prop_no]), G_TYPE_FLOAT))
            {
              g_print ("%2.2f", G_PARAM_SPEC_FLOAT (self[prop_no])->default_value);
            }
          else if (g_type_is_a (G_PARAM_SPEC_VALUE_TYPE (self[prop_no]), G_TYPE_BOOLEAN))
            {
              g_print ("%s", G_PARAM_SPEC_BOOLEAN (self[prop_no])->default_value?"True":"False");
            }
          else if (g_type_is_a (G_PARAM_SPEC_VALUE_TYPE (self[prop_no]), G_TYPE_STRING))
            {
              const gchar *string = G_PARAM_SPEC_STRING (self[prop_no])->default_value;

              if (strlen (string) > 8)
                {
                  gchar copy[16];
                  g_snprintf (copy, 12, "%s..", string);
                  g_print ("%s", copy);
                }
              else
                g_print ("%s", string);
            }
          else if (g_type_is_a (G_PARAM_SPEC_VALUE_TYPE (self[prop_no]), GEGL_TYPE_COLOR))
            {
              GeglColor *color = gegl_param_spec_color_get_default (self[prop_no]);
              if (color)
                {
                  gchar *string;

                  g_object_get (color, "string", &string, NULL);
                  g_print ("%s", string);
                  g_free (string);

                  g_object_unref (color);
                }
            }
          else
            {
              g_print ("\n");
            }
          g_print ("</span></td>");

          g_print("<td class='prop_name' valign='top'>%s</td>\n",
            g_param_spec_get_name (self[prop_no]));

          if (g_param_spec_get_blurb (self[prop_no])[0]!='\0')
            g_print ("<td colspan='1' valign='top' class='prop_blurb'>%s</td>\n",
            g_param_spec_get_blurb (self[prop_no]));
          else
            g_print ("<td><em>not documented</em></td>\n\n");

          g_print ("</tr>\n");

        }
    }
  if (self)
    g_free (self);
  if (parent)
    g_free (parent);
}
示例#24
0
static VALUE
get_blurb(VALUE self)
{
    const gchar* str = g_param_spec_get_blurb(rbgobj_get_param_spec(self));
    return str ? rb_str_new2(str) : Qnil;
}
示例#25
0
void
gss_config_append_config_block (GObject * object, GssTransaction * t,
    gboolean show)
{
  GString *s = t->s;
  GParamSpec **pspecs;
  guint n_pspecs;
  int i;

  pspecs = g_object_class_list_properties (G_OBJECT_GET_CLASS (object),
      &n_pspecs);

  for (i = 0; i < (int) n_pspecs; i++) {
    if (!(pspecs[i]->flags & G_PARAM_READABLE)) {
      if (pspecs[i]->value_type == G_TYPE_BOOLEAN) {
        gss_html_append_button (s, g_param_spec_get_nick (pspecs[i]),
            pspecs[i]->name, "on");
      }
    }
  }

  if (!(t->resource->flags & GSS_RESOURCE_ADMIN)) {
    g_string_append (s, "<div class='accordion' id='accordion-config'>\n");
    g_string_append (s, "<div class='accordion-group'>\n");
    g_string_append (s, "<div class='accordion-heading'>\n");
    g_string_append (s, "<div class='accordion-toggle'>\n");
    g_string_append (s, "<button class='btn btn-mini' data-toggle='collapse' "
        "data-parent='#accordion-config' href='#collapse-config'>\n");
    g_string_append (s, "<b class='caret'></b> Edit\n");
    g_string_append (s, "</button>\n");
    g_string_append (s, "</div>\n");
    g_string_append_printf (s,
        "<div id='collapse-config' class='accordion-body collapse %s'>\n",
        show ? "in" : "out");
    g_string_append (s, "<div class='accordion-inner'>\n");
  }

  g_string_append_printf (s,
      "<form class='form-horizontal' method='post' enctype='multipart/form-data' >\n");

  if (t->session) {
    g_string_append_printf (s,
        "<input name='session_id' type='hidden' value='%s'>\n",
        t->session->session_id);
  }

  for (i = 0; i < (int) n_pspecs; i++) {
    char *value;
    const char *blurb;

    if (!(pspecs[i]->flags & G_PARAM_READABLE))
      continue;
    if (pspecs[i]->flags & GSS_PARAM_HIDE)
      continue;
    if (strcmp (pspecs[i]->name, "name") == 0)
      continue;

    if (strcmp (pspecs[i]->name, "width") == 0) {
      int width, height;

      g_object_get (object, "width", &width, "height", &height, NULL);

      g_string_append (s, "<div class='control-group'>\n");
      g_string_append_printf (s,
          "<label class='control-label' for='size'>Size</label>\n");

      g_string_append (s, "<div class='controls'>\n");
      g_string_append (s, "<div class='input-append'>\n");
      g_string_append_printf (s,
          "<input type='text' class='input-small' id='width' name='width' "
          "value='%d'>", width);
      g_string_append (s, "<span class='add-on'>&times;</span>");
      g_string_append_printf (s,
          "<input type='text' class='input-small' id='height' name='height' "
          "value='%d'>", height);

      g_string_append (s,
          "<div class='btn-toolbar'>"
          "<div class='btn-group'>"
          "<button class='btn dropdown-toggle' data-toggle='dropdown' href='#'><b class='caret'></b> Common Sizes</button>"
          "<ul class='dropdown-menu'>"
          "<li><a href='javascript:void(0)' onclick='setsize(320,240)'>320x240</a></li>"
          "<li><a href='javascript:void(0)' onclick='setsize(400,300)'>400x300</a></li>"
          "<li><a href='javascript:void(0)' onclick='setsize(480,360)'>480x360</a></li>"
          "<li><a href='javascript:void(0)' onclick='setsize(640,480)'>640x480</a></li>"
          "<li class='divider'></li>"
          "<li><a href='javascript:void(0)' onclick='setsize(320,180)'>320x180</a></li>"
          "<li><a href='javascript:void(0)' onclick='setsize(400,224)'>400x224</a></li>"
          "<li><a href='javascript:void(0)' onclick='setsize(480,270)'>480x270</a></li>"
          "<li><a href='javascript:void(0)' onclick='setsize(640,360)'>640x360</a></li>"
          "<li><a href='javascript:void(0)' onclick='setsize(800,450)'>800x450</a></li>"
          "<li><a href='javascript:void(0)' onclick='setsize(960,540)'>960x540</a></li>"
          "<li><a href='javascript:void(0)' onclick='setsize(1280,720)'>1280x720</a></li>"
          "<li><a href='javascript:void(0)' onclick='setsize(1600,900)'>1600x900</a></li>"
          "<li><a href='javascript:void(0)' onclick='setsize(1920,1080)'>1920x1080</a></li>"
          "</ul>" "</div>" "</div>\n");
      g_string_append (s, "<script>function setsize(width,height) {\n"
          "document.getElementById('width').value=width;"
          "document.getElementById('height').value=height;"
          "return false;" "}</script>\n");

      g_string_append_printf (s, "</div>");
      g_string_append_printf (s, "</div>");
      g_string_append_printf (s, "</div>");

      continue;
    }
    if (strcmp (pspecs[i]->name, "height") == 0)
      continue;

    value = g_object_get_as_string (object, pspecs[i]);

    g_string_append (s, "<div class='control-group'>\n");
    if (g_object_property_is_default (object, pspecs[i])) {
      g_string_append_printf (s,
          "<label class='control-label' for='%s'>%s</label>\n",
          pspecs[i]->name, g_param_spec_get_nick (pspecs[i]));
    } else {
      g_string_append_printf (s,
          "<label class='control-label' for='%s'><b>%s</b></label>\n",
          pspecs[i]->name, g_param_spec_get_nick (pspecs[i]));
    }

    g_string_append (s, "<div class='controls'>\n");
    if (pspecs[i]->flags & GSS_PARAM_SECURE) {
      g_string_append_printf (s, "<div id='hide-%s'>\n", pspecs[i]->name);
      g_string_append_printf (s,
          "<button class='btn' type='button' onclick=\""
          "document.getElementById('show-%s').style.display='block';"
          "document.getElementById('hide-%s').style.display='none';"
          "\">Show</button>\n", pspecs[i]->name, pspecs[i]->name);
      g_string_append (s, "</div>\n");
      g_string_append_printf (s, "<div id='show-%s' style='display: none;'>\n",
          pspecs[i]->name);
    }
    blurb = g_param_spec_get_blurb (pspecs[i]);
    if (blurb[0] == '[') {
      g_string_append_printf (s, "<div class='input-append'>");
    }
    if (!(pspecs[i]->flags & G_PARAM_WRITABLE)) {
      char *safe;
      safe = gss_html_sanitize_attribute (value);
      g_string_append_printf (s,
          "<span class='input uneditable-input'>%s</span>", safe);
      g_free (safe);
    } else if (G_TYPE_IS_ENUM (pspecs[i]->value_type)) {
      GEnumClass *eclass;
      int value;
      int j;

      eclass = G_ENUM_CLASS (g_type_class_peek (pspecs[i]->value_type));

      g_object_get (object, pspecs[i]->name, &value, NULL);

      g_string_append_printf (s, "<select id='%s' name='%s'>\n",
          pspecs[i]->name, pspecs[i]->name);

      for (j = 0; j < (int) eclass->n_values; j++) {
        GEnumValue *ev = eclass->values + j;
        g_string_append_printf (s, "<option value=\"%s\" %s>%s</option>\n",
            ev->value_name,
            (ev->value == value) ? "selected=\"selected\"" : "",
            ev->value_nick);
      }
      g_string_append_printf (s, "</select>");
    } else if (pspecs[i]->value_type == G_TYPE_BOOLEAN) {
      gboolean selected = TRUE;

      g_object_get (object, pspecs[i]->name, &selected, NULL);

      g_string_append_printf (s,
          "<input type='hidden' name='%s' value='0'>"
          "<input type='checkbox' class='input' "
          "id='%s' name='%s' value='1' %s>",
          pspecs[i]->name,
          pspecs[i]->name, pspecs[i]->name, selected ? "checked='on'" : "");
    } else if ((pspecs[i]->value_type == G_TYPE_STRING) &&
        pspecs[i]->flags & GSS_PARAM_FILE_UPLOAD) {
      g_string_append_printf (s, "<input type='file' class='input-xlarge' "
          "id='%s' name='%s' value=''>", pspecs[i]->name, pspecs[i]->name);
    } else if (pspecs[i]->value_type == G_TYPE_INT) {
      g_string_append_printf (s,
          "<input type='text' class='input-medium' id='%s' name='%s' "
          "value='%s'>", pspecs[i]->name, pspecs[i]->name, value);
    } else {
      char *u;
      u = gss_html_sanitize_attribute (value);
      if (pspecs[i]->flags & GSS_PARAM_MULTILINE) {
        g_string_append_printf (s,
            "<textarea rows='4' class='input-large' id='%s' name='%s'>"
            "%s</textarea>", pspecs[i]->name, pspecs[i]->name, u);
      } else {
        g_string_append_printf (s,
            "<input type='text' class='input-large' id='%s' name='%s' "
            "value='%s'>", pspecs[i]->name, pspecs[i]->name, u);
      }
      g_free (u);
    }
    if (blurb[0] == '[') {
      const char *end = strchr (blurb + 1, ']');
      int len = end - blurb - 1;
      g_string_append_printf (s, "<span class='add-on'>%.*s</span>",
          len, blurb + 1);
      g_string_append (s, "</div>\n");
      blurb = end + 1;
    }
    if (pspecs[i]->flags & GSS_PARAM_SECURE) {
      g_string_append (s, "</div>\n");
    }
    g_string_append_printf (s, "<span class='help-inline'>%s</span>", blurb);
    g_string_append (s, "</div>\n");
    g_string_append (s, "</div>\n");

    g_free (value);
  }

  g_string_append (s, "<div class='form-actions'>\n");
  g_string_append (s,
      "<button type='submit' class='btn btn-primary'>Save changes</button>\n");
  //g_string_append (s, "<button class='btn'>Cancel</button>");
  g_string_append (s, "</div>\n");

  g_free (pspecs);

  g_string_append (s, "</form>\n");

  if (!(t->resource->flags & GSS_RESOURCE_ADMIN)) {
    g_string_append (s, "</div>\n");
    g_string_append (s, "</div>\n");
    g_string_append (s, "</div>\n");
    g_string_append (s, "</div>\n");
    g_string_append (s, "</div>\n");
  }

}
示例#26
0
文件: actions.c 项目: jiapei100/gimp
void
action_select_property (GimpActionSelectType  select_type,
                        GimpDisplay          *display,
                        GObject              *object,
                        const gchar          *property_name,
                        gdouble               small_inc,
                        gdouble               inc,
                        gdouble               skip_inc,
                        gdouble               delta_factor,
                        gboolean              wrap)
{
  GParamSpec *pspec;

  g_return_if_fail (display == NULL || GIMP_IS_DISPLAY (display));
  g_return_if_fail (G_IS_OBJECT (object));
  g_return_if_fail (property_name != NULL);

  pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (object),
                                        property_name);

  if (G_IS_PARAM_SPEC_DOUBLE (pspec))
    {
      gdouble value;

      g_object_get (object, property_name, &value, NULL);

      value = action_select_value (select_type,
                                   value,
                                   G_PARAM_SPEC_DOUBLE (pspec)->minimum,
                                   G_PARAM_SPEC_DOUBLE (pspec)->maximum,
                                   G_PARAM_SPEC_DOUBLE (pspec)->default_value,
                                   small_inc, inc, skip_inc, delta_factor, wrap);

      g_object_set (object, property_name, value, NULL);

      if (display)
        {
          const gchar *blurb = g_param_spec_get_blurb (pspec);

          if (blurb)
            {
              /*  value description and new value shown in the status bar  */
              action_message (display, object, _("%s: %.2f"), blurb, value);
            }
        }
    }
  else if (G_IS_PARAM_SPEC_INT (pspec))
    {
      gint value;

      g_object_get (object, property_name, &value, NULL);

      value = action_select_value (select_type,
                                   value,
                                   G_PARAM_SPEC_INT (pspec)->minimum,
                                   G_PARAM_SPEC_INT (pspec)->maximum,
                                   G_PARAM_SPEC_INT (pspec)->default_value,
                                   small_inc, inc, skip_inc, delta_factor, wrap);

      g_object_set (object, property_name, value, NULL);

      if (display)
        {
          const gchar *blurb = g_param_spec_get_blurb (pspec);

          if (blurb)
            {
              /*  value description and new value shown in the status bar  */
              action_message (display, object, _("%s: %d"), blurb, value);
            }
        }
    }
  else
    {
      g_return_if_reached ();
    }
}
/* XXX Historical note, originally I tried (ab)using override properties
 *     in ESourceCamel, which redirected to the equivalent CamelSettings
 *     property.  Seemed to work at first, and I was proud of my clever
 *     hack, but it turns out g_object_class_list_properties() excludes
 *     override properties.  So the ESourceCamel properties were being
 *     skipped in source_load_from_key_file() (e-source.c). */
static GParamSpec *
param_spec_clone (GParamSpec *pspec)
{
	GParamSpec *clone;
	GParamFlags flags;
	const gchar *name, *nick, *blurb;

	name = g_param_spec_get_name (pspec);
	nick = g_param_spec_get_nick (pspec);
	blurb = g_param_spec_get_blurb (pspec);
	flags = (pspec->flags & ~(G_PARAM_STATIC_STRINGS));

	if (G_IS_PARAM_SPEC_BOOLEAN (pspec)) {
		GParamSpecBoolean *pspec_boolean = G_PARAM_SPEC_BOOLEAN (pspec);

		clone = g_param_spec_boolean (name, nick, blurb,
			pspec_boolean->default_value,
			flags);
	} else if (G_IS_PARAM_SPEC_CHAR (pspec)) {
		GParamSpecChar *pspec_char = G_PARAM_SPEC_CHAR (pspec);

		clone = g_param_spec_char (name, nick, blurb,
			pspec_char->minimum,
			pspec_char->maximum,
			pspec_char->default_value,
			flags);
	} else if (G_IS_PARAM_SPEC_UCHAR (pspec)) {
		GParamSpecUChar *pspec_uchar = G_PARAM_SPEC_UCHAR (pspec);

		clone = g_param_spec_uchar (name, nick, blurb,
			pspec_uchar->minimum,
			pspec_uchar->maximum,
			pspec_uchar->default_value,
			flags);
	} else if (G_IS_PARAM_SPEC_INT (pspec)) {
		GParamSpecInt *pspec_int = G_PARAM_SPEC_INT (pspec);

		clone = g_param_spec_int (name, nick, blurb,
			pspec_int->minimum,
			pspec_int->maximum,
			pspec_int->default_value,
			flags);
	} else if (G_IS_PARAM_SPEC_UINT (pspec)) {
		GParamSpecUInt *pspec_uint = G_PARAM_SPEC_UINT (pspec);

		clone = g_param_spec_uint (name, nick, blurb,
			pspec_uint->minimum,
			pspec_uint->maximum,
			pspec_uint->default_value,
			flags);
	} else if (G_IS_PARAM_SPEC_LONG (pspec)) {
		GParamSpecLong *pspec_long = G_PARAM_SPEC_LONG (pspec);

		clone = g_param_spec_long (name, nick, blurb,
			pspec_long->minimum,
			pspec_long->maximum,
			pspec_long->default_value,
			flags);
	} else if (G_IS_PARAM_SPEC_ULONG (pspec)) {
		GParamSpecULong *pspec_ulong = G_PARAM_SPEC_ULONG (pspec);

		clone = g_param_spec_ulong (name, nick, blurb,
			pspec_ulong->minimum,
			pspec_ulong->maximum,
			pspec_ulong->default_value,
			flags);
	} else if (G_IS_PARAM_SPEC_INT64 (pspec)) {
		GParamSpecInt64 *pspec_int64 = G_PARAM_SPEC_INT64 (pspec);

		clone = g_param_spec_int64 (name, nick, blurb,
			pspec_int64->minimum,
			pspec_int64->maximum,
			pspec_int64->default_value,
			flags);
	} else if (G_IS_PARAM_SPEC_UINT64 (pspec)) {
		GParamSpecUInt64 *pspec_uint64 = G_PARAM_SPEC_UINT64 (pspec);

		clone = g_param_spec_uint64 (name, nick, blurb,
			pspec_uint64->minimum,
			pspec_uint64->maximum,
			pspec_uint64->default_value,
			flags);
	} else if (G_IS_PARAM_SPEC_FLOAT (pspec)) {
		GParamSpecFloat *pspec_float = G_PARAM_SPEC_FLOAT (pspec);

		clone = g_param_spec_float (name, nick, blurb,
			pspec_float->minimum,
			pspec_float->maximum,
			pspec_float->default_value,
			flags);
	} else if (G_IS_PARAM_SPEC_DOUBLE (pspec)) {
		GParamSpecDouble *pspec_double = G_PARAM_SPEC_DOUBLE (pspec);

		clone = g_param_spec_double (name, nick, blurb,
			pspec_double->minimum,
			pspec_double->maximum,
			pspec_double->default_value,
			flags);
	} else if (G_IS_PARAM_SPEC_ENUM (pspec)) {
		GParamSpecEnum *pspec_enum = G_PARAM_SPEC_ENUM (pspec);

		clone = g_param_spec_enum (name, nick, blurb,
			pspec->value_type,
			pspec_enum->default_value,
			flags);
	} else if (G_IS_PARAM_SPEC_FLAGS (pspec)) {
		GParamSpecFlags *pspec_flags = G_PARAM_SPEC_FLAGS (pspec);

		clone = g_param_spec_flags (name, nick, blurb,
			pspec->value_type,
			pspec_flags->default_value,
			flags);
	} else if (G_IS_PARAM_SPEC_STRING (pspec)) {
		GParamSpecString *pspec_string = G_PARAM_SPEC_STRING (pspec);

		clone = g_param_spec_string (name, nick, blurb,
			pspec_string->default_value,
			flags);
	} else if (G_IS_PARAM_SPEC_PARAM (pspec)) {
		clone = g_param_spec_param (name, nick, blurb,
			pspec->value_type,
			flags);
	} else if (G_IS_PARAM_SPEC_BOXED (pspec)) {
		clone = g_param_spec_boxed (name, nick, blurb,
			pspec->value_type,
			flags);
	} else if (G_IS_PARAM_SPEC_POINTER (pspec)) {
		clone = g_param_spec_pointer (name, nick, blurb, flags);
	} else if (G_IS_PARAM_SPEC_OBJECT (pspec)) {
		clone = g_param_spec_object (name, nick, blurb,
			pspec->value_type,
			flags);
	} else if (G_IS_PARAM_SPEC_UNICHAR (pspec)) {
		GParamSpecUnichar *pspec_unichar = G_PARAM_SPEC_UNICHAR (pspec);

		clone = g_param_spec_unichar (name, nick, blurb,
			pspec_unichar->default_value,
			flags);
	} else if (G_IS_PARAM_SPEC_GTYPE (pspec)) {
		GParamSpecGType *pspec_gtype = G_PARAM_SPEC_GTYPE (pspec);

		clone = g_param_spec_gtype (name, nick, blurb,
			pspec_gtype->is_a_type,
			flags);
	} else if (G_IS_PARAM_SPEC_VARIANT (pspec)) {
		GParamSpecVariant *pspec_variant = G_PARAM_SPEC_VARIANT (pspec);

		clone = g_param_spec_variant (name, nick, blurb,
			pspec_variant->type,
			pspec_variant->default_value,
			flags);
	} else {
		g_warn_if_reached ();
	}

	return clone;
}
示例#28
0
static void
json_list_properties (GType type, const gchar *opname)
{
  GParamSpec **self;
  GParamSpec **parent;
  guint n_self;
  guint n_parent;
  gint prop_no;
  gboolean first_prop = TRUE;

  g_print (",'properties':[\n");

  if (!type)
    return;

  self = g_object_class_list_properties (
            G_OBJECT_CLASS (g_type_class_ref (type)),
            &n_self);
  parent = g_object_class_list_properties (
            /*G_OBJECT_CLASS (g_type_class_peek_parent (g_type_class_ref (type))),*/
            G_OBJECT_CLASS (g_type_class_ref (GEGL_TYPE_OPERATION)),
            &n_parent);


  for (prop_no=0;prop_no<n_self;prop_no++)
    {
      gint parent_no;
      gboolean found=FALSE;
      for (parent_no=0;parent_no<n_parent;parent_no++)
        if (self[prop_no]==parent[parent_no])
          found=TRUE;
      /* only print properties if we are an addition compared to
       * GeglOperation
       */
      if (!found)
        {
          const gchar *type_name = g_type_name (G_OBJECT_TYPE (self[prop_no]));

          if (first_prop)
          {
            first_prop = FALSE;
            g_print(" { 'name':'%s'\n", g_param_spec_get_name (self[prop_no]));
          }
          else
            g_print(",{'name':'%s'\n", g_param_spec_get_name (self[prop_no]));

          g_print("  ,'label':\"");
            json_escape_string (g_param_spec_get_nick (self[prop_no]));
          g_print ("\"\n");

          if(strstr (type_name, "Param"))
          {
            type_name = strstr (type_name, "Param");
            type_name+=5;
          }

          g_print("  ,'type':'");
          {
            for (const char *p = type_name; *p; p++)
              g_print("%c", g_ascii_tolower (*p));
          }
          g_print("'\n");

          if (g_type_is_a (G_PARAM_SPEC_VALUE_TYPE (self[prop_no]), G_TYPE_DOUBLE))
            {
              gdouble default_value = G_PARAM_SPEC_DOUBLE (self[prop_no])->default_value;
              gdouble min = G_PARAM_SPEC_DOUBLE (self[prop_no])->minimum;
              gdouble max = G_PARAM_SPEC_DOUBLE (self[prop_no])->maximum;

              if (default_value<-10000000)
                g_print ("  ,'default':'-inf'\n");
              else if (default_value>10000000)
                g_print ("  ,'default':'+inf'\n");
              else
                g_print ("  ,'default':'%2.2f'\n", default_value);

              if (min<-10000000)
                g_print ("  ,'minimum':'-inf'\n");
              else
                g_print ("  ,'minimum':'%2.2f'\n", min);

              if (max>10000000)
                g_print ("  ,'maximum':'+inf'\n");
              else
                g_print ("  ,'maximum':'%2.2f'\n", max);
              
              if (GEGL_IS_PARAM_SPEC_DOUBLE (self[prop_no]))
              {
                GeglParamSpecDouble *pspec =
                              GEGL_PARAM_SPEC_DOUBLE (self[prop_no]);

                if (pspec->ui_minimum < -10000000)
                  g_print ("  ,'ui-minimum':'-inf'\n");
                else
                  g_print ("  ,'ui-minimum':'%2.2f'\n", pspec->ui_minimum);

                if (pspec->ui_maximum > 10000000)
                  g_print ("  ,'ui-maximum':'+inf'\n");
                else
                  g_print ("  ,'ui-maximum':'%2.2f'\n", pspec->ui_maximum);

                g_print ("  ,'ui-gamma':'%2.2f'\n", pspec->ui_gamma);
                g_print ("  ,'ui-step-small':'%2.2f'\n", pspec->ui_step_small);
                g_print ("  ,'ui-step-big':'%2.2f'\n", pspec->ui_step_big);
                g_print ("  ,'ui-digits':'%i'\n", pspec->ui_digits);
              }

            }
          else if (g_type_is_a (G_PARAM_SPEC_VALUE_TYPE (self[prop_no]), G_TYPE_INT))
            {
              gint default_value = G_PARAM_SPEC_INT (self[prop_no])->default_value;
              gint min = G_PARAM_SPEC_INT (self[prop_no])->minimum;
              gint max = G_PARAM_SPEC_INT (self[prop_no])->maximum;

              if (default_value<-10000000)
                g_print ("  ,'default':'-inf'\n");
              else if (default_value>10000000)
                g_print ("  ,'default':'+inf'\n");
              else
                g_print ("  ,'default':'%i'\n", default_value);

              if (min<-10000000)
                g_print ("  ,'minimum':'-inf'\n");
              else
                g_print ("  ,'minimum':'%i'\n", min);

              if (max>10000000)
                g_print ("  ,'maximum':'+inf'\n");
              else
                g_print ("  ,'maximum':'%i'\n", max);

              if (GEGL_IS_PARAM_SPEC_INT (self[prop_no]))
              {
                GeglParamSpecInt *pspec =
                              GEGL_PARAM_SPEC_INT (self[prop_no]);

                if (pspec->ui_minimum < -10000000)
                  g_print ("  ,'ui-minimum':'-inf'\n");
                else
                  g_print ("  ,'ui-minimum':'%i'\n", pspec->ui_minimum);

                if (pspec->ui_maximum > 10000000)
                  g_print ("  ,'ui-maximum':'+inf'\n");
                else
                  g_print ("  ,'ui-maximum':'%i'\n", pspec->ui_maximum);

                g_print ("  ,'ui-gamma':'%2.2f'\n", pspec->ui_gamma);
                g_print ("  ,'ui-step-small':'%i'\n", pspec->ui_step_small);
                g_print ("  ,'ui-step-big':'%i'\n", pspec->ui_step_big);
              }

            }
          else if (g_type_is_a (G_PARAM_SPEC_VALUE_TYPE (self[prop_no]), G_TYPE_BOOLEAN))
            {
              g_print ("  ,'default':'%s'\n", G_PARAM_SPEC_BOOLEAN (self[prop_no])->default_value?"True":"False");
            }
          else if (g_type_is_a (G_PARAM_SPEC_VALUE_TYPE (self[prop_no]), G_TYPE_STRING))
            {
              const gchar *string = G_PARAM_SPEC_STRING (self[prop_no])->default_value;

              g_print ("  ,'default':\"");
              json_escape_string (string);
              g_print ("\"\n");

            }
          else if (g_type_is_a (G_PARAM_SPEC_VALUE_TYPE (self[prop_no]), GEGL_TYPE_COLOR))
            {
              GeglColor *color = gegl_param_spec_color_get_default (self[prop_no]);
              if (color)
                {
                  gchar *string;

                  g_object_get (color, "string", &string, NULL);
                  g_print ("  ,'default':\"");
                  json_escape_string (string);
                  g_print ("\"\n");
                  g_free (string);
                }
            }
          else
            {
            }

          if (g_param_spec_get_blurb (self[prop_no]) &&
              g_param_spec_get_blurb (self[prop_no])[0]!='\0')
          {
            g_print ("  ,'description':\"");
          
            json_escape_string (g_param_spec_get_blurb (self[prop_no]));
            g_print ("\"\n");
          }

      {
        guint count;
        gchar **property_keys = gegl_operation_list_property_keys (
            opname, 
            g_param_spec_get_name (self[prop_no]),
            
            &count);

        if (property_keys)
        {
          int i;
          if (property_keys[0])
          {
            /* XXX: list is in reverse order */
            for (i = 0; property_keys[i]; i++)
            {
              g_print ("  ,'%s':'%s'\n",
                    property_keys[i],
                    gegl_operation_get_property_key (opname, 
                                      g_param_spec_get_name (self[prop_no]),
                                                property_keys[i]));
            }
          }
          g_free (property_keys);
        }
      }

          g_print(" }");
        }
    }
  if (self)
    g_free (self);
  if (parent)
    g_free (parent);
  g_print ("]");
}
示例#29
0
static void
print_element_properties_info (GstElement * element)
{
  GParamSpec **property_specs;
  guint num_properties, i;
  gboolean readable;
  gboolean first_flag;

  property_specs = g_object_class_list_properties
      (G_OBJECT_GET_CLASS (element), &num_properties);
  n_print ("\n");
  n_print ("Element Properties:\n");

  for (i = 0; i < num_properties; i++) {
    GValue value = { 0, };
    GParamSpec *param = property_specs[i];

    readable = FALSE;

    g_value_init (&value, param->value_type);

    n_print ("  %-20s: %s\n", g_param_spec_get_name (param),
        g_param_spec_get_blurb (param));

    first_flag = TRUE;
    n_print ("%-23.23s flags: ", "");
    if (param->flags & G_PARAM_READABLE) {
      g_object_get_property (G_OBJECT (element), param->name, &value);
      readable = TRUE;
      g_print ("%s%s", (first_flag) ? "" : ", ", _("readable"));
      first_flag = FALSE;
    } else {
      /* if we can't read the property value, assume it's set to the default
       * (which might not be entirely true for sub-classes, but that's an
       * unlikely corner-case anyway) */
      g_param_value_set_default (param, &value);
    }
    if (param->flags & G_PARAM_WRITABLE) {
      g_print ("%s%s", (first_flag) ? "" : ", ", _("writable"));
      first_flag = FALSE;
    }
    if (param->flags & G_PARAM_DEPRECATED) {
      g_print ("%s%s", (first_flag) ? "" : ", ", _("deprecated"));
      first_flag = FALSE;
    }
    if (param->flags & GST_PARAM_CONTROLLABLE) {
      g_print (", %s", _("controllable"));
      first_flag = FALSE;
    }
    if (param->flags & GST_PARAM_MUTABLE_PLAYING) {
      g_print (", %s", _("changeable in NULL, READY, PAUSED or PLAYING state"));
    } else if (param->flags & GST_PARAM_MUTABLE_PAUSED) {
      g_print (", %s", _("changeable only in NULL, READY or PAUSED state"));
    } else if (param->flags & GST_PARAM_MUTABLE_READY) {
      g_print (", %s", _("changeable only in NULL or READY state"));
    }
    if (param->flags & ~KNOWN_PARAM_FLAGS) {
      g_print ("%s0x%0x", (first_flag) ? "" : ", ",
          param->flags & ~KNOWN_PARAM_FLAGS);
    }
    n_print ("\n");

    switch (G_VALUE_TYPE (&value)) {
      case G_TYPE_STRING:
      {
        const char *string_val = g_value_get_string (&value);

        n_print ("%-23.23s String. ", "");

        if (string_val == NULL)
          g_print ("Default: null");
        else
          g_print ("Default: \"%s\"", string_val);
        break;
      }
      case G_TYPE_BOOLEAN:
      {
        gboolean bool_val = g_value_get_boolean (&value);

        n_print ("%-23.23s Boolean. ", "");

        g_print ("Default: %s", bool_val ? "true" : "false");
        break;
      }
      case G_TYPE_ULONG:
      {
        GParamSpecULong *pulong = G_PARAM_SPEC_ULONG (param);

        n_print ("%-23.23s Unsigned Long. ", "");
        g_print ("Range: %lu - %lu Default: %lu ",
            pulong->minimum, pulong->maximum, g_value_get_ulong (&value));

        GST_ERROR ("%s: property '%s' of type ulong: consider changing to "
            "uint/uint64", GST_OBJECT_NAME (element),
            g_param_spec_get_name (param));
        break;
      }
      case G_TYPE_LONG:
      {
        GParamSpecLong *plong = G_PARAM_SPEC_LONG (param);

        n_print ("%-23.23s Long. ", "");
        g_print ("Range: %ld - %ld Default: %ld ",
            plong->minimum, plong->maximum, g_value_get_long (&value));

        GST_ERROR ("%s: property '%s' of type long: consider changing to "
            "int/int64", GST_OBJECT_NAME (element),
            g_param_spec_get_name (param));
        break;
      }
      case G_TYPE_UINT:
      {
        GParamSpecUInt *puint = G_PARAM_SPEC_UINT (param);

        n_print ("%-23.23s Unsigned Integer. ", "");
        g_print ("Range: %u - %u Default: %u ",
            puint->minimum, puint->maximum, g_value_get_uint (&value));
        break;
      }
      case G_TYPE_INT:
      {
        GParamSpecInt *pint = G_PARAM_SPEC_INT (param);

        n_print ("%-23.23s Integer. ", "");
        g_print ("Range: %d - %d Default: %d ",
            pint->minimum, pint->maximum, g_value_get_int (&value));
        break;
      }
      case G_TYPE_UINT64:
      {
        GParamSpecUInt64 *puint64 = G_PARAM_SPEC_UINT64 (param);

        n_print ("%-23.23s Unsigned Integer64. ", "");
        g_print ("Range: %" G_GUINT64_FORMAT " - %" G_GUINT64_FORMAT
            " Default: %" G_GUINT64_FORMAT " ",
            puint64->minimum, puint64->maximum, g_value_get_uint64 (&value));
        break;
      }
      case G_TYPE_INT64:
      {
        GParamSpecInt64 *pint64 = G_PARAM_SPEC_INT64 (param);

        n_print ("%-23.23s Integer64. ", "");
        g_print ("Range: %" G_GINT64_FORMAT " - %" G_GINT64_FORMAT
            " Default: %" G_GINT64_FORMAT " ",
            pint64->minimum, pint64->maximum, g_value_get_int64 (&value));
        break;
      }
      case G_TYPE_FLOAT:
      {
        GParamSpecFloat *pfloat = G_PARAM_SPEC_FLOAT (param);

        n_print ("%-23.23s Float. ", "");
        g_print ("Range: %15.7g - %15.7g Default: %15.7g ",
            pfloat->minimum, pfloat->maximum, g_value_get_float (&value));
        break;
      }
      case G_TYPE_DOUBLE:
      {
        GParamSpecDouble *pdouble = G_PARAM_SPEC_DOUBLE (param);

        n_print ("%-23.23s Double. ", "");
        g_print ("Range: %15.7g - %15.7g Default: %15.7g ",
            pdouble->minimum, pdouble->maximum, g_value_get_double (&value));
        break;
      }
      case G_TYPE_CHAR:
      case G_TYPE_UCHAR:
        GST_ERROR ("%s: property '%s' of type char: consider changing to "
            "int/string", GST_OBJECT_NAME (element),
            g_param_spec_get_name (param));
        /* fall through */
      default:
        if (param->value_type == GST_TYPE_CAPS) {
          const GstCaps *caps = gst_value_get_caps (&value);

          if (!caps)
            n_print ("%-23.23s Caps (NULL)", "");
          else {
            print_caps (caps, "                           ");
          }
        } else if (G_IS_PARAM_SPEC_ENUM (param)) {
          GEnumValue *values;
          guint j = 0;
          gint enum_value;
          const gchar *value_nick = "";

          values = G_ENUM_CLASS (g_type_class_ref (param->value_type))->values;
          enum_value = g_value_get_enum (&value);

          while (values[j].value_name) {
            if (values[j].value == enum_value)
              value_nick = values[j].value_nick;
            j++;
          }

          n_print ("%-23.23s Enum \"%s\" Default: %d, \"%s\"", "",
              g_type_name (G_VALUE_TYPE (&value)), enum_value, value_nick);

          j = 0;
          while (values[j].value_name) {
            g_print ("\n");
            if (_name)
              g_print ("%s", _name);
            g_print ("%-23.23s    (%d): %-16s - %s", "",
                values[j].value, values[j].value_nick, values[j].value_name);
            j++;
          }
          /* g_type_class_unref (ec); */
        } else if (G_IS_PARAM_SPEC_FLAGS (param)) {
          GParamSpecFlags *pflags = G_PARAM_SPEC_FLAGS (param);
          GFlagsValue *vals;
          gchar *cur;

          vals = pflags->flags_class->values;

          cur = flags_to_string (vals, g_value_get_flags (&value));

          n_print ("%-23.23s Flags \"%s\" Default: 0x%08x, \"%s\"", "",
              g_type_name (G_VALUE_TYPE (&value)),
              g_value_get_flags (&value), cur);

          while (vals[0].value_name) {
            g_print ("\n");
            if (_name)
              g_print ("%s", _name);
            g_print ("%-23.23s    (0x%08x): %-16s - %s", "",
                vals[0].value, vals[0].value_nick, vals[0].value_name);
            ++vals;
          }

          g_free (cur);
        } else if (G_IS_PARAM_SPEC_OBJECT (param)) {
          n_print ("%-23.23s Object of type \"%s\"", "",
              g_type_name (param->value_type));
        } else if (G_IS_PARAM_SPEC_BOXED (param)) {
          n_print ("%-23.23s Boxed pointer of type \"%s\"", "",
              g_type_name (param->value_type));
          if (param->value_type == GST_TYPE_STRUCTURE) {
            const GstStructure *s = gst_value_get_structure (&value);
            if (s)
              gst_structure_foreach (s, print_field,
                  (gpointer) "                           ");
          }
        } else if (G_IS_PARAM_SPEC_POINTER (param)) {
          if (param->value_type != G_TYPE_POINTER) {
            n_print ("%-23.23s Pointer of type \"%s\".", "",
                g_type_name (param->value_type));
          } else {
            n_print ("%-23.23s Pointer.", "");
          }
        } else if (param->value_type == G_TYPE_VALUE_ARRAY) {
          GParamSpecValueArray *pvarray = G_PARAM_SPEC_VALUE_ARRAY (param);

          if (pvarray->element_spec) {
            n_print ("%-23.23s Array of GValues of type \"%s\"", "",
                g_type_name (pvarray->element_spec->value_type));
          } else {
            n_print ("%-23.23s Array of GValues", "");
          }
        } else if (GST_IS_PARAM_SPEC_FRACTION (param)) {
          GstParamSpecFraction *pfraction = GST_PARAM_SPEC_FRACTION (param);

          n_print ("%-23.23s Fraction. ", "");

          g_print ("Range: %d/%d - %d/%d Default: %d/%d ",
              pfraction->min_num, pfraction->min_den,
              pfraction->max_num, pfraction->max_den,
              gst_value_get_fraction_numerator (&value),
              gst_value_get_fraction_denominator (&value));
        } else {
          n_print ("%-23.23s Unknown type %ld \"%s\"", "",
              (glong) param->value_type, g_type_name (param->value_type));
        }
        break;
    }
    if (!readable)
      g_print (" Write only\n");
    else
      g_print ("\n");

    g_value_reset (&value);
  }
  if (num_properties == 0)
    n_print ("  none\n");

  g_free (property_specs);
}