mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
gtk_entry_get_text instead of gtk_editable_get_chars
This commit is contained in:
@@ -2196,14 +2196,13 @@ static void
|
||||
gnc_account_renumber_update_examples (RenumberDialog *data)
|
||||
{
|
||||
gchar *str;
|
||||
gchar *prefix;
|
||||
gint interval;
|
||||
gint digits;
|
||||
unsigned int num_digits = 1;
|
||||
|
||||
g_return_if_fail (data->num_children > 0);
|
||||
|
||||
prefix = gtk_editable_get_chars (GTK_EDITABLE(data->prefix), 0, -1);
|
||||
const gchar *prefix = gtk_entry_get_text (GTK_ENTRY(data->prefix));
|
||||
interval = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON(data->interval));
|
||||
digits = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON(data->digits));
|
||||
|
||||
@@ -2225,7 +2224,7 @@ gnc_account_renumber_update_examples (RenumberDialog *data)
|
||||
else
|
||||
num_digits = digits;
|
||||
|
||||
if (strlen (prefix))
|
||||
if (prefix && *prefix)
|
||||
str = g_strdup_printf ("%s-%0*d", prefix, num_digits, interval);
|
||||
else
|
||||
str = g_strdup_printf ("%0*d", num_digits, interval);
|
||||
@@ -2243,7 +2242,6 @@ gnc_account_renumber_update_examples (RenumberDialog *data)
|
||||
gtk_label_set_text (GTK_LABEL(data->example2), str);
|
||||
|
||||
g_free (str);
|
||||
g_free (prefix);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -2276,7 +2274,6 @@ gnc_account_renumber_response_cb (GtkDialog *dialog,
|
||||
{
|
||||
GList *children = gnc_account_get_children_sorted (data->parent);
|
||||
GList *tmp;
|
||||
gchar *prefix;
|
||||
gint interval;
|
||||
unsigned int num_digits, i;
|
||||
|
||||
@@ -2288,7 +2285,7 @@ gnc_account_renumber_response_cb (GtkDialog *dialog,
|
||||
g_free (data);
|
||||
return;
|
||||
}
|
||||
prefix = gtk_editable_get_chars (GTK_EDITABLE(data->prefix), 0, -1);
|
||||
const gchar *prefix = gtk_entry_get_text (GTK_ENTRY(data->prefix));
|
||||
interval = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON(data->interval));
|
||||
num_digits = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON(data->digits));
|
||||
|
||||
@@ -2306,7 +2303,6 @@ gnc_account_renumber_response_cb (GtkDialog *dialog,
|
||||
g_free (str);
|
||||
}
|
||||
gnc_unset_busy_cursor (NULL);
|
||||
g_free (prefix);
|
||||
g_list_free (children);
|
||||
}
|
||||
gtk_widget_destroy (data->dialog);
|
||||
|
||||
@@ -154,7 +154,7 @@ gnc_dense_cal_store_clear(GncDenseCalStore *model)
|
||||
}
|
||||
|
||||
void
|
||||
gnc_dense_cal_store_update_name(GncDenseCalStore *model, gchar *name)
|
||||
gnc_dense_cal_store_update_name(GncDenseCalStore *model, const gchar *name)
|
||||
{
|
||||
if (model->name != NULL)
|
||||
{
|
||||
@@ -165,7 +165,7 @@ gnc_dense_cal_store_update_name(GncDenseCalStore *model, gchar *name)
|
||||
}
|
||||
|
||||
void
|
||||
gnc_dense_cal_store_update_info(GncDenseCalStore *model, gchar *info)
|
||||
gnc_dense_cal_store_update_info(GncDenseCalStore *model, const gchar *info)
|
||||
{
|
||||
if (model->info != NULL)
|
||||
{
|
||||
|
||||
@@ -46,8 +46,8 @@ typedef struct _GncDenseCalStoreClass GncDenseCalStoreClass;
|
||||
GType gnc_dense_cal_store_get_type(void);
|
||||
GncDenseCalStore* gnc_dense_cal_store_new(int num_marks);
|
||||
void gnc_dense_cal_store_clear(GncDenseCalStore *model);
|
||||
void gnc_dense_cal_store_update_name(GncDenseCalStore *model, gchar* name);
|
||||
void gnc_dense_cal_store_update_info(GncDenseCalStore *model, gchar* info);
|
||||
void gnc_dense_cal_store_update_name(GncDenseCalStore *model, const gchar* name);
|
||||
void gnc_dense_cal_store_update_info(GncDenseCalStore *model, const gchar* info);
|
||||
|
||||
void gnc_dense_cal_store_update_recurrences_no_end(GncDenseCalStore *model, GDate *start, GList *recurrences);
|
||||
void gnc_dense_cal_store_update_recurrences_count_end(GncDenseCalStore *model, GDate *start, GList *recurrences, int num_occur);
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
\********************************************************************/
|
||||
|
||||
#include <config.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <glib/gi18n.h>
|
||||
@@ -114,7 +115,7 @@ struct _GncSxEditorDialog
|
||||
GncDenseCalStore *dense_cal_model;
|
||||
GncDenseCal *example_cal;
|
||||
|
||||
GtkEditable *nameEntry;
|
||||
GtkEntry *nameEntry;
|
||||
|
||||
GtkLabel *lastOccurLabel;
|
||||
|
||||
@@ -264,9 +265,9 @@ editor_ok_button_clicked_cb (GtkButton *b, GncSxEditorDialog *sxed)
|
||||
static gboolean
|
||||
gnc_sxed_check_name_changed (GncSxEditorDialog *sxed)
|
||||
{
|
||||
const char *name = gtk_entry_get_text (GTK_ENTRY (sxed->nameEntry));
|
||||
const char *name = gtk_entry_get_text (sxed->nameEntry);
|
||||
|
||||
if (strlen (name) == 0)
|
||||
if (!name || !name[0])
|
||||
return TRUE;
|
||||
|
||||
if (xaccSchedXactionGetName (sxed->sx) == NULL ||
|
||||
@@ -481,33 +482,27 @@ check_credit_debit_balance (gpointer key, gpointer val, gpointer ud)
|
||||
static gboolean
|
||||
gnc_sxed_check_names (GncSxEditorDialog *sxed)
|
||||
{
|
||||
gchar *name, *nameKey;
|
||||
gboolean nameExists, nameHasChanged;
|
||||
GList *sxList;
|
||||
|
||||
name = gtk_editable_get_chars (GTK_EDITABLE (sxed->nameEntry), 0, -1);
|
||||
if (strlen (name) == 0)
|
||||
const gchar *name = gtk_entry_get_text (sxed->nameEntry);
|
||||
if (!name || !name[0])
|
||||
{
|
||||
const char *sx_has_no_name_msg =
|
||||
_("Please name the Scheduled Transaction.");
|
||||
gnc_error_dialog (GTK_WINDOW (sxed->dialog), "%s", sx_has_no_name_msg);
|
||||
g_free (name);
|
||||
return FALSE;
|
||||
|
||||
}
|
||||
|
||||
nameExists = FALSE;
|
||||
nameKey = g_utf8_collate_key (name, -1);
|
||||
nameHasChanged =
|
||||
bool nameExists = FALSE;
|
||||
gchar *nameKey = g_utf8_collate_key (name, -1);
|
||||
bool nameHasChanged =
|
||||
(xaccSchedXactionGetName (sxed->sx) == NULL)
|
||||
|| (strcmp (xaccSchedXactionGetName (sxed->sx), name) != 0);
|
||||
for (sxList = gnc_book_get_schedxactions (gnc_get_current_book ())->sx_list;
|
||||
for (GList *sxList = gnc_book_get_schedxactions (gnc_get_current_book ())->sx_list;
|
||||
nameHasChanged && !nameExists && sxList;
|
||||
sxList = sxList->next)
|
||||
{
|
||||
char *existingName, *existingNameKey;
|
||||
existingName = xaccSchedXactionGetName ((SchedXaction*)sxList->data);
|
||||
existingNameKey = g_utf8_collate_key (existingName, -1);
|
||||
const char *existingName = xaccSchedXactionGetName ((SchedXaction*)sxList->data);
|
||||
char *existingNameKey = g_utf8_collate_key (existingName, -1);
|
||||
nameExists |= (strcmp (nameKey, existingNameKey) == 0);
|
||||
g_free (existingNameKey);
|
||||
}
|
||||
@@ -519,12 +514,8 @@ gnc_sxed_check_names (GncSxEditorDialog *sxed)
|
||||
"Are you sure you want to name this one the same?");
|
||||
if (!gnc_verify_dialog (GTK_WINDOW (sxed->dialog), FALSE,
|
||||
sx_has_existing_name_msg, name))
|
||||
{
|
||||
g_free (name);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
g_free (name);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -668,7 +659,7 @@ gnc_sxed_split_calculate_formula (GncSxEditorDialog *sxed, Split *s,
|
||||
qof_instance_get (QOF_INSTANCE (s),
|
||||
key, &str,
|
||||
NULL);
|
||||
if (str == NULL || strlen (str) == 0)
|
||||
if (!str || !str[0])
|
||||
{
|
||||
if (str)
|
||||
g_free (str);
|
||||
@@ -910,13 +901,9 @@ gnc_sxed_save_sx (GncSxEditorDialog *sxed)
|
||||
gnc_sx_begin_edit (sxed->sx);
|
||||
|
||||
/* name */
|
||||
{
|
||||
char *name;
|
||||
|
||||
name = gtk_editable_get_chars (sxed->nameEntry, 0, -1);
|
||||
const gchar *name = gtk_entry_get_text (sxed->nameEntry);
|
||||
if (name && *name)
|
||||
xaccSchedXactionSetName (sxed->sx, name);
|
||||
g_free (name);
|
||||
}
|
||||
|
||||
/* date */
|
||||
{
|
||||
@@ -1209,7 +1196,7 @@ gnc_ui_scheduled_xaction_editor_dialog_create (GtkWindow *parent,
|
||||
/* Connect the Widgets */
|
||||
sxed->dialog = GTK_WIDGET (gtk_builder_get_object (builder, "scheduled_transaction_editor_dialog"));
|
||||
sxed->notebook = GTK_NOTEBOOK (gtk_builder_get_object (builder, "editor_notebook"));
|
||||
sxed->nameEntry = GTK_EDITABLE (gtk_builder_get_object (builder, "sxe_name"));
|
||||
sxed->nameEntry = GTK_ENTRY (gtk_builder_get_object (builder, "sxe_name"));
|
||||
sxed->enabledOpt = GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "enabled_opt"));
|
||||
sxed->autocreateOpt = GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "autocreate_opt"));
|
||||
sxed->notifyOpt = GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "notify_opt"));
|
||||
@@ -1405,7 +1392,7 @@ schedXact_editor_populate (GncSxEditorDialog *sxed)
|
||||
name = xaccSchedXactionGetName (sxed->sx);
|
||||
if (name)
|
||||
{
|
||||
gtk_entry_set_text (GTK_ENTRY (sxed->nameEntry), name );
|
||||
gtk_entry_set_text (sxed->nameEntry, name);
|
||||
}
|
||||
{
|
||||
gd = xaccSchedXactionGetLastOccurDate (sxed->sx);
|
||||
|
||||
@@ -177,23 +177,22 @@ sxftd_get_end_info(SXFromTransInfo *sxfti)
|
||||
|
||||
if (gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(sxfti->oc_but) ))
|
||||
{
|
||||
gchar *text, *endptr;
|
||||
guint n_occs;
|
||||
|
||||
text = gtk_editable_get_chars(GTK_EDITABLE(sxfti->n_occurences), 0, -1);
|
||||
if (text == NULL || strlen(text) == 0)
|
||||
const gchar *text = gtk_entry_get_text (GTK_ENTRY(sxfti->n_occurences));
|
||||
if (!text || !text[0])
|
||||
{
|
||||
n_occs = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
gchar *endptr;
|
||||
n_occs = strtoul(text, &endptr, 10);
|
||||
if ( !endptr )
|
||||
{
|
||||
n_occs = -1;
|
||||
}
|
||||
}
|
||||
g_free(text);
|
||||
|
||||
retval.type = END_AFTER_N_OCCS;
|
||||
retval.n_occurrences = n_occs;
|
||||
@@ -447,7 +446,6 @@ sxftd_init( SXFromTransInfo *sxfti )
|
||||
static guint
|
||||
sxftd_compute_sx(SXFromTransInfo *sxfti)
|
||||
{
|
||||
gchar *name;
|
||||
GDate date;
|
||||
GList *schedule = NULL;
|
||||
getEndTuple end_info;
|
||||
@@ -456,10 +454,7 @@ sxftd_compute_sx(SXFromTransInfo *sxfti)
|
||||
SchedXaction *sx = sxfti->sx;
|
||||
|
||||
/* get the name */
|
||||
name = gtk_editable_get_chars(GTK_EDITABLE(sxfti->name), 0, -1);
|
||||
|
||||
xaccSchedXactionSetName(sx, name);
|
||||
g_free(name);
|
||||
xaccSchedXactionSetName(sx, gtk_entry_get_text (sxfti->name));
|
||||
|
||||
gnc_gdate_set_time64( &date, gnc_date_edit_get_date( sxfti->startDateGDE ) );
|
||||
|
||||
@@ -695,14 +690,8 @@ sxftd_update_example_cal( SXFromTransInfo *sxfti )
|
||||
g_date_clear(&nextDate, 1);
|
||||
recurrenceListNextInstance(schedule, &date, &nextDate);
|
||||
|
||||
{
|
||||
gchar *name;
|
||||
/* get the name */
|
||||
name = NULL;
|
||||
name = gtk_editable_get_chars(GTK_EDITABLE(sxfti->name), 0, -1);
|
||||
gnc_dense_cal_store_update_name(sxfti->dense_cal_model, name);
|
||||
g_free(name);
|
||||
}
|
||||
gnc_dense_cal_store_update_name (sxfti->dense_cal_model,
|
||||
gtk_entry_get_text (sxfti->name));
|
||||
|
||||
{
|
||||
gchar *schedule_desc;
|
||||
|
||||
Reference in New Issue
Block a user