Commit 380ff133 authored by Morten Welinder's avatar Morten Welinder Committed by Morten Welinder

Rename "visible" property to "visibility" and make it an enum. All users

2005-06-08  Morten Welinder  <terra@gnome.org>

	* src/sheet.c (gnm_sheet_class_init): Rename "visible" property to
	"visibility" and make it an enum.  All users changed.
	* src/sheet.h (struct _Sheet): Ditto for is_visible member.

	* src/workbook-view.c (wb_view_sheet_remove): New function to
	mirror wb_view_sheet_add.
	* src/workbook.c (workbook_sheet_hide_controls): Use
	wb_view_sheet_remove.
parent c7c01a8b
2005-06-08 Morten Welinder <terra@gnome.org>
* src/sheet.c (gnm_sheet_class_init): Rename "visible" property to
"visibility" and make it an enum. All users changed.
* src/sheet.h (struct _Sheet): Ditto for is_visible member.
* src/workbook-view.c (wb_view_sheet_remove): New function to
mirror wb_view_sheet_add.
* src/workbook.c (workbook_sheet_hide_controls): Use
wb_view_sheet_remove.
2005-06-08 Ivan, Wogn Yat Cheung <email@ivanwong.info>
* src/sheet-control-gui.c (scg_drag_receive_uri_list):
......
......@@ -59,7 +59,7 @@ Morten:
* Add tooltips for ok_button, cancel_button, and func_button.
[#160344]
* Fix paste problem. [#305404]
* Fix brown bag text import problem.
* Fix brown bag text import problem. [Later reported as #305624]
* Improve R.QPOIS accuracy, efficiency, and termination.
* Improve R.QNORM's accuracy in the long double case.
* Improve R.QCAUCHY's accuracy.
......@@ -68,6 +68,7 @@ Morten:
* Fix xml export of shared array formulae.
* Fix number matching problem. [#306254]
* Fix R.PBETA screwup for log case.
* Fix problem with hiding sheets.
--------------------------------------------------------------------------
Gnumeric 1.5.1
......
2005-06-08 Morten Welinder <terra@gnome.org>
* src/sheet.c (gnm_sheet_class_init): Rename "visible" property to
"visibility" and make it an enum. All users changed.
* src/sheet.h (struct _Sheet): Ditto for is_visible member.
* src/workbook-view.c (wb_view_sheet_remove): New function to
mirror wb_view_sheet_add.
* src/workbook.c (workbook_sheet_hide_controls): Use
wb_view_sheet_remove.
2005-06-08 Ivan, Wogn Yat Cheung <email@ivanwong.info>
* src/sheet-control-gui.c (scg_drag_receive_uri_list):
......
......@@ -80,11 +80,6 @@
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "gnumeric:read"
typedef enum {
MS_SHEET_VISIBLE,
MS_SHEET_HIDDEN,
MS_SHEET_VERY_HIDDEN
} MSSheetVisibility;
typedef struct {
ExcelReadSheet *esheet;
char *name;
......@@ -92,7 +87,7 @@ typedef struct {
unsigned index;
MsBiffFileType type;
GnmSheetType gnm_type;
MSSheetVisibility visibility;
GnmSheetVisibility visibility;
} BiffBoundsheetData;
#define N_BYTES_BETWEEN_PROGRESS_UPDATES 0x1000
......@@ -1115,7 +1110,7 @@ excel_read_BOUNDSHEET (BiffQuery *q, ExcelWorkbook *ewb, MsBiffVersion ver)
bs->streamStartPos = 0; /* Excel 4 doesn't tell us */
bs->type = MS_BIFF_TYPE_Worksheet;
default_name = _("Sheet%d");
bs->visibility = MS_SHEET_VISIBLE;
bs->visibility = GNM_SHEET_VISIBILITY_VISIBLE;
bs->name = biff_get_text (q->data + 1,
GSF_LE_GET_GUINT8 (q->data), NULL, ver);
} else {
......@@ -1144,15 +1139,15 @@ excel_read_BOUNDSHEET (BiffQuery *q, ExcelWorkbook *ewb, MsBiffVersion ver)
bs->type = MS_BIFF_TYPE_Unknown;
}
switch ((GSF_LE_GET_GUINT8 (q->data + 4)) & 0x3) {
case 0: bs->visibility = MS_SHEET_VISIBLE;
case 0: bs->visibility = GNM_SHEET_VISIBILITY_VISIBLE;
break;
case 1: bs->visibility = MS_SHEET_HIDDEN;
case 1: bs->visibility = GNM_SHEET_VISIBILITY_HIDDEN;
break;
case 2: bs->visibility = MS_SHEET_VERY_HIDDEN;
case 2: bs->visibility = GNM_SHEET_VISIBILITY_VERY_HIDDEN;
break;
default:
fprintf (stderr,"Unknown sheet hiddenness %d\n", (GSF_LE_GET_GUINT8 (q->data + 4)) & 0x3);
bs->visibility = MS_SHEET_VISIBLE;
bs->visibility = GNM_SHEET_VISIBILITY_VISIBLE;
}
/* TODO: find some documentation on this.
......@@ -1181,7 +1176,7 @@ excel_read_BOUNDSHEET (BiffQuery *q, ExcelWorkbook *ewb, MsBiffVersion ver)
if (bs->esheet && bs->esheet->sheet)
g_object_set (bs->esheet->sheet,
"visible", (bs->visibility == MS_SHEET_VISIBLE),
"visibility", bs->visibility,
NULL);
break;
default :
......
......@@ -1002,7 +1002,7 @@ excel_write_BOUNDSHEET (BiffPut *bp, Sheet *sheet)
GSF_LE_SET_GUINT32 (data, 0xdeadbeef); /* To be stream start pos */
/* NOTE : MS Docs appear wrong. It is visiblity _then_ type */
GSF_LE_SET_GUINT8 (data+4, sheet->is_visible ? 0 : 1);
GSF_LE_SET_GUINT8 (data+4, sheet->visibility);
switch (sheet->sheet_type) {
default:
......
......@@ -5209,7 +5209,7 @@ cmd_reorganize_sheets (WorkbookControl *wbc, GSList *new_order,
while (the_sheets) {
Sheet *sheet = workbook_sheet_by_index (wb, GPOINTER_TO_INT (the_sheets->data));
me->old_visibility = g_slist_prepend (me->old_visibility, GINT_TO_POINTER (
(sheet == NULL) || sheet->is_visible));
sheet ? sheet->visibility : GNM_SHEET_VISIBILITY_VISIBLE));
the_sheets = the_sheets->next;
}
me->old_visibility = g_slist_reverse (me->old_visibility);
......
......@@ -279,12 +279,16 @@ cb_toggled_visible (G_GNUC_UNUSED GtkCellRendererToggle *cell,
gtk_tree_model_get (model, &iter, SHEET_VISIBLE, &value, -1);
if (value) {
gtk_list_store_set (GTK_LIST_STORE (model), &iter, SHEET_VISIBLE, FALSE,
SHEET_VISIBLE_IMAGE, NULL, -1);
gtk_list_store_set (GTK_LIST_STORE (model), &iter,
SHEET_VISIBLE, FALSE,
SHEET_VISIBLE_IMAGE, NULL,
-1);
} else {
gtk_list_store_set (GTK_LIST_STORE (model), &iter, SHEET_VISIBLE, TRUE,
SHEET_VISIBLE_IMAGE, state->image_visible, -1);
gtk_list_store_set (GTK_LIST_STORE (model), &iter,
SHEET_VISIBLE, TRUE,
SHEET_VISIBLE_IMAGE, state->image_visible,
-1);
}
gtk_tree_path_free (path);
}
......@@ -337,9 +341,10 @@ populate_sheet_list (SheetManager *state)
SHEET_LOCKED, sheet->is_protected,
SHEET_LOCK_IMAGE, sheet->is_protected ?
state->image_padlock : state->image_padlock_no,
SHEET_VISIBLE, sheet->is_visible,
SHEET_VISIBLE_IMAGE, sheet->is_visible ?
state->image_visible : NULL,
SHEET_VISIBLE, (sheet->visibility == GNM_SHEET_VISIBILITY_VISIBLE),
SHEET_VISIBLE_IMAGE, (sheet->visibility == GNM_SHEET_VISIBILITY_VISIBLE
? state->image_visible
: NULL),
SHEET_NAME, sheet->name_unquoted,
SHEET_NEW_NAME, "",
SHEET_POINTER, sheet,
......@@ -676,15 +681,14 @@ cb_ok_clicked (G_GNUC_UNUSED GtkWidget *ignore, SheetManager *state)
GINT_TO_POINTER (is_locked));
}
one_is_visible = one_is_visible || is_visible;
vis_changed = (this_sheet == NULL) ||
(is_visible != this_sheet->is_visible);
vis_changed = !this_sheet || is_visible != (this_sheet->visibility == GNM_SHEET_VISIBILITY_VISIBLE);
if (vis_changed) {
visibility_changed = g_slist_prepend
(visibility_changed,
GINT_TO_POINTER (this_sheet_idx));
new_visibility = g_slist_prepend
(new_visibility,
GINT_TO_POINTER (is_visible));
GINT_TO_POINTER (is_visible ? GNM_SHEET_VISIBILITY_VISIBLE : GNM_SHEET_VISIBILITY_HIDDEN));
}
g_object_set (this_sheet, "text-is-rtl", is_rtl, NULL);
......
......@@ -84,7 +84,7 @@ enum {
PROP_0,
PROP_NAME,
PROP_RTL,
PROP_VISIBLE,
PROP_VISIBILITY,
PROP_PROTECTED,
PROP_DISPLAY_FORMULAS,
PROP_DISPLAY_ZEROS,
......@@ -118,13 +118,12 @@ sheet_set_direction (Sheet *sheet, gboolean text_is_rtl)
}
static void
sheet_set_visibility (Sheet *sheet, gboolean visible)
sheet_set_visibility (Sheet *sheet, GnmSheetVisibility visibility)
{
visible = !!visible;
if (sheet->is_visible == visible)
if (sheet->visibility == visibility)
return;
sheet->is_visible = visible;
sheet->visibility = visibility;
sheet_set_dirty (sheet, TRUE);
}
......@@ -294,8 +293,8 @@ gnm_sheet_set_property (GObject *object, guint property_id,
case PROP_RTL:
sheet_set_direction (sheet, g_value_get_boolean (value));
break;
case PROP_VISIBLE:
sheet_set_visibility (sheet, g_value_get_boolean (value));
case PROP_VISIBILITY:
sheet_set_visibility (sheet, g_value_get_enum (value));
break;
case PROP_PROTECTED:
sheet->is_protected = !!g_value_get_boolean (value);
......@@ -358,8 +357,8 @@ gnm_sheet_get_property (GObject *object, guint property_id,
case PROP_RTL:
g_value_set_boolean (value, sheet->text_is_rtl);
break;
case PROP_VISIBLE:
g_value_set_boolean (value, sheet->is_visible);
case PROP_VISIBILITY:
g_value_set_boolean (value, sheet->visibility);
break;
case PROP_PROTECTED:
g_value_set_boolean (value, sheet->is_protected);
......@@ -423,7 +422,7 @@ gnm_sheet_init (Sheet *sheet)
sheet->outline_symbols_right = TRUE;
sheet->tab_color = NULL;
sheet->tab_text_color = NULL;
sheet->is_visible = TRUE;
sheet->visibility = GNM_SHEET_VISIBILITY_VISIBLE;
#ifdef WITH_GTK
sheet->text_is_rtl = (gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL);
#else
......@@ -512,13 +511,14 @@ gnm_sheet_class_init (GObjectClass *gobject_class)
G_PARAM_READWRITE));
g_object_class_install_property
(gobject_class,
PROP_VISIBLE,
g_param_spec_boolean ("visible",
_("Visible"),
_("Sheet is visible."),
TRUE,
GSF_PARAM_STATIC |
G_PARAM_READWRITE));
PROP_VISIBILITY,
g_param_spec_enum ("visibility",
_("Visibility"),
_("How visible the sheet is."),
GNM_SHEET_VISIBILITY_TYPE,
GNM_SHEET_VISIBILITY_VISIBLE,
GSF_PARAM_STATIC |
G_PARAM_READWRITE));
g_object_class_install_property
(gobject_class,
PROP_PROTECTED,
......@@ -645,13 +645,25 @@ gnm_sheet_class_init (GObjectClass *gobject_class)
GSF_CLASS (GnmSheet, gnm_sheet,
gnm_sheet_class_init, gnm_sheet_init, G_TYPE_OBJECT)
void
sheet_redraw_all (Sheet const *sheet, gboolean headers)
/* ------------------------------------------------------------------------- */
GType
gnm_sheet_visibility_get_type (void)
{
SHEET_FOREACH_CONTROL (sheet, view, control,
sc_redraw_all (control, headers););
static GType etype = 0;
if (etype == 0) {
static const GEnumValue values[] = {
{ GNM_SHEET_VISIBILITY_VISIBLE, (char*)"GNM_SHEET_VISIBILITY_VISIBLE", (char*)"visible" },
{ GNM_SHEET_VISIBILITY_HIDDEN, (char*)"GNM_SHEET_VISIBILITY_HIDDEN", (char*)"hidden" },
{ GNM_SHEET_VISIBILITY_VERY_HIDDEN, (char*)"GNM_SHEET_VISIBILITY_VERY_HIDDEN", (char*)"very-hidden" },
{ 0, NULL, NULL }
};
etype = g_enum_register_static ("GnmSheetVisibility", values);
}
return etype;
}
/* ------------------------------------------------------------------------- */
/**
* sheet_new_with_type :
* @wb : #Workbook
......@@ -712,6 +724,13 @@ sheet_new (Workbook *wb, char const *name)
/****************************************************************************/
void
sheet_redraw_all (Sheet const *sheet, gboolean headers)
{
SHEET_FOREACH_CONTROL (sheet, view, control,
sc_redraw_all (control, headers););
}
static GnmValue *
cb_clear_rendered_values (Sheet *sheet, int col, int row, GnmCell *cell,
gpointer ignored)
......
......@@ -13,6 +13,14 @@ typedef enum {
GNM_SHEET_XLM
} GnmSheetType;
typedef enum {
GNM_SHEET_VISIBILITY_VISIBLE,
GNM_SHEET_VISIBILITY_HIDDEN,
GNM_SHEET_VISIBILITY_VERY_HIDDEN
} GnmSheetVisibility;
GType gnm_sheet_visibility_get_type (void);
#define GNM_SHEET_VISIBILITY_TYPE (gnm_sheet_visibility_get_type ())
struct _Sheet {
GObject base;
......@@ -55,7 +63,7 @@ struct _Sheet {
gboolean hide_col_header;
gboolean hide_row_header;
gboolean is_protected;
gboolean is_visible;
GnmSheetVisibility visibility;
gboolean display_outlines;
gboolean outline_symbols_below;
......
......@@ -922,7 +922,7 @@ wbcg_sheet_add (WorkbookControl *wbc, SheetView *sv)
g_return_if_fail (wbcg != NULL);
sheet = sv_sheet (sv);
if (!sheet->is_visible)
if (sheet->visibility != GNM_SHEET_VISIBILITY_VISIBLE)
return;
if (wbcg->notebook == NULL)
......
......@@ -131,6 +131,21 @@ wb_view_sheet_add (WorkbookView *wbv, Sheet *new_sheet)
wb_control_sheet_add (control, new_view););
}
void
wb_view_sheet_remove (WorkbookView *wbv, Sheet *sheet)
{
SheetView *sv;
g_return_if_fail (IS_WORKBOOK_VIEW (wbv));
WORKBOOK_VIEW_FOREACH_CONTROL (wbv, control,
wb_control_sheet_remove (control, sheet););
sv = sheet_get_view (sheet, wbv);
if (sv)
sv_dispose (sv);
}
gboolean
wb_view_is_protected (WorkbookView *wbv, gboolean check_sheet)
{
......
......@@ -59,6 +59,7 @@ Sheet *wb_view_cur_sheet (WorkbookView const *wbv);
SheetView *wb_view_cur_sheet_view (WorkbookView const *wbv);
void wb_view_sheet_focus (WorkbookView *wbv, Sheet *sheet);
void wb_view_sheet_add (WorkbookView *wbv, Sheet *new_sheet);
void wb_view_sheet_remove (WorkbookView *wbv, Sheet *sheet);
gboolean wb_view_is_protected (WorkbookView *wbv, gboolean check_sheet);
/* Manipulation */
......
......@@ -886,13 +886,13 @@ workbook_focus_other_sheet (Workbook *wb, Sheet *sheet)
for (i = sheet_index; !focus && --i >= 0; ) {
Sheet *this_sheet = g_ptr_array_index (wb->sheets, i);
if (this_sheet->is_visible)
if (this_sheet->visibility == GNM_SHEET_VISIBILITY_VISIBLE)
focus = this_sheet;
}
for (i = sheet_index; !focus && ++i < (int)wb->sheets->len; ) {
Sheet *this_sheet = g_ptr_array_index (wb->sheets, i);
if (this_sheet->is_visible)
if (this_sheet->visibility == GNM_SHEET_VISIBILITY_VISIBLE)
focus = this_sheet;
}
......@@ -933,9 +933,9 @@ workbook_sheet_hide_controls (Workbook *wb, Sheet *sheet)
if (!wb->during_destruction)
focus = workbook_focus_other_sheet (wb, sheet);
/* Remove all controls */
WORKBOOK_FOREACH_CONTROL (wb, view, control,
wb_control_sheet_remove (control, sheet););
/* Remove all controls and views. */
WORKBOOK_FOREACH_VIEW (wb, wbv,
wb_view_sheet_remove (wbv, sheet););
return focus != NULL;
}
......@@ -956,7 +956,7 @@ cb_sheet_visibility_change (Sheet *sheet,
G_GNUC_UNUSED GParamSpec *pspec,
G_GNUC_UNUSED gpointer data)
{
if (sheet->is_visible)
if (sheet->visibility == GNM_SHEET_VISIBILITY_VISIBLE)
workbook_sheet_unhide_controls (sheet->workbook, sheet);
else
workbook_sheet_hide_controls (sheet->workbook, sheet);
......@@ -994,7 +994,7 @@ workbook_sheet_attach_at_pos (Workbook *wb, Sheet *new_sheet, int pos)
wb_view_sheet_add (view, new_sheet););
g_signal_connect (G_OBJECT (new_sheet),
"notify::visible",
"notify::visibility",
G_CALLBACK (cb_sheet_visibility_change),
NULL);
}
......@@ -1458,9 +1458,9 @@ workbook_sheet_change_visibility (Workbook *wb,
Sheet *sheet = workbook_sheet_by_index
(wb, GPOINTER_TO_INT (sheets->data));
if (sheet != NULL) {
gboolean visible = GPOINTER_TO_INT (visibility->data);
GnmSheetVisibility v = GPOINTER_TO_INT (visibility->data);
g_object_set (sheet,
"visible", visible,
"visibility", v,
NULL);
}
sheets = sheets->next;
......
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