diff options
author | Vyas Giridharan <vyasgiridhar27@gmail.com> | 2017-08-22 20:56:10 +0530 |
---|---|---|
committer | Ernestas Kulik <ernestask@gnome.org> | 2017-08-23 09:32:20 +0300 |
commit | 588230863776fdb4eeff14217d707f6510cb1552 (patch) | |
tree | c9cb0cd1af6c003ea55a77a5ff8f8bdaaf30932b | |
parent | ccb8ed44b9186e0fcded42d5b884408fc5eb4ea0 (diff) | |
download | nautilus-588230863776fdb4eeff14217d707f6510cb1552.tar.gz |
search-engine-model: ported declaration to G_DECLARE*
This patch ports declaration of NautilusSearchEngineModel to
the G_DECLARE* format.
https://bugzilla.gnome.org/show_bug.cgi?id=771777
-rw-r--r-- | src/nautilus-search-engine-model.c | 75 | ||||
-rw-r--r-- | src/nautilus-search-engine-model.h | 21 |
2 files changed, 39 insertions, 57 deletions
diff --git a/src/nautilus-search-engine-model.c b/src/nautilus-search-engine-model.c index b8f2a940f..b00f3f7c5 100644 --- a/src/nautilus-search-engine-model.c +++ b/src/nautilus-search-engine-model.c @@ -34,8 +34,10 @@ #include <glib.h> #include <gio/gio.h> -struct NautilusSearchEngineModelDetails +struct _NautilusSearchEngineModel { + GObject parent; + NautilusQuery *query; GList *hits; @@ -67,20 +69,20 @@ finalize (GObject *object) model = NAUTILUS_SEARCH_ENGINE_MODEL (object); - if (model->details->hits != NULL) + if (model->hits != NULL) { - g_list_free_full (model->details->hits, g_object_unref); - model->details->hits = NULL; + g_list_free_full (model->hits, g_object_unref); + model->hits = NULL; } - if (model->details->finished_id != 0) + if (model->finished_id != 0) { - g_source_remove (model->details->finished_id); - model->details->finished_id = 0; + g_source_remove (model->finished_id); + model->finished_id = 0; } - g_clear_object (&model->details->directory); - g_clear_object (&model->details->query); + g_clear_object (&model->directory); + g_clear_object (&model->query); G_OBJECT_CLASS (nautilus_search_engine_model_parent_class)->finalize (object); } @@ -88,18 +90,18 @@ finalize (GObject *object) static gboolean search_finished (NautilusSearchEngineModel *model) { - model->details->finished_id = 0; + model->finished_id = 0; - if (model->details->hits != NULL) + if (model->hits != NULL) { DEBUG ("Model engine hits added"); nautilus_search_provider_hits_added (NAUTILUS_SEARCH_PROVIDER (model), - model->details->hits); - g_list_free_full (model->details->hits, g_object_unref); - model->details->hits = NULL; + model->hits); + g_list_free_full (model->hits, g_object_unref); + model->hits = NULL; } - model->details->query_pending = FALSE; + model->query_pending = FALSE; g_object_notify (G_OBJECT (model), "running"); @@ -114,12 +116,12 @@ search_finished (NautilusSearchEngineModel *model) static void search_finished_idle (NautilusSearchEngineModel *model) { - if (model->details->finished_id != 0) + if (model->finished_id != 0) { return; } - model->details->finished_id = g_idle_add ((GSourceFunc) search_finished, model); + model->finished_id = g_idle_add ((GSourceFunc) search_finished, model); } static void @@ -139,7 +141,7 @@ model_directory_ready_cb (NautilusDirectory *directory, GPtrArray *date_range; files = nautilus_directory_get_file_list (directory); - mime_types = nautilus_query_get_mime_types (model->details->query); + mime_types = nautilus_query_get_mime_types (model->query); hits = NULL; for (l = files; l != NULL; l = l->next) @@ -147,7 +149,7 @@ model_directory_ready_cb (NautilusDirectory *directory, file = l->data; display_name = nautilus_file_get_display_name (file); - match = nautilus_query_matches_string (model->details->query, display_name); + match = nautilus_query_matches_string (model->query, display_name); found = (match > -1); if (found && mime_types) @@ -164,13 +166,13 @@ model_directory_ready_cb (NautilusDirectory *directory, } } - date_range = nautilus_query_get_date_range (model->details->query); + date_range = nautilus_query_get_date_range (model->query); if (found && date_range != NULL) { NautilusQuerySearchType type; guint64 current_file_unix_time; - type = nautilus_query_get_search_type (model->details->query); + type = nautilus_query_get_search_type (model->query); initial_date = g_ptr_array_index (date_range, 0); end_date = g_ptr_array_index (date_range, 1); @@ -203,7 +205,7 @@ model_directory_ready_cb (NautilusDirectory *directory, g_list_free_full (mime_types, g_free); nautilus_file_list_free (files); - model->details->hits = hits; + model->hits = hits; search_finished (model); } @@ -215,7 +217,7 @@ nautilus_search_engine_model_start (NautilusSearchProvider *provider) model = NAUTILUS_SEARCH_ENGINE_MODEL (provider); - if (model->details->query_pending) + if (model->query_pending) { return; } @@ -223,17 +225,17 @@ nautilus_search_engine_model_start (NautilusSearchProvider *provider) DEBUG ("Model engine start"); g_object_ref (model); - model->details->query_pending = TRUE; + model->query_pending = TRUE; g_object_notify (G_OBJECT (provider), "running"); - if (model->details->directory == NULL) + if (model->directory == NULL) { search_finished_idle (model); return; } - nautilus_directory_call_when_ready (model->details->directory, + nautilus_directory_call_when_ready (model->directory, NAUTILUS_FILE_ATTRIBUTE_INFO, TRUE, model_directory_ready_cb, model); } @@ -245,16 +247,16 @@ nautilus_search_engine_model_stop (NautilusSearchProvider *provider) model = NAUTILUS_SEARCH_ENGINE_MODEL (provider); - if (model->details->query_pending) + if (model->query_pending) { DEBUG ("Model engine stop"); - nautilus_directory_cancel_callback (model->details->directory, + nautilus_directory_cancel_callback (model->directory, model_directory_ready_cb, model); search_finished_idle (model); } - g_clear_object (&model->details->directory); + g_clear_object (&model->directory); } static void @@ -266,8 +268,8 @@ nautilus_search_engine_model_set_query (NautilusSearchProvider *provider, model = NAUTILUS_SEARCH_ENGINE_MODEL (provider); g_object_ref (query); - g_clear_object (&model->details->query); - model->details->query = query; + g_clear_object (&model->query); + model->query = query; } static gboolean @@ -277,7 +279,7 @@ nautilus_search_engine_model_is_running (NautilusSearchProvider *provider) model = NAUTILUS_SEARCH_ENGINE_MODEL (provider); - return model->details->query_pending; + return model->query_pending; } static void @@ -326,14 +328,11 @@ nautilus_search_engine_model_class_init (NautilusSearchEngineModelClass *class) */ g_object_class_override_property (gobject_class, PROP_RUNNING, "running"); - g_type_class_add_private (class, sizeof (NautilusSearchEngineModelDetails)); } static void nautilus_search_engine_model_init (NautilusSearchEngineModel *engine) { - engine->details = G_TYPE_INSTANCE_GET_PRIVATE (engine, NAUTILUS_TYPE_SEARCH_ENGINE_MODEL, - NautilusSearchEngineModelDetails); } NautilusSearchEngineModel * @@ -350,12 +349,12 @@ void nautilus_search_engine_model_set_model (NautilusSearchEngineModel *model, NautilusDirectory *directory) { - g_clear_object (&model->details->directory); - model->details->directory = nautilus_directory_ref (directory); + g_clear_object (&model->directory); + model->directory = nautilus_directory_ref (directory); } NautilusDirectory * nautilus_search_engine_model_get_model (NautilusSearchEngineModel *model) { - return model->details->directory; + return model->directory; } diff --git a/src/nautilus-search-engine-model.h b/src/nautilus-search-engine-model.h index 16f3388fc..3c98edf21 100644 --- a/src/nautilus-search-engine-model.h +++ b/src/nautilus-search-engine-model.h @@ -24,25 +24,8 @@ #include "nautilus-directory.h" -#define NAUTILUS_TYPE_SEARCH_ENGINE_MODEL (nautilus_search_engine_model_get_type ()) -#define NAUTILUS_SEARCH_ENGINE_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NAUTILUS_TYPE_SEARCH_ENGINE_MODEL, NautilusSearchEngineModel)) -#define NAUTILUS_SEARCH_ENGINE_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_SEARCH_ENGINE_MODEL, NautilusSearchEngineModelClass)) -#define NAUTILUS_IS_SEARCH_ENGINE_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NAUTILUS_TYPE_SEARCH_ENGINE_MODEL)) -#define NAUTILUS_IS_SEARCH_ENGINE_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_SEARCH_ENGINE_MODEL)) -#define NAUTILUS_SEARCH_ENGINE_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NAUTILUS_TYPE_SEARCH_ENGINE_MODEL, NautilusSearchEngineModelClass)) - -typedef struct NautilusSearchEngineModelDetails NautilusSearchEngineModelDetails; - -typedef struct NautilusSearchEngineModel { - GObject parent; - NautilusSearchEngineModelDetails *details; -} NautilusSearchEngineModel; - -typedef struct { - GObjectClass parent_class; -} NautilusSearchEngineModelClass; - -GType nautilus_search_engine_model_get_type (void); +#define NAUTILUS_TYPE_SEARCH_ENGINE_MODEL (nautilus_search_engine_model_get_type ()) +G_DECLARE_FINAL_TYPE (NautilusSearchEngineModel, nautilus_search_engine_model, NAUTILUS, SEARCH_ENGINE_MODEL, GObject) NautilusSearchEngineModel* nautilus_search_engine_model_new (void); void nautilus_search_engine_model_set_model (NautilusSearchEngineModel *model, |