mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Merge Jean Laroche's 'bug798164' into maint.
This commit is contained in:
commit
cde8f9168f
@ -315,3 +315,127 @@ gnc_choose_radio_option_dialog(GtkWidget *parent,
|
||||
|
||||
return radio_result;
|
||||
}
|
||||
|
||||
static gchar *
|
||||
gnc_input_dialog_internal (GtkWidget *parent, const gchar *title, const gchar *msg, const gchar *default_input, gboolean use_entry)
|
||||
{
|
||||
gint result;
|
||||
GtkWidget *view;
|
||||
GtkTextBuffer *buffer;
|
||||
gchar *user_input = NULL;
|
||||
GtkTextIter start, end;
|
||||
|
||||
/* Create the widgets */
|
||||
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);
|
||||
GtkWidget* content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
|
||||
|
||||
// add a label
|
||||
GtkWidget* label = gtk_label_new (msg);
|
||||
gtk_box_pack_start(GTK_BOX(content_area), label, FALSE, FALSE, 0);
|
||||
|
||||
// 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)
|
||||
{
|
||||
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);
|
||||
|
||||
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 *view;
|
||||
GtkTextBuffer *buffer;
|
||||
gint width, height;
|
||||
|
||||
/* Create the widgets */
|
||||
GtkWidget* dialog = gtk_dialog_new_with_buttons (title, GTK_WINDOW (parent),
|
||||
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
_("_OK"), GTK_RESPONSE_ACCEPT,
|
||||
NULL);
|
||||
GtkWidget* content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
|
||||
|
||||
// add a scroll area
|
||||
GtkWidget* 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);
|
||||
}
|
||||
|
@ -104,6 +104,14 @@ 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 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);
|
||||
|
||||
extern void
|
||||
gnc_gnome_help (GtkWindow *parent, const char *file_name, const char *target_link);
|
||||
|
@ -74,10 +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 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))
|
||||
|
||||
static QofLogModule UNUSED_VAR log_module = G_LOG_DOMAIN; //G_LOG_BUSINESS;
|
||||
@ -392,114 +388,3 @@ 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) *
|
||||
* *
|
||||
* 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);
|
||||
}
|
||||
|
@ -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
|
||||
*******************************************************/
|
||||
|
@ -68,11 +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 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);
|
||||
|
||||
|
||||
CustomerImportGui *
|
||||
gnc_plugin_customer_import_showGUI(GtkWindow *parent)
|
||||
{
|
||||
@ -353,115 +348,3 @@ void gnc_customer_import_gui_type_cb (GtkWidget *widget, gpointer data)
|
||||
//printf ("TYPE set to, %s\n",gui->type); // DEBUG
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/********************************************************************\
|
||||
* 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) *
|
||||
* *
|
||||
* 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);
|
||||
}
|
||||
|
@ -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);
|
||||
@ -884,6 +885,119 @@ gnc_gen_trans_assign_transfer_account_to_selection_cb (GtkMenuItem *menuitem,
|
||||
LEAVE("");
|
||||
}
|
||||
|
||||
typedef enum
|
||||
{
|
||||
DESCRIPTION,
|
||||
MEMO,
|
||||
NOTES,
|
||||
} edit_field;
|
||||
|
||||
static void
|
||||
gnc_gen_trans_edit_fields (GtkMenuItem *menuitem, GNCImportMainMatcher *info,
|
||||
edit_field field)
|
||||
{
|
||||
GtkTreeView *treeview;
|
||||
GtkTreeSelection *selection;
|
||||
GtkTreeModel *model;
|
||||
GList *selected_rows;
|
||||
GList *refs = NULL;
|
||||
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);
|
||||
|
||||
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)
|
||||
{
|
||||
case DESCRIPTION:
|
||||
{
|
||||
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);
|
||||
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,
|
||||
@ -971,7 +1085,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;
|
||||
@ -986,6 +1101,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; */
|
||||
@ -1017,14 +1159,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");
|
||||
@ -1045,7 +1187,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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user