Initial checkin of Pika from heckimp

This commit is contained in:
2023-09-25 15:35:21 -07:00
commit 891e999216
6761 changed files with 5240685 additions and 0 deletions

392
app/config/config-enums.c Normal file
View File

@ -0,0 +1,392 @@
/* Generated data (by pika-mkenums) */
#include "stamp-config-enums.h"
#include "config.h"
#include <gio/gio.h>
#include "libpikabase/pikabase.h"
#include "config-enums.h"
#include "pika-intl.h"
/* enumerations from "config-enums.h" */
GType
pika_canvas_padding_mode_get_type (void)
{
static const GEnumValue values[] =
{
{ PIKA_CANVAS_PADDING_MODE_DEFAULT, "PIKA_CANVAS_PADDING_MODE_DEFAULT", "default" },
{ PIKA_CANVAS_PADDING_MODE_LIGHT_CHECK, "PIKA_CANVAS_PADDING_MODE_LIGHT_CHECK", "light-check" },
{ PIKA_CANVAS_PADDING_MODE_DARK_CHECK, "PIKA_CANVAS_PADDING_MODE_DARK_CHECK", "dark-check" },
{ PIKA_CANVAS_PADDING_MODE_CUSTOM, "PIKA_CANVAS_PADDING_MODE_CUSTOM", "custom" },
{ 0, NULL, NULL }
};
static const PikaEnumDesc descs[] =
{
{ PIKA_CANVAS_PADDING_MODE_DEFAULT, NC_("canvas-padding-mode", "From theme"), NULL },
{ PIKA_CANVAS_PADDING_MODE_LIGHT_CHECK, NC_("canvas-padding-mode", "Light check color"), NULL },
{ PIKA_CANVAS_PADDING_MODE_DARK_CHECK, NC_("canvas-padding-mode", "Dark check color"), NULL },
{ PIKA_CANVAS_PADDING_MODE_CUSTOM, NC_("canvas-padding-mode", "Custom color"), NULL },
{ 0, NULL, NULL }
};
static GType type = 0;
if (G_UNLIKELY (! type))
{
type = g_enum_register_static ("PikaCanvasPaddingMode", values);
pika_type_set_translation_context (type, "canvas-padding-mode");
pika_enum_set_value_descriptions (type, descs);
}
return type;
}
GType
pika_cursor_format_get_type (void)
{
static const GEnumValue values[] =
{
{ PIKA_CURSOR_FORMAT_BITMAP, "PIKA_CURSOR_FORMAT_BITMAP", "bitmap" },
{ PIKA_CURSOR_FORMAT_PIXBUF, "PIKA_CURSOR_FORMAT_PIXBUF", "pixbuf" },
{ 0, NULL, NULL }
};
static const PikaEnumDesc descs[] =
{
{ PIKA_CURSOR_FORMAT_BITMAP, NC_("cursor-format", "Black & white"), NULL },
{ PIKA_CURSOR_FORMAT_PIXBUF, NC_("cursor-format", "Fancy"), NULL },
{ 0, NULL, NULL }
};
static GType type = 0;
if (G_UNLIKELY (! type))
{
type = g_enum_register_static ("PikaCursorFormat", values);
pika_type_set_translation_context (type, "cursor-format");
pika_enum_set_value_descriptions (type, descs);
}
return type;
}
GType
pika_cursor_mode_get_type (void)
{
static const GEnumValue values[] =
{
{ PIKA_CURSOR_MODE_TOOL_ICON, "PIKA_CURSOR_MODE_TOOL_ICON", "tool-icon" },
{ PIKA_CURSOR_MODE_TOOL_CROSSHAIR, "PIKA_CURSOR_MODE_TOOL_CROSSHAIR", "tool-crosshair" },
{ PIKA_CURSOR_MODE_CROSSHAIR, "PIKA_CURSOR_MODE_CROSSHAIR", "crosshair" },
{ 0, NULL, NULL }
};
static const PikaEnumDesc descs[] =
{
{ PIKA_CURSOR_MODE_TOOL_ICON, NC_("cursor-mode", "Tool icon"), NULL },
{ PIKA_CURSOR_MODE_TOOL_CROSSHAIR, NC_("cursor-mode", "Tool icon with crosshair"), NULL },
{ PIKA_CURSOR_MODE_CROSSHAIR, NC_("cursor-mode", "Crosshair only"), NULL },
{ 0, NULL, NULL }
};
static GType type = 0;
if (G_UNLIKELY (! type))
{
type = g_enum_register_static ("PikaCursorMode", values);
pika_type_set_translation_context (type, "cursor-mode");
pika_enum_set_value_descriptions (type, descs);
}
return type;
}
GType
pika_export_file_type_get_type (void)
{
static const GEnumValue values[] =
{
{ PIKA_EXPORT_FILE_PNG, "PIKA_EXPORT_FILE_PNG", "png" },
{ PIKA_EXPORT_FILE_JPG, "PIKA_EXPORT_FILE_JPG", "jpg" },
{ PIKA_EXPORT_FILE_ORA, "PIKA_EXPORT_FILE_ORA", "ora" },
{ PIKA_EXPORT_FILE_PSD, "PIKA_EXPORT_FILE_PSD", "psd" },
{ PIKA_EXPORT_FILE_PDF, "PIKA_EXPORT_FILE_PDF", "pdf" },
{ PIKA_EXPORT_FILE_TIF, "PIKA_EXPORT_FILE_TIF", "tif" },
{ PIKA_EXPORT_FILE_BMP, "PIKA_EXPORT_FILE_BMP", "bmp" },
{ PIKA_EXPORT_FILE_WEBP, "PIKA_EXPORT_FILE_WEBP", "webp" },
{ 0, NULL, NULL }
};
static const PikaEnumDesc descs[] =
{
{ PIKA_EXPORT_FILE_PNG, NC_("export-file-type", "PNG Image"), NULL },
{ PIKA_EXPORT_FILE_JPG, NC_("export-file-type", "JPEG Image"), NULL },
{ PIKA_EXPORT_FILE_ORA, NC_("export-file-type", "OpenRaster Image"), NULL },
{ PIKA_EXPORT_FILE_PSD, NC_("export-file-type", "Photoshop Image"), NULL },
{ PIKA_EXPORT_FILE_PDF, NC_("export-file-type", "Portable Document Format"), NULL },
{ PIKA_EXPORT_FILE_TIF, NC_("export-file-type", "TIFF Image"), NULL },
{ PIKA_EXPORT_FILE_BMP, NC_("export-file-type", "Windows BMP Image"), NULL },
{ PIKA_EXPORT_FILE_WEBP, NC_("export-file-type", "WebP Image"), NULL },
{ 0, NULL, NULL }
};
static GType type = 0;
if (G_UNLIKELY (! type))
{
type = g_enum_register_static ("PikaExportFileType", values);
pika_type_set_translation_context (type, "export-file-type");
pika_enum_set_value_descriptions (type, descs);
}
return type;
}
GType
pika_handedness_get_type (void)
{
static const GEnumValue values[] =
{
{ PIKA_HANDEDNESS_LEFT, "PIKA_HANDEDNESS_LEFT", "left" },
{ PIKA_HANDEDNESS_RIGHT, "PIKA_HANDEDNESS_RIGHT", "right" },
{ 0, NULL, NULL }
};
static const PikaEnumDesc descs[] =
{
{ PIKA_HANDEDNESS_LEFT, NC_("handedness", "Left-handed"), NULL },
{ PIKA_HANDEDNESS_RIGHT, NC_("handedness", "Right-handed"), NULL },
{ 0, NULL, NULL }
};
static GType type = 0;
if (G_UNLIKELY (! type))
{
type = g_enum_register_static ("PikaHandedness", values);
pika_type_set_translation_context (type, "handedness");
pika_enum_set_value_descriptions (type, descs);
}
return type;
}
GType
pika_help_browser_type_get_type (void)
{
static const GEnumValue values[] =
{
{ PIKA_HELP_BROWSER_PIKA, "PIKA_HELP_BROWSER_PIKA", "pika" },
{ PIKA_HELP_BROWSER_WEB_BROWSER, "PIKA_HELP_BROWSER_WEB_BROWSER", "web-browser" },
{ 0, NULL, NULL }
};
static const PikaEnumDesc descs[] =
{
{ PIKA_HELP_BROWSER_PIKA, NC_("help-browser-type", "PIKA help browser"), NULL },
{ PIKA_HELP_BROWSER_WEB_BROWSER, NC_("help-browser-type", "Web browser"), NULL },
{ 0, NULL, NULL }
};
static GType type = 0;
if (G_UNLIKELY (! type))
{
type = g_enum_register_static ("PikaHelpBrowserType", values);
pika_type_set_translation_context (type, "help-browser-type");
pika_enum_set_value_descriptions (type, descs);
}
return type;
}
GType
pika_icon_size_get_type (void)
{
static const GEnumValue values[] =
{
{ PIKA_ICON_SIZE_SMALL, "PIKA_ICON_SIZE_SMALL", "small" },
{ PIKA_ICON_SIZE_MEDIUM, "PIKA_ICON_SIZE_MEDIUM", "medium" },
{ PIKA_ICON_SIZE_LARGE, "PIKA_ICON_SIZE_LARGE", "large" },
{ PIKA_ICON_SIZE_HUGE, "PIKA_ICON_SIZE_HUGE", "huge" },
{ 0, NULL, NULL }
};
static const PikaEnumDesc descs[] =
{
{ PIKA_ICON_SIZE_SMALL, NC_("icon-size", "Small size"), NULL },
{ PIKA_ICON_SIZE_MEDIUM, NC_("icon-size", "Medium size"), NULL },
{ PIKA_ICON_SIZE_LARGE, NC_("icon-size", "Large size"), NULL },
{ PIKA_ICON_SIZE_HUGE, NC_("icon-size", "Huge size"), NULL },
{ 0, NULL, NULL }
};
static GType type = 0;
if (G_UNLIKELY (! type))
{
type = g_enum_register_static ("PikaIconSize", values);
pika_type_set_translation_context (type, "icon-size");
pika_enum_set_value_descriptions (type, descs);
}
return type;
}
GType
pika_position_get_type (void)
{
static const GEnumValue values[] =
{
{ PIKA_POSITION_TOP, "PIKA_POSITION_TOP", "top" },
{ PIKA_POSITION_BOTTOM, "PIKA_POSITION_BOTTOM", "bottom" },
{ PIKA_POSITION_LEFT, "PIKA_POSITION_LEFT", "left" },
{ PIKA_POSITION_RIGHT, "PIKA_POSITION_RIGHT", "right" },
{ 0, NULL, NULL }
};
static const PikaEnumDesc descs[] =
{
{ PIKA_POSITION_TOP, NC_("position", "Top"), NULL },
{ PIKA_POSITION_BOTTOM, NC_("position", "Bottom"), NULL },
{ PIKA_POSITION_LEFT, NC_("position", "Left"), NULL },
{ PIKA_POSITION_RIGHT, NC_("position", "Right"), NULL },
{ 0, NULL, NULL }
};
static GType type = 0;
if (G_UNLIKELY (! type))
{
type = g_enum_register_static ("PikaPosition", values);
pika_type_set_translation_context (type, "position");
pika_enum_set_value_descriptions (type, descs);
}
return type;
}
GType
pika_drag_zoom_mode_get_type (void)
{
static const GEnumValue values[] =
{
{ PROP_DRAG_ZOOM_MODE_DISTANCE, "PROP_DRAG_ZOOM_MODE_DISTANCE", "distance" },
{ PROP_DRAG_ZOOM_MODE_DURATION, "PROP_DRAG_ZOOM_MODE_DURATION", "duration" },
{ 0, NULL, NULL }
};
static const PikaEnumDesc descs[] =
{
{ PROP_DRAG_ZOOM_MODE_DISTANCE, NC_("drag-zoom-mode", "By distance"), NULL },
{ PROP_DRAG_ZOOM_MODE_DURATION, NC_("drag-zoom-mode", "By duration"), NULL },
{ 0, NULL, NULL }
};
static GType type = 0;
if (G_UNLIKELY (! type))
{
type = g_enum_register_static ("PikaDragZoomMode", values);
pika_type_set_translation_context (type, "drag-zoom-mode");
pika_enum_set_value_descriptions (type, descs);
}
return type;
}
GType
pika_space_bar_action_get_type (void)
{
static const GEnumValue values[] =
{
{ PIKA_SPACE_BAR_ACTION_NONE, "PIKA_SPACE_BAR_ACTION_NONE", "none" },
{ PIKA_SPACE_BAR_ACTION_PAN, "PIKA_SPACE_BAR_ACTION_PAN", "pan" },
{ PIKA_SPACE_BAR_ACTION_MOVE, "PIKA_SPACE_BAR_ACTION_MOVE", "move" },
{ 0, NULL, NULL }
};
static const PikaEnumDesc descs[] =
{
{ PIKA_SPACE_BAR_ACTION_NONE, NC_("space-bar-action", "No action"), NULL },
{ PIKA_SPACE_BAR_ACTION_PAN, NC_("space-bar-action", "Pan view"), NULL },
{ PIKA_SPACE_BAR_ACTION_MOVE, NC_("space-bar-action", "Switch to Move tool"), NULL },
{ 0, NULL, NULL }
};
static GType type = 0;
if (G_UNLIKELY (! type))
{
type = g_enum_register_static ("PikaSpaceBarAction", values);
pika_type_set_translation_context (type, "space-bar-action");
pika_enum_set_value_descriptions (type, descs);
}
return type;
}
GType
pika_window_hint_get_type (void)
{
static const GEnumValue values[] =
{
{ PIKA_WINDOW_HINT_NORMAL, "PIKA_WINDOW_HINT_NORMAL", "normal" },
{ PIKA_WINDOW_HINT_UTILITY, "PIKA_WINDOW_HINT_UTILITY", "utility" },
{ PIKA_WINDOW_HINT_KEEP_ABOVE, "PIKA_WINDOW_HINT_KEEP_ABOVE", "keep-above" },
{ 0, NULL, NULL }
};
static const PikaEnumDesc descs[] =
{
{ PIKA_WINDOW_HINT_NORMAL, NC_("window-hint", "Normal window"), NULL },
{ PIKA_WINDOW_HINT_UTILITY, NC_("window-hint", "Utility window"), NULL },
{ PIKA_WINDOW_HINT_KEEP_ABOVE, NC_("window-hint", "Keep above"), NULL },
{ 0, NULL, NULL }
};
static GType type = 0;
if (G_UNLIKELY (! type))
{
type = g_enum_register_static ("PikaWindowHint", values);
pika_type_set_translation_context (type, "window-hint");
pika_enum_set_value_descriptions (type, descs);
}
return type;
}
GType
pika_zoom_quality_get_type (void)
{
static const GEnumValue values[] =
{
{ PIKA_ZOOM_QUALITY_LOW, "PIKA_ZOOM_QUALITY_LOW", "low" },
{ PIKA_ZOOM_QUALITY_HIGH, "PIKA_ZOOM_QUALITY_HIGH", "high" },
{ 0, NULL, NULL }
};
static const PikaEnumDesc descs[] =
{
{ PIKA_ZOOM_QUALITY_LOW, NC_("zoom-quality", "Low"), NULL },
{ PIKA_ZOOM_QUALITY_HIGH, NC_("zoom-quality", "High"), NULL },
{ 0, NULL, NULL }
};
static GType type = 0;
if (G_UNLIKELY (! type))
{
type = g_enum_register_static ("PikaZoomQuality", values);
pika_type_set_translation_context (type, "zoom-quality");
pika_enum_set_value_descriptions (type, descs);
}
return type;
}
/* Generated data ends here */

172
app/config/config-enums.h Normal file
View File

@ -0,0 +1,172 @@
/* PIKA - Photo and Image Kooker Application
* a rebranding of The GNU Image Manipulation Program (created with heckimp)
* A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
*
* Original copyright, applying to most contents (license remains unchanged):
* 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 <https://www.gnu.org/licenses/>.
*/
#ifndef __CONFIG_ENUMS_H__
#define __CONFIG_ENUMS_H__
#define PIKA_TYPE_CANVAS_PADDING_MODE (pika_canvas_padding_mode_get_type ())
GType pika_canvas_padding_mode_get_type (void) G_GNUC_CONST;
typedef enum
{
PIKA_CANVAS_PADDING_MODE_DEFAULT, /*< desc="From theme" >*/
PIKA_CANVAS_PADDING_MODE_LIGHT_CHECK, /*< desc="Light check color" >*/
PIKA_CANVAS_PADDING_MODE_DARK_CHECK, /*< desc="Dark check color" >*/
PIKA_CANVAS_PADDING_MODE_CUSTOM, /*< desc="Custom color" >*/
PIKA_CANVAS_PADDING_MODE_RESET = -1 /*< skip >*/
} PikaCanvasPaddingMode;
#define PIKA_TYPE_CURSOR_FORMAT (pika_cursor_format_get_type ())
GType pika_cursor_format_get_type (void) G_GNUC_CONST;
typedef enum
{
PIKA_CURSOR_FORMAT_BITMAP, /*< desc="Black & white" >*/
PIKA_CURSOR_FORMAT_PIXBUF /*< desc="Fancy" >*/
} PikaCursorFormat;
#define PIKA_TYPE_CURSOR_MODE (pika_cursor_mode_get_type ())
GType pika_cursor_mode_get_type (void) G_GNUC_CONST;
typedef enum
{
PIKA_CURSOR_MODE_TOOL_ICON, /*< desc="Tool icon" >*/
PIKA_CURSOR_MODE_TOOL_CROSSHAIR, /*< desc="Tool icon with crosshair" >*/
PIKA_CURSOR_MODE_CROSSHAIR, /*< desc="Crosshair only" >*/
} PikaCursorMode;
#define PIKA_TYPE_EXPORT_FILE_TYPE (pika_export_file_type_get_type ())
GType pika_export_file_type_get_type (void) G_GNUC_CONST;
typedef enum
{
PIKA_EXPORT_FILE_PNG, /*< desc="PNG Image" >*/
PIKA_EXPORT_FILE_JPG, /*< desc="JPEG Image" >*/
PIKA_EXPORT_FILE_ORA, /*< desc="OpenRaster Image" >*/
PIKA_EXPORT_FILE_PSD, /*< desc="Photoshop Image" >*/
PIKA_EXPORT_FILE_PDF, /*< desc="Portable Document Format" >*/
PIKA_EXPORT_FILE_TIF, /*< desc="TIFF Image" >*/
PIKA_EXPORT_FILE_BMP, /*< desc="Windows BMP Image" >*/
PIKA_EXPORT_FILE_WEBP, /*< desc="WebP Image" >*/
} PikaExportFileType;
#define PIKA_TYPE_HANDEDNESS (pika_handedness_get_type ())
GType pika_handedness_get_type (void) G_GNUC_CONST;
typedef enum
{
PIKA_HANDEDNESS_LEFT, /*< desc="Left-handed" >*/
PIKA_HANDEDNESS_RIGHT /*< desc="Right-handed" >*/
} PikaHandedness;
#define PIKA_TYPE_HELP_BROWSER_TYPE (pika_help_browser_type_get_type ())
GType pika_help_browser_type_get_type (void) G_GNUC_CONST;
typedef enum
{
PIKA_HELP_BROWSER_PIKA, /*< desc="PIKA help browser" >*/
PIKA_HELP_BROWSER_WEB_BROWSER /*< desc="Web browser" >*/
} PikaHelpBrowserType;
#define PIKA_TYPE_ICON_SIZE (pika_icon_size_get_type ())
GType pika_icon_size_get_type (void) G_GNUC_CONST;
typedef enum
{
PIKA_ICON_SIZE_SMALL, /*< desc="Small size" > */
PIKA_ICON_SIZE_MEDIUM, /*< desc="Medium size" > */
PIKA_ICON_SIZE_LARGE, /*< desc="Large size" > */
PIKA_ICON_SIZE_HUGE /*< desc="Huge size" > */
} PikaIconSize;
#define PIKA_TYPE_POSITION (pika_position_get_type ())
GType pika_position_get_type (void) G_GNUC_CONST;
typedef enum
{
PIKA_POSITION_TOP, /*< desc="Top" >*/
PIKA_POSITION_BOTTOM, /*< desc="Bottom" >*/
PIKA_POSITION_LEFT, /*< desc="Left" >*/
PIKA_POSITION_RIGHT /*< desc="Right" >*/
} PikaPosition;
#define PIKA_TYPE_DRAG_ZOOM_MODE (pika_drag_zoom_mode_get_type ())
GType pika_drag_zoom_mode_get_type (void) G_GNUC_CONST;
typedef enum
{
PROP_DRAG_ZOOM_MODE_DISTANCE, /*< desc="By distance" >*/
PROP_DRAG_ZOOM_MODE_DURATION, /*< desc="By duration" >*/
} PikaDragZoomMode;
#define PIKA_TYPE_SPACE_BAR_ACTION (pika_space_bar_action_get_type ())
GType pika_space_bar_action_get_type (void) G_GNUC_CONST;
typedef enum
{
PIKA_SPACE_BAR_ACTION_NONE, /*< desc="No action" >*/
PIKA_SPACE_BAR_ACTION_PAN, /*< desc="Pan view" >*/
PIKA_SPACE_BAR_ACTION_MOVE /*< desc="Switch to Move tool" >*/
} PikaSpaceBarAction;
#define PIKA_TYPE_WINDOW_HINT (pika_window_hint_get_type ())
GType pika_window_hint_get_type (void) G_GNUC_CONST;
typedef enum
{
PIKA_WINDOW_HINT_NORMAL, /*< desc="Normal window" >*/
PIKA_WINDOW_HINT_UTILITY, /*< desc="Utility window" >*/
PIKA_WINDOW_HINT_KEEP_ABOVE /*< desc="Keep above" >*/
} PikaWindowHint;
#define PIKA_TYPE_ZOOM_QUALITY (pika_zoom_quality_get_type ())
GType pika_zoom_quality_get_type (void) G_GNUC_CONST;
typedef enum
{
PIKA_ZOOM_QUALITY_LOW, /*< desc="Low" >*/
PIKA_ZOOM_QUALITY_HIGH /*< desc="High" >*/
} PikaZoomQuality;
#endif /* __CONFIG_ENUMS_H__ */

63
app/config/config-types.h Normal file
View File

@ -0,0 +1,63 @@
/* PIKA - Photo and Image Kooker Application
* a rebranding of The GNU Image Manipulation Program (created with heckimp)
* A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
*
* Original copyright, applying to most contents (license remains unchanged):
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* PikaConfig typedefs
* Copyright (C) 2001-2002 Sven Neumann <sven@gimp.org>
*
* 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 <https://www.gnu.org/licenses/>.
*/
#ifndef __CONFIG_TYPES_H__
#define __CONFIG_TYPES_H__
#include "libpikaconfig/pikaconfigtypes.h"
#include "config/config-enums.h"
#define PIKA_OPACITY_TRANSPARENT 0.0
#define PIKA_OPACITY_OPAQUE 1.0
typedef struct _PikaGeglConfig PikaGeglConfig;
typedef struct _PikaCoreConfig PikaCoreConfig;
typedef struct _PikaDisplayConfig PikaDisplayConfig;
typedef struct _PikaGuiConfig PikaGuiConfig;
typedef struct _PikaDialogConfig PikaDialogConfig;
typedef struct _PikaEarlyRc PikaEarlyRc;
typedef struct _PikaPluginConfig PikaPluginConfig;
typedef struct _PikaRc PikaRc;
typedef struct _PikaXmlParser PikaXmlParser;
typedef struct _PikaDisplayOptions PikaDisplayOptions;
/* should be in core/core-types.h */
typedef struct _PikaGrid PikaGrid;
typedef struct _PikaTemplate PikaTemplate;
/* for now these are defines, but can be turned into something
* fancier for nicer debugging
*/
#define pika_assert g_assert
#define pika_assert_not_reached g_assert_not_reached
#endif /* __CONFIG_TYPES_H__ */

72
app/config/meson.build Normal file
View File

@ -0,0 +1,72 @@
stamp_config_enums = custom_target('stamp-config-enums.h',
input : [
files(
'config-enums.h'
),
],
output: [ 'stamp-config-enums.h', ],
command: [
mkenums_wrap, perl,
meson.project_source_root(), meson.current_source_dir(),
meson.current_build_dir(),
'config-',
'#include <gio/gio.h>\n' +
'#include "libpikabase/pikabase.h"\n',
'#include "pika-intl.h"'
],
build_by_default: true
)
libappconfig_sources = [
'pikaconfig-dump.c',
'pikaconfig-file.c',
'pikaconfig-utils.c',
'pikacoreconfig.c',
'pikadialogconfig.c',
'pikadisplayconfig.c',
'pikadisplayoptions.c',
'pikaearlyrc.c',
'pikageglconfig.c',
'pikaguiconfig.c',
'pikapluginconfig.c',
'pikarc-deserialize.c',
'pikarc-serialize.c',
'pikarc-unknown.c',
'pikarc.c',
'pikaxmlparser.c',
'config-enums.c',
stamp_config_enums,
]
libappconfig = static_library('appconfig',
libappconfig_sources,
include_directories: [ rootInclude, rootAppInclude, ],
c_args: '-DG_LOG_DOMAIN="Pika-Config"',
dependencies: [
cairo, gegl, gdk_pixbuf, gio, gio_specific, libmypaint,
],
)
test('app-config',
executable('test-config',
[ 'test-config.c', app_debug_files, ],
dependencies: [
appstream_glib,
libapp_dep,
],
link_with: [
libpikabase,
libpikaconfig,
libpikacolor,
libpikamath,
libpikamodule,
libpikathumb,
libappconfig,
],
install: false,
),
suite: 'app'
)

View File

