[gnumeric] wbc-gtk.c: Refactor to avoid delicate duplicate code.
- From: Morten Welinder <mortenw src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnumeric] wbc-gtk.c: Refactor to avoid delicate duplicate code.
- Date: Thu, 30 Apr 2009 10:59:31 -0400 (EDT)
commit ef90fcbcf0dbc42be45bec5327abff2a316297e7
Author: Morten Welinder <terra gnome org>
Date: Thu Apr 30 10:58:58 2009 -0400
wbc-gtk.c: Refactor to avoid delicate duplicate code.
---
ChangeLog | 5 +++++
src/wbc-gtk.c | 37 +++++++++++++++++++------------------
2 files changed, 24 insertions(+), 18 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index f7d7efe..f492823 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2009-04-30 Morten Welinder <terra gnome org>
+ * src/wbc-gtk.c (set_entry_contents): New function for common
+ code.
+ (cb_dataset_changed, wbcg_data_allocator_editor): Use
+ set_entry_contents.
+
* src/graph.c (render_val): New function.
(gnm_go_data_scalar_get_str, gnm_go_data_vector_get_str,
gnm_go_data_matrix_get_str): Use render_val.
diff --git a/src/wbc-gtk.c b/src/wbc-gtk.c
index a171712..5e5bb81 100644
--- a/src/wbc-gtk.c
+++ b/src/wbc-gtk.c
@@ -4468,24 +4468,28 @@ cb_graph_dim_entry_focus_out_event (G_GNUC_UNUSED GtkEntry *ignored,
}
static void
+set_entry_contents (GnmExprEntry *entry, GOData *val)
+{
+ SheetControlGUI *scg = gnm_expr_entry_get_scg (entry);
+ Sheet const *sheet = scg_sheet (scg);
+ char *txt = go_data_serialize (val, (gpointer)sheet->convs);
+ gnm_expr_entry_load_from_text (entry, txt);
+ g_free (txt);
+}
+
+static void
cb_dataset_changed (GogDataset *dataset,
gboolean resize,
GraphDimEditor *editor)
{
- GOData *val;
-
- g_signal_handler_block (editor->entry, editor->entry_update_handler);
-
- val = gog_dataset_get_dim (dataset, editor->dim_i);
+ GOData *val = gog_dataset_get_dim (dataset, editor->dim_i);
if (val != NULL) {
- SheetControlGUI *scg = gnm_expr_entry_get_scg (editor->entry);
- Sheet const *sheet = scg_sheet (scg);
- char *txt = go_data_serialize (val, (gpointer)sheet->convs);
- gnm_expr_entry_load_from_text (editor->entry, txt);
- g_free (txt);
+ g_signal_handler_block (editor->entry,
+ editor->entry_update_handler);
+ set_entry_contents (editor->entry, val);
+ g_signal_handler_unblock (editor->entry,
+ editor->entry_update_handler);
}
-
- g_signal_handler_unblock (editor->entry, editor->entry_update_handler);
}
static void
@@ -4526,12 +4530,9 @@ wbcg_data_allocator_editor (GogDataAllocator *dalloc,
GTK_UPDATE_DISCONTINUOUS);
val = gog_dataset_get_dim (dataset, dim_i);
- if (val != NULL) {
- Sheet const *sheet = wbcg_cur_sheet (wbcg);
- char *txt = go_data_serialize (val, (gpointer)sheet->convs);
- gnm_expr_entry_load_from_text (editor->entry, txt);
- g_free (txt);
- }
+ if (val != NULL)
+ set_entry_contents (editor->entry, val);
+
gnm_expr_entry_set_flags (editor->entry, GNM_EE_FORCE_ABS_REF, GNM_EE_MASK);
editor->entry_update_handler = g_signal_connect (G_OBJECT (editor->entry),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]