[gnome-video-arcade] Fix columns not being remembered.
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-video-arcade] Fix columns not being remembered.
- Date: Mon, 25 Apr 2011 13:16:04 +0000 (UTC)
commit 78ef8a136288fc1b2d7382254e28f3345d32864d
Author: Matthew Barnes <mbarnes redhat com>
Date: Mon Apr 25 08:55:47 2011 -0400
Fix columns not being remembered.
As a GtkTreeView destroys its own columns during dispose() it emits
"columns-changed" signals. We normally listen for that signal and save
the column names to GSettings, but obviously we don't want to do that
while the tree view is being disposed. This was causing the "columns"
key in GSettings to be empty after every program exit.
With GTK2 I was checking the GtkTreeView's GTK_IN_DESTRUCTION flag to
know when to ignore the signals. With that flag gone in GTK3 I had left
that bit of code commented out, not remembering what it was for. This
uses a different approach to achieve the same thing -- though it's not
any cleaner than before, unfortunately.
I had the idea of writing a custom GtkTreeView subclass to deal with
this and to make it more of a self-contained widget, but the main tree
view is tangled up into *everything*. Would need sorting out. Too big
a job for now.
data/gnome-video-arcade.builder | 1 -
src/gva-columns.c | 33 ++++++++++++++++++---------------
2 files changed, 18 insertions(+), 16 deletions(-)
---
diff --git a/data/gnome-video-arcade.builder b/data/gnome-video-arcade.builder
index d571c98..e6021d8 100644
--- a/data/gnome-video-arcade.builder
+++ b/data/gnome-video-arcade.builder
@@ -561,7 +561,6 @@
<property name="rules_hint">True</property>
<property name="show_expanders">False</property>
<signal name="button-press-event" handler="gva_tree_view_button_press_event_cb" swapped="no"/>
- <signal name="columns-changed" handler="gva_columns_save" swapped="no"/>
<signal name="row-activated" handler="gva_tree_view_row_activated_cb" swapped="no"/>
<signal name="query-tooltip" handler="gva_tree_view_query_tooltip_cb" swapped="no"/>
<signal name="popup-menu" handler="gva_tree_view_popup_menu_cb" swapped="no"/>
diff --git a/src/gva-columns.c b/src/gva-columns.c
index f3a1552..0914404 100644
--- a/src/gva-columns.c
+++ b/src/gva-columns.c
@@ -1206,6 +1206,17 @@ columns_load_remove_name (GList **p_list, const gchar *name)
return TRUE;
}
+/* Helper for gva_columns_load() */
+static void
+columns_tree_view_destroy_cb (GtkTreeView *tree_view)
+{
+ /* GtkTreeView emits "column-changed" signals as it destroys
+ * its own columns. We don't want those emissions to trigger
+ * gva_columns_save(). */
+ g_signal_handlers_disconnect_by_func (
+ tree_view, gva_columns_save, NULL);
+}
+
/**
* gva_columns_load:
* @view: a #GtkTreeView
@@ -1232,12 +1243,6 @@ gva_columns_load (GtkTreeView *view)
g_return_if_fail (GTK_IS_TREE_VIEW (view));
- /* Adding columns to the tree view will cause it to emit
- * "columns-changed" signals, for which gva_columns_save() is a
- * handler. Prevent the handler from modifying GSettings keys
- * while we're loading. */
- g_signal_handlers_block_by_func (view, gva_columns_save, NULL);
-
settings = gva_get_settings ();
g_settings_get (settings, GVA_SETTING_ALL_COLUMNS, "as", &iter);
@@ -1339,7 +1344,13 @@ gva_columns_load (GtkTreeView *view)
}
}
- g_signal_handlers_unblock_by_func (view, gva_columns_save, NULL);
+ g_signal_connect (
+ view, "columns-changed",
+ G_CALLBACK (gva_columns_save), NULL);
+
+ g_signal_connect (
+ view, "destroy",
+ G_CALLBACK (columns_tree_view_destroy_cb), NULL);
gva_columns_save (view);
}
@@ -1362,14 +1373,6 @@ gva_columns_save (GtkTreeView *view)
g_return_if_fail (GTK_IS_TREE_VIEW (view));
-#if 0
- /* This function is also a "columns-changed" signal handler.
- * Abort the save if the tree view is being destroyed.
- * FIXME Needs to be adapted to gtk+-3.0. */
- if (GTK_OBJECT_FLAGS (view) & GTK_IN_DESTRUCTION)
- return;
-#endif
-
settings = gva_get_settings ();
g_variant_builder_init (&builder, (GVariantType *) "as");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]