Esempio n. 1
0
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);
}
Esempio n. 2
0
static void
on_session_save (AnjutaShell *shell, AnjutaSessionPhase phase, AnjutaSession *session, DmaStart *self)
{
	if (phase != ANJUTA_SESSION_PHASE_NORMAL)
		return;

	anjuta_session_set_string_list (session, "Debugger", "Source directories", self->source_dirs);
	anjuta_session_set_int (session, "Debugger", "Stop at beginning", self->stop_at_beginning + 1);
	anjuta_session_set_string (session, "Debugger", "Remote target", self->remote_debugger);
}
Esempio n. 3
0
static void
anjuta_session_set_limited_string_list (AnjutaSession *session, const gchar *section, const gchar *key, GList **value)
{
	GList *node;

	while ((node = g_list_nth (*value, MAX_RECENT_ITEM)) != NULL)
	{
		g_free (node->data);
		*value = g_list_delete_link (*value, node);
	}
	anjuta_session_set_string_list (session, section, key, *value);
}
Esempio n. 4
0
static void
anjuta_session_set_strv (AnjutaSession *session, const gchar *section, const gchar *key, gchar **value)
{
	GList *list = NULL;

	if (value != NULL)
	{
		for (; *value != NULL; value++)
		{
			list = g_list_append (list, *value);
		}
		list = g_list_reverse (list);
	}

	anjuta_session_set_string_list (session, section, key, list);
	g_list_free (list);
}
Esempio n. 5
0
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);
}
Esempio n. 6
0
/* The value argument is a pointer on a GFile list */
static void
anjuta_session_set_limited_relative_file_list (AnjutaSession *session, const gchar *section, const gchar *key, GList **value)
{
	GList *item;
	GList *list = NULL;

	while ((item = g_list_nth (*value, MAX_RECENT_ITEM)) != NULL)
	{
		g_object_unref (G_OBJECT (item->data));
		*value = g_list_delete_link (*value, item);
	}
	for (item = *value; item != NULL; item = g_list_next (item))
	{
		list = g_list_prepend (list, anjuta_session_get_relative_uri_from_file (session, (GFile *)item->data, NULL));
	}
	list = g_list_reverse (list);

	anjuta_session_set_string_list (session, section, key, list);

	g_list_foreach (list, (GFunc)g_free, NULL);
	g_list_free (list);
}
Esempio n. 7
0
gboolean
gdb_save_pretty_printers (AnjutaSession *session, GList *list)
{
	GList *session_list = NULL;
	GList *item;
	
	for (item = g_list_first (list); item != NULL; item = g_list_next (item))
	{
		GdbPrettyPrinter *printer = (GdbPrettyPrinter *)item->data;
		gchar *name;
		
		name = g_strconcat (printer->enable ? "E:" : "D:", printer->path, ":", printer->function == NULL ? "" : printer->function, NULL);

		session_list = g_list_prepend (session_list, name);
	}
	session_list = g_list_reverse (session_list);
	anjuta_session_set_string_list (session, GDB_SECTION, GDB_PRINTER_KEY, session_list);
	g_list_foreach (session_list, (GFunc)g_free, NULL);
	g_list_free (session_list);
	
	return FALSE;
}
Esempio n. 8
0
static void
on_session_load (AnjutaShell *shell, AnjutaSessionPhase phase,
				 AnjutaSession *session, AnjutaWindow *win)
{
	if (phase == ANJUTA_SESSION_PHASE_START)
	{
		AnjutaApplication *app;

		app = ANJUTA_APPLICATION (gtk_window_get_application (GTK_WINDOW (win)));
		if (app != NULL)
		{
			if (anjuta_application_get_no_session (app))
			{
				/* Clear session */
				anjuta_session_clear (session);
			}
			else if (anjuta_application_get_no_files (app))
			{
				/* Clear files from session */
				anjuta_session_set_string_list (session, "File Loader",
				                                "Files", NULL);
			}
			if (anjuta_application_get_geometry (app))
			{
				/* Set new geometry */
				anjuta_session_set_string (session, "Anjuta", "Geometry",
				                           anjuta_application_get_geometry (app));
			}
		}
	}

	/* We load layout at last so that all plugins would have loaded by now */
	if (phase == ANJUTA_SESSION_PHASE_LAST)
	{
		gchar *geometry;
		gchar *layout_file;

		/* Restore geometry */
		geometry = anjuta_session_get_string (session, "Anjuta", "Geometry");
		anjuta_window_set_geometry (win, geometry);
		g_free (geometry);

		/* Restore window state */
		if (anjuta_session_get_int (session, "Anjuta", "Fullscreen"))
		{
			/* bug #304495 */
			AnjutaUI* ui = anjuta_shell_get_ui(shell, NULL);
			GtkAction* action = anjuta_ui_get_action (ui, "ActionGroupToggleView",
								   "ActionViewFullscreen");
			gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
								  TRUE);

			gtk_window_fullscreen (GTK_WINDOW (shell));

		}
		else if (anjuta_session_get_int (session, "Anjuta", "Maximized"))
		{
			gtk_window_maximize (GTK_WINDOW (shell));
		}
		else
		{
			gtk_window_unmaximize (GTK_WINDOW (shell));
		}
		gtk_widget_show (GTK_WIDGET (win));

		/* Restore layout */
		layout_file = g_build_filename (anjuta_session_get_session_directory (session),
										"dock-layout.xml", NULL);
		anjuta_window_layout_load (win, layout_file, NULL);
		g_free (layout_file);
	}
}