Update to current

Added a significant amount more of the UI code
This commit is contained in:
Leeland Heins 2017-04-11 18:22:23 -05:00 committed by GitHub
parent c5dda859f2
commit fbf7281338
53 changed files with 2935 additions and 235 deletions

View File

@ -1,24 +1,39 @@
#
# Makefile for cavaldos. Prety lame, needs to be improved.
# Makefile for cavaldos. Pretty lame, needs to be improved.
#
NAME=calvados
CFLAGS=-g -Wall -o $(NAME)
GTKFLAGS=-export-dynamic `pkg-config --cflags --libs gtk+-2.0`
#GTKFLAGS=-export-dynamic `pkg-config --cflags --libs gtk+-2.0`
GTKFLAGS=`pkg-config --cflags --libs gtk+-2.0`
SRCS=calvados.c select_volume.c closing_dialog.c close_dialog.c show_about.c \
disk_sector_viewer_popup.c create_disk_image.c new_archive.c \
open_file.c okfunc_create_disk_image.c okfunc_select_volume.c \
help_func_create_disk_image.c help_func_select_volume.c \
do_open_file.c save_to_file.c preferences.c
do_open_file.c save_to_file.c preferences.c print.c add_files.c \
do_new_archive.c create_radio.c acceptfunc_add_files.c \
help_func_add_files.c extract_files.c extractfunc_extract_files.c \
help_func_extract_files.c disk_image_converter.c do_image_converter.c \
do_add_files.c archive_info.c edit_comment.c help_func_archive_info.c \
delete_file.c rename.c select_image_convert.c select_first_sst_image.c \
recompress_files.c show_error.c file_viewer.c donefunc_file_viewer.c \
help_func_file_viewer.c add_disk_image.c test.c findfunc_file_viewer.c \
bulk_disk_image_converter.c close.c save_changes.c reopen.c copy.c paste.c \
paste_special.c find.c select_all.c invert_selection.c
OBJS=$(SRCS:.c=.o)
HEADERS=calvados.h
CC=gcc
DESTDIR=/usr/local
INCLUDE=-I/usr/include/glib-2.0/ -I/usr/lib/x86_64-linux-gnu/glib-2.0/include/ -I/usr/include/pango-1.0/ -I/usr/include/cairo/ -I/usr/include/gdk-pixbuf-2.0/ -I/usr/include/atk-1.0/
INCLUDES=-I/usr/include/glib-2.0/ \
-I/usr/lib/x86_64-linux-gnu/glib-2.0/include/ \
-I/usr/include/pango-1.0/ -I/usr/include/cairo/ \
-I/usr/include/gdk-pixbuf-2.0/ -I/usr/include/atk-1.0/ \
-I/usr/include/gtk-unix-print-2.0/
all: calvados
calvados: $(SRCS) $(HEADERS)
$(CC) $(CFLAGS) $(SRCS) $(GTKFLAGS)
$(CC) $(CFLAGS) $(SRCS) $(GTKFLAGS) $(INCLUDES)
install:
/usr/bin/install $(NAME) $(DESTDIR)/bin

23
acceptfunc_add_files.c Normal file
View File

@ -0,0 +1,23 @@
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include "calvados.h"
/*
*
* acceptfunc_add_files()
*
* Accept Function for add files
*
* Show that the "Accept" button was pressed
*
*/
void acceptfunc_add_files(GtkWidget *widget, gpointer data)
{
/* --- Display message --- */
g_print("Add function goes here.\n");
/* --- Close it. --- */
gtk_widget_destroy(GTK_WIDGET(data));
}

72
add_disk_image.c Normal file
View File

@ -0,0 +1,72 @@
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include "calvados.h"
/*
*
* add_disk_image()
*
* Display add disk image dialog
*
*/
void add_disk_image(GtkWidget *widget, gpointer data)
{
GtkWidget *dialog;
gint res;
GtkFileFilter *diskImagesFilt;
GtkFileFilter *allFilesFilt;
g_print("add disk image goes here\n");
diskImagesFilt = gtk_file_filter_new();
gtk_file_filter_set_name(diskImagesFilt, "Disk Images");
gtk_file_filter_add_pattern(diskImagesFilt, "*.[Ss][Hh][Kk]");
gtk_file_filter_add_pattern(diskImagesFilt, "*.[Ss][Dd][Kk]");
gtk_file_filter_add_pattern(diskImagesFilt, "*.[Dd][Ss][Kk]");
gtk_file_filter_add_pattern(diskImagesFilt, "*.[Pp][Oo]");
gtk_file_filter_add_pattern(diskImagesFilt, "*.[Dd][Oo]");
gtk_file_filter_add_pattern(diskImagesFilt, "*.[Dd]13");
gtk_file_filter_add_pattern(diskImagesFilt, "*.2[Mm][Gg]");
gtk_file_filter_add_pattern(diskImagesFilt, "*.[Ii][Mm][Gg]");
gtk_file_filter_add_pattern(diskImagesFilt, "*.[Nn][Ii][Bb]");
gtk_file_filter_add_pattern(diskImagesFilt, "*.[Nn][Bb]2");
gtk_file_filter_add_pattern(diskImagesFilt, "*.[Rr][Aa][Ww]");
gtk_file_filter_add_pattern(diskImagesFilt, "*.[Hh][Dd][Vv]");
gtk_file_filter_add_pattern(diskImagesFilt, "*.[Dd][Cc]");
gtk_file_filter_add_pattern(diskImagesFilt, "*.[Dd][Cc]6");
gtk_file_filter_add_pattern(diskImagesFilt, "*.[Dd][Dd][Dd]");
gtk_file_filter_add_pattern(diskImagesFilt, "*.[Aa][Pp][Pp]");
gtk_file_filter_add_pattern(diskImagesFilt, "*.[Ff][Dd][Ii]");
gtk_file_filter_add_pattern(diskImagesFilt, "*.[Ii][Ss][Oo]");
gtk_file_filter_add_pattern(diskImagesFilt, "*.[Gg][Zz]");
gtk_file_filter_add_pattern(diskImagesFilt, "*.[Zz][Ii][Pp]");
allFilesFilt = gtk_file_filter_new();
gtk_file_filter_set_name(allFilesFilt, "All Files");
gtk_file_filter_add_pattern(allFilesFilt, "*");
dialog = gtk_file_chooser_dialog_new("Add Disk Image",
NULL,
GTK_FILE_CHOOSER_ACTION_OPEN,
GTK_STOCK_CANCEL,
GTK_RESPONSE_CANCEL,
GTK_STOCK_OPEN,
GTK_RESPONSE_ACCEPT,
NULL);
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), diskImagesFilt);
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), allFilesFilt);
res = gtk_dialog_run(GTK_DIALOG(dialog));
if (res == GTK_RESPONSE_ACCEPT) {
char *filename;
GtkFileChooser *chooser = GTK_FILE_CHOOSER(dialog);
filename = gtk_file_chooser_get_filename(chooser);
do_open_file(filename);
g_free(filename);
}
gtk_widget_destroy(dialog);
}

179
add_files.c Normal file
View File

