add handle fields to ButtonData and GtkPathBar; do correct handle

2005-12-19  Kristian Rietveld  <kris@imendio.com>

	* gtk/gtkpathbar.[ch]: add handle fields to ButtonData and
	GtkPathBar; do correct handle bookkeeping.

	* gtk/gtkfilesystemunix.c (load_folder),
	(gtk_file_system_unix_get_folder),
	(gtk_file_folder_unix_is_finished_loading): add is_finished_loading
	field to GtkFileFolderUnix, which is set to true once we are
	really finished with loading (previous assumption that we are
	always finshed loading is not true anymore).

	* gtk/gtkfilesystemmodel.c (got_root_folder_cb): if the folder is
	finished loading, list the children and update the root level.

	* gtk/gtkfilechooserdefault.c (update_current_folder_get_info_cb):
	handle cancellation.
This commit is contained in:
Kristian Rietveld
2005-12-19 19:43:32 +00:00
committed by Kristian Rietveld
parent 504e508a94
commit 6d05ff46d0
7 changed files with 118 additions and 30 deletions

View File

@@ -1,3 +1,21 @@
2005-12-19 Kristian Rietveld <kris@imendio.com>
* gtk/gtkpathbar.[ch]: add handle fields to ButtonData and
GtkPathBar; do correct handle bookkeeping.
* gtk/gtkfilesystemunix.c (load_folder),
(gtk_file_system_unix_get_folder),
(gtk_file_folder_unix_is_finished_loading): add is_finished_loading
field to GtkFileFolderUnix, which is set to true once we are
really finished with loading (previous assumption that we are
always finshed loading is not true anymore).
* gtk/gtkfilesystemmodel.c (got_root_folder_cb): if the folder is
finished loading, list the children and update the root level.
* gtk/gtkfilechooserdefault.c (update_current_folder_get_info_cb):
handle cancellation.
2005-12-19 Kristian Rietveld <kris@imendio.com>
* gtk/gtktreeview.c: small fix to make it actually work in this

View File

@@ -1,3 +1,21 @@
2005-12-19 Kristian Rietveld <kris@imendio.com>
* gtk/gtkpathbar.[ch]: add handle fields to ButtonData and
GtkPathBar; do correct handle bookkeeping.
* gtk/gtkfilesystemunix.c (load_folder),
(gtk_file_system_unix_get_folder),
(gtk_file_folder_unix_is_finished_loading): add is_finished_loading
field to GtkFileFolderUnix, which is set to true once we are
really finished with loading (previous assumption that we are
always finshed loading is not true anymore).
* gtk/gtkfilesystemmodel.c (got_root_folder_cb): if the folder is
finished loading, list the children and update the root level.
* gtk/gtkfilechooserdefault.c (update_current_folder_get_info_cb):
handle cancellation.
2005-12-19 Kristian Rietveld <kris@imendio.com>
* gtk/gtktreeview.c: small fix to make it actually work in this

View File

