示例#1
0
文件: json.c 项目: GNOME/gegl
static void
set_property (GObject      *gobject,
              guint         property_id,
              const GValue *value,
              GParamSpec   *pspec)
{
  JsonOpClass *json_op_class = (JsonOpClass *)G_OBJECT_GET_CLASS(gobject);
  JsonOp *self = (JsonOp *) gobject;
  PropertyTarget *target;
  GeglNode *node;

  g_assert(self);

  target = g_hash_table_lookup(json_op_class->properties, GINT_TO_POINTER(property_id));
  if (!target) {
    G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, property_id, pspec);
    return;
  }

  node = g_hash_table_lookup(self->nodes, target->node);
  if (!node) {
    G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, property_id, pspec);
    return;
  }

  gegl_node_set_property(node, target->port, value);
}
示例#2
0
void
gimp_gegl_config_proxy_sync (GimpObject  *proxy,
                             GeglNode    *node)
{
  GParamSpec **pspecs;
  gchar       *operation;
  guint        n_pspecs;
  gint         i;

  g_return_if_fail (GIMP_IS_OBJECT (proxy));
  g_return_if_fail (GEGL_IS_NODE (node));

  gegl_node_get (node,
                 "operation", &operation,
                 NULL);

  g_return_if_fail (operation != NULL);

  pspecs = gegl_operation_list_properties (operation, &n_pspecs);
  g_free (operation);

  for (i = 0; i < n_pspecs; i++)
    {
      GParamSpec *gegl_pspec = pspecs[i];
      GParamSpec *gimp_pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (proxy),
                                                             gegl_pspec->name);

      if (gimp_pspec)
        {
          GValue value = { 0, };

          g_value_init (&value, gimp_pspec->value_type);

          g_object_get_property (G_OBJECT (proxy), gimp_pspec->name,
                                 &value);

          if (GEGL_IS_PARAM_SPEC_COLOR (gegl_pspec))
            {
              GimpRGB    gimp_color;
              GeglColor *gegl_color;

              gimp_value_get_rgb (&value, &gimp_color);
              g_value_unset (&value);

              gegl_color = gimp_gegl_color_new (&gimp_color);

              g_value_init (&value, gegl_pspec->value_type);
              g_value_take_object (&value, gegl_color);
            }

          gegl_node_set_property (node, gegl_pspec->name,
                                  &value);

          g_value_unset (&value);
        }
    }

  g_free (pspecs);
}
示例#3
0
static void
gimp_gegl_tool_map (GimpImageMapTool *image_map_tool)
{
  GimpGeglTool  *tool = GIMP_GEGL_TOOL (image_map_tool);
  GParamSpec   **pspecs;
  guint          n_pspecs;
  gint           i;

  if (! tool->config)
    return;

  pspecs = gegl_list_properties (tool->operation, &n_pspecs);

  for (i = 0; i < n_pspecs; i++)
    {
      GParamSpec *gegl_pspec = pspecs[i];
      GParamSpec *gimp_pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (tool->config),
                                                             gegl_pspec->name);

      if (gimp_pspec)
        {
          GValue value = { 0, };

          g_value_init (&value, gimp_pspec->value_type);

          g_object_get_property (G_OBJECT (tool->config), gimp_pspec->name,
                                 &value);

          if (GIMP_IS_PARAM_SPEC_RGB (gimp_pspec))
            {
              GeglColor *gegl_color = gegl_color_new (NULL);
              GimpRGB    gimp_color;

              gimp_value_get_rgb (&value, &gimp_color);
              g_value_unset (&value);

              gegl_color_set_rgba (gegl_color,
                                   gimp_color.r,
                                   gimp_color.g,
                                   gimp_color.b,
                                   gimp_color.a);

              g_value_init (&value, gegl_pspec->value_type);
              g_value_take_object (&value, gegl_color);
            }

          gegl_node_set_property (image_map_tool->operation, gegl_pspec->name,
                                  &value);

          g_value_unset (&value);
        }
    }

  g_free (pspecs);
}
示例#4
0
文件: json.c 项目: GNOME/gegl
static gboolean
set_prop(GeglNode *t, const gchar *port, GParamSpec *paramspec, GValue *value)  {
    GType target_type = G_PARAM_SPEC_VALUE_TYPE(paramspec);
    GValue dest_value = {0,};
    gboolean success;

    g_value_init(&dest_value, target_type);

    success = g_param_value_convert(paramspec, value, &dest_value, FALSE);
    if (success) {
        gegl_node_set_property(t, port, &dest_value);
        return TRUE;
    }

    if (gvalue_from_string(value, target_type, &dest_value)) {
        g_param_value_validate(paramspec, &dest_value);
        gegl_node_set_property(t, port, &dest_value);
        return TRUE;
    }
    return FALSE;
}
示例#5
0
static void
gimp_blend_tool_options_notify (GimpTool         *tool,
                                GimpToolOptions  *options,
                                const GParamSpec *pspec)
{
  GimpContext   *context    = GIMP_CONTEXT (options);
  GimpBlendTool *blend_tool = GIMP_BLEND_TOOL (tool);

  if (! strcmp (pspec->name, "gradient"))
    {
      gimp_blend_tool_set_gradient (blend_tool, context->gradient);

      if (blend_tool->filter)
        gimp_drawable_filter_apply (blend_tool->filter, NULL);
    }
  else if (blend_tool->render_node &&
           gegl_node_find_property (blend_tool->render_node, pspec->name))
    {
      /* Sync any property changes on the config object that match the op */
      GValue value = G_VALUE_INIT;

      g_value_init (&value, pspec->value_type);

      g_object_get_property (G_OBJECT (options), pspec->name, &value);
      gegl_node_set_property (blend_tool->render_node, pspec->name, &value);

      g_value_unset (&value);

      if (! strcmp (pspec->name, "gradient-type"))
        {
          if (gimp_blend_tool_is_shapeburst (blend_tool))
            gimp_blend_tool_precalc_shapeburst (blend_tool);

          gimp_blend_tool_update_graph (blend_tool);
        }

      gimp_drawable_filter_apply (blend_tool->filter, NULL);
    }
  else if (blend_tool->filter &&
           ! strcmp (pspec->name, "opacity"))
    {
      gimp_drawable_filter_set_opacity (blend_tool->filter,
                                        gimp_context_get_opacity (context));
    }
  else if (blend_tool->filter &&
           ! strcmp (pspec->name, "paint-mode"))
    {
      gimp_drawable_filter_set_mode (blend_tool->filter,
                                     gimp_context_get_paint_mode (context));
    }
}
示例#6
0
static void
gegl_node_copy_property_property (GeglOperation *source,
                                  const gchar   *source_property,
                                  GeglOperation *destination,
                                  const gchar   *destination_property)
{
  GValue      value = { 0 };
  GParamSpec *spec  = g_object_class_find_property (G_OBJECT_GET_CLASS (source),
                                                    source_property);

  g_assert (spec);
  g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (spec));
  gegl_node_get_property (source->node, source_property, &value);
  gegl_node_set_property (destination->node, destination_property, &value);
  g_value_unset (&value);
}