[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Graveman-cvs] Changes to graveman/current/src/callbacks.c
From: |
sylvain cresto |
Subject: |
[Graveman-cvs] Changes to graveman/current/src/callbacks.c |
Date: |
Tue, 03 May 2005 21:31:10 -0400 |
Index: graveman/current/src/callbacks.c
diff -u graveman/current/src/callbacks.c:1.40
graveman/current/src/callbacks.c:1.41
--- graveman/current/src/callbacks.c:1.40 Tue May 3 01:22:35 2005
+++ graveman/current/src/callbacks.c Wed May 4 01:31:06 2005
@@ -110,16 +110,17 @@
}
/* callback appele pour l'ajout de chaques fichiers */
-void _add_a_file(gchar *Anom, GtkTreeStore *ATreeStore, GtkTreeIter *Aparent,
Tgrave *Ag, guint64 *Adatasize)
+gint _add_a_file(gchar *Anom, GtkTreeStore *ATreeStore, GtkTreeIter *Aparent,
Tgrave *Ag, guint64 *Adatasize, GtkTreeIter *Aiter)
{
GtkTreeIter Liter;
gchar *LOnlyName;
struct stat Lfi;
- DIR *Ldir;
- struct dirent *Lcurfic;
+ GDir *Lgdir;
+ const gchar *Ldirname;
gchar *Lfullname;
gchar *Lonlynameutf8, *Lnomutf8;
gchar *Lformatsizeutf8;
+ gboolean Lret;
if ((LOnlyName=strrchr(Anom, '/'))) {
LOnlyName++;
@@ -128,15 +129,15 @@
}
if (stat(Anom, &Lfi) == -1) {
- _WARN("erreur lecture fichier '%s'", Anom);
- return;
+ _WARN("erreur lecture fichier '%s' err [%d]", Anom, errno);
+ return errno;
}
gtk_tree_store_append(ATreeStore, &Liter, Aparent);
if (S_ISDIR(Lfi.st_mode)) {
/* si c'est un repertoire alors on lis tout son contenu et on ajoute
- * les fich+ * les fichiers qu'il contient */
Lonlynameutf8 = _UTF8(LOnlyName);
Lnomutf8 = _UTF8(Anom);
@@ -144,20 +145,23 @@
g_free(Lnomutf8);
g_free(Lonlynameutf8);
- Ldir = opendir(Anom);
- if (!Ldir) {
+ Lgdir = g_dir_open(Anom, 0, NULL);
+ if (!Lgdir) {
_WARN("erreur ouverture repertoire '%s'", Anom);
- return;
+ return errno;
}
- while ((Lcurfic = readdir(Ldir))) {
- if (!strcmp(Lcurfic->d_name, ".") || !strcmp(Lcurfic->d_name, ".."))
continue;
-
- Lfullname = g_strdup_printf("%s/%s", Anom, Lcurfic->d_name);
- _add_a_file(Lfullname, ATreeStore, &Liter, Ag, Adatasize);
+ while ((Ldirname = g_dir_read_name(Lgdir))) {
+ if (!strcmp(Ldirname, ".") || !strcmp(Ldirname, "..")) continue;
+
+ Lfullname = g_strdup_printf("%s/%s", Anom, Ldirname);
+ Lret = _add_a_file(Lfullname, ATreeStore, &Liter, Ag, Adatasize, NULL);
g_free(Lfullname);
+
+ if (Lret == ELOOP || Lret == EMLINK) break;
}
- closedir(Ldir);
+
+ g_dir_close(Lgdir);
} else {
Lonlynameutf8 = _UTF8(LOnlyName);
@@ -171,6 +175,10 @@
*(Adatasize)=*(Adatasize) + Lfi.st_size;
}
+
+ if (Aiter) *Aiter = Liter;
+
+ return Lret;
}
/* creer un repertoire */
@@ -541,7 +549,7 @@
Lfiles = gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(Lfilesel));
for (Lcur = Lfiles; Lcur && Lcur->data; Lcur = Lcur->next) {
- _add_a_file((gchar *) Lcur->data, (GtkTreeStore *)Ltreemodel, &Liter,
Lg, Ldatasize);
+ _add_a_file((gchar *) Lcur->data, (GtkTreeStore *)Ltreemodel, &Liter,
Lg, Ldatasize, NULL);
}
g_slist_free(Lfiles);
@@ -603,7 +611,7 @@
Lfiles = gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(Lfilesel));
for (Lcur = Lfiles; Lcur && Lcur->data; Lcur = Lcur->next) {
- _add_a_file((gchar *) Lcur->data, GTK_TREE_STORE(Ltreemodel), &Liter,
Lg, Ldatasize);
+ _add_a_file((gchar *) Lcur->data, GTK_TREE_STORE(Ltreemodel), &Liter,
Lg, Ldatasize, NULL);
}
g_slist_free(Lfiles);
@@ -1049,11 +1057,10 @@
Ltxt = _("Do you really want to create an audio cd ?");
Ltitle = _("Writing audio cd in progress...");
Ldevicename1 = get_drive_info(Lg, "dstaudiocombo");
- Llmediarequis1 = g_slist_append(Llmediarequis1, GINT_TO_POINTER(_MEDIA_CDR
+ _MEDIA_BLANK));
- Llmediarequis1 = g_slist_append(Llmediarequis1, GINT_TO_POINTER(_MEDIA_CDR
+ _MEDIA_APPENDABLE));
- Llmediarequis1 = g_slist_append(Llmediarequis1,
GINT_TO_POINTER(_MEDIA_CDRW + _MEDIA_BLANK));
- Llmediarequis1 = g_slist_append(Llmediarequis1,
GINT_TO_POINTER(_MEDIA_CDRW + _MEDIA_APPENDABLE));
- Llmediarequis1 = g_slist_append(Llmediarequis1,
GINT_TO_POINTER(_MEDIA_CDRW + _MEDIA_NOBLANK));
+ Llmediarequis1 = manage_mediarequis(NULL,
+ _MEDIA_CDR + _MEDIA_BLANK, _MEDIA_CDR +
_MEDIA_APPENDABLE,
+ _MEDIA_CDRW + _MEDIA_BLANK, _MEDIA_CDRW +
_MEDIA_APPENDABLE,
+ _MEDIA_CDRW + _MEDIA_NOBLANK, -1);
Lmediatitle1 = _MEDIA_TITLE_BLANKORAPPENDABLE;
} else if (g_str_has_prefix(Lname, "btnburndata") || g_str_has_prefix(Lname,
"btnburndvddata")) {
GtkTreeIter Liter;
@@ -1089,11 +1096,10 @@
}
if (!Liso) {
Ltitle = _("Writing data cd in progress...");
- Llmediarequis1 = g_slist_append(Llmediarequis1,
GINT_TO_POINTER(_MEDIA_CDR + _MEDIA_BLANK));
- Llmediarequis1 = g_slist_append(Llmediarequis1,
GINT_TO_POINTER(_MEDIA_CDR + _MEDIA_APPENDABLE));
- Llmediarequis1 = g_slist_append(Llmediarequis1,
GINT_TO_POINTER(_MEDIA_CDRW + _MEDIA_BLANK));
- Llmediarequis1 = g_slist_append(Llmediarequis1,
GINT_TO_POINTER(_MEDIA_CDRW + _MEDIA_APPENDABLE));
- Llmediarequis1 = g_slist_append(Llmediarequis1,
GINT_TO_POINTER(_MEDIA_CDRW + _MEDIA_NOBLANK));
+ Llmediarequis1 = manage_mediarequis(NULL,
+ _MEDIA_CDR + _MEDIA_BLANK, _MEDIA_CDR + _MEDIA_APPENDABLE,
+ _MEDIA_CDRW + _MEDIA_BLANK, _MEDIA_CDRW +
_MEDIA_APPENDABLE,
+ _MEDIA_CDRW + _MEDIA_NOBLANK, -1);
Lmediatitle1 = _MEDIA_TITLE_BLANKORAPPENDABLE;
} else {
Ltitle = _("Writing iso image in progress...");
@@ -1104,14 +1110,11 @@
if (!Liso) {
Ltxt = _("Do you really want to create a data dvd ?");
Ltitle = _("Writing data dvd in progress...");
-
- Llmediarequis1 = g_slist_append(Llmediarequis1,
GINT_TO_POINTER(_MEDIA_DVDR_P + _MEDIA_BLANK));
- Llmediarequis1 = g_slist_append(Llmediarequis1,
GINT_TO_POINTER(_MEDIA_DVDR_P + _MEDIA_APPENDABLE));
- Llmediarequis1 = g_slist_append(Llmediarequis1,
GINT_TO_POINTER(_MEDIA_DVDR_M + _MEDIA_BLANK));
- Llmediarequis1 = g_slist_append(Llmediarequis1,
GINT_TO_POINTER(_MEDIA_DVDR_M + _MEDIA_APPENDABLE));
- Llmediarequis1 = g_slist_append(Llmediarequis1,
GINT_TO_POINTER(_MEDIA_DVD_RAM));
- Llmediarequis1 = g_slist_append(Llmediarequis1,
GINT_TO_POINTER(_MEDIA_DVDP_RW));
- Llmediarequis1 = g_slist_append(Llmediarequis1,
GINT_TO_POINTER(_MEDIA_DVDM_RW));
+
+ Llmediarequis1 = manage_mediarequis(NULL,
+ _MEDIA_DVDR_P + _MEDIA_BLANK, _MEDIA_DVDR_P +
_MEDIA_APPENDABLE,
+ _MEDIA_DVDR_M + _MEDIA_BLANK, _MEDIA_DVDR_M +
_MEDIA_APPENDABLE,
+ _MEDIA_DVD_RAM, _MEDIA_DVDP_RW, _MEDIA_DVDM_RW, -1);
Lmediatitle1 = _MEDIA_TITLE_DVDRew;
} else {
/* creation image iso */
@@ -1127,17 +1130,17 @@
Ldevicename1 = get_drive_info(Lg, "srccopycombo");
Liso = !Ldevicename1;
if (!Liso) {
- Llmediarequis1 = g_slist_append(Llmediarequis1,
GINT_TO_POINTER(_MEDIA_CD + _MEDIA_NOBLANK));
+ Llmediarequis1 = manage_mediarequis(NULL, _MEDIA_CD + _MEDIA_NOBLANK,
-1);
Lmediatitle1 = _MEDIA_CD;
}
Ldevicename2 = get_drive_info(Lg, "dstcopycombo");
if (Ldevicename2) {
- Llmediarequis2 = g_slist_append(Llmediarequis2,
GINT_TO_POINTER(_MEDIA_CDR + _MEDIA_BLANK));
- Llmediarequis2 = g_slist_append(Llmediarequis2,
GINT_TO_POINTER(_MEDIA_CDR + _MEDIA_APPENDABLE));
- Llmediarequis2 = g_slist_append(Llmediarequis2,
GINT_TO_POINTER(_MEDIA_CDRW + _MEDIA_BLANK));
- Llmediarequis2 = g_slist_append(Llmediarequis2,
GINT_TO_POINTER(_MEDIA_CDRW + _MEDIA_APPENDABLE));
- Llmediarequis2 = g_slist_append(Llmediarequis2,
GINT_TO_POINTER(_MEDIA_CDRW + _MEDIA_NOBLANK));
+ Llmediarequis2 = manage_mediarequis(NULL,
+ _MEDIA_CDR + _MEDIA_BLANK, _MEDIA_CDR + _MEDIA_APPENDABLE,
+ _MEDIA_CDRW + _MEDIA_BLANK, _MEDIA_CDRW + _MEDIA_APPENDABLE,
+ _MEDIA_CDRW + _MEDIA_NOBLANK, -1);
+
Lmediatitle2 = _MEDIA_TITLE_BLANKORAPPENDABLE;
}
}
@@ -1202,6 +1205,9 @@
gtk_widget_destroy(Lconfirm);
}
+ g_slist_free(Llmediarequis2);
+ g_slist_free(Llmediarequis1);
+
sc_grave_destroy(Ldialoghash);
}
@@ -1803,10 +1809,10 @@
gint i;
gchar **Lallname = g_strsplit(Aseldata->data, "\n", 0);
gchar *Lfilename = NULL;
- GtkTreeIter Liter;
+ GtkTreeIter Liter, Lfirstiter;
GtkTreePath *Lpath = NULL;
- gtk_tree_view_get_cursor(GTK_TREE_VIEW(Aliste), &Lpath, NULL);
+ gtk_tree_view_get_dest_row_at_pos(GTK_TREE_VIEW(Aliste), Ax, Ay, &Lpath,
NULL);
if (!Lpath) {
if (!gtk_tree_model_get_iter_first(Ltreemodel, &Liter)) {
gtk_drag_finish (Acontext, FALSE, FALSE, Atime);
@@ -1822,7 +1828,8 @@
if (g_ascii_strncasecmp(Lunfic, "file://", 7)) continue;
if (!(Lfilename = g_filename_from_uri(Lunfic, NULL, NULL))) continue;
- _add_a_file(Lfilename, GTK_TREE_STORE(Ltreemodel), &Liter, Lg,
Ldatasize);
+ _add_a_file(Lfilename, GTK_TREE_STORE(Ltreemodel), &Liter, Lg, Ldatasize,
+ i == 0 ? &Lfirstiter : NULL);
g_free(Lfilename);
}
@@ -1830,8 +1837,10 @@
g_strfreev(Lallname);
/* expand element ajoute */
- if ((Lpath = gtk_tree_model_get_path(Ltreemodel, &Liter))) {
- gtk_tree_view_expand_row(GTK_TREE_VIEW(Aliste), Lpath, TRUE);
+ if ((Lpath = gtk_tree_model_get_path(Ltreemodel, &Lfirstiter))) {
+ gtk_tree_view_expand_to_path(GTK_TREE_VIEW(Aliste), Lpath);
+ gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(Aliste), Lpath, NULL, FALSE,
0, 0);
+ gtk_tree_view_set_cursor(GTK_TREE_VIEW(Aliste), Lpath, NULL, TRUE);
gtk_tree_path_free(Lpath);
}
@@ -1859,8 +1868,12 @@
gtk_tree_model_get_iter(Ltreemodel, &Litersrc, Lpathsrc);
gtk_tree_model_get_iter(Ltreemodel, &Literdst, Lpathdst);
+
gtk_tree_model_get(Ltreemodel, &Literdst, 0, &Ltype, -1);
-
+
+ /* on ne deplace pas le CD root */
+ if (Ltype == TYPE_CD) return;
+
if (Ltype == TYPE_FILE) {
gtk_tree_store_insert_after(GTK_TREE_STORE(Ltreemodel), &Liternew,
NULL, &Literdst);
} else {
- [Graveman-cvs] Changes to graveman/current/src/callbacks.c, sylvain cresto, 2005/05/02
- [Graveman-cvs] Changes to graveman/current/src/callbacks.c,
sylvain cresto <=
- [Graveman-cvs] Changes to graveman/current/src/callbacks.c, sylvain cresto, 2005/05/09
- [Graveman-cvs] Changes to graveman/current/src/callbacks.c, sylvain cresto, 2005/05/17
- [Graveman-cvs] Changes to graveman/current/src/callbacks.c, sylvain cresto, 2005/05/22
- [Graveman-cvs] Changes to graveman/current/src/callbacks.c, sylvain cresto, 2005/05/27
- [Graveman-cvs] Changes to graveman/current/src/callbacks.c, sylvain cresto, 2005/05/28