[gthumb] location chooser: update the list only after the widget is realized



commit 3aab97f323c977d38dc1217af3f1b79e56a90c28
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Mon Oct 31 16:23:25 2011 +0100

    location chooser: update the list only after the widget is realized
    
    ...and cleaned the code using the G_DEFINE_TYPE macro, and removing
    the GtkHBox inheritance in favor of GtkBox.

 gthumb/gth-location-chooser.c |  395 ++++++++++++++++++++---------------------
 gthumb/gth-location-chooser.h |    4 +-
 2 files changed, 193 insertions(+), 206 deletions(-)
---
diff --git a/gthumb/gth-location-chooser.c b/gthumb/gth-location-chooser.c
index bd5ec4e..ccb17ba 100644
--- a/gthumb/gth-location-chooser.c
+++ b/gthumb/gth-location-chooser.c
@@ -66,6 +66,7 @@ struct _GthLocationChooserPrivate
 	GthIconCache  *icon_cache;
 	GthFileSource *file_source;
 	gulong         entry_points_changed_id;
+	guint          update_list_id;
 };
 
 
@@ -76,64 +77,66 @@ static guint gth_location_chooser_signals[LAST_SIGNAL] = { 0 };
 static void
 gth_location_chooser_finalize (GObject *object)
 {
-	GthLocationChooser *chooser;
+	GthLocationChooser *self;
 
-	chooser = GTH_LOCATION_CHOOSER (object);
+	self = GTH_LOCATION_CHOOSER (object);
 
-	if (chooser->priv != NULL) {
+	if (self->priv->update_list_id != 0)
+		g_source_remove (self->priv->update_list_id);
+	if (self->priv->entry_points_changed_id != 0)
 		g_signal_handler_disconnect (gth_main_get_default_monitor (),
-					     chooser->priv->entry_points_changed_id);
-		if (chooser->priv->file_source != NULL)
-			g_object_unref (chooser->priv->file_source);
-		gth_icon_cache_free (chooser->priv->icon_cache);
-		if (chooser->priv->location != NULL)
-			g_object_unref (chooser->priv->location);
-		g_free (chooser->priv);
-	}
+					     self->priv->entry_points_changed_id);
+	if (self->priv->file_source != NULL)
+		g_object_unref (self->priv->file_source);
+	if (self->priv->location != NULL)
+		g_object_unref (self->priv->location);
 
 	G_OBJECT_CLASS (parent_class)->finalize (object);
 }
 
+
 static void
 gth_location_chooser_grab_focus (GtkWidget *widget)
 {
-	GthLocationChooser *chooser = GTH_LOCATION_CHOOSER (widget);
+	GthLocationChooser *self = GTH_LOCATION_CHOOSER (widget);
 
-	gtk_widget_grab_focus (chooser->priv->combo);
+	gtk_widget_grab_focus (self->priv->combo);
 }
 
 
-static void
-gth_location_chooser_class_init (GthLocationChooserClass *class)
+static gboolean
+get_nth_separator_pos (GthLocationChooser *self,
+		       int                 pos,
+		       int                *idx)
 {
-	GObjectClass   *object_class;
-	GtkWidgetClass *widget_class;
+	GtkTreeIter iter;
+	gboolean    n_found = 0;
 
-	parent_class = g_type_class_peek_parent (class);
+	if (idx != NULL)
+		*idx = 0;
 
-	object_class = (GObjectClass*) class;
-	object_class->finalize = gth_location_chooser_finalize;
+	if (! gtk_tree_model_get_iter_first (GTK_TREE_MODEL (self->priv->model), &iter))
+		return FALSE;
 
-	widget_class = (GtkWidgetClass *) class;
-	widget_class->grab_focus = gth_location_chooser_grab_focus;
+	do {
+		int item_type = ITEM_TYPE_NONE;
 
-	gth_location_chooser_signals[CHANGED] =
-		g_signal_new ("changed",
-			      G_TYPE_FROM_CLASS (class),
-			      G_SIGNAL_RUN_LAST,
-			      G_STRUCT_OFFSET (GthLocationChooserClass, changed),
-			      NULL, NULL,
-			      g_cclosure_marshal_VOID__VOID,
-			      G_TYPE_NONE,
-			      0);
-}
+		gtk_tree_model_get (GTK_TREE_MODEL (self->priv->model),
+				    &iter,
+				    TYPE_COLUMN, &item_type,
+				    -1);
+		if (item_type == ITEM_TYPE_SEPARATOR) {
+			n_found++;
+			if (n_found == pos)
+				break;
+		}
 
+		if (idx != NULL)
+			*idx = *idx + 1;
+	}
+	while (gtk_tree_model_iter_next (GTK_TREE_MODEL (self->priv->model), &iter));
 
