CHDK_DE Vorschauversion  Trunk Rev. 6014
 Alle Datenstrukturen Dateien Funktionen Variablen Typdefinitionen Aufzählungen Aufzählungswerte Makrodefinitionen
gui_fselect.c-Dateireferenz
#include "camera_info.h"
#include "keyboard.h"
#include "modes.h"
#include "sd_card.h"
#include "debug_led.h"
#include "lang.h"
#include "gui.h"
#include "gui_draw.h"
#include "gui_lang.h"
#include "gui_mbox.h"
#include "raw.h"
#include "conf.h"
#include "time.h"
#include "dirent.h"
#include "ctype.h"
#include "gui_fselect.h"
#include "raw_merge.h"
#include "dng.h"
#include "gui_mpopup.h"
#include "gui_tbox.h"
#include "gui_read.h"
#include "module_load.h"
+ Include-Abhängigkeitsdiagramm für gui_fselect.c:

gehe zum Quellcode dieser Datei

Datenstrukturen

struct  _fitem
 
struct  flist
 
struct  fs_dirent
 

Makrodefinitionen

#define BODY_LINES   12
 
#define BODY_FONT_LINES   BODY_LINES * FONT_HEIGHT
 
#define NAME_SIZE   camera_screen.fselect_name_size
 
#define SIZE_SIZE   camera_screen.fselect_size_size
 
#define TIME_SIZE   camera_screen.fselect_time_size
 
#define NAME_FONT_SIZE   NAME_SIZE * FONT_WIDTH
 
#define EXTE_FONT_SIZE   EXTE_SIZE * FONT_WIDTH
 
#define SIZE_FONT_SIZE   SIZE_SIZE * FONT_WIDTH
 
#define TIME_FONT_SIZE   TIME_SIZE * FONT_WIDTH
 
#define SPACING   4
 
#define TAB_DIVIDER   1
 
#define BORDER   2
 
#define SCROLLBAR   4
 
#define MARKED_OP_NONE   0
 
#define MARKED_OP_CUT   1
 
#define MARKED_OP_COPY   2
 
#define MAX_PATH_LEN   100
 
#define MAIN_H   (FONT_HEIGHT + TAB_DIVIDER + BODY_FONT_LINES + TAB_DIVIDER + FONT_HEIGHT)
 
#define MPOPUP_CUT   0x0001
 
#define MPOPUP_COPY   0x0002
 
#define MPOPUP_PASTE   0x0004
 
#define MPOPUP_DELETE   0x0008
 
#define MPOPUP_SELINV   0x0010
 
#define MPOPUP_RAWOPS   0x0020
 
#define MPOPUP_PURGE_DCIM   0x0040
 
#define MPOPUP_PURGE_DIR   0x0080
 
#define MPOPUP_PURGE_FILE   0x0100
 
#define MPOPUP_RMDIR   0x0200
 
#define MPOPUP_MKDIR   0x0400
 
#define MPOPUP_RENAME   0x0800
 
#define MPOPUP_EDITOR   0x1000
 
#define MPOPUP_CHDK_REPLACE   0x2000
 
#define MPOPUP_RAW_ADD   0x0020
 
#define MPOPUP_RAW_AVERAGE   0x0040
 
#define MPOPUP_SUBTRACT   0x0100
 
#define MPOPUP_RAW_DEVELOP   0x0200
 
#define MPOPUP_DNG_TO_CRW   0x0400
 
#define COPY_BUF_SIZE   16384
 
#define MAX_SUB_NAMES   6
 

Typdefinitionen

typedef struct _fitem fitem
 

Funktionen

int gui_fselect_kbd_process ()
 
void gui_fselect_kbd_process_menu_btn ()
 
void gui_fselect_draw (int enforce_redraw)
 
static void free_list (flist *list)
 
static void add_item (flist *list, const char *name, unsigned long size, unsigned long mtime, unsigned char marked, unsigned char isdir, unsigned char isparent, unsigned char isvalid)
 
int fselect_sort (const void *v1, const void *v2)
 
static void sort_list (flist *list)
 
static int chk_ext (const char *ext, const char *tst)
 
static int chk_prefix (const char *name, const char *prefix)
 
static int chk_name (const char *name, const char *tst)
 
static int is_parent (const char *name)
 
static int is_current (const char *name)
 
static int is_raw (const char *name)
 
static int is_jpg (const char *name)
 
static void delete_file (const char *path, const char *name)
 
static void delete_dir (const char *path)
 
static DIRopendir_fselect (const char *path)
 
static int copy_file (const char *src_dir, const char *src_file, const char *dst_dir, const char *dst_file, int overwrite)
 
static int fs_readdir (DIR *d, fs_dirent *de, const char *path)
 
static void process_dir (const char *parent, const char *name, int nested, void(*file_process)(const char *path, const char *file), void(*dir_process)(const char *path))
 
static void fselect_goto_prev (int step)
 
static void fselect_goto_next (int step)
 
static void gui_fselect_free_data ()
 
static void gui_fselect_read_dir ()
 
int gui_fselect_find_start_dir (const char *dir)
 
void gui_fselect_init (int title, const char *prev_dir, const char *default_dir, void(*on_select)(const char *fn))
 
static void fselect_delete_file_cb (unsigned int btn)
 
static int find_jpg (const char *folder, const char *match, int nested)
 
static void purge_file (const char *folder, const char *file)
 
static void purge_file_DCIM (const char *folder, const char *file)
 
static void fselect_purge_cb_DCIM (unsigned int btn)
 
static void fselect_purge_cb_dir (unsigned int btn)
 
static void fselect_purge_cb_file (unsigned int btn)
 
static void fselect_delete_folder_cb (unsigned int btn)
 
static void confirm_delete_directory ()
 
static void fselect_marked_toggle ()
 
static void gui_fselect_marked_free_data ()
 
static void fselect_marked_copy_list ()
 
static void fselect_marked_paste_cb (unsigned int btn)
 
static unsigned int fselect_real_marked_count ()
 
static unsigned int fselect_marked_count ()
 
static void fselect_marked_delete_cb (unsigned int btn)
 
static void fselect_chdk_replace_cb (unsigned int btn)
 
static void fselect_marked_inverse_selection ()
 
void process_raw_files (void)
 
static void fselect_subtract_cb (unsigned int btn)
 
static void setup_batch_subtract (void)
 
void process_dng_to_raw_files (void)
 
static void fselect_mpopup_rawop_cb (unsigned int actn)
 
static void mkdir_cb (const char *name)
 
static void rename_cb (const char *name)
 
static int isPurgeDCIM ()
 
static int isPurgeDir ()
 
static void fselect_mpopup_cb (unsigned int actn)
 
void finalize_fselect ()
 
static void exit_fselect (char *file)
 
int _module_unloader ()
 
int _module_can_unload ()
 
int _module_exit_alt ()
 

Variablen

gui_handler GUI_MODE_FSELECT_MODULE
 
static int running = 0
 
static gui_handlergui_fselect_mode_old
 
static char selected_file [MAX_PATH_LEN]
 
static char buf [MAX_PATH_LEN]
 
static flist items
 
static flist marked_items
 
static fitemtop
 
static fitemselected
 
static char marked_operation
 