@ -0,0 +1,179 @@
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include "calvados.h"
void fileAttributePreservationRbCallback(GtkWidget *widget, gpointer *data)
{
g_print("clicked %s\n", (char *)data);
}
void textConversionRbCallback(GtkWidget *widget, gpointer *data)
{
g_print("clicked %s\n", (char *)data);
}
/*
*
* add_files()
*
* Add Files dialog box.
*
*/
void add_files()
{
GtkWidget *dialog;
GtkWidget *help_button;
GtkWidget *hbox1;
GtkWidget *vboxl;
GtkWidget *vboxr;
GtkWidget *fileAttributePreservationFrame;
GtkWidget *miscellaneousFrame;
GtkWidget *textConversionFrame;
GtkWidget *fileAttributePreservationVbox;
GtkWidget *miscellaneousVbox;
GtkWidget *textConversionVbox;
GtkWidget *storagePrefixVbox;
GtkWidget *ignoreFileAttributePreservationTagsRb;
GtkWidget *useFileAttributePreservationTagsRb;
GtkWidget *useTagsAndGuessTypeFromExtensionRb;
GSList *fileAttributePreservationRbGroup = NULL;
GtkWidget *dontConvertTextFilesRb;
GtkWidget *convertTextFilesByFileTypeRb;
GtkWidget *autoDetectConvertFilesByFileTypeRb;
GtkWidget *convertAllFilesRb;
GSList *textConversionRbGroup = NULL;
GtkWidget *includeSubfoldersCb;
GtkWidget *stripFolderNamesCb;
GtkWidget *overwriteExistingFilesCb;
GtkWidget *storagePrefixLabel;
GtkWidget *storagePrefixEntry;
/* --- Create the dialog --- */
dialog = gtk_file_chooser_dialog_new("Add Files...",
NULL,
GTK_FILE_CHOOSER_ACTION_SAVE,
"_Accept",
GTK_RESPONSE_ACCEPT,
GTK_STOCK_CANCEL,
GTK_RESPONSE_CANCEL,
/*GTK_STOCK_HELP,
GTK_RESPONSE_HELP,*/
NULL);
gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(dialog), FALSE);
/*
* --- Help button
*/
/* --- Create the "Help" button --- */
help_button = gtk_button_new_with_label("Help");
gtk_widget_show(help_button);
gtk_signal_connect(GTK_OBJECT(help_button), "clicked",
GTK_SIGNAL_FUNC(help_func_select_volume),
dialog);
/* --- Add the "Help" button to the dialog --- */
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->action_area), help_button, TRUE, TRUE, 0);
hbox1 = gtk_hbox_new(FALSE, 0);
gtk_widget_show(hbox1);
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox1, TRUE, TRUE, 0);
vboxl = gtk_vbox_new(FALSE, 0);
gtk_widget_show(vboxl);
gtk_box_pack_start(GTK_BOX(hbox1), vboxl, TRUE, TRUE, 0);
vboxr = gtk_vbox_new(FALSE, 0);
gtk_widget_show(vboxr);
gtk_box_pack_start(GTK_BOX(hbox1), vboxr, TRUE, TRUE, 0);
fileAttributePreservationFrame = gtk_frame_new("File attribute preservation");
gtk_widget_show(fileAttributePreservationFrame);
gtk_box_pack_start(GTK_BOX(vboxl), fileAttributePreservationFrame, TRUE, TRUE, 0);
fileAttributePreservationVbox = gtk_vbox_new(FALSE, 0);
gtk_widget_show(fileAttributePreservationVbox);
gtk_container_add(GTK_CONTAINER(fileAttributePreservationFrame), fileAttributePreservationVbox);
textConversionFrame = gtk_frame_new("Text conversion");
gtk_widget_show(textConversionFrame);
gtk_box_pack_start(GTK_BOX(vboxl), textConversionFrame, TRUE, TRUE, 0);
textConversionVbox = gtk_vbox_new(FALSE, 0);
gtk_widget_show(textConversionVbox);
gtk_container_add(GTK_CONTAINER(textConversionFrame), textConversionVbox);
miscellaneousFrame = gtk_frame_new("Miscellaneous");
gtk_widget_show(miscellaneousFrame);
gtk_box_pack_start(GTK_BOX(vboxr), miscellaneousFrame, TRUE, TRUE, 0);
miscellaneousVbox = gtk_vbox_new(FALSE, 0);
gtk_widget_show(miscellaneousVbox);
gtk_container_add(GTK_CONTAINER(miscellaneousFrame), miscellaneousVbox);
storagePrefixVbox = gtk_vbox_new(FALSE, 0);
gtk_widget_show(storagePrefixVbox);
gtk_box_pack_start(GTK_BOX(vboxr), storagePrefixVbox, TRUE, TRUE, 0);
ignoreFileAttributePreservationTagsRb = create_radio(fileAttributePreservationVbox, &fileAttributePreservationRbGroup, "Ignore file attribute preservation tags");
useFileAttributePreservationTagsRb = create_radio(fileAttributePreservationVbox, &fileAttributePreservationRbGroup, "Use file attribute preservation flags");
useTagsAndGuessTypeFromExtensionRb = create_radio(fileAttributePreservationVbox, &fileAttributePreservationRbGroup, "Use tags and guess type from extension");
dontConvertTextFilesRb = create_radio(textConversionVbox, &textConversionRbGroup, "Don't convert text files");
convertTextFilesByFileTypeRb = create_radio(textConversionVbox, &textConversionRbGroup, "Convert text files by file type");
autoDetectConvertFilesByFileTypeRb = create_radio(textConversionVbox, &textConversionRbGroup, "Auto-detect & Convert text files by file type with text");
convertAllFilesRb = create_radio(textConversionVbox, &textConversionRbGroup, "Convert ALL files");
includeSubfoldersCb = gtk_check_button_new_with_label("Include subfolders");
gtk_widget_show(includeSubfoldersCb);
gtk_box_pack_start(GTK_BOX(miscellaneousVbox), includeSubfoldersCb, TRUE, TRUE, 0);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(includeSubfoldersCb), TRUE);
stripFolderNamesCb = gtk_check_button_new_with_label("Strip folder names");
gtk_widget_show(stripFolderNamesCb);
gtk_box_pack_start(GTK_BOX(miscellaneousVbox), stripFolderNamesCb, TRUE, TRUE, 0);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(stripFolderNamesCb), TRUE);
overwriteExistingFilesCb = gtk_check_button_new_with_label("Overwrite existing files");
gtk_widget_show(overwriteExistingFilesCb);
gtk_box_pack_start(GTK_BOX(miscellaneousVbox), overwriteExistingFilesCb, TRUE, TRUE, 0);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(overwriteExistingFilesCb), TRUE);
storagePrefixLabel = gtk_label_new("Storage prefix");
gtk_widget_show(storagePrefixLabel);
gtk_box_pack_start(GTK_BOX(storagePrefixVbox), storagePrefixLabel, TRUE, TRUE, 0);
storagePrefixEntry = gtk_entry_new();
gtk_widget_show(storagePrefixEntry);
gtk_box_pack_start(GTK_BOX(storagePrefixVbox), storagePrefixEntry, TRUE, TRUE, 0);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(useFileAttributePreservationTagsRb), TRUE);
/* Set up callbacks for file attribute preservation frame */
gtk_signal_connect(GTK_OBJECT(ignoreFileAttributePreservationTagsRb), "clicked", GTK_SIGNAL_FUNC(fileAttributePreservationRbCallback), (gpointer)"ignoreFileAttributePreservationTagsRb");
gtk_signal_connect(GTK_OBJECT(useFileAttributePreservationTagsRb), "clicked", GTK_SIGNAL_FUNC(fileAttributePreservationRbCallback), (gpointer)"useFileAttributePreservationTagsRb");
gtk_signal_connect(GTK_OBJECT(useTagsAndGuessTypeFromExtensionRb), "clicked", GTK_SIGNAL_FUNC(fileAttributePreservationRbCallback), (gpointer)"useTagsAndGuessTypeFromExtensionRb");
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(convertTextFilesByFileTypeRb), TRUE);
/* Set up callbacks for text conversion frame */
gtk_signal_connect(GTK_OBJECT(dontConvertTextFilesRb), "clicked", GTK_SIGNAL_FUNC(textConversionRbCallback), (gpointer)"dontConvertTextFilesRb");
gtk_signal_connect(GTK_OBJECT(convertTextFilesByFileTypeRb), "clicked", GTK_SIGNAL_FUNC(textConversionRbCallback), (gpointer)"convertTextFilesByFileTypeRb");
gtk_signal_connect(GTK_OBJECT(autoDetectConvertFilesByFileTypeRb), "clicked", GTK_SIGNAL_FUNC(textConversionRbCallback), (gpointer)"autoDetectConvertFilesByFileTypeRb");
gtk_signal_connect(GTK_OBJECT(convertAllFilesRb), "clicked", GTK_SIGNAL_FUNC(textConversionRbCallback), (gpointer)"convertAllFilesRb");
/* FIXME -- need to make correct path here */
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), "Desktop");
if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
char *filename;
filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
do_add_files(filename);
g_free(filename);
}
gtk_widget_destroy(dialog);
}

202
archive_info.c Normal file
View File

