/* This code wasn't part of the original eel-gconf-extensions.c */
void
eel_gconf_recursive_unset (const char *key)
{
	GConfClient *client;
	GError *error = NULL;

	g_return_if_fail (key != NULL);

	client = eel_gconf_client_get_global ();
	g_return_if_fail (client != NULL);

	gconf_client_recursive_unset (client,
			key,
			GCONF_UNSET_INCLUDING_SCHEMA_NAMES,
			&error);
	eel_gconf_handle_error (&error);
}
static void
unset_all_gconf_keys (void)
{
    GConfClient *gconf;
    gchar *escape_key, *gconf_key;

    escape_key = gconf_escape_key(DEVICE_NAME, -1);
    gconf_key = g_strdup_printf("%s/%s",
                                GPDS_GCONF_DIR,
                                escape_key);
    g_free(escape_key);

    gconf = gconf_client_get_default();
    gconf_client_recursive_unset(gconf, 
                                 gconf_key,
                                 0,
                                 NULL);
    g_free(gconf_key);
    g_object_unref(gconf);
}
Esempio n. 3
0
static void
mud_connections_delete_cb(GtkWidget *widget, MudConnections *conn)
{
    GList *selected =
	gtk_icon_view_get_selected_items(
	    GTK_ICON_VIEW(conn->priv->iconview));
    GtkTreeIter iter;
    gchar *buf, *mud_name, *key, *strip_name,
          *strip_char_name,  *char_name;
    gchar **mud_tuple;
    gint len;
    GConfClient *client = gconf_client_get_default();

    if(g_list_length(selected) == 0)
	return;

    char_name = strip_name = NULL;

    gtk_tree_model_get_iter(conn->priv->icon_model, &iter,
			    (GtkTreePath *)selected->data);
    gtk_tree_model_get(conn->priv->icon_model, &iter, 0, &buf, -1);
	
    mud_tuple = g_strsplit(buf, "\n", -1);
    g_free(buf);

    len = g_strv_length(mud_tuple);

    switch(len)
    {
        /* Delete Mud */
        case 1:
            mud_name = g_strdup(mud_tuple[0]);
            break;

        /* Delete Character */
        case 2:
            char_name = g_strdup(mud_tuple[0]);
            mud_name = g_strdup(mud_tuple[1]);
            break;

        default:
            g_warning("Malformed mud name passed to delete.");
            return;
    }

    if(!mud_connections_delete_confirm(mud_tuple[0]))
    {
        g_free(mud_name);

        if(char_name)
            g_free(char_name);

        g_strfreev(mud_tuple);
        g_object_unref(client);

        g_list_foreach(selected, (GFunc)gtk_tree_path_free, NULL);
        g_list_free(selected);

        return;
    }

    g_strfreev(mud_tuple);

    if(len == 1)
    {
        strip_name = gconf_escape_key(mud_name, -1);
        
        key = g_strdup_printf("/apps/gnome-mud/muds/%s", strip_name);
        gconf_client_recursive_unset(client, key, 0, NULL);
        
        g_free(key);
        
        gconf_client_suggest_sync(client, NULL);
    }
    else if(len == 2)
    {
        strip_name = gconf_escape_key(mud_name, -1);
        strip_char_name = gconf_escape_key(char_name, -1);

        key = g_strdup_printf("/apps/gnome-mud/muds/%s/characters/%s",
                strip_name, strip_char_name);

        gconf_client_recursive_unset(client, key, 0, NULL);

        g_free(key);
        g_free(strip_char_name);
        g_free(char_name);

        gconf_client_suggest_sync(client, NULL);
    }

    g_free(mud_name);
    g_free(strip_name);
    g_object_unref(client);

    g_list_foreach(selected, (GFunc)gtk_tree_path_free, NULL);
    g_list_free(selected);
}
Esempio n. 4
0
static gboolean
mud_connections_property_save(MudConnections *conn)
{
    GConfClient *client;
    const gchar *name =
	gtk_entry_get_text(GTK_ENTRY(conn->priv->name_entry));
    const gchar *host =
	gtk_entry_get_text(GTK_ENTRY(conn->priv->host_entry));
    const gchar *character_name
	= gtk_entry_get_text(GTK_ENTRY(conn->priv->character_name_entry));
    gchar *logon, *profile, *key, *buf, *char_name,
	*stripped_name, *strip_name_new;
    GtkTextIter start, end;
    GtkTextBuffer *buffer;
    GtkTreeIter iter;
    GSList *chars, *entry;

    buffer =
	gtk_text_view_get_buffer(GTK_TEXT_VIEW(conn->priv->logon_textview));
    gtk_text_buffer_get_bounds(buffer, &start, &end);
    logon = gtk_text_iter_get_text(&start, &end);

    if(gtk_combo_box_get_active_iter(
	   GTK_COMBO_BOX(conn->priv->profile_combo), &iter))
	gtk_tree_model_get(
	    GTK_TREE_MODEL(conn->priv->profile_model),
	    &iter, 0, &profile, -1);
    else
	profile = g_strdup("Default");

    if(strlen(name) == 0)
    {
	utils_error_message(conn->priv->properties_window, _("Error"),
			    "%s", _("No mud name specified."));

	if(logon)
	    g_free(logon);

	if(profile)
	    g_free(profile);

	return FALSE;
    }
       
    client = gconf_client_get_default();

    /* If the user renames the mud we need to 
     * transfer over the old character information
     * and do some cleanup */
    if(conn->priv->original_name &&
       strcmp(conn->priv->original_name, name) != 0)
    {
	stripped_name = gconf_escape_key(conn->priv->original_name, -1);
	strip_name_new = gconf_escape_key(name, -1);

	key = g_strdup_printf("/apps/gnome-mud/muds/%s/characters",
			      stripped_name);
	chars = gconf_client_all_dirs(client, key, NULL);
	g_free(key);

	for(entry = chars; entry != NULL; entry = g_slist_next(entry))
	{
	    char_name = g_path_get_basename((gchar *)entry->data);

	    key = g_strdup_printf(
		"/apps/gnome-mud/muds/%s/characters/%s/logon",
		stripped_name, char_name);
	    buf = gconf_client_get_string(client, key, NULL);
	    g_free(key);

	    key = g_strdup_printf(
		"/apps/gnome-mud/muds/%s/characters/%s/logon",
		strip_name_new, char_name);
	    gconf_client_set_string(client, key, buf, NULL);
	    g_free(key);

	    g_free(char_name);
	    g_free(buf);
	}

	for(entry = chars; entry != NULL; entry = g_slist_next(entry))
	    if(entry->data)
		g_free(entry->data);
	g_slist_free(chars);

	key = g_strdup_printf(
	    "/apps/gnome-mud/muds/%s", stripped_name);
	gconf_client_recursive_unset(client, key, 0, NULL);
	g_free(key);

	g_free(stripped_name);
	g_free(strip_name_new);
    }

    stripped_name = gconf_escape_key(name, -1);
    key = g_strdup_printf("/apps/gnome-mud/muds/%s/name", stripped_name);
    gconf_client_set_string(client, key, name, NULL);
    g_free(key);

    key = g_strdup_printf("/apps/gnome-mud/muds/%s/host", stripped_name);
    gconf_client_set_string(client, key, host, NULL);
    g_free(key);

    key = g_strdup_printf("/apps/gnome-mud/muds/%s/port", stripped_name);
    gconf_client_set_int(client, key, 
			 gtk_spin_button_get_value_as_int(
			     GTK_SPIN_BUTTON(conn->priv->port_entry)),
			 NULL);
    g_free(key);

    key = g_strdup_printf("/apps/gnome-mud/muds/%s/icon", stripped_name);
    if(conn->priv->icon_current &&
       strcmp(conn->priv->icon_current, "gnome-mud") != 0)
	gconf_client_set_string(
	    client, key, conn->priv->icon_current, NULL);
    else
	gconf_client_set_string(client, key, "gnome-mud", NULL);
    g_free(key);

    key = g_strdup_printf("/apps/gnome-mud/muds/%s/profile", stripped_name);
    gconf_client_set_string(client, key, profile, NULL);
    g_free(key);

    if(conn->priv->original_char_name && 
       strcmp(conn->priv->original_char_name, character_name) != 0)
    {
	strip_name_new = gconf_escape_key(conn->priv->original_char_name, -1);
	key = g_strdup_printf("/apps/gnome-mud/muds/%s/characters/%s",
			      stripped_name, strip_name_new);
	gconf_client_recursive_unset(client, key, 0, NULL);
	g_free(key);
	g_free(strip_name_new);
    }

    strip_name_new = gconf_escape_key(character_name, -1);

    if(strlen(strip_name_new) > 0)
    {
	key = g_strdup_printf("/apps/gnome-mud/muds/%s/characters/%s/logon",
			      stripped_name, strip_name_new);
	gconf_client_set_string(client, key, logon, NULL);
	g_free(key);

	key = g_strdup_printf("/apps/gnome-mud/muds/%s/characters/%s/name",
			      stripped_name, strip_name_new);
	gconf_client_set_string(client, key, character_name, NULL);
	g_free(key);
    }

    g_object_unref(client);

    if(logon)
	g_free(logon);

    if(profile)
	g_free(profile);

    return TRUE;
}