static coord main_x
 
static coord main_y
 
static coord main_w
 
static coord body_y
 
static coord foot_y
 
static int gui_fselect_redraw
 
static int gui_fselect_readdir
 
static char * fselect_title
 
static void(* fselect_on_select )(const char *fn)
 
static char raw_operation
 
static struct mpopup_item popup []
 
static struct mpopup_item popup_rawop []
 
static unsigned char * ubuf = 0
 
static int mpopup_rawop_flag
 
libfselect_sym _libfselect
 
ModuleInfo _module_info
 

Makro-Dokumentation

#define BODY_FONT_LINES   BODY_LINES * FONT_HEIGHT

Definiert in Zeile 39 der Datei gui_fselect.c.

#define BODY_LINES   12

Definiert in Zeile 38 der Datei gui_fselect.c.

#define BORDER   2

Definiert in Zeile 52 der Datei gui_fselect.c.

#define COPY_BUF_SIZE   16384

Definiert in Zeile 377 der Datei gui_fselect.c.

#define EXTE_FONT_SIZE   EXTE_SIZE * FONT_WIDTH

Definiert in Zeile 46 der Datei gui_fselect.c.

Definiert in Zeile 103 der Datei gui_fselect.c.

#define MARKED_OP_COPY   2

Definiert in Zeile 57 der Datei gui_fselect.c.

#define MARKED_OP_CUT   1

Definiert in Zeile 56 der Datei gui_fselect.c.

#define MARKED_OP_NONE   0

Definiert in Zeile 55 der Datei gui_fselect.c.

#define MAX_PATH_LEN   100

Definiert in Zeile 64 der Datei gui_fselect.c.

#define MAX_SUB_NAMES   6

Definiert in Zeile 1269 der Datei gui_fselect.c.

#define MPOPUP_CHDK_REPLACE   0x2000

Definiert in Zeile 130 der Datei gui_fselect.c.

#define MPOPUP_COPY   0x0002

Definiert in Zeile 118 der Datei gui_fselect.c.

#define MPOPUP_CUT   0x0001

Definiert in Zeile 117 der Datei gui_fselect.c.

#define MPOPUP_DELETE   0x0008

Definiert in Zeile 120 der Datei gui_fselect.c.

#define MPOPUP_DNG_TO_CRW   0x0400

Definiert in Zeile 154 der Datei gui_fselect.c.

#define MPOPUP_EDITOR   0x1000

Definiert in Zeile 129 der Datei gui_fselect.c.

#define MPOPUP_MKDIR   0x0400

Definiert in Zeile 127 der Datei gui_fselect.c.

#define MPOPUP_PASTE   0x0004

Definiert in Zeile 119 der Datei gui_fselect.c.

#define MPOPUP_PURGE_DCIM   0x0040

Definiert in Zeile 123 der Datei gui_fselect.c.

#define MPOPUP_PURGE_DIR   0x0080

Definiert in Zeile 124 der Datei gui_fselect.c.

#define MPOPUP_PURGE_FILE   0x0100

Definiert in Zeile 125 der Datei gui_fselect.c.

#define MPOPUP_RAW_ADD   0x0020

Definiert in Zeile 150 der Datei gui_fselect.c.

#define MPOPUP_RAW_AVERAGE   0x0040

Definiert in Zeile 151 der Datei gui_fselect.c.

#define MPOPUP_RAW_DEVELOP   0x0200

Definiert in Zeile 153 der Datei gui_fselect.c.

#define MPOPUP_RAWOPS   0x0020

Definiert in Zeile 122 der Datei gui_fselect.c.

#define MPOPUP_RENAME   0x0800

Definiert in Zeile 128 der Datei gui_fselect.c.

#define MPOPUP_RMDIR   0x0200

Definiert in Zeile 126 der Datei gui_fselect.c.

#define MPOPUP_SELINV   0x0010

Definiert in Zeile 121 der Datei gui_fselect.c.

#define MPOPUP_SUBTRACT   0x0100

Definiert in Zeile 152 der Datei gui_fselect.c.

#define NAME_FONT_SIZE   NAME_SIZE * FONT_WIDTH

Definiert in Zeile 45 der Datei gui_fselect.c.

#define NAME_SIZE   camera_screen.fselect_name_size

Definiert in Zeile 41 der Datei gui_fselect.c.

#define SCROLLBAR   4

Definiert in Zeile 53 der Datei gui_fselect.c.

#define SIZE_FONT_SIZE   SIZE_SIZE * FONT_WIDTH

Definiert in Zeile 47 der Datei gui_fselect.c.

#define SIZE_SIZE   camera_screen.fselect_size_size

Definiert in Zeile 42 der Datei gui_fselect.c.

#define SPACING   4

Definiert in Zeile 50 der Datei gui_fselect.c.

#define TAB_DIVIDER   1

Definiert in Zeile 51 der Datei gui_fselect.c.

#define TIME_FONT_SIZE   TIME_SIZE * FONT_WIDTH

Definiert in Zeile 48 der Datei gui_fselect.c.

#define TIME_SIZE   camera_screen.fselect_time_size

Definiert in Zeile 43 der Datei gui_fselect.c.

Dokumentation der benutzerdefinierten Typen

typedef struct _fitem fitem

Dokumentation der Funktionen

int _module_can_unload ( )

Definiert in Zeile 1662 der Datei gui_fselect.c.

1663 {
1664  return running == 0;
1665 }
int _module_exit_alt ( )

Definiert in Zeile 1667 der Datei gui_fselect.c.

1668 {
1669  exit_fselect(0);
1670  return 0;
1671 }
int _module_unloader ( )

Definiert in Zeile 1650 der Datei gui_fselect.c.

1651 {
1652  // Free file copy buffer if allocated
1653  if (ubuf)
1654  {
1655  ufree(ubuf);
1656  ubuf = 0;
1657  }
1658  finalize_fselect();
1659  return 0;
1660 }
static void add_item ( flist list,
const char *  name,
unsigned long  size,
unsigned long  mtime,
unsigned char  marked,
unsigned char  isdir,
unsigned char  isparent,
unsigned char  isvalid 
)
static

Definiert in Zeile 183 der Datei gui_fselect.c.

186 {
187  fitem *p = malloc(sizeof(fitem) + strlen(name));
188  if (p)
189  {
190  p->n = list->count;
191  strcpy(p->name, name);
192  p->size = size;
193  p->mtime = mtime;
194  p->marked = marked;
195  p->isdir = isdir;
196  p->isparent = isparent;
197  p->isvalid = isvalid;
198 
199  p->next = 0;
200  p->prev = list->tail;
201  if (list->tail)
202  list->tail->next = p;
203  list->tail = p;
204  if (list->head == 0)
205  list->head = p;
206 
207  list->count++;
208  }
209 }
static int chk_ext ( const char *  ext,
const char *  tst 
)
static

Definiert in Zeile 291 der Datei gui_fselect.c.

292 {
293  if (ext && (*ext != '.')) // if passed file name, find extension
294  ext = strrchr(ext, '.');
295  if (ext)
296  {
297  ext++;
298  if (strlen(ext) == strlen(tst))
299  {
300  int i;
301  for (i=0; i<strlen(tst); i++)
302  if (toupper(ext[i]) != toupper(tst[i]))
303  return 0;
304  return 1;
305  }
306  }
307  return 0;
308 }
static int chk_name ( const char *  name,
const char *  tst 
)
static

