27 |
#include "exit.h" |
#include "exit.h" |
28 |
#include "config_common.h" |
#include "config_common.h" |
29 |
|
|
30 |
static gchar DEFAULT_REPORT[] = "report.out"; |
static gchar DEFAULT_REPORT[] = "report"; |
31 |
|
static gchar DEFAULT_EXTENSION[] = "txt"; |
32 |
static gchar ALL_DISKS[] = N_("All disks"); |
static gchar ALL_DISKS[] = N_("All disks"); |
33 |
static gchar ALL_CATEGORIES[] = N_("(All)"); |
static gchar ALL_CATEGORIES[] = N_("(All)"); |
34 |
static gchar CATEGORY_NONE[] = N_("(None)"); |
static gchar CATEGORY_NONE[] = N_("(None)"); |
55 |
static GtkWidget *button_sortbyfile; |
static GtkWidget *button_sortbyfile; |
56 |
static GtkWidget *button_tree; |
static GtkWidget *button_tree; |
57 |
static GtkWidget *button_html; |
static GtkWidget *button_html; |
58 |
|
static GtkWidget *button_xml; |
59 |
|
static GtkWidget *button_txt; |
60 |
static GtkWidget *button_manydirs; |
static GtkWidget *button_manydirs; |
61 |
static GSList *group_sort; |
static GSList *group_sort; |
62 |
|
static GSList *group_html_xml; |
63 |
static GtkWidget *list_separator; |
static GtkWidget *list_separator; |
64 |
static GtkWidget *output_entry; |
static GtkWidget *output_entry; |
65 |
static GtkWidget *gnome_output_entry; |
static GtkWidget *gnome_output_entry; |
79 |
static gboolean gb_check_only_cat; |
static gboolean gb_check_only_cat; |
80 |
static gboolean gb_spec_report; |
static gboolean gb_spec_report; |
81 |
static gboolean gb_html_report; |
static gboolean gb_html_report; |
82 |
|
static gboolean gb_xml_report; |
83 |
static gboolean gb_manydirs_report; |
static gboolean gb_manydirs_report; |
84 |
static gint cat_to_report; |
static gint cat_to_report; |
85 |
|
|
247 |
char *quot; |
char *quot; |
248 |
char *html_td_start = "<TD>"; |
char *html_td_start = "<TD>"; |
249 |
char *html_td_end = "</TD>"; |
char *html_td_end = "</TD>"; |
250 |
|
char *xml_report_st = "<report>"; |
251 |
|
char *xml_report_ed = "</report>"; |
252 |
|
char *xml_disc_name_st = "\t<disc_name>"; |
253 |
|
char *xml_disc_name_ed = "</disc_name>\n"; |
254 |
|
char *xml_legend_st = "<legend>"; |
255 |
|
char *xml_legend_ed = "</legend>"; |
256 |
|
char *xml_directory_st = "<directory>\n"; |
257 |
|
char *xml_directory_ed = "</directory>"; |
258 |
|
char *xml_file_st = "\t<file_name>"; |
259 |
|
char *xml_file_ed = "</file_name>\n"; |
260 |
|
char *xml_size_st = "\t<file_size>"; |
261 |
|
char *xml_size_ed = "</file_size>\n"; |
262 |
|
char *xml_date_st = "\t<file_date>"; |
263 |
|
char *xml_date_ed = "</file_date>\n"; |
264 |
|
char *xml_description_st = "\t<description>"; |
265 |
|
char *xml_description_ed = "</description>\n"; |
266 |
|
char *xml_information_st = "\t<information>"; |
267 |
|
char *xml_information_ed = "</information>\n"; |
268 |
|
char *xml_category_st = "\t<category>"; |
269 |
|
char *xml_category_ed = "</category>\n"; |
270 |
|
char *xml_location_st = "\t<directory_name>"; |
271 |
|
char *xml_location_ed = "</directory_name>\n"; |
272 |
char *td_st; |
char *td_st; |
273 |
char *td_ed; |
char *td_ed; |
274 |
|
|
279 |
cstring ((gchar *) gtk_entry_get_text (GTK_ENTRY (list_separator))); |
cstring ((gchar *) gtk_entry_get_text (GTK_ENTRY (list_separator))); |
280 |
|
|
281 |
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check_quote)) && |
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check_quote)) && |
282 |
!gb_html_report) |
!gb_html_report && !gb_xml_report) |
283 |
quot = double_quotes; |
quot = double_quotes; |
284 |
else |
else |
285 |
quot = nothing; |
quot = nothing; |
290 |
separator = nothing; |
separator = nothing; |
291 |
} |
} |
292 |
else |
else |
293 |
|
if ( gb_xml_report ) |
294 |
|
separator = nothing; |
295 |
|
else |
296 |
{ |
{ |
297 |
td_st = nothing; |
td_st = nothing; |
298 |
td_ed = nothing; |
td_ed = nothing; |
330 |
|
|
331 |
if (gb_html_report) |
if (gb_html_report) |
332 |
fprintf (file, "<TR>"); |
fprintf (file, "<TR>"); |
333 |
|
if (gb_xml_report) |
334 |
|
fprintf (file, xml_directory_st); |
335 |
if (gb_check_disks) |
if (gb_check_disks) |
336 |
{ |
{ |
337 |
|
if (gb_xml_report) |
338 |
|
{ |
339 |
|
td_st = xml_disc_name_st; |
340 |
|
td_ed = xml_disc_name_ed; |
341 |
|
} |
342 |
fprintf (file, "%s%s%s%s%s%s", td_st, quot, |
fprintf (file, "%s%s%s%s%s%s", td_st, quot, |
343 |
(last_disk_name ? htmlize (last_disk_name) : ""), quot, |
(last_disk_name ? htmlize (last_disk_name) : ""), quot, |
344 |
separator, td_ed); |
separator, td_ed); |
346 |
|
|
347 |
if (gb_check_folders) |
if (gb_check_folders) |
348 |
{ |
{ |
349 |
|
if ( gb_xml_report ) |
350 |
|
{ |
351 |
|
td_st = xml_location_st; |
352 |
|
td_ed = xml_location_ed; |
353 |
|
} |
354 |
gs = get_path_from_node (gn); |
gs = get_path_from_node (gn); |
355 |
gdescr = g_strdup (gs->str); |
gdescr = g_strdup (gs->str); |
356 |
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (no_newline))) |
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (no_newline))) |
379 |
} |
} |
380 |
else |
else |
381 |
{ |
{ |
382 |
fprintf (file, "%s%s%s%s%s%s", td_st, quot, htmlize (gdescr), quot, |
fprintf (file, "%s%s%s%s%s", quot, htmlize (gdescr), quot, |
383 |
separator, td_ed); |
separator, td_ed); |
384 |
} |
} |
385 |
g_free (gdescr); |
g_free (gdescr); |
402 |
} |
} |
403 |
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (no_newline))) |
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (no_newline))) |
404 |
strswap (gdescr, '\n', ' '); |
strswap (gdescr, '\n', ' '); |
405 |
|
if ( gb_xml_report ) |
406 |
|
{ |
407 |
|
td_st = xml_file_st; |
408 |
|
td_ed = xml_file_ed; |
409 |
|
} |
410 |
if (is_dir (gn) && gb_check_files) |
if (is_dir (gn) && gb_check_files) |
411 |
{ |
{ |
412 |
fprintf (file, "%s%s%s/%s%s", td_st, quot, htmlize (gdescr), quot, |
fprintf (file, "%s%s%s/%s%s", td_st, quot, htmlize (gdescr), quot, |
421 |
} |
} |
422 |
if (gb_check_sizes) |
if (gb_check_sizes) |
423 |
{ |
{ |
424 |
|
if (gb_xml_report) |
425 |
|
{ |
426 |
|
td_st = xml_size_st; |
427 |
|
td_ed = xml_size_ed; |
428 |
|
} |
429 |
if (!((fd->a_parent_node_is_vfs == IS_VFS) || (is_unreadable (gn)))) |
if (!((fd->a_parent_node_is_vfs == IS_VFS) || (is_unreadable (gn)))) |
430 |
{ |
{ |
431 |
fprintf (file, "%s%s%s%d%s%s", td_st, separator, quot, fd->taille, |
fprintf (file, "%s%s%s%d%s%s", td_st, separator, quot, fd->taille, |
438 |
} |
} |
439 |
if (gb_check_dates) |
if (gb_check_dates) |
440 |
{ |
{ |
441 |
|
if (gb_xml_report) |
442 |
|
{ |
443 |
|
td_st = xml_date_st; |
444 |
|
td_ed = xml_date_ed; |
445 |
|
} |
446 |
if (!((fd->a_parent_node_is_vfs == IS_VFS) || (is_unreadable (gn)))) |
if (!((fd->a_parent_node_is_vfs == IS_VFS) || (is_unreadable (gn)))) |
447 |
{ |
{ |
448 |
char humandate[] = "DD/MM/YYYY HH:MM:SS "; |
char humandate[] = "DD/MM/YYYY HH:MM:SS "; |
458 |
} |
} |
459 |
if (gb_check_category) |
if (gb_check_category) |
460 |
{ |
{ |
461 |
|
if (gb_xml_report) |
462 |
|
{ |
463 |
|
td_st = xml_category_st; |
464 |
|
td_ed = xml_category_ed; |
465 |
|
} |
466 |
if (fd->categorie != 0) |
if (fd->categorie != 0) |
467 |
{ |
{ |
468 |
gdescr = g_strdup (folder_get_category_from_file_data (fd)); |
gdescr = g_strdup (folder_get_category_from_file_data (fd)); |
479 |
|
|
480 |
if (gb_check_description) |
if (gb_check_description) |
481 |
{ |
{ |
482 |
|
if ( gb_xml_report ) |
483 |
|
{ |
484 |
|
td_st = xml_description_st; |
485 |
|
td_ed = xml_description_ed; |
486 |
|
} |
487 |
if (fd->description != 0) |
if (fd->description != 0) |
488 |
{ |
{ |
489 |
gdescr = g_strdup (folder_get_description_from_file_data (fd)); |
gdescr = g_strdup (folder_get_description_from_file_data (fd)); |
499 |
|
|
500 |
if (gb_check_information) |
if (gb_check_information) |
501 |
{ |
{ |
502 |
|
if ( gb_xml_report ) |
503 |
|
{ |
504 |
|
td_st = xml_information_st; |
505 |
|
td_ed = xml_information_ed; |
506 |
|
} |
507 |
if (fd->information != 0) |
if (fd->information != 0) |
508 |
{ |
{ |
509 |
gdescr = g_strdup (fd->information->str); |
gdescr = g_strdup (fd->information->str); |
518 |
} |
} |
519 |
if (gb_html_report) |
if (gb_html_report) |
520 |
fprintf (file, "</TR>"); |
fprintf (file, "</TR>"); |
521 |
|
if (gb_xml_report) |
522 |
|
fprintf (file, xml_directory_ed); |
523 |
fprintf (file, "\n"); |
fprintf (file, "\n"); |
524 |
} |
} |
525 |
|
|
1094 |
gb_check_only_desc = |
gb_check_only_desc = |
1095 |
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check_only_desc)); |
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check_only_desc)); |
1096 |
if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button_sortbyfile))) |
if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button_sortbyfile))) |
1097 |
|
{ |
1098 |
gb_html_report = FALSE; |
gb_html_report = FALSE; |
1099 |
else |
gb_xml_report = FALSE; |
1100 |
|
} else { |
1101 |
gb_html_report = |
gb_html_report = |
1102 |
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button_html)); |
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button_html)); |
1103 |
|
gb_xml_report = !gb_html_report; |
1104 |
|
} |
1105 |
|
|
1106 |
if (gb_check_disks && !gb_check_folders && !gb_check_files && |
if (gb_check_disks && !gb_check_folders && !gb_check_files && |
1107 |
!gb_check_category && !gb_check_description && !gb_check_information) |
!gb_check_category && !gb_check_description && !gb_check_information) |
1120 |
} |
} |
1121 |
if (gb_html_report) |
if (gb_html_report) |
1122 |
{ |
{ |
1123 |
|
fprintf (file, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">"); |
1124 |
fprintf (file, |
fprintf (file, |
1125 |
"<HTML><HEAD><TITLE>%s</TITLE></HEAD><BODY>", |
"<HTML><HEAD><TITLE>%s</TITLE></HEAD><BODY>", |
1126 |
_("GTKtalog's Catalog")); |
_("GTKtalog's Catalog")); |
1127 |
fprintf (file, "<STYLE><!--\n"); |
fprintf (file, "<STYLE TYPE=\"text/css\"><!--\n"); |
1128 |
|
fprintf (file, "body { background: white; color: black: margin: 0.5em; font-size: 9pt;}\n"); |
1129 |
fprintf (file, "TT { font-family: courier; }\n"); |
fprintf (file, "TT { font-family: courier; }\n"); |
1130 |
fprintf (file, "TD { font-family: helvetica, sans-serif; }\n"); |
fprintf (file, "TD { font-family: helvetica, sans-serif; font-size: 9pt; border-bottom: thin solid #000000; border-left: thin solid #000000;}\n"); |
1131 |
fprintf (file, "CAPTION {\n"); |
fprintf (file, "CAPTION {\n"); |
1132 |
fprintf (file, " font-family: helvetica, sans-serif;\n"); |
fprintf (file, " font-family: helvetica, sans-serif;\n"); |
1133 |
fprintf (file, " font-size: 14pt;\n"); |
fprintf (file, " font-size: 12pt;\n"); |
1134 |
fprintf (file, " text-align: left;\n"); |
fprintf (file, " text-align: left;\n"); |
1135 |
fprintf (file, "}\n--></STYLE>\n</HEAD><BODY>"); |
fprintf (file, "}\n--></STYLE>\n</HEAD><BODY>"); |
1136 |
} |
} |
1137 |
|
if (gb_xml_report) |
1138 |
|
{ |
1139 |
|
fprintf (file, "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n"); |
1140 |
|
fprintf (file, "<?xml-stylesheet type=\"text/css\" href=\"gtktalog.css\"?>\n"); |
1141 |
|
fprintf (file, "<report>\n"); |
1142 |
|
fprintf (file, "<name>%s</name>\n", _("GTKtalog's Catalog")); |
1143 |
|
} |
1144 |
|
|
1145 |
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (add_legend))) |
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (add_legend))) |
1146 |
{ |
{ |
1147 |
if (gb_html_report) |
if (gb_html_report) |
1148 |
fprintf (file, "<PRE>"); |
fprintf (file, "<PRE>"); |
1149 |
|
if (gb_xml_report) |
1150 |
|
fprintf (file, "<legend>\n"); |
1151 |
fprintf (file, _("This report was generated by GTKtalog.\n")); |
fprintf (file, _("This report was generated by GTKtalog.\n")); |
1152 |
fprintf (file, GTKTALOGWEB "\n\n"); |
fprintf (file, GTKTALOGWEB "\n\n"); |
1153 |
|
|
1198 |
fprintf (file, "\n"); |
fprintf (file, "\n"); |
1199 |
if (gb_html_report) |
if (gb_html_report) |
1200 |
fprintf (file, "</PRE>"); |
fprintf (file, "</PRE>"); |
1201 |
|
if (gb_xml_report) |
1202 |
|
fprintf (file, "</legend>\n"); |
1203 |
} |
} |
1204 |
|
|
1205 |
if (gb_html_report) |
if (gb_html_report) |
1206 |
fprintf (file, "<TABLE border=1><CAPTION>Catalog</CAPTION>"); |
fprintf (file, "<TABLE border=0><CAPTION>Catalog</CAPTION>"); |
1207 |
|
|
1208 |
if (gb_check_disks_only) |
if (gb_check_disks_only) |
1209 |
{ |
{ |
1226 |
|
|
1227 |
if (gb_html_report) |
if (gb_html_report) |
1228 |
fprintf (file, "</TABLE>\n</BODY></HTML>"); |
fprintf (file, "</TABLE>\n</BODY></HTML>"); |
1229 |
|
if (gb_xml_report) |
1230 |
|
fprintf (file, "</report>"); |
1231 |
fclose (file); |
fclose (file); |
1232 |
if (result) |
if (result) |
1233 |
WARNING_DIALOG (_("Report successful."), report_dialog_window); |
WARNING_DIALOG (_("Report successful."), report_dialog_window); |
1269 |
} |
} |
1270 |
|
|
1271 |
static void |
static void |
1272 |
|
switch_report_name (GtkWidget * w, gpointer data) |
1273 |
|
{ |
1274 |
|
// this should set the default output to |
1275 |
|
// * DEFAULT_REPORT.html |
1276 |
|
// or |
1277 |
|
// * DEFAULT_REPORT.xml |
1278 |
|
// or |
1279 |
|
// * DEFAULT_REPORT.DEFAULT_EXTENSION |
1280 |
|
} |
1281 |
|
|
1282 |
|
static void |
1283 |
switch_dirs (GtkWidget * w, gpointer data) |
switch_dirs (GtkWidget * w, gpointer data) |
1284 |
{ |
{ |
1285 |
GtkWidget *w2 = data; |
GtkWidget *w2 = data; |
1575 |
gtk_box_pack_start (GTK_BOX (vbox2), add_legend, FALSE, FALSE, 0); |
gtk_box_pack_start (GTK_BOX (vbox2), add_legend, FALSE, FALSE, 0); |
1576 |
gtk_widget_show (add_legend); |
gtk_widget_show (add_legend); |
1577 |
|
|
1578 |
button_html = gtk_check_button_new_with_label (_("HTML")); |
// The TEXT - HTML - XML choice radio buttons |
1579 |
gtk_box_pack_start (GTK_BOX (vbox2), button_html, FALSE, TRUE, 0); |
hbox = gtk_hbox_new (FALSE, 2); |
1580 |
|
gtk_container_add (GTK_CONTAINER (vbox2), hbox); |
1581 |
|
gtk_container_border_width (GTK_CONTAINER (hbox), 3); |
1582 |
|
gtk_widget_show (hbox); |
1583 |
|
|
1584 |
|
button_html = gtk_radio_button_new_with_label (NULL , _("HTML")); |
1585 |
|
gtk_box_pack_start (GTK_BOX (hbox), button_html, TRUE, TRUE, 0); |
1586 |
gtk_widget_show (button_html); |
gtk_widget_show (button_html); |
1587 |
|
|
1588 |
|
group_html_xml = gtk_radio_button_group (GTK_RADIO_BUTTON (button_html)); |
1589 |
|
button_xml = gtk_radio_button_new_with_label (group_html_xml, _("XML")); |
1590 |
|
gtk_box_pack_start (GTK_BOX (hbox), button_xml, TRUE, TRUE, 0); |
1591 |
|
gtk_widget_show (button_xml); |
1592 |
|
|
1593 |
|
group_html_xml = gtk_radio_button_group (GTK_RADIO_BUTTON (button_html)); |
1594 |
|
button_txt = gtk_radio_button_new_with_label (group_html_xml, _("txt")); |
1595 |
|
gtk_box_pack_start (GTK_BOX (hbox), button_txt, TRUE, TRUE, 0); |
1596 |
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button_txt), TRUE); |
1597 |
|
gtk_widget_show (button_txt); |
1598 |
|
|
1599 |
gtk_signal_connect (GTK_OBJECT (button_sortbyfile), "clicked", |
gtk_signal_connect (GTK_OBJECT (button_sortbyfile), "clicked", |
1600 |
GTK_SIGNAL_FUNC (switch_size), button_html); |
GTK_SIGNAL_FUNC (switch_size), button_html); |
1601 |
switch_size (button_sortbyfile, button_html); |
switch_size (button_sortbyfile, button_html); |
1602 |
|
|
1603 |
|
gtk_signal_connect (GTK_OBJECT (button_sortbyfile), "clicked", |
1604 |
|
GTK_SIGNAL_FUNC (switch_size), button_xml); |
1605 |
|
|
1606 |
|
gtk_signal_connect (GTK_OBJECT (button_sortbyfile), "clicked", |
1607 |
|
GTK_SIGNAL_FUNC (switch_size), button_txt); |
1608 |
|
|
1609 |
|
// Don't know the exact implementation |
1610 |
|
// Should connect the HTML / XML / txt radio buttons to switch_report_name-function |
1611 |
|
// to set the default report-name. |
1612 |
|
// gtk_signal_connect (GTK_OBJECT (button_html), "clicked", |
1613 |
|
// GTK_SIGNAL_FUNC (switch_report_name), "html"); |
1614 |
|
|
1615 |
button_manydirs = |
button_manydirs = |
1616 |
gtk_check_button_new_with_label (_("dir1/dir2 becomes dir1,dir2")); |
gtk_check_button_new_with_label (_("dir1/dir2 becomes dir1,dir2")); |
1617 |
gtk_box_pack_start (GTK_BOX (vbox2), button_manydirs, FALSE, TRUE, 0); |
gtk_box_pack_start (GTK_BOX (vbox2), button_manydirs, FALSE, TRUE, 0); |
1643 |
gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY (gnome_output_entry)); |
gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY (gnome_output_entry)); |
1644 |
gtk_entry_set_text (GTK_ENTRY (output_entry), report_out = |
gtk_entry_set_text (GTK_ENTRY (output_entry), report_out = |
1645 |
g_strconcat (getenv ("HOME"), "/", DEFAULT_REPORT, |
g_strconcat (getenv ("HOME"), "/", DEFAULT_REPORT, |
1646 |
NULL)); |
".", DEFAULT_EXTENSION, NULL)); |
1647 |
g_free (report_out); |
g_free (report_out); |
1648 |
gtk_box_pack_start (GTK_BOX (hbox), gnome_output_entry, FALSE, FALSE, 0); |
gtk_box_pack_start (GTK_BOX (hbox), gnome_output_entry, FALSE, FALSE, 0); |
1649 |
gtk_widget_show (gnome_output_entry); |
gtk_widget_show (gnome_output_entry); |