char *preferences_get_highlight_match_key (guint highlight_id, guint match_id, Preference pref_id) { const char *key; char *dir; switch (pref_id) { case PREF_HIGHLIGHT_MATCH_TEXT_COLOR: key = "text-color"; break; case PREF_HIGHLIGHT_MATCH_BASE_COLOR: key = "base-color"; break; case PREF_HIGHLIGHT_MATCH_FONT: key = "font"; break; default: g_assert_not_reached (); return NULL; } dir = g_strdup_printf ("%06X/%d", highlight_id, match_id); return gconf_concat_dir_and_key (gconf_concat_dir_and_key (preferences_get_key (PREF_HIGHLIGHTS), dir), key); }
static void search_preferences_remove_setting(gchar *name) { GConfClient *client; client = gconf_client_get_default(); gconf_client_set_list(client, gconf_concat_dir_and_key(SEARCH_PREF_PATH, "list_pref"), GCONF_VALUE_STRING, list_pref, NULL); // FIXME : Remove Setting Directory gconf_client_remove_dir(client, gconf_concat_dir_and_key(SEARCH_PREF_PATH, name), NULL); }
static void search_preferences_save_search_pref(gchar *name) { GConfClient *client; gchar *path; client = gconf_client_get_default(); gconf_client_set_list(client, gconf_concat_dir_and_key(SEARCH_PREF_PATH, "list_pref"), GCONF_VALUE_STRING, list_pref, NULL); path = gconf_concat_dir_and_key(SEARCH_PREF_PATH, name); gconf_client_add_dir(client, path, GCONF_CLIENT_PRELOAD_NONE, NULL); search_preferences_save_setting(name); }
static void search_preferences_active_selection_row(GtkTreeView *view) { GtkTreeSelection *selection; GtkTreeModel *model; GtkTreeIter iter; gchar *name; selection = gtk_tree_view_get_selection (view); if (gtk_tree_selection_get_selected (selection, &model, &iter) == TRUE) { gtk_tree_model_foreach (model, on_search_preferences_setting_inactive, NULL); gtk_tree_store_set (GTK_TREE_STORE (model), &iter, PREF_ACTIVE_COLUMN, TRUE, -1); gtk_tree_model_get (model, &iter, PREF_NAME_COLUMN, &name, -1); search_preferences_update_entry(name); if (g_ascii_strcasecmp (name, BASIC)) search_preferences_read_setting(gconf_concat_dir_and_key( SEARCH_PREF_PATH, name)); else search_preferences_setting_by_default(); } }
static char* get_lock_dir_from_root_dir (const char *root_dir) { gchar* lockdir; lockdir = gconf_concat_dir_and_key (root_dir, "%gconf-xml-backend.lock"); return lockdir; }
/* * path is here the full path to an item */ static NAObjectItem * read_item( NagpGConfProvider *provider, const gchar *path, GSList **messages ) { static const gchar *thisfn = "nagp_reader_read_item"; NAObjectItem *item; gchar *full_path; gchar *type; gchar *id; ReaderData *data; g_debug( "%s: provider=%p, path=%s", thisfn, ( void * ) provider, path ); g_return_val_if_fail( NAGP_IS_GCONF_PROVIDER( provider ), NULL ); g_return_val_if_fail( NA_IS_IIO_PROVIDER( provider ), NULL ); g_return_val_if_fail( !provider->private->dispose_has_run, NULL ); full_path = gconf_concat_dir_and_key( path, NAGP_ENTRY_TYPE ); type = na_gconf_utils_read_string( provider->private->gconf, full_path, TRUE, NAGP_VALUE_TYPE_ACTION ); g_free( full_path ); item = NULL; /* an item may have 'Action' or 'Menu' type; defaults to Action */ if( !type || !strlen( type ) || !strcmp( type, NAGP_VALUE_TYPE_ACTION )){ item = NA_OBJECT_ITEM( na_object_action_new()); } else if( !strcmp( type, NAGP_VALUE_TYPE_MENU )){ item = NA_OBJECT_ITEM( na_object_menu_new()); } else { g_warning( "%s: unknown type '%s' at %s", thisfn, type, path ); } g_free( type ); if( item ){ id = g_path_get_basename( path ); na_object_set_id( item, id ); g_free( id ); data = g_new0( ReaderData, 1 ); data->path = ( gchar * ) path; data->entries = na_gconf_utils_get_entries( provider->private->gconf, path ); na_gconf_utils_dump_entries( data->entries ); na_ifactory_provider_read_item( NA_IFACTORY_PROVIDER( provider ), data, NA_IFACTORY_OBJECT( item ), messages ); na_gconf_utils_free_entries( data->entries ); g_free( data ); } return( item ); }
static NADataBoxed * get_boxed_from_path( const NagpGConfProvider *provider, const gchar *path, ReaderData *reader_data, const NADataDef *def ) { static const gchar *thisfn = "nagp_reader_get_boxed_from_path"; NADataBoxed *boxed; gboolean have_entry; gchar *str_value; gboolean bool_value; GSList *slist_value; gint int_value; boxed = NULL; have_entry = na_gconf_utils_has_entry( reader_data->entries, def->gconf_entry ); g_debug( "%s: entry=%s, have_entry=%s", thisfn, def->gconf_entry, have_entry ? "True":"False" ); if( have_entry ){ gchar *entry_path = gconf_concat_dir_and_key( path, def->gconf_entry ); boxed = na_data_boxed_new( def ); switch( def->type ){ case NA_DATA_TYPE_STRING: case NA_DATA_TYPE_LOCALE_STRING: str_value = na_gconf_utils_read_string( provider->private->gconf, entry_path, TRUE, NULL ); na_boxed_set_from_string( NA_BOXED( boxed ), str_value ); g_free( str_value ); break; case NA_DATA_TYPE_BOOLEAN: bool_value = na_gconf_utils_read_bool( provider->private->gconf, entry_path, TRUE, FALSE ); na_boxed_set_from_void( NA_BOXED( boxed ), GUINT_TO_POINTER( bool_value )); break; case NA_DATA_TYPE_STRING_LIST: slist_value = na_gconf_utils_read_string_list( provider->private->gconf, entry_path ); na_boxed_set_from_void( NA_BOXED( boxed ), slist_value ); na_core_utils_slist_free( slist_value ); break; case NA_DATA_TYPE_UINT: int_value = na_gconf_utils_read_int( provider->private->gconf, entry_path, TRUE, 0 ); na_boxed_set_from_void( NA_BOXED( boxed ), GUINT_TO_POINTER( int_value )); break; default: g_warning( "%s: unknown type=%u for %s", thisfn, def->type, def->name ); g_free( boxed ); boxed = NULL; } g_free( entry_path ); } return( boxed ); }
void on_setting_pref_remove_clicked(GtkButton *button, gpointer user_data) { GtkTreeView *view; GtkTreeStore *store; GtkTreeSelection *selection; GtkTreeModel *model; GtkTreeIter iter; gboolean valid; gchar *name; GConfClient *client; view = GTK_TREE_VIEW (sr_get_gladewidget(SETTING_PREF_TREEVIEW)->widget); store = GTK_TREE_STORE (gtk_tree_view_get_model(view)); selection = gtk_tree_view_get_selection (view); valid = gtk_tree_selection_get_selected (selection, &model, &iter); if (valid) { gtk_tree_model_get (model, &iter, PREF_NAME_COLUMN, &name, -1); if (g_ascii_strcasecmp (name, BASIC)) { gchar *path; client = gconf_client_get_default(); path = gconf_client_get_string(client, gconf_concat_dir_and_key(SEARCH_PREF_PATH, "search_pref_default"), NULL); gtk_tree_store_remove(store, &iter); list_pref = g_slist_remove(list_pref, search_preferences_find_setting(name)->data); search_preferences_remove_setting(name); if (!g_ascii_strcasecmp (name, path)) { gconf_client_set_string(client, gconf_concat_dir_and_key( SEARCH_PREF_PATH, "search_pref_default"), "", NULL); } g_free(path); search_preferences_update_entry(""); } } }
void search_preferences_init(void) { GConfClient *client; GSList *list; GtkTreeModel *model; GtkTreeIter iter; sr = create_search_replace_instance(NULL); search_preferences_add_treeview(BASIC); client = gconf_client_get_default(); gconf_client_add_dir(client, SEARCH_PREF_PATH, GCONF_CLIENT_PRELOAD_NONE, NULL); list_pref = gconf_client_get_list(client,gconf_concat_dir_and_key(SEARCH_PREF_PATH, "list_pref"), GCONF_VALUE_STRING, NULL); for (list = list_pref; list != NULL; list = g_slist_next(list)) search_preferences_add_treeview(list->data); default_pref = gconf_client_get_string(client,gconf_concat_dir_and_key(SEARCH_PREF_PATH, "search_pref_default"), NULL); model = search_preferences_get_model(); gtk_tree_model_foreach (model, on_search_preferences_setting_inactive, NULL); if (default_pref && (*default_pref != '\0') && g_ascii_strcasecmp (default_pref, BASIC)) search_preferences_read_setting(gconf_concat_dir_and_key(SEARCH_PREF_PATH, default_pref)); else { gtk_tree_model_get_iter_first(model, &iter); gtk_tree_store_set (GTK_TREE_STORE (model), &iter, PREF_ACTIVE_COLUMN, TRUE, -1); search_preferences_setting_by_default(); } search_preferences_activate_default(default_pref); g_free(default_pref); }
static void read_done_action_read_profiles( const NAIFactoryProvider *provider, NAObjectAction *action, ReaderData *data, GSList **messages ) { static const gchar *thisfn = "nagp_reader_read_done_action_read_profiles"; GSList *order; GSList *list_profiles; GSList *ip; gchar *profile_id; gchar *profile_path; NAObjectId *found; NAObjectProfile *profile; data->parent = NA_OBJECT_ITEM( action ); order = na_object_get_items_slist( action ); list_profiles = na_gconf_utils_get_subdirs( NAGP_GCONF_PROVIDER( provider )->private->gconf, data->path ); /* read profiles in the specified order * as a protection against bugs in NACT, we check that profile has not * already been loaded */ for( ip = order ; ip ; ip = ip->next ){ profile_id = ( gchar * ) ip->data; found = na_object_get_item( action, profile_id ); if( !found ){ g_debug( "nagp_reader_read_done_action: loading profile=%s", profile_id ); profile_path = gconf_concat_dir_and_key( data->path, profile_id ); read_done_action_load_profile( provider, data, profile_path, messages ); g_free( profile_path ); } } /* append other profiles * this is mandatory for pre-2.29 actions which introduced order of profiles */ for( ip = list_profiles ; ip ; ip = ip->next ){ profile_id = g_path_get_basename(( const gchar * ) ip->data ); found = na_object_get_item( action, profile_id ); if( !found ){ g_debug( "nagp_reader_read_done_action: loading profile=%s", profile_id ); read_done_action_load_profile( provider, data, ( const gchar * ) ip->data, messages ); } g_free( profile_id ); } /* make sure we have at least one profile */ if( !na_object_get_items_count( action )){ g_warning( "%s: no profile found in GConf backend", thisfn ); profile = na_object_profile_new_with_defaults(); na_object_attach_profile( action, profile ); } }
static void on_search_preferences_treeview_enable_toggle (GtkCellRendererToggle *cell, gchar *path_str, gpointer data) { GtkTreeView *view; GtkTreeModel *model; GtkTreeIter iter; GtkTreePath *path; gboolean state; gchar *name; GConfClient *client; path = gtk_tree_path_new_from_string (path_str); view = GTK_TREE_VIEW (sr_get_gladewidget(SETTING_PREF_TREEVIEW)->widget); model = gtk_tree_view_get_model (view); gtk_tree_model_get_iter (model, &iter, path); gtk_tree_model_get (model, &iter, PREF_NAME_COLUMN, &name, PREF_DEFAULT_COLUMN, &state, -1); client = gconf_client_get_default(); if (state) { gtk_tree_store_set (GTK_TREE_STORE (model), &iter, PREF_DEFAULT_COLUMN, FALSE, -1); gconf_client_set_string(client, gconf_concat_dir_and_key(SEARCH_PREF_PATH, "search_pref_default"), "", NULL); } else { gconf_client_set_string(client, gconf_concat_dir_and_key(SEARCH_PREF_PATH, "search_pref_default"), name, NULL); gtk_tree_model_foreach (model, on_search_preferences_clear_default_foreach, NULL); gtk_tree_store_set (GTK_TREE_STORE (model), &iter, PREF_DEFAULT_COLUMN, TRUE, -1); } }
char *preferences_get_highlight_key (guint highlight_id, Preference pref_id) { char *dir; const char *key; switch (pref_id) { case PREF_HIGHLIGHT_CASE_SENSITIVE: key = "case-sensitive"; break; case PREF_HIGHLIGHT_STRING: key = "string"; break; default: g_assert_not_reached (); return NULL; } dir = g_strdup_printf ("%06X", highlight_id); return gconf_concat_dir_and_key (gconf_concat_dir_and_key (preferences_get_key (PREF_HIGHLIGHTS), dir), key); }
void preferences_init (void) { warlock_gconf_client = gconf_client_get_default (); gconf_client_add_dir (warlock_gconf_client, PREFS_PREFIX, GCONF_CLIENT_PRELOAD_NONE, NULL); profile = g_new (Profile, 1); profile->name = "Default"; profile->path = gconf_concat_dir_and_key (PREFS_PREFIX, profile->name); notifier_data = g_hash_table_new_full (g_direct_hash, notifiers_equal, NULL, notifier_free); }
char *preferences_get_profile_key (guint profile_id, Preference pref_id) { const char *key; char *dir; switch (pref_id) { case PREF_PROFILE_NAME: key = "name"; break; case PREF_PROFILE_USERNAME: key = "username"; break; case PREF_PROFILE_PASSWORD: key = "password"; break; case PREF_PROFILE_GAME: key = "game"; break; case PREF_PROFILE_CHARACTER: key = "character"; break; default: g_assert_not_reached (); return NULL; } dir = g_strdup_printf ("%06X", profile_id); return gconf_concat_dir_and_key (gconf_concat_dir_and_key (preferences_get_global_key (PREF_PROFILES), dir), key); }
/* Get a list of entries from an array. */ GSList * gconf_dbus_utils_get_entries (DBusMessageIter *iter, const gchar *dir) { GSList *entries; DBusMessageIter array_iter; entries = NULL; dbus_message_iter_recurse (iter, &array_iter); /* Loop through while there are structs (entries). */ while (dbus_message_iter_get_arg_type (&array_iter) == DBUS_TYPE_STRUCT) { gchar *key; GConfValue *value; gboolean is_default; gboolean is_writable; gchar *schema_name; GConfEntry *entry; if (!utils_get_entry_values_stringified (&array_iter, &key, &value, &is_default, &is_writable, &schema_name)) break; entry = gconf_entry_new_nocopy (gconf_concat_dir_and_key (dir, key), value); gconf_entry_set_is_default (entry, is_default); gconf_entry_set_is_writable (entry, is_writable); if (schema_name) gconf_entry_set_schema_name (entry, schema_name); entries = g_slist_prepend (entries, entry); dbus_message_iter_next (&array_iter); } return entries; }
Dir* dir_new (const gchar *keyname, const gchar *xml_root_dir, guint dir_mode, guint file_mode) { Dir* d; d = dir_blank(keyname); /* sync with dir_load() */ d->fs_dirname = gconf_concat_dir_and_key(xml_root_dir, keyname); d->xml_filename = g_strconcat(d->fs_dirname, "/%gconf.xml", NULL); d->root_dir_len = strlen(xml_root_dir); d->dir_mode = dir_mode; d->file_mode = file_mode; return d; }
char *preferences_get_global_key (Preference id) { const char *key; switch (id) { case PREF_GLOBAL_NAMES: key = "global-names"; break; case PREF_PROFILES: key = "profiles"; break; case PREF_PROFILES_INDEX: key = "profiles/index"; break; default: g_assert_not_reached (); return NULL; } return gconf_concat_dir_and_key (PREFS_PREFIX, key); }
Dir* dir_load (const gchar* key, const gchar* xml_root_dir, GError** err) { Dir* d; gchar* fs_dirname; gchar* xml_filename; guint dir_mode = 0700; guint file_mode = 0600; g_return_val_if_fail(gconf_valid_key(key, NULL), NULL); fs_dirname = gconf_concat_dir_and_key(xml_root_dir, key); xml_filename = g_strconcat(fs_dirname, "/%gconf.xml", NULL); { struct stat s; gboolean notfound = FALSE; if (g_stat(xml_filename, &s) != 0) { if (errno != ENOENT) { gconf_set_error (err, GCONF_ERROR_FAILED, _("Could not stat `%s': %s"), xml_filename, g_strerror(errno)); } notfound = TRUE; } else if (S_ISDIR(s.st_mode)) { gconf_set_error (err, GCONF_ERROR_FAILED, _("XML filename `%s' is a directory"), xml_filename); notfound = TRUE; } if (notfound) { gconf_log(GCL_DEBUG, "dir file %s not found", xml_filename); g_free(fs_dirname); g_free(xml_filename); return NULL; } else { /* Take directory mode from the xml_root_dir, if possible */ if (g_stat (xml_root_dir, &s) == 0) { dir_mode = _gconf_mode_t_to_mode (s.st_mode); } file_mode = dir_mode & ~0111; /* turn off search bits */ } } d = dir_blank(key); /* sync with dir_new() */ d->fs_dirname = fs_dirname; d->xml_filename = xml_filename; d->root_dir_len = strlen(xml_root_dir); d->dir_mode = dir_mode; d->file_mode = file_mode; gconf_log (GCL_DEBUG, "loaded dir %s", fs_dirname); return d; }
static void search_preferences_save_setting(gchar *name) { GConfClient *client; gchar *path; search_replace_populate(); client = gconf_client_get_default(); path = gconf_concat_dir_and_key(SEARCH_PREF_PATH, name); gconf_client_set_bool(client, gconf_concat_dir_and_key(path, "regex"), sr->search.expr.regex, NULL); gconf_client_set_bool(client, gconf_concat_dir_and_key(path, "greedy"), sr->search.expr.greedy, NULL); gconf_client_set_bool(client, gconf_concat_dir_and_key(path, "match_case"), sr->search.expr.match_case, NULL); gconf_client_set_bool(client, gconf_concat_dir_and_key(path, "whole_word"), sr->search.expr.whole_word, NULL); gconf_client_set_bool(client, gconf_concat_dir_and_key(path, "whole_line"), sr->search.expr.whole_line, NULL); gconf_client_set_bool(client, gconf_concat_dir_and_key(path, "word_start"), sr->search.expr.word_start, NULL); gconf_client_set_bool(client, gconf_concat_dir_and_key(path, "no_limit"), sr->search.expr.no_limit, NULL); gconf_client_set_int(client, gconf_concat_dir_and_key(path, "actions_max"), sr->search.expr.actions_max, NULL); gconf_client_set_int(client, gconf_concat_dir_and_key(path, "type"), sr->search.range.type, NULL); gconf_client_set_int(client, gconf_concat_dir_and_key(path, "direction"), sr->search.range.direction, NULL); gconf_client_set_int(client, gconf_concat_dir_and_key(path, "action"), sr->search.action, NULL); gconf_client_set_bool(client, gconf_concat_dir_and_key(path, "basic_search"), sr->search.basic_search, NULL); }
char *preferences_get_key (Preference id) { const char *key; switch (id) { case PREF_AUTO_LOG: key = "auto-log"; break; case PREF_AUTO_SNEAK: key = "auto-sneak"; break; case PREF_ECHO: key = "echo"; break; case PREF_WINDOW_WIDTH: key = "window-width"; break; case PREF_WINDOW_HEIGHT: key = "window-height"; break; case PREF_SCRIPT_PREFIX: key = "script-prefix"; break; case PREF_DEFAULT_TEXT_COLOR: key = "default-text-color"; break; case PREF_DEFAULT_BASE_COLOR: key = "default-base-color"; break; case PREF_DEFAULT_FONT: key = "default-font"; break; case PREF_TITLE_TEXT_COLOR: key = "title-text-color"; break; case PREF_TITLE_BASE_COLOR: key = "title-base-color"; break; case PREF_TITLE_FONT: key = "title-font"; break; case PREF_MONSTER_TEXT_COLOR: key = "monster-text-color"; break; case PREF_MONSTER_BASE_COLOR: key = "monster-base-color"; break; case PREF_MONSTER_FONT: key = "monster-font"; break; case PREF_ECHO_TEXT_COLOR: key = "echo-text-color"; break; case PREF_ECHO_BASE_COLOR: key = "echo-base-color"; break; case PREF_ECHO_FONT: key = "echo-font"; break; case PREF_TEXT_BUFFER_SIZE: key = "text-buffer-size"; break; case PREF_COMMAND_SIZE: key = "command-size"; break; case PREF_COMMAND_HISTORY_SIZE: key = "command-history-size"; break; case PREF_SCRIPT_PATH: key = "script-path"; break; case PREF_LOG_PATH: key = "log-path"; break; case PREF_ARRIVAL_VIEW: key = "arrival-view"; break; case PREF_THOUGHT_VIEW: key = "thought-view"; break; case PREF_DEATH_VIEW: key = "death-view"; break; case PREF_FAMILIAR_VIEW: key = "familiar-view"; break; case PREF_HIGHLIGHTS: key = "highlights"; break; case PREF_HIGHLIGHTS_INDEX: key = "highlights/index"; break; case PREF_MACROS: key = "macros"; break; case PREF_COMMAND_HISTORY: key = "command-history"; break; default: g_assert_not_reached (); return NULL; } return gconf_concat_dir_and_key (profile->path, key); }
static void search_preferences_read_setting(gchar *name) { GConfClient *client; client = gconf_client_get_default(); sr->search.expr.regex = gconf_client_get_bool(client, gconf_concat_dir_and_key(name, "regex"), NULL); sr->search.expr.greedy = gconf_client_get_bool(client, gconf_concat_dir_and_key(name, "greedy"), NULL); sr->search.expr.match_case = gconf_client_get_bool(client, gconf_concat_dir_and_key(name, "match_case"), NULL); sr->search.expr.whole_word = gconf_client_get_bool(client, gconf_concat_dir_and_key(name, "whole_word"), NULL); sr->search.expr.whole_line = gconf_client_get_bool(client, gconf_concat_dir_and_key(name, "whole_line"), NULL); sr->search.expr.word_start = gconf_client_get_bool(client, gconf_concat_dir_and_key(name, "word_start"), NULL); sr->search.expr.no_limit = gconf_client_get_bool(client, gconf_concat_dir_and_key(name, "no_limit"), NULL); sr->search.expr.actions_max = gconf_client_get_int(client, gconf_concat_dir_and_key(name, "actions_max"), NULL); sr->search.range.type = gconf_client_get_int(client, gconf_concat_dir_and_key(name, "type"), NULL); sr->search.range.direction = gconf_client_get_int(client, gconf_concat_dir_and_key(name, "direction"), NULL); sr->search.action = gconf_client_get_int(client, gconf_concat_dir_and_key(name, "action"), NULL); sr->search.basic_search = gconf_client_get_bool(client, gconf_concat_dir_and_key(name, "basic_search"), NULL); search_update_dialog(); }