aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
diff options
context:
space:
mode:
authorJP Rosevear <jpr@ximian.com>2003-11-17 01:21:31 +0800
committerJP Rosevear <jpr@src.gnome.org>2003-11-17 01:21:31 +0800
commitccdc51ce37535be6efc345c160d874a1f94ea175 (patch)
tree36d244e7b9e208c70272ed13a2fc0a115e2a22ed /widgets
parent80b2e4700bb8b06089c8b36685366efd9d34b161 (diff)
downloadgsoc2013-evolution-ccdc51ce37535be6efc345c160d874a1f94ea175.tar.gz
gsoc2013-evolution-ccdc51ce37535be6efc345c160d874a1f94ea175.tar.zst
gsoc2013-evolution-ccdc51ce37535be6efc345c160d874a1f94ea175.zip
use find_source_iter and get the selection from the right spot
2003-11-16 JP Rosevear <jpr@ximian.com> * e-source-selector.c (e_source_selector_set_primary_selection): use find_source_iter and get the selection from the right spot (find_source_iter): util function to find the iter given the source (e_source_selector_select_source): signal that the model changed (e_source_selector_unselect_source): ditto svn path=/trunk/; revision=23372
Diffstat (limited to 'widgets')
-rw-r--r--widgets/misc/ChangeLog9
-rw-r--r--widgets/misc/e-source-selector.c82
2 files changed, 66 insertions, 25 deletions
diff --git a/widgets/misc/ChangeLog b/widgets/misc/ChangeLog
index c9721e031e..4a05c1b49e 100644
--- a/widgets/misc/ChangeLog
+++ b/widgets/misc/ChangeLog
@@ -1,3 +1,12 @@
+2003-11-16 JP Rosevear <jpr@ximian.com>
+
+ * e-source-selector.c (e_source_selector_set_primary_selection):
+ use find_source_iter and get the selection from the right spot
+ (find_source_iter): util function to find the iter given the
+ source
+ (e_source_selector_select_source): signal that the model changed
+ (e_source_selector_unselect_source): ditto
+
2003-11-14 JP Rosevear <jpr@ximian.com>
* e-source-selector.h: include e-source stuff from e-d-s
diff --git a/widgets/misc/e-source-selector.c b/widgets/misc/e-source-selector.c
index a6d6c5a0c1..6f55ae2989 100644
--- a/widgets/misc/e-source-selector.c
+++ b/widgets/misc/e-source-selector.c
@@ -102,6 +102,30 @@ unselect_source (ESourceSelector *selector,
g_hash_table_remove (selector->priv->selected_sources, source);
}
+static gboolean
+find_source_iter (ESourceSelector *selector, ESource *source, GtkTreeIter *source_iter)
+{
+ GtkTreeModel *model = GTK_TREE_MODEL (selector->priv->tree_store);
+ GtkTreeIter iter;
+
+ if (gtk_tree_model_get_iter_first (model, &iter)) {
+ do {
+ if (gtk_tree_model_iter_children (model, source_iter, &iter)) {
+ do {
+ void *data;
+
+ gtk_tree_model_get (model, source_iter, 0, &data, -1);
+ g_assert (E_IS_SOURCE (data));
+
+ if (E_SOURCE (data) == source)
+ return TRUE;
+ } while (gtk_tree_model_iter_next (model, source_iter));
+ }
+ } while (gtk_tree_model_iter_next (model, &iter));
+ }
+
+ return FALSE;
+}
/* Setting up the model. */
@@ -594,6 +618,8 @@ void
e_source_selector_select_source (ESourceSelector *selector,
ESource *source)
{
+ GtkTreeIter source_iter;
+
g_return_if_fail (E_IS_SOURCE_SELECTOR (selector));
g_return_if_fail (E_IS_SOURCE (source));
@@ -601,7 +627,17 @@ e_source_selector_select_source (ESourceSelector *selector,
return;
select_source (selector, source);
- g_signal_emit (selector, signals[SELECTION_CHANGED], 0);
+
+ if (find_source_iter (selector, source, &source_iter)) {
+ GtkTreeModel *model = GTK_TREE_MODEL (selector->priv->tree_store);
+ GtkTreePath *path;
+
+ path = gtk_tree_model_get_path (model, &source_iter);
+ gtk_tree_model_row_changed (model, path, &source_iter);
+ gtk_tree_path_free (path);
+
+ g_signal_emit (selector, signals[SELECTION_CHANGED], 0);
+ }
}
/**
@@ -615,6 +651,8 @@ void
e_source_selector_unselect_source (ESourceSelector *selector,
ESource *source)
{
+ GtkTreeIter source_iter;
+
g_return_if_fail (E_IS_SOURCE_SELECTOR (selector));
g_return_if_fail (E_IS_SOURCE (source));
@@ -622,7 +660,17 @@ e_source_selector_unselect_source (ESourceSelector *selector,
return;
unselect_source (selector, source);
- g_signal_emit (selector, signals[SELECTION_CHANGED], 0);
+
+ if (find_source_iter (selector, source, &source_iter)) {
+ GtkTreeModel *model = GTK_TREE_MODEL (selector->priv->tree_store);
+ GtkTreePath *path;
+
+ path = gtk_tree_model_get_path (model, &source_iter);
+ gtk_tree_model_row_changed (model, path, &source_iter);
+ gtk_tree_path_free (path);
+
+ g_signal_emit (selector, signals[SELECTION_CHANGED], 0);
+ }
}
/**
@@ -683,31 +731,15 @@ void
e_source_selector_set_primary_selection (ESourceSelector *selector,
ESource *source)
{
- GtkTreeModel *model = GTK_TREE_MODEL (selector->priv->tree_store);
- GtkTreeIter iter;
+ GtkTreeIter source_iter;
- if (gtk_tree_model_get_iter_first (model, &iter)) {
- do {
- GtkTreeIter children_iter;
-
- if (gtk_tree_model_iter_children (model, &children_iter, &iter)) {
- do {
- void *data;
-
- gtk_tree_model_get (model, &iter, 0, &data, -1);
- g_assert (E_IS_SOURCE (data));
-
- if (E_SOURCE (data) == source) {
- GtkTreeSelection *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (selection));
- gtk_tree_selection_select_iter (selection, &children_iter);
- return;
- }
- } while (gtk_tree_model_iter_next (model, &iter));
- }
- } while (gtk_tree_model_iter_next (model, &iter));
+ if (find_source_iter (selector, source, &source_iter)) {
+ GtkTreeSelection *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (selector));
+ gtk_tree_selection_select_iter (selection, &source_iter);
+ } else {
+ g_warning (G_STRLOC ": Cannot find source %p (%s) in selector %p",
+ source, e_source_peek_name (source), selector);
}
-
- g_warning (G_GNUC_FUNCTION ": Cannot find source %p (%s) in selector %p", source, e_source_peek_name (source), selector);
}
d> * - back out special '-I' handling, it causes problems with the stlport [1]netchild2003-04-183-5/+13 * The new version of icc adds -I include paths before the standard includenetchild2003-04-023-2/+3 * - Update to 7.1.006.netchild2003-03-286-288/+685 * Clear moonlight beckons.ade2003-03-072-1/+1 * Update to 7.0.086.netchild2003-03-062-8/+8 * Update to 7.0.083.netchild2003-02-152-8/+8 * - update to 7.0.082netchild2003-02-1010-21/+78 * Remove the "warning -> error" options for excessive function arguments,netchild2003-01-131-1/+2 * Add missing files for the 7.0.078 update.netchild2003-01-1214-0/+1047 * Update icc to 7.0.078.netchild2003-01-129-1129/+1131 * - fix typo in messagenetchild2002-11-131-2/+3 * - mark BROKEN when linux_devtools or ifc is installednetchild2002-11-091-2/+7 * - Keep up with changes on -current (__sF, elf_i386 -> elf_i386_fbsd).netchild2002-11-084-22/+95 * - link libc_pic.a when compiling with "-KPIC -static"netchild2002-09-226-18/+141 * Add another possible download site (it isn't guaranteed that te file isnetchild2002-09-201-1/+1 * - Update to 6.0.1.304.netchild2002-09-207-48/+65 * - C++ support: fix to work also on -current, work around broken exceptionnetchild2002-09-1711-156/+635 * Fix syntax error in the no distfile case.netchild2002-08-221-1/+1 * - add category: develnetchild2002-08-207-85/+236 * 1) The new icc doesn't respect icc.cfg, solve this issue.netchild2002-08-052-3/+10 * Document the bad interaction with the linux-devtools port.netchild2002-07-151-0/+3 * Update to 6.0.159.netchild2002-07-132-9/+9 * Add another download location.netchild2002-07-021-1/+1 * Get the IGNORE warning working. ${DISTFILES} cannot be referenced inknu2002-06-141-1/+1 * - update to icc 6.0.149netchild2002-06-083-15/+17 * Explict dependancy on version 7 of linux_base is not needed anymore.obrien2002-05-281-2/+1 * Oops, last commit was an old version, this one is at least able to linknetchild2002-05-141-2/+3 * Wrapper script for ld, needed to link native binaries.netchild2002-05-141-0/+65 * 1) Document some steps in the targets of the Makefile.netchild2002-05-142-3/+19 * Corrections to some paths in descriptive messages, no need to bump thenetchild2002-05-142-2/+2 * Update icc from 5.0.1 to 6.0.139.netchild2002-05-135-835/+859 * Unbreak for 4.x.netchild2002-04-241-1/+1 * Style fixes.netchild2002-04-161-8/+8 * Spelling fix.netchild2002-04-161-1/+1 * - reword pkg-descrnetchild2002-04-013-11/+31