#pragma implementation #include #include #include #include #include #include #include #include "../framework/framework.h" #include #include "photo.h" #include "photo.m" #include static const char K_DIR[]="dir"; static const char K_PUBLISH[]="publish"; static const char K_COMMAND[]="command"; static const char K_COMPILE[]="compile"; static const char K_IMPORT[]="import"; static const char K_ARCHIVE[]="archive"; static const char K_VIEWCMD[]="viewcmd"; /* Get the path of the compilation script */ static const char *photo_getcompile() { return linuxconf_getval(K_COMMAND,K_COMPILE,"/usr/lib/tlmp/lib/photo_compile"); } /* Get the path of the import script */ static const char *photo_getimport() { return linuxconf_getval(K_COMMAND,K_IMPORT,"/usr/lib/tlmp/lib/photo_import"); } static const char *photo_getarchive() { static char tmp[PATH_MAX]; snprintf (tmp,sizeof(tmp)-1,"%s/.tlphoto",getenv("HOME")); return linuxconf_getval (K_DIR,K_ARCHIVE,tmp); } static const char *photo_getviewcmd() { return linuxconf_getval (K_COMMAND,K_VIEWCMD,"/usr/X11R6/bin/display"); } /* Set the program preferences */ static void photo_prefer() { DIALOG dia; SSTRING compile (photo_getcompile()); dia.newf_str (MSG_U(F_COMPILE,"Compilation command"),compile,60); SSTRING import (photo_getimport()); dia.newf_str (MSG_U(F_IMPORT,"Import command"),import,60); SSTRING viewcmd (photo_getviewcmd()); dia.newf_str (MSG_U(F_VIEWCMD,"View command"),viewcmd,60); SSTRING archive (photo_getarchive()); dia.newf_str (MSG_U(F_ARCHIVEDIR,"Archive directory"),archive,60); dia.settype (DIATYPE_POPUP); int nof = 0; while (1){ MENU_STATUS code = dia.edit (MSG_U(T_PREFER,"Preferences"),"" ,help_nil,nof); if (code == MENU_CANCEL || code == MENU_ESCAPE){ break; }else{ if (file_type (compile.get())!=0){ xconf_error (MSG_U(E_NOCOMMAND,"Command does not exist: %s") ,compile.get()); nof = 0; }else if (file_type (import.get())!=0){ xconf_error (MSG_R(E_NOCOMMAND),import.get()); nof = 1; }else{ linuxconf_replace (K_COMMAND,K_COMPILE,compile); linuxconf_replace (K_COMMAND,K_IMPORT,import); linuxconf_replace (K_COMMAND,K_VIEWCMD,viewcmd); linuxconf_replace (K_DIR,K_ARCHIVE,archive); linuxconf_save(); break; } } } } static void photo_showcmd(const char *cmd) { DIALOG dia; glocal.dia.settype (DIATYPE_POPUP); (cmd,20,true); glocal.dia.newf_info (" ",line); return 0; glocal.dia.newf_info ("**",line); return 0; int nof = 0; glocal.dia.edit (MSG_U(T_CAMERACMD,"Camera commands"),cmd,help_nil,nof,MENUBUT_CANCEL); } static int photo_execcmd(const char *cmd, bool bg) { if (bg && fork() != 0) return 0; SSTRING errs; int ret = 0; (cmd,20,true); return 0; glocal.errs.appendf ("%s\n",line); return 0; if (bg){ _exit (0); }else if (glocal.errs.is_filled()){ xconf_error ("%s\n%s\n\n%s",MSG_R(T_CAMERACMD),cmd,glocal.errs.get()); ret = -1; } return ret; } static int photo_execcmd(const char *cmd) { return photo_execcmd (cmd,false); } static int photo_deltmpdir() { int ret = 0; SSTRING dir; dir.setfromf ("/tmp/tlphoto.%d",getpid()); if (file_exist(dir.get())){ SSTRING cmd; cmd.setfromf ("rm -fr %s",dir.get()); ret = photo_execcmd (cmd.get()); } return ret; } static int photo_edittxt ( const char *fpath, // text file path FRAMEWORK_INFO &info, _F_FRAMEWORK &c) { SSTRING txt; (fpath,false); // Do nothing glocal.txt.append (line); return 0; DIALOG dia; info.msgs.waitfor (dia); dia.newf_textarea (NULL,glocal.txt,50,10); int nof = 0; const char *fname = strrchr(fpath,'/'); if (fname == NULL){ fname = fpath; }else{ fname++; // Skip the slash } int ret = -1; while (1){ MENU_STATUS code = dia.edit (fname,"",help_nil,nof); if (code == MENU_CANCEL || code == MENU_ESCAPE){ break; }else if (code == MENU_MESSAGE){ if (c.must_end (info.msgs)){ break; } }else{ (fpath,false); fputs (glocal.txt.get(),fout); return 0; ret = 0; break; } } return ret; } /* Load the first line of a file if it exist */ static void photo_loadfirstline (const char *file, SSTRING &line) { SSTRING *line; glocal.line = &line; line.setempty(); (file,true); glocal.line->setfrom(line); return -1; } /* Copy a file to a directory. Return -1 if any errors. */ static int photo_copy2dir ( const char *file, const char *dir, bool update_only, DIALOG &dia, int &status, SSTRING &fstatus, const char *cnv_str) { glocal DIALOG *dia = &dia; glocal int *status = &status; int ret = -1; if (file_mkdirp (dir,-1,-1,0755)!=-1){ const char *name = strrchr(file,'/'); if (name == NULL){ name = file; }else{ name++; } SSTRING tmp; tmp.setfromf ("%s/%s",dir,name); fstatus.setfrom (file); status = 0; dia.reload(); // fprintf (stderr,"file_copy %s -> %s\n",file,tmp.get()); struct stat source_st,dest_st; if (!update_only || stat(file,&source_st)==-1 // Not likely || stat(tmp.get(),&dest_st)==-1 // Not likely || source_st.st_size != dest_st.st_size){ if (cnv_str != NULL && cnv_str[0] != '\0'){ SSTRING cmd; cmd.setfromf ("convert %s %s %s",cnv_str,file,tmp.get()); diagui_flush(); (cmd.get(),10,true); return 0; fprintf (stderr,"err: %s\n",line); return 0; }else{ ret = (file,tmp.get()); *glocal.status = sofar*100/size; glocal.dia->reload(); diagui_flush(); } } } return ret; } static void photo_publish ( const char *dir, // Directory containing the photos SSTRINGS &dels, // Photos to exclude const char *destdir, // Target directory where we must // put the webpage and the photos bool pub_photos, // Copy photos bool pub_thumbs, // Copy thumbs bool update_only, // Copy only missing file (and different size) const char *cnv_str) // Argument for the convert program or NULL { glocal DIALOG dia; glocal SSTRING copying; // File being copied glocal SSTRING desc; // Description of the photo glocal int copying_status = 0; glocal int publish_status = 0; glocal const char *dir = dir; glocal const char *destdir = destdir; glocal SSTRINGS *dels = &dels; glocal bool pub_photos = pub_photos; glocal bool pub_thumbs = pub_thumbs; glocal bool update_only = update_only; glocal const char *cnv_str = cnv_str; glocal SSTRINGS photos; // List of jpg to publish glocal int nbphotos = 0; // How many files to copy (glocal.dir); if (strstr(basename,".jpg")!=NULL && strstr(basename,".th.jpg")==NULL && glocal.dels->lookup(basename)==-1){ glocal.nbphotos++; glocal.photos.add (new SSTRING(basename)); } glocal.dia.settype (DIATYPE_POPUP); glocal.dia.newf_str (MSG_U(F_SUBJECT,"Subject"),glocal.desc); glocal.dia.set_lastreadonly(); glocal.dia.newf_gauge ("",glocal.publish_status,glocal.nbphotos); glocal.dia.newf_str (MSG_U(F_FILE,"Copying file"),glocal.copying); glocal.dia.set_lastreadonly(); glocal.dia.newf_gauge ("",glocal.copying_status,100); int nof = 0; glocal.dia.show (MSG_U(F_PUBLISHING,"Publishing"),"",help_nil,nof,0); SSTRING tmp; tmp.setfromf ("%s/index.html",destdir); (tmp.get(),false); glocal FILE *fout = fout; fputs ("\n",fout); fputs ("\n",fout); fputs ("\n",fout); fputs ("\n",fout); SSTRING tmp; tmp.setfromf ("%s/description",glocal.dir); (tmp.get(),true); fputs (MSG_U(I_NODESC,"No description"),glocal.fout); if (noline == 0){ fprintf (glocal.fout,"

