mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Move dialog-dup-trans.c from ledger-core to gnome-utils.
Add gnc_dup_date_dialog() variant that can ask for a date without the "num" field. On pressing the Enter key, the widget closes but logs the following warning: CRIT <Gtk> IA__gtk_widget_event: assertion `WIDGET_REALIZED_FOR_EVENT (widget, event)' failed However, this problem already existed with the old code - the behaviour and warning was unchanged by this commit. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21684 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
3f75cbf8e4
commit
98aeba26d4
@ -32,6 +32,7 @@ libgncmod_gnome_utils_la_SOURCES = \
|
||||
dialog-account.c \
|
||||
dialog-book-close.c \
|
||||
dialog-commodity.c \
|
||||
dialog-dup-trans.c \
|
||||
dialog-file-access.c \
|
||||
dialog-object-references.c \
|
||||
dialog-options.c \
|
||||
@ -113,6 +114,7 @@ gncinclude_HEADERS = \
|
||||
dialog-account.h \
|
||||
dialog-book-close.h \
|
||||
dialog-commodity.h \
|
||||
dialog-dup-trans.h \
|
||||
dialog-file-access.h \
|
||||
dialog-preferences.h \
|
||||
dialog-object-references.h \
|
||||
|
@ -28,13 +28,13 @@
|
||||
#include <time.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "dialog-dup-trans.h"
|
||||
#include "dialog-utils.h"
|
||||
#include "gnc-date-edit.h"
|
||||
#include "qof.h"
|
||||
#include "gnc-ui.h"
|
||||
|
||||
/* This static indicates the debugging module that this .o belongs to. */
|
||||
static QofLogModule log_module = GNC_MOD_GUI;
|
||||
static QofLogModule log_module = G_LOG_DOMAIN;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@ -44,6 +44,10 @@ typedef struct
|
||||
|
||||
GtkWidget * date_edit;
|
||||
GtkWidget * num_edit;
|
||||
|
||||
GtkWidget *duplicate_title_label; // GtkLabel
|
||||
GtkWidget *duplicate_table; // GtkTable
|
||||
GtkWidget *num_label; // GtkLabel
|
||||
} DupTransDialog;
|
||||
|
||||
/* Parses the string value and returns true if it is a
|
||||
@ -121,6 +125,10 @@ gnc_dup_trans_dialog_create (GtkWidget * parent, DupTransDialog *dt_dialog,
|
||||
dt_dialog->date_edit = date_edit;
|
||||
}
|
||||
|
||||
dt_dialog->duplicate_title_label = GTK_WIDGET(gtk_builder_get_object (builder, "duplicate_title_label"));
|
||||
dt_dialog->duplicate_table = GTK_WIDGET(gtk_builder_get_object (builder, "duplicate_table"));
|
||||
dt_dialog->num_label = GTK_WIDGET(gtk_builder_get_object (builder, "num_label"));
|
||||
|
||||
{
|
||||
GtkWidget *num_spin;
|
||||
long int num;
|
||||
@ -143,20 +151,9 @@ gnc_dup_trans_dialog_create (GtkWidget * parent, DupTransDialog *dt_dialog,
|
||||
g_object_unref(G_OBJECT(builder));
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
* gnc_dup_trans_dialog *
|
||||
* opens up a window to do an automatic transfer between accounts *
|
||||
* *
|
||||
* Args: parent - the parent of the window to be created *
|
||||
* date - the initial date to use, and the output *
|
||||
* parameter for the new date *
|
||||
* num - input num field *
|
||||
* out_num - output num field, g_newed string *
|
||||
* Return: TRUE if user closes dialog with 'OK' *
|
||||
\********************************************************************/
|
||||
gboolean
|
||||
gnc_dup_trans_dialog (GtkWidget * parent, time_t *date_p,
|
||||
const char *num, char **out_num)
|
||||
static gboolean
|
||||
gnc_dup_trans_dialog_internal (GtkWidget * parent, const char* title, time_t *date_p,
|
||||
const char *num, char **out_num)
|
||||
{
|
||||
DupTransDialog *dt_dialog;
|
||||
GNCDateEdit *gde;
|
||||
@ -164,7 +161,7 @@ gnc_dup_trans_dialog (GtkWidget * parent, time_t *date_p,
|
||||
gboolean ok;
|
||||
gint result;
|
||||
|
||||
if (!date_p || !out_num)
|
||||
if (!date_p)
|
||||
return FALSE;
|
||||
|
||||
dt_dialog = g_new0 (DupTransDialog, 1);
|
||||
@ -176,12 +173,25 @@ gnc_dup_trans_dialog (GtkWidget * parent, time_t *date_p,
|
||||
|
||||
gtk_widget_grab_focus (entry);
|
||||
|
||||
if (title)
|
||||
{
|
||||
gtk_label_set_text(GTK_LABEL (dt_dialog->duplicate_title_label), title);
|
||||
}
|
||||
|
||||
if (!out_num)
|
||||
{
|
||||
// The "num" field isn't being asked for, so we make the widgets invisible
|
||||
gtk_widget_set_visible(dt_dialog->num_label, FALSE);
|
||||
gtk_widget_set_visible(dt_dialog->num_edit, FALSE);
|
||||
}
|
||||
|
||||
result = gtk_dialog_run (GTK_DIALOG (dt_dialog->dialog));
|
||||
|
||||
if (result == GTK_RESPONSE_OK)
|
||||
{
|
||||
*date_p = gnc_date_edit_get_date (GNC_DATE_EDIT (dt_dialog->date_edit));
|
||||
*out_num = g_strdup (gtk_entry_get_text (GTK_ENTRY (dt_dialog->num_edit)));
|
||||
if (out_num)
|
||||
*out_num = g_strdup (gtk_entry_get_text (GTK_ENTRY (dt_dialog->num_edit)));
|
||||
ok = TRUE;
|
||||
}
|
||||
else
|
||||
@ -192,3 +202,16 @@ gnc_dup_trans_dialog (GtkWidget * parent, time_t *date_p,
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gnc_dup_trans_dialog (GtkWidget * parent, time_t *date_p,
|
||||
const char *num, char **out_num)
|
||||
{
|
||||
return gnc_dup_trans_dialog_internal(parent, NULL, date_p, num, out_num);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gnc_dup_date_dialog (GtkWidget * parent, const char* title, time_t *date_p)
|
||||
{
|
||||
return gnc_dup_trans_dialog_internal(parent, title, date_p, NULL, NULL);
|
||||
}
|
62
src/gnome-utils/dialog-dup-trans.h
Normal file
62
src/gnome-utils/dialog-dup-trans.h
Normal file
@ -0,0 +1,62 @@
|
||||
/********************************************************************\
|
||||
* dialog-dup-trans.h -- duplicate transaction dialog *
|
||||
* Copyright (C) 2001 Gnumatic, Inc. *
|
||||
* Author: Dave Peticolas <dave@krondo.com> *
|
||||
* Copyright (C) 2011, Christian Stimming *
|
||||
* Author: Christian Stimming
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation; either version 2 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License*
|
||||
* along with this program; if not, contact: *
|
||||
* *
|
||||
* Free Software Foundation Voice: +1-617-542-5942 *
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org *
|
||||
\********************************************************************/
|
||||
|
||||
|
||||
#ifndef DIALOGDUPTRANS_H
|
||||
#define DIALOGDUPTRANS_H
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
|
||||
/********************************************************************\
|
||||
* gnc_dup_trans_dialog *
|
||||
* opens up a window to do an automatic transfer between accounts *
|
||||
* *
|
||||
* Args: parent - the parent of the window to be created *
|
||||
* date - the initial date to use, and the output *
|
||||
* parameter for the new date *
|
||||
* num - input num field *
|
||||
* out_num - output num field, g_newed string *
|
||||
* Return: TRUE if user closes dialog with 'OK' *
|
||||
\********************************************************************/
|
||||
gboolean
|
||||
gnc_dup_trans_dialog (GtkWidget * parent, time_t *date_p,
|
||||
const char *num, char **out_num);
|
||||
|
||||
|
||||
/**
|
||||
* Opens up a window to ask for a date for the duplicated element
|
||||
*
|
||||
* \param parent The parent of the window to be created
|
||||
* \param title The text of the title label
|
||||
* \param date The initial date to use, and the output
|
||||
* parameter for the new date
|
||||
*
|
||||
* \return TRUE if user closes dialog with 'OK', otherwise FALSE
|
||||
*/
|
||||
gboolean
|
||||
gnc_dup_date_dialog (GtkWidget * parent, const char* title, time_t *date_p);
|
||||
|
||||
#endif // DIALOGDUPTRANS_H
|
@ -103,8 +103,6 @@ int gnc_choose_radio_option_dialog (GtkWidget *parent,
|
||||
int default_value,
|
||||
GList *radio_list);
|
||||
|
||||
gboolean gnc_dup_trans_dialog (GtkWidget *parent, time_t *date_p,
|
||||
const char *num, char **out_num);
|
||||
void gnc_tax_info_dialog (GtkWidget *parent);
|
||||
void gnc_stock_split_dialog (GtkWidget *parent, Account * initial);
|
||||
|
||||
|
@ -62,7 +62,7 @@
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label1">
|
||||
<object class="GtkLabel" id="duplicate_title_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">0</property>
|
||||
@ -81,7 +81,7 @@
|
||||
<property name="can_focus">False</property>
|
||||
<property name="left_padding">12</property>
|
||||
<child>
|
||||
<object class="GtkTable" id="table2">
|
||||
<object class="GtkTable" id="duplicate_table">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="n_rows">2</property>
|
||||
@ -103,7 +103,7 @@
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label847670">
|
||||
<object class="GtkLabel" id="num_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">0</property>
|
||||
|
@ -3,7 +3,6 @@ SUBDIRS = . test
|
||||
pkglib_LTLIBRARIES = libgncmod-ledger-core.la
|
||||
|
||||
libgncmod_ledger_core_la_SOURCES = \
|
||||
dialog-dup-trans.c \
|
||||
gnc-ledger-display.c \
|
||||
gncmod-ledger-core.c \
|
||||
split-register.c \
|
||||
|
@ -48,6 +48,7 @@
|
||||
#include "split-register-model-save.h"
|
||||
#include "table-allgui.h"
|
||||
#include "dialog-account.h"
|
||||
#include "dialog-dup-trans.h"
|
||||
|
||||
|
||||
/** static variables ******************************************************/
|
||||
|
Loading…
Reference in New Issue
Block a user