Commit c71f1615 authored by Paolo Borelli's avatar Paolo Borelli Committed by Paolo Borelli

Fix refcounting of objects obtained from gtkbuilder

2008-08-10  Paolo Borelli  <pborelli@katamail.com>

        * plugins/spell/gedit-spell-checker-dialog.c:
        * plugins/spell/gedit-spell-language-dialog.c:
        * plugins/time/gedit-time-plugin.c:
        * gedit/gedit-tab.c:
        * gedit/gedit-utils.c:
        * gedit/dialogs/gedit-open-location-dialog.c:
        * gedit/dialogs/gedit-encodings-dialog.c:
        * gedit/dialogs/gedit-preferences-dialog.c:
        * gedit/dialogs/gedit-style-scheme-dialog.c:
        * gedit/dialogs/gedit-search-dialog.c:

        Fix refcounting of objects obtained from gtkbuilder


svn path=/trunk/; revision=6379
parent 7ac8b697
2008-08-10 Paolo Borelli <pborelli@katamail.com>
* plugins/spell/gedit-spell-checker-dialog.c:
* plugins/spell/gedit-spell-language-dialog.c:
* plugins/time/gedit-time-plugin.c:
* gedit/gedit-tab.c:
* gedit/gedit-utils.c:
* gedit/dialogs/gedit-open-location-dialog.c:
* gedit/dialogs/gedit-encodings-dialog.c:
* gedit/dialogs/gedit-preferences-dialog.c:
* gedit/dialogs/gedit-style-scheme-dialog.c:
* gedit/dialogs/gedit-search-dialog.c:
Fix refcounting of objects obtained from gtkbuilder
2008-08-10 Paolo Borelli <pborelli@katamail.com>
* gedit/gedit-tab.c:
......
......@@ -357,6 +357,7 @@ gedit_encodings_dialog_init (GeditEncodingsDialog *dlg)
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox),
content, TRUE, TRUE, 0);
g_object_unref (content);
gtk_container_set_border_width (GTK_CONTAINER (content), 5);
g_signal_connect (dlg->priv->add_button,
......
......@@ -208,6 +208,7 @@ gedit_open_location_dialog_init (GeditOpenLocationDialog *dlg)
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox),
content, FALSE, FALSE, 0);
g_object_unref (content);
gtk_container_set_border_width (GTK_CONTAINER (content), 5);
}
......
......@@ -1148,7 +1148,7 @@ gedit_preferences_dialog_init (GeditPreferencesDialog *dlg)
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox),
dlg->priv->notebook, FALSE, FALSE, 0);
g_object_unref (dlg->priv->notebook);
gtk_container_set_border_width (GTK_CONTAINER (dlg->priv->notebook), 5);
setup_editor_page (dlg);
......
......@@ -438,7 +438,8 @@ gedit_search_dialog_init (GeditSearchDialog *dlg)
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox),
content, FALSE, FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER (content), 5);
g_object_unref (content);
gtk_container_set_border_width (GTK_CONTAINER (content), 5);
g_signal_connect (dlg->priv->search_text_entry,
"insert_text",
......
......@@ -188,6 +188,7 @@ gedit_style_scheme_dialog_init (GeditStyleSchemeDialog *dlg)
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox),
main_vbox,
FALSE, FALSE, 0);
g_objet_unref (main_vbox);
}
static void
......
......@@ -510,8 +510,8 @@ open_location_dialog_response_cb (GeditOpenLocationDialog *dlg,
GeditWindow *window)
{
GFile *location;
GSList *uris = NULL;
const GeditEncoding *encoding;
GSList *uris = NULL;
gedit_debug (DEBUG_COMMANDS);
......@@ -525,17 +525,25 @@ open_location_dialog_response_cb (GeditOpenLocationDialog *dlg,
location = gedit_open_location_dialog_get_location (dlg);
encoding = gedit_open_location_dialog_get_encoding (dlg);
uris = g_slist_prepend (uris, g_file_get_uri (location));
if (location != NULL)
{
uris = g_slist_prepend (uris, g_file_get_uri (location));
g_object_unref (location);
}
gtk_widget_destroy (GTK_WIDGET (dlg));
gedit_commands_load_uris (window,
uris,
encoding,
0);
if (uris != NULL)
{
gedit_commands_load_uris (window,
uris,
encoding,
0);
g_slist_foreach (uris, (GFunc) g_free, NULL);
g_slist_free (uris);
g_slist_foreach (uris, (GFunc) g_free, NULL);
g_slist_free (uris);
}
}
void
......
......@@ -1911,7 +1911,9 @@ _gedit_tab_get_icon (GeditTab *tab)
location = gedit_document_get_location (doc);
pixbuf = get_icon (theme, location, icon_size);
g_object_unref (location);
if (location)
g_object_unref (location);
}
}
......
......@@ -1069,7 +1069,7 @@ gedit_utils_get_ui_objects (const gchar *filename,
gtk_builder_add_from_file (builder,
filename,
&error);
if (error != NULL)
{
*error_widget = handle_builder_error (_("Unable to open ui file %s. Error: %s"),
......@@ -1077,18 +1077,18 @@ gedit_utils_get_ui_objects (const gchar *filename,
error->message);
g_error_free (error);
g_free (filename_markup);
return FALSE;
}
va_start (args, object_name);
for (name = object_name; name; name = va_arg (args, const gchar *) )
{
GObject **gobj;
gobj = va_arg (args, GObject **);
*gobj = gtk_builder_get_object (builder, name);
if (!*gobj)
{
*error_widget = handle_builder_error (_("Unable to find the object '%s' inside file %s."),
......@@ -1097,8 +1097,21 @@ gedit_utils_get_ui_objects (const gchar *filename,
ret = FALSE;
break;
}
g_object_ref (*gobj);
/* we return a new ref for the root objects,
* the others are already reffed by their parent root object */
if (root_objects != NULL)
{
gint i;
for (i = 0; root_objects[i] != NULL; ++i)
{
if ((strcmp (name, root_objects[i]) == 0))
{
g_object_ref (*gobj);
}
}
}
}
va_end (args);
......
......@@ -273,6 +273,7 @@ gedit_spell_checker_dialog_init (GeditSpellCheckerDialog *dlg)
gtk_label_set_label (GTK_LABEL (dlg->language_label), "");
gtk_container_add (GTK_CONTAINER (dlg), content);
g_object_unref (content);
gtk_window_set_resizable (GTK_WINDOW (dlg), FALSE);
gtk_window_set_title (GTK_WINDOW (dlg), _("Check Spelling"));
......@@ -292,12 +293,11 @@ gedit_spell_checker_dialog_init (GeditSpellCheckerDialog *dlg)
gtk_tree_view_append_column (GTK_TREE_VIEW (dlg->suggestions_list), column);
gtk_tree_view_set_search_column (GTK_TREE_VIEW (dlg->suggestions_list),
COLUMN_SUGGESTIONS);
COLUMN_SUGGESTIONS);
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dlg->suggestions_list));
gtk_tree_selection_set_mode (selection,
GTK_SELECTION_SINGLE);
gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
/* Set default button */
GTK_WIDGET_SET_FLAGS (dlg->change_button, GTK_CAN_DEFAULT);
......@@ -306,28 +306,26 @@ gedit_spell_checker_dialog_init (GeditSpellCheckerDialog *dlg)
gtk_entry_set_activates_default (GTK_ENTRY (dlg->word_entry), TRUE);
/* Connect signals */
g_signal_connect (G_OBJECT (dlg->word_entry), "changed",
g_signal_connect (dlg->word_entry, "changed",
G_CALLBACK (word_entry_changed_handler), dlg);
g_signal_connect (G_OBJECT (dlg->close_button), "clicked",
g_signal_connect (dlg->close_button, "clicked",
G_CALLBACK (close_button_clicked_handler), dlg);
g_signal_connect (selection, "changed",
G_CALLBACK (suggestions_list_selection_changed_handler),
dlg);
g_signal_connect (G_OBJECT (dlg->check_word_button), "clicked",
g_signal_connect (dlg->check_word_button, "clicked",
G_CALLBACK (check_word_button_clicked_handler), dlg);
g_signal_connect (G_OBJECT (dlg->add_word_button), "clicked",
g_signal_connect (dlg->add_word_button, "clicked",
G_CALLBACK (add_word_button_clicked_handler), dlg);
g_signal_connect (G_OBJECT (dlg->ignore_button), "clicked",
g_signal_connect (dlg->ignore_button, "clicked",
G_CALLBACK (ignore_button_clicked_handler), dlg);
g_signal_connect (G_OBJECT (dlg->ignore_all_button), "clicked",
g_signal_connect (dlg->ignore_all_button, "clicked",
G_CALLBACK (ignore_all_button_clicked_handler), dlg);
g_signal_connect (G_OBJECT (dlg->change_button), "clicked",
g_signal_connect (dlg->change_button, "clicked",
G_CALLBACK (change_button_clicked_handler), dlg);
g_signal_connect (G_OBJECT (dlg->change_all_button), "clicked",
g_signal_connect (dlg->change_all_button, "clicked",
G_CALLBACK (change_all_button_clicked_handler), dlg);
g_signal_connect (G_OBJECT (dlg->suggestions_list), "row-activated",
g_signal_connect (dlg->suggestions_list, "row-activated",
G_CALLBACK (suggestions_list_row_activated_handler), dlg);
}
......
......@@ -155,7 +155,6 @@ gedit_spell_language_dialog_init (GeditSpellLanguageDialog *dlg)
ret = gedit_utils_get_ui_objects (GEDIT_UIDIR "languages-dialog.ui",
root_objects,
&error_widget,
"content", &content,
"languages_treeview", &dlg->languages_treeview,
NULL);
......@@ -172,7 +171,7 @@ gedit_spell_language_dialog_init (GeditSpellLanguageDialog *dlg)
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox),
content, TRUE, TRUE, 0);
g_object_unref (content);
gtk_container_set_border_width (GTK_CONTAINER (content), 5);
dlg->model = GTK_TREE_MODEL (gtk_list_store_new (ENCODING_NUM_COLS,
......
......@@ -845,6 +845,7 @@ get_configure_dialog (GeditTimePlugin *plugin)
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog->dialog)->vbox),
content, FALSE, FALSE, 0);
g_object_unref (content);
gtk_container_set_border_width (GTK_CONTAINER (content), 5);
gtk_dialog_set_default_response (GTK_DIALOG (dialog->dialog),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment