[gnumeric] add remove button to conditional formatting dialog



commit 9fd6aed1483efec5663d405c2d04872b260c36e9
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Fri Jul 8 02:59:05 2011 -0600

    add remove button to conditional formatting dialog
    
    2011-07-08  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* src/style-conditions.c (gnm_style_conditions_delete): new
    	* src/style-conditions.h (gnm_style_conditions_delete): new
    
    2011-07-08  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* dialog-cell-format-cond.c (cb_c_fmt_dialog_remove_clicked): implement
    	(c_fmt_dialog_init_conditions_page): do not hide the remove button

 ChangeLog                             |    5 +++
 src/dialogs/ChangeLog                 |    5 +++
 src/dialogs/dialog-cell-format-cond.c |   44 +++++++++++++++++++++++++++-----
 src/style-conditions.c                |   13 +++++++++
 src/style-conditions.h                |    2 +
 5 files changed, 62 insertions(+), 7 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 90dc368..9b6fe07 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2011-07-08  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+	* src/style-conditions.c (gnm_style_conditions_delete): new
+	* src/style-conditions.h (gnm_style_conditions_delete): new
+
 2011-07-07  Andreas J. Guelzow <aguelzow pyrshep ca>
 
 	* src/rendered-value.c (gnm_rendered_value_new): consider conditional
diff --git a/src/dialogs/ChangeLog b/src/dialogs/ChangeLog
index e33e7f1..cc12bee 100644
--- a/src/dialogs/ChangeLog
+++ b/src/dialogs/ChangeLog
@@ -1,5 +1,10 @@
 2011-07-08  Andreas J. Guelzow <aguelzow pyrshep ca>
 
+	* dialog-cell-format-cond.c (cb_c_fmt_dialog_remove_clicked): implement
+	(c_fmt_dialog_init_conditions_page): do not hide the remove button
+	
+2011-07-08  Andreas J. Guelzow <aguelzow pyrshep ca>
+
 	* cell-format-cond-def.ui: enable border checkbox
 	* dialog-cell-format-cond.c (cb_c_fmt_dialog_chooser_buttons): handle
 	border items
diff --git a/src/dialogs/dialog-cell-format-cond.c b/src/dialogs/dialog-cell-format-cond.c
index c3a5bcd..ad5d398 100644
--- a/src/dialogs/dialog-cell-format-cond.c
+++ b/src/dialogs/dialog-cell-format-cond.c
@@ -613,12 +613,6 @@ cb_c_fmt_dialog_add_clicked (G_GNUC_UNUSED GtkButton *button, CFormatState *stat
 }
 
 static void
-cb_c_fmt_dialog_remove_clicked (G_GNUC_UNUSED GtkButton *button, CFormatState *state)
-{
-	c_fmt_dialog_load (state);
-}
-
-static void
 cb_c_fmt_dialog_clear_clicked (G_GNUC_UNUSED GtkButton *button, CFormatState *state)
 {
 	state->action.new_style = gnm_style_new ();
@@ -633,6 +627,43 @@ cb_c_fmt_dialog_clear_clicked (G_GNUC_UNUSED GtkButton *button, CFormatState *st
 }
 
 static void
+cb_c_fmt_dialog_remove_clicked (GtkButton *button, CFormatState *state)
+{
+	if (1 == gtk_tree_model_iter_n_children (GTK_TREE_MODEL (state->model), NULL))
+		cb_c_fmt_dialog_clear_clicked (button, state);
+	else {
+		GtkTreeIter iter;
+		if (gtk_tree_selection_get_selected (state->selection, NULL, &iter)) {
+			GtkTreePath *path = gtk_tree_model_get_path 
+				(GTK_TREE_MODEL (state->model), &iter);
+			gint *ind = gtk_tree_path_get_indices (path);
+			if (ind) {
+				GnmStyleConditions *sc;
+				sc = gnm_style_conditions_dup 
+					(gnm_style_get_conditions (state->style));
+				if (sc != NULL) {
+					gnm_style_conditions_delete (sc, *ind);
+					state->action.new_style = gnm_style_new ();
+					gnm_style_set_conditions 
+						(state->action.new_style, sc);
+					
+					c_fmt_dialog_set_conditions 
+						(state, 
+						 _("Remove instance from conditional "
+						   "formatting"));
+
+					gnm_style_unref (state->action.new_style);
+					state->action.new_style = NULL;
+
+					c_fmt_dialog_load (state);
+				}
+			}
+			gtk_tree_path_free (path);
+		}
+	}
+}
+
+static void
 cb_c_fmt_dialog_expand_clicked (G_GNUC_UNUSED GtkButton *button, CFormatState *state)
 {
 	c_fmt_dialog_load (state);
@@ -1057,7 +1088,6 @@ c_fmt_dialog_init_conditions_page (CFormatState *state)
 	g_signal_connect (G_OBJECT (state->edit), "clicked",
 			  G_CALLBACK (cb_c_fmt_dialog_edit_clicked), state);
 	
-	gtk_widget_hide (GTK_WIDGET (state->remove)); 
 	gtk_widget_hide (GTK_WIDGET (state->expand)); 
 	gtk_widget_hide (GTK_WIDGET (state->edit)); 
 }
diff --git a/src/style-conditions.c b/src/style-conditions.c
index f50073a..411c497 100644
--- a/src/style-conditions.c
+++ b/src/style-conditions.c
@@ -194,6 +194,19 @@ gnm_style_conditions_insert (GnmStyleConditions *sc,
 		g_array_insert_val (sc->conditions, pos, *cond);
 }
 
+void 
+gnm_style_conditions_delete  (GnmStyleConditions *sc,
+			      guint pos)
+{
+	g_return_if_fail (sc != NULL);
+	g_return_if_fail (sc->conditions != NULL);
+	g_return_if_fail (sc->conditions->len > pos);
+
+	cond_unref (&g_array_index (sc->conditions, GnmStyleCond, pos));
+	g_array_remove_index (sc->conditions, pos);
+}
+
+
 GPtrArray *
 gnm_style_conditions_overlay (GnmStyleConditions const *sc,
 			      GnmStyle const *base)
diff --git a/src/style-conditions.h b/src/style-conditions.h
index 5a9fc54..d6d533d6 100644
--- a/src/style-conditions.h
+++ b/src/style-conditions.h
@@ -48,6 +48,8 @@ GArray const *gnm_style_conditions_details (GnmStyleConditions const *sc);
 void	      gnm_style_conditions_insert  (GnmStyleConditions *sc,
 					    GnmStyleCond const *cond,
 					    int pos);
+void	      gnm_style_conditions_delete  (GnmStyleConditions *sc,
+					    guint pos);
 GPtrArray    *gnm_style_conditions_overlay (GnmStyleConditions const *sc,
 					    GnmStyle const *base);
 int	      gnm_style_conditions_eval    (GnmStyleConditions const *sc,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]