@ -0,0 +1,650 @@
/* PIKA - Photo and Image Kooker Application
* a rebranding of The GNU Image Manipulation Program (created with heckimp)
* A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
*
* Original copyright, applying to most contents (license remains unchanged):
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* PikaConfig object property dumper.
* Copyright (C) 2001-2006 Sven Neumann <sven@gimp.org>
*
* 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 <https://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <cairo.h>
#include <gegl.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#ifdef G_OS_WIN32
#include <io.h> /* get_osfhandle */
#include <gio/gwin32outputstream.h>
#else
#include <gio/gunixoutputstream.h>
#endif
#include "libpikabase/pikabase.h"
#include "libpikacolor/pikacolor.h"
#include "libpikaconfig/pikaconfig.h"
#include "config-types.h"
#include "pikaconfig-dump.h"
#include "pikarc.h"
static void dump_pikarc_system (PikaConfig *rc,
PikaConfigWriter *writer,
GOutputStream *output);
static void dump_pikarc_manpage (PikaConfig *rc,
PikaConfigWriter *writer,
GOutputStream *output);
static gchar * dump_describe_param (GParamSpec *param_spec);
static void dump_with_linebreaks (GOutputStream *output,
const gchar *text);
gboolean
pika_config_dump (GObject *pika,
PikaConfigDumpFormat format)
{
GOutputStream *output;
PikaConfigWriter *writer;
PikaConfig *rc;
g_return_val_if_fail (G_IS_OBJECT (pika), FALSE);
rc = g_object_new (PIKA_TYPE_RC,
"pika", pika,
NULL);
#ifdef G_OS_WIN32
output = g_win32_output_stream_new ((gpointer) _get_osfhandle (fileno (stdout)), FALSE);
#else
output = g_unix_output_stream_new (1, FALSE);
#endif
writer = pika_config_writer_new_from_stream (output, NULL, NULL);
switch (format)
{
case PIKA_CONFIG_DUMP_NONE:
break;
case PIKA_CONFIG_DUMP_PIKARC:
pika_config_writer_comment (writer,
"Dump of the PIKA default configuration");
pika_config_writer_linefeed (writer);
pika_config_serialize_properties (rc, writer);
pika_config_writer_linefeed (writer);
break;
case PIKA_CONFIG_DUMP_PIKARC_SYSTEM:
dump_pikarc_system (rc, writer, output);
break;
case PIKA_CONFIG_DUMP_PIKARC_MANPAGE:
dump_pikarc_manpage (rc, writer, output);
break;
}
pika_config_writer_finish (writer, NULL, NULL);
g_object_unref (output);
g_object_unref (rc);
return TRUE;
}
static const gchar system_pikarc_header[] =
"This is the system-wide pikarc file. Any change made in this file "
"will affect all users of this system, provided that they are not "
"overriding the default values in their personal pikarc file.\n"
"\n"
"Lines that start with a '#' are comments. Blank lines are ignored.\n"
"\n"
"By default everything in this file is commented out. The file then "
"documents the default values and shows what changes are possible.\n"
"\n"
"The variable ${pika_dir} is set to the value of the environment "
"variable PIKA3_DIRECTORY or, if that is not set, the compiled-in "
"default value is used. If PIKA3_DIRECTORY is not an absolute path, "
"it is interpreted relative to your home directory.";
static void
dump_pikarc_system (PikaConfig *rc,
PikaConfigWriter *writer,
GOutputStream *output)
{
GObjectClass *klass;
GParamSpec **property_specs;
guint n_property_specs;
guint i;
pika_config_writer_comment (writer, system_pikarc_header);
pika_config_writer_linefeed (writer);
klass = G_OBJECT_GET_CLASS (rc);
property_specs = g_object_class_list_properties (klass, &n_property_specs);
for (i = 0; i < n_property_specs; i++)
{
GParamSpec *prop_spec = property_specs[i];
gchar *comment;
if (! (prop_spec->flags & PIKA_CONFIG_PARAM_SERIALIZE))
continue;
if (prop_spec->flags & PIKA_CONFIG_PARAM_IGNORE)
continue;
comment = dump_describe_param (prop_spec);
if (comment)
{
pika_config_writer_comment (writer, comment);
g_free (comment);
}
pika_config_writer_comment_mode (writer, TRUE);
pika_config_writer_linefeed (writer);
if (! strcmp (prop_spec->name, "num-processors"))
{
pika_config_writer_open (writer, "num-processors");
pika_config_writer_printf (writer, "1");
pika_config_writer_close (writer);
}
else if (! strcmp (prop_spec->name, "tile-cache-size"))
{
pika_config_writer_open (writer, "tile-cache-size");
pika_config_writer_printf (writer, "2g");
pika_config_writer_close (writer);
}
else if (! strcmp (prop_spec->name, "undo-size"))
{
pika_config_writer_open (writer, "undo-size");
pika_config_writer_printf (writer, "1g");
pika_config_writer_close (writer);
}
else if (! strcmp (prop_spec->name, "mypaint-brush-path"))
{
gchar *path = g_strdup_printf ("@mypaint_brushes_dir@%s"
"~/.mypaint/brushes",
G_SEARCHPATH_SEPARATOR_S);
pika_config_writer_open (writer, "mypaint-brush-path");
pika_config_writer_string (writer, path);
pika_config_writer_close (writer);
g_free (path);
}
else
{
pika_config_serialize_property (rc, prop_spec, writer);
}
pika_config_writer_comment_mode (writer, FALSE);
pika_config_writer_linefeed (writer);
}
g_free (property_specs);
}
static const gchar man_page_header[] =
".\\\" This man-page is auto-generated by pika --dump-pikarc-manpage.\n"
"\n"
".TH PIKARC 5 \"Version " PIKA_VERSION "\" \"PIKA Manual Pages\"\n"
".SH NAME\n"
"pikarc \\- pika configuration file\n"
".SH DESCRIPTION\n"
"The\n"
".B pikarc\n"
"file is a configuration file read by PIKA when it starts up. There\n"
"are two of these: one system-wide one stored in\n"
"@pikasysconfdir@/pikarc and a per-user @manpage_pikadir@/pikarc\n"
"which may override system settings.\n"
"\n"
"Comments are introduced by a hash sign (#), and continue until the end\n"
"of the line. Blank lines are ignored.\n"
"\n"
"The\n"
".B pikarc\n"
"file associates values with properties. These properties may be set\n"
"by lisp-like assignments of the form:\n"
".IP\n"
"\\f3(\\f2property\\-name\\ value\\f3)\\f1\n"
".TP\n"
"where:\n"
".TP 10\n"
".I property\\-name\n"
"is one of the property names described below.\n"
".TP\n"
".I value\n"
"is the value the property is to be set to.\n"
".PP\n"
"\n"
"Either spaces or tabs may be used to separate the name from the value.\n"
".PP\n"
".SH PROPERTIES\n"
"Valid properties and their default values are:\n"
"\n";
static const gchar *man_page_path =
".PP\n"
".SH PATH EXPANSION\n"
"Strings of type PATH are expanded in a manner similar to\n"
".BR bash (1).\n"
"Specifically: tilde (~) is expanded to the user's home directory. Note that\n"
"the bash feature of being able to refer to other user's home directories\n"
"by writing ~userid/ is not valid in this file.\n"
"\n"
"${variable} is expanded to the current value of an environment variable.\n"
"There are a few variables that are pre-defined:\n"
".TP\n"
".I pika_dir\n"
"The personal pika directory which is set to the value of the environment\n"
"variable PIKA3_DIRECTORY or to @manpage_pikadir@.\n"
".TP\n"
".I pika_data_dir\n"
"Base for paths to shareable data, which is set to the value of the\n"
"environment variable PIKA3_DATADIR or to the compiled-in default value\n"
"@pikadatadir@.\n"
".TP\n"
".I pika_plug_in_dir\n"
"Base to paths for architecture-specific plug-ins and modules, which is set\n"
"to the value of the environment variable PIKA3_PLUGINDIR or to the\n"
"compiled-in default value @pikaplugindir@.\n"
".TP\n"
".I pika_sysconf_dir\n"
"Path to configuration files, which is set to the value of the environment\n"
"variable PIKA3_SYSCONFDIR or to the compiled-in default value \n"
"@pikasysconfdir@.\n"
".TP\n"
".I pika_cache_dir\n"
"Path to cached files, which is set to the value of the environment\n"
"variable PIKA3_CACHEDIR or to the system default for per-user cached files.\n"
".TP\n"
".I pika_temp_dir\n"
"Path to temporary files, which is set to the value of the environment\n"
"variable PIKA3_TEMPDIR or to the system default for temporary files.\n"
"\n";
static const gchar man_page_footer[] =
".SH FILES\n"
".TP\n"
".I @pikasysconfdir@/pikarc\n"
"System-wide configuration file\n"
".TP\n"
".I @manpage_pikadir@/pikarc\n"
"Per-user configuration file\n"
"\n"
".SH \"SEE ALSO\"\n"
".BR pika (1)\n";
static void
dump_pikarc_manpage (PikaConfig *rc,
PikaConfigWriter *writer,
GOutputStream *output)
{
GObjectClass *klass;
GParamSpec **property_specs;
guint n_property_specs;
guint i;
g_output_stream_printf (output, NULL, NULL, NULL,
"%s", man_page_header);
klass = G_OBJECT_GET_CLASS (rc);
property_specs = g_object_class_list_properties (klass, &n_property_specs);
for (i = 0; i < n_property_specs; i++)
{
GParamSpec *prop_spec = property_specs[i];
gchar *desc;
gboolean success;
if (! (prop_spec->flags & PIKA_CONFIG_PARAM_SERIALIZE))
continue;
if (prop_spec->flags & PIKA_CONFIG_PARAM_IGNORE)
continue;
g_output_stream_printf (output, NULL, NULL, NULL,
".TP\n");
if (! strcmp (prop_spec->name, "num-processors"))
{
pika_config_writer_open (writer, "num-processors");
pika_config_writer_printf (writer, "1");
pika_config_writer_close (writer);
success = TRUE;
}
else if (! strcmp (prop_spec->name, "tile-cache-size"))
{
pika_config_writer_open (writer, "tile-cache-size");
pika_config_writer_printf (writer, "2g");
pika_config_writer_close (writer);
success = TRUE;
}
else if (! strcmp (prop_spec->name, "undo-size"))
{
pika_config_writer_open (writer, "undo-size");
pika_config_writer_printf (writer, "1g");
pika_config_writer_close (writer);
success = TRUE;
}
else if (! strcmp (prop_spec->name, "mypaint-brush-path"))
{
gchar *path = g_strdup_printf ("@mypaint_brushes_dir@%s"
"~/.mypaint/brushes",
G_SEARCHPATH_SEPARATOR_S);
pika_config_writer_open (writer, "mypaint-brush-path");
pika_config_writer_string (writer, path);
pika_config_writer_close (writer);
g_free (path);
success = TRUE;
}
else
{
success = pika_config_serialize_property (rc, prop_spec, writer);
}
if (success)
{
g_output_stream_printf (output, NULL, NULL, NULL,
"\n");
desc = dump_describe_param (prop_spec);
dump_with_linebreaks (output, desc);
g_output_stream_printf (output, NULL, NULL, NULL,
"\n");
g_free (desc);
}
}
g_free (property_specs);
g_output_stream_printf (output, NULL, NULL, NULL,
"%s", man_page_path);
g_output_stream_printf (output, NULL, NULL, NULL,
"%s", man_page_footer);
}
static const gchar display_format_description[] =
"This is a format string; certain % character sequences are recognised and "
"expanded as follows:\n"
"\n"
"%% literal percent sign\n"
"%f bare filename, or \"Untitled\"\n"
"%F full path to file, or \"Untitled\"\n"
"%p PDB image id\n"
"%i view instance number\n"
"%t image type (RGB, grayscale, indexed)\n"
"%z zoom factor as a percentage\n"
"%s source scale factor\n"
"%d destination scale factor\n"
"%Dx expands to x if the image is dirty, the empty string otherwise\n"
"%Cx expands to x if the image is clean, the empty string otherwise\n"
"%B expands to (modified) if the image is dirty, the empty string otherwise\n"
"%A expands to (clean) if the image is clean, the empty string otherwise\n"
"%Nx expands to x if the image is export-dirty, the empty string otherwise\n"
"%Ex expands to x if the image is export-clean, the empty string otherwise\n"
"%l the number of layers\n"
"%L the number of layers (long form)\n"
"%m memory used by the image\n"
"%n the name of the active layer/channel\n"
"%P the PDB id of the active layer/channel\n"
"%w image width in pixels\n"
"%W image width in real-world units\n"
"%h image height in pixels\n"
"%H image height in real-world units\n"
"%M the image size expressed in megapixels\n"
"%u unit symbol\n"
"%U unit abbreviation\n"
"%x the width of the active layer/channel in pixels\n"
"%X the width of the active layer/channel in real-world units\n"
"%y the height of the active layer/channel in pixels\n"
"%Y the height of the active layer/channel in real-world units\n"
"%o the name of the image's color profile\n\n";
static gchar *
dump_describe_param (GParamSpec *param_spec)
{
const gchar *blurb = g_param_spec_get_blurb (param_spec);
const gchar *values = NULL;
if (!blurb)
{
g_warning ("FIXME: Property '%s' has no blurb.", param_spec->name);
blurb = g_strdup_printf ("The %s property has no description.",
param_spec->name);
}
if (PIKA_IS_PARAM_SPEC_RGB (param_spec))
{
if (pika_param_spec_rgb_has_alpha (param_spec))
values =
"The color is specified in the form (color-rgba red green blue "
"alpha) with channel values as floats in the range of 0.0 to 1.0.";
else
values =
"The color is specified in the form (color-rgb red green blue) "
"with channel values as floats in the range of 0.0 to 1.0.";
}
else if (PIKA_IS_PARAM_SPEC_MEMSIZE (param_spec))
{
values =
"The integer size can contain a suffix of 'B', 'K', 'M' or 'G' which "
"makes PIKA interpret the size as being specified in bytes, kilobytes, "
"megabytes or gigabytes. If no suffix is specified the size defaults "
"to being specified in kilobytes.";
}
else if (PIKA_IS_PARAM_SPEC_CONFIG_PATH (param_spec))
{
switch (pika_param_spec_config_path_type (param_spec))
{
case PIKA_CONFIG_PATH_FILE:
values = "This is a single filename.";
break;
case PIKA_CONFIG_PATH_FILE_LIST:
switch (G_SEARCHPATH_SEPARATOR)
{
case ':':
values = "This is a colon-separated list of files.";
break;
case ';':
values = "This is a semicolon-separated list of files.";
break;
default:
g_warning ("unhandled G_SEARCHPATH_SEPARATOR value");
break;
}
break;
case PIKA_CONFIG_PATH_DIR:
values = "This is a single folder.";
break;
case PIKA_CONFIG_PATH_DIR_LIST:
switch (G_SEARCHPATH_SEPARATOR)
{
case ':':
values = "This is a colon-separated list of folders to search.";
break;
case ';':
values = "This is a semicolon-separated list of folders to search.";
break;
default:
g_warning ("unhandled G_SEARCHPATH_SEPARATOR value");
break;
}
break;
}
}
else if (PIKA_IS_PARAM_SPEC_UNIT (param_spec))
{
values =
"The unit can be one inches, millimeters, points or picas plus "
"those in your user units database.";
}
else if (g_type_is_a (param_spec->value_type, PIKA_TYPE_CONFIG))
{
values = "This is a parameter list.";
}
else
{
switch (G_TYPE_FUNDAMENTAL (param_spec->value_type))
{
case G_TYPE_BOOLEAN:
values = "Possible values are yes and no.";
break;
case G_TYPE_INT:
case G_TYPE_UINT:
case G_TYPE_LONG:
case G_TYPE_ULONG:
case G_TYPE_INT64:
values = "This is an integer value.";
break;
case G_TYPE_FLOAT:
case G_TYPE_DOUBLE:
values = "This is a float value.";
break;
case G_TYPE_STRING:
/* eek */
if (strcmp (g_param_spec_get_name (param_spec), "image-title-format")
&&
strcmp (g_param_spec_get_name (param_spec), "image-status-format"))
{
values = "This is a string value.";
}
else
{
values = display_format_description;
}
break;
case G_TYPE_ENUM:
{
GEnumClass *enum_class;
GEnumValue *enum_value;
GString *str;
gint i;
enum_class = g_type_class_peek (param_spec->value_type);
str = g_string_new (blurb);
g_string_append (str, " Possible values are ");
for (i = 0, enum_value = enum_class->values;
i < enum_class->n_values;
i++, enum_value++)
{
g_string_append (str, enum_value->value_nick);
switch (enum_class->n_values - i)
{
case 1:
g_string_append_c (str, '.');
break;
case 2:
g_string_append (str, " and ");
break;
default:
g_string_append (str, ", ");
break;
}
}
return g_string_free (str, FALSE);
}
break;
default:
break;
}
}
if (!values)
g_warning ("FIXME: Can't tell anything about a %s.",
g_type_name (param_spec->value_type));
if (strcmp (blurb, "") == 0)
return g_strdup_printf ("%s", values);
else
return g_strdup_printf ("%s %s", blurb, values);
}
#define LINE_LENGTH 78
static void
dump_with_linebreaks (GOutputStream *output,
const gchar *text)
{
gint len = strlen (text);
while (len > 0)
{
const gchar *t;
gint i, space;
/* groff doesn't like lines to start with a single quote */
if (*text == '\'')
g_output_stream_printf (output, NULL, NULL, NULL,
"\\&"); /* a zero width space */
for (t = text, i = 0, space = 0;
*t != '\n' && (i <= LINE_LENGTH || space == 0) && i < len;
t++, i++)
{
if (g_ascii_isspace (*t))
space = i;
}
if (i > LINE_LENGTH && space && *t != '\n')
i = space;
g_output_stream_write_all (output, text, i, NULL, NULL, NULL);
g_output_stream_printf (output, NULL, NULL, NULL,
"\n");
if (*t == '\n')
g_output_stream_printf (output, NULL, NULL, NULL,
".br\n");
i++;
text += i;
len -= i;
}
}

View File

@ -0,0 +1,41 @@
/* PIKA - Photo and Image Kooker Application
* a rebranding of The GNU Image Manipulation Program (created with heckimp)
* A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
*
* Original copyright, applying to most contents (license remains unchanged):
* Copyright (C) 1995-1997 Spencer Kimball and Peter Mattis
*
* Copyright (C) 2003 Sven Neumann <sven@gimp.org>
*
* 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 <https://www.gnu.org/licenses/>.
*/
#ifndef __PIKA_CONFIG_DUMP_H__
#define __PIKA_CONFIG_DUMP_H__
typedef enum
{
PIKA_CONFIG_DUMP_NONE,
PIKA_CONFIG_DUMP_PIKARC,
PIKA_CONFIG_DUMP_PIKARC_SYSTEM,
PIKA_CONFIG_DUMP_PIKARC_MANPAGE
} PikaConfigDumpFormat;
gboolean pika_config_dump (GObject *pika,
PikaConfigDumpFormat format);
#endif /* __PIKA_CONFIG_DUMP_H__ */

View File

