static void gimp_levels_tool_class_init (GimpLevelsToolClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass); GimpColorToolClass *color_tool_class = GIMP_COLOR_TOOL_CLASS (klass); GimpImageMapToolClass *im_tool_class = GIMP_IMAGE_MAP_TOOL_CLASS (klass); object_class->finalize = gimp_levels_tool_finalize; tool_class->initialize = gimp_levels_tool_initialize; color_tool_class->picked = gimp_levels_tool_color_picked; im_tool_class->dialog_desc = _("Adjust Color Levels"); im_tool_class->settings_name = "levels"; im_tool_class->import_dialog_title = _("Import Levels"); im_tool_class->export_dialog_title = _("Export Levels"); im_tool_class->get_operation = gimp_levels_tool_get_operation; im_tool_class->map = gimp_levels_tool_map; im_tool_class->dialog = gimp_levels_tool_dialog; im_tool_class->reset = gimp_levels_tool_reset; im_tool_class->settings_import = gimp_levels_tool_settings_import; im_tool_class->settings_export = gimp_levels_tool_settings_export; }
static void gimp_curves_tool_class_init (GimpCurvesToolClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass); GimpColorToolClass *color_tool_class = GIMP_COLOR_TOOL_CLASS (klass); GimpImageMapToolClass *im_tool_class = GIMP_IMAGE_MAP_TOOL_CLASS (klass); object_class->finalize = gimp_curves_tool_finalize; tool_class->initialize = gimp_curves_tool_initialize; tool_class->button_release = gimp_curves_tool_button_release; tool_class->key_press = gimp_curves_tool_key_press; tool_class->oper_update = gimp_curves_tool_oper_update; color_tool_class->picked = gimp_curves_tool_color_picked; im_tool_class->shell_desc = _("Adjust Color Curves"); im_tool_class->settings_name = "curves"; im_tool_class->import_dialog_title = _("Import Curves"); im_tool_class->export_dialog_title = _("Export Curves"); im_tool_class->get_operation = gimp_curves_tool_get_operation; im_tool_class->map = gimp_curves_tool_map; im_tool_class->dialog = gimp_curves_tool_dialog; im_tool_class->reset = gimp_curves_tool_reset; im_tool_class->settings_import = gimp_curves_tool_settings_import; im_tool_class->settings_export = gimp_curves_tool_settings_export; }
static gboolean gimp_levels_tool_settings_export (GimpImageMapTool *image_map_tool, const gchar *filename, GError **error) { GimpLevelsTool *tool = GIMP_LEVELS_TOOL (image_map_tool); if (tool->export_old_format) { FILE *file; gboolean success; file = g_fopen (filename, "wt"); if (! file) { g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno), _("Could not open '%s' for writing: %s"), gimp_filename_to_utf8 (filename), g_strerror (errno)); return FALSE; } success = gimp_levels_config_save_cruft (tool->config, file, error); fclose (file); return success; } return GIMP_IMAGE_MAP_TOOL_CLASS (parent_class)->settings_export (image_map_tool, filename, error); }
static gboolean gimp_curves_tool_settings_import (GimpImageMapTool *image_map_tool, GInputStream *input, GError **error) { GimpCurvesTool *tool = GIMP_CURVES_TOOL (image_map_tool); gchar header[64]; gsize bytes_read; if (! g_input_stream_read_all (input, header, sizeof (header), &bytes_read, NULL, error) || bytes_read != sizeof (header)) { g_prefix_error (error, _("Could not read header: ")); return FALSE; } g_seekable_seek (G_SEEKABLE (input), 0, G_SEEK_SET, NULL, NULL); if (g_str_has_prefix (header, "# GIMP Curves File\n")) return gimp_curves_config_load_cruft (tool->config, input, error); return GIMP_IMAGE_MAP_TOOL_CLASS (parent_class)->settings_import (image_map_tool, input, error); }
static void gimp_levels_tool_class_init (GimpLevelsToolClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass); GimpColorToolClass *color_tool_class = GIMP_COLOR_TOOL_CLASS (klass); GimpImageMapToolClass *im_tool_class = GIMP_IMAGE_MAP_TOOL_CLASS (klass); object_class->finalize = gimp_levels_tool_finalize; tool_class->initialize = gimp_levels_tool_initialize; color_tool_class->picked = gimp_levels_tool_color_picked; im_tool_class->shell_desc = _("Adjust Color Levels"); im_tool_class->settings_name = "levels"; im_tool_class->load_dialog_title = _("Load Levels"); im_tool_class->load_button_tip = _("Load levels settings from file"); im_tool_class->save_dialog_title = _("Save Levels"); im_tool_class->save_button_tip = _("Save levels settings to file"); im_tool_class->map = gimp_levels_tool_map; im_tool_class->dialog = gimp_levels_tool_dialog; im_tool_class->reset = gimp_levels_tool_reset; im_tool_class->settings_load = gimp_levels_tool_settings_load; im_tool_class->settings_save = gimp_levels_tool_settings_save; }
static void gimp_gegl_tool_class_init (GimpGeglToolClass *klass) { GimpImageMapToolClass *im_tool_class = GIMP_IMAGE_MAP_TOOL_CLASS (klass); im_tool_class->dialog_desc = _("GEGL Operation"); im_tool_class->dialog = gimp_gegl_tool_dialog; }
static void gimp_posterize_tool_class_init (GimpPosterizeToolClass *klass) { GimpImageMapToolClass *im_tool_class = GIMP_IMAGE_MAP_TOOL_CLASS (klass); im_tool_class->dialog_desc = _("Posterize (Reduce Number of Colors)"); im_tool_class->get_operation = gimp_posterize_tool_get_operation; im_tool_class->dialog = gimp_posterize_tool_dialog; }
static void gimp_operation_tool_reset (GimpImageMapTool *im_tool) { GimpOperationTool *tool = GIMP_OPERATION_TOOL (im_tool); GIMP_IMAGE_MAP_TOOL_CLASS (parent_class)->reset (im_tool); if (im_tool->config && GIMP_TOOL (tool)->drawable) gimp_operation_tool_sync_op (tool, GIMP_TOOL (tool)->drawable); }
static void gimp_color_balance_tool_reset (GimpImageMapTool *im_tool) { GimpColorBalanceTool *cb_tool = GIMP_COLOR_BALANCE_TOOL (im_tool); GimpTransferMode range = cb_tool->config->range; GIMP_IMAGE_MAP_TOOL_CLASS (parent_class)->reset (im_tool); g_object_set (cb_tool->config, "range", range, NULL); }
static void gimp_desaturate_tool_class_init (GimpDesaturateToolClass *klass) { GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass); GimpImageMapToolClass *im_tool_class = GIMP_IMAGE_MAP_TOOL_CLASS (klass); tool_class->initialize = gimp_desaturate_tool_initialize; im_tool_class->shell_desc = _("Desaturate (Remove Colors)"); im_tool_class->get_operation = gimp_desaturate_tool_get_operation; im_tool_class->map = gimp_desaturate_tool_map; im_tool_class->dialog = gimp_desaturate_tool_dialog; }
static gboolean gimp_curves_tool_settings_export (GimpImageMapTool *image_map_tool, GOutputStream *output, GError **error) { GimpCurvesTool *tool = GIMP_CURVES_TOOL (image_map_tool); if (tool->export_old_format) return gimp_curves_config_save_cruft (tool->config, output, error); return GIMP_IMAGE_MAP_TOOL_CLASS (parent_class)->settings_export (image_map_tool, output, error); }
static gboolean gimp_levels_tool_settings_import (GimpImageMapTool *image_map_tool, const gchar *filename, GError **error) { GimpLevelsTool *tool = GIMP_LEVELS_TOOL (image_map_tool); FILE *file; gchar header[64]; file = g_fopen (filename, "rt"); if (! file) { g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno), _("Could not open '%s' for reading: %s"), gimp_filename_to_utf8 (filename), g_strerror (errno)); return FALSE; } if (! fgets (header, sizeof (header), file)) { g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno), _("Could not read header from '%s': %s"), gimp_filename_to_utf8 (filename), g_strerror (errno)); fclose (file); return FALSE; } if (g_str_has_prefix (header, "# GIMP Levels File\n")) { gboolean success; rewind (file); success = gimp_levels_config_load_cruft (tool->config, file, error); fclose (file); return success; } fclose (file); return GIMP_IMAGE_MAP_TOOL_CLASS (parent_class)->settings_import (image_map_tool, filename, error); }
static void gimp_levels_tool_reset (GimpImageMapTool *im_tool) { GimpHistogramChannel channel; g_object_get (im_tool->config, "channel", &channel, NULL); GIMP_IMAGE_MAP_TOOL_CLASS (parent_class)->reset (im_tool); g_object_set (im_tool->config, "channel", channel, NULL); }
static gboolean gimp_levels_tool_settings_export (GimpImageMapTool *im_tool, GOutputStream *output, GError **error) { GimpLevelsTool *tool = GIMP_LEVELS_TOOL (im_tool); GimpLevelsConfig *config = GIMP_LEVELS_CONFIG (im_tool->config); if (tool->export_old_format) return gimp_levels_config_save_cruft (config, output, error); return GIMP_IMAGE_MAP_TOOL_CLASS (parent_class)->settings_export (im_tool, output, error); }
static void gimp_color_balance_tool_reset (GimpImageMapTool *im_tool) { GimpTransferMode range; g_object_get (im_tool->config, "range", &range, NULL); GIMP_IMAGE_MAP_TOOL_CLASS (parent_class)->reset (im_tool); g_object_set (im_tool->config, "range", range, NULL); }
static GtkWidget * gimp_operation_tool_get_settings_ui (GimpImageMapTool *im_tool, GimpContainer *settings, GFile *settings_file, const gchar *import_dialog_title, const gchar *export_dialog_title, const gchar *file_dialog_help_id, GFile *default_folder, GtkWidget **settings_box) { GimpOperationTool *tool = GIMP_OPERATION_TOOL (im_tool); GType type = G_TYPE_FROM_INSTANCE (im_tool->config); GtkWidget *widget; gchar *basename; GFile *file; gchar *import_title; gchar *export_title; settings = gimp_gegl_get_config_container (type); if (! gimp_list_get_sort_func (GIMP_LIST (settings))) gimp_list_set_sort_func (GIMP_LIST (settings), (GCompareFunc) gimp_settings_compare); basename = g_strconcat (G_OBJECT_TYPE_NAME (im_tool->config), ".settings", NULL); file = gimp_directory_file ("filters", basename, NULL); g_free (basename); import_title = g_strdup_printf (_("Import '%s' Settings"), tool->undo_desc); export_title = g_strdup_printf (_("Export '%s' Settings"), tool->undo_desc); widget = GIMP_IMAGE_MAP_TOOL_CLASS (parent_class)->get_settings_ui (im_tool, settings, file, import_title, export_title, "help-foo", NULL, /* sic */ settings_box); g_free (import_title); g_free (export_title); g_object_unref (file); return widget; }
static void gimp_color_balance_tool_class_init (GimpColorBalanceToolClass *klass) { GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass); GimpImageMapToolClass *im_tool_class = GIMP_IMAGE_MAP_TOOL_CLASS (klass); tool_class->initialize = gimp_color_balance_tool_initialize; im_tool_class->settings_name = "color-balance"; im_tool_class->import_dialog_title = _("Import Color Balance Settings"); im_tool_class->export_dialog_title = _("Export Color Balance Settings"); im_tool_class->get_operation = gimp_color_balance_tool_get_operation; im_tool_class->dialog = gimp_color_balance_tool_dialog; im_tool_class->reset = gimp_color_balance_tool_reset; }
static void gimp_colorize_tool_class_init (GimpColorizeToolClass *klass) { GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass); GimpImageMapToolClass *im_tool_class = GIMP_IMAGE_MAP_TOOL_CLASS (klass); tool_class->initialize = gimp_colorize_tool_initialize; im_tool_class->dialog_desc = _("Colorize the Image"); im_tool_class->settings_name = "colorize"; im_tool_class->import_dialog_title = _("Import Colorize Settings"); im_tool_class->export_dialog_title = _("Export Colorize Settings"); im_tool_class->get_operation = gimp_colorize_tool_get_operation; im_tool_class->dialog = gimp_colorize_tool_dialog; im_tool_class->color_picked = gimp_colorize_tool_color_picked; }
static void gimp_posterize_tool_class_init (GimpPosterizeToolClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass); GimpImageMapToolClass *im_tool_class = GIMP_IMAGE_MAP_TOOL_CLASS (klass); object_class->finalize = gimp_posterize_tool_finalize; tool_class->initialize = gimp_posterize_tool_initialize; im_tool_class->dialog_desc = _("Posterize (Reduce Number of Colors)"); im_tool_class->get_operation = gimp_posterize_tool_get_operation; im_tool_class->map = gimp_posterize_tool_map; im_tool_class->dialog = gimp_posterize_tool_dialog; }
static void gimp_operation_tool_class_init (GimpOperationToolClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); GimpImageMapToolClass *im_tool_class = GIMP_IMAGE_MAP_TOOL_CLASS (klass); object_class->finalize = gimp_operation_tool_finalize; im_tool_class->dialog_desc = _("GEGL Operation"); im_tool_class->get_operation = gimp_operation_tool_get_operation; im_tool_class->map = gimp_operation_tool_map; im_tool_class->dialog = gimp_operation_tool_dialog; im_tool_class->reset = gimp_operation_tool_reset; im_tool_class->get_settings_ui = gimp_operation_tool_get_settings_ui; im_tool_class->color_picked = gimp_operation_tool_color_picked; }
static void gimp_gegl_tool_class_init (GimpGeglToolClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass); GimpImageMapToolClass *im_tool_class = GIMP_IMAGE_MAP_TOOL_CLASS (klass); object_class->finalize = gimp_gegl_tool_finalize; tool_class->initialize = gimp_gegl_tool_initialize; im_tool_class->dialog_desc = _("GEGL Operation"); im_tool_class->get_operation = gimp_gegl_tool_get_operation; im_tool_class->map = gimp_gegl_tool_map; im_tool_class->dialog = gimp_gegl_tool_dialog; im_tool_class->reset = gimp_gegl_tool_reset; }
static void gimp_brightness_contrast_tool_class_init (GimpBrightnessContrastToolClass *klass) { GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass); GimpImageMapToolClass *im_tool_class = GIMP_IMAGE_MAP_TOOL_CLASS (klass); tool_class->initialize = gimp_brightness_contrast_tool_initialize; tool_class->button_press = gimp_brightness_contrast_tool_button_press; tool_class->button_release = gimp_brightness_contrast_tool_button_release; tool_class->motion = gimp_brightness_contrast_tool_motion; im_tool_class->dialog_desc = _("Adjust Brightness and Contrast"); im_tool_class->settings_name = "brightness-contrast"; im_tool_class->import_dialog_title = _("Import Brightness-Contrast settings"); im_tool_class->export_dialog_title = _("Export Brightness-Contrast settings"); im_tool_class->get_operation = gimp_brightness_contrast_tool_get_operation; im_tool_class->dialog = gimp_brightness_contrast_tool_dialog; }
static void gimp_threshold_tool_class_init (GimpThresholdToolClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass); GimpImageMapToolClass *im_tool_class = GIMP_IMAGE_MAP_TOOL_CLASS (klass); object_class->finalize = gimp_threshold_tool_finalize; tool_class->initialize = gimp_threshold_tool_initialize; im_tool_class->dialog_desc = _("Apply Threshold"); im_tool_class->settings_name = "threshold"; im_tool_class->import_dialog_title = _("Import Threshold Settings"); im_tool_class->export_dialog_title = _("Export Threshold Settings"); im_tool_class->get_operation = gimp_threshold_tool_get_operation; im_tool_class->dialog = gimp_threshold_tool_dialog; }
static void gimp_colorize_tool_class_init (GimpColorizeToolClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass); GimpImageMapToolClass *im_tool_class = GIMP_IMAGE_MAP_TOOL_CLASS (klass); object_class->finalize = gimp_colorize_tool_finalize; tool_class->initialize = gimp_colorize_tool_initialize; im_tool_class->shell_desc = _("Colorize the Image"); im_tool_class->settings_name = "colorize"; im_tool_class->import_dialog_title = _("Import Colorize Settings"); im_tool_class->export_dialog_title = _("Export Colorize Settings"); im_tool_class->get_operation = gimp_colorize_tool_get_operation; im_tool_class->map = gimp_colorize_tool_map; im_tool_class->dialog = gimp_colorize_tool_dialog; }
static void gimp_hue_saturation_tool_class_init (GimpHueSaturationToolClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass); GimpImageMapToolClass *im_tool_class = GIMP_IMAGE_MAP_TOOL_CLASS (klass); object_class->finalize = gimp_hue_saturation_tool_finalize; tool_class->initialize = gimp_hue_saturation_tool_initialize; im_tool_class->dialog_desc = _("Adjust Hue / Lightness / Saturation"); im_tool_class->settings_name = "hue-saturation"; im_tool_class->import_dialog_title = _("Import Hue-Saturation Settings"); im_tool_class->export_dialog_title = _("Export Hue-Saturation Settings"); im_tool_class->get_operation = gimp_hue_saturation_tool_get_operation; im_tool_class->map = gimp_hue_saturation_tool_map; im_tool_class->dialog = gimp_hue_saturation_tool_dialog; im_tool_class->reset = gimp_hue_saturation_tool_reset; }
static void gimp_gegl_tool_dialog (GimpImageMapTool *image_map_tool) { GimpGeglTool *tool = GIMP_GEGL_TOOL (image_map_tool); GimpOperationTool *o_tool = GIMP_OPERATION_TOOL (image_map_tool); GtkListStore *store; GtkCellRenderer *cell; GtkWidget *main_vbox; GtkWidget *hbox; GtkWidget *combo; GList *opclasses; GList *iter; GIMP_IMAGE_MAP_TOOL_CLASS (parent_class)->dialog (image_map_tool); main_vbox = gimp_image_map_tool_dialog_get_vbox (image_map_tool); /* The operation combo box */ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0); gtk_box_reorder_child (GTK_BOX (main_vbox), hbox, 0); gtk_widget_show (hbox); store = gtk_list_store_new (N_COLUMNS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); opclasses = gimp_get_geglopclasses (); for (iter = opclasses; iter; iter = iter->next) { GeglOperationClass *opclass = GEGL_OPERATION_CLASS (iter->data); const gchar *stock_id; const gchar *label; if (g_str_has_prefix (opclass->name, "gegl:")) { label = opclass->name + strlen ("gegl:"); stock_id = GIMP_STOCK_GEGL; } else { label = opclass->name; stock_id = NULL; } gtk_list_store_insert_with_values (store, NULL, -1, COLUMN_NAME, opclass->name, COLUMN_LABEL, label, COLUMN_STOCK_ID, stock_id, -1); } g_list_free (opclasses); combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (store)); g_object_unref (store); gtk_box_pack_start (GTK_BOX (hbox), combo, TRUE, TRUE, 0); gtk_widget_show (combo); cell = gtk_cell_renderer_pixbuf_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), cell, FALSE); gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combo), cell, "stock-id", COLUMN_STOCK_ID); cell = gtk_cell_renderer_text_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), cell, TRUE); gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combo), cell, "text", COLUMN_LABEL); g_signal_connect (combo, "changed", G_CALLBACK (gimp_gegl_tool_operation_changed), tool); tool->operation_combo = combo; tool->description_label = gtk_label_new (""); gtk_label_set_line_wrap (GTK_LABEL (tool->description_label), TRUE); gtk_misc_set_alignment (GTK_MISC (tool->description_label), 0.0, 0.0); gtk_box_pack_start (GTK_BOX (main_vbox), tool->description_label, FALSE, FALSE, 0); gtk_box_reorder_child (GTK_BOX (main_vbox), tool->description_label, 1); /* The options vbox */ o_tool->options_table = gtk_label_new (_("Select an operation from the list above")); gimp_label_set_attributes (GTK_LABEL (o_tool->options_table), PANGO_ATTR_STYLE, PANGO_STYLE_ITALIC, -1); gtk_misc_set_padding (GTK_MISC (o_tool->options_table), 0, 4); gtk_container_add (GTK_CONTAINER (o_tool->options_box), o_tool->options_table); gtk_widget_show (o_tool->options_table); }