Commit a30b11c9 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann
Browse files

don't serialize unknown tokens; leave that to the gimprc implementation.

2001-12-17  Sven Neumann  <sven@gimp.org>

	* gimpconfig.[ch]: don't serialize unknown tokens; leave that to
	the gimprc implementation. Create file with correct permissions.

	* test-config.c: changed accordingly.

	* gimpguiconfig.[ch]: added more properties.
parent 8ba4e0c0
2001-12-17 Sven Neumann <sven@gimp.org>
* gimpconfig.[ch]: don't serialize unknown tokens; leave that to
the gimprc implementation. Create file with correct permissions.
* test-config.c: changed accordingly.
* gimpguiconfig.[ch]: added more properties.
2001-12-16 Sven Neumann <sven@gimp.org>
* app/config/Makefile.am
......
......@@ -25,6 +25,7 @@
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <glib-object.h>
......@@ -43,8 +44,7 @@
static void gimp_config_iface_init (GimpConfigInterface *gimp_config_iface);
static void gimp_config_iface_serialize (GObject *object,
gint fd,
gboolean put_unknown);
gint fd);
static gboolean gimp_config_iface_deserialize (GObject *object,
GScanner *scanner,
gboolean store_unknown);
......@@ -84,13 +84,9 @@ gimp_config_iface_init (GimpConfigInterface *gimp_config_iface)
}
static void
gimp_config_iface_serialize (GObject *object,
gint fd,
gboolean put_unknown)
gimp_config_iface_serialize (GObject *object,
gint fd)
{
if (put_unknown)
gimp_config_serialize_unknown_tokens (object, fd);
gimp_config_serialize_properties (object, fd);
}
......@@ -106,8 +102,7 @@ gimp_config_iface_deserialize (GObject *object,
gboolean
gimp_config_serialize (GObject *object,
const gchar *filename,
gboolean put_unknown)
const gchar *filename)
{
GimpConfigInterface *gimp_config_iface;
gint fd;
......@@ -119,7 +114,8 @@ gimp_config_serialize (GObject *object,
g_return_val_if_fail (gimp_config_iface != NULL, FALSE);
fd = open (filename, O_WRONLY | O_CREAT);
fd = open (filename, O_WRONLY | O_CREAT,
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
if (fd == -1)
{
......@@ -128,7 +124,7 @@ gimp_config_serialize (GObject *object,
return FALSE;
}
gimp_config_iface->serialize (object, fd, put_unknown);
gimp_config_iface->serialize (object, fd);
close (fd);
......@@ -291,7 +287,6 @@ gimp_config_foreach_unknown_token (GObject *object,
}
}
static void
gimp_config_destroy_unknown_tokens (GSList *unknown_tokens)
{
......
......@@ -33,8 +33,7 @@ struct _GimpConfigInterface
GTypeInterface base_iface;
void (* serialize) (GObject *object,
gint fd,
gboolean put_unknown);
gint fd);
gboolean (* deserialize) (GObject *object,
GScanner *scanner,
gboolean store_unknown);
......@@ -48,8 +47,7 @@ typedef void (*GimpConfigForeachFunc) (const gchar *key,
GType gimp_config_interface_get_type (void) G_GNUC_CONST;
gboolean gimp_config_serialize (GObject *object,
const gchar *filename,
gboolean put_unknown);
const gchar *filename);
gboolean gimp_config_deserialize (GObject *object,
const gchar *filename,
gboolean store_unknown);
......
......@@ -35,6 +35,11 @@
#include "gimpguiconfig.h"
#define BUILD_DATA_PATH(name)\
("${gimp_dir}" G_DIR_SEPARATOR_S name G_SEARCHPATH_SEPARATOR_S \
"${gimp_datadir}" G_DIR_SEPARATOR_S name)
static void gimp_gui_config_class_init (GimpGuiConfigClass *klass);
static void gimp_gui_config_set_property (GObject *object,
guint property_id,
......@@ -66,7 +71,23 @@ enum
PROP_SHOW_RULERS,
PROP_SHOW_STATUSBAR,
PROP_SHOW_TOOL_TIPS,
PROP_GLOBAL_PAINT_OPTIONS
PROP_GLOBAL_PAINT_OPTIONS,
PROP_CONFIRM_ON_CLOSE,
PROP_TRUST_DIRTY_FLAG,
PROP_DEFAULT_DOT_FOR_DOT,
PROP_NAV_WINDOW_PER_DISPLAY,
PROP_INFO_WINDOW_PER_DISPLAY,
PROP_SAVE_DEVICE_STATUS,
PROP_SAVE_SESSION_INFO,
PROP_RESTORE_SESSION,
PROP_SHOW_TIPS,
PROP_TEAROFF_MENUS,
PROP_MONITOR_XRESOLUTION,
PROP_MONITOR_YRESOLUTION,
PROP_MONITOR_RES_FROM_GDK,
PROP_MAX_NEW_IMAGE_SIZE,
PROP_THEME_PATH,
PROP_THEME
};
......@@ -148,7 +169,7 @@ gimp_gui_config_class_init (GimpGuiConfigClass *klass)
"preview-size",
GIMP_TYPE_PREVIEW_SIZE, GIMP_PREVIEW_SIZE_SMALL);
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_NAV_PREVIEW_SIZE,
"nav-preview-size",
"navigation-preview-size",
GIMP_TYPE_PREVIEW_SIZE, GIMP_PREVIEW_SIZE_HUGE);
GIMP_CONFIG_INSTALL_PROP_STRING (object_class, PROP_IMAGE_TITLE_FORMAT,
"image-title-format",
......@@ -165,6 +186,54 @@ gimp_gui_config_class_init (GimpGuiConfigClass *klass)
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_GLOBAL_PAINT_OPTIONS,
"global-paint-options",
FALSE);
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_CONFIRM_ON_CLOSE,
"confirm-on-close",
TRUE);
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_TRUST_DIRTY_FLAG,
"trust-dirty-flag",
FALSE);
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_DEFAULT_DOT_FOR_DOT,
"default-dot-for-dot",
TRUE);
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_NAV_WINDOW_PER_DISPLAY,
"navigation-window-per-display",
FALSE);
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_INFO_WINDOW_PER_DISPLAY,
"info-window-per-display",
FALSE);
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_SAVE_DEVICE_STATUS,
"save-device-status",
FALSE);
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_SAVE_SESSION_INFO,
"save-session-info",
TRUE);
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_RESTORE_SESSION,
"restore-session",
TRUE);
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_SHOW_TIPS,
"show-tips",
TRUE);
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_TEAROFF_MENUS,
"tearoff-menus",
TRUE);
GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_MONITOR_XRESOLUTION,
"monitor-xresolution",
GIMP_MIN_RESOLUTION, G_MAXDOUBLE, 72.0);
GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_MONITOR_YRESOLUTION,
"monitor-yresolution",
GIMP_MIN_RESOLUTION, G_MAXDOUBLE, 72.0);
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_MONITOR_RES_FROM_GDK,
"monitor-resolution-from-windowing-system",
TRUE);
GIMP_CONFIG_INSTALL_PROP_MEMSIZE (object_class, PROP_MAX_NEW_IMAGE_SIZE,
"max-new-image-size",
0, G_MAXUINT, 1 << 25);
GIMP_CONFIG_INSTALL_PROP_PATH (object_class, PROP_THEME_PATH,
"theme-path",
BUILD_DATA_PATH ("themes"));
GIMP_CONFIG_INSTALL_PROP_STRING (object_class, PROP_THEME,
"theme",
NULL);
}
static void
......@@ -237,6 +306,56 @@ gimp_gui_config_set_property (GObject *object,
case PROP_GLOBAL_PAINT_OPTIONS:
gui_config->global_paint_options = g_value_get_boolean (value);
break;
case PROP_CONFIRM_ON_CLOSE:
gui_config->confirm_on_close = g_value_get_boolean (value);
break;
case PROP_TRUST_DIRTY_FLAG:
gui_config->trust_dirty_flag = g_value_get_boolean (value);
break;
case PROP_DEFAULT_DOT_FOR_DOT:
gui_config->default_dot_for_dot = g_value_get_boolean (value);
break;
case PROP_NAV_WINDOW_PER_DISPLAY:
gui_config->nav_window_per_display = g_value_get_boolean (value);
break;
case PROP_INFO_WINDOW_PER_DISPLAY:
gui_config->info_window_per_display = g_value_get_boolean (value);
break;
case PROP_SAVE_DEVICE_STATUS:
gui_config->save_device_status = 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_SHOW_TIPS:
gui_config->show_tips = g_value_get_boolean (value);
break;
case PROP_TEAROFF_MENUS:
gui_config->tearoff_menus = g_value_get_boolean (value);
break;
case PROP_MONITOR_XRESOLUTION:
gui_config->monitor_xres = g_value_get_double (value);
break;
case PROP_MONITOR_YRESOLUTION:
gui_config->monitor_yres = g_value_get_double (value);
break;
case PROP_MONITOR_RES_FROM_GDK:
gui_config->monitor_res_from_gdk = g_value_get_boolean (value);
break;
case PROP_MAX_NEW_IMAGE_SIZE:
gui_config->max_new_image_size = g_value_get_uint (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;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
......@@ -313,6 +432,54 @@ gimp_gui_config_get_property (GObject *object,
case PROP_GLOBAL_PAINT_OPTIONS:
g_value_set_boolean (value, gui_config->global_paint_options);
break;
case PROP_CONFIRM_ON_CLOSE:
g_value_set_boolean (value, gui_config->confirm_on_close);
break;
case PROP_TRUST_DIRTY_FLAG:
g_value_set_boolean (value, gui_config->trust_dirty_flag);
break;
case PROP_DEFAULT_DOT_FOR_DOT:
g_value_set_boolean (value, gui_config->default_dot_for_dot);
break;
case PROP_NAV_WINDOW_PER_DISPLAY:
g_value_set_boolean (value, gui_config->nav_window_per_display);
break;
case PROP_INFO_WINDOW_PER_DISPLAY:
g_value_set_boolean (value, gui_config->info_window_per_display);
break;
case PROP_SAVE_DEVICE_STATUS:
g_value_set_boolean (value, gui_config->save_device_status);
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_SHOW_TIPS:
g_value_set_boolean (value, gui_config->show_tips);
break;
case PROP_TEAROFF_MENUS:
g_value_set_boolean (value, gui_config->tearoff_menus);
break;
case PROP_MONITOR_XRESOLUTION:
g_value_set_double (value, gui_config->monitor_xres);
break;
case PROP_MONITOR_YRESOLUTION:
g_value_set_double (value, gui_config->monitor_yres);
break;
case PROP_MONITOR_RES_FROM_GDK:
g_value_set_boolean (value, gui_config->monitor_res_from_gdk);
break;
case PROP_MAX_NEW_IMAGE_SIZE:
g_value_set_uint (value, gui_config->max_new_image_size);
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;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
......
......@@ -64,32 +64,38 @@ struct _GimpGuiConfig
gboolean show_rulers;
gboolean show_statusbar;
gboolean show_tool_tips;
gboolean global_paint_options;
/* the fields below have not yet been implemented as properties */
gboolean default_dot_for_dot;
gboolean nav_window_per_display;
gboolean info_window_per_display;
gboolean global_paint_options;
gboolean confirm_on_close;
gboolean default_dot_for_dot;
gboolean trust_dirty_flag;
gboolean save_device_status;
gboolean save_session_info;
gboolean always_restore_session;
gboolean restore_session;
gboolean show_tips;
gint last_tip;
gboolean tearoff_menus;
gdouble monitor_xres;
gdouble monitor_yres;
gboolean using_xserver_resolution;
gboolean show_indicators;
gboolean monitor_res_from_gdk;
guint max_new_image_size;
gboolean trust_dirty_flag;
gboolean nav_window_per_display;
gboolean info_window_follows_mouse;
gchar *theme_path;
gchar *theme;
/* the fields below have not yet been implemented as properties */
gboolean show_indicators;
gboolean use_help;
gint help_browser;
gint cursor_mode;
gboolean no_cursor_updating;
gboolean disable_tearoff_menus;
gchar *theme_path;
gchar *theme;
};
struct _GimpGuiConfigClass
......
......@@ -69,7 +69,7 @@ main (int argc,
g_print (" Serializing %s to '%s' ... ",
g_type_name (G_TYPE_FROM_INSTANCE (config)), filename);
gimp_config_serialize (config, filename, TRUE);
gimp_config_serialize (config, filename);
g_print ("done.\n\n");
g_signal_connect (config, "notify",
......
......@@ -25,6 +25,7 @@
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <glib-object.h>
......@@ -43,8 +44,7 @@
static void gimp_config_iface_init (GimpConfigInterface *gimp_config_iface);
static void gimp_config_iface_serialize (GObject *object,
gint fd,
gboolean put_unknown);
gint fd);
static gboolean gimp_config_iface_deserialize (GObject *object,
GScanner *scanner,
gboolean store_unknown);
......@@ -84,13 +84,9 @@ gimp_config_iface_init (GimpConfigInterface *gimp_config_iface)
}
static void
gimp_config_iface_serialize (GObject *object,
gint fd,
gboolean put_unknown)
gimp_config_iface_serialize (GObject *object,
gint fd)
{
if (put_unknown)
gimp_config_serialize_unknown_tokens (object, fd);
gimp_config_serialize_properties (object, fd);
}
......@@ -106,8 +102,7 @@ gimp_config_iface_deserialize (GObject *object,
gboolean
gimp_config_serialize (GObject *object,
const gchar *filename,
gboolean put_unknown)
const gchar *filename)
{
GimpConfigInterface *gimp_config_iface;
gint fd;
......@@ -119,7 +114,8 @@ gimp_config_serialize (GObject *object,
g_return_val_if_fail (gimp_config_iface != NULL, FALSE);
fd = open (filename, O_WRONLY | O_CREAT);
fd = open (filename, O_WRONLY | O_CREAT,
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
if (fd == -1)
{
......@@ -128,7 +124,7 @@ gimp_config_serialize (GObject *object,
return FALSE;
}
gimp_config_iface->serialize (object, fd, put_unknown);
gimp_config_iface->serialize (object, fd);
close (fd);
......@@ -291,7 +287,6 @@ gimp_config_foreach_unknown_token (GObject *object,
}
}
static void
gimp_config_destroy_unknown_tokens (GSList *unknown_tokens)
{
......
......@@ -33,8 +33,7 @@ struct _GimpConfigInterface
GTypeInterface base_iface;
void (* serialize) (GObject *object,
gint fd,
gboolean put_unknown);
gint fd);
gboolean (* deserialize) (GObject *object,
GScanner *scanner,
gboolean store_unknown);
......@@ -48,8 +47,7 @@ typedef void (*GimpConfigForeachFunc) (const gchar *key,
GType gimp_config_interface_get_type (void) G_GNUC_CONST;
gboolean gimp_config_serialize (GObject *object,
const gchar *filename,
gboolean put_unknown);
const gchar *filename);
gboolean gimp_config_deserialize (GObject *object,
const gchar *filename,
gboolean store_unknown);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment