gnucash maint: Multiple changes pushed
John Ralls
jralls at code.gnucash.org
Tue Mar 8 15:36:14 EST 2022
Updated via https://github.com/Gnucash/gnucash/commit/cde8f916 (commit)
via https://github.com/Gnucash/gnucash/commit/8f9b6b1e (commit)
via https://github.com/Gnucash/gnucash/commit/2b2ad464 (commit)
via https://github.com/Gnucash/gnucash/commit/6cbc0b7a (commit)
via https://github.com/Gnucash/gnucash/commit/da8bc64e (commit)
from https://github.com/Gnucash/gnucash/commit/7343959a (commit)
commit cde8f9168f2529c7547faa4ad1511249a5575a21
Merge: 7343959a0 8f9b6b1ec
Author: John Ralls <jralls at ceridwen.us>
Date: Tue Mar 8 12:35:43 2022 -0800
Merge Jean Laroche's 'bug798164' into maint.
commit 8f9b6b1ecc887d531d40bb402a1c8a5f71438c7b
Author: John Ralls <jralls at ceridwen.us>
Date: Tue Mar 8 12:35:01 2022 -0800
Clean up gnc_gen_trans_edit_fields.
diff --git a/gnucash/import-export/import-main-matcher.c b/gnucash/import-export/import-main-matcher.c
index 69700d7f3..ca674484b 100644
--- a/gnucash/import-export/import-main-matcher.c
+++ b/gnucash/import-export/import-main-matcher.c
@@ -882,84 +882,97 @@ gnc_gen_trans_assign_transfer_account_to_selection_cb (GtkMenuItem *menuitem,
typedef enum
{
- DESCRIPTION = 0,
- MEMO = 1,
- NOTES = 2,
+ DESCRIPTION,
+ MEMO,
+ NOTES,
} edit_field;
static void
-gnc_gen_trans_edit_fields (GtkMenuItem *menuitem, GNCImportMainMatcher *info, edit_field field)
+gnc_gen_trans_edit_fields (GtkMenuItem *menuitem, GNCImportMainMatcher *info,
+ edit_field field)
{
GtkTreeView *treeview;
GtkTreeSelection *selection;
GtkTreeModel *model;
- GtkTreeIter iter;
- GNCImportTransInfo *trans_info;
GList *selected_rows;
- gboolean first, is_selection;
GList *refs = NULL;
- const gchar* messages[] = {_("Enter new Description"),_("Enter new Memo"),_("Enter new Notes")};
- const gchar* message = messages[field];
-
+ GtkTreeStore* store;
+ GNCImportTransInfo *trans_info;
+ Transaction* trans;
+ GtkTreeIter iter;
+
+ g_return_if_fail (info != NULL);
ENTER("assign_transfer_account_to_selection_cb");
+
treeview = GTK_TREE_VIEW(info->view);
model = gtk_tree_view_get_model (treeview);
+ store = GTK_TREE_STORE (model);
selection = gtk_tree_view_get_selection (treeview);
selected_rows = gtk_tree_selection_get_selected_rows (selection, &model);
- first = TRUE;
- is_selection = TRUE;
-
- DEBUG("Rows in selection = %i",
- gtk_tree_selection_count_selected_rows (selection));
- DEBUG("Entering loop over selection");
- if (gtk_tree_selection_count_selected_rows (selection) > 0)
+ if (!selected_rows)
+ {
+ LEAVE ("No selected rows");
+ return;
+ }
+
+ if (selected_rows->next)
+ {
+ LEAVE ("User selected multiple rows, not supported");
+ return;
+ }
+
+ g_return_if_fail (gtk_tree_model_get_iter (model, &iter,
+ selected_rows->data));
+
+ gtk_tree_model_get (model, &iter, DOWNLOADED_COL_DATA,
+ &trans_info, -1);
+ trans = gnc_import_TransInfo_get_trans (trans_info);
+
+ switch (field)
{
- GtkTreeStore* store = GTK_TREE_STORE (model);
- for (GList* l = selected_rows; l != NULL; l = l->next)
+ case DESCRIPTION:
{
- gchar *path_str = gtk_tree_path_to_string (l->data);
- GtkTreeRowReference *ref = gtk_tree_row_reference_new (model, l->data);
- g_free (path_str);
- refs = g_list_prepend (refs, ref);
- if (gtk_tree_model_get_iter (model, &iter, l->data))
- {
- Split* first_split;
- Transaction* trans;
- gtk_tree_model_get (model, &iter, DOWNLOADED_COL_DATA, &trans_info, -1);
- trans = gnc_import_TransInfo_get_trans (trans_info);
- if (field == DESCRIPTION)
- {
- gchar* new_field = gnc_input_dialog_with_entry(info->main_widget, "", message, xaccTransGetDescription (trans));
- if (!new_field) break;
- xaccTransSetDescription (trans, new_field);
- gtk_tree_store_set (store, &iter, DOWNLOADED_COL_DESCRIPTION, new_field, -1);
- g_free (new_field);
- }
- else if (field == MEMO)
- {
- gchar* new_field;
- first_split = gnc_import_TransInfo_get_fsplit (trans_info);
- new_field = gnc_input_dialog_with_entry(info->main_widget, "", message, xaccSplitGetMemo (first_split));
- if (!new_field) break;
- xaccSplitSetMemo (first_split, new_field);
- gtk_tree_store_set (store, &iter, DOWNLOADED_COL_MEMO, new_field, -1);
- g_free (new_field);
- }
- else if (field == NOTES)
- {
- gchar* new_field = gnc_input_dialog_with_entry(info->main_widget, "", message, xaccTransGetNotes (trans));
- if (!new_field) break;
- xaccTransSetNotes (trans, new_field);
- g_free (new_field);
- }
- }
+ char* new_field =
+ gnc_input_dialog_with_entry(info->main_widget, "",
+ _("Enter new Description"),
+ xaccTransGetDescription (trans));
+ if (!new_field) break;
+ xaccTransSetDescription (trans, new_field);
+ gtk_tree_store_set (store, &iter, DOWNLOADED_COL_DESCRIPTION,
+ new_field, -1);
+ g_free (new_field);
+ break;
+ }
+ case MEMO:
+ {
+ Split *first_split =
+ gnc_import_TransInfo_get_fsplit (trans_info);
+ char *new_field =
+ gnc_input_dialog_with_entry(info->main_widget, "",
+ _("Enter new Memo"),
+ xaccSplitGetMemo (first_split));
+ if (!new_field) break;
+ xaccSplitSetMemo (first_split, new_field);
+ gtk_tree_store_set (store, &iter,
+ DOWNLOADED_COL_MEMO, new_field, -1);
+ g_free (new_field);
+ break;
+ }
+ case NOTES:
+ {
+ char* new_field =
+ gnc_input_dialog_with_entry(info->main_widget, "",
+ _("Enter new Notes"),
+ xaccTransGetNotes (trans));
+ if (!new_field) break;
+ xaccTransSetNotes (trans, new_field);
+ g_free (new_field);
+ break;
}
}
g_list_free_full (selected_rows, (GDestroyNotify)gtk_tree_path_free);
- g_list_free (refs);
LEAVE("");
-
}
static void
commit 2b2ad46401afd6fe876691d3991174ee41235ee1
Author: jean <27791933+jeanlaroche at users.noreply.github.com>
Date: Mon Oct 11 21:08:01 2021 -0700
bug 798164 Import transaction window does not allow changing the transaction description. Implement right-click to edit description, notes or memo during matching process
diff --git a/gnucash/gnome-utils/gnc-gui-query.c b/gnucash/gnome-utils/gnc-gui-query.c
index dc82b91d7..1aef41910 100644
--- a/gnucash/gnome-utils/gnc-gui-query.c
+++ b/gnucash/gnome-utils/gnc-gui-query.c
@@ -316,24 +316,9 @@ gnc_choose_radio_option_dialog(GtkWidget *parent,
return radio_result;
}
-/********************************************************************\
- * gnc_input_dialog *
- * simple convenience dialog to get a single value from the user *
- * user may choose between "Ok" and "Cancel" *
- * *
- * NOTE: This function does not return until the dialog is closed *
- * *
- * Args: parent - the parent window or NULL *
- * title - the title of the dialog *
- * msg - the message to display *
- * default_input - will be displayed as default input *
- * Return: the input (text) the user entered, if pressed "Ok" *
- * NULL, if pressed "Cancel" *
- \********************************************************************/
-gchar *
-gnc_input_dialog (GtkWidget *parent, const gchar *title, const gchar *msg, const gchar *default_input)
+static gchar *
+gnc_input_dialog_internal (GtkWidget *parent, const gchar *title, const gchar *msg, const gchar *default_input, gboolean use_entry)
{
- GtkWidget *dialog, *label, *content_area;
gint result;
GtkWidget *view;
GtkTextBuffer *buffer;
@@ -341,36 +326,46 @@ gnc_input_dialog (GtkWidget *parent, const gchar *title, const gchar *msg, const
GtkTextIter start, end;
/* Create the widgets */
- dialog = gtk_dialog_new_with_buttons (title, GTK_WINDOW (parent),
+ GtkWidget* dialog = gtk_dialog_new_with_buttons (title, GTK_WINDOW (parent),
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
_("_OK"), GTK_RESPONSE_ACCEPT,
_("_Cancel"), GTK_RESPONSE_REJECT,
NULL);
- content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+ GtkWidget* content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
// add a label
- label = gtk_label_new (msg);
+ GtkWidget* label = gtk_label_new (msg);
gtk_box_pack_start(GTK_BOX(content_area), label, FALSE, FALSE, 0);
- // add a textview
- view = gtk_text_view_new ();
- gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), GTK_WRAP_WORD_CHAR);
- buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
- gtk_text_buffer_set_text (buffer, default_input, -1);
+ // add a textview or an entry.
+ if (use_entry)
+ {
+ view = gtk_entry_new ();
+ gtk_entry_set_text (GTK_ENTRY (view), default_input);
+ }
+ else
+ {
+ view = gtk_text_view_new ();
+ gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), GTK_WRAP_WORD_CHAR);
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
+ gtk_text_buffer_set_text (buffer, default_input, -1);
+ }
gtk_box_pack_start(GTK_BOX(content_area), view, TRUE, TRUE, 0);
-
+
// run the dialog
gtk_widget_show_all (dialog);
result = gtk_dialog_run (GTK_DIALOG (dialog));
- if (result == GTK_RESPONSE_REJECT)
- user_input = 0;
- else
+ if (result != GTK_RESPONSE_REJECT)
{
- gtk_text_buffer_get_start_iter (buffer, &start);
- gtk_text_buffer_get_end_iter (buffer, &end);
- user_input = gtk_text_buffer_get_text (buffer,
- &start, &end, FALSE);
+ if (use_entry)
+ user_input = g_strdup (gtk_entry_get_text ((GTK_ENTRY (view))));
+ else
+ {
+ gtk_text_buffer_get_start_iter (buffer, &start);
+ gtk_text_buffer_get_end_iter (buffer, &end);
+ user_input = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
+ }
}
gtk_widget_destroy (dialog);
@@ -378,23 +373,53 @@ gnc_input_dialog (GtkWidget *parent, const gchar *title, const gchar *msg, const
return user_input;
}
+/********************************************************************\
+ * gnc_input_dialog *
+ * simple convenience dialog to get a single value from the user *
+ * user may choose between "Ok" and "Cancel" *
+ * *
+ * NOTE: This function does not return until the dialog is closed *
+ * *
+ * Args: parent - the parent window or NULL *
+ * title - the title of the dialog *
+ * msg - the message to display *
+ * default_input - will be displayed as default input *
+ * Return: the input (text) the user entered, if pressed "Ok" *
+ * NULL, if pressed "Cancel" *
+ \********************************************************************/
+gchar *
+gnc_input_dialog (GtkWidget *parent, const gchar *title, const gchar *msg, const gchar *default_input)
+{
+ return gnc_input_dialog_internal (parent, title, msg, default_input, FALSE);
+}
+
+/********************************************************************\
+ * gnc_input_dialog_with_entry *
+ * Similar to gnc_input_dialog but use a single line entry widget *
+ * user may choose between "Ok" and "Cancel" *
+ \********************************************************************/
+gchar *
+gnc_input_dialog_with_entry (GtkWidget *parent, const gchar *title, const gchar *msg, const gchar *default_input)
+{
+ return gnc_input_dialog_internal (parent, title, msg, default_input, TRUE);
+}
+
void
gnc_info2_dialog (GtkWidget *parent, const gchar *title, const gchar *msg)
{
- GtkWidget *dialog, *scrolledwindow, *content_area;
GtkWidget *view;
GtkTextBuffer *buffer;
gint width, height;
/* Create the widgets */
- dialog = gtk_dialog_new_with_buttons (title, GTK_WINDOW (parent),
+ GtkWidget* dialog = gtk_dialog_new_with_buttons (title, GTK_WINDOW (parent),
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
_("_OK"), GTK_RESPONSE_ACCEPT,
NULL);
- content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+ GtkWidget* content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
// add a scroll area
- scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
+ GtkWidget* scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
gtk_box_pack_start(GTK_BOX(content_area), scrolledwindow, TRUE, TRUE, 0);
// add a textview
diff --git a/gnucash/gnome-utils/gnc-ui.h b/gnucash/gnome-utils/gnc-ui.h
index 41c3ebd86..bc7327d90 100644
--- a/gnucash/gnome-utils/gnc-ui.h
+++ b/gnucash/gnome-utils/gnc-ui.h
@@ -107,6 +107,9 @@ gnc_error_dialog (GtkWindow *parent,
extern gchar *
gnc_input_dialog (GtkWidget *parent, const gchar *title, const gchar *msg, const gchar *default_input);
+extern gchar *
+gnc_input_dialog_with_entry (GtkWidget *parent, const gchar *title, const gchar *msg, const gchar *default_input);
+
extern void
gnc_info2_dialog (GtkWidget *parent, const gchar *title, const gchar *msg);
diff --git a/gnucash/import-export/import-main-matcher.c b/gnucash/import-export/import-main-matcher.c
index 0b9e02897..69700d7f3 100644
--- a/gnucash/import-export/import-main-matcher.c
+++ b/gnucash/import-export/import-main-matcher.c
@@ -130,7 +130,8 @@ static void gnc_gen_trans_assign_transfer_account_to_selection_cb (GtkMenuItem *
GNCImportMainMatcher *info);
static void gnc_gen_trans_view_popup_menu (GtkTreeView *treeview,
GdkEvent *event,
- GNCImportMainMatcher *info);
+ GNCImportMainMatcher *info,
+ gboolean show_edit_actions);
static gboolean gnc_gen_trans_onButtonPressed_cb (GtkTreeView *treeview,
GdkEvent *event,
GNCImportMainMatcher *info);
@@ -879,6 +880,106 @@ gnc_gen_trans_assign_transfer_account_to_selection_cb (GtkMenuItem *menuitem,
LEAVE("");
}
+typedef enum
+{
+ DESCRIPTION = 0,
+ MEMO = 1,
+ NOTES = 2,
+} edit_field;
+
+static void
+gnc_gen_trans_edit_fields (GtkMenuItem *menuitem, GNCImportMainMatcher *info, edit_field field)
+{
+ GtkTreeView *treeview;
+ GtkTreeSelection *selection;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ GNCImportTransInfo *trans_info;
+ GList *selected_rows;
+ gboolean first, is_selection;
+ GList *refs = NULL;
+ const gchar* messages[] = {_("Enter new Description"),_("Enter new Memo"),_("Enter new Notes")};
+ const gchar* message = messages[field];
+
+ ENTER("assign_transfer_account_to_selection_cb");
+ treeview = GTK_TREE_VIEW(info->view);
+ model = gtk_tree_view_get_model (treeview);
+ selection = gtk_tree_view_get_selection (treeview);
+ selected_rows = gtk_tree_selection_get_selected_rows (selection, &model);
+ first = TRUE;
+ is_selection = TRUE;
+
+ DEBUG("Rows in selection = %i",
+ gtk_tree_selection_count_selected_rows (selection));
+ DEBUG("Entering loop over selection");
+
+ if (gtk_tree_selection_count_selected_rows (selection) > 0)
+ {
+ GtkTreeStore* store = GTK_TREE_STORE (model);
+ for (GList* l = selected_rows; l != NULL; l = l->next)
+ {
+ gchar *path_str = gtk_tree_path_to_string (l->data);
+ GtkTreeRowReference *ref = gtk_tree_row_reference_new (model, l->data);
+ g_free (path_str);
+ refs = g_list_prepend (refs, ref);
+ if (gtk_tree_model_get_iter (model, &iter, l->data))
+ {
+ Split* first_split;
+ Transaction* trans;
+ gtk_tree_model_get (model, &iter, DOWNLOADED_COL_DATA, &trans_info, -1);
+ trans = gnc_import_TransInfo_get_trans (trans_info);
+ if (field == DESCRIPTION)
+ {
+ gchar* new_field = gnc_input_dialog_with_entry(info->main_widget, "", message, xaccTransGetDescription (trans));
+ if (!new_field) break;
+ xaccTransSetDescription (trans, new_field);
+ gtk_tree_store_set (store, &iter, DOWNLOADED_COL_DESCRIPTION, new_field, -1);
+ g_free (new_field);
+ }
+ else if (field == MEMO)
+ {
+ gchar* new_field;
+ first_split = gnc_import_TransInfo_get_fsplit (trans_info);
+ new_field = gnc_input_dialog_with_entry(info->main_widget, "", message, xaccSplitGetMemo (first_split));
+ if (!new_field) break;
+ xaccSplitSetMemo (first_split, new_field);
+ gtk_tree_store_set (store, &iter, DOWNLOADED_COL_MEMO, new_field, -1);
+ g_free (new_field);
+ }
+ else if (field == NOTES)
+ {
+ gchar* new_field = gnc_input_dialog_with_entry(info->main_widget, "", message, xaccTransGetNotes (trans));
+ if (!new_field) break;
+ xaccTransSetNotes (trans, new_field);
+ g_free (new_field);
+ }
+ }
+ }
+ }
+ g_list_free_full (selected_rows, (GDestroyNotify)gtk_tree_path_free);
+ g_list_free (refs);
+ LEAVE("");
+
+}
+
+static void
+gnc_gen_trans_edit_description_cb (GtkMenuItem *menuitem, GNCImportMainMatcher *info)
+{
+ gnc_gen_trans_edit_fields (menuitem, info, DESCRIPTION);
+}
+
+static void
+gnc_gen_trans_edit_memo_cb (GtkMenuItem *menuitem, GNCImportMainMatcher *info)
+{
+ gnc_gen_trans_edit_fields (menuitem, info, MEMO);
+}
+
+static void
+gnc_gen_trans_edit_notes_cb (GtkMenuItem *menuitem, GNCImportMainMatcher *info)
+{
+ gnc_gen_trans_edit_fields (menuitem, info, NOTES);
+}
+
static void
gnc_gen_trans_row_activated_cb (GtkTreeView *treeview,
GtkTreePath *path,
@@ -966,7 +1067,8 @@ gnc_gen_trans_row_changed_cb (GtkTreeSelection *selection,
static void
gnc_gen_trans_view_popup_menu (GtkTreeView *treeview,
GdkEvent *event,
- GNCImportMainMatcher *info)
+ GNCImportMainMatcher *info,
+ gboolean show_edit_actions)
{
GtkWidget *menu, *menuitem;
GdkEventButton *event_button;
@@ -981,6 +1083,33 @@ gnc_gen_trans_view_popup_menu (GtkTreeView *treeview,
info);
DEBUG("Callback to assign destination account to selection connected");
gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem);
+
+ if (show_edit_actions)
+ {
+ menuitem = gtk_menu_item_new_with_label (
+ _("Edit description."));
+ g_signal_connect (menuitem, "activate",
+ G_CALLBACK (gnc_gen_trans_edit_description_cb),
+ info);
+ DEBUG("Callback to edit description");
+ gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem);
+
+ menuitem = gtk_menu_item_new_with_label (
+ _("Edit memo."));
+ g_signal_connect (menuitem, "activate",
+ G_CALLBACK (gnc_gen_trans_edit_memo_cb),
+ info);
+ DEBUG("Callback to edit memo");
+ gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem);
+
+ menuitem = gtk_menu_item_new_with_label (
+ _("Edit notes."));
+ g_signal_connect (menuitem, "activate",
+ G_CALLBACK (gnc_gen_trans_edit_notes_cb),
+ info);
+ DEBUG("Callback to edit notes");
+ gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem);
+ }
gtk_widget_show_all (menu);
event_button = (GdkEventButton *) event;
/* Note: event can be NULL here when called from view_onPopupMenu; */
@@ -1012,14 +1141,14 @@ gnc_gen_trans_onButtonPressed_cb (GtkTreeView *treeview,
selection = gtk_tree_view_get_selection (treeview);
count = gtk_tree_selection_count_selected_rows (selection);
if (count > 1)
- gnc_gen_trans_view_popup_menu (treeview, event, info);
+ gnc_gen_trans_view_popup_menu (treeview, event, info, FALSE);
else if (count > 0)
{
GList* selected;
GtkTreeModel *model;
selected = gtk_tree_selection_get_selected_rows (selection, &model);
if (get_action_for_path (selected->data, model) == GNCImport_ADD)
- gnc_gen_trans_view_popup_menu (treeview, event, info);
+ gnc_gen_trans_view_popup_menu (treeview, event, info, TRUE);
g_list_free_full (selected, (GDestroyNotify)gtk_tree_path_free);
}
LEAVE("return TRUE");
@@ -1040,7 +1169,7 @@ gnc_gen_trans_onPopupMenu_cb (GtkTreeView *treeview,
selection = gtk_tree_view_get_selection (treeview);
if (gtk_tree_selection_count_selected_rows (selection) > 0)
{
- gnc_gen_trans_view_popup_menu (treeview, NULL, info);
+ gnc_gen_trans_view_popup_menu (treeview, NULL, info, TRUE);
LEAVE ("TRUE");
return TRUE;
}
commit 6cbc0b7aee3f2413fdbdce72ec871793d2aabc28
Author: jean <27791933+jeanlaroche at users.noreply.github.com>
Date: Tue Oct 5 20:55:40 2021 -0700
Remove duplicate version of gnc_info2_dialog
diff --git a/gnucash/gnome-utils/gnc-gui-query.c b/gnucash/gnome-utils/gnc-gui-query.c
index a4d8b6b94..dc82b91d7 100644
--- a/gnucash/gnome-utils/gnc-gui-query.c
+++ b/gnucash/gnome-utils/gnc-gui-query.c
@@ -377,3 +377,40 @@ gnc_input_dialog (GtkWidget *parent, const gchar *title, const gchar *msg, const
return user_input;
}
+
+void
+gnc_info2_dialog (GtkWidget *parent, const gchar *title, const gchar *msg)
+{
+ GtkWidget *dialog, *scrolledwindow, *content_area;
+ GtkWidget *view;
+ GtkTextBuffer *buffer;
+ gint width, height;
+
+ /* Create the widgets */
+ dialog = gtk_dialog_new_with_buttons (title, GTK_WINDOW (parent),
+ GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+ _("_OK"), GTK_RESPONSE_ACCEPT,
+ NULL);
+ content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+
+ // add a scroll area
+ scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
+ gtk_box_pack_start(GTK_BOX(content_area), scrolledwindow, TRUE, TRUE, 0);
+
+ // add a textview
+ view = gtk_text_view_new ();
+ gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
+ gtk_text_buffer_set_text (buffer, msg, -1);
+ gtk_container_add (GTK_CONTAINER (scrolledwindow), view);
+
+ // run the dialog
+ if (parent)
+ {
+ gtk_window_get_size (GTK_WINDOW(parent), &width, &height);
+ gtk_window_set_default_size (GTK_WINDOW(dialog), width, height);
+ }
+ gtk_widget_show_all (dialog);
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+}
diff --git a/gnucash/gnome-utils/gnc-ui.h b/gnucash/gnome-utils/gnc-ui.h
index f3a123a8f..41c3ebd86 100644
--- a/gnucash/gnome-utils/gnc-ui.h
+++ b/gnucash/gnome-utils/gnc-ui.h
@@ -107,6 +107,9 @@ gnc_error_dialog (GtkWindow *parent,
extern gchar *
gnc_input_dialog (GtkWidget *parent, const gchar *title, const gchar *msg, const gchar *default_input);
+extern void
+gnc_info2_dialog (GtkWidget *parent, const gchar *title, const gchar *msg);
+
extern void
gnc_gnome_help (GtkWindow *parent, const char *file_name, const char *target_link);
diff --git a/gnucash/import-export/bi-import/dialog-bi-import-gui.c b/gnucash/import-export/bi-import/dialog-bi-import-gui.c
index d7e5cbfcc..7dd065291 100644
--- a/gnucash/import-export/bi-import/dialog-bi-import-gui.c
+++ b/gnucash/import-export/bi-import/dialog-bi-import-gui.c
@@ -74,9 +74,6 @@ void gnc_bi_import_gui_option5_cb (GtkWidget *widget, gpointer data);
void gnc_bi_import_gui_open_mode_cb (GtkWidget *widget, gpointer data);
void gnc_import_gui_type_cb (GtkWidget *widget, gpointer data);
-// utils
-static void gnc_info2_dialog (GtkWidget *parent, const gchar *title, const gchar *msg);
-
#define UNUSED_VAR __attribute__ ((unused))
static QofLogModule UNUSED_VAR log_module = G_LOG_DOMAIN; //G_LOG_BUSINESS;
@@ -391,51 +388,3 @@ void gnc_import_gui_type_cb (GtkWidget *widget, gpointer data)
}
-/********************************************************************\
- * gnc_info2_dialog *
- * displays an information dialog box (with scrollable text area) *
- * *
- * NOTE: This function does not return until the dialog is closed *
- * *
- * Args: parent - the parent window or NULL *
- * title - the title of the dialog *
- * msg - the message to display *
- * Return: none *
-\********************************************************************/
-static void
-gnc_info2_dialog (GtkWidget *parent, const gchar *title, const gchar *msg)
-{
- GtkWidget *dialog, *scrolledwindow, *content_area;
- GtkWidget *view;
- GtkTextBuffer *buffer;
- gint width, height;
-
- /* Create the widgets */
- dialog = gtk_dialog_new_with_buttons (title, GTK_WINDOW (parent),
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
- _("_OK"), GTK_RESPONSE_ACCEPT,
- NULL);
- content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
-
- // add a scroll area
- scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
- gtk_box_pack_start(GTK_BOX(content_area), scrolledwindow, TRUE, TRUE, 0);
-
- // add a textview
- view = gtk_text_view_new ();
- gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
- buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
- gtk_text_buffer_set_text (buffer, msg, -1);
- gtk_container_add (GTK_CONTAINER (scrolledwindow), view);
-
- // run the dialog
- if (parent)
- {
- gtk_window_get_size (GTK_WINDOW(parent), &width, &height);
- gtk_window_set_default_size (GTK_WINDOW(dialog), width, height);
- }
- gtk_widget_show_all (dialog);
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
-}
-
diff --git a/gnucash/import-export/customer-import/dialog-customer-import-gui.c b/gnucash/import-export/customer-import/dialog-customer-import-gui.c
index 088713898..1fd461b62 100644
--- a/gnucash/import-export/customer-import/dialog-customer-import-gui.c
+++ b/gnucash/import-export/customer-import/dialog-customer-import-gui.c
@@ -68,10 +68,6 @@ void gnc_customer_import_gui_option4_cb (GtkWidget *widget, gpointer data);
void gnc_customer_import_gui_option5_cb (GtkWidget *widget, gpointer data);
void gnc_customer_import_gui_type_cb (GtkWidget *widget, gpointer data);
-// utils
-static void gnc_info2_dialog (GtkWidget *parent, const gchar *title, const gchar *msg);
-
-
CustomerImportGui *
gnc_plugin_customer_import_showGUI(GtkWindow *parent)
{
@@ -352,51 +348,3 @@ void gnc_customer_import_gui_type_cb (GtkWidget *widget, gpointer data)
//printf ("TYPE set to, %s\n",gui->type); // DEBUG
}
-
-/********************************************************************\
- * gnc_info2_dialog *
- * displays an information dialog box (with scrollable text area) *
- * *
- * NOTE: This function does not return until the dialog is closed *
- * *
- * Args: parent - the parent window or NULL *
- * title - the title of the dialog *
- * msg - the message to display *
- * Return: none *
-\********************************************************************/
-static void
-gnc_info2_dialog (GtkWidget *parent, const gchar *title, const gchar *msg)
-{
- GtkWidget *dialog, *scrolledwindow, *content_area;
- GtkWidget *view;
- GtkTextBuffer *buffer;
- gint width, height;
-
- /* Create the widgets */
- dialog = gtk_dialog_new_with_buttons (title, GTK_WINDOW (parent),
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
- _("_OK"), GTK_RESPONSE_ACCEPT,
- NULL);
- content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
-
- // add a scroll area
- scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
- gtk_box_pack_start(GTK_BOX(content_area), scrolledwindow, TRUE, TRUE, 0);
-
- // add a textview
- view = gtk_text_view_new ();
- gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
- buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
- gtk_text_buffer_set_text (buffer, msg, -1);
- gtk_container_add (GTK_CONTAINER (scrolledwindow), view);
-
- // run the dialog
- if (parent)
- {
- gtk_window_get_size (GTK_WINDOW(parent), &width, &height);
- gtk_window_set_default_size (GTK_WINDOW(dialog), width, height);
- }
- gtk_widget_show_all (dialog);
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
-}
commit da8bc64e93f9d00313c250e5c27d5adb87c07a66
Author: jean <27791933+jeanlaroche at users.noreply.github.com>
Date: Tue Oct 5 20:51:23 2021 -0700
Remove triplicate versions of gnc_input_dialog
diff --git a/gnucash/gnome-utils/gnc-gui-query.c b/gnucash/gnome-utils/gnc-gui-query.c
index 9ada424de..a4d8b6b94 100644
--- a/gnucash/gnome-utils/gnc-gui-query.c
+++ b/gnucash/gnome-utils/gnc-gui-query.c
@@ -315,3 +315,65 @@ gnc_choose_radio_option_dialog(GtkWidget *parent,
return radio_result;
}
+
+/********************************************************************\
+ * gnc_input_dialog *
+ * simple convenience dialog to get a single value from the user *
+ * user may choose between "Ok" and "Cancel" *
+ * *
+ * NOTE: This function does not return until the dialog is closed *
+ * *
+ * Args: parent - the parent window or NULL *
+ * title - the title of the dialog *
+ * msg - the message to display *
+ * default_input - will be displayed as default input *
+ * Return: the input (text) the user entered, if pressed "Ok" *
+ * NULL, if pressed "Cancel" *
+ \********************************************************************/
+gchar *
+gnc_input_dialog (GtkWidget *parent, const gchar *title, const gchar *msg, const gchar *default_input)
+{
+ GtkWidget *dialog, *label, *content_area;
+ gint result;
+ GtkWidget *view;
+ GtkTextBuffer *buffer;
+ gchar *user_input = NULL;
+ GtkTextIter start, end;
+
+ /* Create the widgets */
+ dialog = gtk_dialog_new_with_buttons (title, GTK_WINDOW (parent),
+ GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+ _("_OK"), GTK_RESPONSE_ACCEPT,
+ _("_Cancel"), GTK_RESPONSE_REJECT,
+ NULL);
+ content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+
+ // add a label
+ label = gtk_label_new (msg);
+ gtk_box_pack_start(GTK_BOX(content_area), label, FALSE, FALSE, 0);
+
+ // add a textview
+ view = gtk_text_view_new ();
+ gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), GTK_WRAP_WORD_CHAR);
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
+ gtk_text_buffer_set_text (buffer, default_input, -1);
+ gtk_box_pack_start(GTK_BOX(content_area), view, TRUE, TRUE, 0);
+
+ // run the dialog
+ gtk_widget_show_all (dialog);
+ result = gtk_dialog_run (GTK_DIALOG (dialog));
+
+ if (result == GTK_RESPONSE_REJECT)
+ user_input = 0;
+ else
+ {
+ gtk_text_buffer_get_start_iter (buffer, &start);
+ gtk_text_buffer_get_end_iter (buffer, &end);
+ user_input = gtk_text_buffer_get_text (buffer,
+ &start, &end, FALSE);
+ }
+
+ gtk_widget_destroy (dialog);
+
+ return user_input;
+}
diff --git a/gnucash/gnome-utils/gnc-ui.h b/gnucash/gnome-utils/gnc-ui.h
index 6be6192db..f3a123a8f 100644
--- a/gnucash/gnome-utils/gnc-ui.h
+++ b/gnucash/gnome-utils/gnc-ui.h
@@ -104,6 +104,8 @@ extern void
gnc_error_dialog (GtkWindow *parent,
const char *format, ...) G_GNUC_PRINTF (2, 3);
+extern gchar *
+gnc_input_dialog (GtkWidget *parent, const gchar *title, const gchar *msg, const gchar *default_input);
extern void
gnc_gnome_help (GtkWindow *parent, const char *file_name, const char *target_link);
diff --git a/gnucash/import-export/bi-import/dialog-bi-import-gui.c b/gnucash/import-export/bi-import/dialog-bi-import-gui.c
index 943869e01..d7e5cbfcc 100644
--- a/gnucash/import-export/bi-import/dialog-bi-import-gui.c
+++ b/gnucash/import-export/bi-import/dialog-bi-import-gui.c
@@ -75,7 +75,6 @@ void gnc_bi_import_gui_open_mode_cb (GtkWidget *widget, gpointer data);
void gnc_import_gui_type_cb (GtkWidget *widget, gpointer data);
// utils
-static gchar *gnc_input_dialog (GtkWidget *parent, const gchar *title, const gchar *msg, const gchar *default_input);
static void gnc_info2_dialog (GtkWidget *parent, const gchar *title, const gchar *msg);
#define UNUSED_VAR __attribute__ ((unused))
@@ -392,70 +391,6 @@ void gnc_import_gui_type_cb (GtkWidget *widget, gpointer data)
}
-
-/********************************************************************\
- * gnc_input_dialog *
- * simple convenience dialog to get a single value from the user *
- * user may choose between "Ok" and "Cancel" *
- * *
- * NOTE: This function does not return until the dialog is closed *
- * *
- * Args: parent - the parent window or NULL *
- * title - the title of the dialog *
- * msg - the message to display *
- * default_input - will be displayed as default input *
- * Return: the input (text) the user entered, if pressed "Ok" *
- * NULL, if pressed "Cancel" *
-\********************************************************************/
-static gchar *
-gnc_input_dialog (GtkWidget *parent, const gchar *title, const gchar *msg, const gchar *default_input)
-{
- GtkWidget *dialog, *label, *content_area;
- gint result;
- GtkWidget *view;
- GtkTextBuffer *buffer;
- gchar *user_input = NULL;
- GtkTextIter start, end;
-
- /* Create the widgets */
- dialog = gtk_dialog_new_with_buttons (title, GTK_WINDOW (parent),
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
- _("_OK"), GTK_RESPONSE_ACCEPT,
- _("_Cancel"), GTK_RESPONSE_REJECT,
- NULL);
- content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
-
- // add a label
- label = gtk_label_new (msg);
- gtk_box_pack_start(GTK_BOX(content_area), label, FALSE, FALSE, 0);
-
- // add a textview
- view = gtk_text_view_new ();
- gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), GTK_WRAP_WORD_CHAR);
- buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
- gtk_text_buffer_set_text (buffer, default_input, -1);
- gtk_box_pack_start(GTK_BOX(content_area), view, TRUE, TRUE, 0);
-
- // run the dialog
- gtk_widget_show_all (dialog);
- result = gtk_dialog_run (GTK_DIALOG (dialog));
-
- if (result == GTK_RESPONSE_REJECT)
- user_input = 0;
- else
- {
- gtk_text_buffer_get_start_iter (buffer, &start);
- gtk_text_buffer_get_end_iter (buffer, &end);
- user_input = gtk_text_buffer_get_text (buffer,
- &start, &end, FALSE);
- }
-
- gtk_widget_destroy (dialog);
-
- return user_input;
-}
-
-
/********************************************************************\
* gnc_info2_dialog *
* displays an information dialog box (with scrollable text area) *
@@ -503,3 +438,4 @@ gnc_info2_dialog (GtkWidget *parent, const gchar *title, const gchar *msg)
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
}
+
diff --git a/gnucash/import-export/csv-imp/assistant-csv-account-import.c b/gnucash/import-export/csv-imp/assistant-csv-account-import.c
index 953c8f66b..ebb68fd1d 100644
--- a/gnucash/import-export/csv-imp/assistant-csv-account-import.c
+++ b/gnucash/import-export/csv-imp/assistant-csv-account-import.c
@@ -65,8 +65,6 @@ void csv_import_hrows_cb (GtkWidget *spin, gpointer user_data );
void csv_import_file_chooser_file_activated_cb (GtkFileChooser *chooser, CsvImportInfo *info);
void csv_import_file_chooser_selection_changed_cb (GtkFileChooser *chooser, CsvImportInfo *info);
-static gchar *gnc_input_dialog (GtkWidget *parent, const gchar *title, const gchar *msg, const gchar *default_input);
-
static const gchar *finish_tree_string = N_(
"The accounts will be imported from the file '%s' when you click 'Apply'.\n\n"
"You can verify your selections by clicking on 'Back' or 'Cancel' to Abort Import.\n");
@@ -346,74 +344,6 @@ void load_settings (CsvImportInfo *info)
/* =============================================================== */
-
-/********************************************************************\
- * gnc_input_dialog *
- * simple convenience dialog to get a single value from the user *
- * user may choose between "Ok" and "Cancel" *
- * *
- * NOTE: This function does not return until the dialog is closed *
- * *
- * Args: parent - the parent window or NULL *
- * title - the title of the dialog *
- * msg - the message to display *
- * default_input - will be displayed as default input *
- * Return: the input (text) the user entered, if pressed "Ok" *
- * NULL, if pressed "Cancel" *
-\********************************************************************/
-static gchar *
-gnc_input_dialog (GtkWidget *parent, const gchar *title, const gchar *msg, const gchar *default_input)
-{
- GtkWidget *dialog, *label, *content_area;
- gint result;
- GtkWidget *view;
- GtkTextBuffer *buffer;
- gchar *user_input;
- GtkTextIter start, end;
-
- /* Create the widgets */
- dialog = gtk_dialog_new_with_buttons (title, GTK_WINDOW(parent),
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
- _("_OK"), GTK_RESPONSE_ACCEPT,
- _("_Cancel"), GTK_RESPONSE_REJECT,
- NULL);
-
- content_area = gtk_dialog_get_content_area (GTK_DIALOG(dialog));
-
- // add a label
- label = gtk_label_new (msg);
- gtk_container_add (GTK_CONTAINER(content_area), label);
-
- // add a textview
- view = gtk_text_view_new ();
- gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW(view), GTK_WRAP_WORD_CHAR);
- buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW(view));
- gtk_text_buffer_set_text (buffer, default_input, -1);
- gtk_container_add (GTK_CONTAINER(content_area), view);
-
- // run the dialog
- gtk_widget_show_all (dialog);
- result = gtk_dialog_run (GTK_DIALOG(dialog));
-
- if (result == GTK_RESPONSE_REJECT)
- user_input = 0;
- else
- {
- gtk_text_buffer_get_start_iter (buffer, &start);
- gtk_text_buffer_get_end_iter (buffer, &end);
- user_input = gtk_text_buffer_get_text (buffer,
- &start, &end, FALSE);
- }
-
- gtk_widget_destroy (dialog);
-
- return user_input;
-}
-
-
-/* =============================================================== */
-
-
/*******************************************************
* Assistant page prepare functions
*******************************************************/
diff --git a/gnucash/import-export/customer-import/dialog-customer-import-gui.c b/gnucash/import-export/customer-import/dialog-customer-import-gui.c
index eba0f033a..088713898 100644
--- a/gnucash/import-export/customer-import/dialog-customer-import-gui.c
+++ b/gnucash/import-export/customer-import/dialog-customer-import-gui.c
@@ -69,7 +69,6 @@ void gnc_customer_import_gui_option5_cb (GtkWidget *widget, gpointer data);
void gnc_customer_import_gui_type_cb (GtkWidget *widget, gpointer data);
// utils
-static gchar *gnc_input_dialog (GtkWidget *parent, const gchar *title, const gchar *msg, const gchar *default_input);
static void gnc_info2_dialog (GtkWidget *parent, const gchar *title, const gchar *msg);
@@ -354,70 +353,6 @@ void gnc_customer_import_gui_type_cb (GtkWidget *widget, gpointer data)
}
-
-
-/********************************************************************\
- * gnc_input_dialog *
- * simple convenience dialog to get a single value from the user *
- * user may choose between "Ok" and "Cancel" *
- * *
- * NOTE: This function does not return until the dialog is closed *
- * *
- * Args: parent - the parent window or NULL *
- * title - the title of the dialog *
- * msg - the message to display *
- * default_input - will be displayed as default input *
- * Return: the input (text) the user entered, if pressed "Ok" *
- * NULL, if pressed "Cancel" *
-\********************************************************************/
-static gchar *
-gnc_input_dialog (GtkWidget *parent, const gchar *title, const gchar *msg, const gchar *default_input)
-{
- GtkWidget *dialog, *label, *content_area;
- gint result;
- GtkWidget *view;
- GtkTextBuffer *buffer;
- gchar *user_input;
- GtkTextIter start, end;
-
- /* Create the widgets */
- dialog = gtk_dialog_new_with_buttons (title, GTK_WINDOW (parent),
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
- _("_OK"), GTK_RESPONSE_ACCEPT,
- _("_Cancel"), GTK_RESPONSE_REJECT,
- NULL);
- content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
-
- // add a label
- label = gtk_label_new (msg);
- gtk_box_pack_start(GTK_BOX(content_area), label, FALSE, FALSE, 0);
-
- // add a textview
- view = gtk_text_view_new ();
- gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), GTK_WRAP_WORD_CHAR);
- buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
- gtk_text_buffer_set_text (buffer, default_input, -1);
- gtk_box_pack_start(GTK_BOX(content_area), view, TRUE, TRUE, 0);
-
- // run the dialog
- gtk_widget_show_all (dialog);
- result = gtk_dialog_run (GTK_DIALOG (dialog));
-
- if (result == GTK_RESPONSE_REJECT)
- user_input = 0;
- else
- {
- gtk_text_buffer_get_start_iter (buffer, &start);
- gtk_text_buffer_get_end_iter (buffer, &end);
- user_input = gtk_text_buffer_get_text (buffer,
- &start, &end, FALSE);
- }
-
- gtk_widget_destroy (dialog);
-
- return user_input;
-}
-
/********************************************************************\
* gnc_info2_dialog *
* displays an information dialog box (with scrollable text area) *
Summary of changes:
gnucash/gnome-utils/gnc-gui-query.c | 124 +++++++++++++++++
gnucash/gnome-utils/gnc-ui.h | 8 ++
.../import-export/bi-import/dialog-bi-import-gui.c | 115 ----------------
.../csv-imp/assistant-csv-account-import.c | 70 ----------
.../customer-import/dialog-customer-import-gui.c | 117 ----------------
gnucash/import-export/import-main-matcher.c | 152 ++++++++++++++++++++-
6 files changed, 279 insertions(+), 307 deletions(-)
More information about the gnucash-changes
mailing list