Skip to content

Commit 6946d21

Browse files
committed
Change default invoice report dialog
If selected default invoice report is missing, hide the timeout and wait for user selection.
1 parent 45a0746 commit 6946d21

File tree

3 files changed

+52
-16
lines changed

3 files changed

+52
-16
lines changed

gnucash/gnome-utils/gnc-report-combo.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,20 @@ gnc_report_combo_set_active_guid_name (GncReportCombo *grc,
446446
}
447447
}
448448

449+
gboolean
450+
gnc_report_combo_is_warning_visible_for_active (GncReportCombo *grc)
451+
{
452+
GncReportComboPrivate *priv;
453+
gboolean missing = FALSE;
454+
455+
g_return_val_if_fail (grc != NULL, FALSE);
456+
g_return_val_if_fail (GNC_IS_REPORT_COMBO(grc), FALSE);
457+
458+
priv = GET_PRIVATE(grc);
459+
460+
return gtk_widget_is_visible (GTK_WIDGET(priv->warning_image));
461+
}
462+
449463
static void
450464
combo_changed_cb (GtkComboBox *widget, gpointer user_data)
451465
{

gnucash/gnome-utils/gnc-report-combo.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ gchar * gnc_report_combo_get_active_name (GncReportCombo *grc);
104104

105105
/** Set the active report to the guid string
106106
*
107-
* @param combo The GtkComboBox that presents the list.
107+
* @param grc The report combo widget.
108108
*
109109
* @param guid_name The concatination of the guid/name of the Invoice Report
110110
*/
@@ -120,4 +120,12 @@ void gnc_report_combo_set_active_guid_name (GncReportCombo *grc,
120120
*/
121121
gchar * gnc_report_combo_get_active_guid_name (GncReportCombo *grc);
122122

123+
/** Is the warning displayed for active entry.
124+
*
125+
* @param grc The report combo widget.
126+
*
127+
* @return TRUE is warning is displayed, else FALSE
128+
*/
129+
gboolean gnc_report_combo_is_warning_visible_for_active (GncReportCombo *grc);
130+
123131
#endif /* __GNC_REPORT_COMBO_H__ */

gnucash/gnome/dialog-invoice.c

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -834,8 +834,8 @@ combo_changed_cb (GtkComboBox *widget, gpointer user_data)
834834

835835
/* This function will return the selected invoice report guid if
836836
* the countdown times out or a selection is made and OK pressed.
837-
*
838-
* If cancel is pressed then it return a NULL
837+
*
838+
* If cancel is pressed then it will return NULL
839839
*/
840840
static char*
841841
use_default_report_template_or_change (GtkWindow *parent)
@@ -847,20 +847,34 @@ use_default_report_template_or_change (GtkWindow *parent)
847847
GtkWidget *ok_button;
848848
GtkWidget *report_combo_hbox;
849849
GtkWidget *progress_bar;
850+
GtkWidget *label;
850851
gchar *ret_guid = NULL;
851852
gchar *rep_guid = NULL;
852853
gchar *rep_name = NULL;
854+
gboolean warning_visible = FALSE;
853855
gint result;
854856
gdouble timeout;
855857
dialog_args *args;
856858

857859
timeout = qof_book_get_default_invoice_report_timeout (book);
858860

859-
if (timeout == 0)
860-
return gnc_get_default_invoice_print_report ();
861-
862861
combo = gnc_default_invoice_report_combo ("gnc:custom-report-invoice-template-guids");
863862

863+
rep_name = qof_book_get_default_invoice_report_name (book);
864+
rep_guid = gnc_get_default_invoice_print_report ();
865+
866+
gnc_report_combo_set_active (GNC_REPORT_COMBO(combo),
867+
rep_guid,
868+
rep_name);
869+
g_free (rep_guid);
870+
g_free (rep_name);
871+
872+
warning_visible = gnc_report_combo_is_warning_visible_for_active (GNC_REPORT_COMBO(combo));
873+
874+
// When timeout is 0, only return if warning not visible
875+
if (timeout == 0 && !warning_visible)
876+
return gnc_get_default_invoice_print_report ();
877+
864878
builder = gtk_builder_new ();
865879
gnc_builder_add_from_file (builder, "dialog-invoice.glade", "invoice_print_dialog");
866880

@@ -873,20 +887,12 @@ use_default_report_template_or_change (GtkWindow *parent)
873887
ok_button = GTK_WIDGET(gtk_builder_get_object (builder, "ok_button"));
874888
report_combo_hbox = GTK_WIDGET(gtk_builder_get_object (builder, "report_combo_hbox"));
875889
progress_bar = GTK_WIDGET(gtk_builder_get_object (builder, "progress_bar"));
890+
label = GTK_WIDGET(gtk_builder_get_object (builder, "label"));
876891

877892
gtk_box_pack_start (GTK_BOX(report_combo_hbox), GTK_WIDGET(combo), TRUE, TRUE, 0);
878893

879894
gtk_widget_grab_focus (ok_button);
880895

881-
rep_name = qof_book_get_default_invoice_report_name (book);
882-
rep_guid = gnc_get_default_invoice_print_report ();
883-
884-
gnc_report_combo_set_active (GNC_REPORT_COMBO(combo),
885-
rep_guid,
886-
rep_name);
887-
g_free (rep_guid);
888-
g_free (rep_name);
889-
890896
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR(progress_bar), 1);
891897

892898
args = g_malloc (sizeof(dialog_args));
@@ -907,7 +913,15 @@ use_default_report_template_or_change (GtkWindow *parent)
907913
g_signal_connect (G_OBJECT(combo), "notify::popup-shown",
908914
G_CALLBACK (combo_popped_cb), args);
909915

910-
g_timeout_add (100, update_progress_bar, args);
916+
// if warning visible, do not add args timeout, wait for user
917+
if (warning_visible)
918+
{
919+
gtk_label_set_text (GTK_LABEL(label),
920+
N_("Choose a different report template or Printable Invoice will be used"));
921+
gtk_widget_hide (GTK_WIDGET(progress_bar));
922+
}
923+
else
924+
g_timeout_add (100, update_progress_bar, args);
911925

912926
result = gtk_dialog_run (GTK_DIALOG(dialog));
913927

0 commit comments

Comments
 (0)