Commit 73a18b0f authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

switch Format->Workbook with Format->AutoFormat ditto.

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

	* src/GNOME_Gnumeric.xml : switch Format->Workbook with
	  Format->AutoFormat
	* src/workbook-control-gui.c (workbook_menu_format) : ditto.

	* src/workbook-view.c (wb_view_is_protected) : new.

	* src/workbook-edit.c (wbcg_edit_start) : load style directly
	  don't use cell_get_style.  This enables support for protection of
	  blank cells.  Use wb_view_is_protected, and command_context_invalid.

2002-03-08  C. Scott Ananian <cananian@lesser-magoo.lcs.mit.edu>

	* src/gnumeric-canvas.c (gnm_canvas_key_mode_sheet): don't put us in
	  edit mode if wbcg_edit_start indicates the cell is locked.
	* src/workbook-control-gui.c (cb_autosum, cb_autofunction): handle
	  case where wbcg_edit_start returns FALSE indicating that cell is
	  locked.
	* src/workbook-edit.c (wbcg_edit_start): this function now returns a
	   boolean which indicates whether the 'edit_start' attempt succeeded.
	   Check cell properties to return FALSE if the cell is locked.
	* src/workbook-edit.h (wbcg_edit_start): modify the prototype as per above.
	* src/workbook-view.c (wb_view_set_attribute, workbook_view_init):
	  Remove ARG_VIEW_* enumeration, which isn't used after Gnome2 port.
	  Add WorkbookView::is_protected attribute, and initialize it to
	  FALSE.  The update to wb_view_set_attribute is enough to get
	  xml_sax import working properly (yay, modular code!).
	* src/workbook-view.h: add 'is_protected' field to WorkbookView struct.
	  This is TRUE iff the workbook is locked.
	* src/xml-io.c (xml_write_wbv_attributes):
	  Write the new 'protected' workbook view attribute.  Two lines are
	  enough to get read/write from xml_io working.  Score one for
	  xml_sax: zero should have been sufficient.
	* src/dialogs/cell-format.glade: The 'worksheet protected' checkbox
	  shouldn't be greyed-out anymore.
	* src/dialogs/dialog-cell-format.c (cb_protection_sheet_protected_toggle,
	fmt_dialog_init_protection_page, cb_fmt_dialog_dialog_buttons):
	  connect up the 'worksheet protected' button in the
	  Format->Cells->Protection dialog.  Update worksheet object when
	  toggled and mark that the dialog's changed.
	* src/dialogs/dialog-workbook-attr.c src/dialogs/workbook-attr.glade:
	  Add Format->Worksheet->Protection dialog.
