moo_prefs_create_key()

master
Yevgen Muntyan 2006-11-19 12:35:32 -06:00
parent 787f22a414
commit 521ba4b18c
6 changed files with 45 additions and 60 deletions

View File

@ -2220,7 +2220,7 @@ create_paned (MooEditWindow *window)
char *key = g_strdup_printf (MOO_EDIT_PREFS_PREFIX "/window/panes/%s",
PANE_POSITIONS[i]);
_moo_prefs_new_key_int_state (key, -1);
moo_prefs_create_key (key, MOO_PREFS_STATE, G_TYPE_INT, -1);
size = moo_prefs_get_int (key);
if (size > 0)

View File

@ -75,8 +75,8 @@ init_find_history (void)
moo_history_list_set_max_entries (replace_history, 20);
last_search = moo_history_list_get_last_item (search_history);
moo_prefs_new_key_flags (moo_edit_setting (MOO_EDIT_PREFS_SEARCH_FLAGS),
MOO_TYPE_FIND_FLAGS, MOO_FIND_CASELESS);
moo_prefs_create_key (moo_edit_setting (MOO_EDIT_PREFS_SEARCH_FLAGS), MOO_PREFS_STATE,
MOO_TYPE_FIND_FLAGS, MOO_FIND_CASELESS);
last_search_flags = moo_prefs_get_flags (moo_edit_setting (MOO_EDIT_PREFS_SEARCH_FLAGS));
}
}

View File

@ -1342,7 +1342,7 @@ file_selector_plugin_init (Plugin *plugin)
"ShowFileSelector", -1);
}
_moo_prefs_new_key_string_state (DIR_PREFS, NULL);
moo_prefs_create_key (DIR_PREFS, MOO_PREFS_STATE, G_TYPE_STRING, NULL);
g_type_class_unref (klass);
return TRUE;

View File

@ -21,6 +21,7 @@
#include "mooutils/mooutils-debug.h"
#include <string.h>
#include <errno.h>
#include <gobject/gvaluecollector.h>
#define PREFS_TYPE_LAST 2
#define PREFS_ROOT "Prefs"
@ -256,6 +257,39 @@ moo_prefs_new_key (const char *key,
}
void
moo_prefs_create_key (const char *key,
MooPrefsType prefs_type,
GType value_type,
...)
{
va_list args;
GValue default_value;
char *error = NULL;
g_return_if_fail (key != NULL);
g_return_if_fail (prefs_type < 2);
g_return_if_fail (_moo_value_type_supported (value_type));
default_value.g_type = 0;
g_value_init (&default_value, value_type);
va_start (args, value_type);
G_VALUE_COLLECT (&default_value, args, 0, &error);
va_end (args);
if (error)
{
g_warning ("%s: could not read value: %s", G_STRLOC, error);
g_free (error);
return;
}
moo_prefs_new_key (key, value_type, &default_value, prefs_type);
g_value_unset (&default_value);
}
GType
moo_prefs_get_key_type (const char *key)
{
@ -1259,21 +1293,6 @@ moo_prefs_new_key_bool (const char *key,
moo_prefs_new_key (key, G_TYPE_BOOLEAN, &val, MOO_PREFS_RC);
}
void
_moo_prefs_new_key_bool_state (const char *key,
gboolean default_val)
{
GValue val;
g_return_if_fail (key != NULL);
val.g_type = 0;
g_value_init (&val, G_TYPE_BOOLEAN);
g_value_set_boolean (&val, default_val);
moo_prefs_new_key (key, G_TYPE_BOOLEAN, &val, MOO_PREFS_STATE);
}
void
moo_prefs_new_key_int (const char *key,
@ -1290,21 +1309,6 @@ moo_prefs_new_key_int (const char *key,
moo_prefs_new_key (key, G_TYPE_INT, &val, MOO_PREFS_RC);
}
void
_moo_prefs_new_key_int_state (const char *key,
int default_val)
{
GValue val;
g_return_if_fail (key != NULL);
val.g_type = 0;
g_value_init (&val, G_TYPE_INT);
g_value_set_int (&val, default_val);
moo_prefs_new_key (key, G_TYPE_INT, &val, MOO_PREFS_STATE);
}
void
moo_prefs_new_key_enum (const char *key,
@ -1357,23 +1361,6 @@ moo_prefs_new_key_string (const char *key,
g_value_unset (&val);
}
void
_moo_prefs_new_key_string_state (const char *key,
const char *default_val)
{
static GValue val;
g_return_if_fail (key != NULL);
val.g_type = 0;
g_value_init (&val, G_TYPE_STRING);
g_value_set_static_string (&val, default_val);
moo_prefs_new_key (key, G_TYPE_STRING, &val, MOO_PREFS_STATE);
g_value_unset (&val);
}
void
moo_prefs_new_key_color (const char *key,

View File

@ -89,12 +89,10 @@ void moo_prefs_new_key_flags (const char *key,
GType flags_type,
int default_val);
void _moo_prefs_new_key_bool_state (const char *key,
gboolean default_val);
void _moo_prefs_new_key_int_state (const char *key,
int default_val);
void _moo_prefs_new_key_string_state (const char *key,
const char *default_val);
void moo_prefs_create_key (const char *key,
MooPrefsType prefs_type,
GType value_type,
...);
char *moo_prefs_make_key (const char *first_comp,
...) G_GNUC_NULL_TERMINATED;

View File

@ -791,9 +791,9 @@ static void init_prefs (MooWindow *window)
GTK_TYPE_TOOLBAR_STYLE,
get_toolbar_style_gtk (window));
_moo_prefs_new_key_bool_state (setting (window, PREFS_MAXIMIZED), FALSE);
_moo_prefs_new_key_int_state (setting (window, PREFS_WIDTH), -1);
_moo_prefs_new_key_int_state (setting (window, PREFS_HEIGHT), -1);
moo_prefs_create_key (setting (window, PREFS_MAXIMIZED), MOO_PREFS_STATE, G_TYPE_BOOLEAN, FALSE);
moo_prefs_create_key (setting (window, PREFS_WIDTH), MOO_PREFS_STATE, G_TYPE_INT, -1);
moo_prefs_create_key (setting (window, PREFS_HEIGHT), MOO_PREFS_STATE, G_TYPE_INT, -1);
}