Scroll to the newly added row. (rule_delete): Scroll to the selected row.

2003-01-03  Jeffrey Stedfast  <fejj@ximian.com>

	* rule-editor.c (add_editor_response): Scroll to the newly added
	row.
	(rule_delete): Scroll to the selected row.
	(rule_move): After moving the row, re-select it and then scroll to
	make sure that it is still visible.

svn path=/trunk/; revision=19226
This commit is contained in:
Jeffrey Stedfast
2003-01-03 20:00:46 +00:00
committed by Jeffrey Stedfast
parent 589d5c074b
commit 4aa0c65063
2 changed files with 41 additions and 10 deletions

View File

@ -1,3 +1,11 @@
2003-01-03 Jeffrey Stedfast <fejj@ximian.com>
* rule-editor.c (add_editor_response): Scroll to the newly added
row.
(rule_delete): Scroll to the selected row.
(rule_move): After moving the row, re-select it and then scroll to
make sure that it is still visible.
2003-01-02 Jeffrey Stedfast <fejj@ximian.com>
Fixed to build with -DG_DISABLE_DEPRECATED and

View File

@ -254,6 +254,11 @@ add_editor_response (GtkWidget *dialog, int button, RuleEditor *re)
selection = gtk_tree_view_get_selection (re->list);
gtk_tree_selection_select_iter (selection, &iter);
/* scroll to the newly added row */
path = gtk_tree_model_get_path ((GtkTreeModel *) re->model, &iter);
gtk_tree_view_scroll_to_cell (re->list, path, NULL, TRUE, 1.0, 0.0);
gtk_tree_path_free (path);
re->current = re->edit;
rule_context_add_rule (re->context, re->current);
@ -405,6 +410,7 @@ rule_delete (GtkWidget *widget, RuleEditor *re)
len = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (re->model), NULL);
pos = pos >= len ? len - 1 : pos;
if (pos >= 0) {
path = gtk_tree_path_new ();
gtk_tree_path_append_index (path, pos);
gtk_tree_model_get_iter (GTK_TREE_MODEL (re->model), &iter, path);
@ -412,6 +418,12 @@ rule_delete (GtkWidget *widget, RuleEditor *re)
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (re->list));
gtk_tree_selection_select_iter (selection, &iter);
/* scroll to the selected row */
path = gtk_tree_model_get_path ((GtkTreeModel *) re->model, &iter);
gtk_tree_view_scroll_to_cell (re->list, path, NULL, FALSE, 0.0, 0.0);
gtk_tree_path_free (path);
}
}
rule_editor_set_sensitive (re);
@ -440,11 +452,22 @@ rule_move (RuleEditor *re, int from, int to)
gtk_tree_model_get (GTK_TREE_MODEL (re->model), &iter, 1, &rule, -1);
g_assert (rule != NULL);
/* remove and then re-insert the row at the new location */
gtk_list_store_remove (re->model, &iter);
gtk_list_store_insert (re->model, &iter, to);
/* set the data on the row */
gtk_list_store_set (re->model, &iter, 0, rule->name, 1, rule, -1);
/* select the row */
selection = gtk_tree_view_get_selection (re->list);
gtk_tree_selection_select_iter (selection, &iter);
/* scroll to the selected row */
path = gtk_tree_model_get_path ((GtkTreeModel *) re->model, &iter);
gtk_tree_view_scroll_to_cell (re->list, path, NULL, FALSE, 0.0, 0.0);
gtk_tree_path_free (path);
rule_editor_set_sensitive (re);
}