mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Simplify dialog creation on date close dialog
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@22356 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
02970201a0
commit
653d7da4d8
@ -23,7 +23,6 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <gnome.h>
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
#include "dialog-utils.h"
|
||||
@ -118,46 +117,6 @@ fill_in_acct_info (DialogDateClose *ddc, gboolean set_default_acct)
|
||||
gnc_account_sel_set_account( gas, ddc->acct, set_default_acct );
|
||||
}
|
||||
|
||||
static void
|
||||
build_date_close_window (GtkWidget *hbox, const char *message)
|
||||
{
|
||||
GtkWidget *pixmap = NULL;
|
||||
GtkWidget *label;
|
||||
GtkWidget *alignment;
|
||||
char *s;
|
||||
|
||||
s = gnome_program_locate_file (NULL,
|
||||
GNOME_FILE_DOMAIN_PIXMAP,
|
||||
"gnome-question.png", TRUE, NULL);
|
||||
if (s)
|
||||
{
|
||||
pixmap = gtk_image_new_from_file(s);
|
||||
g_free(s);
|
||||
}
|
||||
|
||||
if (pixmap)
|
||||
{
|
||||
gtk_box_pack_start (GTK_BOX(hbox), pixmap, FALSE, TRUE, 0);
|
||||
gtk_widget_show (pixmap);
|
||||
}
|
||||
|
||||
label = gtk_label_new (message);
|
||||
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
|
||||
gtk_misc_set_padding (GTK_MISC (label), GNOME_PAD, 0);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
|
||||
gtk_widget_show (label);
|
||||
|
||||
/* Add some extra space on the right to balance the pixmap */
|
||||
if (pixmap)
|
||||
{
|
||||
alignment = gtk_alignment_new (0., 0., 0., 0.);
|
||||
gtk_widget_set_size_request (alignment, GNOME_PAD, -1);
|
||||
gtk_widget_show (alignment);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (hbox), alignment, FALSE, FALSE, 0);
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
gnc_dialog_date_close_parented (GtkWidget *parent, const char *message,
|
||||
const char *label_message,
|
||||
@ -167,8 +126,7 @@ gnc_dialog_date_close_parented (GtkWidget *parent, const char *message,
|
||||
{
|
||||
DialogDateClose *ddc;
|
||||
GtkWidget *date_box;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *label;
|
||||
GtkLabel *label;
|
||||
GtkBuilder *builder;
|
||||
gboolean retval;
|
||||
|
||||
@ -181,20 +139,20 @@ gnc_dialog_date_close_parented (GtkWidget *parent, const char *message,
|
||||
builder = gtk_builder_new();
|
||||
gnc_builder_add_from_file (builder, "dialog-date-close.glade", "Date Close Dialog");
|
||||
ddc->dialog = GTK_WIDGET(gtk_builder_get_object (builder, "Date Close Dialog"));
|
||||
hbox = GTK_WIDGET(gtk_builder_get_object (builder, "the_hbox"));
|
||||
label = GTK_WIDGET(gtk_builder_get_object (builder, "label"));
|
||||
|
||||
date_box = GTK_WIDGET(gtk_builder_get_object (builder, "date_box"));
|
||||
ddc->date = gnc_date_edit_new (time(NULL), FALSE, FALSE);
|
||||
gtk_box_pack_start (GTK_BOX(date_box), ddc->date, TRUE, TRUE, 0);
|
||||
gnc_date_edit_set_time_ts (GNC_DATE_EDIT (ddc->date), *ts);
|
||||
|
||||
if (parent)
|
||||
gtk_window_set_transient_for (GTK_WINDOW(ddc->dialog), GTK_WINDOW(parent));
|
||||
|
||||
build_date_close_window (hbox, message);
|
||||
|
||||
gnc_date_edit_set_time_ts (GNC_DATE_EDIT (ddc->date), *ts);
|
||||
gtk_label_set_text (GTK_LABEL (label), label_message);
|
||||
/* Set the labels */
|
||||
label = GTK_LABEL (gtk_builder_get_object (builder, "msg_label"));
|
||||
gtk_label_set_text (label, message);
|
||||
label = GTK_LABEL (gtk_builder_get_object (builder, "label"));
|
||||
gtk_label_set_text (label, label_message);
|
||||
|
||||
/* Setup signals */
|
||||
gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, ddc);
|
||||
@ -204,7 +162,7 @@ gnc_dialog_date_close_parented (GtkWidget *parent, const char *message,
|
||||
ddc->retval = FALSE;
|
||||
while (gtk_dialog_run (GTK_DIALOG (ddc->dialog)) == GTK_RESPONSE_OK)
|
||||
{
|
||||
/* If reponse is OK but flag is not set, try again */
|
||||
/* If response is OK but flag is not set, try again */
|
||||
if (ddc->retval)
|
||||
break;
|
||||
}
|
||||
@ -246,8 +204,7 @@ gnc_dialog_dates_acct_question_parented (GtkWidget *parent, const char *message,
|
||||
char **memo, Account **acct, gboolean *answer)
|
||||
{
|
||||
DialogDateClose *ddc;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *label;
|
||||
GtkLabel *label;
|
||||
GtkWidget *date_box;
|
||||
GtkWidget *acct_box;
|
||||
GtkBuilder *builder;
|
||||
@ -273,7 +230,6 @@ gnc_dialog_dates_acct_question_parented (GtkWidget *parent, const char *message,
|
||||
gnc_builder_add_from_file (builder, "dialog-date-close.glade", "Date Account Dialog");
|
||||
ddc->dialog = GTK_WIDGET(gtk_builder_get_object (builder, "Date Account Dialog"));
|
||||
ddc->memo_entry = GTK_WIDGET(gtk_builder_get_object (builder, "memo_entry"));
|
||||
hbox = GTK_WIDGET(gtk_builder_get_object (builder, "the_top_hbox"));
|
||||
|
||||
acct_box = GTK_WIDGET(gtk_builder_get_object (builder, "acct_hbox"));
|
||||
ddc->acct_combo = gnc_account_sel_new();
|
||||
@ -292,15 +248,16 @@ gnc_dialog_dates_acct_question_parented (GtkWidget *parent, const char *message,
|
||||
if (parent)
|
||||
gtk_window_set_transient_for (GTK_WINDOW(ddc->dialog), GTK_WINDOW(parent));
|
||||
|
||||
build_date_close_window (hbox, message);
|
||||
|
||||
/* Set the labels */
|
||||
label = GTK_WIDGET(gtk_builder_get_object (builder, "date_label"));
|
||||
gtk_label_set_text (GTK_LABEL (label), ddue_label_message);
|
||||
label = GTK_WIDGET(gtk_builder_get_object (builder, "postdate_label"));
|
||||
gtk_label_set_text (GTK_LABEL (label), post_label_message);
|
||||
label = GTK_WIDGET(gtk_builder_get_object (builder, "acct_label"));
|
||||
gtk_label_set_text (GTK_LABEL (label), acct_label_message);
|
||||
label = GTK_LABEL (gtk_builder_get_object (builder, "top_msg_label"));
|
||||
gtk_label_set_text (label, message);
|
||||
label = GTK_LABEL (gtk_builder_get_object (builder, "date_label"));
|
||||
gtk_label_set_text (label, ddue_label_message);
|
||||
label = GTK_LABEL (gtk_builder_get_object (builder, "postdate_label"));
|
||||
gtk_label_set_text (label, post_label_message);
|
||||
label = GTK_LABEL (gtk_builder_get_object (builder, "acct_label"));
|
||||
gtk_label_set_text (label, acct_label_message);
|
||||
|
||||
if (question_check_message)
|
||||
{
|
||||
@ -342,7 +299,7 @@ gnc_dialog_dates_acct_question_parented (GtkWidget *parent, const char *message,
|
||||
ddc->retval = FALSE;
|
||||
while (gtk_dialog_run (GTK_DIALOG (ddc->dialog)) == GTK_RESPONSE_OK)
|
||||
{
|
||||
/* If reponse is OK but flag is not set, try again */
|
||||
/* If response is OK but flag is not set, try again */
|
||||
if (ddc->retval)
|
||||
break;
|
||||
}
|
||||
@ -369,8 +326,7 @@ gnc_dialog_date_acct_parented (GtkWidget *parent, const char *message,
|
||||
Timespec *date, Account **acct)
|
||||
{
|
||||
DialogDateClose *ddc;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *label;
|
||||
GtkLabel *label;
|
||||
GtkWidget *date_box;
|
||||
GtkWidget *acct_box;
|
||||
GtkBuilder *builder;
|
||||
@ -389,7 +345,6 @@ gnc_dialog_date_acct_parented (GtkWidget *parent, const char *message,
|
||||
builder = gtk_builder_new();
|
||||
gnc_builder_add_from_file (builder, "dialog-date-close.glade", "Date Account Dialog");
|
||||
ddc->dialog = GTK_WIDGET(gtk_builder_get_object (builder, "Date Account Dialog"));
|
||||
hbox = GTK_WIDGET(gtk_builder_get_object (builder, "the_top_hbox"));
|
||||
|
||||
acct_box = GTK_WIDGET(gtk_builder_get_object (builder, "acct_hbox"));
|
||||
ddc->acct_combo = gnc_account_sel_new();
|
||||
@ -404,13 +359,14 @@ gnc_dialog_date_acct_parented (GtkWidget *parent, const char *message,
|
||||
if (parent)
|
||||
gtk_window_set_transient_for (GTK_WINDOW(ddc->dialog), GTK_WINDOW(parent));
|
||||
|
||||
build_date_close_window (hbox, message);
|
||||
|
||||
/* Set the labels */
|
||||
label = GTK_WIDGET(gtk_builder_get_object (builder, "date_label"));
|
||||
gtk_label_set_text (GTK_LABEL (label), date_label_message);
|
||||
label = GTK_WIDGET(gtk_builder_get_object (builder, "acct_label"));
|
||||
gtk_label_set_text (GTK_LABEL (label), acct_label_message);
|
||||
label = GTK_LABEL (gtk_builder_get_object (builder, "top_msg_label"));
|
||||
gtk_label_set_text (label, message);
|
||||
label = GTK_LABEL (gtk_builder_get_object (builder, "date_label"));
|
||||
gtk_label_set_text (label, date_label_message);
|
||||
label = GTK_LABEL (gtk_builder_get_object (builder, "acct_label"));
|
||||
gtk_label_set_text (label, acct_label_message);
|
||||
|
||||
/* Set the date widget */
|
||||
gnc_date_edit_set_time_ts (GNC_DATE_EDIT (ddc->date), *date);
|
||||
@ -431,7 +387,7 @@ gnc_dialog_date_acct_parented (GtkWidget *parent, const char *message,
|
||||
ddc->retval = FALSE;
|
||||
while (gtk_dialog_run (GTK_DIALOG (ddc->dialog)) == GTK_RESPONSE_OK)
|
||||
{
|
||||
/* If reponse is OK but flag is not set, try again */
|
||||
/* If response is OK but flag is not set, try again */
|
||||
if (ddc->retval)
|
||||
break;
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
<?xml version="1.0"?>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<requires lib="gtk+" version="2.16"/>
|
||||
<!-- interface-naming-policy project-wide -->
|
||||
<object class="GtkDialog" id="Date Account Dialog">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
@ -70,7 +69,30 @@
|
||||
<property name="can_focus">False</property>
|
||||
<property name="border_width">3</property>
|
||||
<child>
|
||||
<placeholder/>
|
||||
<object class="GtkImage" id="image2">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xpad">8</property>
|
||||
<property name="stock">gtk-dialog-question</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="top_msg_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xpad">8</property>
|
||||
<property name="label" translatable="yes">Dummy message</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
@ -366,7 +388,30 @@
|
||||
<property name="can_focus">False</property>
|
||||
<property name="border_width">3</property>
|
||||
<child>
|
||||
<placeholder/>
|
||||
<object class="GtkImage" id="image1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xpad">8</property>
|
||||
<property name="stock">gtk-dialog-question</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="msg_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xpad">8</property>
|
||||
<property name="label" translatable="yes">Dummy message</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
|
Loading…
Reference in New Issue
Block a user