static void
desktop_call_when_ready (CajaDirectory *directory,
                         CajaFileAttributes file_attributes,
                         gboolean wait_for_file_list,
                         CajaDirectoryCallback callback,
                         gpointer callback_data)
{
    CajaDesktopDirectory *desktop;
    MergedCallback search_key, *merged_callback;

    desktop = CAJA_DESKTOP_DIRECTORY (directory);

    /* Check to be sure we aren't overwriting. */
    search_key.callback = callback;
    search_key.callback_data = callback_data;
    if (g_hash_table_lookup (desktop->details->callbacks, &search_key) != NULL)
    {
        g_warning ("tried to add a new callback while an old one was pending");
        return;
    }

    /* Create a merged_callback record. */
    merged_callback = g_new0 (MergedCallback, 1);
    merged_callback->desktop_dir = desktop;
    merged_callback->callback = callback;
    merged_callback->callback_data = callback_data;
    merged_callback->wait_for_attributes = file_attributes;
    merged_callback->wait_for_file_list = wait_for_file_list;
    merged_callback->non_ready_directories = g_list_prepend
            (merged_callback->non_ready_directories, directory);
    merged_callback->non_ready_directories = g_list_prepend
            (merged_callback->non_ready_directories, desktop->details->real_directory);


    merged_callback->merged_file_list = g_list_concat (NULL,
                                        caja_file_list_copy (directory->details->file_list));

    /* Put it in the hash table. */
    g_hash_table_insert (desktop->details->callbacks,
                         merged_callback, merged_callback);

    /* Now tell all the directories about it. */
    caja_directory_call_when_ready
    (desktop->details->real_directory,
     merged_callback->wait_for_attributes,
     merged_callback->wait_for_file_list,
     directory_ready_callback, merged_callback);
    caja_directory_call_when_ready_internal
    (directory,
     NULL,
     merged_callback->wait_for_attributes,
     merged_callback->wait_for_file_list,
     directory_ready_callback,
     NULL,
     merged_callback);

}
static void
desktop_monitor_add (CajaDirectory *directory,
                     gconstpointer client,
                     gboolean monitor_hidden_files,
                     gboolean monitor_backup_files,
                     CajaFileAttributes file_attributes,
                     CajaDirectoryCallback callback,
                     gpointer callback_data)
{
    CajaDesktopDirectory *desktop;
    MergedMonitor *monitor;
    GList *merged_callback_list;

    desktop = CAJA_DESKTOP_DIRECTORY (directory);

    /* Map the client to a unique value so this doesn't interfere
     * with direct monitoring of the directory by the same client.
     */
    monitor = g_hash_table_lookup (desktop->details->monitors, client);
    if (monitor != NULL)
    {
        g_assert (monitor->desktop_dir == desktop);
    }
    else
    {
        monitor = g_new0 (MergedMonitor, 1);
        monitor->desktop_dir = desktop;
        g_hash_table_insert (desktop->details->monitors,
                             (gpointer) client, monitor);
    }
    monitor->monitor_hidden_files = monitor_hidden_files;
    monitor->monitor_backup_files = monitor_backup_files;
    monitor->monitor_attributes = file_attributes;

    /* Call through to the real directory add calls. */
    merged_callback_list = NULL;

    /* Call up to real dir */
    caja_directory_file_monitor_add
    (desktop->details->real_directory, monitor,
     monitor_hidden_files, monitor_backup_files,
     file_attributes,
     build_merged_callback_list, &merged_callback_list);

    /* Handle the desktop part */
    merged_callback_list = g_list_concat (merged_callback_list,
                                          caja_file_list_copy (directory->details->file_list));


    if (callback != NULL)
    {
        (* callback) (directory, merged_callback_list, callback_data);
    }
    caja_file_list_free (merged_callback_list);
}
static void
build_merged_callback_list (CajaDirectory *directory,
                            GList *file_list,
                            gpointer callback_data)
{
    GList **merged_list;

    merged_list = callback_data;
    *merged_list = g_list_concat (*merged_list,
                                  caja_file_list_copy (file_list));
}
Пример #4
0
static CajaClipboardInfo *
caja_clipboard_info_new (GList *files,
                         gboolean cut)
{
    CajaClipboardInfo *info;

    info = g_slice_new0 (CajaClipboardInfo);
    info->files = caja_file_list_copy (files);
    info->cut = cut;

    return info;
}
static void
directory_ready_callback (CajaDirectory *directory,
                          GList *files,
                          gpointer callback_data)
{
    MergedCallback *merged_callback;

    g_assert (CAJA_IS_DIRECTORY (directory));
    g_assert (callback_data != NULL);

    merged_callback = callback_data;
    g_assert (g_list_find (merged_callback->non_ready_directories, directory) != NULL);

    /* Update based on this call. */
    merged_callback->merged_file_list = g_list_concat
                                        (merged_callback->merged_file_list,
                                         caja_file_list_copy (files));

    /* Check if we are ready. */
    merged_callback_remove_directory (merged_callback, directory);
}