[file-roller/wip/jtojnar/gobject-modernization: 1/5] window: Use declare type macro
- From: Jan Tojnar <jtojnar src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [file-roller/wip/jtojnar/gobject-modernization: 1/5] window: Use declare type macro
- Date: Fri, 5 Aug 2022 19:10:22 +0000 (UTC)
commit 5c678b7efa74e12deba5a128ef76b8f7fcd274b2
Author: Jan Tojnar <jtojnar gmail com>
Date: Fri Aug 5 20:55:42 2022 +0200
window: Use declare type macro
Let’s make the class final. That will require getting rid of the class properties.
While at it, switch to g_signal_newv.
https://blogs.gnome.org/desrt/2015/01/27/g_declare_finalderivable_type/
src/fr-window.c | 22 ++++++++++++----------
src/fr-window.h | 27 ++-------------------------
2 files changed, 14 insertions(+), 35 deletions(-)
---
diff --git a/src/fr-window.c b/src/fr-window.c
index 6791697a..6d0f6ee5 100644
--- a/src/fr-window.c
+++ b/src/fr-window.c
@@ -841,34 +841,36 @@ fr_window_class_init (FrWindowClass *klass)
fr_window_parent_class = g_type_class_peek_parent (klass);
+ GType archive_loaded_types[] = { G_TYPE_BOOLEAN };
+ GType progress_types[] = { G_TYPE_DOUBLE, G_TYPE_STRING };
+ GType ready_types[] = { G_TYPE_POINTER };
fr_window_signals[ARCHIVE_LOADED] =
- g_signal_new ("archive-loaded",
+ g_signal_newv ("archive-loaded",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (FrWindowClass, archive_loaded),
+ /* class_closure = */ NULL,
NULL, NULL,
fr_marshal_VOID__BOOLEAN,
G_TYPE_NONE, 1,
- G_TYPE_BOOLEAN);
+ archive_loaded_types);
fr_window_signals[PROGRESS] =
- g_signal_new ("progress",
+ g_signal_newv ("progress",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (FrWindowClass, progress),
+ /* class_closure = */ NULL,
NULL, NULL,
fr_marshal_VOID__DOUBLE_STRING,
G_TYPE_NONE, 2,
- G_TYPE_DOUBLE,
- G_TYPE_STRING);
+ progress_types);
fr_window_signals[READY] =
- g_signal_new ("ready",
+ g_signal_newv ("ready",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (FrWindowClass, ready),
+ /* class_closure = */ NULL,
NULL, NULL,
fr_marshal_VOID__POINTER,
G_TYPE_NONE, 1,
- G_TYPE_POINTER);
+ ready_types);
gobject_class = G_OBJECT_CLASS (klass);
gobject_class->finalize = fr_window_finalize;
diff --git a/src/fr-window.h b/src/fr-window.h
index 7bbffec5..fae40619 100644
--- a/src/fr-window.h
+++ b/src/fr-window.h
@@ -70,15 +70,9 @@ typedef enum {
/* -- FrWindow -- */
-#define FR_TYPE_WINDOW (fr_window_get_type ())
-#define FR_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FR_TYPE_WINDOW, FrWindow))
-#define FR_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FR_WINDOW_TYPE, FrWindowClass))
-#define FR_IS_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FR_TYPE_WINDOW))
-#define FR_IS_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FR_TYPE_WINDOW))
-#define FR_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), FR_TYPE_WINDOW, FrWindowClass))
+#define FR_TYPE_WINDOW (fr_window_get_type ())
+G_DECLARE_FINAL_TYPE (FrWindow, fr_window, FR, WINDOW, GtkApplicationWindow)
-typedef struct _FrWindow FrWindow;
-typedef struct _FrWindowClass FrWindowClass;
typedef struct _FrWindowPrivate FrWindowPrivate;
struct _FrWindow
@@ -87,23 +81,6 @@ struct _FrWindow
FrWindowPrivate *priv;
FrArchive *archive;
};
-
-struct _FrWindowClass
-{
- GtkApplicationWindowClass __parent_class;
-
- /*<signals>*/
-
- void (*archive_loaded) (FrWindow *window,
- gboolean success);
- void (*progress) (FrWindow *window,
- double fraction,
- const char *msg);
- void (*ready) (FrWindow *window,
- GError *error);
-};
-
-GType fr_window_get_type (void);
GtkWidget * fr_window_new (void);
void fr_window_close (FrWindow *window);
void fr_window_set_dialog (FrWindow *window,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]