gnumeric r16909 - trunk/src/dialogs
- From: guelzow svn gnome org
- To: svn-commits-list gnome org
- Subject: gnumeric r16909 - trunk/src/dialogs
- Date: Mon, 20 Oct 2008 22:22:13 +0000 (UTC)
Author: guelzow
Date: Mon Oct 20 22:22:13 2008
New Revision: 16909
URL: http://svn.gnome.org/viewvc/gnumeric?rev=16909&view=rev
Log:
2008-10-20 Andreas J. Guelzow <aguelzow pyrshep ca>
* dialog-sheet-order.c (SheetManager): add new listener
fields
(workbook_signals_block): new
(workbook_signals_unblock): new
replace all g_signal_handler_[un]block referring to
sheet_order_changed_listener with calls to the two above
(cb_sheet_order_destroy): destroy the two new listeners
(dialog_sheet_order_update_sheet_order): the dialog
and the true number of sheets may not match temporarily if
a sheet was just added or deleted.
(cb_sheet_deleted): new
(cb_sheet_added): new
(dialog_sheet_order): setup new listeners
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 Mon Oct 20 22:22:13 2008
@@ -87,6 +87,9 @@
gboolean initial_colors_set;
gulong sheet_order_changed_listener;
+ gulong sheet_added_listener;
+ gulong sheet_deleted_listener;
+
gulong model_selection_changed_listener;
gulong model_row_insertion_listener;
} SheetManager;
@@ -107,6 +110,34 @@
};
static void
+workbook_signals_block (SheetManager *state)
+{
+ WorkbookControl *wbc = WORKBOOK_CONTROL (state->wbcg);
+ Workbook *wb = wb_control_get_workbook (wbc);
+
+ g_signal_handler_block (G_OBJECT (wb),
+ state->sheet_order_changed_listener);
+ g_signal_handler_block (G_OBJECT (wb),
+ state->sheet_added_listener);
+ g_signal_handler_block (G_OBJECT (wb),
+ state->sheet_deleted_listener);
+}
+
+static void
+workbook_signals_unblock (SheetManager *state)
+{
+ WorkbookControl *wbc = WORKBOOK_CONTROL (state->wbcg);
+ Workbook *wb = wb_control_get_workbook (wbc);
+
+ g_signal_handler_unblock (G_OBJECT (wb),
+ state->sheet_order_changed_listener);
+ g_signal_handler_unblock (G_OBJECT (wb),
+ state->sheet_added_listener);
+ g_signal_handler_unblock (G_OBJECT (wb),
+ state->sheet_deleted_listener);
+}
+
+static void
cb_name_edited (G_GNUC_UNUSED GtkCellRendererText *cell,
gchar *path_string,
gchar *new_text,
@@ -682,15 +713,13 @@
index = this_sheet->index_in_wb;
}
- g_signal_handler_block (G_OBJECT (wb),
- state->sheet_order_changed_listener);
+ workbook_signals_block (state);
old_state = workbook_sheet_state_new (wb);
workbook_sheet_add (wb, index);
cmd_reorganize_sheets (wbc, old_state, NULL);
- g_signal_handler_unblock (G_OBJECT (wb),
- state->sheet_order_changed_listener);
+ workbook_signals_unblock (state);
g_signal_handler_block (state->model, state->model_row_insertion_listener);
if (index == -1) {
@@ -716,15 +745,13 @@
GtkTreeIter iter;
Sheet *sheet;
- g_signal_handler_block (G_OBJECT (wb),
- state->sheet_order_changed_listener);
+ workbook_signals_block (state);
old_state = workbook_sheet_state_new (wb);
workbook_sheet_add (wb, -1);
cmd_reorganize_sheets (wbc, old_state, NULL);
- g_signal_handler_unblock (G_OBJECT (wb),
- state->sheet_order_changed_listener);
+ workbook_signals_unblock (state);
sheet = workbook_sheet_by_index (wb, workbook_sheet_count (wb) - 1);
@@ -757,16 +784,16 @@
SHEET_POINTER, &this_sheet,
-1);
- g_signal_handler_block (G_OBJECT (wb),
- state->sheet_order_changed_listener);
+ workbook_signals_block (state);
+
old_state = workbook_sheet_state_new (wb);
index = this_sheet->index_in_wb;
new_sheet = sheet_dup (this_sheet);
workbook_sheet_attach_at_pos (wb, new_sheet, index + 1);
g_signal_emit_by_name (G_OBJECT (wb), "sheet_added", 0);
cmd_reorganize_sheets (wbc, old_state, NULL);
- g_signal_handler_unblock (G_OBJECT (wb),
- state->sheet_order_changed_listener);
+
+ workbook_signals_unblock (state);
g_signal_handler_block (state->model, state->model_row_insertion_listener);
gtk_list_store_insert_after (state->model, &iter, &sel_iter);
@@ -802,15 +829,14 @@
}
gtk_list_store_remove (state->model, &sel_iter);
- g_signal_handler_block (G_OBJECT (wb),
- state->sheet_order_changed_listener);
+
+ workbook_signals_block (state);
old_state = workbook_sheet_state_new (wb);
workbook_sheet_delete (sheet);
cmd_reorganize_sheets (wbc, old_state, NULL);
- g_signal_handler_unblock (G_OBJECT (wb),
- state->sheet_order_changed_listener);
+ workbook_signals_unblock (state);
cb_selection_changed (NULL, state);
}
@@ -890,8 +916,7 @@
return;
/* Stop listening to changes in the sheet order. */
- g_signal_handler_block (G_OBJECT (wb),
- state->sheet_order_changed_listener);
+ workbook_signals_block (state);
old_state = workbook_sheet_state_new (wb);
while (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (state->model),
@@ -920,8 +945,7 @@
cmd_reorganize_sheets (wbc, old_state, NULL);
- g_signal_handler_unblock (G_OBJECT (wb),
- state->sheet_order_changed_listener);
+ workbook_signals_unblock (state);
}
static void
@@ -933,6 +957,12 @@
if (state->sheet_order_changed_listener)
g_signal_handler_disconnect (G_OBJECT (wb),
state->sheet_order_changed_listener);
+ if (state->sheet_added_listener)
+ g_signal_handler_disconnect (G_OBJECT (wb),
+ state->sheet_added_listener);
+ if (state->sheet_deleted_listener)
+ g_signal_handler_disconnect (G_OBJECT (wb),
+ state->sheet_deleted_listener);
if (state->model != NULL) {
g_object_unref (G_OBJECT (state->model));
@@ -978,7 +1008,12 @@
n_sheets = workbook_sheet_count (wb);
n_children = gtk_tree_model_iter_n_children (model, NULL);
- g_return_if_fail (n_sheets == n_children);
+
+ if (n_sheets != n_children) {
+ /* This signal also occurs when sheets are added or deleted. We handle this */
+ /* when those signals arrive. */
+ return;
+ }
for (i = 0; i < n_sheets; i++) {
sheet_wb = workbook_sheet_by_index (wb, i);
@@ -1046,6 +1081,18 @@
dialog_sheet_order_update_sheet_order (state);
}
+static void
+cb_sheet_deleted (Workbook *wb, SheetManager *state)
+{
+ populate_sheet_list (state);
+}
+
+static void
+cb_sheet_added (Workbook *wb, SheetManager *state)
+{
+ populate_sheet_list (state);
+}
+
static void
@@ -1057,8 +1104,7 @@
GtkTreeIter this_iter;
gint n = 0, changes = 0;
- g_signal_handler_block (G_OBJECT (wb),
- state->sheet_order_changed_listener);
+ workbook_signals_block (state);
old_state = workbook_sheet_state_new (wb);
while (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (state->model),
@@ -1079,8 +1125,7 @@
else
workbook_sheet_state_free (old_state);
- g_signal_handler_unblock (G_OBJECT (wb),
- state->sheet_order_changed_listener);
+ workbook_signals_unblock (state);
}
static void
@@ -1183,6 +1228,12 @@
state->sheet_order_changed_listener = g_signal_connect (G_OBJECT (wb),
"sheet_order_changed", G_CALLBACK (cb_sheet_order_changed),
state);
+ state->sheet_added_listener = g_signal_connect (G_OBJECT (wb),
+ "sheet_added", G_CALLBACK (cb_sheet_added),
+ state);
+ state->sheet_deleted_listener = g_signal_connect (G_OBJECT (wb),
+ "sheet_deleted", G_CALLBACK (cb_sheet_deleted),
+ state);
table = GTK_TABLE (glade_xml_get_widget (gui,"sheet_order_buttons_table"));
cg = go_color_group_fetch ("back_color_group",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]