Commit 45c51f55 authored by Andy Hertzfeld's avatar Andy Hertzfeld
Browse files

made the rpm view handle error presentation for the verify command.


	made the rpm view handle error presentation for the verify command.
parent 8eb88fc0
2000-09-03 Andy Hertzfeld <andy@eazel.com>
* components/rpmview/nautilus-rpm-verify-window.h:
added "continue" signal
* components/rpmview/nautilus-rpm-verify-window.c:
(nautilus_rpm_verify_window_initialize_class),
(continue_button_callback), (cancel_button_callback),
(nautilus_rpm_verify_window_initialize),
(nautilus_rpm_verify_window_set_error_mode):
implemented verify error presentation, by adding a continue and cancel button,
with a method to show them, and a signal to resume verification after errors
* components/rpmview/nautilus-rpm-view.c:
(nautilus_rpm_view_verify_files),
(nautilus_rpm_view_verify_package_callback),
(rpm_view_continue_verify):
connect to the "continue" signal and resume verification; remember where we
left off in an instance variable. We still need more descriptive messages.
2000-09-02 Andy Hertzfeld <andy@eazel.com>
* components/rpmview/Makefile.am:
......@@ -12,7 +31,7 @@
(nautilus_rpm_view_destroy), (nautilus_rpm_view_update_from_uri),
(nautilus_rpm_view_verify_package_callback):
made the verify command work, but it's still needs to handle verification errors
made it list files with rpm version 3.0 or greater
made the file list work correctly with rpmlib version >= 3.0
* src/nautilus-about.c: (nautilus_about_draw_info):
at Arlo's request, made the comment text in the about window have a white shadow
......
......@@ -49,10 +49,18 @@
struct NautilusRPMVerifyWindowDetails {
GtkWidget *package_name;
GtkWidget *file_message;
gboolean error_mode;
GtkWidget *continue_button;
GtkWidget *cancel_button;
};
enum {
CONTINUE,
LAST_SIGNAL
};
static guint signals[LAST_SIGNAL];
static void nautilus_rpm_verify_window_initialize_class (NautilusRPMVerifyWindowClass *klass);
static void nautilus_rpm_verify_window_initialize (NautilusRPMVerifyWindow *rpm_verify_window);
static void nautilus_rpm_verify_window_destroy (GtkObject *object);
......@@ -63,6 +71,17 @@ static void
nautilus_rpm_verify_window_initialize_class (NautilusRPMVerifyWindowClass *rpm_verify_window_class)
{
GtkObjectClass *object_class = GTK_OBJECT_CLASS (rpm_verify_window_class);
signals[CONTINUE]
= gtk_signal_new ("continue",
GTK_RUN_LAST,
object_class->type,
GTK_SIGNAL_OFFSET (NautilusRPMVerifyWindowClass,
continue_verify),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL);
object_class->destroy = nautilus_rpm_verify_window_destroy;
}
......@@ -79,13 +98,29 @@ nautilus_rpm_verify_window_destroy (GtkObject *object)
NAUTILUS_CALL_PARENT_CLASS (GTK_OBJECT_CLASS, destroy, (object));
}
/* handle the continue button */
static void
continue_button_callback (GtkWidget *widget, NautilusRPMVerifyWindow *rpm_verify_window)
{
gtk_signal_emit (GTK_OBJECT (rpm_verify_window),
signals[CONTINUE]);
}
/* handle the cancel button */
static void
cancel_button_callback (GtkWidget *widget, NautilusRPMVerifyWindow *rpm_verify_window)
{
nautilus_rpm_verify_window_set_error_mode (rpm_verify_window, FALSE);
gnome_dialog_close (GNOME_DIALOG (rpm_verify_window));
}
/* initialize the rpm_verify_window */
static void
nautilus_rpm_verify_window_initialize (NautilusRPMVerifyWindow *rpm_verify_window)
{
GtkWidget *window_contents;
GtkWidget *label;
GtkWidget *label, *button_box;
rpm_verify_window->details = g_new0 (NautilusRPMVerifyWindowDetails, 1);
......@@ -111,8 +146,21 @@ nautilus_rpm_verify_window_initialize (NautilusRPMVerifyWindow *rpm_verify_windo
gtk_box_pack_start (GTK_BOX (window_contents), label, FALSE, FALSE, 8);
rpm_verify_window->details->file_message = label;
/* allocate the error mode buttons */
button_box = gtk_hbox_new (FALSE, 2);
gtk_widget_show (button_box);
gtk_box_pack_start (GTK_BOX (window_contents), button_box, FALSE, FALSE, 8);
rpm_verify_window->details->continue_button = gtk_button_new_with_label ("Continue");
gtk_box_pack_start (GTK_BOX (button_box), rpm_verify_window->details->continue_button, FALSE, FALSE, 4);
gtk_signal_connect(GTK_OBJECT (rpm_verify_window->details->continue_button), "clicked", GTK_SIGNAL_FUNC (continue_button_callback), rpm_verify_window);
rpm_verify_window->details->cancel_button = gtk_button_new_with_label ("Cancel");
gtk_box_pack_start (GTK_BOX (button_box), rpm_verify_window->details->cancel_button, FALSE, FALSE, 4);
gtk_signal_connect(GTK_OBJECT (rpm_verify_window->details->cancel_button), "clicked", GTK_SIGNAL_FUNC (cancel_button_callback), rpm_verify_window);
/* configure the dialog */
gtk_widget_set_usize (GTK_WIDGET (rpm_verify_window), 200, 140);
gtk_widget_set_usize (GTK_WIDGET (rpm_verify_window), 320, 180);
gnome_dialog_append_button ( GNOME_DIALOG(rpm_verify_window),
GNOME_STOCK_BUTTON_OK);
......@@ -146,3 +194,19 @@ nautilus_rpm_verify_window_set_message (NautilusRPMVerifyWindow *window, const c
{
nautilus_label_set_text (NAUTILUS_LABEL (window->details->file_message), message);
}
void
nautilus_rpm_verify_window_set_error_mode (NautilusRPMVerifyWindow *window, gboolean error_mode)
{
if (window->details->error_mode != error_mode) {
window->details->error_mode = error_mode;
if (error_mode) {
gtk_widget_show (window->details->continue_button);
gtk_widget_show (window->details->cancel_button);
} else {
gtk_widget_hide (window->details->continue_button);
gtk_widget_hide (window->details->cancel_button);
}
}
}
......@@ -52,11 +52,15 @@ struct NautilusRPMVerifyWindow {
struct NautilusRPMVerifyWindowClass {
GnomeDialogClass parent_class;
/* signals */
void (* continue_verify) (NautilusRPMVerifyWindow *window);
};
GtkType nautilus_rpm_verify_window_get_type (void);
GtkWidget* nautilus_rpm_verify_window_new (const char *package_name);
void nautilus_rpm_verify_window_set_message (NautilusRPMVerifyWindow *window, const char *message);
void nautilus_rpm_verify_window_set_error_mode (NautilusRPMVerifyWindow *window, gboolean error_mode);
#ifdef __cplusplus
}
......
......@@ -109,6 +109,7 @@ struct NautilusRPMViewDetails {
int background_connection;
int file_count;
int last_file_index;
int selected_file;
};
......@@ -147,6 +148,8 @@ static void file_selection_callback (GtkCList *clist,
static void go_to_button_callback (GtkWidget *widget,
NautilusRPMView *rpm_view);
static void rpm_view_continue_verify (GtkWidget *window, NautilusRPMView *rpm_view);
NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusRPMView, nautilus_rpm_view, GTK_TYPE_EVENT_BOX)
static void
......@@ -162,7 +165,7 @@ nautilus_rpm_view_initialize_class (NautilusRPMViewClass *klass)
widget_class->drag_data_received = nautilus_rpm_view_drag_data_received;
}
/* initialize ourselves by connecting to the location change signal and allocating our subviews */
/* initialize the rpm view */
static void
nautilus_rpm_view_initialize (NautilusRPMView *rpm_view)
......@@ -821,12 +824,13 @@ rpm_view_load_location_callback (NautilusView *view,
nautilus_view_report_load_complete (rpm_view->details->nautilus_view);
}
/* callback to handle the verify command */
/* routine to handle the verify command */
static void
nautilus_rpm_view_verify_package_callback (GtkWidget *widget,
nautilus_rpm_view_verify_files (GtkWidget *widget,
NautilusRPMView *rpm_view)
{
int index;
int index, initial_index;
int file_result, info_result, file_count;
Header package_header, signature;
char *path_name, *file_message, *temp_str;
......@@ -851,30 +855,65 @@ nautilus_rpm_view_verify_package_callback (GtkWidget *widget,
/* put up a window to give file handling feedback */
if (rpm_view->details->verify_window == NULL) {
rpm_view->details->verify_window = nautilus_rpm_verify_window_new (rpm_view->details->package_name);
gtk_signal_connect (GTK_OBJECT (rpm_view->details->verify_window),
"continue",
GTK_SIGNAL_FUNC (rpm_view_continue_verify),
rpm_view);
}
nautilus_gtk_window_present (GTK_WINDOW (rpm_view->details->verify_window));
/* iterate through the files, verifying one at a time and presenting the result
in the verify window */
for (index = 0; index < file_count; index++) {
initial_index = rpm_view->details->last_file_index;
for (index = initial_index; index < file_count; index++) {
rpmVerifyFile ("", package_header, index, &file_result, 0);
/* FIXME - check result code soon */
gtk_clist_get_text (GTK_CLIST (rpm_view->details->package_file_list), index, 0, &temp_str);
file_message = g_strdup_printf (_("checking %s..."), temp_str);
if (file_result == 0) {
file_message = g_strdup_printf (_("checking %s..."), temp_str);
} else {
file_message = g_strdup_printf (_("file %s has an error!"), temp_str);
}
nautilus_rpm_verify_window_set_message (NAUTILUS_RPM_VERIFY_WINDOW (rpm_view->details->verify_window), file_message);
g_free (file_message);
while (gtk_events_pending ())
gtk_main_iteration ();
if (file_result != 0) {
nautilus_rpm_verify_window_set_error_mode (NAUTILUS_RPM_VERIFY_WINDOW (rpm_view->details->verify_window), TRUE);
rpm_view->details->last_file_index = index + 1;
fdClose (file_descriptor);
return;
}
}
nautilus_rpm_verify_window_set_error_mode (NAUTILUS_RPM_VERIFY_WINDOW (rpm_view->details->verify_window), FALSE);
nautilus_rpm_verify_window_set_message (NAUTILUS_RPM_VERIFY_WINDOW (rpm_view->details->verify_window), _("Verification completed."));
fdClose (file_descriptor);
}
/* callback to handle the verify command */
static void
nautilus_rpm_view_verify_package_callback (GtkWidget *widget,
NautilusRPMView *rpm_view)
{
rpm_view->details->last_file_index = 0;
nautilus_rpm_view_verify_files (widget, rpm_view);
}
/* respond to the continue signal by continuing the verify command */
static void
rpm_view_continue_verify (GtkWidget *window, NautilusRPMView *rpm_view)
{
nautilus_rpm_verify_window_set_error_mode (NAUTILUS_RPM_VERIFY_WINDOW (rpm_view->details->verify_window), FALSE);
nautilus_rpm_view_verify_files (window, rpm_view);
}
/* handle drag and drop */
static void
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment