hotplug-sniffer: Modernize GObject usage

This commit is contained in:
Florian Müllner 2015-09-24 18:47:03 +02:00
parent a539e6236a
commit ede81017ec
2 changed files with 15 additions and 31 deletions

View File

@ -43,8 +43,6 @@
#define DIRECTORY_LOAD_ITEMS_PER_CALLBACK 100 #define DIRECTORY_LOAD_ITEMS_PER_CALLBACK 100
#define HIGH_SCORE_RATIO 0.10 #define HIGH_SCORE_RATIO 0.10
G_DEFINE_TYPE (ShellMimeSniffer, shell_mime_sniffer, G_TYPE_OBJECT);
enum { enum {
PROP_FILE = 1, PROP_FILE = 1,
NUM_PROPERTIES NUM_PROPERTIES
@ -72,6 +70,15 @@ typedef struct {
gint total_items; gint total_items;
} DeepCountState; } DeepCountState;
typedef struct _ShellMimeSnifferPrivate ShellMimeSnifferPrivate;
struct _ShellMimeSniffer
{
GObject parent_instance;
ShellMimeSnifferPrivate *priv;
};
struct _ShellMimeSnifferPrivate { struct _ShellMimeSnifferPrivate {
GFile *file; GFile *file;
@ -82,6 +89,8 @@ struct _ShellMimeSnifferPrivate {
gchar **sniffed_mime; gchar **sniffed_mime;
}; };
G_DEFINE_TYPE_WITH_PRIVATE (ShellMimeSniffer, shell_mime_sniffer, G_TYPE_OBJECT);
static void deep_count_load (DeepCountState *state, static void deep_count_load (DeepCountState *state,
GFile *file); GFile *file);
@ -550,17 +559,13 @@ shell_mime_sniffer_class_init (ShellMimeSnifferClass *klass)
G_TYPE_FILE, G_TYPE_FILE,
G_PARAM_READWRITE); G_PARAM_READWRITE);
g_type_class_add_private (klass, sizeof (ShellMimeSnifferPrivate));
g_object_class_install_properties (oclass, NUM_PROPERTIES, properties); g_object_class_install_properties (oclass, NUM_PROPERTIES, properties);
} }
static void static void
shell_mime_sniffer_init (ShellMimeSniffer *self) shell_mime_sniffer_init (ShellMimeSniffer *self)
{ {
self->priv = self->priv = shell_mime_sniffer_get_instance_private (self);
G_TYPE_INSTANCE_GET_PRIVATE (self,
SHELL_TYPE_MIME_SNIFFER,
ShellMimeSnifferPrivate);
init_mimetypes (); init_mimetypes ();
} }

View File

@ -27,30 +27,9 @@
G_BEGIN_DECLS G_BEGIN_DECLS
#define SHELL_TYPE_MIME_SNIFFER (shell_mime_sniffer_get_type ()) #define SHELL_TYPE_MIME_SNIFFER (shell_mime_sniffer_get_type ())
#define SHELL_MIME_SNIFFER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SHELL_TYPE_MIME_SNIFFER, ShellMimeSniffer)) G_DECLARE_FINAL_TYPE (ShellMimeSniffer, shell_mime_sniffer,
#define SHELL_IS_MIME_SNIFFER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SHELL_TYPE_MIME_SNIFFER)) SHELL, MIME_SNIFFER, GObject)
#define SHELL_MIME_SNIFFER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SHELL_TYPE_MIME_SNIFFER, ShellMimeSnifferClass))
#define SHELL_IS_MIME_SNIFFER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SHELL_TYPE_MIME_SNIFFER))
#define SHELL_MIME_SNIFFER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SHELL_TYPE_MIME_SNIFFER, ShellMimeSnifferClass))
typedef struct _ShellMimeSniffer ShellMimeSniffer;
typedef struct _ShellMimeSnifferPrivate ShellMimeSnifferPrivate;
typedef struct _ShellMimeSnifferClass ShellMimeSnifferClass;
struct _ShellMimeSniffer
{
GObject parent_instance;
ShellMimeSnifferPrivate *priv;
};
struct _ShellMimeSnifferClass
{
GObjectClass parent_class;
};
GType shell_mime_sniffer_get_type (void) G_GNUC_CONST;
ShellMimeSniffer *shell_mime_sniffer_new (GFile *file); ShellMimeSniffer *shell_mime_sniffer_new (GFile *file);