/** * operation: The operation to process * message: The message that will be pushed to the status bar * fract: The fraction of the progress bar to fill * swidget: The SeahorseWidget to extract the gtk widgets from * * This gets called whenever an operation updates it's progress status thingy. * We update the appbar as appropriate. If operation != NULL then we only * display the latest operation in our special list * **/ static void operation_progress (SeahorseOperation *operation, const gchar *message, gdouble fract, SeahorseWidget *swidget) { GtkProgressBar *progress; GtkStatusbar *status; guint id; progress = GTK_PROGRESS_BAR (seahorse_widget_get_widget (swidget, "progress")); status = GTK_STATUSBAR (seahorse_widget_get_widget (swidget, "status")); if (!seahorse_operation_is_running (operation)) fract = 0.0; if (message != NULL && status) { g_return_if_fail (GTK_IS_STATUSBAR (status)); id = gtk_statusbar_get_context_id (status, "operation-progress"); gtk_statusbar_pop (status, id); if (message[0]) gtk_statusbar_push (status, id, message); } if(progress) { g_return_if_fail (GTK_IS_PROGRESS_BAR (progress)); if (fract >= 0.0) { stop_pulse (progress); gtk_progress_bar_set_fraction (progress, fract); } else { start_pulse (progress); } } }
static void progress_update_display (TrackedTask *task) { GtkProgressBar *progress = NULL; GtkStatusbar *status = NULL; GtkLabel *label = NULL; GtkWidget *widget; TrackedPart *part; gdouble fraction; guint id; if (task->builder == NULL) return; /* Dig out our progress display stuff */ widget = GTK_WIDGET (gtk_builder_get_object (task->builder, "progress-bar")); if (widget == NULL) g_warning ("cannot display progress because seahorse window has no progress widget"); else progress = GTK_PROGRESS_BAR (widget); widget = GTK_WIDGET (gtk_builder_get_object (task->builder, "status")); if (GTK_IS_STATUSBAR (widget)) { status = GTK_STATUSBAR (widget); } else { widget = GTK_WIDGET (gtk_builder_get_object (task->builder, "progress-details")); if (GTK_IS_LABEL (widget)) label = GTK_LABEL (widget); } /* The details is the first on a begun part */ part = tracked_part_find (task, find_part_begun_with_details, NULL); if (status) { id = gtk_statusbar_get_context_id (status, "operation-progress"); gtk_statusbar_pop (status, id); if (part != NULL) gtk_statusbar_push (status, id, part->details); } else if (label) { gtk_label_set_text (label, part ? part->details : ""); } /* If all parts are running simultaneously then indeterminate */ if (task->parts_prepped == 0 && task->parts_ended == 0) { fraction = -1; } else { fraction = (gdouble)task->parts_ended / (gdouble)task->parts->length; } if (progress) { if (fraction >= 0.0) { stop_pulse (progress); gtk_progress_bar_set_fraction (progress, fraction); } else { start_pulse (progress); } } }
/** * operation: The SeahorseOperation to use * message: An optional message to display * fract: The fraction finished * swidget: the SeahorseWidget to get the widgets from * * Progress window update. Similar to operation_progress * **/ static void progress_operation_update (SeahorseOperation *operation, const gchar *message, gdouble fract, SeahorseWidget *swidget) { GtkProgressBar *progress; GtkWidget *w; const gchar *t; w = GTK_WIDGET (seahorse_widget_get_widget (swidget, "operation-details")); g_return_if_fail (w != NULL); t = seahorse_operation_get_message (operation); gtk_label_set_text (GTK_LABEL (w), t ? t : ""); progress = GTK_PROGRESS_BAR (seahorse_widget_get_widget (swidget, "operation-bar")); g_return_if_fail (w != NULL); if (fract >= 0.0) { stop_pulse (progress); gtk_progress_bar_set_fraction (progress, fract); } else { start_pulse (progress); } }