[glade/tintou/more-g-declare: 16/21] gladeui: Use G_DECLARE_DERIVABLE_TYPE for GladeEditor



commit 2694a8fd9afbec8f98377f312a87874205bc13ee
Author: Corentin Noël <corentin noel collabora com>
Date:   Fri Aug 16 17:51:18 2019 +0200

    gladeui: Use G_DECLARE_DERIVABLE_TYPE for GladeEditor

 gladeui/glade-editor.c | 60 +++++++++++++++++++++++++-------------------------
 gladeui/glade-editor.h | 27 +++--------------------
 2 files changed, 33 insertions(+), 54 deletions(-)
---
diff --git a/gladeui/glade-editor.c b/gladeui/glade-editor.c
index 6838a710..d918b724 100644
--- a/gladeui/glade-editor.c
+++ b/gladeui/glade-editor.c
@@ -69,9 +69,7 @@ enum
   N_PROPERTIES
 };
 
-#define GLADE_EDITOR_PRIVATE(object) (((GladeEditor*)object)->priv)
-
-struct _GladeEditorPrivate
+typedef struct _GladeEditorPrivate
 {
 
   GtkWidget *notebook; /* The notebook widget */
@@ -137,7 +135,7 @@ struct _GladeEditorPrivate
   GtkWidget *class_label; /* A label with the current class label. */
 
   gboolean show_class_field; /* Whether or not to show the class field at the top */
-};
+} GladeEditorPrivate;
 
 G_DEFINE_TYPE_WITH_PRIVATE (GladeEditor, glade_editor, GTK_TYPE_BOX);
 