-static void
-gth_location_chooser_init (GthLocationChooser *chooser)
-{
-	gtk_widget_set_can_focus (GTK_WIDGET (chooser), TRUE);
-	chooser->priv = g_new0 (GthLocationChooserPrivate, 1);
+	return n_found == pos;
 }
 
 
@@ -141,15 +144,15 @@ static void
 combo_changed_cb (GtkComboBox *widget,
 		  gpointer     user_data)
 {
-	GthLocationChooser *chooser = user_data;
+	GthLocationChooser *self = user_data;
 	GtkTreeIter         iter;
 	char               *uri = NULL;
 	int                 item_type = ITEM_TYPE_NONE;
 
-	if (! gtk_combo_box_get_active_iter (GTK_COMBO_BOX (chooser->priv->combo), &iter))
+	if (! gtk_combo_box_get_active_iter (GTK_COMBO_BOX (self->priv->combo), &iter))
 		return;
 
-	gtk_tree_model_get (GTK_TREE_MODEL (chooser->priv->model),
+	gtk_tree_model_get (GTK_TREE_MODEL (self->priv->model),
 			    &iter,
 			    TYPE_COLUMN, &item_type,
 			    URI_COLUMN, &uri,
@@ -159,67 +162,15 @@ combo_changed_cb (GtkComboBox *widget,
 		GFile *file;
 
 		file = g_file_new_for_uri (uri);
-		gth_location_chooser_set_current (chooser, file);
+		gth_location_chooser_set_current (self, file);
 
 		g_object_unref (file);
 	}
 }
 
 
-static gboolean
-row_separator_func (GtkTreeModel *model,
-		    GtkTreeIter  *iter,
-		    gpointer      data)
-{
-	int item_type = ITEM_TYPE_NONE;
-
-	gtk_tree_model_get (model,
-			    iter,
-			    TYPE_COLUMN, &item_type,
-			    -1);
-
-	return (item_type == ITEM_TYPE_SEPARATOR);
-}
-
-
-static gboolean
-get_nth_separator_pos (GthLocationChooser *chooser,
-		       int                 pos,
-		       int                *idx)
-{
-	GtkTreeIter iter;
-	gboolean    n_found = 0;
-
-	if (idx != NULL)
-		*idx = 0;
-
-	if (! gtk_tree_model_get_iter_first (GTK_TREE_MODEL (chooser->priv->model), &iter))
-		return FALSE;
-
-	do {
-		int item_type = ITEM_TYPE_NONE;
-
-		gtk_tree_model_get (GTK_TREE_MODEL (chooser->priv->model),
-				    &iter,
-				    TYPE_COLUMN, &item_type,
-				    -1);
-		if (item_type == ITEM_TYPE_SEPARATOR) {
-			n_found++;
-			if (n_found == pos)
-				break;
-		}
-
-		if (idx != NULL)
-			*idx = *idx + 1;
-	}
-	while (gtk_tree_model_iter_next (GTK_TREE_MODEL (chooser->priv->model), &iter));
-
-	return n_found == pos;
-}
-
-
 static void
-add_file_source_entries (GthLocationChooser *chooser,
+add_file_source_entries (GthLocationChooser *self,
 			 GFile              *file,
 			 const char         *name,
 			 GIcon              *icon,
@@ -231,11 +182,11 @@ add_file_source_entries (GthLocationChooser *chooser,
 	GdkPixbuf   *pixbuf;
 	char        *uri;
 
-	pixbuf = gth_icon_cache_get_pixbuf (chooser->priv->icon_cache, icon);
+	pixbuf = gth_icon_cache_get_pixbuf (self->priv->icon_cache, icon);
 	uri = g_file_get_uri (file);
 
-	gtk_tree_store_insert (chooser->priv->model, &iter, NULL, position);
-	gtk_tree_store_set (chooser->priv->model, &iter,
+	gtk_tree_store_insert (self->priv->model, &iter, NULL, position);
+	gtk_tree_store_set (self->priv->model, &iter,
 			    TYPE_COLUMN, iter_type,
 			    ICON_COLUMN, pixbuf,
 			    NAME_COLUMN, name,
@@ -246,16 +197,16 @@ add_file_source_entries (GthLocationChooser *chooser,
 	g_free (uri);
 	g_object_unref (pixbuf);
 
-	if (update_active_iter && g_file_equal (chooser->priv->location, file)) {
-		g_signal_handlers_block_by_func (chooser->priv->combo, combo_changed_cb, chooser);
-		gtk_combo_box_set_active_iter (GTK_COMBO_BOX (chooser->priv->combo), &iter);
-		g_signal_handlers_unblock_by_func (chooser->priv->combo, combo_changed_cb, chooser);
+	if (update_active_iter && g_file_equal (self->priv->location, file)) {
+		g_signal_handlers_block_by_func (self->priv->combo, combo_changed_cb, self);
+		gtk_combo_box_set_active_iter (GTK_COMBO_BOX (self->priv->combo), &iter);
+		g_signal_handlers_unblock_by_func (self->priv->combo, combo_changed_cb, self);
 	}
 }
 
 
 static void
-update_entry_point_list (GthLocationChooser *chooser)
+update_entry_point_list (GthLocationChooser *self)
 {
 	int    first_position;
 	int    i;
@@ -263,7 +214,9 @@ update_entry_point_list (GthLocationChooser *chooser)
 	GList *entry_points;
 	GList *scan;
 
-	if (! get_nth_separator_pos (chooser, 1, &first_position))
+	self->priv->update_list_id = 0;
+
+	if (! get_nth_separator_pos (self, 1, &first_position))
 		return;
 
 	for (i = first_position + 1; TRUE; i++) {
@@ -271,8 +224,8 @@ update_entry_point_list (GthLocationChooser *chooser)
 		GtkTreeIter  iter;
 
 		path = gtk_tree_path_new_from_indices (first_position + 1, -1);
-		if (gtk_tree_model_get_iter (GTK_TREE_MODEL (chooser->priv->model), &iter, path))
-			gtk_tree_store_remove (chooser->priv->model, &iter);
+		if (gtk_tree_model_get_iter (GTK_TREE_MODEL (self->priv->model), &iter, path))
+			gtk_tree_store_remove (self->priv->model, &iter);
 		else
 			break;
 
@@ -284,7 +237,7 @@ update_entry_point_list (GthLocationChooser *chooser)
 	for (scan = entry_points; scan; scan = scan->next) {
 		GthFileData *file_data = scan->data;
 
-		add_file_source_entries (chooser,
+		add_file_source_entries (self,
 					 file_data->file,
 					 g_file_info_get_display_name (file_data->info),
 					 g_file_info_get_icon (file_data->info),
@@ -297,48 +250,120 @@ update_entry_point_list (GthLocationChooser *chooser)
 }
 
 
+static gboolean
+row_separator_func (GtkTreeModel *model,
+		    GtkTreeIter  *iter,
+		    gpointer      data)
+{
+	int item_type = ITEM_TYPE_NONE;
+
+	gtk_tree_model_get (model,
+			    iter,
+			    TYPE_COLUMN, &item_type,
+			    -1);
+
+	return (item_type == ITEM_TYPE_SEPARATOR);
+}
+
+
 static void
 entry_points_changed_cb (GthMonitor         *monitor,
-			 GthLocationChooser *chooser)
+			 GthLocationChooser *self)
 {
-	call_when_idle ((DataFunc) update_entry_point_list, chooser);
+	if (self->priv->update_list_id != 0)
+		return;
+	self->priv->update_list_id = call_when_idle ((DataFunc) update_entry_point_list, self);
 }
 
 
 static void
-gth_location_chooser_construct (GthLocationChooser *chooser)
+gth_location_chooser_realize (GtkWidget *widget)
+{
+	GthLocationChooser *self = GTH_LOCATION_CHOOSER (widget);
+
+	GTK_WIDGET_CLASS (parent_class)->realize (widget);
+	self->priv->icon_cache = gth_icon_cache_new (gtk_icon_theme_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (self))),
+						     _gtk_icon_get_pixel_size (GTK_WIDGET (self), GTK_ICON_SIZE_MENU));
+	entry_points_changed_cb (NULL, self);
+}
+
+
+static void
+gth_location_chooser_unrealize (GtkWidget *widget)
+{
+	GthLocationChooser *self = GTH_LOCATION_CHOOSER (widget);
+
+	gth_icon_cache_free (self->priv->icon_cache);
+	GTK_WIDGET_CLASS (parent_class)->unrealize (widget);
+}
+
+
+static void
+gth_location_chooser_class_init (GthLocationChooserClass *klass)
+{
+	GObjectClass   *object_class;
+	GtkWidgetClass *widget_class;
+
+	parent_class = g_type_class_peek_parent (klass);
+	g_type_class_add_private (klass, sizeof (GthLocationChooserPrivate));
+
+	object_class = (GObjectClass*) klass;
+	object_class->finalize = gth_location_chooser_finalize;
+
+	widget_class = (GtkWidgetClass *) klass;
+	widget_class->grab_focus = gth_location_chooser_grab_focus;
+	widget_class->realize = gth_location_chooser_realize;
+	widget_class->unrealize = gth_location_chooser_unrealize;
+
+	gth_location_chooser_signals[CHANGED] =
+		g_signal_new ("changed",
+			      G_TYPE_FROM_CLASS (klass),
+			      G_SIGNAL_RUN_LAST,
+			      G_STRUCT_OFFSET (GthLocationChooserClass, changed),
+			      NULL, NULL,
+			      g_cclosure_marshal_VOID__VOID,
+			      G_TYPE_NONE,
+			      0);
+}
+
+
+static void
+gth_location_chooser_init (GthLocationChooser *self)
 {
 	GtkCellRenderer *renderer;
 	GtkTreeIter      iter;
 
-	chooser->priv->icon_cache = gth_icon_cache_new (gtk_icon_theme_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (chooser))),
-							 _gtk_icon_get_pixel_size (GTK_WIDGET (chooser), GTK_ICON_SIZE_MENU));
-
-	chooser->priv->model = gtk_tree_store_new (N_COLUMNS,
-						    GDK_TYPE_PIXBUF,
-						    G_TYPE_STRING,
-						    G_TYPE_STRING,
-						    G_TYPE_INT,
-						    PANGO_TYPE_ELLIPSIZE_MODE);
-	chooser->priv->combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (chooser->priv->model));
-	g_object_unref (chooser->priv->model);
-	g_signal_connect (chooser->priv->combo,
+	gtk_widget_set_can_focus (GTK_WIDGET (self), TRUE);
+	gtk_orientable_set_orientation (GTK_ORIENTABLE (self), GTK_ORIENTATION_HORIZONTAL);
+
+	self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GTH_TYPE_LOCATION_CHOOSER, GthLocationChooserPrivate);
+	self->priv->icon_cache = NULL;
+
+	self->priv->model = gtk_tree_store_new (N_COLUMNS,
+						GDK_TYPE_PIXBUF,
+						G_TYPE_STRING,
+						G_TYPE_STRING,
+						G_TYPE_INT,
+						PANGO_TYPE_ELLIPSIZE_MODE);
+	self->priv->combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (self->priv->model));
+	g_object_unref (self->priv->model);
+	g_signal_connect (self->priv->combo,
 			  "changed",
 			  G_CALLBACK (combo_changed_cb),
-			  chooser);
-	gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (chooser->priv->combo),
+			  self);
+	gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (self->priv->combo),
 					      row_separator_func,
-					      chooser,
+					      self,
 					      NULL);
-	gtk_widget_set_size_request (chooser->priv->combo, MIN_WIDTH, -1);
+	gtk_widget_set_size_request (self->priv->combo, MIN_WIDTH, -1);
 
 	/* icon column */
 
 	renderer = gtk_cell_renderer_pixbuf_new ();
-	gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (chooser->priv->combo),
+	gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (self->priv->combo),
 				    renderer,
 				    FALSE);
-	gtk_cell_layout_set_attributes  (GTK_CELL_LAYOUT (chooser->priv->combo),
+	gtk_cell_layout_set_attributes  (GTK_CELL_LAYOUT (self->priv->combo),
 					 renderer,
 					 "pixbuf", ICON_COLUMN,
 					 NULL);
@@ -346,10 +371,10 @@ gth_location_chooser_construct (GthLocationChooser *chooser)
 	/* path column */
 
 	renderer = gtk_cell_renderer_text_new ();
-	gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (chooser->priv->combo),
+	gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (self->priv->combo),
 				    renderer,
 				    TRUE);
-	gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (chooser->priv->combo),
+	gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (self->priv->combo),
 					renderer,
 					"text", NAME_COLUMN,
 					"ellipsize", ELLIPSIZE_COLUMN,
@@ -357,110 +382,72 @@ gth_location_chooser_construct (GthLocationChooser *chooser)
 
 	/**/
 
-	gtk_widget_show (chooser->priv->combo);
-	gtk_container_add (GTK_CONTAINER (chooser), chooser->priv->combo);
+	gtk_widget_show (self->priv->combo);
+	gtk_box_pack_start (GTK_BOX (self), self->priv->combo, TRUE, TRUE, 0);
 
 	/* Add standard items. */
 
 	/* separator #1 */
 
-	gtk_tree_store_append (chooser->priv->model, &iter, NULL);
-	gtk_tree_store_set (chooser->priv->model, &iter,
+	gtk_tree_store_append (self->priv->model, &iter, NULL);
+	gtk_tree_store_set (self->priv->model, &iter,
 			    TYPE_COLUMN, ITEM_TYPE_SEPARATOR,
 			    -1);
 
 	/**/
 
-	performance (DEBUG_INFO, "update_entry_point_list");
-
-	update_entry_point_list (chooser);
-
-	performance (DEBUG_INFO, "location constructed");
-
-	/**/
-
-	chooser->priv->entry_points_changed_id =
+	self->priv->entry_points_changed_id =
 			g_signal_connect (gth_main_get_default_monitor (),
 					  "entry-points-changed",
 					  G_CALLBACK (entry_points_changed_cb),
-					  chooser);
+					  self);
 }
 
 
-GType
-gth_location_chooser_get_type (void)
-{
-	static GType type = 0;
-
-	if (! type) {
-		GTypeInfo type_info = {
-			sizeof (GthLocationChooserClass),
-			NULL,
-			NULL,
-			(GClassInitFunc) gth_location_chooser_class_init,
-			NULL,
-			NULL,
-			sizeof (GthLocationChooser),
-			0,
-			(GInstanceInitFunc) gth_location_chooser_init
-		};
-
-		type = g_type_register_static (GTK_TYPE_HBOX,
-					       "GthLocationChooser",
-					       &type_info,
-					       0);
-	}
-
-	return type;
-}
+G_DEFINE_TYPE(GthLocationChooser, gth_location_chooser, GTK_TYPE_BOX)
 
 
-GtkWidget*
+GtkWidget *
 gth_location_chooser_new (void)
 {
-	GtkWidget *widget;
-
-	widget = GTK_WIDGET (g_object_new (GTH_TYPE_LOCATION_CHOOSER, NULL));
-	gth_location_chooser_construct (GTH_LOCATION_CHOOSER (widget));
-
-	return widget;
+	return GTK_WIDGET (g_object_new (GTH_TYPE_LOCATION_CHOOSER, NULL));
 }
 
 
 static gboolean
-delete_current_file_entries (GthLocationChooser *chooser)
+delete_current_file_entries (GthLocationChooser *self)
 {
 	gboolean    found = FALSE;
 	GtkTreeIter iter;
 
-	if (! gtk_tree_model_get_iter_first (GTK_TREE_MODEL (chooser->priv->model), &iter))
+	if (! gtk_tree_model_get_iter_first (GTK_TREE_MODEL (self->priv->model), &iter))
 		return FALSE;
 
 	do {
 		int item_type = ITEM_TYPE_NONE;
 
-		gtk_tree_model_get (GTK_TREE_MODEL (chooser->priv->model),
+		gtk_tree_model_get (GTK_TREE_MODEL (self->priv->model),
 				    &iter,
 				    TYPE_COLUMN, &item_type,
 				    -1);
 		if (item_type == ITEM_TYPE_SEPARATOR)
 			break;
 	}
-	while (gtk_tree_store_remove (chooser->priv->model, &iter));
+	while (gtk_tree_store_remove (self->priv->model, &iter));
 
 	return found;
 }
 
 
 static gboolean
-get_iter_from_current_file_entries (GthLocationChooser *chooser,
+get_iter_from_current_file_entries (GthLocationChooser *self,
 				    GFile              *file,
 				    GtkTreeIter        *iter)
 {
 	gboolean  found = FALSE;
 	char     *uri;
 
-	if (! gtk_tree_model_get_iter_first (GTK_TREE_MODEL (chooser->priv->model), iter))
+	if (! gtk_tree_model_get_iter_first (GTK_TREE_MODEL (self->priv->model), iter))
 		return FALSE;
 
 	uri = g_file_get_uri (file);
@@ -468,7 +455,7 @@ get_iter_from_current_file_entries (GthLocationChooser *chooser,
 		int   item_type = ITEM_TYPE_NONE;
 		char *list_uri;
 
-		gtk_tree_model_get (GTK_TREE_MODEL (chooser->priv->model),
+		gtk_tree_model_get (GTK_TREE_MODEL (self->priv->model),
 				    iter,
 				    TYPE_COLUMN, &item_type,
 				    URI_COLUMN, &list_uri,
@@ -482,7 +469,7 @@ get_iter_from_current_file_entries (GthLocationChooser *chooser,
 		}
 		g_free (list_uri);
 	}
-	while (gtk_tree_model_iter_next (GTK_TREE_MODEL (chooser->priv->model), iter));
+	while (gtk_tree_model_iter_next (GTK_TREE_MODEL (self->priv->model), iter));
 
 	g_free (uri);
 
@@ -491,46 +478,46 @@ get_iter_from_current_file_entries (GthLocationChooser *chooser,
 
 
 void
-gth_location_chooser_set_current (GthLocationChooser *chooser,
+gth_location_chooser_set_current (GthLocationChooser *self,
 				  GFile              *file)
 {
 	GtkTreeIter iter;
 
-	if (chooser->priv->file_source != NULL)
-		g_object_unref (chooser->priv->file_source);
-	chooser->priv->file_source = gth_main_get_file_source (file);
+	if (self->priv->file_source != NULL)
+		g_object_unref (self->priv->file_source);
+	self->priv->file_source = gth_main_get_file_source (file);
 
-	if (chooser->priv->file_source == NULL)
+	if (self->priv->file_source == NULL)
 		return;
 
-	if ((chooser->priv->location != NULL) && g_file_equal (file, chooser->priv->location))
+	if ((self->priv->location != NULL) && g_file_equal (file, self->priv->location))
 		return;
 
-	if (chooser->priv->location != NULL)
-		g_object_unref (chooser->priv->location);
-	chooser->priv->location = g_file_dup (file);
+	if (self->priv->location != NULL)
+		g_object_unref (self->priv->location);
+	self->priv->location = g_file_dup (file);
 
-	if (get_iter_from_current_file_entries (chooser, chooser->priv->location, &iter)) {
-		g_signal_handlers_block_by_func (chooser->priv->combo, combo_changed_cb, chooser);
-		gtk_combo_box_set_active_iter (GTK_COMBO_BOX (chooser->priv->combo), &iter);
-		g_signal_handlers_unblock_by_func (chooser->priv->combo, combo_changed_cb, chooser);
+	if (get_iter_from_current_file_entries (self, self->priv->location, &iter)) {
+		g_signal_handlers_block_by_func (self->priv->combo, combo_changed_cb, self);
+		gtk_combo_box_set_active_iter (GTK_COMBO_BOX (self->priv->combo), &iter);
+		g_signal_handlers_unblock_by_func (self->priv->combo, combo_changed_cb, self);
 	}
 	else {
 		GList *list;
 		GList *scan;
 		int    position = 0;
 
-		delete_current_file_entries (chooser);
+		delete_current_file_entries (self);
 
-		list = gth_file_source_get_current_list (chooser->priv->file_source, chooser->priv->location);
+		list = gth_file_source_get_current_list (self->priv->file_source, self->priv->location);
 		for (scan = list; scan; scan = scan->next) {
 			GFile     *file = scan->data;
 			GFileInfo *info;
 
-			info = gth_file_source_get_file_info (chooser->priv->file_source, file, GFILE_DISPLAY_ATTRIBUTES);
+			info = gth_file_source_get_file_info (self->priv->file_source, file, GFILE_DISPLAY_ATTRIBUTES);
 			if (info == NULL)
 				continue;
-			add_file_source_entries (chooser,
+			add_file_source_entries (self,
 						 file,
 						 g_file_info_get_display_name (info),
 						 g_file_info_get_icon (info),
@@ -542,12 +529,12 @@ gth_location_chooser_set_current (GthLocationChooser *chooser,
 		}
 	}
 
-	g_signal_emit (G_OBJECT (chooser), gth_location_chooser_signals[CHANGED], 0);
+	g_signal_emit (G_OBJECT (self), gth_location_chooser_signals[CHANGED], 0);
 }
 
 
 GFile *
-gth_location_chooser_get_current (GthLocationChooser *chooser)
+gth_location_chooser_get_current (GthLocationChooser *self)
 {
-	return chooser->priv->location;
+	return self->priv->location;
 }
diff --git a/gthumb/gth-location-chooser.h b/gthumb/gth-location-chooser.h
index cfec256..01cdf81 100644
--- a/gthumb/gth-location-chooser.h
+++ b/gthumb/gth-location-chooser.h
@@ -40,13 +40,13 @@ typedef struct _GthLocationChooserClass    GthLocationChooserClass;
 
 struct _GthLocationChooser
 {
-	GtkHBox __parent;
+	GtkBox __parent;
 	GthLocationChooserPrivate *priv;
 };
 
 struct _GthLocationChooserClass
 {
-	GtkHBoxClass __parent_class;
+	GtkBoxClass __parent_class;
 
 	/* -- Signals -- */
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]