%s

\n",line); fputs ("

\n",glocal.fout); }else{ fprintf (glocal.fout,"%s\n",line); } return 0; fputs ("
\n",glocal.fout);
fputs ("\n",fout); glocal int rowcnt=0; for (int i=0; iget(); glocal SSTRING prec; glocal SSTRING next; glocal SSTRING name; glocal SSTRING file_image; glocal SSTRING file_html; glocal SSTRING file_txt; glocal SSTRING path; glocal SSTRING path_th; if (i!=0){ const char *pt = glocal.photos.getitem(i-1)->get(); int len = strlen(pt)-4; glocal.prec.setfromf ("%*.*s.html",len,len,pt); } if (i < glocal.photos.getnb()-1){ const char *pt = glocal.photos.getitem(i+1)->get(); int len = strlen(pt)-4; glocal.next.setfromf ("%*.*s.html",len,len,pt); } glocal.name.setfrom (basename,strlen(basename)-4); glocal.file_image.setfromf ("%s.jpg",glocal.name.get()); glocal.file_txt.setfromf ("%s/%s.txt",glocal.dir,glocal.name.get()); glocal.file_html.setfromf ("%s/%s.html",glocal.destdir,glocal.name.get()); glocal.path.setfromf ("%s/%s.jpg",glocal.dir,glocal.name.get()); glocal.path_th.setfromf ("%s/%s.th.jpg",glocal.dir,glocal.name.get()); if (glocal.rowcnt == 3){ fputs ("",glocal.fout); glocal.rowcnt = 0; } fputs ("\n"); glocal.publish_status++; glocal.dia.reload(); if (glocal.destdir != NULL){ // Copy the image and the thumbnail if (glocal.pub_photos){ photo_copy2dir (glocal.path.get(),glocal.destdir ,glocal.update_only ,glocal.dia,glocal.copying_status ,glocal.copying,glocal.cnv_str); } if (glocal.pub_thumbs){ photo_copy2dir (glocal.path_th.get(),glocal.destdir ,glocal.update_only ,glocal.dia,glocal.copying_status ,glocal.copying,NULL); } } } fputs ("
",glocal.fout); glocal.rowcnt++; fprintf (glocal.fout,"\n" ,glocal.name.get(),glocal.name.get()); fputs ("
\n",glocal.fout); // Create the large image html file (glocal.file_html.get(),false); glocal FILE *fout_html = fout; fputs ("\n",fout); fprintf (fout,"%s\n" ,MSG_U(I_INDEX,"Index")); if (glocal.prec.is_filled()){ fprintf (fout,"%s\n",glocal.prec.get() ,MSG_U(I_PREC,"Précédant")); } if (glocal.next.is_filled()){ fprintf (fout,"%s\n",glocal.next.get() ,MSG_U(I_NEXT,"Suivant")); } fputs ("

\n",fout); fputs ("

\n",fout); // Read the description associated with the file (glocal.file_txt.get(),false); glocal.desc.setfrom (MSG_U(I_NODESCRIPTION,"*** No description ***")); if (noline == 0){ glocal.desc.setfrom (line); glocal.desc.strip_end(); } // We limit description in the index html file if (noline < 4){ fputs (line,glocal.fout); }else if (noline == 4){ fputs ("...\n",glocal.fout); } fputs (line,glocal.fout_html); return 0; fputs ("
\n",fout); fputs ("

\n",fout); fprintf (fout,"

\n",glocal.name.get()); fputs ("\n",fout); return 0;
fprintf (glocal.fout,"
\n",fout); fputs ("\n",fout); fputs ("\n",fout); return 0;
}
static void photo_publish (const char *dir, SSTRINGS &dels) { DIALOG dia; SSTRING destdir; FIELD_COMBO *comb = dia.newf_combo (MSG_U(F_TARGETDIR,"Target directory") ,destdir); SSTRINGS tb; { linuxconf_getall (K_DIR,K_PUBLISH,tb,true); if (tb.getnb()==0){ SSTRING *s = new SSTRING; s->setfromf ("%s/n/html",getenv("HOME")); tb.add (s); } for (int i=0; iaddopt (tb.getitem(i)->get()); } } char export_photo = 1, export_thumbs = 1; dia.newf_chk (MSG_U(F_PUBLISH,"Publish"),export_photo ,MSG_U(I_PUBLISHPHOTOS,"photos")); dia.newf_chk (MSG_R(F_PUBLISH),export_thumbs ,MSG_U(I_PUBLISHTHUMBS,"thumbnails")); char copyonly = 1; dia.newf_chk (MSG_U(F_COPYONLY,"Copy only"),copyonly,MSG_U(I_COPYONLY,"modified files")); SSTRING cnv_str; cnv_str.setfrom ("-resize 1024x768"); dia.newf_str (MSG_U(F_CNV_STR,"Convert command argument"),cnv_str); dia.settype (DIATYPE_POPUP); if (dia.edit (MSG_U(T_PUBLISHDIR,"Publication directory"),"",help_nil) == MENU_ACCEPT){ if (tb.lookup(destdir.get())==-1){ tb.insert (0,new SSTRING(destdir)); } for (int i=10; i static int photo_import (SSTRING &dir) { SSTRING desc; dir.setfrom (photo_getarchive()); dir.setfrom (linuxconf_getval(K_DIR,K_IMPORT,dir.get())); DIALOG dia; dia.settype (DIATYPE_POPUP); FIELD_COMBO *comb = dia.newf_combo (MSG_R(F_DIRECTORY),dir,50); comb->addopt (photo_getarchive()); dia.newf_textarea (MSG_U(F_DESCRIPTION,"Description"),glocal.desc,50,10); int nof = 0; int ret = -1; while (1){ MENU_STATUS code = dia.edit (MSG_U(T_IMPORTDIR,"Import photos") ,MSG_U(I_IMPORTDIR ,"Enter the path of the directory where you want\n" "import the photos. The directory will be created as needed.\n" "Fill a description for the album.") ,help_nil ,nof); if (code == MENU_ESCAPE || code == MENU_CANCEL){ break; }else{ SSTRING cmd; // First we must know how many photos int nb; DIALOG dia; // Use to present the progress bars int thumbs; int images; bool importing_images; SSTRING errs; glocal.nb = 0; cmd.setfrom ("jphoto tree"); (cmd.get(),5,true); if (strcasestr(line,".jpg")!=NULL) glocal.nb++; return 0; glocal.thumbs = glocal.images = 0; glocal.importing_images = true; glocal.dia.newf_gauge (MSG_U(F_THUMBNAILS,"Thumb nails"),glocal.thumbs,glocal.nb); glocal.dia.newf_gauge (MSG_U(F_PHOTOS,"Photos"),glocal.images,glocal.nb); glocal.dia.settype (DIATYPE_POPUP); int nof=0; glocal.dia.show (MSG_U(T_IMPORTING,"Importing"),"",help_nil,nof,0); if (dir.get()[0] != '/'){ // Relative directory, turn it into absolute char cwd[PATH_MAX]; if (getcwd(cwd,sizeof(cwd)-1)!=NULL){ dir.setfromf ("%s/%s",cwd,dir.get()); } } cmd.setfromf ("%s %s",photo_getimport(),dir.get()); ret = (cmd.get(),20,true); if (strcmp(line,"#IMAGES")==0){ glocal.importing_images = true; }else if (strcmp(line,"#THUMBS")==0){ glocal.importing_images = false; }else if (strstr(line,".jpg")!=NULL){ if (glocal.importing_images){ glocal.images++; }else{ glocal.thumbs++; } glocal.dia.reload(); diagui_flush(); } return 0; glocal.errs.appendf ("%s\n",line); return 0; if (ret > 0 && glocal.errs.is_empty()){ SSTRING file; file.setfromf ("%s/description",dir.get()); (file.get(),false); fputs (glocal.desc.get(),fout); return 0; linuxconf_replace (K_DIR,K_IMPORT,dir.get()); linuxconf_save(); break; }else{ xconf_error (MSG_U(E_IMPORTFAIL,"Import failed:\n%s") ,glocal.errs.get()); } } } return ret; } struct PHOTO_ST{ PRIVATE_MESSAGE msg; // Click on photo; PRIVATE_MESSAGE del; // Click on the delete flag PRIVATE_MESSAGE pub; // Click on the publish flag bool published; // Is this photo published bool deleted; // Is this photo deleted SSTRING desc; // One line description SSTRING last; // Was this the last photo reviewed // Should be a small icon FIELD_BUTTON_ICON *fdel; // To change button content FIELD_BUTTON_ICON *fpub; PHOTO_ST(){ published = true; deleted = false; fpub = NULL; fdel = NULL; } }; int main (int argc, char *argv[]) { (argc,argv,"tlmpwork"); xconf_error ("%s",msg); glocal PRIVATE_MESSAGE loaddesc; (MSG_U(T_TLPHOTO,"TLMP Photo")); ("TLMP photo",TLMPWORK_VERSION,TLMPWORK_RELEASE); printf (MSG_U(I_ABOUT ,"This is TLMP photo\n" "\n" "This software is used to manage photos from a digital\n" "camera, documente them and publish albums on the internet\n")); printf ("Jacques Gélinas jack@solucorp.qc.ca\n"); setgpl(); printf (MSG_U(I_HOMESITE,"Home site http://www.solucorp.qc.ca/tlmp\n")); layout_area1(true); topmenu(MSG_U(M_FILE,"File")); menuentry (1,MSG_U(M_BROWSEDIR,"Browse directory")); menuentry (2,MSG_U(M_PREFER,"Preferences")); menuentry (3,MSG_U(M_CLOSE,"Close")); menuentry (99,MSG_U(M_QUIT,"Quit")); endmenu(); topmenu (MSG_U(M_CAMERA,"Camera")); menuentry (101,MSG_U(F_CAMINFO,"Camera info")); menuentry (102,MSG_U(F_CAMCONTENT,"Content")); menuentry (103,MSG_U(F_CAMFREE,"Flash usage")); menuentry (104,MSG_U(F_CAMTHUMB,"Import photos")); menuentry (105,MSG_U(F_ERASEFLASH,"Erase all pictures")); endmenu(); helpmenu(); endmenu(); if (id == 1){ DIALOG dia; dia.settype (DIATYPE_POPUP); SSTRING dir; dia.newf_str (MSG_U(F_DIRECTORY,"Directory"),dir,60); if (dia.edit ("","",help_nil)==MENU_ACCEPT){ newdocument (strdup(dir.get())); } }else if (id == 2){ photo_prefer(); }else if (id == 99){ end(); }else if (id == 101){ photo_showcmd ("jphoto status"); }else if (id == 102){ photo_showcmd ("jphoto tree"); }else if (id == 103){ photo_showcmd ("jphoto storage"); }else if (id == 104){ SSTRING dir; if (photo_import(dir) != -1){ dialog_sendmessage (glocal.loaddesc); newdocument (strdup(dir.get())); } }else if (id == 105){ } const char *dir = (const char *)info.data; glocal FRAMEWORK_INFO *info = &info; if (info.nbdocument==1){ glocal SSTRINGS dirs; (MSG_U(T_INDEX,"Index"),"",help_nil); newf_head (MSG_U(H_CATALOGS,"Catalogs\tDescription")); nobutton(); sortable(); sortpolicy ("aa"); waitfor(glocal.info->msgs.ending); waitfor(glocal.info->msgs.mayend); waitfor(glocal.loaddesc); if (glocal.FRAMEWORK.must_end(glocal.info->msgs)){ endedit(); } glocal.dirs.remove_all(); (photo_getarchive()); if (file_type(path)==1){ glocal.dirs.add (new SSTRING(relpath)); SSTRING descfile; descfile.setfromf ("%s/description",path); SSTRING desc; photo_loadfirstline (descfile.get(),desc); glocal.editrecords.new_menuitem (relpath,desc.get()); } const char *dir = glocal.dirs.getitem(no)->get(); char tmp[PATH_MAX]; sprintf (tmp,"%s/%s",photo_getarchive(),dir); if (uistate.rightb){ DIALOG_MENUPOPUP pop; pop.new_menuitem ("",MSG_R(M_EDIT)); pop.new_menuitem ("",MSG_U(M_PUBLISH,"Publish")); pop.new_menuitem ("",MSG_R(M_DELETE)); int sel = 0; if (pop.editmenu (NULL,sel)==MENU_OK){ if (sel == 0){ strcat (tmp,"/description"); photo_edittxt (tmp,*glocal.info,glocal.FRAMEWORK); }else if (sel == 1){ SSTRINGS dels; photo_publish(tmp,dels); }else if (sel == 2){ // Delete everything } } }else{ glocal.FRAMEWORK.newdocument ((void*)strdup(tmp)); } }else if (strstr (dir,".txt")!=NULL){ // A comment file if (photo_edittxt (dir,info,*this) != -1){ dialog_sendmessage(glocal.loaddesc); } }else{ // A directory glocal DIALOG dia; glocal SSTRINGS files; glocal const char *dir = dir; glocal int n = dir_getlist (dir,".jpg",glocal.files); glocal.dia.waitfor (glocal.loaddesc); info.msgs.waitfor (glocal.dia); diagui_seticonpath (dir); for (int i=0; iget(); if (strstr(s,".th")!=NULL){ glocal.files.remove_del(i); glocal.n--; i--; } } glocal PHOTO_ST *photos = new PHOTO_ST[glocal.n]; // Read the saved state of the publish buttons SSTRING notpub; notpub.setfromf ("%s/notpublished",dir); (notpub.get(),true); // This is ok, the file is optional int look = glocal.files.lookup(line); if (look != -1){ glocal.photos[look].published = false; } return 0; for (int i=0; i 0) glocal.dia.newline(); for (int j=i; jget(); SSTRING tmp; tmp.setfromf ("%s/%s.th.xpm",dir,file); if (file_exist(tmp.get())){ glocal.dia.new_button_icon (tmp.get(),file,st->msg); }else{ tmp.setfromf ("%s/%s.th.jpg",dir,file); if (file_exist(tmp.get())){ glocal.dia.new_button_icon (tmp.get(),file,st->msg); }else{ glocal.dia.new_button (file,"",st->msg); } } glocal.dia.gui_dispolast (GUI_H_CENTER,4,GUI_V_CENTER,1); } glocal.dia.newline(); for (int j=i; jget()); photo_loadfirstline (txt.get(),st->desc); st->desc.truncate(20); glocal.dia.newf_str (NULL,st->last,1); glocal.dia.set_lastreadonly(); glocal.dia.newf_str (NULL,st->desc,20); glocal.dia.set_lastreadonly(); st->fdel = glocal.dia.new_button_icon ("kept",MSG_U(B_DELETETHIS,"Delete photo"),st->del); st->fpub = glocal.dia.new_button_icon ( st->published ? "published" : "notpublished" ,MSG_U(B_PUBLISHTHIS,"Publish photo"),st->pub); } } int nof = 0; glocal.dia.setbutinfo (MENU_USR1,MSG_R(M_PUBLISH),MSG_R(M_PUBLISH)); glocal.dia.setbutinfo (MENU_USR2,MSG_U(B_COMMIT,"Commit deletion"),MSG_R(B_COMMIT)); glocal.dia.setbutinfo (MENU_USR3,MSG_U(B_ALL,"Publish all"),MSG_R(B_ALL)); glocal.dia.setbutinfo (MENU_USR4,MSG_U(B_NONE,"None"),MSG_R(B_NONE)); glocal.dia.setbutinfo (MENU_USR5,MSG_U(B_INDEX,"Index"),MSG_R(B_INDEX)); glocal.dia.waitfor (glocal.info->docmsgs.menubar); while (1){ MENU_STATUS code = glocal.dia.edit (dir,"",help_nil,nof ,MENUBUT_CANCEL|MENUBUT_USR1|MENUBUT_USR2 |MENUBUT_USR3|MENUBUT_USR4|MENUBUT_USR5); bool must_reload = false; if (code == MENU_ESCAPE || code == MENU_CANCEL){ break; }else if (code == MENU_MESSAGE){ if (must_end (info.msgs)){ break; }else if (dialog_testmessage(glocal.loaddesc)){ must_reload = true; }else if (dialog_testmessage(glocal.info->docmsgs.menubar)){ if (glocal.info->menuid == 3){ break; } }else{ for (int i=0; imsg)){ for (int j=0; jlast.setfrom (">"); glocal.dia.reload(); UISTATE uist; diajava_lastmousestate(uist); // fprintf (stderr,"uist %d %d %d shift %d\n",uist.leftb,uist.middleb,uist.rightb,uist.shiftkey); if (uist.shiftkey || uist.rightb){ DIALOG_MENUPOPUP pop; pop.new_menuitem ("",MSG_U(M_VIEW,"View")); pop.new_menuitem ("",MSG_U(M_EDIT,"Edit comment")); pop.new_menuitem ("",MSG_U(M_MODIFY,"Modify image")); pop.new_menuitem ("",MSG_U(M_DELETE,"Delete")); int sel = 0; if (pop.editmenu (NULL,sel)==MENU_OK){ SSTRING cmd; if (sel == 0){ // Show the photo cmd.setfromf ("%s %s/%s.jpg" ,photo_getviewcmd() ,dir,glocal.files.getitem(i)->get()); photo_execcmd(cmd.get(),true); }else if (sel == 1){ cmd.setfromf ("%s/%s.txt" ,dir,glocal.files.getitem(i)->get()); newdocument (strdup(cmd.get())); }else if (sel == 2){ // Modify cmd.setfromf ("gimp %s/%s.jpg" ,dir,glocal.files.getitem(i)->get()); photo_execcmd(cmd.get(),true); }else if (sel == 3){ st->deleted = ! st->deleted; st->fdel->seticon (st->deleted ? "deleted" : "kept"); } } }else{ // Show the photo SSTRING cmd; cmd.setfromf ("%s %s/%s.jpg" ,photo_getviewcmd() ,dir,glocal.files.getitem(i)->get()); photo_execcmd(cmd.get(),true); } break; }else if (dialog_testmessage(st->del)){ st->deleted = ! st->deleted; st->fdel->seticon (st->deleted ? "deleted" : "kept"); }else if (dialog_testmessage(st->pub)){ st->published = ! st->published; st->fpub->seticon (st->published ? "published" : "notpublished"); (notpub.get(),false); for (int i=0; iget()); } } return 0; } } } }else if (code == MENU_USR1){ SSTRINGS dels; for (int i=0; ipublished){ SSTRING *s = new SSTRING; s->setfromf ("%s.jpg",glocal.files.getitem(i)->get()); dels.add (s); } } photo_publish (dir,dels); }else if (code == MENU_USR2){ for (int i=0; ideleted){ for (int j=0; j<3; j++){ SSTRING cmd; static const char *exts[]={"jpg","th.jpg","txt"}; cmd.setfromf ("%s/%s.%s" ,dir,glocal.files.getitem(i)->get(),exts[j]); unlink (cmd.get()); } } } break; }else if (code == MENU_USR3 || code == MENU_USR4){ for (int i=0; ipublished = code == MENU_USR3; st->fpub->seticon (code == MENU_USR3 ? "published" : "notpublished"); } }else if (code == MENU_USR5){ // Build the index.html file in the photo directory SSTRING indexfile; indexfile.setfromf ("%s/index.html",dir); (indexfile.get(),false); fprintf (fout,"\n"); fprintf (fout,"\n"); fprintf (fout,"\n"); for (int i=0; i\n"); for (int j=i; jget(); fprintf (fout,"\n"); } fprintf (fout,"\n"); } fprintf (fout,"\n"); fprintf (fout,"\n"); xconf_notice (MSG_U(I_INDEXDONE,"File %s was created") ,fname); return 0; } if (must_reload){ for (int i=0; iget()); photo_loadfirstline (txt.get(),st->desc); st->desc.truncate(20); } glocal.dia.reload(); } } delete [] glocal.photos; } free ((void*)dir); fram.newdocument (); fram.loop(); photo_deltmpdir(); return 0; }

" ,name,name); FILE *fout; glocal.fout = fout; SSTRING txt; txt.setfromf ("%s/%s.txt",glocal.dir,name); (txt.get(),true); fprintf (glocal.fout,"%s\n",line); return -1; fprintf (fout,"