Definiert in Zeile 325 der Datei gui_fselect.c.

326 {
327  if (name && (strlen(name) == strlen(tst)))
328  {
329  int i;
330  for (i=0; i<strlen(tst); i++)
331  if (toupper(tst[i]) != toupper(name[i]))
332  return 0;
333  return 1;
334  }
335  return 0;
336 }
static int chk_prefix ( const char *  name,
const char *  prefix 
)
static

Definiert in Zeile 311 der Datei gui_fselect.c.

312 {
313  if (name && (strlen(name) >= strlen(prefix)))
314  {
315  int i;
316  for (i=0; i<strlen(prefix); i++)
317  if (toupper(prefix[i]) != toupper(name[i]))
318  return 0;
319  return 1;
320  }
321  return 0;
322 }
static void confirm_delete_directory ( )
static
static int copy_file ( const char *  src_dir,
const char *  src_file,
const char *  dst_dir,
const char *  dst_file,
int  overwrite 
)
static

Definiert in Zeile 379 der Datei gui_fselect.c.

380 {
381  int rv = 0;
382 
383  // If source and destination are the same abort (and fail) copy operation
384  if (chk_name(src_dir, dst_dir) && chk_name(src_file, dst_file))
385  return 0;
386 
387  // Get source path and open file
388  sprintf(selected_file, "%s/%s", src_dir, src_file);
389  int fsrc = open(selected_file, O_RDONLY, 0777);
390 
391  if (fsrc >= 0)
392  {
393  // Get destination path, check for overwrite, and open file
394  sprintf(selected_file,"%s/%s", dst_dir, dst_file);
395  if (!overwrite)
396  {
397  struct stat st;
398  if (stat(selected_file, &st) == 0)
399  {
400  close(fsrc);
401  // destination exists, and overwrite not selected, copy failed
402  return 0;
403  }
404  }
405  int fdst = open(selected_file, O_WRONLY|O_CREAT|O_TRUNC, 0777);
406 
407  if (fdst >= 0)
408  {
409  int ss, sd = 0;
410 
411  // Allocate buffer if not already allocated
412  if (ubuf == 0)
413  {
415  if (ubuf == 0)
416  {
417  // umalloc failed - ToDo this should display an error popup?
418  close(fdst);
419  close(fsrc);
420  return 0;
421  }
422  }
423 
424  // Copy contents
425  do
426  {
427  ss = read(fsrc, ubuf, COPY_BUF_SIZE);
428  if (ss > 0)
429  sd = write(fdst, ubuf, ss);
430  } while (ss > 0 && ss == sd);
431 
432  if (ss == 0)
433  rv = 1;
434 
435  close(fdst);
436 
437  struct utimbuf t;
438  t.actime = t.modtime = selected->mtime;
439  utime(selected_file, &t);
440  }
441 
442  close(fsrc);
443  }
444 
445  return rv;
446 }
static void delete_dir ( const char *  path)
static

Definiert in Zeile 364 der Datei gui_fselect.c.

365 {
366  remove(path);
367 }
static void delete_file ( const char *  path,
const char *  name 
)
static

Definiert in Zeile 358 der Datei gui_fselect.c.

359 {
360  sprintf(selected_file, "%s/%s", path, name);
361  remove(selected_file);
362 }
static void exit_fselect ( char *  file)
static

Definiert in Zeile 1459 der Datei gui_fselect.c.

1460 {
1461  finalize_fselect();
1462 
1464 
1465  // call callback if set. file will be null if canceled (menu or leaving alt)
1466  if (fselect_on_select)
1467  {
1468  fselect_on_select(file);
1469  // if called mode will return control to filemanager - we need to redraw it
1470  gui_fselect_redraw = 2;
1471  }
1472 
1473  running = 0;
1474 }
void finalize_fselect ( )

Definiert in Zeile 1453 der Datei gui_fselect.c.

1454 {
1457 }
static int find_jpg ( const char *  folder,
const char *  match,
int  nested 
)
static

Definiert in Zeile 942 der Datei gui_fselect.c.

943 {
944  DIR *d;
945  fs_dirent de;
946  int rv = 0;
947 
948  // Open directory
949  d = opendir_fselect(folder);
950 
951  if (d)
952  {
953  // Process contents
954  while (fs_readdir(d, &de, folder) && !rv)
955  {
956  if (!de.deleted)
957  {
958  // Sub directory? Process recursively (but only 'nested' levels deep)
959  if (de.isdir)
960  {
961  if (!de.isparent && !de.iscurrent && nested)
962  {
963  // Search sub-directory
964  char *path = malloc(strlen(folder) + strlen(de.de->d_name) + 2);
965  sprintf(path, "%s/%s", folder, de.de->d_name);
966  if (find_jpg(path, match, nested-1))
967  rv = 1;
968  free(path);
969  }
970  }
971  else
972  {
973  //If the four digits of the Canon number are the same AND file is JPG
974  if (is_jpg(de.de->d_name) && (strncmp(match+4, de.de->d_name+4, 4) == 0))
975  rv = 1;
976  }
977  }
978  }
979  closedir(d);
980  }
981 
982  return rv;
983 }
static void free_list ( flist list)
static

Definiert in Zeile 168 der Datei gui_fselect.c.

169 {
170  fitem *ptr = list->head;
171 
172  while (ptr)
173  {
174  fitem *prev = ptr;
175  ptr = ptr->next;
176  free(prev);
177  }
178 
179  list->head = list->tail = 0;
180  list->count = 0;
181 }
static int fs_readdir ( DIR d,
fs_dirent de,
const char *  path 
)
static

Definiert in Zeile 466 der Datei gui_fselect.c.

467 {
468  // DO NOT USE 'selected_file' global var.
469  // This function is called from GUI task, 'selected_file' is used by 'KBD' task
470  char pbuf[MAX_PATH_LEN];
471 
472  de->de = readdir(d);
473  de->size = 0;
474  de->mtime = 0;
475  de->deleted = 0;
476  de->isparent = 0;
477  de->iscurrent = 0;
478  de->isdir = 0;
479  de->isvalid = 0;
480  de->ishidden = 0;
481 
482  if (de->de)
483  {
484  if (de->de->d_name[0] == 0xE5)
485  {
486  de->deleted = 1;
487  }
488  else
489  {
490  de->isparent = is_parent(de->de->d_name);
491  de->iscurrent = is_current(de->de->d_name);
492 
493  sprintf(pbuf, "%s/%s", path, de->de->d_name);
494  struct stat st;
495  if (de->isparent || de->iscurrent)
496  {
497  de->isdir = 1;
498  de->isvalid = 1;
499  }
500  else if (stat(pbuf, &st) == 0)
501  {
502  de->size = st.st_size;
503  de->mtime = st.st_mtime;
504  de->isvalid = 1;
505  de->isdir = ((st.st_attrib & DOS_ATTR_DIRECTORY) != 0);
506  de->ishidden = ((st.st_attrib & DOS_ATTR_HIDDEN) != 0);
507  }
508  }
509 
510  return 1;
511  }
512 
513  return 0;
514 }
static void fselect_chdk_replace_cb ( unsigned int  btn)
static