@ -0,0 +1,202 @@
#include <string.h>
#include <gtk/gtk.h>
#include "calvados.h"
/* FIXME -- this needs to be thought through and moved to the .h file or somewhere better */
#define SHK 0
#define DSK 1
/*
*
* archive_info()
*
*/
void archive_info()
{
GtkWidget *dialog;
GtkWidget *vbox;
GtkWidget *archiveInfoFrame;
GtkWidget *archiveInfoHbox;
GtkWidget *archiveInfoVboxl;
GtkWidget *archiveInfoVboxr;
GtkWidget *filenameLabel;
GtkWidget *formatLabel;
GtkWidget *recordsLabel;
GtkWidget *masterVersionLabel;
GtkWidget *createdLabel;
GtkWidget *modifiedLabel;
GtkWidget *junkSkippedLabel;
GtkWidget *fileCharacteristicsFrame;
GtkWidget *fileCharacteristicsHbox;
GtkWidget *fileCharacteristicsVboxl;
GtkWidget *fileCharacteristicsVboxr;
GtkWidget *diskCharacteristicsFrame;
GtkWidget *diskCharacteristicsHbox;
GtkWidget *diskCharacteristicsInfoVboxl;
GtkWidget *diskCharacteristicsInfoVboxr;
GtkWidget *hbox2;
GtkWidget *helpButton;
GtkWidget *doneButton;
int archive_type = 0;
char dialog_title[256];
g_print("archive info goes here\n");
/* FIXME -- need to detect what type of archive we are looking at */
if (archive_type == SHK) {
strcpy(dialog_title, "NuFX (ShrinkIt) Archive");
} else if (archive_type == DSK) {
strcpy(dialog_title, "Disk Image Info");
} else {
strcpy(dialog_title, "Disk Image Info");
}
/* --- Create a dialog window --- */
dialog = gtk_dialog_new();
/* --- Trap the destroy button --- */
gtk_signal_connect(GTK_OBJECT(dialog), "destroy",
GTK_SIGNAL_FUNC(gtk_widget_destroyed),
&dialog);
/* --- Add a title to the window --- */
gtk_window_set_title(GTK_WINDOW(dialog), dialog_title);
/* --- Create a small border --- */
gtk_container_border_width(GTK_CONTAINER(dialog), 5);
vbox = gtk_vbox_new(FALSE, 0);
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), vbox, TRUE, TRUE, 0);
gtk_widget_show(vbox);
/* For archive info SHK, etc */
if (archive_type == SHK) {
archiveInfoFrame = gtk_frame_new("Archive Info");
gtk_box_pack_start(GTK_BOX(vbox), archiveInfoFrame, TRUE, TRUE, 0);
gtk_widget_show(archiveInfoFrame);
archiveInfoHbox = gtk_hbox_new(FALSE, 0);
gtk_container_add(GTK_CONTAINER(archiveInfoFrame), archiveInfoHbox);
gtk_widget_show(archiveInfoHbox);
archiveInfoVboxl = gtk_vbox_new(FALSE, 0);
gtk_box_pack_start(GTK_BOX(archiveInfoHbox), archiveInfoVboxl, TRUE, TRUE, 0);
gtk_widget_show(archiveInfoVboxl);
archiveInfoVboxr = gtk_vbox_new(FALSE, 0);
gtk_box_pack_start(GTK_BOX(archiveInfoHbox), archiveInfoVboxr, TRUE, TRUE, 0);
gtk_widget_show(archiveInfoVboxr);
filenameLabel = gtk_label_new("Filename:");
gtk_box_pack_start(GTK_BOX(archiveInfoVboxl), filenameLabel, TRUE, TRUE, 0);
gtk_widget_show(filenameLabel);
formatLabel = gtk_label_new("Format:");
gtk_box_pack_start(GTK_BOX(archiveInfoVboxl), formatLabel, TRUE, TRUE, 0);
gtk_widget_show(formatLabel);
recordsLabel = gtk_label_new("Records:");
gtk_box_pack_start(GTK_BOX(archiveInfoVboxl), recordsLabel, TRUE, TRUE, 0);
gtk_widget_show(recordsLabel);
masterVersionLabel = gtk_label_new("Master Version:");
gtk_box_pack_start(GTK_BOX(archiveInfoVboxl), masterVersionLabel, TRUE, TRUE, 0);
gtk_widget_show(masterVersionLabel);
createdLabel = gtk_label_new("Created:");
gtk_box_pack_start(GTK_BOX(archiveInfoVboxl), createdLabel, TRUE, TRUE, 0);
gtk_widget_show(createdLabel);
modifiedLabel = gtk_label_new("Modified:");
gtk_box_pack_start(GTK_BOX(archiveInfoVboxl), modifiedLabel, TRUE, TRUE, 0);
gtk_widget_show(modifiedLabel);
junkSkippedLabel = gtk_label_new("Junk Skipped:");
gtk_box_pack_start(GTK_BOX(archiveInfoVboxl), junkSkippedLabel, TRUE, TRUE, 0);
gtk_widget_show(junkSkippedLabel);
} else {
/* For disk image info DSK, etc */
fileCharacteristicsFrame = gtk_frame_new("File Characteristics");
gtk_box_pack_start(GTK_BOX(vbox), fileCharacteristicsFrame, TRUE, TRUE, 0);
gtk_widget_show(fileCharacteristicsFrame);
fileCharacteristicsHbox = gtk_hbox_new(FALSE, 0);
gtk_container_add(GTK_CONTAINER(fileCharacteristicsFrame), fileCharacteristicsHbox);
gtk_widget_show(fileCharacteristicsHbox);
fileCharacteristicsVboxl = gtk_vbox_new(FALSE, 0);
gtk_box_pack_start(GTK_BOX(fileCharacteristicsHbox), fileCharacteristicsVboxl, TRUE, TRUE, 0);
gtk_widget_show(fileCharacteristicsVboxl);
fileCharacteristicsVboxr = gtk_vbox_new(FALSE, 0);
gtk_box_pack_start(GTK_BOX(fileCharacteristicsHbox), fileCharacteristicsVboxr, TRUE, TRUE, 0);
gtk_widget_show(fileCharacteristicsVboxr);
filenameLabel = gtk_label_new("Filename:");
gtk_box_pack_start(GTK_BOX(fileCharacteristicsVboxl), filenameLabel, TRUE, TRUE, 0);
gtk_widget_show(filenameLabel);
diskCharacteristicsFrame = gtk_frame_new("Disk Characteristics");
gtk_box_pack_start(GTK_BOX(vbox), diskCharacteristicsFrame, TRUE, TRUE, 0);
gtk_widget_show(diskCharacteristicsFrame);
diskCharacteristicsHbox = gtk_hbox_new(FALSE, 0);
gtk_container_add(GTK_CONTAINER(diskCharacteristicsFrame), diskCharacteristicsHbox);
gtk_widget_show(diskCharacteristicsHbox);
}
hbox2 = gtk_hbox_new(FALSE, 0);
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->action_area), hbox2, TRUE, TRUE, 0);
gtk_widget_show(hbox2);
/*
* --- Help button
*/
/* --- Create the "Help" button --- */
helpButton = gtk_button_new_with_label("Help");
gtk_signal_connect(GTK_OBJECT(helpButton), "clicked",
GTK_SIGNAL_FUNC(help_func_archive_info),
dialog);
/* --- Add the "Help" button to the dialog --- */
gtk_box_pack_start(GTK_BOX(hbox2), helpButton, TRUE, TRUE, 0);
/* --- Make the button visible. --- */
gtk_widget_show(helpButton);
/*
* --- "done" button
*/
/* --- Create the "done" button --- */
doneButton = gtk_button_new_with_label("Cancel");
/* --- Need to close the window if they press "done" --- */
gtk_signal_connect(GTK_OBJECT(doneButton), "clicked",
GTK_SIGNAL_FUNC(close_dialog),
dialog);
/* --- Allow it to be the default button --- */
GTK_WIDGET_SET_FLAGS(doneButton, GTK_CAN_DEFAULT);
/* --- Add the button to the dialog --- */
gtk_box_pack_start(GTK_BOX(hbox2), doneButton, TRUE, TRUE, 0);
/* --- Make the button the default button --- */
gtk_widget_grab_default(doneButton);
/* --- Make the button visible --- */
gtk_widget_show(doneButton);
/* --- Need to close the window if they press "done" --- */
gtk_signal_connect(GTK_OBJECT(doneButton), "clicked",
GTK_SIGNAL_FUNC(close_dialog),
dialog);
/* --- Make the dialog visible --- */
gtk_widget_show(dialog);
gtk_grab_add(dialog);
}

