Beispiel #1
0
static gboolean
gimp_posterize_tool_initialize (GimpTool     *tool,
                                GimpDisplay  *display,
                                GError      **error)
{
  GimpPosterizeTool *posterize_tool = GIMP_POSTERIZE_TOOL (tool);
  GimpImage         *image          = gimp_display_get_image (display);
  GimpDrawable      *drawable;

  drawable = gimp_image_get_active_drawable (image);

  if (! drawable)
    return FALSE;

  if (gimp_drawable_is_indexed (drawable))
    {
      g_set_error_literal (error, GIMP_ERROR, GIMP_FAILED,
			   _("Posterize does not operate on indexed layers."));
      return FALSE;
    }

  gimp_config_reset (GIMP_CONFIG (posterize_tool->config));

  if (! GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error))
    {
      return FALSE;
    }

  gtk_adjustment_set_value (posterize_tool->levels_data,
                            posterize_tool->config->levels);

  gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (posterize_tool));

  return TRUE;
}
static void
brightness_contrast_config_notify (GObject                    *object,
                                   GParamSpec                 *pspec,
                                   GimpBrightnessContrastTool *bc_tool)
{
  GimpBrightnessContrastConfig *config;

  config = GIMP_BRIGHTNESS_CONTRAST_CONFIG (object);

  if (! bc_tool->brightness_data)
    return;

  if (! strcmp (pspec->name, "brightness"))
    {
      gtk_adjustment_set_value (bc_tool->brightness_data,
                                config->brightness * 127.0);
    }
  else if (! strcmp (pspec->name, "contrast"))
    {
      gtk_adjustment_set_value (bc_tool->contrast_data,
                                config->contrast * 127.0);
    }

  gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (bc_tool));
}
static void
gimp_gegl_tool_config_notify (GObject      *object,
                              GParamSpec   *pspec,
                              GimpGeglTool *tool)
{
  gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (tool));
}
Beispiel #4
0
static gboolean
gimp_colorize_tool_initialize (GimpTool     *tool,
                               GimpDisplay  *display,
                               GError      **error)
{
  GimpColorizeTool *col_tool = GIMP_COLORIZE_TOOL (tool);
  GimpDrawable     *drawable = gimp_image_get_active_drawable (display->image);

  if (! drawable)
    return FALSE;

  if (! gimp_drawable_is_rgb (drawable))
    {
      g_set_error (error, 0, 0,
                   _("Colorize operates only on RGB color layers."));
      return FALSE;
    }

  gimp_config_reset (GIMP_CONFIG (col_tool->config));

  GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error);

  gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (tool));

  return TRUE;
}
Beispiel #5
0
static void
gimp_colorize_tool_config_notify (GObject          *object,
                                  GParamSpec       *pspec,
                                  GimpColorizeTool *col_tool)
{
  GimpColorizeConfig *config = GIMP_COLORIZE_CONFIG (object);

  if (! col_tool->hue_data)
    return;

  if (! strcmp (pspec->name, "hue"))
    {
      gtk_adjustment_set_value (col_tool->hue_data,
                                config->hue * 360.0);
    }
  else if (! strcmp (pspec->name, "saturation"))
    {
      gtk_adjustment_set_value (col_tool->saturation_data,
                                config->saturation * 100.0);
    }
  else if (! strcmp (pspec->name, "lightness"))
    {
      gtk_adjustment_set_value (col_tool->lightness_data,
                                config->lightness * 100.0);
    }

  gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (col_tool));
}
Beispiel #6
0
static gboolean
gimp_threshold_tool_initialize (GimpTool     *tool,
                                GimpDisplay  *display,
                                GError      **error)
{
  GimpThresholdTool *t_tool   = GIMP_THRESHOLD_TOOL (tool);
  GimpImage         *image    = gimp_display_get_image (display);
  GimpDrawable      *drawable = gimp_image_get_active_drawable (image);

  if (! drawable)
    return FALSE;

  gimp_config_reset (GIMP_CONFIG (t_tool->config));

  if (! GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error))
    {
      return FALSE;
    }

  gimp_drawable_calculate_histogram (drawable, t_tool->histogram);
  gimp_histogram_view_set_histogram (t_tool->histogram_box->view,
                                     t_tool->histogram);

  gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (t_tool));

  return TRUE;
}
Beispiel #7
0
static void
gimp_operation_tool_aux_input_notify (GimpBufferSourceBox *box,
                                      const GParamSpec    *pspec,
                                      GimpOperationTool   *tool)
{
    gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (tool));
}
static void
gimp_image_map_tool_config_notify (GObject          *object,
                                   const GParamSpec *pspec,
                                   GimpImageMapTool *im_tool)
{
  gimp_image_map_tool_preview (im_tool);
}
Beispiel #9
0
static gboolean
gimp_desaturate_tool_initialize (GimpTool     *tool,
                                GimpDisplay  *display,
                                GError      **error)
{
  GimpDesaturateTool *desaturate_tool = GIMP_DESATURATE_TOOL (tool);
  GimpDrawable       *drawable;

  drawable = gimp_image_get_active_drawable (display->image);

  if (! drawable)
    return FALSE;

  if (! gimp_drawable_is_rgb (drawable))
    {
      g_set_error (error, 0, 0,
                   _("Desaturate does only operate on RGB layers."));
      return FALSE;
    }

  gimp_config_reset (GIMP_CONFIG (desaturate_tool->config));

  GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error);

  gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (desaturate_tool->button),
                                   desaturate_tool->config->mode);

  gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (desaturate_tool));

  return TRUE;
}
Beispiel #10
0
static void
gimp_image_map_tool_options_notify (GimpTool         *tool,
                                    GimpToolOptions  *options,
                                    const GParamSpec *pspec)
{
  GimpImageMapTool    *image_map_tool = GIMP_IMAGE_MAP_TOOL (tool);
  GimpImageMapOptions *im_options     = GIMP_IMAGE_MAP_OPTIONS (options);

  if (! strcmp (pspec->name, "preview") &&
      image_map_tool->image_map)
    {
      if (im_options->preview)
        {
          gimp_tool_control_push_preserve (tool->control, TRUE);

          gimp_image_map_tool_map (image_map_tool);

          gimp_tool_control_pop_preserve (tool->control);
        }
      else
        {
          gimp_tool_control_push_preserve (tool->control, TRUE);

          gimp_image_map_abort (image_map_tool->image_map);

          gimp_tool_control_pop_preserve (tool->control);
        }
    }
  else if (! strcmp (pspec->name, "region") &&
           image_map_tool->image_map)
    {
      gimp_image_map_set_region (image_map_tool->image_map, im_options->region);
      gimp_image_map_tool_preview (image_map_tool);
    }
}
Beispiel #11
0
static void
gimp_levels_tool_color_picked (GimpColorTool      *color_tool,
                               GimpColorPickState  pick_state,
                               GimpImageType       sample_type,
                               GimpRGB            *color,
                               gint                color_index)
{
  GimpLevelsTool *tool = GIMP_LEVELS_TOOL (color_tool);
  guchar          col[5];
  guint           value;

  gimp_rgba_get_uchar (color,
                       col + RED_PIX,
                       col + GREEN_PIX,
                       col + BLUE_PIX,
                       col + ALPHA_PIX);

  value = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (tool->active_picker),
                                               "pick_value"));

  if (value & ALL_CHANNELS && GIMP_IMAGE_TYPE_IS_RGB (sample_type))
    {
      GimpHistogramChannel  channel;

      /*  first reset the value channel  */
      switch (value & 0xF)
        {
        case LOW_INPUT:
          tool->levels->low_input[GIMP_HISTOGRAM_VALUE] = 0;
          break;
        case GAMMA:
          tool->levels->gamma[GIMP_HISTOGRAM_VALUE] = 1.0;
          break;
        case HIGH_INPUT:
          tool->levels->high_input[GIMP_HISTOGRAM_VALUE] = 255;
          break;
        default:
          break;
        }

      /*  then adjust all color channels  */
      for (channel = GIMP_HISTOGRAM_RED;
           channel <= GIMP_HISTOGRAM_BLUE;
           channel++)
        {
          levels_input_adjust_by_color (tool->levels,
                                        value, channel, col);
        }
    }
  else
    {
      levels_input_adjust_by_color (tool->levels,
                                    value, tool->channel, col);
    }

  levels_update (tool, ALL);

  gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (tool));
}
Beispiel #12
0
static void
levels_channel_reset_callback (GtkWidget      *widget,
                               GimpLevelsTool *tool)
{
  levels_channel_reset (tool->levels, tool->channel);
  levels_update (tool, ALL);

  gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (tool));
}
Beispiel #13
0
static void
levels_stretch_callback (GtkWidget      *widget,
                      GimpLevelsTool *tool)
{
  levels_stretch (tool->levels, tool->hist, tool->color);
  levels_update (tool, ALL);

  gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (tool));
}
static void
gamma_hack (GtkToggleButton  *button,
            GimpImageMapTool *im_tool)
{
  if (im_tool->image_map)
    {
      gimp_image_map_set_gamma_hack (im_tool->image_map,
                                     gtk_toggle_button_get_active (button));
      gimp_image_map_tool_preview (im_tool);
    }
}
Beispiel #15
0
static void
levels_gamma_adjustment_update (GtkAdjustment  *adjustment,
                                GimpLevelsTool *tool)
{
  if (tool->levels->gamma[tool->channel] != adjustment->value)
    {
      tool->levels->gamma[tool->channel] = adjustment->value;
      levels_update (tool, INPUT_LEVELS | INPUT_SLIDERS);

      gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (tool));
    }
}
Beispiel #16
0
static void
gimp_posterize_tool_config_notify (GObject           *object,
                                   GParamSpec        *pspec,
                                   GimpPosterizeTool *posterize_tool)
{
  GimpPosterizeConfig *config = GIMP_POSTERIZE_CONFIG (object);

  if (! posterize_tool->levels_data)
    return;

  gtk_adjustment_set_value (posterize_tool->levels_data, config->levels);

  gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (posterize_tool));
}
Beispiel #17
0
static void
levels_high_output_adjustment_update (GtkAdjustment  *adjustment,
                                      GimpLevelsTool *tool)
{
  gint value = ROUND (adjustment->value);

  if (tool->levels->high_output[tool->channel] != value)
    {
      tool->levels->high_output[tool->channel] = value;
      levels_update (tool, OUTPUT_LEVELS | OUTPUT_SLIDERS);

      gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (tool));
    }
}
Beispiel #18
0
static void
gimp_desaturate_tool_config_notify (GObject            *object,
                                    GParamSpec         *pspec,
                                    GimpDesaturateTool *desaturate_tool)
{
  GimpDesaturateConfig *config = GIMP_DESATURATE_CONFIG (object);

  if (! desaturate_tool->button)
    return;

  gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (desaturate_tool->button),
                                   config->mode);

  gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (desaturate_tool));
}
Beispiel #19
0
static void
gimp_image_map_tool_gegl_notify (GObject          *config,
                                 const GParamSpec *pspec,
                                 GimpImageMapTool *im_tool)
{
  if (im_tool->image_map)
    {
      gimp_tool_control_set_preserve (GIMP_TOOL (im_tool)->control, TRUE);

      gimp_image_map_tool_create_map (im_tool);

      gimp_tool_control_set_preserve (GIMP_TOOL (im_tool)->control, FALSE);

      gimp_image_map_tool_preview (im_tool);
    }
}
Beispiel #20
0
static void
gimp_threshold_tool_config_notify (GObject           *object,
                                   GParamSpec        *pspec,
                                   GimpThresholdTool *t_tool)
{
  GimpThresholdConfig *config = GIMP_THRESHOLD_CONFIG (object);

  if (! t_tool->histogram_box)
    return;

  gimp_histogram_view_set_range (t_tool->histogram_box->view,
                                 config->low  * 255.999,
                                 config->high * 255.999);

  gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (t_tool));
}
Beispiel #21
0
static void
levels_high_input_adjustment_update (GtkAdjustment  *adjustment,
                                     GimpLevelsTool *tool)
{
  gint value = ROUND (adjustment->value);

  value = CLAMP (value, tool->levels->low_input[tool->channel], 255);

  /*  enforce a consistent displayed value (high_input >= low_input)  */
  gtk_adjustment_set_value (adjustment, value);

  if (tool->levels->high_input[tool->channel] != value)
    {
      tool->levels->high_input[tool->channel] = value;
      levels_update (tool, INPUT_LEVELS | INPUT_SLIDERS);

      gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (tool));
    }
}
static void
gimp_brightness_contrast_tool_button_release (GimpTool              *tool,
        const GimpCoords      *coords,
        guint32                time,
        GdkModifierType        state,
        GimpButtonReleaseType  release_type,
        GimpDisplay           *display)
{
    GimpBrightnessContrastTool *bc_tool = GIMP_BRIGHTNESS_CONTRAST_TOOL (tool);
    GimpImageMapTool           *im_tool = GIMP_IMAGE_MAP_TOOL (tool);

    gimp_tool_control_halt (tool->control);

    if (bc_tool->dx == 0 && bc_tool->dy == 0)
        return;

    if (release_type == GIMP_BUTTON_RELEASE_CANCEL)
        gimp_config_reset (GIMP_CONFIG (bc_tool->config));

    gimp_image_map_tool_preview (im_tool);
}
static void
hue_saturation_config_notify (GObject               *object,
                              GParamSpec            *pspec,
                              GimpHueSaturationTool *hs_tool)
{
  GimpHueSaturationConfig *config = GIMP_HUE_SATURATION_CONFIG (object);

  if (! hs_tool->hue_data)
    return;

  if (! strcmp (pspec->name, "range"))
    {
      gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (hs_tool->range_radio),
                                       config->range);
    }
  else if (! strcmp (pspec->name, "hue"))
    {
      gtk_adjustment_set_value (hs_tool->hue_data,
                                config->hue[config->range] * 180.0);
    }
  else if (! strcmp (pspec->name, "lightness"))
    {
      gtk_adjustment_set_value (hs_tool->lightness_data,
                                config->lightness[config->range] * 100.0);
    }
  else if (! strcmp (pspec->name, "saturation"))
    {
      gtk_adjustment_set_value (hs_tool->saturation_data,
                                config->saturation[config->range] * 100.0);
    }
  else if (! strcmp (pspec->name, "overlap"))
    {
      gtk_adjustment_set_value (hs_tool->overlap_data,
                                config->overlap * 100.0);
    }

  hue_saturation_update_color_areas (hs_tool);

  gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (hs_tool));
}
static void
color_balance_config_notify (GObject              *object,
                             GParamSpec           *pspec,
                             GimpColorBalanceTool *cb_tool)
{
  GimpColorBalanceConfig *config = GIMP_COLOR_BALANCE_CONFIG (object);

  if (! cb_tool->cyan_red_adj)
    return;

  if (! strcmp (pspec->name, "range"))
    {
      gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (cb_tool->range_radio),
                                       config->range);
    }
  else if (! strcmp (pspec->name, "cyan-red"))
    {
      gtk_adjustment_set_value (cb_tool->cyan_red_adj,
                                config->cyan_red[config->range] * 100.0);
    }
  else if (! strcmp (pspec->name, "magenta-green"))
    {
      gtk_adjustment_set_value (cb_tool->magenta_green_adj,
                                config->magenta_green[config->range] * 100.0);
    }
  else if (! strcmp (pspec->name, "yellow-blue"))
    {
      gtk_adjustment_set_value (cb_tool->yellow_blue_adj,
                                config->yellow_blue[config->range] * 100.0);
    }
  else if (! strcmp (pspec->name, "preserve-luminosity"))
    {
      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cb_tool->preserve_toggle),
                                    config->preserve_luminosity);
    }

  gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (cb_tool));
}
static void
gimp_image_map_tool_response (GimpToolGui      *gui,
                              gint              response_id,
                              GimpImageMapTool *im_tool)
{
  GimpTool *tool = GIMP_TOOL (im_tool);

  switch (response_id)
    {
    case RESPONSE_RESET:
      gimp_image_map_tool_reset (im_tool);
      gimp_image_map_tool_preview (im_tool);
      break;

    case GTK_RESPONSE_OK:
      gimp_tool_control (tool, GIMP_TOOL_ACTION_COMMIT, tool->display);
      break;

    default:
      gimp_tool_control (tool, GIMP_TOOL_ACTION_HALT, tool->display);
      break;
    }
}
static void
gimp_gegl_tool_operation_changed (GtkWidget    *widget,
                                  GimpGeglTool *tool)
{
  GtkTreeModel *model;
  GtkTreeIter   iter;

  if (! gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter))
    return;

  model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget));

  if (tool->operation)
    {
      g_free (tool->operation);
      tool->operation = NULL;
    }

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

  gtk_tree_model_get (model, &iter,
                      COLUMN_NAME, &tool->operation,
                      -1);

  if (! tool->operation)
    return;

  if (GIMP_IMAGE_MAP_TOOL (tool)->image_map)
    {
      gimp_image_map_clear (GIMP_IMAGE_MAP_TOOL (tool)->image_map);
      g_object_unref (GIMP_IMAGE_MAP_TOOL (tool)->image_map);
      GIMP_IMAGE_MAP_TOOL (tool)->image_map = NULL;
    }

  gegl_node_set (GIMP_IMAGE_MAP_TOOL (tool)->operation,
                 "operation", tool->operation,
                 NULL);

  gimp_image_map_tool_create_map (GIMP_IMAGE_MAP_TOOL (tool));

  tool->config = gimp_gegl_tool_get_config (tool);

  if (tool->options_table)
    {
      gtk_container_remove (GTK_CONTAINER (tool->options_frame),
                            tool->options_table);
      tool->options_table = NULL;
    }

  if (tool->config)
    {
      g_signal_connect_object (tool->config, "notify",
                               G_CALLBACK (gimp_gegl_tool_config_notify),
                               G_OBJECT (tool), 0);

      tool->options_table =
        gimp_prop_table_new (G_OBJECT (tool->config),
                             G_TYPE_FROM_INSTANCE (tool->config),
                             GIMP_CONTEXT (GIMP_TOOL_GET_OPTIONS (tool)));
      gtk_container_add (GTK_CONTAINER (tool->options_frame),
                         tool->options_table);
      gtk_widget_show (tool->options_table);
    }

  gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (tool));
}
Beispiel #27
0
static void
gimp_image_map_tool_response (GtkWidget        *widget,
                              gint              response_id,
                              GimpImageMapTool *image_map_tool)
{
  GimpTool *tool = GIMP_TOOL (image_map_tool);

  switch (response_id)
    {
    case RESPONSE_RESET:
      gimp_image_map_tool_reset (image_map_tool);
      gimp_image_map_tool_preview (image_map_tool);
      break;

    case GTK_RESPONSE_OK:
      gimp_dialog_factory_hide_dialog (image_map_tool->shell);

      if (image_map_tool->image_map)
        {
          GimpImageMapOptions *options = GIMP_IMAGE_MAP_TOOL_GET_OPTIONS (tool);

          gimp_tool_control_set_preserve (tool->control, TRUE);

          if (! options->preview)
            gimp_image_map_tool_map (image_map_tool);

          gimp_image_map_commit (image_map_tool->image_map);
          g_object_unref (image_map_tool->image_map);
          image_map_tool->image_map = NULL;

          gimp_tool_control_set_preserve (tool->control, FALSE);

          gimp_image_flush (tool->display->image);

          if (image_map_tool->config)
            gimp_settings_box_add_current (GIMP_SETTINGS_BOX (image_map_tool->settings_box));
        }

      tool->display  = NULL;
      tool->drawable = NULL;
      break;

    default:
      gimp_dialog_factory_hide_dialog (image_map_tool->shell);

      if (image_map_tool->image_map)
        {
          gimp_tool_control_set_preserve (tool->control, TRUE);

          gimp_image_map_abort (image_map_tool->image_map);
          g_object_unref (image_map_tool->image_map);
          image_map_tool->image_map = NULL;

          gimp_tool_control_set_preserve (tool->control, FALSE);

          gimp_image_flush (tool->display->image);
        }

      tool->display  = NULL;
      tool->drawable = NULL;
      break;
    }
}
Beispiel #28
0
void
gimp_operation_tool_set_operation (GimpOperationTool *tool,
                                   const gchar       *operation,
                                   const gchar       *undo_desc,
                                   const gchar       *icon_name)
{
    GimpImageMapTool *im_tool;
    GtkSizeGroup     *size_group = NULL;
    gint              aux;

    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);

    g_list_free_full (tool->aux_inputs,
                      (GDestroyNotify) gimp_operation_tool_aux_input_free);
    tool->aux_inputs = 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->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));
        }
    }

    for (aux = 1; ; aux++)
    {
        gchar pad[32];
        gchar label[32];

        if (aux == 1)
        {
            g_snprintf (pad,   sizeof (pad),   "aux");
            g_snprintf (label, sizeof (label), _("Aux Input"));
        }
        else
        {
            g_snprintf (pad,   sizeof (pad),   "aux%d", aux);
            g_snprintf (label, sizeof (label), _("Aux%d Input"), aux);
        }

        if (gegl_node_has_pad (im_tool->operation, pad))
        {
            AuxInput  *input;
            GtkWidget *toggle;

            if (! size_group)
                size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);

            input = gimp_operation_tool_aux_input_new (tool,
                    im_tool->operation, pad,
                    label);

            tool->aux_inputs = g_list_append (tool->aux_inputs, input);

            toggle = gimp_buffer_source_box_get_toggle (GIMP_BUFFER_SOURCE_BOX (input->box));
            gtk_size_group_add_widget (size_group, toggle);

            if (tool->options_box)
            {
                gtk_box_pack_start (GTK_BOX (tool->options_box), input->box,
                                    FALSE, FALSE, 0);
                gtk_widget_show (input->box);
            }
        }
        else
        {
            break;
        }
    }

    if (size_group)
        g_object_unref (size_group);

    if (im_tool->config)
    {
        tool->options_gui =
            gimp_prop_gui_new (G_OBJECT (im_tool->config),
                               G_TYPE_FROM_INSTANCE (im_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);
    }
}
Beispiel #29
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));
}
Beispiel #30
0
static gboolean
levels_output_area_event (GtkWidget      *widget,
                          GdkEvent       *event,
                          GimpLevelsTool *tool)
{
  GdkEventButton *bevent;
  GdkEventMotion *mevent;
  gint            x, distance;
  gint            i;
  gboolean        update = FALSE;

  switch (event->type)
    {
    case GDK_BUTTON_PRESS:
      bevent = (GdkEventButton *) event;

      distance = G_MAXINT;
      for (i = 3; i < 5; i++)
        if (fabs (bevent->x - tool->slider_pos[i]) < distance)
          {
            tool->active_slider = i;
            distance = fabs (bevent->x - tool->slider_pos[i]);
          }

      x = bevent->x;
      update = TRUE;
      break;

    case GDK_BUTTON_RELEASE:
      switch (tool->active_slider)
        {
        case 3:  /*  low output  */
          levels_update (tool, LOW_OUTPUT);
          break;
        case 4:  /*  high output  */
          levels_update (tool, HIGH_OUTPUT);
          break;
        }

      gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (tool));
      break;

    case GDK_MOTION_NOTIFY:
      mevent = (GdkEventMotion *) event;
      gdk_window_get_pointer (widget->window, &x, NULL, NULL);
      update = TRUE;
      break;

    default:
      break;
    }

  if (update)
    {
      gint  width;
      gint  border;

      g_object_get (tool->hist_view, "border-width", &border, NULL);

      width = widget->allocation.width - 2 * border;

      if (width < 1)
        return FALSE;

      switch (tool->active_slider)
        {
        case 3:  /*  low output  */
          tool->levels->low_output[tool->channel] =
            ((gdouble) (x - border) / (gdouble) width) * 255.0;

          tool->levels->low_output[tool->channel] =
            CLAMP (tool->levels->low_output[tool->channel], 0, 255);
          break;

        case 4:  /*  high output  */
          tool->levels->high_output[tool->channel] =
            ((gdouble) (x - border) / (gdouble) width) * 255.0;

          tool->levels->high_output[tool->channel] =
            CLAMP (tool->levels->high_output[tool->channel], 0, 255);
          break;
        }

      levels_update (tool, OUTPUT_SLIDERS);
    }

  return FALSE;
}