app: make the MyPaint brush path configurable in Prefs -> Folders

Keep the config values around even if compiled without MyPaint brush
support, so we remember the values between sessions of differently
compiled GIMP versions.
This commit is contained in:
Michael Natterer 2015-04-25 21:12:19 -04:00
parent 5eaf8045ec
commit 9d510d8fff
7 changed files with 106 additions and 9 deletions

View File

@ -10,6 +10,7 @@ libgimpthumb = $(top_builddir)/libgimpthumb/libgimpthumb-$(GIMP_API_VERSION).la
AM_CPPFLAGS = \
-DG_LOG_DOMAIN=\"Gimp-Config\" \
-DGIMP_APP_VERSION_STRING=\"$(GIMP_APP_VERSION)\" \
-DDATADIR=\""$(datadir)"\" \
-I$(top_builddir) \
-I$(top_srcdir) \
-I$(top_builddir)/app \

View File

@ -41,14 +41,15 @@
#include "gimp-intl.h"
#define DEFAULT_BRUSH "Round Fuzzy"
#define DEFAULT_DYNAMICS "Dynamics Off"
#define DEFAULT_PATTERN "Pine"
#define DEFAULT_PALETTE "Default"
#define DEFAULT_GRADIENT "FG to BG (RGB)"
#define DEFAULT_TOOL_PRESET "Current Options"
#define DEFAULT_FONT "Sans"
#define DEFAULT_COMMENT "Created with GIMP"
#define DEFAULT_BRUSH "Round Fuzzy"
#define DEFAULT_DYNAMICS "Dynamics Off"
#define DEFAULT_PATTERN "Pine"
#define DEFAULT_PALETTE "Default"
#define DEFAULT_GRADIENT "FG to BG (RGB)"
#define DEFAULT_TOOL_PRESET "Current Options"
#define DEFAULT_FONT "Sans"
#define DEFAULT_MYPAINT_BRUSH "Fixme"
#define DEFAULT_COMMENT "Created with GIMP"
enum
@ -75,6 +76,8 @@ enum
PROP_TOOL_PRESET_PATH_WRITABLE,
PROP_FONT_PATH,
PROP_FONT_PATH_WRITABLE,
PROP_MYPAINT_BRUSH_PATH,
PROP_MYPAINT_BRUSH_PATH_WRITABLE,
PROP_DEFAULT_BRUSH,
PROP_DEFAULT_DYNAMICS,
PROP_DEFAULT_PATTERN,
@ -82,6 +85,7 @@ enum
PROP_DEFAULT_GRADIENT,
PROP_DEFAULT_TOOL_PRESET,
PROP_DEFAULT_FONT,
PROP_DEFAULT_MYPAINT_BRUSH,
PROP_GLOBAL_BRUSH,
PROP_GLOBAL_DYNAMICS,
PROP_GLOBAL_PATTERN,
@ -140,6 +144,8 @@ gimp_core_config_class_init (GimpCoreConfigClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
gchar *path;
gchar *dir1;
gchar *dir2;
GimpRGB red = { 1.0, 0, 0, 0.5 };
guint64 undo_size;
@ -310,6 +316,38 @@ gimp_core_config_class_init (GimpCoreConfigClass *klass)
GIMP_CONFIG_PATH_DIR_LIST, NULL,
GIMP_PARAM_STATIC_STRINGS |
GIMP_CONFIG_PARAM_IGNORE);
/* FIXME */
dir1 = g_build_filename (DATADIR, "mypaint", "brushes", NULL);
dir2 = g_build_filename (g_get_user_data_dir (), "mypaint", "brushes", NULL);
path = g_build_path (G_SEARCHPATH_SEPARATOR_S,
"/usr/share/mypaint/brushes",
"/usr/local/share/mypaint/brushes",
dir1,
dir2,
"~/.mypaint/brushes",
NULL);
GIMP_CONFIG_INSTALL_PROP_PATH (object_class, PROP_MYPAINT_BRUSH_PATH,
"mypaint-brush-path", MYPAINT_BRUSH_PATH_BLURB,
GIMP_CONFIG_PATH_DIR_LIST, path,
GIMP_PARAM_STATIC_STRINGS |
GIMP_CONFIG_PARAM_RESTART);
g_free (path);
g_free (dir1);
/* FIXME */
path = g_build_path (G_SEARCHPATH_SEPARATOR_S,
dir2,
"~/.mypaint/brushes",
NULL);
GIMP_CONFIG_INSTALL_PROP_PATH (object_class, PROP_MYPAINT_BRUSH_PATH_WRITABLE,
"mypaint-brush-path-writable", NULL,
GIMP_CONFIG_PATH_DIR_LIST, path,
GIMP_PARAM_STATIC_STRINGS |
GIMP_CONFIG_PARAM_RESTART);
g_free (path);
g_free (dir2);
GIMP_CONFIG_INSTALL_PROP_STRING (object_class, PROP_DEFAULT_BRUSH,
"default-brush", DEFAULT_BRUSH_BLURB,
DEFAULT_BRUSH,
@ -338,6 +376,11 @@ gimp_core_config_class_init (GimpCoreConfigClass *klass)
"default-font", DEFAULT_FONT_BLURB,
DEFAULT_FONT,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_INSTALL_PROP_STRING (object_class, PROP_DEFAULT_MYPAINT_BRUSH,
"default-mypaint-brush", DEFAULT_MYPAINT_BRUSH_BLURB,
DEFAULT_MYPAINT_BRUSH,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_GLOBAL_BRUSH,
"global-brush", GLOBAL_BRUSH_BLURB,
TRUE,
@ -623,6 +666,14 @@ gimp_core_config_set_property (GObject *object,
g_free (core_config->font_path_writable);
core_config->font_path_writable = g_value_dup_string (value);
break;
case PROP_MYPAINT_BRUSH_PATH:
g_free (core_config->mypaint_brush_path);
core_config->mypaint_brush_path = g_value_dup_string (value);
break;
case PROP_MYPAINT_BRUSH_PATH_WRITABLE:
g_free (core_config->mypaint_brush_path_writable);
core_config->mypaint_brush_path_writable = g_value_dup_string (value);
break;
case PROP_DEFAULT_BRUSH:
g_free (core_config->default_brush);
core_config->default_brush = g_value_dup_string (value);
@ -651,6 +702,10 @@ gimp_core_config_set_property (GObject *object,
g_free (core_config->default_font);
core_config->default_font = g_value_dup_string (value);
break;
case PROP_DEFAULT_MYPAINT_BRUSH:
g_free (core_config->default_mypaint_brush);
core_config->default_mypaint_brush = g_value_dup_string (value);
break;
case PROP_GLOBAL_BRUSH:
core_config->global_brush = g_value_get_boolean (value);
break;
@ -806,6 +861,12 @@ gimp_core_config_get_property (GObject *object,
case PROP_FONT_PATH_WRITABLE:
g_value_set_string (value, core_config->font_path_writable);
break;
case PROP_MYPAINT_BRUSH_PATH:
g_value_set_string (value, core_config->mypaint_brush_path);
break;
case PROP_MYPAINT_BRUSH_PATH_WRITABLE:
g_value_set_string (value, core_config->mypaint_brush_path_writable);
break;
case PROP_DEFAULT_BRUSH:
g_value_set_string (value, core_config->default_brush);
break;
@ -827,6 +888,9 @@ gimp_core_config_get_property (GObject *object,
case PROP_DEFAULT_FONT:
g_value_set_string (value, core_config->default_font);
break;
case PROP_DEFAULT_MYPAINT_BRUSH:
g_value_set_string (value, core_config->default_mypaint_brush);
break;
case PROP_GLOBAL_BRUSH:
g_value_set_boolean (value, core_config->global_brush);
break;

View File

@ -60,6 +60,8 @@ struct _GimpCoreConfig
gchar *tool_preset_path_writable;
gchar *font_path;
gchar *font_path_writable; /* unused */
gchar *mypaint_brush_path;
gchar *mypaint_brush_path_writable;
gchar *default_brush;
gchar *default_dynamics;
gchar *default_pattern;
@ -67,6 +69,7 @@ struct _GimpCoreConfig
gchar *default_tool_preset;
gchar *default_gradient;
gchar *default_font;
gchar *default_mypaint_brush;
gboolean global_brush;
gboolean global_dynamics;
gboolean global_pattern;

View File

@ -83,6 +83,9 @@ _("When enabled, this will ensure that each pixel of an image gets " \
#define DEFAULT_IMAGE_BLURB \
"Sets the default image in the \"File/New\" dialog."
#define DEFAULT_MYPAINT_BRUSH_BLURB \
"Specify a default MyPaint brush."
#define DEFAULT_PATTERN_BLURB \
"Specify a default pattern."
@ -238,6 +241,11 @@ _("Sets the monitor's vertical resolution, in dots per inch. If set to " \
_("If enabled, the move tool sets the edited layer or path as active. " \
"This used to be the default behaviour in older versions.")
#define MYPAINT_BRUSH_PATH_BLURB \
"Sets the brush search path."
#define MYPAINT_BRUSH_PATH_WRITABLE_BLURB ""
#define NAVIGATION_PREVIEW_SIZE_BLURB \
_("Sets the size of the navigation preview available in the lower right " \
"corner of the image window.")

View File

@ -1256,6 +1256,7 @@ prefs_dialog_new (Gimp *gimp,
GObject *object;
GimpCoreConfig *core_config;
GimpDisplayConfig *display_config;
GimpGuiConfig *gui_config;
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
g_return_val_if_fail (GIMP_IS_CONFIG (config), NULL);
@ -1263,6 +1264,7 @@ prefs_dialog_new (Gimp *gimp,
object = G_OBJECT (config);
core_config = GIMP_CORE_CONFIG (config);
display_config = GIMP_DISPLAY_CONFIG (config);
gui_config = GIMP_GUI_CONFIG (config);
dialog = gimp_dialog_new (_("Preferences"), "gimp-preferences",
NULL, 0,
@ -2638,6 +2640,12 @@ prefs_dialog_new (Gimp *gimp,
GIMP_HELP_PREFS_FOLDERS_TOOL_PRESETS,
N_("Select Tool Preset Folders"),
"tool-preset-path", "tool-preset-path-writable" },
#ifdef HAVE_LIBMYPAINT
{ N_("MyPaint Brushes"), N_("MyPaint Brush Folders"), "folders-mypaint-brushes",
GIMP_HELP_PREFS_FOLDERS_MYPAINT_BRUSHES,
N_("Select MyPaint Brush Folders"),
"mypaint-brush-path", "mypaint-brush-path-writable" },
#endif
{ N_("Plug-Ins"), N_("Plug-In Folders"), "folders-plug-ins",
GIMP_HELP_PREFS_FOLDERS_PLUG_INS,
N_("Select Plug-In Folders"),
@ -2668,6 +2676,14 @@ prefs_dialog_new (Gimp *gimp,
{
GtkWidget *editor;
#ifdef HAVE_LIBMYPAINT
if (! gui_config->playground_mybrush_tool &&
! strcmp (paths[i].path_property_name, "mypaint-brush-path"))
{
continue;
}
#endif
pixbuf = prefs_get_pixbufs (dialog, paths[i].icon, &small_pixbuf);
vbox = gimp_prefs_box_add_page (GIMP_PREFS_BOX (prefs_box),
gettext (paths[i].label),

View File

@ -28,6 +28,10 @@
#include "tools-types.h"
#include "config/gimpcoreconfig.h"
#include "core/gimp.h"
#include "paint/gimpmybrushoptions.h"
#include "widgets/gimppropwidgets.h"
@ -181,7 +185,7 @@ gimp_mybrush_options_gui (GimpToolOptions *tool_options)
model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo));
path = gimp_config_path_expand_to_files ("/usr/share/mypaint/brushes", NULL);
path = gimp_config_path_expand_to_files (GIMP_CONTEXT (config)->gimp->config->mypaint_brush_path, NULL);
for (list = path; list; list = g_list_next (list))
{

View File

@ -484,6 +484,7 @@
#define GIMP_HELP_PREFS_FOLDERS_GRADIENTS "gimp-prefs-folders-gradients"
#define GIMP_HELP_PREFS_FOLDERS_FONTS "gimp-prefs-folders-fonts"
#define GIMP_HELP_PREFS_FOLDERS_TOOL_PRESETS "gimp-prefs-folders-tool-presets"
#define GIMP_HELP_PREFS_FOLDERS_MYPAINT_BRUSHES "gimp-prefs-folders-mypaint-brushes"
#define GIMP_HELP_PREFS_FOLDERS_PLUG_INS "gimp-prefs-folders-plug-ins"
#define GIMP_HELP_PREFS_FOLDERS_SCRIPTS "gimp-prefs-folders-scripts"
#define GIMP_HELP_PREFS_FOLDERS_MODULES "gimp-prefs-folders-modules"