filesystemmodel: Use G_DECLARE_FINAL_TYPE()

Clean up boilerplate. It's a private object anyway.
This commit is contained in:
Georges Basile Stavracas Neto 2023-01-07 09:08:25 -05:00 committed by Matthias Clasen
parent a8690c84ab
commit 202e889577
2 changed files with 13 additions and 33 deletions

View File

@ -38,7 +38,6 @@
#define FILES_PER_QUERY 100
typedef struct _FileModelNode FileModelNode;
typedef struct _GtkFileSystemModelClass GtkFileSystemModelClass;
struct _FileModelNode
{
@ -84,19 +83,6 @@ struct _GtkFileSystemModel
guint filter_folders :1;/* whether filter applies to folders */
};
#define GTK_FILE_SYSTEM_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_FILE_SYSTEM_MODEL, GtkFileSystemModelClass))
#define GTK_IS_FILE_SYSTEM_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_FILE_SYSTEM_MODEL))
#define GTK_FILE_SYSTEM_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_FILE_SYSTEM_MODEL, GtkFileSystemModelClass))
struct _GtkFileSystemModelClass
{
GObjectClass parent_class;
/* Signals */
void (*finished_loading) (GtkFileSystemModel *model, GError *error);
};
static void freeze_updates (GtkFileSystemModel *model);
static void thaw_updates (GtkFileSystemModel *model);
@ -344,7 +330,7 @@ enum {
static guint file_system_model_signals[LAST_SIGNAL] = { 0 };
G_DEFINE_TYPE_WITH_CODE (GtkFileSystemModel, _gtk_file_system_model, G_TYPE_OBJECT,
G_DEFINE_TYPE_WITH_CODE (GtkFileSystemModel, gtk_file_system_model, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (G_TYPE_LIST_MODEL,
g_list_model_iface_init))
@ -508,7 +494,7 @@ gtk_file_system_model_dispose (GObject *object)
if (model->dir_monitor)
g_file_monitor_cancel (model->dir_monitor);
G_OBJECT_CLASS (_gtk_file_system_model_parent_class)->dispose (object);
G_OBJECT_CLASS (gtk_file_system_model_parent_class)->dispose (object);
}
@ -533,11 +519,11 @@ gtk_file_system_model_finalize (GObject *object)
g_clear_pointer (&model->file_lookup, g_hash_table_destroy);
g_clear_object (&model->filter);
G_OBJECT_CLASS (_gtk_file_system_model_parent_class)->finalize (object);
G_OBJECT_CLASS (gtk_file_system_model_parent_class)->finalize (object);
}
static void
_gtk_file_system_model_class_init (GtkFileSystemModelClass *class)
gtk_file_system_model_class_init (GtkFileSystemModelClass *class)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
@ -548,14 +534,13 @@ _gtk_file_system_model_class_init (GtkFileSystemModelClass *class)
g_signal_new (I_("finished-loading"),
G_OBJECT_CLASS_TYPE (gobject_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkFileSystemModelClass, finished_loading),
NULL, NULL,
0, NULL, NULL,
NULL,
G_TYPE_NONE, 1, G_TYPE_ERROR);
}
static void
_gtk_file_system_model_init (GtkFileSystemModel *model)
gtk_file_system_model_init (GtkFileSystemModel *model)
{
model->show_files = TRUE;
model->show_folders = TRUE;
@ -664,9 +649,9 @@ gtk_file_system_model_got_files (GObject *object,
}
static void
_gtk_file_system_model_update_file (GtkFileSystemModel *model,
GFile *file,
GFileInfo *info)
gtk_file_system_model_update_file (GtkFileSystemModel *model,
GFile *file,
GFileInfo *info)
{
FileModelNode *node;
guint id;
@ -704,7 +689,7 @@ query_done_helper (GObject *object,
info = g_file_query_info_finish (file, res, NULL);
if (info)
{
_gtk_file_system_model_update_file (model, file, info);
gtk_file_system_model_update_file (model, file, info);
g_object_unref (info);
}
@ -1021,7 +1006,7 @@ _gtk_file_system_model_update_files (GtkFileSystemModel *model,
freeze_updates (model);
for (l = files, i = infos; l; l = l->next, i = i->next)
_gtk_file_system_model_update_file (model, (GFile *)l->data, (GFileInfo *)i->data);
gtk_file_system_model_update_file (model, (GFile *)l->data, (GFileInfo *)i->data);
thaw_updates (model);
}

View File

@ -24,13 +24,8 @@
G_BEGIN_DECLS
#define GTK_TYPE_FILE_SYSTEM_MODEL (_gtk_file_system_model_get_type ())
#define GTK_FILE_SYSTEM_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FILE_SYSTEM_MODEL, GtkFileSystemModel))
#define GTK_IS_FILE_SYSTEM_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_FILE_SYSTEM_MODEL))
typedef struct _GtkFileSystemModel GtkFileSystemModel;
GType _gtk_file_system_model_get_type (void) G_GNUC_CONST;
#define GTK_TYPE_FILE_SYSTEM_MODEL (gtk_file_system_model_get_type ())
G_DECLARE_FINAL_TYPE (GtkFileSystemModel, gtk_file_system_model, GTK, FILE_SYSTEM_MODEL, GObject)
GtkFileSystemModel *_gtk_file_system_model_new (void);
GtkFileSystemModel *_gtk_file_system_model_new_for_directory(GFile *dir,