static void on_profile_scoped(AnjutaProfileManager *profile_manager, AnjutaProfile *profile, AnjutaApp *app) { gchar *session_dir; static gboolean first_time = TRUE; if (strcmp(anjuta_profile_get_name(profile), USER_PROFILE_NAME) != 0) return; /* If profile scoped to "user", restore user session */ if (system_restore_session) { session_dir = system_restore_session; system_restore_session = NULL; } else { session_dir = get_user_session_dir(); } if (first_time) { first_time = FALSE; } else { AnjutaSession *session; session = anjuta_session_new(session_dir); anjuta_session_sync(session); g_object_unref(session); } /* Restore session */ anjuta_shell_session_load(ANJUTA_SHELL (app), session_dir, NULL); g_free(session_dir); }
static void jsdirs_save (GtkTreeModel *list_store) { GtkTreeIter iter; const gchar *project_root = NULL; anjuta_shell_get (ANJUTA_PLUGIN (getPlugin ())->shell, IANJUTA_PROJECT_MANAGER_PROJECT_ROOT_URI, G_TYPE_STRING, &project_root, NULL); GFile *tmp = g_file_new_for_uri (project_root); AnjutaSession *session = anjuta_session_new (g_file_get_path (tmp)); g_object_unref (tmp); GList *dirs = NULL; if (!gtk_tree_model_iter_children (list_store, &iter, NULL)) return; do { gchar *dir; gtk_tree_model_get (list_store, &iter, 0, &dir, -1); g_assert (dir != NULL); dirs = g_list_append (dirs, dir); } while (gtk_tree_model_iter_next (list_store, &iter)); anjuta_session_set_string_list (session, "options", "js_dirs", dirs); anjuta_session_sync (session); }
static void on_profile_scoped (AnjutaProfileManager *profile_manager, AnjutaProfile *profile, AnjutaApp *app) { gchar *session_dir; static gboolean first_time = TRUE; DEBUG_PRINT ("Profile scoped: %s", anjuta_profile_get_name (profile)); if (strcmp (anjuta_profile_get_name (profile), USER_PROFILE_NAME) != 0) return; DEBUG_PRINT ("%s", "User profile loaded; Restoring user session"); /* If profile scoped to "user", restore user session */ if (system_restore_session) { session_dir = system_restore_session; system_restore_session = NULL; } else { session_dir = USER_SESSION_PATH_NEW; } if (first_time) { first_time = FALSE; } else { /* Clear the files list since we don't want to load them later */ AnjutaSession *session; session = anjuta_session_new (session_dir); anjuta_session_set_string_list (session, "File Loader", "Files", NULL); anjuta_session_sync (session); g_object_unref (session); } /* Restore session */ anjuta_shell_session_load (ANJUTA_SHELL (app), session_dir, NULL); g_free (session_dir); }
void anjuta_shell_session_save (AnjutaShell *shell, const gchar *session_directory, GError **error) { AnjutaSession *session; g_return_if_fail (ANJUTA_IS_SHELL (shell)); g_return_if_fail (session_directory != NULL); session = anjuta_session_new (session_directory); anjuta_session_clear (session); g_signal_emit_by_name (G_OBJECT (shell), "save_session", ANJUTA_SESSION_PHASE_FIRST, session); g_signal_emit_by_name (G_OBJECT (shell), "save_session", ANJUTA_SESSION_PHASE_NORMAL, session); g_signal_emit_by_name (G_OBJECT (shell), "save_session", ANJUTA_SESSION_PHASE_LAST, session); anjuta_session_sync (session); g_object_unref (session); }
/** * anjuta_session_clear: * @session: an #AnjutaSession object * * Clears the session. */ void anjuta_session_clear (AnjutaSession *session) { gchar *cmd; gchar *quoted; g_return_if_fail (ANJUTA_IS_SESSION (session)); g_key_file_free (session->priv->key_file); session->priv->key_file = g_key_file_new (); anjuta_session_sync (session); quoted = g_shell_quote (session->priv->dir_path); cmd = g_strconcat ("rm -fr ", quoted, NULL); system (cmd); g_free (cmd); cmd = g_strconcat ("mkdir -p ", quoted, NULL); system (cmd); g_free (cmd); g_free (quoted); }