Пример #1
0
void
caja_autorun_set_preferences (const char *x_content_type,
                              gboolean pref_start_app,
                              gboolean pref_ignore,
                              gboolean pref_open_folder)
{
    char **x_content_start_app;
    char **x_content_ignore;
    char **x_content_open_folder;

    g_assert (x_content_type != NULL);

    x_content_start_app = g_settings_get_strv (caja_media_preferences, CAJA_PREFERENCES_MEDIA_AUTORUN_X_CONTENT_START_APP);
    x_content_ignore = g_settings_get_strv (caja_media_preferences, CAJA_PREFERENCES_MEDIA_AUTORUN_X_CONTENT_IGNORE);
    x_content_open_folder = g_settings_get_strv (caja_media_preferences, CAJA_PREFERENCES_MEDIA_AUTORUN_X_CONTENT_OPEN_FOLDER);

    remove_elem_from_str_array (x_content_start_app, x_content_type);
    if (pref_start_app)
    {
        x_content_start_app = add_elem_to_str_array (x_content_start_app, x_content_type);
    }
    g_settings_set_strv (caja_media_preferences, CAJA_PREFERENCES_MEDIA_AUTORUN_X_CONTENT_START_APP, (const gchar * const*) x_content_start_app);

    remove_elem_from_str_array (x_content_ignore, x_content_type);
    if (pref_ignore)
    {
        x_content_ignore = add_elem_to_str_array (x_content_ignore, x_content_type);
    }
    g_settings_set_strv (caja_media_preferences, CAJA_PREFERENCES_MEDIA_AUTORUN_X_CONTENT_IGNORE, (const gchar * const*) x_content_ignore);

    remove_elem_from_str_array (x_content_open_folder, x_content_type);
    if (pref_open_folder)
    {
        x_content_open_folder = add_elem_to_str_array (x_content_open_folder, x_content_type);
    }
    g_settings_set_strv (caja_media_preferences, CAJA_PREFERENCES_MEDIA_AUTORUN_X_CONTENT_OPEN_FOLDER, (const gchar * const*) x_content_open_folder);

    g_strfreev (x_content_open_folder);
    g_strfreev (x_content_ignore);
    g_strfreev (x_content_start_app);

}
static void
csd_autorun_set_preferences (const char *x_content_type,
                             gboolean pref_start_app,
                             gboolean pref_ignore,
                             gboolean pref_open_folder)
{
        GSettings *settings;
	char **x_content_start_app;
	char **x_content_ignore;
	char **x_content_open_folder;

	g_assert (x_content_type != NULL);

	settings = g_settings_new ("org.cinnamon.desktop.media-handling");

	x_content_start_app = g_settings_get_strv (settings, "autorun-x-content-start-app");
	x_content_ignore = g_settings_get_strv (settings, "autorun-x-content-ignore");
	x_content_open_folder = g_settings_get_strv (settings, "autorun-x-content-open-folder");

	x_content_start_app = remove_elem_from_str_array (x_content_start_app, x_content_type);
	if (pref_start_app) {
		x_content_start_app = add_elem_to_str_array (x_content_start_app, x_content_type);
	}
	g_settings_set_strv (settings, "autorun-x-content-start-app", (const gchar * const*) x_content_start_app);

	x_content_ignore = remove_elem_from_str_array (x_content_ignore, x_content_type);
	if (pref_ignore) {
		x_content_ignore = add_elem_to_str_array (x_content_ignore, x_content_type);
	}
	g_settings_set_strv (settings, "autorun-x-content-ignore", (const gchar * const*) x_content_ignore);

	x_content_open_folder = remove_elem_from_str_array (x_content_open_folder, x_content_type);
	if (pref_open_folder) {
		x_content_open_folder = add_elem_to_str_array (x_content_open_folder, x_content_type);
	}
	g_settings_set_strv (settings, "autorun-x-content-open-folder", (const gchar * const*) x_content_open_folder);

	g_strfreev (x_content_open_folder);
	g_strfreev (x_content_ignore);
	g_strfreev (x_content_start_app);
        g_object_unref (settings);
}