Definiert in Zeile 1213 der Datei gui_fselect.c.

1214 {
1215  if (btn == MBOX_BTN_YES)
1216  {
1217  copy_file(items.dir, selected->name, "A", "DISKBOOT.BIN", 1);
1218  gui_browser_progress_show("Please reboot",100);
1219  }
1220 }
static void fselect_delete_file_cb ( unsigned int  btn)
static

Definiert in Zeile 927 der Datei gui_fselect.c.

928 {
929  if (btn==MBOX_BTN_YES)
930  {
931  started();
933  finished();
935  }
936  gui_fselect_redraw = 2;
937 }
static void fselect_delete_folder_cb ( unsigned int  btn)
static

Definiert in Zeile 1064 der Datei gui_fselect.c.

1065 {
1066  if (btn==MBOX_BTN_YES)
1067  {
1069  gui_fselect_readdir = 1;
1070  }
1071  gui_fselect_redraw = 2;
1072 }
static void fselect_goto_next ( int  step)
static

Definiert in Zeile 593 der Datei gui_fselect.c.

594 {
595  int j;
596  for (j=0; j<step; ++j)
597  {
598  if (selected->next)
599  {
600  selected = selected->next; // next line
601  if (((selected->n - top->n) == (BODY_LINES - 1)) && selected->next)
602  top = top->next;
603  }
604  else if (step == 1)
605  {
606  selected = top = items.head; // off bottom - jump to top
607  }
608  }
609 }
static void fselect_goto_prev ( int  step)
static

Definiert in Zeile 570 der Datei gui_fselect.c.

571 {
572  int j;
573 
574  for (j=0; j<step; ++j)
575  {
576  if (selected->prev)
577  {
578  selected = selected->prev; // previous line
579  if (selected == top && top->prev)
580  top = top->prev;
581  }
582  else if (step == 1)
583  {
584  // off top - jump to bottom
585  selected = top = items.tail;
586  while (((selected->n - top->n) < (BODY_LINES - 1)) && top->prev)
587  top = top->prev;
588  }
589  }
590 }
static void fselect_marked_copy_list ( )
static

Definiert in Zeile 1098 der Datei gui_fselect.c.

1099 {
1101 
1102  fitem *ptr;
1103 
1104  for (ptr=items.head; ptr; ptr=ptr->next)
1105  if (ptr->marked)
1106  add_item(&marked_items, ptr->name, ptr->size, ptr->mtime, 1, ptr->isdir, ptr->isparent, ptr->isvalid);
1107 
1108  if (!marked_items.count)
1109  if (selected && selected->isvalid && !selected->isdir)
1111 
1113 }
static unsigned int fselect_marked_count ( )
static

Definiert in Zeile 1169 der Datei gui_fselect.c.

1170 {
1171  register unsigned int cnt = fselect_real_marked_count();
1172 
1173  if (!cnt)
1174  {
1175  if (selected && selected->isvalid && !selected->isdir)
1176  ++cnt;
1177  }
1178 
1179  return cnt;
1180 }
static void fselect_marked_delete_cb ( unsigned int  btn)
static

Definiert in Zeile 1183 der Datei gui_fselect.c.

1184 {
1185  fitem *ptr;
1186  unsigned int del_cnt=0, cnt;
1187 
1188  if (btn != MBOX_BTN_YES) return;
1189 
1190  cnt = fselect_marked_count();
1191  for (ptr=items.head; ptr; ptr=ptr->next)
1192  if (ptr->marked && ptr->isvalid && !ptr->isdir)
1193  {
1194  started();
1195  ++del_cnt;
1196  if (cnt)
1198  delete_file(items.dir, ptr->name);
1199  finished();
1200  }
1201 
1202  if (del_cnt == 0 && selected)
1203  {
1204  started();
1206  finished();
1207  }
1208  gui_fselect_readdir = 1;
1209  gui_fselect_redraw = 2;
1210 }
static void fselect_marked_inverse_selection ( )
static

Definiert in Zeile 1223 der Datei gui_fselect.c.

1224 {
1225  fitem *ptr;
1226 
1227  for (ptr=items.head; ptr; ptr=ptr->next)
1228  if (ptr->isvalid && !ptr->isdir)
1229  ptr->marked = !ptr->marked;
1230 
1231  gui_fselect_redraw = 2;
1232 }
static void fselect_marked_paste_cb ( unsigned int  btn)
static

Definiert in Zeile 1116 der Datei gui_fselect.c.

1117 {
1118  fitem *ptr;
1119  int i = 0;
1120 
1121  if (btn != MBOX_BTN_YES) return;
1122 
1123  if (strcmp(marked_items.dir, items.dir) != 0)
1124  {
1125  for (ptr=marked_items.head; ptr; ptr=ptr->next)
1126  {
1127  if (ptr->isvalid && !ptr->isdir)
1128  {
1129  started();
1130 
1131  ++i;
1132  if (marked_items.count)
1134 
1135  int copied = copy_file(marked_items.dir, ptr->name, items.dir, ptr->name, 0);
1136 
1137  if (copied && (marked_operation == MARKED_OP_CUT))
1138  {
1140  }
1141 
1142  finished();
1143  }
1144  }
1146  {
1148  }
1149  gui_fselect_readdir = 1;
1150  }
1151  gui_fselect_redraw = 2;
1152 }
static void fselect_marked_toggle ( )
static

Definiert in Zeile 1082 der Datei gui_fselect.c.

1083 {
1084  if (selected && selected->isvalid && !selected->isdir)
1085  {
1087  }
1088 }
static void fselect_mpopup_cb ( unsigned int  actn)
static

Definiert in Zeile 1388 der Datei gui_fselect.c.