View File

@ -0,0 +1,72 @@
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include "calvados.h"
/*
*
* bulk_disk_image_converter()
*
* Display bulk disk image converter dialog
*
*/
void bulk_disk_image_converter(GtkWidget *widget, gpointer data)
{
GtkWidget *dialog;
gint res;
GtkFileFilter *diskImagesFilt;
GtkFileFilter *allFilesFilt;
g_print("bulk disk image convert goes here\n");
diskImagesFilt = gtk_file_filter_new();
gtk_file_filter_set_name(diskImagesFilt, "Disk Images");
gtk_file_filter_add_pattern(diskImagesFilt, "*.[Ss][Hh][Kk]");
gtk_file_filter_add_pattern(diskImagesFilt, "*.[Ss][Dd][Kk]");
gtk_file_filter_add_pattern(diskImagesFilt, "*.[Dd][Ss][Kk]");
gtk_file_filter_add_pattern(diskImagesFilt, "*.[Pp][Oo]");
gtk_file_filter_add_pattern(diskImagesFilt, "*.[Dd][Oo]");
gtk_file_filter_add_pattern(diskImagesFilt, "*.[Dd]13");
gtk_file_filter_add_pattern(diskImagesFilt, "*.2[Mm][Gg]");
gtk_file_filter_add_pattern(diskImagesFilt, "*.[Ii][Mm][Gg]");
gtk_file_filter_add_pattern(diskImagesFilt, "*.[Nn][Ii][Bb]");
gtk_file_filter_add_pattern(diskImagesFilt, "*.[Nn][Bb]2");
gtk_file_filter_add_pattern(diskImagesFilt, "*.[Rr][Aa][Ww]");
gtk_file_filter_add_pattern(diskImagesFilt, "*.[Hh][Dd][Vv]");
gtk_file_filter_add_pattern(diskImagesFilt, "*.[Dd][Cc]");
gtk_file_filter_add_pattern(diskImagesFilt, "*.[Dd][Cc]6");
gtk_file_filter_add_pattern(diskImagesFilt, "*.[Dd][Dd][Dd]");
gtk_file_filter_add_pattern(diskImagesFilt, "*.[Aa][Pp][Pp]");
gtk_file_filter_add_pattern(diskImagesFilt, "*.[Ff][Dd][Ii]");
gtk_file_filter_add_pattern(diskImagesFilt, "*.[Ii][Ss][Oo]");
gtk_file_filter_add_pattern(diskImagesFilt, "*.[Gg][Zz]");
gtk_file_filter_add_pattern(diskImagesFilt, "*.[Zz][Ii][Pp]");
allFilesFilt = gtk_file_filter_new();
gtk_file_filter_set_name(allFilesFilt, "All Files");
gtk_file_filter_add_pattern(allFilesFilt, "*");
dialog = gtk_file_chooser_dialog_new("Select images to convert",
NULL,
GTK_FILE_CHOOSER_ACTION_OPEN,
GTK_STOCK_CANCEL,
GTK_RESPONSE_CANCEL,
GTK_STOCK_OPEN,
GTK_RESPONSE_ACCEPT,
NULL);
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), diskImagesFilt);
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), allFilesFilt);
res = gtk_dialog_run(GTK_DIALOG(dialog));
if (res == GTK_RESPONSE_ACCEPT) {
char *filename;
GtkFileChooser *chooser = GTK_FILE_CHOOSER(dialog);
filename = gtk_file_chooser_get_filename(chooser);
do_open_file(filename);
g_free(filename);
}
gtk_widget_destroy(dialog);
}

View File

