예제 #1
0
static void
unset_tree (GConfClient     *dest,
            const char      *path,
	    GConfChangeSet  *changes,
            const char     **excludes)
{
	GSList *list, *l;
	GConfEntry *entry;

	if (path_is_excluded (path, excludes))
		return;

	list = gconf_client_all_entries (dest, path, NULL);
	for (l = list; l; l = l->next) {
		entry = l->data;
		if (!path_is_excluded (entry->key, excludes))
			gconf_change_set_unset (changes, entry->key);
	}
	g_slist_foreach (list, (GFunc)gconf_entry_free, NULL);
	g_slist_free (list);

	list = gconf_client_all_dirs (dest, path, NULL);
	for (l = list; l; l = l->next)
		unset_tree (dest, (const char *)l->data, changes, excludes);
	g_slist_foreach (list, (GFunc)g_free, NULL);
	g_slist_free (list);
}
예제 #2
0
/*
 * Class:     gnu_java_util_prefs_gconf_GConfNativePeer
 * Method:    gconf_client_gconf_client_all_nodes
 * Signature: (Ljava/lang/String;)Ljava/util/List;
 */
JNIEXPORT jobject JNICALL
Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1gconf_1client_1all_1nodes
  (JNIEnv *env, jclass clazz __attribute__ ((unused)), jstring node)
{
  const char *dir = NULL;
  GError *err = NULL;
  GSList *entries = NULL;
  GSList *tmp;

  /* java.util.ArrayList */
  jobject jlist = NULL;

  dir = JCL_jstring_to_cstring (env, node);
  if (dir == NULL)
    {
      return NULL;
    }

  gdk_threads_enter ();
  entries = gconf_client_all_dirs (client, dir, &err);
  gdk_threads_leave ();
  if (err != NULL)
    {
      throw_exception_by_name (env, "java/util/prefs/BackingStoreException",
                               err->message);
      g_error_free (err);
      err = NULL;
      JCL_free_cstring (env, node, dir);
      return NULL;
    }

  jlist = get_jlist_reference (env, jlist_class);
  if (jlist == NULL)
    {
      throw_exception_by_name (env, "java/util/prefs/BackingStoreException",
			       "Unable to get java.util.List reference in native code\n");
      JCL_free_cstring (env, node, dir);
      g_slist_foreach (entries, (GFunc) gconf_entry_free, NULL);
      g_slist_free (entries);
      return NULL;
    }

  tmp = entries;
  while (tmp != NULL)
    {
      const char *_val = tmp->data;
      _val = strrchr (_val, '/');
      ++_val;
      (*env)->CallBooleanMethod (env, jlist, jlist_add_id,
				 (*env)->NewStringUTF (env, _val));
      tmp = g_slist_next (tmp);
    }

  /* clean up things */
  JCL_free_cstring (env, node, dir);
  g_slist_foreach (entries, (GFunc) gconf_entry_free, NULL);
  g_slist_free (entries);

  return jlist;
}
예제 #3
0
/** 
 * gnome_vfs_connect_to_server:
 * @uri: The string representation of the server to connect to.
 * @display_name: The display name that is used to identify the server connection.
 * @icon: The icon that is used to identify the server connection.
 *
 * This function adds a server connection to the specified @uri, which is displayed
 * in user interfaces with the specified @display_name and @icon.
 *
 * If this function is invoked successfully, the created server shows up in the
 * list of mounted volumes of the #GnomeVFSVolumeMonitor, which can be queried
 * using gnome_vfs_volume_monitor_get_mounted_volumes().
 *
 * <note>
 * <para>
 * This function does not have a return value. Hence, you can't easily detect
 * whether the specified server was successfully created. The actual creation and
 * consumption of the new server through the #GnomeVFSVolumeMonitor is done
 * asynchronously.
 * </para>
 * <para>
 * @uri, @display_name, and @icon can be freely chosen, but should be meaningful:
 * </para>
 * <para>
 * @uri should refer to a valid location. You can check the validity of the
 * location by calling gnome_vfs_uri_new() with @uri, and checking whether
 * the return value is not %NULL.
 * </para>
 * <para>
 * The @display_name should be queried from the user, and an empty string
 * should not be considered valid.
 * </para>
 * <para>
 * @icon typically references an icon from the icon theme. Some
 * implementations currently use <literal>gnome-fs-smb</literal>,
 * <literal>gnome-fs-ssh</literal>, <literal>gnome-fs-ftp</literal> and
 * <literal>gnome-fs-share</literal>, depending on the type of the server
 * referenced by @uri. The icon naming conventions might change in the
 * future, though. Obeying the <ulink
 * url="http://standards.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html">
 * freedesktop.org Icon Naming Specification</ulink> is suggested.
 * </para>
 * </note>
 *
 * Since: 2.6
 */
