New function to destroy an rc context.

2006-07-21  Matthias Clasen  <mclasen@redhat.com>

	* gtk/gtkrc.h:
	* gtk/gtkrc.c (_gtk_rc_context_destroy): New function to
	destroy an rc context.

	* gtk/gtksettings.c (gtk_settings_finalize): Destroy the rc context.
	(gtk_settings_get_for_screen): Unref the settings when the screen
	goes away. (#348096, Chris Wilson)
This commit is contained in:
Matthias Clasen 2006-07-21 16:12:44 +00:00 committed by Matthias Clasen
parent a0cdff6cca
commit fee9accbd1
5 changed files with 90 additions and 28 deletions

View File

@ -1,3 +1,13 @@
2006-07-21 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkrc.h:
* gtk/gtkrc.c (_gtk_rc_context_destroy): New function to
destroy an rc context.
* gtk/gtksettings.c (gtk_settings_finalize): Destroy the rc context.
(gtk_settings_get_for_screen): Unref the settings when the screen
goes away. (#348096, Chris Wilson)
2006-07-21 Richard Hult <richard@imendio.com>
* gdk/quartz/gdkgc-quartz.c: (gdk_quartz_gc_get_values),
@ -9,11 +19,6 @@
2006-07-21 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkstyle.c:
* gtk/gtkrc.c:
* gtk/gtkwidget.c: Replace gtk_rc_style_ref/unref by
g_object_ref/unref.
* gtk/gtkimcontextsimple.c (gtk_im_context_simple_get_preedit_string):
0-terminate outbuf in all cases. (#348227, Nguyen Thái Ngoc Duy)

View File

@ -1,3 +1,13 @@
2006-07-21 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkrc.h:
* gtk/gtkrc.c (_gtk_rc_context_destroy): New function to
destroy an rc context.
* gtk/gtksettings.c (gtk_settings_finalize): Destroy the rc context.
(gtk_settings_get_for_screen): Unref the settings when the screen
goes away. (#348096, Chris Wilson)
2006-07-21 Richard Hult <richard@imendio.com>
* gdk/quartz/gdkgc-quartz.c: (gdk_quartz_gc_get_values),
@ -9,11 +19,6 @@
2006-07-21 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkstyle.c:
* gtk/gtkrc.c:
* gtk/gtkwidget.c: Replace gtk_rc_style_ref/unref by
g_object_ref/unref.
* gtk/gtkimcontextsimple.c (gtk_im_context_simple_get_preedit_string):
0-terminate outbuf in all cases. (#348227, Nguyen Thái Ngoc Duy)

View File

@ -720,6 +720,70 @@ gtk_rc_context_get (GtkSettings *settings)
return settings->rc_context;
}
static void
gtk_rc_clear_rc_files (GtkRcContext *context)
{
GSList *list;
list = context->rc_files;
while (list)
{
GtkRcFile *rc_file = list->data;
if (rc_file->canonical_name != rc_file->name)
g_free (rc_file->canonical_name);
g_free (rc_file->directory);
g_free (rc_file->name);
g_free (rc_file);
list = list->next;
}
g_slist_free (context->rc_files);
context->rc_files = NULL;
}
void
_gtk_rc_context_destroy (GtkSettings *settings)
{
GtkRcContext *context;
g_return_if_fail (GTK_IS_SETTINGS (settings));
context = settings->rc_context;
if (!context)
return;
_gtk_settings_reset_rc_values (context->settings);
gtk_rc_clear_styles (context);
gtk_rc_clear_rc_files (context);
if (context->default_style)
g_object_unref (context->default_style);
g_strfreev (context->pixmap_path);
g_free (context->theme_name);
g_free (context->key_theme_name);
g_free (context->font_name);
if (context->color_hash)
g_hash_table_unref (context->color_hash);
g_signal_handlers_disconnect_by_func (settings,
gtk_rc_settings_changed, context);
g_signal_handlers_disconnect_by_func (settings,
gtk_rc_font_name_changed, context);
g_signal_handlers_disconnect_by_func (settings,
gtk_rc_color_hash_changed, context);
rc_contexts = g_slist_remove (rc_contexts, context);
g_free (context);
settings->rc_context = NULL;
}
static void
gtk_rc_parse_named (GtkRcContext *context,
const gchar *name,
@ -1646,7 +1710,6 @@ gtk_rc_reparse_all_for_settings (GtkSettings *settings,
GtkRcFile *rc_file;
GSList *tmp_list;
GtkRcContext *context;
struct stat statbuf;
g_return_val_if_fail (GTK_IS_SETTINGS (settings), FALSE);
@ -1684,22 +1747,7 @@ gtk_rc_reparse_all_for_settings (GtkSettings *settings,
context->reloading = TRUE;
_gtk_settings_reset_rc_values (context->settings);
tmp_list = context->rc_files;
while (tmp_list)
{
rc_file = tmp_list->data;
if (rc_file->canonical_name != rc_file->name)
g_free (rc_file->canonical_name);
g_free (rc_file->directory);
g_free (rc_file->name);
g_free (rc_file);
tmp_list = tmp_list->next;
}
g_slist_free (context->rc_files);
context->rc_files = NULL;
gtk_rc_clear_rc_files (context);
gtk_rc_parse_default_files (context);

View File

@ -248,6 +248,7 @@ const GtkRcProperty* _gtk_rc_style_lookup_rc_property (GtkRcStyle *rc_style,
GSList * _gtk_rc_style_get_color_hashes (GtkRcStyle *rc_style);
const gchar* _gtk_rc_context_get_default_font_name (GtkSettings *settings);
void _gtk_rc_context_destroy (GtkSettings *settings);
G_END_DECLS

View File

@ -524,6 +524,8 @@ gtk_settings_finalize (GObject *object)
g_value_unset (&settings->property_values[i].value);
g_free (settings->property_values);
_gtk_rc_context_destroy (settings);
g_datalist_clear (&settings->queued_settings);
G_OBJECT_CLASS (gtk_settings_parent_class)->finalize (object);
@ -551,7 +553,8 @@ gtk_settings_get_for_screen (GdkScreen *screen)
{
settings = g_object_new (GTK_TYPE_SETTINGS, NULL);
settings->screen = screen;
g_object_set_data (G_OBJECT (screen), I_("gtk-settings"), settings);
g_object_set_data_full (G_OBJECT (screen), I_("gtk-settings"),
settings, g_object_unref);
gtk_rc_reparse_all_for_settings (settings, TRUE);
settings_update_double_click (settings);