@ -7,11 +7,162 @@
* 20170310 Leeland Heins
*
*/
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include <gdk/gdkkeysyms-compat.h>
#include "calvados.h"
enum {
COL_PATHNAME = 0,
COL_TYPE,
COL_AUX,
COL_MODDATE,
COL_FORMAT,
COL_SIZE,
COL_RATIO,
COL_PACKED,
COL_ACCESS,
NUM_MAIN_WINDOW_COLS
};
/* For displaying displaying disk images/archives in main window */
GtkListStore *mw_store;
/*GtkTreeIter mw_iter;*/
GtkCellRenderer *mw_renderer;
GtkTreeModel *mw_model;
GtkWidget *mw_view;
/*
*
* display_image()
*
* Display the tree view in the main window,
*
*/
GtkWidget *display_image(GtkWidget *widget, gpointer data, GtkWidget *mw_box)
{
mw_store = gtk_list_store_new(NUM_MAIN_WINDOW_COLS, G_TYPE_STRING, G_TYPE_UINT);
/*FIXME*/
/* This needs to be in a loop reading from somewhere */
/* Append a row and fill in some data */
/*gtk_list_store_append(store, &mw_iter);
gtk_list_store_set(store, &mw_iter,
COL_PATHNAME, "",
COL_TYPE, "",
COL_AUX, "",
COL_MODDATE, "",
COL_FORMAT, "",
COL_SIZE, "",
COL_RATIO, "",
COL_PACKED, "",
COL_ACCESS, "",
-1);*/
mw_view = gtk_tree_view_new();
gtk_widget_set_size_request(mw_view, LIST_WIDTH, LIST_HEIGHT);
/* --- Column #1 --- */
mw_renderer = gtk_cell_renderer_text_new();
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(mw_view),
-1,
"Pathname",
mw_renderer,
"text", COL_PATHNAME,
NULL);
/* --- Column #2 --- */
mw_renderer = gtk_cell_renderer_text_new();
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(mw_view),
-1,
"Type",
mw_renderer,
"text", COL_TYPE,
NULL);
/* --- Column #3 --- */
mw_renderer = gtk_cell_renderer_text_new();
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(mw_view),
-1,
"Aux",
mw_renderer,
"text", COL_AUX,
NULL);
/* --- Column #4 --- */
mw_renderer = gtk_cell_renderer_text_new();
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(mw_view),
-1,
"Mod Date",
mw_renderer,
"text", COL_MODDATE,
NULL);
/* --- Column #5 --- */
mw_renderer = gtk_cell_renderer_text_new();
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(mw_view),
-1,
"Format",
mw_renderer,
"text", COL_FORMAT,
NULL);
/* --- Column #6 --- */
mw_renderer = gtk_cell_renderer_text_new();
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(mw_view),
-1,
"Size",
mw_renderer,
"text", COL_SIZE,
NULL);
/* --- Column #7 --- */
mw_renderer = gtk_cell_renderer_text_new();
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(mw_view),
-1,
"Ratio",
mw_renderer,
"text", COL_RATIO,
NULL);
/* --- Column #8 --- */
mw_renderer = gtk_cell_renderer_text_new();
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(mw_view),
-1,
"Packed",
mw_renderer,
"text", COL_PACKED,
NULL);
/* --- Column #9 --- */
mw_renderer = gtk_cell_renderer_text_new();
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(mw_view),
-1,
"Access",
mw_renderer,
"text", COL_ACCESS,
NULL);
mw_model = GTK_TREE_MODEL(mw_store);
gtk_tree_view_set_model(GTK_TREE_VIEW(mw_view), mw_model);
/* The tree view has acquired its own reference to the
* model, so we can drop ours. That way the model will
* be freed automatically when the tree view is destroyed */
g_object_unref(mw_model);
gtk_box_pack_start(GTK_BOX(mw_box), mw_view, TRUE, TRUE, 0);
gtk_widget_show(mw_view);
return mw_view;
}
int main(int argc, char *argv[])
{
/* Our root window */
@ -253,9 +404,25 @@ int main(int argc, char *argv[])
gtk_menu_shell_append(GTK_MENU_SHELL(fileMenu), printMi);
gtk_menu_shell_append(GTK_MENU_SHELL(fileMenu), fileSep2);
gtk_menu_shell_append(GTK_MENU_SHELL(fileMenu), quitMi);
/* Add file menu to menu bar */
gtk_menu_shell_append(GTK_MENU_SHELL(menubar), fileMi);
/* connect 'reopen' menu item to the reopen dialog event */
g_signal_connect(G_OBJECT(reopenMi), "activate", G_CALLBACK(reopen_menu_item), (gpointer)"reopenMi");
/* connect 'save changes' menu item to the save_changes dialog event */
g_signal_connect(G_OBJECT(saveChangesMi), "activate", G_CALLBACK(save_changes), (gpointer)"saveChangesMi");
/* connect 'close' menu item to the close_menu_item dialog event */
g_signal_connect(G_OBJECT(closeMi), "activate", G_CALLBACK(close_menu_item), (gpointer)"closeMi");
/* connect 'archive info' menu item to the archive_info dialog event */
g_signal_connect(G_OBJECT(archiveInfoMi), "activate", G_CALLBACK(archive_info), (gpointer)"archiveInfoMi");
/* Hook up the print menu item to the print dialog box */
g_signal_connect(G_OBJECT(printMi), "activate", G_CALLBACK(print_page), (gpointer)"printMi");
/* Edit menu bar items */
editMi = gtk_menu_item_new_with_mnemonic("_Edit");
copyMi = gtk_image_menu_item_new_from_stock(GTK_STOCK_COPY, accel_group);
@ -332,8 +499,26 @@ int main(int argc, char *argv[])
/* Add edit menu to menu bar */
gtk_menu_shell_append(GTK_MENU_SHELL(menubar), editMi);
/* connect 'copy' menu item to the copy_menu_item dialog event */
g_signal_connect(G_OBJECT(copyMi), "activate", G_CALLBACK(copy_menu_item), (gpointer)"copyMi");
/* connect 'paste' menu item to the paste dialog event */
g_signal_connect(G_OBJECT(pasteMi), "activate", G_CALLBACK(paste), (gpointer)"pasteMi");
/* connect 'paste special' menu item to the paste_special dialog event */
g_signal_connect(G_OBJECT(pasteSpecialMi), "activate", G_CALLBACK(paste_special), (gpointer)"pasteSpecialMi");
/* connect 'find' menu item to the find dialog event */
g_signal_connect(G_OBJECT(findMi), "activate", G_CALLBACK(find), (gpointer)"findMi");
/* connect 'select all' menu item to the select_all dialog event */
g_signal_connect(G_OBJECT(selectAllMi), "activate", G_CALLBACK(select_all), (gpointer)"selectAllMi");
/* connect 'invert selection' menu item to the invert_selection dialog event */
g_signal_connect(G_OBJECT(invertSelectionMi), "activate", G_CALLBACK(invert_selection), (gpointer)"invertSelectionMi");
/* connect 'preferences' menu item to the preferences dialog event */
g_signal_connect(G_OBJECT(preferencesMi), "activate", G_CALLBACK(preferences), NULL);
g_signal_connect(G_OBJECT(preferencesMi), "activate", G_CALLBACK(preferences), (gpointer)"preferencesMi");
/* Action menu bar items */
actionsMi = gtk_menu_item_new_with_label("Actions");
@ -431,25 +616,52 @@ int main(int argc, char *argv[])
gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, FALSE, 0);
/* connect 'open image' menu item to the create welcomeage dialog event */
g_signal_connect(G_OBJECT(openMi), "activate", G_CALLBACK(open_file), NULL);
g_signal_connect(G_OBJECT(openMi), "activate", G_CALLBACK(open_file), (gpointer)"openMi");
/* connect 'view' menu item to the file viewer dialog event */
g_signal_connect(G_OBJECT(viewMi), "activate", G_CALLBACK(file_viewer), (gpointer)"viewMi");
/* connect 'disk image' menu item to the create disk image dialog event */
g_signal_connect(G_OBJECT(diskImageMi), "activate", G_CALLBACK(create_disk_image), NULL);
g_signal_connect(G_OBJECT(diskImageMi), "activate", G_CALLBACK(create_disk_image), (gpointer)"diskImageMi");
/* connect 'add disk image' menu item to the add disk image dialog event */
g_signal_connect(G_OBJECT(addDiskImageMi), "activate", G_CALLBACK(add_disk_image), (gpointer)"addDiskImageMi");
/* connect 'shrinkit archive' menu item to the new archive dialog event */
g_signal_connect(G_OBJECT(shrinkItArchiveMi), "activate", G_CALLBACK(new_archive), NULL);
g_signal_connect(G_OBJECT(shrinkItArchiveMi), "activate", G_CALLBACK(new_archive), (gpointer)"shrinkItArchiveMi");
/* connect 'select volume' menu item to the open volume dialog event */
g_signal_connect(G_OBJECT(openVolumeMi), "activate", G_CALLBACK(select_volume), NULL);
g_signal_connect(G_OBJECT(openVolumeMi), "activate", G_CALLBACK(select_volume), (gpointer)"openVolumeMi");
/* connect 'rename' menu item to the rename dialog event */
g_signal_connect(G_OBJECT(renameMi), "activate", G_CALLBACK(rename_file), (gpointer)"renameMi");
/* connect 'delete' menu item to the delete dialog event */
g_signal_connect(G_OBJECT(deleteMi), "activate", G_CALLBACK(delete_file), (gpointer)"deleteMi");
/* connect 'recompress' menu item to the recompress dialog event */
g_signal_connect(G_OBJECT(recompressMi), "activate", G_CALLBACK(recompress_files), (gpointer)"recompressMi");
/* connect 'edit comment' menu item to the edit comment dialog event */
g_signal_connect(G_OBJECT(editCommentMi), "activate", G_CALLBACK(edit_comment), (gpointer)"editCommentMi");
/* connect 'about' menu item to the about box event */
g_signal_connect(G_OBJECT(aboutCalvadosMi), "activate", G_CALLBACK(show_about), NULL);
g_signal_connect(G_OBJECT(aboutCalvadosMi), "activate", G_CALLBACK(show_about), (gpointer)"aboutCalvadosMi");
/* connect 'disk sector viewer' menu item to the popup menu event */
g_signal_connect(G_OBJECT(diskSectorViewerMi), "activate", G_CALLBACK(disk_sector_viewer_popup), NULL);
g_signal_connect(G_OBJECT(diskSectorViewerMi), "activate", G_CALLBACK(disk_sector_viewer_popup), (gpointer)"diskSectorViewerMi");
/* connect 'Select image convert' menu item to the select image conversions popup menu event */
g_signal_connect(G_OBJECT(diskImageConverterMi), "activate", G_CALLBACK(select_image_convert), (gpointer)"diskImageConverterMi");
/* connect 'Select bulk disk image converter' menu item to the bulk disk image converter popup menu event */
g_signal_connect(G_OBJECT(bulkDiskImageConverterMi), "activate", G_CALLBACK(bulk_disk_image_converter), (gpointer)"bulkDiskImageConverterMi");
/* connect 'Merge SST Images' menu item to the merge sst images popup menu event */
g_signal_connect(G_OBJECT(mergeSSTImagesMi), "activate", G_CALLBACK(select_first_sst_image), (gpointer)"mergeSSTImagesMi");
/* Connect 'quit' menu item to the window's "destroy" event */
g_signal_connect(G_OBJECT(quitMi), "activate", G_CALLBACK(gtk_main_quit), NULL);
g_signal_connect(G_OBJECT(quitMi), "activate", G_CALLBACK(gtk_main_quit), (gpointer)"quitMi");
/* Create the tool bar */
toolbar = gtk_toolbar_new();
@ -587,30 +799,69 @@ int main(int argc, char *argv[])
gtk_widget_set_tooltip_text(GTK_WIDGET(exitTb), "Exit");
/* Hook up the open image button to the open file dialog box */
g_signal_connect(G_OBJECT(openTb), "clicked", G_CALLBACK(open_file), NULL);
g_signal_connect(G_OBJECT(openTb), "clicked", G_CALLBACK(open_file), (gpointer)"openTb");
/* Hook up the create disk image button to the create disk image dialog box */
g_signal_connect(G_OBJECT(createDiskImageTb), "clicked", G_CALLBACK(create_disk_image), NULL);
g_signal_connect(G_OBJECT(createDiskImageTb), "clicked", G_CALLBACK(create_disk_image), (gpointer)"createDiskImageTb");
/* Hook up the new archive image button to the create disk image dialog box */
g_signal_connect(G_OBJECT(newArchiveTb), "clicked", G_CALLBACK(new_archive), NULL);
g_signal_connect(G_OBJECT(newArchiveTb), "clicked", G_CALLBACK(new_archive), (gpointer)"newArchiveTb");
/* Hook up the open volume button to the select volume dialog box */
g_signal_connect(G_OBJECT(openVolumeTb), "clicked", G_CALLBACK(select_volume), NULL);
g_signal_connect(G_OBJECT(openVolumeTb), "clicked", G_CALLBACK(select_volume), (gpointer)"openVolumeTb");
/* Hook up the print button to the print dialog box */
g_signal_connect(G_OBJECT(printTb), "clicked", G_CALLBACK(print_page), (gpointer)window);
/* Hook up the add files button to the add files dialog box */
g_signal_connect(G_OBJECT(addFilesTb), "clicked", G_CALLBACK(add_files), (gpointer)"addFilesTb");
/* Hook up the add disk image button to the add disk image dialog box */
g_signal_connect(G_OBJECT(addDiskImageTb), "clicked", G_CALLBACK(add_disk_image), (gpointer)"addDiskImageTb");
/* Hook up the view button to the file viewer dialog box */
g_signal_connect(G_OBJECT(viewTb), "clicked", G_CALLBACK(file_viewer), (gpointer)"viewTb");
/* Hook up the extract files button to the extract files dialog box */
g_signal_connect(G_OBJECT(extractTb), "clicked", G_CALLBACK(extract_files), (gpointer)"extractTb");
/* Hook up the test button to the test dialog box */
g_signal_connect(G_OBJECT(testTb), "clicked", G_CALLBACK(test), (gpointer)"testTb");
/* Hook up the rename button to the rename dialog box */
g_signal_connect(G_OBJECT(renameTb), "clicked", G_CALLBACK(rename_file), (gpointer)"renameTb");
/* Hook up the delete button to the delete dialog box */
g_signal_connect(G_OBJECT(deleteTb), "clicked", G_CALLBACK(delete_file), (gpointer)"deleteTb");
/* Hook up the recompress button to the delete dialog box */
g_signal_connect(G_OBJECT(recompressTb), "clicked", G_CALLBACK(recompress_files), (gpointer)"recompressTb");
/* Hook up the edit comment button to the edit comment dialog box */
g_signal_connect(G_OBJECT(editCommentTb), "clicked", G_CALLBACK(edit_comment), (gpointer)"editCommentTb");
/* Hook up the disk sector viewer button to the disk sector viewer popup menu */
g_signal_connect(G_OBJECT(diskSectorViewerTb), "clicked", G_CALLBACK(disk_sector_viewer_popup), NULL);
g_signal_connect(G_OBJECT(diskSectorViewerTb), "clicked", G_CALLBACK(disk_sector_viewer_popup), (gpointer)"diskSectorViewerTb");
/* Hook up the disk image converter button to the disk image converter dialog box */
g_signal_connect(G_OBJECT(diskImageConverterTb), "clicked", G_CALLBACK(disk_image_converter), (gpointer)"diskImageConverterTb");
/* Hook up the volume copier button to the volume copier dialog box */
/* FIXME */
g_signal_connect(G_OBJECT(volumeCopierTb), "clicked", G_CALLBACK(select_volume), (gpointer)"volumeCopierTb");
/* Hook up the 'Select image convert' button item to the select image conversions dialog box */
g_signal_connect(G_OBJECT(diskImageConverterTb), "clicked", G_CALLBACK(select_image_convert), (gpointer)"diskImageConverterTb");
/* Hook up the merge sst images button to the merge sst images dialog box */
g_signal_connect(G_OBJECT(mergeSSTImagesTb), "clicked", G_CALLBACK(select_first_sst_image), (gpointer)"mergeSSTImagesTb");
/* Hook up the exit button to the quit function */
g_signal_connect(G_OBJECT(exitTb), "clicked", G_CALLBACK(gtk_main_quit), NULL);
g_signal_connect(G_OBJECT(exitTb), "clicked", G_CALLBACK(gtk_main_quit), (gpointer)"exitTb");
/* Add the tool bar to the vbox */
gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, FALSE, 5);
/*button = gtk_button_new_with_label("Hello Window");
gtk_container_add(GTK_CONTAINER(vbox), button);
g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(gtk_main_quit), NULL);*/
/* Add the status bar */
statusbar = gtk_statusbar_new();
gtk_box_pack_end(GTK_BOX(vbox), statusbar, FALSE, TRUE, 0);