parent b76c132f
......@@ -7,34 +7,29 @@ release, and longer term bugs.
Release Critical
----------------
http://bugzilla.gnome.org/show_bug.cgi?id=71551
We need to somehow add --export-dynamic to the gnumeric link line, or else
plugins won't load on Solaris/gcc.
Why doesn't float_range_function2 use its "flags" argument?
Search and search/replace dialogs are currently shot.
Printing dialogs are shot.
Paste-special dialog crashes.
Text-import dialog crashes.
Summary dialog is non-functional.
Go-to cell dialog is shot.
- http://bugzilla.gnome.org/show_bug.cgi?id=71551
- We need to somehow add --export-dynamic to the gnumeric link line, or else
plugins won't load on Solaris/gcc.
- Why doesn't float_range_function2 use its "flags" argument?
- Search and search/replace dialogs are currently shot.
- Printing dialogs are shot.
- Text-import dialog crashes.
- Summary dialog is non-functional.
- Go-to cell dialog is shot.
- rewrite editable-lable to be utf8 clean
1.2 Targets
-----------
- PROB sucks right now.
- 3D reference support
- load/save of external references
Pending Patches
---------------
Yukihiro's IM support (broken in the context of gnome2)
- Yukihiro's IM support (broken in the context of gnome2)
- http://flowernet.gr.jp/jado/comp/patch/gnumeric/gnumeric-1.0.4-excel-cjk.patch
Long term breakage
------------------
......@@ -105,7 +100,6 @@ Long term breakage
current cell.
* Should <ok> add the name ?
: Fix XL named expr import for sheet local names
* externsheet for biff7 type=3
* test for unicode
: Check scoping changes.
......@@ -188,8 +182,6 @@ Long term breakage
: Add keyboard controls for the control points
: display a view per Pane not per scg
: Add object control for resize to disable invalid sizes.
: do not show the middle size boxes when the space between corners is too
small.
- Add a warning when attempting to save using the suffix from a different saver.
eg saving .gnumeric as foo.xls
......
......@@ -104,6 +104,7 @@ Morten:
Scott Ananian:
* Update the debian control files.
* Initial support for WorkbookView::is_protected.
Wayne Schuster:
* Implement opening of comment dialog by double clicking marker.
......
......@@ -2461,10 +2461,10 @@ ms_excel_chart (BiffQuery *q, MSContainer *container, MsBiffVersion ver, GObject
break;
case BIFF_PROTECT : {
gboolean const protected =
gboolean const is_protected =
(1 == MS_OLE_GET_GUINT16 (q->data));
d (4, printf ("Chart is%s protected;\n",
protected ? "" : " not"););
is_protected ? "" : " not"););
break;
}
......
......@@ -2099,7 +2099,7 @@ log_xf_data (ExcelWorkbook *wb, BiffXFData *xfd, int idx)
* See S59E1E.HTM
*
* All BIFF V7 features are implemented, except:
* - hidden and locked - not yet in gnumeric.
* - hidden - not yet in gnumeric.
*
* Apart from font, the style elements we retrieve do *not* need to be unrefed.
**/
......
2002-03-09 Jody Goldberg <jody@gnome.org>
* dialog-paste-special.c : fix.
2002-03-08 Jon K Hellan <hellan@acm.org>
* dialog-plugin-manager.c (cb_pm_button_activate_plugin_clicked):
......
......@@ -3289,7 +3289,7 @@
<child>
<widget class="GtkCheckButton" id="protection_sheet_protected">
<property name="sensitive">no</property>
<property name="sensitive">yes</property>
<property name="can_focus">yes</property>
<property name="label" translatable="yes">Worksheet _protected</property>
<property name="active">no</property>
......
......@@ -33,6 +33,7 @@
#include <validation.h>
#include <workbook.h>
#include <workbook-edit.h>
#include <workbook-view.h>
#include <commands.h>
#include <widgets/gnumeric-expr-entry.h>
......@@ -159,7 +160,10 @@ typedef struct _FormatState
PatternPicker pattern;
} back;
struct {
GtkCheckButton *hidden, *locked;
GtkCheckButton *hidden, *locked, *sheet_protected;
gboolean sheet_protected_changed;
gboolean sheet_protected_value;
} protection;
struct {
GtkTable *criteria_table;
......@@ -1960,6 +1964,17 @@ cb_protection_hidden_toggle (GtkToggleButton *button, FormatState *state)
}
}
static void
cb_protection_sheet_protected_toggle (GtkToggleButton *button, FormatState *state)
{
if (state->enable_edit) {
state->protection.sheet_protected_value =
gtk_toggle_button_get_active (button);
state->protection.sheet_protected_changed = TRUE;
fmt_dialog_changed (state);
}
}
static void
fmt_dialog_init_protection_page (FormatState *state)
{
......@@ -1983,6 +1998,15 @@ fmt_dialog_init_protection_page (FormatState *state)
g_signal_connect (GTK_OBJECT (w),
"toggled", G_CALLBACK (cb_protection_hidden_toggle),
state);
state->protection.sheet_protected_changed = FALSE;
flag = wb_control_view (WORKBOOK_CONTROL (state->wbcg))->is_protected;
w = glade_xml_get_widget (state->gui, "protection_sheet_protected");
state->protection.sheet_protected = GTK_CHECK_BUTTON (w);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w), flag);
g_signal_connect (G_OBJECT (w),
"toggled",
G_CALLBACK (cb_protection_sheet_protected_toggle), state);
}
/*****************************************************************************/
......@@ -2300,6 +2324,12 @@ cb_fmt_dialog_dialog_buttons (GtkWidget *btn, FormatState *state)
if (state->validation.changed)
validation_rebuild_validation (state);
if (state->protection.sheet_protected_changed) {
WorkbookView *wbv = wb_control_view (WORKBOOK_CONTROL (state->wbcg));
wbv->is_protected = state->protection.sheet_protected_value;
wb_view_prefs_update (wbv);
state->protection.sheet_protected_changed = FALSE;
}
mstyle_ref (state->result);
......
/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* dialog-paste-special.c: The dialog for selecting non-standard
* behaviors when pasting.
......@@ -19,14 +20,14 @@
#define BUTTON_PASTE_LINK 0
static const struct {
const char *name;
int disables_second_group;
} paste_types[] = {
{ N_("All"), 0 },
{ N_("Content"), 0 },
{ N_("As Value"), 0 },
{ N_("Formats"), 1 },
{ NULL, 0 }
char const *name;
gboolean allows_operations;
} paste_types [] = {
{ N_("All"), TRUE },
{ N_("Content"), TRUE },
{ N_("As Value"), TRUE },
{ N_("Formats"), FALSE },
{ NULL, FALSE }
};
static const char *paste_ops[] = {
......@@ -40,155 +41,139 @@ static const char *paste_ops[] = {
typedef struct {
GtkDialog *dialog;
GSList *group_type;
GSList *group_ops;
GtkWidget *op_frame;
GtkToggleButton *transpose;
GtkToggleButton *skip_blanks;
GSList *type_group, *op_group;
int type, op;
} PasteSpecialState;
/* The "Paste Link" button should be grayed-out, unless type "All" is
selected, operation "None" is selected, and "Transpose" and "Skip
Blanks" are not selected. */
static void
disable_op_group (GtkWidget *widget, GtkWidget *group)
paste_link_set_sensitive (GtkWidget *ignored, PasteSpecialState *state)
{
gtk_widget_set_sensitive (group, FALSE);
}
gboolean sensitive =
(gtk_radio_group_get_selected (state->type_group) == 0) &&
(gtk_radio_group_get_selected (state->op_group) == 0) &&
!gtk_toggle_button_get_active (state->transpose) &&
!gtk_toggle_button_get_active (state->skip_blanks);
static void
enable_op_group (GtkWidget *widget, GtkWidget *group)
{
gtk_widget_set_sensitive (group, TRUE);
gtk_dialog_set_response_sensitive (state->dialog,
BUTTON_PASTE_LINK, sensitive);
}
static void
checkbutton_toggled (GtkWidget *widget, gboolean *flag)
cb_type_toggle (GtkWidget *ignored, PasteSpecialState *state)
{
*flag = GTK_TOGGLE_BUTTON (widget)->active;
state->type = gtk_radio_group_get_selected (state->type_group);
gtk_widget_set_sensitive (state->op_frame,
paste_types [state->type].allows_operations);
paste_link_set_sensitive (NULL, state);
}
static gboolean
dialog_destroy (GtkObject *w, PasteSpecialState *state)
static void
cb_op_toggle (GtkWidget *ignored, PasteSpecialState *state)
{
g_free (state);
return FALSE;
state->op = gtk_radio_group_get_selected (state->op_group);
paste_link_set_sensitive (NULL, state);
}
/* The "Paste Link" button should be grayed-out, unless type "All" is
selected, operation "None" is selected, and "Transpose" and "Skip
Blanks" are not selected. */
static void
paste_link_set_sensitive (GtkWidget *widget, PasteSpecialState *state)
checkbutton_toggled (GtkWidget *widget, gboolean *flag)
{
gboolean sensitive =
(gtk_radio_group_get_selected (state->group_type) == 0) &&
(gtk_radio_group_get_selected (state->group_ops) == 0) &&
!state->transpose->active &&
!state->skip_blanks->active;
gtk_dialog_set_response_sensitive (state->dialog,
BUTTON_PASTE_LINK, sensitive);
*flag = GTK_TOGGLE_BUTTON (widget)->active;
}
int
dialog_paste_special (WorkbookControlGUI *wbcg)
{
GtkWidget *hbox, *vbox;
GtkWidget *f1, *f1v, *f2, *f2v, *first_button = NULL;
GtkWidget *f1, *f1v, *op_box, *first_button = NULL;
int result, i;
int v;
gboolean do_transpose = FALSE;
gboolean do_skip_blanks = FALSE;
PasteSpecialState *state;
PasteSpecialState state;
GtkWidget *tmp;
state = g_new (PasteSpecialState, 1);
tmp = gtk_dialog_new_with_buttons (_("Paste special"),
wbcg_toplevel (wbcg),
GTK_DIALOG_DESTROY_WITH_PARENT,
_("Paste Link"), BUTTON_PASTE_LINK,
GTK_STOCK_OK, GTK_RESPONSE_OK,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OK, GTK_RESPONSE_OK,
NULL);
state->dialog = GTK_DIALOG (tmp);
g_signal_connect (G_OBJECT (state->dialog),
"destroy",
G_CALLBACK (dialog_destroy), state);
gtk_dialog_set_default_response (state->dialog, GTK_RESPONSE_CANCEL);
state.dialog = GTK_DIALOG (tmp);
gtk_dialog_set_default_response (state.dialog, GTK_RESPONSE_CANCEL);
f1 = gtk_frame_new (_("Paste type"));
f1v = gtk_vbox_new (TRUE, 0);
gtk_container_add (GTK_CONTAINER (f1), f1v);
f2 = gtk_frame_new (_("Operation"));
f2v = gtk_vbox_new (TRUE, 0);
gtk_container_add (GTK_CONTAINER (f2), f2v);
state.op_frame = gtk_frame_new (_("Operation"));
op_box = gtk_vbox_new (TRUE, 0);
gtk_container_add (GTK_CONTAINER (state.op_frame), op_box);
state->group_type = NULL;
state.type = 0;
state.type_group = NULL;
for (i = 0; paste_types[i].name; i++){
GCallback func;
GtkWidget *r;
if (paste_types[i].disables_second_group)
func = G_CALLBACK (disable_op_group);
else
func = G_CALLBACK (enable_op_group);
r = gtk_radio_button_new_with_label (state->group_type, _(paste_types[i].name));
state->group_type = GTK_RADIO_BUTTON (r)->group;
g_signal_connect (G_OBJECT (r), "toggled", func, f2);
GtkWidget *r = gtk_radio_button_new_with_label (state.type_group,
_(paste_types[i].name));
state.type_group = GTK_RADIO_BUTTON (r)->group;
g_signal_connect (G_OBJECT (r),
"toggled",
G_CALLBACK (paste_link_set_sensitive), state);
G_CALLBACK (cb_type_toggle), &state);
gtk_box_pack_start_defaults (GTK_BOX (f1v), r);
if (i == 0) first_button = r;
if (i == 0)
first_button = r;
}
state->group_ops = NULL;
state.op = 0;
state.op_group = NULL;
for (i = 0; paste_ops[i]; i++){
GtkWidget *r;
r = gtk_radio_button_new_with_label (state->group_ops, _(paste_ops[i]));
GtkWidget *r = gtk_radio_button_new_with_label (state.op_group,
_(paste_ops[i]));
state.op_group = GTK_RADIO_BUTTON (r)->group;
g_signal_connect (G_OBJECT (r),
"toggled",
G_CALLBACK (paste_link_set_sensitive),
state);
state->group_ops = GTK_RADIO_BUTTON (r)->group;
gtk_box_pack_start_defaults (GTK_BOX (f2v), r);
G_CALLBACK (cb_op_toggle), &state);
gtk_box_pack_start_defaults (GTK_BOX (op_box), r);
}
vbox = gtk_vbox_new (TRUE, 0);
state->transpose = GTK_TOGGLE_BUTTON (gtk_check_button_new_with_label (_("Transpose")));
g_signal_connect (G_OBJECT (state->transpose),
state.transpose = GTK_TOGGLE_BUTTON (gtk_check_button_new_with_label (_("Transpose")));
g_signal_connect (G_OBJECT (state.transpose),
"toggled",
G_CALLBACK (checkbutton_toggled), &do_transpose);
g_signal_connect (G_OBJECT (state->transpose),
g_signal_connect (G_OBJECT (state.transpose),
"toggled",
G_CALLBACK (paste_link_set_sensitive), state);
gtk_box_pack_start_defaults (GTK_BOX (vbox), GTK_WIDGET (state->transpose));
G_CALLBACK (paste_link_set_sensitive), &state);
gtk_box_pack_start_defaults (GTK_BOX (vbox), GTK_WIDGET (state.transpose));
state->skip_blanks = GTK_TOGGLE_BUTTON (gtk_check_button_new_with_label (_("Skip Blanks")));
g_signal_connect (G_OBJECT (state->skip_blanks),
state.skip_blanks = GTK_TOGGLE_BUTTON (gtk_check_button_new_with_label (_("Skip Blanks")));
g_signal_connect (G_OBJECT (state.skip_blanks),
"toggled",
G_CALLBACK (checkbutton_toggled), &do_skip_blanks);
g_signal_connect (G_OBJECT (state->skip_blanks),
g_signal_connect (G_OBJECT (state.skip_blanks),
"toggled",
G_CALLBACK (paste_link_set_sensitive), state);
gtk_box_pack_start_defaults (GTK_BOX (vbox), GTK_WIDGET (state->skip_blanks));
G_CALLBACK (paste_link_set_sensitive), &state);
gtk_box_pack_start_defaults (GTK_BOX (vbox), GTK_WIDGET (state.skip_blanks));
hbox = gtk_hbox_new (TRUE, 0);
gtk_box_pack_start_defaults (GTK_BOX (hbox), f1);
gtk_box_pack_start_defaults (GTK_BOX (hbox), f2);
gtk_box_pack_start_defaults (GTK_BOX (hbox), state.op_frame);
gtk_box_pack_start_defaults (GTK_BOX (hbox), vbox);
gtk_box_pack_start (GTK_BOX (state->dialog->vbox), hbox, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (state.dialog->vbox), hbox, TRUE, TRUE, 0);
gtk_widget_show_all (hbox);
gtk_widget_grab_focus (first_button);
/* Run the dialog */
gtk_window_set_modal (GTK_WINDOW (state->dialog), TRUE);
v = gnumeric_dialog_run (wbcg, state->dialog);
gtk_window_set_modal (GTK_WINDOW (state.dialog), TRUE);
v = gnumeric_dialog_run (wbcg, state.dialog);
/* If closed with the window manager, cancel */
if (v == -1)
......@@ -199,55 +184,28 @@ dialog_paste_special (WorkbookControlGUI *wbcg)
/* Fetch the results */
if (v == GTK_RESPONSE_OK) {
result = 0;
i = gtk_radio_group_get_selected (state->group_type);
switch (i){
case 0: /* all */
result = PASTE_ALL_TYPES;
break;
case 1: /* content */
result = PASTE_CONTENT;
break;
case 2: /* as values */
result = PASTE_AS_VALUES;
break;
case 3: /* formats */
result = PASTE_FORMATS;
break;
switch (state.type) {
case 0: result = PASTE_ALL_TYPES; break;
case 1: result = PASTE_CONTENT; break;
case 2: result = PASTE_AS_VALUES; break;
case 3: result = PASTE_FORMATS; break;
}
/* If it was not just formats, check operation */
if (i != 3){
i = gtk_radio_group_get_selected (state->group_ops);
switch (i){
case 1: /* Add */
result |= PASTE_OPER_ADD;
break;
case 2:
result |= PASTE_OPER_SUB;
break;
case 3:
result |= PASTE_OPER_MULT;
break;
case 4:
result |= PASTE_OPER_DIV;
break;
if (result != PASTE_FORMATS) {
switch (state.op) {
case 1 : result |= PASTE_OPER_ADD; break;
case 2 : result |= PASTE_OPER_SUB; break;
case 3 : result |= PASTE_OPER_MULT; break;
case 4 : result |= PASTE_OPER_DIV; break;
}
}
if (do_transpose)
result |= PASTE_TRANSPOSE;
if (do_skip_blanks)
result |= PASTE_SKIP_BLANKS;
} else if (v == BUTTON_PASTE_LINK) {
} else if (v == BUTTON_PASTE_LINK)
result = PASTE_LINK;
}
gtk_object_destroy (GTK_OBJECT (state->dialog));
return result;
}
......@@ -47,6 +47,7 @@ typedef struct _AttrState
GtkToggleButton *show_vsb;
GtkToggleButton *show_tabs;
GtkToggleButton *autocomplete;
GtkToggleButton *is_protected;
} view;
} AttrState;
......@@ -94,6 +95,8 @@ cb_attr_dialog_dialog_apply (GtkObject *w, int page, AttrState *state)
gtk_toggle_button_get_active (state->view.show_tabs);
state->wbv->do_auto_completion =
gtk_toggle_button_get_active (state->view.autocomplete);
state->wbv->is_protected =
gtk_toggle_button_get_active (state->view.is_protected);
wb_view_prefs_update (state->wbv);
}
......@@ -147,6 +150,9 @@ attr_dialog_init_view_page (AttrState *state)
state->view.autocomplete = attr_dialog_init_toggle (state,
"WorkbookView::do_auto_completion",
state->wbv->do_auto_completion);
state->view.is_protected = attr_dialog_init_toggle (state,
"WorkbookView::workbook_protected",
state->wbv->is_protected);
}
/*****************************************************************************/
......
......@@ -135,6 +135,55 @@
<property name="type">tab</property>
</packing>
</child>
<child>
<widget class="GtkTable" id="table2">
<property name="border_width">4</property>
<property name="homogeneous">no</property>
<property name="row_spacing">0</property>
<property name="column_spacing">0</property>
<property name="n-rows">1</property>
<property name="n-columns">2</property>
<property name="visible">yes</property>
<child>
<widget class="GtkCheckButton" id="WorkbookView::workbook_protected">
<property name="can_focus">yes</property>
<property name="label" translatable="yes">Workbook _Protected</property>
<property name="active">no</property>
<property name="draw_indicator">yes</property>
<property name="visible">yes</property>
<property name="use_underline">yes</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">2</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="x_padding">0</property>
<property name="y_padding">0</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label2">
<property name="label" translatable="yes">Protection</property>
<property name="justify">GTK_JUSTIFY_CENTER</property>
<property name="wrap">no</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="visible">yes</property>
</widget>
<packing>
<property name="type">tab</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
......
......@@ -2416,11 +2416,13 @@ cb_autosum (GtkWidget *widget, WorkbookControlGUI *wbcg)
entry = wbcg_get_entry (wbcg);
txt = gtk_entry_get_text (entry);
if (strncmp (txt, "=sum(", 5)) {
wbcg_edit_start (wbcg, TRUE, TRUE);
if (!wbcg_edit_start (wbcg, TRUE, TRUE))
return; /* attempt to edit failed */
gtk_entry_set_text (entry, "=sum()");
gtk_editable_set_position (GTK_EDITABLE (entry), 5);
} else {
wbcg_edit_start (wbcg, FALSE, TRUE);
if (!wbcg_edit_start (wbcg, FALSE, TRUE))
return; /* attempt to edit failed */
/*
* FIXME : This is crap!
......@@ -2910,13 +2912,13 @@ static GnomeUIInfo workbook_menu_format [] = {
GNOMEUIINFO_SUBTREE(N_("_Row"), workbook_menu_format_row),
GNOMEUIINFO_SUBTREE(N_("_Sheet"), workbook_menu_format_sheet),
GNOMEUIINFO_ITEM_NONE (N_("_Autoformat..."),
N_("Format a region of cells according to a pre-defined template"),
cb_autoformat),
GNOMEUIINFO_ITEM_NONE (N_("_Workbook..."),
N_("Modify the workbook attributes"),
cb_workbook_attr),
GNOMEUIINFO_ITEM_NONE (N_("_Autoformat..."),
N_("Format a region of cells according to a pre-defined template"),
cb_autoformat),
GNOMEUIINFO_END
};
......@@ -3411,7 +3413,7 @@ cb_editline_focus_in (GtkWidget *w, GdkEventFocus *event,
WorkbookControlGUI *wbcg)
{
if (!wbcg->editing)
wbcg_edit_start (wbcg, FALSE, TRUE);
return wbcg_edit_start (wbcg, FALSE, TRUE);
return TRUE;
}
......@@ -3450,11 +3452,13 @@ cb_autofunction (GtkWidget *widget, WorkbookControlGUI *wbcg)
entry = wbcg_get_entry (wbcg);
txt = gtk_entry_get_text (entry);
if (strncmp (txt, "=", 1)) {
wbcg_edit_start (wbcg, TRUE, TRUE);
if (!wbcg_edit_start (wbcg, TRUE, TRUE))
return; /* attempt to edit failed */
gtk_entry_set_text (entry, "=");
gtk_editable_set_position (GTK_EDITABLE (entry), 1);
} else {
wbcg_edit_start (wbcg, FALSE, TRUE);
if (!wbcg_edit_start (wbcg, FALSE, TRUE))
return; /* attempt to edit failed */
/* FIXME : This is crap!
* When the function druid is more complete use that.
......
......@@ -311,8 +311,11 @@ entry_changed (GtkEntry *entry, void *data)
* editing:
* 1) in-cell editing when you just start typing, and
* 2) above sheet editing when you hit F2.
*
* Returns TRUE if we did indeed start editing. Returns FALSE if the
* cell-to-be-edited was locked.
*/
void
gboolean
wbcg_edit_start (WorkbookControlGUI *wbcg,
gboolean blankp, gboolean cursorp)
{
......@@ -324,16 +327,14 @@ wbcg_edit_start (WorkbookControlGUI *wbcg,
int col, row;
WorkbookView *wbv;
g_return_if_fail (IS_WORKBOOK_CONTROL_GUI (wbcg));
g_return_val_if_fail (IS_WORKBOOK_CONTROL_GUI (wbcg), FALSE);
if (wbcg->editing)
return;
return TRUE;
/* Avoid recursion, and do not begin editing if a guru is up */
if (inside_editing || wbcg_edit_has_guru (wbcg))
return;
inside_editing = TRUE;
return TRUE;
wbv = wb_control_view (WORKBOOK_CONTROL (wbcg));
sheet = wb_control_cur_sheet (WORKBOOK_CONTROL (wbcg));
......@@ -342,17 +343,34 @@ wbcg_edit_start (WorkbookControlGUI *wbcg,
col = sheet->edit_pos.col;
row = sheet->edit_pos.row;
/* don't edit a locked cell */
/* TODO : extend this to disable edits that can not succeed
* like editing a single cell of an array. I think we have enough
* information if we look at the selection.
*/
if (wb_view_is_protected (wbv, TRUE) &&
mstyle_get_content_locked (sheet_style_get (sheet, col, row))) {
char *pos = g_strdup_printf ( _("%s!%s is locked.\n"),
sheet->name_quoted, cell_coord_name (col, row));
gnumeric_error_invalid (COMMAND_CONTEXT (wbcg), pos,
wb_view_is_protected (wbv, FALSE)
? _("Unprotect the sheet to enable editing.")
: _("Unprotect the workbook to enable editing."));
g_free (pos);
return FALSE;
}
inside_editing = TRUE;
application_clipboard_unant ();
workbook_edit_set_sensitive (wbcg, TRUE, FALSE);
cell = sheet_cell_get (sheet, col, row);
if (!blankp) {
if (cell != NULL)
text = cell_get_entered_text (cell);
/*
* If this is part of an array we need to remove the
/* If this is part of an array we need to remove the
* '{' '}' and the size information from the display.
* That is not actually part of the parsable expression.
*/
......@@ -405,6 +423,7 @@ wbcg_edit_start (WorkbookControlGUI *wbcg,
g_free (text);
inside_editing = FALSE;
return TRUE;
}
GtkEntry *
......
......@@ -8,7 +8,7 @@
void wbcg_edit_ctor (WorkbookControlGUI *wbcg);
void wbcg_edit_dtor (WorkbookControlGUI *wbcg);
gboolean wbcg_edit_finish (WorkbookControlGUI *wbcg, gboolean accept);
void wbcg_edit_start (WorkbookControlGUI *wbcg,
gboolean wbcg_edit_start (WorkbookControlGUI *wbcg,
gboolean blankp, gboolean cursorp);
void wbcg_edit_attach_guru (WorkbookControlGUI *wbcg, GtkWidget *guru);
......
......@@ -47,14 +47,6 @@
#include <gal/util/e-util.h>
#include <locale.h>