summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nautilus-file-operations.c62
-rw-r--r--src/nautilus-file-operations.h20
-rw-r--r--src/nautilus-file-utilities.c4
-rw-r--r--src/nautilus-search-engine.c125
-rw-r--r--src/nautilus-search-engine.h4
-rw-r--r--src/nautilus-search-provider.h7
6 files changed, 164 insertions, 58 deletions
diff --git a/src/nautilus-file-operations.c b/src/nautilus-file-operations.c
index 5951d0040..f3cf2ca0f 100644
--- a/src/nautilus-file-operations.c
+++ b/src/nautilus-file-operations.c
@@ -2530,9 +2530,7 @@ setup_delete_job (GList *files,
static void
trash_or_delete_internal_sync (GList *files,
GtkWindow *parent_window,
- gboolean try_trash,
- NautilusDeleteCallback done_callback,
- gpointer done_callback_data)
+ gboolean try_trash)
{
GTask *task;
DeleteJob *job;
@@ -2540,13 +2538,17 @@ trash_or_delete_internal_sync (GList *files,
job = setup_delete_job (files,
parent_window,
try_trash,
- done_callback,
- done_callback_data);
+ NULL,
+ NULL);
- task = g_task_new (NULL, NULL, delete_task_done, job);
+ task = g_task_new (NULL, NULL, NULL, job);
g_task_set_task_data (task, job, NULL);
g_task_run_in_thread_sync (task, trash_or_delete_internal);
g_object_unref (task);
+ /* Since g_task_run_in_thread_sync doesn't work with callbacks (in this case not reaching
+ * delete_task_done) we need to set up the undo information ourselves.
+ */
+ delete_task_done (NULL, NULL, job);
}
static void
@@ -2572,25 +2574,15 @@ trash_or_delete_internal_async (GList *files,
}
void
-nautilus_file_operations_trash_or_delete_sync (GList *files,
- GtkWindow *parent_window,
- NautilusDeleteCallback done_callback,
- gpointer done_callback_data)
+nautilus_file_operations_trash_or_delete_sync (GList *files)
{
- trash_or_delete_internal_sync (files, parent_window,
- TRUE,
- done_callback, done_callback_data);
+ trash_or_delete_internal_sync (files, NULL, TRUE);
}
void
-nautilus_file_operations_delete_sync (GList *files,
- GtkWindow *parent_window,
- NautilusDeleteCallback done_callback,
- gpointer done_callback_data)
+nautilus_file_operations_delete_sync (GList *files)
{
- trash_or_delete_internal_sync (files, parent_window,
- FALSE,
- done_callback, done_callback_data);
+ trash_or_delete_internal_sync (files, NULL, FALSE);
}
void
@@ -5782,24 +5774,25 @@ nautilus_file_operations_copy (GTask *task,
void
nautilus_file_operations_copy_sync (GList *files,
- GFile *target_dir,
- GtkWindow *parent_window,
- NautilusCopyCallback done_callback,
- gpointer done_callback_data)
+ GFile *target_dir)
{
GTask *task;
CopyMoveJob *job;
job = copy_job_setup (files,
target_dir,
- parent_window,
- done_callback,
- done_callback_data);
+ NULL,
+ NULL,
+ NULL);
- task = g_task_new (NULL, job->common.cancellable, copy_task_done, job);
+ task = g_task_new (NULL, job->common.cancellable, NULL, job);
g_task_set_task_data (task, job, NULL);
g_task_run_in_thread_sync (task, nautilus_file_operations_copy);
g_object_unref (task);
+ /* Since g_task_run_in_thread_sync doesn't work with callbacks (in this case not reaching
+ * copy_task_done) we need to set up the undo information ourselves.
+ */
+ copy_task_done (NULL, NULL, job);
}
void
@@ -6305,19 +6298,20 @@ move_job_setup (GList *files,
void
nautilus_file_operations_move_sync (GList *files,
- GFile *target_dir,
- GtkWindow *parent_window,
- NautilusCopyCallback done_callback,
- gpointer done_callback_data)
+ GFile *target_dir)
{
GTask *task;
CopyMoveJob *job;
- job = move_job_setup (files, target_dir, parent_window, done_callback, done_callback_data);
- task = g_task_new (NULL, job->common.cancellable, move_task_done, job);
+ job = move_job_setup (files, target_dir, NULL, NULL, NULL);
+ task = g_task_new (NULL, job->common.cancellable, NULL, job);
g_task_set_task_data (task, job, NULL);
g_task_run_in_thread_sync (task, nautilus_file_operations_move);
g_object_unref (task);
+ /* Since g_task_run_in_thread_sync doesn't work with callbacks (in this case not reaching
+ * move_task_done) we need to set up the undo information ourselves.
+ */
+ move_task_done (NULL, NULL, job);
}
void
diff --git a/src/nautilus-file-operations.h b/src/nautilus-file-operations.h
index 5eaa95bdd..c9f0ae79a 100644
--- a/src/nautilus-file-operations.h
+++ b/src/nautilus-file-operations.h
@@ -76,14 +76,8 @@ void nautilus_file_operations_new_file_from_template (GtkWidget *p
NautilusCreateCallback done_callback,
gpointer data);
-void nautilus_file_operations_trash_or_delete_sync (GList *files,
- GtkWindow *parent_window,
- NautilusDeleteCallback done_callback,
- gpointer done_callback_data);
-void nautilus_file_operations_delete_sync (GList *files,
- GtkWindow *parent_window,
- NautilusDeleteCallback done_callback,
- gpointer done_callback_data);
+void nautilus_file_operations_trash_or_delete_sync (GList *files);
+void nautilus_file_operations_delete_sync (GList *files);
void nautilus_file_operations_trash_or_delete_async (GList *files,
GtkWindow *parent_window,
NautilusDeleteCallback done_callback,
@@ -126,10 +120,7 @@ void nautilus_file_operations_copy_async (GList *files,
NautilusCopyCallback done_callback,
gpointer done_callback_data);
void nautilus_file_operations_copy_sync (GList *files,
- GFile *target_dir,
- GtkWindow *parent_window,
- NautilusCopyCallback done_callback,
- gpointer done_callback_data);
+ GFile *target_dir);
void nautilus_file_operations_move_async (GList *files,
GFile *target_dir,
@@ -137,10 +128,7 @@ void nautilus_file_operations_move_async (GList *files,
NautilusCopyCallback done_callback,
gpointer done_callback_data);
void nautilus_file_operations_move_sync (GList *files,
- GFile *target_dir,
- GtkWindow *parent_window,
- NautilusCopyCallback done_callback,
- gpointer done_callback_data);
+ GFile *target_dir);
void nautilus_file_operations_duplicate (GList *files,
GtkWindow *parent_window,
diff --git a/src/nautilus-file-utilities.c b/src/nautilus-file-utilities.c
index 66117891a..575c138cf 100644
--- a/src/nautilus-file-utilities.c
+++ b/src/nautilus-file-utilities.c
@@ -819,9 +819,7 @@ ensure_dirs_task_ready_cb (GObject *_source,
nautilus_file_operations_move_sync
(locations,
- original_dir_location,
- data->parent_window,
- NULL, NULL);
+ original_dir_location);
g_list_free_full (locations, g_object_unref);
g_object_unref (original_dir_location);
diff --git a/src/nautilus-search-engine.c b/src/nautilus-search-engine.c
index 5f0fa85c1..23c1c7e88 100644
--- a/src/nautilus-search-engine.c
+++ b/src/nautilus-search-engine.c
@@ -25,7 +25,6 @@
#include "nautilus-file.h"
#include "nautilus-search-engine-model.h"
-#include "nautilus-search-provider.h"
#include <glib/gi18n.h>
#define DEBUG_FLAG NAUTILUS_DEBUG_SEARCH
#include "nautilus-debug.h"
@@ -84,7 +83,7 @@ nautilus_search_engine_set_query (NautilusSearchProvider *provider,
}
static void
-search_engine_start_real (NautilusSearchEngine *engine)
+search_engine_start_real_setup (NautilusSearchEngine *engine)
{
NautilusSearchEnginePrivate *priv;
@@ -96,27 +95,143 @@ search_engine_start_real (NautilusSearchEngine *engine)
priv->restart = FALSE;
- DEBUG ("Search engine start real");
+ DEBUG ("Search engine start real setup");
g_object_ref (engine);
+}
+
+static void
+search_engine_start_real_tracker (NautilusSearchEngine *engine)
+{
+ NautilusSearchEnginePrivate *priv;
+ priv = nautilus_search_engine_get_instance_private (engine);
+
priv->providers_running++;
nautilus_search_provider_start (NAUTILUS_SEARCH_PROVIDER (priv->tracker));
+}
+
+static void
+search_engine_start_real_recent (NautilusSearchEngine *engine)
+{
+ NautilusSearchEnginePrivate *priv;
+ priv = nautilus_search_engine_get_instance_private (engine);
+
priv->providers_running++;
nautilus_search_provider_start (NAUTILUS_SEARCH_PROVIDER (priv->recent));
+}
+
+static void
+search_engine_start_real_model (NautilusSearchEngine *engine)
+{
+ NautilusSearchEnginePrivate *priv;
+ priv = nautilus_search_engine_get_instance_private (engine);
if (nautilus_search_engine_model_get_model (priv->model))
{
priv->providers_running++;
nautilus_search_provider_start (NAUTILUS_SEARCH_PROVIDER (priv->model));
}
+}
+
+static void
+search_engine_start_real_simple (NautilusSearchEngine *engine)
+{
+ NautilusSearchEnginePrivate *priv;
+ priv = nautilus_search_engine_get_instance_private (engine);
priv->providers_running++;
+
nautilus_search_provider_start (NAUTILUS_SEARCH_PROVIDER (priv->simple));
}
static void
+search_engine_start_real (NautilusSearchEngine *engine,
+ NautilusSearchEngineTarget target_engine)
+{
+ search_engine_start_real_setup (engine);
+
+ switch (target_engine)
+ {
+ case NAUTILUS_SEARCH_ENGINE_TRACKER_ENGINE:
+ {
+ search_engine_start_real_tracker (engine);
+ }
+ break;
+
+ case NAUTILUS_SEARCH_ENGINE_RECENT_ENGINE:
+ {
+ search_engine_start_real_recent (engine);
+ }
+ break;
+
+ case NAUTILUS_SEARCH_ENGINE_MODEL_ENGINE:
+ {
+ search_engine_start_real_model (engine);
+ }
+ break;
+
+ case NAUTILUS_SEARCH_ENGINE_SIMPLE_ENGINE:
+ {
+ search_engine_start_real_simple (engine);
+ }
+ break;
+
+ case NAUTILUS_SEARCH_ENGINE_ALL_ENGINES:
+ default:
+ {
+ search_engine_start_real_tracker (engine);
+ search_engine_start_real_recent (engine);
+ search_engine_start_real_model (engine);
+ search_engine_start_real_simple (engine);
+ }
+ }
+}
+
+void
+nautilus_search_engine_start_by_target (NautilusSearchProvider *provider,
+ NautilusSearchEngineTarget target_engine)
+{
+ NautilusSearchEngine *engine;
+ NautilusSearchEnginePrivate *priv;
+ gint num_finished;
+
+ engine = NAUTILUS_SEARCH_ENGINE (provider);
+ priv = nautilus_search_engine_get_instance_private (engine);
+
+ DEBUG ("Search engine start");
+
+ num_finished = priv->providers_error + priv->providers_finished;
+
+ if (priv->running)
+ {
+ if (num_finished == priv->providers_running &&
+ priv->restart)
+ {
+ search_engine_start_real (engine, target_engine);
+ }
+
+ return;
+ }
+
+ priv->running = TRUE;
+
+ g_object_notify (G_OBJECT (provider), "running");
+
+ if (num_finished < priv->providers_running)
+ {
+ priv->restart = TRUE;
+ }
+ else
+ {
+ search_engine_start_real (engine, target_engine);
+ }
+}
+
+
+
+static void
nautilus_search_engine_start (NautilusSearchProvider *provider)
{
NautilusSearchEngine *engine;
@@ -135,7 +250,7 @@ nautilus_search_engine_start (NautilusSearchProvider *provider)
if (num_finished == priv->providers_running &&
priv->restart)
{
- search_engine_start_real (engine);
+ search_engine_start_real (engine, NAUTILUS_SEARCH_ENGINE_ALL_ENGINES);
}
return;
@@ -151,7 +266,7 @@ nautilus_search_engine_start (NautilusSearchProvider *provider)
}
else
{
- search_engine_start_real (engine);
+ search_engine_start_real (engine, NAUTILUS_SEARCH_ENGINE_ALL_ENGINES);
}
}
diff --git a/src/nautilus-search-engine.h b/src/nautilus-search-engine.h
index 62d767377..33c3644be 100644
--- a/src/nautilus-search-engine.h
+++ b/src/nautilus-search-engine.h
@@ -25,6 +25,7 @@
#include "nautilus-directory.h"
#include "nautilus-search-engine-model.h"
+#include "nautilus-search-provider.h"
G_BEGIN_DECLS
@@ -42,3 +43,6 @@ NautilusSearchEngineModel *
nautilus_search_engine_get_model_provider (NautilusSearchEngine *engine);
G_END_DECLS
+
+void nautilus_search_engine_start_by_target (NautilusSearchProvider *provider,
+ NautilusSearchEngineTarget taregt_engine); \ No newline at end of file
diff --git a/src/nautilus-search-provider.h b/src/nautilus-search-provider.h
index c25d16161..a1ff6f3a1 100644
--- a/src/nautilus-search-provider.h
+++ b/src/nautilus-search-provider.h
@@ -28,6 +28,13 @@ typedef enum {
NAUTILUS_SEARCH_PROVIDER_STATUS_RESTARTING
} NautilusSearchProviderStatus;
+typedef enum {
+ NAUTILUS_SEARCH_ENGINE_ALL_ENGINES,
+ NAUTILUS_SEARCH_ENGINE_TRACKER_ENGINE,
+ NAUTILUS_SEARCH_ENGINE_RECENT_ENGINE,
+ NAUTILUS_SEARCH_ENGINE_MODEL_ENGINE,
+ NAUTILUS_SEARCH_ENGINE_SIMPLE_ENGINE,
+} NautilusSearchEngineTarget;
#define NAUTILUS_TYPE_SEARCH_PROVIDER (nautilus_search_provider_get_type ())