View File

@ -6,12 +6,16 @@
*
*/
/* Main window size */
#define WINDOW_WIDTH 1300
#define WINDOW_HEIGHT 725
#define LIST_WIDTH 1280
#define LIST_HEIGHT 705
/* Prototypes */
void close_dialog(GtkWidget *widget, gpointer data);
void closing_dialog(GtkWidget *widget, gpointer data);
void select_volume();
void select_volume(GtkWidget *widget, gpointer data);
void show_about(GtkWidget *widget, gpointer data);
void disk_sector_viewer_popup();
void okfunc_create_disk_image(GtkWidget *widget, gpointer data);
@ -22,6 +26,44 @@ void create_disk_image();
void do_open_file(char *filename);
void open_file();
void save_to_file(char *filename);
void do_new_archive(char *filename);
void new_archive();
void preferences();
void print_page(GtkWidget *widget, gpointer user_data);
void add_files();
GtkWidget *create_radio(GtkWidget *box, GSList **group, char *rLabel);
void acceptfunc_add_files(GtkWidget *widget, gpointer data);
void help_func_add_files(GtkWidget *widget, gpointer data);
void extract_files();
void extractfunc_extract_files(GtkWidget *widget, gpointer data);
void help_func_extract_files(GtkWidget *widget, gpointer data);
void disk_image_converter(GtkWidget *widget, gpointer data);
void do_image_converter(char *filename);
void do_add_files(char *filename);
void archive_info();
void help_func_archive_info(GtkWidget *widget, gpointer data);
void delete_file(GtkWidget *widget, gpointer data);
void rename_file(GtkWidget *widget, gpointer data);
void select_first_sst_image(GtkWidget *widget, gpointer data);
void select_image_convert(GtkWidget *widget, gpointer data);
void recompress_files(GtkWidget *widget, gpointer data);
void show_error(GtkWidget *widget, gpointer data, char *message);
GtkWidget *display_image(GtkWidget *widget, gpointer data, GtkWidget *mw_box);
void file_viewer(GtkWidget *widget, gpointer data);
void donefunc_file_viewer(GtkWidget *widget, gpointer data);
void help_func_file_viewer(GtkWidget *widget, gpointer data);
void add_disk_image(GtkWidget *widget, gpointer data);
void test(GtkWidget *widget, gpointer data);
void edit_comment(GtkWidget *widget, gpointer data);
void findfunc_file_viewer(GtkWidget *widget, gpointer data);
void bulk_disk_image_converter(GtkWidget *widget, gpointer data);
void close_menu_item(GtkWidget *widget, gpointer data);
void save_changes(GtkWidget *widget, gpointer data);
void reopen_menu_item(GtkWidget *widget, gpointer data);
void copy_menu_item(GtkWidget *widget, gpointer data);
void paste(GtkWidget *widget, gpointer data);
void paste_special(GtkWidget *widget, gpointer data);
void find(GtkWidget *widget, gpointer data);
void select_all(GtkWidget *widget, gpointer data);
void invert_selection(GtkWidget *widget, gpointer data);

15
close.c Normal file
View File

@ -0,0 +1,15 @@
#include <gtk/gtk.h>
/*
*
* close_menu_item()
*
* Close from the menu.
*
*/
void close_menu_item(GtkWidget *widget, gpointer data)
{
/* --- Display message --- */
g_print("Close function goes here.\n");
}

15
copy.c Normal file
View File

@ -0,0 +1,15 @@
#include <gtk/gtk.h>
/*
*
* copy_menu_item()
*
* Copy from the menu.
*
*/
void copy_menu_item(GtkWidget *widget, gpointer data)
{
/* --- Display message --- */
g_print("Copy function goes here.\n");
}

View File

