Commit 69d6d36b authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

It is possible to have a guru up without editing.


2000-06-30  Jody Goldberg <jgoldberg@home.com>

	* src/gnumeric-sheet.c (gnumeric_sheet_can_select_expr_range) : It is
	  possible to have a guru up without editing.
	(gnumeric_sheet_key_press) : rename from gnumeric_sheet_key.
	(gnumeric_sheet_size_allocate) : rename from gnumeric_size_allocate.
	(gnumeric_sheet_focus_in) : Enable the input context.
	(gnumeric_sheet_focus_out) : Disable the input context.
	(gnumeric_sheet_realize) : Create the input context.
	(gnumeric_sheet_unrealize) : Destroy the input context.
	(gnumeric_sheet_class_init) : Register the new methods.
	(gnumeric_sheet_init) : Init the input context.

	* src/clipboard.c (x_selection_handler) : Adjust to changes in
	  application_clipboard_clear.
	(x_selection_clear) : Ditto.
	* src/cmd-edit.c (cmd_paste) : Ditto.
	* src/sheet.c (sheet_destroy) : Ditto.

	* src/application.c (application_clipboard_clear) : Make dropping the
	  selection optional.  This removes the kludges necessary to handle
	  changing the clipboard when we already have the selection.

	* src/functions/fn-logical.c (gnumeric_true, gnumeric_false) :
	  fix signatures.
