diff options
author | Javier Jardón <jjardon@gnome.org> | 2010-08-26 15:57:05 +0200 |
---|---|---|
committer | Javier Jardón <jjardon@gnome.org> | 2010-08-26 15:58:20 +0200 |
commit | 8d983a4547a37d93e88960ea0c64cca67f9bbd29 (patch) | |
tree | 374a87007df8bf335bd2598268c0f63a67f4565b /gtk/gtkfilesystem.c | |
parent | 904769b0049f5e817d1d85ff1df9ea2dd012836e (diff) | |
download | gtk+-8d983a4547a37d93e88960ea0c64cca67f9bbd29.tar.gz |
gtk/gtkfilesystem: Do not use GET_PRIVATE macro all the time
Use a private pointer instead
Diffstat (limited to 'gtk/gtkfilesystem.c')
-rw-r--r-- | gtk/gtkfilesystem.c | 118 |
1 files changed, 41 insertions, 77 deletions
diff --git a/gtk/gtkfilesystem.c b/gtk/gtkfilesystem.c index 93c77b7edc..2442f17d6c 100644 --- a/gtk/gtkfilesystem.c +++ b/gtk/gtkfilesystem.c @@ -38,8 +38,6 @@ #define DEBUG(x) #endif -#define GTK_FILE_SYSTEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_TYPE_FILE_SYSTEM, GtkFileSystemPrivate)) -#define GTK_FOLDER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_TYPE_FOLDER, GtkFolderPrivate)) #define FILES_PER_QUERY 100 /* The pointers we return for a GtkFileSystemVolume are opaque tokens; they are @@ -75,11 +73,9 @@ enum { static guint fs_signals [FS_LAST_SIGNAL] = { 0, }; static guint folder_signals [FOLDER_LAST_SIGNAL] = { 0, }; -typedef struct GtkFileSystemPrivate GtkFileSystemPrivate; -typedef struct GtkFolderPrivate GtkFolderPrivate; typedef struct AsyncFuncData AsyncFuncData; -struct GtkFileSystemPrivate +struct GtkFileSystemPriv { GVolumeMonitor *volume_monitor; @@ -94,7 +90,7 @@ struct GtkFileSystemPrivate GFileMonitor *bookmarks_monitor; }; -struct GtkFolderPrivate +struct GtkFolderPriv { GFile *folder_file; GHashTable *children; @@ -163,12 +159,11 @@ volumes_changed (GVolumeMonitor *volume_monitor, static void gtk_file_system_dispose (GObject *object) { - GtkFileSystemPrivate *priv; + GtkFileSystem *file_system = GTK_FILE_SYSTEM (object); + GtkFileSystemPriv *priv = file_system->priv; DEBUG ("dispose"); - priv = GTK_FILE_SYSTEM_GET_PRIVATE (object); - if (priv->volumes) { g_slist_foreach (priv->volumes, (GFunc) g_object_unref, NULL); @@ -189,12 +184,11 @@ gtk_file_system_dispose (GObject *object) static void gtk_file_system_finalize (GObject *object) { - GtkFileSystemPrivate *priv; + GtkFileSystem *file_system = GTK_FILE_SYSTEM (object); + GtkFileSystemPriv *priv = file_system->priv; DEBUG ("finalize"); - priv = GTK_FILE_SYSTEM_GET_PRIVATE (object); - if (priv->bookmarks_monitor) g_object_unref (priv->bookmarks_monitor); @@ -233,7 +227,7 @@ _gtk_file_system_class_init (GtkFileSystemClass *class) g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); - g_type_class_add_private (object_class, sizeof (GtkFileSystemPrivate)); + g_type_class_add_private (object_class, sizeof (GtkFileSystemPriv)); } static GFile * @@ -335,9 +329,8 @@ bookmarks_file_changed (GFileMonitor *monitor, GFileMonitorEvent event, gpointer data) { - GtkFileSystemPrivate *priv; - - priv = GTK_FILE_SYSTEM_GET_PRIVATE (data); + GtkFileSystem *file_system = GTK_FILE_SYSTEM (data); + GtkFileSystemPriv *priv = file_system->priv; switch (event) { @@ -396,7 +389,7 @@ mount_referenced_by_volume_activation_root (GList *volumes, GMount *mount) static void get_volumes_list (GtkFileSystem *file_system) { - GtkFileSystemPrivate *priv; + GtkFileSystemPriv *priv = file_system->priv; GList *l, *ll; GList *drives; GList *volumes; @@ -405,8 +398,6 @@ get_volumes_list (GtkFileSystem *file_system) GVolume *volume; GMount *mount; - priv = GTK_FILE_SYSTEM_GET_PRIVATE (file_system); - if (priv->volumes) { g_slist_foreach (priv->volumes, (GFunc) g_object_unref, NULL); @@ -539,13 +530,16 @@ get_volumes_list (GtkFileSystem *file_system) static void _gtk_file_system_init (GtkFileSystem *file_system) { - GtkFileSystemPrivate *priv; + GtkFileSystemPriv *priv; GFile *bookmarks_file; GError *error = NULL; DEBUG ("init"); - priv = GTK_FILE_SYSTEM_GET_PRIVATE (file_system); + file_system->priv = G_TYPE_INSTANCE_GET_PRIVATE (file_system, + GTK_TYPE_FILE_SYSTEM, + GtkFileSystemPriv); + priv = file_system->priv; /* Volumes */ priv->volume_monitor = g_volume_monitor_get (); @@ -597,15 +591,12 @@ _gtk_file_system_new (void) GSList * _gtk_file_system_list_volumes (GtkFileSystem *file_system) { - GtkFileSystemPrivate *priv; + GtkFileSystemPriv *priv = file_system->priv; GSList *list; DEBUG ("list_volumes"); - g_return_val_if_fail (GTK_IS_FILE_SYSTEM (file_system), NULL); - - priv = GTK_FILE_SYSTEM_GET_PRIVATE (file_system); - get_volumes_list (GTK_FILE_SYSTEM (file_system)); + get_volumes_list (file_system); list = g_slist_copy (priv->volumes); @@ -620,12 +611,11 @@ _gtk_file_system_list_volumes (GtkFileSystem *file_system) GSList * _gtk_file_system_list_bookmarks (GtkFileSystem *file_system) { - GtkFileSystemPrivate *priv; + GtkFileSystemPriv *priv = file_system->priv; GSList *bookmarks, *files = NULL; DEBUG ("list_bookmarks"); - priv = GTK_FILE_SYSTEM_GET_PRIVATE (file_system); bookmarks = priv->bookmarks; while (bookmarks) @@ -1073,13 +1063,12 @@ _gtk_file_system_insert_bookmark (GtkFileSystem *file_system, gint position, GError **error) { - GtkFileSystemPrivate *priv; + GtkFileSystemPriv *priv = file_system->priv; GSList *bookmarks; GtkFileSystemBookmark *bookmark; gboolean result = TRUE; GFile *bookmarks_file; - priv = GTK_FILE_SYSTEM_GET_PRIVATE (file_system); bookmarks = priv->bookmarks; while (bookmarks) @@ -1129,14 +1118,12 @@ _gtk_file_system_remove_bookmark (GtkFileSystem *file_system, GFile *file, GError **error) { - GtkFileSystemPrivate *priv; + GtkFileSystemPriv *priv = file_system->priv; GtkFileSystemBookmark *bookmark; GSList *bookmarks; gboolean result = FALSE; GFile *bookmarks_file; - priv = GTK_FILE_SYSTEM_GET_PRIVATE (file_system); - if (!priv->bookmarks) return FALSE; @@ -1186,13 +1173,12 @@ gchar * _gtk_file_system_get_bookmark_label (GtkFileSystem *file_system, GFile *file) { - GtkFileSystemPrivate *priv; + GtkFileSystemPriv *priv = file_system->priv; GSList *bookmarks; gchar *label = NULL; DEBUG ("get_bookmark_label"); - priv = GTK_FILE_SYSTEM_GET_PRIVATE (file_system); bookmarks = priv->bookmarks; while (bookmarks) @@ -1217,14 +1203,13 @@ _gtk_file_system_set_bookmark_label (GtkFileSystem *file_system, GFile *file, const gchar *label) { - GtkFileSystemPrivate *priv; + GtkFileSystemPriv *priv = file_system->priv; gboolean changed = FALSE; GFile *bookmarks_file; GSList *bookmarks; DEBUG ("set_bookmark_label"); - priv = GTK_FILE_SYSTEM_GET_PRIVATE (file_system); bookmarks = priv->bookmarks; while (bookmarks) @@ -1255,12 +1240,10 @@ GtkFileSystemVolume * _gtk_file_system_get_volume_for_file (GtkFileSystem *file_system, GFile *file) { - GtkFileSystemPrivate *priv; GMount *mount; DEBUG ("get_volume_for_file"); - priv = GTK_FILE_SYSTEM_GET_PRIVATE (file_system); mount = g_file_find_enclosing_mount (file, NULL, NULL); if (!mount && g_file_is_native (file)) @@ -1276,9 +1259,8 @@ gtk_folder_set_property (GObject *object, const GValue *value, GParamSpec *pspec) { - GtkFolderPrivate *priv; - - priv = GTK_FOLDER_GET_PRIVATE (object); + GtkFolder *folder = GTK_FOLDER (object); + GtkFolderPriv *priv = folder->priv; switch (prop_id) { @@ -1303,9 +1285,8 @@ gtk_folder_get_property (GObject *object, GValue *value, GParamSpec *pspec) { - GtkFolderPrivate *priv; - - priv = GTK_FOLDER_GET_PRIVATE (object); + GtkFolder *folder = GTK_FOLDER (object); + GtkFolderPriv *priv = folder->priv; switch (prop_id) { @@ -1360,12 +1341,10 @@ directory_monitor_changed (GFileMonitor *monitor, GFileMonitorEvent event, gpointer data) { - GtkFolderPrivate *priv; - GtkFolder *folder; + GtkFolder *folder = GTK_FOLDER (data); + GtkFolderPriv *priv = folder->priv; GSList *files; - folder = GTK_FOLDER (data); - priv = GTK_FOLDER_GET_PRIVATE (folder); files = g_slist_prepend (NULL, file); gdk_threads_enter (); @@ -1401,9 +1380,9 @@ enumerator_files_callback (GObject *source_object, GAsyncResult *result, gpointer user_data) { + GtkFolder *folder = GTK_FOLDER (user_data); + GtkFolderPriv *priv = folder->priv; GFileEnumerator *enumerator; - GtkFolderPrivate *priv; - GtkFolder *folder; GError *error = NULL; GSList *files = NULL; GList *file_infos, *f; @@ -1420,9 +1399,6 @@ enumerator_files_callback (GObject *source_object, return; } - folder = GTK_FOLDER (user_data); - priv = GTK_FOLDER_GET_PRIVATE (folder); - if (!file_infos) { g_file_enumerator_close_async (enumerator, @@ -1464,10 +1440,10 @@ enumerator_files_callback (GObject *source_object, static void gtk_folder_constructed (GObject *object) { - GtkFolderPrivate *priv; + GtkFolder *folder = GTK_FOLDER (object); + GtkFolderPriv *priv = folder->priv; GError *error = NULL; - priv = GTK_FOLDER_GET_PRIVATE (object); priv->directory_monitor = g_file_monitor_directory (priv->folder_file, G_FILE_MONITOR_NONE, NULL, &error); if (error) @@ -1493,9 +1469,8 @@ gtk_folder_constructed (GObject *object) static void gtk_folder_finalize (GObject *object) { - GtkFolderPrivate *priv; - - priv = GTK_FOLDER_GET_PRIVATE (object); + GtkFolder *folder = GTK_FOLDER (object); + GtkFolderPriv *priv = folder->priv; g_hash_table_unref (priv->children); @@ -1584,15 +1559,13 @@ _gtk_folder_class_init (GtkFolderClass *class) g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); - g_type_class_add_private (object_class, sizeof (GtkFolderPrivate)); + g_type_class_add_private (object_class, sizeof (GtkFolderPriv)); } static void _gtk_folder_init (GtkFolder *folder) { - GtkFolderPrivate *priv; - - priv = GTK_FOLDER_GET_PRIVATE (folder); + GtkFolderPriv *priv = folder->priv; priv->children = g_hash_table_new_full (g_file_hash, (GEqualFunc) g_file_equal, @@ -1605,9 +1578,8 @@ static void gtk_folder_set_finished_loading (GtkFolder *folder, gboolean finished_loading) { - GtkFolderPrivate *priv; + GtkFolderPriv *priv = folder->priv; - priv = GTK_FOLDER_GET_PRIVATE (folder); priv->finished_loading = (finished_loading == TRUE); gdk_threads_enter (); @@ -1620,9 +1592,7 @@ gtk_folder_add_file (GtkFolder *folder, GFile *file, GFileInfo *info) { - GtkFolderPrivate *priv; - - priv = GTK_FOLDER_GET_PRIVATE (folder); + GtkFolderPriv *priv = folder->priv; g_hash_table_insert (priv->children, g_object_ref (file), @@ -1632,11 +1602,10 @@ gtk_folder_add_file (GtkFolder *folder, GSList * _gtk_folder_list_children (GtkFolder *folder) { - GtkFolderPrivate *priv; + GtkFolderPriv *priv = folder->priv; GList *files, *elem; GSList *children = NULL; - priv = GTK_FOLDER_GET_PRIVATE (folder); files = g_hash_table_get_keys (priv->children); children = NULL; @@ -1652,10 +1621,9 @@ GFileInfo * _gtk_folder_get_info (GtkFolder *folder, GFile *file) { - GtkFolderPrivate *priv; + GtkFolderPriv *priv = folder->priv; GFileInfo *info; - priv = GTK_FOLDER_GET_PRIVATE (folder); info = g_hash_table_lookup (priv->children, file); if (!info) @@ -1667,11 +1635,7 @@ _gtk_folder_get_info (GtkFolder *folder, gboolean _gtk_folder_is_finished_loading (GtkFolder *folder) { - GtkFolderPrivate *priv; - - priv = GTK_FOLDER_GET_PRIVATE (folder); - - return priv->finished_loading; + return folder->priv->finished_loading; } /* GtkFileSystemVolume public methods */ |