1389 {
1390  switch (actn)
1391  {
1392  case MPOPUP_CUT:
1395  break;
1396  case MPOPUP_COPY:
1399  break;
1400  case MPOPUP_PASTE:
1404  break;
1405  case MPOPUP_DELETE:
1409  break;
1410  case MPOPUP_RMDIR:
1412  break;
1413  case MPOPUP_MKDIR:
1415  break;
1416  case MPOPUP_RENAME:
1418  break;
1419  case MPOPUP_PURGE_DCIM:
1420  //If selected folder is A/DCIM or A/RAW (this is to purge all RAW files in any sub-folder)
1422  break;
1423  case MPOPUP_PURGE_DIR:
1424  //If selected item is a Canon folder
1426  break;
1427  case MPOPUP_PURGE_FILE:
1428  //If selected item is a file produced by the camera
1430  break;
1431  case MPOPUP_SELINV:
1433  break;
1434  case MPOPUP_CANCEL:
1435  break;
1436 
1437  case MPOPUP_RAWOPS:
1439  break;
1440 
1441  case MPOPUP_CHDK_REPLACE:
1442  gui_mbox_init((int)"Replacing CHDK", (int)"Do you want to replace current CHDK with this file",
1444  break;
1445  case MPOPUP_EDITOR:
1446  gui_mbox_init((int)"Editor", (int)"edit", MBOX_BTN_OK|MBOX_TEXT_CENTER, NULL);
1447  break;
1448  }
1449  gui_fselect_redraw = 2;
1450 }
static void fselect_mpopup_rawop_cb ( unsigned int  actn)
static

Definiert in Zeile 1326 der Datei gui_fselect.c.

1327 {
1328  switch (actn) {
1329  case MPOPUP_RAW_AVERAGE:
1332  break;
1333  case MPOPUP_RAW_ADD:
1336  break;
1337  case MPOPUP_RAW_DEVELOP:
1338  sprintf(buf, "%s/%s", items.dir, selected->name);
1340  break;
1341  case MPOPUP_SUBTRACT:
1343  break;
1344  case MPOPUP_DNG_TO_CRW:
1346  break;
1347  }
1348 }
static void fselect_purge_cb_DCIM ( unsigned int  btn)
static

Definiert in Zeile 1007 der Datei gui_fselect.c.

1008 {
1009  if (btn == MBOX_BTN_YES)
1010  {
1011  //If selected folder is A/DCIM or A/RAW (this is to purge all RAW files in any sub-folder)
1013  }
1014 }
static void fselect_purge_cb_dir ( unsigned int  btn)
static

Definiert in Zeile 1016 der Datei gui_fselect.c.

1017 {
1018  if (btn == MBOX_BTN_YES)
1019  {
1020  //If item is a Canon sub-folder of A/DCIM or A/RAW (this is to purge all RAW files inside a single Canon folder)
1022  }
1023 }
static void fselect_purge_cb_file ( unsigned int  btn)
static

Definiert in Zeile 1025 der Datei gui_fselect.c.

1026 {
1027  if (btn == MBOX_BTN_YES)
1028  {
1029  //Inside a Canon folder (files list)
1030  fitem *ptr, *ptr2;
1031 
1032  //Loop to find all the RAW files in the list
1033  for (ptr=items.head; ptr; ptr=ptr->next)
1034  {
1035  //If file is RAW (Either CRW/CR2 prefix or file extension) and is not marked
1036  if (is_raw(ptr->name) && !ptr->marked)
1037  {
1038  // Flag for checking if matching JPG exists
1039  int found = 0;
1040 
1041  //Loop to find a corresponding JPG file in the list
1042  for (ptr2=items.head; ptr2; ptr2=ptr2->next)
1043  {
1044  //If this is a JPG and the four digits of the Canon number are the same
1045  if (is_jpg(ptr2->name) && (strncmp(ptr->name+4, ptr2->name+4, 4) == 0))
1046  {
1047  found=1;
1048  break;
1049  }
1050  }
1051 
1052  //If no JPG found, delete RAW file
1053  if (found == 0)
1054  delete_file(items.dir, ptr->name);
1055  }
1056  }
1057  gui_fselect_readdir = 1;
1058  }
1059  gui_fselect_redraw = 2;
1060 }
static unsigned int fselect_real_marked_count ( )
inlinestatic

Definiert in Zeile 1155 der Datei gui_fselect.c.

1156 {
1157  fitem *ptr;
1158  register unsigned int cnt = 0;
1159 
1160  for (ptr=items.head; ptr; ptr=ptr->next)
1161  {
1162  if (ptr->isvalid && !ptr->isdir && ptr->marked)
1163  ++cnt;
1164  }
1165  return cnt;
1166 }
int fselect_sort ( const void *  v1,
const void *  v2 
)

Definiert in Zeile 211 der Datei gui_fselect.c.

212 {
213  fitem *i1 = *((fitem **)v1);
214  fitem *i2 = *((fitem **)v2);
215 
216  if (i1->isdir)
217  {
218  if (i2->isdir)
219  {
220  if (i1->isparent)
221  {
222  return -1;
223  }
224  else if (i2->isparent)
225  {
226  return 1;
227  }
228  else
229  {
230  return strcmp(i1->name, i2->name);
231  }
232  }
233  else
234  {
235  return -1;
236  }
237  }
238  else
239  {
240  if (i2->isdir)
241  {
242  return 1;
243  }
244  else
245  {
246  return strcmp(i1->name, i2->name);
247  }
248  }
249 }
static void fselect_subtract_cb ( unsigned int  btn)
static

Definiert in Zeile 1253 der Datei gui_fselect.c.

1254 {
1255  fitem *ptr;
1256  if (btn != MBOX_BTN_YES) return;
1257 
1258  for (ptr=items.head; ptr; ptr=ptr->next)
1259  {
1260  if (ptr->marked && ptr->isvalid && !ptr->isdir && chk_name(ptr->name,selected->name))
1261  {
1263  }
1264  }
1265  gui_fselect_readdir = 1;
1266  gui_fselect_redraw = 2;
1267 }
void gui_fselect_draw ( int  enforce_redraw)

Definiert in Zeile 743 der Datei gui_fselect.c.

744 {
745  int i, j;
746  twoColors cl_marked;
747 
749  {
752  }
753 
754  if (enforce_redraw)
755  gui_fselect_redraw = 2;
756 
757  if (gui_fselect_redraw)
758  {
759  char dbuf[46];
760 
761  if (gui_fselect_redraw == 2)
762  {
763  // Title
765 
767  draw_line(main_x, body_y-1, main_x+main_w-1, body_y-1, COLOR_WHITE); //border head-body
768  draw_line(main_x, foot_y-1, main_x+main_w-1, foot_y-1, COLOR_WHITE); //border body-foot
769  }
770 
771  int off_body_y = body_y;
772 
773  fitem *ptr;
774  unsigned long sum_size = 0;
775  for (i=0, ptr=top; i<BODY_LINES && ptr; ++i, ptr=ptr->next, off_body_y += FONT_HEIGHT)
776  {
777  cl_marked = MAKE_COLOR((ptr==selected)?COLOR_RED:COLOR_GREY, (ptr->marked)?COLOR_YELLOW:COLOR_WHITE);
778 
779  // print name
780  j = strlen(ptr->name);
781  strncpy(dbuf, ptr->name, NAME_SIZE);
782  if (j > NAME_SIZE)
783  dbuf[NAME_SIZE-1] = '~'; // too long name
784 
785  if (ptr->isdir && ptr->isvalid)
786  {
787  if (j < NAME_SIZE)
788  {
789  dbuf[j++] = '/';
790  }
791  else
792  {
793  dbuf[NAME_SIZE-2] = '~';
794  dbuf[NAME_SIZE-1] = '/';
795  }
796  }
797  for (; j < NAME_SIZE; j++)
798  dbuf[j] = ' ';
799  j = NAME_SIZE;
800  dbuf[j++] = 0x06; // Vertical line
801 
802  // print size or <Dir>
803  if (ptr->isdir)
804  {
805  if (!ptr->isvalid)
806  {
807  sprintf(dbuf+j, " ??? ");
808  }
809  else if (ptr->isparent)
810  {
811  sprintf(dbuf+j, " <Up> ");
812  }
813  else
814  {
815  sprintf(dbuf+j, " <Dir>");
816  }
817  }
818  else
819  {
820  unsigned long n = ptr->size;
821 
822  if (ptr->marked)
823  sum_size += n;
824 
825  if (n < 1024)
826  sprintf(dbuf+j, "%5db", n); // " 1023 b"
827  else
828  {
829  static char* suffixes = "kMG";
830  int sfx = 0;
831  if (n >= 4294967245ul) // 4GB - 51 - avoid overflow
832  {
833  sfx = 2; // 'G' suffix
834  n = 4096; // 4G
835  }
836  else
837  {
838  // Round to 1 decimal place (51 = 1024 * 0.05)
839  n += 51;
840  // Reduce and round until < 1M, incrementing size suffix index
841  while (n >= 1024*1024)
842  {
843  n >>= 10;
844  n += 51;
845  sfx += 1;
846  }
847  }
848  unsigned long f = ((n & 0x3FF) * 10) >> 10; // 1 digit of remainder % 1024
849  sprintf(dbuf+j, "%3d.%1d%c", n >> 10, f, suffixes[sfx]);
850  }
851  }
852  j += SIZE_SIZE;
853  dbuf[j++] = 0x06; // Vertical line
854 
855  // print modification time
856  if (ptr->mtime)
857  {
858  struct tm *time = localtime(&(ptr->mtime));
859  sprintf(dbuf+j, "%02u.%02u'%02u %02u:%02u", time->tm_mday, time->tm_mon+1, (time->tm_year<100)?time->tm_year:time->tm_year-100, time->tm_hour, time->tm_min);
860  }
861  else
862  {
863  sprintf(dbuf+j, "%14s", "");
864  }
865  j += TIME_SIZE;
866  dbuf[j] = 0;
867 
868  draw_string_justified(main_x, off_body_y, dbuf, cl_marked, SPACING, main_w-SCROLLBAR, TEXT_LEFT|TEXT_FILL);
869  }
870 
871  //fill the rest of body
872  if (i>0 && i<BODY_LINES)
873  {
875  }
876 
877  // scrollbar
878  int off_sbar_x = main_x + main_w - SCROLLBAR;
880  if (items.count > BODY_LINES)
881  {
882  i = BODY_FONT_LINES - 1;
883  j = (i * BODY_LINES) / items.count;
884  if (j < 20) j = 20;
885  i = ((i - j) * selected->n) / (items.count-1);
886  draw_rectangle(off_sbar_x, body_y+i, off_sbar_x+SCROLLBAR-2, body_y+i+j, MAKE_COLOR(COLOR_WHITE, COLOR_WHITE), RECT_BORDER0|DRAW_FILLED);
887  }
888 
889  //footer
890  int max_footer_len = NAME_SIZE + SIZE_SIZE + SPACING;
891  i = strlen(items.dir);
892  if (i > max_footer_len)
893  {
894  strncpy(dbuf, items.dir+i-max_footer_len, max_footer_len);
895  dbuf[0] = '.';
896  dbuf[1] = '.';
897  }
898  else
899  {
900  strcpy(dbuf, items.dir);
901  }
903 
904  if (sum_size)
905  {
906  sprintf(dbuf, "%d b", sum_size); //selected size
907  }
908  else
909  {
910  unsigned int fr = GetFreeCardSpaceKb();
911  unsigned int tot = GetTotalCardSpaceKb();
912  if (tot != 0)
913  tot = (fr * 100) / tot;
914 
915  if (fr < 1024*1024)
916  sprintf(dbuf, "%dM (%d%%)", fr>>10, tot);
917  else
918  sprintf(dbuf, "%d.%dG (%d%%)", fr>>20, ((fr&0x000FFFFF)*100)>>20, tot);
919  }
920  draw_string(main_x+main_w-strlen(dbuf)*FONT_WIDTH-BORDER, foot_y, dbuf, MAKE_COLOR(COLOR_GREY, COLOR_WHITE)); // free space
921 
922  gui_fselect_redraw = 0;
923  }
924 }
int gui_fselect_find_start_dir ( const char *  dir)

Definiert in Zeile 661 der Datei gui_fselect.c.

662 {
663  selected_file[0] = 0;
664  strcpy(items.dir, dir);
665 
666  // Make sure there is something left to check
667  while (strlen(items.dir) > 0)
668  {
669  // Find start of filename part (if present)
670  char *p = strrchr(items.dir,'/');
671 
672  struct stat st;
673  // check if input 'dir' exists
674  if (stat(items.dir,&st) == 0)
675  {
676  // exists - check if it is a directory or file
677  if ((st.st_attrib & DOS_ATTR_DIRECTORY) == 0)
678  {
679  // 'dir' is a file, copy filename to 'selected_file' and remove from 'items.dir'
680  strcpy(selected_file, p+1);
681  *p = 0;
682  }
683  return 1;
684  }
685  else
686  {
687  // could not find 'dir' - try one level up
688  if (p)
689  *p = 0;
690  else
691  return 0;
692  }
693  }
694 
695  return 0;
696 }
static void gui_fselect_free_data ( )
static

Definiert in Zeile 612 der Datei gui_fselect.c.

613 {
614  free_list(&items);
615  top = selected = NULL;
616 }
void gui_fselect_init ( int  title,
const char *  prev_dir,
const char *  default_dir,
void(*)(const char *fn on_select 
)

Definiert in Zeile 699 der Datei gui_fselect.c.

700 {
701  running = 1;
702 
704  main_x = (camera_screen.width - main_w) >> 1;
705  main_y = (camera_screen.height - MAIN_H) >> 1;
706 
709 
710  fselect_title = lang_str(title);
711 
712  // Try and set start directory, and optionally selected file, from inputs
713  if (!gui_fselect_find_start_dir(prev_dir))
714  if (!gui_fselect_find_start_dir(default_dir))
716 
718 
719  // Find selected file if it exists in list
720  if (selected_file[0])
721  {
722  fitem *p = items.head;
723  while (p)
724  {
725  if (chk_name(p->name,selected_file))
726  {
727  break;
728  }
729  p = p->next;
731  }
732  if (!p) selected_file[0] = 0;
733  }
734 
735  fselect_on_select = on_select;
737  gui_fselect_redraw = 2;
740 }
int gui_fselect_kbd_process ( )

Definiert in Zeile 1477 der Datei gui_fselect.c.

1478 {
1479  int i;
1480  int do_exit = 0;
1481 
1483  {
1484  case JOGDIAL_LEFT:
1485  case KEY_UP:
1486  if (selected)
1487  {
1489  else fselect_goto_prev(1);
1490  gui_fselect_redraw = 1;
1491  }
1492  break;
1493  case KEY_DOWN:
1494  case JOGDIAL_RIGHT:
1495  if (selected)
1496  {
1498  else fselect_goto_next(1);
1499  gui_fselect_redraw = 1;
1500  }
1501  break;
1502  case KEY_ZOOM_OUT:
1503  if (selected)
1504  {
1506  gui_fselect_redraw = 1;
1507  }
1508  break;
1509  case KEY_ZOOM_IN:
1510  if (selected)
1511  {
1513  gui_fselect_redraw = 1;
1514  }
1515  break;
1516  case KEY_RIGHT:
1517  if (selected)
1518  {
1520  fselect_goto_next(1);
1521  gui_fselect_redraw = 1;
1522  }
1523  break;
1524  case KEY_LEFT:
1525  if (selected && selected->isvalid)
1526  {
1527  int marked_count = fselect_marked_count();
1528 
1530  mpopup_rawop_flag = 0;
1531 
1532  if (marked_count > 0)
1533  {
1535  if (marked_count > 1)
1537  // doesn't make sense to subtract from itself!
1538  if (selected->marked == 0 && fselect_real_marked_count() > 0)
1540  }
1541 
1543  i |= MPOPUP_PASTE;
1544 
1545  //Check if 'Purge RAW' applies
1546  if (isPurgeDCIM()) // DCIM or RAW selected in A
1547  i |= MPOPUP_PURGE_DCIM;
1548  if (isPurgeDir()) // sub-dir selected in A/DCIM or A/RAW
1549  i |= MPOPUP_PURGE_DIR;
1550  if (is_raw(selected->name)) // raw file selected
1551  i |= MPOPUP_PURGE_FILE;
1552 
1553  if (selected->isdir && !selected->isparent)
1554  i |= MPOPUP_RMDIR;
1555 
1556  if (!selected->isparent) //If item is not UpDir
1557  i |= MPOPUP_RENAME;
1558 
1561 
1562  if ((marked_count > 1) || (selected->size > camera_sensor.raw_size))
1564 
1565  if (chk_ext(selected->name, "bin")) //If item is *.bin file
1566  i |= MPOPUP_CHDK_REPLACE;
1567 
1568  if (mpopup_rawop_flag)
1569  i |= MPOPUP_RAWOPS;
1570 
1572  }
1573  break;
1574  case KEY_SET:
1576  {
1577  if (selected->isdir)
1578  {
1579  if (selected->isparent)
1580  {
1581  char *s = strrchr(items.dir, '/');
1582  if (s) *s = 0;
1583  }
1584  else
1585  {
1587  }
1588  gui_fselect_readdir = 1;
1589  gui_fselect_redraw = 1;
1590  }
1591  else
1592  {
1593  sprintf(selected_file, "%s/%s", items.dir, selected->name);
1594 
1595  char *ext = strrchr(selected->name,'.');
1596  do_exit = 1;
1597 
1598  if (!fselect_on_select)
1599  {
1600  if (chk_ext(ext,"txt") || chk_ext(ext,"log") || chk_ext(ext,"csv"))
1601  {
1602  fselect_on_select = (void (*)(const char*))libtxtread->read_file;
1603  }
1604  else if (chk_ext(ext,"flt"))
1605  {
1606  fselect_on_select = (void (*)(const char*))module_run;
1607  }
1608  }
1609  }
1610  }
1611  break;
1612  case KEY_ERASE:
1613  case KEY_DISPLAY:
1614  if (selected && selected->isvalid)
1615  {
1616  if (selected->isdir)
1617  {
1619  } else
1620  {
1623  }
1624  }
1625  break;
1626  }
1627 
1628  if (do_exit)
1630 
1631  return 0;
1632 }
void gui_fselect_kbd_process_menu_btn ( )

Definiert in Zeile 1634 der Datei gui_fselect.c.

1635 {
1636  // just free resource. callback called with NULL ptr
1637  exit_fselect(0);
1638 }
static void gui_fselect_marked_free_data ( )
static

Definiert in Zeile 1091 der Datei gui_fselect.c.

1092 {
1095 }
static void gui_fselect_read_dir ( )
static

Definiert in Zeile 619 der Datei gui_fselect.c.

620 {
621  DIR *d;
622  fs_dirent de;
623  int fndParent = 0; // Set if parent ".." directory returned by fs_readdir (does not exist on exFat paritions)
624 
626 
627  if ((items.dir[0] == 'A') && (items.dir[1] == 0))
628  d = opendir_fselect("A/");
629  else
631 
632  if (d)
633  {
634  while (fs_readdir(d, &de, items.dir))
635  {
636  if (!de.deleted && !de.iscurrent && (conf.show_hiddenfiles || !de.ishidden))
637  {
638  add_item(&items, de.de->d_name, de.size, de.mtime, 0, de.isdir, de.isparent, de.isvalid);
639  if (de.isparent)
640  fndParent = 1;
641  }
642  }
643  closedir(d);
644  }
645 
646  // If not reading root directory, and ".." not found, then add it (for exFat partitions)
647  if ((strlen(items.dir) > 2) && !fndParent)
648  {
649  add_item(&items, "..", 0, 0, 0, 1, 1, 1);
650  }
651 
652  sort_list(&items);
653 
654  top = selected = items.head;
655 }
static int is_current ( const char *  name)
static

Definiert in Zeile 340 der Datei gui_fselect.c.

340 { return (strcmp(name, ".") == 0); }
static int is_jpg ( const char *  name)
static

Definiert in Zeile 350 der Datei gui_fselect.c.

351 {
352  return (chk_prefix(name,"img_")) && (chk_ext(name,"jpg"));
353 }
static int is_parent ( const char *  name)
static

Definiert in Zeile 339 der Datei gui_fselect.c.

339 { return (strcmp(name, "..") == 0); }
static int is_raw ( const char *  name)
static

Definiert in Zeile 343 der Datei gui_fselect.c.

344 {
345  return ((chk_prefix(name,"crw_") || (chk_prefix(name,"img_")))) &&
346  ((chk_ext(name,"cr2") || (chk_ext(name,"crw") || (chk_ext(name,"dng")))));
347 }
static int isPurgeDCIM ( )
static

Definiert in Zeile 1377 der Datei gui_fselect.c.

1378 {
1379  return (chk_name(items.dir, "A") && (chk_name(selected->name, "DCIM") || chk_name(selected->name, "RAW")));
1380 }
static int isPurgeDir ( )
static

Definiert in Zeile 1383 der Datei gui_fselect.c.

1384 {
1385  return (selected->isdir && !selected->isparent && ((chk_name(items.dir, "A/DCIM")) || (chk_name(items.dir, "A/RAW"))));
1386 }
static void mkdir_cb ( const char *  name)
static

Definiert in Zeile 1350 der Datei gui_fselect.c.

1351 {
1352  if (name)
1353  {
1354  sprintf(selected_file,"%s/%s", items.dir, name);
1356  gui_fselect_readdir = 1;
1357  gui_fselect_redraw = 2;
1358  }
1359 }
static DIR* opendir_fselect ( const char *  path)
static

Definiert in Zeile 370 der Datei gui_fselect.c.

static void process_dir ( const char *  parent,
const char *  name,
int  nested,
void(*)(const char *path, const char *file)  file_process,
void(*)(const char *path)  dir_process 
)
static

Definiert in Zeile 520 der Datei gui_fselect.c.

521 {
522  DIR *d;
523  fs_dirent de;
524 
525  // Get full name
526  char *path;
527  if (name)
528  {
529  path = malloc(strlen(parent) + strlen(name) + 2);
530  sprintf(path, "%s/%s", parent, name);
531  }
532  else
533  {
534  path = (char*)parent;
535  }
536 
537  // Open directory
538  d = opendir_fselect(path);
539 
540  if (d)
541  {
542  // Process contents
543  while (fs_readdir(d, &de, path))
544  {
545  if (!de.deleted)
546  {
547  // Sub directory? Process recursively (but only 'nested' level deep)
548  if (de.isdir)
549  {
550  if (!de.isparent && !de.iscurrent && nested)
551  process_dir(path, de.de->d_name, nested-1, file_process, dir_process);
552  }
553  else if (file_process)
554  {
555  file_process(path, de.de->d_name);
556  }
557  }
558  }
559  closedir(d);
560 
561  if (dir_process)
562  dir_process(path);
563  }
564 
565  if (name)
566  free(path);
567 }
void process_dng_to_raw_files ( void  )

Definiert in Zeile 1300 der Datei gui_fselect.c.

1301 {
1302  fitem *ptr;
1303  int i=0;
1304  started();
1305  msleep(100);
1306  finished();
1307 
1309  {
1310  for (ptr=items.head; ptr; ptr=ptr->next)
1311  if (ptr->marked && ptr->isvalid && !ptr->isdir)
1312  {
1313  sprintf(selected_file, "%s/%s", items.dir, ptr->name);
1316  }
1317  }
1318  else
1319  {
1320  sprintf(selected_file, "%s/%s", items.dir, selected->name);
1322  }
1323  gui_fselect_readdir = 1;
1324 }
void process_raw_files ( void  )

Definiert in Zeile 1235 der Datei gui_fselect.c.

1236 {
1237  fitem *ptr;
1238 
1240  {
1241  for (ptr=items.head; ptr; ptr=ptr->next)
1242  if (ptr->marked && ptr->isvalid && !ptr->isdir)
1243  {
1244  sprintf(selected_file, "%s/%s", items.dir, ptr->name);
1246  }
1248  gui_fselect_readdir = 1;
1249  gui_fselect_redraw = 2;
1250  }
1251 }
static void purge_file ( const char *  folder,
const char *  file 
)
static

Definiert in Zeile 987 der Datei gui_fselect.c.

988 {
989  //If no JPG found, delete RAW file
990  if (is_raw(file))
991  if (!find_jpg(folder, file, 0))
992  delete_file(folder, file);
993 }
static void purge_file_DCIM ( const char *  folder,
const char *  file 
)
static

Definiert in Zeile 999 der Datei gui_fselect.c.

1000 {
1001  //If no JPG found, delete RAW file (search all sub-folders of A/DCIM for JPG)
1002  if (is_raw(file))
1003  if (!find_jpg("A/DCIM", file, 1))
1004  delete_file(folder, file);
1005 }
static void rename_cb ( const char *  name)
static

Definiert in Zeile 1361 der Datei gui_fselect.c.

1362 {
1363  if (name)
1364  {
1365  sprintf(selected_file, "%s/%s", items.dir, selected->name);
1366  sprintf(buf, "%s/%s", items.dir, name);
1368  gui_fselect_readdir = 1;
1369  gui_fselect_redraw = 2;
1370  }
1371 }
static void setup_batch_subtract ( void  )
static

Definiert in Zeile 1270 der Datei gui_fselect.c.

1271 {
1272  fitem *ptr;
1273  int i;
1274  char *p = buf + sprintf(buf,"%s %s\n",selected->name,lang_str(LANG_FSELECT_SUB_FROM));
1275  for (ptr=items.head, i=0; ptr; ptr=ptr->next)
1276  {
1277  if (ptr->marked && ptr->isvalid && !ptr->isdir && (ptr->size >= camera_sensor.raw_size))
1278  {
1279  if ( i < MAX_SUB_NAMES )
1280  {
1281  sprintf(p, "%s\n",ptr->name);
1282  // keep a pointer to the one before the end, so we can stick ...and more on
1283  if (i < MAX_SUB_NAMES - 1)
1284  {
1285  p += strlen(p);
1286  }
1287  }
1288  i++;
1289  }
1290  }
1291  if (i > MAX_SUB_NAMES)
1292  {
1293 // "...%d more files"
1295  }
1298 }
static void sort_list ( flist list)
static

Definiert in Zeile 251 der Datei gui_fselect.c.

252 {
253  if (list->count)
254  {
255  // sort
256  fitem **sbuf = malloc(list->count*sizeof(fitem*));
257  if (sbuf)
258  {
259  fitem *ptr = list->head;
260  int i = 0;
261  while (ptr)
262  {
263  sbuf[i++] = ptr;
264  ptr = ptr->next;
265  }
266 
267  extern int fselect_sort_nothumb(const void* v1, const void* v2);
268  qsort(sbuf, list->count, sizeof(fitem*), fselect_sort_nothumb);
269 
270  list->head = sbuf[0];
271  list->tail = sbuf[list->count-1];
272  for (i=0; i<list->count-1; i++)
273  {
274  sbuf[i]->n = i;
275  sbuf[i]->next = sbuf[i+1];
276  sbuf[i+1]->prev = sbuf[i];
277  }
278  list->head->prev = 0;
279  list->tail->next = 0;
280  list->tail->n = list->count - 1;
281 
282  free(sbuf);
283  }
284  }
285 }

Variablen-Dokumentation

libfselect_sym _libfselect
Initialisierung:

Definiert in Zeile 1675 der Datei gui_fselect.c.

coord body_y
static

Definiert in Zeile 106 der Datei gui_fselect.c.

char buf[MAX_PATH_LEN]
static

Definiert in Zeile 68 der Datei gui_fselect.c.

coord foot_y
static

Definiert in Zeile 107 der Datei gui_fselect.c.

void(* fselect_on_select)(const char *fn)
static

Definiert in Zeile 113 der Datei gui_fselect.c.

char* fselect_title
static

Definiert in Zeile 111 der Datei gui_fselect.c.

gui_handler* gui_fselect_mode_old
static

Definiert in Zeile 62 der Datei gui_fselect.c.

int gui_fselect_readdir
static

Definiert in Zeile 110 der Datei gui_fselect.c.

int gui_fselect_redraw
static

Definiert in Zeile 109 der Datei gui_fselect.c.

gui_handler GUI_MODE_FSELECT_MODULE
Initialisierung:

Definiert in Zeile 34 der Datei gui_fselect.c.

flist items
static

Definiert in Zeile 95 der Datei gui_fselect.c.

coord main_w
static

Definiert in Zeile 105 der Datei gui_fselect.c.

coord main_x
static

Definiert in Zeile 105 der Datei gui_fselect.c.

coord main_y
static

Definiert in Zeile 105 der Datei gui_fselect.c.

flist marked_items
static

Definiert in Zeile 96 der Datei gui_fselect.c.

char marked_operation
static

Definiert in Zeile 101 der Datei gui_fselect.c.

int mpopup_rawop_flag
static

Definiert in Zeile 1373 der Datei gui_fselect.c.

struct mpopup_item popup_rawop[]
static
Initialisierung:

Definiert in Zeile 156 der Datei gui_fselect.c.

char raw_operation
static

Definiert in Zeile 114 der Datei gui_fselect.c.

int running = 0
static

Definiert in Zeile 61 der Datei gui_fselect.c.

fitem* selected
static

Definiert in Zeile 99 der Datei gui_fselect.c.

char selected_file[MAX_PATH_LEN]
static

Definiert in Zeile 67 der Datei gui_fselect.c.

fitem* top
static

Definiert in Zeile 98 der Datei gui_fselect.c.

unsigned char* ubuf = 0
static

Definiert in Zeile 376 der Datei gui_fselect.c.