summaryrefslogtreecommitdiff
path: root/src/project.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2009-07-14 11:54:46 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2009-07-14 11:54:46 (GMT)
commit24d7c72a124df20339a50bb61e66385352e68a1b (patch)
treebe215cb28b1ee8e146d7ec6e86401fd792ce61a7 /src/project.c
parentc9465acd65e197e48da8648eb8d1ef602d6772ed (diff)
Loaded the last project at startup.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@92 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/project.c')
-rw-r--r--src/project.c109
1 files changed, 65 insertions, 44 deletions
diff --git a/src/project.c b/src/project.c
index 9273b94..21a3380 100644
--- a/src/project.c
+++ b/src/project.c
@@ -24,14 +24,11 @@
#include "project.h"
-#include <dirent.h>
#include <malloc.h>
-#include <stdio.h>
#include <string.h>
-#include <unistd.h>
-#include "xdg.h"
+#include "params.h"
#include "xml.h"
#include "gtkext/easygtk.h"
#include "gtkext/gtkblockview.h"
@@ -504,6 +501,60 @@ const openida_binary **get_openida_project_binaries(const openida_project *proje
/******************************************************************************
* *
+* Paramètres : project = projet à traiter. *
+* *
+* Description : Place un projet au sommet de la pile des projets récents. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void push_openida_project_into_recent_list(const openida_project *project)
+{
+ configuration *config; /* Configuration principale */
+ unsigned int i; /* Boucle de parcours */
+ const char *filename; /* Chemin d'un projet donné */
+
+ pop_openida_project_from_recent_list(project);
+
+ config = get_main_configuration();
+
+ for (i = MPT_RECENT_PROJECT_7; i > MPT_RECENT_PROJECT_1; i--)
+ {
+ filename = get_string_config_value(config, i - 1);
+ set_string_config_value(config, i, filename);
+ }
+
+ set_string_config_value(config, MPT_RECENT_PROJECT_1, project->filename);
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : project = projet à traiter. *
+* *
+* Description : Retire un projet de la pile des projets récents. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void pop_openida_project_from_recent_list(const openida_project *project)
+{
+
+
+
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : ref = espace global de référencement. *
* func = fonction à appeler lors d'un clic sur les menus. *
* *
@@ -515,17 +566,14 @@ const openida_binary **get_openida_project_binaries(const openida_project *proje
* *
******************************************************************************/
-void load_recent_openida_projects_list(GObject *ref, GCallback *func)
+void load_recent_openida_projects_list(GObject *ref, GCallback func)
{
gboolean one_entry; /* Au moins en entrée chargée */
GtkWidget *menuitem; /* Menu principal à compléter */
GtkWidget *menubar; /* Support pour éléments */
- char *directory; /* Répertoire prévu pour proj. */
- DIR *dir; /* Répertoire avec contenu ? */
- struct dirent *entry; /* Elément de répertoire */
- char *filename; /* Nom de fichier à ouvrir */
- char realfile[PATH_MAX]; /* Nom du fichier pointé */
- ssize_t ret; /* Bilan de la lecture */
+ configuration *config; /* Configuration principale */
+ unsigned int i; /* Boucle de parcours */
+ const char *filename; /* Nom de fichier à ouvrir */
GtkWidget *submenuitem; /* Sous-menu à ajouter */
one_entry = false;
@@ -533,50 +581,23 @@ void load_recent_openida_projects_list(GObject *ref, GCallback *func)
menuitem = GTK_WIDGET(g_object_get_data(ref, "menu_recent_prjs"));
menubar = gtk_menu_item_get_submenu(GTK_MENU_ITEM(menuitem));
- directory = get_xdg_config_dir("openida/recents");
-
- dir = opendir(directory);
- /* TODO :: check */
+ config = get_main_configuration();
- if (dir != NULL)
+ for (i = MPT_RECENT_PROJECT_1; i <= MPT_RECENT_PROJECT_7; i++)
{
- for (entry = readdir(dir); entry != NULL; entry = readdir(dir))
- {
- if (strcmp(entry->d_name, ".") == 0) continue;
- if (strcmp(entry->d_name, "..") == 0) continue;
-
- if (strlen(entry->d_name) <= 4) continue;
- if (strcmp(&entry->d_name[strlen(entry->d_name) - 4], ".xml") != 0) continue;
-
- filename = (char *)calloc(strlen(directory) + 2 + strlen(entry->d_name) + 1, sizeof(char));
- strcpy(filename, directory);
- strcat(filename, "/");
- strcat(filename, entry->d_name);
-
- ret = readlink(filename, realfile, PATH_MAX);
- /* TODO :: check */
-
- if (ret == -1) goto process_next_recent;
+ filename = get_string_config_value(config, i);
- submenuitem = qck_create_menu_item(NULL, NULL, realfile, func, ref);
+ if (filename != NULL)
+ {
+ submenuitem = qck_create_menu_item(NULL, NULL, filename, func, ref);
gtk_container_add(GTK_CONTAINER(menubar), submenuitem);
one_entry = true;
- process_next_recent:
-
- free(filename);
-
}
- closedir(dir);
-
}
- free(directory);
-
- recent_list_end:
-
gtk_widget_set_sensitive(menuitem, one_entry);
}