static void gimp_curves_config_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { GimpCurvesConfig *self = GIMP_CURVES_CONFIG (object); switch (property_id) { case PROP_CHANNEL: self->channel = g_value_get_enum (value); g_object_notify (object, "curve"); break; case PROP_CURVE: { GimpCurve *src_curve = g_value_get_object (value); GimpCurve *dest_curve = self->curve[self->channel]; if (src_curve && dest_curve) { gimp_config_copy (GIMP_CONFIG (src_curve), GIMP_CONFIG (dest_curve), 0); } } break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; } }
static void gimp_levels_tool_reset (GimpImageMapTool *image_map_tool) { GimpLevelsTool *tool = GIMP_LEVELS_TOOL (image_map_tool); GimpHistogramChannel channel = tool->config->channel; g_object_freeze_notify (image_map_tool->config); if (image_map_tool->default_config) { gimp_config_copy (GIMP_CONFIG (image_map_tool->default_config), GIMP_CONFIG (image_map_tool->config), 0); } else { gimp_config_reset (GIMP_CONFIG (image_map_tool->config)); } g_object_set (tool->config, "channel", channel, NULL); g_object_thaw_notify (image_map_tool->config); }
static void tool_manager_preset_changed (GimpContext *user_context, GimpToolPreset *preset, GimpToolManager *tool_manager) { GimpToolInfo *preset_tool; gboolean tool_change = FALSE; if (! preset || user_context->gimp->busy) return; preset_tool = gimp_context_get_tool (GIMP_CONTEXT (preset->tool_options)); if (preset_tool != gimp_context_get_tool (user_context)) tool_change = TRUE; if (! tool_change) tool_manager_disconnect_options (user_context, preset_tool); gimp_config_copy (GIMP_CONFIG (preset->tool_options), GIMP_CONFIG (preset_tool->tool_options), 0); if (tool_change) gimp_context_set_tool (user_context, preset_tool); else tool_manager_connect_options (user_context, preset_tool); gimp_context_copy_properties (GIMP_CONTEXT (preset->tool_options), user_context, gimp_tool_preset_get_prop_mask (preset)); }
static void gimp_hue_saturation_tool_reset (GimpImageMapTool *image_map_tool) { GimpHueSaturationTool *hs_tool = GIMP_HUE_SATURATION_TOOL (image_map_tool); GimpHueRange range = hs_tool->config->range; g_object_freeze_notify (image_map_tool->config); if (image_map_tool->default_config) { gimp_config_copy (GIMP_CONFIG (image_map_tool->default_config), GIMP_CONFIG (image_map_tool->config), 0); } else { gimp_config_reset (GIMP_CONFIG (image_map_tool->config)); } g_object_set (hs_tool->config, "range", range, NULL); g_object_thaw_notify (image_map_tool->config); }
static void gimp_curves_tool_reset (GimpImageMapTool *image_map_tool) { GimpCurvesTool *tool = GIMP_CURVES_TOOL (image_map_tool); GimpCurvesConfig *default_config; GimpHistogramChannel channel; default_config = GIMP_CURVES_CONFIG (image_map_tool->default_config); for (channel = GIMP_HISTOGRAM_VALUE; channel <= GIMP_HISTOGRAM_ALPHA; channel++) { if (default_config) { GimpCurveType curve_type = tool->config->curve[channel]->curve_type; g_object_freeze_notify (G_OBJECT (tool->config->curve[channel])); gimp_config_copy (GIMP_CONFIG (default_config->curve[channel]), GIMP_CONFIG (tool->config->curve[channel]), 0); g_object_set (tool->config->curve[channel], "curve-type", curve_type, NULL); g_object_thaw_notify (G_OBJECT (tool->config->curve[channel])); } else { gimp_curve_reset (tool->config->curve[channel], FALSE); } } }
static void tool_manager_preset_changed (GimpContext *user_context, GimpToolPreset *preset, GimpToolManager *tool_manager) { GimpToolInfo *preset_tool; gchar *options_name; gboolean tool_change = FALSE; if (! preset || user_context->gimp->busy) return; preset_tool = gimp_context_get_tool (GIMP_CONTEXT (preset->tool_options)); if (preset_tool != gimp_context_get_tool (user_context)) tool_change = TRUE; /* save the name, we don't want to overwrite it */ options_name = g_strdup (gimp_object_get_name (preset_tool->tool_options)); gimp_config_copy (GIMP_CONFIG (preset->tool_options), GIMP_CONFIG (preset_tool->tool_options), 0); /* restore the saved name */ gimp_object_take_name (GIMP_OBJECT (preset_tool->tool_options), options_name); if (tool_change) gimp_context_set_tool (user_context, preset_tool); gimp_context_copy_properties (GIMP_CONTEXT (preset->tool_options), user_context, gimp_tool_preset_get_prop_mask (preset)); if (GIMP_IS_PAINT_OPTIONS (preset->tool_options)) { GimpToolOptions *src; GimpToolOptions *dest; GimpContextPropMask prop_mask = 0; src = preset->tool_options; dest = tool_manager->active_tool->tool_info->tool_options; /* copy various data objects' additional tool options again * manually, they might have been overwritten by e.g. the "link * brush stuff to brush defaults" logic in gimptooloptions.c */ if (preset->use_brush) prop_mask |= GIMP_CONTEXT_PROP_MASK_BRUSH; if (preset->use_dynamics) prop_mask |= GIMP_CONTEXT_PROP_MASK_DYNAMICS; if (preset->use_gradient) prop_mask |= GIMP_CONTEXT_PROP_MASK_GRADIENT; gimp_paint_options_copy_props (GIMP_PAINT_OPTIONS (src), GIMP_PAINT_OPTIONS (dest), prop_mask); } }
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; g_object_freeze_notify (im_tool->config); if (im_tool->default_config) { gimp_config_copy (GIMP_CONFIG (im_tool->default_config), GIMP_CONFIG (im_tool->config), 0); } else { gimp_config_reset (GIMP_CONFIG (im_tool->config)); } g_object_set (cb_tool->config, "range", range, NULL); g_object_thaw_notify (im_tool->config); }
static void gimp_dynamics_editor_set_data (GimpDataEditor *editor, GimpData *data) { GimpDynamicsEditor *dynamics_editor = GIMP_DYNAMICS_EDITOR (editor); if (editor->data) g_signal_handlers_disconnect_by_func (editor->data, gimp_dynamics_editor_notify_data, editor); GIMP_DATA_EDITOR_CLASS (parent_class)->set_data (editor, data); if (editor->data) { g_signal_handlers_block_by_func (dynamics_editor->dynamics_model, gimp_dynamics_editor_notify_model, editor); gimp_config_copy (GIMP_CONFIG (editor->data), GIMP_CONFIG (dynamics_editor->dynamics_model), GIMP_CONFIG_PARAM_SERIALIZE); g_signal_handlers_unblock_by_func (dynamics_editor->dynamics_model, gimp_dynamics_editor_notify_model, editor); g_signal_connect (editor->data, "notify", G_CALLBACK (gimp_dynamics_editor_notify_data), editor); } gtk_widget_set_sensitive (dynamics_editor->notebook, editor->data_editable); }
static GimpConfig * gimp_config_iface_duplicate (GimpConfig *config) { GObject *object = G_OBJECT (config); GObjectClass *klass = G_OBJECT_GET_CLASS (object); GParamSpec **property_specs; guint n_property_specs; gint n_construct_properties = 0; const gchar **construct_names = NULL; GValue *construct_values = NULL; guint i; GObject *dup; property_specs = g_object_class_list_properties (klass, &n_property_specs); construct_names = g_new0 (const gchar *, n_property_specs); construct_values = g_new0 (GValue, n_property_specs); for (i = 0; i < n_property_specs; i++) { GParamSpec *prop_spec = property_specs[i]; if ((prop_spec->flags & G_PARAM_READABLE) && (prop_spec->flags & G_PARAM_WRITABLE) && (prop_spec->flags & G_PARAM_CONSTRUCT_ONLY)) { construct_names[n_construct_properties] = prop_spec->name; g_value_init (&construct_values[n_construct_properties], prop_spec->value_type); g_object_get_property (object, prop_spec->name, &construct_values[n_construct_properties]); n_construct_properties++; } } g_free (property_specs); dup = g_object_new_with_properties (G_TYPE_FROM_INSTANCE (object), n_construct_properties, (const gchar **) construct_names, (const GValue *) construct_values); for (i = 0; i < n_construct_properties; i++) g_value_unset (&construct_values[i]); g_free (construct_names); g_free (construct_values); gimp_config_copy (config, GIMP_CONFIG (dup), 0); return GIMP_CONFIG (dup); }
static void gimp_curve_data_copy (GimpData *data, GimpData *src_data) { gimp_data_freeze (data); gimp_config_copy (GIMP_CONFIG (src_data), GIMP_CONFIG (data), 0); gimp_data_thaw (data); }
static void gimp_tool_preset_editor_set_data (GimpDataEditor *editor, GimpData *data) { GimpToolPresetEditor *preset_editor = GIMP_TOOL_PRESET_EDITOR (editor); if (editor->data) g_signal_handlers_disconnect_by_func (editor->data, gimp_tool_preset_editor_notify_data, editor); GIMP_DATA_EDITOR_CLASS (parent_class)->set_data (editor, data); if (editor->data) { GimpToolInfo *tool_info; const gchar *stock_id; gchar *label; g_signal_handlers_block_by_func (preset_editor->tool_preset_model, gimp_tool_preset_editor_notify_model, editor); gimp_config_copy (GIMP_CONFIG (editor->data), GIMP_CONFIG (preset_editor->tool_preset_model), GIMP_CONFIG_PARAM_SERIALIZE); g_signal_handlers_unblock_by_func (preset_editor->tool_preset_model, gimp_tool_preset_editor_notify_model, editor); g_signal_connect (editor->data, "notify", G_CALLBACK (gimp_tool_preset_editor_notify_data), editor); tool_info = preset_editor->tool_preset_model->tool_options->tool_info; stock_id = gimp_viewable_get_stock_id (GIMP_VIEWABLE (tool_info)); label = g_strdup_printf (_("%s Preset"), tool_info->blurb); gtk_image_set_from_stock (GTK_IMAGE (preset_editor->tool_icon), stock_id, GTK_ICON_SIZE_MENU); gtk_label_set_text (GTK_LABEL (preset_editor->tool_label), label); g_free (label); } }
void view_color_management_reset_cmd_callback (GtkAction *action, gpointer data) { GimpDisplayShell *shell; GimpColorConfig *global_config; GimpColorConfig *shell_config; return_if_no_shell (shell, data); global_config = GIMP_CORE_CONFIG (shell->display->config)->color_management; shell_config = gimp_display_shell_get_color_config (shell); gimp_config_copy (GIMP_CONFIG (global_config), GIMP_CONFIG (shell_config), 0); shell->color_config_set = FALSE; }
static void gimp_image_map_tool_real_reset (GimpImageMapTool *im_tool) { if (im_tool->config) { if (im_tool->default_config) { gimp_config_copy (GIMP_CONFIG (im_tool->default_config), GIMP_CONFIG (im_tool->config), 0); } else { gimp_config_reset (GIMP_CONFIG (im_tool->config)); } } }
static void gimp_dynamics_editor_notify_data (GimpDynamics *options, const GParamSpec *pspec, GimpDynamicsEditor *editor) { GimpDataEditor *data_editor = GIMP_DATA_EDITOR (editor); g_signal_handlers_block_by_func (editor->dynamics_model, gimp_dynamics_editor_notify_model, editor); gimp_config_copy (GIMP_CONFIG (data_editor->data), GIMP_CONFIG (editor->dynamics_model), GIMP_CONFIG_PARAM_SERIALIZE); g_signal_handlers_unblock_by_func (editor->dynamics_model, gimp_dynamics_editor_notify_model, editor); }
static void gimp_image_map_tool_reset (GimpImageMapTool *tool) { if (GIMP_IMAGE_MAP_TOOL_GET_CLASS (tool)->reset) { GIMP_IMAGE_MAP_TOOL_GET_CLASS (tool)->reset (tool); } else if (tool->config) { if (tool->default_config) { gimp_config_copy (GIMP_CONFIG (tool->default_config), GIMP_CONFIG (tool->config), 0); } else { gimp_config_reset (GIMP_CONFIG (tool->config)); } } }
static void gimp_tool_preset_editor_notify_model (GimpToolPreset *options, const GParamSpec *pspec, GimpToolPresetEditor *editor) { GimpDataEditor *data_editor = GIMP_DATA_EDITOR (editor); if (data_editor->data) { g_signal_handlers_block_by_func (data_editor->data, gimp_tool_preset_editor_notify_data, editor); gimp_config_copy (GIMP_CONFIG (editor->tool_preset_model), GIMP_CONFIG (data_editor->data), GIMP_CONFIG_PARAM_SERIALIZE); g_signal_handlers_unblock_by_func (data_editor->data, gimp_tool_preset_editor_notify_data, editor); } }
static gboolean gimp_curves_config_copy (GimpConfig *src, GimpConfig *dest, GParamFlags flags) { GimpCurvesConfig *src_config = GIMP_CURVES_CONFIG (src); GimpCurvesConfig *dest_config = GIMP_CURVES_CONFIG (dest); GimpHistogramChannel channel; for (channel = GIMP_HISTOGRAM_VALUE; channel <= GIMP_HISTOGRAM_ALPHA; channel++) { gimp_config_copy (GIMP_CONFIG (src_config->curve[channel]), GIMP_CONFIG (dest_config->curve[channel]), flags); } dest_config->channel = src_config->channel; g_object_notify (G_OBJECT (dest), "channel"); return TRUE; }
static void tool_manager_preset_changed (GimpContext *user_context, GimpToolPreset *preset, GimpToolManager *tool_manager) { GimpToolInfo *preset_tool; gchar *options_name; gboolean tool_change = FALSE; if (! preset || user_context->gimp->busy) return; preset_tool = gimp_context_get_tool (GIMP_CONTEXT (preset->tool_options)); if (preset_tool != gimp_context_get_tool (user_context)) tool_change = TRUE; if (! tool_change) tool_manager_disconnect_options (tool_manager, user_context, preset_tool); /* save the name, we don't want to overwrite it */ options_name = g_strdup (gimp_object_get_name (preset_tool->tool_options)); gimp_config_copy (GIMP_CONFIG (preset->tool_options), GIMP_CONFIG (preset_tool->tool_options), 0); /* restore the saved name */ gimp_object_take_name (GIMP_OBJECT (preset_tool->tool_options), options_name); if (tool_change) gimp_context_set_tool (user_context, preset_tool); else tool_manager_connect_options (tool_manager, user_context, preset_tool); gimp_context_copy_properties (GIMP_CONTEXT (preset->tool_options), user_context, gimp_tool_preset_get_prop_mask (preset)); if (GIMP_IS_PAINT_OPTIONS (preset->tool_options)) { GimpCoreConfig *config = user_context->gimp->config; GimpToolOptions *src = preset->tool_options; GimpToolOptions *dest = tool_manager->active_tool->tool_info->tool_options; /* if connect_options() did overwrite the brush options and the * preset contains a brush, use the brush options from the * preset */ if (config->global_brush && preset->use_brush) gimp_paint_options_copy_brush_props (GIMP_PAINT_OPTIONS (src), GIMP_PAINT_OPTIONS (dest)); if (config->global_dynamics && preset->use_dynamics) gimp_paint_options_copy_dynamics_props (GIMP_PAINT_OPTIONS (src), GIMP_PAINT_OPTIONS (dest)); if (config->global_gradient && preset->use_gradient) gimp_paint_options_copy_gradient_props (GIMP_PAINT_OPTIONS (src), GIMP_PAINT_OPTIONS (dest)); } }
static void gimp_device_info_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { GimpDeviceInfo *info = GIMP_DEVICE_INFO (object); GdkDevice *device = info->device; GimpCurve *src_curve = NULL; GimpCurve *dest_curve = NULL; switch (property_id) { case PROP_DEVICE: info->device = g_value_get_object (value); break; case PROP_DISPLAY: info->display = g_value_get_object (value); break; case PROP_MODE: gimp_device_info_set_mode (info, g_value_get_enum (value)); break; case PROP_AXES: { GimpValueArray *array = g_value_get_boxed (value); if (array) { gint i; gint n_device_values; if (device) { n_device_values = MIN (gimp_value_array_length (array), device->num_axes); } else { n_device_values = gimp_value_array_length (array); info->n_axes = n_device_values; info->axes = g_renew (GdkAxisUse, info->axes, info->n_axes); memset (info->axes, 0, info->n_axes * sizeof (GdkAxisUse)); } for (i = 0; i < n_device_values; i++) { GdkAxisUse axis_use; axis_use = g_value_get_enum (gimp_value_array_index (array, i)); gimp_device_info_set_axis_use (info, i, axis_use); } } } break; case PROP_KEYS: { GimpValueArray *array = g_value_get_boxed (value); if (array) { gint i; gint n_device_values; if (device) { n_device_values = MIN (gimp_value_array_length (array), device->num_keys); } else { n_device_values = gimp_value_array_length (array); info->n_keys = n_device_values; info->keys = g_renew (GdkDeviceKey, info->keys, info->n_keys); memset (info->keys, 0, info->n_keys * sizeof (GdkDeviceKey)); } for (i = 0; i < n_device_values; i++) { const gchar *accel; guint keyval; GdkModifierType modifiers; accel = g_value_get_string (gimp_value_array_index (array, i)); gtk_accelerator_parse (accel, &keyval, &modifiers); gimp_device_info_set_key (info, i, keyval, modifiers); } } } break; case PROP_PRESSURE_CURVE: src_curve = g_value_get_object (value); dest_curve = info->pressure_curve; break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; } if (src_curve && dest_curve) { gimp_config_copy (GIMP_CONFIG (src_curve), GIMP_CONFIG (dest_curve), GIMP_CONFIG_PARAM_SERIALIZE); } }