From: Matthias Clasen Date: Tue, 15 Aug 2006 18:11:13 +0000 (+0000) Subject: Don't store GSource pointers, but ids. (gtk_file_chooser_entry_dispose): X-Git-Url: http://pileus.org/git/?p=~andy%2Fgtk;a=commitdiff_plain;h=ce94b03def34e32f223700c198a55d930f1d1759 Don't store GSource pointers, but ids. (gtk_file_chooser_entry_dispose): 2006-08-15 Matthias Clasen * gtk/gtkfilechooserentry.c (struct _GtkFileChooserEntry): Don't store GSource pointers, but ids. (gtk_file_chooser_entry_dispose): Remove idles. (idle_add, idle_add): Factor this out. (gtk_file_chooser_entry_maybe_update_directory): (add_completion_idle): And use it here. (#350039, Chris Wilson) --- diff --git a/ChangeLog b/ChangeLog index bba27499e..72b55a069 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2006-08-15 Matthias Clasen + * gtk/gtkfilechooserentry.c (struct _GtkFileChooserEntry): Don't + store GSource pointers, but ids. + (gtk_file_chooser_entry_dispose): Remove idles. + (idle_add, idle_add): Factor this out. + (gtk_file_chooser_entry_maybe_update_directory): + (add_completion_idle): And use it here. (#350039, Chris Wilson) + * gtk/gtkicontheme.c (do_theme_change): Run the reset_styles idle at a priority higher than size negotiation. (#350517, Søren Sandmann) diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index bba27499e..72b55a069 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,5 +1,12 @@ 2006-08-15 Matthias Clasen + * gtk/gtkfilechooserentry.c (struct _GtkFileChooserEntry): Don't + store GSource pointers, but ids. + (gtk_file_chooser_entry_dispose): Remove idles. + (idle_add, idle_add): Factor this out. + (gtk_file_chooser_entry_maybe_update_directory): + (add_completion_idle): And use it here. (#350039, Chris Wilson) + * gtk/gtkicontheme.c (do_theme_change): Run the reset_styles idle at a priority higher than size negotiation. (#350517, Søren Sandmann) diff --git a/gtk/gtkfilechooserentry.c b/gtk/gtkfilechooserentry.c index c4924542c..221230483 100644 --- a/gtk/gtkfilechooserentry.c +++ b/gtk/gtkfilechooserentry.c @@ -51,8 +51,8 @@ struct _GtkFileChooserEntry GtkFilePath *current_folder_path; gchar *file_part; gint file_part_pos; - GSource *check_completion_idle; - GSource *load_directory_idle; + guint check_completion_idle; + guint load_directory_idle; GtkFileFolder *current_folder; GtkFileSystemHandle *load_folder_handle; @@ -214,6 +214,18 @@ gtk_file_chooser_entry_dispose (GObject *object) chooser_entry->file_system = NULL; } + if (chooser_entry->check_completion_idle) + { + g_source_remove (chooser_entry->check_completion_idle); + chooser_entry->check_completion_idle = 0; + } + + if (chooser_entry->load_directory_idle) + { + g_source_remove (chooser_entry->load_directory_idle); + chooser_entry->load_directory_idle = 0; + } + G_OBJECT_CLASS (_gtk_file_chooser_entry_parent_class)->dispose (object); } @@ -492,7 +504,7 @@ check_completion_callback (GtkFileChooserEntry *chooser_entry) g_assert (chooser_entry->file_part); - chooser_entry->check_completion_idle = NULL; + chooser_entry->check_completion_idle = 0; if (strcmp (chooser_entry->file_part, "") == 0) goto done; @@ -512,19 +524,30 @@ check_completion_callback (GtkFileChooserEntry *chooser_entry) return FALSE; } +static guint +idle_add (GtkFileChooserEntry *chooser_entry, + GCallback cb) +{ + GSource *source; + guint id; + + source = g_idle_source_new (); + g_source_set_priority (source, G_PRIORITY_HIGH); + g_source_set_closure (source, + g_cclosure_new_object (cb, G_OBJECT (chooser_entry))); + id = g_source_attach (source, NULL); + g_source_unref (source); + + return id; +} + static void add_completion_idle (GtkFileChooserEntry *chooser_entry) { /* idle to update the selection based on the file list */ - if (chooser_entry->check_completion_idle == NULL) - { - chooser_entry->check_completion_idle = g_idle_source_new (); - g_source_set_priority (chooser_entry->check_completion_idle, G_PRIORITY_HIGH); - g_source_set_closure (chooser_entry->check_completion_idle, - g_cclosure_new_object (G_CALLBACK (check_completion_callback), - G_OBJECT (chooser_entry))); - g_source_attach (chooser_entry->check_completion_idle, NULL); - } + if (chooser_entry->check_completion_idle == 0) + chooser_entry->check_completion_idle = + idle_add (chooser_entry, G_CALLBACK (check_completion_callback)); } @@ -627,7 +650,7 @@ load_directory_callback (GtkFileChooserEntry *chooser_entry) GDK_THREADS_ENTER (); - chooser_entry->load_directory_idle = NULL; + chooser_entry->load_directory_idle = 0; /* guard against bogus settings*/ if (chooser_entry->current_folder_path == NULL || @@ -783,15 +806,9 @@ gtk_file_chooser_entry_maybe_update_directory (GtkFileChooserEntry *chooser_entr chooser_entry->current_folder_path = folder_path; - if (queue_idle && chooser_entry->load_directory_idle == NULL) - { - chooser_entry->load_directory_idle = g_idle_source_new (); - g_source_set_priority (chooser_entry->load_directory_idle, G_PRIORITY_HIGH); - g_source_set_closure (chooser_entry->load_directory_idle, - g_cclosure_new_object (G_CALLBACK (load_directory_callback), - G_OBJECT (chooser_entry))); - g_source_attach (chooser_entry->load_directory_idle, NULL); - } + if (queue_idle && chooser_entry->load_directory_idle == 0) + chooser_entry->load_directory_idle = + idle_add (chooser_entry, G_CALLBACK (load_directory_callback)); }