void select_color (GtkButton *widget, gpointer user_data)
{
  GtkColorSelectionDialog* dialog = GTK_COLOR_SELECTION_DIALOG(gtk_color_selection_dialog_new("Select Color")); //todo put the old color selection in

  gint result = gtk_dialog_run(GTK_DIALOG(dialog));

  //

  if(result == GTK_RESPONSE_OK)
    {

      select_color_info* info = (select_color_info*)user_data;
      GtkColorSelection* colsel = GTK_COLOR_SELECTION(dialog->colorsel);

      GdkColor* sel_color = malloc(sizeof(GdkColor));
      gtk_color_selection_get_current_color(colsel, sel_color);

      GeglColor* color = gegl_color_new(NULL);
      gegl_color_set_rgba(color, (double)sel_color->red/65535.0,
			  (double)sel_color->green/65535.0,
			  (double)sel_color->blue/65535.0,
			  (double)gtk_color_selection_get_current_alpha(colsel)/65535.0);

      free(sel_color);

      gegl_node_set(info->node, info->property, color, NULL);

      refresh_images(info->layer);
    }
  gtk_widget_destroy(GTK_WIDGET(dialog));
}
Esempio n. 2
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);
}