[gnumeric] SheetObjectListBase: cleanup.
- From: Morten Welinder <mortenw src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnumeric] SheetObjectListBase: cleanup.
- Date: Tue, 13 Oct 2009 19:43:06 +0000 (UTC)
commit 8b89605ad9d7984fbbee4d1c9a9f6c2ba45e9396
Author: Morten Welinder <terra gnome org>
Date: Tue Oct 13 15:39:06 2009 -0400
SheetObjectListBase: cleanup.
ChangeLog | 6 ++++
src/commands.c | 8 +----
src/dialogs/dialog-so-list.c | 20 ++++++++++----
src/sheet-object-widget.c | 60 ++++++++++++++++++++++++-----------------
src/sheet-object-widget.h | 4 +-
5 files changed, 59 insertions(+), 39 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 1400fe6..80654f8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,12 @@
* src/sheet-object-widget.c (sheet_widget_adjustment_get_horizontal):
New function.
+ (sheet_widget_list_base_get_content_link): Rename from
+ sheet_widget_list_base_get_content_dep. Return ref'd GnmExprTop.
+ All callers changed.
+ (sheet_widget_list_base_get_result_link): Rename from
+ sheet_widget_list_base_get_result_dep. Return ref'd GnmExprTop.
+ All callers changed.
2009-10-11 Andreas J. Guelzow <aguelzow pyrshep ca>
diff --git a/src/commands.c b/src/commands.c
index b33d7cb..b91a2e6 100644
--- a/src/commands.c
+++ b/src/commands.c
@@ -7094,12 +7094,8 @@ cmd_so_set_links_redo (GnmCommand *cmd, G_GNUC_UNUSED WorkbookControl *wbc)
GnmExprTop const *old_output;
GnmExprTop const *old_content;
- old_content = sheet_widget_list_base_get_content_dep (me->so)->texpr;
- if (old_content)
- gnm_expr_top_ref (old_content);
- old_output = sheet_widget_list_base_get_result_dep (me->so)->texpr;
- if (old_output)
- gnm_expr_top_ref (old_output);
+ old_content = sheet_widget_list_base_get_content_link (me->so);
+ old_output = sheet_widget_list_base_get_result_link (me->so);
sheet_widget_list_base_set_links
(me->so, me->output, me->content);
diff --git a/src/dialogs/dialog-so-list.c b/src/dialogs/dialog-so-list.c
index 83bb0b4..38602c6 100644
--- a/src/dialogs/dialog-so-list.c
+++ b/src/dialogs/dialog-so-list.c
@@ -60,10 +60,12 @@ cb_so_list_destroy (GnmDialogSOList *state)
static GnmExprEntry *
init_entry (GnmDialogSOList *state, char const *name,
- GnmDependent const *dep)
+ GnmExprTop const *texpr)
{
GnmExprEntry *gee;
GtkWidget *w = glade_xml_get_widget (state->gui, name);
+ Sheet *sheet = sheet_object_get_sheet (state->so);
+ GnmParsePos pp;
g_return_val_if_fail (w != NULL, NULL);
@@ -75,7 +77,9 @@ init_entry (GnmDialogSOList *state, char const *name,
gnm_expr_entry_set_flags (gee, GNM_EE_FORCE_ABS_REF |
GNM_EE_SHEET_OPTIONAL |
GNM_EE_SINGLE_RANGE, GNM_EE_MASK);
- gnm_expr_entry_load_from_dep (gee, dep);
+
+ parse_pos_init_sheet (&pp, sheet);
+ gnm_expr_entry_load_from_expr (gee, texpr, &pp);
return gee;
}
@@ -105,6 +109,7 @@ static gboolean
so_list_init (GnmDialogSOList *state, WBCGtk *wbcg, SheetObject *so)
{
GtkTable *table;
+ GnmExprTop const *texpr;
state->gui = gnm_glade_xml_new (GO_CMD_CONTEXT (wbcg),
"so-list.glade", NULL, NULL);
@@ -116,10 +121,13 @@ so_list_init (GnmDialogSOList *state, WBCGtk *wbcg, SheetObject *so)
state->dialog = glade_xml_get_widget (state->gui, "SOList");
table = GTK_TABLE (glade_xml_get_widget (state->gui, "table"));
- state->content_entry = init_entry (state, "content-entry",
- sheet_widget_list_base_get_content_dep (so));
- state->link_entry = init_entry (state, "link-entry",
- sheet_widget_list_base_get_result_dep (so));
+ texpr = sheet_widget_list_base_get_content_link (so);
+ state->content_entry = init_entry (state, "content-entry", texpr);
+ if (texpr) gnm_expr_top_unref (texpr);
+
+ texpr = sheet_widget_list_base_get_result_link (so);
+ state->link_entry = init_entry (state, "link-entry", texpr);
+ if (texpr) gnm_expr_top_unref (texpr);
g_signal_connect (G_OBJECT (state->dialog), "response",
G_CALLBACK (cb_so_list_response), state);
diff --git a/src/sheet-object-widget.c b/src/sheet-object-widget.c
index 59e2e5a..b25b9a4 100644
--- a/src/sheet-object-widget.c
+++ b/src/sheet-object-widget.c
@@ -932,10 +932,10 @@ sheet_widget_button_get_link (SheetObject *so)
{
SheetWidgetButton *swb = SHEET_WIDGET_BUTTON (so);
GnmExprTop const *texpr = swb->dep.texpr;
-
+
if (texpr)
gnm_expr_top_ref (texpr);
-
+
return texpr;
}
@@ -2573,11 +2573,11 @@ typedef struct {
GtkWidget *dialog;
GnmExprEntry *expression;
GtkWidget *label, *value;
-
+
char *old_label;
GnmValue *old_value;
GtkWidget *old_focus;
-
+
WBCGtk *wbcg;
SheetWidgetRadioButton *swrb;
Sheet *sheet;
@@ -2589,7 +2589,7 @@ cb_radio_button_set_focus (GtkWidget *window, GtkWidget *focus_widget,
{
/* Note: half of the set-focus action is handle by the default
* callback installed by wbc_gtk_attach_guru */
-
+
/* Force an update of the content in case it needs tweaking (eg make it
* absolute) */
if (state->old_focus != NULL &&
@@ -2609,12 +2609,12 @@ static void
cb_radio_button_config_destroy (RadioButtonConfigState *state)
{
g_return_if_fail (state != NULL);
-
+
if (state->gui != NULL) {
g_object_unref (G_OBJECT (state->gui));
state->gui = NULL;
}
-
+
g_free (state->old_label);
state->old_label = NULL;
@@ -2683,13 +2683,13 @@ sheet_widget_radio_button_user_config (SheetObject *so, SheetControl *sc)
RadioButtonConfigState *state;
GtkWidget *table;
GString *valstr;
-
+
g_return_if_fail (swrb != NULL);
-
+
/* Only pop up one copy per workbook */
if (gnumeric_dialog_raise_if_exists (wbcg, SHEET_OBJECT_CONFIG_KEY))
return;
-
+
state = g_new (RadioButtonConfigState, 1);
state->swrb = swrb;
state->wbcg = wbcg;
@@ -2700,9 +2700,9 @@ sheet_widget_radio_button_user_config (SheetObject *so, SheetControl *sc)
state->gui = gnm_glade_xml_new (GO_CMD_CONTEXT (wbcg),
"so-radiobutton.glade", NULL, NULL);
state->dialog = glade_xml_get_widget (state->gui, "SO-Radiobutton");
-
+
table = glade_xml_get_widget (state->gui, "table");
-
+
state->expression = gnm_expr_entry_new (wbcg, TRUE);
gnm_expr_entry_set_flags (state->expression,
GNM_EE_FORCE_ABS_REF | GNM_EE_SHEET_OPTIONAL | GNM_EE_SINGLE_RANGE,
@@ -2715,7 +2715,7 @@ sheet_widget_radio_button_user_config (SheetObject *so, SheetControl *sc)
GTK_EXPAND | GTK_FILL, 0,
0, 0);
gtk_widget_show (GTK_WIDGET (state->expression));
-
+
state->label = glade_xml_get_widget (state->gui, "label_entry");
gtk_entry_set_text (GTK_ENTRY (state->label), swrb->label);
gtk_editable_select_region (GTK_EDITABLE(state->label), 0, -1);
@@ -2732,7 +2732,7 @@ sheet_widget_radio_button_user_config (SheetObject *so, SheetControl *sc)
GTK_WIDGET (state->label));
gnumeric_editable_enters (GTK_WINDOW (state->dialog),
GTK_WIDGET (state->value));
-
+
g_signal_connect (G_OBJECT (state->label),
"changed",
G_CALLBACK (cb_radio_button_label_changed), state);
@@ -2745,23 +2745,23 @@ sheet_widget_radio_button_user_config (SheetObject *so, SheetControl *sc)
g_signal_connect (G_OBJECT (glade_xml_get_widget (state->gui, "cancel_button")),
"clicked",
G_CALLBACK (cb_radio_button_config_cancel_clicked), state);
-
+
gnumeric_init_help_button (
glade_xml_get_widget (state->gui, "help_button"),
GNUMERIC_HELP_LINK_SO_RADIO_BUTTON);
-
+
gnumeric_keyed_dialog (state->wbcg, GTK_WINDOW (state->dialog),
SHEET_OBJECT_CONFIG_KEY);
-
+
wbc_gtk_attach_guru (state->wbcg, state->dialog);
g_object_set_data_full (G_OBJECT (state->dialog),
"state", state, (GDestroyNotify) cb_radio_button_config_destroy);
-
+
/* Note: half of the set-focus action is handle by the default */
/* callback installed by wbc_gtk_attach_guru */
g_signal_connect (G_OBJECT (state->dialog), "set-focus",
G_CALLBACK (cb_radio_button_set_focus), state);
-
+
gtk_widget_show (state->dialog);
}
@@ -3053,18 +3053,28 @@ sheet_widget_list_base_set_links (SheetObject *so,
list_content_eval (&swl->content_dep); /* populate the list */
}
-GnmDependent const *
-sheet_widget_list_base_get_result_dep (SheetObject const *so)
+GnmExprTop const *
+sheet_widget_list_base_get_result_link (SheetObject const *so)
{
SheetWidgetListBase *swl = SHEET_WIDGET_LIST_BASE (so);
- return &swl->output_dep;
+ GnmExprTop const *texpr = swl->output_dep.texpr;
+
+ if (texpr)
+ gnm_expr_top_ref (texpr);
+
+ return texpr;
}
-GnmDependent const *
-sheet_widget_list_base_get_content_dep (SheetObject const *so)
+GnmExprTop const *
+sheet_widget_list_base_get_content_link (SheetObject const *so)
{
SheetWidgetListBase *swl = SHEET_WIDGET_LIST_BASE (so);
- return &swl->content_dep;
+ GnmExprTop const *texpr = swl->content_dep.texpr;
+
+ if (texpr)
+ gnm_expr_top_ref (texpr);
+
+ return texpr;
}
/****************************************************************************/
diff --git a/src/sheet-object-widget.h b/src/sheet-object-widget.h
index 75b2327..2ab9b59 100644
--- a/src/sheet-object-widget.h
+++ b/src/sheet-object-widget.h
@@ -86,8 +86,8 @@ void sheet_widget_frame_set_label (SheetObject *so, char const *str);
void sheet_widget_list_base_set_links (SheetObject *so,
GnmExprTop const *result_link,
GnmExprTop const *content);
-GnmDependent const *sheet_widget_list_base_get_result_dep (SheetObject const *so);
-GnmDependent const *sheet_widget_list_base_get_content_dep (SheetObject const *so);
+GnmExprTop const *sheet_widget_list_base_get_result_link (SheetObject const *so);
+GnmExprTop const *sheet_widget_list_base_get_content_link (SheetObject const *so);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]