gnumeric r16910 - trunk/src/dialogs
- From: guelzow svn gnome org
- To: svn-commits-list gnome org
- Subject: gnumeric r16910 - trunk/src/dialogs
- Date: Tue, 21 Oct 2008 01:59:58 +0000 (UTC)
Author: guelzow
Date: Tue Oct 21 01:59:58 2008
New Revision: 16910
URL: http://svn.gnome.org/viewvc/gnumeric?rev=16910&view=rev
Log:
2008-10-20 Andreas J. Guelzow <aguelzow pyrshep ca>
* dialog-sheet-order.c (cb_name_edited): enable "apply names"
button as appropriate
(verify_validity): show the correct name
(cb_apply_names_clicked): do not use a dialog
(cb_sheet_order_cnt_visible): make sure that the model contains
up-to-date information
(sheet_order_cnt_visible): we need to pass the state to
cb_sheet_order_cnt_visible
(cb_toggled_visible): don't show a warning if this sheet
is already invisible
(cb_delete_clicked): don't delete the last visible sheet. Note
that sheet_order_cnt_visible may change the visibility
of this sheet.
Modified:
trunk/src/dialogs/ChangeLog
trunk/src/dialogs/dialog-sheet-order.c
Modified: trunk/src/dialogs/dialog-sheet-order.c
==============================================================================
--- trunk/src/dialogs/dialog-sheet-order.c (original)
+++ trunk/src/dialogs/dialog-sheet-order.c Tue Oct 21 01:59:58 2008
@@ -75,6 +75,7 @@
GtkWidget *cancel_btn;
GtkWidget *ccombo_back;
GtkWidget *ccombo_fore;
+ GtkWidget *warning;
GdkPixbuf *image_padlock;
GdkPixbuf *image_padlock_no;
@@ -109,6 +110,9 @@
NUM_COLMNS
};
+static char *verify_validity (SheetManager *state, gboolean *pchanged);
+
+
static void
workbook_signals_block (SheetManager *state)
{
@@ -145,6 +149,8 @@
{
GtkTreeIter iter;
GtkTreePath *path;
+ gboolean changed = FALSE;
+ char *error;
path = gtk_tree_path_new_from_string (path_string);
@@ -157,6 +163,17 @@
}
gtk_tree_path_free (path);
+
+ error = verify_validity (state, &changed);
+
+ if (error != NULL) {
+ gtk_widget_set_sensitive (state->apply_names_btn, FALSE);
+ gtk_label_set_text (GTK_LABEL (state->warning), error);
+ } else {
+ gtk_widget_set_sensitive (state->apply_names_btn, changed);
+ gtk_label_set_markup (GTK_LABEL (state->warning),
+ changed ? _("<b>Note:</b> A sheet name change is pending.") : "");
+ }
}
static gboolean
@@ -404,29 +421,49 @@
}
+typedef struct {
+ int i;
+ SheetManager *state;
+} SheetManager_Vis_Counter;
+
static gboolean
cb_sheet_order_cnt_visible (GtkTreeModel *model,
GtkTreePath *path,
GtkTreeIter *iter,
gpointer data)
{
- int *i = data;
+ SheetManager_Vis_Counter *svc = data;
gboolean is_visible;
+ Sheet *this_sheet;
gtk_tree_model_get (model, iter,
SHEET_VISIBLE, &is_visible,
+ SHEET_POINTER, &this_sheet,
-1);
- return (is_visible && (++(*i)>1));
+ if (is_visible != (this_sheet->visibility == GNM_SHEET_VISIBILITY_VISIBLE)) {
+ gtk_list_store_set (GTK_LIST_STORE (model), iter,
+ SHEET_VISIBLE, (this_sheet->visibility == GNM_SHEET_VISIBILITY_VISIBLE),
+ SHEET_VISIBLE_IMAGE, (this_sheet->visibility == GNM_SHEET_VISIBILITY_VISIBLE
+ ? svc->state->image_visible
+ : NULL),
+ -1);
+ is_visible = (this_sheet->visibility == GNM_SHEET_VISIBILITY_VISIBLE);
+ }
+
+ if (is_visible)
+ (svc->i)++;
+
+ return FALSE;
}
static gint
sheet_order_cnt_visible (SheetManager *state)
{
- gint i = 0;
+ SheetManager_Vis_Counter data = {0, state};
gtk_tree_model_foreach (GTK_TREE_MODEL (state->model),
cb_sheet_order_cnt_visible,
- &i);
- return i;
+ &data);
+ return data.i;
}
static void
@@ -443,6 +480,7 @@
WorkbookSheetState *old_state;
WorkbookControl *wbc = WORKBOOK_CONTROL (state->wbcg);
Workbook *wb = wb_control_get_workbook (wbc);
+ int cnt;
if (!gtk_tree_model_get_iter (model, &iter, path)) {
g_warning ("Did not get a valid iterator");
@@ -456,11 +494,19 @@
-1);
if (is_visible) {
- if (sheet_order_cnt_visible (state) <= 1) {
- go_gtk_notice_dialog (GTK_WINDOW (state->dialog), GTK_MESSAGE_ERROR,
- _("At least one sheet must remain visible!"));
- gtk_tree_path_free (path);
- return;
+ cnt = sheet_order_cnt_visible (state);
+ if (cnt <= 1) {
+ /* Note: sheet_order_cnt_visible may have changed whether this sheet is indeed */
+ /* so we should not post a warning message if the sheet has become invisible. */
+ gtk_tree_model_get (model, &iter,
+ SHEET_VISIBLE, &is_visible,
+ -1);
+ if (is_visible) {
+ go_gtk_notice_dialog (GTK_WINDOW (state->dialog), GTK_MESSAGE_ERROR,
+ _("At least one sheet must remain visible!"));
+ gtk_tree_path_free (path);
+ return;
+ }
}
gtk_list_store_set (GTK_LIST_STORE (model), &iter,
SHEET_VISIBLE, FALSE,
@@ -816,13 +862,15 @@
WorkbookControl *wbc = WORKBOOK_CONTROL (state->wbcg);
Workbook *wb = wb_control_get_workbook (wbc);
gboolean is_visible;
+ int cnt;
if (gtk_tree_selection_get_selected (selection, NULL, &sel_iter)) {
+ cnt = sheet_order_cnt_visible (state);
gtk_tree_model_get (GTK_TREE_MODEL (state->model), &sel_iter,
SHEET_POINTER, &sheet,
SHEET_VISIBLE, &is_visible,
-1);
- if (is_visible && sheet_order_cnt_visible (state) <= 1) {
+ if (is_visible && cnt <= 1) {
go_gtk_notice_dialog (GTK_WINDOW (state->dialog), GTK_MESSAGE_ERROR,
_("At least one sheet must remain visible!"));
return;
@@ -873,8 +921,8 @@
new_name2 = g_utf8_casefold (*new_name != 0 ? new_name : old_name, -1);
if (g_hash_table_lookup (names, new_name2)) {
- result = g_strdup_printf (_("There is more than one sheet named \"%s\""),
- new_name);
+ result = g_strdup_printf (_("You may not call more than one sheet \"%s\"."),
+ *new_name != 0 ? new_name : old_name);
g_free (new_name2);
} else
g_hash_table_insert (names, new_name2, new_name2);
@@ -898,23 +946,10 @@
{
WorkbookControl *wbc = WORKBOOK_CONTROL (state->wbcg);
Workbook *wb = wb_control_get_workbook (wbc);
- char *error;
- gboolean changed;
WorkbookSheetState *old_state;
GtkTreeIter this_iter;
gint n = 0;
- error = verify_validity (state, &changed);
- if (error) {
- go_gtk_notice_dialog (GTK_WINDOW (state->dialog), GTK_MESSAGE_ERROR,
- "%s", error);
- g_free (error);
- return;
- }
-
- if (!changed)
- return;
-
/* Stop listening to changes in the sheet order. */
workbook_signals_block (state);
@@ -1191,6 +1226,7 @@
state->gui = gui;
state->wbcg = wbcg;
state->dialog = glade_xml_get_widget (gui, "sheet-order-dialog");
+ state->warning = glade_xml_get_widget (gui, "warning");
state->up_btn = glade_xml_get_widget (gui, "up_button");
state->down_btn = glade_xml_get_widget (gui, "down_button");
state->add_btn = glade_xml_get_widget (gui, "add_button");
@@ -1283,6 +1319,8 @@
gtk_widget_set_sensitive (state->sort_desc_btn, FALSE);
gtk_widget_set_sensitive (state->undo_btn, FALSE);
+ gtk_widget_set_sensitive (state->apply_names_btn, FALSE);
+
/* a candidate for merging into attach guru */
wbc_gtk_attach_guru (state->wbcg, GTK_WIDGET (state->dialog));
g_object_set_data_full (G_OBJECT (state->dialog),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]