Skip to content
Snippets Groups Projects
Commit d36df4cd authored by Benedikt Meurer's avatar Benedikt Meurer
Browse files

2005-07-16 Benedikt Meurer <benny@xfce.org>

	* thunar/thunar-folder.{c,h}: Add a "files-removed" signal, which can
	  be used by ThunarFolder implementation to solve the reload problem,
	  and probably other problems as well (like asynchronous loading).
	* thunar/thunar-local-folder.c(thunar_local_folder_rescan): Use
	  "files-removed" instead of destroying the no longer present files,
	  so we don't accidently terminate other stuff here.
	* thunar/thunar-list-model.c: Handle the "files-removed" signal of the
	  ThunarFolder.




(Old svn revision: 16391)
parent 60b7a2ea
No related branches found
No related tags found
No related merge requests found
2005-07-16 Benedikt Meurer <benny@xfce.org>
* thunar/thunar-folder.{c,h}: Add a "files-removed" signal, which can
be used by ThunarFolder implementation to solve the reload problem,
and probably other problems as well (like asynchronous loading).
* thunar/thunar-local-folder.c(thunar_local_folder_rescan): Use
"files-removed" instead of destroying the no longer present files,
so we don't accidently terminate other stuff here.
* thunar/thunar-list-model.c: Handle the "files-removed" signal of the
ThunarFolder.
2005-07-15 Benedikt Meurer <benny@xfce.org>
* thunar/thunar-details-view.c: Unselect all selected items if the
......
......@@ -28,6 +28,7 @@
enum
{
FILES_ADDED,
FILES_REMOVED,
LAST_SIGNAL,
};
......@@ -95,6 +96,23 @@ thunar_folder_base_init (gpointer klass)
g_cclosure_marshal_VOID__POINTER,
G_TYPE_NONE, 1, G_TYPE_POINTER);
/**
* ThunarFolder::files-removed:
*
* Emitted by the #ThunarFolder implementation whenever a bunch of
* files is removed from the folder, which means they are not
* necessarily deleted from disk. This can be used to implement
* the reload of folders, which take longer to load.
**/
folder_signals[FILES_REMOVED] =
g_signal_new ("files-removed",
G_TYPE_FROM_INTERFACE (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (ThunarFolderIface, files_removed),
NULL, NULL,
g_cclosure_marshal_VOID__POINTER,
G_TYPE_NONE, 1, G_TYPE_POINTER);
initialized = TRUE;
}
}
......@@ -160,3 +178,23 @@ thunar_folder_files_added (ThunarFolder *folder,
}
/**
* thunar_folder_files_removed:
* @folder : a #ThunarFolder instance.
* @files : the list of removed #ThunarFile<!---->s.
*
* Emits the ::files-removed signal on @folder using the
* given @files. This should only be called by #ThunarFolder
* implementations.
**/
void
thunar_folder_files_removed (ThunarFolder *folder,
GSList *files)
{
g_return_if_fail (THUNAR_IS_FOLDER (folder));
g_return_if_fail (files != NULL);
g_signal_emit (G_OBJECT (folder), folder_signals[FILES_REMOVED], 0, files);
}
......@@ -40,8 +40,10 @@ struct _ThunarFolderIface
GSList *(*get_files) (ThunarFolder *folder);
/* signals */
void (*files_added) (ThunarFolder *folder,
GSList *files);
void (*files_added) (ThunarFolder *folder,
GSList *files);
void (*files_removed) (ThunarFolder *folder,
GSList *files);
};
GType thunar_folder_get_type (void) G_GNUC_CONST;
......@@ -51,6 +53,8 @@ GSList *thunar_folder_get_files (ThunarFolder *folder);
void thunar_folder_files_added (ThunarFolder *folder,
GSList *files);
void thunar_folder_files_removed (ThunarFolder *folder,
GSList *files);
G_END_DECLS;
......
......@@ -142,6 +142,9 @@ static void thunar_list_model_folder_destroy (ThunarFolder
static void thunar_list_model_files_added (ThunarFolder *folder,
GSList *files,
ThunarListModel *store);
static void thunar_list_model_files_removed (ThunarFolder *folder,
GSList *files,
ThunarListModel *store);
static gint sort_by_date_accessed (ThunarFile *a,
ThunarFile *b);
static gint sort_by_date_modified (ThunarFile *a,
......@@ -1285,6 +1288,17 @@ thunar_list_model_files_added (ThunarFolder *folder,
static void
thunar_list_model_files_removed (ThunarFolder *folder,
GSList *files,
ThunarListModel *store)
{
/* drop all the referenced files from the model */
g_slist_foreach (files, (GFunc) thunar_list_model_file_destroy, store);
}
static gint
sort_by_date_accessed (ThunarFile *a,
ThunarFile *b)
......@@ -1652,10 +1666,12 @@ thunar_list_model_set_folder (ThunarListModel *store,
}
/* connect signals to the new folder */
g_signal_connect (G_OBJECT (store->folder), "files-added",
G_CALLBACK (thunar_list_model_files_added), store);
g_signal_connect (G_OBJECT (store->folder), "destroy",
G_CALLBACK (thunar_list_model_folder_destroy), store);
g_signal_connect (G_OBJECT (store->folder), "files-added",
G_CALLBACK (thunar_list_model_files_added), store);
g_signal_connect (G_OBJECT (store->folder), "files-removed",
G_CALLBACK (thunar_list_model_files_removed), store);
}
/* notify listeners that we have a new folder */
......
......@@ -212,16 +212,22 @@ thunar_local_folder_rescan (ThunarLocalFolder *local_folder,
g_dir_close (dp);
/* notify listeners about removed files */
for (lp = ofiles; lp != NULL; lp = lp->next)
/* handle the left over old-files */
if (G_UNLIKELY (ofiles != NULL))
{
g_signal_handlers_disconnect_matched (G_OBJECT (lp->data), G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_CLOSURE,
local_folder->file_destroy_id, 0, local_folder->file_destroy_closure,
NULL, NULL);
gtk_object_destroy (GTK_OBJECT (lp->data));
g_object_unref (G_OBJECT (lp->data));
/* notify listeners about removed files */
thunar_folder_files_removed (THUNAR_FOLDER (local_folder), ofiles);
/* drop old files */
for (lp = ofiles; lp != NULL; lp = lp->next)
{
g_signal_handlers_disconnect_matched (G_OBJECT (lp->data), G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_CLOSURE,
local_folder->file_destroy_id, 0, local_folder->file_destroy_closure,
NULL, NULL);
g_object_unref (G_OBJECT (lp->data));
}
g_slist_free (ofiles);
}
g_slist_free (ofiles);
/* notify listening parties about added files and append the
* new files to our internal file list.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment