Esempio n. 1
0
static GeglNode *
gimp_operation_tool_get_operation (GimpImageMapTool  *im_tool,
                                   GObject          **config,
                                   gchar            **undo_desc)
{
    GimpOperationTool *tool = GIMP_OPERATION_TOOL (im_tool);

    if (tool->operation)
        *config = G_OBJECT (gimp_gegl_get_config_proxy (tool->operation,
                            GIMP_TYPE_SETTINGS));

    if (tool->undo_desc)
        *undo_desc = g_strdup (tool->undo_desc);

    if (tool->operation)
        return gegl_node_new_child (NULL,
                                    "operation", tool->operation,
                                    NULL);

    return gegl_node_new_child (NULL,
                                "operation", "gegl:nop",
                                NULL);
}
Esempio n. 2
0
void
gimp_operation_tool_set_operation (GimpOperationTool *tool,
                                   const gchar       *operation,
                                   const gchar       *undo_desc)
{
  g_return_if_fail (GIMP_IS_OPERATION_TOOL (tool));
  g_return_if_fail (operation != NULL);

  if (tool->operation)
    g_free (tool->operation);

  if (tool->undo_desc)
    g_free (tool->undo_desc);

  tool->operation = g_strdup (operation);
  tool->undo_desc = g_strdup (undo_desc);

  if (tool->config)
    g_object_unref (tool->config);

  tool->config = gimp_gegl_get_config_proxy (tool->operation,
                                             GIMP_TYPE_IMAGE_MAP_CONFIG);

  gimp_image_map_tool_get_operation (GIMP_IMAGE_MAP_TOOL (tool));

  if (undo_desc)
    GIMP_IMAGE_MAP_TOOL_GET_CLASS (tool)->settings_name = "yes"; /* XXX hack */
  else
    GIMP_IMAGE_MAP_TOOL_GET_CLASS (tool)->settings_name = NULL; /* XXX hack */

  if (tool->options_table)
    {
      gtk_widget_destroy (tool->options_table);
      tool->options_table = NULL;
    }

  if (tool->config)
    {
      tool->options_table =
        gimp_prop_table_new (G_OBJECT (tool->config),
                             G_TYPE_FROM_INSTANCE (tool->config),
                             GIMP_CONTEXT (GIMP_TOOL_GET_OPTIONS (tool)),
                             (GimpCreatePickerFunc) gimp_image_map_tool_add_color_picker,
                             tool);

      if (tool->options_box)
        {
          gtk_container_add (GTK_CONTAINER (tool->options_box),
                             tool->options_table);
          gtk_widget_show (tool->options_table);
        }
    }

  if (undo_desc && GIMP_IMAGE_MAP_TOOL (tool)->dialog)
    g_object_set (GIMP_IMAGE_MAP_TOOL (tool)->dialog,
                  "description", undo_desc,
                  NULL);

  if (GIMP_TOOL (tool)->drawable)
    gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (tool));
}
Esempio n. 3
0
void
gimp_operation_tool_set_operation (GimpOperationTool *tool,
                                   const gchar       *operation,
                                   const gchar       *undo_desc,
                                   const gchar       *icon_name)
{
    GimpImageMapTool *im_tool;

    g_return_if_fail (GIMP_IS_OPERATION_TOOL (tool));
    g_return_if_fail (operation != NULL);

    im_tool = GIMP_IMAGE_MAP_TOOL (tool);

    if (tool->operation)
        g_free (tool->operation);

    if (tool->undo_desc)
        g_free (tool->undo_desc);

    if (tool->icon_name)
        g_free (tool->icon_name);

    tool->operation = g_strdup (operation);
    tool->undo_desc = g_strdup (undo_desc);
    tool->icon_name = g_strdup (icon_name);

    if (tool->config)
        g_object_unref (tool->config);

    tool->config = gimp_gegl_get_config_proxy (tool->operation,
                   GIMP_TYPE_SETTINGS);

    if (tool->aux_input)
    {
        g_object_unref (tool->aux_input);
        tool->aux_input = NULL;
    }

    gimp_image_map_tool_get_operation (im_tool);

    if (undo_desc)
        GIMP_IMAGE_MAP_TOOL_GET_CLASS (tool)->settings_name = "yes"; /* XXX hack */
    else
        GIMP_IMAGE_MAP_TOOL_GET_CLASS (tool)->settings_name = NULL; /* XXX hack */

    if (tool->aux_input_box)
    {
        gtk_widget_destroy (tool->aux_input_box);
        tool->aux_input_button = NULL;
        tool->aux_input_box    = NULL;
    }

    if (tool->options_gui)
    {
        gtk_widget_destroy (tool->options_gui);
        tool->options_gui = NULL;

        if (im_tool->active_picker)
        {
            im_tool->active_picker = NULL;
            gimp_color_tool_disable (GIMP_COLOR_TOOL (tool));
        }
    }

    if (gegl_node_has_pad (im_tool->operation, "aux"))
    {
        GimpContext *context;
        GtkWidget   *label;

        tool->aux_input = gegl_node_new_child (NULL,
                                               "operation", "gegl:buffer-source",
                                               NULL);

        gegl_node_connect_to (tool->aux_input,    "output",
                              im_tool->operation, "aux");

        context = GIMP_CONTEXT (GIMP_TOOL_GET_OPTIONS (tool));

        tool->aux_input_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);

        label = gtk_label_new_with_mnemonic (_("_Aux Input"));
        gtk_box_pack_start (GTK_BOX (tool->aux_input_box), label,
                            FALSE, FALSE, 0);
        gtk_widget_show (label);

        tool->aux_input_button =
            gimp_pickable_button_new (context, GIMP_VIEW_SIZE_LARGE, 1);
        gtk_box_pack_start (GTK_BOX (tool->aux_input_box),
                            tool->aux_input_button, FALSE, FALSE, 0);
        gtk_widget_show (tool->aux_input_button);

        gtk_label_set_mnemonic_widget (GTK_LABEL (label),
                                       tool->aux_input_button);

        if (tool->options_box)
        {
            gtk_box_pack_start (GTK_BOX (tool->options_box), tool->aux_input_box,
                                FALSE, FALSE, 0);
            gtk_widget_show (tool->aux_input_box);
        }

        g_signal_connect_object (tool->aux_input_button, "notify::pickable",
                                 G_CALLBACK (gimp_operation_tool_aux_notify),
                                 tool->aux_input, 0);
    }

    if (tool->config)
    {
        tool->options_gui =
            gimp_prop_gui_new (G_OBJECT (tool->config),
                               G_TYPE_FROM_INSTANCE (tool->config),
                               GIMP_CONTEXT (GIMP_TOOL_GET_OPTIONS (tool)),
                               (GimpCreatePickerFunc) gimp_image_map_tool_add_color_picker,
                               tool);

        if (tool->options_box)
        {
            gtk_box_pack_start (GTK_BOX (tool->options_box), tool->options_gui,
                                FALSE, FALSE, 0);
            gtk_widget_show (tool->options_gui);
        }
    }

    if (im_tool->gui)
    {
        if (undo_desc)
            gimp_tool_gui_set_description (im_tool->gui, undo_desc);

        if (icon_name)
            gimp_tool_gui_set_icon_name (im_tool->gui, icon_name);
    }

    if (GIMP_TOOL (tool)->drawable)
    {
        gimp_operation_tool_sync_op (tool, GIMP_TOOL (tool)->drawable);
        gimp_image_map_tool_preview (im_tool);
    }
}