gboolean gimp_tools_clear (Gimp *gimp, GError **error) { GList *list; gboolean success = TRUE; g_return_val_if_fail (GIMP_IS_GIMP (gimp), FALSE); for (list = gimp_get_tool_info_iter (gimp); list && success; list = g_list_next (list)) { GimpToolInfo *tool_info = GIMP_TOOL_INFO (list->data); success = gimp_tool_options_delete (tool_info->tool_options, NULL); } if (success) success = gimp_contexts_clear (gimp, error); if (success) tool_options_deleted = TRUE; return success; }
static gchar * gimp_tool_info_get_description (GimpViewable *viewable, gchar **tooltip) { GimpToolInfo *tool_info = GIMP_TOOL_INFO (viewable); return g_strdup (tool_info->blurb); }
static void gimp_toolbox_drop_tool (GtkWidget *widget, gint x, gint y, GimpViewable *viewable, gpointer data) { GimpContext *context = GIMP_CONTEXT (data); if (context->gimp->busy) return; gimp_context_set_tool (context, GIMP_TOOL_INFO (viewable)); }
void gimp_tools_save (Gimp *gimp, gboolean save_tool_options, gboolean always_save) { GFile *file; g_return_if_fail (GIMP_IS_GIMP (gimp)); if (save_tool_options && (! tool_options_deleted || always_save)) { GList *list; GError *error = NULL; if (! gimp_contexts_save (gimp, &error)) { gimp_message_literal (gimp, NULL, GIMP_MESSAGE_WARNING, error->message); g_clear_error (&error); } gimp_tool_options_create_folder (); for (list = gimp_get_tool_info_iter (gimp); list; list = g_list_next (list)) { GimpToolInfo *tool_info = GIMP_TOOL_INFO (list->data); gimp_tool_options_serialize (tool_info->tool_options, NULL); } } file = gimp_directory_file ("toolrc", NULL); if (gimp->be_verbose) g_print ("Writing '%s'\n", gimp_file_get_utf8_name (file)); gimp_config_serialize_to_gfile (GIMP_CONFIG (gimp->tool_info_list), file, "GIMP toolrc", "end of toolrc", NULL, NULL); g_object_unref (file); }
static void gimp_tool_info_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { GimpToolInfo *tool_info = GIMP_TOOL_INFO (object); switch (property_id) { case PROP_VISIBLE: tool_info->visible = g_value_get_boolean (value); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; } }
static void gimp_tool_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { GimpTool *tool = GIMP_TOOL (object); switch (property_id) { case PROP_TOOL_INFO: tool->tool_info = GIMP_TOOL_INFO (g_value_dup_object (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; } }
void gimp_device_info_set_default_tool (GimpDeviceInfo *info) { g_return_if_fail (GIMP_IS_DEVICE_INFO (info)); if (info->device && gdk_device_get_source (info->device) == GDK_SOURCE_ERASER) { GimpContainer *tools = GIMP_CONTEXT (info)->gimp->tool_info_list; GimpToolInfo *eraser; eraser = GIMP_TOOL_INFO (gimp_container_get_child_by_name (tools, "gimp-eraser-tool")); if (eraser) gimp_context_set_tool (GIMP_CONTEXT (info), eraser); } }
static void gimp_tool_info_dispose (GObject *object) { GimpToolInfo *tool_info = GIMP_TOOL_INFO (object); if (tool_info->tool_options) { g_object_run_dispose (G_OBJECT (tool_info->tool_options)); g_object_unref (tool_info->tool_options); tool_info->tool_options = NULL; } if (tool_info->presets) { g_object_unref (tool_info->presets); tool_info->presets = NULL; } G_OBJECT_CLASS (parent_class)->dispose (object); }
static void gimp_tool_info_finalize (GObject *object) { GimpToolInfo *tool_info = GIMP_TOOL_INFO (object); if (tool_info->blurb) { g_free (tool_info->blurb); tool_info->blurb = NULL; } if (tool_info->help) { g_free (tool_info->help); tool_info->help = NULL; } if (tool_info->menu_label) { g_free (tool_info->menu_label); tool_info->menu_label = NULL; } if (tool_info->menu_accel) { g_free (tool_info->menu_accel); tool_info->menu_accel = NULL; } if (tool_info->help_domain) { g_free (tool_info->help_domain); tool_info->help_domain = NULL; } if (tool_info->help_id) { g_free (tool_info->help_id); tool_info->help_id = NULL; } G_OBJECT_CLASS (parent_class)->finalize (object); }
void gimp_tools_restore (Gimp *gimp) { GimpContainer *gimp_list; GimpObject *object; GFile *file; GList *list; GError *error = NULL; g_return_if_fail (GIMP_IS_GIMP (gimp)); gimp_list = gimp_list_new (GIMP_TYPE_TOOL_INFO, FALSE); file = gimp_directory_file ("toolrc", NULL); if (gimp->be_verbose) g_print ("Parsing '%s'\n", gimp_file_get_utf8_name (file)); if (gimp_config_deserialize_gfile (GIMP_CONFIG (gimp_list), file, NULL, NULL)) { gint n = gimp_container_get_n_children (gimp->tool_info_list); gint i; gimp_list_reverse (GIMP_LIST (gimp_list)); for (list = GIMP_LIST (gimp_list)->list, i = 0; list; list = g_list_next (list), i++) { const gchar *name; name = gimp_object_get_name (list->data); object = gimp_container_get_child_by_name (gimp->tool_info_list, name); if (object) { g_object_set (object, "visible", GIMP_TOOL_INFO (list->data)->visible, NULL); gimp_container_reorder (gimp->tool_info_list, object, MIN (i, n - 1)); } } } g_object_unref (file); g_object_unref (gimp_list); /* make the generic operation tool invisible by default */ object = gimp_container_get_child_by_name (gimp->tool_info_list, "gimp-operation-tool"); if (object) g_object_set (object, "visible", FALSE, NULL); for (list = gimp_get_tool_info_iter (gimp); list; list = g_list_next (list)) { GimpToolInfo *tool_info = GIMP_TOOL_INFO (list->data); /* get default values from prefs (see bug #120832) */ gimp_config_reset (GIMP_CONFIG (tool_info->tool_options)); } if (! gimp_contexts_load (gimp, &error)) { gimp_message_literal (gimp, NULL, GIMP_MESSAGE_WARNING, error->message); g_clear_error (&error); } /* make sure there is always a tool active, so broken config files * can't leave us with no initial tool */ if (! gimp_context_get_tool (gimp_get_user_context (gimp))) { gimp_context_set_tool (gimp_get_user_context (gimp), gimp_get_tool_info_iter (gimp)->data); } for (list = gimp_get_tool_info_iter (gimp); list; list = g_list_next (list)) { GimpToolInfo *tool_info = GIMP_TOOL_INFO (list->data); GimpToolOptionsGUIFunc options_gui_func; GtkWidget *options_gui; /* copy all context properties except those the tool actually * uses, because the subsequent deserialize() on the tool * options will only set the properties that were set to * non-default values at the time of saving, and we want to * keep these default values as if they have been saved. * (see bug #541586). */ gimp_context_copy_properties (gimp_get_user_context (gimp), GIMP_CONTEXT (tool_info->tool_options), GIMP_CONTEXT_PROP_MASK_ALL &~ (tool_info->context_props | GIMP_CONTEXT_PROP_MASK_TOOL | GIMP_CONTEXT_PROP_MASK_PAINT_INFO)); gimp_tool_options_deserialize (tool_info->tool_options, NULL); options_gui_func = g_object_get_data (G_OBJECT (tool_info), "gimp-tool-options-gui-func"); if (options_gui_func) { options_gui = (* options_gui_func) (tool_info->tool_options); } else { GtkWidget *label; options_gui = gimp_tool_options_gui (tool_info->tool_options); label = gtk_label_new (_("This tool has\nno options.")); gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_CENTER); gimp_label_set_attributes (GTK_LABEL (label), PANGO_ATTR_STYLE, PANGO_STYLE_ITALIC, -1); gtk_box_pack_start (GTK_BOX (options_gui), label, FALSE, FALSE, 6); gtk_widget_show (label); } gimp_tools_set_tool_options_gui (tool_info->tool_options, g_object_ref_sink (options_gui)); } }