parent af16133f
2000-06-30 Jody Goldberg <jgoldberg@home.com>
* src/gnumeric-sheet.c (gnumeric_sheet_can_select_expr_range) : It is
possible to have a guru up without editing.
(gnumeric_sheet_key_press) : rename from gnumeric_sheet_key.
(gnumeric_sheet_size_allocate) : rename from gnumeric_size_allocate.
(gnumeric_sheet_focus_in) : Enable the input context.
(gnumeric_sheet_focus_out) : Disable the input context.
(gnumeric_sheet_realize) : Create the input context.
(gnumeric_sheet_unrealize) : Destroy the input context.
(gnumeric_sheet_class_init) : Register the new methods.
(gnumeric_sheet_init) : Init the input context.
* src/clipboard.c (x_selection_handler) : Adjust to changes in
application_clipboard_clear.
(x_selection_clear) : Ditto.
* src/cmd-edit.c (cmd_paste) : Ditto.
* src/sheet.c (sheet_destroy) : Ditto.
* src/application.c (application_clipboard_clear) : Make dropping the
selection optional. This removes the kludges necessary to handle
changing the clipboard when we already have the selection.
* src/functions/fn-logical.c (gnumeric_true, gnumeric_false) :
fix signatures.
2000-06-30 Jukka-Pekka Iivonen <iivonen@iki.fi>
* src/functions/fn-logical.c: Added FALSE().
......
2000-06-30 Jody Goldberg <jgoldberg@home.com>
* src/gnumeric-sheet.c (gnumeric_sheet_can_select_expr_range) : It is
possible to have a guru up without editing.
(gnumeric_sheet_key_press) : rename from gnumeric_sheet_key.
(gnumeric_sheet_size_allocate) : rename from gnumeric_size_allocate.
(gnumeric_sheet_focus_in) : Enable the input context.
(gnumeric_sheet_focus_out) : Disable the input context.
(gnumeric_sheet_realize) : Create the input context.
(gnumeric_sheet_unrealize) : Destroy the input context.
(gnumeric_sheet_class_init) : Register the new methods.
(gnumeric_sheet_init) : Init the input context.
* src/clipboard.c (x_selection_handler) : Adjust to changes in
application_clipboard_clear.
(x_selection_clear) : Ditto.
* src/cmd-edit.c (cmd_paste) : Ditto.
* src/sheet.c (sheet_destroy) : Ditto.
* src/application.c (application_clipboard_clear) : Make dropping the
selection optional. This removes the kludges necessary to handle
changing the clipboard when we already have the selection.
* src/functions/fn-logical.c (gnumeric_true, gnumeric_false) :
fix signatures.
2000-06-30 Jukka-Pekka Iivonen <iivonen@iki.fi>
* src/functions/fn-logical.c: Added FALSE().
......
2000-06-30 Jody Goldberg <jgoldberg@home.com>
* src/gnumeric-sheet.c (gnumeric_sheet_can_select_expr_range) : It is
possible to have a guru up without editing.
(gnumeric_sheet_key_press) : rename from gnumeric_sheet_key.
(gnumeric_sheet_size_allocate) : rename from gnumeric_size_allocate.
(gnumeric_sheet_focus_in) : Enable the input context.
(gnumeric_sheet_focus_out) : Disable the input context.
(gnumeric_sheet_realize) : Create the input context.
(gnumeric_sheet_unrealize) : Destroy the input context.
(gnumeric_sheet_class_init) : Register the new methods.
(gnumeric_sheet_init) : Init the input context.
* src/clipboard.c (x_selection_handler) : Adjust to changes in
application_clipboard_clear.
(x_selection_clear) : Ditto.
* src/cmd-edit.c (cmd_paste) : Ditto.
* src/sheet.c (sheet_destroy) : Ditto.
* src/application.c (application_clipboard_clear) : Make dropping the
selection optional. This removes the kludges necessary to handle
changing the clipboard when we already have the selection.
* src/functions/fn-logical.c (gnumeric_true, gnumeric_false) :
fix signatures.
2000-06-30 Jukka-Pekka Iivonen <iivonen@iki.fi>
* src/functions/fn-logical.c: Added FALSE().
......
2000-06-30 Jody Goldberg <jgoldberg@home.com>
* src/gnumeric-sheet.c (gnumeric_sheet_can_select_expr_range) : It is
possible to have a guru up without editing.
(gnumeric_sheet_key_press) : rename from gnumeric_sheet_key.
(gnumeric_sheet_size_allocate) : rename from gnumeric_size_allocate.
(gnumeric_sheet_focus_in) : Enable the input context.
(gnumeric_sheet_focus_out) : Disable the input context.
(gnumeric_sheet_realize) : Create the input context.
(gnumeric_sheet_unrealize) : Destroy the input context.
(gnumeric_sheet_class_init) : Register the new methods.
(gnumeric_sheet_init) : Init the input context.
* src/clipboard.c (x_selection_handler) : Adjust to changes in
application_clipboard_clear.
(x_selection_clear) : Ditto.
* src/cmd-edit.c (cmd_paste) : Ditto.
* src/sheet.c (sheet_destroy) : Ditto.
* src/application.c (application_clipboard_clear) : Make dropping the
selection optional. This removes the kludges necessary to handle
changing the clipboard when we already have the selection.
* src/functions/fn-logical.c (gnumeric_true, gnumeric_false) :
fix signatures.
2000-06-30 Jukka-Pekka Iivonen <iivonen@iki.fi>
* src/functions/fn-logical.c: Added FALSE().
......
2000-06-30 Jody Goldberg <jgoldberg@home.com>
* src/gnumeric-sheet.c (gnumeric_sheet_can_select_expr_range) : It is
possible to have a guru up without editing.
(gnumeric_sheet_key_press) : rename from gnumeric_sheet_key.
(gnumeric_sheet_size_allocate) : rename from gnumeric_size_allocate.
(gnumeric_sheet_focus_in) : Enable the input context.
(gnumeric_sheet_focus_out) : Disable the input context.
(gnumeric_sheet_realize) : Create the input context.
(gnumeric_sheet_unrealize) : Destroy the input context.
(gnumeric_sheet_class_init) : Register the new methods.
(gnumeric_sheet_init) : Init the input context.
* src/clipboard.c (x_selection_handler) : Adjust to changes in
application_clipboard_clear.
(x_selection_clear) : Ditto.
* src/cmd-edit.c (cmd_paste) : Ditto.
* src/sheet.c (sheet_destroy) : Ditto.
* src/application.c (application_clipboard_clear) : Make dropping the
selection optional. This removes the kludges necessary to handle
changing the clipboard when we already have the selection.
* src/functions/fn-logical.c (gnumeric_true, gnumeric_false) :
fix signatures.
2000-06-30 Jukka-Pekka Iivonen <iivonen@iki.fi>
* src/functions/fn-logical.c: Added FALSE().
......
2000-06-30 Jody Goldberg <jgoldberg@home.com>
* src/gnumeric-sheet.c (gnumeric_sheet_can_select_expr_range) : It is
possible to have a guru up without editing.
(gnumeric_sheet_key_press) : rename from gnumeric_sheet_key.
(gnumeric_sheet_size_allocate) : rename from gnumeric_size_allocate.
(gnumeric_sheet_focus_in) : Enable the input context.
(gnumeric_sheet_focus_out) : Disable the input context.
(gnumeric_sheet_realize) : Create the input context.
(gnumeric_sheet_unrealize) : Destroy the input context.
(gnumeric_sheet_class_init) : Register the new methods.
(gnumeric_sheet_init) : Init the input context.
* src/clipboard.c (x_selection_handler) : Adjust to changes in
application_clipboard_clear.
(x_selection_clear) : Ditto.
* src/cmd-edit.c (cmd_paste) : Ditto.
* src/sheet.c (sheet_destroy) : Ditto.
* src/application.c (application_clipboard_clear) : Make dropping the
selection optional. This removes the kludges necessary to handle
changing the clipboard when we already have the selection.
* src/functions/fn-logical.c (gnumeric_true, gnumeric_false) :
fix signatures.
2000-06-30 Jukka-Pekka Iivonen <iivonen@iki.fi>
* src/functions/fn-logical.c: Added FALSE().
......
2000-06-30 Jody Goldberg <jgoldberg@home.com>
* src/gnumeric-sheet.c (gnumeric_sheet_can_select_expr_range) : It is
possible to have a guru up without editing.
(gnumeric_sheet_key_press) : rename from gnumeric_sheet_key.
(gnumeric_sheet_size_allocate) : rename from gnumeric_size_allocate.
(gnumeric_sheet_focus_in) : Enable the input context.
(gnumeric_sheet_focus_out) : Disable the input context.
(gnumeric_sheet_realize) : Create the input context.
(gnumeric_sheet_unrealize) : Destroy the input context.
(gnumeric_sheet_class_init) : Register the new methods.
(gnumeric_sheet_init) : Init the input context.
* src/clipboard.c (x_selection_handler) : Adjust to changes in
application_clipboard_clear.
(x_selection_clear) : Ditto.
* src/cmd-edit.c (cmd_paste) : Ditto.
* src/sheet.c (sheet_destroy) : Ditto.
* src/application.c (application_clipboard_clear) : Make dropping the
selection optional. This removes the kludges necessary to handle
changing the clipboard when we already have the selection.
* src/functions/fn-logical.c (gnumeric_true, gnumeric_false) :
fix signatures.
2000-06-30 Jukka-Pekka Iivonen <iivonen@iki.fi>
* src/functions/fn-logical.c: Added FALSE().
......
......@@ -239,7 +239,7 @@ static char *help_true = {
};
static Value *
gnumeric_true (FunctionEvalInfo *ei, GList *expr_node_list)
gnumeric_true (FunctionEvalInfo *ei, Value **args)
{
return value_new_bool (TRUE);
}
......@@ -261,7 +261,7 @@ static char *help_false = {
};
static Value *
gnumeric_false (FunctionEvalInfo *ei, GList *expr_node_list)
gnumeric_false (FunctionEvalInfo *ei, Value **args)
{
return value_new_bool (FALSE);
}
......
......@@ -72,7 +72,7 @@ application_init (void)
* not empty.
*/
void
application_clipboard_clear (void)
application_clipboard_clear (gboolean drop_selection)
{
if (app.clipboard_copied_contents) {
clipboard_release (app.clipboard_copied_contents);
......@@ -86,9 +86,10 @@ application_clipboard_clear (void)
app.clipboard_sheet = NULL;
/* Release the selection */
gtk_selection_owner_set (NULL,
GDK_SELECTION_PRIMARY,
GDK_CURRENT_TIME);
if (drop_selection)
gtk_selection_owner_set (NULL,
GDK_SELECTION_PRIMARY,
GDK_CURRENT_TIME);
}
}
......@@ -104,19 +105,7 @@ application_set_selected_sheet (Sheet *sheet)
{
g_return_val_if_fail (sheet != NULL, FALSE);
/* Short circuit if we already have the selection */
if (app.clipboard_sheet != NULL &&
app.clipboard_sheet->workbook == sheet->workbook) {
if (app.clipboard_copied_contents) {
clipboard_release (app.clipboard_copied_contents);
app.clipboard_copied_contents = NULL;
}
sheet_selection_unant (app.clipboard_sheet);
app.clipboard_sheet = sheet;
return TRUE;
}
application_clipboard_clear ();
application_clipboard_clear (FALSE);
if (gtk_selection_owner_set (sheet->workbook->toplevel,
GDK_SELECTION_PRIMARY,
......
......@@ -8,7 +8,7 @@ void application_init (void);
Workbook * application_workbook_get_by_name (char const * const name);
Workbook * application_workbook_get_by_index (int i);
void application_clipboard_clear (void);
void application_clipboard_clear (gboolean drop_selection);
void application_clipboard_copy (Sheet *sheet, Range const *area);
void application_clipboard_cut (Sheet *sheet, Range const *area);
......
......@@ -671,7 +671,7 @@ x_selection_handler (GtkWidget *widget, GtkSelectionData *selection_data, guint
CLEAR_VALUES|CLEAR_COMMENTS);
clipboard_release (clipboard);
application_clipboard_clear ();
application_clipboard_clear (TRUE);
}
}
......@@ -683,7 +683,8 @@ x_selection_handler (GtkWidget *widget, GtkSelectionData *selection_data, guint
static gint
x_selection_clear (GtkWidget *widget, GdkEventSelection *event, Workbook *wb)
{
application_clipboard_clear ();
/* we have already lost the selection, no need to clear it */
application_clipboard_clear (FALSE);
return TRUE;
}
......
......@@ -325,7 +325,7 @@ cmd_paste (CommandContext *context, PasteTarget const *pt, guint32 time)
rinfo.target_sheet = pt->sheet;
cmd_paste_cut (context, &rinfo);
application_clipboard_clear ();
application_clipboard_clear (TRUE);
} else
/*
* Pasting a Copy or from the X selection
......
......@@ -12,24 +12,30 @@
#include "expr.h"
#include "expr-name.h"
#include "workbook.h"
#include "workbook-edit.h"
#include "gnumeric-util.h"
#define LIST_KEY "name_list_data"
typedef struct {
GladeXML *gui;
GtkWidget *dia;
GtkWidget *dialog;
GtkList *list;
GtkEntry *name;
GtkEntry *value;
GList *expr_names;
gint selected;
GtkWidget *ok_button;
GtkWidget *add_button;
GtkWidget *close_button;
GtkWidget *delete_button;
Workbook *wb;
} state_t;
} NameGuruState;
static void
update_edit (state_t *state)
update_edit (NameGuruState *state)
{
gint i = state->selected;
NamedExpression *expr_name;
......@@ -51,7 +57,7 @@ update_edit (state_t *state)
}
static void
select_name (GtkWidget *w, state_t *state)
select_name (GtkWidget *w, NameGuruState *state)
{
guint i = 0;
GList *sel = GTK_LIST(w)->selection;
......@@ -77,7 +83,7 @@ select_name (GtkWidget *w, state_t *state)
}
static void
fill_list (state_t *state)
fill_list (NameGuruState *state)
{
GList *names;
GtkContainer *list;
......@@ -103,7 +109,7 @@ fill_list (state_t *state)
}
static void
destroy_state (state_t *state)
clear_state (NameGuruState *state)
{
if (state->expr_names)
g_list_free (state->expr_names);
......@@ -112,20 +118,19 @@ destroy_state (state_t *state)
}
static void
empty_list (state_t *state)
empty_list (NameGuruState *state)
{
if (state->list)
gtk_list_clear_items (state->list, 0, -1);
state->list = NULL;
destroy_state (state);
clear_state (state);
}
static void
remove_name (GtkWidget *widget, state_t *state)
remove_name (GtkWidget *ignored, NameGuruState *state)
{
gint i;
g_return_if_fail (state != NULL);
g_return_if_fail (widget != NULL);
i = state->selected;
if (i >= 0) {
......@@ -143,7 +148,7 @@ remove_name (GtkWidget *widget, state_t *state)
}
static gboolean
grab_text_ok (state_t *state, gboolean update_list)
grab_text_ok (NameGuruState *state, gboolean update_list)
{
NamedExpression *expr_name;
ExprTree *expr;
......@@ -199,94 +204,114 @@ grab_text_ok (state_t *state, gboolean update_list)
}
static void
destroy_dialog (state_t *state)
cb_name_guru_clicked (GtkWidget *button, NameGuruState *state)
{
if (state->dia)
gnome_dialog_close (GNOME_DIALOG (state->dia));
state->dia = NULL;
state->list = NULL;
state->name = NULL;
state->value = NULL;
if (state->dialog == NULL)
return;
if (button == state->delete_button) {
remove_name (NULL, state);
return;
}
if (button == state->add_button || button == state->ok_button)
grab_text_ok (state, TRUE);
if (button == state->close_button || button == state->ok_button)
gtk_widget_destroy (state->dialog);
}
static void
add_name (GtkWidget *widget, state_t *state)
static GtkWidget *
name_guru_init_button (NameGuruState *state, char const *name)
{
grab_text_ok (state, TRUE);
GtkWidget *tmp = glade_xml_get_widget (state->gui, name);
gtk_signal_connect (GTK_OBJECT (tmp), "clicked",
GTK_SIGNAL_FUNC (cb_name_guru_clicked),
state);
return tmp;
}
static void
close_name (GtkWidget *widget, state_t *state)
static gboolean
cb_name_guru_destroy (GtkObject *w, NameGuruState *state)
{
destroy_state (state);
destroy_dialog (state);
g_return_val_if_fail (w != NULL, FALSE);
g_return_val_if_fail (state != NULL, FALSE);
workbook_edit_detach_guru (state->wb);
if (state->gui != NULL) {
gtk_object_unref (GTK_OBJECT (state->gui));
state->gui = NULL;
}
/* Handle window manger closing the dialog.
* This will be ignored if we are being destroyed differently.
*/
workbook_finish_editing (state->wb, FALSE);
state->dialog = NULL;
g_free (state);
return FALSE;
}
static void
ok_name (GtkWidget *widget, state_t *state)
static gboolean
name_guru_init (NameGuruState *state)
{
if (grab_text_ok (state, FALSE))
close_name (widget, state);
state->gui = gnumeric_glade_xml_new (workbook_command_context_gui (state->wb),
"names.glade");
if (state->gui == NULL)
return TRUE;
state->dialog = glade_xml_get_widget (state->gui, "NamesDialog");
state->name = GTK_ENTRY (glade_xml_get_widget (state->gui, "name"));
state->value = GTK_ENTRY (glade_xml_get_widget (state->gui, "value"));
state->list = GTK_LIST (glade_xml_get_widget (state->gui, "name_list"));
state->expr_names = NULL;
state->selected = -1;
state->ok_button = name_guru_init_button (state, "ok_button");
state->close_button = name_guru_init_button (state, "close_button");
state->add_button = name_guru_init_button (state, "add_button");
state->delete_button = name_guru_init_button (state, "delete_button");
gnumeric_editable_enters (GTK_WINDOW (state->dialog),
GTK_EDITABLE(state->name));
gnumeric_editable_enters (GTK_WINDOW (state->dialog),
GTK_EDITABLE (state->value));
fill_list (state);
gtk_signal_connect (GTK_OBJECT (state->list), "selection_changed",
GTK_SIGNAL_FUNC (select_name), &state);
gtk_signal_connect (GTK_OBJECT (state->dialog), "destroy",
GTK_SIGNAL_FUNC (cb_name_guru_destroy),
state);
gtk_window_set_transient_for (GTK_WINDOW (state->dialog),
GTK_WINDOW (state->wb->toplevel));
workbook_set_entry (state->wb, state->value);
workbook_edit_attach_guru (state->wb, state->dialog);
workbook_edit_select_absolute (state->wb);
return FALSE;
}
void
dialog_define_names (Workbook *wb)
{
gint v;
state_t state;
GtkWidget *w;
NameGuruState *state;
g_return_if_fail (wb != NULL);
state.wb = wb;
state.gui = gnumeric_glade_xml_new (workbook_command_context_gui (wb),
"names.glade");
if (state.gui == NULL)
return;
state.name = GTK_ENTRY (glade_xml_get_widget (state.gui, "name"));
state.value = GTK_ENTRY (glade_xml_get_widget (state.gui, "value"));
state.list = GTK_LIST (glade_xml_get_widget (state.gui, "name_list"));
state.expr_names = NULL;
state.selected = -1;
w = glade_xml_get_widget (state.gui, "ok");
gtk_signal_connect (GTK_OBJECT (w), "clicked",
GTK_SIGNAL_FUNC (ok_name), &state);
w = glade_xml_get_widget (state.gui, "close");
gtk_signal_connect (GTK_OBJECT (w), "clicked",
GTK_SIGNAL_FUNC (close_name), &state);
w = glade_xml_get_widget (state.gui, "add");
gtk_signal_connect (GTK_OBJECT (w), "clicked",
GTK_SIGNAL_FUNC (add_name), &state);
w = glade_xml_get_widget (state.gui, "delete");
gtk_signal_connect (GTK_OBJECT (w), "clicked",
GTK_SIGNAL_FUNC (remove_name), &state);
state.dia = glade_xml_get_widget (state.gui, "NamesDialog");
if (!state.dia) {
printf ("Corrupt file names.glade\n");
state = g_new (NameGuruState, 1);
state->wb = wb;
if (name_guru_init (state)) {
g_free (state);
return;
}
gnome_dialog_editable_enters(GNOME_DIALOG(state.dia),
GTK_EDITABLE(state.name));
gnome_dialog_editable_enters(GNOME_DIALOG(state.dia),
GTK_EDITABLE(state.value));
fill_list (&state);
gtk_signal_connect (GTK_OBJECT (state.list), "selection_changed",
GTK_SIGNAL_FUNC (select_name), &state);
v = gnumeric_dialog_run (wb, GNOME_DIALOG (state.dia));
if (v == -1)
destroy_state (&state);
else
destroy_dialog (&state);
gtk_object_unref (GTK_OBJECT (state.gui));
gtk_widget_show (state->dialog);
}
......@@ -557,7 +557,6 @@ formula_guru_init (FormulaGuruState *state, ExprTree const *expr, Cell const *ce
if (state->gui == NULL)
return TRUE;
state->args = NULL;
state->max_arg = 0;
state->help_tokens = tokenized_help_new (state->fd);
......
......@@ -557,7 +557,6 @@ formula_guru_init (FormulaGuruState *state, ExprTree const *expr, Cell const *ce
if (state->gui == NULL)
return TRUE;
state->args = NULL;
state->max_arg = 0;
state->help_tokens = tokenized_help_new (state->fd);
......
......@@ -19,8 +19,8 @@
<name>NamesDialog</name>
<visible>False</visible>
<title>Define Name</title>
<type>GTK_WINDOW_TOPLEVEL</type>
<position>GTK_WIN_POS_NONE</position>
<type>GTK_WINDOW_DIALOG</type>
<position>GTK_WIN_POS_MOUSE</position>
<modal>False</modal>
<allow_shrink>False</allow_shrink>
<allow_grow>False</allow_grow>
......@@ -153,7 +153,7 @@ Sheet
<widget>
<class>GtkButton</class>
<name>ok</name>
<name>ok_button</name>
<can_default>True</can_default>
<has_default>True</has_default>
<can_focus>True</can_focus>
......@@ -176,7 +176,7 @@ Sheet
<widget>
<class>GtkButton</class>
<name>add</name>
<name>add_button</name>
<height>24</height>
<can_focus>True</can_focus>
<label>Add</label>
......@@ -198,7 +198,7 @@ Sheet
<widget>
<class>GtkButton</class>
<name>close</name>
<name>close_button</name>
<can_focus>True</can_focus>
<stock_button>GNOME_STOCK_BUTTON_CLOSE</stock_button>
<child>
......@@ -244,7 +244,7 @@ Sheet
<widget>
<class>GtkButton</class>
<name>delete</name>
<name>delete_button</name>
<height>24</height>
<can_focus>True</can_focus>
<label>Delete</label>
......
......@@ -239,7 +239,7 @@ static char *help_true = {
};
static Value *
gnumeric_true (FunctionEvalInfo *ei, GList *expr_node_list)
gnumeric_true (FunctionEvalInfo *ei, Value **args)
{
return value_new_bool (TRUE);
}
......@@ -261,7 +261,7 @@ static char *help_false = {
};
static Value *
gnumeric_false (FunctionEvalInfo *ei, GList *expr_node_list)
gnumeric_false (FunctionEvalInfo *ei, Value **args)
{
return value_new_bool (FALSE);
}
......
......@@ -196,6 +196,9 @@ gnumeric_sheet_can_select_expr_range (GnumericSheet *gsheet)
g_return_val_if_fail (GNUMERIC_IS_SHEET (gsheet), FALSE);
wb = gsheet->sheet_view->sheet->workbook;
if (workbook_edit_has_guru (wb))
return TRUE;
if (!wb->editing)
return FALSE;
......@@ -795,7 +798,7 @@ gnumeric_sheet_key_mode_object (GnumericSheet *gsheet, GdkEventKey *event)
}
static gint
gnumeric_sheet_key (GtkWidget *widget, GdkEventKey *event)
gnumeric_sheet_key_press (GtkWidget *widget, GdkEventKey *event)
{
GnumericSheet *gsheet = GNUMERIC_SHEET (widget);
Sheet *sheet = gsheet->sheet_view->sheet;
......@@ -833,6 +836,24 @@ gnumeric_sheet_key_release (GtkWidget *widget, GdkEventKey *event)
return FALSE;
}
/* Focus in handler for the canvas */
static gint
gnumeric_sheet_focus_in (GtkWidget *widget, GdkEventFocus *event)
{
GnumericSheet *gsheet = GNUMERIC_SHEET (widget);
if (gsheet->ic)
gdk_im_begin (gsheet->ic, gsheet->canvas.layout.bin_window);
return FALSE;
}
/* Focus out handler for the canvas */
static gint
gnumeric_sheet_focus_out (GtkWidget *widget, GdkEventFocus *event)
{
gdk_im_end ();
return FALSE;
}
static void
gnumeric_sheet_drag_data_get (GtkWidget *widget,
GdkDragContext *context,
......@@ -981,6 +1002,7 @@ static void
gnumeric_sheet_realize (GtkWidget *widget)
{
GdkWindow *window;
GnumericSheet *gsheet;
if (GTK_WIDGET_CLASS (sheet_parent_class)->realize)
(*GTK_WIDGET_CLASS (sheet_parent_class)->realize)(widget);
......@@ -989,6 +1011,52 @@ gnumeric_sheet_realize (GtkWidget *widget)
gdk_window_set_back_pixmap (GTK_LAYOUT (widget)->bin_window, NULL, FALSE);
cursor_set (window, GNUMERIC_CURSOR_FAT_CROSS);
gsheet = GNUMERIC_SHEET (widget);
if (gdk_im_ready () && (gsheet->ic_attr = gdk_ic_attr_new ()) != NULL) {
GdkEventMask mask;
GdkICAttr *attr = gsheet->ic_attr;
GdkICAttributesType attrmask = GDK_IC_ALL_REQ;
GdkIMStyle style;
GdkIMStyle supported_style = GDK_IM_PREEDIT_NONE |
GDK_IM_PREEDIT_NOTHING |
GDK_IM_STATUS_NONE |
GDK_IM_STATUS_NOTHING;
attr->style = style = gdk_im_decide_style (supported_style);
attr->client_window = gsheet->canvas.layout.bin_window;
gsheet->ic = gdk_ic_new (attr, attrmask);
if (gsheet->ic != NULL) {
mask = gdk_window_get_events (attr->client_window);
mask |= gdk_ic_get_events (gsheet->ic);