@ -0,0 +1,246 @@
/* PIKA - Photo and Image Kooker Application
* a rebranding of The GNU Image Manipulation Program (created with heckimp)
* A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
*
* Original copyright, applying to most contents (license remains unchanged):
* Copyright (C) 1995-1997 Spencer Kimball and Peter Mattis
*
* File Utitility functions for PikaConfig.
* Copyright (C) 2001-2003 Sven Neumann <sven@gimp.org>
*
* 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 <https://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <errno.h>
#include <sys/types.h>
#include <gio/gio.h>
#include <glib/gstdio.h>
#include "libpikabase/pikabase.h"
#include "libpikaconfig/pikaconfig.h"
#ifdef G_OS_WIN32
#include "libpikabase/pikawin32-io.h"
#endif
#include "config-types.h"
#include "pikaconfig-file.h"
#include "pika-intl.h"
gboolean
pika_config_file_copy (const gchar *source,
const gchar *dest,
const gchar *old_options_pattern,
GRegexEvalCallback update_callback,
gpointer user_data,
GError **error)
{
gchar buffer[8192];
FILE *sfile;
FILE *dfile;
GStatBuf stat_buf;
gint nbytes;
gint unwritten_len = 0;
GRegex *old_options_regexp = NULL;
if (old_options_pattern && update_callback)
{
old_options_regexp = g_regex_new (old_options_pattern, 0, 0, error);
/* error set by g_regex_new. */
if (! old_options_regexp)
return FALSE;
}
sfile = g_fopen (source, "rb");
if (sfile == NULL)
{
g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
_("Could not open '%s' for reading: %s"),
pika_filename_to_utf8 (source), g_strerror (errno));
if (old_options_regexp)
g_regex_unref (old_options_regexp);
return FALSE;
}
dfile = g_fopen (dest, "wb");
if (dfile == NULL)
{
g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
_("Could not open '%s' for writing: %s"),
pika_filename_to_utf8 (dest), g_strerror (errno));
fclose (sfile);
if (old_options_regexp)
g_regex_unref (old_options_regexp);
return FALSE;
}
while ((nbytes = fread (buffer + unwritten_len, 1,
sizeof (buffer) - unwritten_len, sfile)) > 0 || unwritten_len)
{
size_t read_len = nbytes + unwritten_len;
size_t write_len;
gchar* eol = NULL;
gchar* write_bytes = NULL;
if (old_options_regexp && update_callback)
{
eol = g_strrstr_len (buffer, read_len, "\n");
if (eol)
{
*eol = '\0';
read_len = strlen (buffer) + 1;
*eol++ = '\n';
}
else if (! feof (sfile))
{
gchar format[256];
/* We are in unlikely case where a single config line is
* longer than the buffer!
*/
g_snprintf (format, sizeof (format),
_("Error parsing '%%s': line longer than %s characters."),
G_GINT64_FORMAT);
g_set_error (error, PIKA_CONFIG_ERROR, PIKA_CONFIG_ERROR_PARSE,
format,
pika_filename_to_utf8 (source),
(gint64) sizeof (buffer));
fclose (sfile);
fclose (dfile);
g_regex_unref (old_options_regexp);
return FALSE;
}
write_bytes = g_regex_replace_eval (old_options_regexp, buffer,
read_len, 0, 0, update_callback,
user_data, error);
if (write_bytes == NULL)
{
/* error already set. */
fclose (sfile);
fclose (dfile);
g_regex_unref (old_options_regexp);
return FALSE;
}
write_len = strlen (write_bytes);
}
else
{
write_bytes = buffer;
write_len = read_len;
}
if (fwrite (write_bytes, 1, write_len, dfile) < write_len)
{
g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
_("Error writing '%s': %s"),
pika_filename_to_utf8 (dest), g_strerror (errno));
if (old_options_regexp && update_callback)
{
g_free (write_bytes);
g_regex_unref (old_options_regexp);
}
fclose (sfile);
fclose (dfile);
return FALSE;
}
if (old_options_regexp && update_callback)
{
g_free (write_bytes);
if (eol)
{
unwritten_len = nbytes + unwritten_len - read_len;
memmove (buffer, eol, unwritten_len);
}
else
/* EOF */
break;
}
}
if (ferror (sfile))
{
g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
_("Error reading '%s': %s"),
pika_filename_to_utf8 (source), g_strerror (errno));
fclose (sfile);
fclose (dfile);
if (old_options_regexp)
g_regex_unref (old_options_regexp);
return FALSE;
}
fclose (sfile);
if (fclose (dfile) == EOF)
{
g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
_("Error writing '%s': %s"),
pika_filename_to_utf8 (dest), g_strerror (errno));
if (old_options_regexp)
g_regex_unref (old_options_regexp);
return FALSE;
}
if (g_stat (source, &stat_buf) == 0)
{
g_chmod (dest, stat_buf.st_mode);
}
if (old_options_regexp)
g_regex_unref (old_options_regexp);
return TRUE;
}
gboolean
pika_config_file_backup_on_error (GFile *file,
const gchar *name,
GError **error)
{
gchar *path;
gchar *backup;
gboolean success;
g_return_val_if_fail (G_IS_FILE (file), FALSE);
g_return_val_if_fail (name != NULL, FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
path = g_file_get_path (file);
backup = g_strconcat (path, "~", NULL);
success = pika_config_file_copy (path, backup, NULL, NULL, NULL, error);
if (success)
g_message (_("There was an error parsing your '%s' file. "
"Default values will be used. A backup of your "
"configuration has been created at '%s'."),
name, pika_filename_to_utf8 (backup));
g_free (backup);
g_free (path);
return success;
}

View File

@ -0,0 +1,41 @@
/* PIKA - Photo and Image Kooker Application
* a rebranding of The GNU Image Manipulation Program (created with heckimp)
* A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
*
* Original copyright, applying to most contents (license remains unchanged):
* Copyright (C) 1995-1997 Spencer Kimball and Peter Mattis
*
* File utitility functions for PikaConfig.
* Copyright (C) 2001-2003 Sven Neumann <sven@gimp.org>
*
* 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 <https://www.gnu.org/licenses/>.
*/
#ifndef __PIKA_CONFIG_FILE_H__
#define __PIKA_CONFIG_FILE_H__
gboolean pika_config_file_copy (const gchar *source,
const gchar *dest,
const gchar *old_options_regexp,
GRegexEvalCallback update_callback,
gpointer user_data,
GError **error);
gboolean pika_config_file_backup_on_error (GFile *file,
const gchar *name,
GError **error);
#endif /* __PIKA_CONFIG_FILE_H__ */

View File

@ -0,0 +1,227 @@
/* PIKA - Photo and Image Kooker Application
* a rebranding of The GNU Image Manipulation Program (created with heckimp)
* A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
*
* Original copyright, applying to most contents (license remains unchanged):
* Copyright (C) 1995-1997 Spencer Kimball and Peter Mattis
*
* Utitility functions for PikaConfig.
* Copyright (C) 2001-2003 Sven Neumann <sven@gimp.org>
*
* 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 <https://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <gio/gio.h>
#include "libpikabase/pikabase.h"
#include "libpikaconfig/pikaconfig.h"
#include "config-types.h"
#include "pikaconfig-utils.h"
static void
pika_config_connect_notify (GObject *src,
GParamSpec *param_spec,
GObject *dest)
{
if (param_spec->flags & G_PARAM_READABLE)
{
GParamSpec *dest_spec;
dest_spec = g_object_class_find_property (G_OBJECT_GET_CLASS (dest),
param_spec->name);
if (dest_spec &&
(dest_spec->value_type == param_spec->value_type) &&
(dest_spec->flags & G_PARAM_WRITABLE) &&
(dest_spec->flags & G_PARAM_CONSTRUCT_ONLY) == 0)
{
GValue value = G_VALUE_INIT;
g_value_init (&value, param_spec->value_type);
g_object_get_property (src, param_spec->name, &value);
g_signal_handlers_block_by_func (dest,
pika_config_connect_notify, src);
g_object_set_property (dest, param_spec->name, &value);
g_signal_handlers_unblock_by_func (dest,
pika_config_connect_notify, src);
g_value_unset (&value);
}
}
}
/**
* pika_config_connect:
* @a: a #GObject
* @b: another #GObject
* @property_name: the name of a property to connect or %NULL for all
*
* Connects the two object @a and @b in a way that property changes of
* one are propagated to the other. This is a two-way connection.
*
* If @property_name is %NULL the connection is setup for all
* properties. It is not required that @a and @b are of the same type.
* Only changes on properties that exist in both object classes and
* are of the same value_type are propagated.
**/
void
pika_config_connect (GObject *a,
GObject *b,
const gchar *property_name)
{
gchar *signal_name;
g_return_if_fail (a != b);
g_return_if_fail (G_IS_OBJECT (a) && G_IS_OBJECT (b));
if (property_name)
signal_name = g_strconcat ("notify::", property_name, NULL);
else
signal_name = "notify";
g_signal_connect_object (a, signal_name,
G_CALLBACK (pika_config_connect_notify),
b, 0);
g_signal_connect_object (b, signal_name,
G_CALLBACK (pika_config_connect_notify),
a, 0);
if (property_name)
g_free (signal_name);
}
static void
pika_config_connect_full_notify (GObject *src,
GParamSpec *param_spec,
GObject *dest)
{
if (param_spec->flags & G_PARAM_READABLE)
{
gchar *attach_key;
gchar *dest_prop_name;
GParamSpec *dest_spec = NULL;
attach_key = g_strdup_printf ("%p-%s", dest, param_spec->name);
dest_prop_name = g_object_get_data (src, attach_key);
g_free (attach_key);
if (dest_prop_name)
dest_spec = g_object_class_find_property (G_OBJECT_GET_CLASS (dest),
dest_prop_name);
if (dest_spec &&
(dest_spec->value_type == param_spec->value_type) &&
(dest_spec->flags & G_PARAM_WRITABLE) &&
(dest_spec->flags & G_PARAM_CONSTRUCT_ONLY) == 0)
{
GValue value = G_VALUE_INIT;
g_value_init (&value, param_spec->value_type);
g_object_get_property (src, param_spec->name, &value);
g_signal_handlers_block_by_func (dest,
pika_config_connect_full_notify, src);
g_object_set_property (dest, dest_prop_name, &value);
g_signal_handlers_unblock_by_func (dest,
pika_config_connect_full_notify, src);
g_value_unset (&value);
}
}
}
/**
* pika_config_connect_full:
* @a: a #GObject
* @b: another #GObject
* @property_name_a: the name of a property of @a to connect
* @property_name_b: the name of a property of @b to connect
*
* Connects the two object @a and @b in a way that property changes of
* one are propagated to the other. This is a two-way connection.
*
* If @property_name is %NULL the connection is setup for all
* properties. It is not required that @a and @b are of the same type.
* Only changes on properties that exist in both object classes and
* are of the same value_type are propagated.
**/
void
pika_config_connect_full (GObject *a,
GObject *b,
const gchar *property_name_a,
const gchar *property_name_b)
{
gchar *signal_name;
gchar *attach_key;
g_return_if_fail (a != b);
g_return_if_fail (G_IS_OBJECT (a) && G_IS_OBJECT (b));
g_return_if_fail (property_name_a != NULL);
g_return_if_fail (property_name_b != NULL);
signal_name = g_strconcat ("notify::", property_name_a, NULL);
attach_key = g_strdup_printf ("%p-%s", b, property_name_a);
g_signal_connect_object (a, signal_name,
G_CALLBACK (pika_config_connect_full_notify),
b, 0);
g_object_set_data_full (a, attach_key, g_strdup (property_name_b),
(GDestroyNotify) g_free);
g_free (signal_name);
g_free (attach_key);
signal_name = g_strconcat ("notify::", property_name_b, NULL);
attach_key = g_strdup_printf ("%p-%s", a, property_name_b);
g_signal_connect_object (b, signal_name,
G_CALLBACK (pika_config_connect_full_notify),
a, 0);
g_object_set_data_full (b, attach_key, g_strdup (property_name_a),
(GDestroyNotify) g_free);
g_free (signal_name);
g_free (attach_key);
}
/**
* pika_config_disconnect:
* @a: a #GObject
* @b: another #GObject
*
* Removes a connection between @dest and @src that was previously set
* up using pika_config_connect().
**/
void
pika_config_disconnect (GObject *a,
GObject *b)
{
g_return_if_fail (G_IS_OBJECT (a) && G_IS_OBJECT (b));
g_signal_handlers_disconnect_by_func (b,
G_CALLBACK (pika_config_connect_notify),
a);
g_signal_handlers_disconnect_by_func (a,
G_CALLBACK (pika_config_connect_notify),
b);
}

View File

@ -0,0 +1,40 @@
/* PIKA - Photo and Image Kooker Application
* a rebranding of The GNU Image Manipulation Program (created with heckimp)
* A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
*
* Original copyright, applying to most contents (license remains unchanged):
* Copyright (C) 1995-1997 Spencer Kimball and Peter Mattis
*
* Utitility functions for PikaConfig.
* Copyright (C) 2001-2003 Sven Neumann <sven@gimp.org>
*
* 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 <https://www.gnu.org/licenses/>.
*/
#ifndef __APP_PIKA_CONFIG_UTILS_H__
#define __APP_PIKA_CONFIG_UTILS_H__
void pika_config_connect (GObject *a,
GObject *b,
const gchar *property_name);
void pika_config_connect_full (GObject *a,
GObject *b,
const gchar *property_name_a,
const gchar *property_name_b);
void pika_config_disconnect (GObject *a,
GObject *b);
#endif /* __APP_PIKA_CONFIG_UTILS_H__ */

1484
app/config/pikacoreconfig.c Normal file

File diff suppressed because it is too large Load Diff

136
app/config/pikacoreconfig.h Normal file
View File

@ -0,0 +1,136 @@
/* PIKA - Photo and Image Kooker Application
* a rebranding of The GNU Image Manipulation Program (created with heckimp)
* A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
*
* Original copyright, applying to most contents (license remains unchanged):
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* PikaCoreConfig class
* Copyright (C) 2001 Sven Neumann <sven@gimp.org>
*
* 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 <https://www.gnu.org/licenses/>.
*/
#ifndef __PIKA_CORE_CONFIG_H__
#define __PIKA_CORE_CONFIG_H__
#include "operations/operations-enums.h"
#include "core/core-enums.h"
#include "config/pikageglconfig.h"
#define PIKA_TYPE_CORE_CONFIG (pika_core_config_get_type ())
#define PIKA_CORE_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PIKA_TYPE_CORE_CONFIG, PikaCoreConfig))
#define PIKA_CORE_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PIKA_TYPE_CORE_CONFIG, PikaCoreConfigClass))
#define PIKA_IS_CORE_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PIKA_TYPE_CORE_CONFIG))
#define PIKA_IS_CORE_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PIKA_TYPE_CORE_CONFIG))
typedef struct _PikaCoreConfigClass PikaCoreConfigClass;
struct _PikaCoreConfig
{
PikaGeglConfig parent_instance;
gchar *language;
gchar *prev_language;
PikaInterpolationType interpolation_type;
gint default_threshold;
gchar *plug_in_path;
gchar *module_path;
gchar *interpreter_path;
gchar *environ_path;
gchar *brush_path;
gchar *brush_path_writable;
gchar *dynamics_path;
gchar *dynamics_path_writable;
gchar *mypaint_brush_path;
gchar *mypaint_brush_path_writable;
gchar *pattern_path;
gchar *pattern_path_writable;
gchar *palette_path;
gchar *palette_path_writable;
gchar *gradient_path;
gchar *gradient_path_writable;
gchar *tool_preset_path;
gchar *tool_preset_path_writable;
gchar *font_path;
gchar *font_path_writable; /* unused */
gchar *default_brush;
gchar *default_dynamics;
gchar *default_mypaint_brush;
gchar *default_pattern;
gchar *default_palette;
gchar *default_tool_preset;
gchar *default_gradient;
gchar *default_font;
gboolean global_brush;
gboolean global_dynamics;
gboolean global_pattern;
gboolean global_palette;
gboolean global_gradient;
gboolean global_font;
PikaTemplate *default_image;
PikaGrid *default_grid;
gint levels_of_undo;
guint64 undo_size;
PikaViewSize undo_preview_size;
gint filter_history_size;
gchar *plug_in_rc_path;
gboolean layer_previews;
gboolean group_layer_previews;
PikaViewSize layer_preview_size;
PikaThumbnailSize thumbnail_size;
guint64 thumbnail_filesize_limit;
PikaColorConfig *color_management;
gboolean save_document_history;
PikaRGB quick_mask_color;
gboolean import_promote_float;
gboolean import_promote_dither;
gboolean import_add_alpha;
gchar *import_raw_plug_in;
PikaExportFileType export_file_type;
gboolean export_color_profile;
gboolean export_comment;
gboolean export_thumbnail;
gboolean export_metadata_exif;
gboolean export_metadata_xmp;
gboolean export_metadata_iptc;
PikaDebugPolicy debug_policy;
#ifdef G_OS_WIN32
PikaWin32PointerInputAPI win32_pointer_input_api;
#endif
PikaSelectMethod items_select_method;
gboolean check_updates;
gint64 check_update_timestamp;
gchar *last_known_release;
gint64 last_release_timestamp;
gchar *last_release_comment;
gint last_revision;
gchar *config_version;
};
struct _PikaCoreConfigClass
{
PikaGeglConfigClass parent_class;
};
GType pika_core_config_get_type (void) G_GNUC_CONST;
#endif /* PIKA_CORE_CONFIG_H__ */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,128 @@
/* PIKA - Photo and Image Kooker Application
* a rebranding of The GNU Image Manipulation Program (created with heckimp)
* A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
*
* Original copyright, applying to most contents (license remains unchanged):
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* PikaDialogConfig class
* Copyright (C) 2016 Michael Natterer <mitch@gimp.org>
*
* 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 <https://www.gnu.org/licenses/>.
*/
#ifndef __PIKA_DIALOG_CONFIG_H__
#define __PIKA_DIALOG_CONFIG_H__
#include "config/pikaguiconfig.h"
/* We don't want to include stuff from core/ here, instead do the next
* less ugly hack...
*/
typedef struct _PikaFillOptions PikaFillOptions;
typedef struct _PikaStrokeOptions PikaStrokeOptions;
#define PIKA_TYPE_DIALOG_CONFIG (pika_dialog_config_get_type ())
#define PIKA_DIALOG_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PIKA_TYPE_DIALOG_CONFIG, PikaDialogConfig))
#define PIKA_DIALOG_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PIKA_TYPE_DIALOG_CONFIG, PikaDialogConfigClass))
#define PIKA_IS_DIALOG_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PIKA_TYPE_DIALOG_CONFIG))
#define PIKA_IS_DIALOG_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PIKA_TYPE_DIALOG_CONFIG))
typedef struct _PikaDialogConfigClass PikaDialogConfigClass;
struct _PikaDialogConfig
{
PikaGuiConfig parent_instance;
PikaColorProfilePolicy color_profile_policy;
PikaMetadataRotationPolicy metadata_rotation_policy;
gchar *color_profile_path;
PikaColorRenderingIntent image_convert_profile_intent;
gboolean image_convert_profile_bpc;
GeglDitherMethod image_convert_precision_layer_dither_method;
GeglDitherMethod image_convert_precision_text_layer_dither_method;
GeglDitherMethod image_convert_precision_channel_dither_method;
PikaConvertPaletteType image_convert_indexed_palette_type;
gint image_convert_indexed_max_colors;
gboolean image_convert_indexed_remove_duplicates;
PikaConvertDitherType image_convert_indexed_dither_type;
gboolean image_convert_indexed_dither_alpha;
gboolean image_convert_indexed_dither_text_layers;
PikaFillType image_resize_fill_type;
PikaItemSet image_resize_layer_set;
gboolean image_resize_resize_text_layers;
gchar *layer_new_name;
PikaLayerMode layer_new_mode;
PikaLayerColorSpace layer_new_blend_space;
PikaLayerColorSpace layer_new_composite_space;
PikaLayerCompositeMode layer_new_composite_mode;
gdouble layer_new_opacity;
PikaFillType layer_new_fill_type;
PikaFillType layer_resize_fill_type;
PikaAddMaskType layer_add_mask_type;
gboolean layer_add_mask_invert;
PikaMergeType layer_merge_type;
gboolean layer_merge_active_group_only;
gboolean layer_merge_discard_invisible;
gchar *channel_new_name;
PikaRGB channel_new_color;
gchar *vectors_new_name;
gchar *vectors_export_path;
gboolean vectors_export_active_only;
gchar *vectors_import_path;
gboolean vectors_import_merge;
gboolean vectors_import_scale;
gdouble selection_feather_radius;
gboolean selection_feather_edge_lock;
gdouble selection_grow_radius;
gdouble selection_shrink_radius;
gboolean selection_shrink_edge_lock;
gdouble selection_border_radius;
gboolean selection_border_edge_lock;
PikaChannelBorderStyle selection_border_style;
PikaFillOptions *fill_options;
PikaStrokeOptions *stroke_options;
};
struct _PikaDialogConfigClass
{
PikaGuiConfigClass parent_class;
};
GType pika_dialog_config_get_type (void) G_GNUC_CONST;
#endif /* PIKA_DIALOG_CONFIG_H__ */

View File

@ -0,0 +1,703 @@
/* PIKA - Photo and Image Kooker Application
* a rebranding of The GNU Image Manipulation Program (created with heckimp)
* A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
*
* Original copyright, applying to most contents (license remains unchanged):
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* PikaDisplayConfig class
* Copyright (C) 2001 Sven Neumann <sven@gimp.org>
*
* 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 <https://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <cairo.h>
#include <gegl.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include "libpikabase/pikabase.h"
#include "libpikacolor/pikacolor.h"
#include "libpikaconfig/pikaconfig.h"
#include "config-types.h"
#include "pikarc-blurbs.h"
#include "pikadisplayconfig.h"
#include "pikadisplayoptions.h"
#include "pika-intl.h"
#define DEFAULT_ACTIVATE_ON_FOCUS TRUE
#define DEFAULT_MONITOR_RESOLUTION 96.0
#define DEFAULT_MARCHING_ANTS_SPEED 200
#define DEFAULT_USE_EVENT_HISTORY FALSE
enum
{
PROP_0,
PROP_TRANSPARENCY_SIZE,
PROP_TRANSPARENCY_TYPE,
PROP_TRANSPARENCY_CUSTOM_COLOR1,
PROP_TRANSPARENCY_CUSTOM_COLOR2,
PROP_SNAP_DISTANCE,
PROP_MARCHING_ANTS_SPEED,
PROP_RESIZE_WINDOWS_ON_ZOOM,
PROP_RESIZE_WINDOWS_ON_RESIZE,
PROP_DEFAULT_SHOW_ALL,
PROP_DEFAULT_DOT_FOR_DOT,
PROP_INITIAL_ZOOM_TO_FIT,
PROP_DRAG_ZOOM_MODE,
PROP_DRAG_ZOOM_SPEED,
PROP_CURSOR_MODE,
PROP_CURSOR_UPDATING,
PROP_SHOW_BRUSH_OUTLINE,
PROP_SNAP_BRUSH_OUTLINE,
PROP_SHOW_PAINT_TOOL_CURSOR,
PROP_IMAGE_TITLE_FORMAT,
PROP_IMAGE_STATUS_FORMAT,
PROP_MODIFIERS_MANAGER,
PROP_MONITOR_XRESOLUTION,
PROP_MONITOR_YRESOLUTION,
PROP_MONITOR_RES_FROM_GDK,
PROP_NAV_PREVIEW_SIZE,
PROP_DEFAULT_VIEW,
PROP_DEFAULT_FULLSCREEN_VIEW,
PROP_ACTIVATE_ON_FOCUS,
PROP_SPACE_BAR_ACTION,
PROP_ZOOM_QUALITY,
PROP_USE_EVENT_HISTORY,
/* ignored, only for backward compatibility: */
PROP_DEFAULT_SNAP_TO_GUIDES,
PROP_DEFAULT_SNAP_TO_GRID,
PROP_DEFAULT_SNAP_TO_CANVAS,
PROP_DEFAULT_SNAP_TO_PATH,
PROP_CONFIRM_ON_CLOSE,
PROP_XOR_COLOR,
PROP_PERFECT_MOUSE
};
static void pika_display_config_finalize (GObject *object);
static void pika_display_config_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void pika_display_config_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void pika_display_config_view_notify (GObject *object,
GParamSpec *pspec,
gpointer data);
static void pika_display_config_fullscreen_notify (GObject *object,
GParamSpec *pspec,
gpointer data);
G_DEFINE_TYPE (PikaDisplayConfig, pika_display_config, PIKA_TYPE_CORE_CONFIG)
#define parent_class pika_display_config_parent_class
static void
pika_display_config_class_init (PikaDisplayConfigClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
PikaRGB color = { 0, 0, 0, 0 };
object_class->finalize = pika_display_config_finalize;
object_class->set_property = pika_display_config_set_property;
object_class->get_property = pika_display_config_get_property;
PIKA_CONFIG_PROP_ENUM (object_class, PROP_TRANSPARENCY_SIZE,
"transparency-size",
"Transparency size",
TRANSPARENCY_SIZE_BLURB,
PIKA_TYPE_CHECK_SIZE,
PIKA_CHECK_SIZE_MEDIUM_CHECKS,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_ENUM (object_class, PROP_TRANSPARENCY_TYPE,
"transparency-type",
"Transparency type",
TRANSPARENCY_TYPE_BLURB,
PIKA_TYPE_CHECK_TYPE,
PIKA_CHECK_TYPE_GRAY_CHECKS,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_RGB (object_class, PROP_TRANSPARENCY_CUSTOM_COLOR1,
"transparency-custom-color1",
"Transparency custom color 1",
TRANSPARENCY_CUSTOM_COLOR1_BLURB,
FALSE, &PIKA_CHECKS_CUSTOM_COLOR1,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_RGB (object_class, PROP_TRANSPARENCY_CUSTOM_COLOR2,
"transparency-custom-color2",
"Transparency custom color 2",
TRANSPARENCY_CUSTOM_COLOR2_BLURB,
FALSE, &PIKA_CHECKS_CUSTOM_COLOR2,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_INT (object_class, PROP_SNAP_DISTANCE,
"snap-distance",
"Snap distance",
DEFAULT_SNAP_DISTANCE_BLURB,
1, 255, 8,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_INT (object_class, PROP_MARCHING_ANTS_SPEED,
"marching-ants-speed",
"Marching ants speed",
MARCHING_ANTS_SPEED_BLURB,
10, 10000, DEFAULT_MARCHING_ANTS_SPEED,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_RESIZE_WINDOWS_ON_ZOOM,
"resize-windows-on-zoom",
"Resize windows on zoom",
RESIZE_WINDOWS_ON_ZOOM_BLURB,
FALSE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_RESIZE_WINDOWS_ON_RESIZE,
"resize-windows-on-resize",
"Resize windows on resize",
RESIZE_WINDOWS_ON_RESIZE_BLURB,
FALSE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_DEFAULT_SHOW_ALL,
"default-show-all",
"Default show-all",
DEFAULT_SHOW_ALL_BLURB,
FALSE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_DEFAULT_DOT_FOR_DOT,
"default-dot-for-dot",
"Default dot-for-dot",
DEFAULT_DOT_FOR_DOT_BLURB,
TRUE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_INITIAL_ZOOM_TO_FIT,
"initial-zoom-to-fit",
"Initial zoom-to-fit",
INITIAL_ZOOM_TO_FIT_BLURB,
TRUE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_ENUM (object_class, PROP_DRAG_ZOOM_MODE,
"drag-zoom-mode",
"Drag-to-zoom behavior",
DRAG_ZOOM_MODE_BLURB,
PIKA_TYPE_DRAG_ZOOM_MODE,
PROP_DRAG_ZOOM_MODE_DISTANCE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_DOUBLE(object_class, PROP_DRAG_ZOOM_SPEED,
"drag-zoom-speed",
"Drag-to-zoom speed",
DRAG_ZOOM_SPEED_BLURB,
25.0, 300.0, 100.0,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_ENUM (object_class, PROP_CURSOR_MODE,
"cursor-mode",
"Cursor mode",
CURSOR_MODE_BLURB,
PIKA_TYPE_CURSOR_MODE,
PIKA_CURSOR_MODE_TOOL_CROSSHAIR,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_CURSOR_UPDATING,
"cursor-updating",
"Cursor updating",
CURSOR_UPDATING_BLURB,
TRUE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_SHOW_BRUSH_OUTLINE,
"show-brush-outline",
"Show brush outline",
SHOW_BRUSH_OUTLINE_BLURB,
TRUE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_SNAP_BRUSH_OUTLINE,
"snap-brush-outline",
"Snap brush outline",
SNAP_BRUSH_OUTLINE_BLURB,
FALSE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_SHOW_PAINT_TOOL_CURSOR,
"show-paint-tool-cursor",
"Show paint tool cursor",
SHOW_PAINT_TOOL_CURSOR_BLURB,
TRUE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_STRING (object_class, PROP_IMAGE_TITLE_FORMAT,
"image-title-format",
"Image title format",
IMAGE_TITLE_FORMAT_BLURB,
PIKA_CONFIG_DEFAULT_IMAGE_TITLE_FORMAT,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_STRING (object_class, PROP_IMAGE_STATUS_FORMAT,
"image-status-format",
"Image statusbar format",
IMAGE_STATUS_FORMAT_BLURB,
PIKA_CONFIG_DEFAULT_IMAGE_STATUS_FORMAT,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_RESOLUTION (object_class, PROP_MONITOR_XRESOLUTION,
"monitor-xresolution",
"Monitor resolution X",
MONITOR_XRESOLUTION_BLURB,
DEFAULT_MONITOR_RESOLUTION,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_RESOLUTION (object_class, PROP_MONITOR_YRESOLUTION,
"monitor-yresolution",
"Monitor resolution Y",
MONITOR_YRESOLUTION_BLURB,
DEFAULT_MONITOR_RESOLUTION,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_MONITOR_RES_FROM_GDK,
"monitor-resolution-from-windowing-system",
"Monitor resolution from windowing system",
MONITOR_RES_FROM_GDK_BLURB,
TRUE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_ENUM (object_class, PROP_NAV_PREVIEW_SIZE,
"navigation-preview-size",
"Navigation preview size",
NAVIGATION_PREVIEW_SIZE_BLURB,
PIKA_TYPE_VIEW_SIZE,
PIKA_VIEW_SIZE_MEDIUM,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_OBJECT (object_class, PROP_DEFAULT_VIEW,
"default-view",
"Default view options",
DEFAULT_VIEW_BLURB,
PIKA_TYPE_DISPLAY_OPTIONS,
PIKA_PARAM_STATIC_STRINGS |
PIKA_CONFIG_PARAM_AGGREGATE);
PIKA_CONFIG_PROP_OBJECT (object_class, PROP_DEFAULT_FULLSCREEN_VIEW,
"default-fullscreen-view",
"Default fullscreen view options",
DEFAULT_FULLSCREEN_VIEW_BLURB,
PIKA_TYPE_DISPLAY_OPTIONS,
PIKA_PARAM_STATIC_STRINGS |
PIKA_CONFIG_PARAM_AGGREGATE);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_ACTIVATE_ON_FOCUS,
"activate-on-focus",
"Activate on focus",
ACTIVATE_ON_FOCUS_BLURB,
DEFAULT_ACTIVATE_ON_FOCUS,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_ENUM (object_class, PROP_SPACE_BAR_ACTION,
"space-bar-action",
"Space bar action",
SPACE_BAR_ACTION_BLURB,
PIKA_TYPE_SPACE_BAR_ACTION,
PIKA_SPACE_BAR_ACTION_PAN,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_ENUM (object_class, PROP_ZOOM_QUALITY,
"zoom-quality",
"Zoom quality",
ZOOM_QUALITY_BLURB,
PIKA_TYPE_ZOOM_QUALITY,
PIKA_ZOOM_QUALITY_HIGH,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_USE_EVENT_HISTORY,
"use-event-history",
"Use event history",
DEFAULT_USE_EVENT_HISTORY_BLURB,
DEFAULT_USE_EVENT_HISTORY,
PIKA_PARAM_STATIC_STRINGS);
/* only for backward compatibility: */
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_DEFAULT_SNAP_TO_GUIDES,
"default-snap-to-guides",
NULL, NULL,
TRUE,
PIKA_PARAM_STATIC_STRINGS |
PIKA_CONFIG_PARAM_IGNORE);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_DEFAULT_SNAP_TO_GRID,
"default-snap-to-grid",
NULL, NULL,
FALSE,
PIKA_PARAM_STATIC_STRINGS |
PIKA_CONFIG_PARAM_IGNORE);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_DEFAULT_SNAP_TO_CANVAS,
"default-snap-to-canvas",
NULL, NULL,
FALSE,
PIKA_PARAM_STATIC_STRINGS |
PIKA_CONFIG_PARAM_IGNORE);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_DEFAULT_SNAP_TO_PATH,
"default-snap-to-path",
NULL, NULL,
FALSE,
PIKA_PARAM_STATIC_STRINGS |
PIKA_CONFIG_PARAM_IGNORE);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_CONFIRM_ON_CLOSE,
"confirm-on-close",
NULL, NULL,
TRUE,
PIKA_PARAM_STATIC_STRINGS |
PIKA_CONFIG_PARAM_IGNORE);
PIKA_CONFIG_PROP_RGB (object_class, PROP_XOR_COLOR,
"xor-color",
NULL, NULL,
FALSE, &color,
PIKA_PARAM_STATIC_STRINGS |
PIKA_CONFIG_PARAM_IGNORE);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_PERFECT_MOUSE,
"perfect-mouse",
NULL, NULL,
TRUE,
PIKA_PARAM_STATIC_STRINGS |
PIKA_CONFIG_PARAM_IGNORE);
/* Stored as a property because we want to copy the object when we
* copy the config (for Preferences, etc.). But we don't want it to be
* stored as a config property into the rc files.
* Modifiers have their own rc file.
*/
g_object_class_install_property (object_class, PROP_MODIFIERS_MANAGER,
g_param_spec_object ("modifiers-manager",
NULL, NULL,
G_TYPE_OBJECT,
PIKA_PARAM_READWRITE));
}
static void
pika_display_config_init (PikaDisplayConfig *config)
{
config->default_view =
g_object_new (PIKA_TYPE_DISPLAY_OPTIONS, NULL);
g_signal_connect (config->default_view, "notify",
G_CALLBACK (pika_display_config_view_notify),
config);
config->default_fullscreen_view =
g_object_new (PIKA_TYPE_DISPLAY_OPTIONS, NULL);
g_signal_connect (config->default_fullscreen_view, "notify",
G_CALLBACK (pika_display_config_fullscreen_notify),
config);
}
static void
pika_display_config_finalize (GObject *object)
{
PikaDisplayConfig *display_config = PIKA_DISPLAY_CONFIG (object);
g_free (display_config->image_title_format);
g_free (display_config->image_status_format);
g_clear_object (&display_config->default_view);
g_clear_object (&display_config->default_fullscreen_view);
g_clear_object (&display_config->modifiers_manager);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
pika_display_config_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
PikaDisplayConfig *display_config = PIKA_DISPLAY_CONFIG (object);
switch (property_id)
{
case PROP_TRANSPARENCY_SIZE:
display_config->transparency_size = g_value_get_enum (value);
break;
case PROP_TRANSPARENCY_TYPE:
display_config->transparency_type = g_value_get_enum (value);
break;
case PROP_TRANSPARENCY_CUSTOM_COLOR1:
display_config->transparency_custom_color1 = *(PikaRGB *) g_value_get_boxed (value);
break;
case PROP_TRANSPARENCY_CUSTOM_COLOR2:
display_config->transparency_custom_color2 = *(PikaRGB *) g_value_get_boxed (value);
break;
case PROP_SNAP_DISTANCE:
display_config->snap_distance = g_value_get_int (value);
break;
case PROP_MARCHING_ANTS_SPEED:
display_config->marching_ants_speed = g_value_get_int (value);
break;
case PROP_RESIZE_WINDOWS_ON_ZOOM:
display_config->resize_windows_on_zoom = g_value_get_boolean (value);
break;
case PROP_RESIZE_WINDOWS_ON_RESIZE:
display_config->resize_windows_on_resize = g_value_get_boolean (value);
break;
case PROP_DEFAULT_SHOW_ALL:
display_config->default_show_all = g_value_get_boolean (value);
break;
case PROP_DEFAULT_DOT_FOR_DOT:
display_config->default_dot_for_dot = g_value_get_boolean (value);
break;
case PROP_INITIAL_ZOOM_TO_FIT:
display_config->initial_zoom_to_fit = g_value_get_boolean (value);
break;
case PROP_DRAG_ZOOM_MODE:
display_config->drag_zoom_mode = g_value_get_enum (value);
break;
case PROP_DRAG_ZOOM_SPEED:
display_config->drag_zoom_speed = g_value_get_double (value);
break;
case PROP_CURSOR_MODE:
display_config->cursor_mode = g_value_get_enum (value);
break;
case PROP_CURSOR_UPDATING:
display_config->cursor_updating = g_value_get_boolean (value);
break;
case PROP_SHOW_BRUSH_OUTLINE:
display_config->show_brush_outline = g_value_get_boolean (value);
break;
case PROP_SNAP_BRUSH_OUTLINE:
display_config->snap_brush_outline = g_value_get_boolean (value);
break;
case PROP_SHOW_PAINT_TOOL_CURSOR:
display_config->show_paint_tool_cursor = g_value_get_boolean (value);
break;
case PROP_IMAGE_TITLE_FORMAT:
g_free (display_config->image_title_format);
display_config->image_title_format = g_value_dup_string (value);
break;
case PROP_IMAGE_STATUS_FORMAT:
g_free (display_config->image_status_format);
display_config->image_status_format = g_value_dup_string (value);
break;
case PROP_MONITOR_XRESOLUTION:
display_config->monitor_xres = g_value_get_double (value);
break;
case PROP_MONITOR_YRESOLUTION:
display_config->monitor_yres = g_value_get_double (value);
break;
case PROP_MONITOR_RES_FROM_GDK:
display_config->monitor_res_from_gdk = g_value_get_boolean (value);
break;
case PROP_NAV_PREVIEW_SIZE:
display_config->nav_preview_size = g_value_get_enum (value);
break;
case PROP_DEFAULT_VIEW:
if (g_value_get_object (value))
pika_config_sync (g_value_get_object (value),
G_OBJECT (display_config->default_view), 0);
break;
case PROP_DEFAULT_FULLSCREEN_VIEW:
if (g_value_get_object (value))
pika_config_sync (g_value_get_object (value),
G_OBJECT (display_config->default_fullscreen_view),
0);
break;
case PROP_ACTIVATE_ON_FOCUS:
display_config->activate_on_focus = g_value_get_boolean (value);
break;
case PROP_SPACE_BAR_ACTION:
display_config->space_bar_action = g_value_get_enum (value);
break;
case PROP_MODIFIERS_MANAGER:
display_config->modifiers_manager = g_value_dup_object (value);
break;
case PROP_ZOOM_QUALITY:
display_config->zoom_quality = g_value_get_enum (value);
break;
case PROP_USE_EVENT_HISTORY:
display_config->use_event_history = g_value_get_boolean (value);
break;
case PROP_DEFAULT_SNAP_TO_GUIDES:
case PROP_DEFAULT_SNAP_TO_GRID:
case PROP_DEFAULT_SNAP_TO_CANVAS:
case PROP_DEFAULT_SNAP_TO_PATH:
case PROP_CONFIRM_ON_CLOSE:
case PROP_XOR_COLOR:
case PROP_PERFECT_MOUSE:
/* ignored */
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
pika_display_config_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
PikaDisplayConfig *display_config = PIKA_DISPLAY_CONFIG (object);
switch (property_id)
{
case PROP_TRANSPARENCY_SIZE:
g_value_set_enum (value, display_config->transparency_size);
break;
case PROP_TRANSPARENCY_TYPE:
g_value_set_enum (value, display_config->transparency_type);
break;
case PROP_TRANSPARENCY_CUSTOM_COLOR1:
g_value_set_boxed (value, &display_config->transparency_custom_color1);
break;
case PROP_TRANSPARENCY_CUSTOM_COLOR2:
g_value_set_boxed (value, &display_config->transparency_custom_color2);
break;
case PROP_SNAP_DISTANCE:
g_value_set_int (value, display_config->snap_distance);
break;
case PROP_MARCHING_ANTS_SPEED:
g_value_set_int (value, display_config->marching_ants_speed);
break;
case PROP_RESIZE_WINDOWS_ON_ZOOM:
g_value_set_boolean (value, display_config->resize_windows_on_zoom);
break;
case PROP_RESIZE_WINDOWS_ON_RESIZE:
g_value_set_boolean (value, display_config->resize_windows_on_resize);
break;
case PROP_DEFAULT_SHOW_ALL:
g_value_set_boolean (value, display_config->default_show_all);
break;
case PROP_DEFAULT_DOT_FOR_DOT:
g_value_set_boolean (value, display_config->default_dot_for_dot);
break;
case PROP_INITIAL_ZOOM_TO_FIT:
g_value_set_boolean (value, display_config->initial_zoom_to_fit);
break;
case PROP_DRAG_ZOOM_MODE:
g_value_set_enum (value, display_config->drag_zoom_mode);
break;
case PROP_DRAG_ZOOM_SPEED:
g_value_set_double (value, display_config->drag_zoom_speed);
break;
case PROP_CURSOR_MODE:
g_value_set_enum (value, display_config->cursor_mode);
break;
case PROP_CURSOR_UPDATING:
g_value_set_boolean (value, display_config->cursor_updating);
break;
case PROP_SHOW_BRUSH_OUTLINE:
g_value_set_boolean (value, display_config->show_brush_outline);
break;
case PROP_SNAP_BRUSH_OUTLINE:
g_value_set_boolean (value, display_config->snap_brush_outline);
break;
case PROP_SHOW_PAINT_TOOL_CURSOR:
g_value_set_boolean (value, display_config->show_paint_tool_cursor);
break;
case PROP_IMAGE_TITLE_FORMAT:
g_value_set_string (value, display_config->image_title_format);
break;
case PROP_IMAGE_STATUS_FORMAT:
g_value_set_string (value, display_config->image_status_format);
break;
case PROP_MONITOR_XRESOLUTION:
g_value_set_double (value, display_config->monitor_xres);
break;
case PROP_MONITOR_YRESOLUTION:
g_value_set_double (value, display_config->monitor_yres);
break;
case PROP_MONITOR_RES_FROM_GDK:
g_value_set_boolean (value, display_config->monitor_res_from_gdk);
break;
case PROP_NAV_PREVIEW_SIZE:
g_value_set_enum (value, display_config->nav_preview_size);
break;
case PROP_DEFAULT_VIEW:
g_value_set_object (value, display_config->default_view);
break;
case PROP_DEFAULT_FULLSCREEN_VIEW:
g_value_set_object (value, display_config->default_fullscreen_view);
break;
case PROP_ACTIVATE_ON_FOCUS:
g_value_set_boolean (value, display_config->activate_on_focus);
break;
case PROP_SPACE_BAR_ACTION:
g_value_set_enum (value, display_config->space_bar_action);
break;
case PROP_MODIFIERS_MANAGER:
g_value_set_object (value, display_config->modifiers_manager);
break;
case PROP_ZOOM_QUALITY:
g_value_set_enum (value, display_config->zoom_quality);
break;
case PROP_USE_EVENT_HISTORY:
g_value_set_boolean (value, display_config->use_event_history);
break;
case PROP_DEFAULT_SNAP_TO_GUIDES:
case PROP_DEFAULT_SNAP_TO_GRID:
case PROP_DEFAULT_SNAP_TO_CANVAS:
case PROP_DEFAULT_SNAP_TO_PATH:
case PROP_CONFIRM_ON_CLOSE:
case PROP_XOR_COLOR:
case PROP_PERFECT_MOUSE:
/* ignored */
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
pika_display_config_view_notify (GObject *object,
GParamSpec *pspec,
gpointer data)
{
g_object_notify (G_OBJECT (data), "default-view");
}
static void
pika_display_config_fullscreen_notify (GObject *object,
GParamSpec *pspec,
gpointer data)
{
g_object_notify (G_OBJECT (data), "default-fullscreen-view");
}

View File

@ -0,0 +1,91 @@
/* PIKA - Photo and Image Kooker Application
* a rebranding of The GNU Image Manipulation Program (created with heckimp)
* A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
*
* Original copyright, applying to most contents (license remains unchanged):
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* PikaDisplayConfig class
* Copyright (C) 2001 Sven Neumann <sven@gimp.org>
*
* 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 <https://www.gnu.org/licenses/>.
*/
#ifndef __PIKA_DISPLAY_CONFIG_H__
#define __PIKA_DISPLAY_CONFIG_H__
#include "config/pikacoreconfig.h"
#define PIKA_CONFIG_DEFAULT_IMAGE_TITLE_FORMAT "%D*%f-%p.%i (%t, %o, %L) %wx%h"
#define PIKA_CONFIG_DEFAULT_IMAGE_STATUS_FORMAT "%n (%m)"
#define PIKA_TYPE_DISPLAY_CONFIG (pika_display_config_get_type ())
#define PIKA_DISPLAY_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PIKA_TYPE_DISPLAY_CONFIG, PikaDisplayConfig))
#define PIKA_DISPLAY_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PIKA_TYPE_DISPLAY_CONFIG, PikaDisplayConfigClass))
#define PIKA_IS_DISPLAY_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PIKA_TYPE_DISPLAY_CONFIG))
#define PIKA_IS_DISPLAY_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PIKA_TYPE_DISPLAY_CONFIG))
typedef struct _PikaDisplayConfigClass PikaDisplayConfigClass;
struct _PikaDisplayConfig
{
PikaCoreConfig parent_instance;
PikaCheckSize transparency_size;
PikaCheckType transparency_type;
PikaRGB transparency_custom_color1;
PikaRGB transparency_custom_color2;
gint snap_distance;
gint marching_ants_speed;
gboolean resize_windows_on_zoom;
gboolean resize_windows_on_resize;
gboolean default_show_all;
gboolean default_dot_for_dot;
gboolean initial_zoom_to_fit;
PikaDragZoomMode drag_zoom_mode;
gboolean drag_zoom_speed;
PikaCursorMode cursor_mode;
gboolean cursor_updating;
gboolean show_brush_outline;
gboolean snap_brush_outline;
gboolean show_paint_tool_cursor;
gchar *image_title_format;
gchar *image_status_format;
gdouble monitor_xres;
gdouble monitor_yres;
gboolean monitor_res_from_gdk;
PikaViewSize nav_preview_size;
PikaDisplayOptions *default_view;
PikaDisplayOptions *default_fullscreen_view;
gboolean activate_on_focus;
PikaSpaceBarAction space_bar_action;
PikaZoomQuality zoom_quality;
gboolean use_event_history;
GObject *modifiers_manager;
};
struct _PikaDisplayConfigClass
{
PikaCoreConfigClass parent_class;
};
GType pika_display_config_get_type (void) G_GNUC_CONST;
#endif /* PIKA_DISPLAY_CONFIG_H__ */

View File

@ -0,0 +1,657 @@
/* PIKA - Photo and Image Kooker Application
* a rebranding of The GNU Image Manipulation Program (created with heckimp)
* A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
*
* Original copyright, applying to most contents (license remains unchanged):
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* PikaDisplayOptions
* Copyright (C) 2003 Sven Neumann <sven@gimp.org>
*
* 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 <https://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <cairo.h>
#include <gegl.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include "libpikabase/pikabase.h"
#include "libpikamath/pikamath.h"
#include "libpikacolor/pikacolor.h"
#include "libpikaconfig/pikaconfig.h"
#include "config-types.h"
#include "pikarc-blurbs.h"
#include "pikadisplayoptions.h"
#include "pika-intl.h"
enum
{
PROP_0,
PROP_SHOW_MENUBAR,
PROP_SHOW_STATUSBAR,
PROP_SHOW_RULERS,
PROP_SHOW_SCROLLBARS,
PROP_SHOW_SELECTION,
PROP_SHOW_LAYER_BOUNDARY,
PROP_SHOW_CANVAS_BOUNDARY,
PROP_SHOW_GUIDES,
PROP_SHOW_GRID,
PROP_SHOW_SAMPLE_POINTS,
PROP_SNAP_TO_GUIDES,
PROP_SNAP_TO_GRID,
PROP_SNAP_TO_CANVAS,
PROP_SNAP_TO_PATH,
PROP_SNAP_TO_BBOX,
PROP_SNAP_TO_EQUIDISTANCE,
PROP_PADDING_MODE,
PROP_PADDING_COLOR,
PROP_PADDING_IN_SHOW_ALL
};
static void pika_display_options_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void pika_display_options_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
G_DEFINE_TYPE_WITH_CODE (PikaDisplayOptions,
pika_display_options,
G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (PIKA_TYPE_CONFIG, NULL))
typedef struct _PikaDisplayOptions PikaDisplayOptionsFullscreen;
typedef struct _PikaDisplayOptionsClass PikaDisplayOptionsFullscreenClass;
#define pika_display_options_fullscreen_init pika_display_options_init
G_DEFINE_TYPE_WITH_CODE (PikaDisplayOptionsFullscreen,
pika_display_options_fullscreen,
PIKA_TYPE_DISPLAY_OPTIONS,
G_IMPLEMENT_INTERFACE (PIKA_TYPE_CONFIG, NULL))
typedef struct _PikaDisplayOptions PikaDisplayOptionsNoImage;
typedef struct _PikaDisplayOptionsClass PikaDisplayOptionsNoImageClass;
#define pika_display_options_no_image_init pika_display_options_init
G_DEFINE_TYPE_WITH_CODE (PikaDisplayOptionsNoImage,
pika_display_options_no_image,
PIKA_TYPE_DISPLAY_OPTIONS,
G_IMPLEMENT_INTERFACE (PIKA_TYPE_CONFIG, NULL))
static void
pika_display_options_class_init (PikaDisplayOptionsClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
PikaRGB white;
pika_rgba_set (&white, 1.0, 1.0, 1.0, PIKA_OPACITY_OPAQUE);
object_class->set_property = pika_display_options_set_property;
object_class->get_property = pika_display_options_get_property;
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_SHOW_MENUBAR,
"show-menubar",
"Show menubar",
SHOW_MENUBAR_BLURB,
TRUE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_SHOW_STATUSBAR,
"show-statusbar",
"Show statusbar",
SHOW_STATUSBAR_BLURB,
TRUE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_SHOW_RULERS,
"show-rulers",
"Show rulers",
SHOW_RULERS_BLURB,
TRUE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_SHOW_SCROLLBARS,
"show-scrollbars",
"Show scrollbars",
SHOW_SCROLLBARS_BLURB,
TRUE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_SHOW_SELECTION,
"show-selection",
"Show selection",
SHOW_SELECTION_BLURB,
TRUE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_SHOW_LAYER_BOUNDARY,
"show-layer-boundary",
"Show layer boundary",
SHOW_LAYER_BOUNDARY_BLURB,
TRUE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_SHOW_CANVAS_BOUNDARY,
"show-canvas-boundary",
"Show canvas boundary",
SHOW_CANVAS_BOUNDARY_BLURB,
TRUE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_SHOW_GUIDES,
"show-guides",
"Show guides",
SHOW_GUIDES_BLURB,
TRUE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_SHOW_GRID,
"show-grid",
"Show grid",
SHOW_GRID_BLURB,
FALSE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_SHOW_SAMPLE_POINTS,
"show-sample-points",
"Show sample points",
SHOW_SAMPLE_POINTS_BLURB,
TRUE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_SNAP_TO_GUIDES,
"snap-to-guides",
"Snap to guides",
SNAP_TO_GUIDES_BLURB,
TRUE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_SNAP_TO_GRID,
"snap-to-grid",
"Snap to grid",
SNAP_TO_GRID_BLURB,
FALSE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_SNAP_TO_CANVAS,
"snap-to-canvas",
"Snap to canvas",
SNAP_TO_CANVAS_BLURB,
FALSE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_SNAP_TO_PATH,
"snap-to-path",
"Snap to path",
SNAP_TO_PATH_BLURB,
FALSE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_SNAP_TO_BBOX,
"snap-to-bbox",
"Snap to bounding boxes",
SNAP_TO_BBOX_BLURB,
FALSE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_SNAP_TO_EQUIDISTANCE,
"snap-to-equidistance",
"Snap to Equidistance",
SNAP_TO_EQUIDISTANCE_BLURB,
FALSE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_ENUM (object_class, PROP_PADDING_MODE,
"padding-mode",
"Padding mode",
CANVAS_PADDING_MODE_BLURB,
PIKA_TYPE_CANVAS_PADDING_MODE,
PIKA_CANVAS_PADDING_MODE_DEFAULT,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_RGB (object_class, PROP_PADDING_COLOR,
"padding-color",
"Padding color",
CANVAS_PADDING_COLOR_BLURB,
FALSE, &white,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_PADDING_IN_SHOW_ALL,
"padding-in-show-all",
"Keep padding in \"Show All\" mode",
CANVAS_PADDING_IN_SHOW_ALL_BLURB,
FALSE,
PIKA_PARAM_STATIC_STRINGS);
}
static void
pika_display_options_fullscreen_class_init (PikaDisplayOptionsFullscreenClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
PikaRGB black;
pika_rgba_set (&black, 0.0, 0.0, 0.0, PIKA_OPACITY_OPAQUE);
object_class->set_property = pika_display_options_set_property;
object_class->get_property = pika_display_options_get_property;
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_SHOW_MENUBAR,
"show-menubar",
"Show menubar",
SHOW_MENUBAR_BLURB,
FALSE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_SHOW_STATUSBAR,
"show-statusbar",
"Show statusbar",
SHOW_STATUSBAR_BLURB,
FALSE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_SHOW_RULERS,
"show-rulers",
"Show rulers",
SHOW_RULERS_BLURB,
FALSE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_SHOW_SCROLLBARS,
"show-scrollbars",
"Show scrollbars",
SHOW_SCROLLBARS_BLURB,
FALSE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_SHOW_SELECTION,
"show-selection",
"Show selection",
SHOW_SELECTION_BLURB,
FALSE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_SHOW_LAYER_BOUNDARY,
"show-layer-boundary",
"Show layer boundary",
SHOW_LAYER_BOUNDARY_BLURB,
FALSE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_SHOW_CANVAS_BOUNDARY,
"show-canvas-boundary",
"Show canvas boundary",
SHOW_CANVAS_BOUNDARY_BLURB,
FALSE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_SHOW_GUIDES,
"show-guides",
"Show guides",
SHOW_GUIDES_BLURB,
FALSE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_SHOW_GRID,
"show-grid",
"Show grid",
SHOW_GRID_BLURB,
FALSE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_SHOW_SAMPLE_POINTS,
"show-sample-points",
"Show sample points",
SHOW_SAMPLE_POINTS_BLURB,
FALSE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_SNAP_TO_GUIDES,
"snap-to-guides",
"Snap to guides",
SNAP_TO_GUIDES_BLURB,
TRUE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_SNAP_TO_GRID,
"snap-to-grid",
"Snap to grid",
SHOW_SCROLLBARS_BLURB,
FALSE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_SNAP_TO_CANVAS,
"snap-to-canvas",
"Snap to canvas",
SNAP_TO_CANVAS_BLURB,
FALSE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_SNAP_TO_PATH,
"snap-to-path",
"Snap to path",
SNAP_TO_PATH_BLURB,
FALSE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_SNAP_TO_BBOX,
"snap-to-bbox",
"Snap to bounding boxes",
SNAP_TO_BBOX_BLURB,
FALSE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_SNAP_TO_EQUIDISTANCE,
"snap-to-equidistance",
"Snap to Equidistance",
SNAP_TO_EQUIDISTANCE_BLURB,
FALSE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_ENUM (object_class, PROP_PADDING_MODE,
"padding-mode",
"Padding mode",
CANVAS_PADDING_MODE_BLURB,
PIKA_TYPE_CANVAS_PADDING_MODE,
PIKA_CANVAS_PADDING_MODE_CUSTOM,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_RGB (object_class, PROP_PADDING_COLOR,
"padding-color",
"Padding color",
CANVAS_PADDING_COLOR_BLURB,
FALSE, &black,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_PADDING_IN_SHOW_ALL,
"padding-in-show-all",
"Keep padding in \"Show All\" mode",
CANVAS_PADDING_IN_SHOW_ALL_BLURB,
FALSE,
PIKA_PARAM_STATIC_STRINGS);
}
static void
pika_display_options_no_image_class_init (PikaDisplayOptionsNoImageClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->set_property = pika_display_options_set_property;
object_class->get_property = pika_display_options_get_property;
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_SHOW_RULERS,
"show-rulers",
"Show rulers",
SHOW_RULERS_BLURB,
FALSE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_SHOW_SCROLLBARS,
"show-scrollbars",
"Show scrollbars",
SHOW_SCROLLBARS_BLURB,
FALSE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_SHOW_SELECTION,
"show-selection",
"Show selection",
SHOW_SELECTION_BLURB,
FALSE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_SHOW_LAYER_BOUNDARY,
"show-layer-boundary",
"Show layer boundary",
SHOW_LAYER_BOUNDARY_BLURB,
FALSE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_SHOW_CANVAS_BOUNDARY,
"show-canvas-boundary",
"Show canvas boundary",
SHOW_CANVAS_BOUNDARY_BLURB,
FALSE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_SHOW_GUIDES,
"show-guides",
"Show guides",
SHOW_GUIDES_BLURB,
FALSE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_SHOW_GRID,
"show-grid",
"Show grid",
SHOW_GRID_BLURB,
FALSE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_SHOW_SAMPLE_POINTS,
"show-sample-points",
"Show sample points",
SHOW_SAMPLE_POINTS_BLURB,
FALSE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_SNAP_TO_GUIDES,
"snap-to-guides",
"Snap to guides",
SNAP_TO_GUIDES_BLURB,
TRUE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_SNAP_TO_GRID,
"snap-to-grid",
"Snap to grid",
SHOW_SCROLLBARS_BLURB,
FALSE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_SNAP_TO_CANVAS,
"snap-to-canvas",
"Snap to canvas",
SNAP_TO_CANVAS_BLURB,
FALSE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_SNAP_TO_PATH,
"snap-to-path",
"Snap tp path",
SNAP_TO_PATH_BLURB,
FALSE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_SNAP_TO_BBOX,
"snap-to-bbox",
"Snap to bounding boxes",
SNAP_TO_BBOX_BLURB,
FALSE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_SNAP_TO_EQUIDISTANCE,
"snap-to-equidistance",
"Snap to Equidistance",
SNAP_TO_EQUIDISTANCE_BLURB,
FALSE,
PIKA_PARAM_STATIC_STRINGS);
}
static void
pika_display_options_init (PikaDisplayOptions *options)
{
options->padding_mode_set = FALSE;
}
static void
pika_display_options_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
PikaDisplayOptions *options = PIKA_DISPLAY_OPTIONS (object);
switch (property_id)
{
case PROP_SHOW_MENUBAR:
options->show_menubar = g_value_get_boolean (value);
break;
case PROP_SHOW_STATUSBAR:
options->show_statusbar = g_value_get_boolean (value);
break;
case PROP_SHOW_RULERS:
options->show_rulers = g_value_get_boolean (value);
break;
case PROP_SHOW_SCROLLBARS:
options->show_scrollbars = g_value_get_boolean (value);
break;
case PROP_SHOW_SELECTION:
options->show_selection = g_value_get_boolean (value);
break;
case PROP_SHOW_LAYER_BOUNDARY:
options->show_layer_boundary = g_value_get_boolean (value);
break;
case PROP_SHOW_CANVAS_BOUNDARY:
options->show_canvas_boundary = g_value_get_boolean (value);
break;
case PROP_SHOW_GUIDES:
options->show_guides = g_value_get_boolean (value);
break;
case PROP_SHOW_GRID:
options->show_grid = g_value_get_boolean (value);
break;
case PROP_SHOW_SAMPLE_POINTS:
options->show_sample_points = g_value_get_boolean (value);
break;
case PROP_SNAP_TO_GUIDES:
options->snap_to_guides = g_value_get_boolean (value);
break;
case PROP_SNAP_TO_GRID:
options->snap_to_grid = g_value_get_boolean (value);
break;
case PROP_SNAP_TO_CANVAS:
options->snap_to_canvas = g_value_get_boolean (value);
break;
case PROP_SNAP_TO_PATH:
options->snap_to_path = g_value_get_boolean (value);
break;
case PROP_SNAP_TO_BBOX:
options->snap_to_bbox = g_value_get_boolean (value);
break;
case PROP_SNAP_TO_EQUIDISTANCE:
options->snap_to_equidistance = g_value_get_boolean (value);
break;
case PROP_PADDING_MODE:
options->padding_mode = g_value_get_enum (value);
break;
case PROP_PADDING_COLOR:
options->padding_color = *(PikaRGB *) g_value_get_boxed (value);
break;
case PROP_PADDING_IN_SHOW_ALL:
options->padding_in_show_all = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
pika_display_options_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
PikaDisplayOptions *options = PIKA_DISPLAY_OPTIONS (object);
switch (property_id)
{
case PROP_SHOW_MENUBAR:
g_value_set_boolean (value, options->show_menubar);
break;
case PROP_SHOW_STATUSBAR:
g_value_set_boolean (value, options->show_statusbar);
break;
case PROP_SHOW_RULERS:
g_value_set_boolean (value, options->show_rulers);
break;
case PROP_SHOW_SCROLLBARS:
g_value_set_boolean (value, options->show_scrollbars);
break;
case PROP_SHOW_SELECTION:
g_value_set_boolean (value, options->show_selection);
break;
case PROP_SHOW_LAYER_BOUNDARY:
g_value_set_boolean (value, options->show_layer_boundary);
break;
case PROP_SHOW_CANVAS_BOUNDARY:
g_value_set_boolean (value, options->show_canvas_boundary);
break;
case PROP_SHOW_GUIDES:
g_value_set_boolean (value, options->show_guides);
break;
case PROP_SHOW_GRID:
g_value_set_boolean (value, options->show_grid);
break;
case PROP_SHOW_SAMPLE_POINTS:
g_value_set_boolean (value, options->show_sample_points);
break;
case PROP_SNAP_TO_GUIDES:
g_value_set_boolean (value, options->snap_to_guides);
break;
case PROP_SNAP_TO_GRID:
g_value_set_boolean (value, options->snap_to_grid);
break;
case PROP_SNAP_TO_CANVAS:
g_value_set_boolean (value, options->snap_to_canvas);
break;
case PROP_SNAP_TO_PATH:
g_value_set_boolean (value, options->snap_to_path);
break;
case PROP_SNAP_TO_BBOX:
g_value_set_boolean (value, options->snap_to_bbox);
break;
case PROP_SNAP_TO_EQUIDISTANCE:
g_value_set_boolean (value, options->snap_to_equidistance);
break;
case PROP_PADDING_MODE:
g_value_set_enum (value, options->padding_mode);
break;
case PROP_PADDING_COLOR:
g_value_set_boxed (value, &options->padding_color);
break;
case PROP_PADDING_IN_SHOW_ALL:
g_value_set_boolean (value, options->padding_in_show_all);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}

View File

@ -0,0 +1,84 @@
/* PIKA - Photo and Image Kooker Application
* a rebranding of The GNU Image Manipulation Program (created with heckimp)
* A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
*
* Original copyright, applying to most contents (license remains unchanged):
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* PikaDisplayOptions
* Copyright (C) 2003 Sven Neumann <sven@gimp.org>
*
* 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 <https://www.gnu.org/licenses/>.
*/
#ifndef __PIKA_DISPLAY_OPTIONS_H__
#define __PIKA_DISPLAY_OPTIONS_H__
#define PIKA_TYPE_DISPLAY_OPTIONS (pika_display_options_get_type ())
#define PIKA_TYPE_DISPLAY_OPTIONS_FULLSCREEN (pika_display_options_fullscreen_get_type ())
#define PIKA_TYPE_DISPLAY_OPTIONS_NO_IMAGE (pika_display_options_no_image_get_type ())
#define PIKA_DISPLAY_OPTIONS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PIKA_TYPE_DISPLAY_OPTIONS, PikaDisplayOptions))
#define PIKA_DISPLAY_OPTIONS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PIKA_TYPE_DISPLAY_OPTIONS, PikaDisplayOptionsClass))
#define PIKA_IS_DISPLAY_OPTIONS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PIKA_TYPE_DISPLAY_OPTIONS))
#define PIKA_IS_DISPLAY_OPTIONS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PIKA_TYPE_DISPLAY_OPTIONS))
#define PIKA_DISPLAY_OPTIONS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PIKA_TYPE_DISPLAY_OPTIONS, PikaDisplayOptionsClass))
typedef struct _PikaDisplayOptionsClass PikaDisplayOptionsClass;
struct _PikaDisplayOptions
{
GObject parent_instance;
/* PikaImageWindow options */
gboolean show_menubar;
gboolean show_statusbar;
/* PikaDisplayShell options */
gboolean show_rulers;
gboolean show_scrollbars;
gboolean show_selection;
gboolean show_layer_boundary;
gboolean show_canvas_boundary;
gboolean show_guides;
gboolean show_grid;
gboolean show_sample_points;
gboolean snap_to_guides;
gboolean snap_to_grid;
gboolean snap_to_canvas;
gboolean snap_to_path;
gboolean snap_to_bbox;
gboolean snap_to_equidistance;
PikaCanvasPaddingMode padding_mode;
PikaRGB padding_color;
gboolean padding_mode_set;
gboolean padding_in_show_all;
};
struct _PikaDisplayOptionsClass
{
GObjectClass parent_class;
};
GType pika_display_options_get_type (void) G_GNUC_CONST;
GType pika_display_options_fullscreen_get_type (void) G_GNUC_CONST;
GType pika_display_options_no_image_get_type (void) G_GNUC_CONST;
#endif /* __PIKA_DISPLAY_OPTIONS_H__ */

350
app/config/pikaearlyrc.c Normal file
View File

@ -0,0 +1,350 @@
/* PIKA - Photo and Image Kooker Application
* a rebranding of The GNU Image Manipulation Program (created with heckimp)
* A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
*
* Original copyright, applying to most contents (license remains unchanged):
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* PikaEarlyRc: pre-parsing of pikarc suitable for use during early
* initialization, when the pika singleton is not constructed yet
*
* Copyright (C) 2017 Jehan <jehan@gimp.org>
*
* 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 <https://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <gio/gio.h>
#include "libpikabase/pikabase.h"
#include "libpikaconfig/pikaconfig.h"
#include "config-types.h"
#include "core/core-types.h"
#include "core/pika-utils.h"
#include "pikaearlyrc.h"
enum
{
PROP_0,
PROP_VERBOSE,
PROP_SYSTEM_PIKARC,
PROP_USER_PIKARC,
PROP_LANGUAGE,
#ifdef G_OS_WIN32
PROP_WIN32_POINTER_INPUT_API,
#endif
};
static void pika_early_rc_constructed (GObject *object);
static void pika_early_rc_finalize (GObject *object);
static void pika_early_rc_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void pika_early_rc_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
/* Just use PikaConfig interface's default implementation which will
* fill the properties. */
G_DEFINE_TYPE_WITH_CODE (PikaEarlyRc, pika_early_rc, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (PIKA_TYPE_CONFIG, NULL))
#define parent_class pika_early_rc_parent_class
static void
pika_early_rc_class_init (PikaEarlyRcClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->constructed = pika_early_rc_constructed;
object_class->finalize = pika_early_rc_finalize;
object_class->set_property = pika_early_rc_set_property;
object_class->get_property = pika_early_rc_get_property;
g_object_class_install_property (object_class, PROP_VERBOSE,
g_param_spec_boolean ("verbose",
NULL, NULL,
FALSE,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class, PROP_SYSTEM_PIKARC,
g_param_spec_object ("system-pikarc",
NULL, NULL,
G_TYPE_FILE,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class, PROP_USER_PIKARC,
g_param_spec_object ("user-pikarc",
NULL, NULL,
G_TYPE_FILE,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY));
PIKA_CONFIG_PROP_STRING (object_class, PROP_LANGUAGE,
"language", NULL, NULL, NULL,
PIKA_PARAM_STATIC_STRINGS);
#ifdef G_OS_WIN32
PIKA_CONFIG_PROP_ENUM (object_class, PROP_WIN32_POINTER_INPUT_API,
"win32-pointer-input-api", NULL, NULL,
PIKA_TYPE_WIN32_POINTER_INPUT_API,
PIKA_WIN32_POINTER_INPUT_API_WINDOWS_INK,
PIKA_PARAM_STATIC_STRINGS |
PIKA_CONFIG_PARAM_RESTART);
#endif
}
static void
pika_early_rc_init (PikaEarlyRc *rc)
{
}
static void
pika_early_rc_constructed (GObject *object)
{
PikaEarlyRc *rc = PIKA_EARLY_RC (object);
GError *error = NULL;
if (rc->verbose)
g_print ("Parsing '%s' for configuration data required during early initialization.\n",
pika_file_get_utf8_name (rc->system_pikarc));
if (! pika_config_deserialize_file (PIKA_CONFIG (rc),
rc->system_pikarc, NULL, &error))
{
if (error->code != PIKA_CONFIG_ERROR_OPEN_ENOENT)
g_message ("%s", error->message);
g_clear_error (&error);
}
if (rc->verbose)
g_print ("Parsing '%s' for configuration data required during early initialization.\n",
pika_file_get_utf8_name (rc->user_pikarc));
if (! pika_config_deserialize_file (PIKA_CONFIG (rc),
rc->user_pikarc, NULL, &error))
{
if (error->code != PIKA_CONFIG_ERROR_OPEN_ENOENT)
g_message ("%s", error->message);
g_clear_error (&error);
}
if (rc->verbose)
{
if (rc->language)
g_print ("Language property found: %s.\n", rc->language);
else
g_print ("No language property found.\n");
}
}
static void
pika_early_rc_finalize (GObject *object)
{
PikaEarlyRc *rc = PIKA_EARLY_RC (object);
g_clear_object (&rc->system_pikarc);
g_clear_object (&rc->user_pikarc);
g_clear_pointer (&rc->language, g_free);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
pika_early_rc_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
PikaEarlyRc *rc = PIKA_EARLY_RC (object);
switch (property_id)
{
case PROP_VERBOSE:
rc->verbose = g_value_get_boolean (value);
break;
case PROP_SYSTEM_PIKARC:
if (rc->system_pikarc)
g_object_unref (rc->system_pikarc);
if (g_value_get_object (value))
rc->system_pikarc = g_value_dup_object (value);
else
rc->system_pikarc = pika_sysconf_directory_file ("pikarc", NULL);
break;
case PROP_USER_PIKARC:
if (rc->user_pikarc)
g_object_unref (rc->user_pikarc);
if (g_value_get_object (value))
rc->user_pikarc = g_value_dup_object (value);
else
rc->user_pikarc = pika_directory_file ("pikarc", NULL);
break;
case PROP_LANGUAGE:
if (rc->language)
g_free (rc->language);
rc->language = g_value_dup_string (value);
break;
#ifdef G_OS_WIN32
case PROP_WIN32_POINTER_INPUT_API:
{
PikaWin32PointerInputAPI api = g_value_get_enum (value);
gboolean have_wintab = pika_win32_have_wintab ();
gboolean have_windows_ink = pika_win32_have_windows_ink ();
gboolean api_is_wintab = (api == PIKA_WIN32_POINTER_INPUT_API_WINTAB);
gboolean api_is_windows_ink = (api == PIKA_WIN32_POINTER_INPUT_API_WINDOWS_INK);
if (api_is_wintab && !have_wintab && have_windows_ink)
{
rc->win32_pointer_input_api = PIKA_WIN32_POINTER_INPUT_API_WINDOWS_INK;
}
else if (api_is_windows_ink && !have_windows_ink && have_wintab)
{
rc->win32_pointer_input_api = PIKA_WIN32_POINTER_INPUT_API_WINTAB;
}
else
{
rc->win32_pointer_input_api = api;
}
}
break;
#endif
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
pika_early_rc_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
PikaEarlyRc *rc = PIKA_EARLY_RC (object);
switch (property_id)
{
case PROP_VERBOSE:
g_value_set_boolean (value, rc->verbose);
break;
case PROP_SYSTEM_PIKARC:
g_value_set_object (value, rc->system_pikarc);
break;
case PROP_USER_PIKARC:
g_value_set_object (value, rc->user_pikarc);
break;
case PROP_LANGUAGE:
g_value_set_string (value, rc->language);
break;
#ifdef G_OS_WIN32
case PROP_WIN32_POINTER_INPUT_API:
g_value_set_enum (value, rc->win32_pointer_input_api);
break;
#endif
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
/**
* pika_early_rc_new:
* @system_pikarc: the name of the system-wide pikarc file or %NULL to
* use the standard location
* @user_pikarc: the name of the user pikarc file or %NULL to use the
* standard location
* @verbose: enable console messages about loading the preferences
*
* Creates a new PikaEarlyRc object which looks for some configuration
* data required during early initialization steps
*
* Returns: the new #PikaEarlyRc.
*/
PikaEarlyRc *
pika_early_rc_new (GFile *system_pikarc,
GFile *user_pikarc,
gboolean verbose)
{
PikaEarlyRc *rc;
g_return_val_if_fail (system_pikarc == NULL || G_IS_FILE (system_pikarc),
NULL);
g_return_val_if_fail (user_pikarc == NULL || G_IS_FILE (user_pikarc),
NULL);
rc = g_object_new (PIKA_TYPE_EARLY_RC,
"verbose", verbose,
"system-pikarc", system_pikarc,
"user-pikarc", user_pikarc,
NULL);
return rc;
}
/**
* pika_early_rc_get_language:
* @rc: a #PikaEarlyRc object.
*
* This function looks up the language set in `pikarc`.
*
* Returns: a newly allocated string representing the language or
* %NULL if the key couldn't be found.
**/
gchar *
pika_early_rc_get_language (PikaEarlyRc *rc)
{
return rc->language ? g_strdup (rc->language) : NULL;
}
#ifdef G_OS_WIN32
/**
* pika_early_rc_get_win32_pointer_input_api:
* @rc: a #PikaEarlyRc object.
*
* This function looks up the win32-specific pointer input API
* set in `pikarc`.
*
* Returns: the selected win32-specific pointer input API
**/
PikaWin32PointerInputAPI
pika_early_rc_get_win32_pointer_input_api (PikaEarlyRc *rc)
{
return rc->win32_pointer_input_api;
}
#endif

75
app/config/pikaearlyrc.h Normal file
View File

@ -0,0 +1,75 @@
/* PIKA - Photo and Image Kooker Application
* a rebranding of The GNU Image Manipulation Program (created with heckimp)
* A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
*
* Original copyright, applying to most contents (license remains unchanged):
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* PikaEarlyRc: pre-parsing of pikarc suitable for use during early
* initialization, when the pika singleton is not constructed yet
*
* Copyright (C) 2017 Jehan <jehan@gimp.org>
*
* 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 <https://www.gnu.org/licenses/>.
*/
#ifndef __PIKA_EARLY_RC_H__
#define __PIKA_EARLY_RC_H__
#include "core/core-enums.h"
#define PIKA_TYPE_EARLY_RC (pika_early_rc_get_type ())
#define PIKA_EARLY_RC(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PIKA_TYPE_EARLY_RC, PikaEarlyRc))
#define PIKA_EARLY_RC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PIKA_TYPE_EARLY_RC, PikaEarlyRcClass))
#define PIKA_IS_EARLY_RC(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PIKA_TYPE_EARLY_RC))
#define PIKA_IS_EARLY_RC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PIKA_TYPE_EARLY_RC))
typedef struct _PikaEarlyRcClass PikaEarlyRcClass;
struct _PikaEarlyRc
{
GObject parent_instance;
GFile *user_pikarc;
GFile *system_pikarc;
gboolean verbose;
gchar *language;
#ifdef G_OS_WIN32
PikaWin32PointerInputAPI win32_pointer_input_api;
#endif
};
struct _PikaEarlyRcClass
{
GObjectClass parent_class;
};
GType pika_early_rc_get_type (void) G_GNUC_CONST;
PikaEarlyRc * pika_early_rc_new (GFile *system_pikarc,
GFile *user_pikarc,
gboolean verbose);
gchar * pika_early_rc_get_language (PikaEarlyRc *rc);
#ifdef G_OS_WIN32
PikaWin32PointerInputAPI pika_early_rc_get_win32_pointer_input_api (PikaEarlyRc *rc);
#endif
#endif /* PIKA_EARLY_RC_H__ */

277
app/config/pikageglconfig.c Normal file
View File

@ -0,0 +1,277 @@
/* PIKA - Photo and Image Kooker Application
* a rebranding of The GNU Image Manipulation Program (created with heckimp)
* A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
*
* Original copyright, applying to most contents (license remains unchanged):
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* PikaGeglConfig class
* Copyright (C) 2001 Sven Neumann <sven@gimp.org>
*
* 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 <https://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <gio/gio.h>
#include <gegl.h>
#include "libpikabase/pikabase.h"
#include "libpikaconfig/pikaconfig.h"
#include "core/core-types.h" /* eek */
#include "pikarc-blurbs.h"
#include "pikageglconfig.h"
#include "core/pika-utils.h"
#include "pika-debug.h"
#include "pika-intl.h"
#define PIKA_DEFAULT_SWAP_COMPRESSION "fast"
#define PIKA_MAX_MEM_PROCESS (MIN (G_MAXSIZE, PIKA_MAX_MEMSIZE))
enum
{
PROP_0,
PROP_TEMP_PATH,
PROP_SWAP_PATH,
PROP_SWAP_COMPRESSION,
PROP_NUM_PROCESSORS,
PROP_TILE_CACHE_SIZE,
PROP_USE_OPENCL,
/* ignored, only for backward compatibility: */
PROP_STINGY_MEMORY_USE
};
static void pika_gegl_config_constructed (GObject *object);
static void pika_gegl_config_finalize (GObject *object);
static void pika_gegl_config_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void pika_gegl_config_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
G_DEFINE_TYPE (PikaGeglConfig, pika_gegl_config, G_TYPE_OBJECT)
#define parent_class pika_gegl_config_parent_class
static void
pika_gegl_config_class_init (PikaGeglConfigClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
gint n_threads;
gint max_n_threads;
guint64 memory_size;
parent_class = g_type_class_peek_parent (klass);
object_class->constructed = pika_gegl_config_constructed;
object_class->finalize = pika_gegl_config_finalize;
object_class->set_property = pika_gegl_config_set_property;
object_class->get_property = pika_gegl_config_get_property;
PIKA_CONFIG_PROP_PATH (object_class, PROP_TEMP_PATH,
"temp-path",
"Temp path",
TEMP_PATH_BLURB,
PIKA_CONFIG_PATH_DIR,
"${pika_temp_dir}",
PIKA_PARAM_STATIC_STRINGS |
PIKA_CONFIG_PARAM_RESTART);
PIKA_CONFIG_PROP_PATH (object_class, PROP_SWAP_PATH,
"swap-path",
"Swap path",
SWAP_PATH_BLURB,
PIKA_CONFIG_PATH_DIR,
"${pika_cache_dir}",
PIKA_PARAM_STATIC_STRINGS |
PIKA_CONFIG_PARAM_RESTART);
PIKA_CONFIG_PROP_STRING (object_class, PROP_SWAP_COMPRESSION,
"swap-compression",
"Swap compression",
SWAP_COMPRESSION_BLURB,
PIKA_DEFAULT_SWAP_COMPRESSION,
PIKA_PARAM_STATIC_STRINGS);
n_threads = g_get_num_processors ();
max_n_threads =
G_PARAM_SPEC_INT (g_object_class_find_property (G_OBJECT_GET_CLASS (gegl_config ()),
"threads"))->maximum;
n_threads = MIN (n_threads, max_n_threads);
PIKA_CONFIG_PROP_INT (object_class, PROP_NUM_PROCESSORS,
"num-processors",
"Number of threads to use",
NUM_PROCESSORS_BLURB,
1, max_n_threads, n_threads,
PIKA_PARAM_STATIC_STRINGS);
memory_size = pika_get_physical_memory_size ();
/* limit to the amount one process can handle */
memory_size = MIN (PIKA_MAX_MEM_PROCESS, memory_size);
if (memory_size > 0)
memory_size = memory_size / 2; /* half the memory */
else
memory_size = 1 << 30; /* 1GB */
PIKA_CONFIG_PROP_MEMSIZE (object_class, PROP_TILE_CACHE_SIZE,
"tile-cache-size",
"Tile cache size",
TILE_CACHE_SIZE_BLURB,
0, PIKA_MAX_MEM_PROCESS,
memory_size,
PIKA_PARAM_STATIC_STRINGS |
PIKA_CONFIG_PARAM_CONFIRM);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_USE_OPENCL,
"use-opencl",
"Use OpenCL",
USE_OPENCL_BLURB,
FALSE,
PIKA_PARAM_STATIC_STRINGS);
/* only for backward compatibility: */
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_STINGY_MEMORY_USE,
"stingy-memory-use",
NULL, NULL,
FALSE,
PIKA_CONFIG_PARAM_IGNORE);
}
static void
pika_gegl_config_init (PikaGeglConfig *config)
{
}
static void
pika_gegl_config_constructed (GObject *object)
{
G_OBJECT_CLASS (parent_class)->constructed (object);
pika_debug_add_instance (object, G_OBJECT_GET_CLASS (object));
}
static void
pika_gegl_config_finalize (GObject *object)
{
PikaGeglConfig *gegl_config = PIKA_GEGL_CONFIG (object);
g_free (gegl_config->temp_path);
g_free (gegl_config->swap_path);
g_free (gegl_config->swap_compression);
pika_debug_remove_instance (object);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
pika_gegl_config_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
PikaGeglConfig *gegl_config = PIKA_GEGL_CONFIG (object);
switch (property_id)
{
case PROP_TEMP_PATH:
g_free (gegl_config->temp_path);
gegl_config->temp_path = g_value_dup_string (value);
break;
case PROP_SWAP_PATH:
g_free (gegl_config->swap_path);
gegl_config->swap_path = g_value_dup_string (value);
break;
case PROP_SWAP_COMPRESSION:
g_free (gegl_config->swap_compression);
gegl_config->swap_compression = g_value_dup_string (value);
break;
case PROP_NUM_PROCESSORS:
gegl_config->num_processors = g_value_get_int (value);
break;
case PROP_TILE_CACHE_SIZE:
gegl_config->tile_cache_size = g_value_get_uint64 (value);
break;
case PROP_USE_OPENCL:
gegl_config->use_opencl = g_value_get_boolean (value);
break;
case PROP_STINGY_MEMORY_USE:
/* ignored */
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
pika_gegl_config_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
PikaGeglConfig *gegl_config = PIKA_GEGL_CONFIG (object);
switch (property_id)
{
case PROP_TEMP_PATH:
g_value_set_string (value, gegl_config->temp_path);
break;
case PROP_SWAP_PATH:
g_value_set_string (value, gegl_config->swap_path);
break;
case PROP_SWAP_COMPRESSION:
g_value_set_string (value, gegl_config->swap_compression);
break;
case PROP_NUM_PROCESSORS:
g_value_set_int (value, gegl_config->num_processors);
break;
case PROP_TILE_CACHE_SIZE:
g_value_set_uint64 (value, gegl_config->tile_cache_size);
break;
case PROP_USE_OPENCL:
g_value_set_boolean (value, gegl_config->use_opencl);
break;
case PROP_STINGY_MEMORY_USE:
/* ignored */
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}

View File

@ -0,0 +1,59 @@
/* PIKA - Photo and Image Kooker Application
* a rebranding of The GNU Image Manipulation Program (created with heckimp)
* A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
*
* Original copyright, applying to most contents (license remains unchanged):
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* PikaGeglConfig class
* Copyright (C) 2001 Sven Neumann <sven@gimp.org>
*
* 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 <https://www.gnu.org/licenses/>.
*/
#ifndef __PIKA_GEGL_CONFIG_H__
#define __PIKA_GEGL_CONFIG_H__
#define PIKA_TYPE_GEGL_CONFIG (pika_gegl_config_get_type ())
#define PIKA_GEGL_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PIKA_TYPE_GEGL_CONFIG, PikaGeglConfig))
#define PIKA_GEGL_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PIKA_TYPE_GEGL_CONFIG, PikaGeglConfigClass))
#define PIKA_IS_GEGL_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PIKA_TYPE_GEGL_CONFIG))
#define PIKA_IS_GEGL_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PIKA_TYPE_GEGL_CONFIG))
typedef struct _PikaGeglConfigClass PikaGeglConfigClass;
struct _PikaGeglConfig
{
GObject parent_instance;
gchar *temp_path;
gchar *swap_path;
gchar *swap_compression;
gint num_processors;
guint64 tile_cache_size;
gboolean use_opencl;
};
struct _PikaGeglConfigClass
{
GObjectClass parent_class;
};
GType pika_gegl_config_get_type (void) G_GNUC_CONST;
#endif /* PIKA_GEGL_CONFIG_H__ */

951
app/config/pikaguiconfig.c Normal file
View File

@ -0,0 +1,951 @@
/* PIKA - Photo and Image Kooker Application
* a rebranding of The GNU Image Manipulation Program (created with heckimp)
* A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
*
* Original copyright, applying to most contents (license remains unchanged):
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* PikaGuiConfig class
* Copyright (C) 2001 Sven Neumann <sven@gimp.org>
*
* 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 <https://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <gio/gio.h>
#include "libpikabase/pikabase.h"
#include "libpikaconfig/pikaconfig.h"
#include "config-types.h"
#include "pikarc-blurbs.h"
#include "pikaguiconfig.h"
#include "pika-intl.h"
#ifdef HAVE_WEBKIT
#define DEFAULT_HELP_BROWSER PIKA_HELP_BROWSER_PIKA
#else
#define DEFAULT_HELP_BROWSER PIKA_HELP_BROWSER_WEB_BROWSER
#endif
#define DEFAULT_USER_MANUAL_ONLINE_URI \
"https://docs.pika.org/" PIKA_APP_VERSION_STRING
enum
{
PROP_0,
PROP_EDIT_NON_VISIBLE,
PROP_MOVE_TOOL_CHANGES_ACTIVE,
PROP_FILTER_TOOL_MAX_RECENT,
PROP_FILTER_TOOL_USE_LAST_SETTINGS,
PROP_FILTER_TOOL_SHOW_COLOR_OPTIONS,
PROP_TRUST_DIRTY_FLAG,
PROP_SAVE_DEVICE_STATUS,
PROP_DEVICES_SHARE_TOOL,
PROP_SAVE_SESSION_INFO,
PROP_RESTORE_SESSION,
PROP_RESTORE_MONITOR,
PROP_SAVE_TOOL_OPTIONS,
PROP_CAN_CHANGE_ACCELS,
PROP_SAVE_ACCELS,
PROP_RESTORE_ACCELS,
PROP_LAST_OPENED_SIZE,
PROP_MAX_NEW_IMAGE_SIZE,
PROP_TOOLBOX_COLOR_AREA,
PROP_TOOLBOX_FOO_AREA,
PROP_TOOLBOX_IMAGE_AREA,
PROP_TOOLBOX_MASCOT,
PROP_TOOLBOX_GROUPS,
PROP_THEME_PATH,
PROP_THEME,
PROP_PREFER_DARK_THEME,
PROP_OVERRIDE_THEME_ICON_SIZE,
PROP_CUSTOM_ICON_SIZE,
PROP_ICON_THEME_PATH,
PROP_ICON_THEME,
PROP_PREFER_SYMBOLIC_ICONS,
PROP_USE_HELP,
PROP_SHOW_HELP_BUTTON,
PROP_HELP_LOCALES,
PROP_HELP_BROWSER,
PROP_ACTION_HISTORY_SIZE,
PROP_USER_MANUAL_ONLINE,
PROP_USER_MANUAL_ONLINE_URI,
PROP_DOCK_WINDOW_HINT,
PROP_CURSOR_HANDEDNESS,
PROP_CUSTOM_TITLE_BAR,
PROP_PLAYGROUND_NPD_TOOL,
PROP_PLAYGROUND_SEAMLESS_CLONE_TOOL,
PROP_PLAYGROUND_PAINT_SELECT_TOOL,
PROP_HIDE_DOCKS,
PROP_SINGLE_WINDOW_MODE,
PROP_SHOW_TABS,
PROP_TABS_POSITION,
PROP_LAST_TIP_SHOWN,
/* ignored, only for backward compatibility: */
PROP_CURSOR_FORMAT,
PROP_IMAGE_MAP_TOOL_MAX_RECENT,
PROP_INFO_WINDOW_PER_DISPLAY,
PROP_MENU_MNEMONICS,
PROP_SHOW_TOOL_TIPS,
PROP_SHOW_TIPS,
PROP_TOOLBOX_WINDOW_HINT,
PROP_TRANSIENT_DOCKS,
PROP_WEB_BROWSER
};
static void pika_gui_config_finalize (GObject *object);
static void pika_gui_config_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void pika_gui_config_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
G_DEFINE_TYPE (PikaGuiConfig, pika_gui_config, PIKA_TYPE_DISPLAY_CONFIG)
#define parent_class pika_gui_config_parent_class
static void
pika_gui_config_class_init (PikaGuiConfigClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
gchar *path;
object_class->finalize = pika_gui_config_finalize;
object_class->set_property = pika_gui_config_set_property;
object_class->get_property = pika_gui_config_get_property;
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_EDIT_NON_VISIBLE,
"edit-non-visible",
"Non-visible layers can be edited",
EDIT_NON_VISIBLE_BLURB,
FALSE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_MOVE_TOOL_CHANGES_ACTIVE,
"move-tool-changes-active",
"Move tool changes active layer",
MOVE_TOOL_CHANGES_ACTIVE_BLURB,
FALSE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_INT (object_class, PROP_FILTER_TOOL_MAX_RECENT,
"filter-tool-max-recent",
"Max recent settings to keep in filters",
FILTER_TOOL_MAX_RECENT_BLURB,
0, 255, 10,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_FILTER_TOOL_USE_LAST_SETTINGS,
"filter-tool-use-last-settings",
"Use last used settings in filters",
FILTER_TOOL_USE_LAST_SETTINGS_BLURB,
FALSE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_FILTER_TOOL_SHOW_COLOR_OPTIONS,
"filter-tool-show-color-options",
"Show advanced color options in filters",
FILTER_TOOL_SHOW_COLOR_OPTIONS_BLURB,
FALSE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_TRUST_DIRTY_FLAG,
"trust-dirty-flag",
"Trust dirty flag",
TRUST_DIRTY_FLAG_BLURB,
FALSE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_SAVE_DEVICE_STATUS,
"save-device-status",
"Save device status",
SAVE_DEVICE_STATUS_BLURB,
TRUE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_DEVICES_SHARE_TOOL,
"devices-share-tool",
"Devices share tool",
DEVICES_SHARE_TOOL_BLURB,
FALSE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_SAVE_SESSION_INFO,
"save-session-info",
"Save session",
SAVE_SESSION_INFO_BLURB,
TRUE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_RESTORE_SESSION,
"restore-session",
"Restore session",
RESTORE_SESSION_BLURB,
TRUE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_RESTORE_MONITOR,
"restore-monitor",
"Restore monitor",
RESTORE_MONITOR_BLURB,
FALSE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_SAVE_TOOL_OPTIONS,
"save-tool-options",
"Save tool options",
SAVE_TOOL_OPTIONS_BLURB,
TRUE,
PIKA_PARAM_STATIC_STRINGS);
/* XXX: this is now ignored and unsed because we were relying on
* "gtk-can-change-accels" property of GtkSettings which is deprecated and
* ignored since GTK+ 3.10.
*
* Keeping the property around as a reminder of the regression in PIKA 3.
* Maybe we can reimplement this with custom code if there are requests. If we
* end up deciding to completely getting rid of the property, we must add
* update rules in pika-user-install.c for the pikarc parsing not to break.
*/
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_CAN_CHANGE_ACCELS,
"can-change-accels",
"Can change accelerators",
CAN_CHANGE_ACCELS_BLURB,
FALSE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_SAVE_ACCELS,
"save-accels",
"Save accelerators",
SAVE_ACCELS_BLURB,
TRUE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_RESTORE_ACCELS,
"restore-accels",
"Restore acclerator",
RESTORE_ACCELS_BLURB,
TRUE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_INT (object_class, PROP_LAST_OPENED_SIZE,
"last-opened-size",
"Size of recently used menu",
LAST_OPENED_SIZE_BLURB,
0, 1024, 10,
PIKA_PARAM_STATIC_STRINGS |
PIKA_CONFIG_PARAM_RESTART);
PIKA_CONFIG_PROP_MEMSIZE (object_class, PROP_MAX_NEW_IMAGE_SIZE,
"max-new-image-size",
"Maximum new image size",
MAX_NEW_IMAGE_SIZE_BLURB,
0, PIKA_MAX_MEMSIZE, 1 << 27, /* 128MB */
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_TOOLBOX_COLOR_AREA,
"toolbox-color-area",
"Show toolbox color area",
TOOLBOX_COLOR_AREA_BLURB,
TRUE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_TOOLBOX_FOO_AREA,
"toolbox-foo-area",
"Show toolbox foo area",
TOOLBOX_FOO_AREA_BLURB,
FALSE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_TOOLBOX_IMAGE_AREA,
"toolbox-image-area",
"Show toolbox image area",
TOOLBOX_IMAGE_AREA_BLURB,
FALSE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_TOOLBOX_MASCOT,
"toolbox-mascot",
"Show toolbox wilber",
TOOLBOX_MASCOT_BLURB,
TRUE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_TOOLBOX_GROUPS,
"toolbox-groups",
"Use toolbox groups",
TOOLBOX_GROUPS_BLURB,
TRUE,
PIKA_PARAM_STATIC_STRINGS);
path = pika_config_build_data_path ("themes");
PIKA_CONFIG_PROP_PATH (object_class, PROP_THEME_PATH,
"theme-path",
"Theme path",
THEME_PATH_BLURB,
PIKA_CONFIG_PATH_DIR_LIST, path,
PIKA_PARAM_STATIC_STRINGS |
PIKA_CONFIG_PARAM_RESTART);
g_free (path);
PIKA_CONFIG_PROP_STRING (object_class, PROP_THEME,
"theme",
"Theme",
THEME_BLURB,
PIKA_CONFIG_DEFAULT_THEME,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_PREFER_DARK_THEME,
"prefer-dark-theme",
"Prefer Dark Theme",
THEME_BLURB,
TRUE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_OVERRIDE_THEME_ICON_SIZE,
"override-theme-icon-size",
"Override theme-set icon sizes",
OVERRIDE_THEME_ICON_SIZE_BLURB,
FALSE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_ENUM (object_class, PROP_CUSTOM_ICON_SIZE,
"custom-icon-size",
"Custom icon size",
ICON_SIZE_BLURB,
PIKA_TYPE_ICON_SIZE,
PIKA_ICON_SIZE_MEDIUM,
PIKA_PARAM_STATIC_STRINGS);
path = pika_config_build_data_path ("icons");
PIKA_CONFIG_PROP_PATH (object_class, PROP_ICON_THEME_PATH,
"icon-theme-path",
"Icon theme path",
ICON_THEME_PATH_BLURB,
PIKA_CONFIG_PATH_DIR_LIST, path,
PIKA_PARAM_STATIC_STRINGS |
PIKA_CONFIG_PARAM_RESTART);
g_free (path);
PIKA_CONFIG_PROP_STRING (object_class, PROP_ICON_THEME,
"icon-theme",
"Icon theme",
ICON_THEME_BLURB,
PIKA_CONFIG_DEFAULT_ICON_THEME,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_PREFER_SYMBOLIC_ICONS,
"prefer-symbolic-icons",
"Prefer symbolic icons",
PREFER_SYMBOLIC_ICONS_BLURB,
TRUE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_USE_HELP,
"use-help",
"Use help",
USE_HELP_BLURB,
TRUE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_SHOW_HELP_BUTTON,
"show-help-button",
"Show help button",
SHOW_HELP_BUTTON_BLURB,
TRUE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_STRING (object_class, PROP_HELP_LOCALES,
"help-locales",
"Help locales",
HELP_LOCALES_BLURB,
"",
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_ENUM (object_class, PROP_HELP_BROWSER,
"help-browser",
"Help browser",
HELP_BROWSER_BLURB,
PIKA_TYPE_HELP_BROWSER_TYPE,
DEFAULT_HELP_BROWSER,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_USER_MANUAL_ONLINE,
"user-manual-online",
"User manual online",
USER_MANUAL_ONLINE_BLURB,
FALSE,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_STRING (object_class, PROP_USER_MANUAL_ONLINE_URI,
"user-manual-online-uri",
"User manual online URI",
USER_MANUAL_ONLINE_URI_BLURB,
DEFAULT_USER_MANUAL_ONLINE_URI,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_INT (object_class, PROP_ACTION_HISTORY_SIZE,
"action-history-size",
"Action history size",
ACTION_HISTORY_SIZE_BLURB,
0, 1000, 100,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_ENUM (object_class, PROP_DOCK_WINDOW_HINT,
"dock-window-hint",
"Dock window hint",
DOCK_WINDOW_HINT_BLURB,
PIKA_TYPE_WINDOW_HINT,
PIKA_WINDOW_HINT_UTILITY,
PIKA_PARAM_STATIC_STRINGS |
PIKA_CONFIG_PARAM_RESTART);
PIKA_CONFIG_PROP_ENUM (object_class, PROP_CURSOR_HANDEDNESS,
"cursor-handedness",
"Cursor handedness",
CURSOR_HANDEDNESS_BLURB,
PIKA_TYPE_HANDEDNESS,
PIKA_HANDEDNESS_RIGHT,
PIKA_PARAM_STATIC_STRINGS);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_CUSTOM_TITLE_BAR,
"custom-title-bar",
"Custom title bar embedding the menu",
CUSTOM_TITLE_BAR_BLURB,
FALSE,
PIKA_PARAM_STATIC_STRINGS |
PIKA_CONFIG_PARAM_RESTART);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_PLAYGROUND_NPD_TOOL,
"playground-npd-tool",
"Playground N-Point Deformation tool",
PLAYGROUND_NPD_TOOL_BLURB,
FALSE,
PIKA_PARAM_STATIC_STRINGS |
PIKA_CONFIG_PARAM_RESTART);
PIKA_CONFIG_PROP_BOOLEAN (object_class,
PROP_PLAYGROUND_SEAMLESS_CLONE_TOOL,
"playground-seamless-clone-tool",
"Playground Seamless Clone tool",
PLAYGROUND_SEAMLESS_CLONE_TOOL_BLURB,
FALSE,
PIKA_PARAM_STATIC_STRINGS |
PIKA_CONFIG_PARAM_RESTART);
PIKA_CONFIG_PROP_BOOLEAN (object_class,
PROP_PLAYGROUND_PAINT_SELECT_TOOL,
"playground-paint-select-tool",
"Playground Paint Select tool",
PLAYGROUND_PAINT_SELECT_TOOL_BLURB,
FALSE,
PIKA_PARAM_STATIC_STRINGS |
PIKA_CONFIG_PARAM_RESTART);
g_object_class_install_property (object_class, PROP_HIDE_DOCKS,
g_param_spec_boolean ("hide-docks",
NULL,
HIDE_DOCKS_BLURB,
FALSE,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT |
PIKA_PARAM_STATIC_STRINGS));
g_object_class_install_property (object_class, PROP_SINGLE_WINDOW_MODE,
g_param_spec_boolean ("single-window-mode",
NULL,
SINGLE_WINDOW_MODE_BLURB,
TRUE,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT |
PIKA_PARAM_STATIC_STRINGS));
g_object_class_install_property (object_class, PROP_SHOW_TABS,
g_param_spec_boolean ("show-tabs",
NULL,
SHOW_TABS_BLURB,
TRUE,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT |
PIKA_PARAM_STATIC_STRINGS));
g_object_class_install_property (object_class, PROP_TABS_POSITION,
g_param_spec_enum ("tabs-position", NULL, NULL,
PIKA_TYPE_POSITION,
PIKA_POSITION_TOP,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT |
PIKA_PARAM_STATIC_STRINGS));
g_object_class_install_property (object_class, PROP_LAST_TIP_SHOWN,
g_param_spec_int ("last-tip-shown",
NULL, NULL,
0, G_MAXINT, 0,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT |
PIKA_PARAM_STATIC_STRINGS));
/* only for backward compatibility: */
PIKA_CONFIG_PROP_ENUM (object_class, PROP_CURSOR_FORMAT,
"cursor-format",
NULL, NULL,
PIKA_TYPE_CURSOR_FORMAT,
PIKA_CURSOR_FORMAT_PIXBUF,
PIKA_PARAM_STATIC_STRINGS |
PIKA_CONFIG_PARAM_IGNORE);
PIKA_CONFIG_PROP_INT (object_class, PROP_IMAGE_MAP_TOOL_MAX_RECENT,
"image-map-tool-max-recent",
NULL, NULL,
0, 255, 10,
PIKA_PARAM_STATIC_STRINGS |
PIKA_CONFIG_PARAM_IGNORE);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_INFO_WINDOW_PER_DISPLAY,
"info-window-per-display",
NULL, NULL,
FALSE,
PIKA_PARAM_STATIC_STRINGS |
PIKA_CONFIG_PARAM_IGNORE);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_MENU_MNEMONICS,
"menu-mnemonics",
NULL, NULL,
TRUE,
PIKA_PARAM_STATIC_STRINGS |
PIKA_CONFIG_PARAM_IGNORE);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_SHOW_TOOL_TIPS,
"show-tool-tips",
NULL, NULL,
FALSE,
PIKA_PARAM_STATIC_STRINGS |
PIKA_CONFIG_PARAM_IGNORE);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_SHOW_TIPS,
"show-tips",
NULL, NULL,
FALSE,
PIKA_PARAM_STATIC_STRINGS |
PIKA_CONFIG_PARAM_IGNORE);
PIKA_CONFIG_PROP_ENUM (object_class, PROP_TOOLBOX_WINDOW_HINT,
"toolbox-window-hint",
NULL, NULL,
PIKA_TYPE_WINDOW_HINT,
PIKA_WINDOW_HINT_UTILITY,
PIKA_PARAM_STATIC_STRINGS |
PIKA_CONFIG_PARAM_IGNORE);
PIKA_CONFIG_PROP_BOOLEAN (object_class, PROP_TRANSIENT_DOCKS,
"transient-docks",
NULL, NULL,
FALSE,
PIKA_PARAM_STATIC_STRINGS |
PIKA_CONFIG_PARAM_IGNORE);
PIKA_CONFIG_PROP_PATH (object_class, PROP_WEB_BROWSER,
"web-browser",
NULL, NULL,
PIKA_CONFIG_PATH_FILE,
"not used any longer",
PIKA_PARAM_STATIC_STRINGS |
PIKA_CONFIG_PARAM_IGNORE);
}
static void
pika_gui_config_init (PikaGuiConfig *config)
{
}
static void
pika_gui_config_finalize (GObject *object)
{
PikaGuiConfig *gui_config = PIKA_GUI_CONFIG (object);
g_free (gui_config->theme_path);
g_free (gui_config->theme);
g_free (gui_config->icon_theme_path);
g_free (gui_config->icon_theme);
g_free (gui_config->help_locales);
g_free (gui_config->user_manual_online_uri);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
pika_gui_config_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
PikaGuiConfig *gui_config = PIKA_GUI_CONFIG (object);
switch (property_id)
{
case PROP_EDIT_NON_VISIBLE:
gui_config->edit_non_visible = g_value_get_boolean (value);
break;
case PROP_MOVE_TOOL_CHANGES_ACTIVE:
gui_config->move_tool_changes_active = g_value_get_boolean (value);
break;
case PROP_FILTER_TOOL_MAX_RECENT:
case PROP_IMAGE_MAP_TOOL_MAX_RECENT:
gui_config->filter_tool_max_recent = g_value_get_int (value);
break;
case PROP_FILTER_TOOL_USE_LAST_SETTINGS:
gui_config->filter_tool_use_last_settings = g_value_get_boolean (value);
break;
case PROP_FILTER_TOOL_SHOW_COLOR_OPTIONS:
gui_config->filter_tool_show_color_options = g_value_get_boolean (value);
break;
case PROP_TRUST_DIRTY_FLAG:
gui_config->trust_dirty_flag = g_value_get_boolean (value);
break;
case PROP_SAVE_DEVICE_STATUS:
gui_config->save_device_status = g_value_get_boolean (value);
break;
case PROP_DEVICES_SHARE_TOOL:
gui_config->devices_share_tool = g_value_get_boolean (value);
break;
case PROP_SAVE_SESSION_INFO:
gui_config->save_session_info = g_value_get_boolean (value);
break;
case PROP_RESTORE_SESSION:
gui_config->restore_session = g_value_get_boolean (value);
break;
case PROP_RESTORE_MONITOR:
gui_config->restore_monitor = g_value_get_boolean (value);
break;
case PROP_SAVE_TOOL_OPTIONS:
gui_config->save_tool_options = g_value_get_boolean (value);
break;
case PROP_CAN_CHANGE_ACCELS:
gui_config->can_change_accels = g_value_get_boolean (value);
break;
case PROP_SAVE_ACCELS:
gui_config->save_accels = g_value_get_boolean (value);
break;
case PROP_RESTORE_ACCELS:
gui_config->restore_accels = g_value_get_boolean (value);
break;
case PROP_LAST_OPENED_SIZE:
gui_config->last_opened_size = g_value_get_int (value);
break;
case PROP_MAX_NEW_IMAGE_SIZE:
gui_config->max_new_image_size = g_value_get_uint64 (value);
break;
case PROP_TOOLBOX_COLOR_AREA:
gui_config->toolbox_color_area = g_value_get_boolean (value);
break;
case PROP_TOOLBOX_FOO_AREA:
gui_config->toolbox_foo_area = g_value_get_boolean (value);
break;
case PROP_TOOLBOX_IMAGE_AREA:
gui_config->toolbox_image_area = g_value_get_boolean (value);
break;
case PROP_TOOLBOX_MASCOT:
gui_config->toolbox_mascot = g_value_get_boolean (value);
break;
case PROP_TOOLBOX_GROUPS:
gui_config->toolbox_groups = g_value_get_boolean (value);
break;
case PROP_THEME_PATH:
g_free (gui_config->theme_path);
gui_config->theme_path = g_value_dup_string (value);
break;
case PROP_THEME:
g_free (gui_config->theme);
gui_config->theme = g_value_dup_string (value);
break;
case PROP_PREFER_DARK_THEME:
gui_config->prefer_dark_theme = g_value_get_boolean (value);
break;
case PROP_OVERRIDE_THEME_ICON_SIZE:
gui_config->override_icon_size = g_value_get_boolean (value);
break;
case PROP_CUSTOM_ICON_SIZE:
gui_config->custom_icon_size = g_value_get_enum (value);
break;
case PROP_ICON_THEME_PATH:
g_free (gui_config->icon_theme_path);
gui_config->icon_theme_path = g_value_dup_string (value);
break;
case PROP_ICON_THEME:
g_free (gui_config->icon_theme);
gui_config->icon_theme = g_value_dup_string (value);
break;
case PROP_PREFER_SYMBOLIC_ICONS:
gui_config->prefer_symbolic_icons = g_value_get_boolean (value);
break;
case PROP_USE_HELP:
gui_config->use_help = g_value_get_boolean (value);
break;
case PROP_SHOW_HELP_BUTTON:
gui_config->show_help_button = g_value_get_boolean (value);
break;
case PROP_HELP_LOCALES:
g_free (gui_config->help_locales);
gui_config->help_locales = g_value_dup_string (value);
break;
case PROP_HELP_BROWSER:
gui_config->help_browser = g_value_get_enum (value);
break;
case PROP_USER_MANUAL_ONLINE:
gui_config->user_manual_online = g_value_get_boolean (value);
break;
case PROP_USER_MANUAL_ONLINE_URI:
g_free (gui_config->user_manual_online_uri);
gui_config->user_manual_online_uri = g_value_dup_string (value);
break;
case PROP_ACTION_HISTORY_SIZE:
gui_config->action_history_size = g_value_get_int (value);
break;
case PROP_DOCK_WINDOW_HINT:
gui_config->dock_window_hint = g_value_get_enum (value);
break;
case PROP_CURSOR_HANDEDNESS:
gui_config->cursor_handedness = g_value_get_enum (value);
break;
case PROP_CUSTOM_TITLE_BAR:
gui_config->custom_title_bar = g_value_get_boolean (value);
break;
case PROP_PLAYGROUND_NPD_TOOL:
gui_config->playground_npd_tool = g_value_get_boolean (value);
break;
case PROP_PLAYGROUND_SEAMLESS_CLONE_TOOL:
gui_config->playground_seamless_clone_tool = g_value_get_boolean (value);
break;
case PROP_PLAYGROUND_PAINT_SELECT_TOOL:
gui_config->playground_paint_select_tool = g_value_get_boolean (value);
break;
case PROP_HIDE_DOCKS:
gui_config->hide_docks = g_value_get_boolean (value);
break;
case PROP_SINGLE_WINDOW_MODE:
gui_config->single_window_mode = g_value_get_boolean (value);
break;
case PROP_SHOW_TABS:
gui_config->show_tabs = g_value_get_boolean (value);
break;
case PROP_TABS_POSITION:
gui_config->tabs_position = g_value_get_enum (value);
break;
case PROP_LAST_TIP_SHOWN:
gui_config->last_tip_shown = g_value_get_int (value);
break;
case PROP_CURSOR_FORMAT:
case PROP_INFO_WINDOW_PER_DISPLAY:
case PROP_MENU_MNEMONICS:
case PROP_SHOW_TOOL_TIPS:
case PROP_SHOW_TIPS:
case PROP_TOOLBOX_WINDOW_HINT:
case PROP_TRANSIENT_DOCKS:
case PROP_WEB_BROWSER:
/* ignored */
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
pika_gui_config_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
PikaGuiConfig *gui_config = PIKA_GUI_CONFIG (object);
switch (property_id)
{
case PROP_EDIT_NON_VISIBLE:
g_value_set_boolean (value, gui_config->edit_non_visible);
break;
case PROP_MOVE_TOOL_CHANGES_ACTIVE:
g_value_set_boolean (value, gui_config->move_tool_changes_active);
break;
case PROP_FILTER_TOOL_MAX_RECENT:
case PROP_IMAGE_MAP_TOOL_MAX_RECENT:
g_value_set_int (value, gui_config->filter_tool_max_recent);
break;
case PROP_FILTER_TOOL_USE_LAST_SETTINGS:
g_value_set_boolean (value, gui_config->filter_tool_use_last_settings);
break;
case PROP_FILTER_TOOL_SHOW_COLOR_OPTIONS:
g_value_set_boolean (value, gui_config->filter_tool_show_color_options);
break;
case PROP_TRUST_DIRTY_FLAG:
g_value_set_boolean (value, gui_config->trust_dirty_flag);
break;
case PROP_SAVE_DEVICE_STATUS:
g_value_set_boolean (value, gui_config->save_device_status);
break;
case PROP_DEVICES_SHARE_TOOL:
g_value_set_boolean (value, gui_config->devices_share_tool);
break;
case PROP_SAVE_SESSION_INFO:
g_value_set_boolean (value, gui_config->save_session_info);
break;
case PROP_RESTORE_SESSION:
g_value_set_boolean (value, gui_config->restore_session);
break;
case PROP_RESTORE_MONITOR:
g_value_set_boolean (value, gui_config->restore_monitor);
break;
case PROP_SAVE_TOOL_OPTIONS:
g_value_set_boolean (value, gui_config->save_tool_options);
break;
case PROP_CAN_CHANGE_ACCELS:
g_value_set_boolean (value, gui_config->can_change_accels);
break;
case PROP_SAVE_ACCELS:
g_value_set_boolean (value, gui_config->save_accels);
break;
case PROP_RESTORE_ACCELS:
g_value_set_boolean (value, gui_config->restore_accels);
break;
case PROP_LAST_OPENED_SIZE:
g_value_set_int (value, gui_config->last_opened_size);
break;
case PROP_MAX_NEW_IMAGE_SIZE:
g_value_set_uint64 (value, gui_config->max_new_image_size);
break;
case PROP_TOOLBOX_COLOR_AREA:
g_value_set_boolean (value, gui_config->toolbox_color_area);
break;
case PROP_TOOLBOX_FOO_AREA:
g_value_set_boolean (value, gui_config->toolbox_foo_area);
break;
case PROP_TOOLBOX_IMAGE_AREA:
g_value_set_boolean (value, gui_config->toolbox_image_area);
break;
case PROP_TOOLBOX_MASCOT:
g_value_set_boolean (value, gui_config->toolbox_mascot);
break;
case PROP_TOOLBOX_GROUPS:
g_value_set_boolean (value, gui_config->toolbox_groups);
break;
case PROP_THEME_PATH:
g_value_set_string (value, gui_config->theme_path);
break;
case PROP_THEME:
g_value_set_string (value, gui_config->theme);
break;
case PROP_PREFER_DARK_THEME:
g_value_set_boolean (value, gui_config->prefer_dark_theme);
break;
case PROP_OVERRIDE_THEME_ICON_SIZE:
g_value_set_boolean (value, gui_config->override_icon_size);
break;
case PROP_CUSTOM_ICON_SIZE:
g_value_set_enum (value, gui_config->custom_icon_size);
break;
case PROP_ICON_THEME_PATH:
g_value_set_string (value, gui_config->icon_theme_path);
break;
case PROP_ICON_THEME:
g_value_set_string (value, gui_config->icon_theme);
break;
case PROP_PREFER_SYMBOLIC_ICONS:
g_value_set_boolean (value, gui_config->prefer_symbolic_icons);
break;
case PROP_USE_HELP:
g_value_set_boolean (value, gui_config->use_help);
break;
case PROP_SHOW_HELP_BUTTON:
g_value_set_boolean (value, gui_config->show_help_button);
break;
case PROP_HELP_LOCALES:
g_value_set_string (value, gui_config->help_locales);
break;
case PROP_HELP_BROWSER:
g_value_set_enum (value, gui_config->help_browser);
break;
case PROP_USER_MANUAL_ONLINE:
g_value_set_boolean (value, gui_config->user_manual_online);
break;
case PROP_USER_MANUAL_ONLINE_URI:
g_value_set_string (value, gui_config->user_manual_online_uri);
break;
case PROP_ACTION_HISTORY_SIZE:
g_value_set_int (value, gui_config->action_history_size);
break;
case PROP_DOCK_WINDOW_HINT:
g_value_set_enum (value, gui_config->dock_window_hint);
break;
case PROP_CURSOR_HANDEDNESS:
g_value_set_enum (value, gui_config->cursor_handedness);
break;
case PROP_CUSTOM_TITLE_BAR:
g_value_set_boolean (value, gui_config->custom_title_bar);
break;
case PROP_PLAYGROUND_NPD_TOOL:
g_value_set_boolean (value, gui_config->playground_npd_tool);
break;
case PROP_PLAYGROUND_SEAMLESS_CLONE_TOOL:
g_value_set_boolean (value, gui_config->playground_seamless_clone_tool);
break;
case PROP_PLAYGROUND_PAINT_SELECT_TOOL:
g_value_set_boolean (value, gui_config->playground_paint_select_tool);
break;
case PROP_HIDE_DOCKS:
g_value_set_boolean (value, gui_config->hide_docks);
break;
case PROP_SINGLE_WINDOW_MODE:
g_value_set_boolean (value, gui_config->single_window_mode);
break;
case PROP_SHOW_TABS:
g_value_set_boolean (value, gui_config->show_tabs);
break;
case PROP_TABS_POSITION:
g_value_set_enum (value, gui_config->tabs_position);
break;
case PROP_LAST_TIP_SHOWN:
g_value_set_int (value, gui_config->last_tip_shown);
break;
case PROP_CURSOR_FORMAT:
case PROP_INFO_WINDOW_PER_DISPLAY:
case PROP_MENU_MNEMONICS:
case PROP_SHOW_TOOL_TIPS:
case PROP_SHOW_TIPS:
case PROP_TOOLBOX_WINDOW_HINT:
case PROP_TRANSIENT_DOCKS:
case PROP_WEB_BROWSER:
/* ignored */
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}

115
app/config/pikaguiconfig.h Normal file
View File

@ -0,0 +1,115 @@
/* PIKA - Photo and Image Kooker Application
* a rebranding of The GNU Image Manipulation Program (created with heckimp)
* A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
*
* Original copyright, applying to most contents (license remains unchanged):
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* PikaGuiConfig class
* Copyright (C) 2001 Sven Neumann <sven@gimp.org>
*
* 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 <https://www.gnu.org/licenses/>.
*/
#ifndef __PIKA_GUI_CONFIG_H__
#define __PIKA_GUI_CONFIG_H__
#include "config/pikadisplayconfig.h"
#define PIKA_CONFIG_DEFAULT_THEME "Default"
#define PIKA_CONFIG_DEFAULT_ICON_THEME "Symbolic"
#define PIKA_TYPE_GUI_CONFIG (pika_gui_config_get_type ())
#define PIKA_GUI_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PIKA_TYPE_GUI_CONFIG, PikaGuiConfig))
#define PIKA_GUI_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PIKA_TYPE_GUI_CONFIG, PikaGuiConfigClass))
#define PIKA_IS_GUI_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PIKA_TYPE_GUI_CONFIG))
#define PIKA_IS_GUI_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PIKA_TYPE_GUI_CONFIG))
typedef struct _PikaGuiConfigClass PikaGuiConfigClass;
struct _PikaGuiConfig
{
PikaDisplayConfig parent_instance;
gboolean edit_non_visible;
gboolean move_tool_changes_active;
gint filter_tool_max_recent;
gboolean filter_tool_use_last_settings;
gboolean filter_tool_show_color_options;
gboolean trust_dirty_flag;
gboolean save_device_status;
gboolean devices_share_tool;
gboolean save_session_info;
gboolean restore_session;
gboolean restore_monitor;
gboolean save_tool_options;
gboolean save_accels;
gboolean restore_accels;
gint last_opened_size;
guint64 max_new_image_size;
gboolean toolbox_color_area;
gboolean toolbox_foo_area;
gboolean toolbox_image_area;
gboolean toolbox_mascot;
gboolean toolbox_groups;
gchar *theme_path;
gchar *theme;
gboolean prefer_dark_theme;
gchar *icon_theme_path;
gchar *icon_theme;
gboolean prefer_symbolic_icons;
gboolean override_icon_size;
PikaIconSize custom_icon_size;
gboolean use_help;
gboolean show_help_button;
gchar *help_locales;
PikaHelpBrowserType help_browser;
gboolean user_manual_online;
gchar *user_manual_online_uri;
gint action_history_size;
PikaWindowHint dock_window_hint;
PikaHandedness cursor_handedness;
gboolean custom_title_bar;
/* experimental playground */
gboolean playground_npd_tool;
gboolean playground_seamless_clone_tool;
gboolean playground_paint_select_tool;
/* saved in sessionrc */
gboolean hide_docks;
gboolean single_window_mode;
gboolean show_tabs;
PikaPosition tabs_position;
gint last_tip_shown;
/* Currently ignored snce "gtk-can-change-accels" settings got deprecated in
* GTK+ 3.10.
*/
gboolean can_change_accels;
};
struct _PikaGuiConfigClass
{
PikaDisplayConfigClass parent_class;
};
GType pika_gui_config_get_type (void) G_GNUC_CONST;
#endif /* PIKA_GUI_CONFIG_H__ */

View File

@ -0,0 +1,221 @@
/* PIKA - Photo and Image Kooker Application
* a rebranding of The GNU Image Manipulation Program (created with heckimp)
* A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
*
* Original copyright, applying to most contents (license remains unchanged):
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* PikaPluginConfig class
* Copyright (C) 2001 Sven Neumann <sven@gimp.org>
*
* 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 <https://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <gio/gio.h>
#include <gegl.h>
#include "libpikabase/pikabase.h"
#include "libpikaconfig/pikaconfig.h"
#include "config-types.h"
#include "pikarc-blurbs.h"
#include "pikapluginconfig.h"
enum
{
PROP_0,
PROP_FRACTALEXPLORER_PATH,
PROP_GFIG_PATH,
PROP_GFLARE_PATH,
PROP_PIKARESSIONIST_PATH,
PROP_SCRIPT_FU_PATH
};
static void pika_plugin_config_finalize (GObject *object);
static void pika_plugin_config_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void pika_plugin_config_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
G_DEFINE_TYPE (PikaPluginConfig, pika_plugin_config, PIKA_TYPE_DIALOG_CONFIG)
#define parent_class pika_plugin_config_parent_class
static void
pika_plugin_config_class_init (PikaPluginConfigClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
gchar *path;
object_class->finalize = pika_plugin_config_finalize;
object_class->set_property = pika_plugin_config_set_property;
object_class->get_property = pika_plugin_config_get_property;
path = pika_config_build_data_path ("fractalexplorer");
PIKA_CONFIG_PROP_PATH (object_class,
PROP_FRACTALEXPLORER_PATH,
"fractalexplorer-path",
"Fractal Explorer path",
FRACTALEXPLORER_PATH_BLURB,
PIKA_CONFIG_PATH_DIR_LIST, path,
PIKA_PARAM_STATIC_STRINGS);
g_free (path);
path = pika_config_build_data_path ("gfig");
PIKA_CONFIG_PROP_PATH (object_class,
PROP_GFIG_PATH,
"gfig-path",
"GFig path",
GFIG_PATH_BLURB,
PIKA_CONFIG_PATH_DIR_LIST, path,
PIKA_PARAM_STATIC_STRINGS);
g_free (path);
path = pika_config_build_data_path ("gflare");
PIKA_CONFIG_PROP_PATH (object_class,
PROP_GFLARE_PATH,
"gflare-path",
"GFlare path",
GFLARE_PATH_BLURB,
PIKA_CONFIG_PATH_DIR_LIST, path,
PIKA_PARAM_STATIC_STRINGS);
g_free (path);
path = pika_config_build_data_path ("pikaressionist");
PIKA_CONFIG_PROP_PATH (object_class,
PROP_PIKARESSIONIST_PATH,
"pikaressionist-path",
"PIKAressionist path",
PIKARESSIONIST_PATH_BLURB,
PIKA_CONFIG_PATH_DIR_LIST, path,
PIKA_PARAM_STATIC_STRINGS);
g_free (path);
path = pika_config_build_data_path ("scripts");
PIKA_CONFIG_PROP_PATH (object_class,
PROP_SCRIPT_FU_PATH,
"script-fu-path",
"Script-Fu path",
SCRIPT_FU_PATH_BLURB,
PIKA_CONFIG_PATH_DIR_LIST, path,
PIKA_PARAM_STATIC_STRINGS);
g_free (path);
}
static void
pika_plugin_config_init (PikaPluginConfig *config)
{
}
static void
pika_plugin_config_finalize (GObject *object)
{
PikaPluginConfig *plugin_config = PIKA_PLUGIN_CONFIG (object);
g_free (plugin_config->fractalexplorer_path);
g_free (plugin_config->gfig_path);
g_free (plugin_config->gflare_path);
g_free (plugin_config->pikaressionist_path);
g_free (plugin_config->script_fu_path);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
pika_plugin_config_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
PikaPluginConfig *plugin_config = PIKA_PLUGIN_CONFIG (object);
switch (property_id)
{
case PROP_FRACTALEXPLORER_PATH:
g_free (plugin_config->fractalexplorer_path);
plugin_config->fractalexplorer_path = g_value_dup_string (value);
break;
case PROP_GFIG_PATH:
g_free (plugin_config->gfig_path);
plugin_config->gfig_path = g_value_dup_string (value);
break;
case PROP_GFLARE_PATH:
g_free (plugin_config->gflare_path);
plugin_config->gflare_path = g_value_dup_string (value);
break;
case PROP_PIKARESSIONIST_PATH:
g_free (plugin_config->pikaressionist_path);
plugin_config->pikaressionist_path = g_value_dup_string (value);
break;
case PROP_SCRIPT_FU_PATH:
g_free (plugin_config->script_fu_path);
plugin_config->script_fu_path = g_value_dup_string (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
pika_plugin_config_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
PikaPluginConfig *plugin_config = PIKA_PLUGIN_CONFIG (object);
switch (property_id)
{
case PROP_FRACTALEXPLORER_PATH:
g_value_set_string (value, plugin_config->fractalexplorer_path);
break;
case PROP_GFIG_PATH:
g_value_set_string (value, plugin_config->gfig_path);
break;
case PROP_GFLARE_PATH:
g_value_set_string (value, plugin_config->gflare_path);
break;
case PROP_PIKARESSIONIST_PATH:
g_value_set_string (value, plugin_config->pikaressionist_path);
break;
case PROP_SCRIPT_FU_PATH:
g_value_set_string (value, plugin_config->script_fu_path);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}

View File

@ -0,0 +1,60 @@
/* PIKA - Photo and Image Kooker Application
* a rebranding of The GNU Image Manipulation Program (created with heckimp)
* A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
*
* Original copyright, applying to most contents (license remains unchanged):
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* PikaPluginConfig class
* Copyright (C) 2001 Sven Neumann <sven@gimp.org>
*
* 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 <https://www.gnu.org/licenses/>.
*/
#ifndef __PIKA_PLUGIN_CONFIG_H__
#define __PIKA_PLUGIN_CONFIG_H__
#include "config/pikadialogconfig.h"
#define PIKA_TYPE_PLUGIN_CONFIG (pika_plugin_config_get_type ())
#define PIKA_PLUGIN_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PIKA_TYPE_PLUGIN_CONFIG, PikaPluginConfig))
#define PIKA_PLUGIN_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PIKA_TYPE_PLUGIN_CONFIG, PikaPluginConfigClass))
#define PIKA_IS_PLUGIN_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PIKA_TYPE_PLUGIN_CONFIG))
#define PIKA_IS_PLUGIN_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PIKA_TYPE_PLUGIN_CONFIG))
typedef struct _PikaPluginConfigClass PikaPluginConfigClass;
struct _PikaPluginConfig
{
PikaDialogConfig parent_instance;
gchar *fractalexplorer_path;
gchar *gfig_path;
gchar *gflare_path;
gchar *pikaressionist_path;
gchar *script_fu_path;
};
struct _PikaPluginConfigClass
{
PikaGuiConfigClass parent_class;
};
GType pika_plugin_config_get_type (void) G_GNUC_CONST;
#endif /* PIKA_PLUGIN_CONFIG_H__ */

792
app/config/pikarc-blurbs.h Normal file
View File

@ -0,0 +1,792 @@
/* pikarc-blurbs.h -- descriptions for pikarc properties */
#ifndef __PIKA_RC_BLURBS_H__
#define __PIKA_RC_BLURBS_H__
/* Not all strings defined here are used in the user interface
* (the preferences dialog mainly) and only those that are should
* be marked for translation.
*/
#define ACTIVATE_ON_FOCUS_BLURB \
_("When enabled, an image will become the active image when its image " \
"window receives the focus. This is useful for window managers using " \
"\"click to focus\".")
#define BRUSH_PATH_BLURB \
"Sets the brush search path."
#define BRUSH_PATH_WRITABLE_BLURB ""
#define DYNAMICS_PATH_BLURB \
_("Sets the dynamics search path.")
#define DYNAMICS_PATH_WRITABLE_BLURB ""
#define TOOL_PRESET_PATH_BLURB \
_("Sets the dynamics search path.")
#define TOOL_PRESET_PATH_WRITABLE_BLURB ""
#define CANVAS_PADDING_COLOR_BLURB \
_("Sets the canvas padding color used if the padding mode is set to " \
"custom color.")
#define CANVAS_PADDING_IN_SHOW_ALL_BLURB \
_("Specifies whether to keep the canvas padding when \"View -> Show All\" " \
"is enabled.")
#define CANVAS_PADDING_MODE_BLURB \
_("Specifies how the area around the image should be drawn.")
#define CHECK_UPDATES_BLURB \
_("Check for availability of PIKA updates through background internet queries.")
#define CHECK_UPDATE_TIMESTAMP_BLURB \
_("Timestamp of the last update check.")
#define COLOR_MANAGEMENT_BLURB \
"Defines the color management behavior."
#define COLOR_PROFILE_POLICY_BLURB \
_("How to handle embedded color profiles when opening a file.")
#define COLOR_PROFILE_PATH_BLURB \
_("Sets the default folder path for all color profile file dialogs.")
#define CURSOR_MODE_BLURB \
_("Sets the type of mouse pointers to use.")
#define CURSOR_HANDEDNESS_BLURB \
_("Sets the handedness for cursor positioning.")
#define CURSOR_UPDATING_BLURB \
_("Context-dependent mouse pointers are helpful. They are enabled by " \
"default. However, they require overhead that you may want to do without.")
#define DEFAULT_BRUSH_BLURB \
"Specify a default brush. The brush is searched for in the " \
"specified brush path."
#define DEFAULT_DYNAMICS_BLURB \
"Specify a default dynamics. The dynamics is searched for in the " \
"specified dynamics path."
#define DEFAULT_TOOL_PRESET_BLURB \
"Specify a default tool preset. The tool preset is searched for in the " \
"specified tool prests path."
#define CUSTOM_TITLE_BAR_BLURB \
_("Merge menu and title bar (client-side decoration)")
#define DEFAULT_SHOW_ALL_BLURB \
_("Show full image content by default.")
#define DEFAULT_DOT_FOR_DOT_BLURB \
_("When enabled, this will ensure that each pixel of an image gets " \
"mapped to a pixel on the screen.")
#define DEFAULT_FONT_BLURB \
"Specify a default font."
#define DEFAULT_GRADIENT_BLURB \
"Specify a default gradient."
#define DEFAULT_GRID_BLURB \
"Specify a default image grid."
#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."
#define DEFAULT_PALETTE_BLURB \
"Specify a default palette."
#define DEFAULT_SNAP_DISTANCE_BLURB \
_("This is the distance in pixels where Guide and Grid snapping " \
"activates.")
#define SNAP_TO_GUIDES_BLURB \
_("Snap to guides by default in new image windows.")
#define SNAP_TO_GRID_BLURB \
_("Snap to the grid by default in new image windows.")
#define SNAP_TO_CANVAS_BLURB \
_("Snap to the canvas edges by default in new image windows.")
#define SNAP_TO_PATH_BLURB \
_("Snap to the active path by default in new image windows.")
#define SNAP_TO_BBOX_BLURB \
_("Snap to the layers bounding boxes by default in new image windows.")
#define SNAP_TO_EQUIDISTANCE_BLURB \
_("Snap to the equidistance between three bounding boxes by default in new image windows.")
#define DEFAULT_THRESHOLD_BLURB \
_("Tools such as fuzzy-select and bucket fill find regions based on a " \
"seed-fill algorithm. The seed fill starts at the initially selected " \
"pixel and progresses in all directions until the difference of pixel " \
"intensity from the original is greater than a specified threshold. " \
"This value represents the default threshold.")
#define DEFAULT_VIEW_BLURB \
"Sets the default settings for the image view."
#define DEFAULT_FULLSCREEN_VIEW_BLURB \
"Sets the default settings used when an image is viewed in fullscreen mode."
#define DOCK_WINDOW_HINT_BLURB \
_("The window type hint that is set on dock windows and the toolbox " \
"window. This may affect the way your window manager decorates and " \
"handles these windows.")
#define ENVIRON_PATH_BLURB \
"Sets the environ search path."
#define FRACTALEXPLORER_PATH_BLURB \
"Where to search for fractals used by the Fractal Explorer plug-in."
#define GFIG_PATH_BLURB \
"Where to search for Gfig figures used by the Gfig plug-in."
#define GFLARE_PATH_BLURB \
"Where to search for gflares used by the GFlare plug-in."
#define PIKARESSIONIST_PATH_BLURB \
"Where to search for data used by the Pikaressionist plug-in."
#define GLOBAL_BRUSH_BLURB \
_("When enabled, the selected brush will be used for all tools.")
#define GLOBAL_DYNAMICS_BLURB \
_("When enabled, the selected dynamics will be used for all tools.")
#define GLOBAL_FONT_BLURB \
"When enabled, the selected font will be used for all tools."
#define GLOBAL_GRADIENT_BLURB \
_("When enabled, the selected gradient will be used for all tools.")
#define GLOBAL_PATTERN_BLURB \
_("When enabled, the selected pattern will be used for all tools.")
#define GLOBAL_PALETTE_BLURB \
"When enabled, the selected palette will be used for all tools."
#define GRADIENT_PATH_BLURB \
"Sets the gradient search path."
#define GRADIENT_PATH_WRITABLE_BLURB ""
#define FONT_PATH_BLURB \
"Where to look for fonts in addition to the system-wide installed fonts."
#define HELP_BROWSER_BLURB \
_("Sets the browser used by the help system.")
#define HELP_LOCALES_BLURB \
"Specifies the language preferences used by the help system. This is a " \
"colon-separated list of language identifiers with decreasing priority. " \
"If empty, the language is taken from the user's locale setting."
#define FILTER_TOOL_MAX_RECENT_BLURB \
_("How many recent settings to keep around in filter tools.")
#define FILTER_TOOL_USE_LAST_SETTINGS_BLURB \
_("Default to the last used settings in filter tools.")
#define FILTER_TOOL_SHOW_COLOR_OPTIONS_BLURB \
_("Show advanced color options in filter tools.")
#define IMAGE_STATUS_FORMAT_BLURB \
_("Sets the text to appear in image window status bars.")
#define IMAGE_TITLE_FORMAT_BLURB \
_("Sets the text to appear in image window titles.")
#define IMPORT_PROMOTE_FLOAT_BLURB \
_("Promote imported images to floating point precision. Does not apply " \
"to indexed images.")
#define IMPORT_PROMOTE_DITHER_BLURB \
_("When promoting imported images to floating point precision, also add " \
"minimal noise in order to distribute color values a bit.")
#define IMPORT_ADD_ALPHA_BLURB \
_("Add an alpha channel to all layers of imported images.")
#define IMPORT_RAW_PLUG_IN_BLURB \
_("Which plug-in to use for importing raw digital camera files.")
#define EXPORT_FILE_TYPE_BLURB \
_("Export file type used by default.")
#define EXPORT_COLOR_PROFILE_BLURB \
_("Export the image's color profile by default.")
#define EXPORT_COMMENT_BLURB \
_("Export the image's comment by default.")
#define EXPORT_THUMBNAIL_BLURB \
_("Export the image's thumbnail by default")
/* Translators: tooltip for configuration option (checkbox).
* It determines how file export plug-ins handle Exif by default.
*/
#define EXPORT_METADATA_EXIF_BLURB \
_("Export Exif metadata by default.")
/* Translators: tooltip for configuration option (checkbox).
* It determines how file export plug-ins handle XMP by default.
*/
#define EXPORT_METADATA_XMP_BLURB \
_("Export XMP metadata by default.")
/* Translators: tooltip for configuration option (checkbox).
* It determines how file export plug-ins handle IPTC by default.
*/
#define EXPORT_METADATA_IPTC_BLURB \
_("Export IPTC metadata by default.")
#define GENERATE_BACKTRACE_BLURB \
_("Try generating debug data for bug reporting when appropriate.")
#define WIN32_POINTER_INPUT_API_BLURB \
_("Sets the preferred pen and touch input API.")
#define INITIAL_ZOOM_TO_FIT_BLURB \
_("When enabled, this will ensure that the full image is visible after a " \
"file is opened, otherwise it will be displayed with a scale of 1:1.")
#define DRAG_ZOOM_MODE_BLURB \
_("Whether to zoom based on distance moved or time spent moving, when " \
"zooming via dragging the mouse.")
#define DRAG_ZOOM_SPEED_BLURB \
_("Adjusts the rate at which dragging the mouse will zoom the canvas, " \
"in percentage.")
#define INTERPOLATION_TYPE_BLURB \
_("Sets the level of interpolation used for scaling and other " \
"transformations.")
#define INTERPRETER_PATH_BLURB \
"Sets the interpreter search path."
#define LANGUAGE_BLURB \
_("Specifies the language to use for the user interface.")
#define LAST_KNOWN_RELEASE_BLURB \
_("The last known release version of PIKA as queried from official website.")
#define CONFIG_VERSION_BLURB \
_("The version of PIKA config files.")
#define LAST_OPENED_SIZE_BLURB \
_("How many recently opened image filenames to keep on the File menu.")
#define LAST_RELEASE_TIMESTAMP_BLURB \
_("The timestamp for the last known release date.")
#define LAST_REVISION_BLURB \
_("The last revision number for the release.")
#define MARCHING_ANTS_SPEED_BLURB \
_("Speed of marching ants in the selection outline. This value is in " \
"milliseconds (less time indicates faster marching).")
#define MAX_NEW_IMAGE_SIZE_BLURB \
_("PIKA will warn the user if an attempt is made to create an image that " \
"would take more memory than the size specified here.")
#define METADATA_ROTATION_POLICY_BLURB \
_("How to handle \"Orientation\" metadata when opening a file.")
#define MODULE_PATH_BLURB \
"Sets the module search path."
#define MONITOR_RES_FROM_GDK_BLURB \
"When enabled, PIKA will use the monitor resolution from the windowing system."
#define MONITOR_XRESOLUTION_BLURB \
_("Sets the monitor's horizontal resolution, in dots per inch. If set to " \
"0, forces the X server to be queried for both horizontal and vertical " \
"resolution information.")
#define MONITOR_YRESOLUTION_BLURB \
_("Sets the monitor's vertical resolution, in dots per inch. If set to " \
"0, forces the X server to be queried for both horizontal and vertical " \
"resolution information.")
#define EDIT_NON_VISIBLE_BLURB \
_("When enabled, non-visible layers can be edited as normal.")
#define MOVE_TOOL_CHANGES_ACTIVE_BLURB \
_("If enabled, the move tool sets the edited layer or path as active. " \
"This used to be the default behavior 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.")
#define NUM_PROCESSORS_BLURB \
_("Sets how many threads PIKA should use for operations that support it.")
#define PALETTE_PATH_BLURB \
"Sets the palette search path."
#define PALETTE_PATH_WRITABLE_BLURB ""
#define PATTERN_PATH_BLURB \
"Sets the pattern search path."
#define PATTERN_PATH_WRITABLE_BLURB ""
#define FILTER_HISTORY_SIZE_BLURB \
"How many recently used filters and plug-ins to keep on the Filters menu."
#define PLUG_IN_PATH_BLURB \
"Sets the plug-in search path."
#define PLUGINRC_PATH_BLURB \
"Sets the pluginrc search path."
#define LAYER_PREVIEWS_BLURB \
_("Sets whether PIKA should create previews of layers and channels. " \
"Previews in the layers and channels dialog are nice to have but they " \
"can slow things down when working with large images.")
#define GROUP_LAYER_PREVIEWS_BLURB \
_("Sets whether PIKA should create previews of layer groups. " \
"Layer group previews are more expensive than ordinary layer previews.")
#define LAYER_PREVIEW_SIZE_BLURB \
_("Sets the preview size used for layers and channel previews in newly " \
"created dialogs.")
#define QUICK_MASK_COLOR_BLURB \
_("Sets the default quick mask color.")
#define RESIZE_WINDOWS_ON_RESIZE_BLURB \
_("When enabled, the image window will automatically resize itself " \
"whenever the physical image size changes. This setting only takes " \
"effect in multi-window mode.")
#define RESIZE_WINDOWS_ON_ZOOM_BLURB \
_("When enabled, the image window will automatically resize itself " \
"when zooming into and out of images. This setting only takes " \
"effect in multi-window mode.")
#define RESTORE_SESSION_BLURB \
_("Let PIKA try to restore your last saved session on each startup.")
#define RESTORE_MONITOR_BLURB \
_("When enabled, PIKA will try to restore windows on the monitor they " \
"were open before. When disabled, windows will appear on the currently " \
"used monitor.")
#define SAVE_DEVICE_STATUS_BLURB \
_("Remember the current tool, pattern, color, and brush across PIKA " \
"sessions.")
#define DEVICES_SHARE_TOOL_BLURB \
_("When enabled, the same tool and tool options will be used for all " \
"input devices. No tool switching will occur when the input device " \
"changes.")
#define SAVE_DOCUMENT_HISTORY_BLURB \
_("Keep a permanent record of all opened and saved files in the Recent " \
"Documents list.")
#define SAVE_SESSION_INFO_BLURB \
_("Save the positions and sizes of the main dialogs when PIKA exits.")
#define SAVE_TOOL_OPTIONS_BLURB \
_("Save the tool options when PIKA exits.")
#define SCRIPT_FU_PATH_BLURB \
"This path will be searched for scripts when the Script-Fu plug-in is run."
#define SHOW_BRUSH_OUTLINE_BLURB \
_("When enabled, all paint tools will show a preview of the current " \
"brush's outline.")
#define SNAP_BRUSH_OUTLINE_BLURB \
_("When enabled, the brush outline will snap to individual dabs while " \
"painting.")
#define SHOW_HELP_BUTTON_BLURB \
_("When enabled, dialogs will show a help button that gives access to " \
"the related help page. Without this button, the help page can still " \
"be reached by pressing F1.")
#define SHOW_PAINT_TOOL_CURSOR_BLURB \
_("When enabled, the pointer will be shown over the image while " \
"using a paint tool. " \
"If both the brush outline and pointer are disabled, the " \
"position will be indicated as unobtrusively as possibly.")
#define SHOW_MENUBAR_BLURB \
_("When enabled, the menubar is visible by default. This can also be " \
"toggled with the \"View->Show Menubar\" command.")
#define SHOW_RULERS_BLURB \
_("When enabled, the rulers are visible by default. This can also be " \
"toggled with the \"View->Show Rulers\" command.")
#define SHOW_SCROLLBARS_BLURB \
_("When enabled, the scrollbars are visible by default. This can also be " \
"toggled with the \"View->Show Scrollbars\" command.")
#define SHOW_STATUSBAR_BLURB \
_("When enabled, the statusbar is visible by default. This can also be " \
"toggled with the \"View->Show Statusbar\" command.")
#define SHOW_SELECTION_BLURB \
_("When enabled, the selection is visible by default. This can also be " \
"toggled with the \"View->Show Selection\" command.")
#define SHOW_LAYER_BOUNDARY_BLURB \
_("When enabled, the layer boundary is visible by default. This can also " \
"be toggled with the \"View->Show Layer Boundary\" command.")
#define SHOW_CANVAS_BOUNDARY_BLURB \
_("When enabled, the canvas boundary is visible by default. This can also " \
"be toggled with the \"View->Show Canvas Boundary\" command.")
#define SHOW_GUIDES_BLURB \
_("When enabled, the guides are visible by default. This can also be " \
"toggled with the \"View->Show Guides\" command.")
#define SHOW_GRID_BLURB \
_("When enabled, the grid is visible by default. This can also be toggled " \
"with the \"View->Show Grid\" command.")
#define SHOW_SAMPLE_POINTS_BLURB \
_("When enabled, the sample points are visible by default. This can also be " \
"toggled with the \"View->Show Sample Points\" command.")
#define SHOW_TOOLTIPS_BLURB \
_("Show a tooltip when the pointer hovers over an item.")
#define SINGLE_WINDOW_MODE_BLURB \
_("Use PIKA in a single-window mode.")
#define HIDE_DOCKS_BLURB \
_("Hide docks and other windows, leaving only image windows.")
#define SHOW_TABS_BLURB \
_("Show the image tabs bar in single window mode.")
#define PLAYGROUND_NPD_TOOL_BLURB \
_("Enable the N-Point Deformation tool.")
#define PLAYGROUND_HANDLE_TRANSFORM_TOOL_BLURB \
_("Enable the Handle Transform tool.")
#define PLAYGROUND_SYMMETRY_BLURB \
_("Enable symmetry on painting.")
#define PLAYGROUND_MYBRUSH_TOOL_BLURB \
_("Enable the MyPaint Brush tool.")
#define PLAYGROUND_SEAMLESS_CLONE_TOOL_BLURB \
_("Enable the Seamless Clone tool.")
#define PLAYGROUND_PAINT_SELECT_TOOL_BLURB \
_("Enable the Paint Select tool.")
#define SPACE_BAR_ACTION_BLURB \
_("What to do when the space bar is pressed in the image window.")
#define SWAP_COMPRESSION_BLURB \
_("The compression method used for tile data stored in the swap file.")
#define SWAP_PATH_BLURB \
_("Sets the swap file location. PIKA uses a tile based memory allocation " \
"scheme. The swap file is used to quickly and easily swap tiles out to " \
"disk and back in. Be aware that the swap file can easily get very large " \
"if PIKA is used with large images. " \
"Also, things can get horribly slow if the swap file is created on " \
"a folder that is mounted over NFS. For these reasons, it may be " \
"desirable to put your swap file in \"/tmp\".")
#define CAN_CHANGE_ACCELS_BLURB \
_("When enabled, you can change keyboard shortcuts for menu items " \
"by hitting a key combination while the menu item is highlighted.")
#define SAVE_ACCELS_BLURB \
_("Save changed keyboard shortcuts when PIKA exits.")
#define RESTORE_ACCELS_BLURB \
_("Restore saved keyboard shortcuts on each PIKA startup.")
#define TEMP_PATH_BLURB \
_("Sets the folder for temporary storage. Files will appear here " \
"during the course of running PIKA. Most files will disappear " \
"when PIKA exits, but some files are likely to remain, so it " \
"is best if this folder not be one that is shared by other users.")
#define THEME_BLURB \
_("The name of the theme to use.")
#define THEME_PATH_BLURB \
"Sets the theme search path."
#define ICON_THEME_BLURB \
"The name of the icon theme to use."
#define OVERRIDE_THEME_ICON_SIZE_BLURB \
_("Override theme-set icon sizes.")
#define ICON_SIZE_BLURB \
_("The size of the icons to use.")
#define PREFER_SYMBOLIC_ICONS_BLURB \
_("When enabled, symbolic icons will be preferred if available.")
#define ICON_THEME_PATH_BLURB \
"Sets the icon theme search path."
#define IMAGE_CONVERT_PROFILE_INTENT_BLURB \
_("Sets the default rendering intent for the 'Convert to Color Profile' dialog.")
#define IMAGE_CONVERT_PROFILE_BPC_BLURB \
_("Sets the default 'Black Point Compensation' state for the " \
"'Convert to Color Profile' dialog.")
#define IMAGE_CONVERT_PRECISION_LAYER_DITHER_METHOD_BLURB \
_("Sets the default layer dithering method for the 'Convert Precision' dialog.")
#define IMAGE_CONVERT_PRECISION_TEXT_LAYER_DITHER_METHOD_BLURB \
_("Sets the default text layer dithering method for the 'Convert Precision' dialog.")
#define IMAGE_CONVERT_PRECISION_CHANNEL_DITHER_METHOD_BLURB \
_("Sets the default channel dithering method for the 'Convert Precision' dialog.")
#define IMAGE_CONVERT_INDEXED_PALETTE_TYPE_BLURB \
_("Sets the default palette type for the 'Convert to Indexed' dialog.")
#define IMAGE_CONVERT_INDEXED_MAX_COLORS_BLURB \
_("Sets the default maximum number of colors for the 'Convert to Indexed' dialog.")
#define IMAGE_CONVERT_INDEXED_REMOVE_DUPLICATES_BLURB \
_("Sets the default 'Remove duplicate colors' state for the 'Convert to Indexed' dialog.")
#define IMAGE_CONVERT_INDEXED_DITHER_TYPE_BLURB \
_("Sets the default dithering type for the 'Convert to Indexed' dialog.")
#define IMAGE_CONVERT_INDEXED_DITHER_ALPHA_BLURB \
_("Sets the default 'Dither alpha' state for the 'Convert to Indexed' dialog.")
#define IMAGE_CONVERT_INDEXED_DITHER_TEXT_LAYERS_BLURB \
_("Sets the default 'Dither text layers' state for the 'Convert to Indexed' dialog.")
#define IMAGE_RESIZE_FILL_TYPE_BLURB \
_("Sets the default fill type for the 'Canvas Size' dialog.")
#define IMAGE_RESIZE_LAYER_SET_BLURB \
_("Sets the default set of layers to resize for the 'Canvas Size' dialog.")
#define IMAGE_RESIZE_RESIZE_TEXT_LAYERS_BLURB \
_("Sets the default 'Resize text layers' state for the 'Canvas Size' dialog.")
# define ITEMS_SELECT_METHOD_BLURB \
_("Sets how items are searched and selected from a textual pattern.")
#define LAYER_NEW_NAME_BLURB \
_("Sets the default layer name for the 'New Layer' dialog.")
#define LAYER_NEW_MODE_BLURB \
_("Sets the default mode for the 'New Layer' dialog.")
#define LAYER_NEW_BLEND_SPACE_BLURB \
_("Sets the default blend space for the 'New Layer' dialog.")
#define LAYER_NEW_COMPOSITE_SPACE_BLURB \
_("Sets the default composite space for the 'New Layer' dialog.")
#define LAYER_NEW_COMPOSITE_MODE_BLURB \
_("Sets the default composite mode for the 'New Layer' dialog.")
#define LAYER_NEW_OPACITY_BLURB \
_("Sets the default opacity for the 'New Layer' dialog.")
#define LAYER_NEW_FILL_TYPE_BLURB \
_("Sets the default fill type for the 'New Layer' dialog.")
#define LAYER_RESIZE_FILL_TYPE_BLURB \
_("Sets the default fill type for the 'Layer Boundary Size' dialog.")
#define LAYER_ADD_MASK_TYPE_BLURB \
_("Sets the default mask for the 'Add Layer Mask' dialog.")
#define LAYER_ADD_MASK_INVERT_BLURB \
_("Sets the default 'invert mask' state for the 'Add Layer Mask' dialog.")
#define LAYER_MERGE_TYPE_BLURB \
_("Sets the default merge type for the 'Merge Visible Layers' dialog.")
#define LAYER_MERGE_ACTIVE_GROUP_ONLY_BLURB \
_("Sets the default 'Active group only' for the 'Merge Visible Layers' dialog.")
#define LAYER_MERGE_DISCARD_INVISIBLE_BLURB \
_("Sets the default 'Discard invisible' for the 'Merge Visible Layers' dialog.")
#define CHANNEL_NEW_NAME_BLURB \
_("Sets the default channel name for the 'New Channel' dialog.")
#define CHANNEL_NEW_COLOR_BLURB \
_("Sets the default color and opacity for the 'New Channel' dialog.")
#define VECTORS_NEW_NAME_BLURB \
_("Sets the default path name for the 'New Path' dialog.")
#define VECTORS_EXPORT_PATH_BLURB \
_("Sets the default folder path for the 'Export Path' dialog.")
#define VECTORS_EXPORT_ACTIVE_ONLY_BLURB \
_("Sets the default 'Export the selected paths' state for the 'Export Path' dialog.")
#define VECTORS_IMPORT_PATH_BLURB \
_("Sets the default folder path for the 'Import Path' dialog.")
#define VECTORS_IMPORT_MERGE_BLURB \
_("Sets the default 'Merge imported paths' state for the 'Import Path' dialog.")
#define VECTORS_IMPORT_SCALE_BLURB \
_("Sets the default 'Scale imported paths to fit size' state for the 'Import Path' dialog.")
#define SELECTION_FEATHER_RADIUS_BLURB \
_("Sets the default feather radius for the 'Feather Selection' dialog.")
#define SELECTION_FEATHER_EDGE_LOCK_BLURB \
_("Sets the default 'Selected areas continue outside the image' setting " \
"for the 'Feather Selection' dialog.")
#define SELECTION_GROW_RADIUS_BLURB \
_("Sets the default grow radius for the 'Grow Selection' dialog.")
#define SELECTION_SHRINK_RADIUS_BLURB \
_("Sets the default shrink radius for the 'Shrink Selection' dialog.")
#define SELECTION_SHRINK_EDGE_LOCK_BLURB \
_("Sets the default 'Selected areas continue outside the image' setting " \
"for the 'Shrink Selection' dialog.")
#define SELECTION_BORDER_RADIUS_BLURB \
_("Sets the default border radius for the 'Border Selection' dialog.")
#define SELECTION_BORDER_EDGE_LOCK_BLURB \
_("Sets the default 'Selected areas continue outside the image' setting " \
"for the 'Border Selection' dialog.")
#define SELECTION_BORDER_STYLE_BLURB \
_("Sets the default border style for the 'Border Selection' dialog.")
#define FILL_OPTIONS_BLURB \
"The default fill options for the fill dialogs."
#define STROKE_OPTIONS_BLURB \
"The default stroke options for the stroke dialogs."
#define THUMBNAIL_SIZE_BLURB \
_("Sets the size of the thumbnail shown in the Open dialog.")
#define THUMBNAIL_FILESIZE_LIMIT_BLURB \
_("The thumbnail in the Open dialog will be automatically updated " \
"if the file being previewed is smaller than the size set here.")
#define TILE_CACHE_SIZE_BLURB \
_("When the amount of pixel data exceeds this limit, PIKA will start to " \
"swap tiles to disk. This is a lot slower but it makes it possible to " \
"work on images that wouldn't fit into memory otherwise. If you have a " \
"lot of RAM, you may want to set this to a higher value.")
#define TOOLBOX_COLOR_AREA_BLURB \
_("Show the current foreground and background colors in the toolbox.")
#define TOOLBOX_FOO_AREA_BLURB \
_("Show the currently selected brush, pattern and gradient in the toolbox.")
#define TOOLBOX_GROUPS_BLURB \
_("Use a single toolbox button for grouped tools.")
#define TOOLBOX_IMAGE_AREA_BLURB \
_("Show the currently active image in the toolbox.")
#define TOOLBOX_MASCOT_BLURB \
_("Show the PIKA mascot at the top of the toolbox.")
#define TRANSPARENCY_CUSTOM_COLOR1_BLURB \
_("The first color to use in the transparency checkerboard, " \
"when Transparency Type is set to Custom colors.")
#define TRANSPARENCY_CUSTOM_COLOR2_BLURB \
_("The second color to use in the transparency checkerboard, " \
"when Transparency Type is set to Custom colors.")
#define TRANSPARENCY_TYPE_BLURB \
_("Sets the manner in which transparency is displayed in images.")
#define TRANSPARENCY_SIZE_BLURB \
_("Sets the size of the checkerboard used to display transparency.")
#define TRUST_DIRTY_FLAG_BLURB \
_("When enabled, PIKA will not save an image if it has not been changed " \
"since it was opened.")
#define UNDO_LEVELS_BLURB \
_("Sets the minimal number of operations that can be undone. More undo " \
"levels are kept available until the undo-size limit is reached.")
#define UNDO_SIZE_BLURB \
_("Sets an upper limit to the memory that is used per image to keep " \
"operations on the undo stack. Regardless of this setting, at least " \
"as many undo-levels as configured can be undone.")
#define UNDO_PREVIEW_SIZE_BLURB \
_("Sets the size of the previews in the Undo History.")
#define USE_HELP_BLURB \
_("When enabled, pressing F1 will open the help browser.")
#define USE_OPENCL_BLURB \
_("When enabled, uses OpenCL for some operations.")
#define USER_MANUAL_ONLINE_BLURB \
"When enabled, the online user manual will be used by the help system. " \
"Otherwise the locally installed copy is used."
#define USER_MANUAL_ONLINE_URI_BLURB \
"The location of the online user manual. This is used if " \
"'user-manual-online' is enabled."
#define ZOOM_QUALITY_BLURB \
"There's a tradeoff between speed and quality of the zoomed-out display."
#define DEFAULT_USE_EVENT_HISTORY_BLURB \
"Bugs in event history buffer are frequent so in case of cursor " \
"offset problems turning it off helps."
#define SEARCH_SHOW_UNAVAILABLE_BLURB \
_("When enabled, a search of actions will also return inactive actions.")
#define ACTION_HISTORY_SIZE_BLURB \
_("The maximum number of actions saved in history.")
#endif /* __PIKA_RC_BLURBS_H__ */

View File

@ -0,0 +1,178 @@
/* PIKA - Photo and Image Kooker Application
* a rebranding of The GNU Image Manipulation Program (created with heckimp)
* A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
*
* Original copyright, applying to most contents (license remains unchanged):
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* PikaRc deserialization routines
* Copyright (C) 2001-2002 Sven Neumann <sven@gimp.org>
*
* 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 <https://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <cairo.h>
#include <gegl.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include "libpikacolor/pikacolor.h"
#include "libpikamath/pikamath.h"
#include "libpikaconfig/pikaconfig.h"
#include "config-types.h"
#include "pikarc-deserialize.h"
#include "pikarc-unknown.h"
#include "pika-intl.h"
static GTokenType pika_rc_deserialize_unknown (PikaConfig *config,
GScanner *scanner);
gboolean
pika_rc_deserialize (PikaConfig *config,
GScanner *scanner,
gint nest_level,
gpointer data)
{
GObjectClass *klass;
GParamSpec **property_specs;
guint n_property_specs;
guint i;
guint scope_id;
guint old_scope_id;
GTokenType token;
GTokenType next;
g_return_val_if_fail (PIKA_IS_CONFIG (config), FALSE);
klass = G_OBJECT_GET_CLASS (config);
property_specs = g_object_class_list_properties (klass, &n_property_specs);
if (! property_specs)
return TRUE;
scope_id = g_type_qname (G_TYPE_FROM_INSTANCE (config));
old_scope_id = g_scanner_set_scope (scanner, scope_id);
for (i = 0; i < n_property_specs; i++)
{
GParamSpec *prop_spec = property_specs[i];
if (prop_spec->flags & PIKA_CONFIG_PARAM_SERIALIZE)
{
g_scanner_scope_add_symbol (scanner, scope_id,
prop_spec->name, prop_spec);
}
}
g_free (property_specs);
g_object_freeze_notify (G_OBJECT (config));
token = G_TOKEN_LEFT_PAREN;
while (TRUE)
{
next = g_scanner_peek_next_token (scanner);
if (G_UNLIKELY (next != token && ! (token == G_TOKEN_SYMBOL &&
next == G_TOKEN_IDENTIFIER)))
{
break;
}
token = g_scanner_get_next_token (scanner);
switch (token)
{
case G_TOKEN_LEFT_PAREN:
token = G_TOKEN_SYMBOL;
break;
case G_TOKEN_IDENTIFIER:
token = pika_rc_deserialize_unknown (config, scanner);
break;
case G_TOKEN_SYMBOL:
token = pika_config_deserialize_property (config,
scanner, nest_level);
break;
case G_TOKEN_RIGHT_PAREN:
token = G_TOKEN_LEFT_PAREN;
break;
default: /* do nothing */
break;
}
}
g_scanner_set_scope (scanner, old_scope_id);
g_object_thaw_notify (G_OBJECT (config));
if (token == G_TOKEN_NONE)
return FALSE;
/* If the unknown token value couldn't be parsed the default error
message is rather confusing. We try to produce something more
meaningful here ...
*/
if (token == G_TOKEN_STRING && next == G_TOKEN_IDENTIFIER)
{
g_scanner_unexp_token (scanner, G_TOKEN_SYMBOL, NULL, NULL, NULL,
_("fatal parse error"), TRUE);
return FALSE;
}
return pika_config_deserialize_return (scanner, token, nest_level);
}
static GTokenType
pika_rc_deserialize_unknown (PikaConfig *config,
GScanner *scanner)
{
gchar *key;
guint old_scope_id;
old_scope_id = g_scanner_set_scope (scanner, 0);
if (g_scanner_peek_next_token (scanner) != G_TOKEN_STRING)
return G_TOKEN_STRING;
key = g_strdup (scanner->value.v_identifier);
g_scanner_get_next_token (scanner);
g_scanner_set_scope (scanner, old_scope_id);
if (! g_utf8_validate (scanner->value.v_string, -1, NULL))
{
g_scanner_error (scanner,
_("value for token %s is not a valid UTF-8 string"),
key);
g_free (key);
return G_TOKEN_NONE;
}
pika_rc_add_unknown_token (config, key, scanner->value.v_string);
g_free (key);
return G_TOKEN_RIGHT_PAREN;
}

View File

@ -0,0 +1,35 @@
/* PIKA - Photo and Image Kooker Application
* a rebranding of The GNU Image Manipulation Program (created with heckimp)
* A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
*
* Original copyright, applying to most contents (license remains unchanged):
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* PikaRc deserialization routines
* Copyright (C) 2001-2005 Sven Neumann <sven@gimp.org>
*
* 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 <https://www.gnu.org/licenses/>.
*/
#ifndef __PIKA_RC_DESERIALIZE_H__
#define __PIKA_RC_DESERIALIZE_H__
gboolean pika_rc_deserialize (PikaConfig *config,
GScanner *scanner,
gint nest_level,
gpointer data);
#endif /* __PIKA_RC_DESERIALIZE_H__ */

View File

@ -0,0 +1,124 @@
/* PIKA - Photo and Image Kooker Application
* a rebranding of The GNU Image Manipulation Program (created with heckimp)
* A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
*
* Original copyright, applying to most contents (license remains unchanged):
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* PikaRc serialization routines
* Copyright (C) 2001-2005 Sven Neumann <sven@gimp.org>
*
* 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 <https://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <gio/gio.h>
#include <gegl.h>
#include "libpikabase/pikabase.h"
#include "libpikaconfig/pikaconfig.h"
#include "config-types.h"
#include "pikarc.h"
#include "pikarc-serialize.h"
#include "pikarc-unknown.h"
static gboolean pika_rc_serialize_properties_diff (PikaConfig *config,
PikaConfig *compare,
PikaConfigWriter *writer);
static gboolean pika_rc_serialize_unknown_tokens (PikaConfig *config,
PikaConfigWriter *writer);
gboolean
pika_rc_serialize (PikaConfig *config,
PikaConfigWriter *writer,
gpointer data)
{
if (data && PIKA_IS_RC (data))
{
if (! pika_rc_serialize_properties_diff (config, data, writer))
return FALSE;
}
else
{
if (! pika_config_serialize_properties (config, writer))
return FALSE;
}
return pika_rc_serialize_unknown_tokens (config, writer);
}
static gboolean
pika_rc_serialize_properties_diff (PikaConfig *config,
PikaConfig *compare,
PikaConfigWriter *writer)
{
GList *diff;
GList *list;
gboolean retval = TRUE;
g_return_val_if_fail (G_IS_OBJECT (config), FALSE);
g_return_val_if_fail (G_IS_OBJECT (compare), FALSE);
g_return_val_if_fail (G_TYPE_FROM_INSTANCE (config) ==
G_TYPE_FROM_INSTANCE (compare), FALSE);
diff = pika_config_diff (G_OBJECT (config),
G_OBJECT (compare), PIKA_CONFIG_PARAM_SERIALIZE);
for (list = diff; list; list = g_list_next (list))
{
GParamSpec *prop_spec = list->data;
if (! (prop_spec->flags & PIKA_CONFIG_PARAM_SERIALIZE))
continue;
if (! pika_config_serialize_property (config, prop_spec, writer))
{
retval = FALSE;
break;
}
}
g_list_free (diff);
return retval;
}
static void
serialize_unknown_token (const gchar *key,
const gchar *value,
gpointer data)
{
PikaConfigWriter *writer = data;
pika_config_writer_open (writer, key);
pika_config_writer_string (writer, value);
pika_config_writer_close (writer);
}
static gboolean
pika_rc_serialize_unknown_tokens (PikaConfig *config,
PikaConfigWriter *writer)
{
g_return_val_if_fail (G_IS_OBJECT (config), FALSE);
pika_config_writer_linefeed (writer);
pika_rc_foreach_unknown_token (config, serialize_unknown_token, writer);
return TRUE;
}

View File

@ -0,0 +1,34 @@
/* PIKA - Photo and Image Kooker Application
* a rebranding of The GNU Image Manipulation Program (created with heckimp)
* A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
*
* Original copyright, applying to most contents (license remains unchanged):
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* PikaRc serialization routines
* Copyright (C) 2001-2005 Sven Neumann <sven@gimp.org>
*
* 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 <https://www.gnu.org/licenses/>.
*/
#ifndef __PIKA_RC_SERIALIZE_H__
#define __PIKA_RC_SERIALIZE_H__
gboolean pika_rc_serialize (PikaConfig *config,
PikaConfigWriter *writer,
gpointer data);
#endif /* __PIKA_RC_SERIALIZE_H__ */

218
app/config/pikarc-unknown.c Normal file
View File

@ -0,0 +1,218 @@
/* PIKA - Photo and Image Kooker Application
* a rebranding of The GNU Image Manipulation Program (created with heckimp)
* A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
*
* Original copyright, applying to most contents (license remains unchanged):
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* PikaRc serialization and deserialization helpers
* Copyright (C) 2001-2005 Sven Neumann <sven@gimp.org>
*
* 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 <https://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <string.h>
#include <gio/gio.h>
#include "libpikabase/pikabase.h"
#include "libpikaconfig/pikaconfig.h"
#include "config-types.h"
#include "pikarc-unknown.h"
/*
* Code to store and lookup unknown tokens (string key/value pairs).
*/
#define PIKA_RC_UNKNOWN_TOKENS "pika-rc-unknown-tokens"
typedef struct
{
gchar *key;
gchar *value;
} PikaConfigToken;
static void pika_rc_destroy_unknown_tokens (GSList *unknown_tokens);
/**
* pika_rc_add_unknown_token:
* @config: a #GObject.
* @key: a nul-terminated string to identify the value.
* @value: a nul-terminated string representing the value.
*
* This function adds arbitrary key/value pairs to a GObject. It's
* purpose is to attach additional data to a #PikaConfig object that
* can be stored along with the object properties when serializing the
* object to a configuration file. Please note however that the
* default pika_config_serialize() implementation does not serialize
* unknown tokens.
*
* If you want to remove a key/value pair from the object, call this
* function with a %NULL @value.
**/
void
pika_rc_add_unknown_token (PikaConfig *config,
const gchar *key,
const gchar *value)
{
PikaConfigToken *token;
GSList *unknown_tokens;
GSList *last;
GSList *list;
g_return_if_fail (PIKA_IS_CONFIG (config));
g_return_if_fail (key != NULL);
unknown_tokens = (GSList *) g_object_get_data (G_OBJECT (config),
PIKA_RC_UNKNOWN_TOKENS);
for (last = NULL, list = unknown_tokens;
list;
last = list, list = g_slist_next (list))
{
token = (PikaConfigToken *) list->data;
if (strcmp (token->key, key) == 0)
{
g_free (token->value);
if (value)
{
token->value = g_strdup (value);
}
else
{
g_free (token->key);
unknown_tokens = g_slist_remove (unknown_tokens, token);
g_object_set_data_full (G_OBJECT (config),
PIKA_RC_UNKNOWN_TOKENS,
unknown_tokens,
(GDestroyNotify) pika_rc_destroy_unknown_tokens);
}
return;
}
}
if (!value)
return;
token = g_slice_new (PikaConfigToken);
token->key = g_strdup (key);
token->value = g_strdup (value);
if (last)
{
last = g_slist_last (g_slist_append (last, token));
}
else
{
unknown_tokens = g_slist_append (NULL, token);
g_object_set_data_full (G_OBJECT (config),
PIKA_RC_UNKNOWN_TOKENS,
unknown_tokens,
(GDestroyNotify) pika_rc_destroy_unknown_tokens);
}
}
/**
* pika_rc_lookup_unknown_token:
* @config: a #GObject.
* @key: a nul-terminated string to identify the value.
*
* This function retrieves data that was previously attached using
* pika_rc_add_unknown_token(). You should not free or modify
* the returned string.
*
* Returns: a pointer to a constant string.
**/
const gchar *
pika_rc_lookup_unknown_token (PikaConfig *config,
const gchar *key)
{
GSList *unknown_tokens;
GSList *list;
g_return_val_if_fail (PIKA_IS_CONFIG (config), NULL);
g_return_val_if_fail (key != NULL, NULL);
unknown_tokens = g_object_get_data (G_OBJECT (config),
PIKA_RC_UNKNOWN_TOKENS);
for (list = unknown_tokens; list; list = g_slist_next (list))
{
PikaConfigToken *token = list->data;
if (strcmp (token->key, key) == 0)
return token->value;
}
return NULL;
}
/**
* pika_rc_foreach_unknown_token:
* @config: a #GObject.
* @func: a function to call for each key/value pair.
* @user_data: data to pass to @func.
*
* Calls @func for each key/value stored with the @config using
* pika_rc_add_unknown_token().
**/
void
pika_rc_foreach_unknown_token (PikaConfig *config,
PikaConfigForeachFunc func,
gpointer user_data)
{
GSList *unknown_tokens;
GSList *list;
g_return_if_fail (PIKA_IS_CONFIG (config));
g_return_if_fail (func != NULL);
unknown_tokens = g_object_get_data (G_OBJECT (config),
PIKA_RC_UNKNOWN_TOKENS);
for (list = unknown_tokens; list; list = g_slist_next (list))
{
PikaConfigToken *token = list->data;
func (token->key, token->value, user_data);
}
}
static void
pika_rc_destroy_unknown_tokens (GSList *unknown_tokens)
{
GSList *list;
for (list = unknown_tokens; list; list = g_slist_next (list))
{
PikaConfigToken *token = list->data;
g_free (token->key);
g_free (token->value);
g_slice_free (PikaConfigToken, token);
}
g_slist_free (unknown_tokens);
}

View File

@ -0,0 +1,44 @@
/* PIKA - Photo and Image Kooker Application
* a rebranding of The GNU Image Manipulation Program (created with heckimp)
* A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
*
* Original copyright, applying to most contents (license remains unchanged):
* Copyright (C) 1995-1997 Spencer Kimball and Peter Mattis
*
* PikaRc serialization and deserialization helpers
* Copyright (C) 2001-2005 Sven Neumann <sven@gimp.org>
*
* 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 <https://www.gnu.org/licenses/>.
*/
#ifndef __PIKA_RC_UNKNOWN_H__
#define __PIKA_RC_UNKNOWN_H__
typedef void (* PikaConfigForeachFunc) (const gchar *key,
const gchar *value,
gpointer user_data);
void pika_rc_add_unknown_token (PikaConfig *config,
const gchar *key,
const gchar *value);
const gchar * pika_rc_lookup_unknown_token (PikaConfig *config,
const gchar *key);
void pika_rc_foreach_unknown_token (PikaConfig *config,
PikaConfigForeachFunc func,
gpointer user_data);
#endif /* __PIKA_RC_UNKNOWN_H__ */

597
app/config/pikarc.c Normal file
View File

@ -0,0 +1,597 @@
/* PIKA - Photo and Image Kooker Application
* a rebranding of The GNU Image Manipulation Program (created with heckimp)
* A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
*
* Original copyright, applying to most contents (license remains unchanged):
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* PikaRc, the object for PIKAs user configuration file pikarc.
* Copyright (C) 2001-2002 Sven Neumann <sven@gimp.org>
*
* 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 <https://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <string.h>
#include <gio/gio.h>
#include <gegl.h>
#include "libpikabase/pikabase.h"
#include "libpikaconfig/pikaconfig.h"
#include "config-types.h"
#include "pikaconfig-file.h"
#include "pikarc.h"
#include "pikarc-deserialize.h"
#include "pikarc-serialize.h"
#include "pikarc-unknown.h"
#include "pika-intl.h"
enum
{
PROP_0,
PROP_VERBOSE,
PROP_SYSTEM_PIKARC,
PROP_USER_PIKARC
};
static void pika_rc_config_iface_init (PikaConfigInterface *iface);
static void pika_rc_dispose (GObject *object);
static void pika_rc_finalize (GObject *object);
static void pika_rc_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void pika_rc_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static PikaConfig * pika_rc_duplicate (PikaConfig *object);
static gboolean pika_rc_idle_save (PikaRc *rc);
static void pika_rc_notify (PikaRc *rc,
GParamSpec *param,
gpointer data);
G_DEFINE_TYPE_WITH_CODE (PikaRc, pika_rc, PIKA_TYPE_PLUGIN_CONFIG,
G_IMPLEMENT_INTERFACE (PIKA_TYPE_CONFIG,
pika_rc_config_iface_init))
#define parent_class pika_rc_parent_class
static void
pika_rc_class_init (PikaRcClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->dispose = pika_rc_dispose;
object_class->finalize = pika_rc_finalize;
object_class->set_property = pika_rc_set_property;
object_class->get_property = pika_rc_get_property;
g_object_class_install_property (object_class, PROP_VERBOSE,
g_param_spec_boolean ("verbose",
NULL, NULL,
FALSE,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
g_object_class_install_property (object_class, PROP_SYSTEM_PIKARC,
g_param_spec_object ("system-pikarc",
NULL, NULL,
G_TYPE_FILE,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
g_object_class_install_property (object_class, PROP_USER_PIKARC,
g_param_spec_object ("user-pikarc",
NULL, NULL,
G_TYPE_FILE,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
}
static void
pika_rc_init (PikaRc *rc)
{
rc->autosave = FALSE;
rc->save_idle_id = 0;
}
static void
pika_rc_dispose (GObject *object)
{
PikaRc *rc = PIKA_RC (object);
if (rc->save_idle_id)
pika_rc_idle_save (rc);
G_OBJECT_CLASS (parent_class)->dispose (object);
}
static void
pika_rc_finalize (GObject *object)
{
PikaRc *rc = PIKA_RC (object);
g_clear_object (&rc->system_pikarc);
g_clear_object (&rc->user_pikarc);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
pika_rc_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
PikaRc *rc = PIKA_RC (object);
switch (property_id)
{
case PROP_VERBOSE:
rc->verbose = g_value_get_boolean (value);
break;
case PROP_SYSTEM_PIKARC:
if (rc->system_pikarc)
g_object_unref (rc->system_pikarc);
if (g_value_get_object (value))
rc->system_pikarc = g_value_dup_object (value);
else
rc->system_pikarc = pika_sysconf_directory_file ("pikarc", NULL);
break;
case PROP_USER_PIKARC:
if (rc->user_pikarc)
g_object_unref (rc->user_pikarc);
if (g_value_get_object (value))
rc->user_pikarc = g_value_dup_object (value);
else
rc->user_pikarc = pika_directory_file ("pikarc", NULL);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
pika_rc_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
PikaRc *rc = PIKA_RC (object);
switch (property_id)
{
case PROP_VERBOSE:
g_value_set_boolean (value, rc->verbose);
break;
case PROP_SYSTEM_PIKARC:
g_value_set_object (value, rc->system_pikarc);
break;
case PROP_USER_PIKARC:
g_value_set_object (value, rc->user_pikarc);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
pika_rc_config_iface_init (PikaConfigInterface *iface)
{
iface->serialize = pika_rc_serialize;
iface->deserialize = pika_rc_deserialize;
iface->duplicate = pika_rc_duplicate;
}
static void
pika_rc_duplicate_unknown_token (const gchar *key,
const gchar *value,
gpointer user_data)
{
pika_rc_add_unknown_token (PIKA_CONFIG (user_data), key, value);
}
static PikaConfig *
pika_rc_duplicate (PikaConfig *config)
{
GObject *pika;
PikaConfig *dup;
g_object_get (config, "pika", &pika, NULL);
dup = g_object_new (PIKA_TYPE_RC,
"pika", pika,
NULL);
if (pika)
g_object_unref (pika);
pika_config_sync (G_OBJECT (config), G_OBJECT (dup), 0);
pika_rc_foreach_unknown_token (config,
pika_rc_duplicate_unknown_token, dup);
return dup;
}
static gboolean
pika_rc_idle_save (PikaRc *rc)
{
pika_rc_save (rc);
rc->save_idle_id = 0;
return FALSE;
}
static void
pika_rc_notify (PikaRc *rc,
GParamSpec *param,
gpointer data)
{
if (!rc->autosave)
return;
if (!rc->save_idle_id)
rc->save_idle_id = g_idle_add ((GSourceFunc) pika_rc_idle_save, rc);
}
/**
* pika_rc_new:
* @pika: a #Pika
* @system_pikarc: the name of the system-wide pikarc file or %NULL to
* use the standard location
* @user_pikarc: the name of the user pikarc file or %NULL to use the
* standard location
* @verbose: enable console messages about loading and saving
*
* Creates a new PikaRc object and loads the system-wide and the user
* configuration files.
*
* Returns: the new #PikaRc.
*/
PikaRc *
pika_rc_new (GObject *pika,
GFile *system_pikarc,
GFile *user_pikarc,
gboolean verbose)
{
PikaRc *rc;
g_return_val_if_fail (G_IS_OBJECT (pika), NULL);
g_return_val_if_fail (system_pikarc == NULL || G_IS_FILE (system_pikarc),
NULL);
g_return_val_if_fail (user_pikarc == NULL || G_IS_FILE (user_pikarc),
NULL);
rc = g_object_new (PIKA_TYPE_RC,
"pika", pika,
"verbose", verbose,
"system-pikarc", system_pikarc,
"user-pikarc", user_pikarc,
NULL);
pika_rc_load_system (rc);
pika_rc_load_user (rc);
return rc;
}
void
pika_rc_load_system (PikaRc *rc)
{
GError *error = NULL;
g_return_if_fail (PIKA_IS_RC (rc));
if (rc->verbose)
g_print ("Parsing '%s'\n",
pika_file_get_utf8_name (rc->system_pikarc));
if (! pika_config_deserialize_file (PIKA_CONFIG (rc),
rc->system_pikarc, NULL, &error))
{
if (error->code != PIKA_CONFIG_ERROR_OPEN_ENOENT)
g_message ("%s", error->message);
g_clear_error (&error);
}
}
void
pika_rc_load_user (PikaRc *rc)
{
GError *error = NULL;
g_return_if_fail (PIKA_IS_RC (rc));
if (rc->verbose)
g_print ("Parsing '%s'\n",
pika_file_get_utf8_name (rc->user_pikarc));
if (! pika_config_deserialize_file (PIKA_CONFIG (rc),
rc->user_pikarc, NULL, &error))
{
if (error->code != PIKA_CONFIG_ERROR_OPEN_ENOENT)
{
g_message ("%s", error->message);
pika_config_file_backup_on_error (rc->user_pikarc, "pikarc", NULL);
}
g_clear_error (&error);
}
}
void
pika_rc_set_autosave (PikaRc *rc,
gboolean autosave)
{
g_return_if_fail (PIKA_IS_RC (rc));
autosave = autosave ? TRUE : FALSE;
if (rc->autosave == autosave)
return;
if (autosave)
g_signal_connect (rc, "notify",
G_CALLBACK (pika_rc_notify),
NULL);
else
g_signal_handlers_disconnect_by_func (rc, pika_rc_notify, NULL);
rc->autosave = autosave;
}
/**
* pika_rc_query:
* @rc: a #PikaRc object.
* @key: a string used as a key for the lookup.
*
* This function looks up @key in the object properties of @rc. If
* there's a matching property, a string representation of its value
* is returned. If no property is found, the list of unknown tokens
* attached to the @rc object is searched.
*
* Returns: (nullable): a newly allocated string representing the value or %NULL
* if the key couldn't be found.
**/
gchar *
pika_rc_query (PikaRc *rc,
const gchar *key)
{
GObjectClass *klass;
GObject *rc_object;
GParamSpec **property_specs;
GParamSpec *prop_spec;
guint i, n_property_specs;
gchar *retval = NULL;
g_return_val_if_fail (PIKA_IS_RC (rc), NULL);
g_return_val_if_fail (key != NULL, NULL);
rc_object = G_OBJECT (rc);
klass = G_OBJECT_GET_CLASS (rc);
property_specs = g_object_class_list_properties (klass, &n_property_specs);
if (!property_specs)
return NULL;
for (i = 0, prop_spec = NULL; i < n_property_specs && !prop_spec; i++)
{
prop_spec = property_specs[i];
if (! (prop_spec->flags & PIKA_CONFIG_PARAM_SERIALIZE) ||
strcmp (prop_spec->name, key))
{
prop_spec = NULL;
}
}
if (prop_spec)
{
GString *str = g_string_new (NULL);
GValue value = G_VALUE_INIT;
g_value_init (&value, prop_spec->value_type);
g_object_get_property (rc_object, prop_spec->name, &value);
if (pika_config_serialize_value (&value, str, FALSE))
retval = g_string_free (str, FALSE);
else
g_string_free (str, TRUE);
g_value_unset (&value);
}
else
{
retval = g_strdup (pika_rc_lookup_unknown_token (PIKA_CONFIG (rc), key));
}
g_free (property_specs);
if (!retval)
{
const gchar * const path_tokens[] =
{
"pika_dir",
"pika_data_dir",
"pika_plug_in_dir",
"pika_plugin_dir",
"pika_sysconf_dir"
};
for (i = 0; !retval && i < G_N_ELEMENTS (path_tokens); i++)
if (strcmp (key, path_tokens[i]) == 0)
retval = g_strdup_printf ("${%s}", path_tokens[i]);
}
if (retval)
{
gchar *tmp = pika_config_path_expand (retval, FALSE, NULL);
if (tmp)
{
g_free (retval);
retval = tmp;
}
}
return retval;
}
/**
* pika_rc_set_unknown_token:
* @pikarc: a #PikaRc object.
* @token:
* @value:
*
* Calls pika_rc_add_unknown_token() and triggers an idle-save if
* autosave is enabled on @pikarc.
**/
void
pika_rc_set_unknown_token (PikaRc *rc,
const gchar *token,
const gchar *value)
{
g_return_if_fail (PIKA_IS_RC (rc));
pika_rc_add_unknown_token (PIKA_CONFIG (rc), token, value);
if (rc->autosave)
pika_rc_notify (rc, NULL, NULL);
}
/**
* pika_rc_save:
* @pikarc: a #PikaRc object.
*
* Saves any settings that differ from the system-wide defined
* defaults to the users personal pikarc file.
**/
void
pika_rc_save (PikaRc *rc)
{
GObject *pika;
PikaRc *global;
gchar *header;
GError *error = NULL;
const gchar *top =
"PIKA pikarc\n"
"\n"
"This is your personal pikarc file. Any variable defined in this file "
"takes precedence over the value defined in the system-wide pikarc: ";
const gchar *bottom =
"\n"
"Most values can be set within PIKA by changing some options in "
"the Preferences dialog.";
const gchar *footer =
"end of pikarc";
g_return_if_fail (PIKA_IS_RC (rc));
g_object_get (rc, "pika", &pika, NULL);
global = g_object_new (PIKA_TYPE_RC,
"pika", pika,
NULL);
if (pika)
g_object_unref (pika);
pika_config_deserialize_file (PIKA_CONFIG (global),
rc->system_pikarc, NULL, NULL);
header = g_strconcat (top, pika_file_get_utf8_name (rc->system_pikarc),
bottom, NULL);
if (rc->verbose)
g_print ("Writing '%s'\n",
pika_file_get_utf8_name (rc->user_pikarc));
if (! pika_config_serialize_to_file (PIKA_CONFIG (rc),
rc->user_pikarc,
header, footer, global,
&error))
{
g_message ("%s", error->message);
g_error_free (error);
}
g_free (header);
g_object_unref (global);
}
/**
* pika_rc_migrate:
* @rc: a #PikaRc object.
*
* Resets all PikaParamConfigPath properties of the passed rc object
* to their default values, in order to prevent paths in a migrated
* pikarc to refer to folders in the old PIKA's user directory.
**/
void
pika_rc_migrate (PikaRc *rc)
{
GParamSpec **pspecs;
guint n_pspecs;
gint i;
g_return_if_fail (PIKA_IS_RC (rc));
pspecs = g_object_class_list_properties (G_OBJECT_GET_CLASS (rc), &n_pspecs);
for (i = 0; i < n_pspecs; i++)
{
GParamSpec *pspec = pspecs[i];
if (PIKA_IS_PARAM_SPEC_CONFIG_PATH (pspec))
{
GValue value = G_VALUE_INIT;
g_value_init (&value, pspec->value_type);
g_param_value_set_default (pspec, &value);
g_object_set_property (G_OBJECT (rc), pspec->name, &value);
g_value_unset (&value);
}
}
g_free (pspecs);
}

81
app/config/pikarc.h Normal file
View File

@ -0,0 +1,81 @@
/* PIKA - Photo and Image Kooker Application
* a rebranding of The GNU Image Manipulation Program (created with heckimp)
* A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
*
* Original copyright, applying to most contents (license remains unchanged):
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* PikaRc
* Copyright (C) 2001 Sven Neumann <sven@gimp.org>
*
* 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 <https://www.gnu.org/licenses/>.
*/
#ifndef __PIKA_RC_H__
#define __PIKA_RC_H__
#include "config/pikapluginconfig.h"
#define PIKA_TYPE_RC (pika_rc_get_type ())
#define PIKA_RC(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PIKA_TYPE_RC, PikaRc))
#define PIKA_RC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PIKA_TYPE_RC, PikaRcClass))
#define PIKA_IS_RC(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PIKA_TYPE_RC))
#define PIKA_IS_RC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PIKA_TYPE_RC))
typedef struct _PikaRcClass PikaRcClass;
struct _PikaRc
{
PikaPluginConfig parent_instance;
GFile *user_pikarc;
GFile *system_pikarc;
gboolean verbose;
gboolean autosave;
guint save_idle_id;
};
struct _PikaRcClass
{
PikaPluginConfigClass parent_class;
};
GType pika_rc_get_type (void) G_GNUC_CONST;
PikaRc * pika_rc_new (GObject *pika,
GFile *system_pikarc,
GFile *user_pikarc,
gboolean verbose);
void pika_rc_load_system (PikaRc *rc);
void pika_rc_load_user (PikaRc *rc);
void pika_rc_set_autosave (PikaRc *rc,
gboolean autosave);
void pika_rc_save (PikaRc *rc);
gchar * pika_rc_query (PikaRc *rc,
const gchar *key);
void pika_rc_set_unknown_token (PikaRc *rc,
const gchar *token,
const gchar *value);
void pika_rc_migrate (PikaRc *rc);
#endif /* PIKA_RC_H__ */

408
app/config/pikaxmlparser.c Normal file
View File

@ -0,0 +1,408 @@
/* PIKA - Photo and Image Kooker Application
* a rebranding of The GNU Image Manipulation Program (created with heckimp)
* A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
*
* Original copyright, applying to most contents (license remains unchanged):
* Copyright (C) 1995-1997 Spencer Kimball and Peter Mattis
*
* PikaXmlParser
* Copyright (C) 2003 Sven Neumann <sven@gimp.org>
*
* 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 <https://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <string.h>
#include <gio/gio.h>
#include "config-types.h"
#include "pikaxmlparser.h"
struct _PikaXmlParser
{
GMarkupParseContext *context;
};
static gboolean parse_encoding (const gchar *text,
gint text_len,
gchar **encodind);
/**
* pika_xml_parser_new:
* @markup_parser: a #GMarkupParser
* @user_data: user data to pass to #GMarkupParser functions
*
* PikaXmlParser is a thin wrapper around GMarkupParser. This function
* creates one for you and sets up a GMarkupParseContext.
*
* Returns: a new #PikaXmlParser
**/
PikaXmlParser *
pika_xml_parser_new (const GMarkupParser *markup_parser,
gpointer user_data)
{
PikaXmlParser *parser;
g_return_val_if_fail (markup_parser != NULL, NULL);
parser = g_slice_new (PikaXmlParser);
parser->context = g_markup_parse_context_new (markup_parser,
0, user_data, NULL);
return parser;
}
/**
* pika_xml_parser_parse_file:
* @parser: a #PikaXmlParser
* @filename: name of a file to parse
* @error: return location for possible errors
*
* This function creates a GIOChannel for @filename and calls
* pika_xml_parser_parse_io_channel() for you.
*
* Returns: %TRUE on success, %FALSE otherwise
**/
gboolean
pika_xml_parser_parse_file (PikaXmlParser *parser,
const gchar *filename,
GError **error)
{
GIOChannel *io;
gboolean success;
g_return_val_if_fail (parser != NULL, FALSE);
g_return_val_if_fail (filename != NULL, FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
io = g_io_channel_new_file (filename, "r", error);
if (!io)
return FALSE;
success = pika_xml_parser_parse_io_channel (parser, io, error);
g_io_channel_unref (io);
return success;
}
/**
* pika_xml_parser_parse_gfile:
* @parser: a #PikaXmlParser
* @file: the #GFile to parse
* @error: return location for possible errors
*
* This function creates a GIOChannel for @file and calls
* pika_xml_parser_parse_io_channel() for you.
*
* Returns: %TRUE on success, %FALSE otherwise
**/
gboolean
pika_xml_parser_parse_gfile (PikaXmlParser *parser,
GFile *file,
GError **error)
{
gchar *path;
gboolean success;
g_return_val_if_fail (parser != NULL, FALSE);
g_return_val_if_fail (G_IS_FILE (file), FALSE);
path = g_file_get_path (file);
success = pika_xml_parser_parse_file (parser, path, error);
g_free (path);
return success;
}
/**
* pika_xml_parser_parse_fd:
* @parser: a #PikaXmlParser
* @fd: a file descriptor
* @error: return location for possible errors
*
* This function creates a GIOChannel for @fd and calls
* pika_xml_parser_parse_io_channel() for you.
*
* Returns: %TRUE on success, %FALSE otherwise
**/
gboolean
pika_xml_parser_parse_fd (PikaXmlParser *parser,
gint fd,
GError **error)
{
GIOChannel *io;
gboolean success;
g_return_val_if_fail (parser != NULL, FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
#ifdef G_OS_WIN32
io = g_io_channel_win32_new_fd (fd);
#else
io = g_io_channel_unix_new (fd);
#endif
success = pika_xml_parser_parse_io_channel (parser, io, error);
g_io_channel_unref (io);
return success;
}
/**
* pika_xml_parser_parse_io_channel:
* @parser: a #PikaXmlParser
* @io: a #GIOChannel
* @error: return location for possible errors
*
* Makes @parser read from the specified @io channel. This function
* returns when the GIOChannel becomes empty (end of file) or an
* error occurs, either reading from @io or parsing the read data.
*
* This function tries to determine the character encoding from the
* XML header and converts the content to UTF-8 for you. For this
* feature to work, the XML header with the encoding attribute must be
* contained in the first 4096 bytes read. Otherwise UTF-8 encoding
* will be assumed and parsing may break later if this assumption
* was wrong.
*
* Returns: %TRUE on success, %FALSE otherwise
**/
gboolean
pika_xml_parser_parse_io_channel (PikaXmlParser *parser,
GIOChannel *io,
GError **error)
{
GIOStatus status;
gchar buffer[4096];
gsize len = 0;
gsize bytes;
const gchar *io_encoding;
gchar *encoding = NULL;
g_return_val_if_fail (parser != NULL, FALSE);
g_return_val_if_fail (io != NULL, FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
io_encoding = g_io_channel_get_encoding (io);
if (g_strcmp0 (io_encoding, "UTF-8"))
{
g_warning ("pika_xml_parser_parse_io_channel():\n"
"The encoding has already been set on this GIOChannel!");
return FALSE;
}
/* try to determine the encoding */
g_io_channel_set_encoding (io, NULL, NULL);
while (len < sizeof (buffer))
{
status = g_io_channel_read_chars (io, buffer + len, 1, &bytes, error);
len += bytes;
if (status == G_IO_STATUS_ERROR)
return FALSE;
if (status == G_IO_STATUS_EOF)
break;
if (parse_encoding (buffer, len, &encoding))
break;
}
if (encoding)
{
if (! g_io_channel_set_encoding (io, encoding, error))
return FALSE;
g_free (encoding);
}
else
{
g_io_channel_set_encoding (io, "UTF-8", NULL);
}
while (TRUE)
{
if (!g_markup_parse_context_parse (parser->context, buffer, len, error))
return FALSE;
status = g_io_channel_read_chars (io,
buffer, sizeof (buffer), &len, error);
switch (status)
{
case G_IO_STATUS_ERROR:
return FALSE;
case G_IO_STATUS_EOF:
return g_markup_parse_context_end_parse (parser->context, error);
case G_IO_STATUS_NORMAL:
case G_IO_STATUS_AGAIN:
break;
}
}
}
/**
* pika_xml_parser_parse_buffer:
* @parser: a #PikaXmlParser
* @buffer: a string buffer
* @len: the number of byes in @buffer or -1 if @buffer is nul-terminated
* @error: return location for possible errors
*
* This function uses the given @parser to parse the XML in @buffer.
*
* Returns: %TRUE on success, %FALSE otherwise
**/
gboolean
pika_xml_parser_parse_buffer (PikaXmlParser *parser,
const gchar *buffer,
gssize len,
GError **error)
{
gchar *encoding = NULL;
gchar *conv = NULL;
gboolean success;
g_return_val_if_fail (parser != NULL, FALSE);
g_return_val_if_fail (buffer != NULL || len == 0, FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
if (len < 0)
len = strlen (buffer);
if (parse_encoding (buffer, len, &encoding) && encoding)
{
if (g_ascii_strcasecmp (encoding, "UTF-8") &&
g_ascii_strcasecmp (encoding, "UTF8"))
{
gsize written;
conv = g_convert (buffer, len,
"UTF-8", encoding, NULL, &written, error);
if (! conv)
{
g_free (encoding);
return FALSE;
}
len = written;
}
g_free (encoding);
}
success = g_markup_parse_context_parse (parser->context,
conv ? conv : buffer, len, error);
if (conv)
g_free (conv);
return success;
}
/**
* pika_xml_parser_free:
* @parser: a #PikaXmlParser
*
* Frees the resources allocated for @parser. You must not access
* @parser after calling this function.
**/
void
pika_xml_parser_free (PikaXmlParser *parser)
{
g_return_if_fail (parser != NULL);
g_markup_parse_context_free (parser->context);
g_slice_free (PikaXmlParser, parser);
}
/* Try to determine encoding from XML header. This function returns
FALSE when it doesn't have enough text to parse. It returns TRUE
and sets encoding when the XML header has been parsed.
*/
static gboolean
parse_encoding (const gchar *text,
gint text_len,
gchar **encoding)
{
const gchar *start;
const gchar *end;
gint i;
g_return_val_if_fail (text, FALSE);
if (text_len < 20)
return FALSE;
start = g_strstr_len (text, text_len, "<?xml");
if (!start)
return FALSE;
end = g_strstr_len (start, text_len - (start - text), "?>");
if (!end)
return FALSE;
*encoding = NULL;
text_len = end - start;
if (text_len < 12)
return TRUE;
start = g_strstr_len (start + 1, text_len - 1, "encoding");
if (!start)
return TRUE;
start += 8;
while (start < end && *start == ' ')
start++;
if (*start != '=')
return TRUE;
start++;
while (start < end && *start == ' ')
start++;
if (*start != '\"' && *start != '\'')
return TRUE;
text_len = end - start;
if (text_len < 1)
return TRUE;
for (i = 1; i < text_len; i++)
if (start[i] == start[0])
break;
if (i == text_len || i < 3)
return TRUE;
*encoding = g_strndup (start + 1, i - 1);
return TRUE;
}

View File

@ -0,0 +1,50 @@
/* PIKA - Photo and Image Kooker Application
* a rebranding of The GNU Image Manipulation Program (created with heckimp)
* A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
*
* Original copyright, applying to most contents (license remains unchanged):
* Copyright (C) 1995-1997 Spencer Kimball and Peter Mattis
*
* PikaXmlParser
* Copyright (C) 2003 Sven Neumann <sven@gimp.org>
*
* 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 <https://www.gnu.org/licenses/>.
*/
#ifndef __PIKA_XML_PARSER_H__
#define __PIKA_XML_PARSER_H__
PikaXmlParser * pika_xml_parser_new (const GMarkupParser *markup_parser,
gpointer user_data);
gboolean pika_xml_parser_parse_file (PikaXmlParser *parser,
const gchar *filename,
GError **error);
gboolean pika_xml_parser_parse_gfile (PikaXmlParser *parser,
GFile *file,
GError **error);
gboolean pika_xml_parser_parse_fd (PikaXmlParser *parser,
gint fd,
GError **error);
gboolean pika_xml_parser_parse_io_channel (PikaXmlParser *parser,
GIOChannel *io,
GError **error);
gboolean pika_xml_parser_parse_buffer (PikaXmlParser *parser,
const gchar *buffer,
gssize len,
GError **error);
void pika_xml_parser_free (PikaXmlParser *parser);
#endif /* __PIKA_XML_PARSER_H__ */

288
app/config/test-config.c Normal file
View File

@ -0,0 +1,288 @@
/* PIKA - Photo and Image Kooker Application
* a rebranding of The GNU Image Manipulation Program (created with heckimp)
* A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
*
* Original copyright, applying to most contents (license remains unchanged):
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* Test suite for PikaConfig.
* Copyright (C) 2001-2002 Sven Neumann <sven@gimp.org>
*
* 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 <https://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "stdlib.h"
#include "string.h"
#include <gio/gio.h>
#include "libpikabase/pikabase.h"
#include "libpikabase/pikabase-private.h"
#include "libpikaconfig/pikaconfig.h"
#include "core/core-types.h"
#include "core/pikagrid.h"
#include "pikarc-unknown.h"
static void notify_callback (GObject *object,
GParamSpec *pspec);
static void output_unknown_token (const gchar *key,
const gchar *value,
gpointer data);
static void units_init (void);
int
main (int argc,
char *argv[])
{
PikaConfig *grid;
PikaConfig *grid2;
GFile *file = g_file_new_for_path ("foorc");
gchar *header;
gchar *result;
GList *list;
gint i;
GError *error = NULL;
for (i = 1; i < argc; i++)
{
if (strcmp (argv[i], "--g-fatal-warnings") == 0)
{
GLogLevelFlags fatal_mask;
fatal_mask = g_log_set_always_fatal (G_LOG_FATAL_MASK);
fatal_mask |= G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL;
g_log_set_always_fatal (fatal_mask);
}
}
units_init ();
g_print ("\nTesting PikaConfig ...\n");
g_print (" Creating a new Grid object ...");
grid = g_object_new (PIKA_TYPE_GRID, NULL);
g_print (" done.\n");
g_print (" Adding the unknown token (foobar \"hadjaha\") ...");
pika_rc_add_unknown_token (grid, "foobar", "hadjaha");
g_print (" done.\n");
g_print (" Serializing %s to '%s' ...",
g_type_name (G_TYPE_FROM_INSTANCE (grid)),
pika_file_get_utf8_name (file));
if (! pika_config_serialize_to_file (grid,
file,
"foorc", "end of foorc",
NULL, &error))
{
g_print ("%s\n", error->message);
return EXIT_FAILURE;
}
g_print (" done.\n");
g_signal_connect (grid, "notify",
G_CALLBACK (notify_callback),
NULL);
g_print (" Deserializing from '%s' ...\n",
pika_file_get_utf8_name (file));
if (! pika_config_deserialize_file (grid, file, NULL, &error))
{
g_print ("%s\n", error->message);
return EXIT_FAILURE;
}
header = " Unknown string tokens:\n";
pika_rc_foreach_unknown_token (grid, output_unknown_token, &header);
g_print (" done.\n\n");
g_print (" Changing a property ...");
g_object_set (grid, "style", PIKA_GRID_DOTS, NULL);
g_print (" Testing pika_config_duplicate() ...");
grid2 = pika_config_duplicate (grid);
g_print (" done.\n");
g_signal_connect (grid2, "notify",
G_CALLBACK (notify_callback),
NULL);
g_print (" Changing a property in the duplicate ...");
g_object_set (grid2, "xspacing", 20.0, NULL);
g_print (" Creating a diff between the two ...");
for (list = pika_config_diff (G_OBJECT (grid), G_OBJECT (grid2), 0);
list;
list = list->next)
{
GParamSpec *pspec = list->data;
g_print ("%c%s", (list->prev ? ',' : ' '), pspec->name);
}
g_print ("\n\n");
g_object_unref (grid2);
g_print (" Deserializing from pikaconfig.c (should fail) ...");
if (! pika_config_deserialize_file (grid,
g_file_new_for_path ("pikaconfig.c"),
NULL, &error))
{
g_print (" OK, failed. The error was:\n %s\n", error->message);
g_error_free (error);
error = NULL;
}
else
{
g_print ("This test should have failed :-(\n");
return EXIT_FAILURE;
}
g_print (" Serializing to a string and back ... ");
result = pika_config_serialize_to_string (grid, NULL);
grid2 = g_object_new (PIKA_TYPE_GRID, NULL);
if (! pika_config_deserialize_string (grid2, result, -1, NULL, &error))
{
g_print ("failed!\nThe error was:\n %s\n", error->message);
g_error_free (error);
return EXIT_FAILURE;
}
else
{
GList *diff = pika_config_diff (G_OBJECT (grid), G_OBJECT (grid2), 0);
if (diff)
{
GList *list;
g_print ("succeeded but properties differ:\n");
for (list = diff; list; list = list->next)
{
GParamSpec *pspec = list->data;
g_print (" %s\n", pspec->name);
}
return EXIT_FAILURE;
}
g_print ("OK (%u bytes)\n", result ? (guint) strlen (result) : 0);
}
g_free (result);
g_object_unref (grid2);
g_object_unref (grid);
g_print ("\nFinished test of PikaConfig.\n\n");
return EXIT_SUCCESS;
}
static void
notify_callback (GObject *object,
GParamSpec *pspec)
{
GString *str;
GValue value = G_VALUE_INIT;
g_return_if_fail (G_IS_OBJECT (object));
g_return_if_fail (G_IS_PARAM_SPEC (pspec));
g_value_init (&value, pspec->value_type);
g_object_get_property (object, pspec->name, &value);
str = g_string_new (NULL);
if (pika_config_serialize_value (&value, str, TRUE))
{
g_print (" %s -> %s\n", pspec->name, str->str);
}
else
{
g_print (" %s changed but we failed to serialize its value!\n",
pspec->name);
}
g_string_free (str, TRUE);
g_value_unset (&value);
}
static void
output_unknown_token (const gchar *key,
const gchar *value,
gpointer data)
{
gchar **header = (gchar **) data;
gchar *escaped = g_strescape (value, NULL);
if (*header)
{
g_print ("%s", *header);
*header = NULL;
}
g_print (" %s \"%s\"\n", key, escaped);
g_free (escaped);
}
/* minimal dummy units implementation */
static const gchar *
unit_get_identifier (PikaUnit unit)
{
switch (unit)
{
case PIKA_UNIT_PIXEL:
return "pixels";
case PIKA_UNIT_INCH:
return "inches";
case PIKA_UNIT_MM:
return "millimeters";
case PIKA_UNIT_POINT:
return "points";
case PIKA_UNIT_PICA:
return "picas";
default:
return NULL;
}
}
static gint
unit_get_number_of_units (void)
{
return PIKA_UNIT_END;
}
static void
units_init (void)
{
PikaUnitVtable vtable;
vtable.unit_get_number_of_units = unit_get_number_of_units;
vtable.unit_get_identifier = unit_get_identifier;
pika_base_init (&vtable);
}