mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Allow progress dialog to be used without ok button.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3146 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
1d50e884f6
commit
1d695f82c5
@ -46,6 +46,7 @@ struct _GNCProgressDialog
|
|||||||
|
|
||||||
SCM cancel_scm_func;
|
SCM cancel_scm_func;
|
||||||
|
|
||||||
|
gboolean use_ok_button;
|
||||||
gboolean closed;
|
gboolean closed;
|
||||||
gboolean finished;
|
gboolean finished;
|
||||||
gboolean destroyed;
|
gboolean destroyed;
|
||||||
@ -184,6 +185,9 @@ gnc_progress_dialog_create(GtkWidget * parent, GNCProgressDialog *progress)
|
|||||||
gtk_signal_connect(GTK_OBJECT(progress->ok_button), "clicked",
|
gtk_signal_connect(GTK_OBJECT(progress->ok_button), "clicked",
|
||||||
GTK_SIGNAL_FUNC(ok_cb), progress);
|
GTK_SIGNAL_FUNC(ok_cb), progress);
|
||||||
|
|
||||||
|
if (!progress->use_ok_button)
|
||||||
|
gtk_widget_hide (progress->ok_button);
|
||||||
|
|
||||||
progress->cancel_button = gtk_object_get_data(tdo, "cancel_button");
|
progress->cancel_button = gtk_object_get_data(tdo, "cancel_button");
|
||||||
|
|
||||||
gtk_signal_connect(GTK_OBJECT(progress->cancel_button), "clicked",
|
gtk_signal_connect(GTK_OBJECT(progress->cancel_button), "clicked",
|
||||||
@ -201,12 +205,14 @@ gnc_progress_dialog_create(GtkWidget * parent, GNCProgressDialog *progress)
|
|||||||
}
|
}
|
||||||
|
|
||||||
GNCProgressDialog *
|
GNCProgressDialog *
|
||||||
gnc_progress_dialog_new (GtkWidget * parent)
|
gnc_progress_dialog_new (GtkWidget * parent, gboolean use_ok_button)
|
||||||
{
|
{
|
||||||
GNCProgressDialog *progress;
|
GNCProgressDialog *progress;
|
||||||
|
|
||||||
progress = g_new0(GNCProgressDialog, 1);
|
progress = g_new0(GNCProgressDialog, 1);
|
||||||
|
|
||||||
|
progress->use_ok_button = use_ok_button;
|
||||||
|
|
||||||
gnc_progress_dialog_create(parent, progress);
|
gnc_progress_dialog_create(parent, progress);
|
||||||
|
|
||||||
gtk_widget_show(progress->dialog);
|
gtk_widget_show(progress->dialog);
|
||||||
@ -322,6 +328,12 @@ gnc_progress_dialog_finish (GNCProgressDialog *progress)
|
|||||||
if (progress == NULL)
|
if (progress == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (!progress->use_ok_button)
|
||||||
|
{
|
||||||
|
gtk_widget_hide (progress->dialog);
|
||||||
|
progress->closed = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
gtk_progress_set_percentage (GTK_PROGRESS (progress->progress_bar), 1.0);
|
gtk_progress_set_percentage (GTK_PROGRESS (progress->progress_bar), 1.0);
|
||||||
|
|
||||||
gtk_widget_set_sensitive (progress->ok_button, TRUE);
|
gtk_widget_set_sensitive (progress->ok_button, TRUE);
|
||||||
|
@ -34,7 +34,8 @@ typedef gboolean (*GNCProgressCancelFunc) (gpointer user_data);
|
|||||||
|
|
||||||
/* Create and return a dialog for displaying the progress of
|
/* Create and return a dialog for displaying the progress of
|
||||||
* an activity. Useful for long-running operations. */
|
* an activity. Useful for long-running operations. */
|
||||||
GNCProgressDialog * gnc_progress_dialog_new (GtkWidget *parent);
|
GNCProgressDialog * gnc_progress_dialog_new (GtkWidget *parent,
|
||||||
|
gboolean use_ok_button);
|
||||||
|
|
||||||
/* Set the title of the progress dialog. */
|
/* Set the title of the progress dialog. */
|
||||||
void gnc_progress_dialog_set_title (GNCProgressDialog *progress,
|
void gnc_progress_dialog_set_title (GNCProgressDialog *progress,
|
||||||
|
@ -68,13 +68,13 @@
|
|||||||
(list "Extensions" "")
|
(list "Extensions" "")
|
||||||
(lambda () (gnc:main-win-account-group-write win))))
|
(lambda () (gnc:main-win-account-group-write win))))
|
||||||
|
|
||||||
(define export-item
|
(define progress-item
|
||||||
(gnc:make-menu-item "Test progress dialog"
|
(gnc:make-menu-item "Test progress dialog"
|
||||||
"Test progress dialog"
|
"Test progress dialog"
|
||||||
(list "Extensions" "")
|
(list "Extensions" "")
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(let ((dialog (gnc:progress-dialog-new
|
(let ((dialog (gnc:progress-dialog-new
|
||||||
(gnc:get-ui-data)))
|
(gnc:get-ui-data) #f))
|
||||||
(canceled #f))
|
(canceled #f))
|
||||||
(gnc:progress-dialog-set-cancel-scm-func
|
(gnc:progress-dialog-set-cancel-scm-func
|
||||||
dialog
|
dialog
|
||||||
@ -104,6 +104,7 @@
|
|||||||
|
|
||||||
(gnc:add-extension menu)
|
(gnc:add-extension menu)
|
||||||
(gnc:add-extension export-item)
|
(gnc:add-extension export-item)
|
||||||
|
(gnc:add-extension progress-item)
|
||||||
|
|
||||||
(if (gnc:debugging?)
|
(if (gnc:debugging?)
|
||||||
(gnc:add-extension strings-item)))
|
(gnc:add-extension strings-item)))
|
||||||
|
@ -44,15 +44,15 @@
|
|||||||
(file-size (stat:size file-stats))
|
(file-size (stat:size file-stats))
|
||||||
(bytes-read 0))
|
(bytes-read 0))
|
||||||
(set! start-time (gettimeofday))
|
(set! start-time (gettimeofday))
|
||||||
|
|
||||||
(if (> file-size 10000)
|
(if (> file-size 10000)
|
||||||
(begin
|
(begin
|
||||||
(set! progress-dialog (gnc:progress-dialog-new #f))
|
(set! progress-dialog (gnc:progress-dialog-new #f #f))
|
||||||
(gnc:progress-dialog-set-title progress-dialog "Progress")
|
(gnc:progress-dialog-set-title progress-dialog "Progress")
|
||||||
(gnc:progress-dialog-set-heading progress-dialog
|
(gnc:progress-dialog-set-heading progress-dialog
|
||||||
"Loading QIF file...")
|
"Loading QIF file...")
|
||||||
(gnc:progress-dialog-set-limits progress-dialog 0.0 100.0)))
|
(gnc:progress-dialog-set-limits progress-dialog 0.0 100.0)))
|
||||||
|
|
||||||
(with-input-from-file path
|
(with-input-from-file path
|
||||||
(lambda ()
|
(lambda ()
|
||||||
;; loop over lines
|
;; loop over lines
|
||||||
|
@ -225,7 +225,7 @@
|
|||||||
|
|
||||||
(if (> work-to-do 100)
|
(if (> work-to-do 100)
|
||||||
(begin
|
(begin
|
||||||
(set! progress-dialog (gnc:progress-dialog-new #f))
|
(set! progress-dialog (gnc:progress-dialog-new #f #f))
|
||||||
(gnc:progress-dialog-set-title progress-dialog "Progress")
|
(gnc:progress-dialog-set-title progress-dialog "Progress")
|
||||||
(gnc:progress-dialog-set-heading progress-dialog
|
(gnc:progress-dialog-set-heading progress-dialog
|
||||||
"Importing transactions...")
|
"Importing transactions...")
|
||||||
|
Loading…
Reference in New Issue
Block a user