Commit 9db88417 authored by Andreas J. Guelzow's avatar Andreas J. Guelzow Committed by Andreas J. Guelzow

renamed to editable_label_start_editing and made non-static

2002-03-15  Andreas J. Guelzow <aguelzow@taliesin.ca>

	* widget-editable-label.[ch] (el_start_editing) : renamed to
	  editable_label_start_editing and made non-static
	(editable_label_set_color) : added third argument
	(editable_label_new) : ditto

2002-03-15  Andreas J. Guelzow <aguelzow@taliesin.ca>

	* dialog-sheet-order.c : support changes to tab colors.
	* sheet-order.glade : rearrange to allow for color pickers

2002-03-15  Andreas J. Guelzow <aguelzow@taliesin.ca>

	* src/commands.c : support tab color changes in cmd_reorganize_sheets
	* src/commands.h (cmd_reorganize_sheets) : add arguments
	* src/sheet.c (sheet_set_tab_color) : add third argument
	(sheet_new) : initialize tab_text_color
	(sheet_destroy) : free tab_text_color
	* src/sheet.h : add tab_text_color to _Sheet
	(sheet_set_tab_color) : add third argument
	* src/workbook-control-gui.c (wbcg_sheet_add) : also set tab_text_color
	(wbcg_sheet_rename) : add arguments to call of cmd_reorganize_sheets
	(cb_insert_sheet) : ditto
	* src/workbook.c (workbook_sheet_reorganize) : support changing of tab
	  colors
	* src/workbook.h (workbook_sheet_reorganize) : add arguments
	* src/xml-io.c : read and write TabTextColor

2002-03-15  Andreas J. Guelzow <aguelzow@taiesin.ca>

	* ms-excel-read.c : calculate desired tab_text_color upon reading of
	  tab_color
