Example #1
0
static void
gimp_blend_tool_start (GimpBlendTool *blend_tool,
                       GimpDisplay   *display)
{
  GimpTool         *tool     = GIMP_TOOL (blend_tool);
  GimpImage        *image    = gimp_display_get_image (display);
  GimpDrawable     *drawable = gimp_image_get_active_drawable (image);
  GimpBlendOptions *options  = GIMP_BLEND_TOOL_GET_OPTIONS (blend_tool);
  GimpContext      *context  = GIMP_CONTEXT (options);

  tool->display  = display;
  tool->drawable = drawable;

  gimp_blend_tool_create_filter (blend_tool, drawable);

  /* Initially sync all of the properties */
  gimp_gegl_config_sync_node (GIMP_OBJECT (options), blend_tool->render_node);

  /* Connect signal handlers for the gradient */
  gimp_blend_tool_set_gradient (blend_tool, context->gradient);

  if (gimp_blend_tool_is_shapeburst (blend_tool))
    gimp_blend_tool_precalc_shapeburst (blend_tool);

  if (! gimp_draw_tool_is_active (GIMP_DRAW_TOOL (blend_tool)))
    gimp_draw_tool_start (GIMP_DRAW_TOOL (blend_tool), display);
}
void
gimp_image_map_tool_get_operation (GimpImageMapTool *im_tool)
{
  GimpImageMapToolClass *klass;
  GimpToolInfo          *tool_info;
  gchar                 *operation_name;

  g_return_if_fail (GIMP_IS_IMAGE_MAP_TOOL (im_tool));

  klass = GIMP_IMAGE_MAP_TOOL_GET_CLASS (im_tool);

  tool_info = GIMP_TOOL (im_tool)->tool_info;

  if (im_tool->image_map)
    {
      gimp_image_map_abort (im_tool->image_map);
      g_object_unref (im_tool->image_map);
      im_tool->image_map = NULL;
    }

  if (im_tool->operation)
    {
      g_object_unref (im_tool->operation);
      im_tool->operation = NULL;
    }

  if (im_tool->config)
    {
      g_signal_handlers_disconnect_by_func (im_tool->config,
                                            gimp_image_map_tool_config_notify,
                                            im_tool);

      g_object_unref (im_tool->config);
      im_tool->config = NULL;
    }

  if (im_tool->default_config)
    {
      g_object_unref (im_tool->default_config);
      im_tool->default_config = NULL;
    }

  if (im_tool->title)
    {
      g_free (im_tool->title);
      im_tool->title = NULL;
    }

  if (im_tool->description)
    {
      g_free (im_tool->description);
      im_tool->description = NULL;
    }

  if (im_tool->undo_desc)
    {
      g_free (im_tool->undo_desc);
      im_tool->undo_desc = NULL;
    }

  if (im_tool->icon_name)
    {
      g_free (im_tool->icon_name);
      im_tool->icon_name = NULL;
    }

  if (im_tool->help_id)
    {
      g_free (im_tool->help_id);
      im_tool->help_id = NULL;
    }

  operation_name = klass->get_operation (im_tool,
                                         &im_tool->title,
                                         &im_tool->description,
                                         &im_tool->undo_desc,
                                         &im_tool->icon_name,
                                         &im_tool->help_id);

  if (! operation_name)
    operation_name = g_strdup ("gegl:nop");

  if (! im_tool->title)
    im_tool->title = g_strdup (tool_info->blurb);

  if (! im_tool->description)
    im_tool->description = g_strdup (im_tool->title);

  if (! im_tool->undo_desc)
    im_tool->undo_desc = g_strdup (tool_info->blurb);

  if (! im_tool->icon_name)
    im_tool->icon_name =
      g_strdup (gimp_viewable_get_icon_name (GIMP_VIEWABLE (tool_info)));

  if (! im_tool->help_id)
    im_tool->help_id = g_strdup (tool_info->help_id);

  im_tool->operation = gegl_node_new_child (NULL,
                                            "operation", operation_name,
                                            NULL);
  im_tool->config = G_OBJECT (gimp_gegl_config_new (operation_name,
                                                    im_tool->icon_name,
                                                    GIMP_TYPE_SETTINGS));

  gimp_gegl_config_sync_node (GIMP_OBJECT (im_tool->config),
                              im_tool->operation);
  gimp_gegl_config_connect_node (GIMP_OBJECT (im_tool->config),
                                 im_tool->operation);

  if (im_tool->gui)
    {
      gimp_tool_gui_set_title       (im_tool->gui, im_tool->title);
      gimp_tool_gui_set_description (im_tool->gui, im_tool->description);
      gimp_tool_gui_set_icon_name   (im_tool->gui, im_tool->icon_name);
      gimp_tool_gui_set_help_id     (im_tool->gui, im_tool->help_id);
    }

  if (gegl_operation_get_key (operation_name, "position-dependent"))
    {
      if (im_tool->gui)
        gtk_widget_show (im_tool->region_combo);
    }
  else
    {
      if (im_tool->gui)
        gtk_widget_hide (im_tool->region_combo);

      g_object_set (GIMP_IMAGE_MAP_TOOL_GET_OPTIONS (im_tool),
                    "region", GIMP_IMAGE_MAP_REGION_SELECTION,
                    NULL);
    }

  g_free (operation_name);

  g_object_set (GIMP_IMAGE_MAP_TOOL_GET_OPTIONS (im_tool),
                "preview-split",    FALSE,
                "preview-position", 0.5,
                NULL);

  if (im_tool->config)
    g_signal_connect_object (im_tool->config, "notify",
                             G_CALLBACK (gimp_image_map_tool_config_notify),
                             G_OBJECT (im_tool), 0);

  if (GIMP_TOOL (im_tool)->drawable)
    gimp_image_map_tool_create_map (im_tool);
}