void
gnome_vfs_connect_to_server (const char               *uri,
			     const char               *display_name,
			     const char               *icon)
{
	GConfClient *client;
	GSList *dirs, *l;
	char *dir, *dir_id;
	int max_id, gconf_id;
	char *key;
	char *id;

	client = gconf_client_get_default ();

	max_id = 0;
	dirs = gconf_client_all_dirs (client,
				      CONNECTED_SERVERS_DIR, NULL);
	for (l = dirs; l != NULL; l = l->next) {
		dir = l->data;

		dir_id = strrchr (dir, '/');
		if (dir_id != NULL) {
			dir_id++;
			gconf_id = strtol (dir_id, NULL, 10);
			max_id = MAX (max_id, gconf_id);
		}
		
		g_free (dir);
	}
	g_slist_free (dirs);

	id = g_strdup_printf ("%d", max_id + 1);
	
	key = g_strconcat (CONNECTED_SERVERS_DIR "/",
			   id,
			   "/icon", NULL);
	gconf_client_set_string (client, key, icon, NULL);
	g_free (key);
	
	key = g_strconcat (CONNECTED_SERVERS_DIR "/",
			   id,
			   "/display_name", NULL);
	gconf_client_set_string (client, key, display_name, NULL);
	g_free (key);

	/* Uri key creation triggers creation, do this last */
	key = g_strconcat (CONNECTED_SERVERS_DIR "/",
			   id,
			   "/uri", NULL);
	gconf_client_set_string (client, key, uri, NULL);
	g_free (key);
	
	g_free (id);
	g_object_unref (client);
}
예제 #4
0
static void
gnocam_applet_load_preferences (GnocamApplet *a)
{
	GConfClient *client;
	gchar *s, *k, *key;
	guint i;
	GnocamAppletCam *c;
	GSList *l;

	g_return_if_fail (GNOCAM_IS_APPLET (a));

	client = gconf_client_get_default ();
	l = gconf_client_all_dirs (client, "/desktop/gnome/cameras", NULL);
	for (i = 0; i < g_slist_length (l); i++) {

		/* Create the widget */
		c = gnocam_applet_add_cam (a, g_slist_nth_data (l, i));

		/* Load the preferences into the widget. */
		key = g_slist_nth_data (l, i);
		k = g_strdup_printf ("%s/name", key);
		s = gconf_client_get_string (client, k, NULL);
		g_object_set (c, "name", s, NULL);
		g_free (s); g_free (k);
		k = g_strdup_printf ("%s/manufacturer", key);
		s = gconf_client_get_string (client, k, NULL);
		g_object_set (c, "manufacturer", s, NULL);
		g_free (s); g_free (k);
		k = g_strdup_printf ("%s/model", key);
		s = gconf_client_get_string (client, k, NULL);
		g_object_set (c, "model", s, NULL);
		g_free (s); g_free (k);
		k = g_strdup_printf ("%s/port", key);
		s = gconf_client_get_string (client, k, NULL);
		g_object_set (c, "port", s, NULL);
		g_free (s); g_free (k);
		k = g_strdup_printf ("%s/connect_auto", key);
		g_object_set (c, "connect_auto", 
			gconf_client_get_bool (client, k, NULL), NULL);
	}
	g_object_unref (client);
}
예제 #5
0
static void
mud_connections_populate_iconview(MudConnections *conn)
{
    GSList *muds, *characters, *mud_entry, *char_entry;
    gchar *key, *mud_name, *char_name, *display_name,
          *name_strip, *char_strip, *buf;
    GConfClient *client = gconf_client_get_default();
    GtkTreeIter iter;
    GdkPixbuf *icon;

    key = g_strdup("/apps/gnome-mud/muds");
    muds = gconf_client_all_dirs(client, key, NULL);
    g_free(key);

    for(mud_entry = muds; mud_entry != NULL;
            mud_entry = g_slist_next(mud_entry))
    {
        mud_name = g_path_get_basename((gchar *)mud_entry->data);
        name_strip = NULL;

        key = g_strdup_printf("/apps/gnome-mud/muds/%s/name", mud_name);
        name_strip = gconf_client_get_string(client, key, NULL);
        g_free(key);

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

        char_entry = characters;

        if(char_entry == NULL) // No Characters
        {
            key = g_strdup_printf("/apps/gnome-mud/muds/%s/icon", mud_name);
            buf = gconf_client_get_string(client, key, NULL);
            g_free(key);

            if(buf && strcmp(buf, "gnome-mud") != 0)
            {
                icon = gdk_pixbuf_new_from_file_at_size(
                        buf, 48, 48, NULL);
                g_free(buf);
            }
            else
                icon =
                    gtk_icon_theme_load_icon(gtk_icon_theme_get_default(),
                            "gnome-mud", 48, 0, NULL);

            gtk_list_store_append(
                    GTK_LIST_STORE(conn->priv->icon_model), &iter);
            gtk_list_store_set(
                    GTK_LIST_STORE(conn->priv->icon_model), &iter,
                    MODEL_COLUMN_STRING, name_strip,
                    MODEL_COLUMN_PIXBUF, icon,
                    -1);

            g_object_unref(icon);
            continue;
        }

        for(char_entry = characters; char_entry != NULL;
                char_entry = g_slist_next(char_entry))
        {
            char_strip = NULL;
            char_name = g_path_get_basename((gchar *)char_entry->data);

            key = g_strdup_printf(
                    "/apps/gnome-mud/muds/%s/characters/%s/name",
                    mud_name, char_name);
            char_strip = gconf_client_get_string(client, key, NULL);
            g_free(key);

            display_name = g_strconcat(char_strip, "\n", name_strip, NULL);

            key = g_strdup_printf("/apps/gnome-mud/muds/%s/icon", mud_name);
            buf = gconf_client_get_string(client, key, NULL);
            g_free(key);

            if(buf && strcmp(buf, "gnome-mud") != 0)
            {
                icon = gdk_pixbuf_new_from_file_at_size(
                        buf, 48, 48, NULL);
                g_free(buf);
            }
            else
                icon =
                    gtk_icon_theme_load_icon(gtk_icon_theme_get_default(),
                            "gnome-mud", 48, 0, NULL);

            gtk_list_store_append(GTK_LIST_STORE(conn->priv->icon_model),
                    &iter);
            gtk_list_store_set(GTK_LIST_STORE(conn->priv->icon_model),
                    &iter,
                    MODEL_COLUMN_STRING, display_name,
                    MODEL_COLUMN_PIXBUF, icon,
                    -1);

            g_object_unref(icon);
            g_free(char_name);
            g_free(char_strip);
            g_free(display_name);
        }

        for(char_entry = characters; char_entry != NULL;
                char_entry = g_slist_next(char_entry))
            if(char_entry->data)
                g_free(char_entry->data);

        if(characters)
            g_slist_free(characters);

        g_free(mud_name);
        g_free(name_strip);
    }

    for(mud_entry = muds; mud_entry != NULL;
            mud_entry = g_slist_next(mud_entry))
        if(mud_entry->data)
            g_free(mud_entry->data);

    if(muds)
        g_slist_free(muds);
}
예제 #6
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;
}