parent 2c9e0473
2002-03-15 Andreas J. Guelzow <aguelzow@taliesin.ca>
* src/commands.c : support tab color changes in cmd_reorganize_sheets
* src/commands.h (cmd_reorganize_sheets) : add arguments
* src/sheet.c (sheet_set_tab_color) : add third argument
(sheet_new) : initialize tab_text_color
(sheet_destroy) : free tab_text_color
* src/sheet.h : add tab_text_color to _Sheet
(sheet_set_tab_color) : add third argument
* src/workbook-control-gui.c (wbcg_sheet_add) : also set tab_text_color
(wbcg_sheet_rename) : add arguments to call of cmd_reorganize_sheets
(cb_insert_sheet) : ditto
* src/workbook.c (workbook_sheet_reorganize) : support changing of tab
colors
* src/workbook.h (workbook_sheet_reorganize) : add arguments
* src/xml-io.c : read and write TabTextColor
2002-03-14 Andreas J. Guelzow <aguelzow@taliesin.ca> 2002-03-14 Andreas J. Guelzow <aguelzow@taliesin.ca>
* src/commands.c (cmd_merge_data_redo) : don't create unnecessary cells * src/commands.c (cmd_merge_data_redo) : don't create unnecessary cells
......
...@@ -4,6 +4,7 @@ Andreas: ...@@ -4,6 +4,7 @@ Andreas:
* Make Single-Factor ANOVA undoable. * Make Single-Factor ANOVA undoable.
* Port search dialog. * Port search dialog.
* Add merge tool. * Add merge tool.
* Implement setting and changing of tab colors.
Jody: Jody:
* Fix XL import of external function names. * Fix XL import of external function names.
......
2002-03-15 Andreas J. Guelzow <aguelzow@taliesin.ca>
* src/commands.c : support tab color changes in cmd_reorganize_sheets
* src/commands.h (cmd_reorganize_sheets) : add arguments
* src/sheet.c (sheet_set_tab_color) : add third argument
(sheet_new) : initialize tab_text_color
(sheet_destroy) : free tab_text_color
* src/sheet.h : add tab_text_color to _Sheet
(sheet_set_tab_color) : add third argument
* src/workbook-control-gui.c (wbcg_sheet_add) : also set tab_text_color
(wbcg_sheet_rename) : add arguments to call of cmd_reorganize_sheets
(cb_insert_sheet) : ditto
* src/workbook.c (workbook_sheet_reorganize) : support changing of tab
colors
* src/workbook.h (workbook_sheet_reorganize) : add arguments
* src/xml-io.c : read and write TabTextColor
2002-03-14 Andreas J. Guelzow <aguelzow@taliesin.ca> 2002-03-14 Andreas J. Guelzow <aguelzow@taliesin.ca>
* src/commands.c (cmd_merge_data_redo) : don't create unnecessary cells * src/commands.c (cmd_merge_data_redo) : don't create unnecessary cells
......
2002-03-15 Andreas J. Guelzow <aguelzow@taliesin.ca>
* src/commands.c : support tab color changes in cmd_reorganize_sheets
* src/commands.h (cmd_reorganize_sheets) : add arguments
* src/sheet.c (sheet_set_tab_color) : add third argument
(sheet_new) : initialize tab_text_color
(sheet_destroy) : free tab_text_color
* src/sheet.h : add tab_text_color to _Sheet
(sheet_set_tab_color) : add third argument
* src/workbook-control-gui.c (wbcg_sheet_add) : also set tab_text_color
(wbcg_sheet_rename) : add arguments to call of cmd_reorganize_sheets
(cb_insert_sheet) : ditto
* src/workbook.c (workbook_sheet_reorganize) : support changing of tab
colors
* src/workbook.h (workbook_sheet_reorganize) : add arguments
* src/xml-io.c : read and write TabTextColor
2002-03-14 Andreas J. Guelzow <aguelzow@taliesin.ca> 2002-03-14 Andreas J. Guelzow <aguelzow@taliesin.ca>
* src/commands.c (cmd_merge_data_redo) : don't create unnecessary cells * src/commands.c (cmd_merge_data_redo) : don't create unnecessary cells
......
2002-03-15 Andreas J. Guelzow <aguelzow@taiesin.ca>
* ms-excel-read.c : calculate desired tab_text_color upon reading of
tab_color
2002-03-14 Jody Goldberg <jody@gnome.org> 2002-03-14 Jody Goldberg <jody@gnome.org>
* ms-obj.c (ms_obj_read_pre_biff8_obj) : doh! Fix sense of result so * ms-obj.c (ms_obj_read_pre_biff8_obj) : doh! Fix sense of result so
......
...@@ -2832,6 +2832,8 @@ ms_excel_read_tab_color (BiffQuery *q, ExcelSheet *esheet) ...@@ -2832,6 +2832,8 @@ ms_excel_read_tab_color (BiffQuery *q, ExcelSheet *esheet)
#endif #endif
guint8 color_index; guint8 color_index;
StyleColor *color; StyleColor *color;
StyleColor *text_color;
int contrast;
g_return_if_fail (q->length == 20); g_return_if_fail (q->length == 20);
...@@ -2840,8 +2842,12 @@ ms_excel_read_tab_color (BiffQuery *q, ExcelSheet *esheet) ...@@ -2840,8 +2842,12 @@ ms_excel_read_tab_color (BiffQuery *q, ExcelSheet *esheet)
*/ */
color_index = MS_OLE_GET_GUINT8 (q->data + 16); color_index = MS_OLE_GET_GUINT8 (q->data + 16);
color = ms_excel_palette_get (esheet->wb->palette, color_index); color = ms_excel_palette_get (esheet->wb->palette, color_index);
sheet_set_tab_color (esheet->gnum_sheet, color); contrast = color->color.red + color->color.green + color->color.blue;
if (contrast >= 0x18000)
text_color = style_color_black ();
else
text_color = style_color_white ();
sheet_set_tab_color (esheet->gnum_sheet, color, text_color);
if (color != NULL) { if (color != NULL) {
d (1, printf ("%s tab colour = %04hx:%04hx:%04hx\n", d (1, printf ("%s tab colour = %04hx:%04hx:%04hx\n",
esheet->gnum_sheet->name_unquoted, esheet->gnum_sheet->name_unquoted,
......
...@@ -58,6 +58,7 @@ ...@@ -58,6 +58,7 @@
#include "sheet-object-widget.h" #include "sheet-object-widget.h"
#include "sheet-object.h" #include "sheet-object.h"
#include "sheet-control.h" #include "sheet-control.h"
#include "style-color.h"
#include <libgnome/gnome-i18n.h> #include <libgnome/gnome-i18n.h>
#include <gal/util/e-util.h> #include <gal/util/e-util.h>
...@@ -3971,6 +3972,11 @@ typedef struct ...@@ -3971,6 +3972,11 @@ typedef struct
GSList *new_names; GSList *new_names;
GSList *old_names; GSList *old_names;
GSList *new_sheets; GSList *new_sheets;
GSList *color_changed;
GSList *new_colors_fore;
GSList *new_colors_back;
GSList *old_colors_fore;
GSList *old_colors_back;
} CmdReorganizeSheets; } CmdReorganizeSheets;
GNUMERIC_MAKE_COMMAND (CmdReorganizeSheets, cmd_reorganize_sheets); GNUMERIC_MAKE_COMMAND (CmdReorganizeSheets, cmd_reorganize_sheets);
...@@ -3995,7 +4001,9 @@ cmd_reorganize_sheets_undo (GnumericCommand *cmd, WorkbookControl *wbc) ...@@ -3995,7 +4001,9 @@ cmd_reorganize_sheets_undo (GnumericCommand *cmd, WorkbookControl *wbc)
me->new_sheets = NULL; me->new_sheets = NULL;
return workbook_sheet_reorganize (me->wbc, me->changed_names, me->old_order, return workbook_sheet_reorganize (me->wbc, me->changed_names, me->old_order,
me->old_names, me->new_names, NULL); me->old_names, me->new_names, NULL,
me->color_changed,
me->old_colors_fore, me->old_colors_back);
} }
static gboolean static gboolean
...@@ -4007,9 +4015,19 @@ cmd_reorganize_sheets_redo (GnumericCommand *cmd, WorkbookControl *wbc) ...@@ -4007,9 +4015,19 @@ cmd_reorganize_sheets_redo (GnumericCommand *cmd, WorkbookControl *wbc)
return workbook_sheet_reorganize (me->wbc, me->changed_names, me->new_order, return workbook_sheet_reorganize (me->wbc, me->changed_names, me->new_order,
me->new_names, me->old_names, me->new_names, me->old_names,
&me->new_sheets); &me->new_sheets, me->color_changed,
me->new_colors_fore, me->new_colors_back);
} }
static void
cb_slist_gdk_color_free (gpointer data, gpointer user_data)
{
if (data)
gdk_color_free (data);
}
static void static void
cmd_reorganize_sheets_finalize (GObject *cmd) cmd_reorganize_sheets_finalize (GObject *cmd)
{ {
...@@ -4033,17 +4051,38 @@ cmd_reorganize_sheets_finalize (GObject *cmd) ...@@ -4033,17 +4051,38 @@ cmd_reorganize_sheets_finalize (GObject *cmd)
e_free_string_slist (me->new_names); e_free_string_slist (me->new_names);
me->new_names = NULL; me->new_names = NULL;
g_slist_free (me->color_changed);
me->color_changed = NULL;
g_slist_foreach (me->new_colors_fore, cb_slist_gdk_color_free, NULL);
g_slist_free (me->new_colors_fore);
me->new_colors_fore = NULL;
g_slist_foreach (me->new_colors_back, cb_slist_gdk_color_free, NULL);
g_slist_free (me->new_colors_back);
me->new_colors_back = NULL;
g_slist_foreach (me->old_colors_fore, cb_slist_gdk_color_free, NULL);
g_slist_free (me->old_colors_fore);
me->old_colors_fore = NULL;
g_slist_foreach (me->old_colors_back, cb_slist_gdk_color_free, NULL);
g_slist_free (me->old_colors_back);
me->old_colors_back = NULL;
gnumeric_command_finalize (cmd); gnumeric_command_finalize (cmd);
} }
gboolean gboolean
cmd_reorganize_sheets (WorkbookControl *wbc, GSList *old_order, GSList *new_order, cmd_reorganize_sheets (WorkbookControl *wbc, GSList *old_order, GSList *new_order,
GSList *changed_names, GSList *new_names, GSList *deleted_sheets) GSList *changed_names, GSList *new_names, GSList *deleted_sheets,
GSList *color_changed, GSList *new_colors_back,
GSList *new_colors_fore)
{ {
GObject *obj; GObject *obj;
CmdReorganizeSheets *me; CmdReorganizeSheets *me;
Workbook *wb = wb_control_workbook (wbc); Workbook *wb = wb_control_workbook (wbc);
GSList *the_names; GSList *the_sheets;
int selector = 0; int selector = 0;
if (deleted_sheets) { if (deleted_sheets) {
...@@ -4065,39 +4104,67 @@ cmd_reorganize_sheets (WorkbookControl *wbc, GSList *old_order, GSList *new_orde ...@@ -4065,39 +4104,67 @@ cmd_reorganize_sheets (WorkbookControl *wbc, GSList *old_order, GSList *new_orde
me->new_names = new_names; me->new_names = new_names;
me->new_sheets = NULL; me->new_sheets = NULL;
me->old_names = NULL; me->old_names = NULL;
the_names = changed_names; me->color_changed = color_changed;
while (the_names) { me->new_colors_fore = new_colors_fore;
Sheet *sheet = the_names->data; me->new_colors_back = new_colors_back;
me->old_colors_fore = NULL;
me->old_colors_back = NULL;
the_sheets = changed_names;
while (the_sheets) {
Sheet *sheet = the_sheets->data;
if (sheet == NULL) if (sheet == NULL)
me->old_names = g_slist_prepend (me->old_names, NULL); me->old_names = g_slist_prepend (me->old_names, NULL);
else else
me->old_names = g_slist_prepend me->old_names = g_slist_prepend
(me->old_names, g_strdup (sheet->name_unquoted)); (me->old_names, g_strdup (sheet->name_unquoted));
the_names = the_names->next; the_sheets = the_sheets->next;
} }
the_sheets = color_changed;
while (the_sheets) {
Sheet *sheet = the_sheets->data;
if (sheet == NULL) {
me->old_colors_fore = g_slist_prepend (me->old_colors_fore, NULL);
me->old_colors_back = g_slist_prepend (me->old_colors_back, NULL);
} else {
me->old_colors_fore = g_slist_prepend (me->old_colors_fore,
sheet->tab_text_color ?
gdk_color_copy (&sheet->tab_text_color->color) : NULL);
me->old_colors_back = g_slist_prepend (me->old_colors_back,
sheet->tab_color ?
gdk_color_copy (&sheet->tab_color->color) : NULL);
}
the_sheets = the_sheets->next;
}
me->old_colors_fore = g_slist_reverse (me->old_colors_fore);
me->old_colors_back = g_slist_reverse (me->old_colors_back);
me->old_names = g_slist_reverse (me->old_names); me->old_names = g_slist_reverse (me->old_names);
me->parent.sheet = NULL; me->parent.sheet = NULL;
me->parent.size = 1; me->parent.size = 1 + g_slist_length (color_changed) + g_slist_length (changed_names);
if (new_order == NULL) if (new_order != NULL)
selector += (1 << 0); selector += (1 << 0);
if (new_names == NULL) if (new_names != NULL) {
selector += (1 << 1); selector += (1 << 1);
else if (new_names->next == NULL) if (new_names->next == NULL)
selector += (1 << 2); selector += (1 << 2);
}
if (color_changed != NULL)
selector += (1 << 3);
switch (selector) { switch (selector) {
case 1: case 0:
me->parent.cmd_descriptor = g_strdup ("Nothing to do?");
break;
case (1 << 1):
me->parent.cmd_descriptor = g_strdup (_("Renaming Sheets")); me->parent.cmd_descriptor = g_strdup (_("Renaming Sheets"));
break; break;
case 2: case (1 << 0):
me->parent.cmd_descriptor = g_strdup (_("Reordering Sheets")); me->parent.cmd_descriptor = g_strdup (_("Reordering Sheets"));
break; break;
case 3: case ((1 << 1) + (1 << 2)):
me->parent.cmd_descriptor = g_strdup ("Nothing to do?");
break;
case 5:
if (changed_names->data == NULL) { if (changed_names->data == NULL) {
if (new_names->data == NULL) if (new_names->data == NULL)
me->parent.cmd_descriptor = g_strdup (_("Adding a sheet")); me->parent.cmd_descriptor = g_strdup (_("Adding a sheet"));
...@@ -4111,6 +4178,9 @@ cmd_reorganize_sheets (WorkbookControl *wbc, GSList *old_order, GSList *new_orde ...@@ -4111,6 +4178,9 @@ cmd_reorganize_sheets (WorkbookControl *wbc, GSList *old_order, GSList *new_orde
((Sheet *)changed_names->data)->name_unquoted, ((Sheet *)changed_names->data)->name_unquoted,
(const char *)new_names->data); (const char *)new_names->data);
break; break;
case (1 << 3):
me->parent.cmd_descriptor = g_strdup (_("Changing Tab Colors"));
break;
default: default:
me->parent.cmd_descriptor = g_strdup (_("Reorganizing Sheets")); me->parent.cmd_descriptor = g_strdup (_("Reorganizing Sheets"));
break; break;
...@@ -4143,7 +4213,8 @@ cmd_rename_sheet (WorkbookControl *wbc, Sheet *sheet, char const *old_name, char ...@@ -4143,7 +4213,8 @@ cmd_rename_sheet (WorkbookControl *wbc, Sheet *sheet, char const *old_name, char
changed_names = g_slist_prepend (changed_names, sheet); changed_names = g_slist_prepend (changed_names, sheet);
new_names = g_slist_prepend (new_names, g_strdup (new_name)); new_names = g_slist_prepend (new_names, g_strdup (new_name));
return cmd_reorganize_sheets (wbc, NULL, NULL, changed_names, new_names, NULL); return cmd_reorganize_sheets (wbc, NULL, NULL, changed_names, new_names,
NULL, NULL, NULL, NULL);
} }
/******************************************************************/ /******************************************************************/
......
...@@ -86,7 +86,9 @@ gboolean cmd_object_move (WorkbookControl *wbc, SheetObject *so, ...@@ -86,7 +86,9 @@ gboolean cmd_object_move (WorkbookControl *wbc, SheetObject *so,
gboolean resize); gboolean resize);
gboolean cmd_reorganize_sheets (WorkbookControl *wbc, GSList *old_order, GSList *new_order, gboolean cmd_reorganize_sheets (WorkbookControl *wbc, GSList *old_order, GSList *new_order,
GSList *changed_names, GSList *new_names, GSList *deleted_sheets); GSList *changed_names, GSList *new_names, GSList *deleted_sheets,
GSList *color_changed, GSList *new_colors_back,
GSList *new_colors_fore);
gboolean cmd_rename_sheet (WorkbookControl *wbc, Sheet *sheet, gboolean cmd_rename_sheet (WorkbookControl *wbc, Sheet *sheet,
char const *old_name, char const *new_name); char const *old_name, char const *new_name);
......
2002-03-15 Andreas J. Guelzow <aguelzow@taliesin.ca>
* dialog-sheet-order.c : support changes to tab colors.
* sheet-order.glade : rearrange to allow for color pickers
2002-03-15 Jukka-Pekka Iivonen <jiivonen@hutcs.cs.hut.fi> 2002-03-15 Jukka-Pekka Iivonen <jiivonen@hutcs.cs.hut.fi>
* dialog-solver.c (cb_dialog_solve_clicked): Changes related to * dialog-solver.c (cb_dialog_solve_clicked): Changes related to
......
...@@ -37,9 +37,11 @@ ...@@ -37,9 +37,11 @@
#include <style-color.h> #include <style-color.h>
#include <commands.h> #include <commands.h>
#include <widgets/gnumeric-cell-renderer-text.h> #include <widgets/gnumeric-cell-renderer-text.h>
#include "pixmaps/gnumeric-stock-pixbufs.h"
#include <libgnome/gnome-i18n.h> #include <libgnome/gnome-i18n.h>
#include <glade/glade.h> #include <glade/glade.h>
#include <gal/widgets/widget-color-combo.h>
typedef struct { typedef struct {
WorkbookControlGUI *wbcg; WorkbookControlGUI *wbcg;
...@@ -56,6 +58,8 @@ typedef struct { ...@@ -56,6 +58,8 @@ typedef struct {
GtkWidget *ok_btn; GtkWidget *ok_btn;
GtkWidget *cancel_btn; GtkWidget *cancel_btn;
GdkPixbuf *sheet_image; GdkPixbuf *sheet_image;
GtkWidget *ccombo_back;
GtkWidget *ccombo_fore;
GSList *old_order; GSList *old_order;
} SheetManager; } SheetManager;
...@@ -96,7 +100,6 @@ location_of_iter (GtkTreeIter *iter, GtkListStore *model) ...@@ -96,7 +100,6 @@ location_of_iter (GtkTreeIter *iter, GtkListStore *model)
GtkTreeIter this_iter; GtkTreeIter this_iter;
gint n = 0; gint n = 0;
gtk_tree_model_get (GTK_TREE_MODEL (model), iter, SHEET_POINTER, &sheet, -1); gtk_tree_model_get (GTK_TREE_MODEL (model), iter, SHEET_POINTER, &sheet, -1);
while (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (model), while (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (model),
...@@ -112,6 +115,34 @@ location_of_iter (GtkTreeIter *iter, GtkListStore *model) ...@@ -112,6 +115,34 @@ location_of_iter (GtkTreeIter *iter, GtkListStore *model)
return -1; return -1;
} }
static void
cb_color_changed_fore (ColorCombo *color_combo, GdkColor *color, gboolean custom,
gboolean by_user, gboolean is_default, SheetManager *state)
{
GtkTreeIter sel_iter;
GtkTreeSelection *selection = gtk_tree_view_get_selection (state->sheet_list);
if (gtk_tree_selection_get_selected (selection, NULL, &sel_iter)) {
gtk_list_store_set (state->model, &sel_iter,
FOREGROUND_COLOUR_POINTER, color,
-1);
}
}
static void
cb_color_changed_back (ColorCombo *color_combo, GdkColor *color, gboolean custom,
gboolean by_user, gboolean is_default, SheetManager *state)
{
GtkTreeIter sel_iter;
GtkTreeSelection *selection = gtk_tree_view_get_selection (state->sheet_list);
if (gtk_tree_selection_get_selected (selection, NULL, &sel_iter)) {
gtk_list_store_set (state->model, &sel_iter,
BACKGROUND_COLOUR_POINTER, color,
-1);
}
}
/** /**
* Refreshes the buttons on a row (un)selection and selects the chosen sheet * Refreshes the buttons on a row (un)selection and selects the chosen sheet
* for this view. * for this view.
...@@ -124,6 +155,7 @@ cb_selection_changed (GtkTreeSelection *ignored, SheetManager *state) ...@@ -124,6 +155,7 @@ cb_selection_changed (GtkTreeSelection *ignored, SheetManager *state)
gint row; gint row;
Sheet *sheet; Sheet *sheet;
gboolean is_deleted; gboolean is_deleted;
GdkColor *fore, *back;
GtkTreeSelection *selection = gtk_tree_view_get_selection (state->sheet_list); GtkTreeSelection *selection = gtk_tree_view_get_selection (state->sheet_list);
gtk_widget_set_sensitive (state->add_btn, TRUE); gtk_widget_set_sensitive (state->add_btn, TRUE);
...@@ -133,13 +165,25 @@ cb_selection_changed (GtkTreeSelection *ignored, SheetManager *state) ...@@ -133,13 +165,25 @@ cb_selection_changed (GtkTreeSelection *ignored, SheetManager *state)
gtk_widget_set_sensitive (state->up_btn, FALSE); gtk_widget_set_sensitive (state->up_btn, FALSE);
gtk_widget_set_sensitive (state->down_btn, FALSE); gtk_widget_set_sensitive (state->down_btn, FALSE);
gtk_widget_set_sensitive (state->delete_btn, FALSE); gtk_widget_set_sensitive (state->delete_btn, FALSE);
gtk_widget_set_sensitive (state->ccombo_back, FALSE);
gtk_widget_set_sensitive (state->ccombo_fore, FALSE);
return; return;
} }
gtk_tree_model_get (GTK_TREE_MODEL (state->model), &iter, gtk_tree_model_get (GTK_TREE_MODEL (state->model), &iter,
IS_DELETED, &is_deleted, IS_DELETED, &is_deleted,
SHEET_POINTER, &sheet, SHEET_POINTER, &sheet,
BACKGROUND_COLOUR_POINTER, &back,
FOREGROUND_COLOUR_POINTER, &fore,
-1); -1);
color_combo_set_color (COLOR_COMBO (state->ccombo_back), back);
if (back)
gdk_color_free (back);
color_combo_set_color (COLOR_COMBO (state->ccombo_fore), fore);
if (fore)
gdk_color_free (fore);
gtk_widget_set_sensitive (state->ccombo_back, TRUE);
gtk_widget_set_sensitive (state->ccombo_fore, TRUE);
gtk_widget_set_sensitive (state->delete_btn, TRUE); gtk_widget_set_sensitive (state->delete_btn, TRUE);
gtk_button_set_label (GTK_BUTTON (state->delete_btn), gtk_button_set_label (GTK_BUTTON (state->delete_btn),
is_deleted ? GTK_STOCK_UNDELETE : GTK_STOCK_DELETE); is_deleted ? GTK_STOCK_UNDELETE : GTK_STOCK_DELETE);
...@@ -187,14 +231,13 @@ populate_sheet_list (SheetManager *state) ...@@ -187,14 +231,13 @@ populate_sheet_list (SheetManager *state)
for (i = 0 ; i < n ; i++) { for (i = 0 ; i < n ; i++) {
Sheet *sheet = workbook_sheet_by_index ( Sheet *sheet = workbook_sheet_by_index (
wb_control_workbook (WORKBOOK_CONTROL (state->wbcg)), i); wb_control_workbook (WORKBOOK_CONTROL (state->wbcg)), i);
GdkColor *color = &sheet->tab_color->color; GdkColor *color = NULL;
int contrast; GdkColor *text_color = NULL;
GdkColor text_color;
if (sheet->tab_color)
if (color == NULL) color = &sheet->tab_color->color;
color = &gs_white; if (sheet->tab_text_color)
contrast = color->red + color->green + color->blue; text_color = &sheet->tab_text_color->color;
text_color = (contrast >= 0x18000) ? gs_black : gs_white;
gtk_list_store_append (state->model, &iter); gtk_list_store_append (state->model, &iter);
gtk_list_store_set (state->model, &iter, gtk_list_store_set (state->model, &iter,
...@@ -205,7 +248,7 @@ populate_sheet_list (SheetManager *state) ...@@ -205,7 +248,7 @@ populate_sheet_list (SheetManager *state)
IS_EDITABLE_COLUMN, TRUE, IS_EDITABLE_COLUMN, TRUE,
IS_DELETED, FALSE, IS_DELETED, FALSE,
BACKGROUND_COLOUR_POINTER, color, BACKGROUND_COLOUR_POINTER, color,
FOREGROUND_COLOUR_POINTER, &text_color, FOREGROUND_COLOUR_POINTER, text_color,
-1); -1);
if (sheet == cur_sheet) if (sheet == cur_sheet)
gtk_tree_selection_select_iter (selection, &iter); gtk_tree_selection_select_iter (selection, &iter);
...@@ -262,7 +305,7 @@ cb_item_move (SheetManager *state, gint direction) ...@@ -262,7 +305,7 @@ cb_item_move (SheetManager *state, gint direction)
gint row; gint row;
gboolean is_deleted; gboolean is_deleted;
gboolean is_editable; gboolean is_editable;
GdkColor *back, *front; GdkColor *back, *fore;
GtkTreeSelection *selection = gtk_tree_view_get_selection (state->sheet_list); GtkTreeSelection *selection = gtk_tree_view_get_selection (state->sheet_list);
if (!gtk_tree_selection_get_selected (selection, NULL, &iter)) if (!gtk_tree_selection_get_selected (selection, NULL, &iter))
...@@ -275,7 +318,7 @@ cb_item_move (SheetManager *state, gint direction) ...@@ -275,7 +318,7 @@ cb_item_move (SheetManager *state, gint direction)
SHEET_POINTER, &sheet, SHEET_POINTER, &sheet,
IS_DELETED, &is_deleted, IS_DELETED, &is_deleted,
BACKGROUND_COLOUR_POINTER, &back, BACKGROUND_COLOUR_POINTER, &back,
FOREGROUND_COLOUR_POINTER, &front, FOREGROUND_COLOUR_POINTER, &fore,
-1); -1);
row = location_of_iter (&iter, state->model); row = location_of_iter (&iter, state->model);
if (row + direction < 0) if (row + direction < 0)
...@@ -290,8 +333,12 @@ cb_item_move (SheetManager *state, gint direction) ...@@ -290,8 +333,12 @@ cb_item_move (SheetManager *state, gint direction)
SHEET_POINTER, sheet, SHEET_POINTER, sheet,
IS_DELETED, is_deleted, IS_DELETED, is_deleted,
BACKGROUND_COLOUR_POINTER, back, BACKGROUND_COLOUR_POINTER, back,
FOREGROUND_COLOUR_POINTER, front, FOREGROUND_COLOUR_POINTER, fore,
-1); -1);
if (back)
gdk_color_free (back);
if (fore)
gdk_color_free (fore);
g_free (name); g_free (name);
g_free (new_name); g_free (new_name);
gtk_tree_selection_select_iter (selection, &iter); gtk_tree_selection_select_iter (selection, &iter);
...@@ -348,8 +395,8 @@ cb_add_clicked (GtkWidget *ignore, SheetManager *state) ...@@ -348,8 +395,8 @@ cb_add_clicked (GtkWidget *ignore, SheetManager *state)
SHEET_POINTER, NULL, SHEET_POINTER, NULL,
IS_EDITABLE_COLUMN, TRUE, IS_EDITABLE_COLUMN, TRUE,
IS_DELETED, FALSE, IS_DELETED, FALSE,
BACKGROUND_COLOUR_POINTER, &gs_white, BACKGROUND_COLOUR_POINTER, NULL,
FOREGROUND_COLOUR_POINTER, &gs_black, FOREGROUND_COLOUR_POINTER, NULL,
-1); -1);
gtk_tree_selection_select_iter (selection, &iter); gtk_tree_selection_select_iter (selection, &iter);
g_free (name); g_free (name);
...@@ -408,6 +455,15 @@ cb_delete_sheets (gpointer data, gpointer dummy) ...@@ -408,6 +455,15 @@ cb_delete_sheets (gpointer data, gpointer dummy)
workbook_sheet_delete (sheet); workbook_sheet_delete (sheet);
} }
static gboolean
sheet_order_gdk_color_equal (GdkColor *color_a, GdkColor *color_b)
{
if (color_a == NULL && color_b == NULL)
return TRUE;
if (color_a != NULL && color_b != NULL)
return gdk_color_equal (color_a, color_b);
return FALSE;
}
static void static void
cb_ok_clicked (GtkWidget *ignore, SheetManager *state) cb_ok_clicked (GtkWidget *ignore, SheetManager *state)
...@@ -415,7 +471,10 @@ cb_ok_clicked (GtkWidget *ignore, SheetManager *state) ...@@ -415,7 +471,10 @@ cb_ok_clicked (GtkWidget *ignore, SheetManager *state)
GSList *new_order = NULL; GSList *new_order = NULL;
GSList *changed_names = NULL; GSList *changed_names = NULL;
GSList *new_names = NULL; GSList *new_names = NULL;
GSList * deleted_sheets = NULL; GSList *deleted_sheets = NULL;
GSList *color_changed = NULL;
GSList *new_colors_back = NULL;
GSList *new_colors_fore = NULL;
GSList * old_order; GSList * old_order;
Sheet *this_sheet; Sheet *this_sheet;
char *old_name, *new_name; char *old_name, *new_name;
...@@ -424,6 +483,8 @@ cb_ok_clicked (GtkWidget *ignore, SheetManager *state) ...@@ -424,6 +483,8 @@ cb_ok_clicked (GtkWidget *ignore, SheetManager *state)
GSList *this_new, *this_old; GSList *this_new, *this_old;
gboolean order_has_changed = FALSE; gboolean order_has_changed = FALSE;
gboolean is_deleted; gboolean is_deleted;
GdkColor *back, *fore;
gboolean fore_changed, back_changed;
while (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (state->model), while (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (state->model),
&this_iter, NULL, n)) { &this_iter, NULL, n)) {
...@@ -432,6 +493,8 @@ cb_ok_clicked (GtkWidget *ignore, SheetManager *state) ...@@ -432,6 +493,8 @@ cb_ok_clicked (GtkWidget *ignore, SheetManager *state)
SHEET_NAME, &old_name, SHEET_NAME, &old_name,
SHEET_NEW_NAME, &new_name, SHEET_NEW_NAME, &new_name,
IS_DELETED, &is_deleted, IS_DELETED, &is_deleted,
BACKGROUND_COLOUR_POINTER, &back,
FOREGROUND_COLOUR_POINTER, &fore,
-1); -1);
if (!is_deleted) { if (!is_deleted) {
new_order = g_slist_prepend (new_order, this_sheet); new_order = g_slist_prepend (new_order, this_sheet);
...@@ -446,11 +509,36 @@ cb_ok_clicked (GtkWidget *ignore, SheetManager *state) ...@@ -446,11 +509,36 @@ cb_ok_clicked (GtkWidget *ignore, SheetManager *state)
g_free (new_name); g_free (new_name);
} }
g_free (old_name); g_free (old_name);
back_changed = (this_sheet == NULL) ||
!sheet_order_gdk_color_equal (back,
this_sheet->tab_color ?
&this_sheet->tab_color->color : NULL);
fore_changed = (this_sheet == NULL) ||
!sheet_order_gdk_color_equal (fore,
this_sheet->tab_text_color ?
&this_sheet->tab_text_color->color : NULL);
if (fore_changed || back_changed) {
color_changed = g_slist_prepend (color_changed, this_sheet);
new_colors_back = g_slist_prepend (new_colors_back, back);