Commit 874a819b authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

try and be smart about what a user wants when they activate and entry. If

2002-10-08  Jody Goldberg <jody@gnome.org>

	* dialog-define-names.c (cb_entry_activate) : try and be smart about
	  what a user wants when they activate and entry.  If there is
	  something there attempt to add it but don't close, else exit.

2002-10-09  Jody Goldberg <jody@gnome.org>

	* src/commands.c (cmd_define_name_redo) : fix ref counting.
parent 502797c7
2002-10-09 Jody Goldberg <jody@gnome.org>
* src/commands.c (cmd_define_name_redo) : fix ref counting.
2002-10-08 Jody Goldberg <jody@gnome.org> 2002-10-08 Jody Goldberg <jody@gnome.org>
* src/format.c (do_render_number) : Use the scale factor. * src/format.c (do_render_number) : Use the scale factor.
......
...@@ -30,6 +30,7 @@ Jody: ...@@ -30,6 +30,7 @@ Jody:
* Import named expressions, arrays and merged regions from OpenCalc * Import named expressions, arrays and merged regions from OpenCalc
* More cleanup after the big parser rework * More cleanup after the big parser rework
* Esoteric XL number formats #,,##0,, * Esoteric XL number formats #,,##0,,
* Simplify some dialog code
Morten: Morten:
* Port search center from gal's e-table to gtk's treeview. * Port search center from gal's e-table to gtk's treeview.
......
2002-10-09 Jody Goldberg <jody@gnome.org>
* src/commands.c (cmd_define_name_redo) : fix ref counting.
2002-10-08 Jody Goldberg <jody@gnome.org> 2002-10-08 Jody Goldberg <jody@gnome.org>
* src/format.c (do_render_number) : Use the scale factor. * src/format.c (do_render_number) : Use the scale factor.
......
2002-10-09 Jody Goldberg <jody@gnome.org>
* src/commands.c (cmd_define_name_redo) : fix ref counting.
2002-10-08 Jody Goldberg <jody@gnome.org> 2002-10-08 Jody Goldberg <jody@gnome.org>
* src/format.c (do_render_number) : Use the scale factor. * src/format.c (do_render_number) : Use the scale factor.
......
...@@ -5296,6 +5296,7 @@ cmd_define_name_redo (GnumericCommand *cmd, WorkbookControl *wbc) ...@@ -5296,6 +5296,7 @@ cmd_define_name_redo (GnumericCommand *cmd, WorkbookControl *wbc)
gnumeric_error_invalid (COMMAND_CONTEXT (wbc), _("Name"), err); gnumeric_error_invalid (COMMAND_CONTEXT (wbc), _("Name"), err);
return TRUE; return TRUE;
} }
expr_name_ref (me->nexpr);
me->expr = NULL; me->expr = NULL;
} else {/* assigning a value to a placeholder */ } else {/* assigning a value to a placeholder */
GnmExpr const *tmp = me->nexpr->t.expr_tree; GnmExpr const *tmp = me->nexpr->t.expr_tree;
......
2002-10-08 Jody Goldberg <jody@gnome.org>
* dialog-define-names.c (cb_entry_activate) : try and be smart about
what a user wants when they activate and entry. If there is
something there attempt to add it but don't close, else exit.
2002-10-07 Andreas J. Guelzow <aguelzow@taliesin.ca> 2002-10-07 Andreas J. Guelzow <aguelzow@taliesin.ca>
* dialog-cell-sort.c (cb_add_clicked): plug leak * dialog-cell-sort.c (cb_add_clicked): plug leak
......
...@@ -386,7 +386,7 @@ cb_cancel_clicked (GtkButton *button, AutoFormatState *state) ...@@ -386,7 +386,7 @@ cb_cancel_clicked (GtkButton *button, AutoFormatState *state)
} }
static void static void
cb_autoformat_destroy (GtkWidget *ignored, AutoFormatState *state) cb_autoformat_destroy (AutoFormatState *state)
{ {
wbcg_edit_detach_guru (state->wbcg); wbcg_edit_detach_guru (state->wbcg);
...@@ -685,9 +685,8 @@ dialog_autoformat (WorkbookControlGUI *wbcg) ...@@ -685,9 +685,8 @@ dialog_autoformat (WorkbookControlGUI *wbcg)
gtk_dialog_set_default_response (state->dialog, GTK_RESPONSE_OK); gtk_dialog_set_default_response (state->dialog, GTK_RESPONSE_OK);
/* a candidate for merging into attach guru */ /* a candidate for merging into attach guru */
g_signal_connect (G_OBJECT (state->dialog), g_object_set_data_full (G_OBJECT (state->dialog),
"destroy", "state", state, (GDestroyNotify)cb_autoformat_destroy);
G_CALLBACK (cb_autoformat_destroy), state);
gnumeric_non_modal_dialog (state->wbcg, GTK_WINDOW (state->dialog)); gnumeric_non_modal_dialog (state->wbcg, GTK_WINDOW (state->dialog));
wbcg_edit_attach_guru (state->wbcg, GTK_WIDGET (state->dialog)); wbcg_edit_attach_guru (state->wbcg, GTK_WIDGET (state->dialog));
gtk_widget_show_all (GTK_WIDGET (state->dialog)); gtk_widget_show_all (GTK_WIDGET (state->dialog));
......
...@@ -2466,7 +2466,7 @@ cb_fmt_dialog_dialog_buttons (GtkWidget *btn, FormatState *state) ...@@ -2466,7 +2466,7 @@ cb_fmt_dialog_dialog_buttons (GtkWidget *btn, FormatState *state)
/* Handler for destroy */ /* Handler for destroy */
static gboolean static gboolean
cb_fmt_dialog_dialog_destroy (GtkObject *unused, FormatState *state) cb_fmt_dialog_dialog_destroy (FormatState *state)
{ {
wbcg_edit_detach_guru (state->wbcg); wbcg_edit_detach_guru (state->wbcg);
style_format_unref (state->format.spec); style_format_unref (state->format.spec);
...@@ -2772,6 +2772,9 @@ fmt_dialog_impl (FormatState *state, FormatDialogPosition_t pageno) ...@@ -2772,6 +2772,9 @@ fmt_dialog_impl (FormatState *state, FormatDialogPosition_t pageno)
/* Ok, edit events from now on are real */ /* Ok, edit events from now on are real */
state->enable_edit = TRUE; state->enable_edit = TRUE;
g_signal_connect (G_OBJECT (dialog),
"set-focus",
G_CALLBACK (cb_fmt_dialog_set_focus), state);
/* We could now make it modeless, and arguably should do so. We must /* We could now make it modeless, and arguably should do so. We must
* then track the selection: styles should be applied to the current * then track the selection: styles should be applied to the current
* selection. * selection.
...@@ -2783,14 +2786,11 @@ fmt_dialog_impl (FormatState *state, FormatDialogPosition_t pageno) ...@@ -2783,14 +2786,11 @@ fmt_dialog_impl (FormatState *state, FormatDialogPosition_t pageno)
* cell is selected? May be, but then we can't first make a style, * cell is selected? May be, but then we can't first make a style,
* then move around and apply it to different cells. * then move around and apply it to different cells.
*/ */
g_signal_connect (G_OBJECT (dialog),
"destroy",
G_CALLBACK (cb_fmt_dialog_dialog_destroy), state);
wbcg_edit_attach_guru (state->wbcg, GTK_WIDGET (state->dialog));
g_signal_connect (G_OBJECT (dialog),
"set-focus",
G_CALLBACK (cb_fmt_dialog_set_focus), state);
/* a candidate for merging into attach guru */
g_object_set_data_full (G_OBJECT (state->dialog),
"state", state, (GDestroyNotify)cb_fmt_dialog_dialog_destroy);
wbcg_edit_attach_guru (state->wbcg, GTK_WIDGET (state->dialog));
gnumeric_non_modal_dialog (state->wbcg, GTK_WINDOW (state->dialog)); gnumeric_non_modal_dialog (state->wbcg, GTK_WINDOW (state->dialog));
gtk_widget_show (GTK_WIDGET (state->dialog)); gtk_widget_show (GTK_WIDGET (state->dialog));
} }
......
...@@ -164,8 +164,8 @@ dialog_set_button_sensitivity (GtkWidget *dummy, ConsolidateState *state) ...@@ -164,8 +164,8 @@ dialog_set_button_sensitivity (GtkWidget *dummy, ConsolidateState *state)
return; return;
} }
static gboolean static void
cb_dialog_destroy (GtkObject *object, ConsolidateState *state) cb_dialog_destroy (ConsolidateState *state)
{ {
wbcg_edit_detach_guru (state->wbcg); wbcg_edit_detach_guru (state->wbcg);
...@@ -176,8 +176,6 @@ cb_dialog_destroy (GtkObject *object, ConsolidateState *state) ...@@ -176,8 +176,6 @@ cb_dialog_destroy (GtkObject *object, ConsolidateState *state)
g_free (state->construct_error); g_free (state->construct_error);
} }
g_free (state); g_free (state);
return FALSE;
} }
static void static void
...@@ -385,9 +383,6 @@ setup_widgets (ConsolidateState *state, GladeXML *glade_gui) ...@@ -385,9 +383,6 @@ setup_widgets (ConsolidateState *state, GladeXML *glade_gui)
gnumeric_editable_enters (GTK_WINDOW (state->gui.dialog), gnumeric_editable_enters (GTK_WINDOW (state->gui.dialog),
GTK_WIDGET (state->gui.source)); GTK_WIDGET (state->gui.source));
g_signal_connect (G_OBJECT (state->gui.dialog),
"destroy",
G_CALLBACK (cb_dialog_destroy), state);
g_signal_connect (G_OBJECT (state->gui.destination), g_signal_connect (G_OBJECT (state->gui.destination),
"changed", "changed",
G_CALLBACK (dialog_set_button_sensitivity), state); G_CALLBACK (dialog_set_button_sensitivity), state);
...@@ -479,9 +474,10 @@ dialog_consolidate (WorkbookControlGUI *wbcg) ...@@ -479,9 +474,10 @@ dialog_consolidate (WorkbookControlGUI *wbcg)
gtk_widget_grab_focus (GTK_WIDGET (state->gui.function)); gtk_widget_grab_focus (GTK_WIDGET (state->gui.function));
gtk_widget_grab_default (GTK_WIDGET (state->gui.btn_ok)); gtk_widget_grab_default (GTK_WIDGET (state->gui.btn_ok));
/* Show the dialog */ /* a candidate for merging into attach guru */
gnumeric_non_modal_dialog (state->wbcg, GTK_WINDOW (state->gui.dialog)); g_object_set_data_full (G_OBJECT (state->gui.dialog),
"state", state, (GDestroyNotify) cb_dialog_destroy);
wbcg_edit_attach_guru (state->wbcg, GTK_WIDGET (state->gui.dialog)); wbcg_edit_attach_guru (state->wbcg, GTK_WIDGET (state->gui.dialog));
gnumeric_non_modal_dialog (state->wbcg, GTK_WINDOW (state->gui.dialog));
gtk_widget_show (GTK_WIDGET (state->gui.dialog)); gtk_widget_show (GTK_WIDGET (state->gui.dialog));
} }
...@@ -424,11 +424,11 @@ name_guru_init_button (NameGuruState *state, char const *name) ...@@ -424,11 +424,11 @@ name_guru_init_button (NameGuruState *state, char const *name)
} }
static gboolean static gboolean
cb_name_guru_destroy (GtkObject *w, NameGuruState *state) cb_name_guru_destroy (NameGuruState *state)
{ {
g_return_val_if_fail (w != NULL, FALSE);
g_return_val_if_fail (state != NULL, FALSE); g_return_val_if_fail (state != NULL, FALSE);
puts ("foo");
wbcg_edit_detach_guru (state->wbcg); wbcg_edit_detach_guru (state->wbcg);
if (state->gui != NULL) { if (state->gui != NULL) {
...@@ -448,6 +448,17 @@ cb_name_guru_destroy (GtkObject *w, NameGuruState *state) ...@@ -448,6 +448,17 @@ cb_name_guru_destroy (GtkObject *w, NameGuruState *state)
return FALSE; return FALSE;
} }
static void
cb_entry_activate (GtkWidget *item, NameGuruState *state)
{
char const *name = gtk_entry_get_text (state->name);
if (name == NULL || *name == '\0' ||
gnm_expr_entry_is_blank (state->expr_entry))
gtk_widget_destroy (state->dialog);
name_guru_add (state);
}
static gboolean static gboolean
name_guru_init (NameGuruState *state, WorkbookControlGUI *wbcg) name_guru_init (NameGuruState *state, WorkbookControlGUI *wbcg)
{ {
...@@ -515,6 +526,10 @@ name_guru_init (NameGuruState *state, WorkbookControlGUI *wbcg) ...@@ -515,6 +526,10 @@ name_guru_init (NameGuruState *state, WorkbookControlGUI *wbcg)
g_signal_connect (G_OBJECT (state->name), g_signal_connect (G_OBJECT (state->name),
"changed", "changed",
G_CALLBACK (cb_name_guru_update_sensitivity), state); G_CALLBACK (cb_name_guru_update_sensitivity), state);
g_signal_connect (G_OBJECT (state->name),
"activate",
G_CALLBACK (cb_entry_activate), state);
/* We need to connect after because this is an expresion, and it will /* We need to connect after because this is an expresion, and it will
* be changed by the mouse selecting a range, update after the entry * be changed by the mouse selecting a range, update after the entry
* is updated with the new text. * is updated with the new text.
...@@ -522,22 +537,20 @@ name_guru_init (NameGuruState *state, WorkbookControlGUI *wbcg) ...@@ -522,22 +537,20 @@ name_guru_init (NameGuruState *state, WorkbookControlGUI *wbcg)
g_signal_connect_after (G_OBJECT (state->expr_entry), g_signal_connect_after (G_OBJECT (state->expr_entry),
"changed", "changed",
G_CALLBACK (cb_name_guru_update_sensitivity), state); G_CALLBACK (cb_name_guru_update_sensitivity), state);
g_signal_connect (G_OBJECT (gnm_expr_entry_get_entry (state->expr_entry)),
gnumeric_editable_enters (GTK_WINDOW (state->dialog), "activate",
GTK_WIDGET (state->name)); G_CALLBACK (cb_entry_activate), state);
gnumeric_editable_enters (GTK_WINDOW (state->dialog),
GTK_WIDGET (state->expr_entry));
gnumeric_keyed_dialog (state->wbcg, GTK_WINDOW (state->dialog),
DEFINE_NAMES_KEY);
gnm_expr_entry_set_scg (state->expr_entry, wbcg_cur_scg (wbcg)); gnm_expr_entry_set_scg (state->expr_entry, wbcg_cur_scg (wbcg));
name_guru_populate_list (state); name_guru_populate_list (state);
gnumeric_keyed_dialog (state->wbcg, GTK_WINDOW (state->dialog),
DEFINE_NAMES_KEY);
/* a candidate for merging into attach guru */ /* a candidate for merging into attach guru */
g_signal_connect (GTK_OBJECT (state->dialog), g_object_set_data_full (G_OBJECT (state->dialog),
"destroy", "state", state, (GDestroyNotify)cb_name_guru_destroy);
G_CALLBACK (cb_name_guru_destroy), state);
gnumeric_non_modal_dialog (state->wbcg, GTK_WINDOW (state->dialog)); gnumeric_non_modal_dialog (state->wbcg, GTK_WINDOW (state->dialog));
wbcg_edit_attach_guru (state->wbcg, state->dialog); wbcg_edit_attach_guru (state->wbcg, state->dialog);
gtk_widget_show_all (GTK_WIDGET (state->dialog)); gtk_widget_show_all (GTK_WIDGET (state->dialog));
......
...@@ -291,7 +291,7 @@ cb_merge_merge_clicked (GtkWidget *ignore, MergeState *state) ...@@ -291,7 +291,7 @@ cb_merge_merge_clicked (GtkWidget *ignore, MergeState *state)
} }
static void static void
cb_merge_destroy (GtkWidget *ignored, MergeState *state) cb_merge_destroy (MergeState *state)
{ {
wbcg_edit_detach_guru (state->wbcg); wbcg_edit_detach_guru (state->wbcg);
g_object_unref (G_OBJECT (state->gui)); g_object_unref (G_OBJECT (state->gui));
...@@ -422,13 +422,13 @@ dialog_merge (WorkbookControlGUI *wbcg) ...@@ -422,13 +422,13 @@ dialog_merge (WorkbookControlGUI *wbcg)
glade_xml_get_widget (state->gui, "help_button"), glade_xml_get_widget (state->gui, "help_button"),
"merge.html"); "merge.html");
g_signal_connect (G_OBJECT (state->dialog),
"destroy",
G_CALLBACK (cb_merge_destroy), state);
gnumeric_non_modal_dialog (state->wbcg, GTK_WINDOW (state->dialog));
wbcg_edit_attach_guru (state->wbcg, GTK_WIDGET (state->dialog));
gnumeric_keyed_dialog (state->wbcg, GTK_WINDOW (state->dialog), gnumeric_keyed_dialog (state->wbcg, GTK_WINDOW (state->dialog),
MERGE_KEY); MERGE_KEY);
/* a candidate for merging into attach guru */
g_object_set_data_full (G_OBJECT (state->dialog),
"state", state, (GDestroyNotify) cb_merge_destroy);
gnumeric_non_modal_dialog (state->wbcg, GTK_WINDOW (state->dialog));
wbcg_edit_attach_guru (state->wbcg, GTK_WIDGET (state->dialog));
gtk_widget_show_all (GTK_WIDGET (state->dialog)); gtk_widget_show_all (GTK_WIDGET (state->dialog));
} }
...@@ -689,7 +689,7 @@ cb_ok_clicked (GtkWidget *ignore, SheetManager *state) ...@@ -689,7 +689,7 @@ cb_ok_clicked (GtkWidget *ignore, SheetManager *state)
} }
static void static void
cb_sheet_order_destroy (GtkWidget *ignored, SheetManager *state) cb_sheet_order_destroy (SheetManager *state)
{ {
Workbook *wb = wb_control_workbook (WORKBOOK_CONTROL (state->wbcg)); Workbook *wb = wb_control_workbook (WORKBOOK_CONTROL (state->wbcg));
...@@ -960,11 +960,9 @@ dialog_sheet_order (WorkbookControlGUI *wbcg) ...@@ -960,11 +960,9 @@ dialog_sheet_order (WorkbookControlGUI *wbcg)
"sheet-order.html"); "sheet-order.html");
/* a candidate for merging into attach guru */ /* a candidate for merging into attach guru */
g_signal_connect (G_OBJECT (state->dialog), g_object_set_data_full (G_OBJECT (state->dialog),
"destroy", "state", state, (GDestroyNotify) cb_sheet_order_destroy);
G_CALLBACK (cb_sheet_order_destroy), state);
gnumeric_non_modal_dialog (state->wbcg, GTK_WINDOW (state->dialog)); gnumeric_non_modal_dialog (state->wbcg, GTK_WINDOW (state->dialog));
wbcg_edit_attach_guru (state->wbcg, GTK_WIDGET (state->dialog)); wbcg_edit_attach_guru (state->wbcg, GTK_WIDGET (state->dialog));
gtk_widget_show_all (GTK_WIDGET (state->dialog)); gtk_widget_show_all (GTK_WIDGET (state->dialog));
} }
...@@ -613,7 +613,7 @@ kill_popup_menu (GtkWidget *widget, GtkMenu *menu) ...@@ -613,7 +613,7 @@ kill_popup_menu (GtkWidget *widget, GtkMenu *menu)
g_return_if_fail (menu != NULL); g_return_if_fail (menu != NULL);
g_return_if_fail (GTK_IS_MENU (menu)); g_return_if_fail (GTK_IS_MENU (menu));
gtk_object_unref (GTK_OBJECT (menu)); gtk_object_destroy (GTK_OBJECT (menu));
} }
void void
......
...@@ -910,7 +910,7 @@ item_bar_destroy (GtkObject *object) ...@@ -910,7 +910,7 @@ item_bar_destroy (GtkObject *object)
ib_fonts_unref (ib); ib_fonts_unref (ib);
if (ib->tip) { if (ib->tip) {
gtk_object_unref (GTK_OBJECT (ib->tip)); gtk_object_destroy (GTK_OBJECT (ib->tip));
ib->tip = NULL; ib->tip = NULL;
} }
......
...@@ -1180,8 +1180,10 @@ scg_finalize (GObject *object) ...@@ -1180,8 +1180,10 @@ scg_finalize (GObject *object)
if (sc->view) if (sc->view)
sv_detach_control (sc); sv_detach_control (sc);
if (scg->table) if (scg->table) {
gtk_object_unref (GTK_OBJECT (scg->table)); gtk_object_destroy (GTK_OBJECT (scg->table));
scg->table =NULL;
}
if (G_OBJECT_CLASS (scg_parent_class)->finalize) if (G_OBJECT_CLASS (scg_parent_class)->finalize)
(*G_OBJECT_CLASS (scg_parent_class)->finalize)(object); (*G_OBJECT_CLASS (scg_parent_class)->finalize)(object);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment