Commit a5eff271 authored by Michael Natterer's avatar Michael Natterer

app: add new GimpData subclass GimpMybrush and infrastructure around it

- GimpContext API and property
- a GimpDataFactory
- List and grid views with GimpDataFactoryView
- actions and a context menu

None of this is connected to the actual tool yet, or depends on
libmypaint in any way.
parent 4f8bc154
......@@ -117,6 +117,8 @@ libappactions_a_SOURCES = \
layers-actions.h \
layers-commands.c \
layers-commands.h \
mypaint-brushes-actions.c \
mypaint-brushes-actions.h \
palette-editor-actions.c \
palette-editor-actions.h \
palette-editor-commands.c \
......
......@@ -76,6 +76,7 @@
#include "image-actions.h"
#include "images-actions.h"
#include "layers-actions.h"
#include "mypaint-brushes-actions.h"
#include "palette-editor-actions.h"
#include "palettes-actions.h"
#include "patterns-actions.h"
......@@ -190,6 +191,9 @@ static const GimpActionFactoryEntry action_groups[] =
{ "layers", N_("Layers"), GIMP_STOCK_LAYER,
layers_actions_setup,
layers_actions_update },
{ "mypaint-brushes", N_("MyPaint Brushes"), GIMP_STOCK_MYPAINT_BRUSH,
mypaint_brushes_actions_setup,
mypaint_brushes_actions_update },
{ "palette-editor", N_("Palette Editor"), GIMP_STOCK_PALETTE,
palette_editor_actions_setup,
palette_editor_actions_update },
......
......@@ -151,6 +151,12 @@ const GimpStringActionEntry dialogs_dockable_actions[] =
"gimp-dynamics-editor",
GIMP_HELP_DYNAMICS_EDITOR_DIALOG },
{ "dialogs-mypaint-brushes", GIMP_STOCK_MYPAINT_BRUSH,
NC_("dialogs-action", "_MyPaint Brushes"), "<primary><shift>Y",
NC_("dialogs-action", "Open the mypaint brushes dialog"),
"gimp-mypaint-brush-grid|gimp-mapyint-brush-list",
GIMP_HELP_MYPAINT_BRUSH_DIALOG },
{ "dialogs-patterns", GIMP_STOCK_PATTERN,
NC_("dialogs-action", "P_atterns"), "<primary><shift>P",
NC_("dialogs-action", "Open the patterns dialog"),
......
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
#include "actions-types.h"
#include "core/gimpcontext.h"
#include "core/gimpmybrush.h"
#include "widgets/gimpactiongroup.h"
#include "widgets/gimphelp-ids.h"
#include "actions.h"
#include "data-commands.h"
#include "mypaint-brushes-actions.h"
#include "gimp-intl.h"
static const GimpActionEntry mypaint_brushes_actions[] =
{
{ "mypaint-brushes-popup", GIMP_STOCK_MYPAINT_BRUSH,
NC_("mypaint-brushes-action", "MyPaint Brushes Menu"), NULL, NULL, NULL,
GIMP_HELP_MYPAINT_BRUSH_DIALOG },
{ "mypaint-brushes-new", "document-new",
NC_("mypaint-brushes-action", "_New MyPaint Brush"), NULL,
NC_("mypaint-brushes-action", "Create a new MyPaint brush"),
G_CALLBACK (data_new_cmd_callback),
GIMP_HELP_MYPAINT_BRUSH_NEW },
{ "mypaint-brushes-duplicate", GIMP_STOCK_DUPLICATE,
NC_("mypaint-brushes-action", "D_uplicate MyPaint Brush"), NULL,
NC_("mypaint-brushes-action", "Duplicate this MyPaint brush"),
G_CALLBACK (data_duplicate_cmd_callback),
GIMP_HELP_MYPAINT_BRUSH_DUPLICATE },
{ "mypaint-brushes-copy-location", "edit-copy",
NC_("mypaint-brushes-action", "Copy MyPaint Brush _Location"), NULL,
NC_("mypaint-brushes-action", "Copy MyPaint brush file location to clipboard"),
G_CALLBACK (data_copy_location_cmd_callback),
GIMP_HELP_MYPAINT_BRUSH_COPY_LOCATION },
{ "mypaint-brushes-show-in-file-manager", "gtk-directory",
NC_("mypaint-brushes-action", "Show in _File Manager"), NULL,
NC_("mypaint-brushes-action", "Show MyPaint brush file location in the file manager"),
G_CALLBACK (data_show_in_file_manager_cmd_callback),
GIMP_HELP_MYPAINT_BRUSH_SHOW_IN_FILE_MANAGER },
{ "mypaint-brushes-delete", "edit-delete",
NC_("mypaint-brushes-action", "_Delete MyPaint Brush"), NULL,
NC_("mypaint-brushes-action", "Delete this MyPaint brush"),
G_CALLBACK (data_delete_cmd_callback),
GIMP_HELP_MYPAINT_BRUSH_DELETE },
{ "mypaint-brushes-refresh", "view-refresh",
NC_("mypaint-brushes-action", "_Refresh MyPaint Brushes"), NULL,
NC_("mypaint-brushes-action", "Refresh MyPaint brushes"),
G_CALLBACK (data_refresh_cmd_callback),
GIMP_HELP_MYPAINT_BRUSH_REFRESH }
};
static const GimpStringActionEntry mypaint_brushes_edit_actions[] =
{
{ "mypaint-brushes-edit", "gtk-edit",
NC_("mypaint-brushes-action", "_Edit MyPaint Brush..."), NULL,
NC_("mypaint-bruahes-action", "Edit MyPaint brush"),
"gimp-mypaint-bruah-editor",
GIMP_HELP_MYPAINT_BRUSH_EDIT }
};
void
mypaint_brushes_actions_setup (GimpActionGroup *group)
{
gimp_action_group_add_actions (group, "mypaint-brushes-action",
mypaint_brushes_actions,
G_N_ELEMENTS (mypaint_brushes_actions));
gimp_action_group_add_string_actions (group, "mypaint-brushes-action",
mypaint_brushes_edit_actions,
G_N_ELEMENTS (mypaint_brushes_edit_actions),
G_CALLBACK (data_edit_cmd_callback));
}
void
mypaint_brushes_actions_update (GimpActionGroup *group,
gpointer user_data)
{
GimpContext *context = action_data_get_context (user_data);
GimpMybrush *brush = NULL;
GimpData *data = NULL;
GFile *file = NULL;
if (context)
{
brush = gimp_context_get_mybrush (context);
if (action_data_sel_count (user_data) > 1)
{
brush = NULL;
}
if (brush)
{
data = GIMP_DATA (brush);
file = gimp_data_get_file (data);
}
}
#define SET_SENSITIVE(action,condition) \
gimp_action_group_set_action_sensitive (group, action, (condition) != 0)
SET_SENSITIVE ("mypaint-brushes-edit", brush && FALSE);
SET_SENSITIVE ("mypaint-brushes-duplicate", brush && GIMP_DATA_GET_CLASS (data)->duplicate);
SET_SENSITIVE ("mypaint-brushes-copy-location", file);
SET_SENSITIVE ("mypaint-brushes-show-in-file-manager", file);
SET_SENSITIVE ("mypaint-brushes-delete", brush && gimp_data_is_deletable (data));
#undef SET_SENSITIVE
}
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __MYPAINT_BRUSHES_ACTIONS_H__
#define __MYPAINT_BRUSHES_ACTIONS_H__
void mypaint_brushes_actions_setup (GimpActionGroup *group);
void mypaint_brushes_actions_update (GimpActionGroup *group,
gpointer data);
#endif /* __MYPAINT_BRUSHES_ACTIONS_H__ */
......@@ -302,6 +302,10 @@ libappcore_a_sources = \
gimplist.h \
gimpmaskundo.c \
gimpmaskundo.h \
gimpmybrush.c \
gimpmybrush.h \
gimpmybrush-load.c \
gimpmybrush-load.h \
gimpobject.c \
gimpobject.h \
gimppaintinfo.c \
......
......@@ -556,14 +556,15 @@ typedef enum /*< pdb-skip, skip >*/
GIMP_CONTEXT_PROP_PAINT_MODE = 9,
GIMP_CONTEXT_PROP_BRUSH = 10,
GIMP_CONTEXT_PROP_DYNAMICS = 11,
GIMP_CONTEXT_PROP_PATTERN = 12,
GIMP_CONTEXT_PROP_GRADIENT = 13,
GIMP_CONTEXT_PROP_PALETTE = 14,
GIMP_CONTEXT_PROP_TOOL_PRESET = 15,
GIMP_CONTEXT_PROP_FONT = 16,
GIMP_CONTEXT_PROP_BUFFER = 17,
GIMP_CONTEXT_PROP_IMAGEFILE = 18,
GIMP_CONTEXT_PROP_TEMPLATE = 19,
GIMP_CONTEXT_PROP_MYBRUSH = 12,
GIMP_CONTEXT_PROP_PATTERN = 13,
GIMP_CONTEXT_PROP_GRADIENT = 14,
GIMP_CONTEXT_PROP_PALETTE = 15,
GIMP_CONTEXT_PROP_TOOL_PRESET = 16,
GIMP_CONTEXT_PROP_FONT = 17,
GIMP_CONTEXT_PROP_BUFFER = 18,
GIMP_CONTEXT_PROP_IMAGEFILE = 19,
GIMP_CONTEXT_PROP_TEMPLATE = 20,
GIMP_CONTEXT_PROP_LAST = GIMP_CONTEXT_PROP_TEMPLATE
} GimpContextPropType;
......@@ -581,14 +582,15 @@ typedef enum /*< pdb-skip, skip >*/
GIMP_CONTEXT_PROP_MASK_PAINT_MODE = 1 << 9,
GIMP_CONTEXT_PROP_MASK_BRUSH = 1 << 10,
GIMP_CONTEXT_PROP_MASK_DYNAMICS = 1 << 11,
GIMP_CONTEXT_PROP_MASK_PATTERN = 1 << 12,
GIMP_CONTEXT_PROP_MASK_GRADIENT = 1 << 13,
GIMP_CONTEXT_PROP_MASK_PALETTE = 1 << 14,
GIMP_CONTEXT_PROP_MASK_TOOL_PRESET = 1 << 15,
GIMP_CONTEXT_PROP_MASK_FONT = 1 << 16,
GIMP_CONTEXT_PROP_MASK_BUFFER = 1 << 17,
GIMP_CONTEXT_PROP_MASK_IMAGEFILE = 1 << 18,
GIMP_CONTEXT_PROP_MASK_TEMPLATE = 1 << 19,
GIMP_CONTEXT_PROP_MASK_MYBRUSH = 1 << 12,
GIMP_CONTEXT_PROP_MASK_PATTERN = 1 << 13,
GIMP_CONTEXT_PROP_MASK_GRADIENT = 1 << 14,
GIMP_CONTEXT_PROP_MASK_PALETTE = 1 << 15,
GIMP_CONTEXT_PROP_MASK_TOOL_PRESET = 1 << 16,
GIMP_CONTEXT_PROP_MASK_FONT = 1 << 17,
GIMP_CONTEXT_PROP_MASK_BUFFER = 1 << 18,
GIMP_CONTEXT_PROP_MASK_IMAGEFILE = 1 << 19,
GIMP_CONTEXT_PROP_MASK_TEMPLATE = 1 << 20,
/* aliases */
GIMP_CONTEXT_PROP_MASK_PAINT = (GIMP_CONTEXT_PROP_MASK_FOREGROUND |
......@@ -604,6 +606,7 @@ typedef enum /*< pdb-skip, skip >*/
GIMP_CONTEXT_PROP_MASK_DISPLAY |
GIMP_CONTEXT_PROP_MASK_TOOL |
GIMP_CONTEXT_PROP_MASK_PAINT_INFO |
GIMP_CONTEXT_PROP_MASK_MYBRUSH |
GIMP_CONTEXT_PROP_MASK_PALETTE |
GIMP_CONTEXT_PROP_MASK_FONT |
GIMP_CONTEXT_PROP_MASK_BUFFER |
......
......@@ -133,6 +133,7 @@ typedef struct _GimpCurve GimpCurve;
typedef struct _GimpDynamics GimpDynamics;
typedef struct _GimpDynamicsOutput GimpDynamicsOutput;
typedef struct _GimpGradient GimpGradient;
typedef struct _GimpMybrush GimpMybrush;
typedef struct _GimpPalette GimpPalette;
typedef struct _GimpPaletteMru GimpPaletteMru;
typedef struct _GimpPattern GimpPattern;
......
......@@ -70,6 +70,8 @@
#include "gimpimagefile.h"
#include "gimplist.h"
#include "gimpmarshal.h"
#include "gimpmybrush-load.h"
#include "gimpmybrush.h"
#include "gimppalette-load.h"
#include "gimppalette.h"
#include "gimpparasitelist.h"
......@@ -331,6 +333,9 @@ gimp_dispose (GObject *object)
if (gimp->dynamics_factory)
gimp_data_factory_data_free (gimp->dynamics_factory);
if (gimp->mybrush_factory)
gimp_data_factory_data_free (gimp->mybrush_factory);
if (gimp->pattern_factory)
gimp_data_factory_data_free (gimp->pattern_factory);
......@@ -359,6 +364,8 @@ gimp_finalize (GObject *object)
gimp_brush_get_standard (gimp->user_context));
standards = g_list_prepend (standards,
gimp_dynamics_get_standard (gimp->user_context));
standards = g_list_prepend (standards,
gimp_mybrush_get_standard (gimp->user_context));
standards = g_list_prepend (standards,
gimp_pattern_get_standard (gimp->user_context));
standards = g_list_prepend (standards,
......@@ -416,6 +423,12 @@ gimp_finalize (GObject *object)
gimp->dynamics_factory = NULL;
}
if (gimp->mybrush_factory)
{
g_object_unref (gimp->mybrush_factory);
gimp->mybrush_factory = NULL;
}
if (gimp->pattern_factory)
{
g_object_unref (gimp->pattern_factory);
......@@ -580,6 +593,8 @@ gimp_get_memsize (GimpObject *object,
gui_size);
memsize += gimp_object_get_memsize (GIMP_OBJECT (gimp->dynamics_factory),
gui_size);
memsize += gimp_object_get_memsize (GIMP_OBJECT (gimp->mybrush_factory),
gui_size);
memsize += gimp_object_get_memsize (GIMP_OBJECT (gimp->pattern_factory),
gui_size);
memsize += gimp_object_get_memsize (GIMP_OBJECT (gimp->gradient_factory),
......@@ -635,6 +650,11 @@ gimp_real_initialize (Gimp *gimp,
{ gimp_dynamics_load, GIMP_DYNAMICS_FILE_EXTENSION, TRUE }
};
static const GimpDataFactoryLoaderEntry mybrush_loader_entries[] =
{
{ gimp_mybrush_load, GIMP_MYBRUSH_FILE_EXTENSION, FALSE }
};
static const GimpDataFactoryLoaderEntry pattern_loader_entries[] =
{
{ gimp_pattern_load, GIMP_PATTERN_FILE_EXTENSION, FALSE },
......@@ -689,6 +709,17 @@ gimp_real_initialize (Gimp *gimp,
gimp_object_set_static_name (GIMP_OBJECT (gimp->dynamics_factory),
"dynamics factory");
gimp->mybrush_factory =
gimp_data_factory_new (gimp,
GIMP_TYPE_MYBRUSH,
"mypaint-brush-path", "mypaint-brush-path-writable",
mybrush_loader_entries,
G_N_ELEMENTS (mybrush_loader_entries),
NULL,
NULL);
gimp_object_set_static_name (GIMP_OBJECT (gimp->mybrush_factory),
"mypaint brush factory");
gimp->pattern_factory =
gimp_data_factory_new (gimp,
GIMP_TYPE_PATTERN,
......@@ -813,6 +844,7 @@ gimp_real_exit (Gimp *gimp,
gimp_data_factory_data_save (gimp->brush_factory);
gimp_data_factory_data_save (gimp->dynamics_factory);
gimp_data_factory_data_save (gimp->mybrush_factory);
gimp_data_factory_data_save (gimp->pattern_factory);
gimp_data_factory_data_save (gimp->gradient_factory);
gimp_data_factory_data_save (gimp->palette_factory);
......@@ -1055,6 +1087,11 @@ gimp_restore (Gimp *gimp,
gimp_data_factory_data_init (gimp->dynamics_factory, gimp->user_context,
gimp->no_data);
/* initialize the list of mypaint brushes */
status_callback (NULL, _("MyPaint Brushes"), 0.25);
gimp_data_factory_data_init (gimp->mybrush_factory, gimp->user_context,
gimp->no_data);
/* initialize the list of gimp patterns */
status_callback (NULL, _("Patterns"), 0.3);
gimp_data_factory_data_init (gimp->pattern_factory, gimp->user_context,
......@@ -1101,6 +1138,8 @@ gimp_restore (Gimp *gimp,
gimp_data_factory_get_container (gimp->brush_factory));
gimp_tag_cache_add_container (gimp->tag_cache,
gimp_data_factory_get_container (gimp->dynamics_factory));
gimp_tag_cache_add_container (gimp->tag_cache,
gimp_data_factory_get_container (gimp->mybrush_factory));
gimp_tag_cache_add_container (gimp->tag_cache,
gimp_data_factory_get_container (gimp->pattern_factory));
gimp_tag_cache_add_container (gimp->tag_cache,
......@@ -1118,6 +1157,7 @@ gimp_restore (Gimp *gimp,
*/
gimp_data_factory_data_clean (gimp->brush_factory);
gimp_data_factory_data_clean (gimp->dynamics_factory);
gimp_data_factory_data_clean (gimp->mybrush_factory);
gimp_data_factory_data_clean (gimp->pattern_factory);
gimp_data_factory_data_clean (gimp->palette_factory);
gimp_data_factory_data_clean (gimp->gradient_factory);
......
......@@ -94,6 +94,7 @@ struct _Gimp
GimpDataFactory *brush_factory;
GimpDataFactory *dynamics_factory;
GimpDataFactory *mybrush_factory;
GimpDataFactory *pattern_factory;
GimpDataFactory *gradient_factory;
GimpDataFactory *palette_factory;
......
This diff is collapsed.
......@@ -76,6 +76,9 @@ struct _GimpContext
GimpDynamics *dynamics;
gchar *dynamics_name;
GimpMybrush *mybrush;
gchar *mybrush_name;
GimpPattern *pattern;
gchar *pattern_name;
......@@ -127,6 +130,8 @@ struct _GimpContextClass
GimpBrush *brush);
void (* dynamics_changed) (GimpContext *context,
GimpDynamics *dynamics);
void (* mybrush_changed) (GimpContext *context,
GimpMybrush *brush);
void (* pattern_changed) (GimpContext *context,
GimpPattern *pattern);
void (* gradient_changed) (GimpContext *context,
......@@ -299,6 +304,13 @@ void gimp_context_set_dynamics (GimpContext *context,
void gimp_context_dynamics_changed (GimpContext *context);
/* mybrush */
GimpMybrush * gimp_context_get_mybrush (GimpContext *context);
void gimp_context_set_mybrush (GimpContext *context,
GimpMybrush *brush);
void gimp_context_mybrush_changed (GimpContext *context);
/* pattern */
GimpPattern * gimp_context_get_pattern (GimpContext *context);
void gimp_context_set_pattern (GimpContext *context,
......
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpbrush-load.c
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gegl.h>
#include "libgimpbase/gimpbase.h"
#include "core-types.h"
#include "gimpmybrush.h"
#include "gimpmybrush-load.h"
#include "gimp-intl.h"
/* public functions */
GList *
gimp_mybrush_load (GimpContext *context,
GFile *file,
GInputStream *input,
GError **error)
{
GimpBrush *brush = NULL;
GdkPixbuf *pixbuf;
gchar *path;
gchar *basename;
gchar *preview_filename;
g_return_val_if_fail (G_IS_FILE (file), NULL);
g_return_val_if_fail (G_IS_INPUT_STREAM (input), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
path = g_file_get_path (file);
basename = g_strndup (path, strlen (path) - 4);
g_free (path);
preview_filename = g_strconcat (basename, "_prev.png", NULL);
g_free (basename);
pixbuf = gdk_pixbuf_new_from_file_at_size (preview_filename,
48, 48, NULL);
if (pixbuf)
{
basename = g_file_get_basename (file);
brush = g_object_new (GIMP_TYPE_MYBRUSH,
"name", gimp_filename_to_utf8 (basename),
"mime-type", "image/x-gimp-myb",
"icon-pixbuf", pixbuf,
NULL);
g_free (basename);
g_object_unref (pixbuf);
}
g_free (preview_filename);
if (! brush)
return NULL;
return g_list_prepend (NULL, brush);
}
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GIMP_MYBRUSH_LOAD_H__
#define __GIMP_MYBRUSH_LOAD_H__
#define GIMP_MYBRUSH_FILE_EXTENSION ".myb"
GList * gimp_mybrush_load (GimpContext *context,
GFile *file,
GInputStream *input,
GError **error);
#endif /* __GIMP_MYBRUSH_LOAD_H__ */
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <cairo.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gegl.h>
#include "core-types.h"
#include "gimpmybrush.h"
#include "gimpmybrush-load.h"
#include "gimptagged.h"
#include "gimp-intl.h"
struct _GimpMybrushPrivate
{
gpointer dummy;
};
static void gimp_mybrush_tagged_iface_init (GimpTaggedInterface *iface);
static void gimp_mybrush_finalize (GObject *object);
static void gimp_mybrush_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_mybrush_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static gint64 gimp_mybrush_get_memsize (GimpObject *object,
gint64 *gui_size);
static gchar * gimp_mybrush_get_description (GimpViewable *viewable,
gchar **tooltip);
static void gimp_mybrush_dirty (GimpData *data);
static const gchar * gimp_mybrush_get_extension (GimpData *data);
static gchar * gimp_mybrush_get_checksum (GimpTagged *tagged);
G_DEFINE_TYPE_WITH_CODE (GimpMybrush, gimp_mybrush, GIMP_TYPE_DATA,
G_IMPLEMENT_INTERFACE (GIMP_TYPE_TAGGED,
gimp_mybrush_tagged_iface_init))
#define parent_class gimp_mybrush_parent_class
static void
gimp_mybrush_class_init (GimpMybrushClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpObjectClass *gimp_object_class = GIMP_OBJECT_CLASS (klass);
GimpViewableClass *viewable_class = GIMP_VIEWABLE_CLASS (klass);
GimpDataClass *data_class = GIMP_DATA_CLASS (klass);
object_class->finalize = gimp_mybrush_finalize;
object_class->get_property = gimp_mybrush_get_property;
object_class->set_property = gimp_mybrush_set_property;
gimp_object_class->get_memsize = gimp_mybrush_get_memsize;
viewable_class->default_icon_name = "gimp-tool-mybrush";
viewable_class->get_description = gimp_mybrush_get_description;
data_class->dirty = gimp_mybrush_dirty;
data_class->get_extension = gimp_mybrush_get_extension;
g_type_class_add_private (klass, sizeof (GimpMybrushPrivate));
}
static void
gimp_mybrush_tagged_iface_init (GimpTaggedInterface *iface)
{
iface->get_checksum = gimp_mybrush_get_checksum;
}
static void
gimp_mybrush_init (GimpMybrush *brush)
{
brush->priv = G_TYPE_INSTANCE_GET_PRIVATE (brush,
GIMP_TYPE_MYBRUSH,
GimpMybrushPrivate);
}
static void
gimp_mybrush_finalize (GObject *object)
{
GimpMybrush *brush = GIMP_MYBRUSH (object);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gimp_mybrush_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpMybrush *brush = GIMP_MYBRUSH (object);
switch (property_id)
{
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_mybrush_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpMybrush *brush = GIMP_MYBRUSH (object);
switch (property_id)
{
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static gint64
gimp_mybrush_get_memsize (GimpObject *object,
gint64 *gui_size)
{
GimpMybrush *brush = GIMP_MYBRUSH (object);
gint64 memsize = 0;
return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object,
gui_size);
}
static gchar *
gimp_mybrush_get_description (GimpViewable *viewable,
gchar **tooltip)
{
GimpMybrush *brush = GIMP_MYBRUSH (viewable);
return g_strdup_printf ("%s",
gimp_object_get_name (brush));
}
static void
gimp_mybrush_dirty (GimpData *data)
{
GimpMybrush *brush = GIMP_MYBRUSH (data);
GIMP_DATA_CLASS (parent_class)->dirty (data);
}
static const gchar *
gimp_mybrush_get_extension (GimpData *data)
{
return GIMP_MYBRUSH_FILE_EXTENSION;
}
static gchar *
gimp_mybrush_get_checksum (GimpTagged *tagged)