@@ -150,6 +148,7 @@ glade_editor_set_property (GObject      *object,
                            GParamSpec   *pspec)
 {
   GladeEditor *editor = GLADE_EDITOR (object);
+  GladeEditorPrivate *priv = glade_editor_get_instance_private (editor);
 
   switch (prop_id)
     {
@@ -166,7 +165,7 @@ glade_editor_set_property (GObject      *object,
           glade_editor_hide_class_field (editor);
         break;
       case PROP_SHOW_BORDER:
-        gtk_notebook_set_show_border (GTK_NOTEBOOK (editor->priv->notebook),
+        gtk_notebook_set_show_border (GTK_NOTEBOOK (priv->notebook),
                                       g_value_get_boolean (value));
         break;
       default:
@@ -182,6 +181,7 @@ glade_editor_get_property (GObject    *object,
                            GParamSpec *pspec)
 {
   GladeEditor *editor = GLADE_EDITOR (object);
+  GladeEditorPrivate *priv = glade_editor_get_instance_private (editor);
 
   switch (prop_id)
     {
@@ -189,19 +189,19 @@ glade_editor_get_property (GObject    *object,
         g_value_set_boolean (value, FALSE);
         break;
       case PROP_WIDGET:
-        g_value_set_object (value, editor->priv->loaded_widget);
+        g_value_set_object (value, priv->loaded_widget);
         break;
       case PROP_SHOW_CLASS_FIELD:
-        g_value_set_boolean (value, editor->priv->show_class_field);
+        g_value_set_boolean (value, priv->show_class_field);
         break;
       case PROP_CLASS_FIELD:
-        g_value_set_static_string (value, gtk_label_get_label (GTK_LABEL (editor->priv->class_label)));
+        g_value_set_static_string (value, gtk_label_get_label (GTK_LABEL (priv->class_label)));
         break;
       case PROP_SHOW_BORDER:
-        g_value_set_boolean (value, gtk_notebook_get_show_border (GTK_NOTEBOOK (editor->priv->notebook)));
+        g_value_set_boolean (value, gtk_notebook_get_show_border (GTK_NOTEBOOK (priv->notebook)));
         break;
       case PROP_SIGNAL_EDITOR:
-        g_value_set_object (value, editor->priv->signal_editor);
+        g_value_set_object (value, priv->signal_editor);
         break;
       default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -212,8 +212,8 @@ glade_editor_get_property (GObject    *object,
 static void
 glade_editor_dispose (GObject *object)
 {
-  GladeEditorPrivate *priv = GLADE_EDITOR_PRIVATE (object);
   GladeEditor *editor = GLADE_EDITOR (object);
+  GladeEditorPrivate *priv = glade_editor_get_instance_private (editor);
 
   glade_editor_load_widget (editor, NULL);
 
@@ -303,7 +303,7 @@ glade_editor_update_class_warning_cb (GladeWidget *widget,
                                       GParamSpec  *pspec,
                                       GladeEditor *editor)
 {
-  GladeEditorPrivate *priv = GLADE_EDITOR_PRIVATE (editor);
+  GladeEditorPrivate *priv = glade_editor_get_instance_private (editor);
 
   if (glade_widget_support_warning (widget))
     gtk_widget_show (priv->warning);
@@ -317,7 +317,7 @@ glade_editor_update_class_warning_cb (GladeWidget *widget,
 static void
 glade_editor_update_class_field (GladeEditor *editor)
 {
-  GladeEditorPrivate *priv = GLADE_EDITOR_PRIVATE (editor);
+  GladeEditorPrivate *priv = glade_editor_get_instance_private (editor);
 
   if (priv->loaded_widget)
     {
@@ -378,7 +378,7 @@ glade_editor_switch_page (GtkNotebook *notebook,
                           guint        page_num,
                           GladeEditor *editor)
 {
-  GladeEditorPrivate *priv = GLADE_EDITOR_PRIVATE (editor);
+  GladeEditorPrivate *priv = glade_editor_get_instance_private (editor);
 
   gtk_widget_hide (priv->page_widget);
   gtk_widget_hide (priv->page_packing);
@@ -405,11 +405,9 @@ glade_editor_switch_page (GtkNotebook *notebook,
 static void
 glade_editor_init (GladeEditor *editor)
 {
-  GladeEditorPrivate *priv;
+  GladeEditorPrivate *priv = glade_editor_get_instance_private (editor);
   gint                icon_height;
 
-  editor->priv = priv = glade_editor_get_instance_private (editor);
-
   priv->show_class_field = TRUE;
 
   gtk_widget_init_template (GTK_WIDGET (editor));
@@ -425,7 +423,7 @@ glade_editor_get_editable_by_adaptor (GladeEditor        *editor,
                                       GladeWidgetAdaptor *adaptor,
                                       GladeEditorPageType type)
 {
-  GladeEditorPrivate *priv = GLADE_EDITOR_PRIVATE (editor);
+  GladeEditorPrivate *priv = glade_editor_get_instance_private (editor);
   GtkWidget *editable;
   GList *list;
 
@@ -487,7 +485,7 @@ glade_editor_load_editable_in_page (GladeEditor        *editor,
                                     GladeWidgetAdaptor *adaptor,
                                     GladeEditorPageType type)
 {
-  GladeEditorPrivate *priv = GLADE_EDITOR_PRIVATE (editor);
+  GladeEditorPrivate *priv = glade_editor_get_instance_private (editor);
   GtkContainer *container = NULL;
   GtkWidget *scrolled_window, *editable;
   GtkAdjustment *adj;
@@ -546,13 +544,14 @@ static void
 glade_editor_load_widget_class (GladeEditor *editor,
                                 GladeWidgetAdaptor *adaptor)
 {
+  GladeEditorPrivate *priv = glade_editor_get_instance_private (editor);
 
   glade_editor_load_editable_in_page (editor, adaptor, GLADE_PAGE_GENERAL);
   glade_editor_load_editable_in_page (editor, adaptor, GLADE_PAGE_COMMON);
   glade_editor_load_editable_in_page (editor, adaptor, GLADE_PAGE_ATK);
   glade_editor_load_editable_in_page (editor, NULL, GLADE_PAGE_PACKING);
 
-  editor->priv->loaded_adaptor = adaptor;
+  priv->loaded_adaptor = adaptor;
 }
 
 static void
@@ -569,10 +568,12 @@ glade_editor_removed_cb (GladeProject *project,
                          GladeWidget *widget,
                          GladeEditor *editor)
 {
+  GladeEditorPrivate *priv = glade_editor_get_instance_private (editor);
+
   /* Widget we were viewing was removed from project,
    * detatch from editor.
    */
-  if (widget == editor->priv->loaded_widget)
+  if (widget == priv->loaded_widget)
     glade_editor_load_widget (editor, NULL);
 
 }
@@ -621,10 +622,11 @@ glade_editor_load_editable (GladeEditor        *editor,
 static void
 clear_editables (GladeEditor *editor)
 {
+  GladeEditorPrivate *priv = glade_editor_get_instance_private (editor);
   GladeEditable *editable;
   GList *l;
 
-  for (l = editor->priv->editables; l; l = l->next)
+  for (l = priv->editables; l; l = l->next)
     {
       editable = l->data;
       glade_editable_load (editable, NULL);
@@ -634,7 +636,7 @@ clear_editables (GladeEditor *editor)
 static void
 glade_editor_load_widget_real (GladeEditor *editor, GladeWidget *widget)
 {
-  GladeEditorPrivate *priv = GLADE_EDITOR_PRIVATE (editor);
+  GladeEditorPrivate *priv = glade_editor_get_instance_private (editor);
   GladeWidgetAdaptor *adaptor;
   GladeProject *project;
 
@@ -737,10 +739,12 @@ glade_editor_new (void)
 void
 glade_editor_load_widget (GladeEditor *editor, GladeWidget *widget)
 {
+  GladeEditorPrivate *priv = glade_editor_get_instance_private (editor);
+
   g_return_if_fail (GLADE_IS_EDITOR (editor));
   g_return_if_fail (widget == NULL || GLADE_IS_WIDGET (widget));
 
-  if (editor->priv->loaded_widget == widget)
+  if (priv->loaded_widget == widget)
     return;
 
   glade_editor_load_widget_real (editor, widget);
@@ -1264,12 +1268,10 @@ glade_editor_hide_info (GladeEditor *editor)
 void
 glade_editor_show_class_field (GladeEditor *editor)
 {
-  GladeEditorPrivate *priv;
+  GladeEditorPrivate *priv = glade_editor_get_instance_private (editor);
 
   g_return_if_fail (GLADE_IS_EDITOR (editor));
 
-  priv = GLADE_EDITOR_PRIVATE (editor);
-
   if (priv->show_class_field != TRUE)
     {
       priv->show_class_field = TRUE;
@@ -1282,12 +1284,10 @@ glade_editor_show_class_field (GladeEditor *editor)
 void
 glade_editor_hide_class_field (GladeEditor *editor)
 {
-  GladeEditorPrivate *priv;
+  GladeEditorPrivate *priv = glade_editor_get_instance_private (editor);
 
   g_return_if_fail (GLADE_IS_EDITOR (editor));
 
-  priv = GLADE_EDITOR_PRIVATE (editor);
-
   if (priv->show_class_field != FALSE)
     {
       priv->show_class_field = FALSE;
diff --git a/gladeui/glade-editor.h b/gladeui/glade-editor.h
index eb1a6b74..968fc8a3 100644
--- a/gladeui/glade-editor.h
+++ b/gladeui/glade-editor.h
@@ -6,42 +6,21 @@
 
 G_BEGIN_DECLS
 
-
-#define GLADE_TYPE_EDITOR            (glade_editor_get_type ())
-#define GLADE_EDITOR(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GLADE_TYPE_EDITOR, GladeEditor))
-#define GLADE_EDITOR_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GLADE_TYPE_EDITOR, GladeEditorClass))
-#define GLADE_IS_EDITOR(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GLADE_TYPE_EDITOR))
-#define GLADE_IS_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GLADE_TYPE_EDITOR))
-#define GLADE_EDITOR_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GLADE_TYPE_EDITOR, GladeEditorClass))
-
-typedef struct _GladeEditor          GladeEditor;
-typedef struct _GladeEditorClass     GladeEditorClass;
-typedef struct _GladeEditorPrivate   GladeEditorPrivate;
+#define GLADE_TYPE_EDITOR glade_editor_get_type ()
+G_DECLARE_DERIVABLE_TYPE (GladeEditor, glade_editor, GLADE, EDITOR, GtkBox)
 
 /* The GladeEditor is a window that is used to display and modify widget
  * properties. The glade editor contains the details of the selected
  * widget for the selected project
  */
-struct _GladeEditor
-{
-  GtkBox vbox;  /* The editor is a vbox */
-
-  GladeEditorPrivate *priv;
-};
 
 struct _GladeEditorClass
 {
   GtkBoxClass parent_class;
 
-  void   (* glade_reserved1)   (void);
-  void   (* glade_reserved2)   (void);
-  void   (* glade_reserved3)   (void);
-  void   (* glade_reserved4)   (void);
+  gpointer padding[4];
 };
 
-
-GType        glade_editor_get_type           (void);
-
 GladeEditor *glade_editor_new                (void);
 void         glade_editor_load_widget        (GladeEditor       *editor,
                                               GladeWidget       *widget);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]