[anjuta] sourceview: Don't store the builder for the preferences in a global variable.
- From: Sebastien Granjoux <sgranjoux src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta] sourceview: Don't store the builder for the preferences in a global variable.
- Date: Wed, 28 Nov 2012 20:38:50 +0000 (UTC)
commit 109066e642d9ede5f6ed01b1316e5a95e3ea3348
Author: Carl-Anton Ingmarsson <ca ingmarsson gmail com>
Date: Wed Nov 28 21:06:12 2012 +0100
sourceview: Don't store the builder for the preferences in a global variable.
There's no need to keep the builder alive since anjuta_preferences_add_from_builder()
will keep the widgets alive and we can just store all the widgets we want to interact with
in the plugin object.
This fixes a crasher when more than one preferences window is used at the same time for
different windows.
https://bugzilla.gnome.org/show_bug.cgi?id=689054
plugins/sourceview/plugin.c | 21 ++++++++++-----------
plugins/sourceview/plugin.h | 1 +
2 files changed, 11 insertions(+), 11 deletions(-)
---
diff --git a/plugins/sourceview/plugin.c b/plugins/sourceview/plugin.c
index 7187db6..f1c90e1 100644
--- a/plugins/sourceview/plugin.c
+++ b/plugins/sourceview/plugin.c
@@ -51,8 +51,6 @@
static gpointer parent_class;
-static GtkBuilder* builder = NULL;
-
static void
on_editor_linenos_activate (GtkAction *action, gpointer user_data)
{
@@ -153,11 +151,9 @@ ui_states_init (SourceviewPlugin* plugin, AnjutaUI *ui)
static void
-on_font_check_toggled(GtkToggleButton* button, GtkBuilder* builder)
+on_font_check_toggled(GtkToggleButton* button, SourceviewPlugin* plugin)
{
- GtkWidget* font_button;
- font_button = GTK_WIDGET (gtk_builder_get_object (builder, FONT_BUTTON));
- gtk_widget_set_sensitive(font_button, !gtk_toggle_button_get_active(button));
+ gtk_widget_set_sensitive(plugin->font_button, !gtk_toggle_button_get_active(button));
}
static gboolean
@@ -350,6 +346,8 @@ ipreferences_merge(IAnjutaPreferences* ipref, AnjutaPreferences* prefs, GError**
GtkCellRenderer* renderer_desc = gtk_cell_renderer_text_new ();
GtkTreeIter* iter = NULL;
GError* error = NULL;
+ GtkBuilder *builder;
+
builder = gtk_builder_new ();
if (!gtk_builder_add_from_file(builder, PREFS_GLADE, &error))
{
@@ -364,11 +362,12 @@ ipreferences_merge(IAnjutaPreferences* ipref, AnjutaPreferences* prefs, GError**
_("GtkSourceView Editor"),
ICON_FILE);
+ plugin->font_button = GTK_WIDGET (gtk_builder_get_object (builder, FONT_BUTTON));
plugin->check_font = GTK_WIDGET (gtk_builder_get_object (builder,
FONT_USE_THEME_BUTTON));
g_signal_connect(G_OBJECT(plugin->check_font), "toggled",
G_CALLBACK(on_font_check_toggled), builder);
- on_font_check_toggled (GTK_TOGGLE_BUTTON (plugin->check_font), builder);
+ on_font_check_toggled (GTK_TOGGLE_BUTTON (plugin->check_font), plugin);
/* Init styles combo */
plugin->combo_styles = GTK_WIDGET (gtk_builder_get_object (builder, COMBO_STYLES));
@@ -391,6 +390,8 @@ ipreferences_merge(IAnjutaPreferences* ipref, AnjutaPreferences* prefs, GError**
iter);
gtk_tree_iter_free (iter);
}
+
+ g_object_unref (builder);
}
static void
@@ -398,13 +399,11 @@ ipreferences_unmerge(IAnjutaPreferences* ipref, AnjutaPreferences* prefs, GError
{
SourceviewPlugin* plugin = ANJUTA_PLUGIN_SOURCEVIEW (ipref);
g_signal_handlers_disconnect_by_func(G_OBJECT(plugin->check_font),
- G_CALLBACK(on_font_check_toggled), builder);
+ G_CALLBACK(on_font_check_toggled), plugin);
g_signal_handlers_disconnect_by_func(G_OBJECT(plugin->combo_styles),
- G_CALLBACK(on_style_changed), builder);
+ G_CALLBACK(on_style_changed), plugin);
anjuta_preferences_remove_page(prefs, _("GtkSourceView Editor"));
- g_object_unref(builder);
- builder = NULL;
}
static void
diff --git a/plugins/sourceview/plugin.h b/plugins/sourceview/plugin.h
index 0fa3d36..e773818 100644
--- a/plugins/sourceview/plugin.h
+++ b/plugins/sourceview/plugin.h
@@ -42,6 +42,7 @@ struct _SourceviewPlugin{
AnjutaPlugin parent;
GtkWidget* combo_styles;
+ GtkWidget* font_button;
GtkWidget* check_font;
GSettings* settings;
GtkActionGroup *group;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]