@ -1,8 +1,73 @@
#include <string.h>
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include <gdk/gdkkeysyms-compat.h>
#include "calvados.h"
GtkWidget *allocateDOSTracksCb;
GtkWidget *diskVolumeEntry;
GtkWidget *prodosVolumeEntry;
GtkWidget *pascalVolumeEntry;
GtkWidget *hfsVolumeEntry;
GtkWidget *blocksEntry;
GtkWidget *blocksLabel;
/*
*
* Grey out radio buttons, checkboxes and entries as appropriate
* for filesystem radio button group.
*
*/
void filesystemRbCallback(GtkWidget *widget, gpointer *data)
{
if ((strcmp((char *)data, "dos32Rb") == 0) ||
(strcmp((char *)data, "dos33Rb") == 0)) {
gtk_widget_set_sensitive(allocateDOSTracksCb, TRUE);
gtk_widget_set_sensitive(diskVolumeEntry, TRUE);
gtk_widget_set_sensitive(prodosVolumeEntry, FALSE);
gtk_widget_set_sensitive(pascalVolumeEntry, FALSE);
gtk_widget_set_sensitive(hfsVolumeEntry, FALSE);
} else if (strcmp((char *)data, "prodosRb") == 0) {
gtk_widget_set_sensitive(allocateDOSTracksCb, FALSE);
gtk_widget_set_sensitive(diskVolumeEntry, FALSE);
gtk_widget_set_sensitive(prodosVolumeEntry, TRUE);
gtk_widget_set_sensitive(pascalVolumeEntry, FALSE);
gtk_widget_set_sensitive(hfsVolumeEntry, FALSE);
} else if (strcmp((char *)data, "pascalRb") == 0) {
gtk_widget_set_sensitive(allocateDOSTracksCb, FALSE);
gtk_widget_set_sensitive(diskVolumeEntry, FALSE);
gtk_widget_set_sensitive(prodosVolumeEntry, FALSE);
gtk_widget_set_sensitive(pascalVolumeEntry, TRUE);
gtk_widget_set_sensitive(hfsVolumeEntry, FALSE);
} else if (strcmp((char *)data, "hfsRb") == 0) {
gtk_widget_set_sensitive(allocateDOSTracksCb, FALSE);
gtk_widget_set_sensitive(diskVolumeEntry, FALSE);
gtk_widget_set_sensitive(prodosVolumeEntry, FALSE);
gtk_widget_set_sensitive(pascalVolumeEntry, FALSE);
gtk_widget_set_sensitive(hfsVolumeEntry, TRUE);
} else if (strcmp((char *)data, "blankRb") == 0) {
gtk_widget_set_sensitive(allocateDOSTracksCb, FALSE);
gtk_widget_set_sensitive(diskVolumeEntry, FALSE);
gtk_widget_set_sensitive(prodosVolumeEntry, FALSE);
gtk_widget_set_sensitive(pascalVolumeEntry, FALSE);
gtk_widget_set_sensitive(hfsVolumeEntry, FALSE);
}
}
void newDiskSizeRbCallback(GtkWidget *widget, gpointer *data)
{
if (strcmp((char *)data, "specifyRb") == 0) {
gtk_widget_set_sensitive(blocksEntry, TRUE);
gtk_widget_set_sensitive(blocksLabel, TRUE);
} else {
gtk_widget_set_sensitive(blocksEntry, FALSE);
gtk_widget_set_sensitive(blocksLabel, FALSE);
}
}
/*
*
* create_disk_image()
@ -12,7 +77,7 @@
*/
void create_disk_image()
{
GtkWidget *dialog_window;
GtkWidget *dialog;
GtkWidget *ok_button;
GtkWidget *cancel_button;
GtkWidget *help_button;
@ -37,6 +102,7 @@ void create_disk_image()
GtkWidget *pascalRb;
GtkWidget *hfsRb;
GtkWidget *blankRb;
GSList *filesystemRbGroup = NULL;
GtkWidget *s140kRb;
GtkWidget *s800kRb;
GtkWidget *s14MRb;
@ -44,38 +110,37 @@ void create_disk_image()
GtkWidget *s16MBRb;
GtkWidget *s20MBRb;
GtkWidget *s32MBRb;
GtkWidget *specifyRb;
GtkWidget *blocksEntry;
GtkWidget *blocksLabel;
GtkWidget *specifyHbox;
GtkWidget *allocateDOSTracksCb;
GtkWidget *specifyRb;
GSList *newDiskSizeRbGroup = NULL;
/*GtkWidget *allocateDOSTracksCb;*/
GtkWidget *diskVolumeLabel;
GtkWidget *diskVolumeEntry;
/*GtkWidget *diskVolumeEntry;*/
GtkWidget *diskVolumeHbox;
GtkWidget *prodosVolumeLabel;
GtkWidget *prodosVolumeEntry;
/*GtkWidget *prodosVolumeEntry;*/
GtkWidget *pascalVolumeLabel;
GtkWidget *pascalVolumeEntry;
/*GtkWidget *pascalVolumeEntry;*/
GtkWidget *hfsVolumeLabel;
GtkWidget *hfsVolumeEntry;
/*GtkWidget *hfsVolumeEntry;*/
/* --- Create the dialog --- */
dialog_window = gtk_dialog_new();
dialog = gtk_dialog_new();
/* --- Trap the window close signal to release the grab --- */
gtk_signal_connect(GTK_OBJECT(dialog_window), "destroy",
gtk_signal_connect(GTK_OBJECT(dialog), "destroy",
GTK_SIGNAL_FUNC(closing_dialog),
&dialog_window);
&dialog);
/* --- Set the title --- */
gtk_window_set_title(GTK_WINDOW(dialog_window), "Create Disk Image");
gtk_window_set_title(GTK_WINDOW(dialog), "Create Disk Image");
/* --- Add a small border --- */
gtk_container_border_width(GTK_CONTAINER(dialog_window), 5);
gtk_container_border_width(GTK_CONTAINER(dialog), 5);
/* Two columns top portion of dialog vbox */
hbox1 = gtk_hbox_new(FALSE, 0);
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog_window)->vbox), hbox1, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox1, TRUE, TRUE, 0);
gtk_widget_show(hbox1);
@ -138,68 +203,36 @@ void create_disk_image()
gtk_container_add(GTK_CONTAINER(hfsOptionsFrame), hfsOptionsVbox);
gtk_widget_show(hfsOptionsVbox);
dos32Rb = gtk_radio_button_new_with_label(NULL, "DOS 3.2 (13-sector)");
dos33Rb = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(dos32Rb), "DOS 3.3");
prodosRb = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(dos33Rb), "ProDOS");
pascalRb = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(prodosRb), "Pascal");
hfsRb = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(pascalRb), "HFS");
blankRb = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(hfsRb), "Blank");
gtk_box_pack_start(GTK_BOX(filesystemVbox), dos32Rb, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(filesystemVbox), dos33Rb, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(filesystemVbox), prodosRb, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(filesystemVbox), pascalRb, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(filesystemVbox), hfsRb, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(filesystemVbox), blankRb, TRUE, TRUE, 0);
gtk_widget_show(dos32Rb);
gtk_widget_show(dos33Rb);
gtk_widget_show(prodosRb);
gtk_widget_show(pascalRb);
gtk_widget_show(hfsRb);
gtk_widget_show(blankRb);
s140kRb = gtk_radio_button_new_with_label(NULL, "140KB (5.25\" floppy)");
s800kRb = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(s140kRb), "800KB (3.5\" floppy)");
s14MRb = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(s800kRb), "1.4MB (3.5\" PC floppy)");
s5MBRb = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(s14MRb), "5MB");
s16MBRb = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(s5MBRb), "16MB");
s20MBRb = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(s16MBRb), "20MB");
s32MBRb = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(s20MBRb), "32MB (largest ProDOS volume)");
specifyRb = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(s32MBRb), "Specify size:");
dos32Rb = create_radio(filesystemVbox, &filesystemRbGroup, "DOS 3.2 (13-sector)");
dos33Rb = create_radio(filesystemVbox, &filesystemRbGroup, "DOS 3.3");
prodosRb = create_radio(filesystemVbox, &filesystemRbGroup, "ProDOS");
pascalRb = create_radio(filesystemVbox, &filesystemRbGroup, "Pascal");
hfsRb = create_radio(filesystemVbox, &filesystemRbGroup, "HFS");
blankRb = create_radio(filesystemVbox, &filesystemRbGroup, "Blank");
specifyHbox = gtk_hbox_new(FALSE, 0);
gtk_widget_show(specifyHbox);
s140kRb = create_radio(newDiskSizeVbox, &newDiskSizeRbGroup, "140KB (5.25\" floppy)");
s800kRb = create_radio(newDiskSizeVbox, &newDiskSizeRbGroup, "800KB (3.5\" floppy)");
s14MRb = create_radio(newDiskSizeVbox, &newDiskSizeRbGroup, "1.4MB (3.5\" PC floppy)");
s5MBRb = create_radio(newDiskSizeVbox, &newDiskSizeRbGroup, "5MB");
s16MBRb = create_radio(newDiskSizeVbox, &newDiskSizeRbGroup, "16MB");
s20MBRb = create_radio(newDiskSizeVbox, &newDiskSizeRbGroup, "20MB");
s32MBRb = create_radio(newDiskSizeVbox, &newDiskSizeRbGroup, "32MB (largest ProDOS volume)");
specifyRb = create_radio(specifyHbox, &newDiskSizeRbGroup, "Specify size:");
blocksEntry = gtk_entry_new();
gtk_entry_set_max_length(GTK_ENTRY(blocksEntry), 8);
gtk_box_pack_start(GTK_BOX(specifyHbox), blocksEntry, TRUE, TRUE, 0);
gtk_widget_show(blocksEntry);
blocksLabel = gtk_label_new(" blocks");
gtk_misc_set_alignment(GTK_MISC(blocksLabel), 0, 0.5);
gtk_box_pack_start(GTK_BOX(specifyHbox), specifyRb, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(specifyHbox), blocksEntry, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(specifyHbox), blocksLabel, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(newDiskSizeVbox), s140kRb, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(newDiskSizeVbox), s800kRb, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(newDiskSizeVbox), s14MRb, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(newDiskSizeVbox), s5MBRb, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(newDiskSizeVbox), s16MBRb, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(newDiskSizeVbox), s20MBRb, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(newDiskSizeVbox), s32MBRb, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(newDiskSizeVbox), specifyHbox, TRUE, TRUE, 0);
gtk_widget_show(s140kRb);
gtk_widget_show(s800kRb);
gtk_widget_show(s14MRb);
gtk_widget_show(s5MBRb);
gtk_widget_show(s16MBRb);
gtk_widget_show(s20MBRb);
gtk_widget_show(s32MBRb);
gtk_widget_show(specifyRb);
gtk_widget_show(blocksEntry);
gtk_widget_show(blocksLabel);
gtk_widget_show(specifyHbox);
gtk_box_pack_start(GTK_BOX(newDiskSizeVbox), specifyHbox, TRUE, TRUE, 0);
allocateDOSTracksCb = gtk_check_button_new_with_label("Allocate DOS tracks");
@ -258,6 +291,46 @@ void create_disk_image()
gtk_widget_show(hfsVolumeLabel);
gtk_widget_show(hfsVolumeEntry);
/* Set default selections. */
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(prodosRb), TRUE);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(s140kRb), TRUE);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(allocateDOSTracksCb), TRUE);
gtk_entry_set_text(GTK_ENTRY(blocksEntry), "280");
gtk_entry_set_text(GTK_ENTRY(diskVolumeEntry), "254");
gtk_entry_set_text(GTK_ENTRY(prodosVolumeEntry), "NEW.DISK");
gtk_entry_set_text(GTK_ENTRY(pascalVolumeEntry), "BLANK");
gtk_entry_set_text(GTK_ENTRY(hfsVolumeEntry), "New Disk");
/* Set default sensitivity to prodos */
gtk_widget_set_sensitive(allocateDOSTracksCb, FALSE);
gtk_widget_set_sensitive(diskVolumeEntry, FALSE);
gtk_widget_set_sensitive(prodosVolumeEntry, TRUE);
gtk_widget_set_sensitive(pascalVolumeEntry, FALSE);
gtk_widget_set_sensitive(hfsVolumeEntry, FALSE);
/* Set up callbacks for filesystem frame */
gtk_signal_connect(GTK_OBJECT(dos32Rb), "clicked", GTK_SIGNAL_FUNC(filesystemRbCallback), (gpointer)"dos32Rb");
gtk_signal_connect(GTK_OBJECT(dos33Rb), "clicked", GTK_SIGNAL_FUNC(filesystemRbCallback), (gpointer)"dos33Rb");
gtk_signal_connect(GTK_OBJECT(prodosRb), "clicked", GTK_SIGNAL_FUNC(filesystemRbCallback), (gpointer)"prodosRb");
gtk_signal_connect(GTK_OBJECT(pascalRb), "clicked", GTK_SIGNAL_FUNC(filesystemRbCallback), (gpointer)"pascalRb");
gtk_signal_connect(GTK_OBJECT(hfsRb), "clicked", GTK_SIGNAL_FUNC(filesystemRbCallback), (gpointer)"hfsRb");
gtk_signal_connect(GTK_OBJECT(blankRb), "clicked", GTK_SIGNAL_FUNC(filesystemRbCallback), (gpointer)"blankRb");
/* Set up callbacks for new disk size frame */
gtk_signal_connect(GTK_OBJECT(s140kRb), "clicked", GTK_SIGNAL_FUNC(newDiskSizeRbCallback), (gpointer)"s140kRb");
gtk_signal_connect(GTK_OBJECT(s800kRb), "clicked", GTK_SIGNAL_FUNC(newDiskSizeRbCallback), (gpointer)"s800kRb");
gtk_signal_connect(GTK_OBJECT(s14MRb), "clicked", GTK_SIGNAL_FUNC(newDiskSizeRbCallback), (gpointer)"s14MRb");
gtk_signal_connect(GTK_OBJECT(s5MBRb), "clicked", GTK_SIGNAL_FUNC(newDiskSizeRbCallback), (gpointer)"s5MBRb");
gtk_signal_connect(GTK_OBJECT(s16MBRb), "clicked", GTK_SIGNAL_FUNC(newDiskSizeRbCallback), (gpointer)"s16MBRb");
gtk_signal_connect(GTK_OBJECT(s20MBRb), "clicked", GTK_SIGNAL_FUNC(newDiskSizeRbCallback), (gpointer)"s20MBRb");
gtk_signal_connect(GTK_OBJECT(s32MBRb), "clicked", GTK_SIGNAL_FUNC(newDiskSizeRbCallback), (gpointer)"s32MBRb");
gtk_signal_connect(GTK_OBJECT(specifyRb), "clicked", GTK_SIGNAL_FUNC(newDiskSizeRbCallback), (gpointer)"specifyRb");
/* Set default sensitivity to not specify */
gtk_widget_set_sensitive(blocksEntry, FALSE);
gtk_widget_set_sensitive(blocksLabel, FALSE);
/*
* --- OK button
*/
@ -267,13 +340,13 @@ void create_disk_image()
gtk_signal_connect(GTK_OBJECT(ok_button), "clicked",
GTK_SIGNAL_FUNC(okfunc_create_disk_image),
dialog_window);
dialog);
/* --- Allow "Cancel" to be a default --- */
GTK_WIDGET_SET_FLAGS(ok_button, GTK_CAN_DEFAULT);
/* --- Add the OK button to the bottom hbox2 --- */
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog_window)->action_area), ok_button, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->action_area), ok_button, TRUE, TRUE, 0);
/* --- Make the "OK" the default --- */
gtk_widget_grab_default(ok_button);
@ -290,13 +363,13 @@ void create_disk_image()
gtk_signal_connect(GTK_OBJECT(cancel_button), "clicked",
GTK_SIGNAL_FUNC(close_dialog),
dialog_window);
dialog);
/* --- Allow "Cancel" to be a default --- */
GTK_WIDGET_SET_FLAGS(cancel_button, GTK_CAN_DEFAULT);
/* --- Add the "Cancel" button to the dialog --- */
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog_window)->action_area), cancel_button, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->action_area), cancel_button, TRUE, TRUE, 0);
/* --- Make the button visible. --- */
gtk_widget_show(cancel_button);
@ -310,18 +383,18 @@ void create_disk_image()
gtk_signal_connect(GTK_OBJECT(help_button), "clicked",
GTK_SIGNAL_FUNC(help_func_create_disk_image),
dialog_window);
dialog);
/* --- Add the "Help" button to the dialog --- */
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog_window)->action_area), help_button, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->action_area), help_button, TRUE, TRUE, 0);
/* --- Make the button visible. --- */
gtk_widget_show(help_button);