@@ -5590,11 +5590,19 @@ update_current_folder_get_info_cb (GtkFileSystemHandle *handle,
const GError *error,
gpointer user_data)
{
gboolean cancelled = handle->cancelled;
struct UpdateCurrentFolderData *data = user_data;
GtkFileChooserDefault *impl = data->impl;
if (handle != impl->update_current_folder_handle)
goto out;
g_object_unref (handle);
impl->update_current_folder_handle = NULL;
if (cancelled)
goto out;
if (error)
{
error_changing_folder_dialog (impl, data->path, g_error_copy (error));

View File

@@ -672,18 +672,13 @@ got_root_folder_cb (GtkFileSystemHandle *handle,
if (!folder)
return;
#if 0
if (!gtk_file_folder_list_children (root_folder, &roots, error))
{
g_object_unref (folder);
return;
}
#endif
model->root_folder = folder;
if (gtk_file_folder_is_finished_loading (model->root_folder))
queue_finished_loading (model); /* done in an idle because we are being created */
{
queue_finished_loading (model); /* done in an idle because we are being created */
gtk_file_folder_list_children (model->root_folder, &roots, NULL);
}
else
g_signal_connect_object (model->root_folder, "finished-loading",
G_CALLBACK (root_folder_finished_loading_cb), model, 0);

View File

@@ -115,6 +115,7 @@ struct _GtkFileFolderUnix
guint have_mime_type : 1;
guint is_network_dir : 1;
guint have_hidden : 1;
guint is_finished_loading : 1;
time_t asof;
};
@@ -787,6 +788,7 @@ load_folder (gpointer data)
if (gtk_file_folder_unix_list_children (GTK_FILE_FOLDER (folder_unix), &children, NULL))
{
folder_unix->is_finished_loading = TRUE;
g_signal_emit_by_name (folder_unix, "files-added", children);
gtk_file_paths_free (children);
}
@@ -899,6 +901,7 @@ gtk_file_system_unix_get_folder (GtkFileSystem *file_system,
folder_unix->have_mime_type = FALSE;
folder_unix->have_stat = FALSE;
folder_unix->have_hidden = FALSE;
folder_unix->is_finished_loading = FALSE;
set_asof = TRUE;
if ((system_unix->have_afs &&
@@ -2524,8 +2527,7 @@ gtk_file_folder_unix_list_children (GtkFileFolder *folder,
static gboolean
gtk_file_folder_unix_is_finished_loading (GtkFileFolder *folder)
{
/* Since we don't do asynchronous loads, we are always finished loading */
return TRUE;
return GTK_FILE_FOLDER_UNIX (folder)->is_finished_loading;
}
static void

View File

@@ -65,6 +65,7 @@ struct _ButtonData
GtkFilePath *path;
GtkWidget *image;
GtkWidget *label;
GtkFileSystemHandle *handle;
guint ignore_changes : 1;
guint file_is_hidden : 1;
};
@@ -140,6 +141,8 @@ gtk_path_bar_init (GtkPathBar *path_bar)
GTK_WIDGET_SET_FLAGS (path_bar, GTK_NO_WINDOW);
gtk_widget_set_redraw_on_allocate (GTK_WIDGET (path_bar), FALSE);
path_bar->set_path_handle = NULL;
path_bar->spacing = 3;
path_bar->up_slider_button = get_slider_button (path_bar, GTK_ARROW_LEFT);
path_bar->down_slider_button = get_slider_button (path_bar, GTK_ARROW_RIGHT);
@@ -207,6 +210,10 @@ gtk_path_bar_finalize (GObject *object)
gtk_path_bar_stop_scrolling (path_bar);
if (path_bar->set_path_handle)
gtk_file_system_cancel_operation (path_bar->set_path_handle);
path_bar->set_path_handle = NULL;
g_list_free (path_bar->button_list);
if (path_bar->root_path)
gtk_file_path_free (path_bar->root_path);
@@ -993,14 +1000,18 @@ set_button_image_get_info_cb (GtkFileSystemHandle *handle,
const GError *error,
gpointer user_data)
{
gboolean cancelled = handle->cancelled;
GdkPixbuf *pixbuf;
struct SetButtonImageData *data = user_data;
if (error)
{
g_free (data);
return;
}
if (handle != data->button_data->handle)
goto out;
g_object_unref (handle);
data->button_data->handle = NULL;
if (cancelled || error)
goto out;
pixbuf = gtk_file_info_render_icon (info, GTK_WIDGET (data->path_bar),
data->path_bar->icon_size, NULL);
@@ -1026,6 +1037,7 @@ set_button_image_get_info_cb (GtkFileSystemHandle *handle,
break;
};
out:
g_free (data);
}
@@ -1071,11 +1083,15 @@ set_button_image (GtkPathBar *path_bar,
data->path_bar = path_bar;
data->button_data = button_data;
gtk_file_system_get_info (path_bar->file_system,
path_bar->home_path,
GTK_FILE_INFO_ICON,
set_button_image_get_info_cb,
data);
if (button_data->handle)
gtk_file_system_cancel_operation (button_data->handle);
button_data->handle =
gtk_file_system_get_info (path_bar->file_system,
path_bar->home_path,
GTK_FILE_INFO_ICON,
set_button_image_get_info_cb,
data);
break;
case DESKTOP_BUTTON:
@@ -1089,11 +1105,15 @@ set_button_image (GtkPathBar *path_bar,
data->path_bar = path_bar;
data->button_data = button_data;
gtk_file_system_get_info (path_bar->file_system,
path_bar->desktop_path,
GTK_FILE_INFO_ICON,
set_button_image_get_info_cb,
data);
if (button_data->handle)
gtk_file_system_cancel_operation (button_data->handle);
button_data->handle =
gtk_file_system_get_info (path_bar->file_system,
path_bar->desktop_path,
GTK_FILE_INFO_ICON,
set_button_image_get_info_cb,
data);
break;
default:
break;
@@ -1103,6 +1123,9 @@ set_button_image (GtkPathBar *path_bar,
static void
button_data_free (ButtonData *button_data)
{
if (button_data->handle)
gtk_file_system_cancel_operation (button_data->handle);
gtk_file_path_free (button_data->path);
g_free (button_data->dir_name);
g_free (button_data);
@@ -1420,14 +1443,23 @@ gtk_path_bar_get_info_callback (GtkFileSystemHandle *handle,
const GError *error,
gpointer data)
{
gboolean cancelled = handle->cancelled;
struct SetPathInfo *path_info = data;
ButtonData *button_data;
const gchar *display_name;
gboolean is_hidden;
gboolean valid;
if (!file_info)
if (handle != path_info->path_bar->set_path_handle)
{
gtk_path_bar_set_path_finish (path_info, FALSE);
return;
}
g_object_unref (handle);
path_info->path_bar->set_path_handle = NULL;
if (cancelled || !file_info)
{
gtk_path_bar_set_path_finish (path_info, FALSE);
return;
@@ -1467,7 +1499,12 @@ gtk_path_bar_get_info_callback (GtkFileSystemHandle *handle,
return;
}
gtk_file_system_get_info (handle->file_system, path_info->path, GTK_FILE_INFO_DISPLAY_NAME | GTK_FILE_INFO_IS_HIDDEN, gtk_path_bar_get_info_callback, path_info);
path_info->path_bar->set_path_handle =
gtk_file_system_get_info (handle->file_system,
path_info->path,
GTK_FILE_INFO_DISPLAY_NAME | GTK_FILE_INFO_IS_HIDDEN,
gtk_path_bar_get_info_callback,
path_info);
}
gboolean
@@ -1505,7 +1542,15 @@ _gtk_path_bar_set_path (GtkPathBar *path_bar,
return result;
}
gtk_file_system_get_info (path_bar->file_system, info->path, GTK_FILE_INFO_DISPLAY_NAME | GTK_FILE_INFO_IS_HIDDEN, gtk_path_bar_get_info_callback, info);
if (path_bar->set_path_handle)
gtk_file_system_cancel_operation (path_bar->set_path_handle);
path_bar->set_path_handle =
gtk_file_system_get_info (path_bar->file_system,
info->path,
GTK_FILE_INFO_DISPLAY_NAME | GTK_FILE_INFO_IS_HIDDEN,
gtk_path_bar_get_info_callback,
info);
return TRUE;
}

View File

@@ -45,6 +45,8 @@ struct _GtkPathBar
GtkFilePath *home_path;
GtkFilePath *desktop_path;
GtkFileSystemHandle *set_path_handle;
GdkPixbuf *root_icon;
GdkPixbuf *home_icon;
GdkPixbuf *desktop_icon;